@agimon-ai/po-style-system-tooling 0.2.14-alpha.33 → 0.2.14-alpha.35
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 +8 -5
- package/dist/index.d.cts +38 -4
- package/dist/index.d.mts +38 -4
- package/dist/index.mjs +8 -6
- package/dist/{stdio-GwfMne20.mjs → stdio-CahIjnuV.mjs} +254 -50
- package/dist/{stdio-Dn3HBb3D.cjs → stdio-Cv0gF9Yo.cjs} +259 -49
- 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 {
|
|
2
|
+
import { B as log, F as DEFAULT_STYLE_SYSTEM_CONFIG, I as TailwindCSSClassesService, T as getAppDesignSystemConfig, V as STYLE_SYSTEM_TYPES, a as STYLE_SYSTEM_CLI_NAME, i as createServer$1, j as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, y as getBundlerServiceFromConfig } from "./stdio-CahIjnuV.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-Cv0gF9Yo.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);
|
|
@@ -38,7 +38,8 @@ var StoryPreviewService = class {
|
|
|
38
38
|
if (!component) throw new Error(`Story file was not indexed: ${node_path.default.relative(workspaceRoot, storyFilePath)}`);
|
|
39
39
|
if (!component.storyExports.includes(input.storyExport)) throw new Error(`Story export "${input.storyExport}" was not found. Available exports: ${component.storyExports.join(", ")}`);
|
|
40
40
|
const [source, config] = await Promise.all([node_fs.promises.readFile(storyFilePath, UTF8_ENCODING), this.configLoader(appPath)]);
|
|
41
|
-
const
|
|
41
|
+
const bundler = this.bundlerFactory(config);
|
|
42
|
+
const result = await require_stdio.withRenderSlot(() => bundler.prerenderComponent({
|
|
42
43
|
componentPath: storyFilePath,
|
|
43
44
|
storyName: input.storyExport,
|
|
44
45
|
args: input.args,
|
|
@@ -48,7 +49,7 @@ var StoryPreviewService = class {
|
|
|
48
49
|
cssFiles: config.cssFiles,
|
|
49
50
|
rootComponent: config.rootComponent,
|
|
50
51
|
unistylesConfig: config.unistylesConfig
|
|
51
|
-
});
|
|
52
|
+
}));
|
|
52
53
|
const htmlFilePath = await node_fs.promises.realpath(result.htmlFilePath);
|
|
53
54
|
const artifactDirectory = node_path.default.dirname(htmlFilePath);
|
|
54
55
|
const artifactRoot = node_path.default.join(appPath, ".tmp");
|
|
@@ -243,7 +244,7 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
243
244
|
const bundler = await pending;
|
|
244
245
|
if (activeBundler && activeBundler !== bundler && activeBundler.isServerRunning()) await activeBundler.cleanup();
|
|
245
246
|
activeBundler = bundler;
|
|
246
|
-
const recycle = bundler.getBundlerId()
|
|
247
|
+
const recycle = ["vite", "vite-react-native"].includes(bundler.getBundlerId()) && captures >= 100;
|
|
247
248
|
if (bundler.isServerRunning() && bundler.getCurrentAppPath() === resolved && !recycle) return;
|
|
248
249
|
if (bundler.isServerRunning()) await bundler.cleanup();
|
|
249
250
|
captures = 0;
|
|
@@ -253,7 +254,8 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
253
254
|
const open = browser;
|
|
254
255
|
browser = void 0;
|
|
255
256
|
captures = 0;
|
|
256
|
-
await Promise.allSettled([open?.then((instance) => instance.close()), ...[...bundlers.values()].map((pending) => pending.then((bundler) => bundler.cleanup()))]);
|
|
257
|
+
const results = await Promise.allSettled([open?.then((instance) => instance.close()), ...[...bundlers.values()].map((pending) => pending.then((bundler) => bundler.cleanup()))]);
|
|
258
|
+
for (const result of results) if (result.status === "rejected") require_stdio.log.warn(`[WarmStoryRenderer] Reset failed to close a resource: ${result.reason}`);
|
|
257
259
|
};
|
|
258
260
|
const run = async (tool, input) => {
|
|
259
261
|
if (disposed) throw new Error("The story renderer is shut down.");
|
|
@@ -410,3 +412,4 @@ exports.launchBrowserWithFallback = require_stdio.launchBrowserWithFallback;
|
|
|
410
412
|
exports.resetStyleSystemConfigCache = require_stdio.resetStyleSystemConfigCache;
|
|
411
413
|
exports.resolveAppDesignSystemConfig = require_stdio.resolveAppDesignSystemConfig;
|
|
412
414
|
exports.resolveStyleSystemThemePath = require_stdio.resolveStyleSystemThemePath;
|
|
415
|
+
exports.withRenderSlot = require_stdio.withRenderSlot;
|
package/dist/index.d.cts
CHANGED
|
@@ -153,9 +153,23 @@ interface BrowserLease {
|
|
|
153
153
|
browser: Browser;
|
|
154
154
|
release(): void;
|
|
155
155
|
}
|
|
156
|
+
/** Renders a page outside Playwright, such as Po Desktop's Electron; returns the PNG as base64. */
|
|
157
|
+
type PageCapture = (request: {
|
|
158
|
+
url: string;
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
fullPage: boolean;
|
|
162
|
+
darkMode: boolean;
|
|
163
|
+
mobile: boolean;
|
|
164
|
+
waitTime: number;
|
|
165
|
+
}) => Promise<{
|
|
166
|
+
png: string;
|
|
167
|
+
}>;
|
|
156
168
|
interface ScreenshotOptions {
|
|
157
169
|
/** A borrowed browser; release runs only after this render's context cleanup settles. */
|
|
158
170
|
sharedBrowser?: () => Promise<Browser | BrowserLease>;
|
|
171
|
+
/** Used instead of a browser when set, except for thumbnails, which still need one. */
|
|
172
|
+
capturePage?: PageCapture;
|
|
159
173
|
url: string;
|
|
160
174
|
output: string;
|
|
161
175
|
width?: number;
|
|
@@ -238,8 +252,8 @@ interface BuildOptions {
|
|
|
238
252
|
rootComponent?: string;
|
|
239
253
|
/** Path to native app Unistyles runtime configuration */
|
|
240
254
|
unistylesConfig?: string;
|
|
241
|
-
/**
|
|
242
|
-
|
|
255
|
+
/** Absolute id of this render's virtual wrapper stylesheet */
|
|
256
|
+
wrapperCssPath: string;
|
|
243
257
|
}
|
|
244
258
|
/**
|
|
245
259
|
* Result from starting a dev server.
|
|
@@ -392,6 +406,8 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
392
406
|
private storyConfigTimestamps;
|
|
393
407
|
/** Promise that resolves when server startup completes, prevents race conditions */
|
|
394
408
|
private serverStartPromise;
|
|
409
|
+
/** Virtual files of the running dev server */
|
|
410
|
+
private devStore;
|
|
395
411
|
/**
|
|
396
412
|
* Creates a new ViteReactBundlerService instance.
|
|
397
413
|
* Use getInstance() for singleton access.
|
|
@@ -516,6 +532,13 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
516
532
|
* is in an unexpected state. Callers should not depend on cleanup failure detection.
|
|
517
533
|
*/
|
|
518
534
|
cleanup(): Promise<void>;
|
|
535
|
+
private disposeDevStore;
|
|
536
|
+
/**
|
|
537
|
+
* Store the files one render reads: the wrapper CSS and snapshots of its declared sources.
|
|
538
|
+
* Transitive imports, nested CSS imports and node_modules are still read from disk.
|
|
539
|
+
* @returns Snapshotted source paths whose content changed
|
|
540
|
+
*/
|
|
541
|
+
private snapshotRender;
|
|
519
542
|
/**
|
|
520
543
|
* Clean up stale story configs to prevent memory leaks.
|
|
521
544
|
* Removes configs that are older than STORY_CONFIG_MAX_AGE_MS or
|
|
@@ -523,8 +546,9 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
523
546
|
*/
|
|
524
547
|
private cleanupStaleStoryConfigs;
|
|
525
548
|
/**
|
|
526
|
-
* Generate
|
|
527
|
-
*
|
|
549
|
+
* Generate the wrapper CSS with @source directives for Tailwind v4.
|
|
550
|
+
* Stylesheets inside the app are snapshotted into it, so a render does not see later edits or a
|
|
551
|
+
* theme file removed mid-render; package and workspace stylesheets stay imports.
|
|
528
552
|
* @param appPath - Absolute path to the app directory
|
|
529
553
|
* @param cssFiles - Array of CSS file paths to import
|
|
530
554
|
* @returns Generated CSS content with @source directive
|
|
@@ -653,6 +677,8 @@ interface StyleSystemModuleOptions {
|
|
|
653
677
|
temporaryDirectory?: string;
|
|
654
678
|
/** A browser a long-lived host keeps warm across renders; one-shot CLI runs leave it unset. */
|
|
655
679
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
680
|
+
/** A host renderer such as Po Desktop's Electron; preferred over the browser when set. */
|
|
681
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
656
682
|
}
|
|
657
683
|
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
658
684
|
//#endregion
|
|
@@ -945,6 +971,7 @@ export declare class ComponentRendererService {
|
|
|
945
971
|
private log;
|
|
946
972
|
private readonly preserveOutput;
|
|
947
973
|
private readonly sharedBrowser;
|
|
974
|
+
private readonly capturePage;
|
|
948
975
|
/**
|
|
949
976
|
* Creates a new ComponentRendererService instance
|
|
950
977
|
* @param designSystemConfig - Design system configuration
|
|
@@ -956,6 +983,7 @@ export declare class ComponentRendererService {
|
|
|
956
983
|
workspaceRoot?: string;
|
|
957
984
|
temporaryDirectory?: string;
|
|
958
985
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
986
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
959
987
|
});
|
|
960
988
|
/**
|
|
961
989
|
* Get the bundler service instance.
|
|
@@ -971,6 +999,7 @@ export declare class ComponentRendererService {
|
|
|
971
999
|
* @throws Error if rendering fails
|
|
972
1000
|
*/
|
|
973
1001
|
renderComponent(componentInfo: ComponentInfo, options?: RenderOptions): Promise<RenderResult>;
|
|
1002
|
+
private renderInSlot;
|
|
974
1003
|
/**
|
|
975
1004
|
* Default maximum number of screenshot files to keep in temp directory.
|
|
976
1005
|
* Prevents disk space issues on long-running servers.
|
|
@@ -2086,6 +2115,10 @@ export declare class StdioTransportHandler {
|
|
|
2086
2115
|
stop(): Promise<void>;
|
|
2087
2116
|
}
|
|
2088
2117
|
//#endregion
|
|
2118
|
+
//#region src/utils/renderSlots.d.ts
|
|
2119
|
+
/** Runs task once a render slot is free; slots are granted in arrival order. */
|
|
2120
|
+
export declare function withRenderSlot<T>(task: () => Promise<T>): Promise<T>;
|
|
2121
|
+
//#endregion
|
|
2089
2122
|
//#region src/utils/storyBrowser.d.ts
|
|
2090
2123
|
/** Server-owned Chrome. Each capture borrows it until its context cleanup settles. */
|
|
2091
2124
|
export declare function createStoryBrowser(): {
|
|
@@ -2127,6 +2160,7 @@ export declare function createWarmStoryRenderer(options?: {
|
|
|
2127
2160
|
workspaceRoot?: string;
|
|
2128
2161
|
temporaryDirectory?: string;
|
|
2129
2162
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
2163
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
2130
2164
|
}): WarmStoryRenderer;
|
|
2131
2165
|
//#endregion
|
|
2132
2166
|
export type { CSSClassCategory, CSSClassValue, CSSClassesResult, DesignSystemConfig, OxlintRestrictedClassPattern, OxlintRestrictedClassesConfig, ResolvedDesignSystemConfig, StoryPreviewIdentity, StoryPreviewInput, StoryPreviewResult, StoryPreviewServiceOptions, StyleSystemConfig, StyleSystemModuleOptions, Tool, ToolDefinition, WarmRendererResult, WarmRendererToolName, WarmStoryRenderer };
|
package/dist/index.d.mts
CHANGED
|
@@ -153,9 +153,23 @@ interface BrowserLease {
|
|
|
153
153
|
browser: Browser;
|
|
154
154
|
release(): void;
|
|
155
155
|
}
|
|
156
|
+
/** Renders a page outside Playwright, such as Po Desktop's Electron; returns the PNG as base64. */
|
|
157
|
+
type PageCapture = (request: {
|
|
158
|
+
url: string;
|
|
159
|
+
width: number;
|
|
160
|
+
height: number;
|
|
161
|
+
fullPage: boolean;
|
|
162
|
+
darkMode: boolean;
|
|
163
|
+
mobile: boolean;
|
|
164
|
+
waitTime: number;
|
|
165
|
+
}) => Promise<{
|
|
166
|
+
png: string;
|
|
167
|
+
}>;
|
|
156
168
|
interface ScreenshotOptions {
|
|
157
169
|
/** A borrowed browser; release runs only after this render's context cleanup settles. */
|
|
158
170
|
sharedBrowser?: () => Promise<Browser | BrowserLease>;
|
|
171
|
+
/** Used instead of a browser when set, except for thumbnails, which still need one. */
|
|
172
|
+
capturePage?: PageCapture;
|
|
159
173
|
url: string;
|
|
160
174
|
output: string;
|
|
161
175
|
width?: number;
|
|
@@ -238,8 +252,8 @@ interface BuildOptions {
|
|
|
238
252
|
rootComponent?: string;
|
|
239
253
|
/** Path to native app Unistyles runtime configuration */
|
|
240
254
|
unistylesConfig?: string;
|
|
241
|
-
/**
|
|
242
|
-
|
|
255
|
+
/** Absolute id of this render's virtual wrapper stylesheet */
|
|
256
|
+
wrapperCssPath: string;
|
|
243
257
|
}
|
|
244
258
|
/**
|
|
245
259
|
* Result from starting a dev server.
|
|
@@ -392,6 +406,8 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
392
406
|
private storyConfigTimestamps;
|
|
393
407
|
/** Promise that resolves when server startup completes, prevents race conditions */
|
|
394
408
|
private serverStartPromise;
|
|
409
|
+
/** Virtual files of the running dev server */
|
|
410
|
+
private devStore;
|
|
395
411
|
/**
|
|
396
412
|
* Creates a new ViteReactBundlerService instance.
|
|
397
413
|
* Use getInstance() for singleton access.
|
|
@@ -516,6 +532,13 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
516
532
|
* is in an unexpected state. Callers should not depend on cleanup failure detection.
|
|
517
533
|
*/
|
|
518
534
|
cleanup(): Promise<void>;
|
|
535
|
+
private disposeDevStore;
|
|
536
|
+
/**
|
|
537
|
+
* Store the files one render reads: the wrapper CSS and snapshots of its declared sources.
|
|
538
|
+
* Transitive imports, nested CSS imports and node_modules are still read from disk.
|
|
539
|
+
* @returns Snapshotted source paths whose content changed
|
|
540
|
+
*/
|
|
541
|
+
private snapshotRender;
|
|
519
542
|
/**
|
|
520
543
|
* Clean up stale story configs to prevent memory leaks.
|
|
521
544
|
* Removes configs that are older than STORY_CONFIG_MAX_AGE_MS or
|
|
@@ -523,8 +546,9 @@ export declare class ViteReactBundlerService extends BaseBundlerService {
|
|
|
523
546
|
*/
|
|
524
547
|
private cleanupStaleStoryConfigs;
|
|
525
548
|
/**
|
|
526
|
-
* Generate
|
|
527
|
-
*
|
|
549
|
+
* Generate the wrapper CSS with @source directives for Tailwind v4.
|
|
550
|
+
* Stylesheets inside the app are snapshotted into it, so a render does not see later edits or a
|
|
551
|
+
* theme file removed mid-render; package and workspace stylesheets stay imports.
|
|
528
552
|
* @param appPath - Absolute path to the app directory
|
|
529
553
|
* @param cssFiles - Array of CSS file paths to import
|
|
530
554
|
* @returns Generated CSS content with @source directive
|
|
@@ -653,6 +677,8 @@ interface StyleSystemModuleOptions {
|
|
|
653
677
|
temporaryDirectory?: string;
|
|
654
678
|
/** A browser a long-lived host keeps warm across renders; one-shot CLI runs leave it unset. */
|
|
655
679
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
680
|
+
/** A host renderer such as Po Desktop's Electron; preferred over the browser when set. */
|
|
681
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
656
682
|
}
|
|
657
683
|
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
658
684
|
//#endregion
|
|
@@ -945,6 +971,7 @@ export declare class ComponentRendererService {
|
|
|
945
971
|
private log;
|
|
946
972
|
private readonly preserveOutput;
|
|
947
973
|
private readonly sharedBrowser;
|
|
974
|
+
private readonly capturePage;
|
|
948
975
|
/**
|
|
949
976
|
* Creates a new ComponentRendererService instance
|
|
950
977
|
* @param designSystemConfig - Design system configuration
|
|
@@ -956,6 +983,7 @@ export declare class ComponentRendererService {
|
|
|
956
983
|
workspaceRoot?: string;
|
|
957
984
|
temporaryDirectory?: string;
|
|
958
985
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
986
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
959
987
|
});
|
|
960
988
|
/**
|
|
961
989
|
* Get the bundler service instance.
|
|
@@ -971,6 +999,7 @@ export declare class ComponentRendererService {
|
|
|
971
999
|
* @throws Error if rendering fails
|
|
972
1000
|
*/
|
|
973
1001
|
renderComponent(componentInfo: ComponentInfo, options?: RenderOptions): Promise<RenderResult>;
|
|
1002
|
+
private renderInSlot;
|
|
974
1003
|
/**
|
|
975
1004
|
* Default maximum number of screenshot files to keep in temp directory.
|
|
976
1005
|
* Prevents disk space issues on long-running servers.
|
|
@@ -2086,6 +2115,10 @@ export declare class StdioTransportHandler {
|
|
|
2086
2115
|
stop(): Promise<void>;
|
|
2087
2116
|
}
|
|
2088
2117
|
//#endregion
|
|
2118
|
+
//#region src/utils/renderSlots.d.ts
|
|
2119
|
+
/** Runs task once a render slot is free; slots are granted in arrival order. */
|
|
2120
|
+
export declare function withRenderSlot<T>(task: () => Promise<T>): Promise<T>;
|
|
2121
|
+
//#endregion
|
|
2089
2122
|
//#region src/utils/storyBrowser.d.ts
|
|
2090
2123
|
/** Server-owned Chrome. Each capture borrows it until its context cleanup settles. */
|
|
2091
2124
|
export declare function createStoryBrowser(): {
|
|
@@ -2127,6 +2160,7 @@ export declare function createWarmStoryRenderer(options?: {
|
|
|
2127
2160
|
workspaceRoot?: string;
|
|
2128
2161
|
temporaryDirectory?: string;
|
|
2129
2162
|
sharedBrowser?: ScreenshotOptions['sharedBrowser'];
|
|
2163
|
+
capturePage?: ScreenshotOptions['capturePage'];
|
|
2130
2164
|
}): WarmStoryRenderer;
|
|
2131
2165
|
//#endregion
|
|
2132
2166
|
export type { CSSClassCategory, CSSClassValue, CSSClassesResult, DesignSystemConfig, OxlintRestrictedClassPattern, OxlintRestrictedClassesConfig, ResolvedDesignSystemConfig, StoryPreviewIdentity, StoryPreviewInput, StoryPreviewResult, StoryPreviewServiceOptions, StyleSystemConfig, StyleSystemModuleOptions, Tool, ToolDefinition, WarmRendererResult, WarmRendererToolName, WarmStoryRenderer };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as
|
|
1
|
+
import { A as StyleSystemConfigLoader, B as log, C as launchBrowserWithFallback, D as hasStyleSystemProjectConfig, E as getSharedComponentTags, F as DEFAULT_STYLE_SYSTEM_CONFIG, I as TailwindCSSClassesService, L as BaseCSSClassesService, M as MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION, N as StoriesIndexService, O as resetStyleSystemConfigCache, P as CSSClassesServiceFactory, R as TemplatesManagerService, S as BaseBundlerService, T as getAppDesignSystemConfig, V as STYLE_SYSTEM_TYPES, _ 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 resolveStyleSystemThemePath, k as resolveAppDesignSystemConfig, 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 withRenderSlot, x as ViteReactBundlerService, y as getBundlerServiceFromConfig, z as isContained } from "./stdio-CahIjnuV.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -36,7 +36,8 @@ var StoryPreviewService = class {
|
|
|
36
36
|
if (!component) throw new Error(`Story file was not indexed: ${path.relative(workspaceRoot, storyFilePath)}`);
|
|
37
37
|
if (!component.storyExports.includes(input.storyExport)) throw new Error(`Story export "${input.storyExport}" was not found. Available exports: ${component.storyExports.join(", ")}`);
|
|
38
38
|
const [source, config] = await Promise.all([promises.readFile(storyFilePath, UTF8_ENCODING), this.configLoader(appPath)]);
|
|
39
|
-
const
|
|
39
|
+
const bundler = this.bundlerFactory(config);
|
|
40
|
+
const result = await withRenderSlot(() => bundler.prerenderComponent({
|
|
40
41
|
componentPath: storyFilePath,
|
|
41
42
|
storyName: input.storyExport,
|
|
42
43
|
args: input.args,
|
|
@@ -46,7 +47,7 @@ var StoryPreviewService = class {
|
|
|
46
47
|
cssFiles: config.cssFiles,
|
|
47
48
|
rootComponent: config.rootComponent,
|
|
48
49
|
unistylesConfig: config.unistylesConfig
|
|
49
|
-
});
|
|
50
|
+
}));
|
|
50
51
|
const htmlFilePath = await promises.realpath(result.htmlFilePath);
|
|
51
52
|
const artifactDirectory = path.dirname(htmlFilePath);
|
|
52
53
|
const artifactRoot = path.join(appPath, ".tmp");
|
|
@@ -241,7 +242,7 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
241
242
|
const bundler = await pending;
|
|
242
243
|
if (activeBundler && activeBundler !== bundler && activeBundler.isServerRunning()) await activeBundler.cleanup();
|
|
243
244
|
activeBundler = bundler;
|
|
244
|
-
const recycle = bundler.getBundlerId()
|
|
245
|
+
const recycle = ["vite", "vite-react-native"].includes(bundler.getBundlerId()) && captures >= 100;
|
|
245
246
|
if (bundler.isServerRunning() && bundler.getCurrentAppPath() === resolved && !recycle) return;
|
|
246
247
|
if (bundler.isServerRunning()) await bundler.cleanup();
|
|
247
248
|
captures = 0;
|
|
@@ -251,7 +252,8 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
251
252
|
const open = browser;
|
|
252
253
|
browser = void 0;
|
|
253
254
|
captures = 0;
|
|
254
|
-
await Promise.allSettled([open?.then((instance) => instance.close()), ...[...bundlers.values()].map((pending) => pending.then((bundler) => bundler.cleanup()))]);
|
|
255
|
+
const results = await Promise.allSettled([open?.then((instance) => instance.close()), ...[...bundlers.values()].map((pending) => pending.then((bundler) => bundler.cleanup()))]);
|
|
256
|
+
for (const result of results) if (result.status === "rejected") log.warn(`[WarmStoryRenderer] Reset failed to close a resource: ${result.reason}`);
|
|
255
257
|
};
|
|
256
258
|
const run = async (tool, input) => {
|
|
257
259
|
if (disposed) throw new Error("The story renderer is shut down.");
|
|
@@ -324,4 +326,4 @@ function createWarmStoryRenderer(options = {}) {
|
|
|
324
326
|
};
|
|
325
327
|
}
|
|
326
328
|
//#endregion
|
|
327
|
-
export { BaseBundlerService, BaseCSSClassesService, CSSClassesServiceFactory, ComponentRendererService, DEFAULT_STYLE_SYSTEM_CONFIG, GetCSSClassesTool, GetComponentVisualTool, GetUiComponentService, ListAppComponentsTool, ListSharedComponentsTool, ListThemesTool, MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION, STYLE_SYSTEM_TYPES, StdioTransportHandler, StoriesIndexService, StoryPreviewService, StyleSystemConfigLoader, TailwindCSSClassesService, ThemeService, ViteReactBundlerService, ViteReactNativeBundlerService, WARM_RENDERER_TOOLS, createContainer, createDefaultBundlerService, createServer, createStoryBrowser, createStyleSystemModule, createWarmStoryRenderer, extractCustomTokenNames, generateRestrictedClassesConfig, getAppDesignSystemConfig, getBundlerService, getBundlerServiceFromConfig, getSharedComponentTags, hasStyleSystemProjectConfig, launchBrowserWithFallback, resetStyleSystemConfigCache, resolveAppDesignSystemConfig, resolveStyleSystemThemePath };
|
|
329
|
+
export { BaseBundlerService, BaseCSSClassesService, CSSClassesServiceFactory, ComponentRendererService, DEFAULT_STYLE_SYSTEM_CONFIG, GetCSSClassesTool, GetComponentVisualTool, GetUiComponentService, ListAppComponentsTool, ListSharedComponentsTool, ListThemesTool, MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION, STYLE_SYSTEM_TYPES, StdioTransportHandler, StoriesIndexService, StoryPreviewService, StyleSystemConfigLoader, TailwindCSSClassesService, ThemeService, ViteReactBundlerService, ViteReactNativeBundlerService, WARM_RENDERER_TOOLS, createContainer, createDefaultBundlerService, createServer, createStoryBrowser, createStyleSystemModule, createWarmStoryRenderer, extractCustomTokenNames, generateRestrictedClassesConfig, getAppDesignSystemConfig, getBundlerService, getBundlerServiceFromConfig, getSharedComponentTags, hasStyleSystemProjectConfig, launchBrowserWithFallback, resetStyleSystemConfigCache, resolveAppDesignSystemConfig, resolveStyleSystemThemePath, withRenderSlot };
|