ctrl-fx 0.1.0 → 0.1.2

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.
Files changed (152) hide show
  1. package/README.md +13 -0
  2. package/dist/chunk-BDTTV33M.js +4050 -0
  3. package/dist/chunk-EKBLRHWK.js +916 -0
  4. package/dist/chunk-OSIRHKDB.js +1812 -0
  5. package/dist/chunk-PKBMQBKP.js +7 -0
  6. package/dist/chunk-XICUXW4T.js +252 -0
  7. package/dist/db/index.d.ts +218 -16
  8. package/dist/db/index.js +53 -19
  9. package/dist/dom/index.d.ts +2 -248
  10. package/dist/dom/index.js +30 -266
  11. package/dist/effects.d.ts +2 -580
  12. package/dist/effects.js +111 -1556
  13. package/dist/index-DeEjNrg-.d.ts +1399 -0
  14. package/dist/index.d.ts +2 -41
  15. package/dist/index.js +18 -78
  16. package/dist/router.d.ts +11 -12
  17. package/dist/router.js +57 -68
  18. package/dist/testing.d.ts +67 -60
  19. package/dist/testing.js +46 -158
  20. package/dist/webcomponent.d.ts +7 -4
  21. package/dist/webcomponent.js +48 -40
  22. package/package.json +4 -3
  23. package/dist/clipboard.d.ts +0 -7
  24. package/dist/clipboard.d.ts.map +0 -1
  25. package/dist/clipboard.js +0 -3
  26. package/dist/db/effects.d.ts +0 -78
  27. package/dist/db/effects.d.ts.map +0 -1
  28. package/dist/db/effects.js +0 -98
  29. package/dist/db/errors.d.ts +0 -21
  30. package/dist/db/errors.d.ts.map +0 -1
  31. package/dist/db/errors.js +0 -13
  32. package/dist/db/index.d.ts.map +0 -1
  33. package/dist/db/keypath.d.ts +0 -40
  34. package/dist/db/keypath.d.ts.map +0 -1
  35. package/dist/db/keypath.js +0 -20
  36. package/dist/db/setup.d.ts +0 -83
  37. package/dist/db/setup.d.ts.map +0 -1
  38. package/dist/db/setup.js +0 -100
  39. package/dist/db/testdb.d.ts +0 -19
  40. package/dist/db/testdb.d.ts.map +0 -1
  41. package/dist/db/testdb.js +0 -34
  42. package/dist/dom/attrs.d.ts +0 -67
  43. package/dist/dom/attrs.d.ts.map +0 -1
  44. package/dist/dom/attrs.js +0 -154
  45. package/dist/dom/components.d.ts +0 -43
  46. package/dist/dom/components.d.ts.map +0 -1
  47. package/dist/dom/components.js +0 -86
  48. package/dist/dom/elems.d.ts +0 -121
  49. package/dist/dom/elems.d.ts.map +0 -1
  50. package/dist/dom/elems.js +0 -52
  51. package/dist/dom/events.d.ts +0 -232
  52. package/dist/dom/events.d.ts.map +0 -1
  53. package/dist/dom/events.js +0 -289
  54. package/dist/dom/index.d.ts.map +0 -1
  55. package/dist/dom/nodeid.d.ts +0 -9
  56. package/dist/dom/nodeid.d.ts.map +0 -1
  57. package/dist/dom/nodeid.js +0 -27
  58. package/dist/dom/svg.d.ts +0 -23
  59. package/dist/dom/svg.d.ts.map +0 -1
  60. package/dist/dom/svg.js +0 -1
  61. package/dist/dom/views.d.ts +0 -60
  62. package/dist/dom/views.d.ts.map +0 -1
  63. package/dist/dom/views.js +0 -154
  64. package/dist/effects.d.ts.map +0 -1
  65. package/dist/index.d.ts.map +0 -1
  66. package/dist/internal/clipboard.d.ts +0 -5
  67. package/dist/internal/clipboard.d.ts.map +0 -1
  68. package/dist/internal/clipboard.js +0 -33
  69. package/dist/internal/cmpmgr.d.ts +0 -46
  70. package/dist/internal/cmpmgr.d.ts.map +0 -1
  71. package/dist/internal/cmpmgr.js +0 -561
  72. package/dist/internal/dbmgr.d.ts +0 -11
  73. package/dist/internal/dbmgr.d.ts.map +0 -1
  74. package/dist/internal/dbmgr.js +0 -200
  75. package/dist/internal/dominterpreter.d.ts +0 -5
  76. package/dist/internal/dominterpreter.d.ts.map +0 -1
  77. package/dist/internal/dominterpreter.js +0 -337
  78. package/dist/internal/eventmgr.d.ts +0 -41
  79. package/dist/internal/eventmgr.d.ts.map +0 -1
  80. package/dist/internal/eventmgr.js +0 -696
  81. package/dist/internal/index.d.ts +0 -19
  82. package/dist/internal/index.d.ts.map +0 -1
  83. package/dist/internal/index.js +0 -38
  84. package/dist/internal/interpreter.d.ts +0 -10
  85. package/dist/internal/interpreter.d.ts.map +0 -1
  86. package/dist/internal/interpreter.js +0 -1
  87. package/dist/internal/locutils.d.ts +0 -4
  88. package/dist/internal/locutils.d.ts.map +0 -1
  89. package/dist/internal/locutils.js +0 -22
  90. package/dist/internal/net.d.ts +0 -4
  91. package/dist/internal/net.d.ts.map +0 -1
  92. package/dist/internal/net.js +0 -64
  93. package/dist/internal/realdom.d.ts +0 -249
  94. package/dist/internal/realdom.d.ts.map +0 -1
  95. package/dist/internal/realdom.js +0 -1
  96. package/dist/internal/styleregistry.d.ts +0 -6
  97. package/dist/internal/styleregistry.d.ts.map +0 -1
  98. package/dist/internal/styleregistry.js +0 -18
  99. package/dist/internal/taskreg.d.ts +0 -9
  100. package/dist/internal/taskreg.d.ts.map +0 -1
  101. package/dist/internal/taskreg.js +0 -28
  102. package/dist/internal/testing.d.ts +0 -12
  103. package/dist/internal/testing.d.ts.map +0 -1
  104. package/dist/internal/testing.js +0 -974
  105. package/dist/internal/testinginterpreter.d.ts +0 -10
  106. package/dist/internal/testinginterpreter.d.ts.map +0 -1
  107. package/dist/internal/testinginterpreter.js +0 -646
  108. package/dist/internal/vdom.d.ts +0 -93
  109. package/dist/internal/vdom.d.ts.map +0 -1
  110. package/dist/internal/vdom.js +0 -470
  111. package/dist/json/index.d.ts +0 -5
  112. package/dist/json/index.d.ts.map +0 -1
  113. package/dist/json/index.js +0 -2
  114. package/dist/json/validation.d.ts +0 -28
  115. package/dist/json/validation.d.ts.map +0 -1
  116. package/dist/json/validation.js +0 -8
  117. package/dist/net/fragment.d.ts +0 -10
  118. package/dist/net/fragment.d.ts.map +0 -1
  119. package/dist/net/fragment.js +0 -27
  120. package/dist/net/index.d.ts +0 -42
  121. package/dist/net/index.d.ts.map +0 -1
  122. package/dist/net/index.js +0 -60
  123. package/dist/net/location.d.ts +0 -21
  124. package/dist/net/location.d.ts.map +0 -1
  125. package/dist/net/location.js +0 -41
  126. package/dist/net/path.d.ts +0 -12
  127. package/dist/net/path.d.ts.map +0 -1
  128. package/dist/net/path.js +0 -29
  129. package/dist/net/queryparam.d.ts +0 -10
  130. package/dist/net/queryparam.d.ts.map +0 -1
  131. package/dist/net/queryparam.js +0 -34
  132. package/dist/router.d.ts.map +0 -1
  133. package/dist/scroll.d.ts +0 -7
  134. package/dist/scroll.d.ts.map +0 -1
  135. package/dist/scroll.js +0 -3
  136. package/dist/testing.d.ts.map +0 -1
  137. package/dist/utils/apply.d.ts +0 -9
  138. package/dist/utils/apply.d.ts.map +0 -1
  139. package/dist/utils/apply.js +0 -10
  140. package/dist/utils/index.d.ts +0 -22
  141. package/dist/utils/index.d.ts.map +0 -1
  142. package/dist/utils/index.js +0 -138
  143. package/dist/utils/lens.d.ts +0 -18
  144. package/dist/utils/lens.d.ts.map +0 -1
  145. package/dist/utils/lens.js +0 -27
  146. package/dist/utils/match.d.ts +0 -17
  147. package/dist/utils/match.d.ts.map +0 -1
  148. package/dist/utils/match.js +0 -28
  149. package/dist/utils/result.d.ts +0 -47
  150. package/dist/utils/result.d.ts.map +0 -1
  151. package/dist/utils/result.js +0 -97
  152. package/dist/webcomponent.d.ts.map +0 -1
