@vue/server-renderer 3.5.39 → 3.5.41

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.39
2
+ * @vue/server-renderer v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -7,7 +7,7 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- var Vue = require('vue');
10
+ var Vue = require('@vue/runtime-dom');
11
11
  var shared = require('@vue/shared');
12
12
  var compilerSsr = require('@vue/compiler-ssr');
13
13
 
@@ -55,7 +55,7 @@ function ssrRenderDynamicAttr(key, value, tag) {
55
55
  return ``;
56
56
  }
57
57
  const attrKey = tag && (tag.indexOf("-") > 0 || shared.isSVGTag(tag)) ? key : shared.propsToAttrMap[key] || key.toLowerCase();
58
- if (shared.isBooleanAttr(attrKey)) {
58
+ if (shared.isBooleanAttr(attrKey) || attrKey === "hidden" && (typeof value === "boolean" || typeof value === "number")) {
59
59
  return shared.includeBooleanAttr(value) ? ` ${attrKey}` : ``;
60
60
  } else if (shared.isSSRSafeAttrName(attrKey)) {
61
61
  return value === "" ? ` ${attrKey}` : ` ${attrKey}="${shared.escapeHtml(value)}"`;
@@ -130,7 +130,9 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
130
130
  slotBuffer.push(item);
131
131
  };
132
132
  const ret = slotFn(
133
- slotProps,
133
+ // keep the slot function's contract in sync with `renderSlot`, which also
134
+ // normalizes nullish props before invoking the slot
135
+ slotProps || {},
134
136
  bufferedPush,
135
137
  parentComponent,
136
138
  slotScopeId ? " " + slotScopeId : ""
@@ -223,265 +225,6 @@ function ssrInterpolate(value) {
223
225
  return shared.escapeHtml(shared.toDisplayString(value));
224
226
  }
225
227
 
226
- // @__NO_SIDE_EFFECTS__
227
- function toRaw(observed) {
228
- const raw = observed && observed["__v_raw"];
229
- return raw ? /* @__PURE__ */ toRaw(raw) : observed;
230
- }
231
-
232
- // @__NO_SIDE_EFFECTS__
233
- function isRef(r) {
234
- return r ? r["__v_isRef"] === true : false;
235
- }
236
-
237
- const stack = [];
238
- function pushWarningContext$1(vnode) {
239
- stack.push(vnode);
240
- }
241
- function popWarningContext$1() {
242
- stack.pop();
243
- }
244
- let isWarning = false;
245
- function warn$1(msg, ...args) {
246
- if (isWarning) return;
247
- isWarning = true;
248
- const instance = stack.length ? stack[stack.length - 1].component : null;
249
- const appWarnHandler = instance && instance.appContext.config.warnHandler;
250
- const trace = getComponentTrace();
251
- if (appWarnHandler) {
252
- callWithErrorHandling(
253
- appWarnHandler,
254
- instance,
255
- 11,
256
- [
257
- // eslint-disable-next-line no-restricted-syntax
258
- msg + args.map((a) => {
259
- var _a, _b;
260
- return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
261
- }).join(""),
262
- instance && instance.proxy,
263
- trace.map(
264
- ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
265
- ).join("\n"),
266
- trace
267
- ]
268
- );
269
- } else {
270
- const warnArgs = [`[Vue warn]: ${msg}`, ...args];
271
- if (trace.length && // avoid spamming console during tests
272
- true) {
273
- warnArgs.push(`
274
- `, ...formatTrace(trace));
275
- }
276
- console.warn(...warnArgs);
277
- }
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 (shared.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 (shared.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
-
348
- const ErrorTypeStrings = {
349
- ["sp"]: "serverPrefetch hook",
350
- ["bc"]: "beforeCreate hook",
351
- ["c"]: "created hook",
352
- ["bm"]: "beforeMount hook",
353
- ["m"]: "mounted hook",
354
- ["bu"]: "beforeUpdate hook",
355
- ["u"]: "updated",
356
- ["bum"]: "beforeUnmount hook",
357
- ["um"]: "unmounted hook",
358
- ["a"]: "activated hook",
359
- ["da"]: "deactivated hook",
360
- ["ec"]: "errorCaptured hook",
361
- ["rtc"]: "renderTracked hook",
362
- ["rtg"]: "renderTriggered hook",
363
- [0]: "setup function",
364
- [1]: "render function",
365
- [2]: "watcher getter",
366
- [3]: "watcher callback",
367
- [4]: "watcher cleanup function",
368
- [5]: "native event handler",
369
- [6]: "component event handler",
370
- [7]: "vnode hook",
371
- [8]: "directive hook",
372
- [9]: "transition hook",
373
- [10]: "app errorHandler",
374
- [11]: "app warnHandler",
375
- [12]: "ref function",
376
- [13]: "async component loader",
377
- [14]: "scheduler flush",
378
- [15]: "component update",
379
- [16]: "app unmount cleanup function"
380
- };
381
- function callWithErrorHandling(fn, instance, type, args) {
382
- try {
383
- return args ? fn(...args) : fn();
384
- } catch (err) {
385
- handleError(err, instance, type);
386
- }
387
- }
388
- function handleError(err, instance, type, throwInDev = true) {
389
- const contextVNode = instance ? instance.vnode : null;
390
- const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || shared.EMPTY_OBJ;
391
- if (instance) {
392
- let cur = instance.parent;
393
- const exposedInstance = instance.proxy;
394
- const errorInfo = ErrorTypeStrings[type] ;
395
- while (cur) {
396
- const errorCapturedHooks = cur.ec;
397
- if (errorCapturedHooks) {
398
- for (let i = 0; i < errorCapturedHooks.length; i++) {
399
- if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
400
- return;
401
- }
402
- }
403
- }
404
- cur = cur.parent;
405
- }
406
- if (errorHandler) {
407
- callWithErrorHandling(errorHandler, null, 10, [
408
- err,
409
- exposedInstance,
410
- errorInfo
411
- ]);
412
- return;
413
- }
414
- }
415
- logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
416
- }
417
- function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
418
- {
419
- const info = ErrorTypeStrings[type];
420
- if (contextVNode) {
421
- pushWarningContext$1(contextVNode);
422
- }
423
- warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
424
- if (contextVNode) {
425
- popWarningContext$1();
426
- }
427
- if (throwInDev) {
428
- throw err;
429
- } else {
430
- console.error(err);
431
- }
432
- }
433
- }
434
-
435
- {
436
- const g = shared.getGlobalThis();
437
- const registerGlobalSetter = (key, setter) => {
438
- let setters;
439
- if (!(setters = g[key])) setters = g[key] = [];
440
- setters.push(setter);
441
- return (v) => {
442
- if (setters.length > 1) setters.forEach((set) => set(v));
443
- else setters[0](v);
444
- };
445
- };
446
- registerGlobalSetter(
447
- `__VUE_INSTANCE_SETTERS__`,
448
- (v) => v
449
- );
450
- registerGlobalSetter(
451
- `__VUE_SSR_SETTERS__`,
452
- (v) => v
453
- );
454
- }
455
- const classifyRE = /(?:^|[-_])\w/g;
456
- const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
457
- function getComponentName(Component, includeInferred = true) {
458
- return shared.isFunction(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
459
- }
460
- function formatComponentName(instance, Component, isRoot = false) {
461
- let name = getComponentName(Component);
462
- if (!name && Component.__file) {
463
- const match = Component.__file.match(/([^/\\]+)\.\w+$/);
464
- if (match) {
465
- name = match[1];
466
- }
467
- }
468
- if (!name && instance) {
469
- const inferFromRegistry = (registry) => {
470
- for (const key in registry) {
471
- if (registry[key] === Component) {
472
- return key;
473
- }
474
- }
475
- };
476
- name = inferFromRegistry(instance.components) || instance.parent && inferFromRegistry(
477
- instance.parent.type.components
478
- ) || inferFromRegistry(instance.appContext.components);
479
- }
480
- return name ? classify(name) : isRoot ? `App` : `Anonymous`;
481
- }
482
-
483
- const warn = warn$1 ;
484
-
485
228
  function ssrRenderList(source, renderItem) {
486
229
  if (shared.isArray(source) || shared.isString(source)) {
487
230
  for (let i = 0, l = source.length; i < l; i++) {
@@ -489,7 +232,7 @@ function ssrRenderList(source, renderItem) {
489
232
  }
490
233
  } else if (typeof source === "number") {
491
234
  if (!Number.isInteger(source) || source < 0) {
492
- warn(
235
+ Vue.warn(
493
236
  `The v-for range expects a positive integer value but got ${source}.`
494
237
  );
495
238
  return;
@@ -694,7 +437,11 @@ function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
694
437
  }).catch(shared.NOOP);
695
438
  return p.then(() => renderComponentSubTree(instance, slotScopeId));
696
439
  } else {
697
- return renderComponentSubTree(instance, slotScopeId);
440
+ try {
441
+ return renderComponentSubTree(instance, slotScopeId);
442
+ } catch (err) {
443
+ return Promise.reject(err);
444
+ }
698
445
  }
699
446
  }
700
447
  function renderComponentSubTree(instance, slotScopeId) {
@@ -756,6 +503,8 @@ function renderComponentSubTree(instance, slotScopeId) {
756
503
  instance.data,
757
504
  instance.ctx
758
505
  );
506
+ } catch (err) {
507
+ Vue.handleError(err, instance, 1);
759
508
  } finally {
760
509
  setCurrentRenderingInstance(prev);
761
510
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/server-renderer v3.5.39
2
+ * @vue/server-renderer v3.5.41
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -7,7 +7,7 @@
7
7
 
8
8
  Object.defineProperty(exports, '__esModule', { value: true });
9
9
 
10
- var Vue = require('vue');
10
+ var Vue = require('@vue/runtime-dom');
11
11
  var shared = require('@vue/shared');
12
12
  var compilerSsr = require('@vue/compiler-ssr');
13
13
 
@@ -55,7 +55,7 @@ function ssrRenderDynamicAttr(key, value, tag) {
55
55
  return ``;
56
56
  }
57
57
  const attrKey = tag && (tag.indexOf("-") > 0 || shared.isSVGTag(tag)) ? key : shared.propsToAttrMap[key] || key.toLowerCase();
58
- if (shared.isBooleanAttr(attrKey)) {
58
+ if (shared.isBooleanAttr(attrKey) || attrKey === "hidden" && (typeof value === "boolean" || typeof value === "number")) {
59
59
  return shared.includeBooleanAttr(value) ? ` ${attrKey}` : ``;
60
60
  } else if (shared.isSSRSafeAttrName(attrKey)) {
61
61
  return value === "" ? ` ${attrKey}` : ` ${attrKey}="${shared.escapeHtml(value)}"`;
@@ -130,7 +130,9 @@ function ssrRenderSlotInner(slots, slotName, slotProps, fallbackRenderFn, push,
130
130
  slotBuffer.push(item);
131
131
  };
132
132
  const ret = slotFn(
133
- slotProps,
133
+ // keep the slot function's contract in sync with `renderSlot`, which also
134
+ // normalizes nullish props before invoking the slot
135
+ slotProps || {},
134
136
  bufferedPush,
135
137
  parentComponent,
136
138
  slotScopeId ? " " + slotScopeId : ""
@@ -420,7 +422,11 @@ function renderComponentVNode(vnode, parentComponent = null, slotScopeId) {
420
422
  }).catch(shared.NOOP);
421
423
  return p.then(() => renderComponentSubTree(instance, slotScopeId));
422
424
  } else {
423
- return renderComponentSubTree(instance, slotScopeId);
425
+ try {
426
+ return renderComponentSubTree(instance, slotScopeId);
427
+ } catch (err) {
428
+ return Promise.reject(err);
429
+ }
424
430
  }
425
431
  }
426
432
  function renderComponentSubTree(instance, slotScopeId) {
@@ -481,6 +487,8 @@ function renderComponentSubTree(instance, slotScopeId) {
481
487
  instance.data,
482
488
  instance.ctx
483
489
  );
490
+ } catch (err) {
491
+ Vue.handleError(err, instance, 1);
484
492
  } finally {
485
493
  setCurrentRenderingInstance(prev);
486
494
  }
@@ -1,4 +1,4 @@
1
- import { VNode, ComponentInternalInstance, App, Slots, Component, ComponentPublicInstance, Directive } from 'vue';
1
+ import { VNode, ComponentInternalInstance, App, Slots, Component, ComponentPublicInstance, Directive } from '@vue/runtime-dom';
2
2
  import { Writable, Readable } from 'node:stream';
3
3
  export { includeBooleanAttr as ssrIncludeBooleanAttr } from '@vue/shared';
4
4
 
@@ -32,8 +32,8 @@ export declare function pipeToWebWritable(input: App | VNode, context: SSRContex
32
32
 
33
33
  type SSRSlots = Record<string, SSRSlot>;
34
34
  type SSRSlot = (props: Props, push: PushFn, parentComponent: ComponentInternalInstance | null, scopeId: string | null) => void;
35
- export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
36
- export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
35
+ export declare function ssrRenderSlot(slots: Slots | SSRSlots, slotName: string, slotProps: Props | null | undefined, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string): void;
36
+ export declare function ssrRenderSlotInner(slots: Slots | SSRSlots, slotName: string, slotProps: Props | null | undefined, fallbackRenderFn: (() => void) | null, push: PushFn, parentComponent: ComponentInternalInstance, slotScopeId?: string, transition?: boolean): void;
37
37
 
38
38
  export declare function ssrRenderComponent(comp: Component, props?: Props | null, children?: Slots | SSRSlots | null, parentComponent?: ComponentInternalInstance | null, slotScopeId?: string): SSRBuffer | Promise<SSRBuffer>;
39
39
 
@@ -56,7 +56,7 @@ export declare function ssrGetDirectiveProps(instance: ComponentPublicInstance,
56
56
  export declare const ssrLooseEqual: (a: unknown, b: unknown) => boolean;
57
57
  export declare function ssrLooseContain(arr: unknown[], value: unknown): boolean;
58
58
  export declare function ssrRenderDynamicModel(type: unknown, model: unknown, value: unknown): string;
59
- export declare function ssrGetDynamicModelProps(existingProps: any, model: unknown): {
59
+ export declare function ssrGetDynamicModelProps(existingProps: any | undefined, model: unknown): {
60
60
  checked: true;
61
61
  } | {
62
62
  value: any;