@cassida/parser 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/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +633 -0
- package/dist/index.js.map +1 -0
- package/dist/path-guard.d.ts +27 -0
- package/dist/path-guard.d.ts.map +1 -0
- package/dist/path-guard.js +19 -0
- package/dist/path-guard.js.map +1 -0
- package/package.json +57 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 FSS contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type CompiledRule, type CassPlugin, type Registry, type ShorthandPolicy } from '@cassida/compiler';
|
|
2
|
+
export interface TransformOptions {
|
|
3
|
+
readonly registry: Registry;
|
|
4
|
+
readonly filename?: string;
|
|
5
|
+
/**
|
|
6
|
+
* The module specifier to recognize as the source of the `fss` import.
|
|
7
|
+
* Defaults to `@cassida/core`. Renamed imports (`{ fss as ff }`) are honored.
|
|
8
|
+
*/
|
|
9
|
+
readonly importSource?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Policy for shorthand ↔ longhand co-occurrence within a single scope.
|
|
12
|
+
* Forwarded to `compileOps`. Defaults to `'strict'`.
|
|
13
|
+
*/
|
|
14
|
+
readonly shorthandPolicy?: ShorthandPolicy;
|
|
15
|
+
/**
|
|
16
|
+
* Build-time plugins forwarded to `compileOps`. Each plugin
|
|
17
|
+
* receives the post-collapse `ScopeBag` tree and returns a new
|
|
18
|
+
* one; the className is derived from the post-plugin form.
|
|
19
|
+
*/
|
|
20
|
+
readonly plugins?: readonly CassPlugin[];
|
|
21
|
+
}
|
|
22
|
+
export interface TransformResult {
|
|
23
|
+
readonly code: string;
|
|
24
|
+
readonly rules: readonly CompiledRule[];
|
|
25
|
+
readonly map: object | null;
|
|
26
|
+
readonly transformed: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function transform(source: string, options: TransformOptions): TransformResult;
|
|
29
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EAQL,KAAK,YAAY,EAEjB,KAAK,UAAU,EAIf,KAAK,QAAQ,EAEb,KAAK,eAAe,EACrB,MAAM,mBAAmB,CAAC;AAY3B,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,eAAe,CAAC;IAC3C;;;;OAIG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,WAAW,EAAE,OAAO,CAAC;CAC/B;AAUD,wBAAgB,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAyJpF"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,633 @@
|
|
|
1
|
+
import { parse } from '@babel/parser';
|
|
2
|
+
import generateModule from '@babel/generator';
|
|
3
|
+
import traverseModule, {} from '@babel/traverse';
|
|
4
|
+
import * as t from '@babel/types';
|
|
5
|
+
import { argModifiers, canonicalModifiers, compileOps, cssToCamel, DYNAMIC_TAG, EvaluatedPrimitiveSchema, isDynamic, } from '@cassida/compiler';
|
|
6
|
+
import { pathAs } from './path-guard.js';
|
|
7
|
+
// Babel's ESM packaging exposes the function under `.default` when imported
|
|
8
|
+
// from a Node ESM consumer. Tolerate either shape.
|
|
9
|
+
const traverse = (traverseModule.default ?? traverseModule);
|
|
10
|
+
const generate = (generateModule.default ?? generateModule);
|
|
11
|
+
const NON_LITERAL = Symbol('fss.non-literal');
|
|
12
|
+
export function transform(source, options) {
|
|
13
|
+
const importSource = options.importSource ?? '@cassida/core';
|
|
14
|
+
const plugins = ['jsx'];
|
|
15
|
+
if (/\.tsx?$/.test(options.filename ?? ''))
|
|
16
|
+
plugins.push('typescript');
|
|
17
|
+
const parseOpts = {
|
|
18
|
+
sourceType: 'module',
|
|
19
|
+
plugins,
|
|
20
|
+
};
|
|
21
|
+
if (options.filename !== undefined)
|
|
22
|
+
parseOpts.sourceFilename = options.filename;
|
|
23
|
+
const ast = parse(source, parseOpts);
|
|
24
|
+
// First pass: collect every local name bound to a Cassida chain
|
|
25
|
+
// entry point (`cas`, `css`, or `cassida` — all aliases for the same
|
|
26
|
+
// function in @cassida/core). Default-export imports are also
|
|
27
|
+
// accepted (`import cas from '@cassida/core'`).
|
|
28
|
+
const chainEntryNames = new Set(['cas', 'css', 'cassida']);
|
|
29
|
+
const casBindings = new Set();
|
|
30
|
+
traverse(ast, {
|
|
31
|
+
ImportDeclaration(path) {
|
|
32
|
+
if (path.node.source.value !== importSource)
|
|
33
|
+
return;
|
|
34
|
+
for (const spec of path.node.specifiers) {
|
|
35
|
+
if (t.isImportDefaultSpecifier(spec)) {
|
|
36
|
+
casBindings.add(spec.local.name);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (t.isImportSpecifier(spec) &&
|
|
40
|
+
t.isIdentifier(spec.imported) &&
|
|
41
|
+
chainEntryNames.has(spec.imported.name)) {
|
|
42
|
+
casBindings.add(spec.local.name);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
if (casBindings.size === 0) {
|
|
48
|
+
return { code: source, rules: [], map: null, transformed: false };
|
|
49
|
+
}
|
|
50
|
+
const rules = [];
|
|
51
|
+
let transformed = false;
|
|
52
|
+
const dynamicSources = new Map();
|
|
53
|
+
const counter = { n: 0 };
|
|
54
|
+
const ctx = { dynamicSources, counter };
|
|
55
|
+
traverse(ast, {
|
|
56
|
+
JSXSpreadAttribute(path) {
|
|
57
|
+
// path.get('argument') on a typed NodePath<JSXSpreadAttribute>
|
|
58
|
+
// returns NodePath<Expression>; no cast needed.
|
|
59
|
+
const argPath = path.get('argument');
|
|
60
|
+
const ops = walkChain(argPath, casBindings, ctx);
|
|
61
|
+
if (!ops)
|
|
62
|
+
return;
|
|
63
|
+
const opening = path.parent;
|
|
64
|
+
if (!t.isJSXOpeningElement(opening))
|
|
65
|
+
return;
|
|
66
|
+
// Reject multiple {...cas()} spreads on the same element.
|
|
67
|
+
const probeCtx = {
|
|
68
|
+
dynamicSources: new Map(),
|
|
69
|
+
counter: { n: 0 },
|
|
70
|
+
};
|
|
71
|
+
const otherCasSpreads = opening.attributes.filter((a) => {
|
|
72
|
+
if (a === path.node || !t.isJSXSpreadAttribute(a))
|
|
73
|
+
return false;
|
|
74
|
+
let probed = null;
|
|
75
|
+
path.parentPath?.traverse({
|
|
76
|
+
JSXSpreadAttribute(p) {
|
|
77
|
+
if (p.node === a) {
|
|
78
|
+
probed = walkChain(p.get('argument'), casBindings, probeCtx);
|
|
79
|
+
p.stop();
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
return probed !== null;
|
|
84
|
+
});
|
|
85
|
+
if (otherCasSpreads.length > 0) {
|
|
86
|
+
throw path.buildCodeFrameError('[cassida] Multiple {...cas()} spreads on the same JSX element are not supported. Combine them into a single chain.');
|
|
87
|
+
}
|
|
88
|
+
const compiled = compileOps(ops, {
|
|
89
|
+
registry: options.registry,
|
|
90
|
+
...(options.shorthandPolicy !== undefined ? { shorthandPolicy: options.shorthandPolicy } : {}),
|
|
91
|
+
...(options.plugins !== undefined ? { plugins: options.plugins } : {}),
|
|
92
|
+
});
|
|
93
|
+
rules.push(compiled);
|
|
94
|
+
let spreadIdx = -1;
|
|
95
|
+
let styleIdx = -1;
|
|
96
|
+
let classNameIdx = -1;
|
|
97
|
+
let existingStyleAttr = null;
|
|
98
|
+
let existingClassNameAttr = null;
|
|
99
|
+
for (let i = 0; i < opening.attributes.length; i++) {
|
|
100
|
+
const a = opening.attributes[i];
|
|
101
|
+
if (a === path.node) {
|
|
102
|
+
spreadIdx = i;
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (t.isJSXAttribute(a) && t.isJSXIdentifier(a.name)) {
|
|
106
|
+
if (a.name.name === 'style') {
|
|
107
|
+
existingStyleAttr = a;
|
|
108
|
+
styleIdx = i;
|
|
109
|
+
}
|
|
110
|
+
else if (a.name.name === 'className') {
|
|
111
|
+
existingClassNameAttr = a;
|
|
112
|
+
classNameIdx = i;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const casWins = spreadIdx > styleIdx;
|
|
117
|
+
const casBaseCssProps = Object.keys(compiled.tree.bag);
|
|
118
|
+
const newClassNameAttr = makeClassNameAttr(existingClassNameAttr, compiled.className);
|
|
119
|
+
const styleResult = decideStyleAttr(existingStyleAttr, compiled.dynamics, casBaseCssProps, dynamicSources, casWins);
|
|
120
|
+
const newAttrs = [];
|
|
121
|
+
for (let i = 0; i < opening.attributes.length; i++) {
|
|
122
|
+
if (i === spreadIdx) {
|
|
123
|
+
newAttrs.push(newClassNameAttr);
|
|
124
|
+
if (styleResult.attr !== null)
|
|
125
|
+
newAttrs.push(styleResult.attr);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (i === classNameIdx)
|
|
129
|
+
continue;
|
|
130
|
+
if (i === styleIdx && styleResult.replacesExisting)
|
|
131
|
+
continue;
|
|
132
|
+
newAttrs.push(opening.attributes[i]);
|
|
133
|
+
}
|
|
134
|
+
opening.attributes = newAttrs;
|
|
135
|
+
transformed = true;
|
|
136
|
+
},
|
|
137
|
+
});
|
|
138
|
+
if (!transformed) {
|
|
139
|
+
return { code: source, rules: [], map: null, transformed: false };
|
|
140
|
+
}
|
|
141
|
+
const generateOpts = {
|
|
142
|
+
sourceMaps: true,
|
|
143
|
+
retainLines: false,
|
|
144
|
+
};
|
|
145
|
+
if (options.filename !== undefined)
|
|
146
|
+
generateOpts.sourceFileName = options.filename;
|
|
147
|
+
const out = generate(ast, generateOpts, source);
|
|
148
|
+
return { code: out.code, rules, map: out.map ?? null, transformed: true };
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Walks a `cas().a().b()...` chain backward from the outermost call,
|
|
152
|
+
* accumulating ops in source order. Modifiers (`hover`, `focus`,
|
|
153
|
+
* `media`, `on`, …) recurse into their callback's body.
|
|
154
|
+
*
|
|
155
|
+
* Type-narrowing is handled through `pathAs`, so this function never
|
|
156
|
+
* needs to spread `as NodePath` casts. Once a path is confirmed to be
|
|
157
|
+
* a `CallExpression`, `path.get('callee')` and `.get('arguments')`
|
|
158
|
+
* return correctly typed sub-paths automatically.
|
|
159
|
+
*
|
|
160
|
+
* Returns null when the expression isn't rooted at one of `chainRoots`,
|
|
161
|
+
* an op has unsupported argument shape (mixed dynamic+literal, spread
|
|
162
|
+
* arguments, multiple-or-zero callback params, etc.), or any other
|
|
163
|
+
* structural mismatch. On null the caller leaves the JSX untouched.
|
|
164
|
+
*/
|
|
165
|
+
function walkChain(start, chainRoots, ctx) {
|
|
166
|
+
const ops = [];
|
|
167
|
+
let current = start;
|
|
168
|
+
while (true) {
|
|
169
|
+
// Inner-chain root: bare Identifier matching a callback param.
|
|
170
|
+
const idPath = pathAs(current, t.isIdentifier);
|
|
171
|
+
if (idPath && chainRoots.has(idPath.node.name))
|
|
172
|
+
break;
|
|
173
|
+
// Otherwise current must be a CallExpression to continue.
|
|
174
|
+
const callPath = pathAs(current, t.isCallExpression);
|
|
175
|
+
if (!callPath)
|
|
176
|
+
return null;
|
|
177
|
+
const calleePath = callPath.get('callee');
|
|
178
|
+
// Branch A: callee is `obj.method(...)` — descend the chain or
|
|
179
|
+
// intercept the special `cas.unsafe(preset)` chain root.
|
|
180
|
+
const memberPath = pathAs(calleePath, t.isMemberExpression);
|
|
181
|
+
if (memberPath && !memberPath.node.computed) {
|
|
182
|
+
const propertyPath = pathAs(memberPath.get('property'), t.isIdentifier);
|
|
183
|
+
if (!propertyPath)
|
|
184
|
+
return null;
|
|
185
|
+
const methodName = propertyPath.node.name;
|
|
186
|
+
const argPaths = callPath.get('arguments');
|
|
187
|
+
// Special case: `cas.unsafe(preset)` at the chain root. Detected
|
|
188
|
+
// when the member-object is the chain-root identifier itself
|
|
189
|
+
// (i.e. `fss`, not a callback param) AND the property is
|
|
190
|
+
// `unsafe`. The preset object is expanded into RawOps which
|
|
191
|
+
// bypass the registry — this is the user's deliberate opt-out
|
|
192
|
+
// of FSS's safety guarantees, in the spirit of Rust's `unsafe`.
|
|
193
|
+
const memberObjId = pathAs(memberPath.get('object'), t.isIdentifier);
|
|
194
|
+
if (memberObjId &&
|
|
195
|
+
chainRoots.has(memberObjId.node.name) &&
|
|
196
|
+
methodName === 'unsafe') {
|
|
197
|
+
if (argPaths.length !== 1)
|
|
198
|
+
return null;
|
|
199
|
+
const evald = argPaths[0].evaluate();
|
|
200
|
+
if (!evald.confident)
|
|
201
|
+
return null;
|
|
202
|
+
const value = evald.value;
|
|
203
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
const expanded = expandUnsafePreset(value);
|
|
207
|
+
for (let i = expanded.length - 1; i >= 0; i--)
|
|
208
|
+
ops.push(expanded[i]);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
if (methodName === 'set') {
|
|
212
|
+
// .set(key, value) — direct CSS property write, bypasses registry.
|
|
213
|
+
// Both args must be confidently-evaluable; non-confident
|
|
214
|
+
// arguments fall through to the runtime fallback for now.
|
|
215
|
+
// (Phase 7: extend RawOp to carry dynamic source IDs.)
|
|
216
|
+
if (argPaths.length !== 2)
|
|
217
|
+
return null;
|
|
218
|
+
const keyEval = argPaths[0].evaluate();
|
|
219
|
+
if (!keyEval.confident || typeof keyEval.value !== 'string')
|
|
220
|
+
return null;
|
|
221
|
+
const valEval = argPaths[1].evaluate();
|
|
222
|
+
if (!valEval.confident)
|
|
223
|
+
return null;
|
|
224
|
+
const valid = EvaluatedPrimitiveSchema.safeParse(valEval.value);
|
|
225
|
+
if (!valid.success)
|
|
226
|
+
return null;
|
|
227
|
+
ops.push({
|
|
228
|
+
property: camelToKebab(keyEval.value),
|
|
229
|
+
value: String(valid.data),
|
|
230
|
+
});
|
|
231
|
+
current = memberPath.get('object');
|
|
232
|
+
continue;
|
|
233
|
+
}
|
|
234
|
+
if (methodName in canonicalModifiers) {
|
|
235
|
+
if (argPaths.length !== 1)
|
|
236
|
+
return null;
|
|
237
|
+
const innerOps = collectFromCallback(argPaths[0], ctx);
|
|
238
|
+
if (innerOps === null)
|
|
239
|
+
return null;
|
|
240
|
+
const scope = canonicalModifiers[methodName];
|
|
241
|
+
ops.push({ scope, ops: innerOps });
|
|
242
|
+
}
|
|
243
|
+
else if (methodName in argModifiers) {
|
|
244
|
+
if (argPaths.length !== 2)
|
|
245
|
+
return null;
|
|
246
|
+
const argEval = argPaths[0].evaluate();
|
|
247
|
+
if (!argEval.confident || typeof argEval.value !== 'string')
|
|
248
|
+
return null;
|
|
249
|
+
const innerOps = collectFromCallback(argPaths[1], ctx);
|
|
250
|
+
if (innerOps === null)
|
|
251
|
+
return null;
|
|
252
|
+
const scope = inferScope(methodName, argEval.value);
|
|
253
|
+
ops.push({ scope, ops: innerOps });
|
|
254
|
+
}
|
|
255
|
+
else {
|
|
256
|
+
const args = readArgs(argPaths, ctx);
|
|
257
|
+
if (args === null)
|
|
258
|
+
return null;
|
|
259
|
+
const dynamics = args.filter(isDynamic);
|
|
260
|
+
if (dynamics.length > 0 && (args.length !== 1 || dynamics.length !== 1)) {
|
|
261
|
+
return null;
|
|
262
|
+
}
|
|
263
|
+
ops.push({ method: methodName, args });
|
|
264
|
+
}
|
|
265
|
+
current = memberPath.get('object');
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
// Branch B: callee is the chain root identifier `cas()`.
|
|
269
|
+
const casIdPath = pathAs(calleePath, t.isIdentifier);
|
|
270
|
+
if (casIdPath && chainRoots.has(casIdPath.node.name)) {
|
|
271
|
+
if (callPath.node.arguments.length === 0)
|
|
272
|
+
break;
|
|
273
|
+
if (callPath.node.arguments.length !== 1)
|
|
274
|
+
return null;
|
|
275
|
+
const argPaths = callPath.get('arguments');
|
|
276
|
+
const evald = argPaths[0].evaluate();
|
|
277
|
+
if (!evald.confident)
|
|
278
|
+
return null;
|
|
279
|
+
const value = evald.value;
|
|
280
|
+
if (typeof value !== 'object' || value === null || Array.isArray(value)) {
|
|
281
|
+
return null;
|
|
282
|
+
}
|
|
283
|
+
const expanded = expandSafePreset(value);
|
|
284
|
+
if (!expanded)
|
|
285
|
+
return null;
|
|
286
|
+
for (let i = expanded.length - 1; i >= 0; i--)
|
|
287
|
+
ops.push(expanded[i]);
|
|
288
|
+
break;
|
|
289
|
+
}
|
|
290
|
+
// Branch C: callee is an Identifier that's NOT a chain root.
|
|
291
|
+
// Treat as same-file function composition: `withCard(cas())` etc.
|
|
292
|
+
// The function must be a 1-param const arrow / function declaration
|
|
293
|
+
// whose body is a chain rooted at the param. The function's body
|
|
294
|
+
// ops are appended to the argument's ops in source order.
|
|
295
|
+
if (casIdPath) {
|
|
296
|
+
const composed = tryFunctionComposition(callPath, casIdPath, chainRoots, ctx);
|
|
297
|
+
if (composed === null)
|
|
298
|
+
return null;
|
|
299
|
+
// Push reversed so the composition lands first after the final reverse.
|
|
300
|
+
for (let i = composed.length - 1; i >= 0; i--)
|
|
301
|
+
ops.push(composed[i]);
|
|
302
|
+
break;
|
|
303
|
+
}
|
|
304
|
+
return null;
|
|
305
|
+
}
|
|
306
|
+
return ops.reverse();
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Attempts to resolve a same-file function composition like
|
|
310
|
+
* `withCard(cas())` or `withCard(withTheme(cas()))`. Returns the
|
|
311
|
+
* composed source-ordered Op list or null if the call doesn't fit
|
|
312
|
+
* the supported pattern.
|
|
313
|
+
*
|
|
314
|
+
* Phase 6c-2 supports:
|
|
315
|
+
* - `const f = (c) => c.chain()` (ArrowFunctionExpression, 1 param)
|
|
316
|
+
* - `const f = (c) => { c.chain(); }` or `{ return c.chain(); }`
|
|
317
|
+
* - `function f(c) { ... }` (FunctionDeclaration, 1 param)
|
|
318
|
+
*
|
|
319
|
+
* Phase 7 will tackle: multi-param functions, conditional bodies,
|
|
320
|
+
* loops, and cross-file imports (Linaria-class static evaluation).
|
|
321
|
+
* Anything outside the simple pattern returns null and the caller
|
|
322
|
+
* lets the chain fall through to runtime fallback.
|
|
323
|
+
*/
|
|
324
|
+
function tryFunctionComposition(callPath, calleeIdPath, chainRoots, ctx) {
|
|
325
|
+
const fnName = calleeIdPath.node.name;
|
|
326
|
+
const binding = calleeIdPath.scope.getBinding(fnName);
|
|
327
|
+
if (!binding)
|
|
328
|
+
return null;
|
|
329
|
+
// Only `const` bindings or function declarations are accepted —
|
|
330
|
+
// `let`/`var` could be reassigned and we can't follow that.
|
|
331
|
+
if (binding.kind !== 'const' && binding.kind !== 'hoisted')
|
|
332
|
+
return null;
|
|
333
|
+
// Locate the function expression (arrow or declaration).
|
|
334
|
+
let paramName = null;
|
|
335
|
+
let bodyPath = null;
|
|
336
|
+
const declPath = binding.path;
|
|
337
|
+
if (t.isVariableDeclarator(declPath.node)) {
|
|
338
|
+
const initPath = pathAs(declPath.get('init'), t.isArrowFunctionExpression);
|
|
339
|
+
if (!initPath)
|
|
340
|
+
return null;
|
|
341
|
+
if (initPath.node.params.length !== 1)
|
|
342
|
+
return null;
|
|
343
|
+
const param = initPath.node.params[0];
|
|
344
|
+
if (!t.isIdentifier(param))
|
|
345
|
+
return null;
|
|
346
|
+
paramName = param.name;
|
|
347
|
+
bodyPath = initPath.get('body');
|
|
348
|
+
}
|
|
349
|
+
else if (t.isFunctionDeclaration(declPath.node)) {
|
|
350
|
+
const fnPath = declPath;
|
|
351
|
+
if (fnPath.node.params.length !== 1)
|
|
352
|
+
return null;
|
|
353
|
+
const param = fnPath.node.params[0];
|
|
354
|
+
if (!t.isIdentifier(param))
|
|
355
|
+
return null;
|
|
356
|
+
paramName = param.name;
|
|
357
|
+
bodyPath = fnPath.get('body');
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
return null;
|
|
361
|
+
}
|
|
362
|
+
if (paramName === null || bodyPath === null)
|
|
363
|
+
return null;
|
|
364
|
+
const innerRoots = new Set([paramName]);
|
|
365
|
+
// Resolve the function body: same logic as a callback body in
|
|
366
|
+
// `collectFromCallback` — expression body or block-of-chains.
|
|
367
|
+
const blockPath = pathAs(bodyPath, t.isBlockStatement);
|
|
368
|
+
const fnBodyOps = blockPath
|
|
369
|
+
? collectFromBlock(blockPath, innerRoots, ctx)
|
|
370
|
+
: walkChain(bodyPath, innerRoots, ctx);
|
|
371
|
+
if (fnBodyOps === null)
|
|
372
|
+
return null;
|
|
373
|
+
// The argument MUST be exactly 1 (the chain to feed in).
|
|
374
|
+
const argPaths = callPath.get('arguments');
|
|
375
|
+
if (argPaths.length !== 1)
|
|
376
|
+
return null;
|
|
377
|
+
const argPath = argPaths[0];
|
|
378
|
+
if (!t.isExpression(argPath.node))
|
|
379
|
+
return null;
|
|
380
|
+
// Walk the argument with the OUTER chainRoots — typically `fss`,
|
|
381
|
+
// sometimes a recursive composition's own scope.
|
|
382
|
+
const argOps = walkChain(argPath, chainRoots, ctx);
|
|
383
|
+
if (argOps === null)
|
|
384
|
+
return null;
|
|
385
|
+
// Compose: argument ops first (the input chain), then function body
|
|
386
|
+
// ops (the mixin layered on top). LIFO inside the merged op list
|
|
387
|
+
// works exactly as if the user had written everything inline.
|
|
388
|
+
return [...argOps, ...fnBodyOps];
|
|
389
|
+
}
|
|
390
|
+
function collectFromCallback(cbPath, ctx) {
|
|
391
|
+
const arrowPath = pathAs(cbPath, t.isArrowFunctionExpression);
|
|
392
|
+
if (!arrowPath)
|
|
393
|
+
return null;
|
|
394
|
+
const params = arrowPath.node.params;
|
|
395
|
+
if (params.length === 0)
|
|
396
|
+
return [];
|
|
397
|
+
if (params.length > 1)
|
|
398
|
+
return null;
|
|
399
|
+
const param = params[0];
|
|
400
|
+
if (!t.isIdentifier(param))
|
|
401
|
+
return null;
|
|
402
|
+
const innerRoots = new Set([param.name]);
|
|
403
|
+
const bodyPath = arrowPath.get('body');
|
|
404
|
+
const blockPath = pathAs(bodyPath, t.isBlockStatement);
|
|
405
|
+
if (blockPath)
|
|
406
|
+
return collectFromBlock(blockPath, innerRoots, ctx);
|
|
407
|
+
return walkChain(bodyPath, innerRoots, ctx);
|
|
408
|
+
}
|
|
409
|
+
function collectFromBlock(blockPath, innerRoots, ctx) {
|
|
410
|
+
const allOps = [];
|
|
411
|
+
const stmtPaths = blockPath.get('body');
|
|
412
|
+
for (const stmtPath of stmtPaths) {
|
|
413
|
+
const exprStmtPath = pathAs(stmtPath, t.isExpressionStatement);
|
|
414
|
+
if (exprStmtPath) {
|
|
415
|
+
const ops = walkChain(exprStmtPath.get('expression'), innerRoots, ctx);
|
|
416
|
+
if (ops === null)
|
|
417
|
+
return null;
|
|
418
|
+
allOps.push(...ops);
|
|
419
|
+
continue;
|
|
420
|
+
}
|
|
421
|
+
const returnStmtPath = pathAs(stmtPath, t.isReturnStatement);
|
|
422
|
+
if (returnStmtPath) {
|
|
423
|
+
// ReturnStatement.argument is `Expression | null | undefined`;
|
|
424
|
+
// `pathAs` (with its widened input type) handles the nullable
|
|
425
|
+
// generic and narrows to NodePath<Expression> in one step.
|
|
426
|
+
const exprPath = pathAs(returnStmtPath.get('argument'), t.isExpression);
|
|
427
|
+
if (!exprPath)
|
|
428
|
+
continue;
|
|
429
|
+
const ops = walkChain(exprPath, innerRoots, ctx);
|
|
430
|
+
if (ops === null)
|
|
431
|
+
return null;
|
|
432
|
+
allOps.push(...ops);
|
|
433
|
+
continue;
|
|
434
|
+
}
|
|
435
|
+
return null;
|
|
436
|
+
}
|
|
437
|
+
return allOps;
|
|
438
|
+
}
|
|
439
|
+
function readArgs(argPaths, ctx) {
|
|
440
|
+
const out = [];
|
|
441
|
+
for (const argPath of argPaths) {
|
|
442
|
+
const node = argPath.node;
|
|
443
|
+
if (!t.isExpression(node))
|
|
444
|
+
return null;
|
|
445
|
+
// 1) Plain literal — fastest path.
|
|
446
|
+
const lit = literalToValue(node);
|
|
447
|
+
if (lit !== NON_LITERAL) {
|
|
448
|
+
out.push(lit);
|
|
449
|
+
continue;
|
|
450
|
+
}
|
|
451
|
+
// 2) Babel's static evaluator. Validate the evaluated result is a
|
|
452
|
+
// CSS-inlineable primitive — confidently-evaluated objects, arrays,
|
|
453
|
+
// and undefineds fall through to dynamic-CSS-variable handling.
|
|
454
|
+
const evald = argPath.evaluate();
|
|
455
|
+
if (evald.confident) {
|
|
456
|
+
const validated = EvaluatedPrimitiveSchema.safeParse(evald.value);
|
|
457
|
+
if (validated.success) {
|
|
458
|
+
out.push(validated.data);
|
|
459
|
+
continue;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
// 3) Dynamic — promote to CSS variable.
|
|
463
|
+
const id = `slot-${++ctx.counter.n}`;
|
|
464
|
+
ctx.dynamicSources.set(id, node);
|
|
465
|
+
out.push({ [DYNAMIC_TAG]: true, id });
|
|
466
|
+
}
|
|
467
|
+
return out;
|
|
468
|
+
}
|
|
469
|
+
function inferScope(modifier, value) {
|
|
470
|
+
if (modifier === 'media') {
|
|
471
|
+
return { kind: 'media', query: value.replace(/^@media\s*/i, '').trim() };
|
|
472
|
+
}
|
|
473
|
+
const trimmed = value.trim();
|
|
474
|
+
if (/^@media\b/i.test(trimmed)) {
|
|
475
|
+
return { kind: 'media', query: trimmed.replace(/^@media\s*/i, '').trim() };
|
|
476
|
+
}
|
|
477
|
+
if (trimmed.startsWith(':') || trimmed.startsWith('::')) {
|
|
478
|
+
return { kind: 'pseudo', selector: trimmed };
|
|
479
|
+
}
|
|
480
|
+
return { kind: 'raw', selector: trimmed };
|
|
481
|
+
}
|
|
482
|
+
/**
|
|
483
|
+
* Expand a confidently-evaluated preset object into a list of
|
|
484
|
+
* MethodOps for the safe `cas(preset)` path. Each key becomes a
|
|
485
|
+
* method call against the registry. Null/undefined values are
|
|
486
|
+
* skipped (idiomatic "unset" syntax). Unknown / blacklisted keys
|
|
487
|
+
* are not pre-checked here — the canonicalizer will surface them
|
|
488
|
+
* with a clear "unknown method" error.
|
|
489
|
+
*/
|
|
490
|
+
function expandSafePreset(value) {
|
|
491
|
+
const ops = [];
|
|
492
|
+
for (const [key, val] of Object.entries(value)) {
|
|
493
|
+
if (val === null || val === undefined)
|
|
494
|
+
continue;
|
|
495
|
+
ops.push({ method: key, args: [val] });
|
|
496
|
+
}
|
|
497
|
+
return ops;
|
|
498
|
+
}
|
|
499
|
+
/**
|
|
500
|
+
* Expand a preset object into RawOps for the unsafe path. Keys are
|
|
501
|
+
* accepted in either camelCase (converted to kebab) or kebab-case
|
|
502
|
+
* (passed through, including vendor prefixes like `-webkit-foo`).
|
|
503
|
+
* Values are stringified as-is. Bypasses the registry, the
|
|
504
|
+
* shorthand-policy guard, and family tracking — that's the contract
|
|
505
|
+
* of `cas.unsafe`.
|
|
506
|
+
*/
|
|
507
|
+
function expandUnsafePreset(value) {
|
|
508
|
+
const ops = [];
|
|
509
|
+
for (const [key, val] of Object.entries(value)) {
|
|
510
|
+
if (val === null || val === undefined)
|
|
511
|
+
continue;
|
|
512
|
+
ops.push({ property: camelToKebab(key), value: String(val) });
|
|
513
|
+
}
|
|
514
|
+
return ops;
|
|
515
|
+
}
|
|
516
|
+
function camelToKebab(s) {
|
|
517
|
+
// Already kebab (or vendor-prefixed `-webkit-foo`) → leave alone.
|
|
518
|
+
if (s.includes('-'))
|
|
519
|
+
return s;
|
|
520
|
+
return s.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
521
|
+
}
|
|
522
|
+
function literalToValue(node) {
|
|
523
|
+
if (t.isStringLiteral(node))
|
|
524
|
+
return node.value;
|
|
525
|
+
if (t.isNumericLiteral(node))
|
|
526
|
+
return node.value;
|
|
527
|
+
if (t.isBooleanLiteral(node))
|
|
528
|
+
return node.value;
|
|
529
|
+
if (t.isNullLiteral(node))
|
|
530
|
+
return null;
|
|
531
|
+
if (t.isUnaryExpression(node) && node.operator === '-') {
|
|
532
|
+
const inner = literalToValue(node.argument);
|
|
533
|
+
if (typeof inner === 'number')
|
|
534
|
+
return -inner;
|
|
535
|
+
return NON_LITERAL;
|
|
536
|
+
}
|
|
537
|
+
if (t.isTemplateLiteral(node) && node.expressions.length === 0) {
|
|
538
|
+
return node.quasis.map((q) => q.value.cooked ?? q.value.raw).join('');
|
|
539
|
+
}
|
|
540
|
+
return NON_LITERAL;
|
|
541
|
+
}
|
|
542
|
+
function makeClassNameAttr(existing, fssClass) {
|
|
543
|
+
if (existing === null || existing.value === null || existing.value === undefined) {
|
|
544
|
+
return t.jsxAttribute(t.jsxIdentifier('className'), t.stringLiteral(fssClass));
|
|
545
|
+
}
|
|
546
|
+
const value = existing.value;
|
|
547
|
+
if (t.isStringLiteral(value)) {
|
|
548
|
+
return t.jsxAttribute(t.jsxIdentifier('className'), t.stringLiteral(`${value.value} ${fssClass}`));
|
|
549
|
+
}
|
|
550
|
+
if (t.isJSXExpressionContainer(value)) {
|
|
551
|
+
const expr = value.expression;
|
|
552
|
+
if (t.isJSXEmptyExpression(expr)) {
|
|
553
|
+
return t.jsxAttribute(t.jsxIdentifier('className'), t.stringLiteral(fssClass));
|
|
554
|
+
}
|
|
555
|
+
return t.jsxAttribute(t.jsxIdentifier('className'), t.jsxExpressionContainer(t.templateLiteral([
|
|
556
|
+
t.templateElement({ raw: '', cooked: '' }, false),
|
|
557
|
+
t.templateElement({ raw: ` ${fssClass}`, cooked: ` ${fssClass}` }, true),
|
|
558
|
+
], [expr])));
|
|
559
|
+
}
|
|
560
|
+
return t.jsxAttribute(t.jsxIdentifier('className'), t.stringLiteral(fssClass));
|
|
561
|
+
}
|
|
562
|
+
function getStaticKeyName(key) {
|
|
563
|
+
if (t.isIdentifier(key))
|
|
564
|
+
return key.name;
|
|
565
|
+
if (t.isStringLiteral(key))
|
|
566
|
+
return key.value;
|
|
567
|
+
return null;
|
|
568
|
+
}
|
|
569
|
+
function getExistingStyleExpr(attr) {
|
|
570
|
+
if (attr === null || attr.value === null || attr.value === undefined)
|
|
571
|
+
return null;
|
|
572
|
+
if (!t.isJSXExpressionContainer(attr.value))
|
|
573
|
+
return null;
|
|
574
|
+
const expr = attr.value.expression;
|
|
575
|
+
if (t.isJSXEmptyExpression(expr))
|
|
576
|
+
return null;
|
|
577
|
+
return expr;
|
|
578
|
+
}
|
|
579
|
+
function decideStyleAttr(existing, dynamics, casCssProps, dynamicSources, casWins) {
|
|
580
|
+
const casCamelProps = new Set(casCssProps.map(cssToCamel));
|
|
581
|
+
const existingExpr = getExistingStyleExpr(existing);
|
|
582
|
+
let mustReplace = dynamics.length > 0;
|
|
583
|
+
if (!mustReplace && casWins && existingExpr !== null && t.isObjectExpression(existingExpr)) {
|
|
584
|
+
for (const p of existingExpr.properties) {
|
|
585
|
+
if (t.isObjectProperty(p) && !p.computed) {
|
|
586
|
+
const key = getStaticKeyName(p.key);
|
|
587
|
+
if (key !== null && casCamelProps.has(key)) {
|
|
588
|
+
mustReplace = true;
|
|
589
|
+
break;
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
if (!mustReplace) {
|
|
595
|
+
return { attr: null, replacesExisting: false };
|
|
596
|
+
}
|
|
597
|
+
const casVarProps = dynamics.map((slot) => {
|
|
598
|
+
const value = dynamicSources.get(slot.sourceId);
|
|
599
|
+
if (!value) {
|
|
600
|
+
throw new Error(`[cassida] internal: missing source AST for slot ${slot.sourceId}`);
|
|
601
|
+
}
|
|
602
|
+
return t.objectProperty(t.stringLiteral(slot.varName), value);
|
|
603
|
+
});
|
|
604
|
+
const userProps = [];
|
|
605
|
+
if (existingExpr !== null) {
|
|
606
|
+
if (t.isObjectExpression(existingExpr)) {
|
|
607
|
+
for (const p of existingExpr.properties) {
|
|
608
|
+
if (casWins && t.isObjectProperty(p) && !p.computed) {
|
|
609
|
+
const key = getStaticKeyName(p.key);
|
|
610
|
+
if (key !== null && casCamelProps.has(key))
|
|
611
|
+
continue;
|
|
612
|
+
}
|
|
613
|
+
if (t.isObjectProperty(p) || t.isSpreadElement(p)) {
|
|
614
|
+
userProps.push(p);
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
else {
|
|
619
|
+
userProps.push(t.spreadElement(existingExpr));
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
const props = casWins
|
|
623
|
+
? [...userProps, ...casVarProps]
|
|
624
|
+
: [...casVarProps, ...userProps];
|
|
625
|
+
if (props.length === 0) {
|
|
626
|
+
return { attr: null, replacesExisting: true };
|
|
627
|
+
}
|
|
628
|
+
return {
|
|
629
|
+
attr: t.jsxAttribute(t.jsxIdentifier('style'), t.jsxExpressionContainer(t.objectExpression(props))),
|
|
630
|
+
replacesExisting: true,
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAqB,MAAM,eAAe,CAAC;AACzD,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,cAAc,EAAE,EAAiB,MAAM,iBAAiB,CAAC;AAChE,OAAO,KAAK,CAAC,MAAM,cAAc,CAAC;AAClC,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,UAAU,EACV,UAAU,EACV,WAAW,EACX,wBAAwB,EACxB,SAAS,GAUV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,4EAA4E;AAC5E,mDAAmD;AACnD,MAAM,QAAQ,GAAG,CACd,cAAsD,CAAC,OAAO,IAAI,cAAc,CACzD,CAAC;AAC3B,MAAM,QAAQ,GAAG,CACd,cAAsD,CAAC,OAAO,IAAI,cAAc,CACzD,CAAC;AA8B3B,MAAM,WAAW,GAAkB,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAQ7D,MAAM,UAAU,SAAS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/traverse';
|
|
2
|
+
import type * as t from '@babel/types';
|
|
3
|
+
/**
|
|
4
|
+
* Path-like input for `pathAs`.
|
|
5
|
+
*
|
|
6
|
+
* Babel's `path.get('field')` may return `NodePath<X | null | undefined>`
|
|
7
|
+
* when the AST field is itself nullable (e.g. `ReturnStatement.argument`).
|
|
8
|
+
* Accepting the wider input type lets `pathAs` be the *single* point of
|
|
9
|
+
* narrowing for both regular and nullable paths.
|
|
10
|
+
*/
|
|
11
|
+
type AnyNodePath = NodePath | NodePath<t.Node | null | undefined>;
|
|
12
|
+
/**
|
|
13
|
+
* Narrows a `NodePath` by a Babel type predicate.
|
|
14
|
+
*
|
|
15
|
+
* The single internal `as` is type-safe: the predicate has just been
|
|
16
|
+
* verified, and `NodePath<X>` is a phantom-typed wrapper (no runtime
|
|
17
|
+
* difference between `NodePath<CallExpression>` and `NodePath<Identifier>`),
|
|
18
|
+
* so reinterpreting the same object under a more specific type generic
|
|
19
|
+
* is sound.
|
|
20
|
+
*
|
|
21
|
+
* Use at the boundary where a generic `NodePath` needs narrowing;
|
|
22
|
+
* downstream code can then call `.get('field')` and receive a properly
|
|
23
|
+
* typed sub-path with no further casts.
|
|
24
|
+
*/
|
|
25
|
+
export declare function pathAs<N extends t.Node>(path: AnyNodePath, predicate: (n: t.Node) => n is N): NodePath<N> | null;
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=path-guard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-guard.d.ts","sourceRoot":"","sources":["../src/path-guard.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,KAAK,CAAC,MAAM,cAAc,CAAC;AAEvC;;;;;;;GAOG;AACH,KAAK,WAAW,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAElE;;;;;;;;;;;;GAYG;AACH,wBAAgB,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,IAAI,EACrC,IAAI,EAAE,WAAW,EACjB,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAC/B,QAAQ,CAAC,CAAC,CAAC,GAAG,IAAI,CAGpB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Narrows a `NodePath` by a Babel type predicate.
|
|
3
|
+
*
|
|
4
|
+
* The single internal `as` is type-safe: the predicate has just been
|
|
5
|
+
* verified, and `NodePath<X>` is a phantom-typed wrapper (no runtime
|
|
6
|
+
* difference between `NodePath<CallExpression>` and `NodePath<Identifier>`),
|
|
7
|
+
* so reinterpreting the same object under a more specific type generic
|
|
8
|
+
* is sound.
|
|
9
|
+
*
|
|
10
|
+
* Use at the boundary where a generic `NodePath` needs narrowing;
|
|
11
|
+
* downstream code can then call `.get('field')` and receive a properly
|
|
12
|
+
* typed sub-path with no further casts.
|
|
13
|
+
*/
|
|
14
|
+
export function pathAs(path, predicate) {
|
|
15
|
+
if (!path.node)
|
|
16
|
+
return null;
|
|
17
|
+
return predicate(path.node) ? path : null;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=path-guard.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path-guard.js","sourceRoot":"","sources":["../src/path-guard.ts"],"names":[],"mappings":"AAaA;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,MAAM,CACpB,IAAiB,EACjB,SAAgC;IAEhC,IAAI,CAAC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAC;IAC5B,OAAO,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAE,IAA+B,CAAC,CAAC,CAAC,IAAI,CAAC;AACxE,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cassida/parser",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cassida Babel-based AST transform: detects cas() chains in JSX spread and rewrites them to static className attributes.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@babel/generator": "^7.26.2",
|
|
20
|
+
"@babel/parser": "^7.26.2",
|
|
21
|
+
"@babel/traverse": "^7.25.9",
|
|
22
|
+
"@babel/types": "^7.26.0",
|
|
23
|
+
"@cassida/compiler": "0.1.0"
|
|
24
|
+
},
|
|
25
|
+
"devDependencies": {
|
|
26
|
+
"@types/babel__generator": "^7.6.8",
|
|
27
|
+
"@types/babel__traverse": "^7.20.6",
|
|
28
|
+
"@types/node": "^22.9.0",
|
|
29
|
+
"typescript": "^5.6.3",
|
|
30
|
+
"vitest": "^2.1.4"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "git+https://github.com/pishio/cassida.git",
|
|
35
|
+
"directory": "packages/parser"
|
|
36
|
+
},
|
|
37
|
+
"homepage": "https://github.com/pishio/cassida/tree/main/packages/parser#readme",
|
|
38
|
+
"bugs": {
|
|
39
|
+
"url": "https://github.com/pishio/cassida/issues"
|
|
40
|
+
},
|
|
41
|
+
"author": "pishio",
|
|
42
|
+
"keywords": [
|
|
43
|
+
"cassida",
|
|
44
|
+
"css-in-js",
|
|
45
|
+
"compile-time",
|
|
46
|
+
"single-class",
|
|
47
|
+
"react"
|
|
48
|
+
],
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public"
|
|
51
|
+
},
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -p tsconfig.json",
|
|
54
|
+
"test": "vitest run",
|
|
55
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
56
|
+
}
|
|
57
|
+
}
|