@vue/server-renderer 3.5.0-alpha.1 → 3.5.0-alpha.3

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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/server-renderer v3.5.0-alpha.1
2
+ * @vue/server-renderer v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -148,13 +148,11 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
148
148
  fallbackRenderFn();
149
149
  }
150
150
  }
151
- const commentTestRE = /^<!--.*-->$/s;
151
+ const commentTestRE = /^<!--[\s\S]*-->$/;
152
152
  const commentRE = /<!--[^]*?-->/gm;
153
153
  function isComment(item) {
154
- if (typeof item !== "string" || !commentTestRE.test(item))
155
- return false;
156
- if (item.length <= 8)
157
- return true;
154
+ if (typeof item !== "string" || !commentTestRE.test(item)) return false;
155
+ if (item.length <= 8) return true;
158
156
  return !item.replace(commentRE, "").trim();
159
157
  }
160
158
 
@@ -188,7 +186,7 @@ function toRaw(observed) {
188
186
  }
189
187
 
190
188
  function isRef(r) {
191
- return r ? r.__v_isRef === true : false;
189
+ return r ? r["__v_isRef"] === true : false;
192
190
  }
193
191
 
194
192
  const stack = [];
@@ -198,7 +196,10 @@ function pushWarningContext(vnode) {
198
196
  function popWarningContext() {
199
197
  stack.pop();
200
198
  }
199
+ let isWarning = false;
201
200
  function warn$1(msg, ...args) {
201
+ if (isWarning) return;
202
+ isWarning = true;
202
203
  const instance = stack.length ? stack[stack.length - 1].component : null;
203
204
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
204
205
  const trace = getComponentTrace();
@@ -208,6 +209,7 @@ function warn$1(msg, ...args) {
208
209
  instance,
209
210
  11,
210
211
  [
212
+ // eslint-disable-next-line no-restricted-syntax
211
213
  msg + args.map((a) => {
212
214
  var _a, _b;
213
215
  return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
@@ -228,6 +230,7 @@ function warn$1(msg, ...args) {
228
230
  }
229
231
  console.warn(...warnArgs);
230
232
  }
233
+ isWarning = false;
231
234
  }
232
235
  function getComponentTrace() {
233
236
  let currentVNode = stack[stack.length - 1];
@@ -326,7 +329,9 @@ const ErrorTypeStrings = {
326
329
  [11]: "app warnHandler",
327
330
  [12]: "ref function",
328
331
  [13]: "async component loader",
329
- [14]: "scheduler flush. This is likely a Vue internals bug. Please open an issue at https://github.com/vuejs/core ."
332
+ [14]: "scheduler flush",
333
+ [15]: "component update",
334
+ [16]: "app unmount cleanup function"
330
335
  };
331
336
  function callWithErrorHandling(fn, instance, type, args) {
332
337
  try {
@@ -337,6 +342,7 @@ function callWithErrorHandling(fn, instance, type, args) {
337
342
  }
338
343
  function handleError(err, instance, type, throwInDev = true) {
339
344
  const contextVNode = instance ? instance.vnode : null;
345
+ const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || shared.EMPTY_OBJ;
340
346
  if (instance) {
341
347
  let cur = instance.parent;
342
348
  const exposedInstance = instance.proxy;
@@ -352,20 +358,18 @@ function handleError(err, instance, type, throwInDev = true) {
352
358
  }
353
359
  cur = cur.parent;
354
360
  }
355
- const appErrorHandler = instance.appContext.config.errorHandler;
356
- if (appErrorHandler) {
357
- callWithErrorHandling(
358
- appErrorHandler,
359
- null,
360
- 10,
361
- [err, exposedInstance, errorInfo]
362
- );
361
+ if (errorHandler) {
362
+ callWithErrorHandling(errorHandler, null, 10, [
363
+ err,
364
+ exposedInstance,
365
+ errorInfo
366
+ ]);
363
367
  return;
364
368
  }
365
369
  }
366
- logError(err, type, contextVNode, throwInDev);
370
+ logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
367
371
  }
368
- function logError(err, type, contextVNode, throwInDev = true) {
372
+ function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
369
373
  {
370
374
  const info = ErrorTypeStrings[type];
371
375
  if (contextVNode) {
@@ -387,14 +391,11 @@ function logError(err, type, contextVNode, throwInDev = true) {
387
391
  const g = shared.getGlobalThis();
388
392
  const registerGlobalSetter = (key, setter) => {
389
393
  let setters;
390
- if (!(setters = g[key]))
391
- setters = g[key] = [];
394
+ if (!(setters = g[key])) setters = g[key] = [];
392
395
  setters.push(setter);
393
396
  return (v) => {
394
- if (setters.length > 1)
395
- setters.forEach((set) => set(v));
396
- else
397
- setters[0](v);
397
+ if (setters.length > 1) setters.forEach((set) => set(v));
398
+ else setters[0](v);
398
399
  };
399
400
  };
400
401
  registerGlobalSetter(
@@ -478,7 +479,7 @@ function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
478
479
  return dir.getSSRProps(
479
480
  {
480
481
  dir,
481
- instance,
482
+ instance: Vue.ssrUtils.getComponentPublicInstance(instance.$),
482
483
  value,
483
484
  oldValue: void 0,
484
485
  arg,
@@ -608,9 +609,9 @@ function createBuffer() {
608
609
  const isStringItem = shared.isString(item);
609
610
  if (appendable && isStringItem) {
610
611
  buffer[buffer.length - 1] += item;
611
- } else {
612
- buffer.push(item);
612
+ return;
613
613
  }
614
+ buffer.push(item);
614
615
  appendable = isStringItem;
615
616
  if (shared.isPromise(item) || shared.isArray(item) && item.hasAsync) {
616
617
  buffer.hasAsync = true;
@@ -680,9 +681,11 @@ function renderComponentSubTree(instance, slotScopeId) {
680
681
  }
681
682
  }
682
683
  if (slotScopeId) {
683
- if (!hasCloned)
684
- attrs = { ...attrs };
685
- attrs[slotScopeId.trim()] = "";
684
+ if (!hasCloned) attrs = { ...attrs };
685
+ const slotScopeIdList = slotScopeId.trim().split(" ");
686
+ for (let i = 0; i < slotScopeIdList.length; i++) {
687
+ attrs[slotScopeIdList[i]] = "";
688
+ }
686
689
  }
687
690
  const prev = setCurrentRenderingInstance(instance);
688
691
  try {
@@ -829,8 +832,7 @@ function applySSRDirectives(vnode, rawProps, dirs) {
829
832
  } = binding;
830
833
  if (getSSRProps) {
831
834
  const props = getSSRProps(binding, vnode);
832
- if (props)
833
- toMerge.push(props);
835
+ if (props) toMerge.push(props);
834
836
  }
835
837
  }
836
838
  return Vue.mergeProps(rawProps || {}, ...toMerge);
@@ -867,24 +869,36 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
867
869
  }
868
870
 
869
871
  const { isVNode: isVNode$1 } = Vue.ssrUtils;
870
- async function unrollBuffer$1(buffer) {
871
- if (buffer.hasAsync) {
872
- let ret = "";
873
- for (let i = 0; i < buffer.length; i++) {
874
- let item = buffer[i];
875
- if (shared.isPromise(item)) {
876
- item = await item;
877
- }
878
- if (shared.isString(item)) {
879
- ret += item;
880
- } else {
881
- ret += await unrollBuffer$1(item);
882
- }
872
+ function nestedUnrollBuffer(buffer, parentRet, startIndex) {
873
+ if (!buffer.hasAsync) {
874
+ return parentRet + unrollBufferSync$1(buffer);
875
+ }
876
+ let ret = parentRet;
877
+ for (let i = startIndex; i < buffer.length; i += 1) {
878
+ const item = buffer[i];
879
+ if (shared.isString(item)) {
880
+ ret += item;
881
+ continue;
883
882
  }
884
- return ret;
885
- } else {
886
- return unrollBufferSync$1(buffer);
883
+ if (shared.isPromise(item)) {
884
+ return item.then((nestedItem) => {
885
+ buffer[i] = nestedItem;
886
+ return nestedUnrollBuffer(buffer, ret, i);
887
+ });
888
+ }
889
+ const result = nestedUnrollBuffer(item, ret, 0);
890
+ if (shared.isPromise(result)) {
891
+ return result.then((nestedItem) => {
892
+ buffer[i] = nestedItem;
893
+ return nestedUnrollBuffer(buffer, "", i);
894
+ });
895
+ }
896
+ ret = result;
887
897
  }
898
+ return ret;
899
+ }
900
+ function unrollBuffer$1(buffer) {
901
+ return nestedUnrollBuffer(buffer, "", 0);
888
902
  }
889
903
  function unrollBufferSync$1(buffer) {
890
904
  let ret = "";
@@ -1018,8 +1032,7 @@ function renderToWebStream(input, context = {}) {
1018
1032
  start(controller) {
1019
1033
  renderToSimpleStream(input, context, {
1020
1034
  push(content) {
1021
- if (cancelled)
1022
- return;
1035
+ if (cancelled) return;
1023
1036
  if (content != null) {
1024
1037
  controller.enqueue(encoder.encode(content));
1025
1038
  } else {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/server-renderer v3.5.0-alpha.1
2
+ * @vue/server-renderer v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -148,13 +148,11 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
148
148
  fallbackRenderFn();
149
149
  }
150
150
  }
151
- const commentTestRE = /^<!--.*-->$/s;
151
+ const commentTestRE = /^<!--[\s\S]*-->$/;
152
152
  const commentRE = /<!--[^]*?-->/gm;
153
153
  function isComment(item) {
154
- if (typeof item !== "string" || !commentTestRE.test(item))
155
- return false;
156
- if (item.length <= 8)
157
- return true;
154
+ if (typeof item !== "string" || !commentTestRE.test(item)) return false;
155
+ if (item.length <= 8) return true;
158
156
  return !item.replace(commentRE, "").trim();
159
157
  }
160
158
 
@@ -220,7 +218,7 @@ function ssrGetDirectiveProps(instance, dir, value, arg, modifiers = {}) {
220
218
  return dir.getSSRProps(
221
219
  {
222
220
  dir,
223
- instance,
221
+ instance: Vue.ssrUtils.getComponentPublicInstance(instance.$),
224
222
  value,
225
223
  oldValue: void 0,
226
224
  arg,
@@ -343,9 +341,9 @@ function createBuffer() {
343
341
  const isStringItem = shared.isString(item);
344
342
  if (appendable && isStringItem) {
345
343
  buffer[buffer.length - 1] += item;
346
- } else {
347
- buffer.push(item);
344
+ return;
348
345
  }
346
+ buffer.push(item);
349
347
  appendable = isStringItem;
350
348
  if (shared.isPromise(item) || shared.isArray(item) && item.hasAsync) {
351
349
  buffer.hasAsync = true;
@@ -415,9 +413,11 @@ function renderComponentSubTree(instance, slotScopeId) {
415
413
  }
416
414
  }
417
415
  if (slotScopeId) {
418
- if (!hasCloned)
419
- attrs = { ...attrs };
420
- attrs[slotScopeId.trim()] = "";
416
+ if (!hasCloned) attrs = { ...attrs };
417
+ const slotScopeIdList = slotScopeId.trim().split(" ");
418
+ for (let i = 0; i < slotScopeIdList.length; i++) {
419
+ attrs[slotScopeIdList[i]] = "";
420
+ }
421
421
  }
422
422
  const prev = setCurrentRenderingInstance(instance);
423
423
  try {
@@ -564,8 +564,7 @@ function applySSRDirectives(vnode, rawProps, dirs) {
564
564
  } = binding;
565
565
  if (getSSRProps) {
566
566
  const props = getSSRProps(binding, vnode);
567
- if (props)
568
- toMerge.push(props);
567
+ if (props) toMerge.push(props);
569
568
  }
570
569
  }
571
570
  return Vue.mergeProps(rawProps || {}, ...toMerge);
@@ -602,24 +601,36 @@ function renderTeleportVNode(push, vnode, parentComponent, slotScopeId) {
602
601
  }
603
602
 
604
603
  const { isVNode: isVNode$1 } = Vue.ssrUtils;
605
- async function unrollBuffer$1(buffer) {
606
- if (buffer.hasAsync) {
607
- let ret = "";
608
- for (let i = 0; i < buffer.length; i++) {
609
- let item = buffer[i];
610
- if (shared.isPromise(item)) {
611
- item = await item;
612
- }
613
- if (shared.isString(item)) {
614
- ret += item;
615
- } else {
616
- ret += await unrollBuffer$1(item);
617
- }
604
+ function nestedUnrollBuffer(buffer, parentRet, startIndex) {
605
+ if (!buffer.hasAsync) {
606
+ return parentRet + unrollBufferSync$1(buffer);
607
+ }
608
+ let ret = parentRet;
609
+ for (let i = startIndex; i < buffer.length; i += 1) {
610
+ const item = buffer[i];
611
+ if (shared.isString(item)) {
612
+ ret += item;
613
+ continue;
618
614
  }
619
- return ret;
620
- } else {
621
- return unrollBufferSync$1(buffer);
615
+ if (shared.isPromise(item)) {
616
+ return item.then((nestedItem) => {
617
+ buffer[i] = nestedItem;
618
+ return nestedUnrollBuffer(buffer, ret, i);
619
+ });
620
+ }
621
+ const result = nestedUnrollBuffer(item, ret, 0);
622
+ if (shared.isPromise(result)) {
623
+ return result.then((nestedItem) => {
624
+ buffer[i] = nestedItem;
625
+ return nestedUnrollBuffer(buffer, "", i);
626
+ });
627
+ }
628
+ ret = result;
622
629
  }
630
+ return ret;
631
+ }
632
+ function unrollBuffer$1(buffer) {
633
+ return nestedUnrollBuffer(buffer, "", 0);
623
634
  }
624
635
  function unrollBufferSync$1(buffer) {
625
636
  let ret = "";
@@ -753,8 +764,7 @@ function renderToWebStream(input, context = {}) {
753
764
  start(controller) {
754
765
  renderToSimpleStream(input, context, {
755
766
  push(content) {
756
- if (cancelled)
757
- return;
767
+ if (cancelled) return;
758
768
  if (content != null) {
759
769
  controller.enqueue(encoder.encode(content));
760
770
  } else {
@@ -1,7 +1,6 @@
1
1
  /// <reference types="node" />
2
- import { VNode, ComponentInternalInstance, App, Slots, Component } from 'vue';
2
+ import { VNode, ComponentInternalInstance, App, Slots, Component, ComponentPublicInstance, Directive } from 'vue';
3
3
  import { Readable, Writable } from 'node:stream';
4
- import { ComponentPublicInstance, Directive } from '@vue/runtime-core';
5
4
  export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
6
5
 
7
6
  type SSRBuffer = SSRBufferItem[] & {