@mapsight/vector-style-compiler 8.0.3 → 10.0.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/README.md +33 -3
- package/dist/cssToRules/mapDeclaration.d.ts +1 -1
- package/dist/cssToRules/mapDeclaration.d.ts.map +1 -1
- package/dist/cssToRules/mapDeclaration.js +2 -2
- package/dist/cssToRules/mapDeclaration.js.map +1 -1
- package/dist/cssToRules/mapRule.d.ts +3 -2
- package/dist/cssToRules/mapRule.d.ts.map +1 -1
- package/dist/cssToRules/mapRule.js +5 -3
- package/dist/cssToRules/mapRule.js.map +1 -1
- package/dist/cssToRules/mapValue.d.ts +3 -0
- package/dist/cssToRules/mapValue.d.ts.map +1 -1
- package/dist/cssToRules/mapValue.js +15 -9
- package/dist/cssToRules/mapValue.js.map +1 -1
- package/dist/cssToRules.d.ts +2 -0
- package/dist/cssToRules.d.ts.map +1 -1
- package/dist/cssToRules.js +4 -3
- package/dist/cssToRules.js.map +1 -1
- package/dist/helpers/Replacer.d.ts.map +1 -1
- package/dist/helpers/Replacer.js +53 -9
- package/dist/helpers/Replacer.js.map +1 -1
- package/dist/helpers/createHelperImportsFromProgram.d.ts +2 -0
- package/dist/helpers/createHelperImportsFromProgram.d.ts.map +1 -0
- package/dist/helpers/createHelperImportsFromProgram.js +9 -0
- package/dist/helpers/createHelperImportsFromProgram.js.map +1 -0
- package/dist/helpers/volatileCalcHelpers.d.ts +3 -0
- package/dist/helpers/volatileCalcHelpers.d.ts.map +1 -0
- package/dist/helpers/volatileCalcHelpers.js +5 -0
- package/dist/helpers/volatileCalcHelpers.js.map +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/rulesToTree.d.ts +2 -0
- package/dist/rulesToTree.d.ts.map +1 -1
- package/dist/rulesToTree.js +3 -0
- package/dist/rulesToTree.js.map +1 -1
- package/dist/template.d.ts +2 -1
- package/dist/template.d.ts.map +1 -1
- package/dist/template.js +11 -2
- package/dist/template.js.map +1 -1
- package/dist/template.source.js +61 -41
- package/dist/treeToProgram.d.ts.map +1 -1
- package/dist/treeToProgram.js +12 -4
- package/dist/treeToProgram.js.map +1 -1
- package/package.json +16 -13
- package/dist/template.source.d.ts +0 -3
- package/dist/template.source.d.ts.map +0 -1
- package/dist/template.source.js.map +0 -1
- package/src/data/custom-css-properties.json +0 -200
- package/src/js/cli.ts +0 -98
- package/src/js/cssToRules/mapDeclaration.ts +0 -45
- package/src/js/cssToRules/mapRule.ts +0 -98
- package/src/js/cssToRules/mapSelector.ts +0 -78
- package/src/js/cssToRules/mapSelectorPart.ts +0 -161
- package/src/js/cssToRules/mapValue.ts +0 -84
- package/src/js/cssToRules.ts +0 -49
- package/src/js/helpers/Replacer.ts +0 -50
- package/src/js/helpers/compileDeclarationBlock.ts +0 -60
- package/src/js/helpers/createModulesMapFromDependencies.ts +0 -40
- package/src/js/helpers/ensureObject.ts +0 -17
- package/src/js/helpers/pathToExpression.ts +0 -5
- package/src/js/helpers/uniqueSerialized.ts +0 -7
- package/src/js/index.ts +0 -28
- package/src/js/rulesToTree.ts +0 -83
- package/src/js/template.source.js +0 -56
- package/src/js/template.ts +0 -50
- package/src/js/treeToProgram.ts +0 -220
package/README.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
# Mapsight vector styles
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Package:** `@mapsight/vector-style-compiler` · **Hub:** [Documentation index](https://github.com/open-mapsight/mapsight/blob/main/docs/README.md)
|
|
4
|
+
|
|
5
|
+
Creates JavaScript code that can be used as a `styleFunction` in Mapsight by
|
|
4
6
|
transforming a subset of CSS.
|
|
5
7
|
|
|
8
|
+
**Deep dive:** [ARCHITECTURE_DEEP_DIVE.md](https://github.com/open-mapsight/mapsight/blob/main/packages/vector-style-compiler/docs/ARCHITECTURE_DEEP_DIVE.md) · **Consumer:** [`@mapsight/traffic-style`](https://github.com/open-mapsight/mapsight/blob/main/packages/traffic-style/README.md), [`@mapsight/core`](https://github.com/open-mapsight/mapsight/blob/main/packages/core/README.md)
|
|
9
|
+
|
|
6
10
|
## How it Works
|
|
7
11
|
|
|
8
12
|
The package compiles a CSS subset into a JavaScript module providing an efficient OpenLayers `styleFunction` with built-in caching.
|
|
@@ -57,7 +61,7 @@ The package compiles a CSS subset into a JavaScript module providing an efficien
|
|
|
57
61
|
│ For each feature: │
|
|
58
62
|
│ │
|
|
59
63
|
│ 1. Filter feature properties │
|
|
60
|
-
│ 2. Compute hashes (env, props, geometry type)
|
|
64
|
+
│ 2. Compute hashes (env, props, geometry type, volatile calcs) │
|
|
61
65
|
│ 3. Check 3-level LRU cache │
|
|
62
66
|
│ 4. Execute declarationFunction if cache miss │
|
|
63
67
|
│ 5. Build OL Style objects │
|
|
@@ -117,18 +121,44 @@ icon-src: "path/to/icon.png";
|
|
|
117
121
|
icon-sizex: 32;
|
|
118
122
|
icon-sizey: 32;
|
|
119
123
|
icon-offsetx: attr(offsetX);
|
|
124
|
+
|
|
125
|
+
/* Runtime icons (async-loaded, cache-aware) */
|
|
126
|
+
icon-src: calc(mapsightRuntimeIcon(attr(mapsightIconId), "default"));
|
|
120
127
|
```
|
|
121
128
|
|
|
122
129
|
See full list of supported properties in [Custom CSS properties](#custom-css-properties).
|
|
123
130
|
|
|
131
|
+
### Volatile `calc()` helpers
|
|
132
|
+
|
|
133
|
+
Some `calc()` expressions call helpers whose return value can change without
|
|
134
|
+
feature props or map env changing — for example runtime icons that return a
|
|
135
|
+
placeholder synchronously and resolve to a real data URL asynchronously.
|
|
136
|
+
|
|
137
|
+
The compiler detects registered volatile helpers (currently
|
|
138
|
+
`mapsightRuntimeIcon`) and emits a
|
|
139
|
+
`volatileHashFunction` alongside the usual `declarationHashFunction` and
|
|
140
|
+
`declarationFunction`. When a stylesheet has no volatile calcs, the function
|
|
141
|
+
body is empty and always returns `createHash([])`.
|
|
142
|
+
|
|
143
|
+
At runtime, the volatile hash is folded into the **L1 cache key**. When an
|
|
144
|
+
icon finishes loading, only features whose resolved icon URL changed get a
|
|
145
|
+
cache miss and are restyled — not the entire map.
|
|
146
|
+
|
|
147
|
+
Volatile helpers must stay synchronous from the style function's perspective
|
|
148
|
+
(they may schedule async work internally, but must return a string immediately).
|
|
149
|
+
Pair them with a map re-render callback when the async result is ready.
|
|
150
|
+
|
|
124
151
|
## Caching
|
|
125
152
|
|
|
126
153
|
High-level 3-level LRU caching strategy:
|
|
127
154
|
|
|
128
|
-
- **Level 1 (Coarse)**: env + geometry type + props (~95% hit, size 100)
|
|
155
|
+
- **Level 1 (Coarse)**: env + volatile calc values + geometry type + props (~95% hit, size 100)
|
|
129
156
|
- **Level 2 (Fine)**: declaration hashes (~92% hit, size 100)
|
|
130
157
|
- **Level 3**: OL Style objects (clone, ~98% hit, size 100)
|
|
131
158
|
|
|
159
|
+
L1 stores fully materialized styles. Volatile calcs (see above) are hashed
|
|
160
|
+
separately so async value changes invalidate only the affected features.
|
|
161
|
+
|
|
132
162
|
**Example** (10k features, 50 styles, 10 zooms):
|
|
133
163
|
|
|
134
164
|
- 9500 L1 hits: instant
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapDeclaration.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,IAAI,cAAc,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"mapDeclaration.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapDeclaration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,WAAW,IAAI,cAAc,EAAC,MAAM,SAAS,CAAC;AAE3D,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,MAAM,eAAe,GAAG;IAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAA;CAAC,CAAC;AAE9D,MAAM,WAAW,eAAe;IAC/B,CAAC,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,CAAC;CACjD;AAED,MAAM,MAAM,WAAW,GAAG;IACzB,WAAW,EAAE,eAAe,CAAC;IAC7B,MAAM,EAAE,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG;QAC/C,IAAI,EAAE,MAAM,CAAC;KACb,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,WAAW,EAAE,cAAc,GACzB,WAAW,CAyBb"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import mapValue from "./mapValue.js";
|
|
2
2
|
export default function mapDeclaration(declaration) {
|
|
3
3
|
const { value, __meta: valueMeta } = mapValue(declaration.value);
|
|
4
|
-
if (!declaration.
|
|
4
|
+
if (!declaration.prop) {
|
|
5
5
|
throw new Error("Declaration is lacking property");
|
|
6
6
|
}
|
|
7
|
-
const keyParts = declaration.
|
|
7
|
+
const keyParts = declaration.prop.split("-");
|
|
8
8
|
// build deep object
|
|
9
9
|
const result = {};
|
|
10
10
|
let current = result;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapDeclaration.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapDeclaration.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAerC,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,WAA2B;IAE3B,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE/D,IAAI,CAAC,WAAW,CAAC,
|
|
1
|
+
{"version":3,"file":"mapDeclaration.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapDeclaration.ts"],"names":[],"mappings":"AAEA,OAAO,QAAQ,MAAM,eAAe,CAAC;AAerC,MAAM,CAAC,OAAO,UAAU,cAAc,CACrC,WAA2B;IAE3B,MAAM,EAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IAE/D,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;QACvB,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7C,oBAAoB;IACpB,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,IAAI,OAAO,GAAoB,MAAM,CAAC;IACtC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,CAAC,CAAE,CAAC;QAC1B,MAAM,IAAI,GAAoB,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;QACrB,OAAO,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;IAChD,OAAO,CAAC,QAAQ,CAAC,GAAG,EAAC,KAAK,EAAC,CAAC;IAE5B,OAAO;QACN,WAAW,EAAE,MAAM;QACnB,MAAM,EAAE,EAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAE,EAAE,GAAG,SAAS,EAAC;KAC1C,CAAC;AACH,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type { Rule } from "postcss";
|
|
2
2
|
import type { DeclarationNode } from "./mapDeclaration.ts";
|
|
3
|
-
export default function mapRule(rule:
|
|
3
|
+
export default function mapRule(rule: Rule): {
|
|
4
4
|
conditions: {
|
|
5
5
|
style: string | undefined;
|
|
6
6
|
state: string | undefined;
|
|
@@ -36,6 +36,7 @@ export default function mapRule(rule: css.Rule): {
|
|
|
36
36
|
declarationNames: string[];
|
|
37
37
|
styleProps: string[];
|
|
38
38
|
stylePropExpressions: string[];
|
|
39
|
+
volatileCalcExpressions: string[];
|
|
39
40
|
};
|
|
40
41
|
}[];
|
|
41
42
|
//# sourceMappingURL=mapRule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapRule.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"mapRule.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapRule.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,IAAI,EAAC,MAAM,SAAS,CAAC;AAO/C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,qBAAqB,CAAC;AAOzD,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAI,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAwFzC"}
|
|
@@ -4,9 +4,9 @@ import deepMerge from "@mapsight/lib-js/object/deep-extend";
|
|
|
4
4
|
import uniqueSerialized from "../helpers/uniqueSerialized.js";
|
|
5
5
|
import mapDeclaration from "./mapDeclaration.js";
|
|
6
6
|
import mapSelector from "./mapSelector.js";
|
|
7
|
-
const isDeclaration = (val) => val.type === "
|
|
7
|
+
const isDeclaration = (val) => val.type === "decl";
|
|
8
8
|
export default function mapRule(rule) {
|
|
9
|
-
const declarations = rule.
|
|
9
|
+
const declarations = rule.nodes
|
|
10
10
|
?.filter(isDeclaration)
|
|
11
11
|
.map(mapDeclaration)
|
|
12
12
|
.filter((a) => !!a) ?? [];
|
|
@@ -15,7 +15,8 @@ export default function mapRule(rule) {
|
|
|
15
15
|
const mergedDeclarationNames = unique(declarations.map((declaration) => declaration.__meta.name));
|
|
16
16
|
const mergedStyleProps = unique(declarations.flatMap((declaration) => declaration.__meta.styleProps));
|
|
17
17
|
const mergedStylePropExpressions = unique(declarations.flatMap((declaration) => declaration.__meta.stylePropExpressions));
|
|
18
|
-
const
|
|
18
|
+
const mergedVolatileCalcExpressions = unique(declarations.flatMap((declaration) => declaration.__meta.volatileCalcExpressions));
|
|
19
|
+
const selectors = uniqueSerialized(rule.selectors.map(mapSelector));
|
|
19
20
|
const groupedSelectors = {};
|
|
20
21
|
selectors.forEach((selector) => {
|
|
21
22
|
const existing = groupedSelectors[selector.group];
|
|
@@ -53,6 +54,7 @@ export default function mapRule(rule) {
|
|
|
53
54
|
...mergedConditionStylePropExpressions,
|
|
54
55
|
...mergedStylePropExpressions,
|
|
55
56
|
],
|
|
57
|
+
volatileCalcExpressions: mergedVolatileCalcExpressions,
|
|
56
58
|
},
|
|
57
59
|
};
|
|
58
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapRule.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapRule.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,SAAS,MAAM,qCAAqC,CAAC;AAE5D,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAE9D,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,WAA4B,MAAM,kBAAkB,CAAC;AAE5D,MAAM,aAAa,GAAG,
|
|
1
|
+
{"version":3,"file":"mapRule.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapRule.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,+BAA+B,CAAC;AACnD,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAClD,OAAO,SAAS,MAAM,qCAAqC,CAAC;AAE5D,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;AAE9D,OAAO,cAAc,MAAM,qBAAqB,CAAC;AACjD,OAAO,WAA4B,MAAM,kBAAkB,CAAC;AAE5D,MAAM,aAAa,GAAG,CAAC,GAA0B,EAAsB,EAAE,CACxE,GAAG,CAA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AC,SAAS,CAAC,KAAK,CAAC;yBACnC,MAAM,CAAC,QAAQ,CAAC,CAClB;oBACD,GAAG,gBAAgB;iBACnB;gBACD,UAAU,EAAE,MAAM,CACjB,UAAU,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAC9C;gBACD,gBAAgB,EAAE,sBAAsB;gBACxC,UAAU,EAAE,CAAC,GAAG,yBAAyB,EAAE,GAAG,gBAAgB,CAAC;gBAC/D,oBAAoB,EAAE;oBACrB,GAAG,mCAAmC;oBACtC,GAAG,0BAA0B;iBAC7B;gBACD,uBAAuB,EAAE,6BAA6B;aACtD;SACD,CAAC;IACH,CAAC,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -3,18 +3,21 @@ export default function mapValue(value: string | number | null | undefined | boo
|
|
|
3
3
|
__meta: {
|
|
4
4
|
styleProps: Array<string>;
|
|
5
5
|
stylePropExpressions: Array<string>;
|
|
6
|
+
volatileCalcExpressions: Array<string>;
|
|
6
7
|
};
|
|
7
8
|
} | {
|
|
8
9
|
value: number;
|
|
9
10
|
__meta: {
|
|
10
11
|
styleProps: Array<string>;
|
|
11
12
|
stylePropExpressions: Array<string>;
|
|
13
|
+
volatileCalcExpressions: Array<string>;
|
|
12
14
|
};
|
|
13
15
|
} | {
|
|
14
16
|
readonly value: string;
|
|
15
17
|
readonly __meta: {
|
|
16
18
|
readonly styleProps: string[];
|
|
17
19
|
readonly stylePropExpressions: string[];
|
|
20
|
+
readonly volatileCalcExpressions: string[];
|
|
18
21
|
};
|
|
19
22
|
};
|
|
20
23
|
//# sourceMappingURL=mapValue.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapValue.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapValue.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mapValue.d.ts","sourceRoot":"","sources":["../../src/js/cssToRules/mapValue.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAC/B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO;;;oBAGhC,KAAK,CAAC,MAAM,CAAC;8BACH,KAAK,CAAC,MAAM,CAAC;iCACV,KAAK,CAAC,MAAM,CAAC;;;;;oBAF1B,KAAK,CAAC,MAAM,CAAC;8BACH,KAAK,CAAC,MAAM,CAAC;iCACV,KAAK,CAAC,MAAM,CAAC;;;;;;;;;EAgE7C"}
|
|
@@ -4,6 +4,7 @@ import trimQuotes from "@mapsight/lib-js/string/trimQuotes";
|
|
|
4
4
|
import isNumberLike from "@mapsight/lib-js/types/isNumberLike";
|
|
5
5
|
import Replacer from "../helpers/Replacer.js";
|
|
6
6
|
import pathToExpression from "../helpers/pathToExpression.js";
|
|
7
|
+
import { containsVolatileCalcHelper } from "../helpers/volatileCalcHelpers.js";
|
|
7
8
|
const replace = (_match, parameter) => {
|
|
8
9
|
const [search, replacement, subject] = parameter
|
|
9
10
|
.split(",")
|
|
@@ -11,19 +12,23 @@ const replace = (_match, parameter) => {
|
|
|
11
12
|
.map(trimQuotes);
|
|
12
13
|
return `' + replace('${search}', '${replacement}', '${subject}') + '`;
|
|
13
14
|
};
|
|
14
|
-
const calc = (_match, parameter, replacer) => {
|
|
15
|
-
// parameter is e.g. "%%%0%%% * 5"
|
|
16
|
-
// Resolve the inner tags back to their actual string representations
|
|
17
|
-
let resolvedParam = replacer.replace(parameter);
|
|
18
|
-
// Clean up the string concatenations generated by the earlier `attr` pass.
|
|
19
|
-
// It extracts `props['test']` out of `' + props['test'] + '`
|
|
20
|
-
resolvedParam = resolvedParam.replace(/' \+ (.*?) \+ '/g, "$1");
|
|
21
|
-
return `' + (${resolvedParam}) + '`;
|
|
22
|
-
};
|
|
23
15
|
export default function mapValue(value) {
|
|
24
16
|
const meta = {
|
|
25
17
|
styleProps: [],
|
|
26
18
|
stylePropExpressions: [],
|
|
19
|
+
volatileCalcExpressions: [],
|
|
20
|
+
};
|
|
21
|
+
const calc = (_match, parameter, replacer) => {
|
|
22
|
+
// parameter is e.g. "%%%0%%% * 5"
|
|
23
|
+
// Resolve the inner tags back to their actual string representations
|
|
24
|
+
let resolvedParam = replacer.replace(parameter);
|
|
25
|
+
// Clean up the string concatenations generated by the earlier `attr` pass.
|
|
26
|
+
// It extracts `props['test']` out of `' + props['test'] + '`
|
|
27
|
+
resolvedParam = resolvedParam.replace(/' \+ (.*?) \+ '/g, "$1");
|
|
28
|
+
if (containsVolatileCalcHelper(resolvedParam)) {
|
|
29
|
+
meta.volatileCalcExpressions.push(resolvedParam);
|
|
30
|
+
}
|
|
31
|
+
return `' + (${resolvedParam}) + '`;
|
|
27
32
|
};
|
|
28
33
|
if (!value) {
|
|
29
34
|
return { value: null, __meta: meta };
|
|
@@ -61,6 +66,7 @@ export default function mapValue(value) {
|
|
|
61
66
|
__meta: {
|
|
62
67
|
styleProps: uniq(meta.styleProps),
|
|
63
68
|
stylePropExpressions: uniq(meta.stylePropExpressions),
|
|
69
|
+
volatileCalcExpressions: uniq(meta.volatileCalcExpressions),
|
|
64
70
|
},
|
|
65
71
|
};
|
|
66
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapValue.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapValue.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,OAAO,EAAC,iBAAiB,EAAC,MAAM,8BAA8B,CAAC;AAC/D,OAAO,UAAU,MAAM,oCAAoC,CAAC;AAC5D,OAAO,YAAY,MAAM,qCAAqC,CAAC;AAG/D,OAAO,QAAQ,MAAM,wBAAwB,CAAC;AAC9C,OAAO,gBAAgB,MAAM,gCAAgC,CAAC;
|
|
1
|
+
{"version":3,"file":"mapValue.js","sourceRoot":"","sources":["../../src/js/cssToRules/mapValue.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,OAAO,E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,CAAC,CAAC;IACtC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IACtC,QAAQ,GAAG,IAAI,QAAQ,GAAG,CAAC;IAE3B,OAAO;QACN,KAAK,EAAE,QAAQ;QAEf,MAAM,EAAE;YACP,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;YACjC,oBAAoB,EAAE,IAAI,CAAC,IAAI,CAAC,oBAAoB,CAAC;YACrD,uBAAuB,EAAE,IAAI,CAAC,IAAI,CAAC,uBAAuB,CAAC;SAC3D;KACQ,CAAC;AACZ,CAAC"}
|
package/dist/cssToRules.d.ts
CHANGED
|
@@ -36,6 +36,7 @@ export default function cssToRules(content: string): {
|
|
|
36
36
|
declarationNames: string[];
|
|
37
37
|
styleProps: string[];
|
|
38
38
|
stylePropExpressions: string[];
|
|
39
|
+
volatileCalcExpressions: string[];
|
|
39
40
|
};
|
|
40
41
|
}[];
|
|
41
42
|
__meta: {
|
|
@@ -45,6 +46,7 @@ export default function cssToRules(content: string): {
|
|
|
45
46
|
declarationNames: string[];
|
|
46
47
|
styleProps: string[];
|
|
47
48
|
stylePropExpressions: string[];
|
|
49
|
+
volatileCalcExpressions: string[];
|
|
48
50
|
};
|
|
49
51
|
};
|
|
50
52
|
//# sourceMappingURL=cssToRules.d.ts.map
|
package/dist/cssToRules.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssToRules.d.ts","sourceRoot":"","sources":["../src/js/cssToRules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cssToRules.d.ts","sourceRoot":"","sources":["../src/js/cssToRules.ts"],"names":[],"mappings":"AA+BA,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC;AAElD,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,OAAO,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBjD"}
|
package/dist/cssToRules.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import postcss from "postcss";
|
|
2
2
|
import unique from "@mapsight/lib-js/array/unique";
|
|
3
3
|
import mapRule from "./cssToRules/mapRule.js";
|
|
4
4
|
const collectMeta = (vals, key) => {
|
|
@@ -12,10 +12,10 @@ function isRule(val) {
|
|
|
12
12
|
// ignored types: media, stylesheet, comment, charset, custom-media, document, font-face,
|
|
13
13
|
// import, keyframes, keyframe, media, namespace, page, supports
|
|
14
14
|
function cssOmToRules(om) {
|
|
15
|
-
return om.
|
|
15
|
+
return om.nodes.filter(isRule).flatMap(mapRule);
|
|
16
16
|
}
|
|
17
17
|
export default function cssToRules(content) {
|
|
18
|
-
const om = parse(content);
|
|
18
|
+
const om = postcss.parse(content);
|
|
19
19
|
const rules = cssOmToRules(om);
|
|
20
20
|
return {
|
|
21
21
|
rules,
|
|
@@ -26,6 +26,7 @@ export default function cssToRules(content) {
|
|
|
26
26
|
declarationNames: collectMeta(rules, "declarationNames"),
|
|
27
27
|
styleProps: collectMeta(rules, "styleProps"),
|
|
28
28
|
stylePropExpressions: collectMeta(rules, "stylePropExpressions"),
|
|
29
|
+
volatileCalcExpressions: collectMeta(rules, "volatileCalcExpressions"),
|
|
29
30
|
},
|
|
30
31
|
};
|
|
31
32
|
}
|
package/dist/cssToRules.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cssToRules.js","sourceRoot":"","sources":["../src/js/cssToRules.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cssToRules.js","sourceRoot":"","sources":["../src/js/cssToRules.ts"],"names":[],"mappings":"AAAA,OAAO,OAA+B,MAAM,SAAS,CAAC;AAEtD,OAAO,MAAM,MAAM,+BAA+B,CAAC;AAEnD,OAAO,OAAO,MAAM,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"Replacer.d.ts","sourceRoot":"","sources":["../../src/js/helpers/Replacer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Replacer.d.ts","sourceRoot":"","sources":["../../src/js/helpers/Replacer.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,UAAU,GAAG,CACxB,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,QAAQ,KACd,MAAM,CAAC;AA0CZ,MAAM,CAAC,OAAO,OAAO,QAAQ;IAC5B,OAAO,CAAC,kBAAkB,CAAa;IACvC,OAAO,CAAC,YAAY,CAAiD;IACrE,OAAO,CAAC,SAAS,CAAsC;gBAE3C,SAAS,GAAE,KAAK,CAAC,CAAC,MAAM,EAAE,UAAU,CAAC,CAAM;IAMvD,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU;IAuCtD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;CAO9B"}
|
package/dist/helpers/Replacer.js
CHANGED
|
@@ -1,6 +1,34 @@
|
|
|
1
|
-
const RE_FUNCTION_PARAMETER = "([^\\)]*?)";
|
|
2
|
-
const RE_DOUBLE_QUOTES_IN_PARIS_ONLY = '(?:(?:[^"]*"){2})*[^"]*$';
|
|
3
1
|
const TAG_DELIMITER = "%%%";
|
|
2
|
+
function findBalancedParameterEnd(value, openParenIndex) {
|
|
3
|
+
let depth = 0;
|
|
4
|
+
let inString = false;
|
|
5
|
+
let stringChar = "";
|
|
6
|
+
for (let i = openParenIndex; i < value.length; i++) {
|
|
7
|
+
const char = value[i];
|
|
8
|
+
if (inString) {
|
|
9
|
+
if (char === stringChar && value[i - 1] !== "\\") {
|
|
10
|
+
inString = false;
|
|
11
|
+
}
|
|
12
|
+
continue;
|
|
13
|
+
}
|
|
14
|
+
if (char === `"` || char === `'`) {
|
|
15
|
+
inString = true;
|
|
16
|
+
stringChar = char;
|
|
17
|
+
continue;
|
|
18
|
+
}
|
|
19
|
+
if (char === "(") {
|
|
20
|
+
depth += 1;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (char === ")") {
|
|
24
|
+
depth -= 1;
|
|
25
|
+
if (depth === 0) {
|
|
26
|
+
return i;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return -1;
|
|
31
|
+
}
|
|
4
32
|
export default class Replacer {
|
|
5
33
|
replacementCounter = 0;
|
|
6
34
|
replacements = [];
|
|
@@ -9,13 +37,29 @@ export default class Replacer {
|
|
|
9
37
|
functions.forEach(([functionName, replacer]) => this.addFunction(functionName, replacer));
|
|
10
38
|
}
|
|
11
39
|
addFunction(functionName, replacer) {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
40
|
+
const fn = (value) => {
|
|
41
|
+
const pattern = new RegExp(`\\b${functionName}\\(`, "ig");
|
|
42
|
+
let result = "";
|
|
43
|
+
let cursor = 0;
|
|
44
|
+
let match;
|
|
45
|
+
while ((match = pattern.exec(value)) !== null) {
|
|
46
|
+
const openParenIndex = match.index + match[0].length - 1;
|
|
47
|
+
const closeParenIndex = findBalancedParameterEnd(value, openParenIndex);
|
|
48
|
+
if (closeParenIndex === -1) {
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
result += value.slice(cursor, match.index);
|
|
52
|
+
const fullMatch = value.slice(match.index, closeParenIndex + 1);
|
|
53
|
+
const parameter = value.slice(openParenIndex + 1, closeParenIndex);
|
|
54
|
+
const tag = TAG_DELIMITER + this.replacementCounter++ + TAG_DELIMITER;
|
|
55
|
+
const replacement = replacer(fullMatch, parameter, this);
|
|
56
|
+
this.replacements.push({ tag, replacement });
|
|
57
|
+
result += tag;
|
|
58
|
+
cursor = closeParenIndex + 1;
|
|
59
|
+
pattern.lastIndex = cursor;
|
|
60
|
+
}
|
|
61
|
+
return result + value.slice(cursor);
|
|
62
|
+
};
|
|
19
63
|
this.functions.push(fn);
|
|
20
64
|
}
|
|
21
65
|
execute(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Replacer.js","sourceRoot":"","sources":["../../src/js/helpers/Replacer.ts"],"names":[],"mappings":"AAAA,MAAM,
|
|
1
|
+
{"version":3,"file":"Replacer.js","sourceRoot":"","sources":["../../src/js/helpers/Replacer.ts"],"names":[],"mappings":"AAAA,MAAM,aAAa,GAAG,KAAK,CAAC;AAQ5B,SAAS,wBAAwB,CAChC,KAAa,EACb,cAAsB;IAEtB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,UAAU,GAAG,EAAE,CAAC;IAEpB,KAAK,IAAI,CAAC,GAAG,cAAc,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpD,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QAEvB,IAAI,QAAQ,EAAE,CAAC;YACd,IAAI,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;gBAClD,QAAQ,GAAG,KAAK,CAAC;YAClB,CAAC;YACD,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClC,QAAQ,GAAG,IAAI,CAAC;YAChB,UAAU,GAAG,IAAI,CAAC;YAClB,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClB,KAAK,IAAI,CAAC,CAAC;YACX,SAAS;QACV,CAAC;QAED,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YAClB,KAAK,IAAI,CAAC,CAAC;YACX,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,CAAC,CAAC;YACV,CAAC;QACF,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,GAAG,CAAC,EAClB,eAAe,CACf,CAAC;gBACF,MAAM,GAAG,GACR,aAAa,GAAG,IAAI,CAAC,kBAAkB,EAAE,GAAG,aAAa,CAAC;gBAC3D,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;gBACzD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,WAAW,EAAC,CAAC,CAAC;gBAC3C,MAAM,IAAI,GAAG,CAAC;gBACd,MAAM,GAAG,eAAe,GAAG,CAAC,CAAC;gBAC7B,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC;YAC5B,CAAC;YAED,OAAO,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC,CAAC;QAEF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;IAED,OAAO,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,CACnC,CAAC,GAAG,EAAE,EAAC,GAAG,EAAE,WAAW,EAAC,EAAE,EAAE,CAC3B,GAAG,CAAC,OAAO,CAAC,IAAI,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,EAAE,WAAW,CAAC,EAC/C,KAAK,CACL,CAAC;IACH,CAAC;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHelperImportsFromProgram.d.ts","sourceRoot":"","sources":["../../src/js/helpers/createHelperImportsFromProgram.ts"],"names":[],"mappings":"AAMA,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACrD,OAAO,EAAE,MAAM,GACb,MAAM,CAMR"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import uniq from "lodash/uniq.js";
|
|
2
|
+
const HELPER_IMPORTS = {
|
|
3
|
+
mapsightRuntimeIcon: `import { mapsightRuntimeIcon } from '@mapsight/traffic-style/runtime';`,
|
|
4
|
+
};
|
|
5
|
+
export default function createHelperImportsFromProgram(program) {
|
|
6
|
+
const helpers = uniq(Object.keys(HELPER_IMPORTS).filter((name) => program.includes(name)));
|
|
7
|
+
return helpers.map((name) => HELPER_IMPORTS[name]).join("\n");
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=createHelperImportsFromProgram.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createHelperImportsFromProgram.js","sourceRoot":"","sources":["../../src/js/helpers/createHelperImportsFromProgram.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,gBAAgB,CAAC;AAElC,MAAM,cAAc,GAA2B;IAC9C,mBAAmB,EAAE,wEAAwE;CAC7F,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,8BAA8B,CACrD,OAAe;IAEf,MAAM,OAAO,GAAG,IAAI,CACnB,MAAM,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CACpE,CAAC;IAEF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volatileCalcHelpers.d.ts","sourceRoot":"","sources":["../../src/js/helpers/volatileCalcHelpers.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,kCAAmC,CAAC;AAEtE,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAEtE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"volatileCalcHelpers.js","sourceRoot":"","sources":["../../src/js/helpers/volatileCalcHelpers.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,qBAAqB,CAAU,CAAC;AAEtE,MAAM,UAAU,0BAA0B,CAAC,UAAkB;IAC5D,OAAO,qBAAqB,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5E,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":"AAEA,OAAwB,EAAC,KAAK,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG7D,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,0BAA0B,CACjD,OAAO,EAAE,MAAM,EACf,EACC,QAA0B,EAC1B,cAAmB,EACnB,UAAc,GACd,GAAE,OAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":"AAEA,OAAwB,EAAC,KAAK,QAAQ,EAAC,MAAM,eAAe,CAAC;AAG7D,MAAM,MAAM,OAAO,GAAG;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,CAAC;IACjD,UAAU,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,0BAA0B,CACjD,OAAO,EAAE,MAAM,EACf,EACC,QAA0B,EAC1B,cAAmB,EACnB,UAAc,GACd,GAAE,OAAY,UAcf"}
|
package/dist/index.js
CHANGED
|
@@ -7,6 +7,9 @@ export default function compileMapsightVectorStyle(content, { template = default
|
|
|
7
7
|
const tree = rulesToTree(rules.rules);
|
|
8
8
|
return template({
|
|
9
9
|
__meta: rules.__meta,
|
|
10
|
+
program0: rules.__meta.volatileCalcExpressions.length > 0
|
|
11
|
+
? treeToProgram(tree, "volatileHash", baseIndent)
|
|
12
|
+
: "",
|
|
10
13
|
program1: treeToProgram(tree, "hash", baseIndent),
|
|
11
14
|
program2: treeToProgram(tree, "declaration", baseIndent),
|
|
12
15
|
...additionalData,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,eAAgC,MAAM,eAAe,CAAC;AAC7D,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAQ/C,MAAM,CAAC,OAAO,UAAU,0BAA0B,CACjD,OAAe,EACf,EACC,QAAQ,GAAG,eAAe,EAC1B,cAAc,GAAG,EAAE,EACnB,UAAU,GAAG,CAAC,MACF,EAAE;IAEf,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC;QACjD,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC;QACxD,GAAG,cAAc;KACjB,CAAC,CAAC;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/js/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,iBAAiB,CAAC;AACzC,OAAO,WAAW,MAAM,kBAAkB,CAAC;AAC3C,OAAO,eAAgC,MAAM,eAAe,CAAC;AAC7D,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAQ/C,MAAM,CAAC,OAAO,UAAU,0BAA0B,CACjD,OAAe,EACf,EACC,QAAQ,GAAG,eAAe,EAC1B,cAAc,GAAG,EAAE,EACnB,UAAU,GAAG,CAAC,MACF,EAAE;IAEf,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAClC,MAAM,IAAI,GAAG,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,OAAO,QAAQ,CAAC;QACf,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,QAAQ,EACP,KAAK,CAAC,MAAM,CAAC,uBAAuB,CAAC,MAAM,GAAG,CAAC;YAC9C,CAAC,CAAC,aAAa,CAAC,IAAI,EAAE,cAAc,EAAE,UAAU,CAAC;YACjD,CAAC,CAAC,EAAE;QACN,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC;QACjD,QAAQ,EAAE,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,CAAC;QACxD,GAAG,cAAc;KACjB,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/rulesToTree.d.ts
CHANGED
|
@@ -5,11 +5,13 @@ export type TreeLeaf = {
|
|
|
5
5
|
declarations?: DeclarationNode;
|
|
6
6
|
children: Child[];
|
|
7
7
|
stylePropExpressions?: Array<string>;
|
|
8
|
+
volatileCalcExpressions?: Array<string>;
|
|
8
9
|
};
|
|
9
10
|
export type Child = {
|
|
10
11
|
conditions: Array<Array<Check>>;
|
|
11
12
|
declarations?: DeclarationNode;
|
|
12
13
|
stylePropExpressions?: Array<string>;
|
|
14
|
+
volatileCalcExpressions?: Array<string>;
|
|
13
15
|
};
|
|
14
16
|
export type Tree = {
|
|
15
17
|
[style: string]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rulesToTree.d.ts","sourceRoot":"","sources":["../src/js/rulesToTree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAE3D,MAAM,MAAM,QAAQ,GAAG;IACtB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"rulesToTree.d.ts","sourceRoot":"","sources":["../src/js/rulesToTree.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iBAAiB,CAAC;AAC3C,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AACpE,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,iCAAiC,CAAC;AAE3D,MAAM,MAAM,QAAQ,GAAG;IACtB,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,QAAQ,EAAE,KAAK,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,uBAAuB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,KAAK,GAAG;IACnB,UAAU,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;IAChC,YAAY,CAAC,EAAE,eAAe,CAAC;IAC/B,oBAAoB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrC,uBAAuB,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,IAAI,GAAG;IAClB,CAAC,KAAK,EAAE,MAAM,GAAG;QAChB,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAAC;KAC1B,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,QAgExD"}
|
package/dist/rulesToTree.js
CHANGED
|
@@ -28,10 +28,13 @@ export default function rulesToTree(rules) {
|
|
|
28
28
|
conditions: conditions,
|
|
29
29
|
declarations: rule.declarations,
|
|
30
30
|
stylePropExpressions: rule.__meta.stylePropExpressions,
|
|
31
|
+
volatileCalcExpressions: rule.__meta.volatileCalcExpressions,
|
|
31
32
|
});
|
|
33
|
+
styleTree[state] = stateTree;
|
|
32
34
|
return;
|
|
33
35
|
}
|
|
34
36
|
stateTree.stylePropExpressions = (stateTree.stylePropExpressions || []).concat(rule.__meta.stylePropExpressions);
|
|
37
|
+
stateTree.volatileCalcExpressions = (stateTree.volatileCalcExpressions || []).concat(rule.__meta.volatileCalcExpressions);
|
|
35
38
|
stateTree.declarations = deepExtend(stateTree.declarations || {}, rule.declarations);
|
|
36
39
|
styleTree[state] = stateTree;
|
|
37
40
|
});
|
package/dist/rulesToTree.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rulesToTree.js","sourceRoot":"","sources":["../src/js/rulesToTree.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qCAAqC,CAAC;
|
|
1
|
+
{"version":3,"file":"rulesToTree.js","sourceRoot":"","sources":["../src/js/rulesToTree.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,qCAAqC,CAAC;AA0B7D,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,KAAqB;IACxD,MAAM,IAAI,GAAS,EAAE,CAAC;IAEtB,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACtB,MAAM,QAAQ,GAGV,EAA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AC,MAAM,CAAC,uBAAuB;qBACpC,CAAC,CAAC;oBACH,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;oBAC7B,OAAO;gBACR,CAAC;gBACD,SAAS,CAAC,oBAAoB,GAAG,CAChC,SAAS,CAAC,oBAAoB,IAAI,EAAE,CACpC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;gBAC3C,SAAS,CAAC,uBAAuB,GAAG,CACnC,SAAS,CAAC,uBAAuB,IAAI,EAAE,CACvC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;gBAE9C,SAAS,CAAC,YAAY,GAAG,UAAU,CAClC,SAAS,CAAC,YAAY,IAAI,EAAE,EAC5B,IAAI,CAAC,YAAY,CACjB,CAAC;gBAEF,SAAS,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;YAC9B,CAAC,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;QACzB,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACb,CAAC"}
|
package/dist/template.d.ts
CHANGED
|
@@ -9,8 +9,9 @@ export type TemplateArgs<TAdditionalData extends Record<string, unknown> = Recor
|
|
|
9
9
|
};
|
|
10
10
|
program1: string;
|
|
11
11
|
program2: string;
|
|
12
|
+
program0?: string;
|
|
12
13
|
};
|
|
13
14
|
export type Template<TAdditionalData extends Record<string, unknown> = Record<string, unknown>> = (args: TemplateArgs<TAdditionalData>) => string;
|
|
14
|
-
declare const defaultTemplate: ({ __meta, program1, program2 }: TemplateArgs) => string;
|
|
15
|
+
declare const defaultTemplate: ({ __meta, program1, program2, program0, }: TemplateArgs) => string;
|
|
15
16
|
export default defaultTemplate;
|
|
16
17
|
//# sourceMappingURL=template.d.ts.map
|
package/dist/template.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/js/template.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"template.d.ts","sourceRoot":"","sources":["../src/js/template.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,YAAY,CACvB,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACtE,eAAe,GAAG;IACrB,MAAM,EAAE;QACP,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,gBAAgB,EAAE,MAAM,EAAE,CAAC;QAC3B,UAAU,EAAE,MAAM,EAAE,CAAC;QACrB,oBAAoB,EAAE,MAAM,EAAE,CAAC;KAC/B,CAAC;IACF,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AACF,MAAM,MAAM,QAAQ,CACnB,eAAe,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACtE,CAAC,IAAI,EAAE,YAAY,CAAC,eAAe,CAAC,KAAK,MAAM,CAAC;AAYpD,QAAA,MAAM,eAAe,GAAI,2CAKtB,YAAY,WAyBd,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
package/dist/template.js
CHANGED
|
@@ -1,21 +1,30 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
|
+
import createHelperImportsFromProgram from "./helpers/createHelperImportsFromProgram.js";
|
|
3
4
|
import createModulesMapFromDependencies from "./helpers/createModulesMapFromDependencies.js";
|
|
4
5
|
const templateSource = readFileSync(resolve(import.meta.dirname, "template.source.js"), "utf8");
|
|
5
6
|
const replaceTag = (content, tag, value) => {
|
|
6
7
|
const pattern = `\\/\\*\\s*${tag}-start:\\s*\\*\\/[\\s\\S]*?\\/\\*\\s*:${tag}-end\\s*\\*\\/`;
|
|
7
8
|
return content.replace(new RegExp(pattern, "g"), () => value);
|
|
8
9
|
};
|
|
9
|
-
const defaultTemplate = ({ __meta, program1, program2 }) => {
|
|
10
|
+
const defaultTemplate = ({ __meta, program1, program2, program0 = "", }) => {
|
|
10
11
|
const { declarationNames, styleProps, styleNames } = __meta;
|
|
11
12
|
const { map: constructorMap, imports: styleImports } = createModulesMapFromDependencies(declarationNames);
|
|
13
|
+
const helperImports = createHelperImportsFromProgram(`${program0}\n${program1}\n${program2}`);
|
|
14
|
+
const combinedImports = [styleImports, helperImports]
|
|
15
|
+
.filter(Boolean)
|
|
16
|
+
.join("\n");
|
|
12
17
|
let result = "// @ts-nocheck\n" + templateSource;
|
|
13
|
-
result = replaceTag(result, "
|
|
18
|
+
result = replaceTag(result, "imports", combinedImports);
|
|
14
19
|
result = replaceTag(result, "constructorMap", constructorMap);
|
|
15
20
|
result = replaceTag(result, "styleNames", JSON.stringify(styleNames));
|
|
16
21
|
result = replaceTag(result, "styleProps", JSON.stringify(styleProps));
|
|
22
|
+
result = replaceTag(result, "program0", program0);
|
|
17
23
|
result = replaceTag(result, "program1", program1);
|
|
18
24
|
result = replaceTag(result, "program2", program2);
|
|
25
|
+
// Strip source map comments injected by tsc or other tooling.
|
|
26
|
+
result = result.replace(/\/\/# sourceMappingURL=[^\n]*/g, "");
|
|
27
|
+
result = result.replace(/\/\*# sourceMappingURL=[^*]*\*\//g, "");
|
|
19
28
|
return result;
|
|
20
29
|
};
|
|
21
30
|
export default defaultTemplate;
|
package/dist/template.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template.js","sourceRoot":"","sources":["../src/js/template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,SAAS,CAAC;AACrC,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAC;AAElC,OAAO,gCAAg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