frameboard 0.18.0 → 0.19.0
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/dist/cli.js
CHANGED
|
@@ -9415,7 +9415,7 @@ async function isDirectory(path) {
|
|
|
9415
9415
|
}
|
|
9416
9416
|
}
|
|
9417
9417
|
// package.json
|
|
9418
|
-
var version$1 = "0.
|
|
9418
|
+
var version$1 = "0.19.0";
|
|
9419
9419
|
var dependencies = { "playwright-core": "1.64.1" };
|
|
9420
9420
|
// src/shared/version.ts
|
|
9421
9421
|
const version = version$1;
|
|
@@ -34935,7 +34935,7 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
|
|
|
34935
34935
|
}
|
|
34936
34936
|
return null;
|
|
34937
34937
|
};
|
|
34938
|
-
const resolveVars = (value, element, depth = 0) => {
|
|
34938
|
+
const resolveVars = (value, element, keep = /* @__PURE__ */ new Set(), depth = 0) => {
|
|
34939
34939
|
if (depth > 16) return null;
|
|
34940
34940
|
let resolved = "";
|
|
34941
34941
|
let rest = value;
|
|
@@ -34944,8 +34944,12 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
|
|
|
34944
34944
|
if (end === -1) return null;
|
|
34945
34945
|
const [name = "", ...fallbackParts] = splitTopLevel(rest.slice(start + 4, end), ",");
|
|
34946
34946
|
const fallback = fallbackParts.length > 0 ? fallbackParts.join(",") : null;
|
|
34947
|
-
|
|
34948
|
-
|
|
34947
|
+
let replacement;
|
|
34948
|
+
if (keep.has(name.trim())) replacement = rest.slice(start, end + 1);
|
|
34949
|
+
else {
|
|
34950
|
+
const custom = inherited(element, name.trim());
|
|
34951
|
+
replacement = custom === null ? fallback === null ? null : resolveVars(fallback, element, keep, depth + 1) : resolveVars(custom.value.trim(), custom.element, keep, depth + 1);
|
|
34952
|
+
}
|
|
34949
34953
|
if (replacement === null) return null;
|
|
34950
34954
|
resolved += rest.slice(0, start) + replacement;
|
|
34951
34955
|
rest = rest.slice(end + 1);
|
|
@@ -34982,7 +34986,8 @@ function buildCascade(source, tokens, { properties = READ } = {}) {
|
|
|
34982
34986
|
userAgent: false,
|
|
34983
34987
|
shorthand: declaration.property !== property
|
|
34984
34988
|
};
|
|
34985
|
-
}
|
|
34989
|
+
},
|
|
34990
|
+
resolve: (value, element, keep) => resolveVars(value, element, keep)
|
|
34986
34991
|
};
|
|
34987
34992
|
}
|
|
34988
34993
|
/** A rule styles elements unless it sits in a non-styling at-rule or inside another rule. */
|
|
@@ -35288,19 +35293,33 @@ const MIX = /^color-mix\(\s*in\s+srgb\s*,\s*var\(\s*(--[\w-]+)\s*(?:,[^)]*)?\)\s
|
|
|
35288
35293
|
const HEX_ALPHA = /^#([0-9a-f]{6})([0-9a-f]{2})$/i;
|
|
35289
35294
|
/**
|
|
35290
35295
|
* A frame's colors as its source states them, read through the static
|
|
35291
|
-
* cascade the checks use, so `var(
|
|
35296
|
+
* cascade the checks use, so a `var()` over a name a token sheet declares
|
|
35297
|
+
* is named exactly, one over a name only the frame declares answers the
|
|
35298
|
+
* value it resolves to, and a raw
|
|
35292
35299
|
* value is answered raw rather than matched to a token that happens to
|
|
35293
35300
|
* share its value. `index` is the edit address's, naming the selected
|
|
35294
35301
|
* element, whose subtree the colors then cover in place of the frame's.
|
|
35295
35302
|
*/
|
|
35296
35303
|
function frameStyles(source, tokens, index) {
|
|
35297
35304
|
const cascade = buildCascade(source, tokens, { properties: PROPERTIES });
|
|
35305
|
+
const tokenNames = declaredNames(tokens);
|
|
35298
35306
|
const target = index === void 0 ? void 0 : source.elements[index];
|
|
35307
|
+
const named = (written, element) => {
|
|
35308
|
+
const value = styleValue(written);
|
|
35309
|
+
if (!value.token || tokenNames.has(value.token)) return value;
|
|
35310
|
+
const resolved = cascade.resolve(`var(${value.token})`, element, tokenNames);
|
|
35311
|
+
if (resolved === null) return value;
|
|
35312
|
+
const raw = styleValue(resolved);
|
|
35313
|
+
return {
|
|
35314
|
+
...raw,
|
|
35315
|
+
percent: Math.round(raw.percent * value.percent / 100)
|
|
35316
|
+
};
|
|
35317
|
+
};
|
|
35299
35318
|
const read = (element, property) => {
|
|
35300
35319
|
const found = cascade.specified(element, property);
|
|
35301
35320
|
if (!found) return null;
|
|
35302
35321
|
const part = found.shorthand ? shorthandPart(found.value, property) : found.value;
|
|
35303
|
-
return part === null ? null :
|
|
35322
|
+
return part === null ? null : named(part, found.element);
|
|
35304
35323
|
};
|
|
35305
35324
|
const family = (element) => {
|
|
35306
35325
|
const found = cascade.specified(element, "font-family");
|
|
@@ -35356,6 +35375,18 @@ function styleValue(written) {
|
|
|
35356
35375
|
percent: 100
|
|
35357
35376
|
};
|
|
35358
35377
|
}
|
|
35378
|
+
/** The custom properties the token sheets declare, which alone are tokens. */
|
|
35379
|
+
function declaredNames(sheets) {
|
|
35380
|
+
const names = /* @__PURE__ */ new Set();
|
|
35381
|
+
for (const sheet of sheets) try {
|
|
35382
|
+
postcss_default.parse(sheet.css).walkDecls(/^--/, (node) => {
|
|
35383
|
+
names.add(node.prop);
|
|
35384
|
+
});
|
|
35385
|
+
} catch {
|
|
35386
|
+
continue;
|
|
35387
|
+
}
|
|
35388
|
+
return names;
|
|
35389
|
+
}
|
|
35359
35390
|
/**
|
|
35360
35391
|
* The part of a `border` or `background` shorthand that sets `property`:
|
|
35361
35392
|
* the last part that reads as a color for a color, since a color comes last
|