storybook 9.1.0-alpha.9 → 9.1.0-beta.1
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/bin/index.cjs +66 -66
- package/dist/bin/index.js +65 -65
- package/dist/cli/bin/index.cjs +1 -1
- package/dist/cli/bin/index.js +1 -1
- package/dist/common/index.cjs +2103 -2103
- package/dist/common/index.js +3197 -3197
- package/dist/components/index.cjs +289 -290
- package/dist/components/index.js +2 -3
- package/dist/core-server/presets/common-manager.js +2243 -2228
- package/dist/core-server/presets/common-preset.cjs +4761 -4759
- package/dist/core-server/presets/common-preset.js +9645 -9643
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.cjs +2 -1
- package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +2 -1
- package/dist/csf/index.cjs +40 -41
- package/dist/csf/index.js +2 -3
- package/dist/instrumenter/index.cjs +370 -352
- package/dist/instrumenter/index.d.ts +24 -3
- package/dist/instrumenter/index.js +268 -250
- package/dist/manager/globals-runtime.js +38 -21
- package/dist/manager-api/index.cjs +1 -1
- package/dist/manager-api/index.d.ts +8 -534
- package/dist/manager-api/index.js +1 -1
- package/dist/preview/runtime.js +3894 -3870
- package/dist/preview-api/index.cjs +43 -37
- package/dist/preview-api/index.d.ts +3 -1
- package/dist/preview-api/index.js +234 -227
- package/dist/telemetry/index.cjs +506 -507
- package/dist/telemetry/index.js +974 -975
- package/package.json +1 -1
|
@@ -889,21 +889,21 @@ var On = I((re) => {
|
|
|
889
889
|
if (typeof r != "string")
|
|
890
890
|
return p;
|
|
891
891
|
let y = r.length, h = "", x = -1, R = -1, m = -1, b = p, w, f = "", g = "", A = !1, S = !1, C = !1, M = !1, j = !1, G = !1, ve = !1, U = 0,
|
|
892
|
-
|
|
892
|
+
F = -1, W = -1, Ft = -1;
|
|
893
893
|
for (let O = 0; O < y + 1; O++) {
|
|
894
894
|
if (U = O !== y ? r.charCodeAt(O) : c, U === c) {
|
|
895
|
-
if (ve = R > x, ve || (R = O), m !== R - 1 && (g = Or(r, m + 1,
|
|
895
|
+
if (ve = R > x, ve || (R = O), m !== R - 1 && (g = Or(r, m + 1, F > -1 ? F : R, C, A), f = o(g), w !== void 0 && (b = (0, Ir.getDeepObject)(
|
|
896
896
|
b, w, f, u && j, u && G))), ve || f !== "") {
|
|
897
897
|
ve && (h = r.slice(R + 1, O), M && (h = h.replace(Fn, " ")), S && (h = (0, Pn.default)(h) || h));
|
|
898
898
|
let je = t(h, f);
|
|
899
899
|
if (a) {
|
|
900
900
|
let tr = b[f];
|
|
901
|
-
tr === void 0 ?
|
|
901
|
+
tr === void 0 ? F > -1 ? b[f] = [je] : b[f] = je : tr.pop ? tr.push(je) : b[f] = [tr, je];
|
|
902
902
|
} else
|
|
903
903
|
b[f] = je;
|
|
904
904
|
}
|
|
905
|
-
h = "", x = O, R = O, A = !1, S = !1, C = !1, M = !1, j = !1, G = !1,
|
|
906
|
-
} else U === 93 ? (a && n === "bracket" && Ft === 91 && (
|
|
905
|
+
h = "", x = O, R = O, A = !1, S = !1, C = !1, M = !1, j = !1, G = !1, F = -1, m = O, b = p, w = void 0, f = "";
|
|
906
|
+
} else U === 93 ? (a && n === "bracket" && Ft === 91 && (F = W), i && (l === "index" || u) && R <= x && (m !== W && (g = Or(r, m + 1, O,
|
|
907
907
|
C, A), f = o(g), w !== void 0 && (b = (0, Ir.getDeepObject)(b, w, f, void 0, u)), w = f, C = !1, A = !1), m = O, G = !0, j = !1)) : U ===
|
|
908
908
|
46 ? i && (l === "dot" || u) && R <= x && (m !== W && (g = Or(r, m + 1, O, C, A), f = o(g), w !== void 0 && (b = (0, Ir.getDeepObject)(
|
|
909
909
|
b, w, f, u)), w = f, C = !1, A = !1), j = !0, G = !1, m = O) : U === 91 ? i && (l === "index" || u) && R <= x && (m !== W && (g = Or(r,
|
|
@@ -3269,9 +3269,8 @@ var Ko = require("storybook/internal/csf"), Xo = require("storybook/internal/csf
|
|
|
3269
3269
|
function Rr() {
|
|
3270
3270
|
try {
|
|
3271
3271
|
return (
|
|
3272
|
-
// @ts-expect-error
|
|
3273
|
-
!!globalThis.__vitest_browser__ ||
|
|
3274
|
-
!!globalThis.__playwright__binding__
|
|
3272
|
+
// @ts-expect-error This property exists in Vitest browser mode
|
|
3273
|
+
!!globalThis.__vitest_browser__ || !!globalThis.window?.navigator?.userAgent?.match(/StorybookTestRunner/)
|
|
3275
3274
|
);
|
|
3276
3275
|
} catch {
|
|
3277
3276
|
return !1;
|
|
@@ -3816,7 +3815,7 @@ var di = /* @__PURE__ */ s((r, e, t) => {
|
|
|
3816
3815
|
}, "sortStoriesV7");
|
|
3817
3816
|
|
|
3818
3817
|
// src/preview-api/modules/preview-web/Preview.tsx
|
|
3819
|
-
var $e = require("storybook/internal/client-logger"),
|
|
3818
|
+
var $e = require("storybook/internal/client-logger"), P = require("storybook/internal/core-events"), D = require("storybook/internal/preview-errors"),
|
|
3820
3819
|
hn = require("@storybook/global");
|
|
3821
3820
|
|
|
3822
3821
|
// src/preview-api/modules/preview-web/render/StoryRender.ts
|
|
@@ -3924,13 +3923,13 @@ var be = class {
|
|
|
3924
3923
|
abortSignal: m,
|
|
3925
3924
|
canvasElement: o,
|
|
3926
3925
|
loaded: {},
|
|
3927
|
-
step: /* @__PURE__ */ s((
|
|
3926
|
+
step: /* @__PURE__ */ s((F, W) => R(F, W, f), "step"),
|
|
3928
3927
|
context: null,
|
|
3929
3928
|
canvas: {},
|
|
3930
3929
|
userEvent: {},
|
|
3931
3930
|
renderToCanvas: /* @__PURE__ */ s(async () => {
|
|
3932
|
-
let
|
|
3933
|
-
this.teardownRender =
|
|
3931
|
+
let F = await this.renderToScreen(g, o);
|
|
3932
|
+
this.teardownRender = F || (() => {
|
|
3934
3933
|
}), b = !0;
|
|
3935
3934
|
}, "renderToCanvas"),
|
|
3936
3935
|
// The story provides (set in a renderer) a mount function that is a higher order function
|
|
@@ -3938,11 +3937,11 @@ var be = class {
|
|
|
3938
3937
|
//
|
|
3939
3938
|
// Before assigning it to the context, we resolve the context dependency,
|
|
3940
3939
|
// so that a user can just call it as await mount(...args) in their play function.
|
|
3941
|
-
mount: /* @__PURE__ */ s(async (...
|
|
3940
|
+
mount: /* @__PURE__ */ s(async (...F) => {
|
|
3942
3941
|
this.callbacks.showStoryDuringRender?.();
|
|
3943
3942
|
let W = null;
|
|
3944
3943
|
return await this.runPhase(m, "rendering", async () => {
|
|
3945
|
-
W = await n.mount(f)(...
|
|
3944
|
+
W = await n.mount(f)(...F);
|
|
3946
3945
|
}), w && await this.runPhase(m, "playing"), W;
|
|
3947
3946
|
}, "mount")
|
|
3948
3947
|
};
|
|
@@ -3956,8 +3955,8 @@ var be = class {
|
|
|
3956
3955
|
story: d,
|
|
3957
3956
|
tags: c,
|
|
3958
3957
|
...this.callbacks,
|
|
3959
|
-
showError: /* @__PURE__ */ s((
|
|
3960
|
-
showException: /* @__PURE__ */ s((
|
|
3958
|
+
showError: /* @__PURE__ */ s((F) => (this.phase = "errored", this.callbacks.showError(F)), "showError"),
|
|
3959
|
+
showException: /* @__PURE__ */ s((F) => (this.phase = "errored", this.callbacks.showException(F)), "showException"),
|
|
3961
3960
|
forceRemount: t || this.notYetRendered,
|
|
3962
3961
|
storyContext: f,
|
|
3963
3962
|
storyFn: /* @__PURE__ */ s(() => h(f), "storyFn"),
|
|
@@ -3970,10 +3969,10 @@ var be = class {
|
|
|
3970
3969
|
let A = await p(f);
|
|
3971
3970
|
if (this.store.addCleanupCallbacks(n, ...A), this.checkIfAborted(m) || (!b && !w && await f.mount(), this.notYetRendered = !1, m.aborted))
|
|
3972
3971
|
return;
|
|
3973
|
-
let S = this.story.parameters?.test?.dangerouslyIgnoreUnhandledErrors === !0, C = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ s((
|
|
3974
|
-
|
|
3975
|
-
}, "onError"), j = /* @__PURE__ */ s((
|
|
3976
|
-
|
|
3972
|
+
let S = this.story.parameters?.test?.dangerouslyIgnoreUnhandledErrors === !0, C = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ s((F) => {
|
|
3973
|
+
F.error && C.add(F.error);
|
|
3974
|
+
}, "onError"), j = /* @__PURE__ */ s((F) => {
|
|
3975
|
+
F.reason && C.add(F.reason);
|
|
3977
3976
|
}, "onUnhandledRejection");
|
|
3978
3977
|
if (this.renderOptions.autoplay && t && x && this.phase !== "errored") {
|
|
3979
3978
|
window?.addEventListener?.("error", M), window?.addEventListener?.("unhandledrejection", j), this.disableKeyListeners = !0;
|
|
@@ -3983,12 +3982,12 @@ var be = class {
|
|
|
3983
3982
|
}, await this.runPhase(m, "playing", async () => x(f))), !b)
|
|
3984
3983
|
throw new Cr.NoStoryMountedError();
|
|
3985
3984
|
this.checkIfAborted(m), !S && C.size > 0 ? await this.runPhase(m, "errored") : await this.runPhase(m, "played");
|
|
3986
|
-
} catch (
|
|
3985
|
+
} catch (F) {
|
|
3987
3986
|
if (this.callbacks.showStoryDuringRender?.(), await this.runPhase(m, "errored", async () => {
|
|
3988
|
-
this.channel.emit(z.PLAY_FUNCTION_THREW_EXCEPTION, mn(
|
|
3987
|
+
this.channel.emit(z.PLAY_FUNCTION_THREW_EXCEPTION, mn(F));
|
|
3989
3988
|
}), this.story.parameters.throwPlayFunctionExceptions !== !1)
|
|
3990
|
-
throw
|
|
3991
|
-
console.error(
|
|
3989
|
+
throw F;
|
|
3990
|
+
console.error(F);
|
|
3992
3991
|
}
|
|
3993
3992
|
if (!S && C.size > 0 && this.channel.emit(
|
|
3994
3993
|
z.UNHANDLED_ERRORS_WHILE_PLAYING,
|
|
@@ -4005,7 +4004,7 @@ var be = class {
|
|
|
4005
4004
|
await y(f);
|
|
4006
4005
|
});
|
|
4007
4006
|
let G = !S && C.size > 0, ve = f.reporting.reports.some(
|
|
4008
|
-
(
|
|
4007
|
+
(F) => F.status === "failed"
|
|
4009
4008
|
), U = G || ve;
|
|
4010
4009
|
await this.runPhase(
|
|
4011
4010
|
m,
|
|
@@ -4050,7 +4049,10 @@ var be = class {
|
|
|
4050
4049
|
// as a method to abort them, ASAP, but this is not foolproof as we cannot control what
|
|
4051
4050
|
// happens inside the user's code.
|
|
4052
4051
|
cancelRender() {
|
|
4053
|
-
this.abortController
|
|
4052
|
+
this.abortController.abort();
|
|
4053
|
+
}
|
|
4054
|
+
cancelPlayFunction() {
|
|
4055
|
+
this.phase === "playing" && (this.abortController.abort(), this.runPhase(this.abortController.signal, "aborted"));
|
|
4054
4056
|
}
|
|
4055
4057
|
async teardown() {
|
|
4056
4058
|
this.torndown = !0, this.cancelRender(), this.story && await this.store.cleanupStory(this.story);
|
|
@@ -4111,10 +4113,11 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4111
4113
|
return this.storeInitializationPromise;
|
|
4112
4114
|
}
|
|
4113
4115
|
setupListeners() {
|
|
4114
|
-
this.channel.on(
|
|
4115
|
-
bind(this)), this.channel.on(
|
|
4116
|
-
bind(this)), this.channel.on(
|
|
4117
|
-
this)), this.channel.on(
|
|
4116
|
+
this.channel.on(P.STORY_INDEX_INVALIDATED, this.onStoryIndexChanged.bind(this)), this.channel.on(P.UPDATE_GLOBALS, this.onUpdateGlobals.
|
|
4117
|
+
bind(this)), this.channel.on(P.UPDATE_STORY_ARGS, this.onUpdateArgs.bind(this)), this.channel.on(P.ARGTYPES_INFO_REQUEST, this.onRequestArgTypesInfo.
|
|
4118
|
+
bind(this)), this.channel.on(P.RESET_STORY_ARGS, this.onResetArgs.bind(this)), this.channel.on(P.FORCE_RE_RENDER, this.onForceReRender.bind(
|
|
4119
|
+
this)), this.channel.on(P.FORCE_REMOUNT, this.onForceRemount.bind(this)), this.channel.on(P.STORY_HOT_UPDATED, this.onStoryHotUpdated.bind(
|
|
4120
|
+
this));
|
|
4118
4121
|
}
|
|
4119
4122
|
async getProjectAnnotationsOrRenderError() {
|
|
4120
4123
|
try {
|
|
@@ -4169,7 +4172,7 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4169
4172
|
globals: this.storyStoreValue.userGlobals.get() || {},
|
|
4170
4173
|
globalTypes: this.storyStoreValue.projectAnnotations.globalTypes || {}
|
|
4171
4174
|
};
|
|
4172
|
-
this.channel.emit(
|
|
4175
|
+
this.channel.emit(P.SET_GLOBALS, e);
|
|
4173
4176
|
}
|
|
4174
4177
|
// EVENT HANDLERS
|
|
4175
4178
|
// This happens when a config file gets reloaded
|
|
@@ -4214,7 +4217,7 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4214
4217
|
throw new D.CalledPreviewMethodBeforeInitializationError({ methodName: "onUpdateGlobals" });
|
|
4215
4218
|
if (this.storyStoreValue.userGlobals.update(e), t) {
|
|
4216
4219
|
let { initialGlobals: o, storyGlobals: n, userGlobals: i, globals: a } = this.storyStoreValue.getStoryContext(t);
|
|
4217
|
-
this.channel.emit(
|
|
4220
|
+
this.channel.emit(P.GLOBALS_UPDATED, {
|
|
4218
4221
|
initialGlobals: o,
|
|
4219
4222
|
userGlobals: i,
|
|
4220
4223
|
storyGlobals: n,
|
|
@@ -4222,7 +4225,7 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4222
4225
|
});
|
|
4223
4226
|
} else {
|
|
4224
4227
|
let { initialGlobals: o, globals: n } = this.storyStoreValue.userGlobals;
|
|
4225
|
-
this.channel.emit(
|
|
4228
|
+
this.channel.emit(P.GLOBALS_UPDATED, {
|
|
4226
4229
|
initialGlobals: o,
|
|
4227
4230
|
userGlobals: n,
|
|
4228
4231
|
storyGlobals: {},
|
|
@@ -4242,7 +4245,7 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4242
4245
|
o.story && o.story.usesMount ? o.remount() : o.rerender()
|
|
4243
4246
|
)
|
|
4244
4247
|
)
|
|
4245
|
-
), this.channel.emit(
|
|
4248
|
+
), this.channel.emit(P.STORY_ARGS_UPDATED, {
|
|
4246
4249
|
storyId: e,
|
|
4247
4250
|
args: this.storyStoreValue.args.get(e)
|
|
4248
4251
|
});
|
|
@@ -4251,14 +4254,14 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4251
4254
|
try {
|
|
4252
4255
|
await this.storeInitializationPromise;
|
|
4253
4256
|
let o = await this.storyStoreValue?.loadStory(t);
|
|
4254
|
-
this.channel.emit(
|
|
4257
|
+
this.channel.emit(P.ARGTYPES_INFO_RESPONSE, {
|
|
4255
4258
|
id: e,
|
|
4256
4259
|
success: !0,
|
|
4257
4260
|
payload: { argTypes: o?.argTypes || {} },
|
|
4258
4261
|
error: null
|
|
4259
4262
|
});
|
|
4260
4263
|
} catch (o) {
|
|
4261
|
-
this.channel.emit(
|
|
4264
|
+
this.channel.emit(P.ARGTYPES_INFO_RESPONSE, {
|
|
4262
4265
|
id: e,
|
|
4263
4266
|
success: !1,
|
|
4264
4267
|
error: o?.message
|
|
@@ -4284,6 +4287,9 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4284
4287
|
async onForceRemount({ storyId: e }) {
|
|
4285
4288
|
await Promise.all(this.storyRenders.filter((t) => t.id === e).map((t) => t.remount()));
|
|
4286
4289
|
}
|
|
4290
|
+
async onStoryHotUpdated() {
|
|
4291
|
+
await Promise.all(this.storyRenders.map((e) => e.cancelPlayFunction()));
|
|
4292
|
+
}
|
|
4287
4293
|
// Used by docs to render a story to a given element
|
|
4288
4294
|
// Note this short-circuits the `prepare()` phase of the StoryRender,
|
|
4289
4295
|
// main to be consistent with the previous behaviour. In the future,
|
|
@@ -4331,7 +4337,7 @@ var { fetch: pi } = hn.global, ui = "./index.json", Se = class {
|
|
|
4331
4337
|
}
|
|
4332
4338
|
// UTILITIES
|
|
4333
4339
|
renderPreviewEntryError(e, t) {
|
|
4334
|
-
this.previewEntryError = t, $e.logger.error(e), $e.logger.error(t), this.channel.emit(
|
|
4340
|
+
this.previewEntryError = t, $e.logger.error(e), $e.logger.error(t), this.channel.emit(P.CONFIG_ERROR, t);
|
|
4335
4341
|
}
|
|
4336
4342
|
};
|
|
4337
4343
|
|
|
@@ -739,7 +739,7 @@ declare class StoryRender<TRenderer extends Renderer> implements Render<TRendere
|
|
|
739
739
|
type: RenderType;
|
|
740
740
|
story?: PreparedStory<TRenderer>;
|
|
741
741
|
phase?: RenderPhase;
|
|
742
|
-
private abortController
|
|
742
|
+
private abortController;
|
|
743
743
|
private canvasElement?;
|
|
744
744
|
private notYetRendered;
|
|
745
745
|
private rerenderEnqueued;
|
|
@@ -770,6 +770,7 @@ declare class StoryRender<TRenderer extends Renderer> implements Render<TRendere
|
|
|
770
770
|
rerender(): Promise<void>;
|
|
771
771
|
remount(): Promise<void>;
|
|
772
772
|
cancelRender(): void;
|
|
773
|
+
cancelPlayFunction(): void;
|
|
773
774
|
teardown(): Promise<void>;
|
|
774
775
|
}
|
|
775
776
|
|
|
@@ -824,6 +825,7 @@ declare class Preview<TRenderer extends Renderer> {
|
|
|
824
825
|
onForceRemount({ storyId }: {
|
|
825
826
|
storyId: StoryId;
|
|
826
827
|
}): Promise<void>;
|
|
828
|
+
onStoryHotUpdated(): Promise<void>;
|
|
827
829
|
renderStoryToElement(story: PreparedStory<TRenderer>, element: TRenderer['canvasElement'], callbacks: RenderContextCallbacks<TRenderer>, options: StoryRenderOptions): () => Promise<void>;
|
|
828
830
|
teardownRender(render: StoryRender<TRenderer> | CsfDocsRender<TRenderer> | MdxDocsRender<TRenderer>, { viewModeChanged }?: {
|
|
829
831
|
viewModeChanged?: boolean;
|