@pandacss/parser 0.0.0-dev-20230418111141 → 0.0.0-dev-20230419091337
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.d.ts +1 -1
- package/dist/index.js +13 -29
- package/dist/index.mjs +13 -29
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -37,7 +37,7 @@ declare const createProject: ({ getFiles, readFile, parserOptions, ...projectOpt
|
|
|
37
37
|
getSourceFile: (filePath: string) => ts_morph.SourceFile | undefined;
|
|
38
38
|
removeSourceFile: (filePath: string) => void;
|
|
39
39
|
createSourceFile: (filePath: string) => ts_morph.SourceFile;
|
|
40
|
-
parseSourceFile: (filePath: string
|
|
40
|
+
parseSourceFile: (filePath: string) => _pandacss_types.ParserResult | undefined;
|
|
41
41
|
reloadSourceFile: (filePath: string) => ts_morph.FileSystemRefreshResult | undefined;
|
|
42
42
|
reloadSourceFiles: () => void;
|
|
43
43
|
};
|
package/dist/index.js
CHANGED
|
@@ -132,7 +132,7 @@ var combineResult = (unboxed) => {
|
|
|
132
132
|
};
|
|
133
133
|
var defaultEnv = { preset: "NONE" };
|
|
134
134
|
function createParser(options) {
|
|
135
|
-
return function parse(sourceFile
|
|
135
|
+
return function parse(sourceFile) {
|
|
136
136
|
if (!sourceFile)
|
|
137
137
|
return;
|
|
138
138
|
const filePath = sourceFile.getFilePath();
|
|
@@ -175,7 +175,7 @@ function createParser(options) {
|
|
|
175
175
|
});
|
|
176
176
|
const functions = /* @__PURE__ */ new Map();
|
|
177
177
|
const components = /* @__PURE__ */ new Map();
|
|
178
|
-
const propertiesMap = new Map(
|
|
178
|
+
const propertiesMap = /* @__PURE__ */ new Map();
|
|
179
179
|
const recipePropertiesByName = /* @__PURE__ */ new Map();
|
|
180
180
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
181
181
|
(acc, recipe) => {
|
|
@@ -195,12 +195,11 @@ function createParser(options) {
|
|
|
195
195
|
const cssAlias = imports.getAlias("css");
|
|
196
196
|
if (options.jsx) {
|
|
197
197
|
options.jsx.nodes.forEach((node) => {
|
|
198
|
-
const properties = node.props ? new Map(propertiesMap) : propertiesMap;
|
|
199
198
|
const alias = imports.getAlias(node.name);
|
|
200
|
-
node.props?.forEach((prop) =>
|
|
201
|
-
functions.set(node.baseName,
|
|
202
|
-
functions.set(alias,
|
|
203
|
-
components.set(alias,
|
|
199
|
+
node.props?.forEach((prop) => propertiesMap.set(prop, true));
|
|
200
|
+
functions.set(node.baseName, propertiesMap);
|
|
201
|
+
functions.set(alias, propertiesMap);
|
|
202
|
+
components.set(alias, propertiesMap);
|
|
204
203
|
});
|
|
205
204
|
}
|
|
206
205
|
const getRecipeName = (0, import_shared2.memo)(options.getRecipeName);
|
|
@@ -215,13 +214,11 @@ function createParser(options) {
|
|
|
215
214
|
const matchTagProp = (0, import_shared2.memo)((tagName, propName) => {
|
|
216
215
|
if (propertiesMap.size === 0)
|
|
217
216
|
return true;
|
|
218
|
-
if (Boolean(components.get(tagName)?.
|
|
217
|
+
if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
|
|
219
218
|
return true;
|
|
220
219
|
if (isJsxTagRecipe(tagName)) {
|
|
221
220
|
const recipe = getRecipeByName(getRecipeName(tagName));
|
|
222
|
-
|
|
223
|
-
return recipePropertiesByName.get(recipe.name)?.has(propName) ?? false;
|
|
224
|
-
}
|
|
221
|
+
return recipe != null && !!recipePropertiesByName.get(recipe.name)?.has(propName);
|
|
225
222
|
}
|
|
226
223
|
return false;
|
|
227
224
|
});
|
|
@@ -230,20 +227,7 @@ function createParser(options) {
|
|
|
230
227
|
return true;
|
|
231
228
|
if (fnName === cvaAlias || fnName === cssAlias || fnName.startsWith(jsxFactoryAlias))
|
|
232
229
|
return true;
|
|
233
|
-
return
|
|
234
|
-
});
|
|
235
|
-
const matchFnProp = (0, import_shared2.memo)((fnName, propName) => {
|
|
236
|
-
if (propertiesMap.size === 0)
|
|
237
|
-
return true;
|
|
238
|
-
if (recipes.has(fnName) || patterns.has(fnName))
|
|
239
|
-
return true;
|
|
240
|
-
if (fnName === cvaAlias)
|
|
241
|
-
return true;
|
|
242
|
-
if (fnName.startsWith(jsxFactoryAlias))
|
|
243
|
-
return true;
|
|
244
|
-
if (fnName === cssAlias)
|
|
245
|
-
return Boolean(propertiesMap.get(propName) || propName === "selectors");
|
|
246
|
-
return Boolean(functions.get(fnName)?.get(propName));
|
|
230
|
+
return functions.has(fnName);
|
|
247
231
|
});
|
|
248
232
|
const measure = import_logger.logger.time.debug(`Tokens extracted from ${filePath}`);
|
|
249
233
|
const extractResultByName = (0, import_extractor.extract)({
|
|
@@ -254,7 +238,7 @@ function createParser(options) {
|
|
|
254
238
|
},
|
|
255
239
|
functions: {
|
|
256
240
|
matchFn: (prop) => matchFn(prop.fnName),
|
|
257
|
-
matchProp: (
|
|
241
|
+
matchProp: () => true,
|
|
258
242
|
matchArg: (prop) => {
|
|
259
243
|
if (prop.fnName === jsxFactoryAlias && prop.index === 1 && import_ts_morph.Node.isIdentifier(prop.argNode))
|
|
260
244
|
return false;
|
|
@@ -331,7 +315,7 @@ function createParser(options) {
|
|
|
331
315
|
return collector;
|
|
332
316
|
};
|
|
333
317
|
}
|
|
334
|
-
var isUpperCase = (value) => value[0] === value[0]
|
|
318
|
+
var isUpperCase = (value) => value[0] === value[0]?.toUpperCase();
|
|
335
319
|
|
|
336
320
|
// src/project.ts
|
|
337
321
|
var createTsProject = (options) => new import_ts_morph2.Project({
|
|
@@ -362,8 +346,8 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
|
|
|
362
346
|
overwrite: true,
|
|
363
347
|
scriptKind: import_ts_morph2.ScriptKind.TSX
|
|
364
348
|
}),
|
|
365
|
-
parseSourceFile: (filePath
|
|
366
|
-
return parser(project.getSourceFile(filePath)
|
|
349
|
+
parseSourceFile: (filePath) => {
|
|
350
|
+
return parser(project.getSourceFile(filePath));
|
|
367
351
|
}
|
|
368
352
|
})),
|
|
369
353
|
(0, import_lil_fp.tap)(({ createSourceFile }) => {
|
package/dist/index.mjs
CHANGED
|
@@ -106,7 +106,7 @@ var combineResult = (unboxed) => {
|
|
|
106
106
|
};
|
|
107
107
|
var defaultEnv = { preset: "NONE" };
|
|
108
108
|
function createParser(options) {
|
|
109
|
-
return function parse(sourceFile
|
|
109
|
+
return function parse(sourceFile) {
|
|
110
110
|
if (!sourceFile)
|
|
111
111
|
return;
|
|
112
112
|
const filePath = sourceFile.getFilePath();
|
|
@@ -149,7 +149,7 @@ function createParser(options) {
|
|
|
149
149
|
});
|
|
150
150
|
const functions = /* @__PURE__ */ new Map();
|
|
151
151
|
const components = /* @__PURE__ */ new Map();
|
|
152
|
-
const propertiesMap = new Map(
|
|
152
|
+
const propertiesMap = /* @__PURE__ */ new Map();
|
|
153
153
|
const recipePropertiesByName = /* @__PURE__ */ new Map();
|
|
154
154
|
const recipeJsxLists = (jsx?.nodes ?? []).filter(isNodeRecipe).reduce(
|
|
155
155
|
(acc, recipe) => {
|
|
@@ -169,12 +169,11 @@ function createParser(options) {
|
|
|
169
169
|
const cssAlias = imports.getAlias("css");
|
|
170
170
|
if (options.jsx) {
|
|
171
171
|
options.jsx.nodes.forEach((node) => {
|
|
172
|
-
const properties = node.props ? new Map(propertiesMap) : propertiesMap;
|
|
173
172
|
const alias = imports.getAlias(node.name);
|
|
174
|
-
node.props?.forEach((prop) =>
|
|
175
|
-
functions.set(node.baseName,
|
|
176
|
-
functions.set(alias,
|
|
177
|
-
components.set(alias,
|
|
173
|
+
node.props?.forEach((prop) => propertiesMap.set(prop, true));
|
|
174
|
+
functions.set(node.baseName, propertiesMap);
|
|
175
|
+
functions.set(alias, propertiesMap);
|
|
176
|
+
components.set(alias, propertiesMap);
|
|
178
177
|
});
|
|
179
178
|
}
|
|
180
179
|
const getRecipeName = memo2(options.getRecipeName);
|
|
@@ -189,13 +188,11 @@ function createParser(options) {
|
|
|
189
188
|
const matchTagProp = memo2((tagName, propName) => {
|
|
190
189
|
if (propertiesMap.size === 0)
|
|
191
190
|
return true;
|
|
192
|
-
if (Boolean(components.get(tagName)?.
|
|
191
|
+
if (Boolean(components.get(tagName)?.has(propName)) || options.jsx?.isStyleProp(propName) || propertiesMap.has(propName))
|
|
193
192
|
return true;
|
|
194
193
|
if (isJsxTagRecipe(tagName)) {
|
|
195
194
|
const recipe = getRecipeByName(getRecipeName(tagName));
|
|
196
|
-
|
|
197
|
-
return recipePropertiesByName.get(recipe.name)?.has(propName) ?? false;
|
|
198
|
-
}
|
|
195
|
+
return recipe != null && !!recipePropertiesByName.get(recipe.name)?.has(propName);
|
|
199
196
|
}
|
|
200
197
|
return false;
|
|
201
198
|
});
|
|
@@ -204,20 +201,7 @@ function createParser(options) {
|
|
|
204
201
|
return true;
|
|
205
202
|
if (fnName === cvaAlias || fnName === cssAlias || fnName.startsWith(jsxFactoryAlias))
|
|
206
203
|
return true;
|
|
207
|
-
return
|
|
208
|
-
});
|
|
209
|
-
const matchFnProp = memo2((fnName, propName) => {
|
|
210
|
-
if (propertiesMap.size === 0)
|
|
211
|
-
return true;
|
|
212
|
-
if (recipes.has(fnName) || patterns.has(fnName))
|
|
213
|
-
return true;
|
|
214
|
-
if (fnName === cvaAlias)
|
|
215
|
-
return true;
|
|
216
|
-
if (fnName.startsWith(jsxFactoryAlias))
|
|
217
|
-
return true;
|
|
218
|
-
if (fnName === cssAlias)
|
|
219
|
-
return Boolean(propertiesMap.get(propName) || propName === "selectors");
|
|
220
|
-
return Boolean(functions.get(fnName)?.get(propName));
|
|
204
|
+
return functions.has(fnName);
|
|
221
205
|
});
|
|
222
206
|
const measure = logger.time.debug(`Tokens extracted from ${filePath}`);
|
|
223
207
|
const extractResultByName = extract({
|
|
@@ -228,7 +212,7 @@ function createParser(options) {
|
|
|
228
212
|
},
|
|
229
213
|
functions: {
|
|
230
214
|
matchFn: (prop) => matchFn(prop.fnName),
|
|
231
|
-
matchProp: (
|
|
215
|
+
matchProp: () => true,
|
|
232
216
|
matchArg: (prop) => {
|
|
233
217
|
if (prop.fnName === jsxFactoryAlias && prop.index === 1 && Node.isIdentifier(prop.argNode))
|
|
234
218
|
return false;
|
|
@@ -305,7 +289,7 @@ function createParser(options) {
|
|
|
305
289
|
return collector;
|
|
306
290
|
};
|
|
307
291
|
}
|
|
308
|
-
var isUpperCase = (value) => value[0] === value[0]
|
|
292
|
+
var isUpperCase = (value) => value[0] === value[0]?.toUpperCase();
|
|
309
293
|
|
|
310
294
|
// src/project.ts
|
|
311
295
|
var createTsProject = (options) => new TsProject({
|
|
@@ -336,8 +320,8 @@ var createProject = ({ getFiles, readFile, parserOptions, ...projectOptions }) =
|
|
|
336
320
|
overwrite: true,
|
|
337
321
|
scriptKind: ScriptKind.TSX
|
|
338
322
|
}),
|
|
339
|
-
parseSourceFile: (filePath
|
|
340
|
-
return parser(project.getSourceFile(filePath)
|
|
323
|
+
parseSourceFile: (filePath) => {
|
|
324
|
+
return parser(project.getSourceFile(filePath));
|
|
341
325
|
}
|
|
342
326
|
})),
|
|
343
327
|
tap(({ createSourceFile }) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pandacss/parser",
|
|
3
|
-
"version": "0.0.0-dev-
|
|
3
|
+
"version": "0.0.0-dev-20230419091337",
|
|
4
4
|
"description": "The static parser for panda css",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
"lil-fp": "1.4.5",
|
|
15
15
|
"ts-morph": "18.0.0",
|
|
16
16
|
"ts-pattern": "4.2.2",
|
|
17
|
-
"@pandacss/extractor": "0.0.0-dev-
|
|
18
|
-
"@pandacss/is-valid-prop": "0.0.0-dev-
|
|
19
|
-
"@pandacss/logger": "0.0.0-dev-
|
|
20
|
-
"@pandacss/shared": "0.0.0-dev-
|
|
21
|
-
"@pandacss/types": "0.0.0-dev-
|
|
17
|
+
"@pandacss/extractor": "0.0.0-dev-20230419091337",
|
|
18
|
+
"@pandacss/is-valid-prop": "0.0.0-dev-20230419091337",
|
|
19
|
+
"@pandacss/logger": "0.0.0-dev-20230419091337",
|
|
20
|
+
"@pandacss/shared": "0.0.0-dev-20230419091337",
|
|
21
|
+
"@pandacss/types": "0.0.0-dev-20230419091337"
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@pandacss/fixture": "0.0.0-dev-
|
|
25
|
-
"@pandacss/generator": "0.0.0-dev-
|
|
24
|
+
"@pandacss/fixture": "0.0.0-dev-20230419091337",
|
|
25
|
+
"@pandacss/generator": "0.0.0-dev-20230419091337"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist"
|