@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
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
17206
|
-
// Storybook over HTTPS
|
|
17207
|
-
//
|
|
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
|
-
...
|
|
17211
|
+
...hmrOverride && {
|
|
17210
17212
|
hmr: {
|
|
17211
|
-
|
|
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
|
-
|
|
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
|
-
|
|
4
|
+
globalThis.require = createRequire(import.meta.url);
|
|
4
5
|
var browser = null;
|
|
5
6
|
async function getBrowser() {
|
|
6
7
|
if (!browser) {
|