@agimon-ai/po-style-system-tooling 0.2.14-alpha.11 → 0.2.14-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_stdio = require("./stdio-DkQ5zJDm.cjs");
2
+ const require_stdio = require("./stdio-DGIW9Sfo.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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
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, i as createServer$1, k as resolveStyleSystemThemePath, o as STYLE_SYSTEM_VERSION, r as generateRestrictedClassesConfig, s as createContainer, t as StdioTransportHandler, y as getBundlerServiceFromConfig } from "./stdio-B_NECMIh.mjs";
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-BN8nqygh.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-DkQ5zJDm.cjs");
2
+ const require_stdio = require("./stdio-DGIW9Sfo.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);
@@ -101,6 +101,7 @@ const WARM_RENDERER_TOOLS = {
101
101
  * skips the browser launch and the static build. Rendered screenshots come back as base64.
102
102
  */
103
103
  function createWarmStoryRenderer(options = {}) {
104
+ const workspaceRoot = options.workspaceRoot ? node_path.default.resolve(options.workspaceRoot) : void 0;
104
105
  let browser;
105
106
  const sharedBrowser = () => {
106
107
  browser ??= require_stdio.launchBrowserWithFallback().catch((error) => {
@@ -109,21 +110,52 @@ function createWarmStoryRenderer(options = {}) {
109
110
  });
110
111
  return browser;
111
112
  };
113
+ let activeBundler;
114
+ const bundlers = /* @__PURE__ */ new Map();
112
115
  const container = require_stdio.createContainer({
116
+ ...options,
117
+ workspaceRoot,
113
118
  sharedBrowser,
114
- temporaryDirectory: options.temporaryDirectory
119
+ bundlerFactory: () => {
120
+ if (!activeBundler) throw new Error("The story bundler has not been initialized.");
121
+ return activeBundler;
122
+ }
115
123
  });
116
- const bundler = require_stdio.createDefaultBundlerService();
124
+ const configLoader = container.get(require_stdio.STYLE_SYSTEM_TYPES.StyleSystemConfigLoader);
125
+ const createBundler = (config) => config.bundler ? require_stdio.getBundlerService(config.bundler, workspaceRoot) : require_stdio.createDefaultBundlerService(workspaceRoot);
117
126
  let queue = Promise.resolve();
118
127
  let disposed = false;
119
128
  const ensureDevServer = async (appPath) => {
120
- const resolved = node_path.default.resolve(appPath);
129
+ const resolved = node_path.default.resolve(workspaceRoot ?? ".", appPath);
130
+ const { config } = await configLoader.resolveProject(resolved);
131
+ const key = config.bundler ?? "vite-react";
132
+ let pending = bundlers.get(key);
133
+ if (!pending) {
134
+ pending = workspaceRoot ? require_stdio.getBundlerServiceFromConfig({
135
+ workspaceRoot,
136
+ configLoader,
137
+ defaultFactory: () => createBundler(config)
138
+ }) : Promise.resolve(createBundler(config));
139
+ bundlers.set(key, pending);
140
+ pending.catch(() => bundlers.delete(key));
141
+ }
142
+ const bundler = await pending;
143
+ if (activeBundler && activeBundler !== bundler && activeBundler.isServerRunning()) await activeBundler.cleanup();
144
+ activeBundler = bundler;
121
145
  if (bundler.isServerRunning() && bundler.getCurrentAppPath() === resolved) return;
122
146
  if (bundler.isServerRunning()) await bundler.cleanup();
123
147
  await bundler.startDevServer(resolved);
124
148
  };
125
149
  const run = async (tool, input) => {
126
150
  if (disposed) throw new Error("The story renderer is shut down.");
151
+ if (workspaceRoot && typeof input.appPath === "string") {
152
+ const [root, appPath] = await Promise.all([node_fs.promises.realpath(workspaceRoot), node_fs.promises.realpath(node_path.default.resolve(workspaceRoot, input.appPath))]);
153
+ if (!require_stdio.isContained(root, appPath)) throw new Error("appPath must remain inside the configured workspace root.");
154
+ input = {
155
+ ...input,
156
+ appPath
157
+ };
158
+ }
127
159
  if (tool === "get_component_visual" && typeof input.appPath === "string") await ensureDevServer(input.appPath);
128
160
  const result = await container.get(WARM_RENDERER_TOOLS[tool]).execute(input);
129
161
  const text = result.content.flatMap((item) => item.type === "text" && item.text ? [item.text] : []).join("\n\n");
@@ -152,7 +184,7 @@ function createWarmStoryRenderer(options = {}) {
152
184
  await queue;
153
185
  const open = browser;
154
186
  browser = void 0;
155
- await Promise.allSettled([open?.then((instance) => instance.close()), bundler.cleanup()]);
187
+ await Promise.allSettled([open?.then((instance) => instance.close()), ...[...bundlers.values()].map((pending) => pending.then((bundler) => bundler.cleanup()))]);
156
188
  }
157
189
  };
158
190
  }
@@ -203,6 +235,7 @@ Object.defineProperty(exports, "ListThemesTool", {
203
235
  return require_stdio.ListThemesTool;
204
236
  }
205
237
  });
238
+ exports.MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION = require_stdio.MAX_STYLE_SYSTEM_VIEWPORT_DIMENSION;
206
239
  exports.STYLE_SYSTEM_TYPES = require_stdio.STYLE_SYSTEM_TYPES;
207
240
  exports.StdioTransportHandler = require_stdio.StdioTransportHandler;
208
241
  Object.defineProperty(exports, "StoriesIndexService", {
@@ -221,6 +254,7 @@ Object.defineProperty(exports, "StyleSystemConfigLoader", {
221
254
  exports.TailwindCSSClassesService = require_stdio.TailwindCSSClassesService;
222
255
  exports.ThemeService = require_stdio.ThemeService;
223
256
  exports.ViteReactBundlerService = require_stdio.ViteReactBundlerService;
257
+ exports.ViteReactNativeBundlerService = require_stdio.ViteReactNativeBundlerService;
224
258
  exports.WARM_RENDERER_TOOLS = WARM_RENDERER_TOOLS;
225
259
  exports.createContainer = require_stdio.createContainer;
226
260
  exports.createDefaultBundlerService = require_stdio.createDefaultBundlerService;