sheetom 0.1.0-rc.4 → 0.1.0-rc.6

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.
Files changed (48) hide show
  1. package/README.md +113 -34
  2. package/compatibility/baselines/0.1.0-rc.5.json +3111 -0
  3. package/compatibility/baselines/0.1.0-rc.6.json +3211 -0
  4. package/compatibility/baselines/README.md +1 -1
  5. package/compatibility/browser-geometric-contracts.json +93 -0
  6. package/compatibility/native-grammar-inventory.json +1810 -0
  7. package/compatibility/number-result-math-capabilities.json +11380 -0
  8. package/compatibility/numeric-property-contracts.json +23 -0
  9. package/compatibility/schemas/browser-geometric-contracts.schema.json +39 -0
  10. package/compatibility/schemas/browser-longhand-composite-contracts.schema.json +39 -0
  11. package/compatibility/schemas/browser-longhand-keyword-contracts.schema.json +51 -0
  12. package/compatibility/schemas/compatibility-report.schema.json +312 -4
  13. package/compatibility/schemas/function-rule-cases.schema.json +49 -0
  14. package/compatibility/schemas/native-grammar-inventory.schema.json +134 -0
  15. package/compatibility/schemas/number-result-math-corpus.schema.json +71 -0
  16. package/compatibility/schemas/numeric-property-contracts.schema.json +37 -0
  17. package/compatibility/schemas/property-grammar-extensions.schema.json +51 -0
  18. package/compatibility/schemas/property-value-observations.schema.json +43 -0
  19. package/compatibility/schemas/property-value-probes.schema.json +26 -0
  20. package/compatibility/schemas/relative-color-corpus.schema.json +90 -0
  21. package/compatibility/schemas/shorthand-grammar-contracts.schema.json +53 -0
  22. package/compatibility/schemas/shorthand-grammar-observations.schema.json +43 -0
  23. package/compatibility/schemas/webref-branch-ratchet.schema.json +48 -0
  24. package/compatibility/schemas/webref-property-branches.schema.json +158 -0
  25. package/compatibility/schemas/webref-semantic-terminals.schema.json +38 -0
  26. package/compatibility/shorthand-grammar-contracts.json +223 -0
  27. package/compatibility/shorthand-grammar-observations.json +4898 -0
  28. package/compatibility/value-capabilities.json +2643 -13
  29. package/dist/index.cjs +885 -9478
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +90 -2
  32. package/dist/index.d.ts +90 -2
  33. package/dist/index.js +877 -9478
  34. package/dist/index.js.map +1 -1
  35. package/docs/api.md +55 -2
  36. package/docs/releasing.md +6 -4
  37. package/native/index.cjs +40 -0
  38. package/native/resolve-target.cjs +56 -0
  39. package/native/sheetom-native.d.ts +63 -0
  40. package/native/sheetom-native.darwin-arm64.node +0 -0
  41. package/native/sheetom-native.darwin-x64.node +0 -0
  42. package/native/sheetom-native.linux-arm64-gnu.node +0 -0
  43. package/native/sheetom-native.linux-arm64-musl.node +0 -0
  44. package/native/sheetom-native.linux-x64-gnu.node +0 -0
  45. package/native/sheetom-native.linux-x64-musl.node +0 -0
  46. package/native/sheetom-native.win32-arm64-msvc.node +0 -0
  47. package/native/sheetom-native.win32-x64-msvc.node +0 -0
  48. package/package.json +57 -9
package/README.md CHANGED
@@ -1,28 +1,34 @@
1
1
  # SheetOM
2
2
 
3
3
  SheetOM is a mutable, browser-shaped CSS authoring object model for Node.js,
4
- Bun, and Deno. It uses Lightning CSS for property parsing and canonicalization
5
- while keeping declaration state and CSSOM serialization under its own control.
4
+ Bun, and Deno. Its repository-owned Rust engine handles parsing,
5
+ canonicalization, declaration state, and safe CSS serialization; JavaScript
6
+ only owns the public WebIDL-shaped facade and live object identity.
6
7
 
7
8
  It is intended for server-side stylesheet editing and serialization. It does
8
9
  not implement the DOM, cascade, selector matching, layout, or computed styles.
