@jbpark/live-editor 1.11.0 → 1.12.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.
@@ -0,0 +1,36 @@
1
+ import { compile } from "tailwindcss";
2
+ //#region src/utils/tailwind/index.ts
3
+ const extractClasses = (code) => {
4
+ const classes = /* @__PURE__ */ new Set();
5
+ const cnPattern = /cn\(([^)]*(?:\([^)]*\)[^)]*)*)\)/gs;
6
+ let cnMatch;
7
+ while ((cnMatch = cnPattern.exec(code)) !== null) {
8
+ const cnContent = cnMatch[1];
9
+ const stringPattern = /['"`]([^'"`]+)['"`]/g;
10
+ let strMatch;
11
+ while ((strMatch = stringPattern.exec(cnContent)) !== null) strMatch[1].split(/\s+/).forEach((cls) => {
12
+ if (cls.trim()) classes.add(cls.trim());
13
+ });
14
+ }
15
+ for (const pattern of [/className=["']([^"']+)["']/g, /className=\{["'`]([^"'`]+)["'`]\}/g]) {
16
+ let match;
17
+ while ((match = pattern.exec(code)) !== null) match[1].split(/\s+/).forEach((cls) => {
18
+ if (cls.trim()) classes.add(cls.trim());
19
+ });
20
+ }
21
+ const conditionalPattern = /&&\s*['"`]([^'"`]+)['"`]/g;
22
+ let condMatch;
23
+ while ((condMatch = conditionalPattern.exec(code)) !== null) condMatch[1].split(/\s+/).forEach((cls) => {
24
+ if (cls.trim()) classes.add(cls.trim());
25
+ });
26
+ return Array.from(classes);
27
+ };
28
+ const generateTailwindCSS = async (code) => {
29
+ const classes = extractClasses(code);
30
+ if (classes.length === 0) return "";
31
+ return (await compile(`@tailwind utilities;`)).build(classes);
32
+ };
33
+ //#endregion
34
+ export { generateTailwindCSS as t };
35
+
36
+ //# sourceMappingURL=tailwind-CzPhj3D9.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tailwind-CzPhj3D9.mjs","names":[],"sources":["../src/utils/tailwind/index.ts"],"sourcesContent":["import { compile } from 'tailwindcss';\n\nconst extractClasses = (code: string): string[] => {\n const classes = new Set<string>();\n\n const cnPattern = /cn\\(([^)]*(?:\\([^)]*\\)[^)]*)*)\\)/gs;\n let cnMatch;\n\n while ((cnMatch = cnPattern.exec(code)) !== null) {\n const cnContent = cnMatch[1];\n\n const stringPattern = /['\"`]([^'\"`]+)['\"`]/g;\n let strMatch;\n\n while ((strMatch = stringPattern.exec(cnContent!)) !== null) {\n strMatch[1]!.split(/\\s+/).forEach(cls => {\n if (cls.trim()) classes.add(cls.trim());\n });\n }\n }\n\n const classNamePatterns = [\n /className=[\"']([^\"']+)[\"']/g,\n /className=\\{[\"'`]([^\"'`]+)[\"'`]\\}/g,\n ];\n\n for (const pattern of classNamePatterns) {\n let match;\n while ((match = pattern.exec(code)) !== null) {\n match[1]!.split(/\\s+/).forEach(cls => {\n if (cls.trim()) classes.add(cls.trim());\n });\n }\n }\n\n const conditionalPattern = /&&\\s*['\"`]([^'\"`]+)['\"`]/g;\n let condMatch;\n\n while ((condMatch = conditionalPattern.exec(code)) !== null) {\n condMatch[1]!.split(/\\s+/).forEach(cls => {\n if (cls.trim()) classes.add(cls.trim());\n });\n }\n\n return Array.from(classes);\n};\n\nexport const generateTailwindCSS = async (code: string): Promise<string> => {\n const classes = extractClasses(code);\n\n if (classes.length === 0) {\n return '';\n }\n\n const compiler = await compile(`@tailwind utilities;`);\n const css = compiler.build(classes);\n\n return css;\n};\n"],"mappings":";;AAEA,MAAM,kBAAkB,SAA2B;CACjD,MAAM,0BAAU,IAAI,IAAY;CAEhC,MAAM,YAAY;CAClB,IAAI;CAEJ,QAAQ,UAAU,UAAU,KAAK,IAAI,OAAO,MAAM;EAChD,MAAM,YAAY,QAAQ;EAE1B,MAAM,gBAAgB;EACtB,IAAI;EAEJ,QAAQ,WAAW,cAAc,KAAK,SAAU,OAAO,MACrD,SAAS,EAAE,CAAE,MAAM,KAAK,CAAC,CAAC,SAAQ,QAAO;GACvC,IAAI,IAAI,KAAK,GAAG,QAAQ,IAAI,IAAI,KAAK,CAAC;EACxC,CAAC;CAEL;CAOA,KAAK,MAAM,WAAW,CAJpB,+BACA,oCAGoC,GAAG;EACvC,IAAI;EACJ,QAAQ,QAAQ,QAAQ,KAAK,IAAI,OAAO,MACtC,MAAM,EAAE,CAAE,MAAM,KAAK,CAAC,CAAC,SAAQ,QAAO;GACpC,IAAI,IAAI,KAAK,GAAG,QAAQ,IAAI,IAAI,KAAK,CAAC;EACxC,CAAC;CAEL;CAEA,MAAM,qBAAqB;CAC3B,IAAI;CAEJ,QAAQ,YAAY,mBAAmB,KAAK,IAAI,OAAO,MACrD,UAAU,EAAE,CAAE,MAAM,KAAK,CAAC,CAAC,SAAQ,QAAO;EACxC,IAAI,IAAI,KAAK,GAAG,QAAQ,IAAI,IAAI,KAAK,CAAC;CACxC,CAAC;CAGH,OAAO,MAAM,KAAK,OAAO;AAC3B;AAEA,MAAa,sBAAsB,OAAO,SAAkC;CAC1E,MAAM,UAAU,eAAe,IAAI;CAEnC,IAAI,QAAQ,WAAW,GACrB,OAAO;CAMT,QAFY,MADW,QAAQ,sBAAsB,EAAA,CAChC,MAAM,OAElB;AACX"}
@@ -1,5 +1,4 @@
1
- import { a as generateDocumentCode, c as getSections, d as ArrayExpression, f as Expression, h as ObjectExpression, i as createSectionPreviewCache, l as parseDocument, m as Node, n as SectionPreviewCache, o as generateSectionPreview, p as File, r as clearDocumentParseCache, s as generateSectionPreviews, t as DocumentTree, u as replaceDocumentSections } from "../../document-DqLm4Vqi.mjs";
2
-
1
+ import { a as generateDocumentCode, c as getSections, d as ArrayExpression, f as Expression, h as ObjectExpression, i as createSectionPreviewCache, l as parseDocument, m as Node, n as SectionPreviewCache, o as generateSectionPreview, p as File, r as clearDocumentParseCache, s as generateSectionPreviews, t as DocumentTree, u as replaceDocumentSections } from "../../document-BVWq-dmf.mjs";
3
2
  //#region src/utils/ast/types.d.ts
4
3
  interface Attribute {
5
4
  name: string;
@@ -64,14 +63,14 @@ declare const parseBinding: (bindingValue: string | null) => BindingItem[];
64
63
  declare const getCurrentValue: (node: DataAttrNode, property: string) => string;
65
64
  declare const findEditableChildren: (node: DataAttrNode) => DataAttrNode[];
66
65
  //#endregion
67
- //#region node_modules/.pnpm/@babel+parser@7.28.6/node_modules/@babel/parser/typings/babel-parser.d.ts
66
+ //#region node_modules/.pnpm/@babel+parser@7.29.8/node_modules/@babel/parser/typings/babel-parser.d.ts
68
67
  declare class Position {
69
68
  line: number;
70
69
  column: number;
71
70
  index: number;
72
71
  constructor(line: number, col: number, index: number);
73
72
  }
74
- type SyntaxPlugin = "flow" | "typescript" | "jsx" | "pipelineOperator" | "placeholders";
73
+ type SyntaxPlugin = "flow" | "typescript" | "jsx" | "functionBind" | "pipelineOperator" | "placeholders";
75
74
  type ParseErrorCode = "BABEL_PARSER_SYNTAX_ERROR" | "BABEL_PARSER_SOURCETYPE_MODULE_REQUIRED";
76
75
  interface ParseErrorSpecification<ErrorDetails> {
77
76
  code: ParseErrorCode;
@@ -89,9 +88,6 @@ type ParseResult<Result extends File | Expression = File> = Result & {
89
88
  errors: null | ParseError[];
90
89
  tokens?: File["tokens"];
91
90
  };
92
- /**
93
- * Parse the provided code as an entire ECMAScript program.
94
- */
95
91
  //#endregion
96
92
  //#region src/utils/ast/value.d.ts
97
93
  declare const parseValue: (value: unknown) => unknown;
@@ -1,4 +1,3 @@
1
- import { a as generateSectionPreviews, c as replaceDocumentSections, i as generateSectionPreview, n as createSectionPreviewCache, o as getSections, r as generateDocumentCode, s as parseDocument, t as clearDocumentParseCache } from "../../document-CBw2uF_P.mjs";
2
- import { _ as parseArrayExpression, a as bulkUpdate, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, s as clearExtractCache, t as validateBindingValue, u as findEditableChildren, v as parseValue, y as generateCode } from "../../ast-C0FNDLFQ.mjs";
3
-
4
- export { arrayExpressionToCode, bulkUpdate, clearDocumentParseCache, clearExtractCache, clone, createNodeFromValue, createSectionPreviewCache, extract, extractNodeValue, extractObjectProperties, fillIds, findEditableChildren, generateCode, generateDocumentCode, generateSectionPreview, generateSectionPreviews, getCurrentValue, getSections, parseArrayExpression, parseBinding, parseDocument, parseValue, replaceDocumentSections, replaceIds, update, validateBindingValue };
1
+ import { a as generateSectionPreviews, c as replaceDocumentSections, i as generateSectionPreview, n as createSectionPreviewCache, o as getSections, r as generateDocumentCode, s as parseDocument, t as clearDocumentParseCache } from "../../document-DocoSXLT.mjs";
2
+ import { _ as parseArrayExpression, a as bulkUpdate, c as extract, d as getCurrentValue, f as parseBinding, g as extractObjectProperties, h as extractNodeValue, i as replaceIds, m as createNodeFromValue, n as clone, o as update, p as arrayExpressionToCode, r as fillIds, s as clearExtractCache, t as validateBindingValue, u as findEditableChildren, v as parseValue, y as generateCode } from "../../ast-9E8pNi7j.mjs";
3
+ export { arrayExpressionToCode, bulkUpdate, clearDocumentParseCache, clearExtractCache, clone, createNodeFromValue, createSectionPreviewCache, extract, extractNodeValue, extractObjectProperties, fillIds, findEditableChildren, generateCode, generateDocumentCode, generateSectionPreview, generateSectionPreviews, getCurrentValue, getSections, parseArrayExpression, parseBinding, parseDocument, parseValue, replaceDocumentSections, replaceIds, update, validateBindingValue };
@@ -1,8 +1,7 @@
1
- import { n as Section, t as Module } from "../index-DdSjzvA3.mjs";
2
- import { i as createSectionPreviewCache, n as SectionPreviewCache } from "../document-DqLm4Vqi.mjs";
1
+ import { n as Section, t as Module } from "../index-C8h8TcIl.mjs";
2
+ import { i as createSectionPreviewCache, n as SectionPreviewCache } from "../document-BVWq-dmf.mjs";
3
3
  import * as ui from "@jbpark/ui-kit";
4
4
  import * as utils from "@jbpark/ui-kit/utils";
5
-
6
5
  //#region node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/clsx.d.mts
7
6
  type ClassValue = ClassArray | ClassDictionary | string | number | bigint | null | boolean | undefined;
8
7
  type ClassDictionary = Record<string, any>;
@@ -1,4 +1,3 @@
1
- import { n as createSectionPreviewCache } from "../document-CBw2uF_P.mjs";
2
- import { a as detectTypeScript, c as generateSections, d as replaceSections, f as transformCode, i as compile, l as getCachedScriptBlob, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as preloadScripts } from "../utils-BjYg1Sh8.mjs";
3
-
4
- export { baseModules, clearCompilationCache, cn, compile, createSectionPreviewCache, detectTypeScript, extractSections, generateSection, generateSections, getCachedScriptBlob, preloadScripts, replaceSections, transformCode };
1
+ import { n as createSectionPreviewCache } from "../document-DocoSXLT.mjs";
2
+ import { a as detectTypeScript, c as generateSections, d as replaceSections, f as transformCode, i as compile, l as getCachedScriptBlob, n as clearCompilationCache, o as extractSections, r as cn, s as generateSection, t as baseModules, u as preloadScripts } from "../utils-DP9WPbBJ.mjs";
3
+ export { baseModules, clearCompilationCache, cn, compile, createSectionPreviewCache, detectTypeScript, extractSections, generateSection, generateSections, getCachedScriptBlob, preloadScripts, replaceSections, transformCode };
@@ -1,37 +1,2 @@
1
- import { compile } from "tailwindcss";
2
-
3
- //#region src/utils/tailwind/index.ts
4
- const extractClasses = (code) => {
5
- const classes = /* @__PURE__ */ new Set();
6
- const cnPattern = /cn\(([^)]*(?:\([^)]*\)[^)]*)*)\)/gs;
7
- let cnMatch;
8
- while ((cnMatch = cnPattern.exec(code)) !== null) {
9
- const cnContent = cnMatch[1];
10
- const stringPattern = /['"`]([^'"`]+)['"`]/g;
11
- let strMatch;
12
- while ((strMatch = stringPattern.exec(cnContent)) !== null) strMatch[1].split(/\s+/).forEach((cls) => {
13
- if (cls.trim()) classes.add(cls.trim());
14
- });
15
- }
16
- for (const pattern of [/className=["']([^"']+)["']/g, /className=\{["'`]([^"'`]+)["'`]\}/g]) {
17
- let match;
18
- while ((match = pattern.exec(code)) !== null) match[1].split(/\s+/).forEach((cls) => {
19
- if (cls.trim()) classes.add(cls.trim());
20
- });
21
- }
22
- const conditionalPattern = /&&\s*['"`]([^'"`]+)['"`]/g;
23
- let condMatch;
24
- while ((condMatch = conditionalPattern.exec(code)) !== null) condMatch[1].split(/\s+/).forEach((cls) => {
25
- if (cls.trim()) classes.add(cls.trim());
26
- });
27
- return Array.from(classes);
28
- };
29
- const generateTailwindCSS = async (code) => {
30
- const classes = extractClasses(code);
31
- if (classes.length === 0) return "";
32
- return (await compile(`@tailwind utilities;`)).build(classes);
33
- };
34
-
35
- //#endregion
1
+ import { t as generateTailwindCSS } from "../../tailwind-CzPhj3D9.mjs";
36
2
  export { generateTailwindCSS };
37
- //# sourceMappingURL=index.mjs.map