@playfast/reform 1.0.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 +103 -56
- package/package.json +17 -17
- package/src/boundary/boundary.test.ts +63 -49
- package/src/boundary/boundary.ts +144 -113
- package/src/calc/asyncCalc.invalidate.test.ts +518 -32
- package/src/calc/asyncCalc.test.ts +207 -213
- package/src/calc/asyncCalc.ts +131 -154
- package/src/calc/asyncData.ts +0 -37
- package/src/calc/calc.test.ts +7 -33
- package/src/calc/calc.ts +44 -58
- package/src/calc/calcFamily.test.ts +80 -34
- package/src/calc/calcFamily.ts +54 -65
- package/src/calc/compose.test.ts +1 -12
- package/src/calc/compose.ts +1 -36
- package/src/calc/queryState.ts +0 -23
- package/src/channel/channel.ts +126 -111
- package/src/compose/composition.test.ts +19 -0
- package/src/compose/composition.ts +351 -127
- package/src/compose/host.ts +0 -6
- package/src/compose/props.ts +13 -12
- package/src/compose/provide.ts +189 -62
- package/src/compose/slot.ts +158 -49
- package/src/compose/structure.test.ts +6 -9
- package/src/compose/structure.ts +108 -79
- package/src/compose/ui.test.ts +19 -7
- package/src/compose/ui.ts +155 -156
- package/src/compose/ui.typecheck.ts +40 -18
- package/src/definition/definition.ts +22 -41
- package/src/event/event.fromSource.test.ts +172 -0
- package/src/event/event.test.ts +10 -3
- package/src/event/event.ts +102 -27
- package/src/event/eventGroup.ts +0 -1
- package/src/feature/feature.mount.test.ts +122 -43
- package/src/feature/feature.test.ts +46 -21
- package/src/feature/feature.ts +1347 -256
- package/src/feature/feature.typecheck.ts +273 -68
- package/src/graph/closure.ts +403 -0
- package/src/index.ts +68 -126
- package/src/internal/bucketCache.ts +39 -0
- package/src/internal/capture.ts +9 -24
- package/src/internal/env.ts +7 -0
- package/src/internal/errors.test.ts +0 -6
- package/src/internal/errors.ts +37 -60
- package/src/internal/inspect.test.ts +0 -6
- package/src/internal/inspect.ts +0 -12
- package/src/internal/queryDriver.ts +105 -201
- package/src/internal/queryDriverStore.ts +156 -0
- package/src/internal/queryDriverTypes.ts +59 -0
- package/src/internal/queryEvents.ts +0 -12
- package/src/internal/queryStore.ts +0 -14
- package/src/internal/reuse.test.ts +10 -14
- package/src/internal/reuse.ts +5 -30
- package/src/internal/scheduler.ts +4 -44
- package/src/internal/seeds.ts +0 -14
- package/src/internal/sources.ts +26 -49
- package/src/internal/stateRegistry.ts +0 -14
- package/src/internal/store.test.ts +1 -3
- package/src/internal/store.ts +0 -37
- package/src/internal/track.ts +3 -20
- package/src/internal/variance.ts +5 -0
- package/src/internal.ts +222 -0
- package/src/namespace/namespace.test.ts +46 -0
- package/src/namespace/namespace.ts +106 -0
- package/src/procedure/procedure.ts +40 -35
- package/src/reducer/reducer.ts +78 -52
- package/src/remote/remoteState.test.ts +590 -397
- package/src/remote/remoteState.ts +425 -347
- package/src/remote/remoteState.typecheck.ts +47 -56
- package/src/runtime/appRuntime.activation.test.ts +100 -0
- package/src/runtime/appRuntime.test.ts +249 -0
- package/src/runtime/appRuntime.ts +415 -97
- package/src/runtime/bus.ts +2 -15
- package/src/runtime/eventBudget.test.ts +152 -0
- package/src/runtime/eventBudget.ts +120 -0
- package/src/runtime/hardening.test.ts +73 -13
- package/src/runtime/instrumentation.test.ts +55 -52
- package/src/runtime/instrumentation.ts +6 -60
- package/src/runtime/loop.test.ts +36 -17
- package/src/runtime/loop.ts +87 -88
- package/src/runtime/queries.ts +0 -17
- package/src/scene/featureScene.test.ts +61 -0
- package/src/scene/scene.ts +247 -104
- package/src/scene/seedScene.test.ts +42 -79
- package/src/state/state.nominal.typecheck.ts +68 -0
- package/src/state/state.test.ts +17 -0
- package/src/state/state.ts +80 -46
- package/src/state/stateFamily.test.ts +16 -11
- package/src/state/stateFamily.ts +55 -65
- package/src/state/stateGroup.ts +53 -64
- package/src/state/token.ts +40 -23
- package/src/synced/syncedStore.ts +46 -58
- package/src/testkit/flight.testkit.ts +75 -0
- package/src/ui/node.ts +0 -6
- package/src/ui/trigger.ts +0 -5
- package/src/wire/tree.test.ts +8 -7
- package/src/wire/tree.ts +0 -39
- package/src/wire/triggers.test.ts +6 -6
- package/src/wire/triggers.ts +14 -32
- package/src/internal/ctx.ts +0 -16
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
import { Effect,
|
|
2
|
-
import { expect,
|
|
1
|
+
import { Effect, Option } from 'effect'
|
|
2
|
+
import { expect, it } from '@effect/vitest'
|
|
3
3
|
import * as Composition from '../compose/composition'
|
|
4
|
+
import { mount } from '../compose/structure'
|
|
4
5
|
import { ui } from '../compose/ui'
|
|
5
6
|
import * as Feature from './feature'
|
|
6
7
|
import { featureModule, isFeature, isFeatureBinding, lazyImport } from './feature'
|
|
7
8
|
|
|
8
9
|
// Minimal composition surface to hang features off — definitions only, no logic.
|
|
9
10
|
class TestUi extends ui('TestUi')<{ props: {}; events: {} }>() {}
|
|
10
|
-
class TestComp extends Composition.make('TestComp', {
|
|
11
|
-
|
|
11
|
+
class TestComp extends Composition.make('TestComp', {
|
|
12
|
+
title: 'Test',
|
|
13
|
+
ui: TestUi,
|
|
14
|
+
})<TestComp>() {}
|
|
15
|
+
class FailComp extends Composition.make('FailComp', {
|
|
16
|
+
title: 'Fail',
|
|
17
|
+
ui: TestUi,
|
|
18
|
+
})<FailComp>() {}
|
|
12
19
|
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
const TestLive = Composition.live(TestComp, function* () {
|
|
21
|
+
return mount({ props: {}, slots: {} })
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
// A valid Feature module owns its declared root Composition service.
|
|
25
|
+
const mod = featureModule([], TestLive)
|
|
15
26
|
|
|
16
27
|
class LazyFeature extends Feature.make('lazyFeature', {
|
|
17
28
|
loadingStrategy: 'lazy',
|
|
@@ -20,41 +31,55 @@ class LazyFeature extends Feature.make('lazyFeature', {
|
|
|
20
31
|
placeholder: { loading: TestComp, failed: FailComp },
|
|
21
32
|
}) {}
|
|
22
33
|
|
|
34
|
+
class SameShapeFeature extends Feature.make('lazyFeature', {
|
|
35
|
+
loadingStrategy: 'lazy',
|
|
36
|
+
composition: TestComp,
|
|
37
|
+
load: lazyImport(() => Promise.resolve({ default: mod })),
|
|
38
|
+
placeholder: { loading: TestComp, failed: FailComp },
|
|
39
|
+
}) {}
|
|
40
|
+
|
|
23
41
|
class EagerFeature extends Feature.make('eagerFeature', {
|
|
24
42
|
composition: TestComp,
|
|
25
43
|
module: mod,
|
|
26
44
|
}) {}
|
|
27
45
|
|
|
28
|
-
|
|
46
|
+
const LazyNative = Feature.tree<typeof LazyFeature>(LazyFeature.token)
|
|
47
|
+
const EagerNative = Feature.tree<typeof EagerFeature>(EagerFeature.token)
|
|
48
|
+
|
|
49
|
+
it('a lazy feature reflects as a Feature manifest with placeholders, no chunk loaded', () => {
|
|
29
50
|
expect(LazyFeature.manifest.kind).toBe('Feature')
|
|
30
51
|
expect(LazyFeature.manifest.name).toBe('lazyFeature')
|
|
31
52
|
expect(LazyFeature.manifest.strategy).toBe('lazy')
|
|
32
53
|
expect(LazyFeature.manifest.composition.name).toBe('TestComp')
|
|
33
54
|
expect(Option.getOrThrow(LazyFeature.manifest.placeholder).loading.name).toBe('TestComp')
|
|
34
55
|
expect(Option.getOrThrow(LazyFeature.manifest.placeholder).failed.name).toBe('FailComp')
|
|
35
|
-
expect(
|
|
56
|
+
expect(LazyNative.eagerModule).toBeUndefined()
|
|
36
57
|
})
|
|
37
58
|
|
|
38
|
-
|
|
59
|
+
it('an eager feature reflects as default strategy with its module available', () => {
|
|
39
60
|
expect(EagerFeature.manifest.strategy).toBe('default')
|
|
40
61
|
expect(Option.isNone(EagerFeature.manifest.placeholder)).toBe(true)
|
|
41
|
-
expect(
|
|
62
|
+
expect(EagerNative.eagerModule).toBe(mod)
|
|
42
63
|
})
|
|
43
64
|
|
|
44
|
-
|
|
65
|
+
it('isFeature / isFeatureBinding discriminate', () => {
|
|
45
66
|
expect(isFeature(LazyFeature)).toBe(true)
|
|
46
67
|
expect(isFeature(TestComp)).toBe(false)
|
|
47
68
|
expect(isFeature(null)).toBe(false)
|
|
48
|
-
expect(isFeatureBinding(
|
|
69
|
+
expect(isFeatureBinding(LazyNative.binding)).toBe(true)
|
|
49
70
|
expect(isFeatureBinding(TestComp)).toBe(false)
|
|
71
|
+
expect(LazyFeature.token).not.toBe(SameShapeFeature.token)
|
|
72
|
+
expect(LazyFeature.token.identity).not.toBe(SameShapeFeature.token.identity)
|
|
50
73
|
})
|
|
51
74
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
75
|
+
it.live('load is an Effect (not a thenable) that yields the module and its requires', () =>
|
|
76
|
+
Effect.gen(function* () {
|
|
77
|
+
// No `.then` on `load` — it is an Effect, run on the Effect runtime.
|
|
78
|
+
expect('then' in LazyNative.load).toBe(false)
|
|
79
|
+
const loaded = yield* LazyNative.load
|
|
80
|
+
expect(loaded.requires).toEqual([])
|
|
81
|
+
expect(loaded).toBe(mod)
|
|
82
|
+
// default strategy resolves immediately to its module.
|
|
83
|
+
expect(yield* EagerNative.load).toBe(mod)
|
|
84
|
+
}),
|
|
85
|
+
)
|