@vue/shared 3.3.4 → 3.3.5

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.
@@ -38,7 +38,7 @@ const isString = (val) => typeof val === "string";
38
38
  const isSymbol = (val) => typeof val === "symbol";
39
39
  const isObject = (val) => val !== null && typeof val === "object";
40
40
  const isPromise = (val) => {
41
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
41
+ return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
42
42
  };
43
43
  const objectToString = Object.prototype.toString;
44
44
  const toTypeString = (value) => objectToString.call(value);
@@ -69,12 +69,13 @@ const hyphenateRE = /\B([A-Z])/g;
69
69
  const hyphenate = cacheStringFunction(
70
70
  (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
71
71
  );
72
- const capitalize = cacheStringFunction(
73
- (str) => str.charAt(0).toUpperCase() + str.slice(1)
74
- );
75
- const toHandlerKey = cacheStringFunction(
76
- (str) => str ? `on${capitalize(str)}` : ``
77
- );
72
+ const capitalize = cacheStringFunction((str) => {
73
+ return str.charAt(0).toUpperCase() + str.slice(1);
74
+ });
75
+ const toHandlerKey = cacheStringFunction((str) => {
76
+ const s = str ? `on${capitalize(str)}` : ``;
77
+ return s;
78
+ });
78
79
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
79
80
  const invokeArrayFns = (fns, arg) => {
80
81
  for (let i = 0; i < fns.length; i++) {
@@ -128,8 +129,9 @@ const slotFlagsText = {
128
129
  [3]: "FORWARDED"
129
130
  };
130
131
 
131
- const GLOBALS_WHITE_LISTED = "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";
132
- const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
132
+ 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";
133
+ const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
134
+ const isGloballyWhitelisted = isGloballyAllowed;
133
135
 
134
136
  const range = 2;
135
137
  function generateCodeFrame(source, start = 0, end = source.length) {
@@ -184,9 +186,7 @@ function normalizeStyle(value) {
184
186
  }
185
187
  }
186
188
  return res;
187
- } else if (isString(value)) {
188
- return value;
189
- } else if (isObject(value)) {
189
+ } else if (isString(value) || isObject(value)) {
190
190
  return value;
191
191
  }
192
192
  }
@@ -433,6 +433,7 @@ exports.isBooleanAttr = isBooleanAttr;
433
433
  exports.isBuiltInDirective = isBuiltInDirective;
434
434
  exports.isDate = isDate;
435
435
  exports.isFunction = isFunction;
436
+ exports.isGloballyAllowed = isGloballyAllowed;
436
437
  exports.isGloballyWhitelisted = isGloballyWhitelisted;
437
438
  exports.isHTMLTag = isHTMLTag;
438
439
  exports.isIntegerKey = isIntegerKey;
@@ -38,7 +38,7 @@ const isString = (val) => typeof val === "string";
38
38
  const isSymbol = (val) => typeof val === "symbol";
39
39
  const isObject = (val) => val !== null && typeof val === "object";
40
40
  const isPromise = (val) => {
41
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
41
+ return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
42
42
  };
43
43
  const objectToString = Object.prototype.toString;
44
44
  const toTypeString = (value) => objectToString.call(value);
@@ -69,12 +69,13 @@ const hyphenateRE = /\B([A-Z])/g;
69
69
  const hyphenate = cacheStringFunction(
70
70
  (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
71
71
  );
72
- const capitalize = cacheStringFunction(
73
- (str) => str.charAt(0).toUpperCase() + str.slice(1)
74
- );
75
- const toHandlerKey = cacheStringFunction(
76
- (str) => str ? `on${capitalize(str)}` : ``
77
- );
72
+ const capitalize = cacheStringFunction((str) => {
73
+ return str.charAt(0).toUpperCase() + str.slice(1);
74
+ });
75
+ const toHandlerKey = cacheStringFunction((str) => {
76
+ const s = str ? `on${capitalize(str)}` : ``;
77
+ return s;
78
+ });
78
79
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
79
80
  const invokeArrayFns = (fns, arg) => {
80
81
  for (let i = 0; i < fns.length; i++) {
@@ -128,8 +129,9 @@ const slotFlagsText = {
128
129
  [3]: "FORWARDED"
129
130
  };
130
131
 
131
- const GLOBALS_WHITE_LISTED = "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";
132
- const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
132
+ 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";
133
+ const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
134
+ const isGloballyWhitelisted = isGloballyAllowed;
133
135
 
134
136
  const range = 2;
135
137
  function generateCodeFrame(source, start = 0, end = source.length) {
@@ -184,9 +186,7 @@ function normalizeStyle(value) {
184
186
  }
185
187
  }
186
188
  return res;
187
- } else if (isString(value)) {
188
- return value;
189
- } else if (isObject(value)) {
189
+ } else if (isString(value) || isObject(value)) {
190
190
  return value;
191
191
  }
192
192
  }
@@ -433,6 +433,7 @@ exports.isBooleanAttr = isBooleanAttr;
433
433
  exports.isBuiltInDirective = isBuiltInDirective;
434
434
  exports.isDate = isDate;
435
435
  exports.isFunction = isFunction;
436
+ exports.isGloballyAllowed = isGloballyAllowed;
436
437
  exports.isGloballyWhitelisted = isGloballyWhitelisted;
437
438
  exports.isHTMLTag = isHTMLTag;
438
439
  exports.isIntegerKey = isIntegerKey;
package/dist/shared.d.ts CHANGED
@@ -54,11 +54,11 @@ export declare const hyphenate: (str: string) => string;
54
54
  /**
55
55
  * @private
56
56
  */
57
- export declare const capitalize: (str: string) => string;
57
+ export declare const capitalize: <T extends string>(str: T) => Capitalize<T>;
58
58
  /**
59
59
  * @private
60
60
  */
61
- export declare const toHandlerKey: (str: string) => string;
61
+ export declare const toHandlerKey: <T extends string>(str: T) => T extends "" ? "" : `on${Capitalize<T>}`;
62
62
  export declare const hasChanged: (value: any, oldValue: any) => boolean;
63
63
  export declare const invokeArrayFns: (fns: Function[], arg?: any) => void;
64
64
  export declare const def: (obj: object, key: string | symbol, value: any) => void;
@@ -68,7 +68,7 @@ export declare const def: (obj: object, key: string | symbol, value: any) => voi
68
68
  */
69
69
  export declare const looseToNumber: (val: any) => any;
70
70
  /**
71
- * Only conerces number-like strings
71
+ * Only concerns number-like strings
72
72
  * "123-foo" will be returned as-is
73
73
  */
74
74
  export declare const toNumber: (val: any) => any;
@@ -234,6 +234,8 @@ export declare const slotFlagsText: {
234
234
  3: string;
235
235
  };
236
236
 
237
+ export declare const isGloballyAllowed: (key: string) => boolean;
238
+ /** @deprecated use `isGloballyAllowed` instead */
237
239
  export declare const isGloballyWhitelisted: (key: string) => boolean;
238
240
 
239
241
  export declare function generateCodeFrame(source: string, start?: number, end?: number): string;
@@ -305,4 +307,7 @@ export type LooseRequired<T> = {
305
307
  [P in keyof (T & Required<T>)]: T[P];
306
308
  };
307
309
  export type IfAny<T, Y, N> = 0 extends 1 & T ? Y : N;
310
+ export type Awaited<T> = T extends null | undefined ? T : T extends object & {
311
+ then(onfulfilled: infer F, ...args: infer _): any;
312
+ } ? F extends (value: infer V, ...args: infer _) => any ? Awaited<V> : never : T;
308
313
 
@@ -34,7 +34,7 @@ const isString = (val) => typeof val === "string";
34
34
  const isSymbol = (val) => typeof val === "symbol";
35
35
  const isObject = (val) => val !== null && typeof val === "object";
36
36
  const isPromise = (val) => {
37
- return isObject(val) && isFunction(val.then) && isFunction(val.catch);
37
+ return (isObject(val) || isFunction(val)) && isFunction(val.then) && isFunction(val.catch);
38
38
  };
39
39
  const objectToString = Object.prototype.toString;
40
40
  const toTypeString = (value) => objectToString.call(value);
@@ -65,12 +65,13 @@ const hyphenateRE = /\B([A-Z])/g;
65
65
  const hyphenate = cacheStringFunction(
66
66
  (str) => str.replace(hyphenateRE, "-$1").toLowerCase()
67
67
  );
68
- const capitalize = cacheStringFunction(
69
- (str) => str.charAt(0).toUpperCase() + str.slice(1)
70
- );
71
- const toHandlerKey = cacheStringFunction(
72
- (str) => str ? `on${capitalize(str)}` : ``
73
- );
68
+ const capitalize = cacheStringFunction((str) => {
69
+ return str.charAt(0).toUpperCase() + str.slice(1);
70
+ });
71
+ const toHandlerKey = cacheStringFunction((str) => {
72
+ const s = str ? `on${capitalize(str)}` : ``;
73
+ return s;
74
+ });
74
75
  const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
75
76
  const invokeArrayFns = (fns, arg) => {
76
77
  for (let i = 0; i < fns.length; i++) {
@@ -124,8 +125,9 @@ const slotFlagsText = {
124
125
  [3]: "FORWARDED"
125
126
  };
126
127
 
127
- const GLOBALS_WHITE_LISTED = "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";
128
- const isGloballyWhitelisted = /* @__PURE__ */ makeMap(GLOBALS_WHITE_LISTED);
128
+ 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";
129
+ const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
130
+ const isGloballyWhitelisted = isGloballyAllowed;
129
131
 
130
132
  const range = 2;
131
133
  function generateCodeFrame(source, start = 0, end = source.length) {
@@ -180,9 +182,7 @@ function normalizeStyle(value) {
180
182
  }
181
183
  }
182
184
  return res;
183
- } else if (isString(value)) {
184
- return value;
185
- } else if (isObject(value)) {
185
+ } else if (isString(value) || isObject(value)) {
186
186
  return value;
187
187
  }
188
188
  }
@@ -405,4 +405,4 @@ const replacer = (_key, val) => {
405
405
  return val;
406
406
  };
407
407
 
408
- export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, genPropsAccessExp, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isBooleanAttr, isBuiltInDirective, isDate, isFunction, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener, isObject, isOn, isPlainObject, isPromise, isRegExp, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, looseToNumber, makeMap, normalizeClass, normalizeProps, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
408
+ export { EMPTY_ARR, EMPTY_OBJ, NO, NOOP, PatchFlagNames, camelize, capitalize, def, escapeHtml, escapeHtmlComment, extend, genPropsAccessExp, generateCodeFrame, getGlobalThis, hasChanged, hasOwn, hyphenate, includeBooleanAttr, invokeArrayFns, isArray, isBooleanAttr, isBuiltInDirective, isDate, isFunction, isGloballyAllowed, isGloballyWhitelisted, isHTMLTag, isIntegerKey, isKnownHtmlAttr, isKnownSvgAttr, isMap, isModelListener, isObject, isOn, isPlainObject, isPromise, isRegExp, isReservedProp, isSSRSafeAttrName, isSVGTag, isSet, isSpecialBooleanAttr, isString, isSymbol, isVoidTag, looseEqual, looseIndexOf, looseToNumber, makeMap, normalizeClass, normalizeProps, normalizeStyle, objectToString, parseStringStyle, propsToAttrMap, remove, slotFlagsText, stringifyStyle, toDisplayString, toHandlerKey, toNumber, toRawType, toTypeString };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/shared",
3
- "version": "3.3.4",
3
+ "version": "3.3.5",
4
4
  "description": "internal utils shared across @vue packages",
5
5
  "main": "index.js",
6
6
  "module": "dist/shared.esm-bundler.js",