foldkit 0.161.0 → 0.162.0-canary.591649ea58a6
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 +4 -4
- package/dist/asyncData/asyncData.d.ts +1 -1
- package/dist/asyncData/asyncData.js +1 -1
- package/dist/devTools/store.d.ts.map +1 -1
- package/dist/devTools/store.js +16 -16
- package/dist/experimental/machine/machine.d.ts +1 -1
- package/dist/experimental/machine/machine.js +1 -1
- package/dist/runtime/deepFreeze.d.ts +1 -1
- package/dist/runtime/deepFreeze.js +1 -1
- package/dist/runtime/managedResourceFibers.d.ts +1 -1
- package/dist/runtime/managedResourceFibers.d.ts.map +1 -1
- package/dist/runtime/managedResourceFibers.js +3 -2
- package/dist/runtime/subscriptionFibers.d.ts +1 -1
- package/dist/runtime/subscriptionFibers.d.ts.map +1 -1
- package/dist/runtime/subscriptionFibers.js +3 -2
- package/dist/struct/index.d.ts +4 -4
- package/dist/struct/index.d.ts.map +1 -1
- package/dist/struct/index.js +4 -4
- package/dist/struct/public.d.ts +1 -1
- package/dist/struct/public.d.ts.map +1 -1
- package/dist/struct/public.js +1 -1
- package/dist/submodel/submodel.d.ts +3 -3
- package/dist/subscription/{keyboardShortcuts.d.ts → keyBindings.d.ts} +23 -23
- package/dist/subscription/keyBindings.d.ts.map +1 -0
- package/dist/subscription/{keyboardShortcuts.js → keyBindings.js} +42 -43
- package/dist/subscription/public.d.ts +2 -2
- package/dist/subscription/public.d.ts.map +1 -1
- package/dist/subscription/public.js +1 -1
- package/dist/test/apps/bubbling.js +5 -5
- package/dist/test/apps/colorPicker.js +2 -2
- package/dist/test/apps/contentEditableEditor.js +3 -3
- package/dist/test/apps/contextMenu.js +2 -2
- package/dist/test/apps/counter.d.ts.map +1 -1
- package/dist/test/apps/counter.js +8 -5
- package/dist/test/apps/crashOnRender.js +3 -3
- package/dist/test/apps/drafts.js +3 -3
- package/dist/test/apps/feedSocket.js +5 -5
- package/dist/test/apps/fileUpload.js +2 -2
- package/dist/test/apps/focusBoundary.js +3 -3
- package/dist/test/apps/formChild.js +4 -4
- package/dist/test/apps/interactions.js +7 -7
- package/dist/test/apps/keypress.js +3 -3
- package/dist/test/apps/keypressSelf.js +2 -2
- package/dist/test/apps/login.js +7 -7
- package/dist/test/apps/mountPanel.js +4 -4
- package/dist/test/apps/multiRole.js +2 -2
- package/dist/test/apps/pointer.js +3 -3
- package/dist/test/apps/resumeUpload.js +5 -5
- package/dist/test/apps/scorePanel.js +2 -2
- package/dist/test/apps/selectiveKeys.d.ts.map +1 -1
- package/dist/test/apps/selectiveKeys.js +5 -3
- package/dist/test/apps/uploads.d.ts.map +1 -1
- package/dist/test/apps/uploads.js +13 -7
- package/dist/test/query.js +5 -5
- package/dist/update/update.d.ts +4 -4
- package/dist/update/update.js +3 -3
- package/package.json +1 -1
- package/dist/subscription/keyboardShortcuts.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -45,7 +45,7 @@ import { Schema } from 'effect'
|
|
|
45
45
|
import { Runtime, Update } from 'foldkit'
|
|
46
46
|
import { Document, HtmlBuilder } from 'foldkit/html'
|
|
47
47
|
import { defineMessageUnion } from 'foldkit/message'
|
|
48
|
-
import {
|
|
48
|
+
import { modifyFields } from 'foldkit/struct'
|
|
49
49
|
|
|
50
50
|
// MODEL
|
|
51
51
|
|
|
@@ -66,12 +66,12 @@ export type Message = typeof Message.Type
|
|
|
66
66
|
export const update = (model: Model, message: Message) =>
|
|
67
67
|
Message.match<Update.Return<Model, Message>>(message, {
|
|
68
68
|
ClickedDecrement: () => ({
|
|
69
|
-
model:
|
|
69
|
+
model: modifyFields(model, { count: count => count - 1 }),
|
|
70
70
|
}),
|
|
71
71
|
ClickedIncrement: () => ({
|
|
72
|
-
model:
|
|
72
|
+
model: modifyFields(model, { count: count => count + 1 }),
|
|
73
73
|
}),
|
|
74
|
-
ClickedReset: () => ({ model:
|
|
74
|
+
ClickedReset: () => ({ model: modifyFields(model, { count: () => 0 }) }),
|
|
75
75
|
})
|
|
76
76
|
|
|
77
77
|
// INIT
|
|
@@ -407,7 +407,7 @@ export declare const all: <const Inputs extends Iterable<AsyncData<any, any>> |
|
|
|
407
407
|
*
|
|
408
408
|
* // One update arm folds it in, whatever the previous state was:
|
|
409
409
|
* SettledLoadNotes: ({ result }) => ({
|
|
410
|
-
* model:
|
|
410
|
+
* model: modifyFields(model, { notes: AsyncData.settle(result) }),
|
|
411
411
|
* })
|
|
412
412
|
* ```
|
|
413
413
|
*/
|
|
@@ -418,7 +418,7 @@ export const all = (inputs) => {
|
|
|
418
418
|
*
|
|
419
419
|
* // One update arm folds it in, whatever the previous state was:
|
|
420
420
|
* SettledLoadNotes: ({ result }) => ({
|
|
421
|
-
* model:
|
|
421
|
+
* model: modifyFields(model, { notes: AsyncData.settle(result) }),
|
|
422
422
|
* })
|
|
423
423
|
* ```
|
|
424
424
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../src/devTools/store.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EACN,OAAO,EACP,OAAO,EAEP,MAAM,EAIN,eAAe,EAEhB,MAAM,QAAQ,CAAA;AAIf,eAAO,MAAM,UAAU,KAAK,CAAA;AAM5B,MAAM,MAAM,UAAU,GAAG,QAAQ,CAAC;IAChC,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;IACrC,aAAa,EAAE,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAA;CACvC,CAAC,CAAA;AAEF,eAAO,MAAM,SAAS,EAAE,UAGvB,CAAA;AAID,eAAO,MAAM,WAAW,aACZ,OAAO,WACR,OAAO,KACf,UA4FF,CAAA;AAID,MAAM,MAAM,aAAa,GAAG,QAAQ,CAAC;IACnC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAA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AK,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1D,oBAAoB,EAAE,CACpB,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,EACvC,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,KAClC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IACxB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IAC1D,iBAAiB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAA;IAC3E,cAAc,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA;IAC5D,MAAM,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACjD,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC3B,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC1B,QAAQ,EAAE,eAAe,CAAC,eAAe,CAAC,UAAU,CAAC,CAAA;CACtD,CAAC,CAAA"}
|
package/dist/devTools/store.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Array, Effect, HashMap, HashSet, Match, Option, Predicate, Record, String, SubscriptionRef, pipe, } from 'effect';
|
|
2
|
-
import {
|
|
2
|
+
import { modifyFields } from '../struct/index.js';
|
|
3
3
|
export const INIT_INDEX = -1;
|
|
4
4
|
const DEFAULT_KEYFRAME_INTERVAL = 31;
|
|
5
5
|
const DEFAULT_MAX_ENTRIES = 100;
|
|
@@ -126,14 +126,14 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
126
126
|
const nextStartIndex = state.startIndex + keyframeInterval;
|
|
127
127
|
const isPausedAtRetainedIndex = state.pausedAtIndex >= nextStartIndex ||
|
|
128
128
|
state.pausedAtIndex === INIT_INDEX;
|
|
129
|
-
return
|
|
129
|
+
return modifyFields(state, {
|
|
130
130
|
entries: Array.drop(keyframeInterval),
|
|
131
131
|
keyframes: HashMap.remove(state.startIndex),
|
|
132
132
|
startIndex: () => nextStartIndex,
|
|
133
133
|
isPaused: isPaused => isPaused && isPausedAtRetainedIndex,
|
|
134
134
|
});
|
|
135
135
|
};
|
|
136
|
-
const recordInit = (model, commands, mountStarts = []) => SubscriptionRef.update(stateRef, state =>
|
|
136
|
+
const recordInit = (model, commands, mountStarts = []) => SubscriptionRef.update(stateRef, state => modifyFields(state, {
|
|
137
137
|
maybeInitModel: () => Option.some(model),
|
|
138
138
|
initCommands: () => commands,
|
|
139
139
|
initMountStarts: () => mountStarts,
|
|
@@ -147,7 +147,7 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
147
147
|
? computeDiff(modelBeforeUpdate, modelAfterUpdate)
|
|
148
148
|
: emptyDiff;
|
|
149
149
|
const hasChangedFields = HashSet.size(diff.changedPaths) > 0;
|
|
150
|
-
const nextState =
|
|
150
|
+
const nextState = modifyFields(state, {
|
|
151
151
|
entries: Array.append({
|
|
152
152
|
tag: message._tag,
|
|
153
153
|
message,
|
|
@@ -171,12 +171,12 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
171
171
|
}
|
|
172
172
|
});
|
|
173
173
|
const recordResolvedCommand = (id, submodelPath) => SubscriptionRef.update(stateRef, state => {
|
|
174
|
-
const updateCommands = (commands) => pipe(commands, Array.findFirstIndex(command => command.id === id), Option.flatMap(index => Array.modify(commands, index, command =>
|
|
174
|
+
const updateCommands = (commands) => pipe(commands, Array.findFirstIndex(command => command.id === id), Option.flatMap(index => Array.modify(commands, index, command => modifyFields(command, {
|
|
175
175
|
maybeSubmodelPath: () => Option.some(submodelPath),
|
|
176
176
|
}))));
|
|
177
177
|
const maybeInitCommands = updateCommands(state.initCommands);
|
|
178
178
|
if (Option.isSome(maybeInitCommands)) {
|
|
179
|
-
return
|
|
179
|
+
return modifyFields(state, {
|
|
180
180
|
initCommands: () => maybeInitCommands.value,
|
|
181
181
|
});
|
|
182
182
|
}
|
|
@@ -186,11 +186,11 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
186
186
|
}
|
|
187
187
|
const maybeEntries = Array.modify(state.entries, maybeEntryIndex.value, entry => Option.match(updateCommands(entry.commands), {
|
|
188
188
|
onNone: () => entry,
|
|
189
|
-
onSome: nextCommands =>
|
|
189
|
+
onSome: nextCommands => modifyFields(entry, { commands: () => nextCommands }),
|
|
190
190
|
}));
|
|
191
191
|
return Option.match(maybeEntries, {
|
|
192
192
|
onNone: () => state,
|
|
193
|
-
onSome: nextEntries =>
|
|
193
|
+
onSome: nextEntries => modifyFields(state, { entries: () => nextEntries }),
|
|
194
194
|
});
|
|
195
195
|
});
|
|
196
196
|
/** Attaches Mount lifecycle events from the most recent render to the
|
|
@@ -209,11 +209,11 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
209
209
|
return state;
|
|
210
210
|
}
|
|
211
211
|
return Array.match(state.entries, {
|
|
212
|
-
onEmpty: () =>
|
|
212
|
+
onEmpty: () => modifyFields(state, {
|
|
213
213
|
initMountStarts: Array.appendAll(mountStarts),
|
|
214
214
|
}),
|
|
215
|
-
onNonEmpty: entries =>
|
|
216
|
-
entries: () => Array.modifyLastNonEmpty(entries, last =>
|
|
215
|
+
onNonEmpty: entries => modifyFields(state, {
|
|
216
|
+
entries: () => Array.modifyLastNonEmpty(entries, last => modifyFields(last, {
|
|
217
217
|
mountStarts: Array.appendAll(mountStarts),
|
|
218
218
|
mountEnds: Array.appendAll(mountEnds),
|
|
219
219
|
})),
|
|
@@ -243,14 +243,14 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
243
243
|
return isTargetRetained
|
|
244
244
|
? [
|
|
245
245
|
false,
|
|
246
|
-
|
|
246
|
+
modifyFields(currentState, {
|
|
247
247
|
isPaused: () => true,
|
|
248
248
|
pausedAtIndex: () => index,
|
|
249
249
|
}),
|
|
250
250
|
]
|
|
251
251
|
: [
|
|
252
252
|
true,
|
|
253
|
-
|
|
253
|
+
modifyFields(currentState, {
|
|
254
254
|
isPaused: () => false,
|
|
255
255
|
}),
|
|
256
256
|
];
|
|
@@ -261,7 +261,7 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
261
261
|
return model;
|
|
262
262
|
});
|
|
263
263
|
const resume = Effect.gen(function* () {
|
|
264
|
-
yield* SubscriptionRef.update(stateRef, state =>
|
|
264
|
+
yield* SubscriptionRef.update(stateRef, state => modifyFields(state, {
|
|
265
265
|
isPaused: () => false,
|
|
266
266
|
}));
|
|
267
267
|
yield* bridge.markRenderPending;
|
|
@@ -274,7 +274,7 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
274
274
|
return state;
|
|
275
275
|
}
|
|
276
276
|
else {
|
|
277
|
-
return
|
|
277
|
+
return modifyFields(state, {
|
|
278
278
|
entries: () => [],
|
|
279
279
|
startIndex: () => 0,
|
|
280
280
|
pausedAtIndex: () => 0,
|
|
@@ -296,7 +296,7 @@ export const createDevToolsStore = (bridge, options = {}) => Effect.gen(function
|
|
|
296
296
|
onSome: ({ diff }) => diff,
|
|
297
297
|
}));
|
|
298
298
|
});
|
|
299
|
-
const updateLatestModel = (model) => SubscriptionRef.update(stateRef,
|
|
299
|
+
const updateLatestModel = (model) => SubscriptionRef.update(stateRef, modifyFields({ maybeLatestModel: () => Option.some(model) }));
|
|
300
300
|
return {
|
|
301
301
|
recordInit,
|
|
302
302
|
recordMessage,
|
|
@@ -340,7 +340,7 @@ export type FoldConfig<ParentModel, State extends Tagged, Message extends Tagged
|
|
|
340
340
|
* machine: uploadMachine,
|
|
341
341
|
* read: (model: Model) => Option.some(model.upload),
|
|
342
342
|
* write: (model, nextUpload) =>
|
|
343
|
-
*
|
|
343
|
+
* modifyFields(model, { upload: () => nextUpload }),
|
|
344
344
|
* context: model => model.uploadQueues,
|
|
345
345
|
* })
|
|
346
346
|
*
|
|
@@ -133,7 +133,7 @@ const transitionFoldedMachine = (config, model, state, message) => {
|
|
|
133
133
|
* machine: uploadMachine,
|
|
134
134
|
* read: (model: Model) => Option.some(model.upload),
|
|
135
135
|
* write: (model, nextUpload) =>
|
|
136
|
-
*
|
|
136
|
+
* modifyFields(model, { upload: () => nextUpload }),
|
|
137
137
|
* context: model => model.uploadQueues,
|
|
138
138
|
* })
|
|
139
139
|
*
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
*
|
|
18
18
|
* Idempotent: already-frozen values are returned as-is. This also serves as
|
|
19
19
|
* the cycle-safety bailout and ensures amortized cost is O(diff) per update
|
|
20
|
-
* when combined with `
|
|
20
|
+
* when combined with `modifyFields()` which preserves unchanged branches by reference.
|
|
21
21
|
*/
|
|
22
22
|
export declare const deepFreeze: <T>(value: T) => T;
|
|
23
23
|
//# sourceMappingURL=deepFreeze.d.ts.map
|
|
@@ -18,7 +18,7 @@ import { Array, Option, Predicate, Record } from 'effect';
|
|
|
18
18
|
*
|
|
19
19
|
* Idempotent: already-frozen values are returned as-is. This also serves as
|
|
20
20
|
* the cycle-safety bailout and ensures amortized cost is O(diff) per update
|
|
21
|
-
* when combined with `
|
|
21
|
+
* when combined with `modifyFields()` which preserves unchanged branches by reference.
|
|
22
22
|
*/
|
|
23
23
|
export const deepFreeze = (value) => {
|
|
24
24
|
if (value === null || typeof value !== 'object') {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Effect, Option, PubSub,
|
|
1
|
+
import { Cause, Effect, Option, PubSub, Scope } from 'effect';
|
|
2
2
|
import type { ManagedResourceRef } from './resourceProvider.js';
|
|
3
3
|
/**
|
|
4
4
|
* Forks one fiber per Managed Resource into the runtime scope. Each fiber
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"managedResourceFibers.d.ts","sourceRoot":"","sources":["../../src/runtime/managedResourceFibers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EAGN,KAAK,
|
|
1
|
+
{"version":3,"file":"managedResourceFibers.d.ts","sourceRoot":"","sources":["../../src/runtime/managedResourceFibers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EAGN,KAAK,EAGN,MAAM,QAAQ,CAAA;AAGf,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAE/D;;;;;;GAMG;AACH,eAAO,MAAM,yBAAyB,GAAI,KAAK,EAAE,OAAO,mGAOrD,QAAQ,CAAC;IACV,mBAAmB,EAAE,aAAa,CAAC,kBAAkB,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAA;IACtE,SAAS,EAAE,KAAK,CAAA;IAChB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACjC,YAAY,EAAE,KAAK,CAAC,KAAK,CAAA;IACzB,oBAAoB,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;IAC/D,SAAS,EAAE,CACT,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EACzB,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,KACjC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;CACzB,CAAC,KAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAkFtB,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Effect, Option, Ref, Schema, Stream, pipe, } from 'effect';
|
|
1
|
+
import { Effect, Option, PubSub, Ref, Schema, Scope, Stream, pipe, } from 'effect';
|
|
2
2
|
/**
|
|
3
3
|
* Forks one fiber per Managed Resource into the runtime scope. Each fiber
|
|
4
4
|
* derives the resource's requirements from every Model, acquires the
|
|
@@ -30,7 +30,8 @@ export const forkManagedResourceFibers = ({ managedResourceRefs, initModel, mode
|
|
|
30
30
|
return pipe(Stream.scoped(Stream.fromEffect(Effect.acquireRelease(acquire, release))), Stream.flatMap(value => Stream.concat(Stream.make(config.onAcquired(value)), Stream.never)), Stream.map(Effect.succeed), Stream.catch(error => Stream.make(Effect.succeed(config.onAcquireError(error)))));
|
|
31
31
|
};
|
|
32
32
|
const forkManagedResourceLifecycle = ({ config, ref: resourceRef, }) => Effect.gen(function* () {
|
|
33
|
-
const
|
|
33
|
+
const modelSubscription = yield* PubSub.subscribe(modelPubSub).pipe(Effect.provideService(Scope.Scope, runtimeScope));
|
|
34
|
+
const modelStream = Stream.concat(Stream.make(initModel), Stream.fromSubscription(modelSubscription));
|
|
34
35
|
const equivalence = Schema.toEquivalence(config.schema);
|
|
35
36
|
yield* Effect.forkIn(runtimeScope)(modelStream.pipe(Stream.map(config.modelToMaybeRequirements), Stream.changesWith(equivalence), Stream.switchMap(maybeRequirementsToLifecycle(config, resourceRef)), Stream.runForEach(Effect.flatMap(enqueueMessageEffect)),
|
|
36
37
|
// NOTE: a defect in `modelToMaybeRequirements` or the equivalence
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Cause, Effect, Option, PubSub,
|
|
1
|
+
import { Cause, Effect, Option, PubSub, Scope } from 'effect';
|
|
2
2
|
import type { Subscriptions } from '../subscription/subscription.js';
|
|
3
3
|
import { type ResolvedSlowPhaseConfig, type SlowSubscriptionDependenciesContext } from './slowPhase.js';
|
|
4
4
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptionFibers.d.ts","sourceRoot":"","sources":["../../src/runtime/subscriptionFibers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EACL,MAAM,EACN,MAAM,EACN,MAAM,EAIN,KAAK,
|
|
1
|
+
{"version":3,"file":"subscriptionFibers.d.ts","sourceRoot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, Ref, Schema, Stream, pipe, } from 'effect';
|
|
1
|
+
import { Effect, Option, PubSub, Record, Ref, Schema, Scope, Stream, pipe, } from 'effect';
|
|
2
2
|
import { measureSlowPhase, reportSlowPhase, } from './slowPhase.js';
|
|
3
3
|
/**
|
|
4
4
|
* Forks one fiber per Subscription into the runtime scope. Each fiber
|
|
@@ -18,7 +18,8 @@ export const forkSubscriptionFibers = ({ subscriptions, initModel, modelPubSub,
|
|
|
18
18
|
thresholdMs,
|
|
19
19
|
}));
|
|
20
20
|
const latestDependenciesRef = yield* Ref.make(initDependencies);
|
|
21
|
-
const
|
|
21
|
+
const modelSubscription = yield* PubSub.subscribe(modelPubSub).pipe(Effect.provideService(Scope.Scope, runtimeScope));
|
|
22
|
+
const modelChangesStream = Stream.fromSubscription(modelSubscription).pipe(
|
|
22
23
|
// NOTE: Ref.set runs upstream of Stream.changesWith on
|
|
23
24
|
// every model change, so readDependencies() returns
|
|
24
25
|
// current values even when the equivalence filter
|
package/dist/struct/index.d.ts
CHANGED
|
@@ -7,12 +7,12 @@ type StrictKeys<O, T> = T extends Record<string, any> ? Exclude<keyof T, keyof O
|
|
|
7
7
|
type Evolved<O, T> = {
|
|
8
8
|
[K in keyof O]: K extends keyof T ? T[K] extends (a: any) => infer R ? R : O[K] : O[K];
|
|
9
9
|
};
|
|
10
|
-
/** Immutably
|
|
11
|
-
export declare const
|
|
10
|
+
/** Immutably modifies fields of a struct by applying transform functions. Each transformer must return its field's existing type. Wraps Effect's `Struct.evolve` with stricter key checking. */
|
|
11
|
+
export declare const modifyFields: {
|
|
12
12
|
<O, const T extends EvolveTransform<O>>(t: StrictKeys<O, T>): (obj: O) => Evolved<O, T>;
|
|
13
13
|
<O, const T extends EvolveTransform<O>>(obj: O, t: StrictKeys<O, T>): Evolved<O, T>;
|
|
14
14
|
};
|
|
15
|
-
/** Creates a
|
|
16
|
-
export declare const
|
|
15
|
+
/** Creates a field modifier for a base shape. Use in generic helpers whose Model extends that shape. Transformers are checked against the base shape, and the returned function preserves the Model's subtype and all fields not in the transform. */
|
|
16
|
+
export declare const makeModifyFieldsFor: <Base extends Record<string, unknown>>() => <Model extends Base>(model: Model, transforms: EvolveTransform<Base>) => Model;
|
|
17
17
|
export {};
|
|
18
18
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/struct/index.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,CAAA;AAEF,KAAK,UAAU,CAAC,CAAC,EAAE,CAAC,IAClB,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACzB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,SAAS,KAAK,GACrC,CAAC,GACD,CAAC,GAAG;KACD,CAAC,IAAI,gBAAgB,OAAO,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,KAAK;CACnE,GACH,KAAK,CAAA;AAEX,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,IAAI;KAClB,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,MAAM,CAAC,GAC7B,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,KAAK,MAAM,CAAC,GAC9B,CAAC,GACD,CAAC,CAAC,CAAC,CAAC,GACN,CAAC,CAAC,CAAC,CAAC;CACT,CAAA;AAED,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/struct/index.ts"],"names":[],"mappings":"AAEA,KAAK,eAAe,CAAC,CAAC,IAAI,OAAO,CAAC;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,EAAE,CA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AI,SACV,KAAK,cACA,eAAe,CAAC,IAAI,CAAC,KAChC,KAE+C,CAAA"}
|
package/dist/struct/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Struct } from 'effect';
|
|
2
|
-
/** Immutably
|
|
3
|
-
export const
|
|
4
|
-
/** Creates a
|
|
5
|
-
export const
|
|
2
|
+
/** Immutably modifies fields of a struct by applying transform functions. Each transformer must return its field's existing type. Wraps Effect's `Struct.evolve` with stricter key checking. */
|
|
3
|
+
export const modifyFields = Struct.evolve;
|
|
4
|
+
/** Creates a field modifier for a base shape. Use in generic helpers whose Model extends that shape. Transformers are checked against the base shape, and the returned function preserves the Model's subtype and all fields not in the transform. */
|
|
5
|
+
export const makeModifyFieldsFor = () => (model, transforms) =>
|
|
6
6
|
/* eslint-disable-next-line @typescript-eslint/consistent-type-assertions */
|
|
7
7
|
Struct.evolve(model, transforms);
|
package/dist/struct/public.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { modifyFields, makeModifyFieldsFor } from './index.js';
|
|
2
2
|
//# sourceMappingURL=public.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/struct/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"public.d.ts","sourceRoot":"","sources":["../../src/struct/public.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA"}
|
package/dist/struct/public.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { modifyFields, makeModifyFieldsFor } from './index.js';
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
*
|
|
10
10
|
* Being dual, it reads two ways. Data-first sets the field and returns the
|
|
11
11
|
* model; data-last returns `(model) => model`, which slots point-free into
|
|
12
|
-
*
|
|
12
|
+
* a `modifyFields` callback:
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
15
|
* // data-first
|
|
16
16
|
* const next = Slider.reflectRange(model.priceSlider, rangeFromUrl)
|
|
17
|
-
* // data-last, point-free in
|
|
18
|
-
*
|
|
17
|
+
* // data-last, point-free in modifyFields
|
|
18
|
+
* modifyFields(model, { priceSlider: Slider.reflectRange(rangeFromUrl) })
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
21
|
export type Reflect<Model, Value> = {
|
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
import { Duration, Stream } from 'effect';
|
|
2
|
-
/** Whether a
|
|
2
|
+
/** Whether a key binding may fire when its event comes from an editable element. */
|
|
3
3
|
export type WhileTyping = 'Suppress' | 'Allow';
|
|
4
4
|
/** A single key press or a sequence of two or more key presses. */
|
|
5
|
-
export type
|
|
5
|
+
export type KeySequence = string | Readonly<[string, string, ...Array<string>]>;
|
|
6
6
|
type BindingBase<Message> = Readonly<{
|
|
7
|
-
|
|
7
|
+
keys: KeySequence;
|
|
8
8
|
toMessage: (event: KeyboardEvent) => Message;
|
|
9
9
|
isEnabled?: boolean;
|
|
10
10
|
whileTyping?: WhileTyping;
|
|
11
11
|
preventDefault?: boolean;
|
|
12
12
|
}>;
|
|
13
13
|
/**
|
|
14
|
-
* One entry in a {@link
|
|
14
|
+
* One entry in a {@link keyBindings} binding table.
|
|
15
15
|
*
|
|
16
16
|
* A string describes one key press, such as `'/'`, `'Escape'`, or `'Mod+K'`.
|
|
17
17
|
* An array describes a sequence of at least two presses, such as
|
|
18
18
|
* `['G', 'H']` or `['G', 'Shift+G']`.
|
|
19
19
|
*/
|
|
20
|
-
export type
|
|
21
|
-
|
|
20
|
+
export type KeyBinding<Message> = BindingBase<Message> & (Readonly<{
|
|
21
|
+
keys: string;
|
|
22
22
|
whenRepeated?: 'Ignore' | 'Allow';
|
|
23
23
|
}> | Readonly<{
|
|
24
|
-
|
|
24
|
+
keys: Readonly<[string, string, ...Array<string>]>;
|
|
25
25
|
whenRepeated?: never;
|
|
26
26
|
}>);
|
|
27
27
|
type ModKey = 'Control' | 'Meta';
|
|
28
|
-
/** Configuration for the {@link
|
|
29
|
-
export type
|
|
30
|
-
bindings: ReadonlyArray<
|
|
28
|
+
/** Configuration for the {@link keyBindings} Stream helper. */
|
|
29
|
+
export type KeyBindingsConfig<Message> = Readonly<{
|
|
30
|
+
bindings: ReadonlyArray<KeyBinding<Message>>;
|
|
31
31
|
target?: EventTarget | (() => EventTarget);
|
|
32
32
|
modKey?: ModKey;
|
|
33
33
|
sequenceTimeout?: Duration.Input;
|
|
34
34
|
}>;
|
|
35
35
|
/**
|
|
36
|
-
* Build a Stream that turns declarative
|
|
36
|
+
* Build a Stream that turns declarative key bindings into Messages.
|
|
37
37
|
*
|
|
38
|
-
* A string
|
|
38
|
+
* A string describes one key press. Modifiers are joined with `+`:
|
|
39
39
|
* `'Mod+K'`, `'Control+Shift+P'`, or `'Alt+ArrowDown'`. The supported modifiers
|
|
40
40
|
* are `Mod`, `Control`, `Meta`, `Alt`, and `Shift`. `Mod` resolves to Meta on
|
|
41
41
|
* Apple platforms and Control elsewhere; `modKey` can override that choice.
|
|
@@ -47,17 +47,17 @@ export type KeyboardShortcutsConfig<Message> = Readonly<{
|
|
|
47
47
|
* one second by default; `sequenceTimeout` accepts any Effect Duration input.
|
|
48
48
|
* Modifier-only events and repeated keydowns do not advance a sequence.
|
|
49
49
|
*
|
|
50
|
-
*
|
|
50
|
+
* Bindings are suppressed by default when the event's composed path contains
|
|
51
51
|
* an `input`, `textarea`, `select`, or contenteditable element. Set
|
|
52
52
|
* `whileTyping` to `'Allow'` for a binding that must work there. Events emitted
|
|
53
53
|
* during IME composition are always ignored. Repeated keydowns are ignored for
|
|
54
|
-
* one-press
|
|
54
|
+
* one-press bindings unless `whenRepeated` is `'Allow'`. An event another
|
|
55
55
|
* handler already canceled is ignored and clears any sequence in progress.
|
|
56
56
|
*
|
|
57
57
|
* Matched key presses call `preventDefault()` before dispatching. For a
|
|
58
58
|
* sequence, that policy applies to every matched press. Set `preventDefault`
|
|
59
59
|
* to `false` to opt out. Sequences sharing a prefix must use the same policy.
|
|
60
|
-
* Duplicate bindings and a complete
|
|
60
|
+
* Duplicate bindings and a complete binding that is also a sequence prefix
|
|
61
61
|
* are rejected when the Stream is created.
|
|
62
62
|
*
|
|
63
63
|
* This helper returns a Stream, not a complete Subscription entry. Use
|
|
@@ -66,7 +66,7 @@ export type KeyboardShortcutsConfig<Message> = Readonly<{
|
|
|
66
66
|
* derive each binding's `isEnabled` from the dependency record. A dependency
|
|
67
67
|
* change opens a new Stream scope and resets any sequence in progress. If a
|
|
68
68
|
* parent owns a condition for a lifted child, declare the table at that parent
|
|
69
|
-
* or put
|
|
69
|
+
* or put bindings with different parent-owned lifetimes in separate child
|
|
70
70
|
* entries so `Subscription.lift` can gate them individually. If the meaning
|
|
71
71
|
* of a key depends on the Model, dispatch a factual key Message and decide
|
|
72
72
|
* what it means in update instead of reading the Model from `toMessage`.
|
|
@@ -74,28 +74,28 @@ export type KeyboardShortcutsConfig<Message> = Readonly<{
|
|
|
74
74
|
* @example
|
|
75
75
|
* ```typescript
|
|
76
76
|
* const subscriptions = Subscription.make<Model, Message>()(entry => ({
|
|
77
|
-
*
|
|
77
|
+
* keyBindings: entry(
|
|
78
78
|
* { isPaletteOpen: Schema.Boolean },
|
|
79
79
|
* {
|
|
80
80
|
* modelToDependencies: model => ({
|
|
81
81
|
* isPaletteOpen: model.paletteState._tag === 'Open',
|
|
82
82
|
* }),
|
|
83
83
|
* dependenciesToStream: ({ isPaletteOpen }) =>
|
|
84
|
-
* Subscription.
|
|
84
|
+
* Subscription.keyBindings<Message>({
|
|
85
85
|
* bindings: [
|
|
86
86
|
* {
|
|
87
|
-
*
|
|
87
|
+
* keys: 'Escape',
|
|
88
88
|
* isEnabled: isPaletteOpen,
|
|
89
89
|
* whileTyping: 'Allow',
|
|
90
90
|
* toMessage: () => Message.PressedEscape(),
|
|
91
91
|
* },
|
|
92
92
|
* {
|
|
93
|
-
*
|
|
93
|
+
* keys: 'Mod+K',
|
|
94
94
|
* whileTyping: 'Allow',
|
|
95
95
|
* toMessage: () => Message.PressedSearchShortcut(),
|
|
96
96
|
* },
|
|
97
97
|
* {
|
|
98
|
-
*
|
|
98
|
+
* keys: ['G', 'L'],
|
|
99
99
|
* toMessage: () => Message.PressedListShortcut(),
|
|
100
100
|
* },
|
|
101
101
|
* ],
|
|
@@ -105,6 +105,6 @@ export type KeyboardShortcutsConfig<Message> = Readonly<{
|
|
|
105
105
|
* }))
|
|
106
106
|
* ```
|
|
107
107
|
*/
|
|
108
|
-
export declare const
|
|
108
|
+
export declare const keyBindings: <Message>(config: KeyBindingsConfig<Message>) => Stream.Stream<Message>;
|
|
109
109
|
export {};
|
|
110
|
-
//# sourceMappingURL=
|
|
110
|
+
//# sourceMappingURL=keyBindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keyBindings.d.ts","sourceRoot":"","sources":["../../src/subscription/keyBindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,QAAQ,EAOR,MAAM,EAGP,MAAM,QAAQ,CAAA;AAEf,oFAAoF;AACpF,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,OAAO,CAAA;AAE9C,mEAAmE;AACnE,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAA;AAE/E,KAAK,WAAW,CAAC,OAAO,IAAI,QAAQ,CAAC;IACnC,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,OAAO,CAAA;IAC5C,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC,CAAA;AAEF;;;;;;GAMG;AACH,MA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