@playfast/reform 1.1.1 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -55
- package/package.json +17 -17
- package/src/boundary/boundary.test.ts +62 -16
- package/src/boundary/boundary.ts +141 -32
- package/src/calc/asyncCalc.invalidate.test.ts +516 -18
- package/src/calc/asyncCalc.test.ts +207 -175
- package/src/calc/asyncCalc.ts +168 -39
- package/src/calc/calc.test.ts +3 -5
- package/src/calc/calc.ts +44 -18
- package/src/calc/calcFamily.test.ts +80 -22
- package/src/calc/calcFamily.ts +56 -25
- package/src/calc/compose.ts +1 -14
- package/src/channel/channel.ts +128 -11
- package/src/compose/composition.test.ts +19 -0
- package/src/compose/composition.ts +346 -62
- package/src/compose/props.ts +13 -6
- package/src/compose/provide.ts +187 -46
- package/src/compose/slot.ts +156 -19
- package/src/compose/structure.test.ts +6 -3
- package/src/compose/structure.ts +106 -13
- package/src/compose/ui.test.ts +19 -3
- package/src/compose/ui.ts +147 -54
- package/src/compose/ui.typecheck.ts +40 -4
- package/src/definition/definition.ts +22 -9
- package/src/event/event.fromSource.test.ts +172 -0
- package/src/event/event.test.ts +10 -0
- package/src/event/event.ts +102 -18
- package/src/feature/feature.mount.test.ts +123 -56
- package/src/feature/feature.test.ts +67 -63
- package/src/feature/feature.ts +1317 -197
- package/src/feature/feature.typecheck.ts +253 -61
- package/src/graph/closure.ts +403 -0
- package/src/index.ts +171 -245
- package/src/internal/bucketCache.ts +39 -0
- package/src/internal/capture.ts +9 -4
- package/src/internal/env.ts +1 -3
- package/src/internal/errors.ts +21 -10
- package/src/internal/queryDriver.ts +120 -15
- package/src/internal/queryDriverStore.ts +8 -5
- package/src/internal/queryDriverTypes.ts +3 -1
- package/src/internal/reuse.test.ts +10 -3
- package/src/internal/reuse.ts +5 -2
- package/src/internal/scheduler.ts +4 -1
- package/src/internal/sources.ts +25 -11
- package/src/internal/track.ts +3 -2
- package/src/internal.ts +222 -0
- package/src/namespace/namespace.ts +46 -25
- package/src/procedure/procedure.ts +38 -11
- package/src/reducer/reducer.ts +78 -34
- package/src/remote/remoteState.test.ts +515 -339
- package/src/remote/remoteState.ts +572 -107
- package/src/remote/remoteState.typecheck.ts +47 -23
- package/src/runtime/appRuntime.activation.test.ts +100 -0
- package/src/runtime/appRuntime.test.ts +157 -105
- package/src/runtime/appRuntime.ts +394 -33
- package/src/runtime/eventBudget.test.ts +1 -4
- package/src/runtime/eventBudget.ts +9 -8
- package/src/runtime/hardening.test.ts +4 -9
- package/src/runtime/instrumentation.test.ts +174 -192
- package/src/runtime/instrumentation.ts +6 -11
- package/src/runtime/loop.test.ts +36 -0
- package/src/runtime/loop.ts +69 -40
- package/src/scene/featureScene.test.ts +4 -2
- package/src/scene/scene.ts +234 -64
- package/src/scene/seedScene.test.ts +69 -86
- package/src/state/state.nominal.typecheck.ts +68 -0
- package/src/state/state.test.ts +17 -0
- package/src/state/state.ts +79 -26
- package/src/state/stateFamily.test.ts +14 -0
- package/src/state/stateFamily.ts +55 -22
- package/src/state/stateGroup.ts +53 -17
- package/src/state/token.ts +40 -10
- package/src/synced/syncedStore.ts +46 -23
- package/src/testkit/flight.testkit.ts +75 -0
- package/src/wire/tree.test.ts +8 -4
- package/src/wire/triggers.test.ts +6 -2
- package/src/wire/triggers.ts +14 -10
- package/src/calc/asyncCalcDefinitions.ts +0 -48
- package/src/channel/procedureRegistry.ts +0 -90
- package/src/feature/featureBinding.ts +0 -48
- package/src/internal/ctx.ts +0 -9
- package/src/remote/remoteStateDefinition.ts +0 -135
- package/src/remote/remoteStateLayers.ts +0 -118
- package/src/remote/remoteStateLiveTypes.ts +0 -59
- package/src/remote/remoteStateSend.ts +0 -64
package/src/index.ts
CHANGED
|
@@ -1,255 +1,181 @@
|
|
|
1
|
-
export * as State from
|
|
2
|
-
export
|
|
3
|
-
export * as
|
|
4
|
-
export {
|
|
5
|
-
export
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
export * as State from './state/state'
|
|
2
|
+
export type { StateClass, StateStore, StateValue } from './state/state'
|
|
3
|
+
export * as StateGroup from './state/stateGroup'
|
|
4
|
+
export type { SeedsOf } from './state/stateGroup'
|
|
5
|
+
export * as StateFamily from './state/stateFamily'
|
|
6
|
+
export type {
|
|
7
|
+
FamilyKey,
|
|
8
|
+
FamilyValue,
|
|
9
|
+
StateFamilyClass,
|
|
10
|
+
StateFamilyStore,
|
|
11
|
+
} from './state/stateFamily'
|
|
11
12
|
|
|
12
|
-
export * as
|
|
13
|
-
|
|
14
|
-
export * as CalcFamily from "./calc/calcFamily";
|
|
15
|
-
export * as AsyncCalc from "./calc/asyncCalc";
|
|
16
|
-
export { composeCalcs } from "./calc/compose";
|
|
13
|
+
export * as Event from './event/event'
|
|
14
|
+
// TS2742: direct type exports allow declaration emit to name event-derived types.
|
|
17
15
|
export type {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
export
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} from
|
|
36
|
-
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
16
|
+
EventClass,
|
|
17
|
+
EventOf,
|
|
18
|
+
EventPayload,
|
|
19
|
+
SourceChange,
|
|
20
|
+
SourceEventConfig,
|
|
21
|
+
SourceEventConfigExternalApi,
|
|
22
|
+
} from './event/event'
|
|
23
|
+
export * as EventGroup from './event/eventGroup'
|
|
24
|
+
|
|
25
|
+
export * as Reducer from './reducer/reducer'
|
|
26
|
+
export * as Calc from './calc/calc'
|
|
27
|
+
export type { CalcClass, CalcStore } from './calc/calc'
|
|
28
|
+
export * as CalcFamily from './calc/calcFamily'
|
|
29
|
+
export type { CalcFamilyClass, CalcFamilyStore } from './calc/calcFamily'
|
|
30
|
+
export * as AsyncCalc from './calc/asyncCalc'
|
|
31
|
+
export type { AsyncCalcClass, AsyncCalcStore } from './calc/asyncCalc'
|
|
32
|
+
export { composeCalcs } from './calc/compose'
|
|
33
|
+
export type { InputsObject, InputStores, InvalidateBy } from './internal/sources'
|
|
34
|
+
export {
|
|
35
|
+
AsyncData,
|
|
36
|
+
type AsyncError,
|
|
37
|
+
type AsyncIdle,
|
|
38
|
+
type AsyncLoading,
|
|
39
|
+
type AsyncSuccess,
|
|
40
|
+
} from './calc/asyncData'
|
|
41
|
+
export { isLoading, type QueryState, toAsyncData } from './calc/queryState'
|
|
42
|
+
|
|
43
|
+
export * as RemoteState from './remote/remoteState'
|
|
44
|
+
// TS2742: direct exports keep pending and failed state types nameable.
|
|
44
45
|
export type {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
export * as
|
|
54
|
-
// TS2742:
|
|
46
|
+
FailedIntent,
|
|
47
|
+
PendingIntent,
|
|
48
|
+
RemoteStateClass,
|
|
49
|
+
RemoteStatePendingStore,
|
|
50
|
+
RemoteStateSettled,
|
|
51
|
+
RemoteStateTruthStore,
|
|
52
|
+
RemoteStateVisibleStore,
|
|
53
|
+
} from './remote/remoteState'
|
|
54
|
+
export * as SyncedStore from './synced/syncedStore'
|
|
55
|
+
// TS2742: adapters need a directly nameable synchronized source type.
|
|
56
|
+
export type { SyncedSource, SyncedStoreClass, SyncedStoreIdentifier } from './synced/syncedStore'
|
|
57
|
+
export * as Boundary from './boundary/boundary'
|
|
58
|
+
// TS2742: direct exports keep boundary state types nameable.
|
|
55
59
|
export type {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
export * as Channel from "./channel/channel";
|
|
63
|
-
export * as Namespace from "./namespace/namespace";
|
|
64
|
-
export type { FeatureNamespace } from "./namespace/namespace";
|
|
60
|
+
BoundaryErrored,
|
|
61
|
+
BoundaryPending,
|
|
62
|
+
BoundaryReady,
|
|
63
|
+
BoundaryState,
|
|
64
|
+
BoundaryStore,
|
|
65
|
+
} from './boundary/boundary'
|
|
65
66
|
|
|
66
|
-
export * as
|
|
67
|
-
export type {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} from "./compose/composition";
|
|
73
|
-
export {
|
|
74
|
-
absent,
|
|
75
|
-
each,
|
|
76
|
-
type EachFill,
|
|
77
|
-
isStructure,
|
|
78
|
-
mount,
|
|
79
|
-
one,
|
|
80
|
-
type OneFill,
|
|
81
|
-
type AbsentFill,
|
|
82
|
-
type SlotFill,
|
|
83
|
-
type Structure,
|
|
84
|
-
structureEquals,
|
|
85
|
-
type StructureSlots,
|
|
86
|
-
StructureTypeId,
|
|
87
|
-
when,
|
|
88
|
-
} from "./compose/structure";
|
|
89
|
-
export { Props } from "./compose/props";
|
|
90
|
-
export {
|
|
91
|
-
isSlot,
|
|
92
|
-
type Node,
|
|
93
|
-
slot,
|
|
94
|
-
type SlotClass,
|
|
95
|
-
type SlotInstance,
|
|
96
|
-
type SlotProps,
|
|
97
|
-
SlotTypeId,
|
|
98
|
-
} from "./compose/slot";
|
|
99
|
-
export { type SlotRenderer } from "./compose/host";
|
|
100
|
-
export * as Ui from "./compose/ui";
|
|
101
|
-
export {
|
|
102
|
-
type DerivedContract,
|
|
103
|
-
isUi,
|
|
104
|
-
type MadeView,
|
|
105
|
-
ui,
|
|
106
|
-
type UiClass,
|
|
107
|
-
type UiContract,
|
|
108
|
-
type UiManifest,
|
|
109
|
-
UiTypeId,
|
|
110
|
-
UiViewContract,
|
|
111
|
-
type ViewImpl,
|
|
112
|
-
type WireSchemas,
|
|
113
|
-
type WiredUi,
|
|
114
|
-
type WiredUiManifest,
|
|
115
|
-
} from "./compose/ui";
|
|
116
|
-
export { provide } from "./compose/provide";
|
|
117
|
-
export type { Trigger } from "./ui/trigger";
|
|
67
|
+
export * as Procedure from './procedure/procedure'
|
|
68
|
+
export type { ProcedureClass, ProcedureConfig } from './procedure/procedure'
|
|
69
|
+
export * as Channel from './channel/channel'
|
|
70
|
+
export type { ChannelClass, ChannelPolicy } from './channel/channel'
|
|
71
|
+
export * as Namespace from './namespace/namespace'
|
|
72
|
+
export type { FeatureNamespace } from './namespace/namespace'
|
|
118
73
|
|
|
119
|
-
export * as
|
|
120
|
-
export
|
|
74
|
+
export * as Composition from './compose/composition'
|
|
75
|
+
export { liveScoped } from './compose/composition'
|
|
76
|
+
export type {
|
|
77
|
+
CompositionActivation,
|
|
78
|
+
CompositionClass,
|
|
79
|
+
CompositionId,
|
|
80
|
+
CompositionService,
|
|
81
|
+
Frame,
|
|
82
|
+
RenderEnv,
|
|
83
|
+
ScopedCompositionLiveConfig,
|
|
84
|
+
} from './compose/composition'
|
|
85
|
+
export {
|
|
86
|
+
absent,
|
|
87
|
+
type AbsentFill,
|
|
88
|
+
each,
|
|
89
|
+
type EachFill,
|
|
90
|
+
isStructure,
|
|
91
|
+
mount,
|
|
92
|
+
one,
|
|
93
|
+
type OneFill,
|
|
94
|
+
type SlotFill,
|
|
95
|
+
type Structure,
|
|
96
|
+
structureEquals,
|
|
97
|
+
type StructureSlots,
|
|
98
|
+
when,
|
|
99
|
+
} from './compose/structure'
|
|
100
|
+
export { Props } from './compose/props'
|
|
101
|
+
export {
|
|
102
|
+
type CompositionOfSlotTarget,
|
|
103
|
+
type ContractOfSlotTarget,
|
|
104
|
+
type FeatureSlotTarget,
|
|
105
|
+
isSlot,
|
|
106
|
+
type Node,
|
|
107
|
+
type PropsOfSlotTarget,
|
|
108
|
+
slot,
|
|
109
|
+
type SlotClass,
|
|
110
|
+
type SlotComposition,
|
|
111
|
+
type SlotContract,
|
|
112
|
+
type SlotInstance,
|
|
113
|
+
type SlotProps,
|
|
114
|
+
type SlotService,
|
|
115
|
+
type SlotTarget,
|
|
116
|
+
type TargetOfSlot,
|
|
117
|
+
} from './compose/slot'
|
|
118
|
+
export * as Ui from './compose/ui'
|
|
119
|
+
export {
|
|
120
|
+
type CallableView,
|
|
121
|
+
type DerivedContract,
|
|
122
|
+
isUi,
|
|
123
|
+
type MadeView,
|
|
124
|
+
ui,
|
|
125
|
+
type UiClass,
|
|
126
|
+
type UiContract,
|
|
127
|
+
type UiService,
|
|
128
|
+
UiViewContract,
|
|
129
|
+
type ViewImpl,
|
|
130
|
+
} from './compose/ui'
|
|
131
|
+
export { provide, provideExisting, provideMergeExact } from './compose/provide'
|
|
132
|
+
export type { Trigger } from './ui/trigger'
|
|
121
133
|
|
|
122
|
-
export * as
|
|
123
|
-
export {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
134
|
+
export * as Feature from './feature/feature'
|
|
135
|
+
export {
|
|
136
|
+
type EagerFeatureClass,
|
|
137
|
+
type FailedProps,
|
|
138
|
+
type FeatureClass,
|
|
139
|
+
featureModule,
|
|
140
|
+
type FeatureModule,
|
|
141
|
+
type FeatureModuleInput,
|
|
142
|
+
isFeature,
|
|
143
|
+
isFeatureBinding,
|
|
144
|
+
lazyImport,
|
|
145
|
+
type LazyFeatureClass,
|
|
146
|
+
type Placeholders,
|
|
147
|
+
} from './feature/feature'
|
|
129
148
|
|
|
130
|
-
export * as Feature from "./feature/feature";
|
|
131
149
|
export {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
type EagerFeatureClass,
|
|
144
|
-
isFeature,
|
|
145
|
-
isFeatureBinding,
|
|
146
|
-
lazyImport,
|
|
147
|
-
type LazyFeatureClass,
|
|
148
|
-
type LoadedModule,
|
|
149
|
-
mountFeature,
|
|
150
|
-
type Placeholders,
|
|
151
|
-
type ProvidedBy,
|
|
152
|
-
type RequireCarrier,
|
|
153
|
-
} from "./feature/feature";
|
|
154
|
-
export { type SlotChild } from "./compose/slot";
|
|
150
|
+
type CapturedScene,
|
|
151
|
+
featureScene,
|
|
152
|
+
type FeatureSceneConfig,
|
|
153
|
+
isScene,
|
|
154
|
+
type MountedServices,
|
|
155
|
+
profiledScene,
|
|
156
|
+
type Scene,
|
|
157
|
+
scene,
|
|
158
|
+
sceneInstrumentation,
|
|
159
|
+
seedScene,
|
|
160
|
+
} from './scene/scene'
|
|
155
161
|
|
|
156
|
-
export {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
} from "./runtime/bus";
|
|
177
|
-
export {
|
|
178
|
-
type AppRuntime,
|
|
179
|
-
type FeatureMountHandlers,
|
|
180
|
-
makeAppRuntime,
|
|
181
|
-
type RuntimeHandle,
|
|
182
|
-
} from "./runtime/appRuntime";
|
|
183
|
-
export {
|
|
184
|
-
Engine,
|
|
185
|
-
type ReducerEntry,
|
|
186
|
-
Reducers,
|
|
187
|
-
reducersLayer,
|
|
188
|
-
} from "./runtime/loop";
|
|
189
|
-
export {
|
|
190
|
-
CurrentEventBudget,
|
|
191
|
-
defaultEventBudget,
|
|
192
|
-
type EventBudget,
|
|
193
|
-
type ReformOptions,
|
|
194
|
-
resolveEventBudget,
|
|
195
|
-
} from "./runtime/eventBudget";
|
|
196
|
-
export {
|
|
197
|
-
CurrentInstrumentation,
|
|
198
|
-
type Instrumentation,
|
|
199
|
-
noopInstrumentation,
|
|
200
|
-
resolveInstrumentation,
|
|
201
|
-
type SpanEnd,
|
|
202
|
-
} from "./runtime/instrumentation";
|
|
203
|
-
export {
|
|
204
|
-
Queries,
|
|
205
|
-
queriesLayer,
|
|
206
|
-
type QueryHandle,
|
|
207
|
-
type QueryRegistry,
|
|
208
|
-
} from "./runtime/queries";
|
|
209
|
-
export {
|
|
210
|
-
type ChannelClass,
|
|
211
|
-
type ChannelPolicy,
|
|
212
|
-
type ChannelRuntime,
|
|
213
|
-
Channels,
|
|
214
|
-
channelsLayer,
|
|
215
|
-
type ProcedureEntry,
|
|
216
|
-
Procedures,
|
|
217
|
-
proceduresLayer,
|
|
218
|
-
} from "./channel/channel";
|
|
219
|
-
export {
|
|
220
|
-
CurrentTracker,
|
|
221
|
-
type Subscribable,
|
|
222
|
-
type Tracker,
|
|
223
|
-
} from "./internal/track";
|
|
224
|
-
export {
|
|
225
|
-
CaptureSink,
|
|
226
|
-
type CaptureSinkApi,
|
|
227
|
-
type UiCapture,
|
|
228
|
-
} from "./internal/capture";
|
|
229
|
-
export {
|
|
230
|
-
AsyncReducer,
|
|
231
|
-
AsyncSceneLayer,
|
|
232
|
-
DuplicateRegistration,
|
|
233
|
-
EventLoopOverflow,
|
|
234
|
-
FeatureLoadFailed,
|
|
235
|
-
forceSync,
|
|
236
|
-
InvalidProvideTarget,
|
|
237
|
-
UnknownGroupState,
|
|
238
|
-
} from "./internal/errors";
|
|
239
|
-
export {
|
|
240
|
-
defaultScheduler,
|
|
241
|
-
makeScheduler,
|
|
242
|
-
Notifications,
|
|
243
|
-
notificationsLayer,
|
|
244
|
-
resolveScheduler,
|
|
245
|
-
type Scheduler,
|
|
246
|
-
} from "./internal/scheduler";
|
|
247
|
-
export { makeStore, type Store } from "./internal/store";
|
|
248
|
-
export type { FamilyStore } from "./state/stateFamily";
|
|
249
|
-
export {
|
|
250
|
-
type Kind,
|
|
251
|
-
type Manifest,
|
|
252
|
-
yieldableClass,
|
|
253
|
-
} from "./definition/definition";
|
|
254
|
-
export { readTracked } from "./internal/track";
|
|
255
|
-
export { sameKey, wireSources, type WiredSources } from "./internal/sources";
|
|
162
|
+
export { type Priority, publish } from './runtime/bus'
|
|
163
|
+
export {
|
|
164
|
+
type AppRuntime,
|
|
165
|
+
type FeatureMountHandlers,
|
|
166
|
+
makeAppRuntime,
|
|
167
|
+
type RuntimeFeatureAvailability,
|
|
168
|
+
type RuntimeHandle,
|
|
169
|
+
} from './runtime/appRuntime'
|
|
170
|
+
export { Engine } from './runtime/loop'
|
|
171
|
+
export type { EventBudget, ReformOptions } from './runtime/eventBudget'
|
|
172
|
+
export {
|
|
173
|
+
AsyncReducer,
|
|
174
|
+
AsyncSceneLayer,
|
|
175
|
+
DuplicateRegistration,
|
|
176
|
+
EventLoopOverflow,
|
|
177
|
+
FeatureLoadFailed,
|
|
178
|
+
forceSync,
|
|
179
|
+
InvalidProvideTarget,
|
|
180
|
+
UnknownGroupState,
|
|
181
|
+
} from './internal/errors'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Option } from 'effect'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A read-through snapshot cache over a tag-indexed `Map<string, Set<T>>`.
|
|
5
|
+
*
|
|
6
|
+
* The registries keep mutable `Set` buckets so register/unregister stay O(1),
|
|
7
|
+
* but the dispatch loop must iterate a *snapshot*: an entry registered while a
|
|
8
|
+
* frame is folding must not join the fold already in flight (`Set` iteration is
|
|
9
|
+
* live, an array copy is not). Copying per event would pay that snapshot on
|
|
10
|
+
* every dispatch, so the copy is cached and dropped only when the bucket
|
|
11
|
+
* actually changes — registration is rare, dispatch is not.
|
|
12
|
+
*
|
|
13
|
+
* A tag with no bucket returns a shared empty array and is never cached, so
|
|
14
|
+
* events nothing handles allocate nothing and cannot grow the cache.
|
|
15
|
+
*/
|
|
16
|
+
export interface BucketCache<T> {
|
|
17
|
+
readonly read: (tag: string) => ReadonlyArray<T>
|
|
18
|
+
readonly invalidate: (tag: string) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const makeBucketCache = <T>(source: Map<string, Set<T>>): BucketCache<T> => {
|
|
22
|
+
const empty: ReadonlyArray<T> = []
|
|
23
|
+
const cache = new Map<string, ReadonlyArray<T>>()
|
|
24
|
+
const build = (tag: string): ReadonlyArray<T> =>
|
|
25
|
+
Option.match(Option.fromNullable(source.get(tag)), {
|
|
26
|
+
onNone: (): ReadonlyArray<T> => empty,
|
|
27
|
+
onSome: (bucket) => {
|
|
28
|
+
const current: ReadonlyArray<T> = Array.from(bucket)
|
|
29
|
+
cache.set(tag, current)
|
|
30
|
+
return current
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
return {
|
|
34
|
+
read: (tag) => Option.getOrElse(Option.fromNullable(cache.get(tag)), () => build(tag)),
|
|
35
|
+
invalidate: (tag) => {
|
|
36
|
+
cache.delete(tag)
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
}
|
package/src/internal/capture.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Context } from 'effect'
|
|
2
2
|
import type { Trigger } from '../ui/trigger'
|
|
3
3
|
|
|
4
|
-
export interface
|
|
4
|
+
export interface CapturedRender {
|
|
5
5
|
readonly name: string
|
|
6
6
|
readonly props: unknown
|
|
7
7
|
readonly events: Record<string, Trigger<unknown>>
|
|
@@ -9,11 +9,16 @@ export interface UiCapture {
|
|
|
9
9
|
readonly key?: string
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
export type UiCapture = CapturedRender
|
|
13
|
+
|
|
12
14
|
export interface CaptureSinkApi {
|
|
13
|
-
record(capture:
|
|
15
|
+
record(capture: CapturedRender): void
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
const CaptureSinkBase: Context.TagClass<
|
|
17
|
-
|
|
18
|
+
const CaptureSinkBase: Context.TagClass<
|
|
19
|
+
CaptureSink,
|
|
20
|
+
'reform/internal/CaptureSink',
|
|
21
|
+
CaptureSinkApi
|
|
22
|
+
> = Context.Tag('reform/internal/CaptureSink')<CaptureSink, CaptureSinkApi>()
|
|
18
23
|
|
|
19
24
|
export class CaptureSink extends CaptureSinkBase {}
|
package/src/internal/env.ts
CHANGED
package/src/internal/errors.ts
CHANGED
|
@@ -4,7 +4,9 @@ type TaggedErrorClass<Tag extends string, A extends Record<string, unknown>> = n
|
|
|
4
4
|
args: A,
|
|
5
5
|
) => Cause.YieldableError & { readonly _tag: Tag } & Readonly<A>
|
|
6
6
|
|
|
7
|
-
type EmptyTaggedErrorClass<Tag extends string> = new () => Cause.YieldableError & {
|
|
7
|
+
type EmptyTaggedErrorClass<Tag extends string> = new () => Cause.YieldableError & {
|
|
8
|
+
readonly _tag: Tag
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
const InvalidProvideTargetBase: EmptyTaggedErrorClass<'reform/InvalidProvideTarget'> =
|
|
10
12
|
Data.TaggedError('reform/InvalidProvideTarget')<{}>
|
|
@@ -15,8 +17,10 @@ export class InvalidProvideTarget extends InvalidProvideTargetBase {
|
|
|
15
17
|
}
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
const UnknownGroupStateBase: TaggedErrorClass<
|
|
19
|
-
|
|
20
|
+
const UnknownGroupStateBase: TaggedErrorClass<
|
|
21
|
+
'reform/UnknownGroupState',
|
|
22
|
+
{ readonly name: string }
|
|
23
|
+
> = Data.TaggedError('reform/UnknownGroupState')<{ readonly name: string }>
|
|
20
24
|
|
|
21
25
|
export class UnknownGroupState extends UnknownGroupStateBase {
|
|
22
26
|
override get message(): string {
|
|
@@ -24,8 +28,10 @@ export class UnknownGroupState extends UnknownGroupStateBase {
|
|
|
24
28
|
}
|
|
25
29
|
}
|
|
26
30
|
|
|
27
|
-
const FeatureLoadFailedBase: TaggedErrorClass<
|
|
28
|
-
|
|
31
|
+
const FeatureLoadFailedBase: TaggedErrorClass<
|
|
32
|
+
'reform/FeatureLoadFailed',
|
|
33
|
+
{ readonly cause: unknown }
|
|
34
|
+
> = Data.TaggedError('reform/FeatureLoadFailed')<{ readonly cause: unknown }>
|
|
29
35
|
|
|
30
36
|
export class FeatureLoadFailed extends FeatureLoadFailedBase {
|
|
31
37
|
override get message(): string {
|
|
@@ -33,8 +39,9 @@ export class FeatureLoadFailed extends FeatureLoadFailedBase {
|
|
|
33
39
|
}
|
|
34
40
|
}
|
|
35
41
|
|
|
36
|
-
const AsyncReducerBase: EmptyTaggedErrorClass<'reform/AsyncReducer'> =
|
|
37
|
-
|
|
42
|
+
const AsyncReducerBase: EmptyTaggedErrorClass<'reform/AsyncReducer'> = Data.TaggedError(
|
|
43
|
+
'reform/AsyncReducer',
|
|
44
|
+
)<{}>
|
|
38
45
|
|
|
39
46
|
export class AsyncReducer extends AsyncReducerBase {
|
|
40
47
|
override get message(): string {
|
|
@@ -42,8 +49,9 @@ export class AsyncReducer extends AsyncReducerBase {
|
|
|
42
49
|
}
|
|
43
50
|
}
|
|
44
51
|
|
|
45
|
-
const AsyncSceneLayerBase: EmptyTaggedErrorClass<'reform/AsyncSceneLayer'> =
|
|
46
|
-
|
|
52
|
+
const AsyncSceneLayerBase: EmptyTaggedErrorClass<'reform/AsyncSceneLayer'> = Data.TaggedError(
|
|
53
|
+
'reform/AsyncSceneLayer',
|
|
54
|
+
)<{}>
|
|
47
55
|
|
|
48
56
|
export class AsyncSceneLayer extends AsyncSceneLayerBase {
|
|
49
57
|
override get message(): string {
|
|
@@ -81,7 +89,10 @@ export const forceSync = <A>(thunk: () => A): A => {
|
|
|
81
89
|
const DuplicateRegistrationBase: TaggedErrorClass<
|
|
82
90
|
'reform/DuplicateRegistration',
|
|
83
91
|
{ readonly kind: string; readonly name: string }
|
|
84
|
-
> = Data.TaggedError('reform/DuplicateRegistration')<{
|
|
92
|
+
> = Data.TaggedError('reform/DuplicateRegistration')<{
|
|
93
|
+
readonly kind: string
|
|
94
|
+
readonly name: string
|
|
95
|
+
}>
|
|
85
96
|
|
|
86
97
|
export class DuplicateRegistration extends DuplicateRegistrationBase {
|
|
87
98
|
override get message(): string {
|