@agimon-ai/po-style-system-tooling 0.2.14-alpha.27 → 0.2.14-alpha.29
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +25 -8
- package/dist/index.d.cts +8 -7
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +25 -8
- package/dist/{stdio-DkBcS4Ei.mjs → stdio-B12YYINp.mjs} +80 -99
- package/dist/{stdio-SA_mYLbr.cjs → stdio-Dxe1iygw.cjs} +79 -95
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as resolveStyleSystemThemePath, B as STYLE_SYSTEM_TYPES, F as TailwindCSSClassesService, P as DEFAULT_STYLE_SYSTEM_CONFIG, a as STYLE_SYSTEM_CLI_NAME, i as createServer$1, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, w as getAppDesignSystemConfig, y as getBundlerServiceFromConfig, z as log } from "./stdio-
|
|
2
|
+
import { A as resolveStyleSystemThemePath, B as STYLE_SYSTEM_TYPES, F as TailwindCSSClassesService, P as DEFAULT_STYLE_SYSTEM_CONFIG, a as STYLE_SYSTEM_CLI_NAME, i as createServer$1, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, w as getAppDesignSystemConfig, y as getBundlerServiceFromConfig, z as log } from "./stdio-B12YYINp.mjs";
|
|
3
3
|
import { promises } from "node:fs";
|
|
4
4
|
import path, { join } 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-Dxe1iygw.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);
|
|
@@ -16,7 +16,7 @@ var StoryPreviewService = class {
|
|
|
16
16
|
bundlerFactory;
|
|
17
17
|
previews = /* @__PURE__ */ new Map();
|
|
18
18
|
constructor(options = {}) {
|
|
19
|
-
this.workspaceRoot = node_path.default.resolve(options.workspaceRoot
|
|
19
|
+
this.workspaceRoot = options.workspaceRoot !== void 0 ? Promise.resolve(node_path.default.resolve(options.workspaceRoot)) : void 0;
|
|
20
20
|
this.storiesIndexFactory = options.storiesIndexFactory ?? ((workspaceRoot, storyFilePath) => new require_stdio.StoriesIndexService({
|
|
21
21
|
workspaceRoot,
|
|
22
22
|
storyFiles: [storyFilePath],
|
|
@@ -27,7 +27,8 @@ var StoryPreviewService = class {
|
|
|
27
27
|
}
|
|
28
28
|
async build(input) {
|
|
29
29
|
if (!STORY_EXPORT_PATTERN.test(input.storyExport)) throw new Error("storyExport must be an exact JavaScript named export");
|
|
30
|
-
const
|
|
30
|
+
const root = await (this.workspaceRoot ??= require_stdio.TemplatesManagerService.getWorkspaceRoot());
|
|
31
|
+
const workspaceRoot = await node_fs.promises.realpath(root);
|
|
31
32
|
const appPath = await this.resolveContainedPath(workspaceRoot, input.appPath, "appPath");
|
|
32
33
|
const storyFilePath = await this.resolveContainedPath(workspaceRoot, input.storyFilePath, "storyFilePath");
|
|
33
34
|
if (!STORY_FILE_PATTERN.test(storyFilePath)) throw new Error("storyFilePath must name a .stories.ts or .stories.tsx file");
|
|
@@ -190,9 +191,12 @@ const WARM_RENDERER_TOOLS = {
|
|
|
190
191
|
list_shared_components: require_stdio.STYLE_SYSTEM_TYPES.ListSharedComponentsTool,
|
|
191
192
|
list_app_components: require_stdio.STYLE_SYSTEM_TYPES.ListAppComponentsTool
|
|
192
193
|
};
|
|
194
|
+
/** Long enough to cover an edit-and-render loop; an idle dev server still holds its module graph and watchers. */
|
|
195
|
+
const IDLE_CLOSE_MS = 6e5;
|
|
193
196
|
/**
|
|
194
197
|
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
195
198
|
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
199
|
+
* After IDLE_CLOSE_MS without a call it stops them; the next call starts them again.
|
|
196
200
|
*/
|
|
197
201
|
function createWarmStoryRenderer(options = {}) {
|
|
198
202
|
const workspaceRoot = options.workspaceRoot ? node_path.default.resolve(options.workspaceRoot) : void 0;
|
|
@@ -220,6 +224,8 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
220
224
|
let queue = Promise.resolve();
|
|
221
225
|
let disposed = false;
|
|
222
226
|
let captures = 0;
|
|
227
|
+
let inFlight = 0;
|
|
228
|
+
let idleTimer;
|
|
223
229
|
const ensureDevServer = async (appPath) => {
|
|
224
230
|
const resolved = node_path.default.resolve(workspaceRoot ?? ".", appPath);
|
|
225
231
|
const { config } = await configLoader.resolveProject(resolved);
|
|
@@ -290,19 +296,30 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
290
296
|
isError: result.isError === true
|
|
291
297
|
};
|
|
292
298
|
};
|
|
299
|
+
const enqueue = (task) => {
|
|
300
|
+
const next = queue.then(task);
|
|
301
|
+
queue = next.catch(() => void 0);
|
|
302
|
+
return next;
|
|
303
|
+
};
|
|
304
|
+
const armIdleClose = () => {
|
|
305
|
+
if (--inFlight > 0 || disposed) return;
|
|
306
|
+
idleTimer = setTimeout(() => void enqueue(reset), IDLE_CLOSE_MS);
|
|
307
|
+
idleTimer.unref();
|
|
308
|
+
};
|
|
293
309
|
return {
|
|
294
310
|
call(tool, input) {
|
|
295
|
-
|
|
296
|
-
|
|
311
|
+
clearTimeout(idleTimer);
|
|
312
|
+
inFlight++;
|
|
313
|
+
const next = enqueue(() => run(tool, input));
|
|
314
|
+
next.then(armIdleClose, armIdleClose);
|
|
297
315
|
return next;
|
|
298
316
|
},
|
|
299
317
|
restart() {
|
|
300
|
-
|
|
301
|
-
queue = next.catch(() => void 0);
|
|
302
|
-
return next;
|
|
318
|
+
return enqueue(reset);
|
|
303
319
|
},
|
|
304
320
|
async dispose() {
|
|
305
321
|
disposed = true;
|
|
322
|
+
clearTimeout(idleTimer);
|
|
306
323
|
await queue;
|
|
307
324
|
await reset();
|
|
308
325
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -478,10 +478,10 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
478
478
|
* Get Vite resolve configuration for the given app path.
|
|
479
479
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
480
480
|
*/
|
|
481
|
-
protected getViteResolveConfig(appPath: string): {
|
|
481
|
+
protected getViteResolveConfig(appPath: string): Promise<{
|
|
482
482
|
alias: AliasOptions;
|
|
483
483
|
extensions?: string[];
|
|
484
|
-
}
|
|
484
|
+
}>;
|
|
485
485
|
/**
|
|
486
486
|
* Get Vite define replacements.
|
|
487
487
|
* Subclasses can override to provide platform globals.
|
|
@@ -506,7 +506,7 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
506
506
|
* Get additional Vite plugins.
|
|
507
507
|
* Subclasses can override to add platform-specific plugins (e.g., @vitejs/plugin-react).
|
|
508
508
|
*/
|
|
509
|
-
protected getAdditionalVitePlugins(_appPath?: string): Plugin[]
|
|
509
|
+
protected getAdditionalVitePlugins(_appPath?: string): Plugin[] | Promise<Plugin[]>;
|
|
510
510
|
/**
|
|
511
511
|
* Clean up server resources and reset state.
|
|
512
512
|
* Closes the Vite dev server if running.
|
|
@@ -563,7 +563,7 @@ export declare class ViteReactNativeBundlerService extends ViteReactBundlerServi
|
|
|
563
563
|
private static nativeInstance;
|
|
564
564
|
static getInstance(): ViteReactNativeBundlerService;
|
|
565
565
|
getBundlerId(): string;
|
|
566
|
-
protected getAdditionalVitePlugins(appPath?: string): Plugin[]
|
|
566
|
+
protected getAdditionalVitePlugins(appPath?: string): Promise<Plugin[]>;
|
|
567
567
|
protected generateFrameworkSetupImports(options: BuildOptions): string;
|
|
568
568
|
protected generateStoryImport(componentPath: string): string;
|
|
569
569
|
protected wrapFrameworkElement(elementExpression: string): string;
|
|
@@ -571,10 +571,10 @@ export declare class ViteReactNativeBundlerService extends ViteReactBundlerServi
|
|
|
571
571
|
protected getViteOxcConfig(): false;
|
|
572
572
|
protected getViteDefineConfig(): UserConfig['define'];
|
|
573
573
|
protected generatePreviewStyles(): string;
|
|
574
|
-
protected getViteResolveConfig(appPath: string): {
|
|
574
|
+
protected getViteResolveConfig(appPath: string): Promise<{
|
|
575
575
|
alias: AliasOptions;
|
|
576
576
|
extensions?: string[];
|
|
577
|
-
}
|
|
577
|
+
}>;
|
|
578
578
|
}
|
|
579
579
|
//#endregion
|
|
580
580
|
//#region src/services/BundlerService/BundlerServiceFactory.d.ts
|
|
@@ -1180,7 +1180,7 @@ interface StoryPreviewServiceOptions {
|
|
|
1180
1180
|
//#region src/services/StoryPreviewService/StoryPreviewService.d.ts
|
|
1181
1181
|
/** Builds and owns disposable, self-contained HTML previews for exact story exports. */
|
|
1182
1182
|
export declare class StoryPreviewService {
|
|
1183
|
-
private
|
|
1183
|
+
private workspaceRoot;
|
|
1184
1184
|
private readonly storiesIndexFactory;
|
|
1185
1185
|
private readonly configLoader;
|
|
1186
1186
|
private readonly bundlerFactory;
|
|
@@ -2121,6 +2121,7 @@ interface WarmStoryRenderer {
|
|
|
2121
2121
|
/**
|
|
2122
2122
|
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
2123
2123
|
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
2124
|
+
* After IDLE_CLOSE_MS without a call it stops them; the next call starts them again.
|
|
2124
2125
|
*/
|
|
2125
2126
|
export declare function createWarmStoryRenderer(options?: {
|
|
2126
2127
|
workspaceRoot?: string;
|
package/dist/index.d.mts
CHANGED
|
@@ -478,10 +478,10 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
478
478
|
* Get Vite resolve configuration for the given app path.
|
|
479
479
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
480
480
|
*/
|
|
481
|
-
protected getViteResolveConfig(appPath: string): {
|
|
481
|
+
protected getViteResolveConfig(appPath: string): Promise<{
|
|
482
482
|
alias: AliasOptions;
|
|
483
483
|
extensions?: string[];
|
|
484
|
-
}
|
|
484
|
+
}>;
|
|
485
485
|
/**
|
|
486
486
|
* Get Vite define replacements.
|
|
487
487
|
* Subclasses can override to provide platform globals.
|
|
@@ -506,7 +506,7 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
506
506
|
* Get additional Vite plugins.
|
|
507
507
|
* Subclasses can override to add platform-specific plugins (e.g., @vitejs/plugin-react).
|
|
508
508
|
*/
|
|
509
|
-
protected getAdditionalVitePlugins(_appPath?: string): Plugin[]
|
|
509
|
+
protected getAdditionalVitePlugins(_appPath?: string): Plugin[] | Promise<Plugin[]>;
|
|
510
510
|
/**
|
|
511
511
|
* Clean up server resources and reset state.
|
|
512
512
|
* Closes the Vite dev server if running.
|
|
@@ -563,7 +563,7 @@ export declare class ViteReactNativeBundlerService extends ViteReactBundlerServi
|
|
|
563
563
|
private static nativeInstance;
|
|
564
564
|
static getInstance(): ViteReactNativeBundlerService;
|
|
565
565
|
getBundlerId(): string;
|
|
566
|
-
protected getAdditionalVitePlugins(appPath?: string): Plugin[]
|
|
566
|
+
protected getAdditionalVitePlugins(appPath?: string): Promise<Plugin[]>;
|
|
567
567
|
protected generateFrameworkSetupImports(options: BuildOptions): string;
|
|
568
568
|
protected generateStoryImport(componentPath: string): string;
|
|
569
569
|
protected wrapFrameworkElement(elementExpression: string): string;
|
|
@@ -571,10 +571,10 @@ export declare class ViteReactNativeBundlerService extends ViteReactBundlerServi
|
|
|
571
571
|
protected getViteOxcConfig(): false;
|
|
572
572
|
protected getViteDefineConfig(): UserConfig['define'];
|
|
573
573
|
protected generatePreviewStyles(): string;
|
|
574
|
-
protected getViteResolveConfig(appPath: string): {
|
|
574
|
+
protected getViteResolveConfig(appPath: string): Promise<{
|
|
575
575
|
alias: AliasOptions;
|
|
576
576
|
extensions?: string[];
|
|
577
|
-
}
|
|
577
|
+
}>;
|
|
578
578
|
}
|
|
579
579
|
//#endregion
|
|
580
580
|
//#region src/services/BundlerService/BundlerServiceFactory.d.ts
|
|
@@ -1180,7 +1180,7 @@ interface StoryPreviewServiceOptions {
|
|
|
1180
1180
|
//#region src/services/StoryPreviewService/StoryPreviewService.d.ts
|
|
1181
1181
|
/** Builds and owns disposable, self-contained HTML previews for exact story exports. */
|
|
1182
1182
|
export declare class StoryPreviewService {
|
|
1183
|
-
private
|
|
1183
|
+
private workspaceRoot;
|
|
1184
1184
|
private readonly storiesIndexFactory;
|
|
1185
1185
|
private readonly configLoader;
|
|
1186
1186
|
private readonly bundlerFactory;
|
|
@@ -2121,6 +2121,7 @@ interface WarmStoryRenderer {
|
|
|
2121
2121
|
/**
|
|
2122
2122
|
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
2123
2123
|
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
2124
|
+
* After IDLE_CLOSE_MS without a call it stops them; the next call starts them again.
|
|
2124
2125
|
*/
|
|
2125
2126
|
export declare function createWarmStoryRenderer(options?: {
|
|
2126
2127
|
workspaceRoot?: string;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as resolveStyleSystemThemePath, B as STYLE_SYSTEM_TYPES, C as launchBrowserWithFallback, D as resetStyleSystemConfigCache, E as hasStyleSystemProjectConfig, F as TailwindCSSClassesService, I as BaseCSSClassesService, L as TemplatesManagerService, M as StoriesIndexService, N as CSSClassesServiceFactory, O as resolveAppDesignSystemConfig, P as DEFAULT_STYLE_SYSTEM_CONFIG, R as isContained, S as BaseBundlerService, T as getSharedComponentTags, _ as createDefaultBundlerService, b as ViteReactNativeBundlerService, c as createStyleSystemModule, d as GetComponentVisualTool, f as GetCSSClassesTool, g as ThemeService, h as ComponentRendererService, i as createServer, j as MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION, k as StyleSystemConfigLoader, l as ListAppComponentsTool, m as GetUiComponentService, n as extractCustomTokenNames, p as ListThemesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListSharedComponentsTool, v as getBundlerService, w as getAppDesignSystemConfig, x as ViteReactBundlerService, y as getBundlerServiceFromConfig, z as log } from "./stdio-
|
|
1
|
+
import { A as resolveStyleSystemThemePath, B as STYLE_SYSTEM_TYPES, C as launchBrowserWithFallback, D as resetStyleSystemConfigCache, E as hasStyleSystemProjectConfig, F as TailwindCSSClassesService, I as BaseCSSClassesService, L as TemplatesManagerService, M as StoriesIndexService, N as CSSClassesServiceFactory, O as resolveAppDesignSystemConfig, P as DEFAULT_STYLE_SYSTEM_CONFIG, R as isContained, S as BaseBundlerService, T as getSharedComponentTags, _ as createDefaultBundlerService, b as ViteReactNativeBundlerService, c as createStyleSystemModule, d as GetComponentVisualTool, f as GetCSSClassesTool, g as ThemeService, h as ComponentRendererService, i as createServer, j as MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION, k as StyleSystemConfigLoader, l as ListAppComponentsTool, m as GetUiComponentService, n as extractCustomTokenNames, p as ListThemesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListSharedComponentsTool, v as getBundlerService, w as getAppDesignSystemConfig, x as ViteReactBundlerService, y as getBundlerServiceFromConfig, z as log } from "./stdio-B12YYINp.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -14,7 +14,7 @@ var StoryPreviewService = class {
|
|
|
14
14
|
bundlerFactory;
|
|
15
15
|
previews = /* @__PURE__ */ new Map();
|
|
16
16
|
constructor(options = {}) {
|
|
17
|
-
this.workspaceRoot = path.resolve(options.workspaceRoot
|
|
17
|
+
this.workspaceRoot = options.workspaceRoot !== void 0 ? Promise.resolve(path.resolve(options.workspaceRoot)) : void 0;
|
|
18
18
|
this.storiesIndexFactory = options.storiesIndexFactory ?? ((workspaceRoot, storyFilePath) => new StoriesIndexService({
|
|
19
19
|
workspaceRoot,
|
|
20
20
|
storyFiles: [storyFilePath],
|
|
@@ -25,7 +25,8 @@ var StoryPreviewService = class {
|
|
|
25
25
|
}
|
|
26
26
|
async build(input) {
|
|
27
27
|
if (!STORY_EXPORT_PATTERN.test(input.storyExport)) throw new Error("storyExport must be an exact JavaScript named export");
|
|
28
|
-
const
|
|
28
|
+
const root = await (this.workspaceRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
29
|
+
const workspaceRoot = await promises.realpath(root);
|
|
29
30
|
const appPath = await this.resolveContainedPath(workspaceRoot, input.appPath, "appPath");
|
|
30
31
|
const storyFilePath = await this.resolveContainedPath(workspaceRoot, input.storyFilePath, "storyFilePath");
|
|
31
32
|
if (!STORY_FILE_PATTERN.test(storyFilePath)) throw new Error("storyFilePath must name a .stories.ts or .stories.tsx file");
|
|
@@ -188,9 +189,12 @@ const WARM_RENDERER_TOOLS = {
|
|
|
188
189
|
list_shared_components: STYLE_SYSTEM_TYPES.ListSharedComponentsTool,
|
|
189
190
|
list_app_components: STYLE_SYSTEM_TYPES.ListAppComponentsTool
|
|
190
191
|
};
|
|
192
|
+
/** Long enough to cover an edit-and-render loop; an idle dev server still holds its module graph and watchers. */
|
|
193
|
+
const IDLE_CLOSE_MS = 6e5;
|
|
191
194
|
/**
|
|
192
195
|
* Keeps one browser and one Vite dev server warm across renders, so a render after the first
|
|
193
196
|
* skips the browser launch and the static build. Rendered screenshots come back as base64.
|
|
197
|
+
* After IDLE_CLOSE_MS without a call it stops them; the next call starts them again.
|
|
194
198
|
*/
|
|
195
199
|
function createWarmStoryRenderer(options = {}) {
|
|
196
200
|
const workspaceRoot = options.workspaceRoot ? path.resolve(options.workspaceRoot) : void 0;
|
|
@@ -218,6 +222,8 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
218
222
|
let queue = Promise.resolve();
|
|
219
223
|
let disposed = false;
|
|
220
224
|
let captures = 0;
|
|
225
|
+
let inFlight = 0;
|
|
226
|
+
let idleTimer;
|
|
221
227
|
const ensureDevServer = async (appPath) => {
|
|
222
228
|
const resolved = path.resolve(workspaceRoot ?? ".", appPath);
|
|
223
229
|
const { config } = await configLoader.resolveProject(resolved);
|
|
@@ -288,19 +294,30 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
288
294
|
isError: result.isError === true
|
|
289
295
|
};
|
|
290
296
|
};
|
|
297
|
+
const enqueue = (task) => {
|
|
298
|
+
const next = queue.then(task);
|
|
299
|
+
queue = next.catch(() => void 0);
|
|
300
|
+
return next;
|
|
301
|
+
};
|
|
302
|
+
const armIdleClose = () => {
|
|
303
|
+
if (--inFlight > 0 || disposed) return;
|
|
304
|
+
idleTimer = setTimeout(() => void enqueue(reset), IDLE_CLOSE_MS);
|
|
305
|
+
idleTimer.unref();
|
|
306
|
+
};
|
|
291
307
|
return {
|
|
292
308
|
call(tool, input) {
|
|
293
|
-
|
|
294
|
-
|
|
309
|
+
clearTimeout(idleTimer);
|
|
310
|
+
inFlight++;
|
|
311
|
+
const next = enqueue(() => run(tool, input));
|
|
312
|
+
next.then(armIdleClose, armIdleClose);
|
|
295
313
|
return next;
|
|
296
314
|
},
|
|
297
315
|
restart() {
|
|
298
|
-
|
|
299
|
-
queue = next.catch(() => void 0);
|
|
300
|
-
return next;
|
|
316
|
+
return enqueue(reset);
|
|
301
317
|
},
|
|
302
318
|
async dispose() {
|
|
303
319
|
disposed = true;
|
|
320
|
+
clearTimeout(idleTimer);
|
|
304
321
|
await queue;
|
|
305
322
|
await reset();
|
|
306
323
|
}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
2
|
import { Container, ContainerModule, inject, injectable, optional } from "inversify";
|
|
3
|
-
import {
|
|
3
|
+
import { promises } from "node:fs";
|
|
4
4
|
import * as path$1 from "node:path";
|
|
5
5
|
import path, { dirname } from "node:path";
|
|
6
6
|
import os, * as os$1 from "node:os";
|
|
7
7
|
import pino from "pino";
|
|
8
8
|
import * as fs from "node:fs/promises";
|
|
9
|
-
import { writeFile } from "node:fs/promises";
|
|
10
|
-
import * as yaml from "js-yaml";
|
|
9
|
+
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
11
10
|
import postcss from "postcss";
|
|
12
11
|
import { createHash, randomUUID } from "node:crypto";
|
|
13
12
|
import { loadCsf } from "storybook/internal/csf-tools";
|
|
14
13
|
import { glob } from "glob";
|
|
14
|
+
import * as yaml from "js-yaml";
|
|
15
15
|
import { z } from "zod";
|
|
16
16
|
import { chromium, firefox, webkit } from "playwright";
|
|
17
17
|
import tailwindcss from "@tailwindcss/vite";
|
|
@@ -20,9 +20,6 @@ import { fileURLToPath } from "node:url";
|
|
|
20
20
|
import react from "@vitejs/plugin-react";
|
|
21
21
|
import { Server } from "@modelcontextprotocol/server";
|
|
22
22
|
import { serveStdio } from "@modelcontextprotocol/server/stdio";
|
|
23
|
-
//#region \0rolldown/runtime.js
|
|
24
|
-
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
25
|
-
//#endregion
|
|
26
23
|
//#region src/container/types.ts
|
|
27
24
|
const STYLE_SYSTEM_TYPES = {
|
|
28
25
|
ListThemesTool: Symbol.for("StyleSystem:ListThemesTool"),
|
|
@@ -146,14 +143,6 @@ async function pathExists(filePath) {
|
|
|
146
143
|
return false;
|
|
147
144
|
}
|
|
148
145
|
}
|
|
149
|
-
function pathExistsSync(filePath) {
|
|
150
|
-
try {
|
|
151
|
-
accessSync(filePath);
|
|
152
|
-
return true;
|
|
153
|
-
} catch {
|
|
154
|
-
return false;
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
146
|
//#endregion
|
|
158
147
|
//#region src/utils/TemplatesManagerService.ts
|
|
159
148
|
var TemplatesManagerService = class TemplatesManagerService {
|
|
@@ -182,15 +171,6 @@ var TemplatesManagerService = class TemplatesManagerService {
|
|
|
182
171
|
currentPath = path.dirname(currentPath);
|
|
183
172
|
}
|
|
184
173
|
}
|
|
185
|
-
static findWorkspaceRootSync(startPath) {
|
|
186
|
-
let currentPath = path.resolve(startPath);
|
|
187
|
-
const rootPath = path.parse(currentPath).root;
|
|
188
|
-
while (true) {
|
|
189
|
-
if (pathExistsSync(path.join(currentPath, ".git"))) return currentPath;
|
|
190
|
-
if (currentPath === rootPath) return process.cwd();
|
|
191
|
-
currentPath = path.dirname(currentPath);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
174
|
static async readToolkitConfig(startPath = process.cwd()) {
|
|
195
175
|
const workspaceRoot = await TemplatesManagerService.findWorkspaceRoot(startPath);
|
|
196
176
|
const yaml = await import("js-yaml");
|
|
@@ -212,30 +192,9 @@ var TemplatesManagerService = class TemplatesManagerService {
|
|
|
212
192
|
const content = await fs.readFile(legacyConfigPath, "utf-8");
|
|
213
193
|
return yaml.load(content);
|
|
214
194
|
}
|
|
215
|
-
static readToolkitConfigSync(startPath = process.cwd()) {
|
|
216
|
-
const workspaceRoot = TemplatesManagerService.findWorkspaceRootSync(startPath);
|
|
217
|
-
const yaml = __require("js-yaml");
|
|
218
|
-
const toolkitFolder = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_FOLDER);
|
|
219
|
-
const settingsPath = path.join(toolkitFolder, TemplatesManagerService.SETTINGS_FILE);
|
|
220
|
-
const settingsLocalPath = path.join(toolkitFolder, TemplatesManagerService.SETTINGS_LOCAL_FILE);
|
|
221
|
-
if (pathExistsSync(settingsPath)) {
|
|
222
|
-
const base = yaml.load(readFileSync(settingsPath, "utf-8"));
|
|
223
|
-
if (pathExistsSync(settingsLocalPath)) {
|
|
224
|
-
const local = yaml.load(readFileSync(settingsLocalPath, "utf-8"));
|
|
225
|
-
return TemplatesManagerService.mergeToolkitConfigs(base, local);
|
|
226
|
-
}
|
|
227
|
-
return base;
|
|
228
|
-
}
|
|
229
|
-
const legacyConfigPath = path.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
|
|
230
|
-
if (!pathExistsSync(legacyConfigPath)) return null;
|
|
231
|
-
return yaml.load(readFileSync(legacyConfigPath, "utf-8"));
|
|
232
|
-
}
|
|
233
195
|
static async getWorkspaceRoot(startPath = process.cwd()) {
|
|
234
196
|
return TemplatesManagerService.findWorkspaceRoot(startPath);
|
|
235
197
|
}
|
|
236
|
-
static getWorkspaceRootSync(startPath = process.cwd()) {
|
|
237
|
-
return TemplatesManagerService.findWorkspaceRootSync(startPath);
|
|
238
|
-
}
|
|
239
198
|
};
|
|
240
199
|
//#endregion
|
|
241
200
|
//#region src/services/ThemeService/CSSThemeService.ts
|
|
@@ -280,7 +239,7 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
280
239
|
*/
|
|
281
240
|
constructor(config, workspaceRoot) {
|
|
282
241
|
super(config);
|
|
283
|
-
this.monorepoRoot = workspaceRoot
|
|
242
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
284
243
|
}
|
|
285
244
|
/**
|
|
286
245
|
* Get the source identifier for this service
|
|
@@ -299,7 +258,7 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
299
258
|
* @throws Error if no theme files are configured or files cannot be read
|
|
300
259
|
*/
|
|
301
260
|
async listThemes() {
|
|
302
|
-
const cssFilePaths = this.resolveCSSFilePaths();
|
|
261
|
+
const cssFilePaths = await this.resolveCSSFilePaths();
|
|
303
262
|
if (cssFilePaths.length === 0) throw new Error("No theme CSS files configured. Set themePath or cssFiles in style-system.config.yaml.");
|
|
304
263
|
const themes = [];
|
|
305
264
|
const results = await Promise.allSettled(cssFilePaths.map(async (cssFilePath) => {
|
|
@@ -319,14 +278,15 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
319
278
|
* Resolve configured CSS file paths to absolute paths.
|
|
320
279
|
* @returns Array of absolute CSS file paths
|
|
321
280
|
*/
|
|
322
|
-
resolveCSSFilePaths() {
|
|
281
|
+
async resolveCSSFilePaths() {
|
|
282
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
323
283
|
const paths = [];
|
|
324
284
|
if (this.config.themePath) {
|
|
325
|
-
const themePath = path.isAbsolute(this.config.themePath) ? this.config.themePath : path.join(
|
|
285
|
+
const themePath = path.isAbsolute(this.config.themePath) ? this.config.themePath : path.join(monorepoRoot, this.config.themePath);
|
|
326
286
|
paths.push(themePath);
|
|
327
287
|
}
|
|
328
288
|
if (this.config.cssFiles && this.config.cssFiles.length > 0) for (const cssFile of this.config.cssFiles) {
|
|
329
|
-
const cssPath = path.isAbsolute(cssFile) ? cssFile : path.join(
|
|
289
|
+
const cssPath = path.isAbsolute(cssFile) ? cssFile : path.join(monorepoRoot, cssFile);
|
|
330
290
|
if (!paths.includes(cssPath)) paths.push(cssPath);
|
|
331
291
|
}
|
|
332
292
|
return paths;
|
|
@@ -859,7 +819,7 @@ let CSSClassesServiceFactory = class CSSClassesServiceFactory {
|
|
|
859
819
|
async loadCustomService(config) {
|
|
860
820
|
const servicePath = config.customServicePath;
|
|
861
821
|
if (!servicePath) throw new Error("customServicePath is required for custom service loading");
|
|
862
|
-
const monorepoRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
822
|
+
const monorepoRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
863
823
|
const resolvedPath = path.resolve(monorepoRoot, servicePath);
|
|
864
824
|
const normalizedWorkspaceRoot = path.resolve(monorepoRoot);
|
|
865
825
|
if (!resolvedPath.startsWith(normalizedWorkspaceRoot + path.sep)) throw new Error(`Security error: customServicePath "${servicePath}" resolves outside workspace root`);
|
|
@@ -932,7 +892,7 @@ let StoriesIndexService = class StoriesIndexService {
|
|
|
932
892
|
*/
|
|
933
893
|
constructor(config = {}) {
|
|
934
894
|
this.config = config;
|
|
935
|
-
this.monorepoRoot = config.workspaceRoot ? path.resolve(config.workspaceRoot) :
|
|
895
|
+
this.monorepoRoot = config.workspaceRoot ? path.resolve(config.workspaceRoot) : "";
|
|
936
896
|
}
|
|
937
897
|
/**
|
|
938
898
|
* Initialize the index by scanning all .stories files.
|
|
@@ -940,7 +900,7 @@ let StoriesIndexService = class StoriesIndexService {
|
|
|
940
900
|
*/
|
|
941
901
|
async initialize() {
|
|
942
902
|
if (this.initialized && this.lastInitResult) return this.lastInitResult;
|
|
943
|
-
|
|
903
|
+
this.monorepoRoot = this.config.workspaceRoot ? await promises.realpath(this.monorepoRoot) : await TemplatesManagerService.getWorkspaceRoot();
|
|
944
904
|
log.info("[StoriesIndexService] Initializing story index...");
|
|
945
905
|
const storyFiles = await this.findStoryFiles();
|
|
946
906
|
log.info(`[StoriesIndexService] Found ${storyFiles.length} story files`);
|
|
@@ -1350,9 +1310,9 @@ const EXPO_APP_CONFIG_FILE = "app.json";
|
|
|
1350
1310
|
* values, and warns when it is the one that resolves.
|
|
1351
1311
|
*/
|
|
1352
1312
|
async function resolveStyleSystemThemePath(input) {
|
|
1353
|
-
const hostRoot = input.workspaceRoot ?? TemplatesManagerService.
|
|
1313
|
+
const hostRoot = input.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
1354
1314
|
const resolvedAppPath = input.appPath ? path.isAbsolute(input.appPath) ? path.normalize(input.appPath) : path.join(hostRoot, input.appPath) : hostRoot;
|
|
1355
|
-
const monorepoRoot = input.workspaceRoot ?? (input.appPath ? TemplatesManagerService.
|
|
1315
|
+
const monorepoRoot = input.workspaceRoot ?? (input.appPath ? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath) : hostRoot);
|
|
1356
1316
|
const workspaceCandidate = path.join(monorepoRoot, input.themePath);
|
|
1357
1317
|
const candidates = path.isAbsolute(input.themePath) ? [input.themePath] : [workspaceCandidate, path.resolve(resolvedAppPath, input.themePath)];
|
|
1358
1318
|
const uniqueCandidates = [...new Set(candidates)];
|
|
@@ -1418,7 +1378,8 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1418
1378
|
this.projectCache.clear();
|
|
1419
1379
|
}
|
|
1420
1380
|
/** Load and cache the workspace root config. */
|
|
1421
|
-
async loadRoot(workspaceRoot
|
|
1381
|
+
async loadRoot(workspaceRoot) {
|
|
1382
|
+
workspaceRoot ??= this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
1422
1383
|
let pending = this.rootPromises.get(workspaceRoot);
|
|
1423
1384
|
if (!pending) {
|
|
1424
1385
|
pending = this.readRoot(workspaceRoot);
|
|
@@ -1434,8 +1395,8 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1434
1395
|
/** Resolve the merged configuration for a project. */
|
|
1435
1396
|
async resolveProject(appPath) {
|
|
1436
1397
|
if (!appPath || typeof appPath !== "string") throw new Error("appPath is required and must be a non-empty string");
|
|
1437
|
-
const resolvedAppPath = path.isAbsolute(appPath) ? path.normalize(appPath) : path.join(this.workspaceRoot ?? TemplatesManagerService.
|
|
1438
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
1398
|
+
const resolvedAppPath = path.isAbsolute(appPath) ? path.normalize(appPath) : path.join(this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(), appPath);
|
|
1399
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath);
|
|
1439
1400
|
const cached = this.projectCache.get(resolvedAppPath);
|
|
1440
1401
|
if (cached) return cached;
|
|
1441
1402
|
const pending = this.readProject(resolvedAppPath, workspaceRoot);
|
|
@@ -2062,7 +2023,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2062
2023
|
constructor(config = {}, workspaceRoot) {
|
|
2063
2024
|
super(config);
|
|
2064
2025
|
this.workspaceRoot = workspaceRoot;
|
|
2065
|
-
this.monorepoRoot = workspaceRoot
|
|
2026
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
2066
2027
|
}
|
|
2067
2028
|
/**
|
|
2068
2029
|
* Get the singleton instance of ViteReactBundlerService.
|
|
@@ -2137,7 +2098,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2137
2098
|
* @throws Error if server fails to start
|
|
2138
2099
|
*/
|
|
2139
2100
|
async startDevServer(appPath) {
|
|
2140
|
-
const
|
|
2101
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2102
|
+
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(monorepoRoot, appPath);
|
|
2141
2103
|
if (this.isServerRunning() && this.currentAppPath === resolvedAppPath) {
|
|
2142
2104
|
log.info(`[ViteReactBundlerService] Server already running for ${resolvedAppPath}`);
|
|
2143
2105
|
return {
|
|
@@ -2177,7 +2139,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2177
2139
|
plugins: [
|
|
2178
2140
|
tailwindcss(),
|
|
2179
2141
|
createTanStackStartStubPlugin(),
|
|
2180
|
-
...this.getAdditionalVitePlugins(resolvedAppPath),
|
|
2142
|
+
...await this.getAdditionalVitePlugins(resolvedAppPath),
|
|
2181
2143
|
{
|
|
2182
2144
|
name: "style-system-preview-html",
|
|
2183
2145
|
configureServer: (server) => {
|
|
@@ -2207,7 +2169,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2207
2169
|
},
|
|
2208
2170
|
createStoryEntryPlugin((id) => this.storyConfigs.get(id), (opts) => this.generateEntryFile(opts))
|
|
2209
2171
|
],
|
|
2210
|
-
resolve: this.getViteResolveConfig(resolvedAppPath),
|
|
2172
|
+
resolve: await this.getViteResolveConfig(resolvedAppPath),
|
|
2211
2173
|
define: this.getViteDefineConfig(),
|
|
2212
2174
|
esbuild: this.getViteEsbuildConfig(),
|
|
2213
2175
|
oxc: this.getViteOxcConfig(),
|
|
@@ -2257,8 +2219,9 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2257
2219
|
validateStoryName(storyName);
|
|
2258
2220
|
validateComponentPath(componentPath);
|
|
2259
2221
|
validateArgsSize(args);
|
|
2260
|
-
const
|
|
2261
|
-
|
|
2222
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2223
|
+
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(monorepoRoot, appPath);
|
|
2224
|
+
validateCssFiles(cssFiles, this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath));
|
|
2262
2225
|
if (this.currentAppPath !== resolvedAppPath) throw new Error(`Dev server is running for ${this.currentAppPath} but requested ${resolvedAppPath}.`);
|
|
2263
2226
|
const tmpDir = path.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2264
2227
|
try {
|
|
@@ -2305,8 +2268,9 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2305
2268
|
validateStoryName(storyName);
|
|
2306
2269
|
validateComponentPath(componentPath);
|
|
2307
2270
|
validateArgsSize(args);
|
|
2308
|
-
const
|
|
2309
|
-
|
|
2271
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2272
|
+
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(monorepoRoot, appPath);
|
|
2273
|
+
validateCssFiles(cssFiles, this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath));
|
|
2310
2274
|
const tmpDir = path.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2311
2275
|
try {
|
|
2312
2276
|
await promises.mkdir(tmpDir, { recursive: true });
|
|
@@ -2331,8 +2295,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2331
2295
|
* Get Vite resolve configuration for the given app path.
|
|
2332
2296
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
2333
2297
|
*/
|
|
2334
|
-
getViteResolveConfig(appPath) {
|
|
2335
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
2298
|
+
async getViteResolveConfig(appPath) {
|
|
2299
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(appPath);
|
|
2336
2300
|
const frontendPackagePath = (packageDir, sourcePath = "index.ts") => path.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", packageDir, APP_SOURCE_DIR$1, sourcePath);
|
|
2337
2301
|
return { alias: [
|
|
2338
2302
|
...appReactAliases(appPath),
|
|
@@ -2442,7 +2406,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2442
2406
|
*/
|
|
2443
2407
|
async generateWrapperCss(appPath, cssFiles) {
|
|
2444
2408
|
const resolvedCssFiles = cssFiles.length > 0 ? cssFiles : await this.getDefaultCssFiles(appPath);
|
|
2445
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
2409
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(appPath);
|
|
2446
2410
|
const cssImportStatements = resolvedCssFiles.map((cssFile) => {
|
|
2447
2411
|
if (path.isAbsolute(cssFile)) return `@import '${cssFile}';`;
|
|
2448
2412
|
if (cssFile.startsWith(PACKAGE_IMPORT_PREFIX) || cssFile.startsWith(TAILWIND_IMPORT_PREFIX)) return `@import '${cssFile}';`;
|
|
@@ -2628,10 +2592,10 @@ mount();
|
|
|
2628
2592
|
tailwindcss(),
|
|
2629
2593
|
viteSingleFile(),
|
|
2630
2594
|
createTanStackStartStubPlugin(),
|
|
2631
|
-
...this.getAdditionalVitePlugins(appPath),
|
|
2595
|
+
...await this.getAdditionalVitePlugins(appPath),
|
|
2632
2596
|
createStoryEntryPlugin((id) => buildStoryConfigs.get(id), (opts) => this.generateEntryFile(opts))
|
|
2633
2597
|
],
|
|
2634
|
-
resolve: this.getViteResolveConfig(appPath),
|
|
2598
|
+
resolve: await this.getViteResolveConfig(appPath),
|
|
2635
2599
|
define: this.getViteDefineConfig(),
|
|
2636
2600
|
esbuild: this.getViteEsbuildConfig(),
|
|
2637
2601
|
oxc: this.getViteOxcConfig(),
|
|
@@ -2741,10 +2705,8 @@ const SHIMS_DIR_CANDIDATES = [
|
|
|
2741
2705
|
path.resolve(__dirname, "../shims"),
|
|
2742
2706
|
path.resolve(__dirname, "../src/shims")
|
|
2743
2707
|
];
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
const existing = candidates.find((candidate) => existsSync(candidate) && isValidDir(candidate));
|
|
2747
|
-
if (existing) return existing;
|
|
2708
|
+
async function resolveExistingDir(candidates, label, isValidDir) {
|
|
2709
|
+
for (const candidate of candidates) if (await isValidDir(candidate)) return candidate;
|
|
2748
2710
|
throw new Error(`Could not resolve ${label}. Tried: ${candidates.join(", ")}`);
|
|
2749
2711
|
}
|
|
2750
2712
|
function resolvePackageDirFrom(fromPath, packageName) {
|
|
@@ -2761,15 +2723,23 @@ function toViteImportPath(filePath) {
|
|
|
2761
2723
|
* matching TrueType font. Metadata-only glyph maps (e.g. `FontAwesome5Free_meta.json`)
|
|
2762
2724
|
* have no font and are skipped.
|
|
2763
2725
|
*/
|
|
2764
|
-
function resolveExpoVectorIconFamilies(appPath) {
|
|
2726
|
+
async function resolveExpoVectorIconFamilies(appPath) {
|
|
2765
2727
|
const packageDir = dirname(resolvePackageSubpathFrom(appPath, `${EXPO_VECTOR_ICONS_PREFIX}/${PACKAGE_JSON_SUBPATH}`));
|
|
2766
2728
|
const glyphMapDir = path.join(packageDir, EXPO_VECTOR_ICONS_GLYPHMAP_DIR);
|
|
2767
2729
|
const fontDir = path.join(packageDir, EXPO_VECTOR_ICONS_FONT_DIR);
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2730
|
+
const families = [];
|
|
2731
|
+
for (const entry of await readdir(glyphMapDir)) {
|
|
2732
|
+
if (!entry.endsWith(GLYPHMAP_EXTENSION)) continue;
|
|
2733
|
+
const family = entry.slice(0, -5);
|
|
2734
|
+
const fontPath = path.join(fontDir, `${family}${FONT_EXTENSION}`);
|
|
2735
|
+
if (!await pathExists(fontPath)) continue;
|
|
2736
|
+
families.push({
|
|
2737
|
+
family,
|
|
2738
|
+
fontPath: toViteImportPath(fontPath),
|
|
2739
|
+
glyphMapPath: toViteImportPath(path.join(glyphMapDir, entry))
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
return families;
|
|
2773
2743
|
}
|
|
2774
2744
|
function getExpoVectorIconsVirtualModuleId(source, families) {
|
|
2775
2745
|
if (source === EXPO_VECTOR_ICONS_PREFIX) return `${EXPO_VECTOR_ICONS_RESOLVED_MODULE_PREFIX}/index`;
|
|
@@ -2802,13 +2772,20 @@ function createSvgComponentPlugin() {
|
|
|
2802
2772
|
return {
|
|
2803
2773
|
name: SVG_COMPONENT_PLUGIN_NAME,
|
|
2804
2774
|
enforce: VITE_PLUGIN_ENFORCE_PRE,
|
|
2805
|
-
load(id) {
|
|
2775
|
+
async load(id) {
|
|
2806
2776
|
const [filePath] = id.split(VITE_QUERY_SEPARATOR);
|
|
2807
|
-
if (!filePath?.endsWith(SVG_EXTENSION)
|
|
2777
|
+
if (!filePath?.endsWith(SVG_EXTENSION)) return null;
|
|
2778
|
+
let content;
|
|
2779
|
+
try {
|
|
2780
|
+
content = await readFile(filePath);
|
|
2781
|
+
} catch (error) {
|
|
2782
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
2783
|
+
throw error;
|
|
2784
|
+
}
|
|
2808
2785
|
return `
|
|
2809
2786
|
import React from 'react';
|
|
2810
2787
|
|
|
2811
|
-
const svgSource = '${`${SVG_DATA_URI_PREFIX}${
|
|
2788
|
+
const svgSource = '${`${SVG_DATA_URI_PREFIX}${content.toString(BASE64_ENCODING)}`}';
|
|
2812
2789
|
|
|
2813
2790
|
function normalizeStyle(style) {
|
|
2814
2791
|
if (Array.isArray(style)) return Object.assign({}, ...style.filter(Boolean));
|
|
@@ -2879,8 +2856,8 @@ function createNativeBabelTransformPlugin(appPath) {
|
|
|
2879
2856
|
}
|
|
2880
2857
|
};
|
|
2881
2858
|
}
|
|
2882
|
-
function createExpoVectorIconsVirtualModule(appPath) {
|
|
2883
|
-
const iconFamilies = resolveExpoVectorIconFamilies(appPath);
|
|
2859
|
+
async function createExpoVectorIconsVirtualModule(appPath) {
|
|
2860
|
+
const iconFamilies = await resolveExpoVectorIconFamilies(appPath);
|
|
2884
2861
|
const iconFamilyNames = new Set(iconFamilies.map(({ family }) => family));
|
|
2885
2862
|
const assetImports = iconFamilies.map(({ family, fontPath, glyphMapPath }) => `import ${family}FontUrl from '${fontPath}?url';\n import ${family}GlyphMap from '${glyphMapPath}';`).join("\n ");
|
|
2886
2863
|
return {
|
|
@@ -2972,8 +2949,8 @@ function createExpoVectorIconsVirtualModule(appPath) {
|
|
|
2972
2949
|
function resolveShimsDir() {
|
|
2973
2950
|
return resolveExistingDir(SHIMS_DIR_CANDIDATES, REACT_NATIVE_VISUAL_RENDER_SHIMS_LABEL, hasRequiredReactNativeShims);
|
|
2974
2951
|
}
|
|
2975
|
-
function hasRequiredReactNativeShims(candidate) {
|
|
2976
|
-
return REQUIRED_REACT_NATIVE_SHIM_FILES.
|
|
2952
|
+
async function hasRequiredReactNativeShims(candidate) {
|
|
2953
|
+
return (await Promise.all(REQUIRED_REACT_NATIVE_SHIM_FILES.map((shimFile) => pathExists(path.join(candidate, shimFile))))).every(Boolean);
|
|
2977
2954
|
}
|
|
2978
2955
|
var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends ViteReactBundlerService {
|
|
2979
2956
|
static nativeInstance = null;
|
|
@@ -2984,7 +2961,7 @@ var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends
|
|
|
2984
2961
|
getBundlerId() {
|
|
2985
2962
|
return VITE_REACT_NATIVE_BUNDLER_ID;
|
|
2986
2963
|
}
|
|
2987
|
-
getAdditionalVitePlugins(appPath) {
|
|
2964
|
+
async getAdditionalVitePlugins(appPath) {
|
|
2988
2965
|
return [
|
|
2989
2966
|
{
|
|
2990
2967
|
name: REACT_NATIVE_OPTIMIZE_DEPS_PLUGIN_NAME,
|
|
@@ -3002,7 +2979,7 @@ var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends
|
|
|
3002
2979
|
},
|
|
3003
2980
|
createExpoTypeDeclarationStubPlugin(),
|
|
3004
2981
|
createSvgComponentPlugin(),
|
|
3005
|
-
...appPath ? [createExpoVectorIconsVirtualModule(appPath)] : [],
|
|
2982
|
+
...appPath ? [await createExpoVectorIconsVirtualModule(appPath)] : [],
|
|
3006
2983
|
...appPath ? [createNativeBabelTransformPlugin(appPath)] : [],
|
|
3007
2984
|
...react()
|
|
3008
2985
|
];
|
|
@@ -3057,7 +3034,8 @@ const styleSystemSafeAreaMetrics = {
|
|
|
3057
3034
|
min-height: 100vh;
|
|
3058
3035
|
}`;
|
|
3059
3036
|
}
|
|
3060
|
-
getViteResolveConfig(appPath) {
|
|
3037
|
+
async getViteResolveConfig(appPath) {
|
|
3038
|
+
const shimsDir = await resolveShimsDir();
|
|
3061
3039
|
const reactNativeUnistylesDir = resolvePackageDirFrom(appPath, REACT_NATIVE_UNISTYLES_PACKAGE);
|
|
3062
3040
|
const reactNativeUnistylesEntry = path.join(reactNativeUnistylesDir, REACT_NATIVE_UNISTYLES_WEB_INDEX);
|
|
3063
3041
|
const reactNativeWebDir = resolvePackageDirFrom(appPath, REACT_NATIVE_WEB_PACKAGE);
|
|
@@ -3083,7 +3061,7 @@ const styleSystemSafeAreaMetrics = {
|
|
|
3083
3061
|
},
|
|
3084
3062
|
{
|
|
3085
3063
|
find: EXPO_SYMBOLS_PACKAGE,
|
|
3086
|
-
replacement: path.join(
|
|
3064
|
+
replacement: path.join(shimsDir, EXPO_SYMBOLS_SHIM_FILE)
|
|
3087
3065
|
},
|
|
3088
3066
|
{
|
|
3089
3067
|
find: STORYBOOK_REACT_NATIVE_PACKAGE,
|
|
@@ -3217,7 +3195,7 @@ async function loadBundlerServiceFromConfig(options) {
|
|
|
3217
3195
|
cachedBundlerService = fallback();
|
|
3218
3196
|
return cachedBundlerService;
|
|
3219
3197
|
}
|
|
3220
|
-
const monorepoRoot = options?.workspaceRoot ?? TemplatesManagerService.
|
|
3198
|
+
const monorepoRoot = options?.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
3221
3199
|
const customServicePath = path.resolve(monorepoRoot, config.customService);
|
|
3222
3200
|
const normalizedWorkspaceRoot = path.resolve(monorepoRoot);
|
|
3223
3201
|
if (!customServicePath.startsWith(normalizedWorkspaceRoot + path.sep)) {
|
|
@@ -3306,7 +3284,7 @@ var ThemeService = class {
|
|
|
3306
3284
|
* @param config - Design system configuration
|
|
3307
3285
|
*/
|
|
3308
3286
|
constructor(config, workspaceRoot) {
|
|
3309
|
-
this.monorepoRoot = workspaceRoot
|
|
3287
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
3310
3288
|
this.config = config;
|
|
3311
3289
|
if (this.config.themeProvider) log.info(`[ThemeService] Using theme provider: ${this.config.themeProvider}`);
|
|
3312
3290
|
log.info(`[ThemeService] Design system type: ${this.config.type}`);
|
|
@@ -3323,12 +3301,13 @@ var ThemeService = class {
|
|
|
3323
3301
|
* @returns Array of absolute paths to CSS files
|
|
3324
3302
|
*/
|
|
3325
3303
|
async getThemeCSS() {
|
|
3326
|
-
|
|
3304
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
3305
|
+
if (this.config.cssFiles && this.config.cssFiles.length > 0) return this.config.cssFiles.map((cssFile) => path.isAbsolute(cssFile) ? cssFile : path.join(monorepoRoot, cssFile));
|
|
3327
3306
|
const cssPatterns = ["**/packages/frontend/web-theme/src/**/*.css", "**/packages/frontend/shared-theme/**/*.css"];
|
|
3328
3307
|
const cssFiles = [];
|
|
3329
3308
|
for (const pattern of cssPatterns) {
|
|
3330
3309
|
const files = await glob(pattern, {
|
|
3331
|
-
cwd:
|
|
3310
|
+
cwd: monorepoRoot,
|
|
3332
3311
|
absolute: true,
|
|
3333
3312
|
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
3334
3313
|
});
|
|
@@ -3417,7 +3396,8 @@ export { WrappedComponent };
|
|
|
3417
3396
|
* @throws Error if themes directory cannot be read
|
|
3418
3397
|
*/
|
|
3419
3398
|
async listAvailableThemes() {
|
|
3420
|
-
const
|
|
3399
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
3400
|
+
const configsPath = path.join(monorepoRoot, "packages/frontend/shared-theme/configs");
|
|
3421
3401
|
try {
|
|
3422
3402
|
const themeFiles = (await promises.readdir(configsPath)).filter((file) => file.endsWith(JSON_FILE_EXTENSION));
|
|
3423
3403
|
const themes = [];
|
|
@@ -3952,7 +3932,7 @@ let AppComponentsService = class AppComponentsService {
|
|
|
3952
3932
|
if (input.cursor !== void 0 && typeof input.cursor !== "string") throw new Error("cursor must be a string");
|
|
3953
3933
|
const { appPath, cursor } = input;
|
|
3954
3934
|
const { offset } = cursor ? this.decodeCursor(cursor) : { offset: 0 };
|
|
3955
|
-
const monorepoRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
3935
|
+
const monorepoRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
3956
3936
|
const resolvedAppPath = path.isAbsolute(appPath) ? appPath : path.join(monorepoRoot, appPath);
|
|
3957
3937
|
try {
|
|
3958
3938
|
await promises.access(resolvedAppPath);
|
|
@@ -4225,7 +4205,8 @@ let ListThemesTool = class ListThemesTool {
|
|
|
4225
4205
|
themePath: appConfig.themePath,
|
|
4226
4206
|
workspaceRoot: this.configLoader?.workspaceRoot
|
|
4227
4207
|
}) : void 0;
|
|
4228
|
-
|
|
4208
|
+
const workspaceRoot = this.configLoader?.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
4209
|
+
cssFiles = themePath ? void 0 : appConfig.cssFiles?.map((file) => path.resolve(workspaceRoot, input.appPath, file));
|
|
4229
4210
|
}
|
|
4230
4211
|
const result = await (await this.serviceFactory.createService({
|
|
4231
4212
|
themePath,
|
|
@@ -4733,7 +4714,7 @@ function createContainer(options) {
|
|
|
4733
4714
|
}
|
|
4734
4715
|
//#endregion
|
|
4735
4716
|
//#region package.json
|
|
4736
|
-
var version = "0.2.14-alpha.
|
|
4717
|
+
var version = "0.2.14-alpha.29";
|
|
4737
4718
|
//#endregion
|
|
4738
4719
|
//#region src/metadata.ts
|
|
4739
4720
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -30,13 +30,13 @@ let pino = require("pino");
|
|
|
30
30
|
pino = __toESM(pino, 1);
|
|
31
31
|
let node_fs_promises = require("node:fs/promises");
|
|
32
32
|
node_fs_promises = __toESM(node_fs_promises, 1);
|
|
33
|
-
let js_yaml = require("js-yaml");
|
|
34
|
-
js_yaml = __toESM(js_yaml, 1);
|
|
35
33
|
let postcss = require("postcss");
|
|
36
34
|
postcss = __toESM(postcss, 1);
|
|
37
35
|
let node_crypto = require("node:crypto");
|
|
38
36
|
let storybook_internal_csf_tools = require("storybook/internal/csf-tools");
|
|
39
37
|
let glob = require("glob");
|
|
38
|
+
let js_yaml = require("js-yaml");
|
|
39
|
+
js_yaml = __toESM(js_yaml, 1);
|
|
40
40
|
let zod = require("zod");
|
|
41
41
|
let playwright = require("playwright");
|
|
42
42
|
let node_module = require("node:module");
|
|
@@ -171,14 +171,6 @@ async function pathExists(filePath) {
|
|
|
171
171
|
return false;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
174
|
-
function pathExistsSync(filePath) {
|
|
175
|
-
try {
|
|
176
|
-
(0, node_fs.accessSync)(filePath);
|
|
177
|
-
return true;
|
|
178
|
-
} catch {
|
|
179
|
-
return false;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
174
|
//#endregion
|
|
183
175
|
//#region src/utils/TemplatesManagerService.ts
|
|
184
176
|
var TemplatesManagerService = class TemplatesManagerService {
|
|
@@ -207,15 +199,6 @@ var TemplatesManagerService = class TemplatesManagerService {
|
|
|
207
199
|
currentPath = node_path.default.dirname(currentPath);
|
|
208
200
|
}
|
|
209
201
|
}
|
|
210
|
-
static findWorkspaceRootSync(startPath) {
|
|
211
|
-
let currentPath = node_path.default.resolve(startPath);
|
|
212
|
-
const rootPath = node_path.default.parse(currentPath).root;
|
|
213
|
-
while (true) {
|
|
214
|
-
if (pathExistsSync(node_path.default.join(currentPath, ".git"))) return currentPath;
|
|
215
|
-
if (currentPath === rootPath) return process.cwd();
|
|
216
|
-
currentPath = node_path.default.dirname(currentPath);
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
202
|
static async readToolkitConfig(startPath = process.cwd()) {
|
|
220
203
|
const workspaceRoot = await TemplatesManagerService.findWorkspaceRoot(startPath);
|
|
221
204
|
const yaml = await import("js-yaml");
|
|
@@ -237,30 +220,9 @@ var TemplatesManagerService = class TemplatesManagerService {
|
|
|
237
220
|
const content = await node_fs_promises.readFile(legacyConfigPath, "utf-8");
|
|
238
221
|
return yaml.load(content);
|
|
239
222
|
}
|
|
240
|
-
static readToolkitConfigSync(startPath = process.cwd()) {
|
|
241
|
-
const workspaceRoot = TemplatesManagerService.findWorkspaceRootSync(startPath);
|
|
242
|
-
const yaml = require("js-yaml");
|
|
243
|
-
const toolkitFolder = node_path.default.join(workspaceRoot, TemplatesManagerService.TOOLKIT_FOLDER);
|
|
244
|
-
const settingsPath = node_path.default.join(toolkitFolder, TemplatesManagerService.SETTINGS_FILE);
|
|
245
|
-
const settingsLocalPath = node_path.default.join(toolkitFolder, TemplatesManagerService.SETTINGS_LOCAL_FILE);
|
|
246
|
-
if (pathExistsSync(settingsPath)) {
|
|
247
|
-
const base = yaml.load((0, node_fs.readFileSync)(settingsPath, "utf-8"));
|
|
248
|
-
if (pathExistsSync(settingsLocalPath)) {
|
|
249
|
-
const local = yaml.load((0, node_fs.readFileSync)(settingsLocalPath, "utf-8"));
|
|
250
|
-
return TemplatesManagerService.mergeToolkitConfigs(base, local);
|
|
251
|
-
}
|
|
252
|
-
return base;
|
|
253
|
-
}
|
|
254
|
-
const legacyConfigPath = node_path.default.join(workspaceRoot, TemplatesManagerService.TOOLKIT_CONFIG_FILE);
|
|
255
|
-
if (!pathExistsSync(legacyConfigPath)) return null;
|
|
256
|
-
return yaml.load((0, node_fs.readFileSync)(legacyConfigPath, "utf-8"));
|
|
257
|
-
}
|
|
258
223
|
static async getWorkspaceRoot(startPath = process.cwd()) {
|
|
259
224
|
return TemplatesManagerService.findWorkspaceRoot(startPath);
|
|
260
225
|
}
|
|
261
|
-
static getWorkspaceRootSync(startPath = process.cwd()) {
|
|
262
|
-
return TemplatesManagerService.findWorkspaceRootSync(startPath);
|
|
263
|
-
}
|
|
264
226
|
};
|
|
265
227
|
//#endregion
|
|
266
228
|
//#region src/services/ThemeService/CSSThemeService.ts
|
|
@@ -305,7 +267,7 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
305
267
|
*/
|
|
306
268
|
constructor(config, workspaceRoot) {
|
|
307
269
|
super(config);
|
|
308
|
-
this.monorepoRoot = workspaceRoot
|
|
270
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
309
271
|
}
|
|
310
272
|
/**
|
|
311
273
|
* Get the source identifier for this service
|
|
@@ -324,7 +286,7 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
324
286
|
* @throws Error if no theme files are configured or files cannot be read
|
|
325
287
|
*/
|
|
326
288
|
async listThemes() {
|
|
327
|
-
const cssFilePaths = this.resolveCSSFilePaths();
|
|
289
|
+
const cssFilePaths = await this.resolveCSSFilePaths();
|
|
328
290
|
if (cssFilePaths.length === 0) throw new Error("No theme CSS files configured. Set themePath or cssFiles in style-system.config.yaml.");
|
|
329
291
|
const themes = [];
|
|
330
292
|
const results = await Promise.allSettled(cssFilePaths.map(async (cssFilePath) => {
|
|
@@ -344,14 +306,15 @@ var CSSThemeService = class extends BaseThemeService {
|
|
|
344
306
|
* Resolve configured CSS file paths to absolute paths.
|
|
345
307
|
* @returns Array of absolute CSS file paths
|
|
346
308
|
*/
|
|
347
|
-
resolveCSSFilePaths() {
|
|
309
|
+
async resolveCSSFilePaths() {
|
|
310
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
348
311
|
const paths = [];
|
|
349
312
|
if (this.config.themePath) {
|
|
350
|
-
const themePath = node_path.default.isAbsolute(this.config.themePath) ? this.config.themePath : node_path.default.join(
|
|
313
|
+
const themePath = node_path.default.isAbsolute(this.config.themePath) ? this.config.themePath : node_path.default.join(monorepoRoot, this.config.themePath);
|
|
351
314
|
paths.push(themePath);
|
|
352
315
|
}
|
|
353
316
|
if (this.config.cssFiles && this.config.cssFiles.length > 0) for (const cssFile of this.config.cssFiles) {
|
|
354
|
-
const cssPath = node_path.default.isAbsolute(cssFile) ? cssFile : node_path.default.join(
|
|
317
|
+
const cssPath = node_path.default.isAbsolute(cssFile) ? cssFile : node_path.default.join(monorepoRoot, cssFile);
|
|
355
318
|
if (!paths.includes(cssPath)) paths.push(cssPath);
|
|
356
319
|
}
|
|
357
320
|
return paths;
|
|
@@ -884,7 +847,7 @@ let CSSClassesServiceFactory = class CSSClassesServiceFactory {
|
|
|
884
847
|
async loadCustomService(config) {
|
|
885
848
|
const servicePath = config.customServicePath;
|
|
886
849
|
if (!servicePath) throw new Error("customServicePath is required for custom service loading");
|
|
887
|
-
const monorepoRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
850
|
+
const monorepoRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
888
851
|
const resolvedPath = node_path.default.resolve(monorepoRoot, servicePath);
|
|
889
852
|
const normalizedWorkspaceRoot = node_path.default.resolve(monorepoRoot);
|
|
890
853
|
if (!resolvedPath.startsWith(normalizedWorkspaceRoot + node_path.default.sep)) throw new Error(`Security error: customServicePath "${servicePath}" resolves outside workspace root`);
|
|
@@ -957,7 +920,7 @@ let StoriesIndexService = class StoriesIndexService {
|
|
|
957
920
|
*/
|
|
958
921
|
constructor(config = {}) {
|
|
959
922
|
this.config = config;
|
|
960
|
-
this.monorepoRoot = config.workspaceRoot ? node_path.default.resolve(config.workspaceRoot) :
|
|
923
|
+
this.monorepoRoot = config.workspaceRoot ? node_path.default.resolve(config.workspaceRoot) : "";
|
|
961
924
|
}
|
|
962
925
|
/**
|
|
963
926
|
* Initialize the index by scanning all .stories files.
|
|
@@ -965,7 +928,7 @@ let StoriesIndexService = class StoriesIndexService {
|
|
|
965
928
|
*/
|
|
966
929
|
async initialize() {
|
|
967
930
|
if (this.initialized && this.lastInitResult) return this.lastInitResult;
|
|
968
|
-
|
|
931
|
+
this.monorepoRoot = this.config.workspaceRoot ? await node_fs.promises.realpath(this.monorepoRoot) : await TemplatesManagerService.getWorkspaceRoot();
|
|
969
932
|
log.info("[StoriesIndexService] Initializing story index...");
|
|
970
933
|
const storyFiles = await this.findStoryFiles();
|
|
971
934
|
log.info(`[StoriesIndexService] Found ${storyFiles.length} story files`);
|
|
@@ -1375,9 +1338,9 @@ const EXPO_APP_CONFIG_FILE = "app.json";
|
|
|
1375
1338
|
* values, and warns when it is the one that resolves.
|
|
1376
1339
|
*/
|
|
1377
1340
|
async function resolveStyleSystemThemePath(input) {
|
|
1378
|
-
const hostRoot = input.workspaceRoot ?? TemplatesManagerService.
|
|
1341
|
+
const hostRoot = input.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
1379
1342
|
const resolvedAppPath = input.appPath ? node_path.default.isAbsolute(input.appPath) ? node_path.default.normalize(input.appPath) : node_path.default.join(hostRoot, input.appPath) : hostRoot;
|
|
1380
|
-
const monorepoRoot = input.workspaceRoot ?? (input.appPath ? TemplatesManagerService.
|
|
1343
|
+
const monorepoRoot = input.workspaceRoot ?? (input.appPath ? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath) : hostRoot);
|
|
1381
1344
|
const workspaceCandidate = node_path.default.join(monorepoRoot, input.themePath);
|
|
1382
1345
|
const candidates = node_path.default.isAbsolute(input.themePath) ? [input.themePath] : [workspaceCandidate, node_path.default.resolve(resolvedAppPath, input.themePath)];
|
|
1383
1346
|
const uniqueCandidates = [...new Set(candidates)];
|
|
@@ -1443,7 +1406,8 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1443
1406
|
this.projectCache.clear();
|
|
1444
1407
|
}
|
|
1445
1408
|
/** Load and cache the workspace root config. */
|
|
1446
|
-
async loadRoot(workspaceRoot
|
|
1409
|
+
async loadRoot(workspaceRoot) {
|
|
1410
|
+
workspaceRoot ??= this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
1447
1411
|
let pending = this.rootPromises.get(workspaceRoot);
|
|
1448
1412
|
if (!pending) {
|
|
1449
1413
|
pending = this.readRoot(workspaceRoot);
|
|
@@ -1459,8 +1423,8 @@ let StyleSystemConfigLoader = class StyleSystemConfigLoader {
|
|
|
1459
1423
|
/** Resolve the merged configuration for a project. */
|
|
1460
1424
|
async resolveProject(appPath) {
|
|
1461
1425
|
if (!appPath || typeof appPath !== "string") throw new Error("appPath is required and must be a non-empty string");
|
|
1462
|
-
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? node_path.default.normalize(appPath) : node_path.default.join(this.workspaceRoot ?? TemplatesManagerService.
|
|
1463
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
1426
|
+
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? node_path.default.normalize(appPath) : node_path.default.join(this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(), appPath);
|
|
1427
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath);
|
|
1464
1428
|
const cached = this.projectCache.get(resolvedAppPath);
|
|
1465
1429
|
if (cached) return cached;
|
|
1466
1430
|
const pending = this.readProject(resolvedAppPath, workspaceRoot);
|
|
@@ -2087,7 +2051,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2087
2051
|
constructor(config = {}, workspaceRoot) {
|
|
2088
2052
|
super(config);
|
|
2089
2053
|
this.workspaceRoot = workspaceRoot;
|
|
2090
|
-
this.monorepoRoot = workspaceRoot
|
|
2054
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
2091
2055
|
}
|
|
2092
2056
|
/**
|
|
2093
2057
|
* Get the singleton instance of ViteReactBundlerService.
|
|
@@ -2162,7 +2126,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2162
2126
|
* @throws Error if server fails to start
|
|
2163
2127
|
*/
|
|
2164
2128
|
async startDevServer(appPath) {
|
|
2165
|
-
const
|
|
2129
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2130
|
+
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(monorepoRoot, appPath);
|
|
2166
2131
|
if (this.isServerRunning() && this.currentAppPath === resolvedAppPath) {
|
|
2167
2132
|
log.info(`[ViteReactBundlerService] Server already running for ${resolvedAppPath}`);
|
|
2168
2133
|
return {
|
|
@@ -2202,7 +2167,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2202
2167
|
plugins: [
|
|
2203
2168
|
(0, _tailwindcss_vite.default)(),
|
|
2204
2169
|
createTanStackStartStubPlugin(),
|
|
2205
|
-
...this.getAdditionalVitePlugins(resolvedAppPath),
|
|
2170
|
+
...await this.getAdditionalVitePlugins(resolvedAppPath),
|
|
2206
2171
|
{
|
|
2207
2172
|
name: "style-system-preview-html",
|
|
2208
2173
|
configureServer: (server) => {
|
|
@@ -2232,7 +2197,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2232
2197
|
},
|
|
2233
2198
|
createStoryEntryPlugin((id) => this.storyConfigs.get(id), (opts) => this.generateEntryFile(opts))
|
|
2234
2199
|
],
|
|
2235
|
-
resolve: this.getViteResolveConfig(resolvedAppPath),
|
|
2200
|
+
resolve: await this.getViteResolveConfig(resolvedAppPath),
|
|
2236
2201
|
define: this.getViteDefineConfig(),
|
|
2237
2202
|
esbuild: this.getViteEsbuildConfig(),
|
|
2238
2203
|
oxc: this.getViteOxcConfig(),
|
|
@@ -2282,8 +2247,9 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2282
2247
|
validateStoryName(storyName);
|
|
2283
2248
|
validateComponentPath(componentPath);
|
|
2284
2249
|
validateArgsSize(args);
|
|
2285
|
-
const
|
|
2286
|
-
|
|
2250
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2251
|
+
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(monorepoRoot, appPath);
|
|
2252
|
+
validateCssFiles(cssFiles, this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath));
|
|
2287
2253
|
if (this.currentAppPath !== resolvedAppPath) throw new Error(`Dev server is running for ${this.currentAppPath} but requested ${resolvedAppPath}.`);
|
|
2288
2254
|
const tmpDir = node_path.default.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2289
2255
|
try {
|
|
@@ -2330,8 +2296,9 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2330
2296
|
validateStoryName(storyName);
|
|
2331
2297
|
validateComponentPath(componentPath);
|
|
2332
2298
|
validateArgsSize(args);
|
|
2333
|
-
const
|
|
2334
|
-
|
|
2299
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
2300
|
+
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(monorepoRoot, appPath);
|
|
2301
|
+
validateCssFiles(cssFiles, this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(resolvedAppPath));
|
|
2335
2302
|
const tmpDir = node_path.default.join(resolvedAppPath, TMP_DIR_NAME);
|
|
2336
2303
|
try {
|
|
2337
2304
|
await node_fs.promises.mkdir(tmpDir, { recursive: true });
|
|
@@ -2356,8 +2323,8 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2356
2323
|
* Get Vite resolve configuration for the given app path.
|
|
2357
2324
|
* Subclasses can override to add platform-specific aliases (e.g., react-native-web).
|
|
2358
2325
|
*/
|
|
2359
|
-
getViteResolveConfig(appPath) {
|
|
2360
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
2326
|
+
async getViteResolveConfig(appPath) {
|
|
2327
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(appPath);
|
|
2361
2328
|
const frontendPackagePath = (packageDir, sourcePath = "index.ts") => node_path.default.join(workspaceRoot, WORKSPACE_PACKAGE_DIR_PREFIX, "frontend", packageDir, APP_SOURCE_DIR$1, sourcePath);
|
|
2362
2329
|
return { alias: [
|
|
2363
2330
|
...appReactAliases(appPath),
|
|
@@ -2467,7 +2434,7 @@ var ViteReactBundlerService = class ViteReactBundlerService extends BaseBundlerS
|
|
|
2467
2434
|
*/
|
|
2468
2435
|
async generateWrapperCss(appPath, cssFiles) {
|
|
2469
2436
|
const resolvedCssFiles = cssFiles.length > 0 ? cssFiles : await this.getDefaultCssFiles(appPath);
|
|
2470
|
-
const workspaceRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
2437
|
+
const workspaceRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot(appPath);
|
|
2471
2438
|
const cssImportStatements = resolvedCssFiles.map((cssFile) => {
|
|
2472
2439
|
if (node_path.default.isAbsolute(cssFile)) return `@import '${cssFile}';`;
|
|
2473
2440
|
if (cssFile.startsWith(PACKAGE_IMPORT_PREFIX) || cssFile.startsWith(TAILWIND_IMPORT_PREFIX)) return `@import '${cssFile}';`;
|
|
@@ -2653,10 +2620,10 @@ mount();
|
|
|
2653
2620
|
(0, _tailwindcss_vite.default)(),
|
|
2654
2621
|
(0, vite_plugin_singlefile.viteSingleFile)(),
|
|
2655
2622
|
createTanStackStartStubPlugin(),
|
|
2656
|
-
...this.getAdditionalVitePlugins(appPath),
|
|
2623
|
+
...await this.getAdditionalVitePlugins(appPath),
|
|
2657
2624
|
createStoryEntryPlugin((id) => buildStoryConfigs.get(id), (opts) => this.generateEntryFile(opts))
|
|
2658
2625
|
],
|
|
2659
|
-
resolve: this.getViteResolveConfig(appPath),
|
|
2626
|
+
resolve: await this.getViteResolveConfig(appPath),
|
|
2660
2627
|
define: this.getViteDefineConfig(),
|
|
2661
2628
|
esbuild: this.getViteEsbuildConfig(),
|
|
2662
2629
|
oxc: this.getViteOxcConfig(),
|
|
@@ -2766,10 +2733,8 @@ const SHIMS_DIR_CANDIDATES = [
|
|
|
2766
2733
|
node_path.default.resolve(__dirname$1, "../shims"),
|
|
2767
2734
|
node_path.default.resolve(__dirname$1, "../src/shims")
|
|
2768
2735
|
];
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
const existing = candidates.find((candidate) => (0, node_fs.existsSync)(candidate) && isValidDir(candidate));
|
|
2772
|
-
if (existing) return existing;
|
|
2736
|
+
async function resolveExistingDir(candidates, label, isValidDir) {
|
|
2737
|
+
for (const candidate of candidates) if (await isValidDir(candidate)) return candidate;
|
|
2773
2738
|
throw new Error(`Could not resolve ${label}. Tried: ${candidates.join(", ")}`);
|
|
2774
2739
|
}
|
|
2775
2740
|
function resolvePackageDirFrom(fromPath, packageName) {
|
|
@@ -2786,15 +2751,23 @@ function toViteImportPath(filePath) {
|
|
|
2786
2751
|
* matching TrueType font. Metadata-only glyph maps (e.g. `FontAwesome5Free_meta.json`)
|
|
2787
2752
|
* have no font and are skipped.
|
|
2788
2753
|
*/
|
|
2789
|
-
function resolveExpoVectorIconFamilies(appPath) {
|
|
2754
|
+
async function resolveExpoVectorIconFamilies(appPath) {
|
|
2790
2755
|
const packageDir = (0, node_path.dirname)(resolvePackageSubpathFrom(appPath, `${EXPO_VECTOR_ICONS_PREFIX}/${PACKAGE_JSON_SUBPATH}`));
|
|
2791
2756
|
const glyphMapDir = node_path.default.join(packageDir, EXPO_VECTOR_ICONS_GLYPHMAP_DIR);
|
|
2792
2757
|
const fontDir = node_path.default.join(packageDir, EXPO_VECTOR_ICONS_FONT_DIR);
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
|
|
2797
|
-
|
|
2758
|
+
const families = [];
|
|
2759
|
+
for (const entry of await (0, node_fs_promises.readdir)(glyphMapDir)) {
|
|
2760
|
+
if (!entry.endsWith(GLYPHMAP_EXTENSION)) continue;
|
|
2761
|
+
const family = entry.slice(0, -5);
|
|
2762
|
+
const fontPath = node_path.default.join(fontDir, `${family}${FONT_EXTENSION}`);
|
|
2763
|
+
if (!await pathExists(fontPath)) continue;
|
|
2764
|
+
families.push({
|
|
2765
|
+
family,
|
|
2766
|
+
fontPath: toViteImportPath(fontPath),
|
|
2767
|
+
glyphMapPath: toViteImportPath(node_path.default.join(glyphMapDir, entry))
|
|
2768
|
+
});
|
|
2769
|
+
}
|
|
2770
|
+
return families;
|
|
2798
2771
|
}
|
|
2799
2772
|
function getExpoVectorIconsVirtualModuleId(source, families) {
|
|
2800
2773
|
if (source === EXPO_VECTOR_ICONS_PREFIX) return `${EXPO_VECTOR_ICONS_RESOLVED_MODULE_PREFIX}/index`;
|
|
@@ -2827,13 +2800,20 @@ function createSvgComponentPlugin() {
|
|
|
2827
2800
|
return {
|
|
2828
2801
|
name: SVG_COMPONENT_PLUGIN_NAME,
|
|
2829
2802
|
enforce: VITE_PLUGIN_ENFORCE_PRE,
|
|
2830
|
-
load(id) {
|
|
2803
|
+
async load(id) {
|
|
2831
2804
|
const [filePath] = id.split(VITE_QUERY_SEPARATOR);
|
|
2832
|
-
if (!filePath?.endsWith(SVG_EXTENSION)
|
|
2805
|
+
if (!filePath?.endsWith(SVG_EXTENSION)) return null;
|
|
2806
|
+
let content;
|
|
2807
|
+
try {
|
|
2808
|
+
content = await (0, node_fs_promises.readFile)(filePath);
|
|
2809
|
+
} catch (error) {
|
|
2810
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") return null;
|
|
2811
|
+
throw error;
|
|
2812
|
+
}
|
|
2833
2813
|
return `
|
|
2834
2814
|
import React from 'react';
|
|
2835
2815
|
|
|
2836
|
-
const svgSource = '${`${SVG_DATA_URI_PREFIX}${
|
|
2816
|
+
const svgSource = '${`${SVG_DATA_URI_PREFIX}${content.toString(BASE64_ENCODING)}`}';
|
|
2837
2817
|
|
|
2838
2818
|
function normalizeStyle(style) {
|
|
2839
2819
|
if (Array.isArray(style)) return Object.assign({}, ...style.filter(Boolean));
|
|
@@ -2904,8 +2884,8 @@ function createNativeBabelTransformPlugin(appPath) {
|
|
|
2904
2884
|
}
|
|
2905
2885
|
};
|
|
2906
2886
|
}
|
|
2907
|
-
function createExpoVectorIconsVirtualModule(appPath) {
|
|
2908
|
-
const iconFamilies = resolveExpoVectorIconFamilies(appPath);
|
|
2887
|
+
async function createExpoVectorIconsVirtualModule(appPath) {
|
|
2888
|
+
const iconFamilies = await resolveExpoVectorIconFamilies(appPath);
|
|
2909
2889
|
const iconFamilyNames = new Set(iconFamilies.map(({ family }) => family));
|
|
2910
2890
|
const assetImports = iconFamilies.map(({ family, fontPath, glyphMapPath }) => `import ${family}FontUrl from '${fontPath}?url';\n import ${family}GlyphMap from '${glyphMapPath}';`).join("\n ");
|
|
2911
2891
|
return {
|
|
@@ -2997,8 +2977,8 @@ function createExpoVectorIconsVirtualModule(appPath) {
|
|
|
2997
2977
|
function resolveShimsDir() {
|
|
2998
2978
|
return resolveExistingDir(SHIMS_DIR_CANDIDATES, REACT_NATIVE_VISUAL_RENDER_SHIMS_LABEL, hasRequiredReactNativeShims);
|
|
2999
2979
|
}
|
|
3000
|
-
function hasRequiredReactNativeShims(candidate) {
|
|
3001
|
-
return REQUIRED_REACT_NATIVE_SHIM_FILES.
|
|
2980
|
+
async function hasRequiredReactNativeShims(candidate) {
|
|
2981
|
+
return (await Promise.all(REQUIRED_REACT_NATIVE_SHIM_FILES.map((shimFile) => pathExists(node_path.default.join(candidate, shimFile))))).every(Boolean);
|
|
3002
2982
|
}
|
|
3003
2983
|
var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends ViteReactBundlerService {
|
|
3004
2984
|
static nativeInstance = null;
|
|
@@ -3009,7 +2989,7 @@ var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends
|
|
|
3009
2989
|
getBundlerId() {
|
|
3010
2990
|
return VITE_REACT_NATIVE_BUNDLER_ID;
|
|
3011
2991
|
}
|
|
3012
|
-
getAdditionalVitePlugins(appPath) {
|
|
2992
|
+
async getAdditionalVitePlugins(appPath) {
|
|
3013
2993
|
return [
|
|
3014
2994
|
{
|
|
3015
2995
|
name: REACT_NATIVE_OPTIMIZE_DEPS_PLUGIN_NAME,
|
|
@@ -3027,7 +3007,7 @@ var ViteReactNativeBundlerService = class ViteReactNativeBundlerService extends
|
|
|
3027
3007
|
},
|
|
3028
3008
|
createExpoTypeDeclarationStubPlugin(),
|
|
3029
3009
|
createSvgComponentPlugin(),
|
|
3030
|
-
...appPath ? [createExpoVectorIconsVirtualModule(appPath)] : [],
|
|
3010
|
+
...appPath ? [await createExpoVectorIconsVirtualModule(appPath)] : [],
|
|
3031
3011
|
...appPath ? [createNativeBabelTransformPlugin(appPath)] : [],
|
|
3032
3012
|
...(0, _vitejs_plugin_react.default)()
|
|
3033
3013
|
];
|
|
@@ -3082,7 +3062,8 @@ const styleSystemSafeAreaMetrics = {
|
|
|
3082
3062
|
min-height: 100vh;
|
|
3083
3063
|
}`;
|
|
3084
3064
|
}
|
|
3085
|
-
getViteResolveConfig(appPath) {
|
|
3065
|
+
async getViteResolveConfig(appPath) {
|
|
3066
|
+
const shimsDir = await resolveShimsDir();
|
|
3086
3067
|
const reactNativeUnistylesDir = resolvePackageDirFrom(appPath, REACT_NATIVE_UNISTYLES_PACKAGE);
|
|
3087
3068
|
const reactNativeUnistylesEntry = node_path.default.join(reactNativeUnistylesDir, REACT_NATIVE_UNISTYLES_WEB_INDEX);
|
|
3088
3069
|
const reactNativeWebDir = resolvePackageDirFrom(appPath, REACT_NATIVE_WEB_PACKAGE);
|
|
@@ -3108,7 +3089,7 @@ const styleSystemSafeAreaMetrics = {
|
|
|
3108
3089
|
},
|
|
3109
3090
|
{
|
|
3110
3091
|
find: EXPO_SYMBOLS_PACKAGE,
|
|
3111
|
-
replacement: node_path.default.join(
|
|
3092
|
+
replacement: node_path.default.join(shimsDir, EXPO_SYMBOLS_SHIM_FILE)
|
|
3112
3093
|
},
|
|
3113
3094
|
{
|
|
3114
3095
|
find: STORYBOOK_REACT_NATIVE_PACKAGE,
|
|
@@ -3242,7 +3223,7 @@ async function loadBundlerServiceFromConfig(options) {
|
|
|
3242
3223
|
cachedBundlerService = fallback();
|
|
3243
3224
|
return cachedBundlerService;
|
|
3244
3225
|
}
|
|
3245
|
-
const monorepoRoot = options?.workspaceRoot ?? TemplatesManagerService.
|
|
3226
|
+
const monorepoRoot = options?.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
3246
3227
|
const customServicePath = node_path.default.resolve(monorepoRoot, config.customService);
|
|
3247
3228
|
const normalizedWorkspaceRoot = node_path.default.resolve(monorepoRoot);
|
|
3248
3229
|
if (!customServicePath.startsWith(normalizedWorkspaceRoot + node_path.default.sep)) {
|
|
@@ -3331,7 +3312,7 @@ var ThemeService = class {
|
|
|
3331
3312
|
* @param config - Design system configuration
|
|
3332
3313
|
*/
|
|
3333
3314
|
constructor(config, workspaceRoot) {
|
|
3334
|
-
this.monorepoRoot = workspaceRoot
|
|
3315
|
+
this.monorepoRoot = workspaceRoot !== void 0 ? Promise.resolve(workspaceRoot) : void 0;
|
|
3335
3316
|
this.config = config;
|
|
3336
3317
|
if (this.config.themeProvider) log.info(`[ThemeService] Using theme provider: ${this.config.themeProvider}`);
|
|
3337
3318
|
log.info(`[ThemeService] Design system type: ${this.config.type}`);
|
|
@@ -3348,12 +3329,13 @@ var ThemeService = class {
|
|
|
3348
3329
|
* @returns Array of absolute paths to CSS files
|
|
3349
3330
|
*/
|
|
3350
3331
|
async getThemeCSS() {
|
|
3351
|
-
|
|
3332
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
3333
|
+
if (this.config.cssFiles && this.config.cssFiles.length > 0) return this.config.cssFiles.map((cssFile) => node_path.default.isAbsolute(cssFile) ? cssFile : node_path.default.join(monorepoRoot, cssFile));
|
|
3352
3334
|
const cssPatterns = ["**/packages/frontend/web-theme/src/**/*.css", "**/packages/frontend/shared-theme/**/*.css"];
|
|
3353
3335
|
const cssFiles = [];
|
|
3354
3336
|
for (const pattern of cssPatterns) {
|
|
3355
3337
|
const files = await (0, glob.glob)(pattern, {
|
|
3356
|
-
cwd:
|
|
3338
|
+
cwd: monorepoRoot,
|
|
3357
3339
|
absolute: true,
|
|
3358
3340
|
ignore: ["**/node_modules/**", "**/dist/**"]
|
|
3359
3341
|
});
|
|
@@ -3442,7 +3424,8 @@ export { WrappedComponent };
|
|
|
3442
3424
|
* @throws Error if themes directory cannot be read
|
|
3443
3425
|
*/
|
|
3444
3426
|
async listAvailableThemes() {
|
|
3445
|
-
const
|
|
3427
|
+
const monorepoRoot = await (this.monorepoRoot ??= TemplatesManagerService.getWorkspaceRoot());
|
|
3428
|
+
const configsPath = node_path.default.join(monorepoRoot, "packages/frontend/shared-theme/configs");
|
|
3446
3429
|
try {
|
|
3447
3430
|
const themeFiles = (await node_fs.promises.readdir(configsPath)).filter((file) => file.endsWith(JSON_FILE_EXTENSION));
|
|
3448
3431
|
const themes = [];
|
|
@@ -3977,7 +3960,7 @@ let AppComponentsService = class AppComponentsService {
|
|
|
3977
3960
|
if (input.cursor !== void 0 && typeof input.cursor !== "string") throw new Error("cursor must be a string");
|
|
3978
3961
|
const { appPath, cursor } = input;
|
|
3979
3962
|
const { offset } = cursor ? this.decodeCursor(cursor) : { offset: 0 };
|
|
3980
|
-
const monorepoRoot = this.workspaceRoot ?? TemplatesManagerService.
|
|
3963
|
+
const monorepoRoot = this.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
3981
3964
|
const resolvedAppPath = node_path.default.isAbsolute(appPath) ? appPath : node_path.default.join(monorepoRoot, appPath);
|
|
3982
3965
|
try {
|
|
3983
3966
|
await node_fs.promises.access(resolvedAppPath);
|
|
@@ -4250,7 +4233,8 @@ let ListThemesTool = class ListThemesTool {
|
|
|
4250
4233
|
themePath: appConfig.themePath,
|
|
4251
4234
|
workspaceRoot: this.configLoader?.workspaceRoot
|
|
4252
4235
|
}) : void 0;
|
|
4253
|
-
|
|
4236
|
+
const workspaceRoot = this.configLoader?.workspaceRoot ?? await TemplatesManagerService.getWorkspaceRoot();
|
|
4237
|
+
cssFiles = themePath ? void 0 : appConfig.cssFiles?.map((file) => node_path.default.resolve(workspaceRoot, input.appPath, file));
|
|
4254
4238
|
}
|
|
4255
4239
|
const result = await (await this.serviceFactory.createService({
|
|
4256
4240
|
themePath,
|
|
@@ -4758,7 +4742,7 @@ function createContainer(options) {
|
|
|
4758
4742
|
}
|
|
4759
4743
|
//#endregion
|
|
4760
4744
|
//#region package.json
|
|
4761
|
-
var version = "0.2.14-alpha.
|
|
4745
|
+
var version = "0.2.14-alpha.29";
|
|
4762
4746
|
//#endregion
|
|
4763
4747
|
//#region src/metadata.ts
|
|
4764
4748
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agimon-ai/po-style-system-tooling",
|
|
3
|
-
"version": "0.2.14-alpha.
|
|
3
|
+
"version": "0.2.14-alpha.29",
|
|
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",
|