9
10
 
10
11
  ## Install
11
12
 
12
- Install the current release candidate from the `next` dist-tag:
13
+ Install the active release:
13
14
 
14
15
  ```sh
15
- npm install sheetom@next
16
+ npm install sheetom
16
17
  ```
17
18
 
18
- `lightningcss`, `css-tree`, `cssstyle`, and the CSS Tools tokenizer are regular
19
- dependencies; consumers do not need to install peer dependencies or globals.
20
- SheetOM validates values before using `cssstyle` only as a static shorthand
21
- expander, and uses the tokenizer for lossless recovered-rule spans.
19
+ After the first stable release, use `npm install sheetom@next` to opt into an
20
+ active prerelease. Until then, the `latest` and `next` dist-tags both identify
21
+ the active release candidate.
22
+
23
+ The package has no JavaScript runtime or peer dependencies. Its native engine
24
+ includes a pinned, locally maintained Lightning CSS source snapshot; consumers
25
+ do not install a second parser, provide globals, or select a fallback engine.
26
+ SheetOM owns observable-value serialization and shorthand expansion rather
27
+ than delegating CSSOM state to a browser-DOM emulation package.
22
28
 
23
29
  Node.js 22 and 24 are tested on Linux x64, Windows x64, and macOS arm64. Bun
24
30
  1.3.1 and Deno 2.9.5 are tested on Linux x64. Deno must use a local
25
- `node_modules` directory and grant the native Lightning CSS binding FFI and
31
+ `node_modules` directory and grant SheetOM's native binding FFI and
26
32
  system-information permissions:
27
33
 
28
34
  ```sh
@@ -42,7 +48,7 @@ sheet.replaceSync(".card { width: 12px; }");
42
48
  const rule = sheet.cssRules[0];
43
49
  if (rule instanceof CSSStyleRule) {
44
50
  rule.style.setProperty("padding", "8px 16px");
45
- Reflect.set(rule.style, "backgroundColor", "rebeccapurple");
51
+ rule.style.setProperty("background-color", "rebeccapurple");
46
52
  }
47
53
 
48
54
  console.log(sheet.serialize());
@@ -53,6 +59,11 @@ const existing = parseStyleSheet('@import "theme.css"; .card { color: red; }', {
53
59
  console.log(existing.cssRules.length); // 2
54
60
  ```
55
61
 
62
+ `setProperty()` is the standard, fully typed way to set a declaration,
63
+ especially when its name is dynamic. Browser-style camelCase assignments such
64
+ as `rule.style.backgroundColor = "rebeccapurple"` work at runtime, but the
65
+ current TypeScript declarations do not enumerate every named CSS property.
66
+
56
67
  Constructed sheets follow browser replacement behavior and strip `@import`.
57
68
  `parseStyleSheet` creates a regular authoring sheet and preserves valid imports
58
69
  without loading them.
@@ -60,15 +71,18 @@ without loading them.
60
71
  ## Recovered values and reparsable serialization
61
72
 
62
73
  SheetOM distinguishes browser-facing CSSOM text from reparsable stylesheet
63
- output. Chromium
64
- accepts some values using CSS Syntax end-of-input recovery while preserving the
65
- unclosed input in `getPropertyValue()` and `cssText`:
74
+ output. Chromium accepts some values using CSS Syntax end-of-input recovery
75
+ while preserving the unclosed input in `getPropertyValue()` and `cssText`:
66
76
 
