@onlook/storybook-plugin 0.3.7-beta.0 → 0.3.8-beta.0
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/index.js +28 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16982,6 +16982,31 @@ function notifyOnbookIndexChanged() {
|
|
|
16982
16982
|
}, DEBOUNCE_MS);
|
|
16983
16983
|
}
|
|
16984
16984
|
|
|
16985
|
+
// src/utils/notifyOnbookIndexChanged/waitForIndexAndBroadcast.ts
|
|
16986
|
+
var PROBE_INTERVAL_MS = 500;
|
|
16987
|
+
var PROBE_CEILING_MS = 5 * 60 * 1e3;
|
|
16988
|
+
async function waitForIndexAndBroadcast(port = 6006) {
|
|
16989
|
+
const url = `http://localhost:${port}/onbook-index.json`;
|
|
16990
|
+
const deadline = Date.now() + PROBE_CEILING_MS;
|
|
16991
|
+
while (Date.now() < deadline) {
|
|
16992
|
+
try {
|
|
16993
|
+
const res = await fetch(url, {
|
|
16994
|
+
signal: AbortSignal.timeout(2e3)
|
|
16995
|
+
});
|
|
16996
|
+
if (res.ok) {
|
|
16997
|
+
notifyOnbookIndexChanged();
|
|
16998
|
+
return;
|
|
16999
|
+
}
|
|
17000
|
+
} catch {
|
|
17001
|
+
}
|
|
17002
|
+
await new Promise((r2) => setTimeout(r2, PROBE_INTERVAL_MS));
|
|
17003
|
+
}
|
|
17004
|
+
console.warn("[STORYBOOK_PLUGIN] waitForIndexAndBroadcast hit ceiling without a 2xx", {
|
|
17005
|
+
url,
|
|
17006
|
+
ceilingMs: PROBE_CEILING_MS
|
|
17007
|
+
});
|
|
17008
|
+
}
|
|
17009
|
+
|
|
16985
17010
|
// src/handlers/handleStoryFileChange/handleStoryFileChange.ts
|
|
16986
17011
|
var cachedIndex = null;
|
|
16987
17012
|
var indexFetchPromise = null;
|
|
@@ -17392,10 +17417,12 @@ function storybookOnlookPlugin(options = {}) {
|
|
|
17392
17417
|
server.watcher.on("add", scheduleRefresh);
|
|
17393
17418
|
server.watcher.on("change", scheduleRefresh);
|
|
17394
17419
|
server.httpServer?.once("listening", () => {
|
|
17420
|
+
const probePort = server.config.server.port ?? port;
|
|
17395
17421
|
console.log("[STORYBOOK_PLUGIN] Server is listening", {
|
|
17396
|
-
port:
|
|
17422
|
+
port: probePort,
|
|
17397
17423
|
host: server.config.server.host
|
|
17398
17424
|
});
|
|
17425
|
+
void waitForIndexAndBroadcast(probePort);
|
|
17399
17426
|
});
|
|
17400
17427
|
},
|
|
17401
17428
|
configurePreviewServer(server) {
|