@swirls/looms 0.21.0 → 0.22.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/CHANGELOG.md +6 -0
- package/dist/debugger/app/assets/{index-Et8_0gnF.js → index-CxbIGkpY.js} +2 -2
- package/dist/debugger/app/assets/{routes-DcJehTYv.js → routes-Ch30UGik.js} +2 -2
- package/dist/debugger/app/index.html +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/react.d.ts +27 -3
- package/dist/react/react.js +8 -2
- package/dist/react/store.d.ts +12 -0
- package/dist/react/store.js +11 -2
- package/dist/schedule/effects.d.ts +18 -18
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Looms debugger</title>
|
|
7
|
-
<script type="module" crossorigin src="./assets/index-
|
|
7
|
+
<script type="module" crossorigin src="./assets/index-CxbIGkpY.js"></script>
|
|
8
8
|
<link rel="modulepreload" crossorigin href="./assets/rolldown-runtime-CbXtAM7H.js">
|
|
9
9
|
<link rel="stylesheet" crossorigin href="./assets/index-CO5gIvV8.css">
|
|
10
10
|
</head>
|
package/dist/react/index.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export type { StoreObservation, StoreObserver } from './observer';
|
|
|
5
5
|
export { materializeEvents } from './materialize';
|
|
6
6
|
export { emptyTables, type MaterializedTables, type RunRow, type ThreadRow } from './tables';
|
|
7
7
|
export type { LoomsRegister, RegisteredEvent, AnyEventEnvelope } from '@swirls/looms/core';
|
|
8
|
-
export { LoomsProvider, preloadRunStore, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent, useLiveFold, type LoomsProviderProps, type PreloadRunStoreOptions, type RunStoreOptions, type UseRunStoreOptions, type RunSummary, } from './react';
|
|
8
|
+
export { LoomsProvider, preloadRunStore, useRunStore, useProjection, useRunSelector, useRunSummary, useRunEvents, useThreadTree, useEventCounts, useEventBySeq, useLatestEvent, useLiveFold, type LoomsProviderProps, type PreloadRunStoreOptions, type RunGrantSource, type RunStoreOptions, type UseRunStoreOptions, type RunSummary, } from './react';
|
package/dist/react/react.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
+
import type { SubscriptionSocketConstructor } from '@swirls/looms/client';
|
|
2
3
|
import { type AnyEventEnvelope, type ProjectionDefinition, type RegisteredEvent, type RunAttributes, type RunLaunchSource, type RunStatus, type SubscriptionTransport, type ThreadTree } from '@swirls/looms/core';
|
|
3
4
|
import type { EventCache } from './cache';
|
|
4
5
|
import { defineLiveFold, foldLive, type LiveFoldDefinition } from './derived';
|
|
@@ -19,8 +20,25 @@ export interface LoomsProviderProps {
|
|
|
19
20
|
cache?: EventCache;
|
|
20
21
|
/** Told how long each run took to show and how long each commit took. */
|
|
21
22
|
observer?: StoreObserver;
|
|
23
|
+
/** Makes every HTTP request a run store sends. See `LoomsClientStoreOptions.fetch`. */
|
|
24
|
+
fetch?: typeof fetch;
|
|
25
|
+
/** Opens a run store's live socket, in place of the global `WebSocket`. */
|
|
26
|
+
webSocket?: SubscriptionSocketConstructor;
|
|
27
|
+
/**
|
|
28
|
+
* The read grant for a run, for a host on another origin than the page. Asked each time a
|
|
29
|
+
* store connects. See `LoomsClientStoreOptions.grant`.
|
|
30
|
+
*/
|
|
31
|
+
grant?: RunGrantSource;
|
|
32
|
+
}
|
|
33
|
+
/** What gives a run's current read grant, or undefined when it has none. */
|
|
34
|
+
export type RunGrantSource = (runId: string) => string | undefined;
|
|
35
|
+
/** How a store reaches its host. Not part of which store a run gets: the first to open it decides. */
|
|
36
|
+
interface StoreReach {
|
|
37
|
+
readonly fetch?: typeof fetch;
|
|
38
|
+
readonly webSocket?: SubscriptionSocketConstructor;
|
|
39
|
+
readonly grant?: RunGrantSource;
|
|
22
40
|
}
|
|
23
|
-
interface ProviderContextValue {
|
|
41
|
+
interface ProviderContextValue extends StoreReach {
|
|
24
42
|
endpoint: string;
|
|
25
43
|
coalesce?: CoalesceOption;
|
|
26
44
|
transport?: SubscriptionTransport;
|
|
@@ -29,7 +47,7 @@ interface ProviderContextValue {
|
|
|
29
47
|
observer?: StoreObserver;
|
|
30
48
|
}
|
|
31
49
|
/** Root provider that supplies the Looms host endpoint to run stores. */
|
|
32
|
-
export declare function LoomsProvider({ children, endpoint, coalesce, transport, retainMs, cache, observer, }: LoomsProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<ProviderContextValue>>;
|
|
50
|
+
export declare function LoomsProvider({ children, endpoint, coalesce, transport, retainMs, cache, observer, fetch, webSocket, grant, }: LoomsProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<ProviderContextValue>>;
|
|
33
51
|
export interface UseRunStoreOptions {
|
|
34
52
|
endpoint?: string;
|
|
35
53
|
reconnectDelayMs?: number;
|
|
@@ -44,9 +62,15 @@ export interface UseRunStoreOptions {
|
|
|
44
62
|
/**
|
|
45
63
|
* Everything that decides which store a run gets when there is no provider to supply part of
|
|
46
64
|
* it. Inside React the provider gives `endpoint`, `coalesce`, `transport`, `retainMs`, `cache`
|
|
47
|
-
* and `
|
|
65
|
+
* `observer`, `fetch`, `webSocket` and `grant`; outside it the caller passes them.
|
|
48
66
|
*/
|
|
49
67
|
export interface RunStoreOptions extends UseRunStoreOptions {
|
|
68
|
+
/** Makes every HTTP request the store sends. See `LoomsClientStoreOptions.fetch`. */
|
|
69
|
+
fetch?: typeof fetch;
|
|
70
|
+
/** Opens the store's live socket, in place of the global `WebSocket`. */
|
|
71
|
+
webSocket?: SubscriptionSocketConstructor;
|
|
72
|
+
/** The read grant for a run. See `LoomsClientStoreOptions.grant`. */
|
|
73
|
+
grant?: RunGrantSource;
|
|
50
74
|
/** Keeps the run's durable events on the device. See `indexedDbEventCache`. */
|
|
51
75
|
cache?: EventCache;
|
|
52
76
|
/** Told how long the run took to show and how long each commit took. */
|
package/dist/react/react.js
CHANGED
|
@@ -43,6 +43,9 @@ function peekStore(runId, identity) {
|
|
|
43
43
|
fromSeq: identity.fromSeq,
|
|
44
44
|
cache: identity.cache,
|
|
45
45
|
observer: identity.observer,
|
|
46
|
+
fetch: identity.fetch,
|
|
47
|
+
webSocket: identity.webSocket,
|
|
48
|
+
grant: identity.grant === undefined ? undefined : () => identity.grant?.(runId),
|
|
46
49
|
});
|
|
47
50
|
const retainMs = Math.max(0, identity.retainMs ?? DEFAULT_RETAIN_MS);
|
|
48
51
|
registry.set(key, {
|
|
@@ -79,8 +82,8 @@ function releaseStore(runId, identity) {
|
|
|
79
82
|
}
|
|
80
83
|
}
|
|
81
84
|
/** Root provider that supplies the Looms host endpoint to run stores. */
|
|
82
|
-
export function LoomsProvider({ children, endpoint = '', coalesce, transport, retainMs, cache, observer, }) {
|
|
83
|
-
const value = useMemo(() => ({ endpoint, coalesce, transport, retainMs, cache, observer }), [endpoint, coalesce, transport, retainMs, cache, observer]);
|
|
85
|
+
export function LoomsProvider({ children, endpoint = '', coalesce, transport, retainMs, cache, observer, fetch, webSocket, grant, }) {
|
|
86
|
+
const value = useMemo(() => ({ endpoint, coalesce, transport, retainMs, cache, observer, fetch, webSocket, grant }), [endpoint, coalesce, transport, retainMs, cache, observer, fetch, webSocket, grant]);
|
|
84
87
|
return createElement(LoomsContext.Provider, { value, children });
|
|
85
88
|
}
|
|
86
89
|
/**
|
|
@@ -160,6 +163,9 @@ export function useRunStore(runId, options) {
|
|
|
160
163
|
retainMs,
|
|
161
164
|
cache: context.cache,
|
|
162
165
|
observer: context.observer,
|
|
166
|
+
fetch: context.fetch,
|
|
167
|
+
webSocket: context.webSocket,
|
|
168
|
+
grant: context.grant,
|
|
163
169
|
};
|
|
164
170
|
const store = peekStore(runId, identity);
|
|
165
171
|
useEffect(() => {
|
package/dist/react/store.d.ts
CHANGED
|
@@ -46,7 +46,19 @@ export interface LoomsClientStoreOptions {
|
|
|
46
46
|
endpoint: string;
|
|
47
47
|
/** Backoff between reconnects. The delay stays fixed, matching the SSE client. */
|
|
48
48
|
reconnectDelayMs?: number;
|
|
49
|
+
/**
|
|
50
|
+
* Makes every HTTP request the store sends, so a host can add what its backend authenticates
|
|
51
|
+
* by. With one, the live stream is read through it too, in place of `EventSource`, which
|
|
52
|
+
* cannot carry headers.
|
|
53
|
+
*/
|
|
49
54
|
fetch?: typeof fetch;
|
|
55
|
+
/**
|
|
56
|
+
* A read grant for this run (see `issueRunGrant`), or what gives the current one. Sent as
|
|
57
|
+
* `grant` on the requests that read the log, the WebSocket included, which has no other way
|
|
58
|
+
* to carry a credential across origins. Asked again on every connection, so a host can hand
|
|
59
|
+
* out short-lived grants and renew them. Never sent with a commit.
|
|
60
|
+
*/
|
|
61
|
+
grant?: string | (() => string | undefined);
|
|
50
62
|
coalesce?: CoalesceOption;
|
|
51
63
|
/**
|
|
52
64
|
* `undefined` keeps the current SSE path. `websocket` and `auto` use a hibernating
|
package/dist/react/store.js
CHANGED
|
@@ -292,8 +292,16 @@ export function createLoomsStore(options) {
|
|
|
292
292
|
}
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
+
/** Adds the run's read grant to a request that reads its log, when the host gave one. */
|
|
296
|
+
const withGrant = (params) => {
|
|
297
|
+
const grant = Predicate.isFunction(options.grant) ? options.grant() : options.grant;
|
|
298
|
+
if (grant !== undefined && grant !== '') {
|
|
299
|
+
params.set('grant', grant);
|
|
300
|
+
}
|
|
301
|
+
return params;
|
|
302
|
+
};
|
|
295
303
|
const liveUrl = () => {
|
|
296
|
-
const params = new URLSearchParams({ live: 'true', fromSeq: String(fromSeq) });
|
|
304
|
+
const params = withGrant(new URLSearchParams({ live: 'true', fromSeq: String(fromSeq) }));
|
|
297
305
|
if (options.threadId) {
|
|
298
306
|
params.set('threadId', options.threadId);
|
|
299
307
|
}
|
|
@@ -303,7 +311,8 @@ export function createLoomsStore(options) {
|
|
|
303
311
|
return `${endpoint}/runs/${encodeURIComponent(options.storeId)}/events?${params.toString()}`;
|
|
304
312
|
};
|
|
305
313
|
const pull = Effect.gen(function* () {
|
|
306
|
-
const
|
|
314
|
+
const query = withGrant(new URLSearchParams({ fromSeq: String(fromSeq) }));
|
|
315
|
+
const url = `${endpoint}/runs/${encodeURIComponent(options.storeId)}/events?${query.toString()}`;
|
|
307
316
|
const res = yield* Effect.tryPromise({
|
|
308
317
|
try: (signal) => fetchFn(url, { signal }),
|
|
309
318
|
catch: (cause) => new LoomsStoreError('Event pull failed', cause),
|
|
@@ -332,15 +332,6 @@ export declare const planEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
332
332
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
333
333
|
readonly type: "schedule.paused";
|
|
334
334
|
readonly payload: {};
|
|
335
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
336
|
-
readonly type: "schedule.resumed";
|
|
337
|
-
readonly payload: {};
|
|
338
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
339
|
-
readonly type: "schedule.retired";
|
|
340
|
-
readonly payload: {};
|
|
341
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
342
|
-
readonly type: "schedule.triggered";
|
|
343
|
-
readonly payload: {};
|
|
344
335
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
345
336
|
readonly type: "schedule.planned";
|
|
346
337
|
readonly payload: {
|
|
@@ -364,6 +355,12 @@ export declare const planEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
364
355
|
readonly payload: {
|
|
365
356
|
readonly reason: string;
|
|
366
357
|
};
|
|
358
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
359
|
+
readonly type: "schedule.resumed";
|
|
360
|
+
readonly payload: {};
|
|
361
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
362
|
+
readonly type: "schedule.retired";
|
|
363
|
+
readonly payload: {};
|
|
367
364
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
368
365
|
readonly type: "schedule.skipped";
|
|
369
366
|
readonly payload: {
|
|
@@ -374,6 +371,9 @@ export declare const planEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
374
371
|
readonly manual: boolean;
|
|
375
372
|
readonly triggerId?: string | undefined;
|
|
376
373
|
};
|
|
374
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
375
|
+
readonly type: "schedule.triggered";
|
|
376
|
+
readonly payload: {};
|
|
377
377
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
378
378
|
readonly type: "schedule.updated";
|
|
379
379
|
readonly payload: {
|
|
@@ -683,15 +683,6 @@ export declare const fireEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
683
683
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
684
684
|
readonly type: "schedule.paused";
|
|
685
685
|
readonly payload: {};
|
|
686
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
687
|
-
readonly type: "schedule.resumed";
|
|
688
|
-
readonly payload: {};
|
|
689
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
690
|
-
readonly type: "schedule.retired";
|
|
691
|
-
readonly payload: {};
|
|
692
|
-
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
693
|
-
readonly type: "schedule.triggered";
|
|
694
|
-
readonly payload: {};
|
|
695
686
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
696
687
|
readonly type: "schedule.planned";
|
|
697
688
|
readonly payload: {
|
|
@@ -715,6 +706,12 @@ export declare const fireEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
715
706
|
readonly payload: {
|
|
716
707
|
readonly reason: string;
|
|
717
708
|
};
|
|
709
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
710
|
+
readonly type: "schedule.resumed";
|
|
711
|
+
readonly payload: {};
|
|
712
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
713
|
+
readonly type: "schedule.retired";
|
|
714
|
+
readonly payload: {};
|
|
718
715
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
719
716
|
readonly type: "schedule.skipped";
|
|
720
717
|
readonly payload: {
|
|
@@ -725,6 +722,9 @@ export declare const fireEffect: NoInfer<import("@swirls/looms/core").LocalEffec
|
|
|
725
722
|
readonly manual: boolean;
|
|
726
723
|
readonly triggerId?: string | undefined;
|
|
727
724
|
};
|
|
725
|
+
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
726
|
+
readonly type: "schedule.triggered";
|
|
727
|
+
readonly payload: {};
|
|
728
728
|
}) | (Omit<import("@swirls/looms/core").EventInput, "payload" | "type"> & {
|
|
729
729
|
readonly type: "schedule.updated";
|
|
730
730
|
readonly payload: {
|