@ikas/component-cli 0.15.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.
Files changed (55) hide show
  1. package/bin/create-ikas-component.js +8 -0
  2. package/bin/ikas-component.js +8 -0
  3. package/dist/commands/add.d.ts +3 -0
  4. package/dist/commands/add.d.ts.map +1 -0
  5. package/dist/commands/add.js +156 -0
  6. package/dist/commands/add.js.map +1 -0
  7. package/dist/commands/build.d.ts +3 -0
  8. package/dist/commands/build.d.ts.map +1 -0
  9. package/dist/commands/build.js +273 -0
  10. package/dist/commands/build.js.map +1 -0
  11. package/dist/commands/create.d.ts +4 -0
  12. package/dist/commands/create.d.ts.map +1 -0
  13. package/dist/commands/create.js +572 -0
  14. package/dist/commands/create.js.map +1 -0
  15. package/dist/commands/dev.d.ts +3 -0
  16. package/dist/commands/dev.d.ts.map +1 -0
  17. package/dist/commands/dev.js +381 -0
  18. package/dist/commands/dev.js.map +1 -0
  19. package/dist/commands/publish.d.ts +3 -0
  20. package/dist/commands/publish.d.ts.map +1 -0
  21. package/dist/commands/publish.js +136 -0
  22. package/dist/commands/publish.js.map +1 -0
  23. package/dist/index.d.ts +3 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +20 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/types.d.ts +76 -0
  28. package/dist/types.d.ts.map +1 -0
  29. package/dist/types.js +2 -0
  30. package/dist/types.js.map +1 -0
  31. package/dist/utils/compile.d.ts +25 -0
  32. package/dist/utils/compile.d.ts.map +1 -0
  33. package/dist/utils/compile.js +420 -0
  34. package/dist/utils/compile.js.map +1 -0
  35. package/dist/utils/component-helpers.d.ts +23 -0
  36. package/dist/utils/component-helpers.d.ts.map +1 -0
  37. package/dist/utils/component-helpers.js +177 -0
  38. package/dist/utils/component-helpers.js.map +1 -0
  39. package/dist/utils/css-import-resolver.d.ts +10 -0
  40. package/dist/utils/css-import-resolver.d.ts.map +1 -0
  41. package/dist/utils/css-import-resolver.js +40 -0
  42. package/dist/utils/css-import-resolver.js.map +1 -0
  43. package/dist/utils/esm-transform.d.ts +29 -0
  44. package/dist/utils/esm-transform.d.ts.map +1 -0
  45. package/dist/utils/esm-transform.js +216 -0
  46. package/dist/utils/esm-transform.js.map +1 -0
  47. package/dist/utils/observer-runtime.d.ts +3 -0
  48. package/dist/utils/observer-runtime.d.ts.map +1 -0
  49. package/dist/utils/observer-runtime.js +52 -0
  50. package/dist/utils/observer-runtime.js.map +1 -0
  51. package/dist/utils/websocket-server.d.ts +180 -0
  52. package/dist/utils/websocket-server.d.ts.map +1 -0
  53. package/dist/utils/websocket-server.js +287 -0
  54. package/dist/utils/websocket-server.js.map +1 -0
  55. package/package.json +43 -0
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Prop types available for code components
3
+ * These map to the PropType enum in @ikas/editor-models
4
+ */
5
+ export type PropType = "TEXT" | "RICH_TEXT" | "NUMBER" | "BOOLEAN" | "IMAGE" | "LINK" | "LIST_OF_LINK" | "COLOR" | "ENUM" | "PRODUCT" | "PRODUCT_LIST" | "CATEGORY" | "CATEGORY_LIST" | "BRAND" | "BRAND_LIST" | "BLOG" | "BLOG_LIST" | "BLOG_CATEGORY" | "BLOG_CATEGORY_LIST";
6
+ /**
7
+ * Configuration for a code component project (ikas.config.json)
8
+ */
9
+ export interface IkasComponentConfig {
10
+ name: string;
11
+ version: string;
12
+ /** 8-char random alphanumeric ID that namespaces all component/chunk IDs in this project */
13
+ projectId?: string;
14
+ components: ComponentDefinition[];
15
+ }
16
+ /**
17
+ * Definition of a single component in the project
18
+ */
19
+ export interface ComponentDefinition {
20
+ id: string;
21
+ name: string;
22
+ entry: string;
23
+ styles: string;
24
+ props: ComponentProp[];
25
+ /** Component type - 'component' (child of section) or 'section' (page-level section) */
26
+ type?: "component" | "section";
27
+ }
28
+ /**
29
+ * Prop definition for a component
30
+ */
31
+ export interface ComponentProp {
32
+ name: string;
33
+ displayName: string;
34
+ type: PropType;
35
+ required: boolean;
36
+ defaultValue?: unknown;
37
+ description?: string;
38
+ }
39
+ /**
40
+ * Result of component compilation
41
+ */
42
+ export interface CompilationResult {
43
+ success: boolean;
44
+ serverJs: string;
45
+ clientJs: string;
46
+ scopedCss: string;
47
+ error?: string;
48
+ }
49
+ /**
50
+ * Result of multi-entry compilation with code splitting
51
+ */
52
+ export interface MultiCompilationResult {
53
+ success: boolean;
54
+ entries: Map<string, {
55
+ serverJs: string;
56
+ clientJs: string;
57
+ }>;
58
+ chunks: Map<string, {
59
+ serverJs: string;
60
+ clientJs: string;
61
+ }>;
62
+ css: Map<string, string>;
63
+ chunkCss: Map<string, string>;
64
+ error?: string;
65
+ }
66
+ /**
67
+ * Shared module data (a chunk extracted by esbuild code splitting)
68
+ */
69
+ export interface SharedModuleData {
70
+ id: string;
71
+ compiledServerJs: string;
72
+ compiledClientJs: string;
73
+ canvasClientJs: string;
74
+ compiledCss: string;
75
+ }
76
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,WAAW,GACX,QAAQ,GACR,SAAS,GACT,OAAO,GACP,MAAM,GACN,cAAc,GACd,OAAO,GACP,MAAM,GACN,SAAS,GACT,cAAc,GACd,UAAU,GACV,eAAe,GACf,OAAO,GACP,YAAY,GACZ,MAAM,GACN,WAAW,GACX,eAAe,GACf,oBAAoB,CAAC;AAEzB;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,4FAA4F;IAC5F,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,mBAAmB,EAAE,CAAC;CACnC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CA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MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;CACrB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,25 @@
1
+ import type { CompilationResult, MultiCompilationResult } from "../types.js";
2
+ /**
3
+ * Compile a single component's TSX and CSS
4
+ */
5
+ export declare function compileComponent(entryPath: string, stylesPath: string, componentId: string): Promise<CompilationResult>;
6
+ /**
7
+ * Scope CSS selectors with a component-specific class prefix
8
+ */
9
+ export declare function scopeCSS(css: string, componentId: string): string;
10
+ /**
11
+ * Scope CSS selectors with multiple class prefixes (for shared chunks).
12
+ * Each selector becomes: .cc_id1 .sel, .cc_id2 .sel { ... }
13
+ */
14
+ export declare function scopeCSSMulti(css: string, componentIds: string[]): string;
15
+ /**
16
+ * Compile all components together with esbuild code splitting.
17
+ * Shared code is automatically extracted into chunk files.
18
+ * When there's no shared code, output is identical to per-component compilation.
19
+ */
20
+ export declare function compileAllComponents(components: {
21
+ id: string;
22
+ entryPath: string;
23
+ stylesPath: string;
24
+ }[]): Promise<MultiCompilationResult>;
25
+ //# sourceMappingURL=compile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.d.ts","sourceRoot":"","sources":["../../src/utils/compile.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAuB,iBAAiB,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AA2BlG;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,iBAAiB,CAAC,CAkF5B;AAED;;GAEG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAGjE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,GAAG,MAAM,CAGzE;AAuFD;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,UAAU,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,EAAE,GAClE,OAAO,CAAC,sBAAsB,CAAC,CAsMjC"}
@@ -0,0 +1,420 @@
1
+ import * as esbuild from "esbuild";
2
+ import * as fs from "fs";
3
+ import * as os from "os";
4
+ import * as path from "path";
5
+ import { resolveCssImports } from "./css-import-resolver.js";
6
+ import { ikasComponentUtilsPlugin } from "./observer-runtime.js";
7
+ /**
8
+ * External dependencies - these will be provided by the generated storefront
9
+ */
10
+ const SERVER_EXTERNALS = [
11
+ "preact",
12
+ "preact/hooks",
13
+ "preact-render-to-string",
14
+ "mobx",
15
+ "@ikas/bp-storefront",
16
+ "@ikas/bp-storefront-models",
17
+ "@ikas/bp-storefront-config",
18
+ "@ikas/bp-storefront-api"
19
+ ];
20
+ const CLIENT_EXTERNALS = [
21
+ "preact",
22
+ "preact/hooks",
23
+ "mobx",
24
+ "@ikas/bp-storefront",
25
+ "@ikas/bp-storefront-models",
26
+ "@ikas/bp-storefront-config"
27
+ ];
28
+ /**
29
+ * Compile a single component's TSX and CSS
30
+ */
31
+ export async function compileComponent(entryPath, stylesPath, componentId) {
32
+ try {
33
+ // Build server bundle (for SSR with preact-render-to-string)
34
+ const serverResult = await esbuild.build({
35
+ entryPoints: [path.resolve(process.cwd(), entryPath)],
36
+ bundle: true,
37
+ format: "esm",
38
+ platform: "node",
39
+ target: "node18",
40
+ write: false,
41
+ external: SERVER_EXTERNALS,
42
+ plugins: [ikasComponentUtilsPlugin()],
43
+ jsx: "transform",
44
+ jsxFactory: "h",
45
+ jsxFragment: "Fragment",
46
+ tsconfigRaw: {
47
+ compilerOptions: {
48
+ jsx: "react",
49
+ jsxFactory: "h",
50
+ jsxFragmentFactory: "Fragment"
51
+ }
52
+ },
53
+ minify: true,
54
+ sourcemap: false,
55
+ banner: {
56
+ js: 'import{h,Fragment}from"preact";'
57
+ }
58
+ });
59
+ // Build client bundle (for hydration)
60
+ const clientResult = await esbuild.build({
61
+ entryPoints: [path.resolve(process.cwd(), entryPath)],
62
+ bundle: true,
63
+ format: "esm",
64
+ platform: "browser",
65
+ target: "es2020",
66
+ write: false,
67
+ external: CLIENT_EXTERNALS,
68
+ plugins: [ikasComponentUtilsPlugin()],
69
+ jsx: "transform",
70
+ jsxFactory: "h",
71
+ jsxFragment: "Fragment",
72
+ tsconfigRaw: {
73
+ compilerOptions: {
74
+ jsx: "react",
75
+ jsxFactory: "h",
76
+ jsxFragmentFactory: "Fragment"
77
+ }
78
+ },
79
+ minify: true,
80
+ sourcemap: false,
81
+ banner: {
82
+ js: 'import{h,Fragment}from"preact";'
83
+ }
84
+ });
85
+ // Read CSS (with import resolution)
86
+ const cssPath = path.resolve(process.cwd(), stylesPath);
87
+ let css = "";
88
+ if (fs.existsSync(cssPath)) {
89
+ const rawCss = fs.readFileSync(cssPath, "utf-8");
90
+ css = resolveCssImports(rawCss, cssPath);
91
+ }
92
+ // Scope CSS
93
+ const scopedCss = scopeCSS(css, componentId);
94
+ return {
95
+ success: true,
96
+ serverJs: serverResult.outputFiles[0]?.text || "",
97
+ clientJs: clientResult.outputFiles[0]?.text || "",
98
+ scopedCss
99
+ };
100
+ }
101
+ catch (error) {
102
+ return {
103
+ success: false,
104
+ serverJs: "",
105
+ clientJs: "",
106
+ scopedCss: "",
107
+ error: error.message || String(error)
108
+ };
109
+ }
110
+ }
111
+ /**
112
+ * Scope CSS selectors with a component-specific class prefix
113
+ */
114
+ export function scopeCSS(css, componentId) {
115
+ const scopeClass = `cc_${componentId.replace(/[^a-zA-Z0-9]/g, "_")}`;
116
+ return scopeCSSWithClasses(css, [scopeClass]);
117
+ }
118
+ /**
119
+ * Scope CSS selectors with multiple class prefixes (for shared chunks).
120
+ * Each selector becomes: .cc_id1 .sel, .cc_id2 .sel { ... }
121
+ */
122
+ export function scopeCSSMulti(css, componentIds) {
123
+ const scopeClasses = componentIds.map(id => `cc_${id.replace(/[^a-zA-Z0-9]/g, "_")}`);
124
+ return scopeCSSWithClasses(css, scopeClasses);
125
+ }
126
+ /**
127
+ * Internal: scope CSS selectors with one or more scope class prefixes
128
+ */
129
+ function scopeCSSWithClasses(css, scopeClasses) {
130
+ const lines = css.split("\n");
131
+ const scopedLines = [];
132
+ let inMediaQuery = false;
133
+ let inKeyframes = false;
134
+ for (const line of lines) {
135
+ const trimmed = line.trim();
136
+ if (!trimmed) {
137
+ scopedLines.push(line);
138
+ continue;
139
+ }
140
+ if (trimmed.startsWith("@media")) {
141
+ inMediaQuery = true;
142
+ scopedLines.push(line);
143
+ continue;
144
+ }
145
+ if (trimmed.startsWith("@keyframes") || trimmed.startsWith("@-webkit-keyframes")) {
146
+ inKeyframes = true;
147
+ scopedLines.push(line);
148
+ continue;
149
+ }
150
+ if (trimmed === "}" && (inMediaQuery || inKeyframes)) {
151
+ if (inKeyframes && !trimmed.includes("{")) {
152
+ inKeyframes = false;
153
+ }
154
+ else if (inMediaQuery) {
155
+ inMediaQuery = false;
156
+ }
157
+ scopedLines.push(line);
158
+ continue;
159
+ }
160
+ if (inKeyframes) {
161
+ scopedLines.push(line);
162
+ continue;
163
+ }
164
+ if (!trimmed.includes("{") || trimmed.startsWith("@")) {
165
+ scopedLines.push(line);
166
+ continue;
167
+ }
168
+ const [selector, rest] = line.split("{");
169
+ if (selector && rest !== undefined) {
170
+ const scopedSelector = selector
171
+ .split(",")
172
+ .flatMap((s) => scopeClasses.map(cls => `.${cls} ${s.trim()}`))
173
+ .join(", ");
174
+ scopedLines.push(`${scopedSelector} {${rest}`);
175
+ }
176
+ else {
177
+ scopedLines.push(line);
178
+ }
179
+ }
180
+ return scopedLines.join("\n");
181
+ }
182
+ /**
183
+ * Common esbuild options shared between server and client builds
184
+ */
185
+ function commonBuildOptions() {
186
+ return {
187
+ bundle: true,
188
+ jsx: "transform",
189
+ jsxFactory: "h",
190
+ jsxFragment: "Fragment",
191
+ tsconfigRaw: {
192
+ compilerOptions: {
193
+ jsx: "react",
194
+ jsxFactory: "h",
195
+ jsxFragmentFactory: "Fragment"
196
+ }
197
+ },
198
+ minify: true,
199
+ sourcemap: false,
200
+ };
201
+ }
202
+ /**
203
+ * Compile all components together with esbuild code splitting.
204
+ * Shared code is automatically extracted into chunk files.
205
+ * When there's no shared code, output is identical to per-component compilation.
206
+ */
207
+ export async function compileAllComponents(components) {
208
+ if (components.length === 0) {
209
+ return { success: true, entries: new Map(), chunks: new Map(), css: new Map(), chunkCss: new Map() };
210
+ }
211
+ const tmpBase = path.join(os.tmpdir(), `ikas-compile-${Date.now()}`);
212
+ const serverDir = path.join(tmpBase, "server");
213
+ const clientDir = path.join(tmpBase, "client");
214
+ fs.mkdirSync(serverDir, { recursive: true });
215
+ fs.mkdirSync(clientDir, { recursive: true });
216
+ // Build entry points map: componentId → absolute path
217
+ const entryPoints = {};
218
+ for (const comp of components) {
219
+ entryPoints[comp.id] = path.resolve(process.cwd(), comp.entryPath);
220
+ }
221
+ try {
222
+ // Server build with code splitting
223
+ await esbuild.build({
224
+ ...commonBuildOptions(),
225
+ entryPoints,
226
+ format: "esm",
227
+ platform: "node",
228
+ target: "node18",
229
+ external: SERVER_EXTERNALS,
230
+ plugins: [ikasComponentUtilsPlugin()],
231
+ splitting: true,
232
+ outdir: serverDir,
233
+ entryNames: "[name]",
234
+ chunkNames: "chunk-[hash]",
235
+ banner: {
236
+ js: 'import{h,Fragment}from"preact";'
237
+ }
238
+ });
239
+ // Client build with code splitting (metafile enabled for dependency tracking)
240
+ const clientBuildResult = await esbuild.build({
241
+ ...commonBuildOptions(),
242
+ entryPoints,
243
+ format: "esm",
244
+ platform: "browser",
245
+ target: "es2020",
246
+ external: CLIENT_EXTERNALS,
247
+ plugins: [ikasComponentUtilsPlugin()],
248
+ splitting: true,
249
+ outdir: clientDir,
250
+ entryNames: "[name]",
251
+ chunkNames: "chunk-[hash]",
252
+ metafile: true,
253
+ banner: {
254
+ js: 'import{h,Fragment}from"preact";'
255
+ }
256
+ });
257
+ // Read output files
258
+ const entries = new Map();
259
+ const chunks = new Map();
260
+ // Collect entry IDs for identification
261
+ const entryIds = new Set(components.map(c => c.id));
262
+ // Read server output
263
+ const serverFiles = fs.readdirSync(serverDir).filter(f => f.endsWith(".js"));
264
+ const serverMap = new Map();
265
+ for (const file of serverFiles) {
266
+ const content = fs.readFileSync(path.join(serverDir, file), "utf-8");
267
+ const baseName = file.replace(/\.js$/, "");
268
+ serverMap.set(baseName, content);
269
+ }
270
+ // Read client output
271
+ const clientFiles = fs.readdirSync(clientDir).filter(f => f.endsWith(".js"));
272
+ const clientMap = new Map();
273
+ for (const file of clientFiles) {
274
+ const content = fs.readFileSync(path.join(clientDir, file), "utf-8");
275
+ const baseName = file.replace(/\.js$/, "");
276
+ clientMap.set(baseName, content);
277
+ }
278
+ // Categorize as entry vs chunk
279
+ const allKeys = new Set([...serverMap.keys(), ...clientMap.keys()]);
280
+ for (const key of allKeys) {
281
+ const serverJs = serverMap.get(key) || "";
282
+ const clientJs = clientMap.get(key) || "";
283
+ if (entryIds.has(key)) {
284
+ entries.set(key, { serverJs, clientJs });
285
+ }
286
+ else {
287
+ // It's a chunk file
288
+ chunks.set(key, { serverJs, clientJs });
289
+ }
290
+ }
291
+ // Build dependency maps from metafile
292
+ const metafile = clientBuildResult.metafile;
293
+ const entryDirSet = new Map(); // entryId → absolute dir of entry file
294
+ for (const comp of components) {
295
+ entryDirSet.set(comp.id, path.dirname(path.resolve(process.cwd(), comp.entryPath)));
296
+ }
297
+ // Map each output to its input source files
298
+ const entryInputs = new Map(); // entryId → list of input paths
299
+ const chunkInputs = new Map(); // chunkId → list of input paths
300
+ const chunkConsumers = new Map(); // chunkId → list of entry IDs that import it
301
+ for (const [outputPath, outputMeta] of Object.entries(metafile.outputs)) {
302
+ const baseName = path.basename(outputPath, ".js");
303
+ const inputPaths = Object.keys(outputMeta.inputs || {});
304
+ if (entryIds.has(baseName)) {
305
+ entryInputs.set(baseName, inputPaths);
306
+ }
307
+ else if (baseName.startsWith("chunk-")) {
308
+ chunkInputs.set(baseName, inputPaths);
309
+ }
310
+ }
311
+ // Determine chunk→consumers: which entries import each chunk
312
+ for (const [outputPath, outputMeta] of Object.entries(metafile.outputs)) {
313
+ const baseName = path.basename(outputPath, ".js");
314
+ if (!entryIds.has(baseName))
315
+ continue;
316
+ const imports = outputMeta.imports || [];
317
+ for (const imp of imports) {
318
+ const impBaseName = path.basename(imp.path, ".js");
319
+ if (chunkInputs.has(impBaseName)) {
320
+ if (!chunkConsumers.has(impBaseName)) {
321
+ chunkConsumers.set(impBaseName, []);
322
+ }
323
+ chunkConsumers.get(impBaseName).push(baseName);
324
+ }
325
+ }
326
+ }
327
+ // Resolve CSS: entry CSS + entry-only dependency CSS + chunk CSS
328
+ const css = new Map();
329
+ const chunkCss = new Map();
330
+ for (const comp of components) {
331
+ // 1. Read entry's own styles.css + resolve @imports (unchanged)
332
+ const cssPath = path.resolve(process.cwd(), comp.stylesPath);
333
+ let cssContent = "";
334
+ if (fs.existsSync(cssPath)) {
335
+ const rawCss = fs.readFileSync(cssPath, "utf-8");
336
+ cssContent = resolveCssImports(rawCss, cssPath);
337
+ }
338
+ // 2. Collect CSS from entry-only dependencies (source files in entry inputs, not in any chunk)
339
+ const allChunkInputPaths = new Set();
340
+ for (const inputs of chunkInputs.values()) {
341
+ for (const p of inputs)
342
+ allChunkInputPaths.add(p);
343
+ }
344
+ const entryOnlyInputs = (entryInputs.get(comp.id) || []).filter(p => !allChunkInputPaths.has(p));
345
+ const depCss = collectSourceCssFiles(entryOnlyInputs, entryDirSet.get(comp.id));
346
+ for (const depCssPath of depCss) {
347
+ const rawDepCss = fs.readFileSync(depCssPath, "utf-8");
348
+ cssContent += "\n" + resolveCssImports(rawDepCss, depCssPath);
349
+ }
350
+ // 3. Scope combined CSS with entry ID
351
+ css.set(comp.id, scopeCSS(cssContent, comp.id));
352
+ }
353
+ // Process chunk CSS
354
+ for (const [chunkId, inputPaths] of chunkInputs) {
355
+ const consumers = chunkConsumers.get(chunkId) || [];
356
+ if (consumers.length === 0)
357
+ continue;
358
+ // Collect CSS from all entry dirs to exclude (we only exclude entry file dirs)
359
+ const excludeDirs = Array.from(entryDirSet.values());
360
+ const chunkCssFiles = collectSourceCssFiles(inputPaths, undefined, excludeDirs);
361
+ if (chunkCssFiles.length === 0)
362
+ continue;
363
+ let combinedCss = "";
364
+ for (const cssFilePath of chunkCssFiles) {
365
+ const rawCss = fs.readFileSync(cssFilePath, "utf-8");
366
+ combinedCss += "\n" + resolveCssImports(rawCss, cssFilePath);
367
+ }
368
+ if (combinedCss.trim()) {
369
+ chunkCss.set(chunkId, scopeCSSMulti(combinedCss, consumers));
370
+ }
371
+ }
372
+ return { success: true, entries, chunks, css, chunkCss };
373
+ }
374
+ catch (error) {
375
+ return {
376
+ success: false,
377
+ entries: new Map(),
378
+ chunks: new Map(),
379
+ css: new Map(),
380
+ chunkCss: new Map(),
381
+ error: error.message || String(error)
382
+ };
383
+ }
384
+ finally {
385
+ // Clean up temp directory
386
+ fs.rmSync(tmpBase, { recursive: true, force: true });
387
+ }
388
+ }
389
+ /**
390
+ * For each source file input path (.ts/.tsx/.js/.jsx), check if a sibling
391
+ * styles.css exists in the same directory. Optionally skip specific directories.
392
+ * Returns deduplicated list of CSS file paths.
393
+ */
394
+ function collectSourceCssFiles(inputPaths, excludeDir, excludeDirs) {
395
+ const cssFiles = [];
396
+ const seen = new Set();
397
+ const allExcludeDirs = new Set();
398
+ if (excludeDir)
399
+ allExcludeDirs.add(path.resolve(excludeDir));
400
+ if (excludeDirs)
401
+ excludeDirs.forEach(d => allExcludeDirs.add(path.resolve(d)));
402
+ for (const inputPath of inputPaths) {
403
+ if (!/\.(tsx?|jsx?)$/.test(inputPath))
404
+ continue;
405
+ const absPath = path.resolve(process.cwd(), inputPath);
406
+ const dir = path.dirname(absPath);
407
+ // Skip excluded directories (entry component dirs)
408
+ if (allExcludeDirs.has(dir))
409
+ continue;
410
+ const cssPath = path.join(dir, "styles.css");
411
+ if (seen.has(cssPath))
412
+ continue;
413
+ seen.add(cssPath);
414
+ if (fs.existsSync(cssPath)) {
415
+ cssFiles.push(cssPath);
416
+ }
417
+ }
418
+ return cssFiles;
419
+ }
420
+ //# sourceMappingURL=compile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compile.js","sourceRoot":"","sources":["../../src/utils/compile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAE7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAEjE;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,QAAQ;IACR,cAAc;IACd,yBAAyB;IACzB,MAAM;IACN,qBAAqB;IACrB,4BAA4B;IAC5B,4BAA4B;IAC5B,yBAAyB;CAC1B,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,QAAQ;IACR,cAAc;IACd,MAAM;IACN,qBAAqB;IACrB,4BAA4B;IAC5B,4BAA4B;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,SAAiB,EACjB,UAAkB,EAClB,WAAmB;IAEnB,IAAI,CAAC;QACH,6DAA6D;QAC7D,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;YACvC,WAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,CAAC,CAAC;YACrD,MAAM,EAAE,IAAI;Y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C,CAAC;QACzB,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -0,0 +1,23 @@
1
+ import type { ComponentProp } from "../types.js";
2
+ /**
3
+ * Generate an 8-character random alphanumeric project ID (lowercase + digits).
4
+ * Used to namespace component IDs across independent CLI projects.
5
+ */
6
+ export declare function generateProjectId(): string;
7
+ /**
8
+ * Generate a component ID namespaced by projectId.
9
+ * Format: `${projectId}-${kebabName}`
10
+ */
11
+ export declare function generateComponentId(projectId: string, kebabName: string): string;
12
+ export declare const PROP_TYPES: readonly ["TEXT", "NUMBER", "BOOLEAN", "IMAGE", "LINK", "LIST_OF_LINK", "COLOR", "SELECT", "PRODUCT", "PRODUCT_LIST", "CATEGORY", "CATEGORY_LIST", "BRAND", "BRAND_LIST", "BLOG_POST", "BLOG_POST_LIST"];
13
+ export declare const PROP_TYPE_TO_TS: Record<string, string>;
14
+ export declare function toKebabCase(str: string): string;
15
+ export declare function toPascalCase(str: string): string;
16
+ export declare function generateTypesFile(componentName: string, props: ComponentProp[], type?: "component" | "section"): string;
17
+ export declare function generateComponentFile(componentName: string, props: ComponentProp[], type?: "component" | "section"): string;
18
+ export declare function generateStylesFile(componentName: string, type?: "component" | "section"): string;
19
+ /**
20
+ * Update the barrel export file (src/components/index.ts) to include all components
21
+ */
22
+ export declare function updateBarrelExport(projectRoot: string, componentNames: string[]): void;
23
+ //# sourceMappingURL=component-helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"component-helpers.d.ts","sourceRoot":"","sources":["../../src/utils/component-helpers.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAQ1C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAEhF;AAED,eAAO,MAAM,UAAU,0MAiBb,CAAC;AAEX,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAiBlD,CAAC;AAEF,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAK/C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKhD;AAED,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CA+BvH;AAED,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,aAAa,EAAE,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAgC3H;AAED,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAsChG;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,QAM/E"}