package/dist/effects.d.ts CHANGED
@@ -1,580 +1,2 @@
1
- import type { ClipboardError } from './clipboard';
2
- import type { ScrollElementError } from './scroll';
3
- import type { DbEffect } from './db/effects';
4
- import type { DbSetupEffect } from './db/setup';
5
- import type { DbError } from './db/errors';
6
- import type { DbName, DbVersion, ObjectStore } from './db/index';
7
- import { type HttpError, type HttpRequest, type HttpResponse, type RequestError } from './net';
8
- import { type InternalLocation } from './net/location';
9
- import { type Lens } from './utils/lens';
10
- import { type Result } from './utils/result';
11
- import type { Permission, Uuid } from '.';
12
- export type { ClipboardError } from './clipboard';
13
- export type { ScrollElementError } from './scroll';
14
- export type { DbEffect } from './db/effects';
15
- export type { DbSetupEffect } from './db/setup';
16
- export type { DbError, UnexpectedError, NotFoundError, ConstraintError, } from './db/errors';
17
- export type { DbName, DbVersion, ObjectStore } from './db/index';
18
- export type { HttpError, HttpRequest, HttpResponse, RequestError, Json, DecodingError, Method, Headers, ResponseBody, } from './net';
19
- export type { InternalLocation } from './net/location';
20
- export type { Path } from './net/path';
21
- export type { QueryParam } from './net/queryparam';
22
- export type { Fragment } from './net/fragment';
23
- export type { Lens } from './utils/lens';
24
- export type { Result } from './utils/result';
25
- type Alert = {
26
- _type: 'Alert';
27
- input: any;
28
- };
29
- type Async<State, Event> = {
30
- _type: 'Async';
31
- input: {
32
- effect: Effect<State, Event, void>;
33
- delayInMillis: number;
34
- };
35
- };
36
- type CancelTask = {
37
- _type: 'CancelTask';
38
- input: TaskId;
39
- };
40
- type ClearAppBadge = {
41
- _type: 'ClearAppBadge';
42
- input: void;
43
- };
44
- type ReadClipboard = {
45
- _type: 'ReadClipboard';
46
- input: void;
47
- };
48
- type WriteClipboard = {
49
- _type: 'WriteClipboard';
50
- input: string;
51
- };
52
- type SetAppBadge = {
53
- _type: 'SetAppBadge';
54
- input: number;
55
- };
56
- type SetDocumentTitle = {
57
- _type: 'SetDocumentTitle';
58
- input: string;
59
- };
60
- type Confirm = {
61
- _type: 'Confirm';
62
- input: string;
63
- };
64
- type FireEvent<Event> = {
65
- _type: 'FireEvent';
66
- input: Event;
67
- };
68
- type GenerateUuid = {
69
- _type: 'GenerateUuid';
70
- input: void;
71
- };
72
- type GetNotificationPermission = {
73
- _type: 'GetNotificationPermission';
74
- input: void;
75
- };
76
- type RequestNotificationPermission = {
77
- _type: 'RequestNotificationPermission';
78
- input: void;
79
- };
80
- type GetLocation = {
81
- _type: 'GetLocation';
82
- input: void;
83
- };
84
- type GetState = {
85
- _type: 'GetState';
86
- input: void;
87
- };
88
- type GetTime = {
89
- _type: 'GetTime';
90
- input: void;
91
- };
92
- type GetRandom = {
93
- _type: 'GetRandom';
94
- input: void;
95
- };
96
- type Prompt = {
97
- _type: 'Prompt';
98
- input: {
99
- message: string;
100
- default: string | undefined;
101
- };
102
- };
103
- type Log = {
104
- _type: 'Log';
105
- input: any;
106
- };
107
- type MakeHttpRequest = {
108
- _type: 'MakeHttpRequest';
109
- input: HttpRequest;
110
- };
111
- type OpenDatabase = {
112
- _type: 'OpenDatabase';
113
- input: {
114
- db: DbName;
115
- version: DbVersion;
116
- setup: (oldVersion: DbVersion) => DbSetupEffect<void>;
117
- };
118
- };
119
- type RunDbTransaction = {
120
- _type: 'RunDbTransaction';
121
- input: {
122
- db: DbName;
123
- objectStores: readonly ObjectStore[];
124
- mode: 'readonly' | 'readwrite';
125
- effect: DbEffect<void>;
126
- };
127
- };
128
- type Product<State, Event, A, B> = {
129
- _type: 'Product';
130
- input: [Effect<State, Event, A>, Effect<State, Event, B>];
131
- };
132
- /** A branded string that uniquely identifies a scheduled task. */
133
- export type TaskId = string & {
134
- __brand: 'TaskId';
135
- };
136
- /** Creates a typed TaskId from a plain string. */
137
- export declare function taskId(id: string): TaskId;
138
- type ScheduleTask<State, Event> = {
139
- _type: 'ScheduleTask';
140
- input: {
141
- task: Effect<State, Event, void>;
142
- initialDelayInMillis: number;
143
- repeatIntervalInMillis: number | undefined;
144
- taskId: TaskId | undefined;
145
- };
146
- };
147
- type SetTimeout = {
148
- _type: 'SetTimeout';
149
- input: number;
150
- };
151
- type UpdateState<State> = {
152
- _type: 'UpdateState';
153
- input: (state: State) => State;
154
- };
155
- export type StorageTarget = 'local' | 'session';
156
- type GetStorageItem = {
157
- _type: 'GetStorageItem';
158
- input: {
159
- storage: StorageTarget;
160
- key: string;
161
- };
162
- };
163
- type Go = {
164
- _type: 'Go';
165
- input: number;
166
- };
167
- type PushState = {
168
- _type: 'PushState';
169
- input: InternalLocation;
170
- };
171
- type ReplaceState = {
172
- _type: 'ReplaceState';
173
- input: InternalLocation;
174
- };
175
- type SetStorageItem = {
176
- _type: 'SetStorageItem';
177
- input: {
178
- storage: StorageTarget;
179
- key: string;
180
- value: string;
181
- };
182
- };
183
- type RemoveStorageItem = {
184
- _type: 'RemoveStorageItem';
185
- input: {
186
- storage: StorageTarget;
187
- key: string;
188
- };
189
- };
190
- type ClearStorage = {
191
- _type: 'ClearStorage';
192
- input: {
193
- storage: StorageTarget;
194
- };
195
- };
196
- export type ScrollOptions = {
197
- top?: number;
198
- left?: number;
199
- behavior?: 'smooth' | 'instant' | 'auto';
200
- };
201
- type ScrollWindow = {
202
- _type: 'ScrollWindow';
203
- input: ScrollOptions;
204
- };
205
- type ScrollElement = {
206
- _type: 'ScrollElement';
207
- input: {
208
- selector: string;
209
- options: ScrollOptions;
210
- };
211
- };
212
- export type DownloadInput = {
213
- filename: string;
214
- content: string;
215
- contentType: string;
216
- };
217
- type Download = {
218
- _type: 'Download';
219
- input: DownloadInput;
220
- };
221
- type PostBroadcastMessage = {
222
- _type: 'PostBroadcastMessage';
223
- input: {
224
- channel: string;
225
- message: unknown;
226
- };
227
- };
228
- type SubscribeToBroadcastChannel<State, Event> = {
229
- _type: 'SubscribeToBroadcastChannel';
230
- input: {
231
- channel: string;
232
- handler: (message: unknown) => Effect<State, Event, void>;
233
- taskId: TaskId | undefined;
234
- };
235
- };
236
- type CustomEffect<In, Out, Custom> = {
237
- _type: 'CustomEffect';
238
- input: {
239
- args: In;
240
- f: (args: In) => Out | Promise<Out>;
241
- test: (args: In, data: Custom) => {
242
- out: Out;
243
- data: Custom;
244
- };
245
- };
246
- };
247
- /**
248
- * Creates a factory for effects that call an external library function.
249
- * Use this when you want to call a library whose logic would be too cumbersome
250
- * to reimplement using built-in effects. In production `f` is called directly.
251
- * In tests the `test` callback receives the arguments and a queue of scripted
252
- * return values (`data`), and must return `{ out, data }` where `data` is the
253
- * remaining queue after consuming one entry.
254
- *
255
- * @param f Production implementation. May return a Promise.
256
- * @param test Test-time implementation. Receives the scripted data queue and
257
- * returns `{ out, data }` — `out` is the value to return, `data` is the
258
- * remaining queue. Provide scripted values via `newTestData(queue)`.
259
- */
260
- export declare function customEffect<State, Event, In, Out, Custom>(f: (args: In) => Out | Promise<Out>, test: (args: In, data: Custom) => {
261
- out: Out;
262
- data: Custom;
263
- }): (args: In) => Effect<State, Event, Out>;
264
- type Operation<State, Event> = Alert | Async<State, Event> | CancelTask | ClearAppBadge | ClearStorage | Confirm | CustomEffect<unknown, unknown, unknown> | Download | FireEvent<Event> | GetLocation | GetNotificationPermission | RequestNotificationPermission | PostBroadcastMessage | ReadClipboard | WriteClipboard | GenerateUuid | GetState | GetStorageItem | GetTime | GetRandom | Log | MakeHttpRequest | Go | OpenDatabase | Product<State, Event, unknown, unknown> | Prompt | PushState | ReplaceState | RemoveStorageItem | RunDbTransaction | ScheduleTask<State, Event> | ScrollElement | ScrollWindow | SetAppBadge | SetDocumentTitle | SetStorageItem | SetTimeout | SubscribeToBroadcastChannel<State, Event> | UpdateState<State>;
265
- export type Suspend<State, Event, A> = {
266
- _type: 'Suspend';
267
- operation: Operation<State, Event>;
268
- /**
269
- * Sequences this effect with another, passing its result to `f` to produce
270
- * the next effect. Use this when the second effect depends on the value
271
- * produced by the first. For independent sequencing use `and`.
272
- */
273
- flatMap<B>(f: (a: A) => Effect<State, Event, B>): Effect<State, Event, B>;
274
- /**
275
- * Sequences this effect and `effect`, discarding this effect's result. Use
276
- * this when you want both effects to run but the first result is not needed.
277
- * For result-dependent sequencing use `flatMap`.
278
- */
279
- and<B>(effect: Effect<State, Event, B>): Effect<State, Event, B>;
280
- /** Transforms the result of this effect with `f`, without performing any additional effects. */
281
- map<B>(f: (a: A) => B): Effect<State, Event, B>;
282
- /** Replaces the result of this effect with `b`, discarding the original result. */
283
- as<B>(b: B): Effect<State, Event, B>;
284
- /** Discards the result, producing `Effect<State, Event, void>`. */
285
- void(): Effect<State, Event, void>;
286
- /** Passes this effect to `f` and returns the result. Useful for applying a function that takes an effect without breaking a method chain. */
287
- apply<B>(f: (effect: Effect<State, Event, A>) => B): B;
288
- };
289
- export type Return<State, Event, A> = {
290
- _type: 'Return';
291
- value: A;
292
- /** @inheritDoc Suspend.flatMap */
293
- flatMap<B>(f: (a: A) => Effect<State, Event, B>): Effect<State, Event, B>;
294
- /** @inheritDoc Suspend.and */
295
- and<B>(effect: Effect<State, Event, B>): Effect<State, Event, B>;
296
- /** @inheritDoc Suspend.map */
297
- map<B>(f: (a: A) => B): Effect<State, Event, B>;
298
- /** @inheritDoc Suspend.as */
299
- as<B>(b: B): Effect<State, Event, B>;
300
- /** @inheritDoc Suspend.void */
301
- void(): Effect<State, Event, void>;
302
- /** @inheritDoc Suspend.apply */
303
- apply<B>(f: (effect: Effect<State, Event, A>) => B): B;
304
- };
305
- export type FlatMap<State, Event, A, B> = {
306
- _type: 'FlatMap';
307
- effect: Effect<State, Event, A>;
308
- next: (a: A) => Effect<State, Event, B>;
309
- /** @inheritDoc Suspend.flatMap */
310
- flatMap<C>(f: (b: B) => Effect<State, Event, C>): Effect<State, Event, C>;
311
- /** @inheritDoc Suspend.and */
312
- and<C>(effect: Effect<State, Event, C>): Effect<State, Event, C>;
313
- /** @inheritDoc Suspend.map */
314
- map<C>(f: (b: B) => C): Effect<State, Event, C>;
315
- /** @inheritDoc Suspend.as */
316
- as<C>(c: C): Effect<State, Event, C>;
317
- /** @inheritDoc Suspend.void */
318
- void(): Effect<State, Event, void>;
319
- /** @inheritDoc Suspend.apply */
320
- apply<C>(f: (effect: Effect<State, Event, B>) => C): C;
321
- };
322
- /**
323
- * A lazy, pure description of a side effect to be performed by the framework.
324
- * An Effect is just a data structure — it does nothing until the framework
325
- * interprets it. This means effects can be composed, transformed, and tested
326
- * without executing any real side effects.
327
- *
328
- * `State` is the application state type the effect can read and update.
329
- * `Event` is the component event type the effect can fire.
330
- * `A` is the value the effect produces when it completes.
331
- */
332
- export type Effect<State, Event, A> = Suspend<State, Event, A> | Return<State, Event, A> | FlatMap<State, Event, any, A>;
333
- /**
334
- * Wraps a plain value in an Effect that completes immediately without performing any operations.
335
- * Useful as a base case when building effects conditionally, or to lift a
336
- * computed value into the Effect chain.
337
- */
338
- export declare function pure<State, Event, A>(value: A): Effect<State, Event, A>;
339
- /** An effect describing a browser alert dialog. */
340
- export declare function alert<State, Event>(message: any): Effect<State, Event, void>;
341
- /**
342
- * An effect describing a browser confirm dialog.
343
- * @returns true if confirmed
344
- */
345
- export declare function confirm<State, Event>(message: string): Effect<State, Event, boolean>;
346
- /**
347
- * An effect describing a browser prompt dialog.
348
- * @returns the entered string, or null if cancelled
349
- */
350
- export declare function prompt<State, Event>(message: string, defaultValue?: string): Effect<State, Event, string | null>;
351
- /** An effect describing a clear of the app badge on the browser/OS icon. */
352
- export declare function clearAppBadge<State, Event>(): Effect<State, Event, void>;
353
- /** An effect describing a clipboard text read. */
354
- export declare function readClipboard<State, Event>(): Effect<State, Event, Result<string, ClipboardError>>;
355
- /** An effect describing a clipboard write of `text`. */
356
- export declare function writeClipboard<State, Event>(text: string): Effect<State, Event, Result<void, ClipboardError>>;
357
- /** An effect describing a `document.title` update. */
358
- export declare function setDocumentTitle<State, Event>(title: string): Effect<State, Event, void>;
359
- /** An effect describing an app badge count update on the browser/OS icon. */
360
- export declare function setAppBadge<State, Event>(count: number): Effect<State, Event, void>;
361
- /**
362
- * An effect describing fire-and-forget async dispatch of `effect`.
363
- * The chain continues without waiting for `effect` to complete.
364
- * Use `scheduleTask` instead if you need cancellation or debounce/repeat behaviour.
365
- */
366
- export declare function async<State, Event>(effect: Effect<State, Event, void>, delayInMillis?: number): Effect<State, Event, void>;
367
- /** An effect describing the cancellation of a previously scheduled task. */
368
- export declare function cancelTask<State, Event>(taskId: TaskId): Effect<State, Event, void>;
369
- /**
370
- * An effect describing a typed component event to be delivered to any `onEvent` listener
371
- * registered by the parent that mounted this component. Has no effect when
372
- * used in a top-level application (which has no parent).
373
- */
374
- export declare function fireEvent<State, Event>(event: Event): Effect<State, Event, void>;
375
- /** An effect describing a UUID v4 generation. */
376
- export declare function generateUuid<State, Event>(): Effect<State, Event, Uuid>;
377
- /** An effect describing a read of the current time. */
378
- export declare function getTime<State, Event>(): Effect<State, Event, Date>;
379
- /** An effect describing a random number in [0, 1), equivalent to Math.random(). */
380
- export declare function getRandom<State, Event>(): Effect<State, Event, number>;
381
- /** An effect describing a console log of `message`. */
382
- export declare function log<State, Event>(message: any): Effect<State, Event, void>;
383
- /** An effect describing an HTTP request. */
384
- export declare function makeHttpRequest<State, Event>(request: HttpRequest): Effect<State, Event, Result<HttpResponse, RequestError | HttpError>>;
385
- /** An effect describing a read of the current browser location. */
386
- export declare function getLocation<State, Event>(): Effect<State, Event, InternalLocation>;
387
- /** An effect describing a read of the current notification permission state. */
388
- export declare function getNotificationPermission<State, Event>(): Effect<State, Event, Permission>;
389
- /** An effect describing a notification permission request. */
390
- export declare function requestNotificationPermission<State, Event>(): Effect<State, Event, Permission>;
391
- /**
392
- * An effect describing a read of the current application state. Because state updates are
393
- * themselves effects sequenced in order, the value produced reflects all
394
- * `updateState` effects that appear earlier in the same effect chain.
395
- */
396
- export declare function getState<State, Event>(): Effect<State, Event, State>;
397
- /**
398
- * An effect describing two concurrent sub-effects, returning both results as a tuple `[A, B]`.
399
- * Both effects share the same initial state snapshot; neither sees state
400
- * changes made by the other. Use `flatMap` instead when the second effect
401
- * must observe state updates from the first.
402
- */
403
- export declare function product<State, Event, A, B>(effectA: Effect<State, Event, A>, effectB: Effect<State, Event, B>): Effect<State, Event, [A, B]>;
404
- /**
405
- * An effect describing the scheduling of `task` to run after `initialDelayInMillis` milliseconds.
406
- *
407
- * If `taskId` is provided and a task with that id is already pending, the
408
- * pending task is cancelled and replaced. This makes `scheduleTask` the
409
- * idiomatic way to implement debouncing: use the same `taskId` on
410
- * every keystroke and only the final one will fire.
411
- *
412
- * @param repeatIntervalInMillis If provided, the task repeats on this interval
413
- * indefinitely after the initial delay. Cancel with `cancelTask`.
414
- * @param taskId Stable identifier used to cancel-and-reschedule. Create one
415
- * with `taskId('name')` and store it as a module-level constant.
416
- * @returns The TaskId of the newly scheduled task.
417
- */
418
- export declare function scheduleTask<State, Event>(task: Effect<State, Event, void>, initialDelayInMillis: number, repeatIntervalInMillis: number | undefined, taskId: TaskId | undefined): Effect<State, Event, TaskId>;
419
- /** An effect describing a delay of `delayInMilliseconds` ms before continuing the chain. */
420
- export declare function setTimeout<State, Event>(delayInMilliseconds: number): Effect<State, Event, void>;
421
- /** An effect describing a state update via `f`. */
422
- export declare function updateState<State, Event>(f: (state: State) => State): Effect<State, Event, void>;
423
- /** An effect describing an IndexedDB database open (or create), with `setup` applied for schema migrations. */
424
- export declare function openDatabase<State, Event>(db: DbName, version: DbVersion, setup: (oldVersion: DbVersion) => DbSetupEffect<void>): Effect<State, Event, Result<void, DbError>>;
425
- /** An effect describing an IndexedDB transaction containing `effect`. */
426
- export declare function runDbTransaction<State, Event>(db: DbName, objectStores: readonly ObjectStore[], mode: 'readonly' | 'readwrite', effect: DbEffect<void>): Effect<State, Event, Result<void, DbError>>;
427
- /** An effect describing a browser history navigation of `delta` steps. */
428
- export declare function go<State, Event>(delta: number): Effect<State, Event, void>;
429
- /** An effect describing a `history.pushState` to `location`. */
430
- export declare function pushState<State, Event>(location: InternalLocation | string): Effect<State, Event, void>;
431
- /** An effect describing a `history.replaceState` with `location`. */
432
- export declare function replaceState<State, Event>(location: InternalLocation | string): Effect<State, Event, void>;
433
- /** An effect describing a localStorage read for `key`. */
434
- export declare function getLocalStorageItem<State, Event>(key: string): Effect<State, Event, string | null>;
435
- /** An effect describing a localStorage write of `value` for `key`. */
436
- export declare function setLocalStorageItem<State, Event>(key: string, value: string): Effect<State, Event, void>;
437
- /** An effect describing the removal of `key` from localStorage. */
438
- export declare function removeLocalStorageItem<State, Event>(key: string): Effect<State, Event, void>;
439
- /** An effect describing a localStorage clear. */
440
- export declare function clearLocalStorage<State, Event>(): Effect<State, Event, void>;
441
- /** An effect describing a sessionStorage read for `key`. */
442
- export declare function getSessionStorageItem<State, Event>(key: string): Effect<State, Event, string | null>;
443
- /** An effect describing a sessionStorage write of `value` for `key`. */
444
- export declare function setSessionStorageItem<State, Event>(key: string, value: string): Effect<State, Event, void>;
445
- /** An effect describing the removal of `key` from sessionStorage. */
446
- export declare function removeSessionStorageItem<State, Event>(key: string): Effect<State, Event, void>;
447
- /** An effect describing a sessionStorage clear. */
448
- export declare function clearSessionStorage<State, Event>(): Effect<State, Event, void>;
449
- /**
450
- * Transforms the `Event` type of an effect by mapping each fired event through `f`.
451
- * Used when composing components: a child component fires `EventA`, and the
452
- * parent needs to convert those into its own `EventB` before wiring them up.
453
- * You rarely need to call this directly — `ComponentElement.onEvent` handles it.
454
- */
455
- export declare function mapEvent<State, EventA, EventB, R>(effect: Effect<State, EventA, R>, f: (eventA: EventA) => EventB): Effect<State, EventB, R>;
456
- /**
457
- * Adapts an effect written against a sub-state `StateA` so it can run in a
458
- * parent context with state `StateB`. The lens provides the `get`/`set`
459
- * functions that translate between the two state shapes.
460
- * Used when composing components whose effects operate on a slice of a larger state.
461
- */
462
- export declare function mapState<StateA, StateB, Event, R>(effect: Effect<StateA, Event, R>, lens: Lens<StateB, StateA>): Effect<StateB, Event, R>;
463
- /** Returns true if `value` is an Effect. */
464
- export declare function isEffect(value: any): value is Effect<any, any, any>;
465
- /** An effect describing a window scroll. */
466
- export declare function scrollWindow<State, Event>(options: ScrollOptions): Effect<State, Event, void>;
467
- /** An effect describing a scroll of the element matching `selector`. */
468
- export declare function scrollElement<State, Event>(selector: string, options: ScrollOptions): Effect<State, Event, Result<void, ScrollElementError>>;
469
- /** An effect describing a file download. */
470
- export declare function download<State, Event>(filename: string, content: string, contentType?: string): Effect<State, Event, void>;
471
- /** An effect describing a BroadcastChannel message post. */
472
- export declare function postBroadcastMessage<State, Event>(channel: string, message: unknown): Effect<State, Event, void>;
473
- /**
474
- * An effect describing a BroadcastChannel subscription, with `handler` called for each message received.
475
- * @returns a TaskId that can be used to cancel the subscription
476
- */
477
- export declare function subscribeToBroadcastChannel<State, Event>(channel: string, handler: (message: unknown) => Effect<State, Event, void>, taskId?: TaskId | undefined): Effect<State, Event, TaskId>;
478
- /** An Effect that does nothing. */
479
- export declare function noop<State, Event>(): Effect<State, Event, void>;
480
- /**
481
- * Returns all built-in effect constructors with `State` and `Event` pre-applied.
482
- * Call this once per module, passing your application's state and event types,
483
- * and destructure the effects you need. This removes the need to repeat the
484
- * type parameters at every call site.
485
- *
486
- * ```ts
487
- * const { updateState, getTime, scheduleTask } = makeEffects<MyState, MyEvent>()
488
- * ```
489
- */
490
- export declare function makeEffects<State, Event>(): {
491
- alert: (message: any) => Effect<State, Event, void>;
492
- confirm: (message: string) => Effect<State, Event, boolean>;
493
- prompt: (message: string, defaultValue?: string) => Effect<State, Event, string | null>;
494
- cancelTask: (taskId: TaskId) => Effect<State, Event, void>;
495
- getLocation: () => Effect<State, Event, InternalLocation>;
496
- getNotificationPermission: () => Effect<State, Event, Permission>;
497
- requestNotificationPermission: () => Effect<State, Event, Permission>;
498
- clearAppBadge: () => Effect<State, Event, void>;
499
- readClipboard: () => Effect<State, Event, Result<string, ClipboardError>>;
500
- setAppBadge: (count: number) => Effect<State, Event, void>;
501
- setDocumentTitle: (title: string) => Effect<State, Event, void>;
502
- writeClipboard: (text: string) => Effect<State, Event, Result<void, ClipboardError>>;
503
- fireEvent: (event: Event) => Effect<State, Event, void>;
504
- getState: () => Effect<State, Event, State>;
505
- getTime: () => Effect<State, Event, Date>;
506
- getRandom: () => Effect<State, Event, number>;
507
- log: (message: any) => Effect<State, Event, void>;
508
- makeHttpRequest: (request: HttpRequest) => Effect<State, Event, Result<HttpResponse, HttpError | RequestError>>;
509
- scheduleTask: (task: Effect<State, Event, void>, initialDelayInMillis: number, repeatIntervalInMillis: number | undefined, taskId: TaskId | undefined) => Effect<State, Event, TaskId>;
510
- setTimeout: (delayInMilliseconds: number) => Effect<State, Event, void>;
511
- updateState: (f: (state: State) => State) => Effect<State, Event, void>;
512
- pure<A>(a: A): Effect<State, Event, A>;
513
- noop: () => Effect<State, Event, void>;
514
- generateUuid: () => Effect<State, Event, Uuid>;
515
- getJson: (uri: string) => Effect<State, Event, Result<import("./net").Json, HttpError | RequestError | import("./net").DecodingError>>;
516
- go: (delta: number) => Effect<State, Event, void>;
517
- scrollWindow: (options: ScrollOptions) => Effect<State, Event, void>;
518
- scrollElement: (selector: string, options: ScrollOptions) => Effect<State, Event, Result<void, ScrollElementError>>;
519
- download: (filename: string, content: string, contentType?: string) => Effect<State, Event, void>;
520
- postBroadcastMessage: (channel: string, message: unknown) => Effect<State, Event, void>;
521
- subscribeToBroadcastChannel: (channel: string, handler: (message: unknown) => Effect<State, Event, void>, taskId?: TaskId | undefined) => Effect<State, Event, TaskId>;
522
- pushState: (location: InternalLocation | string) => Effect<State, Event, void>;
523
- replaceState: (location: InternalLocation | string) => Effect<State, Event, void>;
524
- getLocalStorageItem: (key: string) => Effect<State, Event, string | null>;
525
- setLocalStorageItem: (key: string, value: string) => Effect<State, Event, void>;
526
- removeLocalStorageItem: (key: string) => Effect<State, Event, void>;
527
- clearLocalStorage: () => Effect<State, Event, void>;
528
- getSessionStorageItem: (key: string) => Effect<State, Event, string | null>;
529
- setSessionStorageItem: (key: string, value: string) => Effect<State, Event, void>;
530
- removeSessionStorageItem: (key: string) => Effect<State, Event, void>;
531
- clearSessionStorage: () => Effect<State, Event, void>;
532
- resultT<A, E>(effect: Effect<State, Event, Result<A, E>>): ResultTransformer<State, Event, A, E>;
533
- };
534
- /**
535
- * Maps each element of `as` to an effect and runs them in sequence, collecting
536
- * all results into an array. Each effect runs after the previous one completes,
537
- * so state changes from earlier effects are visible to later ones.
538
- */
539
- export declare function traverse<State, Event, A, B>(as: readonly A[], f: (a: A) => Effect<State, Event, B>): Effect<State, Event, readonly B[]>;
540
- /**
541
- * Wraps an `Effect<State, Event, Result<A, E>>` to allow chaining on the
542
- * success and error branches without manually unwrapping the `Result` at each
543
- * step. Methods like `flatMap` and `errorFlatMap` short-circuit on the other
544
- * branch. Call `.value` to get the underlying effect back.
545
- */
546
- export declare class ResultTransformer<State, Event, A, E> {
547
- /** The underlying wrapped effect. */
548
- readonly value: Effect<State, Event, Result<A, E>>;
549
- constructor(value: Effect<State, Event, Result<A, E>>);
550
- /** Transforms the success value. */
551
- map<B>(f: (a: A) => B): ResultTransformer<State, Event, B, E>;
552
- /** Replaces the success value with `b`. */
553
- as<B>(b: B): ResultTransformer<State, Event, B, E>;
554
- /** Discards the success value. */
555
- void(): ResultTransformer<State, Event, void, E>;
556
- /** Discards the error value. */
557
- errorVoid(): ResultTransformer<State, Event, A, void>;
558
- /** Chains on success, short-circuits on failure. */
559
- flatMap<B>(f: (a: A) => Effect<State, Event, Result<B, E>>): ResultTransformer<State, Event, B, E>;
560
- /** Like `flatMap` but `f` returns an unwrapped Effect rather than an Effect of Result. */
561
- semiFlatMap<B>(f: (a: A) => Effect<State, Event, B>): ResultTransformer<State, Event, B, E>;
562
- /** Sequences on success, short-circuits on failure. */
563
- and<B>(effect: Effect<State, Event, Result<B, E>>): ResultTransformer<State, Event, B, E>;
564
- /** Unwraps the Result, returning either the success value or the error. */
565
- merge(): Effect<State, Event, A | E>;
566
- /** Logs the error to the console without changing the Result. */
567
- logError(): ResultTransformer<State, Event, A, E>;
568
- /** Logs the error and converts it to void. */
569
- logAndDropError(): ResultTransformer<State, Event, A, void>;
570
- /** Transforms the error value. */
571
- errorMap<EE>(f: (error: E) => EE): ResultTransformer<State, Event, A, EE>;
572
- /** Chains on failure, short-circuits on success. */
573
- errorFlatMap<EE>(f: (error: E) => Effect<State, Event, EE>): ResultTransformer<State, Event, A, EE>;
574
- }
575
- /**
576
- * Lifts an `Effect<State, Event, Result<A, E>>` into a `ResultTransformer` for
577
- * chaining. Equivalent to `new ResultTransformer(effect)`.
578
- */
579
- export declare function resultT<State, Event, A, E>(effect: Effect<State, Event, Result<A, E>>): ResultTransformer<State, Event, A, E>;
580
- //# sourceMappingURL=effects.d.ts.map
1
+ export { h as ClipboardError, j as DecodingError, k as DownloadInput, E as Effect, F as FlatMap, l as Fragment, n as Headers, d as HttpError, H as HttpRequest, b as HttpResponse, I as InternalLocation, J as Json, L as Lens, M as Method, o as Path, Q as QueryParam, c as RequestError, f as ResponseBody, R as Result, q as ResultTransformer, r as Return, v as ScrollElementError, S as ScrollOptions, w as StorageTarget, x as Suspend, T as TaskId, y as alert, z as async, B as cancelTask, G as clearAppBadge, K as clearLocalStorage, O as clearSessionStorage, V as confirm, W as customEffect, X as download, Y as fireEvent, Z as generateUuid, _ as getLocalStorageItem, $ as getLocation, a0 as getNotificationPermission, a1 as getRandom, a2 as getSessionStorageItem, a3 as getState, a4 as getTime, a5 as go, a6 as isEffect, a7 as log, a8 as makeEffects, a9 as makeHttpRequest, aa as mapEvent, ab as mapState, ac as noop, ad as openDatabase, ae as postBroadcastMessage, af as product, ag as prompt, ah as pure, ai as pushState, aj as readClipboard, ak as removeLocalStorageItem, al as removeSessionStorageItem, am as replaceState, an as requestNotificationPermission, ao as resultT, ap as runDbTransaction, aq as scheduleTask, ar as scrollElement, as as scrollWindow, at as setAppBadge, au as setDocumentTitle, av as setLocalStorageItem, aw as setSessionStorageItem, ax as setTimeout, ay as subscribeToBroadcastChannel, az as taskId, aA as traverse, aB as updateState, aC as writeClipboard } from './index-DeEjNrg-.js';
2
+ export { ConstraintError, DbEffect, DbError, DbName, DbSetupEffect, DbVersion, NotFoundError, ObjectStore, UnexpectedError } from './db/index.js';