storybook 10.1.0-alpha.8 → 10.1.0-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.
Files changed (198) hide show
  1. package/dist/_browser-chunks/Color-FTG7SQDA.js +1097 -0
  2. package/dist/_browser-chunks/WithTooltip-LMROHDUP.js +1651 -0
  3. package/dist/_browser-chunks/chunk-2FRVAXCZ.js +7 -0
  4. package/dist/_browser-chunks/{chunk-FDWKXLBI.js → chunk-2XZMBGTA.js} +44 -109
  5. package/dist/_browser-chunks/chunk-3IAH5M2U.js +171 -0
  6. package/dist/_browser-chunks/chunk-3OXGAGBE.js +779 -0
  7. package/dist/_browser-chunks/{chunk-TMDZCWME.js → chunk-3PJE6VLG.js} +1 -3
  8. package/dist/_browser-chunks/{chunk-VAMFPZY3.js → chunk-45UGUKRX.js} +2 -7
  9. package/dist/_browser-chunks/chunk-6XWLIJQL.js +11 -0
  10. package/dist/_browser-chunks/{chunk-MM7DTO55.js → chunk-A242L54C.js} +10 -16
  11. package/dist/_browser-chunks/chunk-AIOS4NGK.js +252 -0
  12. package/dist/_browser-chunks/chunk-AS2HQEYC.js +14 -0
  13. package/dist/_browser-chunks/chunk-AXG2BOBL.js +836 -0
  14. package/dist/_browser-chunks/{chunk-MH6AXFXB.js → chunk-CHUV5WSW.js} +0 -5
  15. package/dist/_browser-chunks/chunk-EUVGDK4H.js +93 -0
  16. package/dist/_browser-chunks/chunk-EZSQOHRI.js +18 -0
  17. package/dist/_browser-chunks/{chunk-CADGRH3P.js → chunk-FNXWN6IK.js} +3 -8
  18. package/dist/_browser-chunks/chunk-FQ7SLVLR.js +66 -0
  19. package/dist/_browser-chunks/chunk-GFLS4VP3.js +64 -0
  20. package/dist/_browser-chunks/chunk-GFY5R5EY.js +47 -0
  21. package/dist/_browser-chunks/{chunk-L2D73C6Z.js → chunk-H6XK3RSC.js} +13 -21
  22. package/dist/_browser-chunks/chunk-IPA5A322.js +71 -0
  23. package/dist/_browser-chunks/chunk-JP7NCOJX.js +37 -0
  24. package/dist/_browser-chunks/chunk-KJHJLCBK.js +11 -0
  25. package/dist/_browser-chunks/{chunk-OWPZQM2D.js → chunk-L4RMQ7D7.js} +60 -110
  26. package/dist/_browser-chunks/chunk-P4F4UVXX.js +951 -0
  27. package/dist/_browser-chunks/{chunk-AB7OOPUX.js → chunk-QKODTO7K.js} +0 -5
  28. package/dist/_browser-chunks/chunk-RP5RXKFU.js +2491 -0
  29. package/dist/_browser-chunks/chunk-SL75JR6Y.js +9 -0
  30. package/dist/_browser-chunks/chunk-SS2NHR7W.js +2969 -0
  31. package/dist/_browser-chunks/chunk-UD6FQLAF.js +1481 -0
  32. package/dist/_browser-chunks/chunk-VYJQ7RU5.js +2853 -0
  33. package/dist/_browser-chunks/chunk-WJYERY3R.js +136 -0
  34. package/dist/_browser-chunks/chunk-XJNX76GA.js +85 -0
  35. package/dist/_browser-chunks/{chunk-F4Q6SGTB.js → chunk-YKE5S47A.js} +177 -399
  36. package/dist/_browser-chunks/{chunk-SN4J4IQ3.js → chunk-ZUWEVLDX.js} +1 -7
  37. package/dist/_browser-chunks/{formatter-OMEEQ6HG.js → formatter-QJ4M4OGQ.js} +4 -9
  38. package/dist/_browser-chunks/{syntaxhighlighter-CAVLW7PM.js → syntaxhighlighter-IQDEPFLK.js} +704 -1848
  39. package/dist/_node-chunks/{builder-manager-57OYTFQ5.js → builder-manager-BDAQHXFI.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3C7DZZPX.js +37 -0
  41. package/dist/_node-chunks/chunk-2IIQTGNE.js +6024 -0
  42. package/dist/_node-chunks/chunk-56U5LEMP.js +3043 -0
  43. package/dist/_node-chunks/chunk-7LIRCAQE.js +20 -0
  44. package/dist/_node-chunks/chunk-7RN6TXKP.js +603 -0
  45. package/dist/_node-chunks/chunk-7SJ7PZNL.js +4523 -0
  46. package/dist/_node-chunks/{chunk-2GK7NW46.js → chunk-BG4RDXG7.js} +8 -10
  47. package/dist/_node-chunks/chunk-CBQKMXLQ.js +18 -0
  48. package/dist/_node-chunks/chunk-CN2IW2KQ.js +1564 -0
  49. package/dist/_node-chunks/chunk-CQMAU6UQ.js +943 -0
  50. package/dist/_node-chunks/{chunk-RG4Z25PY.js → chunk-D6ND3TVY.js} +116 -276
  51. package/dist/_node-chunks/chunk-DC355CYB.js +61 -0
  52. package/dist/_node-chunks/{chunk-EBYCXVVR.js → chunk-EVK2SBW5.js} +292 -688
  53. package/dist/_node-chunks/chunk-IXWEUXJ2.js +119 -0
  54. package/dist/_node-chunks/{chunk-6F6CCOXH.js → chunk-KVRF22SH.js} +469 -983
  55. package/dist/_node-chunks/chunk-LEDP4QQW.js +919 -0
  56. package/dist/_node-chunks/{chunk-C4KEDJ6O.js → chunk-MMVV6DGG.js} +8133 -8887
  57. package/dist/_node-chunks/chunk-O5CGEVRI.js +29 -0
  58. package/dist/_node-chunks/chunk-OZZO56XN.js +299 -0
  59. package/dist/_node-chunks/chunk-POT2EVGD.js +78 -0
  60. package/dist/_node-chunks/chunk-R5YGFSTV.js +3781 -0
  61. package/dist/_node-chunks/chunk-SQCTM2OS.js +23 -0
  62. package/dist/_node-chunks/chunk-UFOFO5H7.js +54 -0
  63. package/dist/_node-chunks/chunk-VBF7ALJF.js +72 -0
  64. package/dist/_node-chunks/chunk-W6MAMTUF.js +70 -0
  65. package/dist/_node-chunks/chunk-WURL4XOT.js +46662 -0
  66. package/dist/_node-chunks/chunk-XGK6MVKR.js +61 -0
  67. package/dist/_node-chunks/chunk-YV3GDSDT.js +765 -0
  68. package/dist/_node-chunks/{chunk-RSHLCHYY.js → chunk-YWV55YW3.js} +15 -24
  69. package/dist/_node-chunks/dist-KEP4IFRN.js +121 -0
  70. package/dist/_node-chunks/globby-4WUBTDCN.js +3452 -0
  71. package/dist/_node-chunks/lib-JVOEKTYM.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-C5WFYYXR.js +14329 -0
  73. package/dist/_node-chunks/p-limit-LDY632RS.js +116 -0
  74. package/dist/actions/decorator.js +21 -42
  75. package/dist/actions/index.js +3 -3
  76. package/dist/babel/index.d.ts +671 -335
  77. package/dist/babel/index.js +10 -11
  78. package/dist/bin/core.js +601 -1548
  79. package/dist/bin/dispatcher.js +36 -36
  80. package/dist/bin/loader.js +24 -38
  81. package/dist/channels/index.js +98 -234
  82. package/dist/cli/index.d.ts +1479 -133
  83. package/dist/cli/index.js +30 -8540
  84. package/dist/client-logger/index.js +31 -61
  85. package/dist/common/index.d.ts +139 -62
  86. package/dist/common/index.js +66 -51
  87. package/dist/components/index.d.ts +575 -273
  88. package/dist/components/index.js +14863 -4313
  89. package/dist/core-events/index.js +2 -66
  90. package/dist/core-server/index.d.ts +3 -2
  91. package/dist/core-server/index.js +2910 -8519
  92. package/dist/core-server/presets/common-manager.css +2 -2
  93. package/dist/core-server/presets/common-manager.js +2521 -5233
  94. package/dist/core-server/presets/common-override-preset.js +31 -60
  95. package/dist/core-server/presets/common-preset.js +663 -962
  96. package/dist/csf/index.js +534 -1179
  97. package/dist/csf-tools/index.js +9 -9
  98. package/dist/docs-tools/index.js +6 -6
  99. package/dist/highlight/index.js +2 -2
  100. package/dist/instrumenter/index.js +199 -415
  101. package/dist/manager/globals-runtime.js +59044 -67141
  102. package/dist/manager/globals.js +2 -3
  103. package/dist/manager/manager-stores.d.ts +1 -0
  104. package/dist/manager/manager-stores.js +23 -0
  105. package/dist/manager/runtime.js +11511 -10953
  106. package/dist/manager-api/index.d.ts +1811 -2
  107. package/dist/manager-api/index.js +1348 -2401
  108. package/dist/manager-errors.d.ts +9 -0
  109. package/dist/manager-errors.js +3 -3
  110. package/dist/mocking-utils/index.d.ts +1126 -0
  111. package/dist/mocking-utils/index.js +1181 -0
  112. package/dist/node-logger/index.d.ts +192 -24
  113. package/dist/node-logger/index.js +23 -4471
  114. package/dist/preview/globals.js +2 -3
  115. package/dist/preview/runtime.js +10799 -22393
  116. package/dist/preview-api/index.d.ts +1 -1
  117. package/dist/preview-api/index.js +13 -13
  118. package/dist/preview-errors.d.ts +9 -0
  119. package/dist/preview-errors.js +4 -4
  120. package/dist/router/index.js +347 -899
  121. package/dist/server-errors.d.ts +34 -1
  122. package/dist/server-errors.js +17 -10
  123. package/dist/telemetry/index.d.ts +24 -3
  124. package/dist/telemetry/index.js +25 -24
  125. package/dist/test/index.js +6131 -11916
  126. package/dist/theming/create.d.ts +1 -0
  127. package/dist/theming/create.js +4 -4
  128. package/dist/theming/index.d.ts +3366 -2599
  129. package/dist/theming/index.js +501 -1091
  130. package/dist/types/index.d.ts +72 -8
  131. package/dist/types/index.js +27 -12
  132. package/dist/viewport/index.js +3 -3
  133. package/package.json +26 -17
  134. package/dist/_browser-chunks/Color-7ZNS6F6B.js +0 -1676
  135. package/dist/_browser-chunks/WithTooltip-SK46ZJ2J.js +0 -13
  136. package/dist/_browser-chunks/chunk-6A7OIVEL.js +0 -66
  137. package/dist/_browser-chunks/chunk-B4A3ADP3.js +0 -3816
  138. package/dist/_browser-chunks/chunk-BOOOPFZF.js +0 -2335
  139. package/dist/_browser-chunks/chunk-FSBVR7H5.js +0 -106
  140. package/dist/_browser-chunks/chunk-FUOHXXZT.js +0 -23
  141. package/dist/_browser-chunks/chunk-GTKOCWCT.js +0 -17
  142. package/dist/_browser-chunks/chunk-HHW4FUMO.js +0 -12
  143. package/dist/_browser-chunks/chunk-JVSKG4YS.js +0 -4052
  144. package/dist/_browser-chunks/chunk-LASUB7TL.js +0 -76
  145. package/dist/_browser-chunks/chunk-LYCSRYYR.js +0 -101
  146. package/dist/_browser-chunks/chunk-NVV6MIOE.js +0 -243
  147. package/dist/_browser-chunks/chunk-OBXWFEPB.js +0 -852
  148. package/dist/_browser-chunks/chunk-OPCDBBL3.js +0 -48
  149. package/dist/_browser-chunks/chunk-PB6FZ3WE.js +0 -130
  150. package/dist/_browser-chunks/chunk-RNE2IUTB.js +0 -1300
  151. package/dist/_browser-chunks/chunk-RW5PKMWM.js +0 -4182
  152. package/dist/_browser-chunks/chunk-SYS437NN.js +0 -122
  153. package/dist/_browser-chunks/chunk-U46RQHA4.js +0 -12
  154. package/dist/_browser-chunks/chunk-UTNZYD2N.js +0 -311
  155. package/dist/_browser-chunks/chunk-VUAFL5XK.js +0 -20
  156. package/dist/_browser-chunks/chunk-XDGMHOV7.js +0 -2197
  157. package/dist/_browser-chunks/chunk-XW6KSYKF.js +0 -16
  158. package/dist/_browser-chunks/chunk-Y3M7TW6K.js +0 -1041
  159. package/dist/_browser-chunks/chunk-ZNRFDIVA.js +0 -233
  160. package/dist/_node-chunks/camelcase-2KEDZHZ2.js +0 -18
  161. package/dist/_node-chunks/chunk-34NNXTBR.js +0 -28
  162. package/dist/_node-chunks/chunk-3N2A3KZX.js +0 -420
  163. package/dist/_node-chunks/chunk-5P7P5KDN.js +0 -90
  164. package/dist/_node-chunks/chunk-5WBRBDXI.js +0 -79
  165. package/dist/_node-chunks/chunk-7PWTU7T2.js +0 -697
  166. package/dist/_node-chunks/chunk-CHRHQ7AZ.js +0 -4272
  167. package/dist/_node-chunks/chunk-D4EGQLJI.js +0 -64656
  168. package/dist/_node-chunks/chunk-EKCURTKU.js +0 -1544
  169. package/dist/_node-chunks/chunk-GBVPPW4H.js +0 -1657
  170. package/dist/_node-chunks/chunk-J6VOKT2F.js +0 -220
  171. package/dist/_node-chunks/chunk-JLBYSGXS.js +0 -69
  172. package/dist/_node-chunks/chunk-LLCELSUL.js +0 -1198
  173. package/dist/_node-chunks/chunk-NS4OCQ4F.js +0 -61
  174. package/dist/_node-chunks/chunk-NXVLFYDR.js +0 -1518
  175. package/dist/_node-chunks/chunk-NZPWAJOZ.js +0 -304
  176. package/dist/_node-chunks/chunk-OYFSIV3I.js +0 -6712
  177. package/dist/_node-chunks/chunk-OZ43LMDF.js +0 -5029
  178. package/dist/_node-chunks/chunk-Q5HJHFF2.js +0 -61
  179. package/dist/_node-chunks/chunk-QHER4CEN.js +0 -34
  180. package/dist/_node-chunks/chunk-RF2PJM54.js +0 -1531
  181. package/dist/_node-chunks/chunk-S3OHGEE3.js +0 -101
  182. package/dist/_node-chunks/chunk-S5XOMVSV.js +0 -2256
  183. package/dist/_node-chunks/chunk-SGXQZ47H.js +0 -1586
  184. package/dist/_node-chunks/chunk-TDU6OVUH.js +0 -111
  185. package/dist/_node-chunks/chunk-TYQQFNQX.js +0 -1250
  186. package/dist/_node-chunks/chunk-WNGLARN2.js +0 -4741
  187. package/dist/_node-chunks/chunk-YUOVDCXL.js +0 -18
  188. package/dist/_node-chunks/dist-O5FB7YUW.js +0 -175
  189. package/dist/_node-chunks/globby-3NMV7WHX.js +0 -5222
  190. package/dist/_node-chunks/lib-VZD7BRSA.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-3RP7RKKU.js +0 -22017
  192. package/dist/_node-chunks/p-limit-LIKBTXEJ.js +0 -168
  193. package/dist/_node-chunks/plugin-2NYZBK4A.js +0 -129
  194. package/dist/_node-chunks/plugin-6QGMO7J7.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-Z2JI6J2H.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-D4BE2SSI.js +0 -124
  197. package/dist/core-server/presets/webpack/loaders/storybook-mock-transform-loader.js +0 -36
  198. package/dist/core-server/presets/webpack/loaders/webpack-automock-loader.js +0 -33
@@ -1,13 +1,11 @@
1
1
  import {
2
2
  CallStates,
3
3
  EVENTS
4
- } from "../_browser-chunks/chunk-SN4J4IQ3.js";
4
+ } from "../_browser-chunks/chunk-ZUWEVLDX.js";
5
5
  import {
6
6
  processError
7
- } from "../_browser-chunks/chunk-JVSKG4YS.js";
8
- import {
9
- __name
10
- } from "../_browser-chunks/chunk-MM7DTO55.js";
7
+ } from "../_browser-chunks/chunk-RP5RXKFU.js";
8
+ import "../_browser-chunks/chunk-A242L54C.js";
11
9
 
