@vue/shared 3.5.0-alpha.2 → 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/shared v3.5.0-alpha.2
2
+ * @vue/shared v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -80,9 +80,9 @@ const toHandlerKey = cacheStringFunction((str) => {
80
80
  return s;
81
81
  });
82
82
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
83
- const invokeArrayFns = (fns, arg) => {
83
+ const invokeArrayFns = (fns, ...arg) => {
84
84
  for (let i = 0; i < fns.length; i++) {
85
- fns[i](arg);
85
+ fns[i](...arg);
86
86
  }
87
87
  };
88
88
  const def = (obj, key, value, writable = false) => {
@@ -135,8 +135,8 @@ const PatchFlags = {
135
135
  "1024": "DYNAMIC_SLOTS",
136
136
  "DEV_ROOT_FRAGMENT": 2048,
137
137
  "2048": "DEV_ROOT_FRAGMENT",
138
- "HOISTED": -1,
139
- "-1": "HOISTED",
138
+ "CACHED": -1,
139
+ "-1": "CACHED",
140
140
  "BAIL": -2,
141
141
  "-2": "BAIL"
142
142
  };
@@ -196,12 +196,15 @@ const slotFlagsText = {
196
196
  [3]: "FORWARDED"
197
197
  };
198
198
 
199
- const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
199
+ const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
200
200
  const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
201
201
  const isGloballyWhitelisted = isGloballyAllowed;
202
202
 
203
203
  const range = 2;
204
204
  function generateCodeFrame(source, start = 0, end = source.length) {
205
+ start = Math.max(0, Math.min(start, source.length));
206
+ end = Math.max(0, Math.min(end, source.length));
207
+ if (start > end) return "";
205
208
  let lines = source.split(/(\r?\n)/);
206
209
  const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
207
210
  lines = lines.filter((_, idx) => idx % 2 === 0);
@@ -211,8 +214,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
211
214
  count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
212
215
  if (count >= start) {
213
216
  for (let j = i - range; j <= i + range || end > count; j++) {
214
- if (j < 0 || j >= lines.length)
215
- continue;
217
+ if (j < 0 || j >= lines.length) continue;
216
218
  const line = j + 1;
217
219
  res.push(
218
220
  `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
@@ -277,8 +279,8 @@ function stringifyStyle(styles) {
277
279
  }
278
280
  for (const key in styles) {
279
281
  const value = styles[key];
280
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
281
282
  if (isString(value) || typeof value === "number") {
283
+ const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
282
284
  ret += `${normalizedKey}:${value};`;
283
285
  }
284
286
  }
@@ -305,8 +307,7 @@ function normalizeClass(value) {
305
307
  return res.trim();
306
308
  }
307
309
  function normalizeProps(props) {
308
- if (!props)
309
- return null;
310
+ if (!props) return null;
310
311
  let { class: klass, style } = props;
311
312
  if (klass && !isString(klass)) {
312
313
  props.class = normalizeClass(klass);
@@ -411,8 +412,7 @@ function escapeHtmlComment(src) {
411
412
  }
412
413
 
413
414
  function looseCompareArrays(a, b) {
414
- if (a.length !== b.length)
415
- return false;
415
+ if (a.length !== b.length) return false;
416
416
  let equal = true;
417
417
  for (let i = 0; equal && i < a.length; i++) {
418
418
  equal = looseEqual(a[i], b[i]);
@@ -420,8 +420,7 @@ function looseCompareArrays(a, b) {
420
420
  return equal;
421
421
  }
422
422
  function looseEqual(a, b) {
423
- if (a === b)
424
- return true;
423
+ if (a === b) return true;
425
424
  let aValidType = isDate(a);
426
425
  let bValidType = isDate(b);
427
426
  if (aValidType || bValidType) {
@@ -462,11 +461,14 @@ function looseIndexOf(arr, val) {
462
461
  return arr.findIndex((item) => looseEqual(item, val));
463
462
  }
464
463
 
464
+ const isRef = (val) => {
465
+ return !!(val && val["__v_isRef"] === true);
466
+ };
465
467
  const toDisplayString = (val) => {
466
- return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
468
+ return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
467
469
  };
468
470
  const replacer = (_key, val) => {
469
- if (val && val.__v_isRef) {
471
+ if (isRef(val)) {
470
472
  return replacer(_key, val.value);
471
473
  } else if (isMap(val)) {
472
474
  return {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.5.0-alpha.2
2
+ * @vue/shared v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -80,9 +80,9 @@ const toHandlerKey = cacheStringFunction((str) => {
80
80
  return s;
81
81
  });
82
82
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
83
- const invokeArrayFns = (fns, arg) => {
83
+ const invokeArrayFns = (fns, ...arg) => {
84
84
  for (let i = 0; i < fns.length; i++) {
85
- fns[i](arg);
85
+ fns[i](...arg);
86
86
  }
87
87
  };
88
88
  const def = (obj, key, value, writable = false) => {
@@ -135,8 +135,8 @@ const PatchFlags = {
135
135
  "1024": "DYNAMIC_SLOTS",
136
136
  "DEV_ROOT_FRAGMENT": 2048,
137
137
  "2048": "DEV_ROOT_FRAGMENT",
138
- "HOISTED": -1,
139
- "-1": "HOISTED",
138
+ "CACHED": -1,
139
+ "-1": "CACHED",
140
140
  "BAIL": -2,
141
141
  "-2": "BAIL"
142
142
  };
@@ -196,12 +196,15 @@ const slotFlagsText = {
196
196
  [3]: "FORWARDED"
197
197
  };
198
198
 
199
- const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
199
+ const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
200
200
  const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
201
201
  const isGloballyWhitelisted = isGloballyAllowed;
202
202
 
203
203
  const range = 2;
204
204
  function generateCodeFrame(source, start = 0, end = source.length) {
205
+ start = Math.max(0, Math.min(start, source.length));
206
+ end = Math.max(0, Math.min(end, source.length));
207
+ if (start > end) return "";
205
208
  let lines = source.split(/(\r?\n)/);
206
209
  const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
207
210
  lines = lines.filter((_, idx) => idx % 2 === 0);
@@ -211,8 +214,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
211
214
  count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
212
215
  if (count >= start) {
213
216
  for (let j = i - range; j <= i + range || end > count; j++) {
214
- if (j < 0 || j >= lines.length)
215
- continue;
217
+ if (j < 0 || j >= lines.length) continue;
216
218
  const line = j + 1;
217
219
  res.push(
218
220
  `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
@@ -277,8 +279,8 @@ function stringifyStyle(styles) {
277
279
  }
278
280
  for (const key in styles) {
279
281
  const value = styles[key];
280
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
281
282
  if (isString(value) || typeof value === "number") {
283
+ const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
282
284
  ret += `${normalizedKey}:${value};`;
283
285
  }
284
286
  }
@@ -305,8 +307,7 @@ function normalizeClass(value) {
305
307
  return res.trim();
306
308
  }
307
309
  function normalizeProps(props) {
308
- if (!props)
309
- return null;
310
+ if (!props) return null;
310
311
  let { class: klass, style } = props;
311
312
  if (klass && !isString(klass)) {
312
313
  props.class = normalizeClass(klass);
@@ -411,8 +412,7 @@ function escapeHtmlComment(src) {
411
412
  }
412
413
 
413
414
  function looseCompareArrays(a, b) {
414
- if (a.length !== b.length)
415
- return false;
415
+ if (a.length !== b.length) return false;
416
416
  let equal = true;
417
417
  for (let i = 0; equal && i < a.length; i++) {
418
418
  equal = looseEqual(a[i], b[i]);
@@ -420,8 +420,7 @@ function looseCompareArrays(a, b) {
420
420
  return equal;
421
421
  }
422
422
  function looseEqual(a, b) {
423
- if (a === b)
424
- return true;
423
+ if (a === b) return true;
425
424
  let aValidType = isDate(a);
426
425
  let bValidType = isDate(b);
427
426
  if (aValidType || bValidType) {
@@ -462,11 +461,14 @@ function looseIndexOf(arr, val) {
462
461
  return arr.findIndex((item) => looseEqual(item, val));
463
462
  }
464
463
 
464
+ const isRef = (val) => {
465
+ return !!(val && val["__v_isRef"] === true);
466
+ };
465
467
  const toDisplayString = (val) => {
466
- return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
468
+ return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
467
469
  };
468
470
  const replacer = (_key, val) => {
469
- if (val && val.__v_isRef) {
471
+ if (isRef(val)) {
470
472
  return replacer(_key, val.value);
471
473
  } else if (isMap(val)) {
472
474
  return {
package/dist/shared.d.ts CHANGED
@@ -61,7 +61,7 @@ export declare const capitalize: <T extends string>(str: T) => Capitalize<T>;
61
61
  */
62
62
  export declare const toHandlerKey: <T extends string>(str: T) => T extends "" ? "" : `on${Capitalize<T>}`;
63
63
  export declare const hasChanged: (value: any, oldValue: any) => boolean;
64
- export declare const invokeArrayFns: (fns: Function[], arg?: any) => void;
64
+ export declare const invokeArrayFns: (fns: Function[], ...arg: any[]) => void;
65
65
  export declare const def: (obj: object, key: string | symbol, value: any, writable?: boolean) => void;
66
66
  /**
67
67
  * "123-foo" will be parsed to 123
@@ -174,10 +174,10 @@ export declare enum PatchFlags {
174
174
  * flag, simply check patchFlag === FLAG.
175
175
  */
176
176
  /**
177
- * Indicates a hoisted static vnode. This is a hint for hydration to skip
177
+ * Indicates a cached static vnode. This is also a hint for hydration to skip
178
178
  * the entire sub tree since static content never needs to be updated.
179
179
  */
180
- HOISTED = -1,
180
+ CACHED = -1,
181
181
  /**
182
182
  * A special flag that indicates that the diffing algorithm should bail out
183
183
  * of optimized mode. For example, on block fragments created by renderSlot()
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.5.0-alpha.2
2
+ * @vue/shared v3.5.0-alpha.3
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -76,9 +76,9 @@ const toHandlerKey = cacheStringFunction((str) => {
76
76
  return s;
77
77
  });
78
78
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
79
- const invokeArrayFns = (fns, arg) => {
79
+ const invokeArrayFns = (fns, ...arg) => {
80
80
  for (let i = 0; i < fns.length; i++) {
81
- fns[i](arg);
81
+ fns[i](...arg);
82
82
  }
83
83
  };
84
84
  const def = (obj, key, value, writable = false) => {
@@ -131,8 +131,8 @@ const PatchFlags = {
131
131
  "1024": "DYNAMIC_SLOTS",
132
132
  "DEV_ROOT_FRAGMENT": 2048,
133
133
  "2048": "DEV_ROOT_FRAGMENT",
134
- "HOISTED": -1,
135
- "-1": "HOISTED",
134
+ "CACHED": -1,
135
+ "-1": "CACHED",
136
136
  "BAIL": -2,
137
137
  "-2": "BAIL"
138
138
  };
@@ -192,12 +192,15 @@ const slotFlagsText = {
192
192
  [3]: "FORWARDED"
193
193
  };
194
194
 
195
- const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error";
195
+ const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
196
196
  const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
197
197
  const isGloballyWhitelisted = isGloballyAllowed;
198
198
 
199
199
  const range = 2;
200
200
  function generateCodeFrame(source, start = 0, end = source.length) {
201
+ start = Math.max(0, Math.min(start, source.length));
202
+ end = Math.max(0, Math.min(end, source.length));
203
+ if (start > end) return "";
201
204
  let lines = source.split(/(\r?\n)/);
202
205
  const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
203
206
  lines = lines.filter((_, idx) => idx % 2 === 0);
@@ -207,8 +210,7 @@ function generateCodeFrame(source, start = 0, end = source.length) {
207
210
  count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
208
211
  if (count >= start) {
209
212
  for (let j = i - range; j <= i + range || end > count; j++) {
210
- if (j < 0 || j >= lines.length)
211
- continue;
213
+ if (j < 0 || j >= lines.length) continue;
212
214
  const line = j + 1;
213
215
  res.push(
214
216
  `${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
@@ -273,8 +275,8 @@ function stringifyStyle(styles) {
273
275
  }
274
276
  for (const key in styles) {
275
277
  const value = styles[key];
276
- const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
277
278
  if (isString(value) || typeof value === "number") {
279
+ const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
278
280
  ret += `${normalizedKey}:${value};`;
279
281
  }
280
282
  }
@@ -301,8 +303,7 @@ function normalizeClass(value) {
301
303
  return res.trim();
302
304
  }
303
305
  function normalizeProps(props) {
304
- if (!props)
305
- return null;
306
+ if (!props) return null;
306
307
  let { class: klass, style } = props;
307
308
  if (klass && !isString(klass)) {
308
309
  props.class = normalizeClass(klass);
@@ -407,8 +408,7 @@ function escapeHtmlComment(src) {
407
408
  }
408
409
 
409
410
  function looseCompareArrays(a, b) {
410
- if (a.length !== b.length)
411
- return false;
411
+ if (a.length !== b.length) return false;
412
412
  let equal = true;
413
413
  for (let i = 0; equal && i < a.length; i++) {
414
414
  equal = looseEqual(a[i], b[i]);
@@ -416,8 +416,7 @@ function looseCompareArrays(a, b) {
416
416
  return equal;
417
417
  }
418
418
  function looseEqual(a, b) {
419
- if (a === b)
420
- return true;
419
+ if (a === b) return true;
421
420
  let aValidType = isDate(a);
422
421
  let bValidType = isDate(b);
423
422
  if (aValidType || bValidType) {
@@ -458,11 +457,14 @@ function looseIndexOf(arr, val) {
458
457
  return arr.findIndex((item) => looseEqual(item, val));
459
458
  }
460
459
 
460
+ const isRef = (val) => {
461
+ return !!(val && val["__v_isRef"] === true);
462
+ };
461
463
  const toDisplayString = (val) => {
462
- return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? JSON.stringify(val, replacer, 2) : String(val);
464
+ return isString(val) ? val : val == null ? "" : isArray(val) || isObject(val) && (val.toString === objectToString || !isFunction(val.toString)) ? isRef(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
463
465
  };
464
466
  const replacer = (_key, val) => {
465
- if (val && val.__v_isRef) {
467
+ if (isRef(val)) {
466
468
  return replacer(_key, val.value);
467
469
  } else if (isMap(val)) {
468
470
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/shared",
3
- "version": "3.5.0-alpha.2",
3
+ "version": "3.5.0-alpha.3",
4
4
  "description": "internal utils shared across @vue packages",
5
5
  "main": "index.js",
6
6
  "module": "dist/shared.esm-bundler.js",