@storybook/addon-docs 10.2.0-alpha.9 → 10.2.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.
@@ -1,20 +1,20 @@
1
- import CJS_COMPAT_NODE_URL_vha0rbla5wk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_vha0rbla5wk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_vha0rbla5wk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_01k6pddjk2qr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_01k6pddjk2qr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_01k6pddjk2qr from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_vha0rbla5wk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_vha0rbla5wk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_vha0rbla5wk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_01k6pddjk2qr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_01k6pddjk2qr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_01k6pddjk2qr.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
12
  import {
13
13
  compile
14
- } from "./_node-chunks/chunk-43QYHLJV.js";
15
- import "./_node-chunks/chunk-YI66PKT4.js";
16
- import "./_node-chunks/chunk-5AZDHS7P.js";
17
- import "./_node-chunks/chunk-3UNO4NZF.js";
14
+ } from "./_node-chunks/chunk-QRHGYQPV.js";
15
+ import "./_node-chunks/chunk-JA736U6F.js";
16
+ import "./_node-chunks/chunk-V6MI33O5.js";
17
+ import "./_node-chunks/chunk-6BX4ITXI.js";
18
18
 
19
19
  // src/mdx-loader.ts
20
20
  var DEFAULT_RENDERER = `
package/dist/preset.js CHANGED
@@ -1,20 +1,20 @@
1
- import CJS_COMPAT_NODE_URL_vha0rbla5wk from 'node:url';
2
- import CJS_COMPAT_NODE_PATH_vha0rbla5wk from 'node:path';
3
- import CJS_COMPAT_NODE_MODULE_vha0rbla5wk from "node:module";
1
+ import CJS_COMPAT_NODE_URL_01k6pddjk2qr from 'node:url';
2
+ import CJS_COMPAT_NODE_PATH_01k6pddjk2qr from 'node:path';
3
+ import CJS_COMPAT_NODE_MODULE_01k6pddjk2qr from "node:module";
4
4
 
5
- var __filename = CJS_COMPAT_NODE_URL_vha0rbla5wk.fileURLToPath(import.meta.url);
6
- var __dirname = CJS_COMPAT_NODE_PATH_vha0rbla5wk.dirname(__filename);
7
- var require = CJS_COMPAT_NODE_MODULE_vha0rbla5wk.createRequire(import.meta.url);
5
+ var __filename = CJS_COMPAT_NODE_URL_01k6pddjk2qr.fileURLToPath(import.meta.url);
6
+ var __dirname = CJS_COMPAT_NODE_PATH_01k6pddjk2qr.dirname(__filename);
7
+ var require = CJS_COMPAT_NODE_MODULE_01k6pddjk2qr.createRequire(import.meta.url);
8
8
 
9
9
  // ------------------------------------------------------------
10
10
  // end of CJS compatibility banner, injected by Storybook's esbuild configuration
11
11
  // ------------------------------------------------------------
12
- import "./_node-chunks/chunk-3UNO4NZF.js";
12
+ import "./_node-chunks/chunk-6BX4ITXI.js";
13
13
 
14
14
  // src/preset.ts
15
15
  import { isAbsolute as isAbsolute2 } from "node:path";
16
16
  import { fileURLToPath as fileURLToPath2 } from "node:url";
17
- import { logger } from "storybook/internal/node-logger";
17
+ import { logger as logger2 } from "storybook/internal/node-logger";
18
18
 
19
19
  // ../../core/src/shared/utils/module.ts
20
20
  import { fileURLToPath, pathToFileURL } from "node:url";
@@ -149,12 +149,12 @@ function normalizeWindowsPath(input = "") {
149
149
  return input && input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
150
150
  }
151
151
  var _UNC_REGEX = /^[/\\]{2}/, _IS_ABSOLUTE_RE = /^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Za-z]:[/\\]/, _DRIVE_LETTER_RE = /^[A-Za-z]:$/;
152
- var normalize = function(path2) {
153
- if (path2.length === 0)
152
+ var normalize = function(path3) {
153
+ if (path3.length === 0)
154
154
  return ".";
155
- path2 = normalizeWindowsPath(path2);
156
- let isUNCPath = path2.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path2), trailingSeparator = path2[path2.length - 1] === "/";
157
- return path2 = normalizeString(path2, !isPathAbsolute), path2.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path2 += "/"), _DRIVE_LETTER_RE.test(path2) && (path2 += "/"), isUNCPath ? isPathAbsolute ? `//${path2}` : `//./${path2}` : isPathAbsolute && !isAbsolute(path2) ? `/${path2}` : path2);
155
+ path3 = normalizeWindowsPath(path3);
156
+ let isUNCPath = path3.match(_UNC_REGEX), isPathAbsolute = isAbsolute(path3), trailingSeparator = path3[path3.length - 1] === "/";
157
+ return path3 = normalizeString(path3, !isPathAbsolute), path3.length === 0 ? isPathAbsolute ? "/" : trailingSeparator ? "./" : "." : (trailingSeparator && (path3 += "/"), _DRIVE_LETTER_RE.test(path3) && (path3 += "/"), isUNCPath ? isPathAbsolute ? `//${path3}` : `//./${path3}` : isPathAbsolute && !isAbsolute(path3) ? `/${path3}` : path3);
158
158
  }, join = function(...arguments_) {
159
159
  if (arguments_.length === 0)
160
160
  return ".";
@@ -163,11 +163,11 @@ var normalize = function(path2) {
163
163
  argument && argument.length > 0 && (joined === void 0 ? joined = argument : joined += `/${argument}`);
164
164
  return joined === void 0 ? "." : normalize(joined.replace(/\/\/+/g, "/"));
165
165
  };
166
- function normalizeString(path2, allowAboveRoot) {
166
+ function normalizeString(path3, allowAboveRoot) {
167
167
  let res = "", lastSegmentLength = 0, lastSlash = -1, dots = 0, char = null;
168
- for (let index = 0; index <= path2.length; ++index) {
169
- if (index < path2.length)
170
- char = path2[index];
168
+ for (let index = 0; index <= path3.length; ++index) {
169
+ if (index < path3.length)
170
+ char = path3[index];
171
171
  else {
172
172
  if (char === "/")
173
173
  break;
@@ -187,7 +187,7 @@ function normalizeString(path2, allowAboveRoot) {
187
187
  }
188
188
  allowAboveRoot && (res += res.length > 0 ? "/.." : "..", lastSegmentLength = 2);
189
189
  } else
190
- res.length > 0 ? res += `/${path2.slice(lastSlash + 1, index)}` : res = path2.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
190
+ res.length > 0 ? res += `/${path3.slice(lastSlash + 1, index)}` : res = path3.slice(lastSlash + 1, index), lastSegmentLength = index - lastSlash - 1;
191
191
  lastSlash = index, dots = 0;
192
192
  } else char === "." && dots !== -1 ? ++dots : dots = -1;
193
193
  }
@@ -212,6 +212,85 @@ var importMetaResolve = (...args) => typeof import.meta.resolve != "function" &&
212
212
  }
213
213
  };
214
214
 
215
+ // src/manifest.ts
216
+ import * as fs from "node:fs/promises";
217
+ import * as path2 from "node:path";
218
+ import { groupBy } from "storybook/internal/common";
219
+ import { Tag, analyzeMdx } from "storybook/internal/core-server";
220
+ import { logger } from "storybook/internal/node-logger";
221
+ async function createDocsManifestEntry(entry) {
222
+ let absolutePath = path2.join(process.cwd(), entry.importPath);
223
+ try {
224
+ let content = await fs.readFile(absolutePath, "utf-8"), { summary } = await analyzeMdx(content);
225
+ return {
226
+ id: entry.id,
227
+ name: entry.name,
228
+ path: entry.importPath,
229
+ title: entry.title,
230
+ content,
231
+ ...summary && { summary }
232
+ };
233
+ } catch (err) {
234
+ return {
235
+ id: entry.id,
236
+ name: entry.name,
237
+ path: entry.importPath,
238
+ title: entry.title,
239
+ error: {
240
+ name: err instanceof Error ? err.name : "Error",
241
+ message: err instanceof Error ? err.message : String(err)
242
+ }
243
+ };
244
+ }
245
+ }
246
+ async function extractUnattachedDocsEntries(entries) {
247
+ if (entries.length === 0)
248
+ return {};
249
+ let entriesWithContent = await Promise.all(entries.map(createDocsManifestEntry));
250
+ return Object.fromEntries(entriesWithContent.map((entry) => [entry.id, entry]));
251
+ }
252
+ async function extractAttachedDocsEntries(entries, existingComponents) {
253
+ if (!existingComponents || entries.length === 0)
254
+ return existingComponents;
255
+ let entriesWithContent = await Promise.all(entries.map(createDocsManifestEntry));
256
+ for (let docsEntry of entriesWithContent) {
257
+ let componentId = docsEntry.id.split("--")[0], component = existingComponents.components[componentId];
258
+ component && (component.docs || (component.docs = {}), component.docs[docsEntry.id] = docsEntry);
259
+ }
260
+ return existingComponents;
261
+ }
262
+ var manifests = async (existingManifests = {}, { manifestEntries }) => {
263
+ let startPerformance = performance.now(), docsEntries = manifestEntries.filter(
264
+ (entry) => entry.type === "docs"
265
+ );
266
+ if (docsEntries.length === 0)
267
+ return existingManifests;
268
+ let { attachedEntries = [], unattachedEntries = [] } = groupBy(docsEntries, (entry) => {
269
+ switch (!0) {
270
+ case entry.tags?.includes(Tag.UNATTACHED_MDX):
271
+ return "unattachedEntries";
272
+ case entry.tags?.includes(Tag.ATTACHED_MDX):
273
+ return "attachedEntries";
274
+ default:
275
+ return "ignored";
276
+ }
277
+ });
278
+ if (unattachedEntries.length === 0 && attachedEntries.length === 0)
279
+ return existingManifests;
280
+ let existingManifestsWithDocs = existingManifests, [unattachedDocs, updatedComponents] = await Promise.all([
281
+ extractUnattachedDocsEntries(unattachedEntries),
282
+ extractAttachedDocsEntries(attachedEntries, existingManifestsWithDocs.components)
283
+ ]), processedCount = unattachedEntries.length + attachedEntries.length;
284
+ logger.verbose(
285
+ `Docs manifest generation took ${performance.now() - startPerformance}ms for ${processedCount} entries (${unattachedEntries.length} unattached, ${attachedEntries.length} attached)`
286
+ );
287
+ let result = { ...existingManifestsWithDocs };
288
+ return Object.keys(unattachedDocs).length > 0 && (result.docs = {
289
+ v: 0,
290
+ docs: unattachedDocs
291
+ }), updatedComponents && (result.components = updatedComponents), result;
292
+ };
293
+
215
294
  // src/preset.ts
216
295
  var getResolvedReact = async (options) => {
217
296
  let resolvedReact2 = await options.presets.apply("resolvedReact", {});
@@ -227,7 +306,7 @@ var getResolvedReact = async (options) => {
227
306
  };
228
307
  };
229
308
  async function webpack(webpackConfig = {}, options) {
230
- let { module = {} } = webpackConfig, { csfPluginOptions = {}, mdxPluginOptions = {} } = options, enrichCsf = await options.presets.apply("experimental_enrichCsf"), rehypeSlug = (await import("./_node-chunks/rehype-slug-O7HUORBA.js")).default, rehypeExternalLinks = (await import("./_node-chunks/rehype-external-links-ZPBLZPHM.js")).default, mdxLoaderOptions = await options.presets.apply("mdxLoaderOptions", {
309
+ let { module = {} } = webpackConfig, { csfPluginOptions = {}, mdxPluginOptions = {} } = options, enrichCsf = await options.presets.apply("experimental_enrichCsf"), rehypeSlug = (await import("./_node-chunks/rehype-slug-X4CX3DCY.js")).default, rehypeExternalLinks = (await import("./_node-chunks/rehype-external-links-BKM5LEVM.js")).default, mdxLoaderOptions = await options.presets.apply("mdxLoaderOptions", {
231
310
  ...mdxPluginOptions,
232
311
  mdxCompileOptions: {
233
312
  providerImportSource: import.meta.resolve("@storybook/addon-docs/mdx-react-shim"),
@@ -239,7 +318,7 @@ async function webpack(webpackConfig = {}, options) {
239
318
  ]
240
319
  }
241
320
  });
242
- logger.info("Addon-docs: using MDX3");
321
+ logger2.info("Addon-docs: using MDX3");
243
322
  let { react, reactDom, mdx } = await getResolvedReact(options), alias;
244
323
  return Array.isArray(webpackConfig.resolve?.alias) ? (alias = [...webpackConfig.resolve?.alias], alias.push(
245
324
  {
@@ -303,7 +382,7 @@ var docs = (input = {}, options) => {
303
382
  }, addons = [
304
383
  import.meta.resolve("@storybook/react-dom-shim/preset")
305
384
  ], viteFinal = async (config, options) => {
306
- let { plugins = [] } = config, { mdxPlugin } = await import("./_node-chunks/mdx-plugin-AJ33BARZ.js"), { react, reactDom, mdx } = await getResolvedReact(options), packageDeduplicationPlugin = {
385
+ let { plugins = [] } = config, { mdxPlugin } = await import("./_node-chunks/mdx-plugin-LGUWTE7W.js"), { react, reactDom, mdx } = await getResolvedReact(options), packageDeduplicationPlugin = {
307
386
  name: "storybook:package-deduplication",
308
387
  enforce: "pre",
309
388
  config: () => ({
@@ -334,6 +413,7 @@ var docs = (input = {}, options) => {
334
413
  export {
335
414
  addons,
336
415
  docsX as docs,
416
+ manifests as experimental_manifests,
337
417
  optimizeViteDeps,
338
418
  resolvedReact,
339
419
  viteFinal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@storybook/addon-docs",
3
- "version": "10.2.0-alpha.9",
3
+ "version": "10.2.0-beta.0",
4
4
  "description": "Storybook Docs: Document UI components automatically with stories and MDX",
5
5
  "keywords": [
6
6
  "docs",
@@ -80,9 +80,9 @@
80
80
  ],
81
81
  "dependencies": {
82
82
  "@mdx-js/react": "^3.0.0",
83
- "@storybook/csf-plugin": "10.2.0-alpha.9",
84
- "@storybook/icons": "^2.0.0",
85
- "@storybook/react-dom-shim": "10.2.0-alpha.9",
83
+ "@storybook/csf-plugin": "10.2.0-beta.0",
84
+ "@storybook/icons": "^2.0.1",
85
+ "@storybook/react-dom-shim": "10.2.0-beta.0",
86
86
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
87
87
  "react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
88
88
  "ts-dedent": "^2.0.0"
@@ -93,7 +93,7 @@
93
93
  "@types/color-convert": "^2.0.0",
94
94
  "@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
95
95
  "color-convert": "^2.0.1",
96
- "es-toolkit": "^1.36.0",
96
+ "es-toolkit": "^1.43.0",
97
97
  "github-slugger": "^2.0.0",
98
98
  "markdown-to-jsx": "^7.7.2",
99
99
  "memoizerific": "^1.11.3",
@@ -105,11 +105,11 @@
105
105
  "rehype-slug": "^6.0.0",
106
106
  "telejson": "8.0.0",
107
107
  "tocbot": "^4.20.1",
108
- "typescript": "^5.8.3",
108
+ "typescript": "^5.9.3",
109
109
  "vite": "^7.0.4"
110
110
  },
111
111
  "peerDependencies": {
112
- "storybook": "^10.2.0-alpha.9"
112
+ "storybook": "^10.2.0-beta.0"
113
113
  },
114
114
  "publishConfig": {
115
115
  "access": "public"
@@ -1,209 +0,0 @@
1
- // ../../../node_modules/es-toolkit/dist/function/debounce.mjs
2
- function debounce(func, debounceMs, { signal, edges } = {}) {
3
- let pendingThis, pendingArgs = null, leading = edges != null && edges.includes("leading"), trailing = edges == null || edges.includes("trailing"), invoke = () => {
4
- pendingArgs !== null && (func.apply(pendingThis, pendingArgs), pendingThis = void 0, pendingArgs = null);
5
- }, onTimerEnd = () => {
6
- trailing && invoke(), cancel();
7
- }, timeoutId = null, schedule = () => {
8
- timeoutId != null && clearTimeout(timeoutId), timeoutId = setTimeout(() => {
9
- timeoutId = null, onTimerEnd();
10
- }, debounceMs);
11
- }, cancelTimer = () => {
12
- timeoutId !== null && (clearTimeout(timeoutId), timeoutId = null);
13
- }, cancel = () => {
14
- cancelTimer(), pendingThis = void 0, pendingArgs = null;
15
- }, flush = () => {
16
- cancelTimer(), invoke();
17
- }, debounced = function(...args) {
18
- if (signal?.aborted)
19
- return;
20
- pendingThis = this, pendingArgs = args;
21
- let isFirstCall = timeoutId == null;
22
- schedule(), leading && isFirstCall && invoke();
23
- };
24
- return debounced.schedule = schedule, debounced.cancel = cancel, debounced.flush = flush, signal?.addEventListener("abort", cancel, { once: !0 }), debounced;
25
- }
26
-
27
- // src/blocks/controls/helpers.ts
28
- var getControlId = (value) => `control-${value.replace(/\s+/g, "-")}`, getControlSetterButtonId = (value) => `set-${value.replace(/\s+/g, "-")}`;
29
-
30
- // ../../../node_modules/es-toolkit/dist/function/partial.mjs
31
- function partial(func, ...partialArgs) {
32
- return partialImpl(func, placeholderSymbol, ...partialArgs);
33
- }
34
- function partialImpl(func, placeholder, ...partialArgs) {
35
- let partialed = function(...providedArgs) {
36
- let providedArgsIndex = 0, substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg), remainingArgs = providedArgs.slice(providedArgsIndex);
37
- return func.apply(this, substitutedArgs.concat(remainingArgs));
38
- };
39
- return func.prototype && (partialed.prototype = Object.create(func.prototype)), partialed;
40
- }
41
- var placeholderSymbol = Symbol("partial.placeholder");
42
- partial.placeholder = placeholderSymbol;
43
-
44
- // ../../../node_modules/es-toolkit/dist/function/partialRight.mjs
45
- function partialRight(func, ...partialArgs) {
46
- return partialRightImpl(func, placeholderSymbol2, ...partialArgs);
47
- }
48
- function partialRightImpl(func, placeholder, ...partialArgs) {
49
- let partialedRight = function(...providedArgs) {
50
- let placeholderLength = partialArgs.filter((arg) => arg === placeholder).length, rangeLength = Math.max(providedArgs.length - placeholderLength, 0), remainingArgs = providedArgs.slice(0, rangeLength), providedArgsIndex = rangeLength, substitutedArgs = partialArgs.slice().map((arg) => arg === placeholder ? providedArgs[providedArgsIndex++] : arg);
51
- return func.apply(this, remainingArgs.concat(substitutedArgs));
52
- };
53
- return func.prototype && (partialedRight.prototype = Object.create(func.prototype)), partialedRight;
54
- }
55
- var placeholderSymbol2 = Symbol("partialRight.placeholder");
56
- partialRight.placeholder = placeholderSymbol2;
57
-
58
- // ../../../node_modules/es-toolkit/dist/function/asyncNoop.mjs
59
- async function asyncNoop() {
60
- }
61
-
62
- // ../../../node_modules/es-toolkit/dist/function/identity.mjs
63
- function identity(x) {
64
- return x;
65
- }
66
-
67
- // ../../../node_modules/es-toolkit/dist/function/memoize.mjs
68
- function memoize(fn, options = {}) {
69
- let { cache = /* @__PURE__ */ new Map(), getCacheKey } = options, memoizedFn = function(arg) {
70
- let key = getCacheKey ? getCacheKey(arg) : arg;
71
- if (cache.has(key))
72
- return cache.get(key);
73
- let result = fn.call(this, arg);
74
- return cache.set(key, result), result;
75
- };
76
- return memoizedFn.cache = cache, memoizedFn;
77
- }
78
-
79
- // ../../../node_modules/es-toolkit/dist/function/noop.mjs
80
- function noop() {
81
- }
82
-
83
- // ../../../node_modules/es-toolkit/dist/function/once.mjs
84
- function once(func) {
85
- let called = !1, cache;
86
- return function(...args) {
87
- return called || (called = !0, cache = func(...args)), cache;
88
- };
89
- }
90
-
91
- // ../../../node_modules/es-toolkit/dist/error/AbortError.mjs
92
- var AbortError = class extends Error {
93
- constructor(message = "The operation was aborted") {
94
- super(message), this.name = "AbortError";
95
- }
96
- };
97
-
98
- // ../../../node_modules/es-toolkit/dist/promise/delay.mjs
99
- function delay(ms, { signal } = {}) {
100
- return new Promise((resolve, reject) => {
101
- let abortError = () => {
102
- reject(new AbortError());
103
- }, abortHandler = () => {
104
- clearTimeout(timeoutId), abortError();
105
- };
106
- if (signal?.aborted)
107
- return abortError();
108
- let timeoutId = setTimeout(() => {
109
- signal?.removeEventListener("abort", abortHandler), resolve();
110
- }, ms);
111
- signal?.addEventListener("abort", abortHandler, { once: !0 });
112
- });
113
- }
114
-
115
- // ../../../node_modules/es-toolkit/dist/function/retry.mjs
116
- var DEFAULT_DELAY = 0, DEFAULT_RETRIES = Number.POSITIVE_INFINITY;
117
- async function retry(func, _options) {
118
- let delay$1, retries, signal;
119
- typeof _options == "number" ? (delay$1 = DEFAULT_DELAY, retries = _options, signal = void 0) : (delay$1 = _options?.delay ?? DEFAULT_DELAY, retries = _options?.retries ?? DEFAULT_RETRIES, signal = _options?.signal);
120
- let error;
121
- for (let attempts = 0; attempts < retries; attempts++) {
122
- if (signal?.aborted)
123
- throw error ?? new Error("The retry operation was aborted due to an abort signal.");
124
- try {
125
- return await func();
126
- } catch (err) {
127
- error = err;
128
- let currentDelay = typeof delay$1 == "function" ? delay$1(attempts) : delay$1;
129
- await delay(currentDelay);
130
- }
131
- }
132
- throw error;
133
- }
134
-
135
- // ../../../node_modules/es-toolkit/dist/function/ary.mjs
136
- function ary(func, n) {
137
- return function(...args) {
138
- return func.apply(this, args.slice(0, n));
139
- };
140
- }
141
-
142
- // ../../../node_modules/es-toolkit/dist/function/unary.mjs
143
- function unary(func) {
144
- return ary(func, 1);
145
- }
146
-
147
- // ../../../node_modules/es-toolkit/dist/function/negate.mjs
148
- function negate(func) {
149
- return ((...args) => !func(...args));
150
- }
151
-
152
- // ../../../node_modules/es-toolkit/dist/function/flow.mjs
153
- function flow(...funcs) {
154
- return function(...args) {
155
- let result = funcs.length ? funcs[0].apply(this, args) : args[0];
156
- for (let i = 1; i < funcs.length; i++)
157
- result = funcs[i].call(this, result);
158
- return result;
159
- };
160
- }
161
-
162
- // ../../../node_modules/es-toolkit/dist/function/flowRight.mjs
163
- function flowRight(...funcs) {
164
- return flow(...funcs.reverse());
165
- }
166
-
167
- // ../../../node_modules/es-toolkit/dist/function/rest.mjs
168
- function rest(func, startIndex = func.length - 1) {
169
- return function(...args) {
170
- let rest2 = args.slice(startIndex), params = args.slice(0, startIndex);
171
- for (; params.length < startIndex; )
172
- params.push(void 0);
173
- return func.apply(this, [...params, rest2]);
174
- };
175
- }
176
-
177
- // ../../../node_modules/es-toolkit/dist/function/after.mjs
178
- function after(n, func) {
179
- if (!Number.isInteger(n) || n < 0)
180
- throw new Error("n must be a non-negative integer.");
181
- let counter = 0;
182
- return (...args) => {
183
- if (++counter >= n)
184
- return func(...args);
185
- };
186
- }
187
-
188
- export {
189
- partialImpl,
190
- partialRightImpl,
191
- AbortError,
192
- asyncNoop,
193
- identity,
194
- memoize,
195
- noop,
196
- once,
197
- delay,
198
- retry,
199
- ary,
200
- unary,
201
- negate,
202
- debounce,
203
- flow,
204
- flowRight,
205
- rest,
206
- after,
207
- getControlId,
208
- getControlSetterButtonId
209
- };