67
77
  ```ts
68
78
  const sheet = new CSSStyleSheet();
69
79
  sheet.insertRule(".card {}");
70
80
 
71
- const rule = sheet.cssRules[0] as CSSStyleRule;
81
+ const rule = sheet.cssRules[0];
82
+ if (!(rule instanceof CSSStyleRule)) {
83
+ throw new TypeError("Expected a style rule");
84
+ }
85
+
72
86
  rule.style.setProperty("padding", "72px var(--space, var(--space,");
73
87
 
74
88
  rule.style.getPropertyValue("padding");
@@ -107,6 +121,24 @@ getters and `cssText` are synthesized only while the complete current longhand
107
121
  set has compatible values and priorities; genuinely deferred substitutions
108
122
  retain separate provenance until a longhand mutation breaks their group.
109
123
 
124
+ The Chromium 151 compatibility baseline covers all 129 manifested
125
+ multi-longhand shorthands. Grammar depth is a finite reviewed contract rather
126
+ than a claim to implement every future CSS production: 24 codec profiles
127
+ currently carry 96 positive and neighboring-negative branch cases, including
128
+ cardinality, slash and comma lists, compound optional keywords, mutation
129
+ atomicity, and reparsable round-trips. CI reprobes those cases against the
130
+ pinned Chromium engine, and a release is blocked unless all 129 breadth seeds
131
+ and all 96 reviewed branches pass exactly. The contracts and browser
132
+ observations ship as audit evidence but are never imported as runtime value
133
+ authority.
134
+
135
+ Relative colors use the same typed engine rather than a text fallback. The
136
+ pinned Chromium 151 and WPT corpus contains 1,146 accepted and 160 rejected
137
+ branches across `rgb()`, `hsl()`, `hwb()`, Lab, LCH, predefined color spaces,
138
+ channel calculations, missing components, and nested color functions. CI
139
+ compares all 1,306 browser-facing getters in one batched browser session and
140
+ also requires every accepted value to survive reparsable serialization.
141
+
110
142
  ## API scope
111
143
 
112
144
  - `CSSStyleSheet`, live `CSSRuleList`, `CSSRule`, and `MediaList`
@@ -115,6 +147,8 @@ retain separate provenance until a longhand mutation breaks their group.
115
147
  - import, font-face, page/margin, nested-declaration, and position-try rules
116
148
  - keyframes and mutable keyframe rules
117
149
  - counter-style descriptors and font-feature-value maps
150
+ - custom `@function` parameters, return types, conditional groups, and live
151
+ function descriptors
118
152
  - live indexed and named `CSSStyleDeclaration`
119
153
  - `insertRule`, `deleteRule`, `replace`, and `replaceSync`
120
154
  - `parseStyleSheet` for forgiving regular-sheet parsing
@@ -131,6 +165,33 @@ Modern or implementation-dependent value grammar is bounded by the checked-in
131
165
  [`Value Capability Corpus`](./compatibility/value-capabilities.json). Each
132
166
  measured family includes accepted and rejected neighboring cases; browser
133
167
  probing occurs only during conformance work and never at runtime.
168
+ The corpus includes 94 CSS Math branches across number, integer, length,
169
+ percentage, angle, and time contexts. It locks dimensional rejection,
170
+ mixed-unit ordering, non-finite constants, function arity, CSSOM observable
171
+ serialization, and atomic failure to Chromium 151.
172
+
173
+ Computed-context number results are covered separately by the checked-in
174
+ [`Number Result Math Corpus`](./compatibility/number-result-math-capabilities.json).
175
+ It records 860 batched Chromium observations across all 70 accepting
176
+ properties, including relative lengths, percentages, dynamic products and
177
+ quotients, dimension-result neighbors, invalid dimensional multiplication,
178
+ CSSOM expansion, declaration serialization, multi-item animations, slash
179
+ sections, and contextual values in every position of `flex`, `grid`, columns,
180
+ aspect ratios, and border-image families. Both direct and composite properties
181
+ must pass mutation, `cssText`, safe round-trip, and atomic-rejection gates.
182
+
183
+ Direct numeric and cross-dimension syntax is gated independently by the
184
+ [`Numeric Property Contracts`](./compatibility/numeric-property-contracts.json).
185
+ It crosses 57 number-, percentage-, length-, and legacy-number properties with
186
+ 11 accepted and rejected neighboring branches. The public binding must match
187
+ Chromium for acceptance, observable values, `cssText`, indexed names, and
188
+ invalid-mutation atomicity; the browser observations remain test evidence and
189
+ are never loaded by the runtime.
190
+
191
+ The corresponding shorthand depth evidence is split between the reviewed
192
+ [`Grammar Branch Contracts`](./compatibility/shorthand-grammar-contracts.json)
193
+ and the generated
194
+ [`Chromium observations`](./compatibility/shorthand-grammar-observations.json).
134
195
 
135
196
  See [the behavioral API reference](./docs/api.md) for return, exception,
136
197
  identity, and detachment contracts. Maintainers use the separately reviewed
@@ -144,36 +205,54 @@ advancing the Compatibility Baseline.
144
205
 
145
206
  SheetOM does not fetch `@import` targets or URLs and does not execute CSS. It is
146
207
  also not a sanitizer: valid authored URLs, imports, and browser features remain
147
- in serialized output. Callers must sanitize untrusted output before attaching
148
- it to a document or another rendering environment.
208
+ in serialized output. Callers must apply their own content and resource policy
209
+ before attaching untrusted output to a document or another rendering
210
+ environment.
211
+
212
+ Every sheet has a high default Resource Budget that is checked before native
213
+ parsing or CSSOM mutation: 64 MiB of stylesheet source, 1 MiB per declaration
214
+ value, syntax depth 4,096, one million rules, and 100,000 declarations per
215
+ block. Exceeding a budget throws `RangeError` without changing the previous
216
+ sheet or declaration state. Limits are UTF-8 byte counts where applicable and
217
+ can be changed per sheet without affecting other sheets:
218
+
219
+ ```js
220
+ const bounded = new CSSStyleSheet({
221
+ resourceBudget: {
222
+ maxStylesheetBytes: 8 * 1024 * 1024,
223
+ maxRuleCount: 100_000,
224
+ },
225
+ });
226
+ ```
149
227
 
150
- The browser-shaped interface has no implicit input-size, nesting-depth, or
151
- mutation-count limits. Isolate or bound untrusted workloads according to your
152
- application's resource policy. See [SECURITY.md](./SECURITY.md) for private
153
- vulnerability reporting and supported-release policy.
228
+ Resource Budgets protect the host process; they are not content policy,
229
+ sanitization, or a rendering sandbox. See [the API contract](./docs/api.md) and
230
+ [SECURITY.md](./SECURITY.md) for details.
154
231
 
155
232
  ## Development
156
233
 
157
234
  ```sh
