storybook 10.1.0-alpha.9 → 10.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.
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-SM3UWERX.js → builder-manager-FTVC2JL7.js} +510 -1019
  40. package/dist/_node-chunks/camelcase-3SMT5WKC.js +37 -0
  41. package/dist/_node-chunks/chunk-2OVULPK3.js +54 -0
  42. package/dist/_node-chunks/chunk-3JJPSDXI.js +3043 -0
  43. package/dist/_node-chunks/chunk-54NMJ4II.js +1564 -0
  44. package/dist/_node-chunks/chunk-5V4A6MSI.js +943 -0
  45. package/dist/_node-chunks/chunk-6DEMT5VX.js +299 -0
  46. package/dist/_node-chunks/{chunk-HHSTA6QS.js → chunk-6L7FFBOW.js} +8 -10
  47. package/dist/_node-chunks/chunk-6ULDIDXV.js +46662 -0
  48. package/dist/_node-chunks/chunk-AREL5IXS.js +603 -0
  49. package/dist/_node-chunks/chunk-DWA53E73.js +23 -0
  50. package/dist/_node-chunks/chunk-FNYKBULZ.js +765 -0
  51. package/dist/_node-chunks/chunk-IUYZQKSX.js +70 -0
  52. package/dist/_node-chunks/{chunk-F6EFOEC7.js → chunk-K673CX4Q.js} +469 -983
  53. package/dist/_node-chunks/chunk-KJAFCNZ3.js +61 -0
  54. package/dist/_node-chunks/chunk-N3BJOOY5.js +78 -0
  55. package/dist/_node-chunks/{chunk-EBUEXRH5.js → chunk-O5FMCQHP.js} +116 -276
  56. package/dist/_node-chunks/chunk-RIKQZHV3.js +29 -0
  57. package/dist/_node-chunks/chunk-RURZIE3W.js +3780 -0
  58. package/dist/_node-chunks/chunk-RVII4SK6.js +919 -0
  59. package/dist/_node-chunks/chunk-S3PBHOVC.js +6024 -0
  60. package/dist/_node-chunks/chunk-SQSFX47N.js +61 -0
  61. package/dist/_node-chunks/{chunk-SGM3ZCCT.js → chunk-TURUTKVH.js} +292 -688
  62. package/dist/_node-chunks/chunk-VRICJPXY.js +72 -0
  63. package/dist/_node-chunks/chunk-WIWWMCEU.js +119 -0
  64. package/dist/_node-chunks/{chunk-ATDHMMIZ.js → chunk-XGNRK7QB.js} +15 -24
  65. package/dist/_node-chunks/chunk-Y2FOTPAE.js +4523 -0
  66. package/dist/_node-chunks/{chunk-GHIBZRKD.js → chunk-Y4UYN72K.js} +8133 -8887
  67. package/dist/_node-chunks/chunk-Z4BMBA5L.js +18 -0
  68. package/dist/_node-chunks/chunk-ZMCJS2GU.js +20 -0
  69. package/dist/_node-chunks/dist-TZLZ3T6L.js +121 -0
  70. package/dist/_node-chunks/globby-22GFCZQD.js +3452 -0
  71. package/dist/_node-chunks/lib-37NQ4ZIJ.js +366 -0
  72. package/dist/_node-chunks/mdx-N42X6CFJ-2TRB7OEH.js +14329 -0
  73. package/dist/_node-chunks/p-limit-UD7TYFDW.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 +602 -1549
  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 +2911 -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 +11569 -10953
  106. package/dist/manager-api/index.d.ts +1813 -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-H5QSGQLK.js +0 -18
  161. package/dist/_node-chunks/chunk-3THWHQOC.js +0 -61
  162. package/dist/_node-chunks/chunk-45YUOLTU.js +0 -69
  163. package/dist/_node-chunks/chunk-4QSNCPAU.js +0 -64656
  164. package/dist/_node-chunks/chunk-744PQSOU.js +0 -79
  165. package/dist/_node-chunks/chunk-74Z2U7QG.js +0 -1544
  166. package/dist/_node-chunks/chunk-7MB7TFPO.js +0 -1198
  167. package/dist/_node-chunks/chunk-A7GS4RFT.js +0 -697
  168. package/dist/_node-chunks/chunk-BIA3A5UM.js +0 -61
  169. package/dist/_node-chunks/chunk-C5G7CLWX.js +0 -1657
  170. package/dist/_node-chunks/chunk-DLFUKMYJ.js +0 -1531
  171. package/dist/_node-chunks/chunk-EMRGRXKT.js +0 -111
  172. package/dist/_node-chunks/chunk-EX46EHHY.js +0 -420
  173. package/dist/_node-chunks/chunk-F76QKNOJ.js +0 -304
  174. package/dist/_node-chunks/chunk-HDCRUTEF.js +0 -220
  175. package/dist/_node-chunks/chunk-HUYAOIPH.js +0 -90
  176. package/dist/_node-chunks/chunk-IBJZQZJC.js +0 -101
  177. package/dist/_node-chunks/chunk-KZN2RDDT.js +0 -6712
  178. package/dist/_node-chunks/chunk-LYUNFU3F.js +0 -4741
  179. package/dist/_node-chunks/chunk-N44SIS6K.js +0 -28
  180. package/dist/_node-chunks/chunk-NILZM6KR.js +0 -18
  181. package/dist/_node-chunks/chunk-PC4ZRP6W.js +0 -34
  182. package/dist/_node-chunks/chunk-TJNGOQUH.js +0 -4272
  183. package/dist/_node-chunks/chunk-UBSYLHIL.js +0 -1250
  184. package/dist/_node-chunks/chunk-UTCLXPOC.js +0 -1518
  185. package/dist/_node-chunks/chunk-WOXXODXP.js +0 -5029
  186. package/dist/_node-chunks/chunk-XC4MEUA6.js +0 -1586
  187. package/dist/_node-chunks/chunk-YRXXMKRR.js +0 -2256
  188. package/dist/_node-chunks/dist-SL73W244.js +0 -175
  189. package/dist/_node-chunks/globby-ZSHAUQZ5.js +0 -5222
  190. package/dist/_node-chunks/lib-U2VIPUTI.js +0 -518
  191. package/dist/_node-chunks/mdx-N42X6CFJ-ZLHD33JK.js +0 -22017
  192. package/dist/_node-chunks/p-limit-K5BS5MSV.js +0 -168
  193. package/dist/_node-chunks/plugin-5PD4YIUH.js +0 -129
  194. package/dist/_node-chunks/plugin-MONDT2WL.js +0 -159
  195. package/dist/_node-chunks/webpack-inject-mocker-runtime-plugin-EUZJRG3W.js +0 -69102
  196. package/dist/_node-chunks/webpack-mock-plugin-T4LDXEHE.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,168 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- __name
