@vue/shared 3.6.0-rc.8 → 3.6.0-rc.9

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.6.0-rc.8
2
+ * @vue/shared v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -315,10 +315,10 @@ function normalizeStyle(value) {
315
315
  }
316
316
  const listDelimiterRE = /;(?![^(]*\))/g;
317
317
  const propertyDelimiterRE = /:([^]+)/;
318
- const styleCommentRE = /\/\*[^]*?\*\//g;
318
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
319
319
  function parseStringStyle(cssText) {
320
320
  const ret = {};
321
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
321
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
322
322
  if (item) {
323
323
  const tmp = item.split(propertyDelimiterRE);
324
324
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -541,19 +541,19 @@ function getEscapedCssVarName(key, doubleEscape) {
541
541
  }
542
542
  //#endregion
543
543
  //#region packages/shared/src/looseEqual.ts
544
- function looseCompareArrays(a, b) {
544
+ function looseCompareArrays(a, b, seen) {
545
545
  if (a.length !== b.length) return false;
546
546
  let equal = true;
547
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
547
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
548
548
  return equal;
549
549
  }
550
- function looseCompareCollections(a, b) {
550
+ function looseCompareCollections(a, b, seen) {
551
551
  if (a.size !== b.size) return false;
552
552
  const candidates = Array.from(b);
553
553
  const matched = new Uint8Array(candidates.length);
554
554
  for (const item of a) {
555
555
  let index = -1;
556
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
556
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
557
557
  index = i;
558
558
  break;
559
559
  }
@@ -562,7 +562,33 @@ function looseCompareCollections(a, b) {
562
562
  }
563
563
  return true;
564
564
  }
565
- function looseEqual(a, b) {
565
+ function looseCompareObjects(a, b, seen) {
566
+ let aValidType = isMap(a);
567
+ let bValidType = isMap(b);
568
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
569
+ aValidType = isSet(a);
570
+ bValidType = isSet(b);
571
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
572
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
573
+ for (const key in a) {
574
+ const aHasKey = a.hasOwnProperty(key);
575
+ const bHasKey = b.hasOwnProperty(key);
576
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
577
+ }
578
+ return String(a) === String(b);
579
+ }
580
+ function looseCompareNested(a, b, seen, compare) {
581
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
582
+ const [seenA, seenB] = seen;
583
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
584
+ seenA.set(a, b);
585
+ seenB.set(b, a);
586
+ const equal = compare(a, b, seen);
587
+ seenA.delete(a);
588
+ seenB.delete(b);
589
+ return equal;
590
+ }
591
+ function looseEqual(a, b, seen) {
566
592
  if (a === b) return true;
567
593
  let aValidType = isDate(a);
568
594
  let bValidType = isDate(b);
@@ -572,23 +598,12 @@ function looseEqual(a, b) {
572
598
  if (aValidType || bValidType) return a === b;
573
599
  aValidType = isArray(a);
574
600
  bValidType = isArray(b);
575
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
601
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
576
602
  aValidType = isObject(a);
577
603
  bValidType = isObject(b);
578
604
  if (aValidType || bValidType) {
579
605
  if (!aValidType || !bValidType) return false;
580
- aValidType = isMap(a);
581
- bValidType = isMap(b);
582
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
583
- aValidType = isSet(a);
584
- bValidType = isSet(b);
585
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
586
- if (Object.keys(a).length !== Object.keys(b).length) return false;
587
- for (const key in a) {
588
- const aHasKey = a.hasOwnProperty(key);
589
- const bHasKey = b.hasOwnProperty(key);
590
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
591
- }
606
+ return looseCompareNested(a, b, seen, looseCompareObjects);
592
607
  }
593
608
  return String(a) === String(b);
594
609
  }
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.6.0-rc.8
2
+ * @vue/shared v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -315,10 +315,10 @@ function normalizeStyle(value) {
315
315
  }
316
316
  const listDelimiterRE = /;(?![^(]*\))/g;
317
317
  const propertyDelimiterRE = /:([^]+)/;
318
- const styleCommentRE = /\/\*[^]*?\*\//g;
318
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
319
319
  function parseStringStyle(cssText) {
320
320
  const ret = {};
321
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
321
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
322
322
  if (item) {
323
323
  const tmp = item.split(propertyDelimiterRE);
324
324
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -541,19 +541,19 @@ function getEscapedCssVarName(key, doubleEscape) {
541
541
  }
542
542
  //#endregion
543
543
  //#region packages/shared/src/looseEqual.ts
544
- function looseCompareArrays(a, b) {
544
+ function looseCompareArrays(a, b, seen) {
545
545
  if (a.length !== b.length) return false;
546
546
  let equal = true;
547
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
547
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
548
548
  return equal;
549
549
  }
550
- function looseCompareCollections(a, b) {
550
+ function looseCompareCollections(a, b, seen) {
551
551
  if (a.size !== b.size) return false;
552
552
  const candidates = Array.from(b);
553
553
  const matched = new Uint8Array(candidates.length);
554
554
  for (const item of a) {
555
555
  let index = -1;
556
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
556
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
557
557
  index = i;
558
558
  break;
559
559
  }
@@ -562,7 +562,33 @@ function looseCompareCollections(a, b) {
562
562
  }
563
563
  return true;
564
564
  }
565
- function looseEqual(a, b) {
565
+ function looseCompareObjects(a, b, seen) {
566
+ let aValidType = isMap(a);
567
+ let bValidType = isMap(b);
568
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
569
+ aValidType = isSet(a);
570
+ bValidType = isSet(b);
571
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
572
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
573
+ for (const key in a) {
574
+ const aHasKey = a.hasOwnProperty(key);
575
+ const bHasKey = b.hasOwnProperty(key);
576
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
577
+ }
578
+ return String(a) === String(b);
579
+ }
580
+ function looseCompareNested(a, b, seen, compare) {
581
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
582
+ const [seenA, seenB] = seen;
583
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
584
+ seenA.set(a, b);
585
+ seenB.set(b, a);
586
+ const equal = compare(a, b, seen);
587
+ seenA.delete(a);
588
+ seenB.delete(b);
589
+ return equal;
590
+ }
591
+ function looseEqual(a, b, seen) {
566
592
  if (a === b) return true;
567
593
  let aValidType = isDate(a);
568
594
  let bValidType = isDate(b);
@@ -572,23 +598,12 @@ function looseEqual(a, b) {
572
598
  if (aValidType || bValidType) return a === b;
573
599
  aValidType = isArray(a);
574
600
  bValidType = isArray(b);
575
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
601
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
576
602
  aValidType = isObject(a);
577
603
  bValidType = isObject(b);
578
604
  if (aValidType || bValidType) {
579
605
  if (!aValidType || !bValidType) return false;
580
- aValidType = isMap(a);
581
- bValidType = isMap(b);
582
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
583
- aValidType = isSet(a);
584
- bValidType = isSet(b);
585
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
586
- if (Object.keys(a).length !== Object.keys(b).length) return false;
587
- for (const key in a) {
588
- const aHasKey = a.hasOwnProperty(key);
589
- const bHasKey = b.hasOwnProperty(key);
590
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
591
- }
606
+ return looseCompareNested(a, b, seen, looseCompareObjects);
592
607
  }
593
608
  return String(a) === String(b);
594
609
  }
package/dist/shared.d.ts CHANGED
@@ -353,7 +353,8 @@ export declare const cssVarNameEscapeSymbolsRE: RegExp;
353
353
  export declare function getEscapedCssVarName(key: string, doubleEscape: boolean): string;
354
354
  //#endregion
355
355
  //#region temp/packages/shared/src/looseEqual.d.ts
356
- export declare function looseEqual(a: any, b: any): boolean;
356
+ type ComparisonState = [Map<any, any>, Map<any, any>];
357
+ export declare function looseEqual(a: any, b: any, seen?: ComparisonState): boolean;
357
358
  export declare function looseIndexOf(arr: any[], val: any): number;
358
359
  //#endregion
359
360
  //#region temp/packages/shared/src/toDisplayString.d.ts
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @vue/shared v3.6.0-rc.8
2
+ * @vue/shared v3.6.0-rc.9
3
3
  * (c) 2018-present Yuxi (Evan) You and Vue contributors
4
4
  * @license MIT
5
5
  **/
@@ -311,10 +311,10 @@ function normalizeStyle(value) {
311
311
  }
312
312
  const listDelimiterRE = /;(?![^(]*\))/g;
313
313
  const propertyDelimiterRE = /:([^]+)/;
314
- const styleCommentRE = /\/\*[^]*?\*\//g;
314
+ const styleCommentRE = /"(?:[^"\\]|\\[^])*"|'(?:[^'\\]|\\[^])*'|\\[^]|\/\*[^]*?\*\//g;
315
315
  function parseStringStyle(cssText) {
316
316
  const ret = {};
317
- cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
317
+ cssText.replace(styleCommentRE, (match) => match.startsWith("/*") ? "" : match).split(listDelimiterRE).forEach((item) => {
318
318
  if (item) {
319
319
  const tmp = item.split(propertyDelimiterRE);
320
320
  tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
@@ -537,19 +537,19 @@ function getEscapedCssVarName(key, doubleEscape) {
537
537
  }
538
538
  //#endregion
539
539
  //#region packages/shared/src/looseEqual.ts
540
- function looseCompareArrays(a, b) {
540
+ function looseCompareArrays(a, b, seen) {
541
541
  if (a.length !== b.length) return false;
542
542
  let equal = true;
543
- for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i]);
543
+ for (let i = 0; equal && i < a.length; i++) equal = looseEqual(a[i], b[i], seen);
544
544
  return equal;
545
545
  }
546
- function looseCompareCollections(a, b) {
546
+ function looseCompareCollections(a, b, seen) {
547
547
  if (a.size !== b.size) return false;
548
548
  const candidates = Array.from(b);
549
549
  const matched = new Uint8Array(candidates.length);
550
550
  for (const item of a) {
551
551
  let index = -1;
552
- for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i])) {
552
+ for (let i = 0; i < candidates.length; i++) if (!matched[i] && looseEqual(item, candidates[i], seen)) {
553
553
  index = i;
554
554
  break;
555
555
  }
@@ -558,7 +558,33 @@ function looseCompareCollections(a, b) {
558
558
  }
559
559
  return true;
560
560
  }
561
- function looseEqual(a, b) {
561
+ function looseCompareObjects(a, b, seen) {
562
+ let aValidType = isMap(a);
563
+ let bValidType = isMap(b);
564
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
565
+ aValidType = isSet(a);
566
+ bValidType = isSet(b);
567
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b, seen) : false;
568
+ if (Object.keys(a).length !== Object.keys(b).length) return false;
569
+ for (const key in a) {
570
+ const aHasKey = a.hasOwnProperty(key);
571
+ const bHasKey = b.hasOwnProperty(key);
572
+ if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key], seen)) return false;
573
+ }
574
+ return String(a) === String(b);
575
+ }
576
+ function looseCompareNested(a, b, seen, compare) {
577
+ if (!seen) seen = [/* @__PURE__ */ new Map(), /* @__PURE__ */ new Map()];
578
+ const [seenA, seenB] = seen;
579
+ if (seenA.has(a) || seenB.has(b)) return seenA.get(a) === b && seenB.get(b) === a;
580
+ seenA.set(a, b);
581
+ seenB.set(b, a);
582
+ const equal = compare(a, b, seen);
583
+ seenA.delete(a);
584
+ seenB.delete(b);
585
+ return equal;
586
+ }
587
+ function looseEqual(a, b, seen) {
562
588
  if (a === b) return true;
563
589
  let aValidType = isDate(a);
564
590
  let bValidType = isDate(b);
@@ -568,23 +594,12 @@ function looseEqual(a, b) {
568
594
  if (aValidType || bValidType) return a === b;
569
595
  aValidType = isArray(a);
570
596
  bValidType = isArray(b);
571
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareArrays(a, b) : false;
597
+ if (aValidType || bValidType) return aValidType && bValidType ? looseCompareNested(a, b, seen, looseCompareArrays) : false;
572
598
  aValidType = isObject(a);
573
599
  bValidType = isObject(b);
574
600
  if (aValidType || bValidType) {
575
601
  if (!aValidType || !bValidType) return false;
576
- aValidType = isMap(a);
577
- bValidType = isMap(b);
578
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
579
- aValidType = isSet(a);
580
- bValidType = isSet(b);
581
- if (aValidType || bValidType) return aValidType && bValidType ? looseCompareCollections(a, b) : false;
582
- if (Object.keys(a).length !== Object.keys(b).length) return false;
583
- for (const key in a) {
584
- const aHasKey = a.hasOwnProperty(key);
585
- const bHasKey = b.hasOwnProperty(key);
586
- if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) return false;
587
- }
602
+ return looseCompareNested(a, b, seen, looseCompareObjects);
588
603
  }
589
604
  return String(a) === String(b);
590
605
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue/shared",
3
- "version": "3.6.0-rc.8",
3
+ "version": "3.6.0-rc.9",
4
4
  "description": "internal utils shared across @vue packages",
5
5
  "main": "index.js",
6
6
  "module": "dist/shared.esm-bundler.js",