@bamboocss/parser 1.13.2 → 1.15.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/dist/index.cjs +28 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +28 -0
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -482,6 +482,7 @@ var ParserResult = class {
|
|
|
482
482
|
cva = /* @__PURE__ */ new Set();
|
|
483
483
|
sva = /* @__PURE__ */ new Set();
|
|
484
484
|
token = /* @__PURE__ */ new Set();
|
|
485
|
+
viewTransition = /* @__PURE__ */ new Set();
|
|
485
486
|
recipe = /* @__PURE__ */ new Map();
|
|
486
487
|
pattern = /* @__PURE__ */ new Map();
|
|
487
488
|
filePath;
|
|
@@ -560,6 +561,11 @@ var ParserResult = class {
|
|
|
560
561
|
setToken(result) {
|
|
561
562
|
this.token.add(this.append(Object.assign({ type: "token" }, result)));
|
|
562
563
|
}
|
|
564
|
+
setViewTransition(result) {
|
|
565
|
+
this.viewTransition.add(this.append(Object.assign({ type: "viewTransition" }, result)));
|
|
566
|
+
const encoder = this.encoder;
|
|
567
|
+
result.data.forEach((obj) => encoder.processViewTransition(obj));
|
|
568
|
+
}
|
|
563
569
|
setJsx(result) {
|
|
564
570
|
this.jsx.add(this.append(Object.assign({ type: "jsx" }, result)));
|
|
565
571
|
const encoder = this.encoder;
|
|
@@ -601,6 +607,7 @@ var ParserResult = class {
|
|
|
601
607
|
result.cva.forEach((item) => this.cva.add(this.append(item)));
|
|
602
608
|
result.sva.forEach((item) => this.sva.add(this.append(item)));
|
|
603
609
|
result.token.forEach((item) => this.token.add(this.append(item)));
|
|
610
|
+
result.viewTransition.forEach((item) => this.viewTransition.add(this.append(item)));
|
|
604
611
|
result.jsx.forEach((item) => this.jsx.add(this.append(item)));
|
|
605
612
|
result.recipe.forEach((items, name) => {
|
|
606
613
|
const set = (0, _bamboocss_shared.getOrCreateSet)(this.recipe, name);
|
|
@@ -621,6 +628,7 @@ var ParserResult = class {
|
|
|
621
628
|
cva: Array.from(this.cva),
|
|
622
629
|
sva: Array.from(this.sva),
|
|
623
630
|
token: Array.from(this.token),
|
|
631
|
+
viewTransition: Array.from(this.viewTransition),
|
|
624
632
|
jsx: Array.from(this.jsx),
|
|
625
633
|
recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
|
|
626
634
|
pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)]))
|
|
@@ -637,6 +645,13 @@ const combineResult = (unboxed) => {
|
|
|
637
645
|
];
|
|
638
646
|
};
|
|
639
647
|
const defaultEnv = { preset: "ECMA" };
|
|
648
|
+
/**
|
|
649
|
+
* `fallback()` is generated into `styled-system/css`, so evaluating a call to it would mean
|
|
650
|
+
* resolving and running generated code. It is a pure string builder, so the definition is
|
|
651
|
+
* repeated here — without it the call is unresolvable and the whole declaration is dropped
|
|
652
|
+
* with no diagnostic, which is worse than not shipping the helper at all.
|
|
653
|
+
*/
|
|
654
|
+
const fallbackImpl = (...values) => values.some((value) => value === void 0) ? void 0 : `fallback(${values.join(", ")})`;
|
|
640
655
|
const evaluateOptions = { environment: defaultEnv };
|
|
641
656
|
function createParser(context) {
|
|
642
657
|
const { jsx, imports, recipes, config } = context;
|
|
@@ -684,6 +699,11 @@ function createParser(context) {
|
|
|
684
699
|
getEvaluateOptions: (node) => {
|
|
685
700
|
if (!ts_morph.Node.isCallExpression(node)) return evaluateOptions;
|
|
686
701
|
const propAccessExpr = node.getExpression();
|
|
702
|
+
if (ts_morph.Node.isIdentifier(propAccessExpr)) {
|
|
703
|
+
const local = propAccessExpr.getText();
|
|
704
|
+
if (!file.match(local) || file.getName(local) !== "fallback") return evaluateOptions;
|
|
705
|
+
return { environment: Object.assign({}, defaultEnv, { extra: { [local]: fallbackImpl } }) };
|
|
706
|
+
}
|
|
687
707
|
if (!ts_morph.Node.isPropertyAccessExpression(propAccessExpr)) return evaluateOptions;
|
|
688
708
|
let name = propAccessExpr.getText();
|
|
689
709
|
if (!file.isRawFn(name)) return evaluateOptions;
|
|
@@ -742,6 +762,14 @@ function createParser(context) {
|
|
|
742
762
|
data: combineResult((0, _bamboocss_extractor.unbox)(query.box.value[0]))
|
|
743
763
|
});
|
|
744
764
|
});
|
|
765
|
+
}).when((name) => syntax !== "template-literal" && file.isViewTransitionFn(name), (name) => {
|
|
766
|
+
result.queryList.forEach((query) => {
|
|
767
|
+
if (query.kind === "call-expression") parserResult.setViewTransition({
|
|
768
|
+
name,
|
|
769
|
+
box: query.box.value[0] ?? _bamboocss_extractor.box.fallback(query.box),
|
|
770
|
+
data: combineResult((0, _bamboocss_extractor.unbox)(query.box.value[0]))
|
|
771
|
+
});
|
|
772
|
+
});
|
|
745
773
|
}).when(jsx.isJsxFactory, () => {
|
|
746
774
|
result.queryList.forEach((query) => {
|
|
747
775
|
if (query.kind === "call-expression" && query.box.value[1]) {
|
package/dist/index.d.cts
CHANGED
|
@@ -129,6 +129,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
129
129
|
cva: Set<ResultItem>;
|
|
130
130
|
sva: Set<ResultItem>;
|
|
131
131
|
token: Set<ResultItem>;
|
|
132
|
+
viewTransition: Set<ResultItem>;
|
|
132
133
|
recipe: Map<string, Set<ResultItem>>;
|
|
133
134
|
pattern: Map<string, Set<ResultItem>>;
|
|
134
135
|
filePath: string | undefined;
|
|
@@ -140,6 +141,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
140
141
|
setCva(result: ResultItem): void;
|
|
141
142
|
setSva(result: ResultItem): void;
|
|
142
143
|
setToken(result: ResultItem): void;
|
|
144
|
+
setViewTransition(result: ResultItem): void;
|
|
143
145
|
setJsx(result: ResultItem): void;
|
|
144
146
|
setPattern(name: string, result: ResultItem): void;
|
|
145
147
|
setRecipe(recipeName: string, result: ResultItem): void;
|
|
@@ -152,6 +154,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
152
154
|
cva: ResultItem[];
|
|
153
155
|
sva: ResultItem[];
|
|
154
156
|
token: ResultItem[];
|
|
157
|
+
viewTransition: ResultItem[];
|
|
155
158
|
jsx: ResultItem[];
|
|
156
159
|
recipe: {
|
|
157
160
|
[k: string]: ResultItem[];
|
package/dist/index.d.mts
CHANGED
|
@@ -129,6 +129,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
129
129
|
cva: Set<ResultItem>;
|
|
130
130
|
sva: Set<ResultItem>;
|
|
131
131
|
token: Set<ResultItem>;
|
|
132
|
+
viewTransition: Set<ResultItem>;
|
|
132
133
|
recipe: Map<string, Set<ResultItem>>;
|
|
133
134
|
pattern: Map<string, Set<ResultItem>>;
|
|
134
135
|
filePath: string | undefined;
|
|
@@ -140,6 +141,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
140
141
|
setCva(result: ResultItem): void;
|
|
141
142
|
setSva(result: ResultItem): void;
|
|
142
143
|
setToken(result: ResultItem): void;
|
|
144
|
+
setViewTransition(result: ResultItem): void;
|
|
143
145
|
setJsx(result: ResultItem): void;
|
|
144
146
|
setPattern(name: string, result: ResultItem): void;
|
|
145
147
|
setRecipe(recipeName: string, result: ResultItem): void;
|
|
@@ -152,6 +154,7 @@ declare class ParserResult implements ParserResultInterface {
|
|
|
152
154
|
cva: ResultItem[];
|
|
153
155
|
sva: ResultItem[];
|
|
154
156
|
token: ResultItem[];
|
|
157
|
+
viewTransition: ResultItem[];
|
|
155
158
|
jsx: ResultItem[];
|
|
156
159
|
recipe: {
|
|
157
160
|
[k: string]: ResultItem[];
|
package/dist/index.mjs
CHANGED
|
@@ -481,6 +481,7 @@ var ParserResult = class {
|
|
|
481
481
|
cva = /* @__PURE__ */ new Set();
|
|
482
482
|
sva = /* @__PURE__ */ new Set();
|
|
483
483
|
token = /* @__PURE__ */ new Set();
|
|
484
|
+
viewTransition = /* @__PURE__ */ new Set();
|
|
484
485
|
recipe = /* @__PURE__ */ new Map();
|
|
485
486
|
pattern = /* @__PURE__ */ new Map();
|
|
486
487
|
filePath;
|
|
@@ -559,6 +560,11 @@ var ParserResult = class {
|
|
|
559
560
|
setToken(result) {
|
|
560
561
|
this.token.add(this.append(Object.assign({ type: "token" }, result)));
|
|
561
562
|
}
|
|
563
|
+
setViewTransition(result) {
|
|
564
|
+
this.viewTransition.add(this.append(Object.assign({ type: "viewTransition" }, result)));
|
|
565
|
+
const encoder = this.encoder;
|
|
566
|
+
result.data.forEach((obj) => encoder.processViewTransition(obj));
|
|
567
|
+
}
|
|
562
568
|
setJsx(result) {
|
|
563
569
|
this.jsx.add(this.append(Object.assign({ type: "jsx" }, result)));
|
|
564
570
|
const encoder = this.encoder;
|
|
@@ -600,6 +606,7 @@ var ParserResult = class {
|
|
|
600
606
|
result.cva.forEach((item) => this.cva.add(this.append(item)));
|
|
601
607
|
result.sva.forEach((item) => this.sva.add(this.append(item)));
|
|
602
608
|
result.token.forEach((item) => this.token.add(this.append(item)));
|
|
609
|
+
result.viewTransition.forEach((item) => this.viewTransition.add(this.append(item)));
|
|
603
610
|
result.jsx.forEach((item) => this.jsx.add(this.append(item)));
|
|
604
611
|
result.recipe.forEach((items, name) => {
|
|
605
612
|
const set = getOrCreateSet(this.recipe, name);
|
|
@@ -620,6 +627,7 @@ var ParserResult = class {
|
|
|
620
627
|
cva: Array.from(this.cva),
|
|
621
628
|
sva: Array.from(this.sva),
|
|
622
629
|
token: Array.from(this.token),
|
|
630
|
+
viewTransition: Array.from(this.viewTransition),
|
|
623
631
|
jsx: Array.from(this.jsx),
|
|
624
632
|
recipe: Object.fromEntries(Array.from(this.recipe.entries()).map(([key, value]) => [key, Array.from(value)])),
|
|
625
633
|
pattern: Object.fromEntries(Array.from(this.pattern.entries()).map(([key, value]) => [key, Array.from(value)]))
|
|
@@ -636,6 +644,13 @@ const combineResult = (unboxed) => {
|
|
|
636
644
|
];
|
|
637
645
|
};
|
|
638
646
|
const defaultEnv = { preset: "ECMA" };
|
|
647
|
+
/**
|
|
648
|
+
* `fallback()` is generated into `styled-system/css`, so evaluating a call to it would mean
|
|
649
|
+
* resolving and running generated code. It is a pure string builder, so the definition is
|
|
650
|
+
* repeated here — without it the call is unresolvable and the whole declaration is dropped
|
|
651
|
+
* with no diagnostic, which is worse than not shipping the helper at all.
|
|
652
|
+
*/
|
|
653
|
+
const fallbackImpl = (...values) => values.some((value) => value === void 0) ? void 0 : `fallback(${values.join(", ")})`;
|
|
639
654
|
const evaluateOptions = { environment: defaultEnv };
|
|
640
655
|
function createParser(context) {
|
|
641
656
|
const { jsx, imports, recipes, config } = context;
|
|
@@ -683,6 +698,11 @@ function createParser(context) {
|
|
|
683
698
|
getEvaluateOptions: (node) => {
|
|
684
699
|
if (!Node.isCallExpression(node)) return evaluateOptions;
|
|
685
700
|
const propAccessExpr = node.getExpression();
|
|
701
|
+
if (Node.isIdentifier(propAccessExpr)) {
|
|
702
|
+
const local = propAccessExpr.getText();
|
|
703
|
+
if (!file.match(local) || file.getName(local) !== "fallback") return evaluateOptions;
|
|
704
|
+
return { environment: Object.assign({}, defaultEnv, { extra: { [local]: fallbackImpl } }) };
|
|
705
|
+
}
|
|
686
706
|
if (!Node.isPropertyAccessExpression(propAccessExpr)) return evaluateOptions;
|
|
687
707
|
let name = propAccessExpr.getText();
|
|
688
708
|
if (!file.isRawFn(name)) return evaluateOptions;
|
|
@@ -741,6 +761,14 @@ function createParser(context) {
|
|
|
741
761
|
data: combineResult(unbox(query.box.value[0]))
|
|
742
762
|
});
|
|
743
763
|
});
|
|
764
|
+
}).when((name) => syntax !== "template-literal" && file.isViewTransitionFn(name), (name) => {
|
|
765
|
+
result.queryList.forEach((query) => {
|
|
766
|
+
if (query.kind === "call-expression") parserResult.setViewTransition({
|
|
767
|
+
name,
|
|
768
|
+
box: query.box.value[0] ?? box.fallback(query.box),
|
|
769
|
+
data: combineResult(unbox(query.box.value[0]))
|
|
770
|
+
});
|
|
771
|
+
});
|
|
744
772
|
}).when(jsx.isJsxFactory, () => {
|
|
745
773
|
result.queryList.forEach((query) => {
|
|
746
774
|
if (query.kind === "call-expression" && query.box.value[1]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bamboocss/parser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.15.0",
|
|
4
4
|
"description": "The static parser for bamboo css",
|
|
5
5
|
"homepage": "https://bamboocss.com",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,17 +34,17 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"ts-morph": "28.0.0",
|
|
36
36
|
"ts-pattern": "5.9.0",
|
|
37
|
-
"@bamboocss/config": "^1.
|
|
38
|
-
"@bamboocss/core": "^1.
|
|
39
|
-
"@bamboocss/extractor": "1.
|
|
40
|
-
"@bamboocss/
|
|
41
|
-
"@bamboocss/
|
|
42
|
-
"@bamboocss/types": "1.
|
|
37
|
+
"@bamboocss/config": "^1.15.0",
|
|
38
|
+
"@bamboocss/core": "^1.15.0",
|
|
39
|
+
"@bamboocss/extractor": "1.15.0",
|
|
40
|
+
"@bamboocss/shared": "1.15.0",
|
|
41
|
+
"@bamboocss/logger": "1.15.0",
|
|
42
|
+
"@bamboocss/types": "1.15.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@bamboocss/generator": "1.
|
|
46
|
-
"@bamboocss/plugin-svelte": "1.
|
|
47
|
-
"@bamboocss/plugin-vue": "1.
|
|
45
|
+
"@bamboocss/generator": "1.15.0",
|
|
46
|
+
"@bamboocss/plugin-svelte": "1.15.0",
|
|
47
|
+
"@bamboocss/plugin-vue": "1.15.0"
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "tsdown src/index.ts --format=esm,cjs --dts",
|