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,76 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-MM7DTO55.js";
4
-
5
- // src/storybook-error.ts
6
- function parseErrorCode({
7
- code,
8
- category
9
- }) {
10
- const paddedCode = String(code).padStart(4, "0");
11
- return `SB_${category}_${paddedCode}`;
12
- }
13
- __name(parseErrorCode, "parseErrorCode");
14
- function appendErrorRef(url) {
15
- if (/^(?!.*storybook\.js\.org)|[?&]ref=error\b/.test(url)) {
16
- return url;
17
- }
18
- try {
19
- const urlObj = new URL(url);
20
- urlObj.searchParams.set("ref", "error");
21
- return urlObj.toString();
22
- } catch {
23
- return url;
24
- }
25
- }
26
- __name(appendErrorRef, "appendErrorRef");
27
- var _StorybookError = class _StorybookError extends Error {
28
- constructor(props) {
29
- super(_StorybookError.getFullMessage(props));
30
- /**
31
- * Data associated with the error. Used to provide additional information in the error message or
32
- * to be passed to telemetry.
33
- */
34
- this.data = {};
35
- /** Flag used to easily determine if the error originates from Storybook. */
36
- this.fromStorybook = true;
37
- this.category = props.category;
38
- this.documentation = props.documentation ?? false;
39
- this.code = props.code;
40
- }
41
- get fullErrorCode() {
42
- return parseErrorCode({ code: this.code, category: this.category });
43
- }
44
- /** Overrides the default `Error.name` property in the format: SB_<CATEGORY>_<CODE>. */
45
- get name() {
46
- const errorName = this.constructor.name;
47
- return `${this.fullErrorCode} (${errorName})`;
48
- }
49
- /** Generates the error message along with additional documentation link (if applicable). */
50
- static getFullMessage({
51
- documentation,
52
- code,
53
- category,
54
- message
55
- }) {
56
- let page;
57
- if (documentation === true) {
58
- page = `https://storybook.js.org/error/${parseErrorCode({ code, category })}?ref=error`;
59
- } else if (typeof documentation === "string") {
60
- page = appendErrorRef(documentation);
61
- } else if (Array.isArray(documentation)) {
62
- page = `
63
- ${documentation.map((doc) => ` - ${appendErrorRef(doc)}`).join("\n")}`;
64
- }
65
- return `${message}${page != null ? `
66
-
67
- More info: ${page}
68
- ` : ""}`;
69
- }
70
- };
71
- __name(_StorybookError, "StorybookError");
72
- var StorybookError = _StorybookError;
73
-
74
- export {
75
- StorybookError
76
- };
@@ -1,101 +0,0 @@
1
- import {
2
- __name
3
- } from "./chunk-MM7DTO55.js";
4
-
5
- // src/preview-api/modules/preview-web/render/animation-utils.ts
6
- var ANIMATION_TIMEOUT = 5e3;
7
- function isTestEnvironment() {
8
- try {
9
- return (
10
- // @ts-expect-error This property exists in Vitest browser mode
11
- !!globalThis.__vitest_browser__ || !!globalThis.window?.navigator?.userAgent?.match(/StorybookTestRunner/)
12
- );
13
- } catch {
14
- return false;
15
- }
16
- }
17
- __name(isTestEnvironment, "isTestEnvironment");
18
- function pauseAnimations(atEnd = true) {
19
- if (!("document" in globalThis && "createElement" in globalThis.document)) {
20
- return () => {
21
- };
22
- }
23
- const disableStyle = document.createElement("style");
24
- disableStyle.textContent = `*, *:before, *:after {
25
- animation: none !important;
26
- }`;
27
- document.head.appendChild(disableStyle);
28
- const pauseStyle = document.createElement("style");
29
- pauseStyle.textContent = `*, *:before, *:after {
30
- animation-delay: 0s !important;
31
- animation-direction: ${atEnd ? "reverse" : "normal"} !important;
32
- animation-play-state: paused !important;
33
- transition: none !important;
34
- }`;
35
- document.head.appendChild(pauseStyle);
36
- document.body.clientHeight;
37
- document.head.removeChild(disableStyle);
38
- return () => {
39
- pauseStyle.parentNode?.removeChild(pauseStyle);
40
- };
41
- }
42
- __name(pauseAnimations, "pauseAnimations");
43
- async function waitForAnimations(signal) {
44
- if (!("document" in globalThis && "getAnimations" in globalThis.document && "querySelectorAll" in globalThis.document)) {
45
- return;
46
- }
47
- let timedOut = false;
48
- await Promise.race([
49
- // After 50ms, retrieve any running animations and wait for them to finish
50
- // If new animations are created while waiting, we'll wait for them too
51
- new Promise((resolve) => {
52
- setTimeout(() => {
53
- const animationRoots = [globalThis.document, ...getShadowRoots(globalThis.document)];
54
- const checkAnimationsFinished = /* @__PURE__ */ __name(async () => {
55
- if (timedOut || signal?.aborted) {
56
- return;
57
- }
58
- const runningAnimations = animationRoots.flatMap((el) => el?.getAnimations?.() || []).filter((a) => a.playState === "running" && !isInfiniteAnimation(a));
59
- if (runningAnimations.length > 0) {
60
- await Promise.all(runningAnimations.map((a) => a.finished));
61
- await checkAnimationsFinished();
62
- }
63
- }, "checkAnimationsFinished");
64
- checkAnimationsFinished().then(resolve);
65
- }, 100);
66
- }),
67
- // If animations don't finish within the timeout, continue without waiting
68
- new Promise(
69
- (resolve) => setTimeout(() => {
70
- timedOut = true;
71
- resolve(void 0);
72
- }, ANIMATION_TIMEOUT)
73
- )
74
- ]);
75
- }
76
- __name(waitForAnimations, "waitForAnimations");
77
- function getShadowRoots(doc) {
78
- return [doc, ...doc.querySelectorAll("*")].reduce((acc, el) => {
79
- if ("shadowRoot" in el && el.shadowRoot) {
80
- acc.push(el.shadowRoot, ...getShadowRoots(el.shadowRoot));
81
- }
82
- return acc;
83
- }, []);
84
- }
85
- __name(getShadowRoots, "getShadowRoots");
86
- function isInfiniteAnimation(anim) {
87
- if (anim instanceof CSSAnimation && anim.effect instanceof KeyframeEffect && anim.effect.target) {
88
- const style = getComputedStyle(anim.effect.target, anim.effect.pseudoElement);
89
- const index = style.animationName?.split(", ").indexOf(anim.animationName);
90
- const iterations = style.animationIterationCount.split(", ")[index];
91
- return iterations === "infinite";
92
- }
93
- return false;
94
- }
95
- __name(isInfiniteAnimation, "isInfiniteAnimation");
96
-
97
- export {
98
- isTestEnvironment,
99
- pauseAnimations,
100
- waitForAnimations
101
- };
@@ -1,243 +0,0 @@
1
- import {
2
- __commonJS,
3
- __name,
4
- __require
5
- } from "./chunk-MM7DTO55.js";
6
-
7
- // ../node_modules/memoizerific/memoizerific.js
8
- var require_memoizerific = __commonJS({
9
- "../node_modules/memoizerific/memoizerific.js"(exports, module) {
10
- (function(f) {
11
- if (typeof exports === "object" && typeof module !== "undefined") {
12
- module.exports = f();
13
- } else if (typeof define === "function" && define.amd) {
14
- define([], f);
15
- } else {
16
- var g;
17
- if (typeof window !== "undefined") {
18
- g = window;
19
- } else if (typeof global !== "undefined") {
20
- g = global;
21
- } else if (typeof self !== "undefined") {
22
- g = self;
23
- } else {
24
- g = this;
25
- }
26
- g.memoizerific = f();
27
- }
28
- })(function() {
29
- var define2, module2, exports2;
30
- return (/* @__PURE__ */ __name(function e(t, n, r) {
31
- function s(o2, u) {
32
- if (!n[o2]) {
33
- if (!t[o2]) {
34
- var a = typeof __require == "function" && __require;
35
- if (!u && a) return a(o2, true);
36
- if (i) return i(o2, true);
37
- var f = new Error("Cannot find module '" + o2 + "'");
38
- throw f.code = "MODULE_NOT_FOUND", f;
39
- }
40
- var l = n[o2] = { exports: {} };
41
- t[o2][0].call(l.exports, function(e2) {
42
- var n2 = t[o2][1][e2];
43
- return s(n2 ? n2 : e2);
44
- }, l, l.exports, e, t, n, r);
45
- }
46
- return n[o2].exports;
47
- }
48
- __name(s, "s");
49
- var i = typeof __require == "function" && __require;
50
- for (var o = 0; o < r.length; o++) s(r[o]);
51
- return s;
52
- }, "e"))({ 1: [function(_dereq_, module3, exports3) {
53
- module3.exports = function(forceSimilar) {
54
- if (typeof Map !== "function" || forceSimilar) {
55
- var Similar = _dereq_("./similar");
56
- return new Similar();
57
- } else {
58
- return /* @__PURE__ */ new Map();
59
- }
60
- };
61
- }, { "./similar": 2 }], 2: [function(_dereq_, module3, exports3) {
62
- function Similar() {
63
- this.list = [];
64
- this.lastItem = void 0;
65
- this.size = 0;
66
- return this;
67
- }
68
- __name(Similar, "Similar");
69
- Similar.prototype.get = function(key) {
70
- var index;
71
- if (this.lastItem && this.isEqual(this.lastItem.key, key)) {
72
- return this.lastItem.val;
73
- }
74
- index = this.indexOf(key);
75
- if (index >= 0) {
76
- this.lastItem = this.list[index];
77
- return this.list[index].val;
78
- }
79
- return void 0;
80
- };
81
- Similar.prototype.set = function(key, val) {
82
- var index;
83
- if (this.lastItem && this.isEqual(this.lastItem.key, key)) {
84
- this.lastItem.val = val;
85
- return this;
86
- }
87
- index = this.indexOf(key);
88
- if (index >= 0) {
89
- this.lastItem = this.list[index];
90
- this.list[index].val = val;
91
- return this;
92
- }
93
- this.lastItem = { key, val };
94
- this.list.push(this.lastItem);
95
- this.size++;
96
- return this;
97
- };
98
- Similar.prototype.delete = function(key) {
99
- var index;
100
- if (this.lastItem && this.isEqual(this.lastItem.key, key)) {
101
- this.lastItem = void 0;
102
- }
103
- index = this.indexOf(key);
104
- if (index >= 0) {
105
- this.size--;
106
- return this.list.splice(index, 1)[0];
107
- }
108
- return void 0;
109
- };
110
- Similar.prototype.has = function(key) {
111
- var index;
112
- if (this.lastItem && this.isEqual(this.lastItem.key, key)) {
113
- return true;
114
- }
115
- index = this.indexOf(key);
116
- if (index >= 0) {
117
- this.lastItem = this.list[index];
118
- return true;
119
- }
120
- return false;
121
- };
122
- Similar.prototype.forEach = function(callback, thisArg) {
123
- var i;
124
- for (i = 0; i < this.size; i++) {
125
- callback.call(thisArg || this, this.list[i].val, this.list[i].key, this);
126
- }
127
- };
128
- Similar.prototype.indexOf = function(key) {
129
- var i;
130
- for (i = 0; i < this.size; i++) {
131
- if (this.isEqual(this.list[i].key, key)) {
132
- return i;
133
- }
134
- }
135
- return -1;
136
- };
137
- Similar.prototype.isEqual = function(val1, val2) {
138
- return val1 === val2 || val1 !== val1 && val2 !== val2;
139
- };
140
- module3.exports = Similar;
141
- }, {}], 3: [function(_dereq_, module3, exports3) {
142
- var MapOrSimilar = _dereq_("map-or-similar");
143
- module3.exports = function(limit) {
144
- var cache = new MapOrSimilar(false), lru = [];
145
- return function(fn) {
146
- var memoizerific = /* @__PURE__ */ __name(function() {
147
- var currentCache = cache, newMap, fnResult, argsLengthMinusOne = arguments.length - 1, lruPath = Array(argsLengthMinusOne + 1), isMemoized = true, i;
148
- if ((memoizerific.numArgs || memoizerific.numArgs === 0) && memoizerific.numArgs !== argsLengthMinusOne + 1) {
149
- throw new Error("Memoizerific functions should always be called with the same number of arguments");
150
- }
151
- for (i = 0; i < argsLengthMinusOne; i++) {
152
- lruPath[i] = {
153
- cacheItem: currentCache,
154
- arg: arguments[i]
155
- };
156
- if (currentCache.has(arguments[i])) {
157
- currentCache = currentCache.get(arguments[i]);
158
- continue;
159
- }
160
- isMemoized = false;
161
- newMap = new MapOrSimilar(false);
162
- currentCache.set(arguments[i], newMap);
163
- currentCache = newMap;
164
- }
165
- if (isMemoized) {
166
- if (currentCache.has(arguments[argsLengthMinusOne])) {
167
- fnResult = currentCache.get(arguments[argsLengthMinusOne]);
168
- } else {
169
- isMemoized = false;
170
- }
171
- }
172
- if (!isMemoized) {
173
- fnResult = fn.apply(null, arguments);
174
- currentCache.set(arguments[argsLengthMinusOne], fnResult);
175
- }
176
- if (limit > 0) {
177
- lruPath[argsLengthMinusOne] = {
178
- cacheItem: currentCache,
179
- arg: arguments[argsLengthMinusOne]
180
- };
181
- if (isMemoized) {
182
- moveToMostRecentLru(lru, lruPath);
183
- } else {
184
- lru.push(lruPath);
185
- }
186
- if (lru.length > limit) {
187
- removeCachedResult(lru.shift());
188
- }
189
- }
190
- memoizerific.wasMemoized = isMemoized;
191
- memoizerific.numArgs = argsLengthMinusOne + 1;
192
- return fnResult;
193
- }, "memoizerific");
194
- memoizerific.limit = limit;
195
- memoizerific.wasMemoized = false;
196
- memoizerific.cache = cache;
197
- memoizerific.lru = lru;
198
- return memoizerific;
199
- };
200
- };
201
- function moveToMostRecentLru(lru, lruPath) {
202
- var lruLen = lru.length, lruPathLen = lruPath.length, isMatch, i, ii;
203
- for (i = 0; i < lruLen; i++) {
204
- isMatch = true;
205
- for (ii = 0; ii < lruPathLen; ii++) {
206
- if (!isEqual(lru[i][ii].arg, lruPath[ii].arg)) {
207
- isMatch = false;
208
- break;
209
- }
210
- }
211
- if (isMatch) {
212
- break;
213
- }
214
- }
215
- lru.push(lru.splice(i, 1)[0]);
216
- }
217
- __name(moveToMostRecentLru, "moveToMostRecentLru");
218
- function removeCachedResult(removedLru) {
219
- var removedLruLen = removedLru.length, currentLru = removedLru[removedLruLen - 1], tmp, i;
220
- currentLru.cacheItem.delete(currentLru.arg);
221
- for (i = removedLruLen - 2; i >= 0; i--) {
222
- currentLru = removedLru[i];
223
- tmp = currentLru.cacheItem.get(currentLru.arg);
224
- if (!tmp || !tmp.size) {
225
- currentLru.cacheItem.delete(currentLru.arg);
226
- } else {
227
- break;
228
- }
229
- }
230
- }
231
- __name(removeCachedResult, "removeCachedResult");
232
- function isEqual(val1, val2) {
233
- return val1 === val2 || val1 !== val1 && val2 !== val2;
234
- }
235
- __name(isEqual, "isEqual");
236
- }, { "map-or-similar": 1 }] }, {}, [3])(3);
237
- });
238
- }
239
- });
240
-
241
- export {
242
- require_memoizerific
243
- };