158
- npm test
159
- npm run typecheck
160
- npm run build
161
- npm run conformance:validate
235
+ npm run check
236
+ npm run test:browser:matrix
237
+ npm run test:differential
162
238
  npm run conformance:drift
163
239
  npm run fuzz
164
240
  npm run benchmark
165
- npm run pack:test
166
241
  ```
167
242
 
168
- `npm test` runs unit, deterministic fuzz, and local Chromium projects. Use
169
- `npm run test:browser:matrix` on a machine with all Playwright dependencies to
170
- run Chromium, Firefox, and WebKit. The browser matrix also runs a deterministic,
171
- grammar-oriented declaration differential; any minimized mismatch must become
172
- an immutable Operation Fixture with an explicit Compatibility Resolution.
173
- `npm run docs:build` generates the TypeDoc reference under `site/api`. The benchmark gates both a 10,000-rule stress case
174
- and a publisher-shaped reference workload with one shared stylesheet, 20 page
175
- stylesheets, nested layers/media, distributed mutations, and two idempotent
176
- serialization passes.
243
+ `npm run check` covers types, public unit behavior, conformance documents, API
244
+ documentation, build output, runtime artifacts, and the packed-package smoke
245
+ test. Use `npm run test:browser:matrix` on a machine with all Playwright
246
+ dependencies to run Chromium, Firefox, and WebKit. CI separately runs
247
+ `npm run test:differential`, a deterministic, grammar-oriented declaration
248
+ differential with native-browser reparsing witnesses. Any minimized mismatch
249
+ must become an immutable Operation Fixture with an explicit Compatibility
250
+ Resolution.
251
+
252
+ `npm run docs:build` generates the TypeDoc reference under `site/api`. The
253
+ benchmark gates both a 10,000-rule stress case and a publisher-shaped reference
254
+ workload with one shared stylesheet, 20 page stylesheets, nested layers/media,
255
+ distributed mutations, and two idempotent serialization passes.
177
256
 
178
257
  Only the latest published `0.x` minor and its active prereleases receive fixes
179
258
  before 1.0. During `0.x`, observable compatibility corrections and interface