14
- } from "./chunk-3THWHQOC.js";
15
-
16
- // ../node_modules/yocto-queue/index.js
17
- var Node = class {
18
- static {
19
- __name(this, "Node");
20
- }
21
- value;
22
- next;
23
- constructor(value) {
24
- this.value = value;
25
- }
26
- };
27
- var Queue = class {
28
- static {
29
- __name(this, "Queue");
30
- }
31
- #head;
32
- #tail;
33
- #size;
34
- constructor() {
35
- this.clear();
36
- }
37
- enqueue(value) {
38
- const node = new Node(value);
39
- if (this.#head) {
40
- this.#tail.next = node;
41
- this.#tail = node;
42
- } else {
43
- this.#head = node;
44
- this.#tail = node;
45
- }
46
- this.#size++;
47
- }
48
- dequeue() {
49
- const current = this.#head;
50
- if (!current) {
51
- return;
52
- }
53
- this.#head = this.#head.next;
54
- this.#size--;
55
- return current.value;
56
- }
57
- peek() {
58
- if (!this.#head) {
59
- return;
60
- }
61
- return this.#head.value;
62
- }
63
- clear() {
64
- this.#head = void 0;
65
- this.#tail = void 0;
66
- this.#size = 0;
67
- }
68
- get size() {
69
- return this.#size;
70
- }
71
- *[Symbol.iterator]() {
72
- let current = this.#head;
73
- while (current) {
74
- yield current.value;
75
- current = current.next;
76
- }
77
- }
78
- *drain() {
79
- while (this.#head) {
80
- yield this.dequeue();
81
- }
82
- }
83
- };
84
-
85
- // ../node_modules/p-limit/index.js
86
- function pLimit(concurrency) {
87
- validateConcurrency(concurrency);
88
- const queue = new Queue();
89
- let activeCount = 0;
90
- const resumeNext = /* @__PURE__ */ __name(() => {
91
- if (activeCount < concurrency && queue.size > 0) {
92
- queue.dequeue()();
93
- activeCount++;
94
- }
95
- }, "resumeNext");
96
- const next = /* @__PURE__ */ __name(() => {
97
- activeCount--;
98
- resumeNext();
99
- }, "next");
100
- const run = /* @__PURE__ */ __name(async (function_, resolve, arguments_) => {
101
- const result = (async () => function_(...arguments_))();
102
- resolve(result);
103
- try {
104
- await result;
105
- } catch {
106
- }
107
- next();
108
- }, "run");
109
- const enqueue = /* @__PURE__ */ __name((function_, resolve, arguments_) => {
110
- new Promise((internalResolve) => {
111
- queue.enqueue(internalResolve);
112
- }).then(
113
- run.bind(void 0, function_, resolve, arguments_)
114
- );
115
- (async () => {
116
- await Promise.resolve();
117
- if (activeCount < concurrency) {
118
- resumeNext();
119
- }
120
- })();
121
- }, "enqueue");
122
- const generator = /* @__PURE__ */ __name((function_, ...arguments_) => new Promise((resolve) => {
123
- enqueue(function_, resolve, arguments_);
124
- }), "generator");
125
- Object.defineProperties(generator, {
126
- activeCount: {
127
- get: /* @__PURE__ */ __name(() => activeCount, "get")
128
- },
129
- pendingCount: {
130
- get: /* @__PURE__ */ __name(() => queue.size, "get")
131
- },
132
- clearQueue: {
133
- value() {
134
- queue.clear();
135
- }
136
- },
137
- concurrency: {
138
- get: /* @__PURE__ */ __name(() => concurrency, "get"),
139
- set(newConcurrency) {
140
- validateConcurrency(newConcurrency);
141
- concurrency = newConcurrency;
142
- queueMicrotask(() => {
143
- while (activeCount < concurrency && queue.size > 0) {
144
- resumeNext();
145
- }
146
- });
147
- }
148
- }
149
- });
150
- return generator;
151
- }
152
- __name(pLimit, "pLimit");
153
- function limitFunction(function_, option) {
154
- const { concurrency } = option;
155
- const limit = pLimit(concurrency);
156
- return (...arguments_) => limit(() => function_(...arguments_));
157
- }
158
- __name(limitFunction, "limitFunction");
159
- function validateConcurrency(concurrency) {
160
- if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {
161
- throw new TypeError("Expected `concurrency` to be a number from 1 and up");
162
- }
163
- }
164
- __name(validateConcurrency, "validateConcurrency");
165
- export {
166
- pLimit as default,
167
- limitFunction
168
- };
@@ -1,129 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- resolvePackageDir
14
- } from "./chunk-74Z2U7QG.js";
15
- import "./chunk-HDCRUTEF.js";
16
- import {
17
- require_dist
18
- } from "./chunk-45YUOLTU.js";
19
- import {
20
- __name,
21
- __toESM
22
- } from "./chunk-3THWHQOC.js";
23
-
24
- // src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
25
- import { readFileSync } from "node:fs";
26
- import { join } from "node:path";
27
- import { fileURLToPath } from "node:url";
28
-
29
- // ../node_modules/@rolldown/pluginutils/dist/index.js
30
- function exactRegex(str, flags) {
31
- return new RegExp(`^${escapeRegex(str)}$`, flags);
32
- }
33
- __name(exactRegex, "exactRegex");
34
- var escapeRegexRE = /[-/\\^$*+?.()|[\]{}]/g;
35
- function escapeRegex(str) {
36
- return str.replace(escapeRegexRE, "\\$&");
37
- }
38
- __name(escapeRegex, "escapeRegex");
39
-
40
- // src/core-server/presets/vitePlugins/vite-inject-mocker/plugin.ts
41
- var import_ts_dedent = __toESM(require_dist(), 1);
42
- var entryPath = "/vite-inject-mocker-entry.js";
43
- var entryCode = import_ts_dedent.dedent`
44
- <script type="module" src=".${entryPath}"></script>
45
- `;
46
- var server;
47
- var viteInjectMockerRuntime = /* @__PURE__ */ __name((options) => {
48
- let viteConfig;
49
- return {
50
- name: "vite:storybook-inject-mocker-runtime",
51
- buildStart() {
52
- if (viteConfig.command === "build") {
53
- this.emitFile({
54
- type: "chunk",
55
- id: join(
56
- resolvePackageDir("storybook"),
57
- "assets",
58
- "server",
59
- "mocker-runtime.template.js"
60
- ),
61
- fileName: entryPath.slice(1)
62
- });
63
- }
64
- },
65
- config() {
66
- return {
67
- optimizeDeps: {
68
- include: ["@vitest/mocker", "@vitest/mocker/browser"]
69
- },
70
- resolve: {
71
- // Aliasing necessary for package managers like pnpm, since resolving modules from a virtual module
72
- // leads to errors, if the imported module is not a dependency of the project.
73
- // By resolving the module to the real path, we can avoid this issue.
74
- alias: {
75
- "@vitest/mocker/browser": fileURLToPath(import.meta.resolve("@vitest/mocker/browser")),
76
- "@vitest/mocker": fileURLToPath(import.meta.resolve("@vitest/mocker"))
77
- }
78
- }
79
- };
80
- },
81
- configResolved(config) {
82
- viteConfig = config;
83
- },
84
- configureServer(server_) {
85
- server = server_;
86
- if (options.previewConfigPath) {
87
- server.watcher.on("change", (file) => {
88
- if (file === options.previewConfigPath) {
89
- server.ws.send({
90
- type: "custom",
91
- event: "invalidate-mocker"
92
- });
93
- }
94
- });
95
- }
96
- },
97
- resolveId: {
98
- filter: {
99
- id: [exactRegex(entryPath)]
100
- },
101
- handler(id) {
102
- if (exactRegex(id).test(entryPath)) {
103
- return id;
104
- }
105
- return null;
106
- }
107
- },
108
- async load(id) {
109
- if (exactRegex(id).test(entryPath)) {
110
- return readFileSync(
111
- join(resolvePackageDir("storybook"), "assets", "server", "mocker-runtime.template.js"),
112
- "utf-8"
113
- );
114
- }
115
- return null;
116
- },
117
- transformIndexHtml(html) {
118
- const headTag = html.match(/<head[^>]*>/);
119
- if (headTag) {
120
- const headTagIndex = html.indexOf(headTag[0]);
121
- const newHtml = html.slice(0, headTagIndex + headTag[0].length) + entryCode + html.slice(headTagIndex + headTag[0].length);
122
- return newHtml;
123
- }
124
- }
125
- };
126
- }, "viteInjectMockerRuntime");
127
- export {
128
- viteInjectMockerRuntime
129
- };
@@ -1,159 +0,0 @@
1
- import CJS_COMPAT_NODE_URL_jpweijb0qqj from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_jpweijb0qqj from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_jpweijb0qqj from "node:module";
4
-
5
- var __filename = CJS_COMPAT_NODE_URL_jpweijb0qqj.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_jpweijb0qqj.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_jpweijb0qqj.createRequire(import.meta.url);
8
-
9
- // ------------------------------------------------------------
10
- // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
- // ------------------------------------------------------------
12
- import {
13
- getAutomockCode
14
- } from "./chunk-UBSYLHIL.js";
15
- import {
16
- babelParser,
17
- extractMockCalls,
18
- getRealPath,
19
- rewriteSbMockImportCalls
20
- } from "./chunk-EX46EHHY.js";
21
- import {
22
- normalize
23
- } from "./chunk-HDCRUTEF.js";
24
- import {
25
- __name
26
- } from "./chunk-3THWHQOC.js";
27
-
28
- // src/core-server/presets/vitePlugins/vite-mock/plugin.ts
29
- import { readFileSync } from "node:fs";
30
- import { logger } from "storybook/internal/node-logger";
31
-
32
- // src/core-server/presets/vitePlugins/vite-mock/utils.ts
33
- function getCleanId(id) {
34
- return id.replace(/^.*\/deps\//, "").replace(/\.js.*$/, "").replace(/_/g, "/");
35
- }
36
- __name(getCleanId, "getCleanId");
37
- function invalidateAllRelatedModules(server, absPath, pkgName) {
38
- for (const mod of server.moduleGraph.idToModuleMap.values()) {
39
- if (mod.id === absPath || mod.id && getCleanId(mod.id) === pkgName) {
40
- server.moduleGraph.invalidateModule(mod);
41
- }
42
- }
43
- }
44
- __name(invalidateAllRelatedModules, "invalidateAllRelatedModules");
45
-
46
- // src/core-server/presets/vitePlugins/vite-mock/plugin.ts
47
- function viteMockPlugin(options) {
48
- let viteConfig;
49
- let mockCalls = [];
50
- const normalizedPreviewConfigPath = normalize(options.previewConfigPath);
51
- return [
52
- {
53
- name: "storybook:mock-loader",
54
- configResolved(config) {
55
- viteConfig = config;
56
- },
57
- buildStart() {
58
- mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
59
- },
60
- configureServer(server) {
61
- async function invalidateAffectedFiles(file) {
62
- if (file === options.previewConfigPath || file.includes("__mocks__")) {
63
- const oldMockCalls = mockCalls;
64
- mockCalls = extractMockCalls(options, babelParser, viteConfig.root);
65
- const previewMod = server.moduleGraph.getModuleById(options.previewConfigPath);
66
- if (previewMod) {
67
- server.moduleGraph.invalidateModule(previewMod);
68
- }
69
- for (const call of mockCalls) {
70
- invalidateAllRelatedModules(server, call.absolutePath, call.path);
71
- }
72
- const newAbsPaths = new Set(mockCalls.map((c) => c.absolutePath));
73
- for (const oldCall of oldMockCalls) {
74
- if (!newAbsPaths.has(oldCall.absolutePath)) {
75
- invalidateAllRelatedModules(server, oldCall.absolutePath, oldCall.path);
76
- }
77
- }
78
- server.ws.send({ type: "full-reload" });
79
- return [];
80
- }
81
- }
82
- __name(invalidateAffectedFiles, "invalidateAffectedFiles");
83
- server.watcher.on("change", invalidateAffectedFiles);
84
- server.watcher.on("add", invalidateAffectedFiles);
85
- server.watcher.on("unlink", invalidateAffectedFiles);
86
- },
87
- load: {
88
- order: "pre",
89
- handler(id) {
90
- const preserveSymlinks = viteConfig.resolve.preserveSymlinks;
91
- const idNorm = getRealPath(id, preserveSymlinks);
92
- const cleanId = getCleanId(idNorm);
93
- for (const call of mockCalls) {
94
- const callNorm = getRealPath(call.absolutePath, preserveSymlinks);
95
- if (callNorm !== idNorm && call.path !== cleanId) {
96
- continue;
97
- }
98
- if (call.redirectPath) {
99
- this.addWatchFile(call.redirectPath);
100
- return readFileSync(call.redirectPath, "utf-8");
101
- }
102
- }
103
- return null;
104
- }
105
- },
106
- transform: {
107
- order: "pre",
108
- handler(code, id) {
109
- for (const call of mockCalls) {
110
- const preserveSymlinks = viteConfig.resolve.preserveSymlinks;
111
- const idNorm = getRealPath(id, preserveSymlinks);
112
- const callNorm = getRealPath(call.absolutePath, preserveSymlinks);
113
- if (viteConfig.command !== "serve") {
114
- if (callNorm !== idNorm) {
115
- continue;
116
- }
117
- } else {
118
- const cleanId = getCleanId(idNorm);
119
- if (call.path !== cleanId && callNorm !== idNorm) {
120
- continue;
121
- }
122
- }
123
- try {
124
- if (!call.redirectPath) {
125
- const automockedCode = getAutomockCode(code, call.spy, babelParser);
126
- return {
127
- code: automockedCode.toString(),
128
- map: automockedCode.generateMap()
129
- };
130
- }
131
- } catch (e) {
132
- logger.error(`Error automocking ${id}: ${e}`);
133
- return null;
134
- }
135
- }
136
- return null;
137
- }
138
- }
139
- },
140
- {
141
- name: "storybook:mock-loader-preview",
142
- transform(code, id) {
143
- if (id === normalizedPreviewConfigPath) {
144
- try {
145
- return rewriteSbMockImportCalls(code);
146
- } catch (e) {
147
- logger.debug(`Could not transform sb.mock(import(...)) calls in ${id}: ${e}`);
148
- return null;
149
- }
150
- }
151
- return null;
152
- }
153
- }
154
- ];
155
- }
156
- __name(viteMockPlugin, "viteMockPlugin");
157
- export {
158
- viteMockPlugin
159
- };