@playfast/reform-proof 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 +12 -12
- package/package.json +18 -18
- package/src/engine.ts +1657 -8
- package/src/fingerprint.test.ts +24 -0
- package/src/fingerprint.ts +73 -0
- package/src/index.ts +352 -87
- package/src/nested-feature.test.ts +174 -0
- package/src/runner.ts +5 -1
- package/src/structure-events.test.ts +9 -3
- package/src/structure-locators.test.ts +19 -9
- package/src/typed-seams.test.ts +6 -3
- package/src/assertions.ts +0 -65
- package/src/driverTypes.ts +0 -19
- package/src/execution.ts +0 -100
- package/src/facade.ts +0 -258
- package/src/product.ts +0 -77
- package/src/runtimeFacade.ts +0 -269
- package/src/runtimeTreeDispose.ts +0 -21
- package/src/runtimeTreeDriver.ts +0 -285
- package/src/runtimeTreeFacade.ts +0 -134
- package/src/runtimeTreeSettle.ts +0 -34
- package/src/runtimeTreeTypes.ts +0 -99
- package/src/sink.ts +0 -73
- package/src/treeBindings.ts +0 -121
package/src/treeBindings.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { Effect, Match, Option, Record as Rec } from 'effect'
|
|
2
|
-
import {
|
|
3
|
-
type CompositionClass,
|
|
4
|
-
isFeatureBinding,
|
|
5
|
-
type SlotChild,
|
|
6
|
-
type SlotClass,
|
|
7
|
-
type SlotFill,
|
|
8
|
-
type Structure,
|
|
9
|
-
type UiContract,
|
|
10
|
-
} from '@playfast/reform'
|
|
11
|
-
import { eventsOf, type Sink, uiNameOf } from './sink'
|
|
12
|
-
|
|
13
|
-
export interface Mounted {
|
|
14
|
-
readonly comp: CompositionClass<unknown>
|
|
15
|
-
readonly props: unknown
|
|
16
|
-
readonly key: Option.Option<string>
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface NodeRef {
|
|
20
|
-
readonly name: string
|
|
21
|
-
readonly index: number
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface SettleProgress {
|
|
25
|
-
readonly previous: string
|
|
26
|
-
readonly remaining: number
|
|
27
|
-
readonly stable: boolean
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export interface PumpStep {
|
|
31
|
-
readonly input: unknown
|
|
32
|
-
readonly index: number
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export const childComposition = (child: SlotChild): CompositionClass<unknown> =>
|
|
36
|
-
isFeatureBinding(child) ? child.composition : child
|
|
37
|
-
|
|
38
|
-
export const slotsOf = (comp: CompositionClass<unknown>): Record<string, SlotClass> =>
|
|
39
|
-
Option.getOrElse(Option.fromNullable(comp.manifest.slots), () => ({}))
|
|
40
|
-
|
|
41
|
-
const isSlotFill = (candidate: unknown): candidate is SlotFill<unknown> =>
|
|
42
|
-
typeof candidate === 'object' &&
|
|
43
|
-
candidate !== null &&
|
|
44
|
-
'_tag' in candidate &&
|
|
45
|
-
(candidate._tag === 'Each' || candidate._tag === 'One' || candidate._tag === 'Absent')
|
|
46
|
-
|
|
47
|
-
export const structureFills = (
|
|
48
|
-
structure: Structure<UiContract>,
|
|
49
|
-
): Record<string, SlotFill<unknown>> =>
|
|
50
|
-
Rec.fromEntries(
|
|
51
|
-
Rec.toEntries(structure.slots).flatMap(([slotName, fillValue]) =>
|
|
52
|
-
isSlotFill(fillValue) ? [[slotName, fillValue] as const] : [],
|
|
53
|
-
),
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
export const collectBindings: (
|
|
57
|
-
root: CompositionClass<unknown>,
|
|
58
|
-
) => Effect.Effect<Map<SlotClass, CompositionClass<unknown>>, never, SlotChild> = Effect.fn(
|
|
59
|
-
'collectBindings',
|
|
60
|
-
)(function* (
|
|
61
|
-
root: CompositionClass<unknown>,
|
|
62
|
-
): Effect.fn.Return<Map<SlotClass, CompositionClass<unknown>>, never, SlotChild> {
|
|
63
|
-
const bindings = new Map<SlotClass, CompositionClass<unknown>>()
|
|
64
|
-
const walk: (comp: CompositionClass<unknown>) => Effect.Effect<void, never, SlotChild> = Effect.fn(
|
|
65
|
-
'collectBindings.walk',
|
|
66
|
-
)(function* (comp: CompositionClass<unknown>): Effect.fn.Return<void, never, SlotChild> {
|
|
67
|
-
yield* Effect.forEach(Rec.values(slotsOf(comp)), (slotClass) =>
|
|
68
|
-
Effect.gen(function* () {
|
|
69
|
-
if (bindings.has(slotClass)) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
const child = childComposition(yield* slotClass.tag)
|
|
73
|
-
bindings.set(slotClass, child)
|
|
74
|
-
yield* walk(child)
|
|
75
|
-
}),
|
|
76
|
-
)
|
|
77
|
-
})
|
|
78
|
-
yield* walk(root)
|
|
79
|
-
return bindings
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
const enqueueFill = (
|
|
83
|
-
slotName: string,
|
|
84
|
-
fill: SlotFill<unknown>,
|
|
85
|
-
child: CompositionClass<unknown>,
|
|
86
|
-
): ReadonlyArray<Mounted> =>
|
|
87
|
-
Match.value(fill).pipe(
|
|
88
|
-
Match.when({ _tag: 'Each' }, (each) =>
|
|
89
|
-
each.items.map((entry) => ({
|
|
90
|
-
comp: child,
|
|
91
|
-
props: entry.props,
|
|
92
|
-
key: Option.some(entry.key),
|
|
93
|
-
})),
|
|
94
|
-
),
|
|
95
|
-
Match.when({ _tag: 'One' }, (oneFill) => [
|
|
96
|
-
{ comp: child, props: oneFill.props, key: Option.some(`${slotName}.0`) },
|
|
97
|
-
]),
|
|
98
|
-
Match.when({ _tag: 'Absent' }, () => []),
|
|
99
|
-
Match.exhaustive,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
export const driveStructure = (
|
|
103
|
-
comp: CompositionClass<unknown>,
|
|
104
|
-
structure: Structure<UiContract>,
|
|
105
|
-
key: Option.Option<string>,
|
|
106
|
-
sink: Sink,
|
|
107
|
-
bindings: ReadonlyMap<SlotClass, CompositionClass<unknown>>,
|
|
108
|
-
): ReadonlyArray<Mounted> => {
|
|
109
|
-
sink.api.record({
|
|
110
|
-
name: uiNameOf(comp),
|
|
111
|
-
props: structure.props,
|
|
112
|
-
events: eventsOf(structure),
|
|
113
|
-
...(Option.isSome(key) ? { key: key.value } : {}),
|
|
114
|
-
})
|
|
115
|
-
const fills = structureFills(structure)
|
|
116
|
-
return Rec.toEntries(slotsOf(comp)).flatMap(([slotName, slotClass]) => {
|
|
117
|
-
const child = bindings.get(slotClass)
|
|
118
|
-
const fill = fills[slotName]
|
|
119
|
-
return child === undefined || fill === undefined ? [] : enqueueFill(slotName, fill, child)
|
|
120
|
-
})
|
|
121
|
-
}
|