@yaks/wake 0.0.0-stage → 0.2.36

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 (85) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +325 -2
  3. package/_dist/cloudflare.d.ts +68 -0
  4. package/_dist/cloudflare.d.ts.map +1 -0
  5. package/_dist/comp.d.ts +59 -0
  6. package/_dist/comp.d.ts.map +1 -0
  7. package/_dist/deno.d.ts +40 -0
  8. package/_dist/deno.d.ts.map +1 -0
  9. package/_dist/due.d.ts +96 -0
  10. package/_dist/due.d.ts.map +1 -0
  11. package/_dist/every.d.ts +65 -0
  12. package/_dist/every.d.ts.map +1 -0
  13. package/_dist/graph.d.ts +4 -0
  14. package/_dist/graph.d.ts.map +1 -0
  15. package/_dist/held.d.ts +9 -0
  16. package/_dist/held.d.ts.map +1 -0
  17. package/_dist/mod.d.ts +59 -0
  18. package/_dist/mod.d.ts.map +1 -0
  19. package/_dist/plugin.d.ts +20 -0
  20. package/_dist/plugin.d.ts.map +1 -0
  21. package/_dist/run.d.ts +24 -0
  22. package/_dist/run.d.ts.map +1 -0
  23. package/_dist/service.d.ts +9 -0
  24. package/_dist/service.d.ts.map +1 -0
  25. package/_dist/tick.d.ts +36 -0
  26. package/_dist/tick.d.ts.map +1 -0
  27. package/_dist/tools.d.ts +6 -0
  28. package/_dist/tools.d.ts.map +1 -0
  29. package/_dist/vocab.d.ts +7 -0
  30. package/_dist/vocab.d.ts.map +1 -0
  31. package/_dist/watch.d.ts +58 -0
  32. package/_dist/watch.d.ts.map +1 -0
  33. package/_dist/while.d.ts +43 -0
  34. package/_dist/while.d.ts.map +1 -0
  35. package/cloudflare.js +80 -0
  36. package/cloudflare.js.map +1 -0
  37. package/cloudflare.ts +113 -0
  38. package/comp.js +59 -0
  39. package/comp.js.map +1 -0
  40. package/comp.ts +139 -0
  41. package/deno.js +57 -0
  42. package/deno.js.map +1 -0
  43. package/deno.json +1 -0
  44. package/deno.ts +78 -0
  45. package/due.js +147 -0
  46. package/due.js.map +1 -0
  47. package/due.ts +180 -0
  48. package/every.js +203 -0
  49. package/every.js.map +1 -0
  50. package/every.ts +223 -0
  51. package/graph.js +10 -0
  52. package/graph.js.map +1 -0
  53. package/graph.ts +11 -0
  54. package/held.js +29 -0
  55. package/held.js.map +1 -0
  56. package/held.ts +42 -0
  57. package/mod.js +59 -0
  58. package/mod.js.map +1 -0
  59. package/mod.ts +60 -0
  60. package/package.json +49 -4
  61. package/plugin.js +87 -0
  62. package/plugin.js.map +1 -0
  63. package/plugin.ts +94 -0
  64. package/run.js +124 -0
  65. package/run.js.map +1 -0
  66. package/run.ts +117 -0
  67. package/service.js +28 -0
  68. package/service.js.map +1 -0
  69. package/service.ts +42 -0
  70. package/tick.js +168 -0
  71. package/tick.js.map +1 -0
  72. package/tick.ts +181 -0
  73. package/tools.js +83 -0
  74. package/tools.js.map +1 -0
  75. package/tools.ts +76 -0
  76. package/vocab.js +14 -0
  77. package/vocab.js.map +1 -0
  78. package/vocab.json +270 -0
  79. package/vocab.ts +16 -0
  80. package/watch.js +175 -0
  81. package/watch.js.map +1 -0
  82. package/watch.ts +193 -0
  83. package/while.js +159 -0
  84. package/while.js.map +1 -0
  85. package/while.ts +176 -0
