@pandacss/parser 1.9.1 → 1.11.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.d.mts CHANGED
@@ -73,7 +73,7 @@ declare class Project {
73
73
  get getFiles(): () => string[];
74
74
  parseJson: (filePath: string) => ParserResult;
75
75
  parseSourceFile: (filePath: string, encoder?: ParserOptions["encoder"]) => ParserResult | undefined;
76
- transformFile: (filePath: string, content: string) => string;
76
+ transformFile: (_filePath: string, content: string) => string;
77
77
  classify: (fileMap: Map<string, ParserResultInterface>) => _pandacss_types.ClassifyReport;
78
78
  }
79
79
 
package/dist/index.d.ts CHANGED
@@ -73,7 +73,7 @@ declare class Project {
73
73
  get getFiles(): () => string[];
74
74
  parseJson: (filePath: string) => ParserResult;
75
75
  parseSourceFile: (filePath: string, encoder?: ParserOptions["encoder"]) => ParserResult | undefined;
76
- transformFile: (filePath: string, content: string) => string;
76
+ transformFile: (_filePath: string, content: string) => string;
77
77
  classify: (fileMap: Map<string, ParserResultInterface>) => _pandacss_types.ClassifyReport;
78
78
  }
79
79
 
package/dist/index.js CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // src/index.ts
@@ -277,7 +267,7 @@ function classifyProject(ctx, resultMap) {
277
267
  componentReportItem
278
268
  });
279
269
  };
