@vue/server-renderer 3.2.35 → 3.2.38

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.
@@ -288,16 +288,16 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
288
288
  push(`<!--]-->`); // close
289
289
  break;
290
290
  default:
291
- if (shapeFlag & 1 /* ELEMENT */) {
291
+ if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
292
292
  renderElementVNode(push, vnode, parentComponent, slotScopeId);
293
293
  }
294
- else if (shapeFlag & 6 /* COMPONENT */) {
294
+ else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
295
295
  push(renderComponentVNode(vnode, parentComponent, slotScopeId));
296
296
  }
297
- else if (shapeFlag & 64 /* TELEPORT */) {
297
+ else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
298
298
  renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
299
299
  }
300
- else if (shapeFlag & 128 /* SUSPENSE */) {
300
+ else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
301
301
  renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
302
302
  }
303
303
  else {
@@ -354,10 +354,10 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
354
354
  }
355
355
  }
356
356
  if (!hasChildrenOverride) {
357
- if (shapeFlag & 8 /* TEXT_CHILDREN */) {
357
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
358
358
  push(shared.escapeHtml(children));
359
359
  }
360
- else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
360
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
361
361
  renderVNodeChildren(push, children, parentComponent, slotScopeId);
362
362
  }
363
363
  }
@@ -454,7 +454,7 @@ async function resolveTeleports(context) {
454
454
  for (const key in context.__teleportBuffers) {
455
455
  // note: it's OK to await sequentially here because the Promises were
456
456
  // created eagerly in parallel.
457
- context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
457
+ context.teleports[key] = await unrollBuffer(await Promise.all([context.__teleportBuffers[key]]));
458
458
  }
459
459
  }
460
460
  }
@@ -614,7 +614,7 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
614
614
  ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
615
615
  push(`<!--]-->`);
616
616
  }
617
- function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
617
+ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
618
618
  const slotFn = slots[slotName];
