clava 0.6.2 → 0.6.4
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.
- package/CHANGELOG.md +26 -0
- package/README.md +32 -11
- package/dist/index.d.ts +1 -1
- package/dist/index.js +586 -547
- package/dist/index.js.map +1 -1
- package/package.json +8 -7
- package/src/index.ts +1111 -1021
- package/src/refine-warning.ts +9 -5
- package/src/utils.ts +14 -0
package/src/refine-warning.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { hasOwn } from "./utils.ts";
|
|
1
|
+
import { getOwn, hasOwn } from "./utils.ts";
|
|
2
2
|
|
|
3
3
|
export interface CreationFrame {
|
|
4
4
|
stack?: string;
|
|
@@ -36,8 +36,8 @@ export function captureCreationFrame(
|
|
|
36
36
|
// Engines without `Error.captureStackTrace` (SpiderMonkey, JavaScriptCore)
|
|
37
37
|
// can't strip internal frames, but their `Error.stack` getter is still
|
|
38
38
|
// lazy, so returning the Error instance defers the format cost. The
|
|
39
|
-
// resulting trace includes
|
|
40
|
-
// `cv` itself.
|
|
39
|
+
// resulting trace includes extra frames from this helper, `buildComponent`,
|
|
40
|
+
// and `cv` itself.
|
|
41
41
|
return new Error();
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -68,6 +68,9 @@ export function formatCreationStack(frame: CreationFrame): string | undefined {
|
|
|
68
68
|
|
|
69
69
|
function isInternalCreationFrame(line: string): boolean {
|
|
70
70
|
if (line.includes("captureCreationFrame")) return true;
|
|
71
|
+
if (line.startsWith("at buildComponent ")) return true;
|
|
72
|
+
if (line.startsWith("at buildComponent(")) return true;
|
|
73
|
+
if (line.startsWith("buildComponent@")) return true;
|
|
71
74
|
if (line.startsWith("at cv ")) return true;
|
|
72
75
|
if (line.startsWith("at cv(")) return true;
|
|
73
76
|
if (line.startsWith("cv@")) return true;
|
|
@@ -105,8 +108,9 @@ export function accumulateUnstableVariantChanges(
|
|
|
105
108
|
): void {
|
|
106
109
|
for (const key in next) {
|
|
107
110
|
if (!hasOwn(next, key)) continue;
|
|
108
|
-
|
|
109
|
-
|
|
111
|
+
const from = getOwn(prev, key);
|
|
112
|
+
if (!Object.is(from, next[key])) {
|
|
113
|
+
setVariantChange(into, key, from, next[key]);
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
116
|
for (const key in prev) {
|
package/src/utils.ts
CHANGED
|
@@ -2,6 +2,20 @@ import type { HTMLCSSProperties, StyleValue } from "./types.ts";
|
|
|
2
2
|
|
|
3
3
|
export const hasOwn = Object.hasOwn;
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Reads a key that may be absent from a plain record. Variant, prop, and config
|
|
7
|
+
* records are plain objects, so a key inherited from a polluted
|
|
8
|
+
* `Object.prototype` would otherwise read back like a value the caller passed
|
|
9
|
+
* or Clava itself resolved.
|
|
10
|
+
*/
|
|
11
|
+
export function getOwn<T extends object, K extends keyof T & string>(
|
|
12
|
+
record: T,
|
|
13
|
+
key: K,
|
|
14
|
+
): T[K] | undefined {
|
|
15
|
+
if (!hasOwn(record, key)) return undefined;
|
|
16
|
+
return record[key];
|
|
17
|
+
}
|
|
18
|
+
|
|
5
19
|
// Keep this explicit so normalization does not depend on browser globals.
|
|
6
20
|
// Vendor-prefixed variants are derived below instead of duplicating the list.
|
|
7
21
|
const unitlessNumberProperties = new Set([
|