@@ -0,0 +1,40 @@
1
+ /**
2
+ * A long-running process can sleep until the next wake instead of polling at a
3
+ * fixed rate. The cap lets newly written wakes be noticed without a
4
+ * subscription, sleeping ones a write made hold among them, and keeps an empty
5
+ * graph and a far-off date within `setTimeout`'s range. Stopping aborts only
6
+ * the wait: a graph write already underway finishes its phases.
7
+ * @module
8
+ */ import { type Clock } from "@yaks/fp";
9
+ import { type Driver, type Ticked } from "./tick.js";
10
+ /** The loop's lifetime, its maximum sleep, and a callback run after each
11
+ * tick. */ export type LoopOpts = {
12
+ /** abort to stop the loop and release its timer */ signal?: AbortSignal;
13
+ /** maximum sleep in milliseconds (default one minute); also the retry
14
+ * interval for wakes whose transaction was rejected, and the delay while the
15
+ * graph has nothing scheduled */ cap?: number;
16
+ /** called after each tick with the fired and rejected wakes, a wake its
17
+ * `while` could not arm among the rejected */ onTick?: (result: Ticked) => void | Promise<void>;
18
+ /** the time each tick is at, and the timer the loop sleeps on (default the
19
+ * runtime's) */ clock?: Clock;
20
+ };
21
+ /**
22
+ * Rouse and tick immediately, then sleep until the next due instant or the
23
+ * cap, whichever is sooner. A wake whose transaction was rejected on one pass
24
+ * stays due for the next; effects run through the graph. Uses only web timers
25
+ * and `AbortSignal`, available in Deno and Node alike.
26
+ *
27
+ * The first tick happens whatever the signal's state, so one that has already
28
+ * aborted produces exactly one pass — which is how a short-lived process fires
29
+ * what is overdue as it starts up.
30
+ *
31
+ * ```ts
32
+ * import { loop } from '@yaks/wake/deno'
33
+ *
34
+ * let stop = new AbortController()
35
+ * // let running = loop(graph, { signal: stop.signal })
36
+ * // stop.abort()
37
+ * // await running
38
+ * ```
39
+ */ export declare let loop: (graph: Driver, opts?: LoopOpts) => Promise<void>;
40
+ //# sourceMappingURL=deno.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deno.d.ts","sources":["../deno.ts"],"names":[],"mappings":"AAAA;;;;;;;CAOC,GAED,SAAS,KAAK,KAAK,wBAA4C;AAG/D,SAAS,KAAK,MAAM,EAAQ,KAAK,MAAM,oBAAmB;AAE1D;SACS,GACT,YAAY;EACV,iDAAiD,GACjD,SAAS;EACT;;iCAE+B,GAC/B,MAAM,MAAM;EACZ;8CAC4C,GAC5C,UAAU,QAAQ,WAAW,IAAI,GAAG,QAAQ,IAAI;EAChD;gBACc,GACd,QAAQ;;AAGV;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,OACT,OAAO,QACP,OAAM,aACL,QAAQ,IAAI,EAwBd"}
package/_dist/due.d.ts ADDED
@@ -0,0 +1,96 @@
1
+ import type { Bundle, ReadOpts } from "@yaks/graph";
2
+ import { type Built } from "@yaks/query";
3
+ import { type Wake } from "./comp.js";
4
+ /** How a schedule is read: the time zone a cron line is interpreted in. */ export type Clock = {
5
+ /** the time zone a cron `every` is read in (default `UTC`) */ tz?: string;
6
+ };
7
+ /** What reads the wakes: a graph, or the storage under one. */ export type Reads = {
8
+ read: (query: Built, opts: ReadOpts) => Bundle[] | Promise<Bundle[]>;
9
+ };
10
+ /** The wake a bundle carries, or `undefined`. */ export declare let wakeOf: (b: Bundle) => Wake | undefined;
11
+ /**
12
+ * The wakes due at `now`, oldest first — every entity whose `wake.at` has
13
+ * passed, with the query it watches where it watches one.
14
+ *
15
+ * This is the only read the package makes, and it is an ordinary query, so an
16
+ * application that would rather run its own (a narrower filter, a page at a
17
+ * time) can: `.wake.at<=now&?watch`, read at the instant.
18
+ *
19
+ * ```ts
20
+ * import { due, ring } from '@yaks/wake'
21
+ *
22
+ * let now = Date.now()
23
+ * // let owed = due(storage, now)
24
+ * // for (let w of owed) graph.apply([ring(w, now)])
25
+ * ```
26
+ *
27
+ * It follows @yaks/graph's synchronous pass-through: over a synchronous storage
28
+ * it returns the bundles, and over an asynchronous one a promise for them.
29
+ */ export declare let due: (storage: Reads, now?: number) => Bundle[] | Promise<Bundle[]>;
30
+ /** The query clauses a due wake matches, with what it watches: read with the
31
+ * instant as the read's `now`. The instant is the clock a statement binds, not
32
+ * a word of the query, so every read of it is one statement (@yaks/sql
33
+ * `compile`). */ export declare let owed: Built;
34
+ /**
35
+ * The next ISO instant after `now`, computed from a recurrence string or from a
36
+ * wake — `null` for a one-shot, or for a recurrence this package cannot parse.
37
+ * Given a string, a duration is counted from `now`; given a wake, the cadence
38
+ * keeps its original phase.
39
+ *
40
+ * A duration is counted from the wake's own `at`, so a cadence keeps its phase;
41
+ * a cron line is evaluated against the calendar. See
42
+ * {@link https://jsr.io/@yaks/wake/doc/~/recur | recur}.
43
+ *
44
+ * A fixed duration counts from the supplied instant:
45
+ *
46
+ * ```ts
47
+ * import { assertEquals } from '@std/assert'
48
+ * import { next } from '@yaks/wake'
49
+ *
50
+ * let from = Date.parse('2026-01-01T09:00:00Z')
51
+ * assertEquals(next('1d', from), '2026-01-02T09:00:00.000Z')
52
+ * ```
53
+ *
54
+ * A cron line reads its named calendar:
55
+ *
56
+ * ```ts
57
+ * import { assertEquals } from '@std/assert'
58
+ * import { next } from '@yaks/wake'
59
+ *
60
+ * let from = Date.parse('2026-01-01T09:00:00Z')
61
+ * assertEquals(next('@daily', from, 'America/Detroit'), '2026-01-02T05:00:00.000Z')
62
+ * ```
63
+ *
64
+ * A one-shot has no next instant:
65
+ *
66
+ * ```ts
67
+ * import { assertEquals } from '@std/assert'
68
+ * import { next } from '@yaks/wake'
69
+ *
70
+ * let from = Date.parse('2026-01-01T09:00:00Z')
71
+ * assertEquals(next({ at: '2026-01-01T09:00:00Z' }, from), null)
72
+ * ```
73
+ */ export declare let next: (wake: Wake | string, now?: number, clock?: Clock | string) => string | null;
74
+ /**
75
+ * The patch that fires a due wake: the `fired` value, plus its `at` moved on to
76
+ * the next instant — or cleared, when there is no next one. `every` is the
77
+ * cadence it goes on at, its own by default; `tick` passes the one its
78
+ * `while` chose.
79
+ *
80
+ * It returns a bundle rather than applying it. `tick` applies one such bundle
81
+ * per wake, and the graph's rules react to that write in their own phases.
82
+ *
83
+ * ```ts
84
+ * // let owed = due(storage, now)
85
+ * // for (let w of owed) graph.apply([ring(w, now)])
86
+ * ```
87
+ */ export declare let ring: (b: Bundle, now?: number, clock?: Clock, every?: string | null | undefined) => Bundle;
88
+ /**
89
+ * The instant the scheduler should next run — the earliest `at` still in the
90
+ * future, or `null` when nothing is pending. This is what a Durable Object
91
+ * passes to `setAlarm()`, and what a server passes to `setTimeout`.
92
+ *
93
+ * An application may equally ignore this and poll on a fixed cadence; it is
94
+ * here so that one able to sleep until an exact instant does not have to poll.
95
+ */ export declare let soonest: (storage: Reads, now?: number) => number | null | Promise<number | null>;
96
+ //# sourceMappingURL=due.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"due.d.ts","sources":["../due.ts"],"names":[],"mappings":"AAyBA,cAAc,MAAM,EAAgB,QAAQ,2BAAgC;AAE5E,SAAS,KAAK,KAAK,2BAA2C;AAC9D,SAAsB,KAAK,IAAI,oBAA0B;AAGzD,yEAAyE,GACzE,YAAY;EACV,4DAA4D,GAC5D,KAAK,MAAM;;AAKb,6DAA6D,GAC7D,YAAY;EACV,OAAO,OAAO,OAAO,MAAM,aAAa,WAAW,QAAQ;;AAG7D,+CAA+C,GAC/C,OAAO,YAAI,SAAU,GAAG,WAAS,OAAO,SAAS,CACL;AAE5C;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,MACT,SAAS,OACT,MAAK,MAAM,KACV,WAAW,QAAQ,UACuC;AAE7D;;;eAGe,GACf,OAAO,YAAI,MAAM,MAAwC;AAEzD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCC,GACD,OAAO,YAAI,OACT,MAAM,OAAO,MAAM,EACnB,MAAK,MAAM,EACX,QAAO,QAAQ,MAAM,KACpB,MAAM,GAAG,IAAI,CAWf;AAED;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,OACT,GAAG,QACH,MAAK,MAAM,EACX,QAAO,OACP,QAAO,MAAM,GAAG,IAAI,GAAG,SAAS,KAC/B,OAID;AAEF;;;;;;;CAOC,GACD,OAAO,YAAI,UACT,SAAS,OACT,MAAK,MAAM,KACV,MAAM,GAAG,IAAI,GAAG,QAAQ,MAAM,GAAG,IAAI,EAOrC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A recurrence parsed as a fixed length of time, in milliseconds — `null` when
3
+ * it is a cron line, or anything this grammar does not accept.
4
+ *
5
+ * ```ts
6
+ * import { assertEquals } from '@std/assert'
7
+ * import { span } from './every.ts'
8
+ *
9
+ * assertEquals(span('30m'), 1800000)
10
+ * assertEquals(span('every 2 hours'), 7200000)
11
+ * assertEquals(span('0 9 * * 1-5'), null)
12
+ * ```
13
+ */ export declare let span: (every: string) => number | null;
14
+ /**
15
+ * The instant a wake written `at` comes due, in epoch milliseconds: an
16
+ * instant as written, or a delay counted from `now` (`10m`, `2h`, `1d`), as a
17
+ * person says "in ten minutes". `null` for anything else.
18
+ *
19
+ * ```ts
20
+ * import { assertEquals } from '@std/assert'
21
+ * import { when } from './every.ts'
22
+ *
23
+ * let now = Date.parse('2026-01-01T09:00:00Z')
24
+ * assertEquals(when('10m', now), Date.parse('2026-01-01T09:10:00Z'))
25
+ * assertEquals(when('2026-01-02T09:00Z', now), Date.parse('2026-01-02T09:00Z'))
26
+ * assertEquals(when('soon', now), null)
27
+ * ```
28
+ */ export declare let when: (at: string, now: number) => number | null;
29
+ /** The weekday and date of `at` in a cron recurrence's time zone.
30
+ * A cron line without a zone uses UTC. Durations have no calendar date. */ export declare let calendarDate: (every: string, at: number) => string | undefined;
31
+ /**
32
+ * The first instant a recurrence lands on strictly after `now`, counting a
33
+ * duration from `from`.
34
+ *
35
+ * The two moments are different clocks on purpose. A cron line ignores `from`
36
+ * — nine in the morning is nine in the morning. A duration counts from
37
+ * `from`, the last instant the wake was due, so a cadence keeps its phase and
38
+ * a long outage catches up in one step instead of firing once per missed tick.
39
+ *
40
+ * ```ts
41
+ * import { assertEquals } from '@std/assert'
42
+ * import { recur } from './every.ts'
43
+ *
44
+ * let t = Date.parse('2026-01-01T09:17:00Z')
45
+ * // two hours on from 09:17, skipping the ticks a six-hour outage missed
46
+ * assertEquals(recur('2h', t, t + 6 * 3600_000), Date.parse('2026-01-01T17:17:00Z'))
47
+ * assertEquals(recur('@hourly', t, t), Date.parse('2026-01-01T10:00:00Z'))
48
+ * ```
49
+ *
50
+ * Cron follows the named time zone's calendar. At a spring DST gap, a local
51
+ * time that does not exist moves forward by the gap; a local time that occurs
52
+ * twice in autumn fires once, at the first occurrence. These are Croner's
53
+ * existing calendar semantics.
54
+ *
55
+ * A calendar reused from the preceding day still resolves the DST gap:
56
+ *
57
+ * @param every the recurrence: a duration, a cron line, or a `@` shorthand
58
+ * @param from the instant a duration counts from (a cron line ignores it)
59
+ * @param now the moment the result must be strictly after
60
+ * @param tz the default time zone for a cron line with no trailing zone
61
+ * (`UTC`)
62
+ * @returns the instant, in epoch milliseconds, or `null` if `every` cannot be
63
+ * parsed
64
+ */ export declare let recur: (every: string, from: number, now: number, tz?: string) => number | null;
65
+ //# sourceMappingURL=every.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"every.d.ts","sources":["../every.ts"],"names":[],"mappings":"AAqEA;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,OAAQ,OAAO,MAAM,KAAG,MAAM,GAAG,IAAI,CAO/C;AAED;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,OAAQ,IAAI,MAAM,EAAE,KAAK,MAAM,KAAG,MAAM,GAAG,IAAI,CAIzD;AAkCD;yEACyE,GACzE,OAAO,YAAI,eAAgB,OAAO,MAAM,EAAE,IAAI,MAAM,KAAG,MAAM,GAAG,SAAS,CAWxE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCC,GAKD,OAAO,YAAI,QACT,OAAO,MAAM,EACb,MAAM,MAAM,EACZ,KAAK,MAAM,EACX,gBACC,MAAM,GAAG,IAAI,CAoBf"}
@@ -0,0 +1,4 @@
1
+ import type { Plugin } from "@yaks/graph";
2
+ /** `wake{at, every, while, target, note}` and the recurrence that moves one
3
+ * on. */ export declare let plugins: () => Plugin[];
4
+ //# sourceMappingURL=graph.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graph.d.ts","sources":["../graph.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,2BAAgC;AAGpD;OACO,GACP,OAAO,YAAI,eAAc,SAAqB"}
@@ -0,0 +1,9 @@
1
+ import { type Bundle, type Eid, type Graph } from "@yaks/graph";
2
+ type G = Pick<Graph, 'read' | 'get' | 'apply' | 'address'>;
3
+ /** The wakes set for `person` that will fire again, soonest first, whole. */ export declare let held: (g: Pick<Graph, 'read'>, person: Eid) => Promise<Bundle[]>;
4
+ /** The wake `id` names (an eid, a short `#id` or a `W-` number) when it is
5
+ * set for `person`, else `undefined`. */ export declare let theirs: (g: Pick<G, 'get' | 'address'>, person: Eid, id: string) => Promise<Bundle | undefined>;
6
+ /** Cancel the wake `id` names when it is set for `person`: it is deleted, so
7
+ * it never fires again. Answers the wake cancelled, or `undefined` when
8
+ * `person` has no such wake. */ export declare let cancel: (g: Pick<G, 'get' | 'address' | 'apply'>, person: Eid, id: string, opts?: Parameters<Graph['apply']>[1]) => Promise<Bundle | undefined>;
9
+ //# sourceMappingURL=held.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"held.d.ts","sources":["../held.ts"],"names":[],"mappings":"AAKA,SAAoB,KAAK,MAAM,EAAE,KAAK,GAAG,EAAE,KAAK,KAAK,2BAAgC;KAIhF,IAAI,KAAK,OAAO,SAAS,QAAQ,UAAU;AAEhD,2EAA2E,GAC3E,OAAO,YAAI,OAAQ,GAAG,KAAK,OAAO,SAAS,QAAQ,QAAM,QAAQ,UAG9D;AAEH;uCACuC,GACvC,OAAO,YAAI,SACT,GAAG,KAAK,GAAG,QAAQ,YACnB,QAAQ,KACR,IAAI,MAAM,KACT,QAAQ,SAAS,SAAS,EAI5B;AAED;;8BAE8B,GAC9B,OAAO,YAAI,SACT,GAAG,KAAK,GAAG,QAAQ,YAAY,UAC/B,QAAQ,KACR,IAAI,MAAM,EACV,OAAM,WAAW,MAAM,UAAU,OAChC,QAAQ,SAAS,SAAS,EAI5B"}
package/_dist/mod.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @yaks/wake — schedules as graph rows, shared by Deno, Workers and browsers.
3
+ * A wake records when to come back to something; firing it writes `fired{at}`
4
+ * on the same entity. The graph's rules decide what follows that write.
5
+ *
6
+ * - `wake{at, every, while, target, note}` — the next instant, optional
7
+ * recurrence, the conditions it recurs under, what it is about, and why.
8
+ * - `fired{at}` — the most recent firing.
9
+ * - `watch{query, local, seen, changes}` — a query whose change it fires on.
10
+ * - `occurrence{wake, at, call, error}` — one firing that ran a call
11
+ * (`@yaks/wake/run`).
12
+ *
13
+ * `wake.for` is whom a wake was set for: it runs as them, and `held` and
14
+ * `cancel` are their own wakes.
15
+ *
16
+ * ```ts
17
+ * import { next, tick } from '@yaks/wake'
18
+ *
19
+ * let at = next('20 4 * * * America/Detroit', Date.now())
20
+ * // await graph.apply([{ entity: { eid: 'cleanup' }, wake: { at }, sweep: {} }])
21
+ * // await tick(graph, Date.now())
22
+ * ```
23
+ *
24
+ * `tick` finds the due wakes and applies one transaction per wake, each with a
25
+ * precondition on what it read: `fired` plus the next `wake.at`, or a cleared
26
+ * `at` for a one-shot. One rejected transaction leaves that wake due and lets
27
+ * the others fire. Occurrences missed during an outage collapse into one
28
+ * firing, which then advances past now.
29
+ *
30
+ * A rule such as `.wake, *fired, .sweep` runs through the graph's own phases.
31
+ * `produce` is the declarative case; `run` is code. `#Now` is the tick's
32
+ * instant and `#Actor` is the actor of the write, as in every graph write.
33
+ *
34
+ * A duration (`30m`, `every 3 days`) keeps its original cadence. Five cron
35
+ * fields (`0 9 * * 1-5`) or `@hourly`, `@daily`, `@weekly`, `@monthly` name
36
+ * calendar positions. An optional trailing IANA time zone is stored in the same
37
+ * property; with none, UTC is used. Croner uses Intl, with no build step.
38
+ *
39
+ * A wake that watches a query (`watch`) fires only when the query's rows
40
+ * changed since it last looked; a look that finds nothing new moves it on.
41
+ *
42
+ * `while` makes a recurrence conditional: `{match, every}` in order, the first
43
+ * whose query finds anything setting the cadence at each firing. A wake none
44
+ * holds sleeps, and `rouse` arms it again once a write makes one hold.
45
+ *
46
+ * This module starts no timer and imports no platform API. The program running
47
+ * it calls `tick` when its own clock fires, and `rouse` after its writes
48
+ * commit.
49
+ *
50
+ * @module
51
+ */ export * from "./comp.js";
52
+ export * from "./every.js";
53
+ export * from "./due.js";
54
+ export * from "./held.js";
55
+ export * from "./plugin.js";
56
+ export * from "./tick.js";
57
+ export * from "./watch.js";
58
+ export * from "./while.js";
59
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkDC,GAED,0BAAyB;AACzB,2BAA0B;AAC1B,yBAAwB;AACxB,0BAAyB;AACzB,4BAA2B;AAC3B,0BAAyB;AACzB,2BAA0B;AAC1B,2BAA0B"}
@@ -0,0 +1,20 @@
1
+ import { type Hook, type Plugin } from "@yaks/graph/plugin";
2
+ import { type Clock } from "./due.js";
3
+ /** How the plugin reads a schedule, and where it gets the current time. */ export type Opts = Clock & {
4
+ /** the clock, replaceable in tests (default `Date.now`) */ now?: () => number;
5
+ };
6
+ /**
7
+ * The `beforeWrite` hook: a new cadence without a first instant gets one.
8
+ * An existing recurrence without `at` is paused; omission in a patch or a
9
+ * replayed read must leave it paused. Likewise, cadence edits retain an
10
+ * existing instant. Exported for graphs that load the vocabulary separately.
11
+ */ export declare let starting: (opts?: Opts) => Hook;
12
+ /**
13
+ * The wake plugin: the `wake` and `fired` components, and the two hooks
14
+ * above.
15
+ *
16
+ * The application calls `tick(graph, now)` to fire due wakes. Rules matching
17
+ * `.wake, *fired` run in their declared phases; the driver itself calls no
18
+ * handler.
19
+ */ export declare let wakes: (opts?: Opts) => Plugin;
20
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sources":["../plugin.ts"],"names":[],"mappings":"AAqBA,SAAS,KAAK,IAAI,EAAQ,KAAK,MAAM,kCAAuC;AAC5E,SAAS,KAAK,KAAK,mBAA0B;AAK7C,yEAAyE,GACzE,YAAY,OAAO;EACjB,yDAAyD,GACzD,YAAY,MAAM;;AAGpB;;;;;CAKC,GACD,OAAO,YAAI,WAAY,OAAM,SAAY,KAqBtC;AAEH;;;;;;;CAOC,GAUD,OAAO,YAAI,QAAS,OAAM,SAAY,OAcpC"}
package/_dist/run.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { type Bundle, type Eid, type Graph } from "@yaks/graph";
2
+ import { type Runner } from "@yaks/tools";
3
+ type G = Pick<Graph, 'get' | 'apply'>;
4
+ /** The most characters of a call's answer an occurrence says. */ export declare let SAID: number;
5
+ /** The occurrence a wake's firing at `at` records. */ export declare let occurrenceOf: (wake: Eid, at: string) => Eid;
6
+ /** What one firing's call came to: its occurrence, the answer in words, and
7
+ * the failure where it failed. */ export type Ran = {
8
+ occurrence: Eid;
9
+ text: string;
10
+ error?: string;
11
+ };
12
+ /** What the host lends a firing. */ export type Host = {
13
+ /** the runner the call is made through, over the person's tools as they
14
+ * stand now; given the occurrence the call is made for */ runner: (occurrence: Eid) => Runner | Promise<Runner>;
15
+ /** what else the occurrence is written with */ with?: Omit<Bundle, 'entity'>;
16
+ /** whom the call is made by; it comes in through its occurrence */ by?: string;
17
+ };
18
+ /**
19
+ * Record a wake's firing at `at` and run the call it carries, once: answers
20
+ * the occurrence and what the call said, with its failure, or `undefined`
21
+ * when the occurrence already ended. A wake with no call is recorded and
22
+ * answers that nothing was called.
23
+ */ export declare let run: (g: G, wake: Bundle, at: string, host: Host) => Promise<Ran | undefined>;
24
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sources":["../run.ts"],"names":[],"mappings":"AAiBA,SACE,KAAK,MAAM,EAGX,KAAK,GAAG,EACR,KAAK,KAAK,2BACmB;AAC/B,SAA4B,KAAK,MAAM,2BAAwC;KAG1E,IAAI,KAAK,OAAO,QAAQ;AAE7B,+DAA+D,GAC/D,OAAO,YAAI,aAAa;AAExB,oDAAoD,GACpD,OAAO,YAAI,eAAgB,MAAM,KAAK,IAAI,MAAM,KAAG,IACX;AAExC;gCACgC,GAChC,YAAY;EAAQ,YAAY;EAAK,MAAM,MAAM;EAAE,QAAQ,MAAM;;AAEjE,kCAAkC,GAClC,YAAY;EACV;0DACwD,GACxD,SAAS,YAAY,QAAQ,SAAS,QAAQ;EAC9C,6CAA6C,GAC7C,OAAO,KAAK,QAAQ;EACpB,iEAAiE,GACjE,KAAK,MAAM;;AAiBb;;;;;CAKC,GACD,OAAO,YAAI,MACT,GAAG,GACH,MAAM,QACN,IAAI,MAAM,EACV,MAAM,SACL,QAAQ,MAAM,SAAS,EAwCzB"}
@@ -0,0 +1,9 @@
1
+ import type { Graph } from "@yaks/graph";
2
+ /** What a config file can set for this plugin. */ export type Options = {
3
+ /** the longest this may sleep, in milliseconds (default one minute) — also
4
+ * how soon a wake whose transaction was rejected is retried */ cap?: number;
5
+ };
6
+ /** Fire what is due, for as long as the server is up. */ export declare let service: (host: {
7
+ graph: Graph;
8
+ }, options?: Options, signal?: AbortSignal) => Promise<void>;
9
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sources":["../service.ts"],"names":[],"mappings":"AAaA,cAAc,KAAK,2BAAgC;AAInD,gDAAgD,GAChD,YAAY;EACV;+DAC6D,GAC7D,MAAM,MAAM;;AAGd,uDAAuD,GACvD,OAAO,YAAI,UACT;EAAQ,OAAO;GACf,UAAS,SACT,SAAS,gBACR,QAAQ,IAAI,EAYX"}
@@ -0,0 +1,36 @@
1
+ import type { Bundle, Graph } from "@yaks/graph";
2
+ import { type Watching } from "./watch.js";
3
+ /** The part of the graph API a driver needs, also satisfied by a client for a
4
+ * remote graph over HTTP. */ export type Driver = Pick<Graph, 'read' | 'apply'>;
5
+ /** A committed firing and a rejected attempt are separate outcomes. Effect
6
+ * failures are reported through the graph's error reporter instead: their
7
+ * writes have already committed. */ export type Ticked = {
8
+ /** the applied wake bundles, including what the graph's rules produced */ fired: Bundle[];
9
+ /** the wakes left due, with the reason each transaction was rejected */ refused: {
10
+ wake: Bundle;
11
+ error: unknown;
12
+ }[];
13
+ };
14
+ /** How `tick` reads what a wake watches (./watch.ts). */ export type TickOpts = {
15
+ /** the rows a watched query answers for a wake; the graph's by default */ watching?: Watching;
16
+ /** Records made in the same transaction as a firing. */ records?: (wake: Bundle, at: string, changes?: string, refused?: boolean) => Bundle[];
17
+ };
18
+ /**
19
+ * Fire the due wakes, one transaction per wake, each with a precondition on
20
+ * what it read. A wake that watches a query (`watch`) is read again first and
21
+ * fires only when its rows changed, with `watch.changes` saying how; a look
22
+ * that finds nothing new moves `at` on without firing. A look the reader
23
+ * refuses for the query's own sake fires once, `watch.changes` saying why,
24
+ * and not again while later looks are refused for the same reason. `now` is
25
+ * in epoch milliseconds and becomes both `fired.at` and
26
+ * the graph's `#Now` resource. Missed occurrences collapse into one firing, and
27
+ * the recurrence advances past now — at the cadence of the first `while`
28
+ * condition that holds at `now`, else its own `every`, else not at all.
29
+ *
30
+ * ```ts
31
+ * import { tick } from '@yaks/wake'
32
+ *
33
+ * // let { fired, refused } = await tick(graph, Date.now())
34
+ * ```
35
+ */ export declare let tick: (graph: Driver, now?: number, opts?: TickOpts) => Promise<Ticked>;
36
+ //# sourceMappingURL=tick.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tick.d.ts","sources":["../tick.ts"],"names":[],"mappings":"AAQA,cAAc,MAAM,EAAE,KAAK,2BAAgC;AAQ3D,SAAe,KAAK,QAAQ,qBAA6B;AAEzD;2BAC2B,GAC3B,YAAY,SAAS,KAAK,OAAO,SAAS;AAwB1C;;kCAEkC,GAClC,YAAY;EACV,wEAAwE,GACxE,OAAO;EACP,sEAAsE,GACtE;IAAW,MAAM;IAAQ,OAAO,OAAO;;;AAGzC,uDAAuD,GACvD,YAAY;EACV,wEAAwE,GACxE,WAAW;EACX,sDAAsD,GACtD,WACE,MAAM,QACN,IAAI,MAAM,EACV,UAAU,MAAM,EAChB,UAAU,OAAO,KACd;;AAGP;;;;;;;;;;;;;;;;;CAiBC,GACD,OAAO,YAAI,OACT,OAAO,QACP,MAAK,MAAM,EACX,OAAM,aACL,QAAQ,QA2FV"}
@@ -0,0 +1,6 @@
1
+ import type { Runs } from "@yaks/graph/tools";
2
+ /** The implementations of `wake_new`, `wake_list` and `wake_cancel`. A
3
+ * factory, like every such module: `now` is the clock a delay counts from. */ export declare let runs: (o?: {
4
+ now?: () => number;
5
+ }) => Runs;
6
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sources":["../tools.ts"],"names":[],"mappings":"AAYA,cAAc,IAAI,iCAAsC;AAexD;4EAC4E,GAC5E,OAAO,YAAI,OAAQ;EAAK,YAAY,MAAM;MAAU,KA8ClD"}
@@ -0,0 +1,7 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ import { wakeDoc } from "./comp.js";
3
+ export { wakeDoc };
4
+ /** What this package is: its manifest's description, the one place it is
5
+ * written, which a host stamps on each document here. */ export declare let description: string;
6
+ /** Every document this plugin declares. */ export declare let docs: VocabDoc[];
7
+ //# sourceMappingURL=vocab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAIA,cAAc,QAAQ,2BAAgC;AACtD,SAAS,OAAO,oBAAmB;AAGnC,SAAS,OAAO,GAAE;AAElB;uDACuD,GACvD,OAAO,YAAI,aAAa,MAAM,CAAuB;AAErD,yCAAyC,GACzC,OAAO,YAAI,MAAM,WAAsB"}
@@ -0,0 +1,58 @@
1
+ import type { Bundle, Graph } from "@yaks/graph";
2
+ import { type Watch } from "./comp.js";
3
+ /** The most rows a watch keeps track of. */ export declare let ROWS: number;
4
+ /** Each row a look saw, by eid, and a digest of what it held. */ export type Seen = Record<string, string>;
5
+ /** How a watched query is read for a wake: over the graph the wake is kept
6
+ * in, unless its host reads one that is not `local` more widely. */ export type Watching = (wake: Bundle, watch: Watch) => Bundle[] | Promise<Bundle[]>;
7
+ /** The query a wake watches, or `undefined`. */ export declare let watchOf: (b: Bundle) => Watch | undefined;
8
+ /**
9
+ * What `rows` say against what a watch saw before (`was`): what it sees now,
10
+ * and what changed in words, `''` when nothing did.
11
+ *
12
+ * ```ts
13
+ * import { assertEquals } from '@std/assert'
14
+ * import { look } from './watch.ts'
15
+ *
16
+ * let row = { entity: { eid: 'm1' }, meeting: { title: 'Road millage' } }
17
+ * let { seen, changes } = await look({}, [row])
18
+ * assertEquals(changes.split('\n')[0], 'What changed (1 new):')
19
+ * assertEquals((await look(seen, [row])).changes, '')
20
+ * ```
21
+ */ export declare let look: (was: Seen, rows: Bundle[]) => Promise<{
22
+ seen: Seen;
23
+ changes: string;
24
+ }>;
25
+ /**
26
+ * What `changes`, as `look` says them, counted: `1 new, 2 changed`, or
27
+ * nothing for other words.
28
+ *
29
+ * ```ts
30
+ * import { assertEquals } from '@std/assert'
31
+ * import { counted } from './watch.ts'
32
+ * assertEquals(counted('What changed (1 new, 2 gone):\nnew: {}'), '1 new, 2 gone')
33
+ * assertEquals(counted('Fixed it.'), undefined)
34
+ * ```
35
+ */ export declare let counted: (changes: string) => string | undefined;
36
+ /** How long after a commit a stirred wake looks: commits inside it are one
37
+ * look, and one firing. */ export declare let SOON: number;
38
+ /**
39
+ * Something the watching wakes of `graph` read committed: each one `which`
40
+ * picks comes due `soon` after `now` (unless it is due sooner already), so
41
+ * the host's next `tick` reads its query again and fires it if its rows
42
+ * changed. Answers the soonest instant a stirred wake is due, in epoch ms,
43
+ * or null when `which` picks none.
44
+ *
45
+ * ```ts
46
+ * import { assertEquals } from '@std/assert'
47
+ * import { stir } from './watch.ts'
48
+ * import { store, T0, woken } from './testing.ts'
49
+ *
50
+ * let g = woken(store())
51
+ * await g.apply([{ entity: { eid: 'w' }, wake: {}, watch: { query: '.plant' } }])
52
+ * assertEquals(await stir(g, T0), T0 + 2_000)
53
+ * ```
54
+ */ export declare let stir: (graph: Pick<Graph, 'read' | 'apply'>, now: number, opts?: {
55
+ which?: (wake: Bundle) => boolean;
56
+ soon?: number;
57
+ }) => Promise<number | null>;
58
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sources":["../watch.ts"],"names":[],"mappings":"AAgBA,cAAc,MAAM,EAAE,KAAK,2BAAgC;AAI3D,SAAsB,KAAK,KAAK,oBAAmB;AAEnD,0CAA0C,GAC1C,OAAO,YAAI,aAAU;AAErB,+DAA+D,GAC/D,YAAY,OAAO,OAAO,MAAM,EAAE,MAAM;AAExC;kEACkE,GAClE,YAAY,YACV,MAAM,QACN,OAAO,UACJ,WAAW,QAAQ;AAExB,8CAA8C,GAC9C,OAAO,YAAI,UAAW,GAAG,WAAS,QAAQ,SAAS,CACL;AA0B9C;;;;;;;;;;;;;CAaC,GACD,OAAO,YAAI,OACT,KAAK,MACL,MAAM,aACL;EAAU,MAAM;EAAM,SAAS,MAAM;GA+BvC;AAED;;;;;;;;;;CAUC,GACD,OAAO,YAAI,UAAW,SAAS,MAAM,KAAG,MAAM,GAAG,SAAS,CACX;AAE/C;yBACyB,GACzB,OAAO,YAAI,aAAY;AAQvB;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,OACT,OAAO,KAAK,OAAO,SAAS,UAC5B,KAAK,MAAM,EACX;EAAQ,SAAS,MAAM,WAAW,OAAO;EAAE,OAAO,MAAM;MACvD,QAAQ,MAAM,GAAG,IAAI,EAkCvB"}
@@ -0,0 +1,43 @@
1
+ import type { Bundle, Hook } from "@yaks/graph";
2
+ import { type Wake } from "./comp.js";
3
+ import type { Driver } from "./tick.js";
4
+ type Holds = (match: string) => Promise<boolean>;
5
+ export declare let matches: (graph: Pick<Driver, 'read'>, now: number) => Holds;
6
+ /**
7
+ * The cadence a wake's conditions ask for at `now`: the `every` of the first
8
+ * `while` entry whose query finds anything, or `null` when none does.
9
+ *
10
+ * ```ts
11
+ * import { cadence } from '@yaks/wake'
12
+ *
13
+ * // await cadence(graph, { while: [{ match: '.player', every: '5m' }] }, now)
14
+ * ```
15
+ */ export declare let cadence: (graph: Pick<Driver, 'read'>, wake: Wake, now: number, holds?: Holds) => Promise<string | null>;
16
+ /** What a pass of {@link rouse} did: the wakes it armed, and the ones it
17
+ * could not, each with why. */ export type Roused = {
18
+ /** the applied wake bundles */ roused: Bundle[];
19
+ /** the wakes whose conditions could not be read or whose write was refused */ refused: {
20
+ wake: Bundle;
21
+ error: unknown;
22
+ }[];
23
+ };
24
+ /**
25
+ * Arm each wake whose conditions now hold at the first instant its cadence
26
+ * owes, when that is sooner than the instant it holds: a sleeping wake is
27
+ * woken, and one on a slow cadence is brought forward when a faster
28
+ * condition starts to hold. A wake whose `at` moved while this ran keeps the
29
+ * other writer's instant.
30
+ *
31
+ * ```ts
32
+ * import { rouse } from '@yaks/wake'
33
+ *
34
+ * // after a write commits: await rouse(graph, Date.now())
35
+ * ```
36
+ */ export declare let rouse: (graph: Driver, now?: number, catalog?: Bundle[]) => Promise<Roused>;
37
+ /**
38
+ * The `precondition` hook: each `while` a write gives is read once, so a
39
+ * condition that does not parse, or names a word this graph does not speak,
40
+ * is refused with the reader's own reason when it is written, not at every
41
+ * firing after.
42
+ */ export declare let conditions: Hook;
43
+ //# sourceMappingURL=while.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"while.d.ts","sources":["../while.ts"],"names":[],"mappings":"AAoBA,cAAc,MAAM,EAAE,IAAI,2BAAwC;AAIlE,SAAe,KAAK,IAAI,oBAAmB;AAG3C,cAAc,MAAM,oBAAmB;KAGlC,SAAS,OAAO,MAAM,KAAK,QAAQ,OAAO;AAU/C,OAAO,YAAI,UAAW,OAAO,KAAK,QAAQ,SAAS,KAAK,MAAM,KAAG,MAShE;AAED;;;;;;;;;CASC,GACD,OAAO,YAAI,UACT,OAAO,KAAK,QAAQ,SACpB,MAAM,MACN,KAAK,MAAM,EACX,QAAO,UACN,QAAQ,MAAM,GAAG,IAAI,EAKvB;AAED;6BAC6B,GAC7B,YAAY;EACV,6BAA6B,GAC7B,QAAQ;EACR,4EAA4E,GAC5E;IAAW,MAAM;IAAQ,OAAO,OAAO;;;AAGzC;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,QACT,OAAO,QACP,MAAK,MAAM,EACX,UAAU,aACT,QAAQ,QA4CV;AAiBD;;;;;CAKC,GACD,OAAO,YAAI,YAAY,KASpB"}
package/cloudflare.js ADDED
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Cloudflare decides when to run; the graph holds the schedules. A Cron Trigger
3
+ * calls `scheduled`, while a Durable Object can set its single alarm for a wake
4
+ * that falls before the next Cron Trigger. Neither imports a Cloudflare global,
5
+ * so Deno can exercise the same driver with a stand-in storage.
6
+ * @module
7
+ */ import { tick } from "./tick.js";
8
+ // The runtime gives each object a single alarm. Calls within one handler can
9
+ // race, so the read/compare/write is serialized per storage object, even after
10
+ // one of them failed. A later wake must never overwrite an earlier one that is
11
+ // in the middle of being set.
12
+ let arming = new WeakMap();
13
+ /**
14
+ * How long past its instant an alarm may still be held before it is taken as
15
+ * lost. The runtime retries a failing `alarm()` six times, with backoff, then
16
+ * gives up, and `getAlarm()` goes on answering the instant it gave up on; an
17
+ * object whose alarm kept running out of CPU held one for days, and nothing
18
+ * delivered it again.
19
+ */ export let LOST = 15 * 60_000;
20
+ /**
21
+ * The alarm the runtime will deliver: null when none is set, or when the one
22
+ * set is more than `LOST` past its instant.
23
+ *
24
+ * ```ts
25
+ * import { armed, LOST } from '@yaks/wake/cloudflare'
26
+ * import { assertEquals } from '@std/assert'
27
+ *
28
+ * let storage = (at: number | null) => ({
29
+ * getAlarm: () => Promise.resolve(at),
30
+ * setAlarm: () => Promise.resolve(),
31
+ * })
32
+ * assertEquals(await armed(storage(900), 1000), 900)
33
+ * assertEquals(await armed(storage(1000 - LOST - 1), 1000), null)
34
+ * ```
35
+ */ export let armed = async (storage, now = Date.now())=>{
36
+ let at = await storage.getAlarm();
37
+ return lost(at, now) ? null : at;
38
+ };
39
+ let lost = (at, now)=>at != null && at < now - LOST;
40
+ /**
41
+ * A Worker's scheduled handler, reduced to the graph write every runtime
42
+ * shares. The event's cron string does not select a job: the due wake rows do.
43
+ *
44
+ * ```ts
45
+ * import { scheduled } from '@yaks/wake/cloudflare'
46
+ *
47
+ * // export default { scheduled: (event) => scheduled(graph, event) }
48
+ * ```
49
+ */ export let scheduled = (graph, event)=>tick(graph, event.scheduledTime);
50
+ /**
51
+ * Set a Durable Object's alarm for one wake. An alarm that is already earlier
52
+ * is kept, because the object may hold other wakes. Returns whether this wake
53
+ * needs the alarm at all; a wake with no `at`, or a later one, leaves it alone.
54
+ * An alarm the runtime gave up on (`armed`) is set again for `now`, since the
55
+ * run it stood for is still owed.
56
+ *
57
+ * Call it when a wake is written. In the object's `alarm()`, call `tick(graph)`
58
+ * and then set the alarm for its next pending wake. `before` is for an
59
+ * application that also has a Cron Trigger: pass the time of the next trigger,
60
+ * and a wake falling after it is left for that trigger to fire rather than this
61
+ * object. An application whose alarm is its only clock leaves `before` out.
62
+ *
63
+ * ```ts
64
+ * import { arm } from '@yaks/wake/cloudflare'
65
+ *
66
+ * // await arm(ctx.storage, wake)
67
+ * ```
68
+ */ export let arm = (storage, wake, before = Infinity, now = Date.now())=>{
69
+ let pending = (arming.get(storage) ?? Promise.resolve()).then(async ()=>{
70
+ let at = wake.at ? Date.parse(wake.at) : NaN;
71
+ if (!Number.isFinite(at) || at >= before) return false;
72
+ let set = await storage.getAlarm();
73
+ if (lost(set, now)) await storage.setAlarm(Math.min(at, now));
74
+ else if (set == null || set > at) await storage.setAlarm(at);
75
+ return true;
76
+ });
77
+ arming.set(storage, pending.catch(()=>{}));
78
+ return pending;
79
+ };
80
+ //# sourceMappingURL=cloudflare.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloudflare.js","sources":["./cloudflare.ts"],"names":[],"mappings":"AAAA;;;;;;CAMC,GAGD,SAAsB,IAAI,oBAAgC;AAW1D,6EAA6E;AAC7E,+EAA+E;AAC/E,+EAA+E;AAC/E,8BAA8B;AAC9B,IAAI,SAAS,IAAI;AAEjB;;;;;;CAMC,GACD,OAAO,IAAI,OAAe,KAAK,OAAM;AAErC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,IAAI,QAAQ,OACjB,SACA,MAAc,KAAK,GAAG,EAAE;EAExB,IAAI,KAAK,MAAM,QAAQ,QAAQ;EAC/B,OAAO,KAAK,IAAI,OAAO,OAAO;AAChC,EAAC;AAED,IAAI,OAAO,CAAC,IAAmB,MAC7B,MAAM,QAAQ,KAAK,MAAM;AAE3B;;;;;;;;;CASC,GACD,OAAO,IAAI,YAAY,CACrB,OACA,QACoB,KAAK,OAAO,MAAM,aAAa,EAAC;AAEtD;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,IAAI,MAAM,CACf,SACA,MACA,SAAS,QAAQ,EACjB,MAAc,KAAK,GAAG,EAAE;EAExB,IAAI,UAAU,CAAC,OAAO,GAAG,CAAC,YAAY,QAAQ,OAAO,EAAE,EAAE,IAAI,CAAC;IAC5D,IAAI,KAAK,KAAK,EAAE,GAAG,KAAK,KAAK,CAAC,KAAK,EAAE,IAAI;IACzC,IAAI,CAAC,OAAO,QAAQ,CAAC,OAAO,MAAM,QAAQ,OAAO;IACjD,IAAI,MAAM,MAAM,QAAQ,QAAQ;IAChC,IAAI,KAAK,KAAK,MAAM,MAAM,QAAQ,QAAQ,CAAC,KAAK,GAAG,CAAC,IAAI;SACnD,IAAI,OAAO,QAAQ,MAAM,IAAI,MAAM,QAAQ,QAAQ,CAAC;IACzD,OAAO;EACT;EACA,OAAO,GAAG,CAAC,SAAS,QAAQ,KAAK,CAAC,KAAO;EACzC,OAAO;AACT,EAAC"}