@agimon-ai/po-style-system-tooling 0.2.14-alpha.2 → 0.2.14-alpha.3
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/LICENSE +149 -21
- package/README.md +1 -1
- package/dist/cli.cjs +8 -3
- package/dist/cli.mjs +9 -4
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.mts +4 -0
- package/dist/index.mjs +1 -1
- package/dist/{stdio-Dgaj2-_8.mjs → stdio-B2oCIjrt.mjs} +54 -30
- package/dist/{stdio-CT9XjOJQ.cjs → stdio-BiO1Kn_N.cjs} +54 -30
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,149 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
License text copyright © 2017 MariaDB Corporation Ab, All Rights Reserved.
|
|
2
|
+
"Business Source License" is a trademark of MariaDB Corporation Ab.
|
|
3
|
+
|
|
4
|
+
Parameters
|
|
5
|
+
|
|
6
|
+
Licensor: Agimon Pty Ltd
|
|
7
|
+
Licensed Work: Po, the software in the Po source repository and the
|
|
8
|
+
packages released from it, in each version released by
|
|
9
|
+
the Licensor.
|
|
10
|
+
The Licensed Work is (c) 2026 Agimon Pty Ltd.
|
|
11
|
+
Material identified as third-party in the "Third-party
|
|
12
|
+
components" section at the end of this file or in a
|
|
13
|
+
NOTICE file, and any package or directory whose own
|
|
14
|
+
license file grants a different license, is not part of
|
|
15
|
+
the Licensed Work and remains under its own license.
|
|
16
|
+
Additional Use Grant: You may make production use of the Licensed Work if
|
|
17
|
+
your use is Eligible Use. "Eligible Use" is production use that falls
|
|
18
|
+
within at least one of the following:
|
|
19
|
+
|
|
20
|
+
(a) Personal Use. Use by an individual for their own personal purposes,
|
|
21
|
+
and not on behalf of, or for the benefit of, an employer, client, or
|
|
22
|
+
other Organization. Use by an individual in the course of employment
|
|
23
|
+
or engagement by an Organization is use by that Organization.
|
|
24
|
+
|
|
25
|
+
(b) Small Organization Use. Use by or on behalf of an Organization whose
|
|
26
|
+
Annual Revenue is less than USD 1,000,000.
|
|
27
|
+
|
|
28
|
+
(c) Non-profit, Education and Research Use. Use, regardless of Annual
|
|
29
|
+
Revenue, by (i) an Organization registered or recognized as a
|
|
30
|
+
non-profit or charitable organization under the laws of its
|
|
31
|
+
jurisdiction, for its non-profit purposes; (ii) an accredited school,
|
|
32
|
+
college, or university, for teaching, learning, or academic research;
|
|
33
|
+
or (iii) a publicly funded research institution, for its research.
|
|
34
|
+
|
|
35
|
+
(d) Service Provider Use. Use by a consultant, contractor, agency, or other
|
|
36
|
+
service provider, regardless of its own Annual Revenue, solely to
|
|
37
|
+
build, deploy, host, operate, or support the Licensed Work for a client
|
|
38
|
+
whose own use would be Eligible Use under (a), (b), or (c). A service
|
|
39
|
+
provider's use for its own purposes is Eligible Use only if the service
|
|
40
|
+
provider itself qualifies under (b) or (c).
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
Hosted services. Offering the Licensed Work to third parties as a hosted
|
|
44
|
+
or managed service whose primary value is the Licensed Work is Eligible
|
|
45
|
+
Use only if each such third party's own use would be Eligible Use.
|
|
46
|
+
|
|
47
|
+
Definitions. "Organization" means any company, partnership, sole
|
|
48
|
+
proprietorship, trust, association, government body, or other entity, and
|
|
49
|
+
includes an individual acting in a business or professional capacity.
|
|
50
|
+
"Affiliate" means any entity that directly or indirectly controls, is
|
|
51
|
+
controlled by, or is under common control with an Organization, where
|
|
52
|
+
"control" means ownership of more than 50% of the voting interests of an
|
|
53
|
+
entity or the power to direct its management and policies by contract or
|
|
54
|
+
otherwise. "Annual Revenue" means the total gross revenue of an
|
|
55
|
+
Organization and all of its Affiliates combined, from all sources and
|
|
56
|
+
whether or not related to the Licensed Work, for its most recently
|
|
57
|
+
completed fiscal year, or, if it has not completed a fiscal year, for the
|
|
58
|
+
twelve months before the use (or since its formation, if shorter),
|
|
59
|
+
converted into US dollars at the average exchange rate for that period.
|
|
60
|
+
Proceeds of equity or debt financing are not revenue.
|
|
61
|
+
|
|
62
|
+
Threshold. If an Organization stops qualifying under (b), its existing
|
|
63
|
+
production use remains Eligible Use for 90 days after it stops
|
|
64
|
+
qualifying, after which it must obtain a commercial license or stop
|
|
65
|
+
production use. Use that was Eligible Use when it occurred never requires
|
|
66
|
+
a commercial license after the fact.
|
|
67
|
+
Change Date: Four years from the date a version of the Licensed Work
|
|
68
|
+
is first publicly released by the Licensor.
|
|
69
|
+
Change License: Apache License, Version 2.0
|
|
70
|
+
|
|
71
|
+
For information about alternative licensing arrangements for the Licensed
|
|
72
|
+
Work, please visit: https://agimon.ai/licensing
|
|
73
|
+
|
|
74
|
+
Notice
|
|
75
|
+
|
|
76
|
+
The Business Source License (this document, or the "License") is not an Open
|
|
77
|
+
Source license. However, the Licensed Work will eventually be made available
|
|
78
|
+
under an Open Source License, as stated in this License.
|
|
79
|
+
|
|
80
|
+
-----------------------------------------------------------------------------
|
|
81
|
+
|
|
82
|
+
Business Source License 1.1
|
|
83
|
+
|
|
84
|
+
Terms
|
|
85
|
+
|
|
86
|
+
The Licensor hereby grants you the right to copy, modify, create derivative
|
|
87
|
+
works, redistribute, and make non-production use of the Licensed Work. The
|
|
88
|
+
Licensor may make an Additional Use Grant, above, permitting limited
|
|
89
|
+
production use.
|
|
90
|
+
|
|
91
|
+
Effective on the Change Date, or the fourth anniversary of the first publicly
|
|
92
|
+
available distribution of a specific version of the Licensed Work under this
|
|
93
|
+
License, whichever comes first, the Licensor hereby grants you rights under
|
|
94
|
+
the terms of the Change License, and the rights granted in the paragraph
|
|
95
|
+
above terminate.
|
|
96
|
+
|
|
97
|
+
If your use of the Licensed Work does not comply with the requirements
|
|
98
|
+
currently in effect as described in this License, you must purchase a
|
|
99
|
+
commercial license from the Licensor, its affiliated entities, or authorized
|
|
100
|
+
resellers, or you must refrain from using the Licensed Work.
|
|
101
|
+
|
|
102
|
+
All copies of the original and modified Licensed Work, and derivative works
|
|
103
|
+
of the Licensed Work, are subject to this License. This License applies
|
|
104
|
+
separately for each version of the Licensed Work and the Change Date may vary
|
|
105
|
+
for each version of the Licensed Work released by Licensor.
|
|
106
|
+
|
|
107
|
+
You must conspicuously display this License on each original or modified copy
|
|
108
|
+
of the Licensed Work. If you receive the Licensed Work in original or
|
|
109
|
+
modified form from a third party, the terms and conditions set forth in this
|
|
110
|
+
License apply to your use of that work.
|
|
111
|
+
|
|
112
|
+
Any use of the Licensed Work in violation of this License will automatically
|
|
113
|
+
terminate your rights under this License for the current and all other
|
|
114
|
+
versions of the Licensed Work.
|
|
115
|
+
|
|
116
|
+
This License does not grant you any right in any trademark or logo of
|
|
117
|
+
Licensor or its affiliates (provided that you may use a trademark or logo of
|
|
118
|
+
Licensor as expressly required by this License).
|
|
119
|
+
|
|
120
|
+
TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
|
|
121
|
+
AN “AS IS” BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
|
|
122
|
+
EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
|
|
123
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
|
|
124
|
+
TITLE.
|
|
125
|
+
|
|
126
|
+
MariaDB hereby grants you permission to use this License’s text to license
|
|
127
|
+
your works, and to refer to it using the trademark “Business Source License”,
|
|
128
|
+
as long as you comply with the Covenants of Licensor below.
|
|
129
|
+
|
|
130
|
+
Covenants of Licensor
|
|
131
|
+
|
|
132
|
+
In consideration of the right to use this License’s text and the “Business
|
|
133
|
+
Source License” name and trademark, Licensor covenants to MariaDB, and to all
|
|
134
|
+
other recipients of the licensed work to be provided by Licensor:
|
|
135
|
+
|
|
136
|
+
1. To specify as the Change License the GPL Version 2.0 or any later version,
|
|
137
|
+
or a license that is compatible with GPL Version 2.0 or a later version,
|
|
138
|
+
where “compatible” means that software provided under the Change License can
|
|
139
|
+
be included in a program with software provided under GPL Version 2.0 or a
|
|
140
|
+
later version. Licensor may specify additional Change Licenses without
|
|
141
|
+
limitation.
|
|
142
|
+
|
|
143
|
+
2. To either: (a) specify an additional grant of rights to use that does not
|
|
144
|
+
impose any additional restriction on the right granted in this License, as
|
|
145
|
+
the Additional Use Grant; or (b) insert the text “None”.
|
|
146
|
+
|
|
147
|
+
3. To specify a Change Date.
|
|
148
|
+
|
|
149
|
+
4. Not to modify this License in any other way.
|
package/README.md
CHANGED
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_stdio = require("./stdio-
|
|
2
|
+
const require_stdio = require("./stdio-BiO1Kn_N.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);
|
|
@@ -138,7 +138,8 @@ const REQUESTABLE_COLOR_SCHEMES = [LIGHT_COLOR_SCHEME, DARK_COLOR_SCHEME];
|
|
|
138
138
|
const getUiComponentCommand = new commander.Command("get-ui-component").description("Get a screenshot of a UI component rendered with app-specific design system configuration. Returns screenshot path and story file content.").requiredOption("-c, --component-name <name>", "The name of the component to capture (e.g., \"Button\", \"Card\")").requiredOption("-a, --app-path <path>", "The app path (relative or absolute) to load design system config from (e.g., \"apps/agiflow-app\")").option("-s, --story-name <name>", "The story name to render (e.g., \"Playground\", \"Default\")", "Playground").option("-d, --dark-mode", "Request dark mode for automatic-theme apps").option("--color-scheme <scheme>", "Request light or dark mode for automatic-theme apps").option("--width <pixels>", "Override the configured viewport width", Number).option("--height <pixels>", "Override the configured viewport height", Number).action(async (options) => {
|
|
139
139
|
try {
|
|
140
140
|
if (options.colorScheme !== void 0 && !REQUESTABLE_COLOR_SCHEMES.includes(options.colorScheme)) throw new Error("--color-scheme must be light or dark");
|
|
141
|
-
const
|
|
141
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
142
|
+
const tool = require_stdio.createContainer({ temporaryDirectory: sessionTemp ? (0, node_path.join)(sessionTemp, "previews") : void 0 }).get(require_stdio.STYLE_SYSTEM_TYPES.GetComponentVisualTool);
|
|
142
143
|
const darkMode = options.colorScheme === DARK_COLOR_SCHEME ? true : options.colorScheme === LIGHT_COLOR_SCHEME ? false : options.darkMode || void 0;
|
|
143
144
|
const result = await tool.execute({
|
|
144
145
|
componentName: options.componentName,
|
|
@@ -405,7 +406,11 @@ const mcpServeCommand = new commander.Command("mcp-serve").description("Start MC
|
|
|
405
406
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
406
407
|
}
|
|
407
408
|
if (transportType === "stdio") {
|
|
408
|
-
const
|
|
409
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
410
|
+
const container = require_stdio.createContainer({
|
|
411
|
+
defaultThemePath: parsed.themePath,
|
|
412
|
+
temporaryDirectory: sessionTemp ? (0, node_path.join)(sessionTemp, "previews") : void 0
|
|
413
|
+
});
|
|
409
414
|
await startServer(new require_stdio.StdioTransportHandler(() => require_stdio.createServer(container)), bundlerService, devServerPort);
|
|
410
415
|
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
411
416
|
const container = require_stdio.createContainer({ defaultThemePath: parsed.themePath });
|
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, R as log, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-
|
|
2
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, N as DEFAULT_STYLE_SYSTEM_CONFIG, P as TailwindCSSClassesService, R as log, a as STYLE_SYSTEM_CLI_NAME, b as getBundlerServiceFromConfig, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler } from "./stdio-B2oCIjrt.mjs";
|
|
3
3
|
import { promises } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
4
|
+
import path, { join } from "node:path";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { registerManagedProcess } from "@agimon-ai/foundation-exec";
|
|
7
7
|
import { createMcpHandler } from "@modelcontextprotocol/server";
|
|
@@ -136,7 +136,8 @@ const REQUESTABLE_COLOR_SCHEMES = [LIGHT_COLOR_SCHEME, DARK_COLOR_SCHEME];
|
|
|
136
136
|
const getUiComponentCommand = new Command("get-ui-component").description("Get a screenshot of a UI component rendered with app-specific design system configuration. Returns screenshot path and story file content.").requiredOption("-c, --component-name <name>", "The name of the component to capture (e.g., \"Button\", \"Card\")").requiredOption("-a, --app-path <path>", "The app path (relative or absolute) to load design system config from (e.g., \"apps/agiflow-app\")").option("-s, --story-name <name>", "The story name to render (e.g., \"Playground\", \"Default\")", "Playground").option("-d, --dark-mode", "Request dark mode for automatic-theme apps").option("--color-scheme <scheme>", "Request light or dark mode for automatic-theme apps").option("--width <pixels>", "Override the configured viewport width", Number).option("--height <pixels>", "Override the configured viewport height", Number).action(async (options) => {
|
|
137
137
|
try {
|
|
138
138
|
if (options.colorScheme !== void 0 && !REQUESTABLE_COLOR_SCHEMES.includes(options.colorScheme)) throw new Error("--color-scheme must be light or dark");
|
|
139
|
-
const
|
|
139
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
140
|
+
const tool = createContainer({ temporaryDirectory: sessionTemp ? join(sessionTemp, "previews") : void 0 }).get(STYLE_SYSTEM_TYPES.GetComponentVisualTool);
|
|
140
141
|
const darkMode = options.colorScheme === DARK_COLOR_SCHEME ? true : options.colorScheme === LIGHT_COLOR_SCHEME ? false : options.darkMode || void 0;
|
|
141
142
|
const result = await tool.execute({
|
|
142
143
|
componentName: options.componentName,
|
|
@@ -403,7 +404,11 @@ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server w
|
|
|
403
404
|
console.error(`Dev server started at ${url} (port: ${port})`);
|
|
404
405
|
}
|
|
405
406
|
if (transportType === "stdio") {
|
|
406
|
-
const
|
|
407
|
+
const sessionTemp = process.env.PO_SESSION_TEMP_DIR;
|
|
408
|
+
const container = createContainer({
|
|
409
|
+
defaultThemePath: parsed.themePath,
|
|
410
|
+
temporaryDirectory: sessionTemp ? join(sessionTemp, "previews") : void 0
|
|
411
|
+
});
|
|
407
412
|
await startServer(new StdioTransportHandler(() => createServer$1(container)), bundlerService, devServerPort);
|
|
408
413
|
} else if (transportType === "http" && parsed.port !== void 0) {
|
|
409
414
|
const container = createContainer({ defaultThemePath: parsed.themePath });
|
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-BiO1Kn_N.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);
|
package/dist/index.d.cts
CHANGED
|
@@ -5,6 +5,7 @@ import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
|
5
5
|
//#region src/container/module.d.ts
|
|
6
6
|
interface StyleSystemModuleOptions {
|
|
7
7
|
defaultThemePath?: string;
|
|
8
|
+
temporaryDirectory?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
10
11
|
//#endregion
|
|
@@ -863,6 +864,8 @@ export declare class ComponentRendererService {
|
|
|
863
864
|
private themeService;
|
|
864
865
|
private appPath;
|
|
865
866
|
private bundlerFactory;
|
|
867
|
+
private log;
|
|
868
|
+
private readonly preserveOutput;
|
|
866
869
|
/**
|
|
867
870
|
* Creates a new ComponentRendererService instance
|
|
868
871
|
* @param designSystemConfig - Design system configuration
|
|
@@ -871,6 +874,7 @@ export declare class ComponentRendererService {
|
|
|
871
874
|
*/
|
|
872
875
|
constructor(designSystemConfig: DesignSystemConfig, appPath: string, options?: {
|
|
873
876
|
bundlerFactory?: BundlerFactory;
|
|
877
|
+
temporaryDirectory?: string;
|
|
874
878
|
});
|
|
875
879
|
/**
|
|
876
880
|
* Get the bundler service instance.
|
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,7 @@ import { AliasOptions, Plugin, UserConfig } from "vite";
|
|
|
5
5
|
//#region src/container/module.d.ts
|
|
6
6
|
interface StyleSystemModuleOptions {
|
|
7
7
|
defaultThemePath?: string;
|
|
8
|
+
temporaryDirectory?: string;
|
|
8
9
|
}
|
|
9
10
|
export declare function createStyleSystemModule(optionsInput?: StyleSystemModuleOptions): ContainerModule;
|
|
10
11
|
//#endregion
|
|
@@ -863,6 +864,8 @@ export declare class ComponentRendererService {
|
|
|
863
864
|
private themeService;
|
|
864
865
|
private appPath;
|
|
865
866
|
private bundlerFactory;
|
|
867
|
+
private log;
|
|
868
|
+
private readonly preserveOutput;
|
|
866
869
|
/**
|
|
867
870
|
* Creates a new ComponentRendererService instance
|
|
868
871
|
* @param designSystemConfig - Design system configuration
|
|
@@ -871,6 +874,7 @@ export declare class ComponentRendererService {
|
|
|
871
874
|
*/
|
|
872
875
|
constructor(designSystemConfig: DesignSystemConfig, appPath: string, options?: {
|
|
873
876
|
bundlerFactory?: BundlerFactory;
|
|
877
|
+
temporaryDirectory?: string;
|
|
874
878
|
});
|
|
875
879
|
/**
|
|
876
880
|
* Get the bundler service instance.
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, L as isContained, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-
|
|
1
|
+
import { A as STYLE_SYSTEM_TYPES, C as getAppDesignSystemConfig, D as resolveAppDesignSystemConfig, E as resetStyleSystemConfigCache, F as BaseCSSClassesService, I as TemplatesManagerService, L as isContained, M as CSSClassesServiceFactory, N as DEFAULT_STYLE_SYSTEM_CONFIG, O as StyleSystemConfigLoader, P as TailwindCSSClassesService, S as BaseBundlerService, T as hasStyleSystemProjectConfig, _ as ThemeService, b as getBundlerServiceFromConfig, c as createStyleSystemModule, d as ListSharedComponentsTool, f as GetComponentVisualTool, g as ComponentRendererService, h as GetUiComponentService, i as createServer, j as StoriesIndexService, k as resolveStyleSystemThemePath, l as PolishComponentTool, m as ListThemesTool, n as extractCustomTokenNames, p as GetCSSClassesTool, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, u as ListAppComponentsTool, v as createDefaultBundlerService, w as getSharedComponentTags, x as ViteReactBundlerService, y as getBundlerService } from "./stdio-B2oCIjrt.mjs";
|
|
2
2
|
import { promises } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -95,12 +95,23 @@ const logger = pino({
|
|
|
95
95
|
mkdir: true,
|
|
96
96
|
sync: true
|
|
97
97
|
}));
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
98
|
+
function createLog(directory) {
|
|
99
|
+
const target = directory === void 0 ? logger : pino({
|
|
100
|
+
level: "debug",
|
|
101
|
+
timestamp: pino.stdTimeFunctions.isoTime
|
|
102
|
+
}, pino.destination({
|
|
103
|
+
dest: path$1.join(directory, "style-system.log"),
|
|
104
|
+
mkdir: true,
|
|
105
|
+
sync: true
|
|
106
|
+
}));
|
|
107
|
+
return {
|
|
108
|
+
debug: (msg, ...args) => target.debug({ args }, msg),
|
|
109
|
+
info: (msg, ...args) => target.info({ args }, msg),
|
|
110
|
+
warn: (msg, ...args) => target.warn({ args }, msg),
|
|
111
|
+
error: (msg, ...args) => target.error({ args }, msg)
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const log = createLog();
|
|
104
115
|
//#endregion
|
|
105
116
|
//#region src/utils/fsHelpers.ts
|
|
106
117
|
/** True when candidate is root itself or inside it (sibling prefixes like `<root>-evil` are outside). */
|
|
@@ -3379,6 +3390,8 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3379
3390
|
themeService;
|
|
3380
3391
|
appPath;
|
|
3381
3392
|
bundlerFactory;
|
|
3393
|
+
log;
|
|
3394
|
+
preserveOutput;
|
|
3382
3395
|
/**
|
|
3383
3396
|
* Creates a new ComponentRendererService instance
|
|
3384
3397
|
* @param designSystemConfig - Design system configuration
|
|
@@ -3388,7 +3401,10 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3388
3401
|
constructor(designSystemConfig, appPath, options = {}) {
|
|
3389
3402
|
if (!appPath) throw new Error("appPath is required for ComponentRendererService");
|
|
3390
3403
|
this.appPath = appPath;
|
|
3391
|
-
this.tmpDir = path.join(os.tmpdir(), "style-system");
|
|
3404
|
+
this.tmpDir = options.temporaryDirectory ?? path.join(os.tmpdir(), "style-system");
|
|
3405
|
+
this.preserveOutput = options.temporaryDirectory !== void 0;
|
|
3406
|
+
if (options.temporaryDirectory !== void 0 && !path.isAbsolute(options.temporaryDirectory)) throw new Error("Renderer temporary directory must be absolute.");
|
|
3407
|
+
this.log = log;
|
|
3392
3408
|
this.themeService = new ThemeService(designSystemConfig);
|
|
3393
3409
|
if (options.bundlerFactory) this.bundlerFactory = options.bundlerFactory;
|
|
3394
3410
|
else if (designSystemConfig.bundler) this.bundlerFactory = () => getBundlerService(designSystemConfig.bundler);
|
|
@@ -3412,17 +3428,25 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3412
3428
|
async renderComponent(componentInfo, options = {}) {
|
|
3413
3429
|
const { storyName = componentInfo.stories[0] || "Default", args = {}, darkMode = false, width = DEFAULT_RENDER_WIDTH, height = DEFAULT_RENDER_HEIGHT } = options;
|
|
3414
3430
|
try {
|
|
3415
|
-
|
|
3416
|
-
|
|
3431
|
+
await promises.mkdir(this.tmpDir, {
|
|
3432
|
+
recursive: true,
|
|
3433
|
+
mode: 448
|
|
3434
|
+
});
|
|
3435
|
+
if (this.preserveOutput) {
|
|
3436
|
+
const info = await promises.lstat(this.tmpDir);
|
|
3437
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await promises.realpath(this.tmpDir) !== this.tmpDir) throw new Error("Unsafe renderer temporary directory.");
|
|
3438
|
+
if (this.log === log) this.log = createLog(this.tmpDir);
|
|
3439
|
+
}
|
|
3440
|
+
this.log.info(`[ComponentRendererService] Rendering ${componentInfo.title} - ${storyName}`);
|
|
3417
3441
|
const designSystemConfig = this.themeService.getConfig();
|
|
3418
|
-
log.info(`[ComponentRendererService] Using theme provider: ${designSystemConfig.themeProvider}`);
|
|
3419
|
-
log.info(`[ComponentRendererService] Design system type: ${designSystemConfig.type}`);
|
|
3420
|
-
if (!await this.themeService.validateThemeProvider()) log.warn(`[ComponentRendererService] Theme provider path may not exist: ${designSystemConfig.themeProvider}`);
|
|
3442
|
+
this.log.info(`[ComponentRendererService] Using theme provider: ${designSystemConfig.themeProvider}`);
|
|
3443
|
+
this.log.info(`[ComponentRendererService] Design system type: ${designSystemConfig.type}`);
|
|
3444
|
+
if (!await this.themeService.validateThemeProvider()) this.log.warn(`[ComponentRendererService] Theme provider path may not exist: ${designSystemConfig.themeProvider}`);
|
|
3421
3445
|
const bundlerService = this.getBundlerService();
|
|
3422
3446
|
let componentUrl;
|
|
3423
3447
|
let htmlFilePath;
|
|
3424
3448
|
if (bundlerService.isServerRunning()) {
|
|
3425
|
-
log.info("[ComponentRendererService] Using dev server for fast rendering");
|
|
3449
|
+
this.log.info("[ComponentRendererService] Using dev server for fast rendering");
|
|
3426
3450
|
try {
|
|
3427
3451
|
const result = await bundlerService.serveComponent({
|
|
3428
3452
|
componentPath: componentInfo.filePath,
|
|
@@ -3437,9 +3461,9 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3437
3461
|
});
|
|
3438
3462
|
componentUrl = result.url;
|
|
3439
3463
|
htmlFilePath = result.htmlFilePath;
|
|
3440
|
-
log.info(`[ComponentRendererService] Component served at: ${componentUrl}`);
|
|
3464
|
+
this.log.info(`[ComponentRendererService] Component served at: ${componentUrl}`);
|
|
3441
3465
|
} catch (devServerError) {
|
|
3442
|
-
log.warn(`[ComponentRendererService] Dev server failed, falling back to static build: ${devServerError instanceof Error ? devServerError.message : String(devServerError)}`);
|
|
3466
|
+
this.log.warn(`[ComponentRendererService] Dev server failed, falling back to static build: ${devServerError instanceof Error ? devServerError.message : String(devServerError)}`);
|
|
3443
3467
|
const result = await bundlerService.prerenderComponent({
|
|
3444
3468
|
componentPath: componentInfo.filePath,
|
|
3445
3469
|
storyName,
|
|
@@ -3453,10 +3477,10 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3453
3477
|
});
|
|
3454
3478
|
componentUrl = `${FILE_URL_PREFIX}${result.htmlFilePath}`;
|
|
3455
3479
|
htmlFilePath = result.htmlFilePath;
|
|
3456
|
-
log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3480
|
+
this.log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3457
3481
|
}
|
|
3458
3482
|
} else {
|
|
3459
|
-
log.info("[ComponentRendererService] No dev server running, using static build");
|
|
3483
|
+
this.log.info("[ComponentRendererService] No dev server running, using static build");
|
|
3460
3484
|
const result = await bundlerService.prerenderComponent({
|
|
3461
3485
|
componentPath: componentInfo.filePath,
|
|
3462
3486
|
storyName,
|
|
@@ -3470,7 +3494,7 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3470
3494
|
});
|
|
3471
3495
|
componentUrl = `${FILE_URL_PREFIX}${result.htmlFilePath}`;
|
|
3472
3496
|
htmlFilePath = result.htmlFilePath;
|
|
3473
|
-
log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3497
|
+
this.log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3474
3498
|
}
|
|
3475
3499
|
const timestamp = Date.now();
|
|
3476
3500
|
const imageName = `${COMPONENT_FILE_PREFIX}${componentInfo.title.split("/").pop()}-${timestamp}-${randomUUID()}.png`;
|
|
@@ -3488,12 +3512,12 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3488
3512
|
generateThumbnail: false,
|
|
3489
3513
|
base64: false
|
|
3490
3514
|
});
|
|
3491
|
-
log.info(`[ComponentRendererService] Screenshot saved to: ${imagePath}`);
|
|
3515
|
+
this.log.info(`[ComponentRendererService] Screenshot saved to: ${imagePath}`);
|
|
3492
3516
|
let html = "";
|
|
3493
3517
|
if (htmlFilePath) {
|
|
3494
3518
|
html = await promises.readFile(htmlFilePath, "utf-8");
|
|
3495
|
-
log.info(`[ComponentRendererService] HTML file kept at: ${htmlFilePath}`);
|
|
3496
|
-
} else log.warn("[ComponentRendererService] No HTML file path available, returning empty HTML content");
|
|
3519
|
+
this.log.info(`[ComponentRendererService] HTML file kept at: ${htmlFilePath}`);
|
|
3520
|
+
} else this.log.warn("[ComponentRendererService] No HTML file path available, returning empty HTML content");
|
|
3497
3521
|
return {
|
|
3498
3522
|
imagePath,
|
|
3499
3523
|
html,
|
|
@@ -3536,20 +3560,20 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3536
3560
|
};
|
|
3537
3561
|
}));
|
|
3538
3562
|
for (const result of statResults) if (result.status === "fulfilled") componentFiles.push(result.value);
|
|
3539
|
-
else log.warn("[ComponentRendererService] Failed to inspect component file during cleanup:", result.reason);
|
|
3563
|
+
else this.log.warn("[ComponentRendererService] Failed to inspect component file during cleanup:", result.reason);
|
|
3540
3564
|
const oldFiles = componentFiles.filter((f) => now - f.mtime > olderThanMs);
|
|
3541
|
-
await Promise.all(oldFiles.map((file) => promises.unlink(file.path).catch((err) => log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3565
|
+
await Promise.all(oldFiles.map((file) => promises.unlink(file.path).catch((err) => this.log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3542
3566
|
let deletedCount = oldFiles.length;
|
|
3543
3567
|
const remainingFiles = componentFiles.filter((f) => now - f.mtime <= olderThanMs);
|
|
3544
3568
|
if (remainingFiles.length > keepCount) {
|
|
3545
3569
|
remainingFiles.sort((a, b) => a.mtime - b.mtime);
|
|
3546
3570
|
const toDelete = remainingFiles.slice(0, remainingFiles.length - keepCount);
|
|
3547
|
-
await Promise.all(toDelete.map((file) => promises.unlink(file.path).catch((err) => log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3571
|
+
await Promise.all(toDelete.map((file) => promises.unlink(file.path).catch((err) => this.log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3548
3572
|
deletedCount += toDelete.length;
|
|
3549
3573
|
}
|
|
3550
|
-
if (deletedCount > 0) log.info(`[ComponentRendererService] Cleaned up ${deletedCount} temp files`);
|
|
3574
|
+
if (deletedCount > 0) this.log.info(`[ComponentRendererService] Cleaned up ${deletedCount} temp files`);
|
|
3551
3575
|
} catch (error) {
|
|
3552
|
-
log.error("[ComponentRendererService] Cleanup error:", error);
|
|
3576
|
+
this.log.error("[ComponentRendererService] Cleanup error:", error);
|
|
3553
3577
|
}
|
|
3554
3578
|
}
|
|
3555
3579
|
/**
|
|
@@ -3559,11 +3583,11 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3559
3583
|
*/
|
|
3560
3584
|
async dispose() {
|
|
3561
3585
|
try {
|
|
3562
|
-
await this.cleanup(void 0, ComponentRendererService.DISPOSE_KEEP_COUNT);
|
|
3586
|
+
if (!this.preserveOutput) await this.cleanup(void 0, ComponentRendererService.DISPOSE_KEEP_COUNT);
|
|
3563
3587
|
const bundlerService = this.getBundlerService();
|
|
3564
3588
|
if (!bundlerService.isServerRunning()) await bundlerService.cleanup();
|
|
3565
3589
|
} catch (error) {
|
|
3566
|
-
log.error("[ComponentRendererService] Dispose error:", error);
|
|
3590
|
+
this.log.error("[ComponentRendererService] Dispose error:", error);
|
|
3567
3591
|
}
|
|
3568
3592
|
}
|
|
3569
3593
|
};
|
|
@@ -4950,7 +4974,7 @@ function createStyleSystemModule(optionsInput = {}) {
|
|
|
4950
4974
|
options.bind(STYLE_SYSTEM_TYPES.AppComponentsService).to(AppComponentsService).inTransientScope();
|
|
4951
4975
|
options.bind(STYLE_SYSTEM_TYPES.GetUiComponentService).to(GetUiComponentService).inSingletonScope();
|
|
4952
4976
|
options.bind(STYLE_SYSTEM_TYPES.StoriesIndexFactory).toConstantValue(() => new StoriesIndexService());
|
|
4953
|
-
options.bind(STYLE_SYSTEM_TYPES.RendererFactory).toConstantValue((config, appPath) => new ComponentRendererService(config, appPath));
|
|
4977
|
+
options.bind(STYLE_SYSTEM_TYPES.RendererFactory).toConstantValue((config, appPath) => new ComponentRendererService(config, appPath, { temporaryDirectory: optionsInput.temporaryDirectory }));
|
|
4954
4978
|
options.bind(STYLE_SYSTEM_TYPES.ListThemesTool).to(ListThemesTool).inSingletonScope();
|
|
4955
4979
|
options.bind(STYLE_SYSTEM_TYPES.GetCSSClassesTool).to(GetCSSClassesTool).inSingletonScope();
|
|
4956
4980
|
options.bind(STYLE_SYSTEM_TYPES.GetComponentVisualTool).to(GetComponentVisualTool).inSingletonScope();
|
|
@@ -4968,7 +4992,7 @@ function createContainer(options) {
|
|
|
4968
4992
|
}
|
|
4969
4993
|
//#endregion
|
|
4970
4994
|
//#region package.json
|
|
4971
|
-
var version = "0.2.14-alpha.
|
|
4995
|
+
var version = "0.2.14-alpha.3";
|
|
4972
4996
|
//#endregion
|
|
4973
4997
|
//#region src/metadata.ts
|
|
4974
4998
|
const STYLE_SYSTEM_CLI_NAME = "style-system";
|
|
@@ -122,12 +122,23 @@ const logger = (0, pino.default)({
|
|
|
122
122
|
mkdir: true,
|
|
123
123
|
sync: true
|
|
124
124
|
}));
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
125
|
+
function createLog(directory) {
|
|
126
|
+
const target = directory === void 0 ? logger : (0, pino.default)({
|
|
127
|
+
level: "debug",
|
|
128
|
+
timestamp: pino.default.stdTimeFunctions.isoTime
|
|
129
|
+
}, pino.default.destination({
|
|
130
|
+
dest: node_path.join(directory, "style-system.log"),
|
|
131
|
+
mkdir: true,
|
|
132
|
+
sync: true
|
|
133
|
+
}));
|
|
134
|
+
return {
|
|
135
|
+
debug: (msg, ...args) => target.debug({ args }, msg),
|
|
136
|
+
info: (msg, ...args) => target.info({ args }, msg),
|
|
137
|
+
warn: (msg, ...args) => target.warn({ args }, msg),
|
|
138
|
+
error: (msg, ...args) => target.error({ args }, msg)
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
const log = createLog();
|
|
131
142
|
//#endregion
|
|
132
143
|
//#region src/utils/fsHelpers.ts
|
|
133
144
|
/** True when candidate is root itself or inside it (sibling prefixes like `<root>-evil` are outside). */
|
|
@@ -3406,6 +3417,8 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3406
3417
|
themeService;
|
|
3407
3418
|
appPath;
|
|
3408
3419
|
bundlerFactory;
|
|
3420
|
+
log;
|
|
3421
|
+
preserveOutput;
|
|
3409
3422
|
/**
|
|
3410
3423
|
* Creates a new ComponentRendererService instance
|
|
3411
3424
|
* @param designSystemConfig - Design system configuration
|
|
@@ -3415,7 +3428,10 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3415
3428
|
constructor(designSystemConfig, appPath, options = {}) {
|
|
3416
3429
|
if (!appPath) throw new Error("appPath is required for ComponentRendererService");
|
|
3417
3430
|
this.appPath = appPath;
|
|
3418
|
-
this.tmpDir = node_path.default.join(node_os.default.tmpdir(), "style-system");
|
|
3431
|
+
this.tmpDir = options.temporaryDirectory ?? node_path.default.join(node_os.default.tmpdir(), "style-system");
|
|
3432
|
+
this.preserveOutput = options.temporaryDirectory !== void 0;
|
|
3433
|
+
if (options.temporaryDirectory !== void 0 && !node_path.default.isAbsolute(options.temporaryDirectory)) throw new Error("Renderer temporary directory must be absolute.");
|
|
3434
|
+
this.log = log;
|
|
3419
3435
|
this.themeService = new ThemeService(designSystemConfig);
|
|
3420
3436
|
if (options.bundlerFactory) this.bundlerFactory = options.bundlerFactory;
|
|
3421
3437
|
else if (designSystemConfig.bundler) this.bundlerFactory = () => getBundlerService(designSystemConfig.bundler);
|
|
@@ -3439,17 +3455,25 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3439
3455
|
async renderComponent(componentInfo, options = {}) {
|
|
3440
3456
|
const { storyName = componentInfo.stories[0] || "Default", args = {}, darkMode = false, width = DEFAULT_RENDER_WIDTH, height = DEFAULT_RENDER_HEIGHT } = options;
|
|
3441
3457
|
try {
|
|
3442
|
-
|
|
3443
|
-
|
|
3458
|
+
await node_fs.promises.mkdir(this.tmpDir, {
|
|
3459
|
+
recursive: true,
|
|
3460
|
+
mode: 448
|
|
3461
|
+
});
|
|
3462
|
+
if (this.preserveOutput) {
|
|
3463
|
+
const info = await node_fs.promises.lstat(this.tmpDir);
|
|
3464
|
+
if (!info.isDirectory() || info.isSymbolicLink() || await node_fs.promises.realpath(this.tmpDir) !== this.tmpDir) throw new Error("Unsafe renderer temporary directory.");
|
|
3465
|
+
if (this.log === log) this.log = createLog(this.tmpDir);
|
|
3466
|
+
}
|
|
3467
|
+
this.log.info(`[ComponentRendererService] Rendering ${componentInfo.title} - ${storyName}`);
|
|
3444
3468
|
const designSystemConfig = this.themeService.getConfig();
|
|
3445
|
-
log.info(`[ComponentRendererService] Using theme provider: ${designSystemConfig.themeProvider}`);
|
|
3446
|
-
log.info(`[ComponentRendererService] Design system type: ${designSystemConfig.type}`);
|
|
3447
|
-
if (!await this.themeService.validateThemeProvider()) log.warn(`[ComponentRendererService] Theme provider path may not exist: ${designSystemConfig.themeProvider}`);
|
|
3469
|
+
this.log.info(`[ComponentRendererService] Using theme provider: ${designSystemConfig.themeProvider}`);
|
|
3470
|
+
this.log.info(`[ComponentRendererService] Design system type: ${designSystemConfig.type}`);
|
|
3471
|
+
if (!await this.themeService.validateThemeProvider()) this.log.warn(`[ComponentRendererService] Theme provider path may not exist: ${designSystemConfig.themeProvider}`);
|
|
3448
3472
|
const bundlerService = this.getBundlerService();
|
|
3449
3473
|
let componentUrl;
|
|
3450
3474
|
let htmlFilePath;
|
|
3451
3475
|
if (bundlerService.isServerRunning()) {
|
|
3452
|
-
log.info("[ComponentRendererService] Using dev server for fast rendering");
|
|
3476
|
+
this.log.info("[ComponentRendererService] Using dev server for fast rendering");
|
|
3453
3477
|
try {
|
|
3454
3478
|
const result = await bundlerService.serveComponent({
|
|
3455
3479
|
componentPath: componentInfo.filePath,
|
|
@@ -3464,9 +3488,9 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3464
3488
|
});
|
|
3465
3489
|
componentUrl = result.url;
|
|
3466
3490
|
htmlFilePath = result.htmlFilePath;
|
|
3467
|
-
log.info(`[ComponentRendererService] Component served at: ${componentUrl}`);
|
|
3491
|
+
this.log.info(`[ComponentRendererService] Component served at: ${componentUrl}`);
|
|
3468
3492
|
} catch (devServerError) {
|
|
3469
|
-
log.warn(`[ComponentRendererService] Dev server failed, falling back to static build: ${devServerError instanceof Error ? devServerError.message : String(devServerError)}`);
|
|
3493
|
+
this.log.warn(`[ComponentRendererService] Dev server failed, falling back to static build: ${devServerError instanceof Error ? devServerError.message : String(devServerError)}`);
|
|
3470
3494
|
const result = await bundlerService.prerenderComponent({
|
|
3471
3495
|
componentPath: componentInfo.filePath,
|
|
3472
3496
|
storyName,
|
|
@@ -3480,10 +3504,10 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3480
3504
|
});
|
|
3481
3505
|
componentUrl = `${FILE_URL_PREFIX}${result.htmlFilePath}`;
|
|
3482
3506
|
htmlFilePath = result.htmlFilePath;
|
|
3483
|
-
log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3507
|
+
this.log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3484
3508
|
}
|
|
3485
3509
|
} else {
|
|
3486
|
-
log.info("[ComponentRendererService] No dev server running, using static build");
|
|
3510
|
+
this.log.info("[ComponentRendererService] No dev server running, using static build");
|
|
3487
3511
|
const result = await bundlerService.prerenderComponent({
|
|
3488
3512
|
componentPath: componentInfo.filePath,
|
|
3489
3513
|
storyName,
|
|
@@ -3497,7 +3521,7 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3497
3521
|
});
|
|
3498
3522
|
componentUrl = `${FILE_URL_PREFIX}${result.htmlFilePath}`;
|
|
3499
3523
|
htmlFilePath = result.htmlFilePath;
|
|
3500
|
-
log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3524
|
+
this.log.info(`[ComponentRendererService] HTML built to: ${htmlFilePath}`);
|
|
3501
3525
|
}
|
|
3502
3526
|
const timestamp = Date.now();
|
|
3503
3527
|
const imageName = `${COMPONENT_FILE_PREFIX}${componentInfo.title.split("/").pop()}-${timestamp}-${(0, node_crypto.randomUUID)()}.png`;
|
|
@@ -3515,12 +3539,12 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3515
3539
|
generateThumbnail: false,
|
|
3516
3540
|
base64: false
|
|
3517
3541
|
});
|
|
3518
|
-
log.info(`[ComponentRendererService] Screenshot saved to: ${imagePath}`);
|
|
3542
|
+
this.log.info(`[ComponentRendererService] Screenshot saved to: ${imagePath}`);
|
|
3519
3543
|
let html = "";
|
|
3520
3544
|
if (htmlFilePath) {
|
|
3521
3545
|
html = await node_fs.promises.readFile(htmlFilePath, "utf-8");
|
|
3522
|
-
log.info(`[ComponentRendererService] HTML file kept at: ${htmlFilePath}`);
|
|
3523
|
-
} else log.warn("[ComponentRendererService] No HTML file path available, returning empty HTML content");
|
|
3546
|
+
this.log.info(`[ComponentRendererService] HTML file kept at: ${htmlFilePath}`);
|
|
3547
|
+
} else this.log.warn("[ComponentRendererService] No HTML file path available, returning empty HTML content");
|
|
3524
3548
|
return {
|
|
3525
3549
|
imagePath,
|
|
3526
3550
|
html,
|
|
@@ -3563,20 +3587,20 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3563
3587
|
};
|
|
3564
3588
|
}));
|
|
3565
3589
|
for (const result of statResults) if (result.status === "fulfilled") componentFiles.push(result.value);
|
|
3566
|
-
else log.warn("[ComponentRendererService] Failed to inspect component file during cleanup:", result.reason);
|
|
3590
|
+
else this.log.warn("[ComponentRendererService] Failed to inspect component file during cleanup:", result.reason);
|
|
3567
3591
|
const oldFiles = componentFiles.filter((f) => now - f.mtime > olderThanMs);
|
|
3568
|
-
await Promise.all(oldFiles.map((file) => node_fs.promises.unlink(file.path).catch((err) => log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3592
|
+
await Promise.all(oldFiles.map((file) => node_fs.promises.unlink(file.path).catch((err) => this.log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3569
3593
|
let deletedCount = oldFiles.length;
|
|
3570
3594
|
const remainingFiles = componentFiles.filter((f) => now - f.mtime <= olderThanMs);
|
|
3571
3595
|
if (remainingFiles.length > keepCount) {
|
|
3572
3596
|
remainingFiles.sort((a, b) => a.mtime - b.mtime);
|
|
3573
3597
|
const toDelete = remainingFiles.slice(0, remainingFiles.length - keepCount);
|
|
3574
|
-
await Promise.all(toDelete.map((file) => node_fs.promises.unlink(file.path).catch((err) => log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3598
|
+
await Promise.all(toDelete.map((file) => node_fs.promises.unlink(file.path).catch((err) => this.log.warn("[ComponentRendererService] Failed to delete file:", file.path, err))));
|
|
3575
3599
|
deletedCount += toDelete.length;
|
|
3576
3600
|
}
|
|
3577
|
-
if (deletedCount > 0) log.info(`[ComponentRendererService] Cleaned up ${deletedCount} temp files`);
|
|
3601
|
+
if (deletedCount > 0) this.log.info(`[ComponentRendererService] Cleaned up ${deletedCount} temp files`);
|
|
3578
3602
|
} catch (error) {
|
|
3579
|
-
log.error("[ComponentRendererService] Cleanup error:", error);
|
|
3603
|
+
this.log.error("[ComponentRendererService] Cleanup error:", error);
|
|
3580
3604
|
}
|
|
3581
3605
|
}
|
|
3582
3606
|
/**
|
|
@@ -3586,11 +3610,11 @@ var ComponentRendererService = class ComponentRendererService {
|
|
|
3586
3610
|
*/
|
|
3587
3611
|
async dispose() {
|
|
3588
3612
|
try {
|
|
3589
|
-
await this.cleanup(void 0, ComponentRendererService.DISPOSE_KEEP_COUNT);
|
|
3613
|
+
if (!this.preserveOutput) await this.cleanup(void 0, ComponentRendererService.DISPOSE_KEEP_COUNT);
|
|
3590
3614
|
const bundlerService = this.getBundlerService();
|
|
3591
3615
|
if (!bundlerService.isServerRunning()) await bundlerService.cleanup();
|
|
3592
3616
|
} catch (error) {
|
|
3593
|
-
log.error("[ComponentRendererService] Dispose error:", error);
|
|
3617
|
+
this.log.error("[ComponentRendererService] Dispose error:", error);
|
|
3594
3618
|
}
|
|
3595
3619
|
}
|
|
3596
3620
|
};
|
|
@@ -4977,7 +5001,7 @@ function createStyleSystemModule(optionsInput = {}) {
|
|
|
4977
5001
|
options.bind(STYLE_SYSTEM_TYPES.AppComponentsService).to(AppComponentsService).inTransientScope();
|
|
4978
5002
|
options.bind(STYLE_SYSTEM_TYPES.GetUiComponentService).to(GetUiComponentService).inSingletonScope();
|
|
4979
5003
|
options.bind(STYLE_SYSTEM_TYPES.StoriesIndexFactory).toConstantValue(() => new StoriesIndexService());
|
|
4980
|
-
options.bind(STYLE_SYSTEM_TYPES.RendererFactory).toConstantValue((config, appPath) => new ComponentRendererService(config, appPath));
|
|
5004
|
+
options.bind(STYLE_SYSTEM_TYPES.RendererFactory).toConstantValue((config, appPath) => new ComponentRendererService(config, appPath, { temporaryDirectory: optionsInput.temporaryDirectory }));
|
|
4981
5005
|
options.bind(STYLE_SYSTEM_TYPES.ListThemesTool).to(ListThemesTool).inSingletonScope();
|
|
4982
5006
|
options.bind(STYLE_SYSTEM_TYPES.GetCSSClassesTool).to(GetCSSClassesTool).inSingletonScope();
|
|
4983
5007
|
options.bind(STYLE_SYSTEM_TYPES.GetComponentVisualTool).to(GetComponentVisualTool).inSingletonScope();
|
|
@@ -4995,7 +5019,7 @@ function createContainer(options) {
|
|
|
4995
5019
|
}
|
|
4996
5020
|
//#endregion
|
|
4997
5021
|
//#region package.json
|
|
4998
|
-
var version = "0.2.14-alpha.
|
|
5022
|
+
var version = "0.2.14-alpha.3";
|
|
4999
5023
|
//#endregion
|
|
5000
5024
|
//#region src/metadata.ts
|
|
5001
5025
|
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.3",
|
|
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",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"typescript"
|
|
12
12
|
],
|
|
13
13
|
"homepage": "https://agimon.ai",
|
|
14
|
-
"license": "
|
|
14
|
+
"license": "BUSL-1.1",
|
|
15
15
|
"author": "Vuong Ngo",
|
|
16
16
|
"bin": {
|
|
17
17
|
"po-style-system-tooling": "./dist/cli.mjs"
|