12
10
  // src/instrumenter/instrumenter.ts
13
11
  import { once } from "storybook/internal/client-logger";
@@ -23,35 +21,25 @@ var addons = globalThis.__STORYBOOK_ADDONS_PREVIEW;
23
21
 
24
22
  // src/instrumenter/instrumenter.ts
25
23
  var alreadyCompletedException = new Error(
26
- `This function ran after the play function completed. Did you forget to \`await\` it?`
27
- );
28
- var isObject = /* @__PURE__ */ __name((o) => Object.prototype.toString.call(o) === "[object Object]", "isObject");
29
- var isModule = /* @__PURE__ */ __name((o) => Object.prototype.toString.call(o) === "[object Module]", "isModule");
30
- var isInstrumentable = /* @__PURE__ */ __name((o) => {
31
- if (!isObject(o) && !isModule(o)) {
32
- return false;
33
- }
34
- if (o.constructor === void 0) {
35
- return true;
36
- }
37
- const proto = o.constructor.prototype;
38
- if (!isObject(proto)) {
39
- return false;
40
- }
41
- return true;
42
- }, "isInstrumentable");
43
- var construct = /* @__PURE__ */ __name((obj) => {
24
+ "This function ran after the play function completed. Did you forget to `await` it?"
25
+ ), isObject = (o) => Object.prototype.toString.call(o) === "[object Object]", isModule = (o) => Object.prototype.toString.call(o) === "[object Module]", isInstrumentable = (o) => {
26
+ if (!isObject(o) && !isModule(o))
27
+ return !1;
28
+ if (o.constructor === void 0)
29
+ return !0;
30
+ let proto = o.constructor.prototype;
31
+ return !!isObject(proto);
32
+ }, construct = (obj) => {
44
33
  try {
45
34
  return new obj.constructor();
46
35
  } catch {
47
36
  return {};
48
37
  }
49
- }, "construct");
50
- var getInitialState = /* @__PURE__ */ __name(() => ({
38
+ }, getInitialState = () => ({
51
39
  renderPhase: "preparing",
52
- isDebugging: false,
53
- isPlaying: false,
54
- isLocked: false,
40
+ isDebugging: !1,
41
+ isPlaying: !1,
42
+ isLocked: !1,
55
43
  cursor: 0,
56
44
  calls: [],
57
45
  shadowCalls: [],
@@ -61,45 +49,42 @@ var getInitialState = /* @__PURE__ */ __name(() => ({
61
49
  playUntil: void 0,
62
50
  resolvers: {},
63
51
  syncTimeout: void 0
64
- }), "getInitialState");
65
- var getRetainedState = /* @__PURE__ */ __name((state, isDebugging = false) => {
66
- const calls = (isDebugging ? state.shadowCalls : state.calls).filter((call) => call.retain);
67
- if (!calls.length) {
68
- return void 0;
69
- }
70
- const callRefsByResult = new Map(
52
+ }), getRetainedState = (state, isDebugging = !1) => {
53
+ let calls = (isDebugging ? state.shadowCalls : state.calls).filter((call) => call.retain);
54
+ if (!calls.length)
55
+ return;
56
+ let callRefsByResult = new Map(
71
57
  Array.from(state.callRefsByResult.entries()).filter(([, ref]) => ref.retain)
72
58
  );
73
59
  return { cursor: calls.length, calls, callRefsByResult };
74
- }, "getRetainedState");
75
- var _Instrumenter = class _Instrumenter {
60
+ }, Instrumenter = class {
76
61
  constructor() {
77
- this.detached = false;
78
- this.initialized = false;
62
+ this.detached = !1;
63
+ this.initialized = !1;
79
64
  // State is tracked per story to deal with multiple stories on the same canvas (i.e. docs mode)
80
65
  this.state = {};
81
- this.loadParentWindowState = /* @__PURE__ */ __name(() => {
66
+ this.loadParentWindowState = () => {
82
67
  try {
83
68
  this.state = global.window?.parent?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ || {};
84
69
  } catch {
85
- this.detached = true;
70
+ this.detached = !0;
86
71
  }
87
- }, "loadParentWindowState");
88
- this.updateParentWindowState = /* @__PURE__ */ __name(() => {
72
+ };
73
+ this.updateParentWindowState = () => {
89
74
  try {
90
75
  global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
91
76
  } catch {
92
- this.detached = true;
77
+ this.detached = !0;
93
78
  }
94
- }, "updateParentWindowState");
79
+ };
95
80
  this.loadParentWindowState();
96
- const resetState = /* @__PURE__ */ __name(({
81
+ let resetState = ({
97
82
  storyId,
98
83
  renderPhase,
99
- isPlaying = true,
100
- isDebugging = false
84
+ isPlaying = !0,
85
+ isDebugging = !1
101
86
  }) => {
102
- const state = this.getState(storyId);
87
+ let state = this.getState(storyId);
103
88
  this.setState(storyId, {
104
89
  ...getInitialState(),
105
90
  ...getRetainedState(state, isDebugging),
@@ -109,229 +94,137 @@ var _Instrumenter = class _Instrumenter {
109
94
  playUntil: isDebugging ? state.playUntil : void 0,
110
95
  isPlaying,
111
96
  isDebugging
112
- });
113
- this.sync(storyId);
114
- }, "resetState");
115
- const start = /* @__PURE__ */ __name((channel) => ({ storyId, playUntil }) => {
116
- if (!this.getState(storyId).isDebugging) {
117
- this.setState(storyId, ({ calls }) => ({
118
- calls: [],
119
- shadowCalls: calls.map((call) => ({ ...call, status: "waiting" /* WAITING */ })),
120
- isDebugging: true
121
- }));
122
- }
123
- const log = this.getLog(storyId);
97
+ }), this.sync(storyId);
98
+ }, start = (channel) => ({ storyId, playUntil }) => {
99
+ this.getState(storyId).isDebugging || this.setState(storyId, ({ calls }) => ({
100
+ calls: [],
101
+ shadowCalls: calls.map((call) => ({ ...call, status: "waiting" /* WAITING */ })),
102
+ isDebugging: !0
103
+ }));
104
+ let log = this.getLog(storyId);
124
105
  this.setState(storyId, ({ shadowCalls }) => {
125
- if (playUntil || !log.length) {
106
+ if (playUntil || !log.length)
126
107
  return { playUntil };
127
- }
128
- const firstRowIndex = shadowCalls.findIndex((call) => call.id === log[0].callId);
108
+ let firstRowIndex = shadowCalls.findIndex((call) => call.id === log[0].callId);
129
109
  return {
130
110
  playUntil: shadowCalls.slice(0, firstRowIndex).filter((call) => call.interceptable && !call.ancestors?.length).slice(-1)[0]?.id
131
111
  };
132
- });
133
- channel.emit(FORCE_REMOUNT, { storyId, isDebugging: true });
134
- }, "start");
135
- const back = /* @__PURE__ */ __name((channel) => ({ storyId }) => {
136
- const log = this.getLog(storyId).filter((call) => !call.ancestors?.length);
137
- const last = log.reduceRight((res, item, index) => {
138
- if (res >= 0 || item.status === "waiting" /* WAITING */) {
139
- return res;
140
- }
141
- return index;
142
- }, -1);
112
+ }), channel.emit(FORCE_REMOUNT, { storyId, isDebugging: !0 });
113
+ }, back = (channel) => ({ storyId }) => {
114
+ let log = this.getLog(storyId).filter((call) => !call.ancestors?.length), last = log.reduceRight((res, item, index) => res >= 0 || item.status === "waiting" /* WAITING */ ? res : index, -1);
143
115
  start(channel)({ storyId, playUntil: log[last - 1]?.callId });
144
- }, "back");
145
- const goto = /* @__PURE__ */ __name((channel) => ({ storyId, callId }) => {
146
- const { calls, shadowCalls, resolvers } = this.getState(storyId);
147
- const call = calls.find(({ id }) => id === callId);
148
- const shadowCall = shadowCalls.find(({ id }) => id === callId);
116
+ }, goto = (channel) => ({ storyId, callId }) => {
117
+ let { calls, shadowCalls, resolvers } = this.getState(storyId), call = calls.find(({ id }) => id === callId), shadowCall = shadowCalls.find(({ id }) => id === callId);
149
118
  if (!call && shadowCall && Object.values(resolvers).length > 0) {
150
- const nextId = this.getLog(storyId).find((c) => c.status === "waiting" /* WAITING */)?.callId;
151
- if (shadowCall.id !== nextId) {
152
- this.setState(storyId, { playUntil: shadowCall.id });
153
- }
154
- Object.values(resolvers).forEach((resolve) => resolve());
155
- } else {
119
+ let nextId = this.getLog(storyId).find((c) => c.status === "waiting" /* WAITING */)?.callId;
120
+ shadowCall.id !== nextId && this.setState(storyId, { playUntil: shadowCall.id }), Object.values(resolvers).forEach((resolve) => resolve());
121
+ } else
156
122
  start(channel)({ storyId, playUntil: callId });
157
- }
158
- }, "goto");
159
- const next = /* @__PURE__ */ __name((channel) => ({ storyId }) => {
160
- const { resolvers } = this.getState(storyId);
161
- if (Object.values(resolvers).length > 0) {
123
+ }, next = (channel) => ({ storyId }) => {
124
+ let { resolvers } = this.getState(storyId);
125
+ if (Object.values(resolvers).length > 0)
162
126
  Object.values(resolvers).forEach((resolve) => resolve());
163
- } else {
164
- const nextId = this.getLog(storyId).find((c) => c.status === "waiting" /* WAITING */)?.callId;
165
- if (nextId) {
166
- start(channel)({ storyId, playUntil: nextId });
167
- } else {
168
- end({ storyId });
169
- }
127
+ else {
128
+ let nextId = this.getLog(storyId).find((c) => c.status === "waiting" /* WAITING */)?.callId;
129
+ nextId ? start(channel)({ storyId, playUntil: nextId }) : end({ storyId });
170
130
  }
171
- }, "next");
172
- const end = /* @__PURE__ */ __name(({ storyId }) => {
173
- this.setState(storyId, { playUntil: void 0, isDebugging: false });
174
- Object.values(this.getState(storyId).resolvers).forEach((resolve) => resolve());
175
- }, "end");
176
- const renderPhaseChanged = /* @__PURE__ */ __name(({
131
+ }, end = ({ storyId }) => {
132
+ this.setState(storyId, { playUntil: void 0, isDebugging: !1 }), Object.values(this.getState(storyId).resolvers).forEach((resolve) => resolve());
133
+ }, renderPhaseChanged = ({
177
134
  storyId,
178
135
  newPhase
179
136
  }) => {
180
- const { isDebugging } = this.getState(storyId);
181
- if (newPhase === "preparing" && isDebugging) {
137
+ let { isDebugging } = this.getState(storyId);
138
+ if (newPhase === "preparing" && isDebugging)
182
139
  return resetState({ storyId, renderPhase: newPhase, isDebugging });
183
- } else if (newPhase === "playing") {
140
+ if (newPhase === "playing")
184
141
  return resetState({ storyId, renderPhase: newPhase, isDebugging });
185
- }
186
- if (newPhase === "played") {
187
- this.setState(storyId, {
188
- renderPhase: newPhase,
189
- isLocked: false,
190
- isPlaying: false,
191
- isDebugging: false
192
- });
193
- } else if (newPhase === "errored") {
194
- this.setState(storyId, {
195
- renderPhase: newPhase,
196
- isLocked: false,
197
- isPlaying: false
198
- });
199
- } else if (newPhase === "aborted") {
200
- this.setState(storyId, {
201
- renderPhase: newPhase,
202
- isLocked: true,
203
- isPlaying: false
204
- });
205
- } else {
206
- this.setState(storyId, {
207
- renderPhase: newPhase
208
- });
209
- }
210
- this.sync(storyId);
211
- }, "renderPhaseChanged");
212
- if (addons) {
213
- addons.ready().then(() => {
214
- this.channel = addons.getChannel();
215
- this.channel.on(FORCE_REMOUNT, resetState);
216
- this.channel.on(STORY_RENDER_PHASE_CHANGED, renderPhaseChanged);
217
- this.channel.on(SET_CURRENT_STORY, () => {
218
- if (this.initialized) {
219
- this.cleanup();
220
- } else {
221
- this.initialized = true;
222
- }
223
- });
224
- this.channel.on(EVENTS.START, start(this.channel));
225
- this.channel.on(EVENTS.BACK, back(this.channel));
226
- this.channel.on(EVENTS.GOTO, goto(this.channel));
227
- this.channel.on(EVENTS.NEXT, next(this.channel));
228
- this.channel.on(EVENTS.END, end);
229
- });
230
- }
142
+ newPhase === "played" ? this.setState(storyId, {
143
+ renderPhase: newPhase,
144
+ isLocked: !1,
145
+ isPlaying: !1,
146
+ isDebugging: !1
147
+ }) : newPhase === "errored" ? this.setState(storyId, {
148
+ renderPhase: newPhase,
149
+ isLocked: !1,
150
+ isPlaying: !1
151
+ }) : newPhase === "aborted" ? this.setState(storyId, {
152
+ renderPhase: newPhase,
153
+ isLocked: !0,
154
+ isPlaying: !1
155
+ }) : this.setState(storyId, {
156
+ renderPhase: newPhase
157
+ }), this.sync(storyId);
158
+ };
159
+ addons && addons.ready().then(() => {
160
+ this.channel = addons.getChannel(), this.channel.on(FORCE_REMOUNT, resetState), this.channel.on(STORY_RENDER_PHASE_CHANGED, renderPhaseChanged), this.channel.on(SET_CURRENT_STORY, () => {
161
+ this.initialized ? this.cleanup() : this.initialized = !0;
162
+ }), this.channel.on(EVENTS.START, start(this.channel)), this.channel.on(EVENTS.BACK, back(this.channel)), this.channel.on(EVENTS.GOTO, goto(this.channel)), this.channel.on(EVENTS.NEXT, next(this.channel)), this.channel.on(EVENTS.END, end);
163
+ });
231
164
  }
232
165
  getState(storyId) {
233
166
  return this.state[storyId] || getInitialState();
234
167
  }
235
168
  setState(storyId, update) {
236
169
  if (storyId) {
237
- const state = this.getState(storyId);
238
- const patch = typeof update === "function" ? update(state) : update;
239
- this.state = { ...this.state, [storyId]: { ...state, ...patch } };
240
- this.updateParentWindowState();
170
+ let state = this.getState(storyId), patch = typeof update == "function" ? update(state) : update;
171
+ this.state = { ...this.state, [storyId]: { ...state, ...patch } }, this.updateParentWindowState();
241
172
  }
242
173
  }
243
174
  cleanup() {
244
175
  this.state = Object.entries(this.state).reduce(
245
176
  (acc, [storyId, state]) => {
246
- const retainedState = getRetainedState(state);
247
- if (!retainedState) {
248
- return acc;
249
- }
250
- acc[storyId] = Object.assign(getInitialState(), retainedState);
251
- return acc;
177
+ let retainedState = getRetainedState(state);
178
+ return retainedState && (acc[storyId] = Object.assign(getInitialState(), retainedState)), acc;
252
179
  },
253
180
  {}
254
181
  );
255
- const controlStates = {
182
+ let payload = { controlStates: {
256
183
  detached: this.detached,
257
- start: false,
258
- back: false,
259
- goto: false,
260
- next: false,
261
- end: false
262
- };
263
- const payload = { controlStates, logItems: [] };
264
- this.channel?.emit(EVENTS.SYNC, payload);
265
- this.updateParentWindowState();
184
+ start: !1,
185
+ back: !1,
186
+ goto: !1,
187
+ next: !1,
188
+ end: !1
189
+ }, logItems: [] };
190
+ this.channel?.emit(EVENTS.SYNC, payload), this.updateParentWindowState();
266
191
  }
267
192
  getLog(storyId) {
268
- const { calls, shadowCalls } = this.getState(storyId);
269
- const merged = [...shadowCalls];
193
+ let { calls, shadowCalls } = this.getState(storyId), merged = [...shadowCalls];
270
194
  calls.forEach((call, index) => {
271
195
  merged[index] = call;
272
196
  });
273
- const seen = /* @__PURE__ */ new Set();
274
- return merged.reduceRight((acc, call) => {
275
- call.args.forEach((arg) => {
276
- if (arg?.__callId__) {
277
- seen.add(arg.__callId__);
278
- }
279
- });
280
- call.path.forEach((node) => {
281
- if (node.__callId__) {
282
- seen.add(node.__callId__);
283
- }
284
- });
285
- if ((call.interceptable || call.exception) && !seen.has(call.id)) {
286
- acc.unshift({ callId: call.id, status: call.status, ancestors: call.ancestors });
287
- seen.add(call.id);
288
- }
289
- return acc;
290
- }, []);
197
+ let seen = /* @__PURE__ */ new Set();
198
+ return merged.reduceRight((acc, call) => (call.args.forEach((arg) => {
199
+ arg?.__callId__ && seen.add(arg.__callId__);
200
+ }), call.path.forEach((node) => {
201
+ node.__callId__ && seen.add(node.__callId__);
202
+ }), (call.interceptable || call.exception) && !seen.has(call.id) && (acc.unshift({ callId: call.id, status: call.status, ancestors: call.ancestors }), seen.add(call.id)), acc), []);
291
203
  }
292
204
  // Traverses the object structure to recursively patch all function properties.
293
205
  // Returns the original object, or a new object with the same constructor,
294
206
  // depending on whether it should mutate.
295
207
  instrument(obj, options, depth = 0) {
296
- if (!isInstrumentable(obj)) {
208
+ if (!isInstrumentable(obj))
297
209
  return obj;
298
- }
299
- const { mutate = false, path = [] } = options;
300
- const keys = options.getKeys ? options.getKeys(obj, depth) : Object.keys(obj);
301
- depth += 1;
302
- return keys.reduce(
210
+ let { mutate = !1, path = [] } = options, keys = options.getKeys ? options.getKeys(obj, depth) : Object.keys(obj);
211
+ return depth += 1, keys.reduce(
303
212
  (acc, key) => {
304
- const descriptor = getPropertyDescriptor(obj, key);
305
- if (typeof descriptor?.get === "function") {
213
+ let descriptor = getPropertyDescriptor(obj, key);
214
+ if (typeof descriptor?.get == "function") {
306
215
  if (descriptor.configurable) {
307
- const getter = /* @__PURE__ */ __name(() => descriptor?.get?.bind(obj)?.(), "getter");
216
+ let getter = () => descriptor?.get?.bind(obj)?.();
308
217
  Object.defineProperty(acc, key, {
309
- get: /* @__PURE__ */ __name(() => {
310
- return this.instrument(getter(), { ...options, path: path.concat(key) }, depth);
311
- }, "get")
218
+ get: () => this.instrument(getter(), { ...options, path: path.concat(key) }, depth)
312
219
  });
313
220
  }
314
221
  return acc;
315
222
  }
316
- const value = obj[key];
317
- if (typeof value !== "function") {
318
- acc[key] = this.instrument(value, { ...options, path: path.concat(key) }, depth);
319
- return acc;
320
- }
321
- if ("__originalFn__" in value && typeof value.__originalFn__ === "function") {
322
- acc[key] = value;
323
- return acc;
324
- }
325
- acc[key] = (...args) => this.track(key, value, obj, args, options);
326
- acc[key].__originalFn__ = value;
327
- Object.defineProperty(acc[key], "name", { value: key, writable: false });
328
- if (Object.keys(value).length > 0) {
329
- Object.assign(
330
- acc[key],
331
- this.instrument({ ...value }, { ...options, path: path.concat(key) }, depth)
332
- );
333
- }
334
- return acc;
223
+ let value = obj[key];
224
+ return typeof value != "function" ? (acc[key] = this.instrument(value, { ...options, path: path.concat(key) }, depth), acc) : "__originalFn__" in value && typeof value.__originalFn__ == "function" ? (acc[key] = value, acc) : (acc[key] = (...args) => this.track(key, value, obj, args, options), acc[key].__originalFn__ = value, Object.defineProperty(acc[key], "name", { value: key, writable: !1 }), Object.keys(value).length > 0 && Object.assign(
225
+ acc[key],
226
+ this.instrument({ ...value }, { ...options, path: path.concat(key) }, depth)
227
+ ), acc);
335
228
  },
336
229
  mutate ? obj : construct(obj)
337
230
  );
@@ -340,282 +233,173 @@ var _Instrumenter = class _Instrumenter {
340
233
  // Returns a function that invokes the original function, records the invocation ("call") and
341
234
  // returns the original result.
342
235
  track(method, fn, object, args, options) {
343
- const storyId = args?.[0]?.__storyId__ || global.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId;
344
- const { cursor, ancestors } = this.getState(storyId);
236
+ let storyId = args?.[0]?.__storyId__ || global.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId, { cursor, ancestors } = this.getState(storyId);
345
237
  this.setState(storyId, { cursor: cursor + 1 });
346
- const id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`;
347
- const { path = [], intercept = false, retain = false } = options;
348
- const interceptable = typeof intercept === "function" ? intercept(method, path) : intercept;
349
- const call = { id, cursor, storyId, ancestors, path, method, args, interceptable, retain };
350
- const interceptOrInvoke = interceptable && !ancestors.length ? this.intercept : this.invoke;
351
- const result = interceptOrInvoke.call(this, fn, object, call, options);
352
- return this.instrument(result, { ...options, mutate: true, path: [{ __callId__: call.id }] });
238
+ let id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`, { path = [], intercept = !1, retain = !1 } = options, interceptable = typeof intercept == "function" ? intercept(method, path) : intercept, call = { id, cursor, storyId, ancestors, path, method, args, interceptable, retain }, result = (interceptable && !ancestors.length ? this.intercept : this.invoke).call(this, fn, object, call, options);
239
+ return this.instrument(result, { ...options, mutate: !0, path: [{ __callId__: call.id }] });
353
240
  }
354
241
  intercept(fn, object, call, options) {
355
- const { chainedCallIds, isDebugging, playUntil } = this.getState(call.storyId);
356
- const isChainedUpon = chainedCallIds.has(call.id);
357
- if (!isDebugging || isChainedUpon || playUntil) {
358
- if (playUntil === call.id) {
359
- this.setState(call.storyId, { playUntil: void 0 });
360
- }
361
- return this.invoke(fn, object, call, options);
362
- }
363
- return new Promise((resolve) => {
242
+ let { chainedCallIds, isDebugging, playUntil } = this.getState(call.storyId), isChainedUpon = chainedCallIds.has(call.id);
243
+ return !isDebugging || isChainedUpon || playUntil ? (playUntil === call.id && this.setState(call.storyId, { playUntil: void 0 }), this.invoke(fn, object, call, options)) : new Promise((resolve) => {
364
244
  this.setState(call.storyId, ({ resolvers }) => ({
365
- isLocked: false,
245
+ isLocked: !1,
366
246
  resolvers: { ...resolvers, [call.id]: resolve }
367
247
  }));
368
- }).then(() => {
369
- this.setState(call.storyId, (state) => {
370
- const { [call.id]: _, ...resolvers } = state.resolvers;
371
- return { isLocked: true, resolvers };
372
- });
373
- return this.invoke(fn, object, call, options);
374
- });
248
+ }).then(() => (this.setState(call.storyId, (state) => {
249
+ let { [call.id]: _, ...resolvers } = state.resolvers;
250
+ return { isLocked: !0, resolvers };
251
+ }), this.invoke(fn, object, call, options)));
375
252
  }
376
253
  invoke(fn, object, call, options) {
377
- const { callRefsByResult, renderPhase } = this.getState(call.storyId);
378
- const maximumDepth = 25;
379
- const serializeValues = /* @__PURE__ */ __name((value, depth, seen) => {
380
- if (seen.includes(value)) {
254
+ let { callRefsByResult, renderPhase } = this.getState(call.storyId), maximumDepth = 25, serializeValues = (value, depth, seen) => {
255
+ if (seen.includes(value))
381
256
  return "[Circular]";
382
- }
383
- seen = [...seen, value];
384
- if (depth > maximumDepth) {
257
+ if (seen = [...seen, value], depth > maximumDepth)
385
258
  return "...";
386
- }
387
- if (callRefsByResult.has(value)) {
259
+ if (callRefsByResult.has(value))
388
260
  return callRefsByResult.get(value);
389
- }
390
- if (value instanceof Array) {
261
+ if (value instanceof Array)
391
262
  return value.map((it) => serializeValues(it, ++depth, seen));
392
- }
393
- if (value instanceof Date) {
263
+ if (value instanceof Date)
394
264
  return { __date__: { value: value.toISOString() } };
395
- }
396
265
  if (value instanceof Error) {
397
- const { name, message, stack } = value;
266
+ let { name, message, stack } = value;
398
267
  return { __error__: { name, message, stack } };
399
268
  }
400
269
  if (value instanceof RegExp) {
401
- const { flags, source } = value;
270
+ let { flags, source } = value;
402
271
  return { __regexp__: { flags, source } };
403
272
  }
404
273
  if (value instanceof global.window?.HTMLElement) {
405
- const { prefix, localName, id, classList, innerText } = value;
406
- const classNames = Array.from(classList);
274
+ let { prefix, localName, id, classList, innerText } = value, classNames = Array.from(classList);
407
275
  return { __element__: { prefix, localName, id, classNames, innerText } };
408
276
  }
409
- if (typeof value === "function") {
410
- return {
411
- __function__: { name: "getMockName" in value ? value.getMockName() : value.name }
412
- };
413
- }
414
- if (typeof value === "symbol") {
415
- return { __symbol__: { description: value.description } };
416
- }
417
- if (typeof value === "object" && value?.constructor?.name && value?.constructor?.name !== "Object") {
418
- return { __class__: { name: value.constructor.name } };
419
- }
420
- if (Object.prototype.toString.call(value) === "[object Object]") {
421
- return Object.fromEntries(
422
- Object.entries(value).map(([key, val]) => [key, serializeValues(val, ++depth, seen)])
423
- );
424
- }
425
- return value;
426
- }, "serializeValues");
427
- const info = {
277
+ return typeof value == "function" ? {
278
+ __function__: { name: "getMockName" in value ? value.getMockName() : value.name }
279
+ } : typeof value == "symbol" ? { __symbol__: { description: value.description } } : typeof value == "object" && value?.constructor?.name && value?.constructor?.name !== "Object" ? { __class__: { name: value.constructor.name } } : Object.prototype.toString.call(value) === "[object Object]" ? Object.fromEntries(
280
+ Object.entries(value).map(([key, val]) => [key, serializeValues(val, ++depth, seen)])
281
+ ) : value;
282
+ }, info = {
428
283
  ...call,
429
284
  args: call.args.map((arg) => serializeValues(arg, 0, []))
430
285
  };
431
286
  call.path.forEach((ref) => {
432
- if (ref?.__callId__) {
433
- this.setState(call.storyId, ({ chainedCallIds }) => ({
434
- chainedCallIds: new Set(Array.from(chainedCallIds).concat(ref.__callId__))
435
- }));
436
- }
287
+ ref?.__callId__ && this.setState(call.storyId, ({ chainedCallIds }) => ({
288
+ chainedCallIds: new Set(Array.from(chainedCallIds).concat(ref.__callId__))
289
+ }));
437
290
  });
438
- const handleException = /* @__PURE__ */ __name((e) => {
291
+ let handleException = (e) => {
439
292
  if (e instanceof Error) {
440
- const { name, message, stack, callId = call.id } = e;
441
- const {
293
+ let { name, message, stack, callId = call.id } = e, {
442
294
  showDiff = void 0,
443
295
  diff = void 0,
444
296
  actual = void 0,
445
297
  expected = void 0
446
- } = e.name === "AssertionError" ? processError(e) : e;
447
- const exception = { name, message, stack, callId, showDiff, diff, actual, expected };
448
- this.update({ ...info, status: "error" /* ERROR */, exception });
449
- this.setState(call.storyId, (state) => ({
298
+ } = e.name === "AssertionError" ? processError(e) : e, exception = { name, message, stack, callId, showDiff, diff, actual, expected };
299
+ if (this.update({ ...info, status: "error" /* ERROR */, exception }), this.setState(call.storyId, (state) => ({
450
300
  callRefsByResult: new Map([
451
301
  ...Array.from(state.callRefsByResult.entries()),
452
302
  [e, { __callId__: call.id, retain: call.retain }]
453
303
  ])
454
- }));
455
- if (call.ancestors?.length) {
456
- if (!Object.prototype.hasOwnProperty.call(e, "callId")) {
457
- Object.defineProperty(e, "callId", { value: call.id });
458
- }
459
- throw e;
460
- }
304
+ })), call.ancestors?.length)
305
+ throw Object.prototype.hasOwnProperty.call(e, "callId") || Object.defineProperty(e, "callId", { value: call.id }), e;
461
306
  }
462
307
  throw e;
463
- }, "handleException");
308
+ };
464
309
  try {
465
- if (renderPhase === "played" && !call.retain) {
310
+ if (renderPhase === "played" && !call.retain)
466
311
  throw alreadyCompletedException;
467
- }
468
- const actualArgs = options.getArgs ? options.getArgs(call, this.getState(call.storyId)) : call.args;
469
- const finalArgs = actualArgs.map((arg) => {
470
- if (typeof arg !== "function" || isClass(arg) || Object.keys(arg).length) {
471
- return arg;
312
+ let finalArgs = (options.getArgs ? options.getArgs(call, this.getState(call.storyId)) : call.args).map((arg) => typeof arg != "function" || isClass(arg) || Object.keys(arg).length ? arg : (...args) => {
313
+ let { cursor, ancestors } = this.getState(call.storyId);
314
+ this.setState(call.storyId, { cursor: 0, ancestors: [...ancestors, call.id] });
315
+ let restore = () => this.setState(call.storyId, { cursor, ancestors }), willRestore = !1;
316
+ try {
317
+ let res = arg(...args);
318
+ return res instanceof Promise ? (willRestore = !0, res.finally(restore)) : res;
319
+ } finally {
320
+ willRestore || restore();
472
321
  }
473
- return (...args) => {
474
- const { cursor, ancestors } = this.getState(call.storyId);
475
- this.setState(call.storyId, { cursor: 0, ancestors: [...ancestors, call.id] });
476
- const restore = /* @__PURE__ */ __name(() => this.setState(call.storyId, { cursor, ancestors }), "restore");
477
- let willRestore = false;
478
- try {
479
- const res = arg(...args);
480
- if (res instanceof Promise) {
481
- willRestore = true;
482
- return res.finally(restore);
483
- }
484
- return res;
485
- } finally {
486
- if (!willRestore) {
487
- restore();
488
- }
489
- }
490
- };
491
- });
492
- const result = fn.apply(object, finalArgs);
493
- if (result && ["object", "function", "symbol"].includes(typeof result)) {
494
- this.setState(call.storyId, (state) => ({
495
- callRefsByResult: new Map([
496
- ...Array.from(state.callRefsByResult.entries()),
497
- [result, { __callId__: call.id, retain: call.retain }]
498
- ])
499
- }));
500
- }
501
- this.update({
322
+ }), result = fn.apply(object, finalArgs);
323
+ return result && ["object", "function", "symbol"].includes(typeof result) && this.setState(call.storyId, (state) => ({
324
+ callRefsByResult: new Map([
325
+ ...Array.from(state.callRefsByResult.entries()),
326
+ [result, { __callId__: call.id, retain: call.retain }]
327
+ ])
328
+ })), this.update({
502
329
  ...info,
503
330
  status: result instanceof Promise ? "active" /* ACTIVE */ : "done" /* DONE */
504
- });
505
- if (result instanceof Promise) {
506
- return result.then((value) => {
507
- this.update({ ...info, status: "done" /* DONE */ });
508
- return value;
509
- }, handleException);
510
- }
511
- return result;
331
+ }), result instanceof Promise ? result.then((value) => (this.update({ ...info, status: "done" /* DONE */ }), value), handleException) : result;
512
332
  } catch (e) {
513
333
  return handleException(e);
514
334
  }
515
335
  }
516
336
  // Sends the call info to the manager and synchronizes the log.
517
337
  update(call) {
518
- this.channel?.emit(EVENTS.CALL, call);
519
- this.setState(call.storyId, ({ calls }) => {
520
- const callsById = calls.concat(call).reduce((a, c) => Object.assign(a, { [c.id]: c }), {});
338
+ this.channel?.emit(EVENTS.CALL, call), this.setState(call.storyId, ({ calls }) => {
339
+ let callsById = calls.concat(call).reduce((a, c) => Object.assign(a, { [c.id]: c }), {});
521
340
  return {
522
341
  // Calls are sorted to ensure parent calls always come before calls in their callback.
523
342
  calls: Object.values(callsById).sort(
524
- (a, b) => a.id.localeCompare(b.id, void 0, { numeric: true })
343
+ (a, b) => a.id.localeCompare(b.id, void 0, { numeric: !0 })
525
344
  )
526
345
  };
527
- });
528
- this.sync(call.storyId);
346
+ }), this.sync(call.storyId);
529
347
  }
530
348
  // Builds a log of interceptable calls and control states and sends it to the manager.
531
349
  // Uses a 0ms debounce because this might get called many times in one tick.
532
350
  sync(storyId) {
533
- const synchronize = /* @__PURE__ */ __name(() => {
534
- const { isLocked, isPlaying } = this.getState(storyId);
535
- const logItems = this.getLog(storyId);
536
- const pausedAt = logItems.filter(({ ancestors }) => !ancestors.length).find((item) => item.status === "waiting" /* WAITING */)?.callId;
537
- const hasActive = logItems.some((item) => item.status === "active" /* ACTIVE */);
351
+ let synchronize = () => {
352
+ let { isLocked, isPlaying } = this.getState(storyId), logItems = this.getLog(storyId), pausedAt = logItems.filter(({ ancestors }) => !ancestors.length).find((item) => item.status === "waiting" /* WAITING */)?.callId, hasActive = logItems.some((item) => item.status === "active" /* ACTIVE */);
538
353
  if (this.detached || isLocked || hasActive || logItems.length === 0) {
539
- const controlStates2 = {
354
+ let payload2 = { controlStates: {
540
355
  detached: this.detached,
541
- start: false,
542
- back: false,
543
- goto: false,
544
- next: false,
545
- end: false
546
- };
547
- const payload2 = { controlStates: controlStates2, logItems };
356
+ start: !1,
357
+ back: !1,
358
+ goto: !1,
359
+ next: !1,
360
+ end: !1
361
+ }, logItems };
548
362
  this.channel?.emit(EVENTS.SYNC, payload2);
549
363
  return;
550
364
  }
551
- const hasPrevious = logItems.some(
365
+ let hasPrevious = logItems.some(
552
366
  (item) => item.status === "done" /* DONE */ || item.status === "error" /* ERROR */
553
- );
554
- const controlStates = {
367
+ ), payload = { controlStates: {
555
368
  detached: this.detached,
556
369
  start: hasPrevious,
557
370
  back: hasPrevious,
558
- goto: true,
371
+ goto: !0,
559
372
  next: isPlaying,
560
373
  end: isPlaying
561
- };
562
- const payload = { controlStates, logItems, pausedAt };
374
+ }, logItems, pausedAt };
563
375
  this.channel?.emit(EVENTS.SYNC, payload);
564
- }, "synchronize");
565
- this.setState(storyId, ({ syncTimeout }) => {
566
- clearTimeout(syncTimeout);
567
- return { syncTimeout: setTimeout(synchronize, 0) };
568
- });
376
+ };
377
+ this.setState(storyId, ({ syncTimeout }) => (clearTimeout(syncTimeout), { syncTimeout: setTimeout(synchronize, 0) }));
569
378
  }
570
379
  };
571
- __name(_Instrumenter, "Instrumenter");
572
- var Instrumenter = _Instrumenter;
573
380
  function instrument(obj, options = {}) {
574
381
  try {
575
- let forceInstrument = false;
576
- let skipInstrument = false;
577
- if (global.window?.location?.search?.includes("instrument=true")) {
578
- forceInstrument = true;
579
- } else if (global.window?.location?.search?.includes("instrument=false")) {
580
- skipInstrument = true;
581
- }
582
- if (global.window?.parent === global.window && !forceInstrument || skipInstrument) {
583
- return obj;
584
- }
585
- if (global.window && !global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__) {
586
- global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__ = new Instrumenter();
587
- }
588
- const instrumenter = global.window?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__;
589
- return instrumenter.instrument(obj, options);
382
+ let forceInstrument = !1, skipInstrument = !1;
383
+ return global.window?.location?.search?.includes("instrument=true") ? forceInstrument = !0 : global.window?.location?.search?.includes("instrument=false") && (skipInstrument = !0), global.window?.parent === global.window && !forceInstrument || skipInstrument ? obj : (global.window && !global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__ && (global.window.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__ = new Instrumenter()), (global.window?.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__).instrument(obj, options));
590
384
  } catch (e) {
591
- once.warn(e);
592
- return obj;
385
+ return once.warn(e), obj;
593
386
  }
594
387
  }
595
- __name(instrument, "instrument");
596
388
  function getPropertyDescriptor(obj, propName) {
597
389
  let target = obj;
598
- while (target != null) {
599
- const descriptor = Object.getOwnPropertyDescriptor(target, propName);
600
- if (descriptor) {
390
+ for (; target != null; ) {
391
+ let descriptor = Object.getOwnPropertyDescriptor(target, propName);
392
+ if (descriptor)
601
393
  return descriptor;
602
- }
603
394
  target = Object.getPrototypeOf(target);
604
395
  }
605
- return void 0;
606
396
  }
607
- __name(getPropertyDescriptor, "getPropertyDescriptor");
608
397
  function isClass(obj) {
609
- if (typeof obj !== "function") {
610
- return false;
611
- }
612
- const descriptor = Object.getOwnPropertyDescriptor(obj, "prototype");
613
- if (!descriptor) {
614
- return false;
615
- }
616
- return !descriptor.writable;
398
+ if (typeof obj != "function")
399
+ return !1;
400
+ let descriptor = Object.getOwnPropertyDescriptor(obj, "prototype");
401
+ return descriptor ? !descriptor.writable : !1;
617
402
  }
618
- __name(isClass, "isClass");
619
403
  export {
620
404
  CallStates,
621
405
  EVENTS,