@orpc/shared 2.0.0-beta.49 → 2.0.0-beta.50

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 (49) hide show
  1. package/dist/args.d.ts +1 -1
  2. package/dist/args.js +4 -2
  3. package/dist/array.d.ts +4 -1
  4. package/dist/array.js +11 -5
  5. package/dist/bigint.d.ts +1 -1
  6. package/dist/bigint.js +12 -16
  7. package/dist/buffer.d.ts +4 -4
  8. package/dist/buffer.js +44 -67
  9. package/dist/compare.d.ts +1 -1
  10. package/dist/compare.js +23 -42
  11. package/dist/consts.d.ts +1 -1
  12. package/dist/consts.js +3 -1
  13. package/dist/error.d.ts +1 -1
  14. package/dist/error.js +4 -2
  15. package/dist/function.d.ts +1 -1
  16. package/dist/function.js +27 -32
  17. package/dist/http.d.ts +29 -0
  18. package/dist/http.js +128 -94
  19. package/dist/id.d.ts +1 -1
  20. package/dist/id.js +11 -11
  21. package/dist/index.d.ts +26 -34
  22. package/dist/index.js +23 -32
  23. package/dist/interceptor.d.ts +17 -17
  24. package/dist/interceptor.js +106 -126
  25. package/dist/iterator.d.ts +41 -41
  26. package/dist/iterator.js +136 -152
  27. package/dist/object.d.ts +10 -8
  28. package/dist/object.js +176 -227
  29. package/dist/plugin.d.ts +7 -7
  30. package/dist/plugin.js +41 -57
  31. package/dist/promise.d.ts +4 -4
  32. package/dist/promise.js +28 -28
  33. package/dist/proxy.d.ts +2 -2
  34. package/dist/proxy.js +23 -22
  35. package/dist/queue.d.ts +13 -13
  36. package/dist/queue.js +64 -79
  37. package/dist/regex.d.ts +9 -0
  38. package/dist/regex.js +11 -0
  39. package/dist/signal.d.ts +7 -2
  40. package/dist/signal.js +83 -80
  41. package/dist/stream.d.ts +23 -23
  42. package/dist/stream.js +118 -144
  43. package/dist/tracing.d.ts +50 -50
  44. package/dist/tracing.js +60 -85
  45. package/dist/types.d.ts +7 -10
  46. package/dist/value.d.ts +1 -1
  47. package/dist/value.js +5 -5
  48. package/package.json +2 -2
  49. package/dist/types.js +0 -1
package/dist/object.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import type { AnyFunction } from './function.ts';
1
+ import { AnyFunction } from "./function.js";
2
2
  export type Segment = string | number;
3
3
  export declare function findDeepMatches(check: (value: unknown) => boolean, payload: unknown, segments?: Segment[], maps?: Segment[][], values?: unknown[]): {
4
- maps: Segment[][];
5
- values: unknown[];
4
+ maps: Segment[][];
5
+ values: unknown[];
6
6
  };
7
7
  /**
8
8
  * Get constructor of the value
@@ -15,6 +15,10 @@ export declare function getConstructors(value: unknown): Generator<Function>;
15
15
  * `Object.create(null)`.
16
16
  */
17
17
  export declare function isPlainObject(value: unknown): value is Record<PropertyKey, unknown>;
18
+ /**
19
+ * Checks whether a value is an array or a plain object, i.e. something whose keys can be walked.
20
+ */
21
+ export declare function isPlainObjectOrArray(value: unknown): value is unknown[] | Record<PropertyKey, unknown>;
18
22
  /**
19
23
  * Returns `object[key]` only when it is an own property, so keys like
20
24
  * `toString` do not resolve through the prototype chain.
@@ -44,7 +48,7 @@ export declare function clone<T>(value: T): T;
44
48
  export declare function copyOnWrite(parent: object, key: PropertyKey, original: unknown): unknown;
45
49
  export declare function isPropertyKey(value: unknown): value is PropertyKey;
46
50
  export declare const NullProtoObj: {
47
- new <T extends Record<PropertyKey, unknown>>(): T;
51
+ new <T extends Record<PropertyKey, unknown>>(): T;
48
52
  };
49
53
  /**
50
54
  * Returns an object containing all methods of the given object, with each
@@ -54,7 +58,5 @@ export declare const NullProtoObj: {
54
58
  * (excluding `Object.prototype` and the `constructor` property).
55
59
  */
