@vue/server-renderer 3.2.36 → 3.2.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -250,10 +250,14 @@ function renderComponentSubTree(instance, slotScopeId) {
250
250
  }
251
251
  // set current rendering instance for asset resolution
252
252
  const prev = setCurrentRenderingInstance(instance);
253
- ssrRender(instance.proxy, push, instance, attrs,
254
- // compiler-optimized bindings
255
- instance.props, instance.setupState, instance.data, instance.ctx);
256
- setCurrentRenderingInstance(prev);
253
+ try {
254
+ ssrRender(instance.proxy, push, instance, attrs,
255
+ // compiler-optimized bindings
256
+ instance.props, instance.setupState, instance.data, instance.ctx);
257
+ }
258
+ finally {
259
+ setCurrentRenderingInstance(prev);
260
+ }
257
261
  }
258
262
  else if (instance.render && instance.render !== shared.NOOP) {
259
263
  renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
@@ -288,16 +292,16 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
288
292
  push(`<!--]-->`); // close
289
293
  break;
290
294
  default:
291
- if (shapeFlag & 1 /* ELEMENT */) {
295
+ if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
292
296
  renderElementVNode(push, vnode, parentComponent, slotScopeId);
293
297
  }
294
- else if (shapeFlag & 6 /* COMPONENT */) {
298
+ else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
295
299
  push(renderComponentVNode(vnode, parentComponent, slotScopeId));
296
300
  }
297
- else if (shapeFlag & 64 /* TELEPORT */) {
301
+ else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
298
302
  renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
299
303
  }
300
- else if (shapeFlag & 128 /* SUSPENSE */) {
304
+ else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
301
305
  renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
302
306
  }
303
307
  else {
@@ -354,10 +358,10 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
354
358
  }
355
359
  }
356
360
  if (!hasChildrenOverride) {
357
- if (shapeFlag & 8 /* TEXT_CHILDREN */) {
361
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
358
362
  push(shared.escapeHtml(children));
359
363
  }
360
- else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
364
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
361
365
  renderVNodeChildren(push, children, parentComponent, slotScopeId);
362
366
  }
363
367
  }
@@ -454,7 +458,7 @@ async function resolveTeleports(context) {
454
458
  for (const key in context.__teleportBuffers) {
455
459
  // note: it's OK to await sequentially here because the Promises were
456
460
  // created eagerly in parallel.
457
- context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
461
+ context.teleports[key] = await unrollBuffer(await Promise.all([context.__teleportBuffers[key]]));
458
462
  }
459
463
  }
460
464
  }
@@ -614,7 +618,7 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
614
618
  ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
615
619
  push(`<!--]-->`);
616
620
  }
617
- function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
621
+ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
618
622
  const slotFn = slots[slotName];