619
619
  if (slotFn) {
620
620
  const slotBuffer = [];
@@ -630,10 +630,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
630
630
  // ssr slot.
631
631
  // check if the slot renders all comments, in which case use the fallback
632
632
  let isEmptySlot = true;
633
- for (let i = 0; i < slotBuffer.length; i++) {
634
- if (!isComment(slotBuffer[i])) {
635
- isEmptySlot = false;
636
- break;
633
+ if (transition) {
634
+ isEmptySlot = false;
635
+ }
636
+ else {
637
+ for (let i = 0; i < slotBuffer.length; i++) {
638
+ if (!isComment(slotBuffer[i])) {
639
+ isEmptySlot = false;
640
+ break;
641
+ }
637
642
  }
638
643
  }
639
644
  if (isEmptySlot) {
@@ -652,11 +657,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
652
657
  fallbackRenderFn();
653
658
  }
654
659
  }
660
+ const commentTestRE = /^<!--.*-->$/s;
655
661
  const commentRE = /<!--[^]*?-->/gm;
656
662
  function isComment(item) {
657
- return (typeof item === 'string' &&
658
- commentRE.test(item) &&
659
- !item.replace(commentRE, '').trim());
663
+ if (typeof item !== 'string' || !commentTestRE.test(item))
664
+ return false;
665
+ // if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly
666
+ if (item.length <= 8)
667
+ return true;
668
+ return !item.replace(commentRE, '').trim();
660
669
  }
661
670
 
662
671
  function ssrInterpolate(value) {
@@ -664,7 +673,7 @@ function ssrInterpolate(value) {
664
673
  }
665
674
 
666
675
  function toRaw(observed) {
667
- const raw = observed && observed["__v_raw" /* RAW */];
676
+ const raw = observed && observed["__v_raw" /* ReactiveFlags.RAW */];
668
677
  return raw ? toRaw(raw) : observed;
669
678
  }
670
679
 
@@ -684,7 +693,7 @@ function warn(msg, ...args) {
684
693
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
685
694
  const trace = getComponentTrace();
686
695
  if (appWarnHandler) {
687
- callWithErrorHandling(appWarnHandler, instance, 11 /* APP_WARN_HANDLER */, [
696
+ callWithErrorHandling(appWarnHandler, instance, 11 /* ErrorCodes.APP_WARN_HANDLER */, [
688
697
  msg + args.join(''),
689
698
  instance && instance.proxy,
690
699
  trace
@@ -783,35 +792,35 @@ function formatProp(key, value, raw) {
783
792
  }
784
793
 
785
794
  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. ' +
795
+ ["sp" /* LifecycleHooks.SERVER_PREFETCH */]: 'serverPrefetch hook',
796
+ ["bc" /* LifecycleHooks.BEFORE_CREATE */]: 'beforeCreate hook',
797
+ ["c" /* LifecycleHooks.CREATED */]: 'created hook',
798
+ ["bm" /* LifecycleHooks.BEFORE_MOUNT */]: 'beforeMount hook',
799
+ ["m" /* LifecycleHooks.MOUNTED */]: 'mounted hook',
800
+ ["bu" /* LifecycleHooks.BEFORE_UPDATE */]: 'beforeUpdate hook',
801
+ ["u" /* LifecycleHooks.UPDATED */]: 'updated',
802
+ ["bum" /* LifecycleHooks.BEFORE_UNMOUNT */]: 'beforeUnmount hook',
803
+ ["um" /* LifecycleHooks.UNMOUNTED */]: 'unmounted hook',
804
+ ["a" /* LifecycleHooks.ACTIVATED */]: 'activated hook',
805
+ ["da" /* LifecycleHooks.DEACTIVATED */]: 'deactivated hook',
806
+ ["ec" /* LifecycleHooks.ERROR_CAPTURED */]: 'errorCaptured hook',
807
+ ["rtc" /* LifecycleHooks.RENDER_TRACKED */]: 'renderTracked hook',
808
+ ["rtg" /* LifecycleHooks.RENDER_TRIGGERED */]: 'renderTriggered hook',
809
+ [0 /* ErrorCodes.SETUP_FUNCTION */]: 'setup function',
810
+ [1 /* ErrorCodes.RENDER_FUNCTION */]: 'render function',
811
+ [2 /* ErrorCodes.WATCH_GETTER */]: 'watcher getter',
812
+ [3 /* ErrorCodes.WATCH_CALLBACK */]: 'watcher callback',
813
+ [4 /* ErrorCodes.WATCH_CLEANUP */]: 'watcher cleanup function',
814
+ [5 /* ErrorCodes.NATIVE_EVENT_HANDLER */]: 'native event handler',
815
+ [6 /* ErrorCodes.COMPONENT_EVENT_HANDLER */]: 'component event handler',
816
+ [7 /* ErrorCodes.VNODE_HOOK */]: 'vnode hook',
817
+ [8 /* ErrorCodes.DIRECTIVE_HOOK */]: 'directive hook',
818
+ [9 /* ErrorCodes.TRANSITION_HOOK */]: 'transition hook',
819
+ [10 /* ErrorCodes.APP_ERROR_HANDLER */]: 'app errorHandler',
820
+ [11 /* ErrorCodes.APP_WARN_HANDLER */]: 'app warnHandler',
821
+ [12 /* ErrorCodes.FUNCTION_REF */]: 'ref function',
822
+ [13 /* ErrorCodes.ASYNC_COMPONENT_LOADER */]: 'async component loader',
823
+ [14 /* ErrorCodes.SCHEDULER */]: 'scheduler flush. This is likely a Vue internals bug. ' +
815
824
  'Please open an issue at https://new-issue.vuejs.org/?repo=vuejs/core'
816
825
  };
817
826
  function callWithErrorHandling(fn, instance, type, args) {
@@ -846,7 +855,7 @@ function handleError(err, instance, type, throwInDev = true) {
846
855
  // app-level handling
847
856
  const appErrorHandler = instance.appContext.config.errorHandler;
848
857
  if (appErrorHandler) {
849
- callWithErrorHandling(appErrorHandler, null, 10 /* APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
858
+ callWithErrorHandling(appErrorHandler, null, 10 /* ErrorCodes.APP_ERROR_HANDLER */, [err, exposedInstance, errorInfo]);
850
859
  return;
851
860
  }
852
861
  }
@@ -874,10 +883,10 @@ function logError(err, type, contextVNode, throwInDev = true) {
874
883
 
875
884
  const classifyRE = /(?:^|[-_])(\w)/g;
876
885
  const classify = (str) => str.replace(classifyRE, c => c.toUpperCase()).replace(/[-_]/g, '');
877
- function getComponentName(Component) {
886
+ function getComponentName(Component, includeInferred = true) {
878
887
  return shared.isFunction(Component)
879
888
  ? Component.displayName || Component.name
880
- : Component.name;
889
+ : Component.name || (includeInferred && Component.__name);
881
890
  }
882
891
  /* istanbul ignore next */
883
892
  function formatComponentName(instance, Component, isRoot = false) {
@@ -285,16 +285,16 @@ function renderVNode(push, vnode, parentComponent, slotScopeId) {
285
285
  push(`<!--]-->`); // close
286
286
  break;
287
287
  default:
288
- if (shapeFlag & 1 /* ELEMENT */) {
288
+ if (shapeFlag & 1 /* ShapeFlags.ELEMENT */) {
289
289
  renderElementVNode(push, vnode, parentComponent, slotScopeId);
290
290
  }
291
- else if (shapeFlag & 6 /* COMPONENT */) {
291
+ else if (shapeFlag & 6 /* ShapeFlags.COMPONENT */) {
292
292
  push(renderComponentVNode(vnode, parentComponent, slotScopeId));
293
293
  }
294
- else if (shapeFlag & 64 /* TELEPORT */) {
294
+ else if (shapeFlag & 64 /* ShapeFlags.TELEPORT */) {
295
295
  renderTeleportVNode(push, vnode, parentComponent, slotScopeId);
296
296
  }
297
- else if (shapeFlag & 128 /* SUSPENSE */) {
297
+ else if (shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
298
298
  renderVNode(push, vnode.ssContent, parentComponent, slotScopeId);
299
299
  }
300
300
  else {
@@ -351,10 +351,10 @@ function renderElementVNode(push, vnode, parentComponent, slotScopeId) {
351
351
  }
352
352
  }
353
353
  if (!hasChildrenOverride) {
354
- if (shapeFlag & 8 /* TEXT_CHILDREN */) {
354
+ if (shapeFlag & 8 /* ShapeFlags.TEXT_CHILDREN */) {
355
355
  push(shared.escapeHtml(children));
356
356
  }
357
- else if (shapeFlag & 16 /* ARRAY_CHILDREN */) {
357
+ else if (shapeFlag & 16 /* ShapeFlags.ARRAY_CHILDREN */) {
358
358
  renderVNodeChildren(push, children, parentComponent, slotScopeId);
359
359
  }
360
360
  }
@@ -451,7 +451,7 @@ async function resolveTeleports(context) {
451
451
  for (const key in context.__teleportBuffers) {
452
452
  // note: it's OK to await sequentially here because the Promises were
453
453
  // created eagerly in parallel.
454
- context.teleports[key] = await unrollBuffer((await Promise.all(context.__teleportBuffers[key])));
454
+ context.teleports[key] = await unrollBuffer(await Promise.all([context.__teleportBuffers[key]]));
455
455
  }
456
456
  }
457
457
  }
@@ -611,7 +611,7 @@ function ssrRenderSlot(slots, slotName, slotProps, fallbackRenderFn, push, paren
611
611
  ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId);
612
612
  push(`<!--]-->`);
613
613
  }
614
- function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId) {
614
+ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push, parentComponent, slotScopeId, transition) {
615
615
  const slotFn = slots[slotName];
616
616
  if (slotFn) {
617
617
  const slotBuffer = [];
@@ -627,10 +627,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
627
627
  // ssr slot.
628
628
  // check if the slot renders all comments, in which case use the fallback
629
629
  let isEmptySlot = true;
630
- for (let i = 0; i < slotBuffer.length; i++) {
631
- if (!isComment(slotBuffer[i])) {
632
- isEmptySlot = false;
633
- break;
630
+ if (transition) {
631
+ isEmptySlot = false;
632
+ }
633
+ else {
634
+ for (let i = 0; i < slotBuffer.length; i++) {
635
+ if (!isComment(slotBuffer[i])) {
636
+ isEmptySlot = false;
637
+ break;
638
+ }
634
639
  }
635
640
  }
636
641
  if (isEmptySlot) {
@@ -649,11 +654,15 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
649
654
  fallbackRenderFn();
650
655
  }
651
656
  }
657
+ const commentTestRE = /^<!--.*-->$/s;
652
658
  const commentRE = /<!--[^]*?-->/gm;
653
659
  function isComment(item) {
654
- return (typeof item === 'string' &&
655
- commentRE.test(item) &&
656
- !item.replace(commentRE, '').trim());
660
+ if (typeof item !== 'string' || !commentTestRE.test(item))
661
+ return false;
662
+ // if item is '<!---->' or '<!--[-->' or '<!--]-->', return true directly
663
+ if (item.length <= 8)
664
+ return true;
665
+ return !item.replace(commentRE, '').trim();
657
666
  }
658
667
 
659
668
  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