apps 0.0.1-beta.7 → 0.0.1-beta.70
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 +25 -22
- package/framework-reference.json +1 -1
- package/js/{chunk-UESPOTUI.js → chunk-2YSTJMBD.js} +899 -190
- package/js/{chunk-RJDDBDSN.js → chunk-3CVQ3VPP.js} +762 -171
- package/js/chunk-3R3KFCDU.js +426 -0
- package/js/{chunk-FL2QR3XW.js → chunk-4NCIPADO.js} +326 -69
- package/js/chunk-5FHWNLCI.js +88 -0
- package/js/{chunk-M3B3DE4K.js → chunk-74YVXBKY.js} +463 -218
- package/js/chunk-7LMU3ER3.js +274 -0
- package/js/chunk-CDXQDN7W.js +92 -0
- package/js/{chunk-RFVIONFX.js → chunk-ECCWT5GJ.js} +79 -41
- package/js/{chunk-UK573G7W.js → chunk-EOPQ727L.js} +87 -51
- package/js/{chunk-27F7W2LG.js → chunk-H2CJWXA3.js} +2 -2
- package/js/{chunk-JU7VHODU.js → chunk-H72MEDMN.js} +65 -10
- package/js/{chunk-CDL5PM2Q.js → chunk-IFJU5SYQ.js} +19082 -18402
- package/js/{chunk-VFZKSM3T.js → chunk-JPEUKEV4.js} +3 -3
- package/js/{chunk-WLE7WX2U.js → chunk-JW5LYSER.js} +2262 -474
- package/js/{chunk-5T57N25Q.js → chunk-KGCTYL2S.js} +511 -63
- package/js/{chunk-KUMBKVJD.js → chunk-KLYSEHUD.js} +2 -2
- package/js/chunk-M5OLYYNU.js +347 -0
- package/js/chunk-MHB7IFG7.js +49 -0
- package/js/chunk-OD3KFKZD.js +1617 -0
- package/js/{chunk-57RKNWL2.js → chunk-PD6I2SDG.js} +4 -4
- package/js/{chunk-NKLWZJLE.js → chunk-RUP4JMKO.js} +25 -14
- package/js/{chunk-IJX4CYZO.js → chunk-TUMGL2OC.js} +228 -264
- package/js/{chunk-72JNVHPK.js → chunk-WDIVWSDG.js} +4 -3
- package/js/{chunk-CMYUWAX7.js → chunk-WGQP62EG.js} +126 -31
- package/js/{chunk-IPI4MFSN.js → chunk-XBG7HHXC.js} +2 -2
- package/js/{chunk-Z5M2LQOZ.js → chunk-ZEJ3IKEC.js} +67 -55
- package/js/chunk-ZR7QAG67.js +171 -0
- package/js/client.js +142 -94
- package/js/contracts.js +125 -26
- package/js/effect.js +19 -19
- package/js/{es-APDZKREY.js → es-DIULA3ZF.js} +62 -1659
- package/js/graphql.js +50 -40
- package/js/host.js +83 -58
- package/js/index.js +131 -46
- package/js/mcp/effect.js +23 -21
- package/js/mcp/stdio.js +44 -34
- package/js/mcp.js +76 -53
- package/js/openapi.js +4063 -1359
- package/js/react.js +2 -3
- package/js/skills/effect.js +6 -3
- package/js/skills.js +208 -81
- package/js/storage/facet.js +1 -540
- package/js/ui/auth/contracts.js +2 -2
- package/js/ui/auth.js +5 -5
- package/js/ui/contracts.js +5 -4
- package/js/ui/serving.js +8517 -214
- package/package.json +3 -4
- package/runtime.json +1 -1
- package/types/app-cache/src/contracts/cache.d.ts +2 -0
- package/types/app-cache/src/index.d.ts +10 -1
- package/types/apps/src/contracts/api-response-error.d.ts +4 -0
- package/types/apps/src/contracts/app.d.ts +7 -3
- package/types/apps/src/contracts/cache.d.ts +20 -0
- package/types/apps/src/contracts/context.d.ts +19 -11
- package/types/apps/src/contracts/elicitation.d.ts +6 -6
- package/types/apps/src/contracts/events.d.ts +93 -0
- package/types/apps/src/contracts/failure.d.ts +30 -1
- package/types/apps/src/contracts/graphql.d.ts +2 -1
- package/types/apps/src/contracts/host.d.ts +641 -16
- package/types/apps/src/contracts/live.d.ts +2 -0
- package/types/apps/src/contracts/mcp.d.ts +80 -10
- package/types/apps/src/contracts/network.d.ts +120 -0
- package/types/apps/src/contracts/openapi-compile.d.ts +82 -3
- package/types/apps/src/contracts/openapi.d.ts +41 -9
- package/types/apps/src/contracts/operations.d.ts +8 -4
- package/types/apps/src/contracts/placement.d.ts +102 -0
- package/types/apps/src/contracts/protocol-version.d.ts +2 -2
- package/types/apps/src/contracts/protocols/1.d.ts +733 -81
- package/types/apps/src/contracts/protocols/10.d.ts +1450 -0
- package/types/apps/src/contracts/protocols/2.d.ts +69 -26
- package/types/apps/src/contracts/protocols/3.d.ts +133 -33
- package/types/apps/src/contracts/protocols/4.d.ts +122 -45
- package/types/apps/src/contracts/protocols/5.d.ts +157 -47
- package/types/apps/src/contracts/protocols/6.d.ts +1629 -0
- package/types/apps/src/contracts/protocols/7.d.ts +1785 -0
- package/types/apps/src/contracts/protocols/8.d.ts +1182 -0
- package/types/apps/src/contracts/protocols/9.d.ts +1104 -0
- package/types/apps/src/contracts/protocols/current.d.ts +3842 -0
- package/types/apps/src/contracts/protocols/oauth-6.d.ts +74 -0
- package/types/apps/src/contracts/protocols/oauth.d.ts +134 -0
- package/types/apps/src/contracts/provider-error.d.ts +9 -0
- package/types/apps/src/contracts/provider.d.ts +90 -6
- package/types/apps/src/contracts/skills.d.ts +50 -13
- package/types/apps/src/contracts/sql.d.ts +63 -0
- package/types/apps/src/contracts/ui.d.ts +19 -1
- package/types/apps/src/contracts/workflows.d.ts +6 -0
- package/types/apps/src/facet.d.ts +4 -5
- package/types/apps/src/host.d.ts +5 -0
- package/types/apps/src/implementation/account-router.d.ts +4 -3
- package/types/apps/src/implementation/authoring.d.ts +25 -5
- package/types/apps/src/implementation/browser-scripts.gen.d.ts +6 -0
- package/types/apps/src/implementation/cache.d.ts +4 -0
- package/types/apps/src/implementation/catalog-cache.d.ts +35 -4
- package/types/apps/src/implementation/elicitation.d.ts +18 -15
- package/types/apps/src/implementation/events.d.ts +59 -0
- package/types/apps/src/implementation/failure-detail.d.ts +25 -3
- package/types/apps/src/implementation/graphql-catalog.d.ts +3 -3
- package/types/apps/src/implementation/graphql.d.ts +4 -3
- package/types/apps/src/implementation/input-problems.d.ts +6 -2
- package/types/apps/src/implementation/invocation-timing.d.ts +16 -0
- package/types/apps/src/implementation/live.d.ts +2 -2
- package/types/apps/src/implementation/mcp-call.d.ts +6 -5
- package/types/apps/src/implementation/mcp-catalog.d.ts +6 -4
- package/types/apps/src/implementation/mcp-client.d.ts +17 -9
- package/types/apps/src/implementation/mcp-stdio.d.ts +1 -1
- package/types/apps/src/implementation/mcp-tools.d.ts +2 -1
- package/types/apps/src/implementation/mcp.d.ts +20 -9
- package/types/apps/src/implementation/network.d.ts +16 -0
- package/types/apps/src/implementation/openapi-compile.d.ts +26 -6
- package/types/apps/src/implementation/openapi-document.d.ts +46 -19
- package/types/apps/src/implementation/openapi-names.d.ts +9 -4
- package/types/apps/src/implementation/openapi-request.d.ts +10 -2
- package/types/apps/src/implementation/openapi-source.d.ts +18 -0
- package/types/apps/src/implementation/openapi-upgrade.d.ts +4 -0
- package/types/apps/src/implementation/operations.d.ts +17 -2
- package/types/apps/src/implementation/optimistic.d.ts +1 -1
- package/types/apps/src/implementation/placement.d.ts +60 -0
- package/types/apps/src/implementation/protocol-operations.d.ts +3 -0
- package/types/apps/src/implementation/provider-error.d.ts +28 -1
- package/types/apps/src/implementation/provider.d.ts +18 -3
- package/types/apps/src/implementation/query-commit.d.ts +1 -1
- package/types/apps/src/implementation/router-catalog.d.ts +11 -13
- package/types/apps/src/implementation/router.d.ts +16 -5
- package/types/apps/src/implementation/runtime-yield.d.ts +7 -0
- package/types/apps/src/implementation/schema.d.ts +90 -10
- package/types/apps/src/implementation/skills.d.ts +18 -24
- package/types/apps/src/implementation/sql.d.ts +71 -0
- package/types/apps/src/implementation/ui-account-notice.d.ts +9 -0
- package/types/apps/src/implementation/ui-auth.d.ts +1 -1
- package/types/apps/src/implementation/ui-client.d.ts +2 -2
- package/types/apps/src/implementation/ui-document.d.ts +5 -0
- package/types/apps/src/implementation/ui-errors.d.ts +1 -1
- package/types/apps/src/implementation/ui-serving.d.ts +11 -5
- package/types/apps/src/implementation/ui-watch.d.ts +1 -1
- package/types/apps/src/implementation/upstream-error.d.ts +7 -0
- package/types/apps/src/implementation/webhooks.d.ts +1 -1
- package/types/apps/src/implementation/workflows.d.ts +1 -1
- package/types/apps/src/index.d.ts +55 -13
- package/types/apps/src/mcp.d.ts +20 -1
- package/types/apps/src/openapi.d.ts +1 -1
- package/types/apps/src/react.d.ts +1 -1
- package/types/apps/src/skills.d.ts +10 -8
- package/types/telemetry/src/app-records.d.ts +42 -0
- package/types/telemetry/src/browser-operations.d.ts +7 -4
- package/types/telemetry/src/browser.d.ts +8 -3
- package/types/telemetry/src/config.d.ts +2 -2
- package/types/telemetry/src/index.d.ts +2 -1
- package/types/telemetry/src/layer.d.ts +2 -2
- package/types/telemetry/src/measurements.d.ts +1 -1
- package/types/telemetry/src/ownership.d.ts +56 -0
- package/types/telemetry/src/recorded-failure.d.ts +29 -0
- package/types/telemetry/src/relay.d.ts +16 -6
- package/types/telemetry/src/span-attributes.d.ts +17 -1
- package/types/telemetry/src/transport.d.ts +8 -1
- package/types/utils/src/api-error.d.ts +55 -0
- package/types/utils/src/connection-failure.d.ts +33 -0
- package/types/utils/src/recorded-message.d.ts +18 -0
- package/types/utils/src/user-facing-error.d.ts +83 -0
- package/js/chunk-MKWZPDR6.js +0 -63
- package/js/chunk-N7YDVXYJ.js +0 -186
- package/js/chunk-OCYUEU47.js +0 -224
- package/js/chunk-PJJ24GU7.js +0 -877
- package/js/chunk-PZB6T6KU.js +0 -19
- package/js/chunk-R3EV5FTO.js +0 -97
- package/js/chunk-YXQHV65J.js +0 -242
- package/js/chunk-ZQINWV4W.js +0 -630
- package/types/app-data/src/implementation/cursor.d.ts +0 -10
- package/types/app-data/src/implementation/index-key.d.ts +0 -7
- package/types/app-data/src/implementation/promise.d.ts +0 -68
- package/types/app-data/src/implementation/range.d.ts +0 -8
- package/types/app-data/src/implementation/schema.d.ts +0 -18
- package/types/app-data/src/implementation/sqlite.d.ts +0 -11
- package/types/app-data/src/index.d.ts +0 -4
- package/types/apps/src/contracts/storage.d.ts +0 -68
- package/types/apps/src/implementation/storage.d.ts +0 -15
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Reactivity,
|
|
3
|
-
invalidate,
|
|
4
|
-
layer,
|
|
5
|
-
mutation
|
|
6
|
-
} from "./chunk-PJJ24GU7.js";
|
|
7
1
|
import {
|
|
8
2
|
Boolean,
|
|
9
3
|
Cause,
|
|
@@ -43,6 +37,7 @@ import {
|
|
|
43
37
|
constTrue,
|
|
44
38
|
constVoid,
|
|
45
39
|
constant,
|
|
40
|
+
context,
|
|
46
41
|
contextWith,
|
|
47
42
|
declareConstructor,
|
|
48
43
|
decodeEffect,
|
|
@@ -53,7 +48,7 @@ import {
|
|
|
53
48
|
effect,
|
|
54
49
|
empty,
|
|
55
50
|
empty2,
|
|
56
|
-
empty3,
|
|
51
|
+
empty6 as empty3,
|
|
57
52
|
empty7 as empty4,
|
|
58
53
|
encodeEffect,
|
|
59
54
|
encodeExit,
|
|
@@ -65,6 +60,7 @@ import {
|
|
|
65
60
|
fail4 as fail3,
|
|
66
61
|
failCause,
|
|
67
62
|
failCause2,
|
|
63
|
+
failCauseUnsafe,
|
|
68
64
|
filter,
|
|
69
65
|
filter2,
|
|
70
66
|
filterInterruptors,
|
|
@@ -75,18 +71,21 @@ import {
|
|
|
75
71
|
flatMap2,
|
|
76
72
|
flatMapEager,
|
|
77
73
|
flatMapNullishOr,
|
|
74
|
+
flow,
|
|
78
75
|
forkDetach,
|
|
79
76
|
fromInputUnsafe,
|
|
80
77
|
fromJsonString,
|
|
78
|
+
fromQueue,
|
|
81
79
|
gen,
|
|
82
80
|
get,
|
|
83
|
-
get2,
|
|
81
|
+
get3 as get2,
|
|
84
82
|
get5 as get3,
|
|
85
83
|
getCurrent,
|
|
86
84
|
getOrElse,
|
|
87
85
|
getOrNull,
|
|
88
86
|
getOrThrowWith,
|
|
89
87
|
getOrUndefined,
|
|
88
|
+
getOrUndefined2,
|
|
90
89
|
getStackTraceLimit,
|
|
91
90
|
getSuccess,
|
|
92
91
|
getUnsafe,
|
|
@@ -109,6 +108,7 @@ import {
|
|
|
109
108
|
joinAll,
|
|
110
109
|
lastNonEmpty,
|
|
111
110
|
link,
|
|
111
|
+
make3 as make,
|
|
112
112
|
makeCompositeAtKey,
|
|
113
113
|
makeMemoMapUnsafe,
|
|
114
114
|
makeUnsafe2 as makeUnsafe,
|
|
@@ -124,19 +124,22 @@ import {
|
|
|
124
124
|
never,
|
|
125
125
|
none,
|
|
126
126
|
offerUnsafe,
|
|
127
|
+
onExit,
|
|
127
128
|
pipe,
|
|
128
129
|
pipeArguments,
|
|
129
130
|
provide2 as provide,
|
|
130
131
|
provideMerge,
|
|
131
|
-
|
|
132
|
+
provideService,
|
|
133
|
+
remove3 as remove,
|
|
132
134
|
runCallbackWith,
|
|
133
135
|
runForEachArray,
|
|
134
136
|
runForkWith,
|
|
137
|
+
runIn,
|
|
135
138
|
runSync,
|
|
136
139
|
runSyncWith,
|
|
137
140
|
scope,
|
|
138
141
|
scopedWith,
|
|
139
|
-
set,
|
|
142
|
+
set4 as set,
|
|
140
143
|
set5 as set2,
|
|
141
144
|
some,
|
|
142
145
|
squash,
|
|
@@ -148,6 +151,7 @@ import {
|
|
|
148
151
|
symbol,
|
|
149
152
|
symbol2,
|
|
150
153
|
sync2 as sync,
|
|
154
|
+
tap,
|
|
151
155
|
toCodecJson,
|
|
152
156
|
toMillis,
|
|
153
157
|
toPull,
|
|
@@ -158,12 +162,12 @@ import {
|
|
|
158
162
|
void_2,
|
|
159
163
|
whileLoop,
|
|
160
164
|
zipRight
|
|
161
|
-
} from "./chunk-
|
|
165
|
+
} from "./chunk-IFJU5SYQ.js";
|
|
162
166
|
import {
|
|
163
167
|
__export
|
|
164
168
|
} from "./chunk-CZ7CSFO4.js";
|
|
165
169
|
|
|
166
|
-
// ../../node_modules/.bun/effect@
|
|
170
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/AsyncResult.js
|
|
167
171
|
var AsyncResult_exports = {};
|
|
168
172
|
__export(AsyncResult_exports, {
|
|
169
173
|
Schema: () => Schema,
|
|
@@ -276,7 +280,7 @@ var failureWithPrevious = (cause2, options) => failure(cause2, {
|
|
|
276
280
|
});
|
|
277
281
|
var fail4 = (error2, options) => failure(fail(error2), options);
|
|
278
282
|
var failWithPrevious = (error2, options) => failureWithPrevious(fail(error2), options);
|
|
279
|
-
var waiting = (self, options) => {
|
|
283
|
+
var waiting = /* @__PURE__ */ dual((args) => isAsyncResult(args[0]), (self, options) => {
|
|
280
284
|
if (self.waiting) {
|
|
281
285
|
return options?.touch ? touch(self) : self;
|
|
282
286
|
}
|
|
@@ -287,7 +291,7 @@ var waiting = (self, options) => {
|
|
|
287
291
|
result.timestamp = Date.now();
|
|
288
292
|
}
|
|
289
293
|
return result;
|
|
290
|
-
};
|
|
294
|
+
});
|
|
291
295
|
var touch = (result) => {
|
|
292
296
|
if (isSuccess(result)) {
|
|
293
297
|
return success(result.value, {
|
|
@@ -296,7 +300,7 @@ var touch = (result) => {
|
|
|
296
300
|
}
|
|
297
301
|
return result;
|
|
298
302
|
};
|
|
299
|
-
var replacePrevious = (self, previous) => {
|
|
303
|
+
var replacePrevious = /* @__PURE__ */ dual(2, (self, previous) => {
|
|
300
304
|
if (self._tag === "Failure") {
|
|
301
305
|
return failureWithPrevious(self.cause, {
|
|
302
306
|
previous,
|
|
@@ -304,7 +308,7 @@ var replacePrevious = (self, previous) => {
|
|
|
304
308
|
});
|
|
305
309
|
}
|
|
306
310
|
return self;
|
|
307
|
-
};
|
|
311
|
+
});
|
|
308
312
|
var value = (self) => {
|
|
309
313
|
if (self._tag === "Success") {
|
|
310
314
|
return some(self.value);
|
|
@@ -600,7 +604,7 @@ var Schema = (options) => {
|
|
|
600
604
|
});
|
|
601
605
|
};
|
|
602
606
|
|
|
603
|
-
// ../../node_modules/.bun/effect@
|
|
607
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/AtomRegistry.js
|
|
604
608
|
var AtomRegistry_exports = {};
|
|
605
609
|
__export(AtomRegistry_exports, {
|
|
606
610
|
AtomRegistry: () => AtomRegistry,
|
|
@@ -610,27 +614,27 @@ __export(AtomRegistry_exports, {
|
|
|
610
614
|
batchState: () => batchState,
|
|
611
615
|
getResult: () => getResult,
|
|
612
616
|
isAtomRegistry: () => isAtomRegistry,
|
|
613
|
-
layer: () =>
|
|
617
|
+
layer: () => layer,
|
|
614
618
|
layerOptions: () => layerOptions,
|
|
615
|
-
make: () =>
|
|
619
|
+
make: () => make2,
|
|
616
620
|
mount: () => mount,
|
|
617
621
|
toStream: () => toStream,
|
|
618
622
|
toStreamResult: () => toStreamResult
|
|
619
623
|
});
|
|
620
624
|
var TypeId2 = "~effect/reactivity/AtomRegistry";
|
|
621
625
|
var isAtomRegistry = (u) => hasProperty(u, TypeId2);
|
|
622
|
-
var
|
|
626
|
+
var make2 = (options) => new RegistryImpl(options?.initialValues, options?.scheduleTask, options?.timeoutResolution, options?.defaultIdleTTL);
|
|
623
627
|
var AtomRegistry = /* @__PURE__ */ Service(TypeId2);
|
|
624
628
|
var layerOptions = (options) => effect(AtomRegistry, gen(function* () {
|
|
625
629
|
const scope2 = yield* scope;
|
|
626
|
-
const registry =
|
|
630
|
+
const registry = make2({
|
|
627
631
|
...options,
|
|
628
632
|
scheduleTask: options?.scheduleTask
|
|
629
633
|
});
|
|
630
634
|
yield* addFinalizer(scope2, sync(() => registry.dispose()));
|
|
631
635
|
return registry;
|
|
632
636
|
}));
|
|
633
|
-
var
|
|
637
|
+
var layer = /* @__PURE__ */ layerOptions();
|
|
634
638
|
var toStream = /* @__PURE__ */ dual(2, (self, atom) => callback2((queue) => suspend(() => {
|
|
635
639
|
const fiber = getCurrent();
|
|
636
640
|
const scope2 = getUnsafe(fiber.context, Scope);
|
|
@@ -660,9 +664,21 @@ var mount = /* @__PURE__ */ dual(2, (self, atom) => acquireRelease(sync(() => se
|
|
|
660
664
|
var constImmediate = {
|
|
661
665
|
immediate: true
|
|
662
666
|
};
|
|
663
|
-
var
|
|
664
|
-
|
|
667
|
+
var invoke = (f) => {
|
|
668
|
+
f();
|
|
665
669
|
};
|
|
670
|
+
var noFailure = {};
|
|
671
|
+
function runAll(items, f) {
|
|
672
|
+
let failure2 = noFailure;
|
|
673
|
+
for (const item of items) {
|
|
674
|
+
try {
|
|
675
|
+
f(item);
|
|
676
|
+
} catch (error2) {
|
|
677
|
+
if (failure2 === noFailure) failure2 = error2;
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
if (failure2 !== noFailure) throw failure2;
|
|
681
|
+
}
|
|
666
682
|
var SerializableTypeId = "~effect-atom/atom/Atom/Serializable";
|
|
667
683
|
var atomKey = (atom) => SerializableTypeId in atom ? atom[SerializableTypeId].key : atom;
|
|
668
684
|
var RegistryImpl = class {
|
|
@@ -733,6 +749,8 @@ var RegistryImpl = class {
|
|
|
733
749
|
const node = this.ensureNode(atom);
|
|
734
750
|
if (options?.immediate) {
|
|
735
751
|
f(node.value());
|
|
752
|
+
} else if (node.state === NodeState.stale) {
|
|
753
|
+
node.value();
|
|
736
754
|
}
|
|
737
755
|
const remove2 = node.subscribe(function() {
|
|
738
756
|
f(node._value);
|
|
@@ -853,26 +871,35 @@ var RegistryImpl = class {
|
|
|
853
871
|
sweepBucket(bucket) {
|
|
854
872
|
const nodes = this.timeoutBuckets.get(bucket)[0];
|
|
855
873
|
this.timeoutBuckets.delete(bucket);
|
|
856
|
-
nodes.
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
874
|
+
runAll(nodes, this.removeIdleNode);
|
|
875
|
+
}
|
|
876
|
+
removeIdleNode = (node) => {
|
|
877
|
+
this.nodeTimeoutBucket.delete(node);
|
|
878
|
+
if (!node.canBeRemoved) return;
|
|
879
|
+
this.nodes.delete(atomKey(node.atom));
|
|
880
|
+
this.onNodeRemoved?.(node);
|
|
881
|
+
this.#currentSweepTTL = node.atom.idleTTL ?? this.defaultIdleTTL;
|
|
882
|
+
try {
|
|
862
883
|
node.remove();
|
|
884
|
+
} finally {
|
|
863
885
|
this.#currentSweepTTL = null;
|
|
864
|
-
}
|
|
865
|
-
}
|
|
886
|
+
}
|
|
887
|
+
};
|
|
866
888
|
reset() {
|
|
867
889
|
this.timeoutBuckets.forEach(([, handle]) => clearTimeout(handle));
|
|
868
890
|
this.timeoutBuckets.clear();
|
|
869
891
|
this.nodeTimeoutBucket.clear();
|
|
870
|
-
this.nodes.
|
|
871
|
-
node.remove();
|
|
872
|
-
this.onNodeRemoved?.(node);
|
|
873
|
-
});
|
|
892
|
+
const nodes = Array.from(this.nodes.values());
|
|
874
893
|
this.nodes.clear();
|
|
894
|
+
for (const node of nodes) {
|
|
895
|
+
node.state = NodeState.removed;
|
|
896
|
+
}
|
|
897
|
+
runAll(nodes, this.destroyNode);
|
|
875
898
|
}
|
|
899
|
+
destroyNode = (node) => {
|
|
900
|
+
node.remove();
|
|
901
|
+
this.onNodeRemoved?.(node);
|
|
902
|
+
};
|
|
876
903
|
dispose() {
|
|
877
904
|
this.disposed = true;
|
|
878
905
|
this.reset();
|
|
@@ -904,13 +931,15 @@ var NodeImpl = class {
|
|
|
904
931
|
lifetime;
|
|
905
932
|
writeContext;
|
|
906
933
|
preserveInitialValueOnBuild = false;
|
|
934
|
+
invalidatedDuringBuild = false;
|
|
935
|
+
failed = false;
|
|
936
|
+
// Every parent that holds this node as a child. A stale node keeps the
|
|
937
|
+
// parents of its last build, so they are not released and their next change
|
|
938
|
+
// still reaches it. A build drops the parents it did not read.
|
|
907
939
|
parents = /* @__PURE__ */ new Set();
|
|
908
|
-
previousParents;
|
|
909
940
|
children = /* @__PURE__ */ new Set();
|
|
910
941
|
listeners = /* @__PURE__ */ new Set();
|
|
911
|
-
|
|
912
|
-
building = false;
|
|
913
|
-
invalidatedDuringBuild = false;
|
|
942
|
+
observedChildren = 0;
|
|
914
943
|
currentState() {
|
|
915
944
|
switch (this.state) {
|
|
916
945
|
case NodeState.uninitialized:
|
|
@@ -926,33 +955,108 @@ var NodeImpl = class {
|
|
|
926
955
|
get canBeRemoved() {
|
|
927
956
|
return !this.atom.keepAlive && this.listeners.size === 0 && this.children.size === 0 && this.state !== 0;
|
|
928
957
|
}
|
|
958
|
+
get building() {
|
|
959
|
+
return this.lifetime !== void 0 && this.lifetime.reads !== void 0;
|
|
960
|
+
}
|
|
961
|
+
// An observed node is rebuilt as soon as it goes stale, because something
|
|
962
|
+
// waits for its value without reading it. The count spares walking the
|
|
963
|
+
// children on every invalidation.
|
|
964
|
+
get isObserved() {
|
|
965
|
+
return !this.atom.lazy || this.listeners.size > 0 || this.observedChildren > 0;
|
|
966
|
+
}
|
|
967
|
+
childObserved(delta) {
|
|
968
|
+
const observed = this.isObserved;
|
|
969
|
+
this.observedChildren += delta;
|
|
970
|
+
if (observed !== this.isObserved) {
|
|
971
|
+
this.observedChanged(delta);
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
observedChanged(delta) {
|
|
975
|
+
for (const parent of this.parents) {
|
|
976
|
+
parent.childObserved(delta);
|
|
977
|
+
}
|
|
978
|
+
}
|
|
929
979
|
_value = void 0;
|
|
930
980
|
value() {
|
|
931
|
-
|
|
932
|
-
this.
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
981
|
+
while ((this.state & NodeFlags.waitingForValue) !== 0) {
|
|
982
|
+
this.build();
|
|
983
|
+
}
|
|
984
|
+
return this._value;
|
|
985
|
+
}
|
|
986
|
+
build() {
|
|
987
|
+
this.disposeLifetime();
|
|
988
|
+
this.invalidatedDuringBuild = false;
|
|
989
|
+
const lifetime = makeLifetime(this);
|
|
990
|
+
this.lifetime = lifetime;
|
|
991
|
+
let value2;
|
|
992
|
+
let read = false;
|
|
993
|
+
try {
|
|
994
|
+
value2 = this.atom.read(lifetime);
|
|
995
|
+
read = true;
|
|
996
|
+
} finally {
|
|
997
|
+
const reads = lifetime.reads;
|
|
998
|
+
lifetime.reads = void 0;
|
|
999
|
+
if (this.lifetime === lifetime) {
|
|
1000
|
+
this.dropUnread(reads);
|
|
1001
|
+
if (!read) this.fail();
|
|
943
1002
|
}
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
1003
|
+
}
|
|
1004
|
+
if (this.lifetime === lifetime && (this.state & NodeFlags.waitingForValue) !== 0) {
|
|
1005
|
+
if (this.preserveInitialValueOnBuild) {
|
|
1006
|
+
this.preserveInitialValueOnBuild = false;
|
|
1007
|
+
this.failed = false;
|
|
1008
|
+
this.state = NodeState.valid;
|
|
1009
|
+
} else {
|
|
1010
|
+
this.setValue(value2);
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
if (lifetime.failure !== noFailure) throw lifetime.failure;
|
|
1014
|
+
}
|
|
1015
|
+
// A build that threw leaves its dependents holding, or reading, a value
|
|
1016
|
+
// this node no longer stands behind, so they go stale and rebuild when
|
|
1017
|
+
// pulled or observed. The read's error is the one reported.
|
|
1018
|
+
fail() {
|
|
1019
|
+
this.failed = true;
|
|
1020
|
+
try {
|
|
1021
|
+
this.invalidateChildren();
|
|
1022
|
+
} catch {
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
readTracked(atom, lifetime) {
|
|
1026
|
+
const parent = this.registry.ensureNode(atom);
|
|
1027
|
+
if (!this.parents.has(parent)) {
|
|
1028
|
+
this.parents.add(parent);
|
|
1029
|
+
parent.children.add(this);
|
|
1030
|
+
if (this.isObserved) {
|
|
1031
|
+
parent.childObserved(1);
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
return parent.value();
|
|
1036
|
+
} catch (error2) {
|
|
1037
|
+
if (lifetime.reads === void 0 || parent.state !== NodeState.valid) throw error2;
|
|
1038
|
+
if (lifetime.failure === noFailure) lifetime.failure = error2;
|
|
1039
|
+
return parent._value;
|
|
1040
|
+
} finally {
|
|
1041
|
+
if (lifetime.reads !== void 0 && !lifetime.disposed) {
|
|
1042
|
+
lifetime.reads.add(parent);
|
|
1043
|
+
}
|
|
1044
|
+
}
|
|
1045
|
+
}
|
|
1046
|
+
dropUnread(reads) {
|
|
1047
|
+
if (reads.size === this.parents.size) return;
|
|
1048
|
+
const observed = this.isObserved;
|
|
1049
|
+
for (const parent of this.parents) {
|
|
1050
|
+
if (reads.has(parent)) continue;
|
|
1051
|
+
this.parents.delete(parent);
|
|
1052
|
+
parent.children.delete(this);
|
|
1053
|
+
if (observed) {
|
|
1054
|
+
parent.childObserved(-1);
|
|
1055
|
+
}
|
|
1056
|
+
if (parent.canBeRemoved) {
|
|
1057
|
+
this.registry.scheduleNodeRemoval(parent);
|
|
953
1058
|
}
|
|
954
1059
|
}
|
|
955
|
-
return this._value;
|
|
956
1060
|
}
|
|
957
1061
|
valueOption() {
|
|
958
1062
|
if ((this.state & NodeFlags.initialized) === 0) {
|
|
@@ -965,151 +1069,143 @@ var NodeImpl = class {
|
|
|
965
1069
|
this.preserveInitialValueOnBuild = true;
|
|
966
1070
|
this.state = NodeState.stale;
|
|
967
1071
|
this._value = value2;
|
|
968
|
-
if (
|
|
969
|
-
|
|
970
|
-
} else {
|
|
971
|
-
this.notify();
|
|
1072
|
+
if (this.listeners.size > 0) {
|
|
1073
|
+
this.announce();
|
|
972
1074
|
}
|
|
973
1075
|
return;
|
|
974
1076
|
}
|
|
975
1077
|
this.setValue(value2);
|
|
976
1078
|
}
|
|
977
1079
|
setValue(value2) {
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
if (batchState.phase === BatchPhase.collect) {
|
|
982
|
-
batchState.notify.add(this);
|
|
983
|
-
} else {
|
|
984
|
-
this.notify();
|
|
985
|
-
}
|
|
986
|
-
return;
|
|
987
|
-
}
|
|
1080
|
+
const recovered = this.failed;
|
|
1081
|
+
this.failed = false;
|
|
1082
|
+
const initialized = (this.state & NodeFlags.initialized) !== 0;
|
|
988
1083
|
this.state = NodeState.valid;
|
|
989
|
-
if (this.atom.equals(this._value, value2)) {
|
|
1084
|
+
if (initialized && this.atom.equals(this._value, value2)) {
|
|
1085
|
+
if (recovered) this.invalidateChildren();
|
|
990
1086
|
return;
|
|
991
1087
|
}
|
|
992
1088
|
this._value = value2;
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
} else {
|
|
1089
|
+
let failure2 = noFailure;
|
|
1090
|
+
try {
|
|
996
1091
|
this.invalidateChildren();
|
|
1092
|
+
} catch (error2) {
|
|
1093
|
+
failure2 = error2;
|
|
997
1094
|
}
|
|
998
1095
|
if (this.listeners.size > 0) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
}
|
|
1002
|
-
|
|
1096
|
+
try {
|
|
1097
|
+
this.announce();
|
|
1098
|
+
} catch (error2) {
|
|
1099
|
+
if (failure2 === noFailure) failure2 = error2;
|
|
1003
1100
|
}
|
|
1004
1101
|
}
|
|
1102
|
+
if (failure2 !== noFailure) throw failure2;
|
|
1005
1103
|
}
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
this.previousParents = void 0;
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
if (!parent.children.has(this)) {
|
|
1015
|
-
parent.children.add(this);
|
|
1016
|
-
if (parent.skipInvalidation) {
|
|
1017
|
-
parent.skipInvalidation = false;
|
|
1018
|
-
}
|
|
1104
|
+
announce() {
|
|
1105
|
+
if (batchState.phase === BatchPhase.collect) {
|
|
1106
|
+
batchState.notify.add(this);
|
|
1107
|
+
} else {
|
|
1108
|
+
this.notify();
|
|
1019
1109
|
}
|
|
1020
1110
|
}
|
|
1021
|
-
removeChild(child) {
|
|
1022
|
-
this.children.delete(child);
|
|
1023
|
-
}
|
|
1024
1111
|
invalidate() {
|
|
1025
|
-
if (this.building && batchState.phase === BatchPhase.collect) {
|
|
1026
|
-
this.invalidatedDuringBuild = true;
|
|
1027
|
-
}
|
|
1028
1112
|
if (this.state === NodeState.valid) {
|
|
1029
1113
|
this.state = NodeState.stale;
|
|
1030
|
-
|
|
1114
|
+
try {
|
|
1115
|
+
this.disposeLifetime();
|
|
1116
|
+
} finally {
|
|
1117
|
+
this.propagate();
|
|
1118
|
+
}
|
|
1119
|
+
} else if (this.building && batchState.phase !== BatchPhase.collect) {
|
|
1120
|
+
this.build();
|
|
1121
|
+
} else {
|
|
1122
|
+
this.propagate();
|
|
1031
1123
|
}
|
|
1124
|
+
}
|
|
1125
|
+
propagate() {
|
|
1032
1126
|
if (batchState.phase === BatchPhase.collect) {
|
|
1127
|
+
if (this.building) {
|
|
1128
|
+
this.invalidatedDuringBuild = true;
|
|
1129
|
+
}
|
|
1033
1130
|
batchState.stale.push(this);
|
|
1034
|
-
} else if (this.
|
|
1035
|
-
this.invalidateChildren();
|
|
1036
|
-
this.skipInvalidation = true;
|
|
1037
|
-
} else {
|
|
1131
|
+
} else if (this.isObserved) {
|
|
1038
1132
|
this.value();
|
|
1133
|
+
} else {
|
|
1134
|
+
this.invalidateChildren();
|
|
1039
1135
|
}
|
|
1040
1136
|
}
|
|
1041
1137
|
invalidateChildren() {
|
|
1042
1138
|
if (this.children.size === 0) {
|
|
1043
1139
|
return;
|
|
1044
1140
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1141
|
+
let failure2 = noFailure;
|
|
1142
|
+
for (const child of Array.from(this.children)) {
|
|
1143
|
+
if (!child.affectedBy(this)) continue;
|
|
1144
|
+
try {
|
|
1145
|
+
child.invalidate();
|
|
1146
|
+
} catch (error2) {
|
|
1147
|
+
if (failure2 === noFailure) failure2 = error2;
|
|
1148
|
+
}
|
|
1049
1149
|
}
|
|
1150
|
+
if (failure2 !== noFailure) throw failure2;
|
|
1151
|
+
}
|
|
1152
|
+
// Whether a change of the parent reaches this node: it holds the parent's
|
|
1153
|
+
// value, or a running build has already read it. A stale node is stale
|
|
1154
|
+
// already, and a build that has not read the parent yet will read the new
|
|
1155
|
+
// value. The exception is an observed node that is still stale: its rebuild
|
|
1156
|
+
// failed, and a parent that has a value again is its chance to recover.
|
|
1157
|
+
affectedBy(parent) {
|
|
1158
|
+
if (this.state === NodeState.valid) return true;
|
|
1159
|
+
const reads = this.lifetime?.reads;
|
|
1160
|
+
if (reads !== void 0) return reads.has(parent);
|
|
1161
|
+
return this.isObserved && parent.state === NodeState.valid;
|
|
1050
1162
|
}
|
|
1051
1163
|
notify() {
|
|
1052
|
-
this.listeners.forEach(notifyListener);
|
|
1053
1164
|
if (batchState.phase === BatchPhase.commit) {
|
|
1054
1165
|
batchState.notify.delete(this);
|
|
1055
1166
|
}
|
|
1167
|
+
runAll(this.listeners, invoke);
|
|
1056
1168
|
}
|
|
1057
1169
|
disposeLifetime() {
|
|
1058
|
-
|
|
1059
|
-
|
|
1170
|
+
const lifetime = this.lifetime;
|
|
1171
|
+
if (lifetime !== void 0) {
|
|
1060
1172
|
this.lifetime = void 0;
|
|
1061
|
-
|
|
1062
|
-
if (this.parents.size !== 0) {
|
|
1063
|
-
this.previousParents = this.parents;
|
|
1064
|
-
this.parents = /* @__PURE__ */ new Set();
|
|
1173
|
+
lifetime.dispose();
|
|
1065
1174
|
}
|
|
1066
1175
|
}
|
|
1067
1176
|
remove() {
|
|
1177
|
+
const observed = this.isObserved;
|
|
1068
1178
|
this.state = NodeState.removed;
|
|
1069
1179
|
this.listeners.clear();
|
|
1070
|
-
|
|
1180
|
+
try {
|
|
1071
1181
|
this.disposeLifetime();
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1182
|
+
} finally {
|
|
1183
|
+
const parents = Array.from(this.parents);
|
|
1184
|
+
this.parents.clear();
|
|
1185
|
+
runAll(parents, (parent) => {
|
|
1186
|
+
parent.children.delete(this);
|
|
1187
|
+
if (observed) {
|
|
1188
|
+
parent.childObserved(-1);
|
|
1189
|
+
}
|
|
1190
|
+
if (parent.canBeRemoved) {
|
|
1191
|
+
this.registry.removeNode(parent);
|
|
1192
|
+
}
|
|
1193
|
+
});
|
|
1083
1194
|
}
|
|
1084
1195
|
}
|
|
1085
1196
|
subscribe(listener) {
|
|
1197
|
+
const observed = this.isObserved;
|
|
1086
1198
|
this.listeners.add(listener);
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
};
|
|
1090
|
-
function childrenAreActive(children) {
|
|
1091
|
-
if (children.size === 0) {
|
|
1092
|
-
return false;
|
|
1093
|
-
}
|
|
1094
|
-
let current = children;
|
|
1095
|
-
let stack;
|
|
1096
|
-
let stackIndex = 0;
|
|
1097
|
-
while (current !== void 0) {
|
|
1098
|
-
for (const child of current) {
|
|
1099
|
-
if (!child.atom.lazy || child.listeners.size > 0) {
|
|
1100
|
-
return true;
|
|
1101
|
-
} else if (child.children.size > 0) {
|
|
1102
|
-
if (stack === void 0) {
|
|
1103
|
-
stack = [child.children];
|
|
1104
|
-
} else {
|
|
1105
|
-
stack.push(child.children);
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1199
|
+
if (!observed) {
|
|
1200
|
+
this.observedChanged(1);
|
|
1108
1201
|
}
|
|
1109
|
-
|
|
1202
|
+
return () => {
|
|
1203
|
+
if (this.listeners.delete(listener) && !this.isObserved) {
|
|
1204
|
+
this.observedChanged(-1);
|
|
1205
|
+
}
|
|
1206
|
+
};
|
|
1110
1207
|
}
|
|
1111
|
-
|
|
1112
|
-
}
|
|
1208
|
+
};
|
|
1113
1209
|
var LifetimeProto = {
|
|
1114
1210
|
get registry() {
|
|
1115
1211
|
return this.node.registry;
|
|
@@ -1123,10 +1219,7 @@ var LifetimeProto = {
|
|
|
1123
1219
|
if (this.disposed) {
|
|
1124
1220
|
return this.node.registry.get(atom);
|
|
1125
1221
|
}
|
|
1126
|
-
|
|
1127
|
-
const value2 = parent.value();
|
|
1128
|
-
this.node.addParent(parent);
|
|
1129
|
-
return value2;
|
|
1222
|
+
return this.node.readTracked(atom, this);
|
|
1130
1223
|
},
|
|
1131
1224
|
result(atom, options) {
|
|
1132
1225
|
if (this.disposed || this.isFn) {
|
|
@@ -1243,28 +1336,23 @@ var LifetimeProto = {
|
|
|
1243
1336
|
}
|
|
1244
1337
|
const finalizers = this.finalizers;
|
|
1245
1338
|
this.finalizers = void 0;
|
|
1246
|
-
|
|
1247
|
-
finalizers[i]();
|
|
1248
|
-
}
|
|
1339
|
+
runAll(finalizers.reverse(), invoke);
|
|
1249
1340
|
}
|
|
1250
1341
|
};
|
|
1251
1342
|
var makeLifetime = (node) => {
|
|
1252
1343
|
function get5(atom) {
|
|
1253
|
-
if (get5.disposed) {
|
|
1254
|
-
return node.registry.get(atom);
|
|
1255
|
-
} else if (get5.isFn) {
|
|
1344
|
+
if (get5.disposed || get5.isFn) {
|
|
1256
1345
|
return node.registry.get(atom);
|
|
1257
1346
|
}
|
|
1258
|
-
|
|
1259
|
-
const value2 = parent.value();
|
|
1260
|
-
node.addParent(parent);
|
|
1261
|
-
return value2;
|
|
1347
|
+
return node.readTracked(atom, get5);
|
|
1262
1348
|
}
|
|
1263
1349
|
Object.setPrototypeOf(get5, LifetimeProto);
|
|
1264
1350
|
get5.isFn = false;
|
|
1265
1351
|
get5.disposed = false;
|
|
1266
1352
|
get5.finalizers = void 0;
|
|
1267
1353
|
get5.node = node;
|
|
1354
|
+
get5.reads = /* @__PURE__ */ new Set();
|
|
1355
|
+
get5.failure = noFailure;
|
|
1268
1356
|
return get5;
|
|
1269
1357
|
};
|
|
1270
1358
|
var WriteContextImpl = class {
|
|
@@ -1299,27 +1387,45 @@ var batchState = {
|
|
|
1299
1387
|
notify: /* @__PURE__ */ new Set()
|
|
1300
1388
|
};
|
|
1301
1389
|
function batch(f) {
|
|
1390
|
+
const previousPhase = batchState.phase;
|
|
1302
1391
|
batchState.phase = BatchPhase.collect;
|
|
1303
1392
|
batchState.depth++;
|
|
1393
|
+
let failure2 = noFailure;
|
|
1304
1394
|
try {
|
|
1305
1395
|
f();
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1396
|
+
} catch (error2) {
|
|
1397
|
+
failure2 = error2;
|
|
1398
|
+
}
|
|
1399
|
+
if (batchState.depth === 1) {
|
|
1400
|
+
const {
|
|
1401
|
+
notify,
|
|
1402
|
+
stale
|
|
1403
|
+
} = batchState;
|
|
1404
|
+
let i = 0;
|
|
1405
|
+
do {
|
|
1406
|
+
batchState.phase = BatchPhase.collect;
|
|
1407
|
+
for (; i < stale.length; i++) {
|
|
1408
|
+
try {
|
|
1409
|
+
batchRebuildNode(stale[i]);
|
|
1410
|
+
} catch (error2) {
|
|
1411
|
+
if (failure2 === noFailure) failure2 = error2;
|
|
1412
|
+
}
|
|
1309
1413
|
}
|
|
1310
1414
|
batchState.phase = BatchPhase.commit;
|
|
1311
|
-
for (const node of
|
|
1312
|
-
|
|
1415
|
+
for (const node of notify) {
|
|
1416
|
+
try {
|
|
1417
|
+
node.notify();
|
|
1418
|
+
} catch (error2) {
|
|
1419
|
+
if (failure2 === noFailure) failure2 = error2;
|
|
1420
|
+
}
|
|
1313
1421
|
}
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
batchState.depth--;
|
|
1318
|
-
if (batchState.depth === 0) {
|
|
1319
|
-
batchState.phase = BatchPhase.disabled;
|
|
1320
|
-
batchState.stale = [];
|
|
1321
|
-
}
|
|
1422
|
+
} while (i < stale.length);
|
|
1423
|
+
batchState.stale = [];
|
|
1424
|
+
notify.clear();
|
|
1322
1425
|
}
|
|
1426
|
+
batchState.depth--;
|
|
1427
|
+
batchState.phase = previousPhase;
|
|
1428
|
+
if (failure2 !== noFailure) throw failure2;
|
|
1323
1429
|
}
|
|
1324
1430
|
function batchRebuildNode(node) {
|
|
1325
1431
|
if (node.state === NodeState.valid) {
|
|
@@ -1330,28 +1436,21 @@ function batchRebuildNode(node) {
|
|
|
1330
1436
|
node.state = NodeState.stale;
|
|
1331
1437
|
node.disposeLifetime();
|
|
1332
1438
|
}
|
|
1333
|
-
|
|
1334
|
-
if (parent.state !== NodeState.valid) {
|
|
1335
|
-
batchRebuildNode(parent);
|
|
1336
|
-
}
|
|
1337
|
-
}
|
|
1338
|
-
if (node.state !== NodeState.valid) {
|
|
1339
|
-
node.value();
|
|
1340
|
-
}
|
|
1439
|
+
node.value();
|
|
1341
1440
|
}
|
|
1342
1441
|
|
|
1343
|
-
// ../../node_modules/.bun/effect@
|
|
1442
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/Atom.js
|
|
1344
1443
|
var Atom_exports = {};
|
|
1345
1444
|
__export(Atom_exports, {
|
|
1346
1445
|
Interrupt: () => Interrupt,
|
|
1347
1446
|
Reset: () => Reset,
|
|
1348
1447
|
SerializableTypeId: () => SerializableTypeId2,
|
|
1349
1448
|
ServerValueTypeId: () => ServerValueTypeId,
|
|
1350
|
-
TypeId: () =>
|
|
1449
|
+
TypeId: () => TypeId4,
|
|
1351
1450
|
WritableTypeId: () => WritableTypeId,
|
|
1352
1451
|
autoDispose: () => autoDispose,
|
|
1353
1452
|
batch: () => batch2,
|
|
1354
|
-
context: () =>
|
|
1453
|
+
context: () => context2,
|
|
1355
1454
|
debounce: () => debounce,
|
|
1356
1455
|
family: () => family,
|
|
1357
1456
|
fn: () => fn,
|
|
@@ -1365,7 +1464,7 @@ __export(Atom_exports, {
|
|
|
1365
1464
|
isWritable: () => isWritable,
|
|
1366
1465
|
keepAlive: () => keepAlive,
|
|
1367
1466
|
kvs: () => kvs,
|
|
1368
|
-
make: () =>
|
|
1467
|
+
make: () => make4,
|
|
1369
1468
|
makeRefreshOnSignal: () => makeRefreshOnSignal,
|
|
1370
1469
|
map: () => map5,
|
|
1371
1470
|
mapResult: () => mapResult,
|
|
@@ -1400,12 +1499,146 @@ __export(Atom_exports, {
|
|
|
1400
1499
|
writable: () => writable
|
|
1401
1500
|
});
|
|
1402
1501
|
|
|
1403
|
-
// ../../node_modules/.bun/effect@
|
|
1502
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/Reactivity.js
|
|
1503
|
+
var TypeId3 = "~effect/reactivity/Reactivity";
|
|
1504
|
+
var Reactivity = /* @__PURE__ */ Service("effect/reactivity/Reactivity");
|
|
1505
|
+
var make3 = /* @__PURE__ */ sync(() => {
|
|
1506
|
+
const handlers = /* @__PURE__ */ new Map();
|
|
1507
|
+
const invalidateUnsafe = (keys) => {
|
|
1508
|
+
keysToHashes(keys, (hash2) => {
|
|
1509
|
+
const set4 = handlers.get(hash2);
|
|
1510
|
+
if (set4 === void 0) return;
|
|
1511
|
+
set4.forEach((run) => run());
|
|
1512
|
+
});
|
|
1513
|
+
};
|
|
1514
|
+
const invalidate2 = (keys) => contextWith((services) => {
|
|
1515
|
+
const pending = getOrUndefined2(services, PendingInvalidation);
|
|
1516
|
+
if (pending) {
|
|
1517
|
+
keysToHashes(keys, (hash2) => {
|
|
1518
|
+
pending.add(hash2);
|
|
1519
|
+
});
|
|
1520
|
+
} else {
|
|
1521
|
+
invalidateUnsafe(keys);
|
|
1522
|
+
}
|
|
1523
|
+
return void_2;
|
|
1524
|
+
});
|
|
1525
|
+
const mutation2 = (keys, effect3) => tap(effect3, invalidate2(keys));
|
|
1526
|
+
const registerUnsafe = (keys, handler) => {
|
|
1527
|
+
const resolvedKeys = [];
|
|
1528
|
+
keysToHashes(keys, (hash2) => {
|
|
1529
|
+
resolvedKeys.push(hash2);
|
|
1530
|
+
let set4 = handlers.get(hash2);
|
|
1531
|
+
if (set4 === void 0) {
|
|
1532
|
+
set4 = /* @__PURE__ */ new Set();
|
|
1533
|
+
handlers.set(hash2, set4);
|
|
1534
|
+
}
|
|
1535
|
+
set4.add(handler);
|
|
1536
|
+
});
|
|
1537
|
+
return () => {
|
|
1538
|
+
for (let i = 0; i < resolvedKeys.length; i++) {
|
|
1539
|
+
const set4 = handlers.get(resolvedKeys[i]);
|
|
1540
|
+
if (set4 === void 0) continue;
|
|
1541
|
+
set4.delete(handler);
|
|
1542
|
+
if (set4.size === 0) {
|
|
1543
|
+
handlers.delete(resolvedKeys[i]);
|
|
1544
|
+
}
|
|
1545
|
+
}
|
|
1546
|
+
};
|
|
1547
|
+
};
|
|
1548
|
+
const query = (keys, effect3) => gen(function* () {
|
|
1549
|
+
const services = yield* context();
|
|
1550
|
+
const scope2 = get(services, Scope);
|
|
1551
|
+
const results = yield* make();
|
|
1552
|
+
const runFork = flow(runForkWith(services), runIn(scope2));
|
|
1553
|
+
let running = false;
|
|
1554
|
+
let pending = false;
|
|
1555
|
+
const handleExit = (exit) => {
|
|
1556
|
+
if (exit._tag === "Failure") {
|
|
1557
|
+
failCauseUnsafe(results, exit.cause);
|
|
1558
|
+
} else {
|
|
1559
|
+
offerUnsafe(results, exit.value);
|
|
1560
|
+
}
|
|
1561
|
+
if (pending) {
|
|
1562
|
+
pending = false;
|
|
1563
|
+
runFork(effect3).addObserver(handleExit);
|
|
1564
|
+
} else {
|
|
1565
|
+
running = false;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
function run() {
|
|
1569
|
+
if (running) {
|
|
1570
|
+
pending = true;
|
|
1571
|
+
return;
|
|
1572
|
+
}
|
|
1573
|
+
running = true;
|
|
1574
|
+
runFork(effect3).addObserver(handleExit);
|
|
1575
|
+
}
|
|
1576
|
+
const cancel = registerUnsafe(keys, run);
|
|
1577
|
+
yield* addFinalizer(scope2, sync(cancel));
|
|
1578
|
+
run();
|
|
1579
|
+
return results;
|
|
1580
|
+
});
|
|
1581
|
+
const stream2 = (tables, effect3) => query(tables, effect3).pipe(map2(fromQueue), unwrap);
|
|
1582
|
+
const withBatch = (effect3) => suspend(() => {
|
|
1583
|
+
const pending = /* @__PURE__ */ new Set();
|
|
1584
|
+
return effect3.pipe(provideService(PendingInvalidation, pending), onExit((_) => sync(() => {
|
|
1585
|
+
pending.forEach((hash2) => {
|
|
1586
|
+
const set4 = handlers.get(hash2);
|
|
1587
|
+
if (set4 === void 0) return;
|
|
1588
|
+
set4.forEach((run) => run());
|
|
1589
|
+
});
|
|
1590
|
+
})));
|
|
1591
|
+
});
|
|
1592
|
+
return Reactivity.of({
|
|
1593
|
+
[TypeId3]: TypeId3,
|
|
1594
|
+
mutation: mutation2,
|
|
1595
|
+
query,
|
|
1596
|
+
stream: stream2,
|
|
1597
|
+
invalidateUnsafe,
|
|
1598
|
+
invalidate: invalidate2,
|
|
1599
|
+
registerUnsafe,
|
|
1600
|
+
withBatch
|
|
1601
|
+
});
|
|
1602
|
+
});
|
|
1603
|
+
var PendingInvalidation = class extends (/* @__PURE__ */ Service()("effect/reactivity/Reactivity/PendingInvalidation")) {
|
|
1604
|
+
};
|
|
1605
|
+
var mutation = /* @__PURE__ */ dual(2, (effect3, keys) => Reactivity.use((_) => _.mutation(keys, effect3)));
|
|
1606
|
+
var invalidate = (keys) => Reactivity.use((r) => r.invalidate(keys));
|
|
1607
|
+
var layer2 = /* @__PURE__ */ effect(Reactivity)(make3);
|
|
1608
|
+
function stringOrHash(u) {
|
|
1609
|
+
switch (typeof u) {
|
|
1610
|
+
case "string":
|
|
1611
|
+
case "number":
|
|
1612
|
+
case "bigint":
|
|
1613
|
+
case "boolean":
|
|
1614
|
+
return String(u);
|
|
1615
|
+
default:
|
|
1616
|
+
return hash(u);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
var keysToHashes = (keys, f) => {
|
|
1620
|
+
if (Array.isArray(keys)) {
|
|
1621
|
+
for (let i = 0; i < keys.length; i++) {
|
|
1622
|
+
f(stringOrHash(keys[i]));
|
|
1623
|
+
}
|
|
1624
|
+
return;
|
|
1625
|
+
}
|
|
1626
|
+
for (const key in keys) {
|
|
1627
|
+
f(key);
|
|
1628
|
+
const ids = keys[key];
|
|
1629
|
+
for (let i = 0; i < ids.length; i++) {
|
|
1630
|
+
f(`${key}:${stringOrHash(ids[i])}`);
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
};
|
|
1634
|
+
|
|
1635
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/persistence/KeyValueStore.js
|
|
1404
1636
|
var ErrorTypeId = "~effect/persistence/KeyValueStore/KeyValueStoreError";
|
|
1405
1637
|
var KeyValueStoreError = class extends (/* @__PURE__ */ TaggedError("KeyValueStoreError")) {
|
|
1406
1638
|
/**
|
|
1407
1639
|
* Marks this value as a key-value store error for runtime guards.
|
|
1408
1640
|
*
|
|
1641
|
+
* @stability unstable
|
|
1409
1642
|
* @since 4.0.0
|
|
1410
1643
|
*/
|
|
1411
1644
|
[ErrorTypeId] = ErrorTypeId;
|
|
@@ -1442,9 +1675,9 @@ var toSchemaStore = (self, schema) => {
|
|
|
1442
1675
|
};
|
|
1443
1676
|
};
|
|
1444
1677
|
|
|
1445
|
-
// ../../node_modules/.bun/effect@
|
|
1446
|
-
var
|
|
1447
|
-
var isAtom = (u) => hasProperty(u,
|
|
1678
|
+
// ../../node_modules/.bun/effect@4.0.1/node_modules/effect/dist/reactivity/Atom.js
|
|
1679
|
+
var TypeId4 = "~effect/reactivity/Atom";
|
|
1680
|
+
var isAtom = (u) => hasProperty(u, TypeId4);
|
|
1448
1681
|
var WritableTypeId = "~effect/reactivity/Atom/Writable";
|
|
1449
1682
|
var setIdleTTL = /* @__PURE__ */ dual(2, (self, durationInput) => {
|
|
1450
1683
|
const duration = fromInputUnsafe(durationInput);
|
|
@@ -1457,7 +1690,7 @@ var setIdleTTL = /* @__PURE__ */ dual(2, (self, durationInput) => {
|
|
|
1457
1690
|
});
|
|
1458
1691
|
var removeTtl = /* @__PURE__ */ setIdleTTL(0);
|
|
1459
1692
|
var AtomProto = {
|
|
1460
|
-
[
|
|
1693
|
+
[TypeId4]: TypeId4,
|
|
1461
1694
|
equals: Object.is,
|
|
1462
1695
|
...PipeInspectableProto,
|
|
1463
1696
|
toJSON() {
|
|
@@ -1555,9 +1788,9 @@ var writable = (read, write, refresh2) => {
|
|
|
1555
1788
|
function constSetSelf(ctx, value2) {
|
|
1556
1789
|
ctx.setSelf(value2);
|
|
1557
1790
|
}
|
|
1558
|
-
var
|
|
1791
|
+
var make4 = (arg, options) => {
|
|
1559
1792
|
const readOrAtom = makeRead(arg, options);
|
|
1560
|
-
if (
|
|
1793
|
+
if (TypeId4 in readOrAtom) {
|
|
1561
1794
|
return readOrAtom;
|
|
1562
1795
|
}
|
|
1563
1796
|
return readable(readOrAtom);
|
|
@@ -1602,7 +1835,7 @@ var effect2 = (get5, effect3, options, services) => {
|
|
|
1602
1835
|
const initialValue2 = options?.initialValue !== void 0 ? success(options.initialValue) : initial();
|
|
1603
1836
|
return makeEffect(get5, effect3, initialValue2, services, options?.uninterruptible);
|
|
1604
1837
|
};
|
|
1605
|
-
function makeEffect(ctx, effect3, initialValue2, services =
|
|
1838
|
+
function makeEffect(ctx, effect3, initialValue2, services = empty(), uninterruptible = false) {
|
|
1606
1839
|
const previous = ctx.self();
|
|
1607
1840
|
const scope2 = makeUnsafe();
|
|
1608
1841
|
ctx.addFinalizer(() => {
|
|
@@ -1627,9 +1860,9 @@ function makeEffect(ctx, effect3, initialValue2, services = empty2(), uninterrup
|
|
|
1627
1860
|
}
|
|
1628
1861
|
return waiting(initialValue2);
|
|
1629
1862
|
}
|
|
1630
|
-
function runCallbackSync(services, effect3,
|
|
1863
|
+
function runCallbackSync(services, effect3, onExit2, uninterruptible = false) {
|
|
1631
1864
|
if (isExit(effect3)) {
|
|
1632
|
-
|
|
1865
|
+
onExit2(effect3);
|
|
1633
1866
|
return void 0;
|
|
1634
1867
|
}
|
|
1635
1868
|
const runFork = runForkWith(services);
|
|
@@ -1637,10 +1870,10 @@ function runCallbackSync(services, effect3, onExit, uninterruptible = false) {
|
|
|
1637
1870
|
fiber.currentDispatcher?.flush();
|
|
1638
1871
|
const result = fiber.pollUnsafe();
|
|
1639
1872
|
if (result) {
|
|
1640
|
-
|
|
1873
|
+
onExit2(result);
|
|
1641
1874
|
return void 0;
|
|
1642
1875
|
}
|
|
1643
|
-
const remove2 = fiber.addObserver(
|
|
1876
|
+
const remove2 = fiber.addObserver(onExit2);
|
|
1644
1877
|
function cancel() {
|
|
1645
1878
|
remove2();
|
|
1646
1879
|
if (!uninterruptible) {
|
|
@@ -1649,10 +1882,10 @@ function runCallbackSync(services, effect3, onExit, uninterruptible = false) {
|
|
|
1649
1882
|
}
|
|
1650
1883
|
return cancel;
|
|
1651
1884
|
}
|
|
1652
|
-
function
|
|
1653
|
-
const memoMap = options?.memoMap ?? removeTtl(
|
|
1885
|
+
function context2(options) {
|
|
1886
|
+
const memoMap = options?.memoMap ?? removeTtl(make4(() => makeMemoMapUnsafe()));
|
|
1654
1887
|
const resolveMemoMap = (get5) => isAtom(memoMap) ? get5(memoMap) : memoMap;
|
|
1655
|
-
let globalLayer =
|
|
1888
|
+
let globalLayer = layer2;
|
|
1656
1889
|
function factory(create) {
|
|
1657
1890
|
const self = Object.create(RuntimeProto);
|
|
1658
1891
|
self.keepAlive = false;
|
|
@@ -1672,9 +1905,9 @@ function context(options) {
|
|
|
1672
1905
|
}
|
|
1673
1906
|
factory.memoMap = memoMap;
|
|
1674
1907
|
factory.addGlobalLayer = (layer3) => {
|
|
1675
|
-
globalLayer = provideMerge(globalLayer, provide(layer3,
|
|
1908
|
+
globalLayer = provideMerge(globalLayer, provide(layer3, layer2));
|
|
1676
1909
|
};
|
|
1677
|
-
const reactivityAtom = removeTtl(
|
|
1910
|
+
const reactivityAtom = removeTtl(make4((get5) => contextWith((services) => buildWithMemoMap(layer2, resolveMemoMap(get5), get(services, Scope))).pipe(map2(get(Reactivity)))));
|
|
1678
1911
|
factory.withReactivity = (keys) => (atom) => transform2(atom, (get5) => {
|
|
1679
1912
|
const reactivity = getOrThrow(get5(reactivityAtom));
|
|
1680
1913
|
get5.addFinalizer(reactivity.registerUnsafe(keys, () => {
|
|
@@ -1687,13 +1920,13 @@ function context(options) {
|
|
|
1687
1920
|
});
|
|
1688
1921
|
return factory;
|
|
1689
1922
|
}
|
|
1690
|
-
var runtime = /* @__PURE__ */
|
|
1923
|
+
var runtime = /* @__PURE__ */ context2();
|
|
1691
1924
|
var withReactivity = runtime.withReactivity;
|
|
1692
1925
|
var stream = (get5, stream2, options, services) => {
|
|
1693
1926
|
const initialValue2 = options?.initialValue !== void 0 ? success(options.initialValue) : initial();
|
|
1694
1927
|
return makeStream(get5, stream2, initialValue2, services);
|
|
1695
1928
|
};
|
|
1696
|
-
function makeStream(ctx, stream2, initialValue2, services =
|
|
1929
|
+
function makeStream(ctx, stream2, initialValue2, services = empty()) {
|
|
1697
1930
|
const previous = ctx.self();
|
|
1698
1931
|
services = add(services, AtomRegistry, ctx.registry);
|
|
1699
1932
|
const run = scopedWith((scope2) => flatMap2(toPullScoped(stream2.channel, scope2), (pull2) => whileLoop({
|
|
@@ -1732,7 +1965,7 @@ var subscriptionRef = (ref) => makeSubRef(readable((get5) => {
|
|
|
1732
1965
|
const value2 = typeof ref === "function" ? ref(get5) : ref;
|
|
1733
1966
|
return isSubscriptionRef(value2) ? value2 : makeEffect(get5, value2, initial(true));
|
|
1734
1967
|
}), readSubscriptionRef);
|
|
1735
|
-
var readSubscriptionRef = (get5, sub, services =
|
|
1968
|
+
var readSubscriptionRef = (get5, sub, services = empty()) => {
|
|
1736
1969
|
if (isSubscriptionRef(sub)) {
|
|
1737
1970
|
get5.addFinalizer(changes2(sub).pipe(runForEachArray((arr) => {
|
|
1738
1971
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -1828,8 +2061,9 @@ function makeResultFn(f, options) {
|
|
|
1828
2061
|
startImmediately: true
|
|
1829
2062
|
}), (fiber) => {
|
|
1830
2063
|
fibers.add(fiber);
|
|
2064
|
+
const runningFibers = Array.from(fibers);
|
|
1831
2065
|
fiber.addObserver(() => fibers.delete(fiber));
|
|
1832
|
-
return map2(joinAll(
|
|
2066
|
+
return map2(joinAll(runningFibers), (arr) => arr[0]);
|
|
1833
2067
|
});
|
|
1834
2068
|
}
|
|
1835
2069
|
return makeEffect(get5, value2, initialValue2, services, false);
|
|
@@ -1860,7 +2094,7 @@ var pull = (create, options) => {
|
|
|
1860
2094
|
var makeStreamPullEffect = (get5, pullSignal, create, options) => flatMap2(toPull(typeof create === "function" ? create(get5) : create), (pullChunk) => {
|
|
1861
2095
|
const fiber = getCurrent();
|
|
1862
2096
|
const services = fiber.context;
|
|
1863
|
-
let acc =
|
|
2097
|
+
let acc = empty2();
|
|
1864
2098
|
const pull2 = matchCauseEffect(pullChunk, {
|
|
1865
2099
|
onFailure(cause2) {
|
|
1866
2100
|
if (isDoneCause(cause2)) {
|
|
@@ -1923,7 +2157,10 @@ var family = typeof WeakRef === "undefined" || typeof FinalizationRegistry === "
|
|
|
1923
2157
|
} : (f) => {
|
|
1924
2158
|
const atoms = empty3();
|
|
1925
2159
|
const registry = new FinalizationRegistry((arg) => {
|
|
1926
|
-
|
|
2160
|
+
const entry = get2(atoms, arg);
|
|
2161
|
+
if (entry._tag === "Some" && entry.value.deref() === void 0) {
|
|
2162
|
+
remove(atoms, arg);
|
|
2163
|
+
}
|
|
1927
2164
|
});
|
|
1928
2165
|
return function(arg) {
|
|
1929
2166
|
const atomEntry = get2(atoms, arg).pipe(flatMapNullishOr((ref) => ref.deref()));
|
|
@@ -2049,7 +2286,15 @@ var swr = /* @__PURE__ */ dual(2, (self, options) => {
|
|
|
2049
2286
|
return current;
|
|
2050
2287
|
}
|
|
2051
2288
|
if (shouldRevalidateSWR(current, staleTime)) {
|
|
2052
|
-
|
|
2289
|
+
let active = true;
|
|
2290
|
+
get5.addFinalizer(() => {
|
|
2291
|
+
active = false;
|
|
2292
|
+
});
|
|
2293
|
+
get5.registry.schedulerAsync.makeDispatcher().scheduleTask(() => {
|
|
2294
|
+
if (active && shouldRevalidateSWR(get5.once(self), staleTime)) {
|
|
2295
|
+
get5.refresh(self);
|
|
2296
|
+
}
|
|
2297
|
+
}, 0);
|
|
2053
2298
|
}
|
|
2054
2299
|
return current;
|
|
2055
2300
|
}, {
|