@agimon-ai/style-system 0.2.7 → 0.2.9
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/cli.cjs
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig,
|
|
2
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, R as log, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-DkNzur0U.mjs";
|
|
3
3
|
import { promises } from "node:fs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { z } from "zod";
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-C5EE-217.cjs");
|
|
3
3
|
let node_fs = require("node:fs");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
node_path = require_stdio.__toESM(node_path, 1);
|
|
@@ -8,10 +8,6 @@ let node_crypto = require("node:crypto");
|
|
|
8
8
|
const STORY_FILE_PATTERN = /\.stories\.(?:ts|tsx)$/;
|
|
9
9
|
const STORY_EXPORT_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
10
10
|
const UTF8_ENCODING = "utf8";
|
|
11
|
-
function isContained(root, candidate) {
|
|
12
|
-
const relative = node_path.default.relative(root, candidate);
|
|
13
|
-
return relative === "" || !relative.startsWith(`..${node_path.default.sep}`) && relative !== ".." && !node_path.default.isAbsolute(relative);
|
|
14
|
-
}
|
|
15
11
|
/** Builds and owns disposable, self-contained HTML previews for exact story exports. */
|
|
16
12
|
var StoryPreviewService = class {
|
|
17
13
|
workspaceRoot;
|
|
@@ -54,7 +50,8 @@ var StoryPreviewService = class {
|
|
|
54
50
|
});
|
|
55
51
|
const htmlFilePath = await node_fs.promises.realpath(result.htmlFilePath);
|
|
56
52
|
const artifactDirectory = node_path.default.dirname(htmlFilePath);
|
|
57
|
-
|
|
53
|
+
const artifactRoot = node_path.default.join(appPath, ".tmp");
|
|
54
|
+
if (!require_stdio.isContained(artifactRoot, artifactDirectory)) throw new Error("Bundler returned a preview artifact outside the project temporary directory");
|
|
58
55
|
const handle = (0, node_crypto.randomUUID)();
|
|
59
56
|
const html = await node_fs.promises.readFile(htmlFilePath, UTF8_ENCODING);
|
|
60
57
|
this.previews.set(handle, { artifactDirectory });
|
|
@@ -85,7 +82,7 @@ var StoryPreviewService = class {
|
|
|
85
82
|
if (!inputPath) throw new Error(`${field} is required`);
|
|
86
83
|
const candidate = node_path.default.isAbsolute(inputPath) ? inputPath : node_path.default.resolve(root, inputPath);
|
|
87
84
|
const canonical = await node_fs.promises.realpath(candidate);
|
|
88
|
-
if (!isContained(root, canonical)) throw new Error(`${field} must remain inside the workspace root`);
|
|
85
|
+
if (!require_stdio.isContained(root, canonical)) throw new Error(`${field} must remain inside the workspace root`);
|
|
89
86
|
return canonical;
|
|
90
87
|
}
|
|
91
88
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-
|
|
1
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, L as isContained, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-DkNzur0U.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -6,10 +6,6 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
6
6
|
const STORY_FILE_PATTERN = /\.stories\.(?:ts|tsx)$/;
|
|
7
7
|
const STORY_EXPORT_PATTERN = /^[A-Za-z_$][A-Za-z0-9_$]*$/;
|
|
8
8
|
const UTF8_ENCODING = "utf8";
|
|
9
|
-
function isContained(root, candidate) {
|
|
10
|
-
const relative = path.relative(root, candidate);
|
|
11
|
-
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
12
|
-
}
|
|
13
9
|
/** Builds and owns disposable, self-contained HTML previews for exact story exports. */
|
|
14
10
|
var StoryPreviewService = class {
|
|
15
11
|
workspaceRoot;
|
|
@@ -52,7 +48,8 @@ var StoryPreviewService = class {
|
|
|
52
48
|
});
|
|
53
49
|
const htmlFilePath = await promises.realpath(result.htmlFilePath);
|
|
54
50
|
const artifactDirectory = path.dirname(htmlFilePath);
|
|
55
|
-
|
|
51
|
+
const artifactRoot = path.join(appPath, ".tmp");
|
|
52
|
+
if (!isContained(artifactRoot, artifactDirectory)) throw new Error("Bundler returned a preview artifact outside the project temporary directory");
|
|
56
53
|
const handle = randomUUID();
|
|
57
54
|
const html = await promises.readFile(htmlFilePath, UTF8_ENCODING);
|
|
58
55
|
this.previews.set(handle, { artifactDirectory });
|
|
@@ -130,6 +130,11 @@ const log = {
|
|
|
130
130
|
};
|
|
131
131
|
//#endregion
|
|
132
132
|
//#region src/utils/fsHelpers.ts
|
|
133
|
+
/** True when candidate is root itself or inside it (sibling prefixes like `<root>-evil` are outside). */
|
|
134
|
+
function isContained(root, candidate) {
|
|
135
|
+
const relative = node_path.default.relative(root, candidate);
|
|
136
|
+
return relative === "" || !relative.startsWith(`..${node_path.default.sep}`) && relative !== ".." && !node_path.default.isAbsolute(relative);
|
|
137
|
+
}
|
|
133
138
|
async function pathExists(filePath) {
|
|
134
139
|
try {
|
|
135
140
|
await node_fs_promises.access(filePath);
|
|
@@ -1860,9 +1865,7 @@ function validateCssFiles(cssFiles, workspaceRoot) {
|
|
|
1860
1865
|
for (const cssFile of cssFiles) {
|
|
1861
1866
|
if (typeof cssFile !== "string") throw new Error("CSS file path must be a string");
|
|
1862
1867
|
if (cssFile.includes("..")) throw new Error(`CSS file path "${cssFile}" must not contain path traversal sequences (..)`);
|
|
1863
|
-
if (node_path.default.isAbsolute(cssFile)) {
|
|
1864
|
-
if (!node_path.default.normalize(cssFile).startsWith(workspaceRoot)) throw new Error(`CSS file path "${cssFile}" must be within workspace boundaries`);
|
|
1865
|
-
}
|
|
1868
|
+
if (node_path.default.isAbsolute(cssFile) && !isContained(workspaceRoot, node_path.default.normalize(cssFile))) throw new Error(`CSS file path "${cssFile}" must be within workspace boundaries`);
|
|
1866
1869
|
const ext = node_path.default.extname(cssFile).toLowerCase();
|
|
1867
1870
|
if (!SUPPORTED_CSS_EXTENSIONS.includes(ext)) throw new Error(`CSS file "${cssFile}" must have a valid CSS extension (${SUPPORTED_CSS_EXTENSIONS_LABEL})`);
|
|
1868
1871
|
}
|
|
@@ -2130,8 +2133,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2130
2133
|
validateStoryName(storyName);
|
|
2131
2134
|
validateComponentPath(componentPath);
|
|
2132
2135
|
validateArgsSize(args);
|
|
2133
|
-
validateCssFiles(cssFiles, this.monorepoRoot);
|
|
2134
2136
|
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(this.monorepoRoot, appPath);
|
|
2137
|
+
validateCssFiles(cssFiles, TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath));
|
|
2135
2138
|
if (this.currentAppPath !== resolvedAppPath) throw new Error(`Dev server is running for ${this.currentAppPath} but requested ${resolvedAppPath}.`);
|
|
2136
2139
|
const tmpDir = node_path.default.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2137
2140
|
try {
|
|
@@ -2178,8 +2181,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2178
2181
|
validateStoryName(storyName);
|
|
2179
2182
|
validateComponentPath(componentPath);
|
|
2180
2183
|
validateArgsSize(args);
|
|
2181
|
-
validateCssFiles(cssFiles, this.monorepoRoot);
|
|
2182
2184
|
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(this.monorepoRoot, appPath);
|
|
2185
|
+
validateCssFiles(cssFiles, TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath));
|
|
2183
2186
|
const tmpDir = node_path.default.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2184
2187
|
try {
|
|
2185
2188
|
await node_fs.promises.mkdir(tmpDir, { recursive: true });
|
|
@@ -2205,7 +2208,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2205
2208
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
2206
2209
|
*/
|
|
2207
2210
|
getViteResolveConfig(appPath) {
|
|
2208
|
-
const
|
|
2211
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(appPath);
|
|
2212
|
+
const frontendPackagePath = (packageDir, sourcePath = "index.ts") => node_path.default.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", packageDir, APP_SOURCE_DIR$1, sourcePath);
|
|
2209
2213
|
return { alias: [
|
|
2210
2214
|
{
|
|
2211
2215
|
find: APP_SOURCE_ALIAS_PATTERN,
|
|
@@ -2217,7 +2221,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2217
2221
|
},
|
|
2218
2222
|
{
|
|
2219
2223
|
find: /^@agimonai\/frontend-web-theme\/modules\/(.*)$/,
|
|
2220
|
-
replacement: `${node_path.default.join(
|
|
2224
|
+
replacement: `${node_path.default.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", "web-theme", APP_SOURCE_DIR$1, "modules")}/$1`
|
|
2221
2225
|
}
|
|
2222
2226
|
] };
|
|
2223
2227
|
}
|
|
@@ -2313,17 +2317,18 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2313
2317
|
*/
|
|
2314
2318
|
async generateWrapperCss(appPath, cssFiles) {
|
|
2315
2319
|
const resolvedCssFiles = cssFiles.length > 0 ? cssFiles : await this.getDefaultCssFiles(appPath);
|
|
2320
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(appPath);
|
|
2316
2321
|
const cssImportStatements = resolvedCssFiles.map((cssFile) => {
|
|
2317
2322
|
if (node_path.default.isAbsolute(cssFile)) return `@import '${cssFile}';`;
|
|
2318
2323
|
if (cssFile.startsWith(PACKAGE_IMPORT_PREFIX) || cssFile.startsWith(TAILWIND_IMPORT_PREFIX)) return `@import '${cssFile}';`;
|
|
2319
|
-
if (cssFile.startsWith(WORKSPACE_PACKAGE_DIR_PREFIX) || cssFile.startsWith(WORKSPACE_APP_DIR_PREFIX)) return `@import '${node_path.default.join(
|
|
2324
|
+
if (cssFile.startsWith(WORKSPACE_PACKAGE_DIR_PREFIX) || cssFile.startsWith(WORKSPACE_APP_DIR_PREFIX)) return `@import '${node_path.default.join(workspaceRoot, cssFile)}';`;
|
|
2320
2325
|
return `@import '${node_path.default.join(appPath, cssFile)}';`;
|
|
2321
2326
|
}).join("\n");
|
|
2322
2327
|
return `${resolvedCssFiles.length === 0 ? "@import 'tailwindcss';\n" : ""}${cssImportStatements}
|
|
2323
2328
|
|
|
2324
2329
|
/* Tailwind v4 source configuration for component scanning */
|
|
2325
|
-
@source "${node_path.default.join(
|
|
2326
|
-
@source "${node_path.default.join(
|
|
2330
|
+
@source "${node_path.default.join(workspaceRoot, WORKSPACE_APP_DIR_PREFIX)}";
|
|
2331
|
+
@source "${node_path.default.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend")}";
|
|
2327
2332
|
@source "${node_path.default.join(appPath, APP_SOURCE_DIR$1)}";
|
|
2328
2333
|
`;
|
|
2329
2334
|
}
|
|
@@ -2473,6 +2478,8 @@ mount();
|
|
|
2473
2478
|
async buildComponent(options) {
|
|
2474
2479
|
const { appPath, darkMode, tmpDir, cssFiles } = options;
|
|
2475
2480
|
const timestamp = Date.now();
|
|
2481
|
+
const htmlTemplateFileName = `${BUILD_HTML_FILE_PREFIX}${timestamp}${HTML_FILE_EXTENSION}`;
|
|
2482
|
+
const htmlTemplatePath = node_path.default.join(tmpDir, htmlTemplateFileName);
|
|
2476
2483
|
try {
|
|
2477
2484
|
const wrapperCssPath = node_path.default.join(tmpDir, TAILWIND_WRAPPER_CSS_FILE);
|
|
2478
2485
|
const wrapperCssContent = await this.generateWrapperCss(appPath, cssFiles);
|
|
@@ -2480,8 +2487,6 @@ mount();
|
|
|
2480
2487
|
const storyId = `${STORY_ID_BUILD_PREFIX}${timestamp}`;
|
|
2481
2488
|
const virtualModuleId = `${VIRTUAL_STORY_ENTRY_SCRIPT_PREFIX}${storyId}`;
|
|
2482
2489
|
const htmlTemplate = this.generateHtmlTemplate(virtualModuleId, darkMode);
|
|
2483
|
-
const htmlTemplateFileName = `${BUILD_HTML_FILE_PREFIX}${timestamp}${HTML_FILE_EXTENSION}`;
|
|
2484
|
-
const htmlTemplatePath = node_path.default.join(tmpDir, htmlTemplateFileName);
|
|
2485
2490
|
await node_fs.promises.writeFile(htmlTemplatePath, htmlTemplate, UTF8_ENCODING$1);
|
|
2486
2491
|
const { build } = await import("vite");
|
|
2487
2492
|
const outDir = node_path.default.join(tmpDir, `${BUILD_OUTPUT_DIR_PREFIX}${timestamp}`);
|
|
@@ -2517,12 +2522,13 @@ mount();
|
|
|
2517
2522
|
});
|
|
2518
2523
|
const builtHtmlPath = node_path.default.join(outDir, htmlTemplateFileName);
|
|
2519
2524
|
log.info(`[ViteReactBundlerService] Component built to: ${builtHtmlPath}`);
|
|
2520
|
-
await node_fs.promises.unlink(htmlTemplatePath).catch((err) => log.debug(`[ViteReactBundlerService] Failed to cleanup temp file: ${err.message}`));
|
|
2521
2525
|
return builtHtmlPath;
|
|
2522
2526
|
} catch (error) {
|
|
2523
2527
|
const err = /* @__PURE__ */ new Error(`Failed to build component: ${error instanceof Error ? error.message : String(error)}`);
|
|
2524
2528
|
err.cause = error;
|
|
2525
2529
|
throw err;
|
|
2530
|
+
} finally {
|
|
2531
|
+
await node_fs.promises.unlink(htmlTemplatePath).catch((err) => log.debug(`[ViteReactBundlerService] Failed to cleanup temp file: ${err.message}`));
|
|
2526
2532
|
}
|
|
2527
2533
|
}
|
|
2528
2534
|
};
|
|
@@ -4963,7 +4969,7 @@ function createContainer(options) {
|
|
|
4963
4969
|
}
|
|
4964
4970
|
//#endregion
|
|
4965
4971
|
//#region package.json
|
|
4966
|
-
var version = "0.2.
|
|
4972
|
+
var version = "0.2.8";
|
|
4967
4973
|
//#endregion
|
|
4968
4974
|
//#region src/metadata.ts
|
|
4969
4975
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -5439,6 +5445,12 @@ Object.defineProperty(exports, "hasStyleSystemProjectConfig", {
|
|
|
5439
5445
|
return hasStyleSystemProjectConfig;
|
|
5440
5446
|
}
|
|
5441
5447
|
});
|
|
5448
|
+
Object.defineProperty(exports, "isContained", {
|
|
5449
|
+
enumerable: true,
|
|
5450
|
+
get: function() {
|
|
5451
|
+
return isContained;
|
|
5452
|
+
}
|
|
5453
|
+
});
|
|
5442
5454
|
Object.defineProperty(exports, "log", {
|
|
5443
5455
|
enumerable: true,
|
|
5444
5456
|
get: function() {
|
|
@@ -104,6 +104,11 @@ const log = {
|
|
|
104
104
|
};
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/utils/fsHelpers.ts
|
|
107
|
+
/** True when candidate is root itself or inside it (sibling prefixes like `<root>-evil` are outside). */
|
|
108
|
+
function isContained(root, candidate) {
|
|
109
|
+
const relative = path.relative(root, candidate);
|
|
110
|
+
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
111
|
+
}
|
|
107
112
|
async function pathExists(filePath) {
|
|
108
113
|
try {
|
|
109
114
|
await fs.access(filePath);
|
|
@@ -1834,9 +1839,7 @@ function validateCssFiles(cssFiles, workspaceRoot) {
|
|
|
1834
1839
|
for (const cssFile of cssFiles) {
|
|
1835
1840
|
if (typeof cssFile !== "string") throw new Error("CSS file path must be a string");
|
|
1836
1841
|
if (cssFile.includes("..")) throw new Error(`CSS file path "${cssFile}" must not contain path traversal sequences (..)`);
|
|
1837
|
-
if (path.isAbsolute(cssFile)) {
|
|
1838
|
-
if (!path.normalize(cssFile).startsWith(workspaceRoot)) throw new Error(`CSS file path "${cssFile}" must be within workspace boundaries`);
|
|
1839
|
-
}
|
|
1842
|
+
if (path.isAbsolute(cssFile) && !isContained(workspaceRoot, path.normalize(cssFile))) throw new Error(`CSS file path "${cssFile}" must be within workspace boundaries`);
|
|
1840
1843
|
const ext = path.extname(cssFile).toLowerCase();
|
|
1841
1844
|
if (!SUPPORTED_CSS_EXTENSIONS.includes(ext)) throw new Error(`CSS file "${cssFile}" must have a valid CSS extension (${SUPPORTED_CSS_EXTENSIONS_LABEL})`);
|
|
1842
1845
|
}
|
|
@@ -2104,8 +2107,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2104
2107
|
validateStoryName(storyName);
|
|
2105
2108
|
validateComponentPath(componentPath);
|
|
2106
2109
|
validateArgsSize(args);
|
|
2107
|
-
validateCssFiles(cssFiles, this.monorepoRoot);
|
|
2108
2110
|
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(this.monorepoRoot, appPath);
|
|
2111
|
+
validateCssFiles(cssFiles, TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath));
|
|
2109
2112
|
if (this.currentAppPath !== resolvedAppPath) throw new Error(`Dev server is running for ${this.currentAppPath} but requested ${resolvedAppPath}.`);
|
|
2110
2113
|
const tmpDir = path.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2111
2114
|
try {
|
|
@@ -2152,8 +2155,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2152
2155
|
validateStoryName(storyName);
|
|
2153
2156
|
validateComponentPath(componentPath);
|
|
2154
2157
|
validateArgsSize(args);
|
|
2155
|
-
validateCssFiles(cssFiles, this.monorepoRoot);
|
|
2156
2158
|
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(this.monorepoRoot, appPath);
|
|
2159
|
+
validateCssFiles(cssFiles, TemplatesManagerService.getWorkspaceRootSync(resolvedAppPath));
|
|
2157
2160
|
const tmpDir = path.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2158
2161
|
try {
|
|
2159
2162
|
await promises.mkdir(tmpDir, { recursive: true });
|
|
@@ -2179,7 +2182,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2179
2182
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
2180
2183
|
*/
|
|
2181
2184
|
getViteResolveConfig(appPath) {
|
|
2182
|
-
const
|
|
2185
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(appPath);
|
|
2186
|
+
const frontendPackagePath = (packageDir, sourcePath = "index.ts") => path.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", packageDir, APP_SOURCE_DIR$1, sourcePath);
|
|
2183
2187
|
return { alias: [
|
|
2184
2188
|
{
|
|
2185
2189
|
find: APP_SOURCE_ALIAS_PATTERN,
|
|
@@ -2191,7 +2195,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2191
2195
|
},
|
|
2192
2196
|
{
|
|
2193
2197
|
find: /^@agimonai\/frontend-web-theme\/modules\/(.*)$/,
|
|
2194
|
-
replacement: `${path.join(
|
|
2198
|
+
replacement: `${path.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", "web-theme", APP_SOURCE_DIR$1, "modules")}/$1`
|
|
2195
2199
|
}
|
|
2196
2200
|
] };
|
|
2197
2201
|
}
|
|
@@ -2287,17 +2291,18 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2287
2291
|
*/
|
|
2288
2292
|
async generateWrapperCss(appPath, cssFiles) {
|
|
2289
2293
|
const resolvedCssFiles = cssFiles.length > 0 ? cssFiles : await this.getDefaultCssFiles(appPath);
|
|
2294
|
+
const workspaceRoot = TemplatesManagerService.getWorkspaceRootSync(appPath);
|
|
2290
2295
|
const cssImportStatements = resolvedCssFiles.map((cssFile) => {
|
|
2291
2296
|
if (path.isAbsolute(cssFile)) return `@import '${cssFile}';`;
|
|
2292
2297
|
if (cssFile.startsWith(PACKAGE_IMPORT_PREFIX) || cssFile.startsWith(TAILWIND_IMPORT_PREFIX)) return `@import '${cssFile}';`;
|
|
2293
|
-
if (cssFile.startsWith(WORKSPACE_PACKAGE_DIR_PREFIX) || cssFile.startsWith(WORKSPACE_APP_DIR_PREFIX)) return `@import '${path.join(
|
|
2298
|
+
if (cssFile.startsWith(WORKSPACE_PACKAGE_DIR_PREFIX) || cssFile.startsWith(WORKSPACE_APP_DIR_PREFIX)) return `@import '${path.join(workspaceRoot, cssFile)}';`;
|
|
2294
2299
|
return `@import '${path.join(appPath, cssFile)}';`;
|
|
2295
2300
|
}).join("\n");
|
|
2296
2301
|
return `${resolvedCssFiles.length === 0 ? "@import 'tailwindcss';\n" : ""}${cssImportStatements}
|
|
2297
2302
|
|
|
2298
2303
|
/* Tailwind v4 source configuration for component scanning */
|
|
2299
|
-
@source "${path.join(
|
|
2300
|
-
@source "${path.join(
|
|
2304
|
+
@source "${path.join(workspaceRoot, WORKSPACE_APP_DIR_PREFIX)}";
|
|
2305
|
+
@source "${path.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend")}";
|
|
2301
2306
|
@source "${path.join(appPath, APP_SOURCE_DIR$1)}";
|
|
2302
2307
|
`;
|
|
2303
2308
|
}
|
|
@@ -2447,6 +2452,8 @@ mount();
|
|
|
2447
2452
|
async buildComponent(options) {
|
|
2448
2453
|
const { appPath, darkMode, tmpDir, cssFiles } = options;
|
|
2449
2454
|
const timestamp = Date.now();
|
|
2455
|
+
const htmlTemplateFileName = `${BUILD_HTML_FILE_PREFIX}${timestamp}${HTML_FILE_EXTENSION}`;
|
|
2456
|
+
const htmlTemplatePath = path.join(tmpDir, htmlTemplateFileName);
|
|
2450
2457
|
try {
|
|
2451
2458
|
const wrapperCssPath = path.join(tmpDir, TAILWIND_WRAPPER_CSS_FILE);
|
|
2452
2459
|
const wrapperCssContent = await this.generateWrapperCss(appPath, cssFiles);
|
|
@@ -2454,8 +2461,6 @@ mount();
|
|
|
2454
2461
|
const storyId = `${STORY_ID_BUILD_PREFIX}${timestamp}`;
|
|
2455
2462
|
const virtualModuleId = `${VIRTUAL_STORY_ENTRY_SCRIPT_PREFIX}${storyId}`;
|
|
2456
2463
|
const htmlTemplate = this.generateHtmlTemplate(virtualModuleId, darkMode);
|
|
2457
|
-
const htmlTemplateFileName = `${BUILD_HTML_FILE_PREFIX}${timestamp}${HTML_FILE_EXTENSION}`;
|
|
2458
|
-
const htmlTemplatePath = path.join(tmpDir, htmlTemplateFileName);
|
|
2459
2464
|
await promises.writeFile(htmlTemplatePath, htmlTemplate, UTF8_ENCODING$1);
|
|
2460
2465
|
const { build } = await import("vite");
|
|
2461
2466
|
const outDir = path.join(tmpDir, `${BUILD_OUTPUT_DIR_PREFIX}${timestamp}`);
|
|
@@ -2491,12 +2496,13 @@ mount();
|
|
|
2491
2496
|
});
|
|
2492
2497
|
const builtHtmlPath = path.join(outDir, htmlTemplateFileName);
|
|
2493
2498
|
log.info(`[ViteReactBundlerService] Component built to: ${builtHtmlPath}`);
|
|
2494
|
-
await promises.unlink(htmlTemplatePath).catch((err) => log.debug(`[ViteReactBundlerService] Failed to cleanup temp file: ${err.message}`));
|
|
2495
2499
|
return builtHtmlPath;
|
|
2496
2500
|
} catch (error) {
|
|
2497
2501
|
const err = /* @__PURE__ */ new Error(`Failed to build component: ${error instanceof Error ? error.message : String(error)}`);
|
|
2498
2502
|
err.cause = error;
|
|
2499
2503
|
throw err;
|
|
2504
|
+
} finally {
|
|
2505
|
+
await promises.unlink(htmlTemplatePath).catch((err) => log.debug(`[ViteReactBundlerService] Failed to cleanup temp file: ${err.message}`));
|
|
2500
2506
|
}
|
|
2501
2507
|
}
|
|
2502
2508
|
};
|
|
@@ -4937,7 +4943,7 @@ function createContainer(options) {
|
|
|
4937
4943
|
}
|
|
4938
4944
|
//#endregion
|
|
4939
4945
|
//#region package.json
|
|
4940
|
-
var version = "0.2.
|
|
4946
|
+
var version = "0.2.8";
|
|
4941
4947
|
//#endregion
|
|
4942
4948
|
//#region src/metadata.ts
|
|
4943
4949
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -5209,4 +5215,4 @@ var StdioTransportHandler = class {
|
|
|
5209
5215
|
}
|
|
5210
5216
|
};
|
|
5211
5217
|
//#endregion
|
|
5212
|
-
export { STYLE_SYSTEM_TYPES as A, getAppDesignSystemConfig as C, resolveAppDesignSystemConfig as D, resetStyleSystemConfigCache as E, BaseCSSClassesService as F, TemplatesManagerService as I,
|
|
5218
|
+
export { STYLE_SYSTEM_TYPES as A, getAppDesignSystemConfig as C, resolveAppDesignSystemConfig as D, resetStyleSystemConfigCache as E, BaseCSSClassesService as F, TemplatesManagerService as I, isContained as L, CSSClassesServiceFactory as M, DEFAULT_STYLE_SYSTEM_CONFIG as N, StyleSystemConfigLoader as O, TailwindCSSClassesService as P, log as R, BaseBundlerService as S, hasStyleSystemProjectConfig as T, ThemeService as _, STYLE_SYSTEM_CLI_NAME as a, getBundlerServiceFromConfig as b, createStyleSystemModule as c, ListSharedComponentsTool as d, GetComponentVisualTool as f, ComponentRendererService as g, GetUiComponentService as h, createServer as i, StoriesIndexService as j, resolveStyleSystemThemePath as k, PolishComponentTool as l, ListThemesTool as m, extractCustomTokenNames as n, STYLE_SYSTEM_VERSION as o, GetCSSClassesTool as p, generateRestrictedClassesConfig as r, createContainer as s, StdioTransportHandler as t, ListAppComponentsTool as u, createDefaultBundlerService as v, getSharedComponentTags as w, ViteReactBundlerService as x, getBundlerService as y };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/style-system",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "MCP server for exploring themes, Tailwind CSS classes, and UI components from Storybook with standalone component rendering capabilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"design-system",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"tailwindcss": "4.3.3",
|
|
62
62
|
"vite": "8.1.5",
|
|
63
63
|
"vite-plugin-singlefile": "^2.3.3",
|
|
64
|
-
"@agimon-ai/foundation-
|
|
65
|
-
"@agimon-ai/foundation-
|
|
64
|
+
"@agimon-ai/foundation-exec": "0.27.9",
|
|
65
|
+
"@agimon-ai/foundation-validator": "0.27.9"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@babel/parser": "8.0.0",
|