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.d.cts
CHANGED
|
@@ -989,7 +989,7 @@ declare class CSSStyleDeclaration {
|
|
|
989
989
|
#private;
|
|
990
990
|
readonly [index: number]: string | undefined;
|
|
991
991
|
readonly parentRule: CSSRule;
|
|
992
|
-
protected constructor(parentRule: CSSRule);
|
|
992
|
+
protected constructor(parentRule: CSSRule, initialCssText?: string);
|
|
993
993
|
get cssText(): string;
|
|
994
994
|
set cssText(value: string);
|
|
995
995
|
get length(): number;
|
package/dist/index.d.ts
CHANGED
|
@@ -989,7 +989,7 @@ declare class CSSStyleDeclaration {
|
|
|
989
989
|
#private;
|
|
990
990
|
readonly [index: number]: string | undefined;
|
|
991
991
|
readonly parentRule: CSSRule;
|
|
992
|
-
protected constructor(parentRule: CSSRule);
|
|
992
|
+
protected constructor(parentRule: CSSRule, initialCssText?: string);
|
|
993
993
|
get cssText(): string;
|
|
994
994
|
set cssText(value: string);
|
|
995
995
|
get length(): number;
|
package/dist/index.js
CHANGED
|
@@ -4,9 +4,9 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
//#endregion
|
|
5
5
|
//#region src/internal/engine-binding.ts
|
|
6
6
|
const expectedEngineAbiIdentity = Object.freeze({
|
|
7
|
-
abiVersion:
|
|
8
|
-
sheetomVersion: "0.1.
|
|
9
|
-
syntaxEngineSetSha256: "
|
|
7
|
+
abiVersion: 4,
|
|
8
|
+
sheetomVersion: "0.1.1",
|
|
9
|
+
syntaxEngineSetSha256: "a0f10d0c1f0fe9e5bac9002e8ee548e7b5f6e2c7add1af3d953ae718d25cb37b"
|
|
10
10
|
});
|
|
11
11
|
var SheetOMEngineBindingError = class extends Error {
|
|
12
12
|
code;
|
|
@@ -41,7 +41,7 @@ function loadBinding() {
|
|
|
41
41
|
validateEngineBindingIdentity(addon);
|
|
42
42
|
return {
|
|
43
43
|
...addon,
|
|
44
|
-
createDeclarationState: (context, ...
|
|
44
|
+
createDeclarationState: (context, ...arguments_) => new addon.NativeDeclarationState(context, ...arguments_)
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
//#endregion
|
|
@@ -128,11 +128,16 @@ var NativeDeclarationBlock = class {
|
|
|
128
128
|
#reservedNestingDepth;
|
|
129
129
|
#observableCache;
|
|
130
130
|
#serializationCache = /* @__PURE__ */ new Map();
|
|
131
|
-
constructor(reportDiagnostic, reportSerializationDiagnostic, context = "style", resourceBudget = defaultResourceBudget, reservedNestingDepth = () => 0) {
|
|
131
|
+
constructor(reportDiagnostic, reportSerializationDiagnostic, context = "style", resourceBudget = defaultResourceBudget, reservedNestingDepth = () => 0, initialCssText) {
|
|
132
132
|
this.#reportDiagnostic = reportDiagnostic;
|
|
133
133
|
this.#reportSerializationDiagnostic = reportSerializationDiagnostic;
|
|
134
134
|
this.#reservedNestingDepth = reservedNestingDepth;
|
|
135
|
-
|
|
135
|
+
try {
|
|
136
|
+
this.#state = engineBinding.createDeclarationState(context, ...nativeBudgetArguments(resourceBudget), initialCssText);
|
|
137
|
+
} catch (error) {
|
|
138
|
+
rethrowResourceBudgetError(error);
|
|
139
|
+
throw error;
|
|
140
|
+
}
|
|
136
141
|
}
|
|
137
142
|
get cssText() {
|
|
138
143
|
this.#observableCache ??= this.#state.cssText;
|
|
@@ -598,6 +603,7 @@ const pageMarginRuleNames = /* @__PURE__ */ new Set([
|
|
|
598
603
|
"left-top"
|
|
599
604
|
]);
|
|
600
605
|
const ignoreDiagnostic = () => {};
|
|
606
|
+
const normalizedSelectorText = Symbol("normalizedSelectorText");
|
|
601
607
|
const ruleDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
602
608
|
const ruleTree = new RuleTree((rule, parentRule, parentStyleSheet) => {
|
|
603
609
|
ruleParentage.set(rule, {
|
|
@@ -1254,7 +1260,7 @@ var CSSViewTransitionRule = class extends CSSRule {
|
|
|
1254
1260
|
var CSSStyleDeclaration = class {
|
|
1255
1261
|
parentRule;
|
|
1256
1262
|
#block;
|
|
1257
|
-
constructor(parentRule) {
|
|
1263
|
+
constructor(parentRule, initialCssText) {
|
|
1258
1264
|
assertInternalConstructor("CSSStyleDeclaration");
|
|
1259
1265
|
this.parentRule = parentRule;
|
|
1260
1266
|
lockOwnProperties(this, "parentRule");
|
|
@@ -1284,7 +1290,7 @@ var CSSStyleDeclaration = class {
|
|
|
1284
1290
|
};
|
|
1285
1291
|
(ruleDiagnostics.get(this.parentRule) ?? ignoreDiagnostic)(diagnostic);
|
|
1286
1292
|
};
|
|
1287
|
-
this.#block = new NativeDeclarationBlock(reportDeclarationDiagnostic, reportSerializationDiagnostic, parentRule instanceof CSSFontFaceRule ? "font-face" : parentRule instanceof CSSFunctionDeclarations ? "function" : "style", ruleResourceBudgets.get(parentRule) ?? defaultResourceBudget, () => declarationSerializationDepth(parentRule));
|
|
1293
|
+
this.#block = new NativeDeclarationBlock(reportDeclarationDiagnostic, reportSerializationDiagnostic, parentRule instanceof CSSFontFaceRule ? "font-face" : parentRule instanceof CSSFunctionDeclarations ? "function" : "style", ruleResourceBudgets.get(parentRule) ?? defaultResourceBudget, () => declarationSerializationDepth(parentRule), initialCssText);
|
|
1288
1294
|
return new Proxy(this, {
|
|
1289
1295
|
get(target, property) {
|
|
1290
1296
|
if (typeof property === "string" && arrayIndexPattern.test(property)) return target.item(Number(property)) || void 0;
|
|
@@ -1369,9 +1375,9 @@ var CSSStyleDeclaration = class {
|
|
|
1369
1375
|
/** A live `@font-face` descriptor rule. */
|
|
1370
1376
|
var CSSFontFaceRule = class extends CSSRule {
|
|
1371
1377
|
style;
|
|
1372
|
-
constructor() {
|
|
1378
|
+
constructor(initialCssText) {
|
|
1373
1379
|
super(CSSRule.FONT_FACE_RULE);
|
|
1374
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1380
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1375
1381
|
lockOwnProperties(this, "style");
|
|
1376
1382
|
}
|
|
1377
1383
|
get cssText() {
|
|
@@ -1382,9 +1388,9 @@ var CSSFontFaceRule = class extends CSSRule {
|
|
|
1382
1388
|
/** Declarations ordered after a nested style rule. */
|
|
1383
1389
|
var CSSNestedDeclarations = class extends CSSRule {
|
|
1384
1390
|
#style;
|
|
1385
|
-
constructor() {
|
|
1391
|
+
constructor(initialCssText) {
|
|
1386
1392
|
super(0);
|
|
1387
|
-
this.#style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1393
|
+
this.#style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1388
1394
|
}
|
|
1389
1395
|
get style() {
|
|
1390
1396
|
return this.#style;
|
|
@@ -1400,9 +1406,9 @@ var CSSNestedDeclarations = class extends CSSRule {
|
|
|
1400
1406
|
/** A run of live descriptors inside a custom function. */
|
|
1401
1407
|
var CSSFunctionDeclarations = class extends CSSRule {
|
|
1402
1408
|
#style;
|
|
1403
|
-
constructor() {
|
|
1409
|
+
constructor(initialCssText) {
|
|
1404
1410
|
super(0);
|
|
1405
|
-
this.#style = constructWebIDL(CSSFunctionDescriptors, [this]);
|
|
1411
|
+
this.#style = constructWebIDL(CSSFunctionDescriptors, [this, initialCssText]);
|
|
1406
1412
|
}
|
|
1407
1413
|
get style() {
|
|
1408
1414
|
return this.#style;
|
|
@@ -1426,10 +1432,10 @@ var CSSFunctionDescriptors = class extends CSSStyleDeclaration {
|
|
|
1426
1432
|
var CSSMarginRule = class extends CSSRule {
|
|
1427
1433
|
name;
|
|
1428
1434
|
style;
|
|
1429
|
-
constructor(name) {
|
|
1435
|
+
constructor(name, initialCssText) {
|
|
1430
1436
|
super(CSSRule.MARGIN_RULE);
|
|
1431
1437
|
this.name = name;
|
|
1432
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1438
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1433
1439
|
lockOwnProperties(this, "name", "style");
|
|
1434
1440
|
}
|
|
1435
1441
|
get cssText() {
|
|
@@ -1441,10 +1447,10 @@ var CSSMarginRule = class extends CSSRule {
|
|
|
1441
1447
|
var CSSPageRule = class extends CSSGroupingRule {
|
|
1442
1448
|
style;
|
|
1443
1449
|
#selectorText;
|
|
1444
|
-
constructor(selectorText) {
|
|
1450
|
+
constructor(selectorText, initialCssText) {
|
|
1445
1451
|
super(CSSRule.PAGE_RULE);
|
|
1446
1452
|
this.#selectorText = selectorText;
|
|
1447
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1453
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1448
1454
|
lockOwnProperties(this, "style");
|
|
1449
1455
|
}
|
|
1450
1456
|
get selectorText() {
|
|
@@ -1465,10 +1471,10 @@ var CSSPageRule = class extends CSSGroupingRule {
|
|
|
1465
1471
|
var CSSPositionTryRule = class extends CSSRule {
|
|
1466
1472
|
name;
|
|
1467
1473
|
style;
|
|
1468
|
-
constructor(name) {
|
|
1474
|
+
constructor(name, initialCssText) {
|
|
1469
1475
|
super(0);
|
|
1470
1476
|
this.name = name;
|
|
1471
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1477
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1472
1478
|
lockOwnProperties(this, "name", "style");
|
|
1473
1479
|
}
|
|
1474
1480
|
get cssText() {
|
|
@@ -1502,10 +1508,10 @@ function normalizeKeyText(value) {
|
|
|
1502
1508
|
var CSSKeyframeRule = class extends CSSRule {
|
|
1503
1509
|
style;
|
|
1504
1510
|
#keyText;
|
|
1505
|
-
constructor(keyText) {
|
|
1511
|
+
constructor(keyText, initialCssText) {
|
|
1506
1512
|
super(CSSRule.KEYFRAME_RULE);
|
|
1507
1513
|
this.#keyText = normalizeKeyText(keyText) ?? keyText;
|
|
1508
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1514
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1509
1515
|
lockOwnProperties(this, "style");
|
|
1510
1516
|
}
|
|
1511
1517
|
get keyText() {
|
|
@@ -1816,10 +1822,10 @@ var CSSFontFeatureValuesRule = class extends CSSRule {
|
|
|
1816
1822
|
var CSSStyleRule = class extends CSSGroupingRule {
|
|
1817
1823
|
style;
|
|
1818
1824
|
#selectorText;
|
|
1819
|
-
constructor(selectorText) {
|
|
1825
|
+
constructor(selectorText, normalized, initialCssText) {
|
|
1820
1826
|
super(CSSRule.STYLE_RULE);
|
|
1821
|
-
this.#selectorText = normalizeSelectorText(`${selectorText}`, currentConstructionResourceBudget()) ?? `${selectorText}`;
|
|
1822
|
-
this.style = constructWebIDL(CSSStyleDeclaration, [this]);
|
|
1827
|
+
this.#selectorText = normalized === normalizedSelectorText ? selectorText : normalizeSelectorText(`${selectorText}`, currentConstructionResourceBudget()) ?? `${selectorText}`;
|
|
1828
|
+
this.style = constructWebIDL(CSSStyleDeclaration, [this, initialCssText]);
|
|
1823
1829
|
lockOwnProperties(this, "style");
|
|
1824
1830
|
}
|
|
1825
1831
|
get selectorText() {
|
|
@@ -1986,24 +1992,19 @@ function isNativeMetadataRule(description) {
|
|
|
1986
1992
|
function createRuleShellFromNative(description, reportDiagnostic, preserveImports, resourceBudget) {
|
|
1987
1993
|
let rule;
|
|
1988
1994
|
switch (description.kind) {
|
|
1989
|
-
case "style":
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1995
|
+
case "style":
|
|
1996
|
+
rule = constructWebIDL(CSSStyleRule, [
|
|
1997
|
+
description.prelude,
|
|
1998
|
+
normalizedSelectorText,
|
|
1999
|
+
description.declarations
|
|
2000
|
+
]);
|
|
1993
2001
|
break;
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
const nested = constructWebIDL(CSSNestedDeclarations);
|
|
1997
|
-
nested.style.cssText = description.declarations;
|
|
1998
|
-
rule = nested;
|
|
2002
|
+
case "nested-declarations":
|
|
2003
|
+
rule = constructWebIDL(CSSNestedDeclarations, [description.declarations]);
|
|
1999
2004
|
break;
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
const declarations = constructWebIDL(CSSFunctionDeclarations);
|
|
2003
|
-
declarations.style.cssText = description.declarations;
|
|
2004
|
-
rule = declarations;
|
|
2005
|
+
case "function-declarations":
|
|
2006
|
+
rule = constructWebIDL(CSSFunctionDeclarations, [description.declarations]);
|
|
2005
2007
|
break;
|
|
2006
|
-
}
|
|
2007
2008
|
case "import": {
|
|
2008
2009
|
if (!preserveImports) return null;
|
|
2009
2010
|
const parsed = parseImportPrelude(description.cssText.replace(/^@import\s+/iu, "").replace(/;\s*$/u, ""));
|
|
@@ -2016,39 +2017,24 @@ function createRuleShellFromNative(description, reportDiagnostic, preserveImport
|
|
|
2016
2017
|
]);
|
|
2017
2018
|
break;
|
|
2018
2019
|
}
|
|
2019
|
-
case "font-face":
|
|
2020
|
-
|
|
2021
|
-
fontFace.style.cssText = description.declarations;
|
|
2022
|
-
rule = fontFace;
|
|
2020
|
+
case "font-face":
|
|
2021
|
+
rule = constructWebIDL(CSSFontFaceRule, [description.declarations]);
|
|
2023
2022
|
break;
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
const page = constructWebIDL(CSSPageRule, [description.prelude]);
|
|
2027
|
-
page.style.cssText = description.declarations;
|
|
2028
|
-
rule = page;
|
|
2023
|
+
case "page":
|
|
2024
|
+
rule = constructWebIDL(CSSPageRule, [description.prelude, description.declarations]);
|
|
2029
2025
|
break;
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
const margin = constructWebIDL(CSSMarginRule, [description.prelude]);
|
|
2033
|
-
margin.style.cssText = description.declarations;
|
|
2034
|
-
rule = margin;
|
|
2026
|
+
case "margin":
|
|
2027
|
+
rule = constructWebIDL(CSSMarginRule, [description.prelude, description.declarations]);
|
|
2035
2028
|
break;
|
|
2036
|
-
|
|
2037
|
-
|
|
2038
|
-
const positionTry = constructWebIDL(CSSPositionTryRule, [description.prelude]);
|
|
2039
|
-
positionTry.style.cssText = description.declarations;
|
|
2040
|
-
rule = positionTry;
|
|
2029
|
+
case "position-try":
|
|
2030
|
+
rule = constructWebIDL(CSSPositionTryRule, [description.prelude, description.declarations]);
|
|
2041
2031
|
break;
|
|
2042
|
-
}
|
|
2043
2032
|
case "keyframes":
|
|
2044
2033
|
rule = constructWebIDL(CSSKeyframesRule, [description.prelude]);
|
|
2045
2034
|
break;
|
|
2046
|
-
case "keyframe":
|
|
2047
|
-
|
|
2048
|
-
keyframe.style.cssText = description.declarations;
|
|
2049
|
-
rule = keyframe;
|
|
2035
|
+
case "keyframe":
|
|
2036
|
+
rule = constructWebIDL(CSSKeyframeRule, [description.prelude, description.declarations]);
|
|
2050
2037
|
break;
|
|
2051
|
-
}
|
|
2052
2038
|
case "counter-style": {
|
|
2053
2039
|
const counterStyle = constructWebIDL(CSSCounterStyleRule, [description.prelude]);
|
|
2054
2040
|
hydrateCounterStyleDescriptors(counterStyle, description.declarations, resourceBudget);
|