56
60
  export declare function bindMethods<T extends object>(obj: T, options?: {
57
- unbound?: (keyof T)[];
58
- }): Pick<T, {
59
- [K in keyof T]: T[K] extends AnyFunction ? K : never;
60
- }[keyof T]>;
61
+ unbound?: (keyof T)[];
62
+ }): Pick<T, { [K in keyof T]: T[K] extends AnyFunction ? K : never; }[keyof T]>;
package/dist/object.js CHANGED
@@ -1,245 +1,194 @@
1
- import { getOrBind, isNonPrimitive } from '@standard-server/shared';
2
- export function findDeepMatches(check, payload, segments = [], maps = [], values = []) {
3
- if (check(payload)) {
4
- maps.push(segments);
5
- values.push(payload);
6
- }
7
- else if (Array.isArray(payload)) {
8
- payload.forEach((v, i) => {
9
- findDeepMatches(check, v, [...segments, i], maps, values);
10
- });
11
- }
12
- else if (isPlainObject(payload)) {
13
- for (const key of Object.keys(payload)) {
14
- findDeepMatches(check, payload[key], [...segments, key], maps, values);
15
- }
16
- }
17
- return { maps, values };
1
+ import { getOrBind, isNonPrimitive } from "@standard-server/shared";
2
+ // src/object.ts
3
+ function findDeepMatches(check, payload, segments = [], maps = [], values = []) {
4
+ if (check(payload)) {
5
+ maps.push(segments);
6
+ values.push(payload);
7
+ } else if (Array.isArray(payload)) payload.forEach((v, i) => {
8
+ findDeepMatches(check, v, [...segments, i], maps, values);
9
+ });
10
+ else if (isPlainObject(payload)) for (const key of Object.keys(payload)) findDeepMatches(check, payload[key], [...segments, key], maps, values);
11
+ return {
12
+ maps,
13
+ values
14
+ };
18
15
  }
19
16
  /**
20
- * Get constructor of the value
21
- *
22
- */
23
- export function getConstructor(value) {
24
- // Object.getPrototypeOf require object in node.js
25
- if (!isNonPrimitive(value)) {
26
- return null;
27
- }
28
- return Object.getPrototypeOf(value)?.constructor;
29
- }
30
- export function* getConstructors(value) {
31
- if (!isNonPrimitive(value)) {
32
- return;
33
- }
34
- let proto = Object.getPrototypeOf(value);
35
- while (proto !== null) {
36
- if (proto.constructor) {
37
- yield proto.constructor;
38
- }
39
- proto = Object.getPrototypeOf(proto);
40
- }
17
+ * Get constructor of the value
18
+ *
19
+ */
20
+ function getConstructor(value) {
21
+ if (!isNonPrimitive(value)) return null;
22
+ return Object.getPrototypeOf(value)?.constructor;
23
+ }
24
+ function* getConstructors(value) {
25
+ if (!isNonPrimitive(value)) return;
26
+ let proto = Object.getPrototypeOf(value);
27
+ while (proto !== null) {
28
+ if (proto.constructor) yield proto.constructor;
29
+ proto = Object.getPrototypeOf(proto);
30
+ }
41
31
  }
42
32
  /**
43
- * Checks whether a value is a plain object, including objects created with
44
- * `Object.create(null)`.
45
- */
46
- export function isPlainObject(value) {
47
- if (!value || typeof value !== 'object') {
48
- return false;
49
- }
50
- const proto = Object.getPrototypeOf(value);
51
- return proto === Object.prototype || !proto || !proto.constructor;
33
+ * Checks whether a value is a plain object, including objects created with
34
+ * `Object.create(null)`.
35
+ */
36
+ function isPlainObject(value) {
37
+ if (!value || typeof value !== "object") return false;
38
+ const proto = Object.getPrototypeOf(value);
39
+ return proto === Object.prototype || !proto || !proto.constructor;
52
40
  }
53
41
  /**
54
- * Returns `object[key]` only when it is an own property, so keys like
55
- * `toString` do not resolve through the prototype chain.
56
- */
57
- export function getOwn(object, key) {
58
- return Object.hasOwn(object, key) ? object[key] : undefined;
59
- }
60
- export function get(object, path) {
61
- let current = object;
62
- for (const key of path) {
63
- if (!isNonPrimitive(current)) {
64
- return undefined;
65
- }
66
- current = getOwn(current, key);
67
- }
68
- return current;
42
+ * Checks whether a value is an array or a plain object, i.e. something whose keys can be walked.
43
+ */
44
+ function isPlainObjectOrArray(value) {
45
+ return Array.isArray(value) || isPlainObject(value);
69
46
  }
70
47
  /**
71
- * Sets a value at the given path, creating plain objects for intermediate keys as needed.
72
- */
73
- export function set(root, path, value) {
74
- let current = root;
75
- for (let i = 0; i < path.length - 1; i++) {
76
- const key = path[i];
77
- const next = getOwn(current, key);
78
- if (!isNonPrimitive(next)) {
79
- const child = {};
80
- setOwn(current, key, child);
81
- current = child;
82
- }
83
- else {
84
- current = next;
85
- }
86
- }
87
- setOwn(current, path.at(-1), value);
48
+ * Returns `object[key]` only when it is an own property, so keys like
49
+ * `toString` do not resolve through the prototype chain.
50
+ */
51
+ function getOwn(object, key) {
52
+ return Object.hasOwn(object, key) ? object[key] : void 0;
53
+ }
54
+ function get(object, path) {
55
+ let current = object;
56
+ for (const key of path) {
57
+ if (!isNonPrimitive(current)) return;
58
+ current = getOwn(current, key);
59
+ }
60
+ return current;
88
61
  }
89
62
  /**
90
- * Sets `object[key]`, defining `__proto__` as an own property instead of re-parenting the object.
91
- */
92
- export function setOwn(object, key, value) {
93
- if (key === '__proto__') {
94
- Object.defineProperty(object, key, {
95
- value,
96
- writable: true,
97
- enumerable: true,
98
- configurable: true,
99
- });
100
- }
101
- else {
102
- ;
103
- object[key] = value;
104
- }
63
+ * Sets a value at the given path, creating plain objects for intermediate keys as needed.
64
+ */
65
+ function set(root, path, value) {
66
+ let current = root;
67
+ for (let i = 0; i < path.length - 1; i++) {
68
+ const key = path[i];
69
+ const next = getOwn(current, key);
70
+ if (!isNonPrimitive(next)) {
71
+ const child = {};
72
+ setOwn(current, key, child);
73
+ current = child;
74
+ } else current = next;
75
+ }
76
+ setOwn(current, path.at(-1), value);
105
77
  }
106
78
  /**
107
- * Merges two values by copying the second over the first, repeating the merge one level deeper for
108
- * nested plain objects. Anything that is not a pair of plain objects is replaced by the second one.
109
- */
110
- export function mergeTwoLevels(first, second) {
111
- if (!isPlainObject(first) || !isPlainObject(second)) {
112
- return second;
113
- }
114
- // Spread keeps special keys like __proto__ as own properties instead of re-parenting the result.
115
- const result = { ...first, ...second };
116
- for (const key of Object.keys(second)) {
117
- if (!Object.hasOwn(first, key)) {
118
- continue;
119
- }
120
- const firstValue = first[key];
121
- const secondValue = second[key];
122
- if (isPlainObject(firstValue) && isPlainObject(secondValue)) {
123
- result[key] = { ...firstValue, ...secondValue };
124
- }
125
- }
126
- return result;
127
- }
128
- export function omit(obj, keys) {
129
- const result = { ...obj };
130
- for (const key of keys) {
131
- delete result[key];
132
- }
133
- return result;
134
- }
135
- export function pick(obj, keys) {
136
- const result = {};
137
- for (const key of keys) {
138
- if (Object.hasOwn(obj, key)) {
139
- result[key] = obj[key];
140
- }
141
- }
142
- return result;
79
+ * Sets `object[key]`, defining `__proto__` as an own property instead of re-parenting the object.
80
+ */
81
+ function setOwn(object, key, value) {
82
+ if (key === "__proto__") Object.defineProperty(object, key, {
83
+ value,
84
+ writable: true,
85
+ enumerable: true,
86
+ configurable: true
87
+ });
88
+ else object[key] = value;
143
89
  }
144
90
  /**
145
- * Deep clones arrays and plain objects, leaving every other value as is.
146
- * Circular and shared references are preserved in the copy.
147
- */
148
- export function clone(value) {
149
- return cloneWithVisited(value, new WeakMap());
91
+ * Merges two values by copying the second over the first, repeating the merge one level deeper for
92
+ * nested plain objects. Anything that is not a pair of plain objects is replaced by the second one.
93
+ */
94
+ function mergeTwoLevels(first, second) {
95
+ if (!isPlainObject(first) || !isPlainObject(second)) return second;
96
+ const result = {
97
+ ...first,
98
+ ...second
99
+ };
100
+ for (const key of Object.keys(second)) {
101
+ if (!Object.hasOwn(first, key)) continue;
102
+ const firstValue = first[key];
103
+ const secondValue = second[key];
104
+ if (isPlainObject(firstValue) && isPlainObject(secondValue)) result[key] = {
105
+ ...firstValue,
106
+ ...secondValue
107
+ };
108
+ }
109
+ return result;
110
+ }
111
+ function omit(obj, keys) {
112
+ const result = { ...obj };
113
+ for (const key of keys) delete result[key];
114
+ return result;
115
+ }
116
+ function pick(obj, keys) {
117
+ const result = {};
118
+ for (const key of keys) if (Object.hasOwn(obj, key)) result[key] = obj[key];
119
+ return result;
120
+ }
121
+ /**
122
+ * Deep clones arrays and plain objects, leaving every other value as is.
123
+ * Circular and shared references are preserved in the copy.
124
+ */
125
+ function clone(value) {
126
+ return cloneWithVisited(value, /* @__PURE__ */ new WeakMap());
150
127
  }
151
128
  function cloneWithVisited(value, visited) {
152
- if (Array.isArray(value)) {
153
- const existing = visited.get(value);
154
- if (existing) {
155
- return existing;
156
- }
157
- const result = [];
158
- visited.set(value, result);
159
- for (const item of value) {
160
- result.push(cloneWithVisited(item, visited));
161
- }
162
- return result;
163
- }
164
- if (isPlainObject(value)) {
165
- const existing = visited.get(value);
166
- if (existing) {
167
- return existing;
168
- }
169
- const result = {};
170
- visited.set(value, result);
171
- // Use setOwn so special keys like __proto__ don't re-parent the result.
172
- for (const key of Object.keys(value)) {
173
- setOwn(result, key, cloneWithVisited(value[key], visited));
174
- }
175
- for (const sym of Object.getOwnPropertySymbols(value)) {
176
- setOwn(result, sym, cloneWithVisited(value[sym], visited));
177
- }
178
- return result;
179
- }
180
- return value;
181
- }
182
- export function copyOnWrite(parent, key, original) {
183
- const value = parent[key];
184
- if (value !== original) {
185
- return value;
186
- }
187
- let copy;
188
- if (Array.isArray(value)) {
189
- copy = value.slice();
190
- }
191
- else if (isPlainObject(value)) {
192
- copy = { ...value };
193
- }
194
- else {
195
- return value;
196
- }
197
- setOwn(parent, key, copy);
198
- return copy;
199
- }
200
- export function isPropertyKey(value) {
201
- const type = typeof value;
202
- return type === 'string' || type === 'number' || type === 'symbol';
203
- }
204
- export const NullProtoObj = /* @__PURE__ */ (() => {
205
- // oxlint-disable-next-line unicorn/consistent-function-scoping
206
- const e = function () { };
207
- e.prototype = Object.create(null);
208
- Object.freeze(e.prototype);
209
- return e;
129
+ if (Array.isArray(value)) {
130
+ const existing = visited.get(value);
131
+ if (existing) return existing;
132
+ const result = [];
133
+ visited.set(value, result);
134
+ for (const item of value) result.push(cloneWithVisited(item, visited));
135
+ return result;
136
+ }
137
+ if (isPlainObject(value)) {
138
+ const existing = visited.get(value);
139
+ if (existing) return existing;
140
+ const result = {};
141
+ visited.set(value, result);
142
+ for (const key of Object.keys(value)) setOwn(result, key, cloneWithVisited(value[key], visited));
143
+ for (const sym of Object.getOwnPropertySymbols(value)) setOwn(result, sym, cloneWithVisited(value[sym], visited));
144
+ return result;
145
+ }
146
+ return value;
147
+ }
148
+ function copyOnWrite(parent, key, original) {
149
+ const value = parent[key];
150
+ if (value !== original) return value;
151
+ let copy;
152
+ if (Array.isArray(value)) copy = value.slice();
153
+ else if (isPlainObject(value)) copy = { ...value };
154
+ else return value;
155
+ setOwn(parent, key, copy);
156
+ return copy;
157
+ }
158
+ function isPropertyKey(value) {
159
+ const type = typeof value;
160
+ return type === "string" || type === "number" || type === "symbol";
161
+ }
162
+ const NullProtoObj = /* @__PURE__ */ (() => {
163
+ const e = function() {};
164
+ e.prototype = Object.create(null);
165
+ Object.freeze(e.prototype);
166
+ return e;
210
167
  })();
211
168
  /**
212
- * Returns an object containing all methods of the given object, with each
213
- * method bound to the original object instance.
214
- *
215
- * Methods are collected from both the object itself and its prototype chain
216
- * (excluding `Object.prototype` and the `constructor` property).
217
- */
218
- export function bindMethods(obj, options = {}) {
219
- const unbound = new Set(options.unbound);
220
- // Use NullProtoObj so special methods like toString and __proto__ are supported.
221
- const methods = new NullProtoObj();
222
- let current = obj;
223
- while (current && current !== Object.prototype) {
224
- for (const key of Object.getOwnPropertyNames(current)) {
225
- if (key === 'constructor' || key in methods) {
226
- continue;
227
- }
228
- const val = getOrBind(obj, key, { bind: !unbound.has(key) });
229
- if (typeof val === 'function') {
230
- methods[key] = val;
231
- }
232
- }
233
- for (const sym of Object.getOwnPropertySymbols(current)) {
234
- if (sym in methods) {
235
- continue;
236
- }
237
- const val = getOrBind(obj, sym, { bind: !unbound.has(sym) });
238
- if (typeof val === 'function') {
239
- methods[sym] = val;
240
- }
241
- }
242
- current = Object.getPrototypeOf(current);
243
- }
244
- return methods;
245
- }
169
+ * Returns an object containing all methods of the given object, with each
170
+ * method bound to the original object instance.
171
+ *
172
+ * Methods are collected from both the object itself and its prototype chain
173
+ * (excluding `Object.prototype` and the `constructor` property).
174
+ */
175
+ function bindMethods(obj, options = {}) {
176
+ const unbound = new Set(options.unbound);
177
+ const methods = new NullProtoObj();
178
+ let current = obj;
179
+ while (current && current !== Object.prototype) {
180
+ for (const key of Object.getOwnPropertyNames(current)) {
181
+ if (key === "constructor" || key in methods) continue;
182
+ const val = getOrBind(obj, key, { bind: !unbound.has(key) });
183
+ if (typeof val === "function") methods[key] = val;
184
+ }
185
+ for (const sym of Object.getOwnPropertySymbols(current)) {
186
+ if (sym in methods) continue;
187
+ const val = getOrBind(obj, sym, { bind: !unbound.has(sym) });
188
+ if (typeof val === "function") methods[sym] = val;
189
+ }
190
+ current = Object.getPrototypeOf(current);
191
+ }
192
+ return methods;
193
+ }
194
+ export { NullProtoObj, bindMethods, clone, copyOnWrite, findDeepMatches, get, getConstructor, getConstructors, getOwn, isPlainObject, isPlainObjectOrArray, isPropertyKey, mergeTwoLevels, omit, pick, set, setOwn };
package/dist/plugin.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  export interface OrderablePlugin {
2
- /** Unique name of the plugin, used for ordering and identification. */
3
- name: string;
4
- /** Plugins this plugin should execute before. */
5
- before?: string[] | undefined;
6
- /** Plugins this plugin should execute after. */
7
- after?: string[] | undefined;
2
+ /** Unique name of the plugin, used for ordering and identification. */
3
+ name: string;
4
+ /** Plugins this plugin should execute before. */
5
+ before?: string[] | undefined;
6
+ /** Plugins this plugin should execute after. */
7
+ after?: string[] | undefined;
8
8
  }
9
9
  /**
10
10
  * Sorts plugins based on their `before` and `after` dependencies.
11
11
  */
12
- export declare function sortPlugins<T extends OrderablePlugin>(plugins: T[]): T[];
12
+ export declare function sortPlugins<T extends OrderablePlugin>(plugins: T[]): T[];
package/dist/plugin.js CHANGED
@@ -1,61 +1,45 @@
1
+ // src/plugin.ts
1
2
  /**
2
- * Sorts plugins based on their `before` and `after` dependencies.
3
- */
4
- export function sortPlugins(plugins) {
5
- const pluginCount = plugins.length;
6
- const pluginIdToIndices = new Map();
7
- for (let i = 0; i < pluginCount; i++) {
8
- const plugin = plugins[i];
9
- const indices = pluginIdToIndices.get(plugin.name);
10
- if (indices === undefined) {
11
- pluginIdToIndices.set(plugin.name, [i]);
12
- }
13
- else {
14
- indices.push(i);
15
- }
16
- }
17
- const dependencies = Array.from({ length: pluginCount }, () => []);
18
- for (let i = 0; i < pluginCount; i++) {
19
- const plugin = plugins[i];
20
- if (plugin.before !== undefined) {
21
- for (const beforeId of plugin.before) {
22
- const beforeIndices = pluginIdToIndices.get(beforeId);
23
- if (beforeIndices !== undefined) {
24
- for (const beforeIndex of beforeIndices) {
25
- dependencies[beforeIndex].push(i);
26
- }
27
- }
28
- }
29
- }
30
- if (plugin.after !== undefined) {
31
- for (const afterId of plugin.after) {
32
- const afterIndices = pluginIdToIndices.get(afterId);
33
- if (afterIndices !== undefined) {
34
- for (const afterIndex of afterIndices) {
35
- dependencies[i].push(afterIndex);
36
- }
37
- }
38
- }
39
- }
40
- }
41
- const sorted = [];
42
- const placed = new Set();
43
- while (sorted.length < pluginCount) {
44
- const next = plugins.findIndex((_, i) => !placed.has(i) && dependencies[i].every((dependency) => placed.has(dependency)));
45
- if (next === -1) {
46
- throw new Error(`Circular dependency detected involving plugin "${findCyclicPlugin(plugins, dependencies, placed).name}"`);
47
- }
48
- placed.add(next);
49
- sorted.push(plugins[next]);
50
- }
51
- return sorted;
3
+ * Sorts plugins based on their `before` and `after` dependencies.
4
+ */
5
+ function sortPlugins(plugins) {
6
+ const pluginCount = plugins.length;
7
+ const pluginIdToIndices = /* @__PURE__ */ new Map();
8
+ for (let i = 0; i < pluginCount; i++) {
9
+ const plugin = plugins[i];
10
+ const indices = pluginIdToIndices.get(plugin.name);
11
+ if (indices === void 0) pluginIdToIndices.set(plugin.name, [i]);
12
+ else indices.push(i);
13
+ }
14
+ const dependencies = Array.from({ length: pluginCount }, () => []);
15
+ for (let i = 0; i < pluginCount; i++) {
16
+ const plugin = plugins[i];
17
+ if (plugin.before !== void 0) for (const beforeId of plugin.before) {
18
+ const beforeIndices = pluginIdToIndices.get(beforeId);
19
+ if (beforeIndices !== void 0) for (const beforeIndex of beforeIndices) dependencies[beforeIndex].push(i);
20
+ }
21
+ if (plugin.after !== void 0) for (const afterId of plugin.after) {
22
+ const afterIndices = pluginIdToIndices.get(afterId);
23
+ if (afterIndices !== void 0) for (const afterIndex of afterIndices) dependencies[i].push(afterIndex);
24
+ }
25
+ }
26
+ const sorted = [];
27
+ const placed = /* @__PURE__ */ new Set();
28
+ while (sorted.length < pluginCount) {
29
+ const next = plugins.findIndex((_, i) => !placed.has(i) && dependencies[i].every((dependency) => placed.has(dependency)));
30
+ if (next === -1) throw new Error(`Circular dependency detected involving plugin "${findCyclicPlugin(plugins, dependencies, placed).name}"`);
31
+ placed.add(next);
32
+ sorted.push(plugins[next]);
33
+ }
34
+ return sorted;
52
35
  }
53
36
  function findCyclicPlugin(plugins, dependencies, placed) {
54
- const seen = new Set();
55
- let current = plugins.findIndex((_, i) => !placed.has(i));
56
- while (!seen.has(current)) {
57
- seen.add(current);
58
- current = dependencies[current].find((dependency) => !placed.has(dependency));
59
- }
60
- return plugins[current];
37
+ const seen = /* @__PURE__ */ new Set();
38
+ let current = plugins.findIndex((_, i) => !placed.has(i));
39
+ while (!seen.has(current)) {
40
+ seen.add(current);
41
+ current = dependencies[current].find((dependency) => !placed.has(dependency));
42
+ }
43
+ return plugins[current];
61
44
  }
45
+ export { sortPlugins };
package/dist/promise.d.ts CHANGED
@@ -6,12 +6,12 @@
6
6
  * where that API is not yet available.
7
7
  */
8
8
  export declare function promiseWithResolvers<T>(): {
9
- promise: Promise<T>;
10
- resolve: (v: T) => void;
11
- reject: (reason: unknown) => void;
9
+ promise: Promise<T>;
10
+ resolve: (v: T) => void;
11
+ reject: (reason: unknown) => void;
12
12
  };
13
13
  /**
14
14
  * Captures the current async context (such as AsyncLocalStorage) through a promise reaction, so no runtime API is needed.
15
15
  * The returned function runs a callback inside it once; later calls reject.
16
16
  */
17
- export declare function captureAsyncContext(): <T>(callback: () => Promise<T>) => Promise<T>;
17
+ export declare function captureAsyncContext(): <T>(callback: () => Promise<T>) => Promise<T>;