sheetom 0.1.0 → 0.1.1
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/index.cjs +51 -65
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +51 -65
- package/dist/index.js.map +1 -1
- package/engine-abi.json +3 -3
- package/package.json +19 -19
package/dist/index.cjs
CHANGED
|
@@ -28,9 +28,9 @@ let node_url = require("node:url");
|
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/internal/engine-binding.ts
|
|
30
30
|
const expectedEngineAbiIdentity = Object.freeze({
|
|
31
|
-
abiVersion:
|
|
32
|
-
sheetomVersion: "0.1.
|
|
33
|
-
syntaxEngineSetSha256: "
|
|
31
|
+
abiVersion: 4,
|
|
32
|
+
sheetomVersion: "0.1.1",
|
|
33
|
+
syntaxEngineSetSha256: "a0f10d0c1f0fe9e5bac9002e8ee548e7b5f6e2c7add1af3d953ae718d25cb37b"
|
|
34
34
|
});
|
|
35
35
|
var SheetOMEngineBindingError = class extends Error {
|
|
36
36
|
code;
|
|
@@ -65,7 +65,7 @@ function loadBinding() {
|
|
|
65
65
|
validateEngineBindingIdentity(addon);
|
|
66
66
|
return {
|
|
67
67
|
...addon,
|
|
68
|
-
createDeclarationState: (context, ...
|
|
68
|
+
createDeclarationState: (context, ...arguments_) => new addon.NativeDeclarationState(context, ...arguments_)
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
//#endregion
|
|
@@ -152,11 +152,16 @@ var NativeDeclarationBlock = class {
|
|
|
152
152
|
#reservedNestingDepth;
|
|
153
153
|
#observableCache;
|
|
154
154
|
#serializationCache = /* @__PURE__ */ new Map();
|
|
155
|
-
constructor(reportDiagnostic, reportSerializationDiagnostic, context = "style", resourceBudget = defaultResourceBudget, reservedNestingDepth = () => 0) {
|
|
155
|
+
constructor(reportDiagnostic, reportSerializationDiagnostic, context = "style", resourceBudget = defaultResourceBudget, reservedNestingDepth = () => 0, initialCssText) {
|
|
156
156
|
this.#reportDiagnostic = reportDiagnostic;
|
|
157
157
|
this.#reportSerializationDiagnostic = reportSerializationDiagnostic;
|
|
158
158
|
this.#reservedNestingDepth = reservedNestingDepth;
|
|
159
|
-
|
|
159
|
+
try {
|
|
160
|
+
this.#state = engineBinding.createDeclarationState(context, ...nativeBudgetArguments(resourceBudget), initialCssText);
|
|
161
|
+
} catch (error) {
|
|
162
|
+
rethrowResourceBudgetError(error);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
160
165
|
}
|
|
161
166
|
get cssText() {
|
|
162
167
|
this.#observableCache ??= this.#state.cssText;
|
|
@@ -622,6 +627,7 @@ const pageMarginRuleNames = /* @__PURE__ */ new Set([
|
|
|
622
627
|
"left-top"
|
|
623
628
|
]);
|
|
624
629
|
const ignoreDiagnostic = () => {};
|
|
630
|
+
const normalizedSelectorText = Symbol("normalizedSelectorText");
|
|
625
631
|
const ruleDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
626
632
|
const ruleTree = new RuleTree((rule, parentRule, parentStyleSheet) => {
|
|
627
633
|
ruleParentage.set(rule, {
|
|
@@ -1278,7 +1284,7 @@ var CSSViewTransitionRule = class extends CSSRule {
|
|
|
1278
1284
|
var CSSStyleDeclaration = class {
|
|
1279
1285
|
parentRule;
|
|
1280
1286
|
#block;
|
|
1281
|
-
constructor(parentRule) {
|
|
1287
|
+
constructor(parentRule, initialCssText) {
|
|
1282
1288
|
assertInternalConstructor("CSSStyleDeclaration");
|
|
1283
1289
|
this.parentRule = parentRule;
|
|
1284
1290
|
lockOwnProperties(this, "parentRule");
|
|
@@ -1308,7 +1314,7 @@ var CSSStyleDeclaration = class {
|
|
|
1308
1314
|
};
|
|
1309
1315
|
(ruleDiagnostics.get(this.parentRule) ?? ignoreDiagnostic)(diagnostic);
|
|
1310
1316
|
};
|
|
1311
|
-
this.#block = new NativeDeclarationBlock(reportDeclarationDiagnostic, reportSerializationDiagnostic, parentRule instanceof CSSFontFaceRule ? "font-face" : parentRule instanceof CSSFunctionDeclarations ? "function" : "style", ruleResourceBudgets.get(parentRule) ?? defaultResourceBudget, () => declarationSerializationDepth(parentRule));
|
|
1317
|
+
this.#block = new NativeDeclarationBlock(reportDeclarationDiagnostic, reportSerializationDiagnostic, parentRule instanceof CSSFontFaceRule ? "font-face" : parentRule instanceof CSSFunctionDeclarations ? "function" : "style", ruleResourceBudgets.get(parentRule) ?? defaultResourceBudget, () => declarationSerializationDepth(parentRule), initialCssText);
|
|
1312
1318
|
return new Proxy(this, {
|
|
1313
1319
|
get(target, property) {
|
|
1314
1320
|
if (typeof property === "string" && arrayIndexPattern.test(property)) return target.item(Number(property)) || void 0;
|
|
@@ -1393,9 +1399,9 @@ var CSSStyleDeclaration = class {
|
|
|
1393
1399
|
/** A live `@font-face` descriptor rule. */
|
|
1394
1400
|
var CSSFontFaceRule = class extends CSSRule {
|
|
1395
1401
|
style;
|
|
1396
|
-
constructor() {
|
|
1402
|
+
constructor(initialCssText) {
|
|
1397
1403
|
super(CSSRule.FONT_FACE_RULE);
|
|
1398
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1404
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1399
1405
|
lockOwnProperties(this, "style");
|
|
1400
1406
|
}
|
|
1401
1407
|
get cssText() {
|
|
@@ -1406,9 +1412,9 @@ var CSSFontFaceRule = class extends CSSRule {
|
|
|
1406
1412
|
/** Declarations ordered after a nested style rule. */
|
|
1407
1413
|
var CSSNestedDeclarations = class extends CSSRule {
|
|
1408
1414
|
#style;
|
|
1409
|
-
constructor() {
|
|
1415
|
+
constructor(initialCssText) {
|
|
1410
1416
|
super(0);
|
|
1411
|
-
this.#style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1417
|
+
this.#style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1412
1418
|
}
|
|
1413
1419
|
get style() {
|
|
1414
1420
|
return this.#style;
|
|
@@ -1424,9 +1430,9 @@ var CSSNestedDeclarations = class extends CSSRule {
|
|
|
1424
1430
|
/** A run of live descriptors inside a custom function. */
|
|
1425
1431
|
var CSSFunctionDeclarations = class extends CSSRule {
|
|
1426
1432
|
#style;
|
|
1427
|
-
constructor() {
|
|
1433
|
+
constructor(initialCssText) {
|
|
1428
1434
|
super(0);
|
|
1429
|
-
this.#style = constructWebIDL(CSSFunctionDescriptors, [this]);
|
|
1435
|
+
this.#style = constructWebIDL(CSSFunctionDescriptors, [this, initialCssText]);
|
|
1430
1436
|
}
|
|
1431
1437
|
get style() {
|
|
1432
1438
|
return this.#style;
|
|
@@ -1450,10 +1456,10 @@ var CSSFunctionDescriptors = class extends CSSStyleDeclaration {
|
|
|
1450
1456
|
var CSSMarginRule = class extends CSSRule {
|
|
1451
1457
|
name;
|
|
1452
1458
|
style;
|
|
1453
|
-
constructor(name) {
|
|
1459
|
+
constructor(name, initialCssText) {
|
|
1454
1460
|
super(CSSRule.MARGIN_RULE);
|
|
1455
1461
|
this.name = name;
|
|
1456
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1462
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1457
1463
|
lockOwnProperties(this, "name", "style");
|
|
1458
1464
|
}
|
|
1459
1465
|
get cssText() {
|
|
@@ -1465,10 +1471,10 @@ var CSSMarginRule = class extends CSSRule {
|
|
|
1465
1471
|
var CSSPageRule = class extends CSSGroupingRule {
|
|
1466
1472
|
style;
|
|
1467
1473
|
#selectorText;
|
|
1468
|
-
constructor(selectorText) {
|
|
1474
|
+
constructor(selectorText, initialCssText) {
|
|
1469
1475
|
super(CSSRule.PAGE_RULE);
|
|
1470
1476
|
this.#selectorText = selectorText;
|
|
1471
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1477
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1472
1478
|
lockOwnProperties(this, "style");
|
|
1473
1479
|
}
|
|
1474
1480
|
get selectorText() {
|
|
@@ -1489,10 +1495,10 @@ var CSSPageRule = class extends CSSGroupingRule {
|
|
|
1489
1495
|
var CSSPositionTryRule = class extends CSSRule {
|
|
1490
1496
|
name;
|
|
1491
1497
|
style;
|
|
1492
|
-
constructor(name) {
|
|
1498
|
+
constructor(name, initialCssText) {
|
|
1493
1499
|
super(0);
|
|
1494
1500
|
this.name = name;
|
|
1495
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1501
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1496
1502
|
lockOwnProperties(this, "name", "style");
|
|
1497
1503
|
}
|
|
1498
1504
|
get cssText() {
|
|
@@ -1526,10 +1532,10 @@ function normalizeKeyText(value) {
|
|
|
1526
1532
|
var CSSKeyframeRule = class extends CSSRule {
|
|
1527
1533
|
style;
|
|
1528
1534
|
#keyText;
|
|
1529
|
-
constructor(keyText) {
|
|
1535
|
+
constructor(keyText, initialCssText) {
|
|
1530
1536
|
super(CSSRule.KEYFRAME_RULE);
|
|
1531
1537
|
this.#keyText = normalizeKeyText(keyText) ?? keyText;
|
|
1532
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1538
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1533
1539
|
lockOwnProperties(this, "style");
|
|
1534
1540
|
}
|
|
1535
1541
|
get keyText() {
|
|
@@ -1840,10 +1846,10 @@ var CSSFontFeatureValuesRule = class extends CSSRule {
|
|
|
1840
1846
|
var CSSStyleRule = class extends CSSGroupingRule {
|
|
1841
1847
|
style;
|
|
1842
1848
|
#selectorText;
|
|
1843
|
-
constructor(selectorText) {
|
|
1849
|
+
constructor(selectorText, normalized, initialCssText) {
|
|
1844
1850
|
super(CSSRule.STYLE_RULE);
|
|
1845
|
-
this.#selectorText = normalizeSelectorText(`${selectorText}`, currentConstructionResourceBudget()) ?? `${selectorText}`;
|
|
1846
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1851
|
+
this.#selectorText = normalized === normalizedSelectorText ? selectorText : normalizeSelectorText(`${selectorText}`, currentConstructionResourceBudget()) ?? `${selectorText}`;
|
|
1852
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1847
1853
|
lockOwnProperties(this, "style");
|
|
1848
1854
|
}
|
|
1849
1855
|
get selectorText() {
|
|
@@ -2010,24 +2016,19 @@ function isNativeMetadataRule(description) {
|
|
|
2010
2016
|
function createRuleShellFromNative(description, reportDiagnostic, preserveImports, resourceBudget) {
|
|
2011
2017
|
let rule;
|
|
2012
2018
|
switch (description.kind) {
|
|
2013
|
-
case "style":
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2019
|
+
case "style":
|
|
2020
|
+
rule = constructWebIDL(CSSStyleRule, [
|
|
2021
|
+
description.prelude,
|
|
2022
|
+
normalizedSelectorText,
|
|
2023
|
+
description.declarations
|
|
2024
|
+
]);
|
|
2017
2025
|
break;
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
const nested = constructWebIDL(CSSNestedDeclarations);
|
|
2021
|
-
nested.style.cssText = description.declarations;
|
|
2022
|
-
rule = nested;
|
|
2026
|
+
case "nested-declarations":
|
|
2027
|
+
rule = constructWebIDL(CSSNestedDeclarations, [description.declarations]);
|
|
2023
2028
|
break;
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
const declarations = constructWebIDL(CSSFunctionDeclarations);
|
|
2027
|
-
declarations.style.cssText = description.declarations;
|
|
2028
|
-
rule = declarations;
|
|
2029
|
+
case "function-declarations":
|
|
2030
|
+
rule = constructWebIDL(CSSFunctionDeclarations, [description.declarations]);
|
|
2029
2031
|
break;
|
|
2030
|
-
}
|
|
2031
2032
|
case "import": {
|
|
2032
2033
|
if (!preserveImports) return null;
|
|
2033
2034
|
const parsed = parseImportPrelude(description.cssText.replace(/^@import\s+/iu, "").replace(/;\s*$/u, ""));
|
|
@@ -2040,39 +2041,24 @@ function createRuleShellFromNative(description, reportDiagnostic, preserveImport
|
|
|
2040
2041
|
]);
|
|
2041
2042
|
break;
|
|
2042
2043
|
}
|
|
2043
|
-
case "font-face":
|
|
2044
|
-
|
|
2045
|
-
fontFace.style.cssText = description.declarations;
|
|
2046
|
-
rule = fontFace;
|
|
2044
|
+
case "font-face":
|
|
2045
|
+
rule = constructWebIDL(CSSFontFaceRule, [description.declarations]);
|
|
2047
2046
|
break;
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
const page = constructWebIDL(CSSPageRule, [description.prelude]);
|
|
2051
|
-
page.style.cssText = description.declarations;
|
|
2052
|
-
rule = page;
|
|
2047
|
+
case "page":
|
|
2048
|
+
rule = constructWebIDL(CSSPageRule, [description.prelude, description.declarations]);
|
|
2053
2049
|
break;
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
const margin = constructWebIDL(CSSMarginRule, [description.prelude]);
|
|
2057
|
-
margin.style.cssText = description.declarations;
|
|
2058
|
-
rule = margin;
|
|
2050
|
+
case "margin":
|
|
2051
|
+
rule = constructWebIDL(CSSMarginRule, [description.prelude, description.declarations]);
|
|
2059
2052
|
break;
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
const positionTry = constructWebIDL(CSSPositionTryRule, [description.prelude]);
|
|
2063
|
-
positionTry.style.cssText = description.declarations;
|
|
2064
|
-
rule = positionTry;
|
|
2053
|
+
case "position-try":
|
|
2054
|
+
rule = constructWebIDL(CSSPositionTryRule, [description.prelude, description.declarations]);
|
|
2065
2055
|
break;
|
|
2066
|
-
}
|
|
2067
2056
|
case "keyframes":
|
|
2068
2057
|
rule = constructWebIDL(CSSKeyframesRule, [description.prelude]);
|
|
2069
2058
|
break;
|
|
2070
|
-
case "keyframe":
|
|
2071
|
-
|
|
2072
|
-
keyframe.style.cssText = description.declarations;
|
|
2073
|
-
rule = keyframe;
|
|
2059
|
+
case "keyframe":
|
|
2060
|
+
rule = constructWebIDL(CSSKeyframeRule, [description.prelude, description.declarations]);
|
|
2074
2061
|
break;
|
|
2075
|
-
}
|
|
2076
2062
|
case "counter-style": {
|
|
2077
2063
|
const counterStyle = constructWebIDL(CSSCounterStyleRule, [description.prelude]);
|
|
2078
2064
|
hydrateCounterStyleDescriptors(counterStyle, description.declarations, resourceBudget);
|