@pumped-fn/core-next 0.5.39 → 0.5.41
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/CHANGELOG.md +15 -0
- package/README.md +72 -5
- package/dist/index.d.ts +141 -122
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +420 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -6
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -152
package/dist/index.js
CHANGED
@@ -1,2 +1,421 @@
|
|
1
|
-
|
1
|
+
//#region src/types.ts
|
2
|
+
const executorSymbol = Symbol.for("@pumped-fn/core/executor");
|
3
|
+
const metaSymbol = Symbol.for("@pumped-fn/core/meta");
|
4
|
+
var SchemaError = class extends Error {
|
5
|
+
issues;
|
6
|
+
constructor(issues) {
|
7
|
+
super(issues[0].message);
|
8
|
+
this.name = "SchemaError";
|
9
|
+
this.issues = issues;
|
10
|
+
}
|
11
|
+
};
|
12
|
+
|
13
|
+
//#endregion
|
14
|
+
//#region src/executor.ts
|
15
|
+
function createExecutor(factory, dependencies, metas) {
|
16
|
+
const executor = {
|
17
|
+
[executorSymbol]: "main",
|
18
|
+
factory: (_, controller) => {
|
19
|
+
if (dependencies === void 0) {
|
20
|
+
const f$1 = factory;
|
21
|
+
return f$1(controller);
|
22
|
+
}
|
23
|
+
const f = factory;
|
24
|
+
return f(_, controller);
|
25
|
+
},
|
26
|
+
dependencies,
|
27
|
+
metas
|
28
|
+
};
|
29
|
+
const lazyExecutor = {
|
30
|
+
[executorSymbol]: "lazy",
|
31
|
+
dependencies: void 0,
|
32
|
+
executor,
|
33
|
+
factory: void 0,
|
34
|
+
metas
|
35
|
+
};
|
36
|
+
const reactiveExecutor = {
|
37
|
+
[executorSymbol]: "reactive",
|
38
|
+
executor,
|
39
|
+
factory: void 0,
|
40
|
+
dependencies: void 0,
|
41
|
+
metas
|
42
|
+
};
|
43
|
+
const staticExecutor = {
|
44
|
+
[executorSymbol]: "static",
|
45
|
+
dependencies: void 0,
|
46
|
+
factory: void 0,
|
47
|
+
metas,
|
48
|
+
executor
|
49
|
+
};
|
50
|
+
Object.defineProperties(executor, {
|
51
|
+
lazy: {
|
52
|
+
value: lazyExecutor,
|
53
|
+
writable: false,
|
54
|
+
configurable: false,
|
55
|
+
enumerable: false
|
56
|
+
},
|
57
|
+
reactive: {
|
58
|
+
value: reactiveExecutor,
|
59
|
+
writable: false,
|
60
|
+
configurable: false,
|
61
|
+
enumerable: false
|
62
|
+
},
|
63
|
+
static: {
|
64
|
+
value: staticExecutor,
|
65
|
+
writable: false,
|
66
|
+
configurable: false,
|
67
|
+
enumerable: false
|
68
|
+
}
|
69
|
+
});
|
70
|
+
return executor;
|
71
|
+
}
|
72
|
+
function isLazyExecutor(executor) {
|
73
|
+
return executor[executorSymbol] === "lazy";
|
74
|
+
}
|
75
|
+
function isReactiveExecutor(executor) {
|
76
|
+
return executor[executorSymbol] === "reactive";
|
77
|
+
}
|
78
|
+
function isStaticExecutor(executor) {
|
79
|
+
return executor[executorSymbol] === "static";
|
80
|
+
}
|
81
|
+
function isMainExecutor(executor) {
|
82
|
+
return isExecutor(executor) && executor[executorSymbol] === "main";
|
83
|
+
}
|
84
|
+
function isExecutor(input) {
|
85
|
+
return typeof input === "object" && input !== null && executorSymbol in input;
|
86
|
+
}
|
87
|
+
function provide(factory, ...metas) {
|
88
|
+
return createExecutor(factory, void 0, metas);
|
89
|
+
}
|
90
|
+
function derive(pdependencies, pfactory, ...metas) {
|
91
|
+
return createExecutor(pfactory, pdependencies, metas);
|
92
|
+
}
|
93
|
+
function preset(e, v) {
|
94
|
+
return {
|
95
|
+
[executorSymbol]: "preset",
|
96
|
+
value: v,
|
97
|
+
executor: e
|
98
|
+
};
|
99
|
+
}
|
100
|
+
|
101
|
+
//#endregion
|
102
|
+
//#region src/ssch.ts
|
103
|
+
function validate(schema, data) {
|
104
|
+
const result = schema["~standard"].validate(data);
|
105
|
+
if ("then" in result) throw new Error("validating async is not supported");
|
106
|
+
if (result.issues) throw new SchemaError(result.issues);
|
107
|
+
return result.value;
|
108
|
+
}
|
109
|
+
async function validateAsync(schema, data) {
|
110
|
+
const result = schema["~standard"].validate(data);
|
111
|
+
if ("then" in result) {
|
112
|
+
const result_1 = await result;
|
113
|
+
if (result_1.issues) throw new SchemaError(result_1.issues);
|
114
|
+
return result_1.value;
|
115
|
+
}
|
116
|
+
if (result.issues) throw new SchemaError(result.issues);
|
117
|
+
return Promise.resolve(result.value);
|
118
|
+
}
|
119
|
+
function custom() {
|
120
|
+
return { "~standard": {
|
121
|
+
vendor: "pumped-fn",
|
122
|
+
version: 1,
|
123
|
+
validate: (value) => {
|
124
|
+
return { value };
|
125
|
+
}
|
126
|
+
} };
|
127
|
+
}
|
128
|
+
|
129
|
+
//#endregion
|
130
|
+
//#region src/meta.ts
|
131
|
+
const meta = (key, schema) => {
|
132
|
+
const _key = typeof key === "string" ? Symbol(key) : key;
|
133
|
+
const fn = (value) => ({
|
134
|
+
[metaSymbol]: true,
|
135
|
+
key: _key,
|
136
|
+
schema,
|
137
|
+
value
|
138
|
+
});
|
139
|
+
Object.defineProperty(fn, "key", {
|
140
|
+
value: _key,
|
141
|
+
configurable: false,
|
142
|
+
enumerable: false,
|
143
|
+
writable: false
|
144
|
+
});
|
145
|
+
Object.defineProperty(fn, metaSymbol, {
|
146
|
+
value: true,
|
147
|
+
configurable: false,
|
148
|
+
enumerable: false,
|
149
|
+
writable: false
|
150
|
+
});
|
151
|
+
Object.defineProperties(fn, {
|
152
|
+
partial: {
|
153
|
+
value: (d) => {
|
154
|
+
return Object.assign({}, fn({}), d);
|
155
|
+
},
|
156
|
+
configurable: false,
|
157
|
+
enumerable: false,
|
158
|
+
writable: false
|
159
|
+
},
|
160
|
+
some: {
|
161
|
+
value: (source) => findValues(source, fn),
|
162
|
+
configurable: false,
|
163
|
+
enumerable: false,
|
164
|
+
writable: false
|
165
|
+
},
|
166
|
+
find: {
|
167
|
+
value: (source) => findValue(source, fn),
|
168
|
+
configurable: false,
|
169
|
+
enumerable: false,
|
170
|
+
writable: false
|
171
|
+
},
|
172
|
+
get: {
|
173
|
+
value: (source) => getValue(findValue(source, fn)),
|
174
|
+
configurable: false,
|
175
|
+
enumerable: false,
|
176
|
+
writable: false
|
177
|
+
}
|
178
|
+
});
|
179
|
+
return fn;
|
180
|
+
};
|
181
|
+
function getValue(meta$1) {
|
182
|
+
return validate(meta$1.schema, meta$1.value);
|
183
|
+
}
|
184
|
+
function findValues(executor, meta$1) {
|
185
|
+
if (!executor) return [];
|
186
|
+
const metas = Array.isArray(executor) ? executor : executor.metas ?? [];
|
187
|
+
const maybeMeta = metas.filter((m) => m.key === meta$1.key);
|
188
|
+
return maybeMeta.map((m) => getValue(m));
|
189
|
+
}
|
190
|
+
function findValue(executor, meta$1) {
|
191
|
+
const values = findValues(executor, meta$1);
|
192
|
+
return values.at(0);
|
193
|
+
}
|
194
|
+
|
195
|
+
//#endregion
|
196
|
+
//#region src/scope.ts
|
197
|
+
function getExecutor(e) {
|
198
|
+
if (isLazyExecutor(e) || isReactiveExecutor(e) || isStaticExecutor(e)) return e.executor;
|
199
|
+
return e;
|
200
|
+
}
|
201
|
+
var Scope = class {
|
202
|
+
disposed = false;
|
203
|
+
cache = new Map();
|
204
|
+
cleanups = new Map();
|
205
|
+
onUpdates = new Map();
|
206
|
+
constructor(...presets) {
|
207
|
+
for (const preset$1 of presets) {
|
208
|
+
const accessor = this["~makeAccessor"](preset$1.executor);
|
209
|
+
this.cache.set(preset$1.executor, {
|
210
|
+
accessor,
|
211
|
+
value: {
|
212
|
+
kind: "resolved",
|
213
|
+
value: preset$1.value
|
214
|
+
}
|
215
|
+
});
|
216
|
+
}
|
217
|
+
}
|
218
|
+
async "~triggerCleanup"(e) {
|
219
|
+
const cs = this.cleanups.get(e);
|
220
|
+
if (cs) for (const c of Array.from(cs.values()).reverse()) await c();
|
221
|
+
}
|
222
|
+
async "~triggerUpdate"(e) {
|
223
|
+
const ce = this.cache.get(e);
|
224
|
+
if (!ce) throw new Error("Executor is not yet resolved");
|
225
|
+
const ou = this.onUpdates.get(e);
|
226
|
+
if (ou) for (const t of Array.from(ou.values())) if (isMainExecutor(t)) {
|
227
|
+
if (this.cleanups.has(t)) this["~triggerCleanup"](t);
|
228
|
+
const a = this.cache.get(t);
|
229
|
+
await a.accessor.resolve(true);
|
230
|
+
if (this.onUpdates.has(t)) await this["~triggerUpdate"](t);
|
231
|
+
} else await t(ce.accessor);
|
232
|
+
}
|
233
|
+
async "~resolveExecutor"(ie, ref) {
|
234
|
+
const e = getExecutor(ie);
|
235
|
+
const a = this["~makeAccessor"](e);
|
236
|
+
if (isLazyExecutor(ie)) return a;
|
237
|
+
if (isReactiveExecutor(ie)) {
|
238
|
+
const c = this.onUpdates.get(ie.executor) ?? new Set();
|
239
|
+
this.onUpdates.set(ie.executor, c);
|
240
|
+
c.add(ref);
|
241
|
+
}
|
242
|
+
await a.resolve(false);
|
243
|
+
if (isStaticExecutor(ie)) return a;
|
244
|
+
return a.get();
|
245
|
+
}
|
246
|
+
async "~resolveDependencies"(ie, ref) {
|
247
|
+
if (ie === void 0) return void 0;
|
248
|
+
if (isExecutor(ie)) return this["~resolveExecutor"](ie, ref);
|
249
|
+
if (Array.isArray(ie)) return await Promise.all(ie.map((item) => this["~resolveDependencies"](item, ref)));
|
250
|
+
const r = {};
|
251
|
+
for (const k of Object.keys(ie)) {
|
252
|
+
const t = ie[k];
|
253
|
+
const rd = await this["~resolveDependencies"](t, ref);
|
254
|
+
r[k] = rd;
|
255
|
+
}
|
256
|
+
return r;
|
257
|
+
}
|
258
|
+
"~ensureNotDisposed"() {
|
259
|
+
if (this.disposed) throw new Error("Scope is disposed");
|
260
|
+
}
|
261
|
+
"~makeAccessor"(e) {
|
262
|
+
const requestor = isLazyExecutor(e) || isReactiveExecutor(e) || isStaticExecutor(e) ? e.executor : e;
|
263
|
+
const cachedAccessor = this.cache.get(requestor);
|
264
|
+
if (cachedAccessor) return cachedAccessor.accessor;
|
265
|
+
const accessor = {};
|
266
|
+
const factory = requestor.factory;
|
267
|
+
const controller = {
|
268
|
+
cleanup: (cleanup) => {
|
269
|
+
const currentSet = this.cleanups.get(requestor) ?? new Set();
|
270
|
+
this.cleanups.set(requestor, currentSet);
|
271
|
+
currentSet.add(cleanup);
|
272
|
+
},
|
273
|
+
release: async () => this.release(requestor),
|
274
|
+
scope: this
|
275
|
+
};
|
276
|
+
const resolve = (force) => {
|
277
|
+
this["~ensureNotDisposed"]();
|
278
|
+
const entry = this.cache.get(requestor);
|
279
|
+
const cached = entry?.value;
|
280
|
+
if (cached && !force) if (cached.kind === "resolved") return Promise.resolve(cached.value);
|
281
|
+
else if (cached.kind === "rejected") throw cached.error;
|
282
|
+
else return cached.promise;
|
283
|
+
const promise = new Promise((resolve$1, reject) => {
|
284
|
+
this["~resolveDependencies"](requestor.dependencies, requestor).then((dependencies) => factory(dependencies, controller)).then((result) => {
|
285
|
+
this.cache.set(requestor, {
|
286
|
+
accessor,
|
287
|
+
value: {
|
288
|
+
kind: "resolved",
|
289
|
+
value: result
|
290
|
+
}
|
291
|
+
});
|
292
|
+
resolve$1(result);
|
293
|
+
}).catch((error) => {
|
294
|
+
this.cache.set(requestor, {
|
295
|
+
accessor,
|
296
|
+
value: {
|
297
|
+
kind: "rejected",
|
298
|
+
error
|
299
|
+
}
|
300
|
+
});
|
301
|
+
reject(error);
|
302
|
+
});
|
303
|
+
});
|
304
|
+
this.cache.set(requestor, {
|
305
|
+
accessor,
|
306
|
+
value: {
|
307
|
+
kind: "pending",
|
308
|
+
promise
|
309
|
+
}
|
310
|
+
});
|
311
|
+
return promise;
|
312
|
+
};
|
313
|
+
return Object.assign(accessor, {
|
314
|
+
get: () => {
|
315
|
+
this["~ensureNotDisposed"]();
|
316
|
+
const cacheEntry = this.cache.get(requestor)?.value;
|
317
|
+
if (!cacheEntry || cacheEntry.kind === "pending") throw new Error("Executor is not resolved");
|
318
|
+
if (cacheEntry.kind === "rejected") throw cacheEntry.error;
|
319
|
+
return cacheEntry.value;
|
320
|
+
},
|
321
|
+
lookup: () => {
|
322
|
+
this["~ensureNotDisposed"]();
|
323
|
+
const cacheEntry = this.cache.get(requestor);
|
324
|
+
if (!cacheEntry) return void 0;
|
325
|
+
return cacheEntry.value;
|
326
|
+
},
|
327
|
+
metas: e.metas,
|
328
|
+
resolve,
|
329
|
+
release: async (soft = false) => {
|
330
|
+
this.release(requestor, soft);
|
331
|
+
},
|
332
|
+
update: (updateFn) => {
|
333
|
+
return this.update(requestor, updateFn);
|
334
|
+
},
|
335
|
+
subscribe: (cb) => {
|
336
|
+
this["~ensureNotDisposed"]();
|
337
|
+
return this.onUpdate(requestor, cb);
|
338
|
+
}
|
339
|
+
});
|
340
|
+
}
|
341
|
+
accessor(executor) {
|
342
|
+
this["~ensureNotDisposed"]();
|
343
|
+
return this["~makeAccessor"](executor);
|
344
|
+
}
|
345
|
+
async resolve(executor, force = false) {
|
346
|
+
this["~ensureNotDisposed"]();
|
347
|
+
const accessor = this["~makeAccessor"](executor);
|
348
|
+
await accessor.resolve(force);
|
349
|
+
return accessor.get();
|
350
|
+
}
|
351
|
+
async resolveAccessor(executor, force = false) {
|
352
|
+
this["~ensureNotDisposed"]();
|
353
|
+
const accessor = this["~makeAccessor"](executor);
|
354
|
+
await accessor.resolve(force);
|
355
|
+
return accessor;
|
356
|
+
}
|
357
|
+
async update(e, u) {
|
358
|
+
this["~ensureNotDisposed"]();
|
359
|
+
this["~triggerCleanup"](e);
|
360
|
+
const accessor = this["~makeAccessor"](e);
|
361
|
+
if (typeof u === "function") {
|
362
|
+
const fn = u;
|
363
|
+
const n = fn(accessor.get());
|
364
|
+
this.cache.set(e, {
|
365
|
+
accessor,
|
366
|
+
value: {
|
367
|
+
kind: "resolved",
|
368
|
+
value: n
|
369
|
+
}
|
370
|
+
});
|
371
|
+
} else this.cache.set(e, {
|
372
|
+
accessor,
|
373
|
+
value: {
|
374
|
+
kind: "resolved",
|
375
|
+
value: u
|
376
|
+
}
|
377
|
+
});
|
378
|
+
await this["~triggerUpdate"](e);
|
379
|
+
}
|
380
|
+
async release(e, s = false) {
|
381
|
+
this["~ensureNotDisposed"]();
|
382
|
+
const ce = this.cache.get(e);
|
383
|
+
if (!ce && !s) throw new Error("Executor is not yet resolved");
|
384
|
+
await this["~triggerCleanup"](e);
|
385
|
+
const ou = this.onUpdates.get(e);
|
386
|
+
if (ou) {
|
387
|
+
for (const t of Array.from(ou.values())) if (isMainExecutor(t)) await this.release(t, true);
|
388
|
+
this.onUpdates.delete(e);
|
389
|
+
}
|
390
|
+
this.cache.delete(e);
|
391
|
+
}
|
392
|
+
async dispose() {
|
393
|
+
this["~ensureNotDisposed"]();
|
394
|
+
const currents = this.cache.keys();
|
395
|
+
for (const current of currents) await this.release(current, true);
|
396
|
+
this.disposed = true;
|
397
|
+
this.cache.clear();
|
398
|
+
this.cleanups.clear();
|
399
|
+
}
|
400
|
+
onUpdate(e, cb) {
|
401
|
+
this["~ensureNotDisposed"]();
|
402
|
+
const ou = this.onUpdates.get(e) ?? new Set();
|
403
|
+
this.onUpdates.set(e, ou);
|
404
|
+
ou.add(cb);
|
405
|
+
return () => {
|
406
|
+
this["~ensureNotDisposed"]();
|
407
|
+
const ou$1 = this.onUpdates.get(e);
|
408
|
+
if (ou$1) {
|
409
|
+
ou$1.delete(cb);
|
410
|
+
if (ou$1.size === 0) this.onUpdates.delete(e);
|
411
|
+
}
|
412
|
+
};
|
413
|
+
}
|
414
|
+
};
|
415
|
+
function createScope(...presets) {
|
416
|
+
return new Scope(...presets);
|
417
|
+
}
|
418
|
+
|
419
|
+
//#endregion
|
420
|
+
export { SchemaError, createScope, custom, derive, executorSymbol, findValue, findValues, getValue, isExecutor, isLazyExecutor, isMainExecutor, isReactiveExecutor, isStaticExecutor, meta, metaSymbol, preset, provide, validate, validateAsync };
|
2
421
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../src/types.ts","../src/executor.ts","../src/ssch.ts","../src/meta.ts","../src/scope.ts"],"sourcesContent":["export const executorSymbol = Symbol.for(\"@pumped-fn/core/executor\");\nexport const metaSymbol = Symbol.for(\"@pumped-fn/core/meta\");\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n export interface Props<Input = unknown, Output = Input> {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: unknown\n ) => Result<Output> | Promise<Result<Output>>;\n readonly types?: Types<Input, Output> | undefined;\n }\n\n export type Result<Output> = SuccessResult<Output> | FailureResult;\n\n export interface SuccessResult<Output> {\n readonly value: Output;\n readonly issues?: undefined;\n }\n\n export interface FailureResult {\n readonly issues: ReadonlyArray<Issue>;\n }\n\n export interface Issue {\n readonly message: string;\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n\n export interface PathSegment {\n readonly key: PropertyKey;\n }\n\n export interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n export type InferInput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"input\"];\n\n export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"output\"];\n}\n\nexport class SchemaError extends Error {\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;\n\n constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>) {\n super(issues[0].message);\n this.name = \"SchemaError\";\n this.issues = issues;\n }\n}\n\nexport declare namespace Meta {\n export interface MetaContainer {\n metas: Meta[] | undefined;\n }\n\n export interface Meta<V = unknown> {\n readonly [metaSymbol]: true;\n readonly key: string | symbol;\n readonly schema: StandardSchemaV1<V>;\n readonly value: V;\n }\n\n export interface MetaFn<V> {\n (value: V): Meta<V>;\n readonly key: string | symbol;\n partial: <D extends Partial<V>>(d: D) => D;\n some: (source: MetaContainer | Meta[] | undefined) => V[];\n find: (source: MetaContainer | Meta[] | undefined) => V | undefined;\n get: (source: MetaContainer | Meta[] | undefined) => V;\n }\n}\n\nexport declare namespace Core {\n export type Output<T> = T | Promise<T>;\n\n export type NoDependencyFn<T> = (scope: Controller) => Output<T>;\n export type DependentFn<T, D> = (\n dependencies: D,\n scope: Controller\n ) => Output<T>;\n export type RecordLike = Record<string, unknown>;\n export type UExecutor = BaseExecutor<unknown>;\n\n export type Cleanup = () => void | Promise<void>;\n\n export type Controller = {\n cleanup: (cleanup: Cleanup) => void;\n release: () => Promise<void>;\n scope: Scope;\n };\n\n export type Kind = \"main\" | \"reactive\" | \"lazy\" | \"static\";\n\n export interface BaseExecutor<T> extends Meta.MetaContainer {\n [executorSymbol]: Kind;\n factory: NoDependencyFn<T> | DependentFn<T, unknown> | undefined;\n dependencies:\n | undefined\n | UExecutor\n | Array<UExecutor>\n | Record<string, UExecutor>;\n }\n\n export interface Executor<T> extends BaseExecutor<T> {\n [executorSymbol]: \"main\";\n factory: NoDependencyFn<T> | DependentFn<T, unknown>;\n\n /** Return an executor controller without resolving Executor */\n readonly lazy: Lazy<T>;\n\n /** Return an resolved executor, and mark the user to be reactived for future changes */\n readonly reactive: Reactive<T>;\n\n /** Return an resolved executor with its controller */\n readonly static: Static<T>;\n }\n\n export interface Reactive<T> extends BaseExecutor<T> {\n [executorSymbol]: \"reactive\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export interface Lazy<T> extends BaseExecutor<Accessor<T>> {\n [executorSymbol]: \"lazy\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export interface Static<T> extends BaseExecutor<Accessor<T>> {\n [executorSymbol]: \"static\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export interface Accessor<T> extends Meta.MetaContainer {\n lookup(): T;\n get(): T;\n resolve(force?: boolean): Promise<T>;\n release(soft?: boolean): Promise<void>;\n update(updateFn: T | ((current: T) => T)): Promise<void>;\n subscribe(callback: (value: T) => void): Cleanup;\n }\n\n export type InferOutput<T> = T extends Executor<infer U> | Reactive<infer U>\n ? Awaited<U>\n : T extends Lazy<infer U> | Static<infer U>\n ? Accessor<Awaited<U>>\n : never;\n\n export interface Scope {\n accessor<T>(executor: Core.Executor<T>, eager?: boolean): Accessor<T>;\n\n resolve<T>(executor: Core.Executor<T>): Promise<T>;\n resolveAccessor<T>(executor: Core.Executor<T>): Promise<Accessor<T>>;\n\n update<T>(\n executor: Executor<T>,\n updateFn: T | ((current: T) => T)\n ): Promise<void>;\n\n reset<T>(executor: Executor<T>): void;\n release(executor: Executor<any>, soft?: boolean): Promise<void>;\n\n dispose(): Promise<void>;\n\n onUpdate<T>(\n executor: Executor<T>,\n callback: (accessor: Accessor<T>) => void\n ): Cleanup;\n // onRelease<T>(executor: Executor<T>, callback: () => void): () => void;\n }\n}\n","import { Core, executorSymbol, Meta } from \"./types\";\n\nfunction createExecutor<T>(\n factory: Core.NoDependencyFn<T> | Core.DependentFn<T, unknown>,\n dependencies:\n | undefined\n | Core.UExecutor\n | Array<Core.UExecutor>\n | Record<string, Core.UExecutor>,\n metas: Meta.Meta[] | undefined\n): Core.Executor<T> {\n const executor = {\n [executorSymbol]: \"base\",\n factory: (_: unknown, controller: Core.Controller) => {\n if (dependencies === undefined) {\n const f = factory as Core.NoDependencyFn<T>;\n return f(controller);\n }\n\n const f = factory as Core.DependentFn<T, unknown>;\n return f(_, controller);\n },\n dependencies,\n metas: metas,\n } as unknown as Core.Executor<T>;\n\n const lazyExecutor = {\n [executorSymbol]: \"lazy\",\n dependencies: undefined,\n executor,\n factory: undefined,\n metas: metas,\n } satisfies Core.Lazy<T>;\n\n const reactiveExecutor = {\n [executorSymbol]: \"reactive\",\n executor,\n factory: undefined,\n dependencies: undefined,\n metas: metas,\n } satisfies Core.Reactive<T>;\n\n const staticExecutor = {\n [executorSymbol]: \"static\",\n dependencies: undefined,\n factory: undefined,\n metas: metas,\n executor,\n } satisfies Core.Static<T>;\n\n Object.defineProperties(executor, {\n lazy: {\n value: lazyExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n reactive: {\n value: reactiveExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n static: {\n value: staticExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n });\n\n return executor;\n}\n\nexport function isLazyExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Lazy<unknown> {\n return executor[executorSymbol] === \"lazy\";\n}\n\nexport function isReactiveExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Reactive<unknown> {\n return executor[executorSymbol] === \"reactive\";\n}\n\nexport function isStaticExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Static<unknown> {\n return executor[executorSymbol] === \"static\";\n}\n\nexport function isExecutor<T>(input: unknown): input is Core.BaseExecutor<T> {\n return typeof input === \"object\" && input !== null && executorSymbol in input;\n}\n\nexport function provide<T>(\n factory: Core.NoDependencyFn<T>,\n ...metas: Meta.Meta[]\n): Core.Executor<T> {\n return createExecutor(factory, undefined, metas);\n}\n\nexport function derive<T, D extends Core.BaseExecutor<unknown>>(\n dependencies: D,\n factory: Core.DependentFn<T, Core.InferOutput<D>>,\n ...metas: Meta.Meta[]\n): Core.Executor<T>;\n\nexport function derive<\n T,\n D extends\n | ReadonlyArray<Core.BaseExecutor<unknown>>\n | Record<string, Core.BaseExecutor<unknown>>\n>(\n dependencies: { [K in keyof D]: D[K] },\n factory: Core.DependentFn<T, { [K in keyof D]: Core.InferOutput<D[K]> }>,\n ...metas: Meta.Meta[]\n): Core.Executor<T>;\n\nexport function derive<T, D>(\n pdependencies:\n | Core.BaseExecutor<D>\n | Array<Core.BaseExecutor<D>>\n | Record<string, Core.BaseExecutor<unknown>>,\n pfactory:\n | Core.DependentFn<T, Core.InferOutput<D>>\n | Core.DependentFn<T, { [K in keyof D]: Core.InferOutput<D[K]> }>,\n ...metas: Meta.Meta[]\n): Core.Executor<T> {\n return createExecutor(pfactory as any, pdependencies, metas);\n}\n","import { SchemaError, StandardSchemaV1 } from \"./types\";\n\nexport function validate<TSchema extends StandardSchemaV1>(\n schema: TSchema,\n data: unknown\n): Awaited<StandardSchemaV1.InferOutput<TSchema>> {\n const result = schema[\"~standard\"].validate(data);\n\n if (\"then\" in result) {\n throw new Error(\"validating async is not supported\");\n }\n\n if (result.issues) {\n throw new SchemaError(result.issues);\n }\n return result.value as any;\n}\n\nexport async function validateAsync<TSchema extends StandardSchemaV1>(\n schema: TSchema,\n data: unknown\n): Promise<Awaited<StandardSchemaV1.InferOutput<TSchema>>> {\n const result = schema[\"~standard\"].validate(data);\n\n if (\"then\" in result) {\n const result_1 = await result;\n if (result_1.issues) {\n throw new SchemaError(result_1.issues);\n }\n return result_1.value as any;\n }\n\n if (result.issues) {\n throw new SchemaError(result.issues);\n }\n\n return Promise.resolve(result.value as any);\n}\n\nexport function custom<T>(): StandardSchemaV1<T, T> {\n return {\n \"~standard\": {\n vendor: \"pumped-fn\",\n version: 1,\n validate: (value) => {\n return { value: value as T };\n },\n },\n };\n}\n","import { validate } from \"./ssch\";\nimport { metaSymbol, StandardSchemaV1, type Meta } from \"./types\";\n\nexport const meta = <V>(\n key: string | symbol,\n schema: StandardSchemaV1<V>\n): Meta.MetaFn<V> => {\n const _key = typeof key === \"string\" ? Symbol(key) : key;\n\n const fn = (value: V) =>\n ({\n [metaSymbol]: true,\n key: _key,\n schema,\n value,\n } as unknown as Meta.MetaFn<V>);\n\n Object.defineProperty(fn, \"key\", {\n value: _key,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n Object.defineProperty(fn, metaSymbol, {\n value: true,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n Object.defineProperties(fn, {\n partial: {\n value: (d: Partial<V>) => {\n return Object.assign({}, fn({} as V), d);\n },\n configurable: false,\n enumerable: false,\n writable: false,\n },\n some: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n findValues(source, fn as unknown as Meta.MetaFn<unknown>),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n find: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n findValue(source, fn as unknown as Meta.MetaFn<unknown>),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n get: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n getValue(\n findValue(\n source,\n fn as unknown as Meta.MetaFn<unknown>\n ) as Meta.Meta<V>\n ),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n });\n\n return fn as any;\n};\n\nexport function getValue<V>(meta: Meta.Meta<V>) {\n return validate(meta.schema, meta.value);\n}\n\nexport function findValues<V = unknown>(\n executor: Meta.MetaContainer | Meta.Meta[] | undefined,\n meta: Meta.MetaFn<V>\n): V[] {\n if (!executor) return [];\n\n const metas = Array.isArray(executor) ? executor : executor.metas ?? [];\n\n const maybeMeta = metas.filter((m) => m.key === meta.key);\n return maybeMeta.map((m) => getValue(m as Meta.Meta<V>));\n}\n\nexport function findValue<V>(\n executor: Meta.MetaContainer | Meta.Meta[] | undefined,\n meta: Meta.MetaFn<V>\n): V | undefined {\n const values = findValues(executor, meta);\n return values.at(0);\n}\n","import {\n isLazyExecutor,\n isReactiveExecutor,\n isStaticExecutor,\n isExecutor,\n} from \"./executor\";\nimport { Core } from \"./types\";\n\nexport interface ScopeInner {\n \"~findAffectedTargets\"(\n target: Core.Executor<unknown>,\n updateSet?: Set<Core.Executor<unknown>>\n ): Set<Core.Executor<unknown>>;\n\n \"~resolveDependencies\"(\n e:\n | undefined\n | Core.BaseExecutor<unknown>\n | Core.BaseExecutor<unknown>[]\n | Record<string, Core.BaseExecutor<unknown>>,\n ref: Core.Executor<unknown>\n ): Promise<undefined | unknown | unknown[] | Record<string, unknown>>;\n\n getCache(): Map<Core.Executor<unknown>, Core.Accessor<unknown>>;\n getValueCache(): Map<Core.Executor<unknown>, unknown>;\n getReactiveness(): Map<Core.Executor<unknown>, Set<Core.Executor<unknown>>>;\n}\n\ntype Value =\n | { kind: \"resolving\"; promise: Promise<unknown> }\n | { kind: \"resolved\"; value: unknown }\n | { kind: \"rejected\"; error: unknown };\n\nclass Scope implements Core.Scope, ScopeInner {\n private isDisposed: boolean = false;\n private cache: Map<Core.Executor<unknown>, Core.Accessor<unknown>> =\n new Map();\n private valueCache: Map<Core.Executor<unknown>, Value> = new Map();\n private reactiveness = new Map<\n Core.Executor<unknown>,\n Set<Core.Executor<unknown>>\n >();\n private cleanups = new Map<Core.Executor<unknown>, Set<Core.Cleanup>>();\n private onUpdates = new Map<\n Core.Executor<unknown>,\n Set<(accessor: Core.Accessor<unknown>) => void | Promise<void>>\n >();\n\n private \"~appendReactive\"(\n reactive: Core.Executor<unknown>,\n ref: Core.Executor<unknown>\n ) {\n const currentSet = this.reactiveness.get(reactive) ?? new Set();\n this.reactiveness.set(reactive, currentSet);\n\n currentSet.add(ref);\n }\n\n async \"~resolveDependencies\"(\n e:\n | undefined\n | Core.BaseExecutor<unknown>\n | Core.BaseExecutor<unknown>[]\n | Record<string, Core.BaseExecutor<unknown>>,\n ref: Core.Executor<unknown>\n ): Promise<undefined | unknown | unknown[] | Record<string, unknown>> {\n if (e === undefined) {\n return undefined;\n }\n\n if (isExecutor(e)) {\n if (isLazyExecutor(e)) {\n return this[\"~resolveLazy\"](e);\n }\n\n const staticResult = await this[\"~resolveStatic\"](\n e as Core.Executor<unknown>\n );\n\n if (isReactiveExecutor(e)) {\n this[\"~appendReactive\"](e.executor, ref);\n }\n\n await staticResult.resolve(false);\n if (isStaticExecutor(e)) {\n return staticResult;\n }\n\n return staticResult.get();\n }\n\n if (Array.isArray(e)) {\n return await Promise.all(\n e.map((item) => this[\"~resolveDependencies\"](item, ref))\n );\n }\n\n const result: Record<string, unknown> = {};\n for (const key of Object.keys(e)) {\n const target = e[key];\n const resolvedResult = await this[\"~resolveDependencies\"](target, ref);\n\n result[key] = resolvedResult;\n }\n\n return result;\n }\n\n private \"~resolveLazy\"(e: Core.Lazy<unknown>): Core.Accessor<unknown> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cached = this.cache.get(e.executor);\n if (cached) {\n return cached;\n }\n\n const accessor = this[\"~makeAccessor\"](e.executor);\n\n return accessor;\n }\n\n private async \"~resolveStatic\"(\n e: Core.Executor<unknown>\n ): Promise<Core.Accessor<unknown>> {\n const cached = this.cache.get(e);\n if (cached) {\n return cached;\n }\n\n const accessor = this[\"~makeAccessor\"](e, true);\n return accessor;\n }\n\n private \"~makeController\"(e: Core.Executor<unknown>): Core.Controller {\n return {\n cleanup: (cleanup: Core.Cleanup) => {\n const currentSet = this.cleanups.get(e) ?? new Set();\n this.cleanups.set(e, currentSet);\n\n currentSet.add(cleanup);\n },\n release: async () => {\n this.release(e);\n },\n scope: this,\n };\n }\n\n private \"~makeAccessor\"(\n e: Core.BaseExecutor<unknown>,\n eager: boolean = false\n ): Core.Accessor<unknown> {\n const accessor = {} as Core.Accessor<unknown>;\n const requestor =\n isLazyExecutor(e) || isReactiveExecutor(e) || isStaticExecutor(e)\n ? e.executor\n : (e as Core.Executor<unknown>);\n\n const cachedAccessor = this.cache.get(requestor);\n if (cachedAccessor) {\n return cachedAccessor;\n }\n\n const factory = requestor.factory;\n const controller = this[\"~makeController\"](requestor);\n\n const resolve = async (force: boolean): Promise<unknown> => {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cached = this.valueCache.get(requestor);\n if (cached && !force) {\n if (cached.kind === \"resolved\") {\n return cached.value;\n } else if (cached.kind === \"rejected\") {\n throw cached.error;\n } else {\n return cached.promise;\n }\n }\n\n const promise = new Promise((resolve, reject) => {\n this[\"~resolveDependencies\"](requestor.dependencies, requestor)\n .then((dependencies) => factory(dependencies as any, controller))\n .then((result) => {\n this.valueCache.set(requestor, { kind: \"resolved\", value: result });\n resolve(result);\n })\n .catch((error) => {\n this.valueCache.set(requestor, { kind: \"rejected\", error });\n reject(error);\n });\n });\n\n this.valueCache.set(requestor, { kind: \"resolving\", promise });\n this.cache.set(requestor, accessor);\n return promise;\n };\n\n if (!isLazyExecutor(e) || eager) {\n resolve(false);\n }\n\n return Object.assign(accessor, {\n get: () => {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const valueCached = this.valueCache.get(requestor);\n\n if (!valueCached || valueCached.kind === \"resolving\") {\n throw new Error(\"Executor not found\");\n }\n\n if (valueCached.kind === \"rejected\") {\n throw valueCached.error;\n }\n\n return valueCached.value;\n },\n lookup: () => {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n return this.valueCache.get(requestor);\n },\n metas: e.metas,\n resolve,\n release: async (soft: boolean = false) => {\n this.release(requestor, soft);\n },\n update: (updateFn: unknown | ((current: unknown) => unknown)) => {\n return this.update(requestor, updateFn);\n },\n subscribe: (cb: (value: unknown) => void) => {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n return this.onUpdate(requestor, cb);\n },\n } satisfies Partial<Core.Accessor<unknown>>);\n }\n\n accessor<T>(executor: Core.Executor<T>): Core.Accessor<T> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n return this[\"~makeAccessor\"](executor, false) as Core.Accessor<T>;\n }\n\n async resolve<T>(executor: Core.Executor<T>): Promise<T> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cached = this.valueCache.get(executor);\n if (cached) {\n if (cached.kind === \"resolved\") {\n return cached.value as T;\n } else if (cached.kind === \"rejected\") {\n throw cached.error;\n } else {\n return (await cached.promise) as T;\n }\n }\n\n const accessor = this[\"~makeAccessor\"](executor, true);\n await accessor.resolve(false);\n\n return accessor.get() as T;\n }\n\n async resolveAccessor<T>(\n executor: Core.Executor<T>\n ): Promise<Core.Accessor<T>> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cachedAccessor = this.cache.get(executor);\n if (!cachedAccessor) {\n const accessor = this[\"~makeAccessor\"](executor, true);\n await accessor.resolve();\n\n return accessor as Core.Accessor<T>;\n }\n\n await cachedAccessor.resolve();\n return cachedAccessor as Core.Accessor<T>;\n }\n\n \"~findAffectedTargets\"(\n target: Core.Executor<unknown>,\n updateSet: Set<Core.Executor<unknown>> = new Set()\n ): Set<Core.Executor<unknown>> {\n const triggerTargets = this.reactiveness.get(target);\n\n if (triggerTargets && triggerTargets.size > 0) {\n for (const target of triggerTargets) {\n if (updateSet.has(target)) {\n updateSet.delete(target);\n }\n updateSet.add(target);\n\n if (this.reactiveness.has(target)) {\n this[\"~findAffectedTargets\"](target, updateSet);\n }\n }\n }\n\n return updateSet;\n }\n\n async update<T>(\n executor: Core.Executor<T>,\n updateFn: T | ((current: T) => T)\n ): Promise<void> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cached = this.cache.get(executor);\n if (!cached) {\n throw new Error(\"Executor is not yet resolved\");\n }\n\n const current = (await cached.resolve(false)) as T;\n const cleanups = this.cleanups.get(executor);\n if (cleanups) {\n for (const cleanup of Array.from(cleanups.values()).reverse()) {\n await cleanup();\n }\n }\n\n if (typeof updateFn === \"function\") {\n const fn = updateFn as (current: T) => T;\n const newValue = fn(current);\n this.valueCache.set(executor, { kind: \"resolved\", value: newValue });\n } else {\n this.valueCache.set(executor, {\n kind: \"resolved\",\n value: updateFn,\n });\n }\n\n const onUpdateSet = this.onUpdates.get(executor);\n if (onUpdateSet) {\n for (const callback of Array.from(onUpdateSet.values())) {\n await callback(cached);\n }\n }\n\n const updateSet = this[\"~findAffectedTargets\"](executor);\n for (const target of updateSet) {\n const cached = this.cache.get(target);\n\n if (cached) {\n const cleanups = this.cleanups.get(target);\n if (cleanups) {\n for (const cleanup of Array.from(cleanups.values()).reverse()) {\n await cleanup();\n }\n }\n\n await cached.resolve(true);\n\n const onUpdateSet = this.onUpdates.get(target);\n if (onUpdateSet) {\n for (const callback of Array.from(onUpdateSet.values())) {\n await callback(cached);\n }\n }\n }\n }\n }\n\n async reset<T>(executor: Core.Executor<T>): Promise<void> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n await this.release(executor, true);\n await this.resolve(executor);\n }\n\n async release(\n executor: Core.Executor<any>,\n soft: boolean = false\n ): Promise<void> {\n if (this.isDisposed) {\n throw new Error(\"Scope is disposed\");\n }\n\n const cached = this.cache.get(executor);\n if (!cached && !soft) {\n throw new Error(\"Executor is not yet resolved\");\n }\n\n const affectedTargets = this[\"~findAffectedTargets\"](executor);\n for (const target of affectedTargets) {\n await this.release(target, true);\n }\n\n const cleanups = this.cleanups.get(executor);\n if (cleanups) {\n for (const cleanup of Array.from(cleanups.values()).reverse()) {\n await cleanup();\n }\n }\n\n this.cache.delete(executor);\n this.valueCache.delete(executor);\n this.reactiveness.delete(executor);\n this.onUpdates.delete(executor);\n }\n\n async dispose(): Promise<void> {\n const currents = this.cache.keys();\n for (const current of currents) {\n await this.release(current, true);\n }\n\n this.isDisposed = true;\n this.cache.clear();\n this.valueCache.clear();\n this.reactiveness.clear();\n this.cleanups.clear();\n }\n\n onUpdate<T>(\n executor: Core.Executor<T>,\n callback: (accessor: Core.Accessor<T>) => void | Promise<void>\n ): Core.Cleanup {\n if (this.isDisposed) {\n throw new Error(\"scope is disposed\");\n }\n\n const onUpdateSet = this.onUpdates.get(executor) ?? new Set();\n this.onUpdates.set(executor, onUpdateSet);\n onUpdateSet.add(callback as any);\n\n return () => {\n if (this.isDisposed) {\n throw new Error(\"scope is disposed\");\n }\n\n const currentSet = this.onUpdates.get(executor);\n if (currentSet) {\n currentSet.delete(callback as any);\n if (currentSet.size === 0) {\n this.onUpdates.delete(executor);\n }\n }\n };\n }\n\n getCache(): Map<Core.Executor<unknown>, Core.Accessor<unknown>> {\n return this.cache;\n }\n\n getValueCache(): Map<Core.Executor<unknown>, unknown> {\n return this.valueCache;\n }\n\n getReactiveness(): Map<Core.Executor<unknown>, Set<Core.Executor<unknown>>> {\n return this.reactiveness;\n }\n}\n\nexport function createScope(): Core.Scope {\n return new Scope();\n}\n"],"mappings":"AAAO,IAA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MAAM,IAAI,MAAM,mBAAmB,EAGrC,IAAMD,EAAc,KAAK,UAAU,IAAIN,CAAQ,GAAK,IAAI,IACxD,YAAK,UAAU,IAAIA,EAAUM,CAAW,EACxCA,EAAY,IAAIC,CAAe,EAExB,IAAM,CACX,GAAI,KAAK,WACP,MAAM,IAAI,MAAM,mBAAmB,EAGrC,IAAMpC,EAAa,KAAK,UAAU,IAAI6B,CAAQ,EAC1C7B,IACFA,EAAW,OAAOoC,CAAe,EAC7BpC,EAAW,OAAS,GACtB,KAAK,UAAU,OAAO6B,CAAQ,EAGpC,CACF,CAEA,UAAgE,CAC9D,OAAO,KAAK,KACd,CAEA,eAAsD,CACpD,OAAO,KAAK,UACd,CAEA,iBAA4E,CAC1E,OAAO,KAAK,YACd,CACF,EAEO,SAASU,GAA0B,CACxC,OAAO,IAAI1C,CACb","names":["executorSymbol","metaSymbol","SchemaError","issues","createExecutor","factory","dependencies","metas","executor","executorSymbol","_","controller","lazyExecutor","reactiveExecutor","staticExecutor","isLazyExecutor","isReactiveExecutor","isStaticExecutor","isExecutor","input","provide","derive","pdependencies","pfactory","validate","schema","data","result","SchemaError","validateAsync","result_1","custom","value","meta","key","schema","_key","fn","value","metaSymbol","d","source","findValues","findValue","getValue","validate","executor","m","Scope","reactive","ref","currentSet","isExecutor","isLazyExecutor","staticResult","isReactiveExecutor","isStaticExecutor","item","result","key","target","resolvedResult","cached","cleanup","eager","accessor","requestor","cachedAccessor","factory","controller","resolve","force","promise","reject","dependencies","error","valueCached","soft","updateFn","cb","executor","updateSet","triggerTargets","current","cleanups","newValue","onUpdateSet","callback","affectedTargets","currents","createScope"]}
|
1
|
+
{"version":3,"file":"index.js","names":["executorSymbol: unique symbol","metaSymbol: unique symbol","issues: ReadonlyArray<StandardSchemaV1.Issue>","factory: Core.NoDependencyFn<T> | Core.DependentFn<T, unknown>","dependencies:\n | undefined\n | Core.UExecutor\n | Array<Core.UExecutor>\n | Record<string, Core.UExecutor>","metas: Meta.Meta[] | undefined","_: unknown","controller: Core.Controller","f","executor: Core.BaseExecutor<unknown>","executor: unknown","input: unknown","factory: Core.NoDependencyFn<T>","pdependencies:\n | Core.BaseExecutor<D>\n | Array<Core.BaseExecutor<D>>\n | Record<string, Core.BaseExecutor<unknown>>","pfactory:\n | Core.DependentFn<T, Core.InferOutput<D>>\n | Core.DependentFn<T, { [K in keyof D]: Core.InferOutput<D[K]> }>","e: Core.Executor<T>","v: T","schema: TSchema","data: unknown","key: string | symbol","schema: StandardSchemaV1<V>","value: V","d: Partial<V>","source: Meta.MetaContainer | Meta.Meta[] | undefined","meta: Meta.Meta<V>","meta","executor: Meta.MetaContainer | Meta.Meta[] | undefined","meta: Meta.MetaFn<V>","e: Core.UExecutor","preset","e: UE","ie: Core.UExecutor","ref: UE","ie:\n | undefined\n | Core.UExecutor\n | Core.UExecutor[]\n | Record<string, Core.UExecutor>","r: Record<string, unknown>","cleanup: Core.Cleanup","force: boolean","resolve","soft: boolean","updateFn: unknown | ((current: unknown) => unknown)","cb: (value: unknown) => void","executor: Core.Executor<T>","e: Core.Executor<T>","u: T | ((current: T) => T)","e: Core.Executor<unknown>","s: boolean","cb: (a: Core.Accessor<T>) => void | Promise<void>","ou"],"sources":["../src/types.ts","../src/executor.ts","../src/ssch.ts","../src/meta.ts","../src/scope.ts"],"sourcesContent":["export const executorSymbol: unique symbol = Symbol.for(\n \"@pumped-fn/core/executor\"\n);\nexport const metaSymbol: unique symbol = Symbol.for(\"@pumped-fn/core/meta\");\n\nexport interface StandardSchemaV1<Input = unknown, Output = Input> {\n readonly \"~standard\": StandardSchemaV1.Props<Input, Output>;\n}\n\nexport declare namespace StandardSchemaV1 {\n export interface Props<Input = unknown, Output = Input> {\n readonly version: 1;\n readonly vendor: string;\n readonly validate: (\n value: unknown\n ) => Result<Output> | Promise<Result<Output>>;\n readonly types?: Types<Input, Output> | undefined;\n }\n\n export type Result<Output> = SuccessResult<Output> | FailureResult;\n\n export interface SuccessResult<Output> {\n readonly value: Output;\n readonly issues?: undefined;\n }\n\n export interface FailureResult {\n readonly issues: ReadonlyArray<Issue>;\n }\n\n export interface Issue {\n readonly message: string;\n readonly path?: ReadonlyArray<PropertyKey | PathSegment> | undefined;\n }\n\n export interface PathSegment {\n readonly key: PropertyKey;\n }\n\n export interface Types<Input = unknown, Output = Input> {\n readonly input: Input;\n readonly output: Output;\n }\n\n export type InferInput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"input\"];\n\n export type InferOutput<Schema extends StandardSchemaV1> = NonNullable<\n Schema[\"~standard\"][\"types\"]\n >[\"output\"];\n}\n\nexport class SchemaError extends Error {\n public readonly issues: ReadonlyArray<StandardSchemaV1.Issue>;\n\n constructor(issues: ReadonlyArray<StandardSchemaV1.Issue>) {\n super(issues[0].message);\n this.name = \"SchemaError\";\n this.issues = issues;\n }\n}\n\nexport declare namespace Meta {\n export interface MetaContainer {\n metas: Meta[] | undefined;\n }\n\n export interface Meta<V = unknown> {\n readonly [metaSymbol]: true;\n readonly key: string | symbol;\n readonly schema: StandardSchemaV1<V>;\n readonly value: V;\n }\n\n export interface MetaFn<V> {\n (value: V): Meta<V>;\n readonly key: string | symbol;\n partial: <D extends Partial<V>>(d: D) => D;\n some: (source: MetaContainer | Meta[] | undefined) => V[];\n find: (source: MetaContainer | Meta[] | undefined) => V | undefined;\n get: (source: MetaContainer | Meta[] | undefined) => V;\n }\n}\n\nexport declare namespace Core {\n export type Output<T> = T | Promise<T>;\n\n export type NoDependencyFn<T> = (scope: Controller) => Output<T>;\n export type DependentFn<T, D> = (\n dependencies: D,\n scope: Controller\n ) => Output<T>;\n export type RecordLike = Record<string, unknown>;\n export type UExecutor = BaseExecutor<unknown>;\n\n export type Cleanup = () => void | Promise<void>;\n\n export type Controller = {\n cleanup: (cleanup: Cleanup) => void;\n release: () => Promise<void>;\n scope: Scope;\n };\n\n export type Kind = \"main\" | \"reactive\" | \"lazy\" | \"static\";\n\n export interface BaseExecutor<T> extends Meta.MetaContainer {\n [executorSymbol]: Kind;\n factory: NoDependencyFn<T> | DependentFn<T, unknown> | undefined;\n dependencies:\n | undefined\n | UExecutor\n | Array<UExecutor>\n | Record<string, UExecutor>;\n }\n\n export interface Executor<T> extends BaseExecutor<T> {\n [executorSymbol]: \"main\";\n factory: NoDependencyFn<T> | DependentFn<T, unknown>;\n\n /** Return an executor controller without resolving Executor */\n readonly lazy: Lazy<T>;\n\n /** Return an resolved executor, and mark the user to be reactived for future changes */\n readonly reactive: Reactive<T>;\n\n /** Return an resolved executor with its controller */\n readonly static: Static<T>;\n }\n\n export interface Reactive<T> extends BaseExecutor<T> {\n [executorSymbol]: \"reactive\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export interface Lazy<T> extends BaseExecutor<Accessor<T>> {\n [executorSymbol]: \"lazy\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export interface Static<T> extends BaseExecutor<Accessor<T>> {\n [executorSymbol]: \"static\";\n factory: undefined;\n readonly executor: Executor<T>;\n }\n\n export type PendingState<T> = { kind: \"pending\"; promise: Promise<T> };\n export type ResolvedState<T> = { kind: \"resolved\"; value: T };\n export type RejectedState = { kind: \"rejected\"; error: unknown };\n\n export type ResolveState<T> =\n | PendingState<T>\n | ResolvedState<T>\n | RejectedState;\n\n export interface Accessor<T> extends Meta.MetaContainer {\n lookup(): undefined | ResolveState<T>;\n\n get(): T;\n resolve(force?: boolean): Promise<T>;\n release(soft?: boolean): Promise<void>;\n update(updateFn: T | ((current: T) => T)): Promise<void>;\n subscribe(callback: (value: T) => void): Cleanup;\n }\n\n export interface Preset<T> {\n [executorSymbol]: \"preset\";\n executor: Executor<T>;\n value: T;\n }\n\n export type InferOutput<T> = T extends Executor<infer U> | Reactive<infer U>\n ? Awaited<U>\n : T extends Lazy<infer U> | Static<infer U>\n ? Accessor<Awaited<U>>\n : never;\n\n export interface Scope {\n accessor<T>(executor: Core.Executor<T>, eager?: boolean): Accessor<T>;\n\n resolve<T>(executor: Core.Executor<T>): Promise<T>;\n resolveAccessor<T>(executor: Core.Executor<T>): Promise<Accessor<T>>;\n\n update<T>(\n executor: Executor<T>,\n updateFn: T | ((current: T) => T)\n ): Promise<void>;\n\n release(executor: Executor<any>, soft?: boolean): Promise<void>;\n\n dispose(): Promise<void>;\n\n onUpdate<T>(\n executor: Executor<T>,\n callback: (accessor: Accessor<T>) => void\n ): Cleanup;\n // onRelease<T>(executor: Executor<T>, callback: () => void): () => void;\n }\n}\n","import { Core, executorSymbol, Meta } from \"./types\";\n\nfunction createExecutor<T>(\n factory: Core.NoDependencyFn<T> | Core.DependentFn<T, unknown>,\n dependencies:\n | undefined\n | Core.UExecutor\n | Array<Core.UExecutor>\n | Record<string, Core.UExecutor>,\n metas: Meta.Meta[] | undefined\n): Core.Executor<T> {\n const executor = {\n [executorSymbol]: \"main\",\n factory: (_: unknown, controller: Core.Controller) => {\n if (dependencies === undefined) {\n const f = factory as Core.NoDependencyFn<T>;\n return f(controller);\n }\n\n const f = factory as Core.DependentFn<T, unknown>;\n return f(_, controller);\n },\n dependencies,\n metas: metas,\n } as unknown as Core.Executor<T>;\n\n const lazyExecutor = {\n [executorSymbol]: \"lazy\",\n dependencies: undefined,\n executor,\n factory: undefined,\n metas: metas,\n } satisfies Core.Lazy<T>;\n\n const reactiveExecutor = {\n [executorSymbol]: \"reactive\",\n executor,\n factory: undefined,\n dependencies: undefined,\n metas: metas,\n } satisfies Core.Reactive<T>;\n\n const staticExecutor = {\n [executorSymbol]: \"static\",\n dependencies: undefined,\n factory: undefined,\n metas: metas,\n executor,\n } satisfies Core.Static<T>;\n\n Object.defineProperties(executor, {\n lazy: {\n value: lazyExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n reactive: {\n value: reactiveExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n static: {\n value: staticExecutor,\n writable: false,\n configurable: false,\n enumerable: false,\n },\n });\n\n return executor;\n}\n\nexport function isLazyExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Lazy<unknown> {\n return executor[executorSymbol] === \"lazy\";\n}\n\nexport function isReactiveExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Reactive<unknown> {\n return executor[executorSymbol] === \"reactive\";\n}\n\nexport function isStaticExecutor(\n executor: Core.BaseExecutor<unknown>\n): executor is Core.Static<unknown> {\n return executor[executorSymbol] === \"static\";\n}\n\nexport function isMainExecutor(\n executor: unknown\n): executor is Core.Executor<unknown> {\n return isExecutor(executor) && executor[executorSymbol] === \"main\";\n}\n\nexport function isExecutor<T>(input: unknown): input is Core.BaseExecutor<T> {\n return typeof input === \"object\" && input !== null && executorSymbol in input;\n}\n\nexport function provide<T>(\n factory: Core.NoDependencyFn<T>,\n ...metas: Meta.Meta[]\n): Core.Executor<T> {\n return createExecutor(factory, undefined, metas);\n}\n\nexport function derive<T, D extends Core.BaseExecutor<unknown>>(\n dependencies: D,\n factory: Core.DependentFn<T, Core.InferOutput<D>>,\n ...metas: Meta.Meta[]\n): Core.Executor<T>;\n\nexport function derive<\n T,\n D extends\n | ReadonlyArray<Core.BaseExecutor<unknown>>\n | Record<string, Core.BaseExecutor<unknown>>\n>(\n dependencies: { [K in keyof D]: D[K] },\n factory: Core.DependentFn<T, { [K in keyof D]: Core.InferOutput<D[K]> }>,\n ...metas: Meta.Meta[]\n): Core.Executor<T>;\n\nexport function derive<T, D>(\n pdependencies:\n | Core.BaseExecutor<D>\n | Array<Core.BaseExecutor<D>>\n | Record<string, Core.BaseExecutor<unknown>>,\n pfactory:\n | Core.DependentFn<T, Core.InferOutput<D>>\n | Core.DependentFn<T, { [K in keyof D]: Core.InferOutput<D[K]> }>,\n ...metas: Meta.Meta[]\n): Core.Executor<T> {\n return createExecutor(pfactory as any, pdependencies, metas);\n}\n\nexport function preset<T>(e: Core.Executor<T>, v: T): Core.Preset<T> {\n return {\n [executorSymbol]: \"preset\",\n value: v,\n executor: e,\n };\n}\n","import { SchemaError, StandardSchemaV1 } from \"./types\";\n\nexport function validate<TSchema extends StandardSchemaV1>(\n schema: TSchema,\n data: unknown\n): Awaited<StandardSchemaV1.InferOutput<TSchema>> {\n const result = schema[\"~standard\"].validate(data);\n\n if (\"then\" in result) {\n throw new Error(\"validating async is not supported\");\n }\n\n if (result.issues) {\n throw new SchemaError(result.issues);\n }\n return result.value as any;\n}\n\nexport async function validateAsync<TSchema extends StandardSchemaV1>(\n schema: TSchema,\n data: unknown\n): Promise<Awaited<StandardSchemaV1.InferOutput<TSchema>>> {\n const result = schema[\"~standard\"].validate(data);\n\n if (\"then\" in result) {\n const result_1 = await result;\n if (result_1.issues) {\n throw new SchemaError(result_1.issues);\n }\n return result_1.value as any;\n }\n\n if (result.issues) {\n throw new SchemaError(result.issues);\n }\n\n return Promise.resolve(result.value as any);\n}\n\nexport function custom<T>(): StandardSchemaV1<T, T> {\n return {\n \"~standard\": {\n vendor: \"pumped-fn\",\n version: 1,\n validate: (value) => {\n return { value: value as T };\n },\n },\n };\n}\n","import { validate } from \"./ssch\";\nimport { metaSymbol, StandardSchemaV1, type Meta } from \"./types\";\n\nexport const meta = <V>(\n key: string | symbol,\n schema: StandardSchemaV1<V>\n): Meta.MetaFn<V> => {\n const _key = typeof key === \"string\" ? Symbol(key) : key;\n\n const fn = (value: V) =>\n ({\n [metaSymbol]: true,\n key: _key,\n schema,\n value,\n } as unknown as Meta.MetaFn<V>);\n\n Object.defineProperty(fn, \"key\", {\n value: _key,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n Object.defineProperty(fn, metaSymbol, {\n value: true,\n configurable: false,\n enumerable: false,\n writable: false,\n });\n\n Object.defineProperties(fn, {\n partial: {\n value: (d: Partial<V>) => {\n return Object.assign({}, fn({} as V), d);\n },\n configurable: false,\n enumerable: false,\n writable: false,\n },\n some: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n findValues(source, fn as unknown as Meta.MetaFn<unknown>),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n find: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n findValue(source, fn as unknown as Meta.MetaFn<unknown>),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n get: {\n value: (source: Meta.MetaContainer | Meta.Meta[] | undefined) =>\n getValue(\n findValue(\n source,\n fn as unknown as Meta.MetaFn<unknown>\n ) as Meta.Meta<V>\n ),\n configurable: false,\n enumerable: false,\n writable: false,\n },\n });\n\n return fn as any;\n};\n\nexport function getValue<V>(meta: Meta.Meta<V>): Awaited<V> {\n return validate(meta.schema, meta.value);\n}\n\nexport function findValues<V = unknown>(\n executor: Meta.MetaContainer | Meta.Meta[] | undefined,\n meta: Meta.MetaFn<V>\n): V[] {\n if (!executor) return [];\n\n const metas = Array.isArray(executor) ? executor : executor.metas ?? [];\n\n const maybeMeta = metas.filter((m) => m.key === meta.key);\n return maybeMeta.map((m) => getValue(m as Meta.Meta<V>));\n}\n\nexport function findValue<V>(\n executor: Meta.MetaContainer | Meta.Meta[] | undefined,\n meta: Meta.MetaFn<V>\n): V | undefined {\n const values = findValues(executor, meta);\n return values.at(0);\n}\n","import {\n isLazyExecutor,\n isReactiveExecutor,\n isStaticExecutor,\n isMainExecutor,\n isExecutor,\n} from \"./executor\";\nimport { Core } from \"./types\";\n\ntype CacheEntry = {\n accessor: Core.Accessor<unknown>;\n value: Core.ResolveState<unknown>;\n};\n\ntype UE = Core.Executor<unknown>;\ntype OnUpdateFn = (accessor: Core.Accessor<unknown>) => void | Promise<void>;\n\nfunction getExecutor(e: Core.UExecutor): Core.Executor<unknown> {\n if (isLazyExecutor(e) || isReactiveExecutor(e) || isStaticExecutor(e)) {\n return e.executor;\n }\n\n return e as Core.Executor<unknown>;\n}\n\nclass Scope implements Core.Scope {\n private disposed: boolean = false;\n private cache: Map<UE, CacheEntry> = new Map();\n private cleanups = new Map<UE, Set<Core.Cleanup>>();\n private onUpdates = new Map<UE, Set<OnUpdateFn | UE>>();\n\n constructor(...presets: Core.Preset<unknown>[]) {\n for (const preset of presets) {\n const accessor = this[\"~makeAccessor\"](preset.executor);\n\n this.cache.set(preset.executor, {\n accessor,\n value: { kind: \"resolved\", value: preset.value },\n });\n }\n }\n\n private async \"~triggerCleanup\"(e: UE): Promise<void> {\n const cs = this.cleanups.get(e);\n if (cs) {\n for (const c of Array.from(cs.values()).reverse()) {\n await c();\n }\n }\n }\n\n private async \"~triggerUpdate\"(e: UE): Promise<void> {\n const ce = this.cache.get(e);\n if (!ce) {\n throw new Error(\"Executor is not yet resolved\");\n }\n\n const ou = this.onUpdates.get(e);\n if (ou) {\n for (const t of Array.from(ou.values())) {\n if (isMainExecutor(t)) {\n if (this.cleanups.has(t)) {\n this[\"~triggerCleanup\"](t);\n }\n\n const a = this.cache.get(t);\n await a!.accessor.resolve(true);\n\n if (this.onUpdates.has(t)) {\n await this[\"~triggerUpdate\"](t);\n }\n } else {\n await t(ce.accessor);\n }\n }\n }\n }\n\n private async \"~resolveExecutor\"(\n ie: Core.UExecutor,\n ref: UE\n ): Promise<unknown> {\n const e = getExecutor(ie);\n const a = this[\"~makeAccessor\"](e);\n\n if (isLazyExecutor(ie)) {\n return a;\n }\n\n if (isReactiveExecutor(ie)) {\n const c = this.onUpdates.get(ie.executor) ?? new Set();\n this.onUpdates.set(ie.executor, c);\n c.add(ref);\n }\n\n await a.resolve(false);\n if (isStaticExecutor(ie)) {\n return a;\n }\n\n return a.get();\n }\n\n private async \"~resolveDependencies\"(\n ie:\n | undefined\n | Core.UExecutor\n | Core.UExecutor[]\n | Record<string, Core.UExecutor>,\n ref: UE\n ): Promise<undefined | unknown | unknown[] | Record<string, unknown>> {\n if (ie === undefined) {\n return undefined;\n }\n\n if (isExecutor(ie)) {\n return this[\"~resolveExecutor\"](ie, ref);\n }\n\n if (Array.isArray(ie)) {\n return await Promise.all(\n ie.map((item) => this[\"~resolveDependencies\"](item, ref))\n );\n }\n\n const r: Record<string, unknown> = {};\n for (const k of Object.keys(ie)) {\n const t = ie[k];\n const rd = await this[\"~resolveDependencies\"](t, ref);\n\n r[k] = rd;\n }\n\n return r;\n }\n\n private \"~ensureNotDisposed\"(): void {\n if (this.disposed) {\n throw new Error(\"Scope is disposed\");\n }\n }\n\n private \"~makeAccessor\"(e: Core.UExecutor): Core.Accessor<unknown> {\n const requestor =\n isLazyExecutor(e) || isReactiveExecutor(e) || isStaticExecutor(e)\n ? e.executor\n : (e as UE);\n\n const cachedAccessor = this.cache.get(requestor);\n if (cachedAccessor) {\n return cachedAccessor.accessor;\n }\n\n const accessor = {} as Core.Accessor<unknown>;\n const factory = requestor.factory;\n const controller = {\n cleanup: (cleanup: Core.Cleanup) => {\n const currentSet = this.cleanups.get(requestor) ?? new Set();\n this.cleanups.set(requestor, currentSet);\n\n currentSet.add(cleanup);\n },\n release: async () => this.release(requestor),\n scope: this,\n };\n\n const resolve = (force: boolean): Promise<unknown> => {\n this[\"~ensureNotDisposed\"]();\n\n const entry = this.cache.get(requestor)!;\n const cached = entry?.value;\n\n if (cached && !force) {\n if (cached.kind === \"resolved\") {\n return Promise.resolve(cached.value);\n } else if (cached.kind === \"rejected\") {\n throw cached.error;\n } else {\n return cached.promise;\n }\n }\n\n const promise = new Promise((resolve, reject) => {\n this[\"~resolveDependencies\"](requestor.dependencies, requestor)\n .then((dependencies) => factory(dependencies as any, controller))\n .then((result) => {\n this.cache.set(requestor, {\n accessor,\n value: { kind: \"resolved\", value: result },\n });\n\n resolve(result);\n })\n .catch((error) => {\n this.cache.set(requestor, {\n accessor,\n value: { kind: \"rejected\", error },\n });\n\n reject(error);\n });\n });\n\n this.cache.set(requestor, {\n accessor,\n value: { kind: \"pending\", promise },\n });\n return promise;\n };\n\n return Object.assign(accessor, {\n get: () => {\n this[\"~ensureNotDisposed\"]();\n\n const cacheEntry = this.cache.get(requestor)?.value;\n\n if (!cacheEntry || cacheEntry.kind === \"pending\") {\n throw new Error(\"Executor is not resolved\");\n }\n\n if (cacheEntry.kind === \"rejected\") {\n throw cacheEntry.error;\n }\n\n return cacheEntry.value;\n },\n lookup: () => {\n this[\"~ensureNotDisposed\"]();\n\n const cacheEntry = this.cache.get(requestor);\n\n if (!cacheEntry) {\n return undefined;\n }\n\n return cacheEntry.value;\n },\n metas: e.metas,\n resolve,\n release: async (soft: boolean = false) => {\n this.release(requestor, soft);\n },\n update: (updateFn: unknown | ((current: unknown) => unknown)) => {\n return this.update(requestor, updateFn);\n },\n subscribe: (cb: (value: unknown) => void) => {\n this[\"~ensureNotDisposed\"]();\n return this.onUpdate(requestor, cb);\n },\n } satisfies Partial<Core.Accessor<unknown>>);\n }\n\n accessor<T>(executor: Core.Executor<T>): Core.Accessor<T> {\n this[\"~ensureNotDisposed\"]();\n return this[\"~makeAccessor\"](executor) as Core.Accessor<T>;\n }\n\n async resolve<T>(\n executor: Core.Executor<T>,\n force: boolean = false\n ): Promise<T> {\n this[\"~ensureNotDisposed\"]();\n const accessor = this[\"~makeAccessor\"](executor);\n await accessor.resolve(force);\n return accessor.get() as T;\n }\n\n async resolveAccessor<T>(\n executor: Core.Executor<T>,\n force: boolean = false\n ): Promise<Core.Accessor<T>> {\n this[\"~ensureNotDisposed\"]();\n const accessor = this[\"~makeAccessor\"](executor);\n await accessor.resolve(force);\n return accessor as Core.Accessor<T>;\n }\n\n async update<T>(\n e: Core.Executor<T>,\n u: T | ((current: T) => T)\n ): Promise<void> {\n this[\"~ensureNotDisposed\"]();\n this[\"~triggerCleanup\"](e);\n const accessor = this[\"~makeAccessor\"](e);\n\n if (typeof u === \"function\") {\n const fn = u as (current: T) => T;\n const n = fn(accessor.get() as T);\n this.cache.set(e, {\n accessor,\n value: { kind: \"resolved\", value: n },\n });\n } else {\n this.cache.set(e, {\n accessor,\n value: { kind: \"resolved\", value: u },\n });\n }\n\n await this[\"~triggerUpdate\"](e);\n }\n\n async release(e: Core.Executor<unknown>, s: boolean = false): Promise<void> {\n this[\"~ensureNotDisposed\"]();\n\n const ce = this.cache.get(e);\n if (!ce && !s) {\n throw new Error(\"Executor is not yet resolved\");\n }\n\n await this[\"~triggerCleanup\"](e);\n\n const ou = this.onUpdates.get(e);\n if (ou) {\n for (const t of Array.from(ou.values())) {\n if (isMainExecutor(t)) {\n await this.release(t, true);\n }\n }\n\n this.onUpdates.delete(e);\n }\n\n this.cache.delete(e);\n }\n\n async dispose(): Promise<void> {\n this[\"~ensureNotDisposed\"]();\n const currents = this.cache.keys();\n for (const current of currents) {\n await this.release(current, true);\n }\n\n this.disposed = true;\n this.cache.clear();\n this.cleanups.clear();\n }\n\n onUpdate<T>(\n e: Core.Executor<T>,\n cb: (a: Core.Accessor<T>) => void | Promise<void>\n ): Core.Cleanup {\n this[\"~ensureNotDisposed\"]();\n\n const ou = this.onUpdates.get(e) ?? new Set();\n this.onUpdates.set(e, ou);\n ou.add(cb as any);\n\n return () => {\n this[\"~ensureNotDisposed\"]();\n\n const ou = this.onUpdates.get(e);\n if (ou) {\n ou.delete(cb as any);\n if (ou.size === 0) {\n this.onUpdates.delete(e);\n }\n }\n };\n }\n}\n\nexport function createScope(...presets: Core.Preset<unknown>[]): Core.Scope {\n return new Scope(...presets);\n}\n"],"mappings":";AAAA,MAAaA,iBAAgC,OAAO,IAClD,2BACD;AACD,MAAaC,aAA4B,OAAO,IAAI,uBAAuB;AAkD3E,IAAa,cAAb,cAAiC,MAAM;CACrC,AAAgB;CAEhB,YAAYC,QAA+C;AACzD,QAAM,OAAO,GAAG,QAAQ;AACxB,OAAK,OAAO;AACZ,OAAK,SAAS;CACf;AACF;;;;AC3DD,SAAS,eACPC,SACAC,cAKAC,OACkB;CAClB,MAAM,WAAW;GACd,iBAAiB;EAClB,SAAS,CAACC,GAAYC,eAAgC;AACpD,OAAI,yBAA4B;IAC9B,MAAMC,MAAI;AACV,WAAO,IAAE,WAAW;GACrB;GAED,MAAM,IAAI;AACV,UAAO,EAAE,GAAG,WAAW;EACxB;EACD;EACO;CACR;CAED,MAAM,eAAe;GAClB,iBAAiB;EAClB;EACA;EACA;EACO;CACR;CAED,MAAM,mBAAmB;GACtB,iBAAiB;EAClB;EACA;EACA;EACO;CACR;CAED,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": "0.5.
|
3
|
+
"version": "0.5.41",
|
4
4
|
"description": "Enhanced function utilities for TypeScript",
|
5
5
|
"type": "module",
|
6
6
|
"main": "./dist/index.js",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"CHANGELOG.md"
|
21
21
|
],
|
22
22
|
"scripts": {
|
23
|
-
"build": "
|
23
|
+
"build": "tsdown",
|
24
24
|
"test": "vitest run",
|
25
25
|
"test:watch": "vitest watch",
|
26
26
|
"typecheck": "tsc --noEmit",
|
@@ -29,9 +29,8 @@
|
|
29
29
|
"release": "pnpm build && pnpm pump && npm publish --access public"
|
30
30
|
},
|
31
31
|
"devDependencies": {
|
32
|
-
"
|
33
|
-
"
|
34
|
-
"vitest": "^1.0.0"
|
32
|
+
"typescript": "^5.8.3",
|
33
|
+
"vitest": "^1.6.1"
|
35
34
|
},
|
36
35
|
"engines": {
|
37
36
|
"node": ">=18"
|
@@ -57,5 +56,8 @@
|
|
57
56
|
"publish": true
|
58
57
|
}
|
59
58
|
},
|
60
|
-
"license": "MIT"
|
59
|
+
"license": "MIT",
|
60
|
+
"dependencies": {
|
61
|
+
"tsdown": "^0.11.13"
|
62
|
+
}
|
61
63
|
}
|