619
623
  if (slotFn) {
620
624
  const slotBuffer = [];
@@ -630,10 +634,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
630
634
  // ssr slot.
631
635
  // check if the slot renders all comments, in which case use the fallback
632
636
  let isEmptySlot = true;
633
- for (let i = 0; i < slotBuffer.length; i++) {
634
- if (!isComment(slotBuffer[i])) {
635
- isEmptySlot = false;
636
- break;
637
+ if (transition) {
638
+ isEmptySlot = false;
639
+ }
640
+ else {
641
+ for (let i = 0; i < slotBuffer.length; i++) {
642
+ if (!isComment(slotBuffer[i])) {
643
+ isEmptySlot = false;
644
+ break;
645
+ }
637
646
  }
638
647
  }
639
648
  if (isEmptySlot) {
@@ -652,11 +661,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
652
661
  fallbackRenderFn();
653
662
  }
654
663
  }
664
+ const commentTestRE = /^<!--.*-->$/s;
655
665
  const commentRE = /<!--[^]*?-->/gm;
656
666
  function isComment(item) {
657
- return (typeof item === 'string' &&
658
- commentRE.test(item) &&
659
- !item.replace(commentRE, '').trim());
667
+ if (typeof item !== 'string' || !commentTestRE.test(item))
668
+ return false;
669
+ // if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly
670
+ if (item.length <= 8)
671
+ return true;
672
+ return !item.replace(commentRE, '').trim();
660
673
  }
661
674
 
662
675
  function ssrInterpolate(value) {
@@ -664,7 +677,7 @@ function ssrInterpolate(value) {
664
677
  }
665
678
 
666
679
  function toRaw(observed) {
667
- const raw = observed && observed["__v_raw" /* RAW */];
680
+ const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
668
681
  return raw ? toRaw(raw) : observed;
669
682
  }
670
683
 
@@ -684,7 +697,7 @@ function warn(msg, ...args) {
684
697
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
685
698
  const trace = getComponentTrace();
686
699
  if (appWarnHandler) {
687
- callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
700
+ callWithErrorHandling(appWarnHandler, instance, 11 /* ErrorCodes.APP_WARN_HANDLER */, [
688
701
  msg + args.join(''),
689
702
  instance && instance.proxy,
690
703
  trace
@@ -783,35 +796,35 @@ function formatProp(key, value, raw) {
783
796
  }
784
797
 
785
798
  const ErrorTypeStrings = {
786
- ["sp" /* SERVER_PREFETCH */]: 'serverPrefetch hook',
787
- ["bc" /* BEFORE_CREATE */]: 'beforeCreate hook',
788
- ["c" /* CREATED */]: 'created hook',
789
- ["bm" /* BEFORE_MOUNT */]: 'beforeMount hook',
790
- ["m" /* MOUNTED */]: 'mounted hook',
791
- ["bu" /* BEFORE_UPDATE */]: 'beforeUpdate hook',
792
- ["u" /* UPDATED */]: 'updated',
793
- ["bum" /* BEFORE_UNMOUNT */]: 'beforeUnmount hook',
794
- ["um" /* UNMOUNTED */]: 'unmounted hook',
795
- ["a" /* ACTIVATED */]: 'activated hook',
796
- ["da" /* DEACTIVATED */]: 'deactivated hook',
797
- ["ec" /* ERROR_CAPTURED */]: 'errorCaptured hook',
798
- ["rtc" /* RENDER_TRACKED */]: 'renderTracked hook',
799
- ["rtg" /* RENDER_TRIGGERED */]: 'renderTriggered hook',
800
- [0 /* SETUP_FUNCTION */]: 'setup function',
801
- [1 /* RENDER_FUNCTION */]: 'render function',
802
- [2 /* WATCH_GETTER */]: 'watcher getter',
803
- [3 /* WATCH_CALLBACK */]: 'watcher callback',
804
- [4 /* WATCH_CLEANUP */]: 'watcher cleanup function',
805
- [5 /* NATIVE_EVENT_HANDLER */]: 'native event handler',
806
- [6 /* COMPONENT_EVENT_HANDLER */]: 'component event handler',
807
- [7 /* VNODE_HOOK */]: 'vnode hook',
808
- [8 /* DIRECTIVE_HOOK */]: 'directive hook',
809
- [9 /* TRANSITION_HOOK */]: 'transition hook',
810
- [10 /* APP_ERROR_HANDLER */]: 'app errorHandler',
811
- [11 /* APP_WARN_HANDLER */]: 'app warnHandler',
812
- [12 /* FUNCTION_REF */]: 'ref function',
813
- [13 /* ASYNC_COMPONENT_LOADER */]: 'async component loader',
814
- [14 /* SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
799
+ ["sp" /* LifecycleHooks.SERVER_PREFETCH */]: 'serverPrefetch hook',
800
+ ["bc" /* LifecycleHooks.BEFORE_CREATE */]: 'beforeCreate hook',
801
+ ["c" /* LifecycleHooks.CREATED */]: 'created hook',
802
+ ["bm" /* LifecycleHooks.BEFORE_MOUNT */]: 'beforeMount hook',
803
+ ["m" /* LifecycleHooks.MOUNTED */]: 'mounted hook',
804
+ ["bu" /* LifecycleHooks.BEFORE_UPDATE */]: 'beforeUpdate hook',
805
+ ["u" /* LifecycleHooks.UPDATED */]: 'updated',
806
+ ["bum" /* LifecycleHooks.BEFORE_UNMOUNT */]: 'beforeUnmount hook',
807
+ ["um" /* LifecycleHooks.UNMOUNTED */]: 'unmounted hook',
808
+ ["a" /* LifecycleHooks.ACTIVATED */]: 'activated hook',
809
+ ["da" /* LifecycleHooks.DEACTIVATED */]: 'deactivated hook',
810
+ ["ec" /* LifecycleHooks.ERROR_CAPTURED */]: 'errorCaptured hook',
811
+ ["rtc" /* LifecycleHooks.RENDER_TRACKED */]: 'renderTracked hook',
812
+ ["rtg" /* LifecycleHooks.RENDER_TRIGGERED */]: 'renderTriggered hook',
813
+ [0 /* ErrorCodes.SETUP_FUNCTION */]: 'setup function',
814
+ [1 /* ErrorCodes.RENDER_FUNCTION */]: 'render function',
815
+ [2 /* ErrorCodes.WATCH_GETTER */]: 'watcher getter',
816
+ [3 /* ErrorCodes.WATCH_CALLBACK */]: 'watcher callback',
817
+ [4 /* ErrorCodes.WATCH_CLEANUP */]: 'watcher cleanup function',
818
+ [5 /* ErrorCodes.NATIVE_EVENT_HANDLER */]: 'native event handler',
819
+ [6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */]: 'component event handler',
820
+ [7 /* ErrorCodes.VNODE_HOOK */]: 'vnode hook',
821
+ [8 /* ErrorCodes.DIRECTIVE_HOOK */]: 'directive hook',
822
+ [9 /* ErrorCodes.TRANSITION_HOOK */]: 'transition hook',
823
+ [10 /* ErrorCodes.APP_ERROR_HANDLER */]: 'app errorHandler',
824
+ [11 /* ErrorCodes.APP_WARN_HANDLER */]: 'app warnHandler',
825
+ [12 /* ErrorCodes.FUNCTION_REF */]: 'ref function',
826
+ [13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */]: 'async component loader',
827
+ [14 /* ErrorCodes.SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
815
828
  'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
816
829
  };
817
830
  function callWithErrorHandling(fn, instance, type, args) {
@@ -846,7 +859,7 @@ function handleError(err, instance, type, throwInDev = true) {
846
859
  // app-level handling
847
860
  const appErrorHandler = instance.appContext.config.errorHandler;
848
861
  if (appErrorHandler) {
849
- callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
862
+ callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
850
863
  return;
851
864
  }
852
865
  }
@@ -874,10 +887,10 @@ function logError(err, type, contextVNode, throwInDev = true) {
874
887
 
875
888
  const classifyRE = /(?:^|[-_])(\w)/g;
876
889
  const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
877
- function getComponentName(Component) {
890
+ function getComponentName(Component, includeInferred = true) {
878
891
  return shared.isFunction(Component)
879
892
  ? Component.displayName || Component.name
880
- : Component.name;
893
+ : Component.name || (includeInferred && Component.__name);
881
894
  }
882
895
  /* istanbul ignore next */
883
896
  function formatComponentName(instance, Component, isRoot = false) {
@@ -247,10 +247,14 @@ function renderComponentSubTree(instance, slotScopeId) {
247
247
  }
248
248
  // set current rendering instance for asset resolution
249
249
  const prev = setCurrentRenderingInstance(instance);
250
- ssrRender(instance.proxy, push, instance, attrs,
251
- // compiler-optimized bindings
252
- instance.props, instance.setupState, instance.data, instance.ctx);
253
- setCurrentRenderingInstance(prev);
250
+ try {
251
+ ssrRender(instance.proxy, push, instance, attrs,
252
+ // compiler-optimized bindings
253
+ instance.props, instance.setupState, instance.data, instance.ctx);
254
+ }
255
+ finally {
256
+ setCurrentRenderingInstance(prev);
257
+ }
254
258
  }
255
259
  else if (instance.render && instance.render !== shared.NOOP) {
256
260
  renderVNode(push, (instance.subTree = renderComponentRoot(instance)), instance, slotScopeId);
@@ -285,16 +289,16 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
285
289
  push(`<!--]-->`); // close
286
290
  break;
287
291
  default:
288
- if (shapeFlag & 1 /* ELEMENT */) {
292
+ if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
289
293
  renderElementVNode(push, vnode, parentComponent, slotScopeId);
290
294
  }
291
- else if (shapeFlag & 6 /* COMPONENT */) {
295
+ else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
292
296
  push(renderComponentVNode(vnode, parentComponent, slotScopeId));
293
297
  }
294
- else if (shapeFlag & 64 /* TELEPORT */) {
298
+ else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
295
299
  renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
296
300
  }
297
- else if (shapeFlag & 128 /* SUSPENSE */) {
301
+ else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
298
302
  renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
299
303
  }
300
304
  else {
@@ -351,10 +355,10 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
351
355
  }
352
356
  }
353
357
  if (!hasChildrenOverride) {
354
- if (shapeFlag & 8 /* TEXT_CHILDREN */) {
358
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
355
359
  push(shared.escapeHtml(children));
356
360
  }
357
- else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
361
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
358
362
  renderVNodeChildren(push, children, parentComponent, slotScopeId);
359
363
  }
360
364
  }
@@ -451,7 +455,7 @@ async function resolveTeleports(context) {
451
455
  for (const key in context.__teleportBuffers) {
452
456
  // note: it's OK to await sequentially here because the Promises were
453
457
  // created eagerly in parallel.
454
- context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
458
+ context.teleports[key] = await unrollBuffer(await Promise.all([context.__teleportBuffers[key]]));
455
459
  }
456
460
  }
457
461
  }
@@ -611,7 +615,7 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
611
615
  ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
612
616
  push(`<!--]-->`);
613
617
  }
614
- function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
618
+ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
615
619
  const slotFn = slots[slotName];
616
620
  if (slotFn) {
617
621
  const slotBuffer = [];
@@ -627,10 +631,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
627
631
  // ssr slot.
628
632
  // check if the slot renders all comments, in which case use the fallback
629
633
  let isEmptySlot = true;
630
- for (let i = 0; i < slotBuffer.length; i++) {
631
- if (!isComment(slotBuffer[i])) {
632
- isEmptySlot = false;
633
- break;
634
+ if (transition) {
635
+ isEmptySlot = false;
636
+ }
637
+ else {
638
+ for (let i = 0; i < slotBuffer.length; i++) {
639
+ if (!isComment(slotBuffer[i])) {
640
+ isEmptySlot = false;
641
+ break;
642
+ }
634
643
  }
635
644
  }
636
645
  if (isEmptySlot) {
@@ -649,11 +658,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
649
658
  fallbackRenderFn();
650
659
  }
651
660
  }
661
+ const commentTestRE = /^<!--.*-->$/s;
652
662
  const commentRE = /<!--[^]*?-->/gm;
653
663
  function isComment(item) {
654
- return (typeof item === 'string' &&
655
- commentRE.test(item) &&
656
- !item.replace(commentRE, '').trim());
664
+ if (typeof item !== 'string' || !commentTestRE.test(item))
665
+ return false;
666
+ // if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly
667
+ if (item.length <= 8)
668
+ return true;
669
+ return !item.replace(commentRE, '').trim();
657
670
  }
658
671
 
659
672
  function ssrInterpolate(value) {
@@ -83,7 +83,7 @@ export declare function ssrRenderList(source: unknown, renderItem: (value: unkno
83
83
 
84
84
  export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
85
85
 
86
- export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
86
+ export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
87
87
 
88
88
  export declare function ssrRenderStyle(raw: unknown): string;
89
89