@onlook/storybook-plugin 0.3.2-beta.0 → 0.3.2-beta.2

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/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ import { createRequire } from 'node:module';
2
3
  import { command, string, boolean, run } from '@drizzle-team/brocli';
3
4
  import { spawn } from 'child_process';
4
5
  import fs, { readFileSync, existsSync } from 'fs';
@@ -6,6 +7,7 @@ import path, { resolve, join, dirname } from 'path';
6
7
  import crypto from 'crypto';
7
8
  import { chromium } from 'playwright';
8
9
 
10
+ globalThis.require = createRequire(import.meta.url);
9
11
  var CACHE_DIR = path.join(process.cwd(), ".storybook-cache");
10
12
  var SCREENSHOTS_DIR = path.join(CACHE_DIR, "screenshots");
11
13
  var MANIFEST_PATH = path.join(CACHE_DIR, "manifest.json");
package/dist/index.d.ts CHANGED
@@ -7,12 +7,17 @@ type OnlookPluginOptions = {
7
7
  /** Additional allowed origins for CORS (merged with defaults) */
8
8
  allowedOrigins?: string[];
9
9
  /**
10
- * Set when this plugin runs inside an E2B sandbox. Enables the
11
- * WSS:443 HMR override required for Vite's HMR client to talk back
12
- * through E2B's HTTPS port-proxy. Leave false (default) for local
13
- * `bun dev:storybook` so HMR uses Vite defaults and actually fires.
10
+ * Override Vite's HMR client config. Set when Storybook is fronted by
11
+ * an HTTPS reverse proxy (sandbox runtime, ngrok, Cloudflare tunnel,
12
+ * etc.) so the in-page HMR client connects via WSS on the public port
13
+ * instead of `ws://localhost:<port>`. Plugin fills in the internal
14
+ * `port` so callers only specify what changes (`protocol`, `clientPort`).
15
+ * Leave undefined locally so Vite defaults apply and HMR fires.
14
16
  */
15
- e2b?: boolean;
17
+ hmr?: {
18
+ protocol?: 'ws' | 'wss';
19
+ clientPort?: number;
20
+ };
16
21
  };
17
22
  declare function storybookOnlookPlugin(options?: OnlookPluginOptions): PluginOption[];
18
23
 
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { createRequire } from 'node:module';
1
2
  import CJS_COMPAT_NODE_URL_at6j9ae2j2t, { fileURLToPath } from 'url';
2
3
  import path5, { dirname, join, relative } from 'path';
3
4
  import CJS_COMPAT_NODE_MODULE_at6j9ae2j2t from 'module';
@@ -14,6 +15,7 @@ import * as k from 'readline';
14
15
  import k__default from 'readline';
15
16
  import { ReadStream } from 'tty';
16
17
 
18
+ globalThis.require = createRequire(import.meta.url);
17
19
  var __create = Object.create;
18
20
  var __defProp = Object.defineProperty;
19
21
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -17189,27 +17191,26 @@ function storybookOnlookPlugin(options = {}) {
17189
17191
  }
17190
17192
  const port = options.port ?? 6006;
17191
17193
  const allowedOrigins = [...DEFAULT_ALLOWED_ORIGINS, ...options.allowedOrigins ?? []];
17192
- const isE2B = options.e2b === true;
17194
+ const hmrOverride = options.hmr;
17193
17195
  console.log("[STORYBOOK_PLUGIN] Plugin initialized", {
17194
17196
  port,
17195
17197
  allowedOrigins,
17196
17198
  storybookLocation,
17197
17199
  repoRoot,
17198
- e2b: isE2B
17200
+ hmr: hmrOverride ?? null
17199
17201
  });
17200
17202
  const mainPlugin = {
17201
17203
  name: "storybook-onlook-plugin",
17202
17204
  config() {
17203
17205
  return {
17204
17206
  server: {
17205
- // HMR override only applies inside E2B sandboxes they front
17206
- // Storybook over HTTPS:443, so the Vite HMR client must connect
17207
- // via WSS:443. Locally, omitting this lets Vite use defaults
17207
+ // HMR override applies only when the caller explicitly opts in
17208
+ // (typically: Storybook fronted over HTTPS by a reverse proxy).
17209
+ // Locally, omitting this lets Vite use defaults
17208
17210
  // (ws://localhost:<port>) and HMR works as expected.
17209
- ...isE2B && {
17211
+ ...hmrOverride && {
17210
17212
  hmr: {
17211
- protocol: "wss",
17212
- clientPort: 443,
17213
+ ...hmrOverride,
17213
17214
  port
17214
17215
  }
17215
17216
  },
@@ -1,9 +1,10 @@
1
+ import { createRequire } from 'node:module';
1
2
  import crypto from 'crypto';
2
3
  import fs from 'fs';
3
4
  import path from 'path';
4
5
  import { chromium } from 'playwright';
5
6
 
6
- // src/utils/fileSystem/fileSystem.ts
7
+ globalThis.require = createRequire(import.meta.url);
7
8
  var CACHE_DIR = path.join(process.cwd(), ".storybook-cache");
8
9
  var SCREENSHOTS_DIR = path.join(CACHE_DIR, "screenshots");
9
10
  var MANIFEST_PATH = path.join(CACHE_DIR, "manifest.json");
@@ -1,6 +1,7 @@
1
+ import { createRequire } from 'node:module';
1
2
  import { chromium } from 'playwright';
2
3
 
3
- // src/screenshot-service/utils/browser/browser.ts
4
+ globalThis.require = createRequire(import.meta.url);
4
5
  var browser = null;
5
6
  async function getBrowser() {
6
7
  if (!browser) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onlook/storybook-plugin",
3
- "version": "0.3.2-beta.0",
3
+ "version": "0.3.2-beta.2",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "onlook-storybook": "./dist/cli/index.js"