@pandacss/parser 0.0.0-dev-20230626085107 → 0.0.0-dev-20230626124525

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.js CHANGED
@@ -206,7 +206,7 @@ function createParser(options) {
206
206
  if (jsx) {
207
207
  importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.name)]));
208
208
  }
209
- return function parse3(sourceFile) {
209
+ return function parse2(sourceFile) {
210
210
  if (!sourceFile)
211
211
  return;
212
212
  const filePath = sourceFile.getFilePath();
@@ -497,23 +497,24 @@ const render = ${fileStr.snip(templateStart, templateEnd).toString()}`
497
497
  };
498
498
 
499
499
  // src/svelte-to-tsx.ts
500
- var svelte = __toESM(require("svelte/compiler"));
501
500
  var import_magic_string2 = __toESM(require("magic-string"));
501
+ var regex_style_tags = /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
502
+ var regex_script_tags = /<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
502
503
  var svelteToTsx = (code) => {
503
504
  try {
504
- const parsed = svelte.parse(code);
505
- const fileStr = new import_magic_string2.default(code);
506
- if (parsed.instance && parsed.instance.content) {
507
- const content = parsed.instance.content;
508
- fileStr.update(parsed.instance.start, parsed.instance.end, code.slice(content.start, content.end));
505
+ const scripts = [];
506
+ const original = new import_magic_string2.default(code);
507
+ let match2;
508
+ while ((match2 = regex_script_tags.exec(code)) != null) {
509
+ const [fullMatch, _attributesStr, scriptContent] = match2;
510
+ if (scriptContent) {
511
+ scripts.push(scriptContent);
512
+ original.remove(match2.index, match2.index + fullMatch.length);
513
+ }
509
514
  }
510
- const moduleContext = parsed.module ? fileStr.snip(parsed.module.start, parsed.module.end) : "";
511
- const scriptContent = parsed.instance ? fileStr.snip(parsed.instance.start, parsed.instance.end) : "";
512
- const templateContent = parsed.html.children?.map((child) => fileStr.snip(child.start, child.end)).join("").trimStart() ?? "";
513
- const transformed = new import_magic_string2.default(
514
- `${moduleContext + "\n"}${scriptContent + "\n"}
515
- const render = <div>${templateContent}</div>`
516
- );
515
+ const templateContent = original.toString().trimStart().replace(regex_style_tags, "").replace(regex_style_tags, "");
516
+ const transformed = `${scripts.join("")}
517
+ const render = <div>${templateContent}</div>`;
517
518
  return transformed.toString().trim();
518
519
  } catch (err) {
519
520
  return "";
package/dist/index.mjs CHANGED
@@ -168,7 +168,7 @@ function createParser(options) {
168
168
  if (jsx) {
169
169
  importRegex.push(createImportMatcher(importMap.jsx, [jsx.factory, ...jsx.nodes.map((node) => node.name)]));
170
170
  }
171
- return function parse3(sourceFile) {
171
+ return function parse2(sourceFile) {
172
172
  if (!sourceFile)
173
173
  return;
174
174
  const filePath = sourceFile.getFilePath();
@@ -459,23 +459,24 @@ const render = ${fileStr.snip(templateStart, templateEnd).toString()}`
459
459
  };
460
460
 
461
461
  // src/svelte-to-tsx.ts
462
- import * as svelte from "svelte/compiler";
463
462
  import MagicString2 from "magic-string";
463
+ var regex_style_tags = /<!--[^]*?-->|<style(\s[^]*?)?(?:>([^]*?)<\/style>|\/>)/gi;
464
+ var regex_script_tags = /<!--[^]*?-->|<script(\s[^]*?)?(?:>([^]*?)<\/script>|\/>)/gi;
464
465
  var svelteToTsx = (code) => {
465
466
  try {
466
- const parsed = svelte.parse(code);
467
- const fileStr = new MagicString2(code);
468
- if (parsed.instance && parsed.instance.content) {
469
- const content = parsed.instance.content;
470
- fileStr.update(parsed.instance.start, parsed.instance.end, code.slice(content.start, content.end));
467
+ const scripts = [];
468
+ const original = new MagicString2(code);
469
+ let match2;
470
+ while ((match2 = regex_script_tags.exec(code)) != null) {
471
+ const [fullMatch, _attributesStr, scriptContent] = match2;
472
+ if (scriptContent) {
473
+ scripts.push(scriptContent);
474
+ original.remove(match2.index, match2.index + fullMatch.length);
475
+ }
471
476
  }
472
- const moduleContext = parsed.module ? fileStr.snip(parsed.module.start, parsed.module.end) : "";
473
- const scriptContent = parsed.instance ? fileStr.snip(parsed.instance.start, parsed.instance.end) : "";
474
- const templateContent = parsed.html.children?.map((child) => fileStr.snip(child.start, child.end)).join("").trimStart() ?? "";
475
- const transformed = new MagicString2(
476
- `${moduleContext + "\n"}${scriptContent + "\n"}
477
- const render = <div>${templateContent}</div>`
478
- );
477
+ const templateContent = original.toString().trimStart().replace(regex_style_tags, "").replace(regex_style_tags, "");
478
+ const transformed = `${scripts.join("")}
479
+ const render = <div>${templateContent}</div>`;
479
480
  return transformed.toString().trim();
480
481
  } catch (err) {
481
482
  return "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pandacss/parser",
3
- "version": "0.0.0-dev-20230626085107",
3
+ "version": "0.0.0-dev-20230626124525",
4
4
  "description": "The static parser for panda css",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -14,19 +14,18 @@
14
14
  "@vue/compiler-sfc": "^3.3.4",
15
15
  "lil-fp": "1.4.5",
16
16
  "magic-string": "^0.30.0",
17
- "svelte": "^4.0.0",
18
17
  "ts-morph": "18.0.0",
19
18
  "ts-pattern": "4.3.0",
20
- "@pandacss/extractor": "0.0.0-dev-20230626085107",
21
- "@pandacss/is-valid-prop": "0.0.0-dev-20230626085107",
22
- "@pandacss/logger": "0.0.0-dev-20230626085107",
23
- "@pandacss/shared": "0.0.0-dev-20230626085107",
24
- "@pandacss/types": "0.0.0-dev-20230626085107"
19
+ "@pandacss/extractor": "0.0.0-dev-20230626124525",
20
+ "@pandacss/is-valid-prop": "0.0.0-dev-20230626124525",
21
+ "@pandacss/logger": "0.0.0-dev-20230626124525",
22
+ "@pandacss/shared": "0.0.0-dev-20230626124525",
23
+ "@pandacss/types": "0.0.0-dev-20230626124525"
25
24
  },
26
25
  "devDependencies": {
27
26
  "hookable": "5.5.3",
28
- "@pandacss/fixture": "0.0.0-dev-20230626085107",
29
- "@pandacss/generator": "0.0.0-dev-20230626085107"
27
+ "@pandacss/fixture": "0.0.0-dev-20230626124525",
28
+ "@pandacss/generator": "0.0.0-dev-20230626124525"
30
29
  },
31
30
  "files": [
32
31
  "dist"