@vue/server-renderer 3.5.17 → 3.6.0-alpha.1

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.17
2
+ * @vue/server-renderer v3.6.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -78,9 +78,23 @@ function ssrRenderStyle(raw) {
78
78
  if (shared.isString(raw)) {
79
79
  return shared.escapeHtml(raw);
80
80
  }
81
- const styles = shared.normalizeStyle(raw);
81
+ const styles = shared.normalizeStyle(ssrResetCssVars(raw));
82
82
  return shared.escapeHtml(shared.stringifyStyle(styles));
83
83
  }
84
+ function ssrResetCssVars(raw) {
85
+ if (!shared.isArray(raw) && shared.isObject(raw)) {
86
+ const res = {};
87
+ for (const key in raw) {
88
+ if (key.startsWith(":--")) {
89
+ res[key.slice(1)] = shared.normalizeCssVarValue(raw[key]);
90
+ } else {
91
+ res[key] = raw[key];
92
+ }
93
+ }
94
+ return res;
95
+ }
96
+ return raw;
97
+ }
84
98
 
85
99
  function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
86
100
  return renderComponentVNode(
@@ -194,6 +208,15 @@ function ssrInterpolate(value) {
194
208
  return shared.escapeHtml(shared.toDisplayString(value));
195
209
  }
196
210
 
211
+ let activeSub = void 0;
212
+ function setActiveSub(sub) {
213
+ try {
214
+ return activeSub;
215
+ } finally {
216
+ activeSub = sub;
217
+ }
218
+ }
219
+
197
220
  function toRaw(observed) {
198
221
  const raw = observed && observed["__v_raw"];
199
222
  return raw ? toRaw(raw) : observed;
@@ -204,8 +227,8 @@ function isRef(r) {
204
227
  }
205
228
 
206
229
  const stack = [];
207
- function pushWarningContext$1(vnode) {
208
- stack.push(vnode);
230
+ function pushWarningContext$1(ctx) {
231
+ stack.push(ctx);
209
232
  }
210
233
  function popWarningContext$1() {
211
234
  stack.pop();
@@ -214,7 +237,9 @@ let isWarning = false;
214
237
  function warn$1(msg, ...args) {
215
238
  if (isWarning) return;
216
239
  isWarning = true;
217
- const instance = stack.length ? stack[stack.length - 1].component : null;
240
+ const prevSub = setActiveSub();
241
+ const entry = stack.length ? stack[stack.length - 1] : null;
242
+ const instance = isVNode$2(entry) ? entry.component : entry;
218
243
  const appWarnHandler = instance && instance.appContext.config.warnHandler;
219
244
  const trace = getComponentTrace();
220
245
  if (appWarnHandler) {
@@ -228,9 +253,9 @@ function warn$1(msg, ...args) {
228
253
  var _a, _b;
229
254
  return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
230
255
  }).join(""),
231
- instance && instance.proxy,
256
+ instance && instance.proxy || instance,
232
257
  trace.map(
233
- ({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
258
+ ({ ctx }) => `at <${formatComponentName(instance, ctx.type)}>`
234
259
  ).join("\n"),
235
260
  trace
236
261
  ]
@@ -244,26 +269,31 @@ function warn$1(msg, ...args) {
244
269
  }
245
270
  console.warn(...warnArgs);
246
271
  }
272
+ setActiveSub(prevSub);
247
273
  isWarning = false;
248
274
  }
249
275
  function getComponentTrace() {
250
- let currentVNode = stack[stack.length - 1];
251
- if (!currentVNode) {
276
+ let currentCtx = stack[stack.length - 1];
277
+ if (!currentCtx) {
252
278
  return [];
253
279
  }
254
280
  const normalizedStack = [];
255
- while (currentVNode) {
281
+ while (currentCtx) {
256
282
  const last = normalizedStack[0];
257
- if (last && last.vnode === currentVNode) {
283
+ if (last && last.ctx === currentCtx) {
258
284
  last.recurseCount++;
259
285
  } else {
260
286
  normalizedStack.push({
261
- vnode: currentVNode,
287
+ ctx: currentCtx,
262
288
  recurseCount: 0
263
289
  });
264
290
  }
265
- const parentInstance = currentVNode.component && currentVNode.component.parent;
266
- currentVNode = parentInstance && parentInstance.vnode;
291
+ if (isVNode$2(currentCtx)) {
292
+ const parent = currentCtx.component && currentCtx.component.parent;
293
+ currentCtx = parent && parent.vnode || parent;
294
+ } else {
295
+ currentCtx = currentCtx.parent;
296
+ }
267
297
  }
268
298
  return normalizedStack;
269
299
  }
@@ -275,16 +305,13 @@ function formatTrace(trace) {
275
305
  });
276
306
  return logs;
277
307
  }
278
- function formatTraceEntry({ vnode, recurseCount }) {
308
+ function formatTraceEntry({ ctx, recurseCount }) {
279
309
  const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
280
- const isRoot = vnode.component ? vnode.component.parent == null : false;
281
- const open = ` at <${formatComponentName(
282
- vnode.component,
283
- vnode.type,
284
- isRoot
285
- )}`;
310
+ const instance = isVNode$2(ctx) ? ctx.component : ctx;
311
+ const isRoot = instance ? instance.parent == null : false;
312
+ const open = ` at <${formatComponentName(instance, ctx.type, isRoot)}`;
286
313
  const close = `>` + postfix;
287
- return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
314
+ return ctx.props ? [open, ...formatProps(ctx.props), close] : [open + close];
288
315
  }
289
316
  function formatProps(props) {
290
317
  const res = [];
@@ -355,11 +382,10 @@ function callWithErrorHandling(fn, instance, type, args) {
355
382
  }
356
383
  }
357
384
  function handleError(err, instance, type, throwInDev = true) {
358
- const contextVNode = instance ? instance.vnode : null;
359
385
  const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || shared.EMPTY_OBJ;
360
386
  if (instance) {
361
387
  let cur = instance.parent;
362
- const exposedInstance = instance.proxy;
388
+ const exposedInstance = instance.proxy || instance;
363
389
  const errorInfo = ErrorTypeStrings[type] ;
364
390
  while (cur) {
365
391
  const errorCapturedHooks = cur.ec;
@@ -373,24 +399,26 @@ function handleError(err, instance, type, throwInDev = true) {
373
399
  cur = cur.parent;
374
400
  }
375
401
  if (errorHandler) {
402
+ const prevSub = setActiveSub();
376
403
  callWithErrorHandling(errorHandler, null, 10, [
377
404
  err,
378
405
  exposedInstance,
379
406
  errorInfo
380
407
  ]);
408
+ setActiveSub(prevSub);
381
409
  return;
382
410
  }
383
411
  }
384
- logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
412
+ logError(err, type, instance, throwInDev, throwUnhandledErrorInProduction);
385
413
  }
386
- function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
414
+ function logError(err, type, instance, throwInDev = true, throwInProd = false) {
387
415
  {
388
416
  const info = ErrorTypeStrings[type];
389
- if (contextVNode) {
390
- pushWarningContext$1(contextVNode);
417
+ if (instance) {
418
+ pushWarningContext$1(instance);
391
419
  }
392
420
  warn$1(`Unhandled error${info ? ` during execution of ${info}` : ``}`);
393
- if (contextVNode) {
421
+ if (instance) {
394
422
  popWarningContext$1();
395
423
  }
396
424
  if (throwInDev) {
@@ -401,26 +429,10 @@ function logError(err, type, contextVNode, throwInDev = true, throwInProd = fals
401
429
  }
402
430
  }
403
431
 
404
- {
405
- const g = shared.getGlobalThis();
406
- const registerGlobalSetter = (key, setter) => {
407
- let setters;
408
- if (!(setters = g[key])) setters = g[key] = [];
409
- setters.push(setter);
410
- return (v) => {
411
- if (setters.length > 1) setters.forEach((set) => set(v));
412
- else setters[0](v);
413
- };
414
- };
415
- registerGlobalSetter(
416
- `__VUE_INSTANCE_SETTERS__`,
417
- (v) => v
418
- );
419
- registerGlobalSetter(
420
- `__VUE_SSR_SETTERS__`,
421
- (v) => v
422
- );
432
+ function isVNode$2(value) {
433
+ return value ? value.__v_isVNode === true : false;
423
434
  }
435
+
424
436
  const classifyRE = /(?:^|[-_])(\w)/g;
425
437
  const classify = (str) => str.replace(classifyRE, (c) => c.toUpperCase()).replace(/[-_]/g, "");
426
438
  function getComponentName(Component, includeInferred = true) {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/server-renderer v3.5.17
2
+ * @vue/server-renderer v3.6.0-alpha.1
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -78,9 +78,23 @@ function ssrRenderStyle(raw) {
78
78
  if (shared.isString(raw)) {
79
79
  return shared.escapeHtml(raw);
80
80
  }
81
- const styles = shared.normalizeStyle(raw);
81
+ const styles = shared.normalizeStyle(ssrResetCssVars(raw));
82
82
  return shared.escapeHtml(shared.stringifyStyle(styles));
83
83
  }
84
+ function ssrResetCssVars(raw) {
85
+ if (!shared.isArray(raw) && shared.isObject(raw)) {
86
+ const res = {};
87
+ for (const key in raw) {
88
+ if (key.startsWith(":--")) {
89
+ res[key.slice(1)] = shared.normalizeCssVarValue(raw[key]);
90
+ } else {
91
+ res[key] = raw[key];
92
+ }
93
+ }
94
+ return res;
95
+ }
96
+ return raw;
97
+ }
84
98
 
85
99
  function ssrRenderComponent(comp, props = null, children = null, parentComponent = null, slotScopeId) {
86
100
  return renderComponentVNode(