Node-Red configuration
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

server-renderer.esm-bundler.js 32KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131
  1. /**
  2. * @vue/server-renderer v3.4.38
  3. * (c) 2018-present Yuxi (Evan) You and Vue contributors
  4. * @license MIT
  5. **/
  6. import { createVNode, ssrUtils, ssrContextKey, warn as warn$2, Fragment, Static, Comment, Text, mergeProps, createApp, initDirectivesForSSR } from 'vue';
  7. import { isOn, isRenderableAttrValue, isSVGTag, propsToAttrMap, isBooleanAttr, includeBooleanAttr, isSSRSafeAttrName, escapeHtml, normalizeClass, isString, normalizeStyle, stringifyStyle, makeMap, isArray, toDisplayString, extend, isFunction, getGlobalThis, NOOP, isObject, looseEqual, looseIndexOf, isPromise, escapeHtmlComment, isVoidTag } from '@vue/shared';
  8. export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
  9. const shouldIgnoreProp = /* @__PURE__ */ makeMap(
  10. `,key,ref,innerHTML,textContent,ref_key,ref_for`
  11. );
  12. function ssrRenderAttrs(props, tag) {
  13. let ret = "";
  14. for (const key in props) {
  15. if (shouldIgnoreProp(key) || isOn(key) || tag === "textarea" && key === "value") {
  16. continue;
  17. }
  18. const value = props[key];
  19. if (key === "class") {
  20. ret += ` class="${ssrRenderClass(value)}"`;
  21. } else if (key === "style") {
  22. ret += ` style="${ssrRenderStyle(value)}"`;
  23. } else {
  24. ret += ssrRenderDynamicAttr(key, value, tag);
  25. }
  26. }
  27. return ret;
  28. }
  29. function ssrRenderDynamicAttr(key, value, tag) {
  30. if (!isRenderableAttrValue(value)) {
  31. return ``;
  32. }
  33. const attrKey = tag && (tag.indexOf("-") > 0 || isSVGTag(tag)) ? key : propsToAttrMap[key] || key.toLowerCase();
  34. if (isBooleanAttr(attrKey)) {
  35. return includeBooleanAttr(value) ? ` ${attrKey}` : ``;
  36. } else if (isSSRSafeAttrName(attrKey)) {
  37. return value === "" ? ` ${attrKey}` : ` ${attrKey}="${escapeHtml(value)}"`;
  38. } else {
  39. console.warn(
  40. `[@vue/server-renderer] Skipped rendering unsafe attribute name: ${attrKey}`
  41. );
  42. return ``;
  43. }
  44. }
  45. function ssrRenderAttr(key, value) {
  46. if (!isRenderableAttrValue(value)) {
  47. return ``;
  48. }
  49. return ` ${key}="${escapeHtml(value)}"`;
  50. }
  51. function ssrRenderClass(raw) {
  52. return escapeHtml(normalizeClass(raw));
  53. }
  54. function ssrRenderStyle(raw) {
  55. if (!raw) {
  56. return "";
  57. }
  58. if (isString(raw)) {
  59. return escapeHtml(raw);
  60. }
  61. const styles = normalizeStyle(raw);
  62. return escapeHtml(stringifyStyle(styles));
  63. }
  64. function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
  65. return renderComponentVNode(
  66. createVNode(comp, props, children),
  67. parentComponent,
  68. slotScopeId
  69. );
  70. }
  71. const { ensureValidVNode } = ssrUtils;
  72. function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
  73. push(`<!--[-->`);
  74. ssrRenderSlotInner(
  75. slots,
  76. slotName,
  77. slotProps,
  78. fallbackRenderFn,
  79. push,
  80. parentComponent,
  81. slotScopeId
  82. );
  83. push(`<!--]-->`);
  84. }
  85. function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
  86. const slotFn = slots[slotName];
  87. if (slotFn) {
  88. const slotBuffer = [];
  89. const bufferedPush = (item) => {
  90. slotBuffer.push(item);
  91. };
  92. const ret = slotFn(
  93. slotProps,
  94. bufferedPush,
  95. parentComponent,
  96. slotScopeId ? " " + slotScopeId : ""
  97. );
  98. if (isArray(ret)) {
  99. const validSlotContent = ensureValidVNode(ret);
  100. if (validSlotContent) {
  101. renderVNodeChildren(
  102. push,
  103. validSlotContent,
  104. parentComponent,
  105. slotScopeId
  106. );
  107. } else if (fallbackRenderFn) {
  108. fallbackRenderFn();
  109. }
  110. } else {
  111. let isEmptySlot = true;
  112. if (transition) {
  113. isEmptySlot = false;
  114. } else {
  115. for (let i = 0; i < slotBuffer.length; i++) {
  116. if (!isComment(slotBuffer[i])) {
  117. isEmptySlot = false;
  118. break;
  119. }
  120. }
  121. }
  122. if (isEmptySlot) {
  123. if (fallbackRenderFn) {
  124. fallbackRenderFn();
  125. }
  126. } else {
  127. let start = 0;
  128. let end = slotBuffer.length;
  129. if (transition && slotBuffer[0] === "<!--[-->" && slotBuffer[end - 1] === "<!--]-->") {
  130. start++;
  131. end--;
  132. }
  133. for (let i = start; i < end; i++) {
  134. push(slotBuffer[i]);
  135. }
  136. }
  137. }
  138. } else if (fallbackRenderFn) {
  139. fallbackRenderFn();
  140. }
  141. }
  142. const commentTestRE = /^<!--[\s\S]*-->$/;
  143. const commentRE = /<!--[^]*?-->/gm;
  144. function isComment(item) {
  145. if (typeof item !== "string" || !commentTestRE.test(item)) return false;
  146. if (item.length <= 8) return true;
  147. return !item.replace(commentRE, "").trim();
  148. }
  149. function ssrRenderTeleport(parentPush, contentRenderFn, target, disabled, parentComponent) {
  150. parentPush("<!--teleport start-->");
  151. const context = parentComponent.appContext.provides[ssrContextKey];
  152. const teleportBuffers = context.__teleportBuffers || (context.__teleportBuffers = {});
  153. const targetBuffer = teleportBuffers[target] || (teleportBuffers[target] = []);
  154. const bufferIndex = targetBuffer.length;
  155. let teleportContent;
  156. if (disabled) {
  157. contentRenderFn(parentPush);
  158. teleportContent = `<!--teleport start anchor--><!--teleport anchor-->`;
  159. } else {
  160. const { getBuffer, push } = createBuffer();
  161. push(`<!--teleport start anchor-->`);
  162. contentRenderFn(push);
  163. push(`<!--teleport anchor-->`);
  164. teleportContent = getBuffer();
  165. }
  166. targetBuffer.splice(bufferIndex, 0, teleportContent);
  167. parentPush("<!--teleport end-->");
  168. }
  169. function ssrInterpolate(value) {
  170. return escapeHtml(toDisplayString(value));
  171. }
  172. let activeEffect;
  173. let shouldTrack = true;
  174. const trackStack = [];
  175. function pauseTracking() {
  176. trackStack.push(shouldTrack);
  177. shouldTrack = false;
  178. }
  179. function resetTracking() {
  180. const last = trackStack.pop();
  181. shouldTrack = last === void 0 ? true : last;
  182. }
  183. function trackEffect(effect2, dep, debuggerEventExtraInfo) {
  184. var _a;
  185. if (dep.get(effect2) !== effect2._trackId) {
  186. dep.set(effect2, effect2._trackId);
  187. const oldDep = effect2.deps[effect2._depsLength];
  188. if (oldDep !== dep) {
  189. effect2.deps[effect2._depsLength++] = dep;
  190. } else {
  191. effect2._depsLength++;
  192. }
  193. if (!!(process.env.NODE_ENV !== "production")) {
  194. (_a = effect2.onTrack) == null ? void 0 : _a.call(effect2, extend({ effect: effect2 }, debuggerEventExtraInfo));
  195. }
  196. }
  197. }
  198. const createDep = (cleanup, computed) => {
  199. const dep = /* @__PURE__ */ new Map();
  200. dep.cleanup = cleanup;
  201. dep.computed = computed;
  202. return dep;
  203. };
  204. const targetMap = /* @__PURE__ */ new WeakMap();
  205. Symbol(!!(process.env.NODE_ENV !== "production") ? "iterate" : "");
  206. Symbol(!!(process.env.NODE_ENV !== "production") ? "Map key iterate" : "");
  207. function track(target, type, key) {
  208. if (shouldTrack && activeEffect) {
  209. let depsMap = targetMap.get(target);
  210. if (!depsMap) {
  211. targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
  212. }
  213. let dep = depsMap.get(key);
  214. if (!dep) {
  215. depsMap.set(key, dep = createDep(() => depsMap.delete(key)));
  216. }
  217. trackEffect(
  218. activeEffect,
  219. dep,
  220. !!(process.env.NODE_ENV !== "production") ? {
  221. target,
  222. type,
  223. key
  224. } : void 0
  225. );
  226. }
  227. }
  228. function toRaw(observed) {
  229. const raw = observed && observed["__v_raw"];
  230. return raw ? toRaw(raw) : observed;
  231. }
  232. function isRef(r) {
  233. return !!(r && r.__v_isRef === true);
  234. }
  235. const stack = [];
  236. function pushWarningContext(vnode) {
  237. stack.push(vnode);
  238. }
  239. function popWarningContext() {
  240. stack.pop();
  241. }
  242. let isWarning = false;
  243. function warn$1(msg, ...args) {
  244. if (isWarning) return;
  245. isWarning = true;
  246. pauseTracking();
  247. const instance = stack.length ? stack[stack.length - 1].component : null;
  248. const appWarnHandler = instance && instance.appContext.config.warnHandler;
  249. const trace = getComponentTrace();
  250. if (appWarnHandler) {
  251. callWithErrorHandling(
  252. appWarnHandler,
  253. instance,
  254. 11,
  255. [
  256. // eslint-disable-next-line no-restricted-syntax
  257. msg + args.map((a) => {
  258. var _a, _b;
  259. return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
  260. }).join(""),
  261. instance && instance.proxy,
  262. trace.map(
  263. ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
  264. ).join("\n"),
  265. trace
  266. ]
  267. );
  268. } else {
  269. const warnArgs = [`[Vue warn]: ${msg}`, ...args];
  270. if (trace.length && // avoid spamming console during tests
  271. true) {
  272. warnArgs.push(`
  273. `, ...formatTrace(trace));
  274. }
  275. console.warn(...warnArgs);
  276. }
  277. resetTracking();
  278. isWarning = false;
  279. }
  280. function getComponentTrace() {
  281. let currentVNode = stack[stack.length - 1];
  282. if (!currentVNode) {
  283. return [];
  284. }
  285. const normalizedStack = [];
  286. while (currentVNode) {
  287. const last = normalizedStack[0];
  288. if (last && last.vnode === currentVNode) {
  289. last.recurseCount++;
  290. } else {
  291. normalizedStack.push({
  292. vnode: currentVNode,
  293. recurseCount: 0
  294. });
  295. }
  296. const parentInstance = currentVNode.component && currentVNode.component.parent;
  297. currentVNode = parentInstance && parentInstance.vnode;
  298. }
  299. return normalizedStack;
  300. }
  301. function formatTrace(trace) {
  302. const logs = [];
  303. trace.forEach((entry, i) => {
  304. logs.push(...i === 0 ? [] : [`
  305. `], ...formatTraceEntry(entry));
  306. });
  307. return logs;
  308. }
  309. function formatTraceEntry({ vnode, recurseCount }) {
  310. const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
  311. const isRoot = vnode.component ? vnode.component.parent == null : false;
  312. const open = ` at <${formatComponentName(
  313. vnode.component,
  314. vnode.type,
  315. isRoot
  316. )}`;
  317. const close = `>` + postfix;
  318. return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
  319. }
  320. function formatProps(props) {
  321. const res = [];
  322. const keys = Object.keys(props);
  323. keys.slice(0, 3).forEach((key) => {
  324. res.push(...formatProp(key, props[key]));
  325. });
  326. if (keys.length > 3) {
  327. res.push(` ...`);
  328. }
  329. return res;
  330. }
  331. function formatProp(key, value, raw) {
  332. if (isString(value)) {
  333. value = JSON.stringify(value);
  334. return raw ? value : [`${key}=${value}`];
  335. } else if (typeof value === "number" || typeof value === "boolean" || value == null) {
  336. return raw ? value : [`${key}=${value}`];
  337. } else if (isRef(value)) {
  338. value = formatProp(key, toRaw(value.value), true);
  339. return raw ? value : [`${key}=Ref<`, value, `>`];
  340. } else if (isFunction(value)) {
  341. return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
  342. } else {
  343. value = toRaw(value);
  344. return raw ? value : [`${key}=`, value];
  345. }
  346. }
  347. const ErrorTypeStrings = {
  348. ["sp"]: "serverPrefetch hook",
  349. ["bc"]: "beforeCreate hook",
  350. ["c"]: "created hook",
  351. ["bm"]: "beforeMount hook",
  352. ["m"]: "mounted hook",
  353. ["bu"]: "beforeUpdate hook",
  354. ["u"]: "updated",
  355. ["bum"]: "beforeUnmount hook",
  356. ["um"]: "unmounted hook",
  357. ["a"]: "activated hook",
  358. ["da"]: "deactivated hook",
  359. ["ec"]: "errorCaptured hook",
  360. ["rtc"]: "renderTracked hook",
  361. ["rtg"]: "renderTriggered hook",
  362. [0]: "setup function",
  363. [1]: "render function",
  364. [2]: "watcher getter",
  365. [3]: "watcher callback",
  366. [4]: "watcher cleanup function",
  367. [5]: "native event handler",
  368. [6]: "component event handler",
  369. [7]: "vnode hook",
  370. [8]: "directive hook",
  371. [9]: "transition hook",
  372. [10]: "app errorHandler",
  373. [11]: "app warnHandler",
  374. [12]: "ref function",
  375. [13]: "async component loader",
  376. [14]: "scheduler flush",
  377. [15]: "component update"
  378. };
  379. function callWithErrorHandling(fn, instance, type, args) {
  380. try {
  381. return args ? fn(...args) : fn();
  382. } catch (err) {
  383. handleError(err, instance, type);
  384. }
  385. }
  386. function handleError(err, instance, type, throwInDev = true) {
  387. const contextVNode = instance ? instance.vnode : null;
  388. if (instance) {
  389. let cur = instance.parent;
  390. const exposedInstance = instance.proxy;
  391. const errorInfo = !!(process.env.NODE_ENV !== "production") ? ErrorTypeStrings[type] : `https://vuejs.org/error-reference/#runtime-${type}`;
  392. while (cur) {
  393. const errorCapturedHooks = cur.ec;
  394. if (errorCapturedHooks) {
  395. for (let i = 0; i < errorCapturedHooks.length; i++) {
  396. if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
  397. return;
  398. }
  399. }
  400. }
  401. cur = cur.parent;
  402. }
  403. const appErrorHandler = instance.appContext.config.errorHandler;
  404. if (appErrorHandler) {
  405. pauseTracking();
  406. callWithErrorHandling(
  407. appErrorHandler,
  408. null,
  409. 10,
  410. [err, exposedInstance, errorInfo]
  411. );
  412. resetTracking();
  413. return;
  414. }
  415. }
  416. logError(err, type, contextVNode, throwInDev);
  417. }
  418. function logError(err, type, contextVNode, throwInDev = true) {
  419. if (!!(process.env.NODE_ENV !== "production")) {
  420. const info = ErrorTypeStrings[type];
  421. if (contextVNode) {
  422. pushWarningContext(contextVNode);
  423. }
  424. warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
  425. if (contextVNode) {
  426. popWarningContext();
  427. }
  428. if (throwInDev) {
  429. throw err;
  430. } else {
  431. console.error(err);
  432. }
  433. } else {
  434. console.error(err);
  435. }
  436. }
  437. let devtools;
  438. let buffer = [];
  439. function setDevtoolsHook(hook, target) {
  440. var _a, _b;
  441. devtools = hook;
  442. if (devtools) {
  443. devtools.enabled = true;
  444. buffer.forEach(({ event, args }) => devtools.emit(event, ...args));
  445. buffer = [];
  446. } else if (
  447. // handle late devtools injection - only do this if we are in an actual
  448. // browser environment to avoid the timer handle stalling test runner exit
  449. // (#4815)
  450. typeof window !== "undefined" && // some envs mock window but not fully
  451. window.HTMLElement && // also exclude jsdom
  452. // eslint-disable-next-line no-restricted-syntax
  453. !((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
  454. ) {
  455. const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
  456. replay.push((newHook) => {
  457. setDevtoolsHook(newHook, target);
  458. });
  459. setTimeout(() => {
  460. if (!devtools) {
  461. target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
  462. buffer = [];
  463. }
  464. }, 3e3);
  465. } else {
  466. buffer = [];
  467. }
  468. }
  469. {
  470. const g = getGlobalThis();
  471. const registerGlobalSetter = (key, setter) => {
  472. let setters;
  473. if (!(setters = g[key])) setters = g[key] = [];
  474. setters.push(setter);
  475. return (v) => {
  476. if (setters.length > 1) setters.forEach((set) => set(v));
  477. else setters[0](v);
  478. };
  479. };
  480. registerGlobalSetter(
  481. `__VUE_INSTANCE_SETTERS__`,
  482. (v) => v
  483. );
  484. registerGlobalSetter(
  485. `__VUE_SSR_SETTERS__`,
  486. (v) => v
  487. );
  488. }
  489. !!(process.env.NODE_ENV !== "production") ? {
  490. get(target, key) {
  491. track(target, "get", "");
  492. return target[key];
  493. },
  494. set() {
  495. warn$1(`setupContext.attrs is readonly.`);
  496. return false;
  497. },
  498. deleteProperty() {
  499. warn$1(`setupContext.attrs is readonly.`);
  500. return false;
  501. }
  502. } : {
  503. get(target, key) {
  504. track(target, "get", "");
  505. return target[key];
  506. }
  507. };
  508. const classifyRE = /(?:^|[-_])(\w)/g;
  509. const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
  510. function getComponentName(Component, includeInferred = true) {
  511. return isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
  512. }
  513. function formatComponentName(instance, Component, isRoot = false) {
  514. let name = getComponentName(Component);
  515. if (!name && Component.__file) {
  516. const match = Component.__file.match(/([^/\\]+)\.\w+$/);
  517. if (match) {
  518. name = match[1];
  519. }
  520. }
  521. if (!name && instance && instance.parent) {
  522. const inferFromRegistry = (registry) => {
  523. for (const key in registry) {
  524. if (registry[key] === Component) {
  525. return key;
  526. }
  527. }
  528. };
  529. name = inferFromRegistry(
  530. instance.components || instance.parent.type.components
  531. ) || inferFromRegistry(instance.appContext.components);
  532. }
  533. return name ? classify(name) : isRoot ? `App` : `Anonymous`;
  534. }
  535. const warn = !!(process.env.NODE_ENV !== "production") ? warn$1 : NOOP;
  536. !!(process.env.NODE_ENV !== "production") || true ? devtools : void 0;
  537. !!(process.env.NODE_ENV !== "production") || true ? setDevtoolsHook : NOOP;
  538. function ssrRenderList(source, renderItem) {
  539. if (isArray(source) || isString(source)) {
  540. for (let i = 0, l = source.length; i < l; i++) {
  541. renderItem(source[i], i);
  542. }
  543. } else if (typeof source === "number") {
  544. if (!!(process.env.NODE_ENV !== "production") && !Number.isInteger(source)) {
  545. warn(`The v-for range expect an integer value but got ${source}.`);
  546. return;
  547. }
  548. for (let i = 0; i < source; i++) {
  549. renderItem(i + 1, i);
  550. }
  551. } else if (isObject(source)) {
  552. if (source[Symbol.iterator]) {
  553. const arr = Array.from(source);
  554. for (let i = 0, l = arr.length; i < l; i++) {
  555. renderItem(arr[i], i);
  556. }
  557. } else {
  558. const keys = Object.keys(source);
  559. for (let i = 0, l = keys.length; i < l; i++) {
  560. const key = keys[i];
  561. renderItem(source[key], key, i);
  562. }
  563. }
  564. }
  565. }
  566. async function ssrRenderSuspense(push, { default: renderContent }) {
  567. if (renderContent) {
  568. renderContent();
  569. } else {
  570. push(`<!---->`);
  571. }
  572. }
  573. function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
  574. if (typeof dir !== "function" && dir.getSSRProps) {
  575. return dir.getSSRProps(
  576. {
  577. dir,
  578. instance: ssrUtils.getComponentPublicInstance(instance.$),
  579. value,
  580. oldValue: void 0,
  581. arg,
  582. modifiers
  583. },
  584. null
  585. ) || {};
  586. }
  587. return {};
  588. }
  589. const ssrLooseEqual = looseEqual;
  590. function ssrLooseContain(arr, value) {
  591. return looseIndexOf(arr, value) > -1;
  592. }
  593. function ssrRenderDynamicModel(type, model, value) {
  594. switch (type) {
  595. case "radio":
  596. return looseEqual(model, value) ? " checked" : "";
  597. case "checkbox":
  598. return (isArray(model) ? ssrLooseContain(model, value) : model) ? " checked" : "";
  599. default:
  600. return ssrRenderAttr("value", model);
  601. }
  602. }
  603. function ssrGetDynamicModelProps(existingProps = {}, model) {
  604. const { type, value } = existingProps;
  605. switch (type) {
  606. case "radio":
  607. return looseEqual(model, value) ? { checked: true } : null;
  608. case "checkbox":
  609. return (isArray(model) ? ssrLooseContain(model, value) : model) ? { checked: true } : null;
  610. default:
  611. return { value: model };
  612. }
  613. }
  614. function ssrCompile(template, instance) {
  615. {
  616. throw new Error(
  617. `On-the-fly template compilation is not supported in the ESM build of @vue/server-renderer. All templates must be pre-compiled into render functions.`
  618. );
  619. }
  620. }
  621. const {
  622. createComponentInstance,
  623. setCurrentRenderingInstance,
  624. setupComponent,
  625. renderComponentRoot,
  626. normalizeVNode
  627. } = ssrUtils;
  628. function createBuffer() {
  629. let appendable = false;
  630. const buffer = [];
  631. return {
  632. getBuffer() {
  633. return buffer;
  634. },
  635. push(item) {
  636. const isStringItem = isString(item);
  637. if (appendable && isStringItem) {
  638. buffer[buffer.length - 1] += item;
  639. return;
  640. }
  641. buffer.push(item);
  642. appendable = isStringItem;
  643. if (isPromise(item) || isArray(item) && item.hasAsync) {
  644. buffer.hasAsync = true;
  645. }
  646. }
  647. };
  648. }
  649. function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
  650. const instance = createComponentInstance(vnode, parentComponent, null);
  651. const res = setupComponent(
  652. instance,
  653. true
  654. /* isSSR */
  655. );
  656. const hasAsyncSetup = isPromise(res);
  657. const prefetches = instance.sp;
  658. if (hasAsyncSetup || prefetches) {
  659. let p = hasAsyncSetup ? res : Promise.resolve();
  660. if (prefetches) {
  661. p = p.then(
  662. () => Promise.all(
  663. prefetches.map((prefetch) => prefetch.call(instance.proxy))
  664. )
  665. ).catch(NOOP);
  666. }
  667. return p.then(() => renderComponentSubTree(instance, slotScopeId));
  668. } else {
  669. return renderComponentSubTree(instance, slotScopeId);
  670. }
  671. }
  672. function renderComponentSubTree(instance, slotScopeId) {
  673. const comp = instance.type;
  674. const { getBuffer, push } = createBuffer();
  675. if (isFunction(comp)) {
  676. let root = renderComponentRoot(instance);
  677. if (!comp.props) {
  678. for (const key in instance.attrs) {
  679. if (key.startsWith(`data-v-`)) {
  680. (root.props || (root.props = {}))[key] = ``;
  681. }
  682. }
  683. }
  684. renderVNode(push, instance.subTree = root, instance, slotScopeId);
  685. } else {
  686. if ((!instance.render || instance.render === NOOP) && !instance.ssrRender && !comp.ssrRender && isString(comp.template)) {
  687. comp.ssrRender = ssrCompile(comp.template);
  688. }
  689. for (const e of instance.scope.effects) {
  690. if (e.computed) {
  691. e.computed._dirty = true;
  692. e.computed._cacheable = true;
  693. }
  694. }
  695. const ssrRender = instance.ssrRender || comp.ssrRender;
  696. if (ssrRender) {
  697. let attrs = instance.inheritAttrs !== false ? instance.attrs : void 0;
  698. let hasCloned = false;
  699. let cur = instance;
  700. while (true) {
  701. const scopeId = cur.vnode.scopeId;
  702. if (scopeId) {
  703. if (!hasCloned) {
  704. attrs = { ...attrs };
  705. hasCloned = true;
  706. }
  707. attrs[scopeId] = "";
  708. }
  709. const parent = cur.parent;
  710. if (parent && parent.subTree && parent.subTree === cur.vnode) {
  711. cur = parent;
  712. } else {
  713. break;
  714. }
  715. }
  716. if (slotScopeId) {
  717. if (!hasCloned) attrs = { ...attrs };
  718. const slotScopeIdList = slotScopeId.trim().split(" ");
  719. for (let i = 0; i < slotScopeIdList.length; i++) {
  720. attrs[slotScopeIdList[i]] = "";
  721. }
  722. }
  723. const prev = setCurrentRenderingInstance(instance);
  724. try {
  725. ssrRender(
  726. instance.proxy,
  727. push,
  728. instance,
  729. attrs,
  730. // compiler-optimized bindings
  731. instance.props,
  732. instance.setupState,
  733. instance.data,
  734. instance.ctx
  735. );
  736. } finally {
  737. setCurrentRenderingInstance(prev);
  738. }
  739. } else if (instance.render && instance.render !== NOOP) {
  740. renderVNode(
  741. push,
  742. instance.subTree = renderComponentRoot(instance),
  743. instance,
  744. slotScopeId
  745. );
  746. } else {
  747. const componentName = comp.name || comp.__file || `<Anonymous>`;
  748. warn$2(`Component ${componentName} is missing template or render function.`);
  749. push(`<!---->`);
  750. }
  751. }
  752. return getBuffer();
  753. }
  754. function renderVNode(push, vnode, parentComponent, slotScopeId) {
  755. const { type, shapeFlag, children } = vnode;
  756. switch (type) {
  757. case Text:
  758. push(escapeHtml(children));
  759. break;
  760. case Comment:
  761. push(
  762. children ? `<!--${escapeHtmlComment(children)}-->` : `<!---->`
  763. );
  764. break;
  765. case Static:
  766. push(children);
  767. break;
  768. case Fragment:
  769. if (vnode.slotScopeIds) {
  770. slotScopeId = (slotScopeId ? slotScopeId + " " : "") + vnode.slotScopeIds.join(" ");
  771. }
  772. push(`<!--[-->`);
  773. renderVNodeChildren(
  774. push,
  775. children,
  776. parentComponent,
  777. slotScopeId
  778. );
  779. push(`<!--]-->`);
  780. break;
  781. default:
  782. if (shapeFlag & 1) {
  783. renderElementVNode(push, vnode, parentComponent, slotScopeId);
  784. } else if (shapeFlag & 6) {
  785. push(renderComponentVNode(vnode, parentComponent, slotScopeId));
  786. } else if (shapeFlag & 64) {
  787. renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
  788. } else if (shapeFlag & 128) {
  789. renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
  790. } else {
  791. warn$2(
  792. "[@vue/server-renderer] Invalid VNode type:",
  793. type,
  794. `(${typeof type})`
  795. );
  796. }
  797. }
  798. }
  799. function renderVNodeChildren(push, children, parentComponent, slotScopeId) {
  800. for (let i = 0; i < children.length; i++) {
  801. renderVNode(push, normalizeVNode(children[i]), parentComponent, slotScopeId);
  802. }
  803. }
  804. function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
  805. const tag = vnode.type;
  806. let { props, children, shapeFlag, scopeId, dirs } = vnode;
  807. let openTag = `<${tag}`;
  808. if (dirs) {
  809. props = applySSRDirectives(vnode, props, dirs);
  810. }
  811. if (props) {
  812. openTag += ssrRenderAttrs(props, tag);
  813. }
  814. if (scopeId) {
  815. openTag += ` ${scopeId}`;
  816. }
  817. let curParent = parentComponent;
  818. let curVnode = vnode;
  819. while (curParent && curVnode === curParent.subTree) {
  820. curVnode = curParent.vnode;
  821. if (curVnode.scopeId) {
  822. openTag += ` ${curVnode.scopeId}`;
  823. }
  824. curParent = curParent.parent;
  825. }
  826. if (slotScopeId) {
  827. openTag += ` ${slotScopeId}`;
  828. }
  829. push(openTag + `>`);
  830. if (!isVoidTag(tag)) {
  831. let hasChildrenOverride = false;
  832. if (props) {
  833. if (props.innerHTML) {
  834. hasChildrenOverride = true;
  835. push(props.innerHTML);
  836. } else if (props.textContent) {
  837. hasChildrenOverride = true;
  838. push(escapeHtml(props.textContent));
  839. } else if (tag === "textarea" && props.value) {
  840. hasChildrenOverride = true;
  841. push(escapeHtml(props.value));
  842. }
  843. }
  844. if (!hasChildrenOverride) {
  845. if (shapeFlag & 8) {
  846. push(escapeHtml(children));
  847. } else if (shapeFlag & 16) {
  848. renderVNodeChildren(
  849. push,
  850. children,
  851. parentComponent,
  852. slotScopeId
  853. );
  854. }
  855. }
  856. push(`</${tag}>`);
  857. }
  858. }
  859. function applySSRDirectives(vnode, rawProps, dirs) {
  860. const toMerge = [];
  861. for (let i = 0; i < dirs.length; i++) {
  862. const binding = dirs[i];
  863. const {
  864. dir: { getSSRProps }
  865. } = binding;
  866. if (getSSRProps) {
  867. const props = getSSRProps(binding, vnode);
  868. if (props) toMerge.push(props);
  869. }
  870. }
  871. return mergeProps(rawProps || {}, ...toMerge);
  872. }
  873. function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
  874. const target = vnode.props && vnode.props.to;
  875. const disabled = vnode.props && vnode.props.disabled;
  876. if (!target) {
  877. if (!disabled) {
  878. warn$2(`[@vue/server-renderer] Teleport is missing target prop.`);
  879. }
  880. return [];
  881. }
  882. if (!isString(target)) {
  883. warn$2(
  884. `[@vue/server-renderer] Teleport target must be a query selector string.`
  885. );
  886. return [];
  887. }
  888. ssrRenderTeleport(
  889. push,
  890. (push2) => {
  891. renderVNodeChildren(
  892. push2,
  893. vnode.children,
  894. parentComponent,
  895. slotScopeId
  896. );
  897. },
  898. target,
  899. disabled || disabled === "",
  900. parentComponent
  901. );
  902. }
  903. const { isVNode: isVNode$1 } = ssrUtils;
  904. function nestedUnrollBuffer(buffer, parentRet, startIndex) {
  905. if (!buffer.hasAsync) {
  906. return parentRet + unrollBufferSync$1(buffer);
  907. }
  908. let ret = parentRet;
  909. for (let i = startIndex; i < buffer.length; i += 1) {
  910. const item = buffer[i];
  911. if (isString(item)) {
  912. ret += item;
  913. continue;
  914. }
  915. if (isPromise(item)) {
  916. return item.then((nestedItem) => {
  917. buffer[i] = nestedItem;
  918. return nestedUnrollBuffer(buffer, ret, i);
  919. });
  920. }
  921. const result = nestedUnrollBuffer(item, ret, 0);
  922. if (isPromise(result)) {
  923. return result.then((nestedItem) => {
  924. buffer[i] = nestedItem;
  925. return nestedUnrollBuffer(buffer, "", i);
  926. });
  927. }
  928. ret = result;
  929. }
  930. return ret;
  931. }
  932. function unrollBuffer$1(buffer) {
  933. return nestedUnrollBuffer(buffer, "", 0);
  934. }
  935. function unrollBufferSync$1(buffer) {
  936. let ret = "";
  937. for (let i = 0; i < buffer.length; i++) {
  938. let item = buffer[i];
  939. if (isString(item)) {
  940. ret += item;
  941. } else {
  942. ret += unrollBufferSync$1(item);
  943. }
  944. }
  945. return ret;
  946. }
  947. async function renderToString(input, context = {}) {
  948. if (isVNode$1(input)) {
  949. return renderToString(createApp({ render: () => input }), context);
  950. }
  951. const vnode = createVNode(input._component, input._props);
  952. vnode.appContext = input._context;
  953. input.provide(ssrContextKey, context);
  954. const buffer = await renderComponentVNode(vnode);
  955. const result = await unrollBuffer$1(buffer);
  956. await resolveTeleports(context);
  957. if (context.__watcherHandles) {
  958. for (const unwatch of context.__watcherHandles) {
  959. unwatch();
  960. }
  961. }
  962. return result;
  963. }
  964. async function resolveTeleports(context) {
  965. if (context.__teleportBuffers) {
  966. context.teleports = context.teleports || {};
  967. for (const key in context.__teleportBuffers) {
  968. context.teleports[key] = await unrollBuffer$1(
  969. await Promise.all([context.__teleportBuffers[key]])
  970. );
  971. }
  972. }
  973. }
  974. const { isVNode } = ssrUtils;
  975. async function unrollBuffer(buffer, stream) {
  976. if (buffer.hasAsync) {
  977. for (let i = 0; i < buffer.length; i++) {
  978. let item = buffer[i];
  979. if (isPromise(item)) {
  980. item = await item;
  981. }
  982. if (isString(item)) {
  983. stream.push(item);
  984. } else {
  985. await unrollBuffer(item, stream);
  986. }
  987. }
  988. } else {
  989. unrollBufferSync(buffer, stream);
  990. }
  991. }
  992. function unrollBufferSync(buffer, stream) {
  993. for (let i = 0; i < buffer.length; i++) {
  994. let item = buffer[i];
  995. if (isString(item)) {
  996. stream.push(item);
  997. } else {
  998. unrollBufferSync(item, stream);
  999. }
  1000. }
  1001. }
  1002. function renderToSimpleStream(input, context, stream) {
  1003. if (isVNode(input)) {
  1004. return renderToSimpleStream(
  1005. createApp({ render: () => input }),
  1006. context,
  1007. stream
  1008. );
  1009. }
  1010. const vnode = createVNode(input._component, input._props);
  1011. vnode.appContext = input._context;
  1012. input.provide(ssrContextKey, context);
  1013. Promise.resolve(renderComponentVNode(vnode)).then((buffer) => unrollBuffer(buffer, stream)).then(() => resolveTeleports(context)).then(() => {
  1014. if (context.__watcherHandles) {
  1015. for (const unwatch of context.__watcherHandles) {
  1016. unwatch();
  1017. }
  1018. }
  1019. }).then(() => stream.push(null)).catch((error) => {
  1020. stream.destroy(error);
  1021. });
  1022. return stream;
  1023. }
  1024. function renderToStream(input, context = {}) {
  1025. console.warn(
  1026. `[@vue/server-renderer] renderToStream is deprecated - use renderToNodeStream instead.`
  1027. );
  1028. return renderToNodeStream(input, context);
  1029. }
  1030. function renderToNodeStream(input, context = {}) {
  1031. {
  1032. throw new Error(
  1033. `ESM build of renderToStream() does not support renderToNodeStream(). Use pipeToNodeWritable() with an existing Node.js Writable stream instance instead.`
  1034. );
  1035. }
  1036. }
  1037. function pipeToNodeWritable(input, context = {}, writable) {
  1038. renderToSimpleStream(input, context, {
  1039. push(content) {
  1040. if (content != null) {
  1041. writable.write(content);
  1042. } else {
  1043. writable.end();
  1044. }
  1045. },
  1046. destroy(err) {
  1047. writable.destroy(err);
  1048. }
  1049. });
  1050. }
  1051. function renderToWebStream(input, context = {}) {
  1052. if (typeof ReadableStream !== "function") {
  1053. throw new Error(
  1054. `ReadableStream constructor is not available in the global scope. If the target environment does support web streams, consider using pipeToWebWritable() with an existing WritableStream instance instead.`
  1055. );
  1056. }
  1057. const encoder = new TextEncoder();
  1058. let cancelled = false;
  1059. return new ReadableStream({
  1060. start(controller) {
  1061. renderToSimpleStream(input, context, {
  1062. push(content) {
  1063. if (cancelled) return;
  1064. if (content != null) {
  1065. controller.enqueue(encoder.encode(content));
  1066. } else {
  1067. controller.close();
  1068. }
  1069. },
  1070. destroy(err) {
  1071. controller.error(err);
  1072. }
  1073. });
  1074. },
  1075. cancel() {
  1076. cancelled = true;
  1077. }
  1078. });
  1079. }
  1080. function pipeToWebWritable(input, context = {}, writable) {
  1081. const writer = writable.getWriter();
  1082. const encoder = new TextEncoder();
  1083. let hasReady = false;
  1084. try {
  1085. hasReady = isPromise(writer.ready);
  1086. } catch (e) {
  1087. }
  1088. renderToSimpleStream(input, context, {
  1089. async push(content) {
  1090. if (hasReady) {
  1091. await writer.ready;
  1092. }
  1093. if (content != null) {
  1094. return writer.write(encoder.encode(content));
  1095. } else {
  1096. return writer.close();
  1097. }
  1098. },
  1099. destroy(err) {
  1100. console.log(err);
  1101. writer.close();
  1102. }
  1103. });
  1104. }
  1105. initDirectivesForSSR();
  1106. export { pipeToNodeWritable, pipeToWebWritable, renderToNodeStream, renderToSimpleStream, renderToStream, renderToString, renderToWebStream, ssrGetDirectiveProps, ssrGetDynamicModelProps, ssrInterpolate, ssrLooseContain, ssrLooseEqual, ssrRenderAttr, ssrRenderAttrs, ssrRenderClass, ssrRenderComponent, ssrRenderDynamicAttr, ssrRenderDynamicModel, ssrRenderList, ssrRenderSlot, ssrRenderSlotInner, ssrRenderStyle, ssrRenderSuspense, ssrRenderTeleport, renderVNode as ssrRenderVNode };