280
- const isSlotRecipe = (v) => ctx.recipes.isSlotRecipe(key);
270
+ const isSlotRecipe = (_v) => ctx.recipes.isSlotRecipe(key);
281
271
  if (isSlotRecipe(recipe)) {
282
272
  Object.values(recipe.base ?? {}).forEach(functionFn);
283
273
  Object.values(recipe.variants ?? {}).forEach((variants) => {
@@ -640,7 +630,7 @@ var evaluateOptions = {
640
630
  function createParser(context) {
641
631
  const { jsx, imports, recipes, config } = context;
642
632
  const syntax = config.syntax;
643
- return function parse2(sourceFile, encoder, options) {
633
+ return function parse(sourceFile, encoder, options) {
644
634
  if (!sourceFile) return;
645
635
  const importDeclarations = getImportDeclarations(context, sourceFile);
646
636
  const file = imports.file(importDeclarations);
@@ -866,91 +856,12 @@ function createParser(context) {
866
856
  };
867
857
  }
868
858
 
869
- // src/svelte-to-tsx.ts
870
- var import_magic_string = __toESM(require("magic-string"));
871
- var regex_style_tags = /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
872
- var regex_script_tags = /<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
873
- var svelteToTsx = (code) => {
874
- try {
875
- const scripts = [];
876
- const original = new import_magic_string.default(code);
877
- let match2;
878
- while ((match2 = regex_script_tags.exec(code)) != null) {
879
- const [fullMatch, _attributesStr, scriptContent] = match2;
880
- if (scriptContent) {
881
- scripts.push(scriptContent);
882
- original.remove(match2.index, match2.index + fullMatch.length);
883
- }
884
- }
885
- const templateContent = original.toString().trimStart().replace(regex_style_tags, "").replace(regex_style_tags, "");
886
- const transformed = `${scripts.join("")}
887
- const render = <div>${templateContent}</div>`;
888
- return transformed.toString().trim();
889
- } catch {
890
- return "";
891
- }
892
- };
893
-
894
- // src/vue-to-tsx.ts
895
- var import_compiler_sfc = require("@vue/compiler-sfc");
896
- var import_magic_string2 = __toESM(require("magic-string"));
897
- var NodeTypes = {
898
- ROOT: 0,
899
- ELEMENT: 1,
900
- TEXT: 2,
901
- COMMENT: 3,
902
- SIMPLE_EXPRESSION: 4,
903
- INTERPOLATION: 5,
904
- ATTRIBUTE: 6,
905
- DIRECTIVE: 7,
906
- COMPOUND_EXPRESSION: 8,
907
- IF: 9,
908
- IF_BRANCH: 10,
909
- FOR: 11,
910
- TEXT_CALL: 12,
911
- VNODE_CALL: 13,
912
- JS_CALL_EXPRESSION: 14,
913
- JS_OBJECT_EXPRESSION: 15,
914
- JS_PROPERTY: 16,
915
- JS_ARRAY_EXPRESSION: 17,
916
- JS_FUNCTION_EXPRESSION: 18,
917
- JS_CONDITIONAL_EXPRESSION: 19,
918
- JS_CACHE_EXPRESSION: 20,
919
- JS_BLOCK_STATEMENT: 21,
920
- JS_TEMPLATE_LITERAL: 22,
921
- JS_IF_STATEMENT: 23,
922
- JS_ASSIGNMENT_EXPRESSION: 24,
923
- JS_SEQUENCE_EXPRESSION: 25,
924
- JS_RETURN_STATEMENT: 26
925
- };
926
- var vueToTsx = (code) => {
927
- try {
928
- const parsed = (0, import_compiler_sfc.parse)(code);
929
- const fileStr = new import_magic_string2.default(`<template>${parsed.descriptor.template?.content}</template>`);
930
- const rewriteProp = (prop) => {
931
- if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
932
- fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
933
- }
934
- };
935
- const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
936
- while (stack.length) {
937
- const node = stack.pop();
938
- if (!node) continue;
939
- if (node.type === NodeTypes.ELEMENT) {
940
- node.props.forEach(rewriteProp);
941
- node.children.forEach((child) => stack.push(child));
942
- }
943
- }
944
- const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
945
- const transformed = new import_magic_string2.default(`${scriptContent}
946
- const render = ${fileStr.toString()}`);
947
- return transformed.toString();
948
- } catch {
949
- return "";
950
- }
951
- };
952
-
953
859
  // src/project.ts
860
+ var normalizeCompilerOptions = (raw) => {
861
+ if (!raw) return {};
862
+ const { options } = import_ts_morph2.ts.convertCompilerOptionsFromJson(raw, process.cwd());
863
+ return options;
864
+ };
954
865
  var createTsProject = (options) => new import_ts_morph2.Project({
955
866
  skipAddingFilesFromTsConfig: true,
956
867
  skipFileDependencyResolution: true,
@@ -960,7 +871,7 @@ var createTsProject = (options) => new import_ts_morph2.Project({
960
871
  allowJs: true,
961
872
  strictNullChecks: false,
962
873
  skipLibCheck: true,
963
- ...options.compilerOptions
874
+ ...normalizeCompilerOptions(options.compilerOptions)
964
875
  }
965
876
  });
966
877
  var Project = class {
@@ -1064,13 +975,7 @@ var Project = class {
1064
975
  hooks["parser:after"]?.({ filePath, result });
1065
976
  return result;
1066
977
  };
1067
- transformFile = (filePath, content) => {
1068
- if (filePath.endsWith(".vue")) {
1069
- return vueToTsx(content);
1070
- }
1071
- if (filePath.endsWith(".svelte")) {
1072
- return svelteToTsx(content);
1073
- }
978
+ transformFile = (_filePath, content) => {
1074
979
  return content;
1075
980
  };
1076
981
  classify = (fileMap) => {
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  // src/project.ts
2
2
  import {
3
3
  ScriptKind,
4
- Project as TsProject
4
+ Project as TsProject,
5
+ ts
5
6
  } from "ts-morph";
6
7
 
7
8
  // src/classify.ts
@@ -243,7 +244,7 @@ function classifyProject(ctx, resultMap) {
243
244
  componentReportItem
244
245
  });
245
246
  };
246
- const isSlotRecipe = (v) => ctx.recipes.isSlotRecipe(key);
247
+ const isSlotRecipe = (_v) => ctx.recipes.isSlotRecipe(key);
247
248
  if (isSlotRecipe(recipe)) {
248
249
  Object.values(recipe.base ?? {}).forEach(functionFn);
249
250
  Object.values(recipe.variants ?? {}).forEach((variants) => {
@@ -606,7 +607,7 @@ var evaluateOptions = {
606
607
  function createParser(context) {
607
608
  const { jsx, imports, recipes, config } = context;
608
609
  const syntax = config.syntax;
609
- return function parse2(sourceFile, encoder, options) {
610
+ return function parse(sourceFile, encoder, options) {
610
611
  if (!sourceFile) return;
611
612
  const importDeclarations = getImportDeclarations(context, sourceFile);
612
613
  const file = imports.file(importDeclarations);
@@ -832,91 +833,12 @@ function createParser(context) {
832
833
  };
833
834
  }
834
835
 
835
- // src/svelte-to-tsx.ts
836
- import MagicString from "magic-string";
837
- var regex_style_tags = /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
838
- var regex_script_tags = /<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
839
- var svelteToTsx = (code) => {
840
- try {
841
- const scripts = [];
842
- const original = new MagicString(code);
843
- let match2;
844
- while ((match2 = regex_script_tags.exec(code)) != null) {
845
- const [fullMatch, _attributesStr, scriptContent] = match2;
846
- if (scriptContent) {
847
- scripts.push(scriptContent);
848
- original.remove(match2.index, match2.index + fullMatch.length);
849
- }
850
- }
851
- const templateContent = original.toString().trimStart().replace(regex_style_tags, "").replace(regex_style_tags, "");
852
- const transformed = `${scripts.join("")}
853
- const render = <div>${templateContent}</div>`;
854
- return transformed.toString().trim();
855
- } catch {
856
- return "";
857
- }
858
- };
859
-
860
- // src/vue-to-tsx.ts
861
- import { parse } from "@vue/compiler-sfc";
862
- import MagicString2 from "magic-string";
863
- var NodeTypes = {
864
- ROOT: 0,
865
- ELEMENT: 1,
866
- TEXT: 2,
867
- COMMENT: 3,
868
- SIMPLE_EXPRESSION: 4,
869
- INTERPOLATION: 5,
870
- ATTRIBUTE: 6,
871
- DIRECTIVE: 7,
872
- COMPOUND_EXPRESSION: 8,
873
- IF: 9,
874
- IF_BRANCH: 10,
875
- FOR: 11,
876
- TEXT_CALL: 12,
877
- VNODE_CALL: 13,
878
- JS_CALL_EXPRESSION: 14,
879
- JS_OBJECT_EXPRESSION: 15,
880
- JS_PROPERTY: 16,
881
- JS_ARRAY_EXPRESSION: 17,
882
- JS_FUNCTION_EXPRESSION: 18,
883
- JS_CONDITIONAL_EXPRESSION: 19,
884
- JS_CACHE_EXPRESSION: 20,
885
- JS_BLOCK_STATEMENT: 21,
886
- JS_TEMPLATE_LITERAL: 22,
887
- JS_IF_STATEMENT: 23,
888
- JS_ASSIGNMENT_EXPRESSION: 24,
889
- JS_SEQUENCE_EXPRESSION: 25,
890
- JS_RETURN_STATEMENT: 26
891
- };
892
- var vueToTsx = (code) => {
893
- try {
894
- const parsed = parse(code);
895
- const fileStr = new MagicString2(`<template>${parsed.descriptor.template?.content}</template>`);
896
- const rewriteProp = (prop) => {
897
- if (prop.type === NodeTypes.DIRECTIVE && prop.exp?.type === NodeTypes.SIMPLE_EXPRESSION && prop.arg?.type === NodeTypes.SIMPLE_EXPRESSION) {
898
- fileStr.replace(prop.loc.source, `${prop.arg.content}={${prop.exp.content}}`);
899
- }
900
- };
901
- const stack = Array.from(parsed.descriptor.template?.ast?.children ?? []);
902
- while (stack.length) {
903
- const node = stack.pop();
904
- if (!node) continue;
905
- if (node.type === NodeTypes.ELEMENT) {
906
- node.props.forEach(rewriteProp);
907
- node.children.forEach((child) => stack.push(child));
908
- }
909
- }
910
- const scriptContent = (parsed.descriptor.scriptSetup ?? parsed.descriptor.script)?.content + "\n";
911
- const transformed = new MagicString2(`${scriptContent}
912
- const render = ${fileStr.toString()}`);
913
- return transformed.toString();
914
- } catch {
915
- return "";
916
- }
917
- };
918
-
919
836
  // src/project.ts
837
+ var normalizeCompilerOptions = (raw) => {
838
+ if (!raw) return {};
839
+ const { options } = ts.convertCompilerOptionsFromJson(raw, process.cwd());
840
+ return options;
841
+ };
920
842
  var createTsProject = (options) => new TsProject({
921
843
  skipAddingFilesFromTsConfig: true,
922
844
  skipFileDependencyResolution: true,
@@ -926,7 +848,7 @@ var createTsProject = (options) => new TsProject({
926
848
  allowJs: true,
927
849
  strictNullChecks: false,
928
850
  skipLibCheck: true,
929
- ...options.compilerOptions
851
+ ...normalizeCompilerOptions(options.compilerOptions)
930
852
  }
931
853
  });
932
854
  var Project = class {
@@ -1030,13 +952,7 @@ var Project = class {
1030
952
  hooks["parser:after"]?.({ filePath, result });
1031
953
  return result;
1032
954
  };
1033
- transformFile = (filePath, content) => {
1034
- if (filePath.endsWith(".vue")) {
1035
- return vueToTsx(content);
1036
- }
1037
- if (filePath.endsWith(".svelte")) {
1038
- return svelteToTsx(content);
1039
- }
955
+ transformFile = (_filePath, content) => {
1040
956
  return content;
1041
957
  };
1042
958
  classify = (fileMap) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "1.9.1",
3
+ "version": "1.11.0",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -29,20 +29,19 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@vue/compiler-sfc": "3.5.25",
33
- "magic-string": "0.30.21",
34
- "ts-morph": "27.0.2",
32
+ "ts-morph": "28.0.0",
35
33
  "ts-pattern": "5.9.0",
36
- "@pandacss/config": "^1.9.1",
37
- "@pandacss/core": "^1.9.1",
38
- "@pandacss/extractor": "1.9.1",
39
- "@pandacss/logger": "1.9.1",
40
- "@pandacss/shared": "1.9.1",
41
- "@pandacss/types": "1.9.1"
34
+ "@pandacss/config": "^1.11.0",
35
+ "@pandacss/core": "^1.11.0",
36
+ "@pandacss/extractor": "1.11.0",
37
+ "@pandacss/logger": "1.11.0",
38
+ "@pandacss/shared": "1.11.0",
39
+ "@pandacss/types": "1.11.0"
42
40
  },
43
41
  "devDependencies": {
44
- "@vue/compiler-core": "3.5.25",
45
- "@pandacss/generator": "1.9.1"
42
+ "@pandacss/generator": "1.11.0",
43
+ "@pandacss/plugin-svelte": "1.11.0",
44
+ "@pandacss/plugin-vue": "1.11.0"
46
45
  },
47
46
  "files": [
48
47
  "dist"