@chikx/compiler 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +40 -2
- package/dist/emitter/index.d.ts +96 -0
- package/dist/emitter/index.d.ts.map +1 -0
- package/dist/emitter/index.js +415 -0
- package/dist/emitter/index.js.map +1 -0
- package/dist/formatter/index.d.ts +53 -0
- package/dist/formatter/index.d.ts.map +1 -0
- package/dist/formatter/index.js +464 -0
- package/dist/formatter/index.js.map +1 -0
- package/dist/host/node.d.ts +34 -0
- package/dist/host/node.d.ts.map +1 -0
- package/dist/host/node.js +80 -0
- package/dist/host/node.js.map +1 -0
- package/dist/index.d.ts +93 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +792 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/factories.d.ts +35 -0
- package/dist/ir/factories.d.ts.map +1 -0
- package/dist/ir/factories.js +47 -0
- package/dist/ir/factories.js.map +1 -0
- package/dist/ir/index.d.ts +13 -0
- package/dist/ir/index.d.ts.map +1 -0
- package/dist/ir/index.js +2 -0
- package/dist/ir/index.js.map +1 -0
- package/dist/ir/types.d.ts +139 -0
- package/dist/ir/types.d.ts.map +1 -0
- package/dist/ir/types.js +2 -0
- package/dist/ir/types.js.map +1 -0
- package/dist/lexer/at-keywords.d.ts +27 -0
- package/dist/lexer/at-keywords.d.ts.map +1 -0
- package/dist/lexer/at-keywords.js +35 -0
- package/dist/lexer/at-keywords.js.map +1 -0
- package/dist/lexer/characters.d.ts +38 -0
- package/dist/lexer/characters.d.ts.map +1 -0
- package/dist/lexer/characters.js +74 -0
- package/dist/lexer/characters.js.map +1 -0
- package/dist/lexer/comments.d.ts +22 -0
- package/dist/lexer/comments.d.ts.map +1 -0
- package/dist/lexer/comments.js +20 -0
- package/dist/lexer/comments.js.map +1 -0
- package/dist/lexer/diagnostics.d.ts +24 -0
- package/dist/lexer/diagnostics.d.ts.map +1 -0
- package/dist/lexer/diagnostics.js +29 -0
- package/dist/lexer/diagnostics.js.map +1 -0
- package/dist/lexer/dollar-refs.d.ts +13 -0
- package/dist/lexer/dollar-refs.d.ts.map +1 -0
- package/dist/lexer/dollar-refs.js +22 -0
- package/dist/lexer/dollar-refs.js.map +1 -0
- package/dist/lexer/index.d.ts +32 -0
- package/dist/lexer/index.d.ts.map +1 -0
- package/dist/lexer/index.js +26 -0
- package/dist/lexer/index.js.map +1 -0
- package/dist/lexer/names.d.ts +23 -0
- package/dist/lexer/names.d.ts.map +1 -0
- package/dist/lexer/names.js +48 -0
- package/dist/lexer/names.js.map +1 -0
- package/dist/lexer/numbers.d.ts +22 -0
- package/dist/lexer/numbers.d.ts.map +1 -0
- package/dist/lexer/numbers.js +60 -0
- package/dist/lexer/numbers.js.map +1 -0
- package/dist/lexer/scanner.d.ts +30 -0
- package/dist/lexer/scanner.d.ts.map +1 -0
- package/dist/lexer/scanner.js +158 -0
- package/dist/lexer/scanner.js.map +1 -0
- package/dist/lexer/strings.d.ts +25 -0
- package/dist/lexer/strings.d.ts.map +1 -0
- package/dist/lexer/strings.js +41 -0
- package/dist/lexer/strings.js.map +1 -0
- package/dist/lexer/urls.d.ts +28 -0
- package/dist/lexer/urls.d.ts.map +1 -0
- package/dist/lexer/urls.js +54 -0
- package/dist/lexer/urls.js.map +1 -0
- package/dist/lowering/expand-groups.d.ts +61 -0
- package/dist/lowering/expand-groups.d.ts.map +1 -0
- package/dist/lowering/expand-groups.js +117 -0
- package/dist/lowering/expand-groups.js.map +1 -0
- package/dist/lowering/group.d.ts +30 -0
- package/dist/lowering/group.d.ts.map +1 -0
- package/dist/lowering/group.js +109 -0
- package/dist/lowering/group.js.map +1 -0
- package/dist/lowering/index.d.ts +26 -0
- package/dist/lowering/index.d.ts.map +1 -0
- package/dist/lowering/index.js +23 -0
- package/dist/lowering/index.js.map +1 -0
- package/dist/lowering/lower.d.ts +21 -0
- package/dist/lowering/lower.d.ts.map +1 -0
- package/dist/lowering/lower.js +296 -0
- package/dist/lowering/lower.js.map +1 -0
- package/dist/lowering/media.d.ts +63 -0
- package/dist/lowering/media.d.ts.map +1 -0
- package/dist/lowering/media.js +237 -0
- package/dist/lowering/media.js.map +1 -0
- package/dist/lowering/merge.d.ts +35 -0
- package/dist/lowering/merge.d.ts.map +1 -0
- package/dist/lowering/merge.js +146 -0
- package/dist/lowering/merge.js.map +1 -0
- package/dist/lowering/property-families.d.ts +50 -0
- package/dist/lowering/property-families.d.ts.map +1 -0
- package/dist/lowering/property-families.js +175 -0
- package/dist/lowering/property-families.js.map +1 -0
- package/dist/lowering/spans.d.ts +36 -0
- package/dist/lowering/spans.d.ts.map +1 -0
- package/dist/lowering/spans.js +100 -0
- package/dist/lowering/spans.js.map +1 -0
- package/dist/naming/index.d.ts +37 -0
- package/dist/naming/index.d.ts.map +1 -0
- package/dist/naming/index.js +34 -0
- package/dist/naming/index.js.map +1 -0
- package/dist/naming/mapgen.d.ts +70 -0
- package/dist/naming/mapgen.d.ts.map +1 -0
- package/dist/naming/mapgen.js +153 -0
- package/dist/naming/mapgen.js.map +1 -0
- package/dist/naming/merge.d.ts +62 -0
- package/dist/naming/merge.d.ts.map +1 -0
- package/dist/naming/merge.js +77 -0
- package/dist/naming/merge.js.map +1 -0
- package/dist/naming/rewrite.d.ts +14 -0
- package/dist/naming/rewrite.d.ts.map +1 -0
- package/dist/naming/rewrite.js +191 -0
- package/dist/naming/rewrite.js.map +1 -0
- package/dist/naming/scan.d.ts +80 -0
- package/dist/naming/scan.d.ts.map +1 -0
- package/dist/naming/scan.js +193 -0
- package/dist/naming/scan.js.map +1 -0
- package/dist/naming/table.d.ts +68 -0
- package/dist/naming/table.d.ts.map +1 -0
- package/dist/naming/table.js +132 -0
- package/dist/naming/table.js.map +1 -0
- package/dist/naming/types.d.ts +94 -0
- package/dist/naming/types.d.ts.map +1 -0
- package/dist/naming/types.js +2 -0
- package/dist/naming/types.js.map +1 -0
- package/dist/output/import-path.d.ts +24 -0
- package/dist/output/import-path.d.ts.map +1 -0
- package/dist/output/import-path.js +30 -0
- package/dist/output/import-path.js.map +1 -0
- package/dist/output/importPath.d.ts +27 -0
- package/dist/output/importPath.d.ts.map +1 -0
- package/dist/output/importPath.js +84 -0
- package/dist/output/importPath.js.map +1 -0
- package/dist/output/index.d.ts +40 -0
- package/dist/output/index.d.ts.map +1 -0
- package/dist/output/index.js +138 -0
- package/dist/output/index.js.map +1 -0
- package/dist/output/manifest.d.ts +17 -0
- package/dist/output/manifest.d.ts.map +1 -0
- package/dist/output/manifest.js +22 -0
- package/dist/output/manifest.js.map +1 -0
- package/dist/output/paths.d.ts +54 -0
- package/dist/output/paths.d.ts.map +1 -0
- package/dist/output/paths.js +183 -0
- package/dist/output/paths.js.map +1 -0
- package/dist/output/resolve.d.ts +100 -0
- package/dist/output/resolve.d.ts.map +1 -0
- package/dist/output/resolve.js +313 -0
- package/dist/output/resolve.js.map +1 -0
- package/dist/output/validate.d.ts +82 -0
- package/dist/output/validate.d.ts.map +1 -0
- package/dist/output/validate.js +128 -0
- package/dist/output/validate.js.map +1 -0
- package/dist/parser/cursor.d.ts +55 -0
- package/dist/parser/cursor.d.ts.map +1 -0
- package/dist/parser/cursor.js +120 -0
- package/dist/parser/cursor.js.map +1 -0
- package/dist/parser/declaration.d.ts +21 -0
- package/dist/parser/declaration.d.ts.map +1 -0
- package/dist/parser/declaration.js +201 -0
- package/dist/parser/declaration.js.map +1 -0
- package/dist/parser/diagnostics.d.ts +52 -0
- package/dist/parser/diagnostics.d.ts.map +1 -0
- package/dist/parser/diagnostics.js +55 -0
- package/dist/parser/diagnostics.js.map +1 -0
- package/dist/parser/group.d.ts +26 -0
- package/dist/parser/group.d.ts.map +1 -0
- package/dist/parser/group.js +219 -0
- package/dist/parser/group.js.map +1 -0
- package/dist/parser/index.d.ts +30 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +48 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/parser/modifier.d.ts +25 -0
- package/dist/parser/modifier.d.ts.map +1 -0
- package/dist/parser/modifier.js +41 -0
- package/dist/parser/modifier.js.map +1 -0
- package/dist/parser/recovery.d.ts +23 -0
- package/dist/parser/recovery.d.ts.map +1 -0
- package/dist/parser/recovery.js +80 -0
- package/dist/parser/recovery.js.map +1 -0
- package/dist/parser/rule.d.ts +39 -0
- package/dist/parser/rule.d.ts.map +1 -0
- package/dist/parser/rule.js +337 -0
- package/dist/parser/rule.js.map +1 -0
- package/dist/parser/statement.d.ts +21 -0
- package/dist/parser/statement.d.ts.map +1 -0
- package/dist/parser/statement.js +48 -0
- package/dist/parser/statement.js.map +1 -0
- package/dist/parser/statements.d.ts +33 -0
- package/dist/parser/statements.d.ts.map +1 -0
- package/dist/parser/statements.js +605 -0
- package/dist/parser/statements.js.map +1 -0
- package/dist/parser/value.d.ts +57 -0
- package/dist/parser/value.d.ts.map +1 -0
- package/dist/parser/value.js +226 -0
- package/dist/parser/value.js.map +1 -0
- package/dist/resolver/graph.d.ts +20 -0
- package/dist/resolver/graph.d.ts.map +1 -0
- package/dist/resolver/graph.js +382 -0
- package/dist/resolver/graph.js.map +1 -0
- package/dist/resolver/groups.d.ts +70 -0
- package/dist/resolver/groups.d.ts.map +1 -0
- package/dist/resolver/groups.js +143 -0
- package/dist/resolver/groups.js.map +1 -0
- package/dist/resolver/index.d.ts +46 -0
- package/dist/resolver/index.d.ts.map +1 -0
- package/dist/resolver/index.js +46 -0
- package/dist/resolver/index.js.map +1 -0
- package/dist/resolver/keyframes.d.ts +56 -0
- package/dist/resolver/keyframes.d.ts.map +1 -0
- package/dist/resolver/keyframes.js +102 -0
- package/dist/resolver/keyframes.js.map +1 -0
- package/dist/resolver/paths.d.ts +37 -0
- package/dist/resolver/paths.d.ts.map +1 -0
- package/dist/resolver/paths.js +135 -0
- package/dist/resolver/paths.js.map +1 -0
- package/dist/resolver/rules.d.ts +34 -0
- package/dist/resolver/rules.d.ts.map +1 -0
- package/dist/resolver/rules.js +52 -0
- package/dist/resolver/rules.js.map +1 -0
- package/dist/resolver/scopes.d.ts +44 -0
- package/dist/resolver/scopes.d.ts.map +1 -0
- package/dist/resolver/scopes.js +213 -0
- package/dist/resolver/scopes.js.map +1 -0
- package/dist/resolver/types.d.ts +238 -0
- package/dist/resolver/types.d.ts.map +1 -0
- package/dist/resolver/types.js +11 -0
- package/dist/resolver/types.js.map +1 -0
- package/dist/selectors/flatten.d.ts +95 -0
- package/dist/selectors/flatten.d.ts.map +1 -0
- package/dist/selectors/flatten.js +384 -0
- package/dist/selectors/flatten.js.map +1 -0
- package/dist/selectors/index.d.ts +15 -0
- package/dist/selectors/index.d.ts.map +1 -0
- package/dist/selectors/index.js +14 -0
- package/dist/selectors/index.js.map +1 -0
- package/dist/selectors/scan.d.ts +54 -0
- package/dist/selectors/scan.d.ts.map +1 -0
- package/dist/selectors/scan.js +191 -0
- package/dist/selectors/scan.js.map +1 -0
- package/dist/selectors/specificity.d.ts +28 -0
- package/dist/selectors/specificity.d.ts.map +1 -0
- package/dist/selectors/specificity.js +297 -0
- package/dist/selectors/specificity.js.map +1 -0
- package/dist/setup-list.d.ts +41 -0
- package/dist/setup-list.d.ts.map +1 -0
- package/dist/setup-list.js +122 -0
- package/dist/setup-list.js.map +1 -0
- package/dist/sourcemaps/index.d.ts +14 -0
- package/dist/sourcemaps/index.d.ts.map +1 -0
- package/dist/sourcemaps/index.js +13 -0
- package/dist/sourcemaps/index.js.map +1 -0
- package/dist/sourcemaps/mappings.d.ts +77 -0
- package/dist/sourcemaps/mappings.d.ts.map +1 -0
- package/dist/sourcemaps/mappings.js +124 -0
- package/dist/sourcemaps/mappings.js.map +1 -0
- package/dist/sourcemaps/vlq.d.ts +12 -0
- package/dist/sourcemaps/vlq.d.ts.map +1 -0
- package/dist/sourcemaps/vlq.js +29 -0
- package/dist/sourcemaps/vlq.js.map +1 -0
- package/dist/types/ast.d.ts +291 -0
- package/dist/types/ast.d.ts.map +1 -0
- package/dist/types/ast.js +2 -0
- package/dist/types/ast.js.map +1 -0
- package/dist/types/diagnostics.d.ts +55 -0
- package/dist/types/diagnostics.d.ts.map +1 -0
- package/dist/types/diagnostics.js +61 -0
- package/dist/types/diagnostics.js.map +1 -0
- package/dist/types/options.d.ts +274 -0
- package/dist/types/options.d.ts.map +1 -0
- package/dist/types/options.js +11 -0
- package/dist/types/options.js.map +1 -0
- package/dist/types/result.d.ts +112 -0
- package/dist/types/result.d.ts.map +1 -0
- package/dist/types/result.js +2 -0
- package/dist/types/result.js.map +1 -0
- package/dist/types/span.d.ts +19 -0
- package/dist/types/span.d.ts.map +1 -0
- package/dist/types/span.js +2 -0
- package/dist/types/span.js.map +1 -0
- package/dist/types/token.d.ts +68 -0
- package/dist/types/token.d.ts.map +1 -0
- package/dist/types/token.js +2 -0
- package/dist/types/token.js.map +1 -0
- package/dist/variables/ast.d.ts +56 -0
- package/dist/variables/ast.d.ts.map +1 -0
- package/dist/variables/ast.js +167 -0
- package/dist/variables/ast.js.map +1 -0
- package/dist/variables/expand.d.ts +109 -0
- package/dist/variables/expand.d.ts.map +1 -0
- package/dist/variables/expand.js +213 -0
- package/dist/variables/expand.js.map +1 -0
- package/dist/variables/index.d.ts +36 -0
- package/dist/variables/index.d.ts.map +1 -0
- package/dist/variables/index.js +33 -0
- package/dist/variables/index.js.map +1 -0
- package/dist/variables/naming.d.ts +39 -0
- package/dist/variables/naming.d.ts.map +1 -0
- package/dist/variables/naming.js +14 -0
- package/dist/variables/naming.js.map +1 -0
- package/dist/variables/runtime.d.ts +81 -0
- package/dist/variables/runtime.d.ts.map +1 -0
- package/dist/variables/runtime.js +228 -0
- package/dist/variables/runtime.js.map +1 -0
- package/dist/variables/substitute.d.ts +65 -0
- package/dist/variables/substitute.d.ts.map +1 -0
- package/dist/variables/substitute.js +73 -0
- package/dist/variables/substitute.js.map +1 -0
- package/dist/variables/walk.d.ts +37 -0
- package/dist/variables/walk.d.ts.map +1 -0
- package/dist/variables/walk.js +113 -0
- package/dist/variables/walk.js.map +1 -0
- package/package.json +35 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in merge grouping (ADR-0024; SPECIFICATION.md §5.3).
|
|
3
|
+
*
|
|
4
|
+
* `safe` grouping only joins *adjacent* identical runs. `merge` keeps that pass
|
|
5
|
+
* and then, for conditional runs only, moves a declaration run into a later run
|
|
6
|
+
* with the **same selector chain, condition string and native at-rule context**
|
|
7
|
+
* when every declaration of every run strictly between them belongs to a
|
|
8
|
+
* property family disjoint from every declaration of the moved run.
|
|
9
|
+
*
|
|
10
|
+
* Why this cannot change a cascade winner:
|
|
11
|
+
*
|
|
12
|
+
* - A winner is decided per property. If the two families are disjoint, no
|
|
13
|
+
* crossed declaration can compete for the moved declaration's property.
|
|
14
|
+
* - The moved run lands *before* the destination run's own declarations, so the
|
|
15
|
+
* relative order of the source and destination is preserved; selector
|
|
16
|
+
* specificity, condition overlap, `@layer` order and `!important` are
|
|
17
|
+
* unchanged by moving a declaration past a different property.
|
|
18
|
+
* - Native blocks are barriers: children of one block are merged among
|
|
19
|
+
* themselves, never across the block boundary, so native context identity is
|
|
20
|
+
* preserved.
|
|
21
|
+
*
|
|
22
|
+
* Wildcards (`all`, or a value containing `var(`) are never moved and nothing
|
|
23
|
+
* crosses them (see `property-families.ts`). A missed merge is acceptable; a
|
|
24
|
+
* changed cascade is not.
|
|
25
|
+
*/
|
|
26
|
+
import type { StylesheetIr } from "../ir/types.js";
|
|
27
|
+
/**
|
|
28
|
+
* Apply merge grouping to an already safe-grouped stylesheet.
|
|
29
|
+
*
|
|
30
|
+
* The public `groupRuns(ir, "merge")` entry point runs the safe adjacent pass
|
|
31
|
+
* first, so `merge` is always a superset of `safe`. This function only adds the
|
|
32
|
+
* cross-run pass and never merges unconditional runs.
|
|
33
|
+
*/
|
|
34
|
+
export declare function mergeRuns(ir: StylesheetIr): StylesheetIr;
|
|
35
|
+
//# sourceMappingURL=merge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.d.ts","sourceRoot":"","sources":["../../src/lowering/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAGH,OAAO,KAAK,EAKV,YAAY,EACb,MAAM,gBAAgB,CAAC;AAsHxB;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,YAAY,GAAG,YAAY,CAIxD"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Opt-in merge grouping (ADR-0024; SPECIFICATION.md §5.3).
|
|
3
|
+
*
|
|
4
|
+
* `safe` grouping only joins *adjacent* identical runs. `merge` keeps that pass
|
|
5
|
+
* and then, for conditional runs only, moves a declaration run into a later run
|
|
6
|
+
* with the **same selector chain, condition string and native at-rule context**
|
|
7
|
+
* when every declaration of every run strictly between them belongs to a
|
|
8
|
+
* property family disjoint from every declaration of the moved run.
|
|
9
|
+
*
|
|
10
|
+
* Why this cannot change a cascade winner:
|
|
11
|
+
*
|
|
12
|
+
* - A winner is decided per property. If the two families are disjoint, no
|
|
13
|
+
* crossed declaration can compete for the moved declaration's property.
|
|
14
|
+
* - The moved run lands *before* the destination run's own declarations, so the
|
|
15
|
+
* relative order of the source and destination is preserved; selector
|
|
16
|
+
* specificity, condition overlap, `@layer` order and `!important` are
|
|
17
|
+
* unchanged by moving a declaration past a different property.
|
|
18
|
+
* - Native blocks are barriers: children of one block are merged among
|
|
19
|
+
* themselves, never across the block boundary, so native context identity is
|
|
20
|
+
* preserved.
|
|
21
|
+
*
|
|
22
|
+
* Wildcards (`all`, or a value containing `var(`) are never moved and nothing
|
|
23
|
+
* crosses them (see `property-families.ts`). A missed merge is acceptable; a
|
|
24
|
+
* changed cascade is not.
|
|
25
|
+
*/
|
|
26
|
+
import { nativeBlockIr, ruleIr, stylesheetIr } from "../ir/factories.js";
|
|
27
|
+
import { propertyFamily } from "./property-families.js";
|
|
28
|
+
import { sameAncestors, sameContext } from "./spans.js";
|
|
29
|
+
/** One run's family set, or `null` when it contains a wildcard declaration. */
|
|
30
|
+
function runFamilies(declarations) {
|
|
31
|
+
const families = new Set();
|
|
32
|
+
for (const declaration of declarations) {
|
|
33
|
+
const family = propertyFamily(declaration.property, declaration.value);
|
|
34
|
+
if (family === null)
|
|
35
|
+
return null;
|
|
36
|
+
families.add(family);
|
|
37
|
+
}
|
|
38
|
+
return families;
|
|
39
|
+
}
|
|
40
|
+
/** Whether two family sets share any property family. */
|
|
41
|
+
function intersects(left, right) {
|
|
42
|
+
for (const family of left) {
|
|
43
|
+
if (right.has(family))
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
return false;
|
|
47
|
+
}
|
|
48
|
+
/** Whether a run may participate in a merge as a destination. */
|
|
49
|
+
function isConditionalRun(rule) {
|
|
50
|
+
return rule.condition !== null && rule.condition.query !== "";
|
|
51
|
+
}
|
|
52
|
+
/** Identical selector chain, condition string and native context. */
|
|
53
|
+
function sameMergeRun(source, destination) {
|
|
54
|
+
return (source.selector === destination.selector &&
|
|
55
|
+
sameAncestors(source.ancestors, destination.ancestors) &&
|
|
56
|
+
sameContext(source.context, destination.context) &&
|
|
57
|
+
source.condition !== null &&
|
|
58
|
+
destination.condition !== null &&
|
|
59
|
+
source.condition.query === destination.condition.query);
|
|
60
|
+
}
|
|
61
|
+
/** Move the source declarations into the destination block, source first. */
|
|
62
|
+
function mergeInto(source, destination) {
|
|
63
|
+
return ruleIr({
|
|
64
|
+
selector: destination.selector,
|
|
65
|
+
ancestors: destination.ancestors,
|
|
66
|
+
declarations: [...source.declarations, ...destination.declarations],
|
|
67
|
+
condition: destination.condition,
|
|
68
|
+
context: destination.context,
|
|
69
|
+
span: destination.span,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Merge non-adjacent conditional runs in one sibling list to a fixpoint.
|
|
74
|
+
*
|
|
75
|
+
* Greedy and deterministic: the lowest source index wins, then the lowest valid
|
|
76
|
+
* destination index. Every merge removes one node, so the loop terminates.
|
|
77
|
+
*/
|
|
78
|
+
function mergeSiblingRuns(nodes) {
|
|
79
|
+
const result = [...nodes];
|
|
80
|
+
let merged = true;
|
|
81
|
+
while (merged) {
|
|
82
|
+
merged = false;
|
|
83
|
+
for (let sourceIndex = 0; sourceIndex < result.length && !merged; sourceIndex += 1) {
|
|
84
|
+
const source = result[sourceIndex];
|
|
85
|
+
if (source === undefined || !("declarations" in source) || !isConditionalRun(source)) {
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
const sourceFamilies = runFamilies(source.declarations);
|
|
89
|
+
if (sourceFamilies === null)
|
|
90
|
+
continue;
|
|
91
|
+
for (let destinationIndex = sourceIndex + 1; destinationIndex < result.length; destinationIndex += 1) {
|
|
92
|
+
const candidate = result[destinationIndex];
|
|
93
|
+
if (candidate === undefined)
|
|
94
|
+
break;
|
|
95
|
+
if (!("declarations" in candidate)) {
|
|
96
|
+
// A native block or descriptor declaration is a hard barrier: no
|
|
97
|
+
// later sibling can be reached without changing native context.
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
if (isConditionalRun(candidate) &&
|
|
101
|
+
sameMergeRun(source, candidate) &&
|
|
102
|
+
runFamilies(candidate.declarations) !== null) {
|
|
103
|
+
result[destinationIndex] = mergeInto(source, candidate);
|
|
104
|
+
result.splice(sourceIndex, 1);
|
|
105
|
+
merged = true;
|
|
106
|
+
break;
|
|
107
|
+
}
|
|
108
|
+
// The candidate is an intervening run. A wildcard or a shared family
|
|
109
|
+
// blocks this source (and every later destination).
|
|
110
|
+
const crossed = runFamilies(candidate.declarations);
|
|
111
|
+
if (crossed === null || intersects(crossed, sourceFamilies))
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return result;
|
|
117
|
+
}
|
|
118
|
+
/** Recurse into native blocks, then merge each sibling list independently. */
|
|
119
|
+
function mergeChildren(children) {
|
|
120
|
+
const rebuilt = children.map((child) => {
|
|
121
|
+
if (!("children" in child))
|
|
122
|
+
return child;
|
|
123
|
+
if (child.statement === true)
|
|
124
|
+
return child;
|
|
125
|
+
return nativeBlockIr({
|
|
126
|
+
name: child.name,
|
|
127
|
+
prelude: child.prelude,
|
|
128
|
+
children: mergeChildren(child.children),
|
|
129
|
+
span: child.span,
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
return mergeSiblingRuns(rebuilt);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Apply merge grouping to an already safe-grouped stylesheet.
|
|
136
|
+
*
|
|
137
|
+
* The public `groupRuns(ir, "merge")` entry point runs the safe adjacent pass
|
|
138
|
+
* first, so `merge` is always a superset of `safe`. This function only adds the
|
|
139
|
+
* cross-run pass and never merges unconditional runs.
|
|
140
|
+
*/
|
|
141
|
+
export function mergeRuns(ir) {
|
|
142
|
+
// Top-level stylesheets hold only rules and native blocks; the child helper's
|
|
143
|
+
// wider `NativeBlockChild` type exists for descriptor at-rules.
|
|
144
|
+
return stylesheetIr(mergeChildren(ir.rules));
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=merge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"merge.js","sourceRoot":"","sources":["../../src/lowering/merge.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQzE,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAExD,+EAA+E;AAC/E,SAAS,WAAW,CAAC,YAAsC;IACzD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE,CAAC;QACvC,MAAM,MAAM,GAAG,cAAc,CAAC,WAAW,CAAC,QAAQ,EAAE,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|
+
/**
|
|
2
|
+
* Property-family classification for cascade-safe media-run merging (ADR-0024).
|
|
3
|
+
*
|
|
4
|
+
* The merge optimizer may move a conditional declaration run past intervening
|
|
5
|
+
* declarations only when no crossed declaration can compete for the same
|
|
6
|
+
* computed property. CSS cascade competition is per property: a winner for
|
|
7
|
+
* `color` never changes the winner for `padding`. A conservative *family*
|
|
8
|
+
* therefore groups every property that can write the same underlying value:
|
|
9
|
+
*
|
|
10
|
+
* - strip one vendor prefix (`-webkit-`, `-moz-`, `-ms-`, `-o-`);
|
|
11
|
+
* - take the segment before the first `-` (`background-color` → `background`,
|
|
12
|
+
* `border-left-color` → `border`, `grid-template-columns` → `grid`,
|
|
13
|
+
* `margin-block` → `margin`);
|
|
14
|
+
* - keep a custom property's full name (`--brand` is its own family and is
|
|
15
|
+
* case-sensitive).
|
|
16
|
+
*
|
|
17
|
+
* Standard shorthands share their longhands' first segment (`background`,
|
|
18
|
+
* `border`, `font`, `grid`, `margin`, `mask`, `outline`, `transition`, …), so
|
|
19
|
+
* the prefix rule already blocks shorthand/longhand competition. The frozen
|
|
20
|
+
* {@link SHORTHAND_FAMILIES} table covers the standard properties whose
|
|
21
|
+
* longhands do **not** share that segment (`inset` vs `top`, `place-*` vs
|
|
22
|
+
* `align-*`/`justify-*`, `columns` vs `column-count`, `gap` vs `row-gap`,
|
|
23
|
+
* `white-space` vs `text-wrap`, `font` vs `line-height`, logical `inline-size`
|
|
24
|
+
* vs `width`, and the legacy aliases) plus the legacy vendor spellings of the
|
|
25
|
+
* same values. Collapsing those groups is deliberately conservative: `width`
|
|
26
|
+
* and `height` never compete, but both use the synthetic `size` family.
|
|
27
|
+
*
|
|
28
|
+
* Two declaration classes are **wildcards** and are never mergeable and never
|
|
29
|
+
* crossed:
|
|
30
|
+
*
|
|
31
|
+
* - the `all` property, which resets every property; and
|
|
32
|
+
* - any declaration whose value contains `var(`, because a custom property set
|
|
33
|
+
* by a crossed declaration could change the substituted value.
|
|
34
|
+
*
|
|
35
|
+
* Unknown *cross-prefix* shorthands are the documented limit of this
|
|
36
|
+
* approximation (ADR-0024): a missed merge is acceptable, a wrong cascade is
|
|
37
|
+
* not. Extend the frozen table when a new such property enters the language;
|
|
38
|
+
* do not add speculative heuristics here.
|
|
39
|
+
*/
|
|
40
|
+
/**
|
|
41
|
+
* Family of one declaration, or `null` when the declaration is a wildcard.
|
|
42
|
+
*
|
|
43
|
+
* @param property Authored property name, custom properties included.
|
|
44
|
+
* @param value Authored value slice; `!important` does not affect the result.
|
|
45
|
+
* @returns The conservative family key, or `null` for `all`/`var()` barriers.
|
|
46
|
+
*/
|
|
47
|
+
export declare function propertyFamily(property: string, value: string): string | null;
|
|
48
|
+
/** Whether one declaration is a wildcard barrier (`all` or a `var()` value). */
|
|
49
|
+
export declare function isWildcardDeclaration(property: string, value: string): boolean;
|
|
50
|
+
//# sourceMappingURL=property-families.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-families.d.ts","sourceRoot":"","sources":["../../src/lowering/property-families.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAyHH;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsB7E;AAED,gFAAgF;AAChF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAE9E"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Property-family classification for cascade-safe media-run merging (ADR-0024).
|
|
3
|
+
*
|
|
4
|
+
* The merge optimizer may move a conditional declaration run past intervening
|
|
5
|
+
* declarations only when no crossed declaration can compete for the same
|
|
6
|
+
* computed property. CSS cascade competition is per property: a winner for
|
|
7
|
+
* `color` never changes the winner for `padding`. A conservative *family*
|
|
8
|
+
* therefore groups every property that can write the same underlying value:
|
|
9
|
+
*
|
|
10
|
+
* - strip one vendor prefix (`-webkit-`, `-moz-`, `-ms-`, `-o-`);
|
|
11
|
+
* - take the segment before the first `-` (`background-color` → `background`,
|
|
12
|
+
* `border-left-color` → `border`, `grid-template-columns` → `grid`,
|
|
13
|
+
* `margin-block` → `margin`);
|
|
14
|
+
* - keep a custom property's full name (`--brand` is its own family and is
|
|
15
|
+
* case-sensitive).
|
|
16
|
+
*
|
|
17
|
+
* Standard shorthands share their longhands' first segment (`background`,
|
|
18
|
+
* `border`, `font`, `grid`, `margin`, `mask`, `outline`, `transition`, …), so
|
|
19
|
+
* the prefix rule already blocks shorthand/longhand competition. The frozen
|
|
20
|
+
* {@link SHORTHAND_FAMILIES} table covers the standard properties whose
|
|
21
|
+
* longhands do **not** share that segment (`inset` vs `top`, `place-*` vs
|
|
22
|
+
* `align-*`/`justify-*`, `columns` vs `column-count`, `gap` vs `row-gap`,
|
|
23
|
+
* `white-space` vs `text-wrap`, `font` vs `line-height`, logical `inline-size`
|
|
24
|
+
* vs `width`, and the legacy aliases) plus the legacy vendor spellings of the
|
|
25
|
+
* same values. Collapsing those groups is deliberately conservative: `width`
|
|
26
|
+
* and `height` never compete, but both use the synthetic `size` family.
|
|
27
|
+
*
|
|
28
|
+
* Two declaration classes are **wildcards** and are never mergeable and never
|
|
29
|
+
* crossed:
|
|
30
|
+
*
|
|
31
|
+
* - the `all` property, which resets every property; and
|
|
32
|
+
* - any declaration whose value contains `var(`, because a custom property set
|
|
33
|
+
* by a crossed declaration could change the substituted value.
|
|
34
|
+
*
|
|
35
|
+
* Unknown *cross-prefix* shorthands are the documented limit of this
|
|
36
|
+
* approximation (ADR-0024): a missed merge is acceptable, a wrong cascade is
|
|
37
|
+
* not. Extend the frozen table when a new such property enters the language;
|
|
38
|
+
* do not add speculative heuristics here.
|
|
39
|
+
*/
|
|
40
|
+
/** Vendor prefixes the family rule strips, in the ADR-0024 order. */
|
|
41
|
+
const VENDOR_PREFIX = /^-(?:webkit|moz|ms|o)-/;
|
|
42
|
+
/** A `var()` substitution makes a declaration depend on crossed declarations. */
|
|
43
|
+
const VAR_REFERENCE = /var\s*\(/i;
|
|
44
|
+
/**
|
|
45
|
+
* Frozen equivalence families for shorthands, logical properties and legacy
|
|
46
|
+
* aliases whose members do not share the first textual segment.
|
|
47
|
+
*
|
|
48
|
+
* Values are the family names `propertyFamily` compares. A key is the
|
|
49
|
+
* unprefixed, lowercased property name. Entries intentionally over-block
|
|
50
|
+
* (for example `width`/`height` share `size`); they never under-block a known
|
|
51
|
+
* shorthand relationship.
|
|
52
|
+
*/
|
|
53
|
+
const SHORTHAND_FAMILIES = Object.freeze({
|
|
54
|
+
// `inset` and the physical offsets it expands to.
|
|
55
|
+
top: "inset",
|
|
56
|
+
right: "inset",
|
|
57
|
+
bottom: "inset",
|
|
58
|
+
left: "inset",
|
|
59
|
+
// Logical sizing competes with physical `width`/`height`; over-block both.
|
|
60
|
+
width: "size",
|
|
61
|
+
height: "size",
|
|
62
|
+
"inline-size": "size",
|
|
63
|
+
"block-size": "size",
|
|
64
|
+
"logical-width": "size",
|
|
65
|
+
"logical-height": "size",
|
|
66
|
+
"min-logical-width": "min",
|
|
67
|
+
"max-logical-width": "max",
|
|
68
|
+
"min-logical-height": "min",
|
|
69
|
+
"max-logical-height": "max",
|
|
70
|
+
// `place-*` shorthands expand into the `align-*` and `justify-*` longhands.
|
|
71
|
+
"align-content": "align",
|
|
72
|
+
"align-items": "align",
|
|
73
|
+
"align-self": "align",
|
|
74
|
+
"justify-content": "align",
|
|
75
|
+
"justify-items": "align",
|
|
76
|
+
"justify-self": "align",
|
|
77
|
+
"place-content": "align",
|
|
78
|
+
"place-items": "align",
|
|
79
|
+
"place-self": "align",
|
|
80
|
+
"flex-align": "align",
|
|
81
|
+
"flex-item-align": "align",
|
|
82
|
+
"flex-line-pack": "align",
|
|
83
|
+
"flex-pack": "align",
|
|
84
|
+
"box-align": "align",
|
|
85
|
+
"box-pack": "align",
|
|
86
|
+
// `gap` expands into row/column gaps; legacy grid-gap spellings follow.
|
|
87
|
+
gap: "gap",
|
|
88
|
+
"row-gap": "gap",
|
|
89
|
+
"column-gap": "gap",
|
|
90
|
+
"grid-gap": "gap",
|
|
91
|
+
"grid-row-gap": "gap",
|
|
92
|
+
"grid-column-gap": "gap",
|
|
93
|
+
// `columns` expands into `column-width` and `column-count`.
|
|
94
|
+
columns: "columns",
|
|
95
|
+
"column-width": "columns",
|
|
96
|
+
"column-count": "columns",
|
|
97
|
+
// `line-clamp` expands into these properties.
|
|
98
|
+
"line-clamp": "line",
|
|
99
|
+
"max-lines": "line",
|
|
100
|
+
"block-ellipsis": "line",
|
|
101
|
+
continue: "line",
|
|
102
|
+
// `white-space` also expands into the `text-wrap-*` longhands.
|
|
103
|
+
"white-space": "white",
|
|
104
|
+
"white-space-collapse": "white",
|
|
105
|
+
"white-space-trim": "white",
|
|
106
|
+
"text-wrap": "white",
|
|
107
|
+
"text-wrap-mode": "white",
|
|
108
|
+
"text-wrap-style": "white",
|
|
109
|
+
// The `font` shorthand resets `line-height`.
|
|
110
|
+
"line-height": "font",
|
|
111
|
+
"line-height-step": "font",
|
|
112
|
+
// Page-break aliases and the fragmentation properties they set.
|
|
113
|
+
"break-before": "break",
|
|
114
|
+
"break-after": "break",
|
|
115
|
+
"break-inside": "break",
|
|
116
|
+
"page-break-before": "break",
|
|
117
|
+
"page-break-after": "break",
|
|
118
|
+
"page-break-inside": "break",
|
|
119
|
+
"column-break-before": "break",
|
|
120
|
+
"column-break-after": "break",
|
|
121
|
+
"column-break-inside": "break",
|
|
122
|
+
// `word-wrap` is the legacy name of `overflow-wrap`.
|
|
123
|
+
"word-wrap": "overflow-wrap",
|
|
124
|
+
"overflow-wrap": "overflow-wrap",
|
|
125
|
+
// `color-adjust` is the legacy name of `print-color-adjust`.
|
|
126
|
+
"color-adjust": "print-color-adjust",
|
|
127
|
+
"print-color-adjust": "print-color-adjust",
|
|
128
|
+
// The legacy `inset-area` name aliases `position-area`.
|
|
129
|
+
"inset-area": "position",
|
|
130
|
+
// The legacy `motion` family aliases the `offset` properties.
|
|
131
|
+
motion: "offset",
|
|
132
|
+
"motion-path": "offset",
|
|
133
|
+
"motion-offset": "offset",
|
|
134
|
+
"motion-rotation": "offset",
|
|
135
|
+
// Legacy `order` and flexbox aliases.
|
|
136
|
+
"flex-order": "order",
|
|
137
|
+
"box-ordinal-group": "order",
|
|
138
|
+
"box-direction": "flex",
|
|
139
|
+
"box-flex": "flex",
|
|
140
|
+
"box-lines": "flex",
|
|
141
|
+
"box-orient": "flex",
|
|
142
|
+
});
|
|
143
|
+
/**
|
|
144
|
+
* Family of one declaration, or `null` when the declaration is a wildcard.
|
|
145
|
+
*
|
|
146
|
+
* @param property Authored property name, custom properties included.
|
|
147
|
+
* @param value Authored value slice; `!important` does not affect the result.
|
|
148
|
+
* @returns The conservative family key, or `null` for `all`/`var()` barriers.
|
|
149
|
+
*/
|
|
150
|
+
export function propertyFamily(property, value) {
|
|
151
|
+
if (VAR_REFERENCE.test(value))
|
|
152
|
+
return null;
|
|
153
|
+
if (property.startsWith("--")) {
|
|
154
|
+
// Custom property names are case-sensitive and never share a family.
|
|
155
|
+
return property;
|
|
156
|
+
}
|
|
157
|
+
const lower = property.trim().toLowerCase();
|
|
158
|
+
if (lower === "" || lower === "all")
|
|
159
|
+
return null;
|
|
160
|
+
const unprefixed = lower.replace(VENDOR_PREFIX, "");
|
|
161
|
+
if (unprefixed.startsWith("-")) {
|
|
162
|
+
// Unknown vendor or malformed property: be safe and treat it as a barrier.
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const override = SHORTHAND_FAMILIES[unprefixed];
|
|
166
|
+
if (override !== undefined)
|
|
167
|
+
return override;
|
|
168
|
+
const dash = unprefixed.indexOf("-");
|
|
169
|
+
return dash < 0 ? unprefixed : unprefixed.slice(0, dash);
|
|
170
|
+
}
|
|
171
|
+
/** Whether one declaration is a wildcard barrier (`all` or a `var()` value). */
|
|
172
|
+
export function isWildcardDeclaration(property, value) {
|
|
173
|
+
return propertyFamily(property, value) === null;
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=property-families.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-families.js","sourceRoot":"","sources":["../../src/lowering/property-families.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,qEAAqE;AACrE,MAAM,aAAa,GAAG,wBAAwB,CAAC;AAE/C,iFAAiF;AACjF,MAAM,aAAa,GAAG,WAAW,CAAC;AAElC;;;;;;;;GAQG;AACH,MAAM,kBAAkB,GAAqC,MAAM,CAAC,MAAM,CAAC;IACzE,kDAAkD;IAClD,GAAG,EAAE,OAAO;IACZ,KAAK,EAAE,OAAO;IACd,MAAM,EAAE,OAAO;IACf,IAAI,EAAE,OAAO;IAEb,2EAA2E;IAC3E,KAAK,EAAE,MAAM;IACb,MAAM,EAAE,MAAM;IACd,aAAa,EAAE,MAAM;IACrB,YAAY,EAAE,MAAM;IACpB,eAAe,EAAE,MAAM;IACvB,gBAAgB,EAAE,MAAM;IACxB,mBAAmB,EAAE,KAAK;IAC1B,mBAAmB,EAAE,KAAK;IAC1B,oBAAoB,EAAE,KAAK;IAC3B,oBAAoB,EAAE,KAAK;IAE3B,4EAA4E;IAC5E,eAAe,EAAE,OAAO;IACxB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,OAAO;IACrB,iBAAiB,EAAE,OAAO;IAC1B,eAAe,EAAE,OAAO;IACxB,cAAc,EAAE,OAAO;IACvB,eAAe,EAAE,OAAO;IACxB,aAAa,EAAE,OAAO;IACtB,YAAY,EAAE,OAAO;IACrB,YAAY,EAAE,OAAO;IACrB,iBAAiB,EAAE,OAAO;IAC1B,gBAAgB,EAAE,OAAO;IACzB,WAAW,EAAE,OAAO;IACpB,WAAW,EAAE,OAAO;IACpB,UAAU,EAAE,OAAO;IAEnB,wEAAwE;IACxE,GAAG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
import type { Declaration, Modifier } from "../types/ast.js";
|
|
3
|
+
import type { Span } from "../types/span.js";
|
|
4
|
+
import type { ConditionAlias } from "./media.js";
|
|
5
|
+
/** Origin of the base segment plus one origin per inline-variant segment. */
|
|
6
|
+
export interface SegmentSpans {
|
|
7
|
+
/** Property through the first modifier (or the whole declaration). */
|
|
8
|
+
readonly base: Span;
|
|
9
|
+
/** One span per variant, in authored order. */
|
|
10
|
+
readonly variants: readonly Span[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Partition a declaration's authored span into segment origins.
|
|
14
|
+
*
|
|
15
|
+
* A segment starts at its modifier and ends at the next modifier, so the
|
|
16
|
+
* segments tile the declaration with no gaps or overlaps. The base segment ends
|
|
17
|
+
* where the first modifier begins. The frozen AST stores no value span for a
|
|
18
|
+
* variant (A04 contract note), so a variant origin necessarily covers its
|
|
19
|
+
* modifier plus the value and separator whitespace that follow it.
|
|
20
|
+
*/
|
|
21
|
+
export declare function declarationSegmentSpans(declaration: Declaration): SegmentSpans;
|
|
22
|
+
/**
|
|
23
|
+
* Exact spans for the aliases of one modifier chain.
|
|
24
|
+
*
|
|
25
|
+
* `@` and `+` are single authored characters, so alias origins can be derived
|
|
26
|
+
* by walking the modifier span in alias order. Escaped alias text keeps its
|
|
27
|
+
* authored length, so the walk stays correct without decoding.
|
|
28
|
+
*/
|
|
29
|
+
export declare function modifierAliasSpans(modifier: Modifier): readonly ConditionAlias[];
|
|
30
|
+
/** Structural equality of two Chikx conditions, used to bound declaration runs. */
|
|
31
|
+
export declare function sameCondition(left: MediaConditionIr | null, right: MediaConditionIr | null): boolean;
|
|
32
|
+
/** Structural equality of two native at-rule context stacks. */
|
|
33
|
+
export declare function sameContext(left: readonly AtRuleContextIr[], right: readonly AtRuleContextIr[]): boolean;
|
|
34
|
+
/** Structural equality of two ancestor selector chains. */
|
|
35
|
+
export declare function sameAncestors(left: readonly string[], right: readonly string[]): boolean;
|
|
36
|
+
//# sourceMappingURL=spans.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spans.d.ts","sourceRoot":"","sources":["../../src/lowering/spans.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAejD,6EAA6E;AAC7E,MAAM,WAAW,YAAY;IAC3B,sEAAsE;IACtE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IACpB,+CAA+C;IAC/C,QAAQ,CAAC,QAAQ,EAAE,SAAS,IAAI,EAAE,CAAC;CACpC;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY,CAwB9E;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,GAAG,SAAS,cAAc,EAAE,CAWhF;AAED,mFAAmF;AACnF,wBAAgB,aAAa,CAC3B,IAAI,EAAE,gBAAgB,GAAG,IAAI,EAC7B,KAAK,EAAE,gBAAgB,GAAG,IAAI,GAC7B,OAAO,CAOT;AAED,gEAAgE;AAChE,wBAAgB,WAAW,CACzB,IAAI,EAAE,SAAS,eAAe,EAAE,EAChC,KAAK,EAAE,SAAS,eAAe,EAAE,GAChC,OAAO,CAUT;AAED,2DAA2D;AAC3D,wBAAgB,aAAa,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAMxF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Span and equality helpers shared by lowering and safe grouping.
|
|
3
|
+
*
|
|
4
|
+
* Everything here is a pure function of AST/IR data: no source text is read
|
|
5
|
+
* back, so spans are derived only from offsets authored by the parser.
|
|
6
|
+
*/
|
|
7
|
+
function clamp(value, minimum, maximum) {
|
|
8
|
+
if (value < minimum)
|
|
9
|
+
return minimum;
|
|
10
|
+
if (value > maximum)
|
|
11
|
+
return maximum;
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Partition a declaration's authored span into segment origins.
|
|
16
|
+
*
|
|
17
|
+
* A segment starts at its modifier and ends at the next modifier, so the
|
|
18
|
+
* segments tile the declaration with no gaps or overlaps. The base segment ends
|
|
19
|
+
* where the first modifier begins. The frozen AST stores no value span for a
|
|
20
|
+
* variant (A04 contract note), so a variant origin necessarily covers its
|
|
21
|
+
* modifier plus the value and separator whitespace that follow it.
|
|
22
|
+
*/
|
|
23
|
+
export function declarationSegmentSpans(declaration) {
|
|
24
|
+
const file = declaration.span.file;
|
|
25
|
+
const { start: declarationStart, end: declarationEnd } = declaration.span;
|
|
26
|
+
if (declaration.variants.length === 0) {
|
|
27
|
+
return { base: declaration.span, variants: Object.freeze([]) };
|
|
28
|
+
}
|
|
29
|
+
const variants = [];
|
|
30
|
+
for (let index = 0; index < declaration.variants.length; index++) {
|
|
31
|
+
const variant = declaration.variants[index];
|
|
32
|
+
const next = declaration.variants[index + 1];
|
|
33
|
+
const start = clamp(variant.span.start, declarationStart, declarationEnd);
|
|
34
|
+
const end = clamp(next === undefined ? declarationEnd : next.span.start, start, declarationEnd);
|
|
35
|
+
variants.push(Object.freeze({ start, end, file }));
|
|
36
|
+
}
|
|
37
|
+
const baseEnd = clamp(declaration.variants[0].span.start, declarationStart, declarationEnd);
|
|
38
|
+
return {
|
|
39
|
+
base: Object.freeze({ start: declarationStart, end: baseEnd, file }),
|
|
40
|
+
variants: Object.freeze(variants),
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Exact spans for the aliases of one modifier chain.
|
|
45
|
+
*
|
|
46
|
+
* `@` and `+` are single authored characters, so alias origins can be derived
|
|
47
|
+
* by walking the modifier span in alias order. Escaped alias text keeps its
|
|
48
|
+
* authored length, so the walk stays correct without decoding.
|
|
49
|
+
*/
|
|
50
|
+
export function modifierAliasSpans(modifier) {
|
|
51
|
+
const spans = [];
|
|
52
|
+
const { start, end, file } = modifier.span;
|
|
53
|
+
let cursor = start + 1;
|
|
54
|
+
for (const alias of modifier.aliases) {
|
|
55
|
+
const aliasStart = clamp(cursor, start, end);
|
|
56
|
+
const aliasEnd = clamp(aliasStart + alias.length, aliasStart, end);
|
|
57
|
+
spans.push({ alias, span: Object.freeze({ start: aliasStart, end: aliasEnd, file }) });
|
|
58
|
+
cursor = aliasEnd + 1;
|
|
59
|
+
}
|
|
60
|
+
return spans;
|
|
61
|
+
}
|
|
62
|
+
/** Structural equality of two Chikx conditions, used to bound declaration runs. */
|
|
63
|
+
export function sameCondition(left, right) {
|
|
64
|
+
if (left === null || right === null)
|
|
65
|
+
return left === right;
|
|
66
|
+
if (left.query !== right.query || left.keys.length !== right.keys.length)
|
|
67
|
+
return false;
|
|
68
|
+
for (let index = 0; index < left.keys.length; index++) {
|
|
69
|
+
if (left.keys[index] !== right.keys[index])
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/** Structural equality of two native at-rule context stacks. */
|
|
75
|
+
export function sameContext(left, right) {
|
|
76
|
+
if (left.length !== right.length)
|
|
77
|
+
return false;
|
|
78
|
+
for (let index = 0; index < left.length; index++) {
|
|
79
|
+
const a = left[index];
|
|
80
|
+
const b = right[index];
|
|
81
|
+
if (a.name !== b.name || a.prelude !== b.prelude)
|
|
82
|
+
return false;
|
|
83
|
+
if (a.span.start !== b.span.start || a.span.end !== b.span.end)
|
|
84
|
+
return false;
|
|
85
|
+
if (a.span.file !== b.span.file)
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
/** Structural equality of two ancestor selector chains. */
|
|
91
|
+
export function sameAncestors(left, right) {
|
|
92
|
+
if (left.length !== right.length)
|
|
93
|
+
return false;
|
|
94
|
+
for (let index = 0; index < left.length; index++) {
|
|
95
|
+
if (left[index] !== right[index])
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
return true;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=spans.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spans.js","sourceRoot":"","sources":["../../src/lowering/spans.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AAEH,SAAS,KAAK,CAAC,KAAa,EAAE,OAAe,EAAE,OAAe;IAC5D,IAAI,KAAK,GAAG,OAAO;QAAE,OAAO,OAAO,CAAC;IACpC,IAAI,KAAK,GAAG,OAAO;QAAE,OAAO,OAAO,CAAC;IACpC,OAAO,KAAK,CAAC;AACf,CAAC;AAUD;;;;;;;;GAQG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAwB;IAC9D,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;IACnC,MAAM,EAAE,KAAK,EAAE,gBAAgB,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC;IAC1E,IAAI,WAAW,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACtC,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC;IAED,MAAM,QAAQ,GAAW,EAAE,CAAC;IAC5B,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,WAAW,CAAC,QAAQ,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjE,MAAM,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAoC,CAAC;QAC/E,MAAM,IAAI,GAAG,WAAW,CAAC,QA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,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO;YAAE,OAAO,KAAK,CAAC;QAC/D,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,IAAI,CAAC,GAAG;YAAE,OAAO,KAAK,CAAC;QAC7E,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;IAChD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,aAAa,CAAC,IAAuB,EAAE,KAAwB;IAC7E,IAAI,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAC/C,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,KAAK,CAAC,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;IACjD,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class naming and export generation (P4, SPECIFICATION.md §7.2 / §8).
|
|
3
|
+
*
|
|
4
|
+
* Two pure passes complete the naming story of the pipeline:
|
|
5
|
+
*
|
|
6
|
+
* 1. {@link renameClasses} — walks the lowered IR after {@link substitute},
|
|
7
|
+
* rebuilds every rule selector with the naming table applied (prefix strategy,
|
|
8
|
+
* `:global(...)` escape), and returns the first-appearance class table.
|
|
9
|
+
* 2. `generateClassMap` — turns that table into an ESM module of camelCase
|
|
10
|
+
* `export const` bindings plus matching opt-in TypeScript declarations, with
|
|
11
|
+
* deterministic `_`/`_N` identifier adjustments and CHIKX4001 warnings.
|
|
12
|
+
* 3. {@link mergeClassTables} — unions the renamed tables of a rule-bearing
|
|
13
|
+
* (`styles`) module graph into the single table the importing build exports
|
|
14
|
+
* (ADR-0014), enforcing the strict same-name/different-emitted conflict.
|
|
15
|
+
*
|
|
16
|
+
* Canonical pipeline position for consumers:
|
|
17
|
+
*
|
|
18
|
+
* ```text
|
|
19
|
+
* parse → buildModuleGraph → (per module) lower → substitute → renameClasses
|
|
20
|
+
* → mergeClassTables → emitRuntimeTokens → groupRuns → flattenIr → emitCss
|
|
21
|
+
* (→ generateClassMap for the JS map and opt-in .d.ts)
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* `renameClasses` only rewrites selectors, so it is independent of the single
|
|
25
|
+
* merged-build runtime emission; the class table is identical either way.
|
|
26
|
+
*
|
|
27
|
+
* Every pass is deterministic, frozen-output and filesystem-free; they never
|
|
28
|
+
* mutate their inputs and never throw on malformed IR. Barrel wiring is
|
|
29
|
+
* lead-directed; import this facade until integration.
|
|
30
|
+
*/
|
|
31
|
+
export { renameClasses } from "./rewrite.js";
|
|
32
|
+
export { generateClassMap } from "./mapgen.js";
|
|
33
|
+
export type { ClassMapOptions } from "./mapgen.js";
|
|
34
|
+
export { mergeClassTables } from "./merge.js";
|
|
35
|
+
export type { ClassEntry, ClassMapResult, ClassNamingOptions, ClassTable, RenameOptions, RenameResult, } from "./types.js";
|
|
36
|
+
export type { ClassTableSource, MergedClassTable } from "./merge.js";
|
|
37
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/naming/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EACV,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,UAAU,EACV,aAAa,EACb,YAAY,GACb,MAAM,YAAY,CAAC;AACpB,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|