likec4 1.48.0 → 1.49.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.
- package/README.md +11 -1
- package/__app__/src/likec4.js +5595 -4127
- package/__app__/src/routes/index.js +3 -153
- package/__app__/src/routes/projects.js +21 -1087
- package/__app__/src/routes/single.js +1221 -16
- package/__app__/src/style.css +1 -1
- package/__app__/src/vendors.js +3507 -894
- package/__app__/src/webcomponent.js +1 -1
- package/config/schema.json +155 -143
- package/dist/THIRD-PARTY-LICENSES.md +1739 -0
- package/dist/_chunks/GraphvizBinaryAdapter.mjs +72 -0
- package/dist/_chunks/filenames.mjs +14 -0
- package/dist/_chunks/index.d.mts +224 -129
- package/dist/_chunks/index2.d.mts +2033 -1908
- package/dist/_chunks/libs/@chevrotain/gast.mjs +1 -3969
- package/dist/_chunks/libs/@chevrotain/regexp-to-ast.mjs +9 -785
- package/dist/_chunks/libs/@chevrotain/utils.mjs +1 -37
- package/dist/_chunks/libs/@hono/mcp.mjs +34 -0
- package/dist/_chunks/libs/@hono/node-server.mjs +1 -436
- package/dist/_chunks/libs/@logtape/logtape.d.mts +741 -0
- package/dist/_chunks/libs/@logtape/logtape.mjs +6 -1354
- package/dist/_chunks/libs/@lume/kiwi.mjs +1 -1355
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.d.mts +14 -14
- package/dist/_chunks/libs/@modelcontextprotocol/sdk.mjs +12 -25105
- package/dist/_chunks/libs/@msgpack/msgpack.mjs +1 -1503
- package/dist/_chunks/libs/@nanostores/react.mjs +1 -30
- package/dist/_chunks/libs/@smithy/util-base64.mjs +1 -100
- package/dist/_chunks/libs/ajv.mjs +1 -777
- package/dist/_chunks/libs/atomically.mjs +1 -362
- package/dist/_chunks/libs/birpc.mjs +1 -201
- package/dist/_chunks/libs/chevrotain-allstar.mjs +2 -850
- package/dist/_chunks/libs/chevrotain.mjs +55 -6229
- package/dist/_chunks/libs/conf.mjs +1 -2258
- package/dist/_chunks/libs/defu.mjs +1 -42
- package/dist/_chunks/libs/esm-env.mjs +1 -5
- package/dist/_chunks/libs/eventemitter3.mjs +1 -243
- package/dist/_chunks/libs/fast-equals.mjs +1 -446
- package/dist/_chunks/libs/find-up-simple.mjs +1 -24
- package/dist/_chunks/libs/get-port.mjs +1 -107
- package/dist/_chunks/libs/is-docker.mjs +1 -26
- package/dist/_chunks/libs/is-error-instance.mjs +1 -26
- package/dist/_chunks/libs/is-inside-container.mjs +1 -20
- package/dist/_chunks/libs/is-plain-obj.mjs +1 -9
- package/dist/_chunks/libs/isexe.mjs +1 -127
- package/dist/_chunks/libs/json5.mjs +14 -959
- package/dist/_chunks/libs/khroma.mjs +1 -605
- package/dist/_chunks/libs/ky.mjs +2 -807
- package/dist/_chunks/libs/langium.d.mts +2880 -2844
- package/dist/_chunks/libs/langium.mjs +32 -20351
- package/dist/_chunks/libs/merge-error-cause.mjs +2 -746
- package/dist/_chunks/libs/nanostores.mjs +1 -198
- package/dist/_chunks/libs/p-limit.mjs +1 -120
- package/dist/_chunks/libs/p-queue.mjs +1 -449
- package/dist/_chunks/libs/package-manager-detector.mjs +1 -559
- package/dist/_chunks/libs/package-up.mjs +1 -10
- package/dist/_chunks/libs/parse-ms.mjs +1 -36
- package/dist/_chunks/libs/pathe.mjs +1 -0
- package/dist/_chunks/libs/picomatch.mjs +1 -1673
- package/dist/_chunks/libs/pretty-ms.mjs +1 -80
- package/dist/_chunks/libs/remeda.mjs +1 -690
- package/dist/_chunks/libs/safe-stringify.mjs +1 -21
- package/dist/_chunks/libs/strip-indent.mjs +1 -15
- package/dist/_chunks/libs/tinyrainbow.mjs +1 -88
- package/dist/_chunks/libs/ts-graphviz.mjs +4 -725
- package/dist/_chunks/libs/ufo.mjs +1 -240
- package/dist/_chunks/libs/which.mjs +1 -84
- package/dist/_chunks/libs/word-wrap.mjs +12 -43
- package/dist/_chunks/node.mjs +481 -0
- package/dist/_chunks/plugin.mjs +98 -772
- package/dist/_chunks/rolldown-runtime.mjs +1 -48
- package/dist/_chunks/sequence-view.mjs +1 -575
- package/dist/cli/index.mjs +127 -1846
- package/dist/config/index.d.mts +2 -2
- package/dist/config/index.mjs +1 -6
- package/dist/index.d.mts +148 -7
- package/dist/index.mjs +1 -21
- package/dist/model/builder.mjs +1 -3
- package/dist/model/index.d.mts +57 -3
- package/dist/model/index.mjs +1 -5
- package/dist/vite-plugin/index.d.mts +4 -3
- package/dist/vite-plugin/index.mjs +1 -22
- package/dist/vite-plugin/internal.d.mts +5 -5
- package/dist/vite-plugin/internal.mjs +1 -68
- package/package.json +60 -41
- package/react/{index.d.ts → index.d.mts} +112 -70
- package/react/{index.js → index.mjs} +21361 -22064
- package/react/package.json +2 -5
- package/vite-plugin-modules.d.ts +5 -5
- package/dist/_chunks/LikeC4.d.mts +0 -121
- package/dist/_chunks/LikeC4.mjs +0 -202
- package/dist/_chunks/config-app.prod.d.mts +0 -18
- package/dist/_chunks/config-app.prod.mjs +0 -188
- package/dist/_chunks/config-webcomponent.prod.mjs +0 -71
- package/dist/_chunks/define-config.mjs +0 -409
- package/dist/_chunks/index3.d.mts +0 -60
- package/dist/_chunks/index4.d.mts +0 -1
- package/dist/_chunks/libs/@smithy/is-array-buffer.mjs +0 -10
- package/dist/_chunks/libs/hono.mjs +0 -1829
- package/dist/_chunks/libs/nanoid.mjs +0 -29
- package/dist/_chunks/model.mjs +0 -12
- package/dist/_chunks/module.d.mts +0 -71
- package/dist/_chunks/module.mjs +0 -18657
- package/dist/_chunks/vite-build.mjs +0 -69
- package/dist/_chunks/vite-dev.mjs +0 -79
- package/dist/_chunks/vite-preview.mjs +0 -27
- package/dist/language/module.d.mts +0 -5
- package/dist/language/module.mjs +0 -20
- package/dist/vite/vite-build.d.mts +0 -26
- package/dist/vite/vite-build.mjs +0 -27
- package/dist/vite/vite-dev.d.mts +0 -34
- package/dist/vite/vite-dev.mjs +0 -29
- package/dist/vite/vite-preview.d.mts +0 -20
- package/dist/vite/vite-preview.mjs +0 -26
|
@@ -1,198 +1 @@
|
|
|
1
|
-
|
|
2
|
-
let clean = Symbol("clean");
|
|
3
|
-
|
|
4
|
-
//#endregion
|
|
5
|
-
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/atom/index.js
|
|
6
|
-
let listenerQueue = [];
|
|
7
|
-
let lqIndex = 0;
|
|
8
|
-
const QUEUE_ITEMS_PER_LISTENER = 4;
|
|
9
|
-
let epoch = 0;
|
|
10
|
-
const atom = /* @__NO_SIDE_EFFECTS__ */ (initialValue) => {
|
|
11
|
-
let listeners = [];
|
|
12
|
-
let $atom = {
|
|
13
|
-
get() {
|
|
14
|
-
if (!$atom.lc) $atom.listen(() => {})();
|
|
15
|
-
return $atom.value;
|
|
16
|
-
},
|
|
17
|
-
lc: 0,
|
|
18
|
-
listen(listener) {
|
|
19
|
-
$atom.lc = listeners.push(listener);
|
|
20
|
-
return () => {
|
|
21
|
-
for (let i = lqIndex + QUEUE_ITEMS_PER_LISTENER; i < listenerQueue.length;) if (listenerQueue[i] === listener) listenerQueue.splice(i, QUEUE_ITEMS_PER_LISTENER);
|
|
22
|
-
else i += QUEUE_ITEMS_PER_LISTENER;
|
|
23
|
-
let index = listeners.indexOf(listener);
|
|
24
|
-
if (~index) {
|
|
25
|
-
listeners.splice(index, 1);
|
|
26
|
-
if (!--$atom.lc) $atom.off();
|
|
27
|
-
}
|
|
28
|
-
};
|
|
29
|
-
},
|
|
30
|
-
notify(oldValue, changedKey) {
|
|
31
|
-
epoch++;
|
|
32
|
-
let runListenerQueue = !listenerQueue.length;
|
|
33
|
-
for (let listener of listeners) listenerQueue.push(listener, $atom.value, oldValue, changedKey);
|
|
34
|
-
if (runListenerQueue) {
|
|
35
|
-
for (lqIndex = 0; lqIndex < listenerQueue.length; lqIndex += QUEUE_ITEMS_PER_LISTENER) listenerQueue[lqIndex](listenerQueue[lqIndex + 1], listenerQueue[lqIndex + 2], listenerQueue[lqIndex + 3]);
|
|
36
|
-
listenerQueue.length = 0;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
off() {},
|
|
40
|
-
set(newValue) {
|
|
41
|
-
let oldValue = $atom.value;
|
|
42
|
-
if (oldValue !== newValue) {
|
|
43
|
-
$atom.value = newValue;
|
|
44
|
-
$atom.notify(oldValue);
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
subscribe(listener) {
|
|
48
|
-
let unbind = $atom.listen(listener);
|
|
49
|
-
listener($atom.value);
|
|
50
|
-
return unbind;
|
|
51
|
-
},
|
|
52
|
-
value: initialValue
|
|
53
|
-
};
|
|
54
|
-
if (process.env.NODE_ENV !== "production") $atom[clean] = () => {
|
|
55
|
-
listeners = [];
|
|
56
|
-
$atom.lc = 0;
|
|
57
|
-
$atom.off();
|
|
58
|
-
};
|
|
59
|
-
return $atom;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
//#endregion
|
|
63
|
-
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/lifecycle/index.js
|
|
64
|
-
const MOUNT = 5;
|
|
65
|
-
const UNMOUNT = 6;
|
|
66
|
-
const REVERT_MUTATION = 10;
|
|
67
|
-
let on = (object, listener, eventKey, mutateStore) => {
|
|
68
|
-
object.events = object.events || {};
|
|
69
|
-
if (!object.events[eventKey + REVERT_MUTATION]) object.events[eventKey + REVERT_MUTATION] = mutateStore((eventProps) => {
|
|
70
|
-
object.events[eventKey].reduceRight((event, l) => (l(event), event), {
|
|
71
|
-
shared: {},
|
|
72
|
-
...eventProps
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
object.events[eventKey] = object.events[eventKey] || [];
|
|
76
|
-
object.events[eventKey].push(listener);
|
|
77
|
-
return () => {
|
|
78
|
-
let currentListeners = object.events[eventKey];
|
|
79
|
-
let index = currentListeners.indexOf(listener);
|
|
80
|
-
currentListeners.splice(index, 1);
|
|
81
|
-
if (!currentListeners.length) {
|
|
82
|
-
delete object.events[eventKey];
|
|
83
|
-
object.events[eventKey + REVERT_MUTATION]();
|
|
84
|
-
delete object.events[eventKey + REVERT_MUTATION];
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
let STORE_UNMOUNT_DELAY = 1e3;
|
|
89
|
-
let onMount = ($store, initialize) => {
|
|
90
|
-
let listener = (payload) => {
|
|
91
|
-
let destroy = initialize(payload);
|
|
92
|
-
if (destroy) $store.events[UNMOUNT].push(destroy);
|
|
93
|
-
};
|
|
94
|
-
return on($store, listener, MOUNT, (runListeners) => {
|
|
95
|
-
let originListen = $store.listen;
|
|
96
|
-
$store.listen = (...args) => {
|
|
97
|
-
if (!$store.lc && !$store.active) {
|
|
98
|
-
$store.active = true;
|
|
99
|
-
runListeners();
|
|
100
|
-
}
|
|
101
|
-
return originListen(...args);
|
|
102
|
-
};
|
|
103
|
-
let originOff = $store.off;
|
|
104
|
-
$store.events[UNMOUNT] = [];
|
|
105
|
-
$store.off = () => {
|
|
106
|
-
originOff();
|
|
107
|
-
setTimeout(() => {
|
|
108
|
-
if ($store.active && !$store.lc) {
|
|
109
|
-
$store.active = false;
|
|
110
|
-
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
111
|
-
$store.events[UNMOUNT] = [];
|
|
112
|
-
}
|
|
113
|
-
}, STORE_UNMOUNT_DELAY);
|
|
114
|
-
};
|
|
115
|
-
if (process.env.NODE_ENV !== "production") {
|
|
116
|
-
let originClean = $store[clean];
|
|
117
|
-
$store[clean] = () => {
|
|
118
|
-
for (let destroy of $store.events[UNMOUNT]) destroy();
|
|
119
|
-
$store.events[UNMOUNT] = [];
|
|
120
|
-
$store.active = false;
|
|
121
|
-
originClean();
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
return () => {
|
|
125
|
-
$store.listen = originListen;
|
|
126
|
-
$store.off = originOff;
|
|
127
|
-
};
|
|
128
|
-
});
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
//#endregion
|
|
132
|
-
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/computed/index.js
|
|
133
|
-
let computedStore = (stores, cb, batched) => {
|
|
134
|
-
if (!Array.isArray(stores)) stores = [stores];
|
|
135
|
-
let previousArgs;
|
|
136
|
-
let currentEpoch;
|
|
137
|
-
let set = () => {
|
|
138
|
-
if (currentEpoch === epoch) return;
|
|
139
|
-
currentEpoch = epoch;
|
|
140
|
-
let args = stores.map(($store) => $store.get());
|
|
141
|
-
if (!previousArgs || args.some((arg, i) => arg !== previousArgs[i])) {
|
|
142
|
-
previousArgs = args;
|
|
143
|
-
let value = cb(...args);
|
|
144
|
-
if (value && value.then && value.t) value.then((asyncValue) => {
|
|
145
|
-
if (previousArgs === args) $computed.set(asyncValue);
|
|
146
|
-
});
|
|
147
|
-
else {
|
|
148
|
-
$computed.set(value);
|
|
149
|
-
currentEpoch = epoch;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
};
|
|
153
|
-
let $computed = /* @__PURE__ */ atom(void 0);
|
|
154
|
-
let get = $computed.get;
|
|
155
|
-
$computed.get = () => {
|
|
156
|
-
set();
|
|
157
|
-
return get();
|
|
158
|
-
};
|
|
159
|
-
let timer;
|
|
160
|
-
let run = batched ? () => {
|
|
161
|
-
clearTimeout(timer);
|
|
162
|
-
timer = setTimeout(set);
|
|
163
|
-
} : set;
|
|
164
|
-
onMount($computed, () => {
|
|
165
|
-
let unbinds = stores.map(($store) => $store.listen(run));
|
|
166
|
-
set();
|
|
167
|
-
return () => {
|
|
168
|
-
for (let unbind of unbinds) unbind();
|
|
169
|
-
};
|
|
170
|
-
});
|
|
171
|
-
return $computed;
|
|
172
|
-
};
|
|
173
|
-
const computed = /* @__NO_SIDE_EFFECTS__ */ (stores, fn) => computedStore(stores, fn);
|
|
174
|
-
const batched = /* @__NO_SIDE_EFFECTS__ */ (stores, fn) => computedStore(stores, fn, true);
|
|
175
|
-
|
|
176
|
-
//#endregion
|
|
177
|
-
//#region ../../node_modules/.pnpm/nanostores@1.1.0/node_modules/nanostores/map/index.js
|
|
178
|
-
const map = /* @__NO_SIDE_EFFECTS__ */ (initial = {}) => {
|
|
179
|
-
let $map = /* @__PURE__ */ atom(initial);
|
|
180
|
-
$map.setKey = function(key, value) {
|
|
181
|
-
let oldMap = $map.value;
|
|
182
|
-
if (typeof value === "undefined" && key in $map.value) {
|
|
183
|
-
$map.value = { ...$map.value };
|
|
184
|
-
delete $map.value[key];
|
|
185
|
-
$map.notify(oldMap, key);
|
|
186
|
-
} else if ($map.value[key] !== value) {
|
|
187
|
-
$map.value = {
|
|
188
|
-
...$map.value,
|
|
189
|
-
[key]: value
|
|
190
|
-
};
|
|
191
|
-
$map.notify(oldMap, key);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
return $map;
|
|
195
|
-
};
|
|
196
|
-
|
|
197
|
-
//#endregion
|
|
198
|
-
export { atom as i, batched as n, computed as r, map as t };
|
|
1
|
+
let clean=Symbol(`clean`),listenerQueue=[],lqIndex=0,epoch=0;const atom=i=>{let a=[],o={get(){return o.lc||o.listen(()=>{})(),o.value},lc:0,listen(e){return o.lc=a.push(e),()=>{for(let r=lqIndex+4;r<listenerQueue.length;)listenerQueue[r]===e?listenerQueue.splice(r,4):r+=4;let r=a.indexOf(e);~r&&(a.splice(r,1),--o.lc||o.off())}},notify(e,i){epoch++;let s=!listenerQueue.length;for(let n of a)listenerQueue.push(n,o.value,e,i);if(s){for(lqIndex=0;lqIndex<listenerQueue.length;lqIndex+=4)listenerQueue[lqIndex](listenerQueue[lqIndex+1],listenerQueue[lqIndex+2],listenerQueue[lqIndex+3]);listenerQueue.length=0}},off(){},set(e){let t=o.value;t!==e&&(o.value=e,o.notify(t))},subscribe(e){let t=o.listen(e);return e(o.value),t},value:i};return process.env.NODE_ENV!==`production`&&(o[clean]=()=>{a=[],o.lc=0,o.off()}),o};let on=(e,t,n,r)=>(e.events=e.events||{},e.events[n+10]||(e.events[n+10]=r(t=>{e.events[n].reduceRight((e,t)=>(t(e),e),{shared:{},...t})})),e.events[n]=e.events[n]||[],e.events[n].push(t),()=>{let r=e.events[n],i=r.indexOf(t);r.splice(i,1),r.length||(delete e.events[n],e.events[n+10](),delete e.events[n+10])}),onMount=(t,n)=>{let r=e=>{let r=n(e);r&&t.events[6].push(r)};return on(t,r,5,n=>{let r=t.listen;t.listen=(...e)=>(!t.lc&&!t.active&&(t.active=!0,n()),r(...e));let i=t.off;if(t.events[6]=[],t.off=()=>{i(),setTimeout(()=>{if(t.active&&!t.lc){t.active=!1;for(let e of t.events[6])e();t.events[6]=[]}},1e3)},process.env.NODE_ENV!==`production`){let n=t[clean];t[clean]=()=>{for(let e of t.events[6])e();t.events[6]=[],t.active=!1,n()}}return()=>{t.listen=r,t.off=i}})},computedStore=(e,t,n)=>{Array.isArray(e)||(e=[e]);let a,s,c=()=>{if(s===epoch)return;s=epoch;let n=e.map(e=>e.get());if(!a||n.some((e,t)=>e!==a[t])){a=n;let e=t(...n);e&&e.then&&e.t?e.then(e=>{a===n&&l.set(e)}):(l.set(e),s=epoch)}},l=atom(void 0),u=l.get;l.get=()=>(c(),u());let d,f=n?()=>{clearTimeout(d),d=setTimeout(c)}:c;return onMount(l,()=>{let t=e.map(e=>e.listen(f));return c(),()=>{for(let e of t)e()}}),l};const computed=(e,t)=>computedStore(e,t),batched=(e,t)=>computedStore(e,t,!0),map=(e={})=>{let t=atom(e);return t.setKey=function(e,n){let r=t.value;n===void 0&&e in t.value?(t.value={...t.value},delete t.value[e],t.notify(r,e)):t.value[e]!==n&&(t.value={...t.value,[e]:n},t.notify(r,e))},t};export{atom as i,batched as n,computed as r,map as t};
|
|
@@ -1,120 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var Node = class {
|
|
3
|
-
value;
|
|
4
|
-
next;
|
|
5
|
-
constructor(value) {
|
|
6
|
-
this.value = value;
|
|
7
|
-
}
|
|
8
|
-
};
|
|
9
|
-
var Queue = class {
|
|
10
|
-
#head;
|
|
11
|
-
#tail;
|
|
12
|
-
#size;
|
|
13
|
-
constructor() {
|
|
14
|
-
this.clear();
|
|
15
|
-
}
|
|
16
|
-
enqueue(value) {
|
|
17
|
-
const node = new Node(value);
|
|
18
|
-
if (this.#head) {
|
|
19
|
-
this.#tail.next = node;
|
|
20
|
-
this.#tail = node;
|
|
21
|
-
} else {
|
|
22
|
-
this.#head = node;
|
|
23
|
-
this.#tail = node;
|
|
24
|
-
}
|
|
25
|
-
this.#size++;
|
|
26
|
-
}
|
|
27
|
-
dequeue() {
|
|
28
|
-
const current = this.#head;
|
|
29
|
-
if (!current) return;
|
|
30
|
-
this.#head = this.#head.next;
|
|
31
|
-
this.#size--;
|
|
32
|
-
if (!this.#head) this.#tail = void 0;
|
|
33
|
-
return current.value;
|
|
34
|
-
}
|
|
35
|
-
peek() {
|
|
36
|
-
if (!this.#head) return;
|
|
37
|
-
return this.#head.value;
|
|
38
|
-
}
|
|
39
|
-
clear() {
|
|
40
|
-
this.#head = void 0;
|
|
41
|
-
this.#tail = void 0;
|
|
42
|
-
this.#size = 0;
|
|
43
|
-
}
|
|
44
|
-
get size() {
|
|
45
|
-
return this.#size;
|
|
46
|
-
}
|
|
47
|
-
*[Symbol.iterator]() {
|
|
48
|
-
let current = this.#head;
|
|
49
|
-
while (current) {
|
|
50
|
-
yield current.value;
|
|
51
|
-
current = current.next;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
*drain() {
|
|
55
|
-
while (this.#head) yield this.dequeue();
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region ../../node_modules/.pnpm/p-limit@7.2.0/node_modules/p-limit/index.js
|
|
61
|
-
function pLimit(concurrency) {
|
|
62
|
-
validateConcurrency(concurrency);
|
|
63
|
-
const queue = new Queue();
|
|
64
|
-
let activeCount = 0;
|
|
65
|
-
const resumeNext = () => {
|
|
66
|
-
if (activeCount < concurrency && queue.size > 0) {
|
|
67
|
-
activeCount++;
|
|
68
|
-
queue.dequeue()();
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
const next = () => {
|
|
72
|
-
activeCount--;
|
|
73
|
-
resumeNext();
|
|
74
|
-
};
|
|
75
|
-
const run = async (function_, resolve, arguments_) => {
|
|
76
|
-
const result = (async () => function_(...arguments_))();
|
|
77
|
-
resolve(result);
|
|
78
|
-
try {
|
|
79
|
-
await result;
|
|
80
|
-
} catch {}
|
|
81
|
-
next();
|
|
82
|
-
};
|
|
83
|
-
const enqueue = (function_, resolve, arguments_) => {
|
|
84
|
-
new Promise((internalResolve) => {
|
|
85
|
-
queue.enqueue(internalResolve);
|
|
86
|
-
}).then(run.bind(void 0, function_, resolve, arguments_));
|
|
87
|
-
if (activeCount < concurrency) resumeNext();
|
|
88
|
-
};
|
|
89
|
-
const generator = (function_, ...arguments_) => new Promise((resolve) => {
|
|
90
|
-
enqueue(function_, resolve, arguments_);
|
|
91
|
-
});
|
|
92
|
-
Object.defineProperties(generator, {
|
|
93
|
-
activeCount: { get: () => activeCount },
|
|
94
|
-
pendingCount: { get: () => queue.size },
|
|
95
|
-
clearQueue: { value() {
|
|
96
|
-
queue.clear();
|
|
97
|
-
} },
|
|
98
|
-
concurrency: {
|
|
99
|
-
get: () => concurrency,
|
|
100
|
-
set(newConcurrency) {
|
|
101
|
-
validateConcurrency(newConcurrency);
|
|
102
|
-
concurrency = newConcurrency;
|
|
103
|
-
queueMicrotask(() => {
|
|
104
|
-
while (activeCount < concurrency && queue.size > 0) resumeNext();
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
map: { async value(iterable, function_) {
|
|
109
|
-
const promises = Array.from(iterable, (value, index) => this(function_, value, index));
|
|
110
|
-
return Promise.all(promises);
|
|
111
|
-
} }
|
|
112
|
-
});
|
|
113
|
-
return generator;
|
|
114
|
-
}
|
|
115
|
-
function validateConcurrency(concurrency) {
|
|
116
|
-
if (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) throw new TypeError("Expected `concurrency` to be a number from 1 and up");
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
//#endregion
|
|
120
|
-
export { pLimit as t };
|
|
1
|
+
var Node=class{value;next;constructor(e){this.value=e}},Queue=class{#e;#t;#n;constructor(){this.clear()}enqueue(t){let n=new Node(t);this.#e?(this.#t.next=n,this.#t=n):(this.#e=n,this.#t=n),this.#n++}dequeue(){let e=this.#e;if(e)return this.#e=this.#e.next,this.#n--,this.#e||(this.#t=void 0),e.value}peek(){if(this.#e)return this.#e.value}clear(){this.#e=void 0,this.#t=void 0,this.#n=0}get size(){return this.#n}*[Symbol.iterator](){let e=this.#e;for(;e;)yield e.value,e=e.next}*drain(){for(;this.#e;)yield this.dequeue()}};function pLimit(e){let n=!1;if(typeof e==`object`&&({concurrency:e,rejectOnClear:n=!1}=e),validateConcurrency(e),typeof n!=`boolean`)throw TypeError("Expected `rejectOnClear` to be a boolean");let i=new Queue,a=0,o=()=>{a<e&&i.size>0&&(a++,i.dequeue().run())},s=()=>{a--,o()},c=async(e,t,n)=>{let r=(async()=>e(...n))();t(r);try{await r}catch{}s()},l=(t,n,r,s)=>{let l={reject:r};new Promise(e=>{l.run=e,i.enqueue(l)}).then(c.bind(void 0,t,n,s)),a<e&&o()},u=(e,...t)=>new Promise((n,r)=>{l(e,n,r,t)});return Object.defineProperties(u,{activeCount:{get:()=>a},pendingCount:{get:()=>i.size},clearQueue:{value(){if(!n){i.clear();return}let e=AbortSignal.abort().reason;for(;i.size>0;)i.dequeue().reject(e)}},concurrency:{get:()=>e,set(t){validateConcurrency(t),e=t,queueMicrotask(()=>{for(;a<e&&i.size>0;)o()})}},map:{async value(e,t){let n=Array.from(e,(e,n)=>this(t,e,n));return Promise.all(n)}}}),u}function validateConcurrency(e){if(!((Number.isInteger(e)||e===1/0)&&e>0))throw TypeError("Expected `concurrency` to be a number from 1 and up")}export{pLimit as t};
|