@maelstrom-co/react 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +75 -2
- package/dist/_testing.d.ts +13 -0
- package/dist/_testing.d.ts.map +1 -0
- package/dist/_testing.js +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6181 -0
- package/dist/lib/build-execute-action.d.ts +9 -0
- package/dist/lib/build-execute-action.d.ts.map +1 -0
- package/dist/lib/chart/chart.d.ts +14 -0
- package/dist/lib/chart/chart.d.ts.map +1 -0
- package/dist/lib/chart/error-boundary.d.ts +17 -0
- package/dist/lib/chart/error-boundary.d.ts.map +1 -0
- package/dist/lib/chart/loading.d.ts +14 -0
- package/dist/lib/chart/loading.d.ts.map +1 -0
- package/dist/lib/chart/motion/flip.d.ts +18 -0
- package/dist/lib/chart/motion/flip.d.ts.map +1 -0
- package/dist/lib/chart/motion/measure.d.ts +8 -0
- package/dist/lib/chart/motion/measure.d.ts.map +1 -0
- package/dist/lib/chart/motion/motion-config.d.ts +27 -0
- package/dist/lib/chart/motion/motion-config.d.ts.map +1 -0
- package/dist/lib/chart/motion/use-chart-motion.d.ts +7 -0
- package/dist/lib/chart/motion/use-chart-motion.d.ts.map +1 -0
- package/dist/lib/chart/motion/use-exiting-instances.d.ts +9 -0
- package/dist/lib/chart/motion/use-exiting-instances.d.ts.map +1 -0
- package/dist/lib/config-types.d.ts +29 -0
- package/dist/lib/config-types.d.ts.map +1 -0
- package/dist/lib/context.d.ts +42 -0
- package/dist/lib/context.d.ts.map +1 -0
- package/dist/lib/create-maelstrom.d.ts +39 -0
- package/dist/lib/create-maelstrom.d.ts.map +1 -0
- package/dist/lib/dynamic-vessel-types.d.ts +57 -0
- package/dist/lib/dynamic-vessel-types.d.ts.map +1 -0
- package/dist/lib/extension-types.d.ts +58 -0
- package/dist/lib/extension-types.d.ts.map +1 -0
- package/dist/lib/maelstrom-instance-types.d.ts +228 -0
- package/dist/lib/maelstrom-instance-types.d.ts.map +1 -0
- package/dist/lib/maelstrom-state-types.d.ts +30 -0
- package/dist/lib/maelstrom-state-types.d.ts.map +1 -0
- package/dist/lib/provider.d.ts +135 -0
- package/dist/lib/provider.d.ts.map +1 -0
- package/dist/lib/register-vessel.d.ts +13 -0
- package/dist/lib/register-vessel.d.ts.map +1 -0
- package/dist/lib/require-context.d.ts +9 -0
- package/dist/lib/require-context.d.ts.map +1 -0
- package/dist/lib/update-vessel.d.ts +21 -0
- package/dist/lib/update-vessel.d.ts.map +1 -0
- package/dist/lib/use-actions.d.ts +19 -0
- package/dist/lib/use-actions.d.ts.map +1 -0
- package/dist/lib/use-instance.d.ts +11 -0
- package/dist/lib/use-instance.d.ts.map +1 -0
- package/dist/lib/use-intent-submission.d.ts +8 -0
- package/dist/lib/use-intent-submission.d.ts.map +1 -0
- package/dist/lib/use-latest-ref.d.ts +4 -0
- package/dist/lib/use-latest-ref.d.ts.map +1 -0
- package/dist/lib/use-maelstrom.d.ts +7 -0
- package/dist/lib/use-maelstrom.d.ts.map +1 -0
- package/dist/lib/use-store-selector.d.ts +17 -0
- package/dist/lib/use-store-selector.d.ts.map +1 -0
- package/dist/lib/use-vessel-core.d.ts +18 -0
- package/dist/lib/use-vessel-core.d.ts.map +1 -0
- package/dist/lib/use-vessel.d.ts +7 -0
- package/dist/lib/use-vessel.d.ts.map +1 -0
- package/dist/lib/vessel-entry-types.d.ts +170 -0
- package/dist/lib/vessel-entry-types.d.ts.map +1 -0
- package/dist/lib/vessel.d.ts +10 -0
- package/dist/lib/vessel.d.ts.map +1 -0
- package/dist/lib/warn-once.d.ts +23 -0
- package/dist/lib/warn-once.d.ts.map +1 -0
- package/dist/warn-once-Cq9ShMdA.js +10 -0
- package/package.json +83 -4
- package/skills/maelstrom-react-sdk/SKILL.md +29 -0
- package/skills/maelstrom-react-sdk/references/common-tasks.md +146 -0
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
import { VesselDefinition } from '@maelstrom-co/protocol';
|
|
2
|
+
import { ComponentType } from 'react';
|
|
3
|
+
import { ChartProps } from './chart/chart.js';
|
|
4
|
+
import { DynamicVesselHandle, UntypedVesselProps } from './dynamic-vessel-types.js';
|
|
5
|
+
import { ExtensionOutput, MaelstromExtension } from './extension-types.js';
|
|
6
|
+
import { MaelstromState } from './maelstrom-state-types.js';
|
|
7
|
+
import { MaelstromProviderProps } from './provider.js';
|
|
8
|
+
import { ActionRunnerLookup, AnyVesselEntry, ExtractVesselByIdFromEntries, TypedVesselProps, UpdateVesselPayload, UpdateVesselResult, VesselIds } from './vessel-entry-types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Reserved keys on the core instance shape. Extensions are forbidden from
|
|
11
|
+
* defining keys with these names so `.with()` cannot silently overwrite
|
|
12
|
+
* `Provider`, `Chart`, the hook surface, etc.
|
|
13
|
+
*/
|
|
14
|
+
export type ReservedInstanceKeys = 'vessels' | 'Provider' | 'Chart' | 'useMaelstrom' | 'useVessel' | 'useActions' | 'useInstance' | 'registerVessel' | 'updateVessel' | 'with';
|
|
15
|
+
/**
|
|
16
|
+
* Branded compile-time guard: when an extension's return type contains any
|
|
17
|
+
* `ReservedInstanceKeys`, the `with()` argument type narrows to this error
|
|
18
|
+
* literal so the call no longer accepts the offending extension function.
|
|
19
|
+
*/
|
|
20
|
+
type ExtensionRejectsReserved<NewExt extends ExtensionOutput> = Extract<keyof NewExt, ReservedInstanceKeys> extends never ? MaelstromExtension<NewExt> : `Error: extension cannot define reserved Maelstrom key '${Extract<keyof NewExt & ReservedInstanceKeys, string>}'`;
|
|
21
|
+
/**
|
|
22
|
+
* Core Maelstrom instance fields. Generic over `Ext` so the recursive
|
|
23
|
+
* `with()` return type can carry accumulated extensions; the public type
|
|
24
|
+
* is `MaelstromInstance<T, Ext> = MaelstromInstanceCore<T, Ext> & Ext`,
|
|
25
|
+
* so extension fields are structurally part of the instance — no
|
|
26
|
+
* intersection casts needed at the merge site.
|
|
27
|
+
*/
|
|
28
|
+
export interface MaelstromInstanceCore<T extends readonly AnyVesselEntry[], Ext extends ExtensionOutput = object> {
|
|
29
|
+
vessels: T;
|
|
30
|
+
Provider: ComponentType<MaelstromProviderProps>;
|
|
31
|
+
Chart: ComponentType<ChartProps>;
|
|
32
|
+
/**
|
|
33
|
+
* Returns reactive Maelstrom state. Call with no args for the full state,
|
|
34
|
+
* or pass a selector to subscribe to a slice and avoid re-renders when
|
|
35
|
+
* unrelated fields change. Derived objects are shallow-compared.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* const { processIntent, isProcessing } = m.useMaelstrom();
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* const isProcessing = m.useMaelstrom((s) => s.isProcessing);
|
|
42
|
+
*/
|
|
43
|
+
useMaelstrom: {
|
|
44
|
+
<TSelected>(selector: (state: MaelstromState) => TSelected): TSelected;
|
|
45
|
+
(): MaelstromState;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Returns typed vessel props for the given vessel ID and instance ID.
|
|
49
|
+
* Returns null when the instance doesn't exist or belongs to a different vessel type.
|
|
50
|
+
*
|
|
51
|
+
* variantProps is a discriminated union narrowable via `variantProps.variant`.
|
|
52
|
+
* executeAction triggers an optimistic local variant transition (if transitionsTo is set),
|
|
53
|
+
* then dispatches to registered action runners via CommandProcessor.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const props = m.useVessel('calendar', instanceId);
|
|
57
|
+
* if (!props) return null;
|
|
58
|
+
* // props.variantProps.variant === 'month' | 'week'
|
|
59
|
+
*/
|
|
60
|
+
useVessel: <Id extends VesselIds<T>>(vesselId: Id, instanceId: string) => TypedVesselProps<ExtractVesselByIdFromEntries<T, Id>> | null;
|
|
61
|
+
/**
|
|
62
|
+
* Registers side-effect handlers for actions dispatched to an instance (both engine-initiated and user-initiated via executeAction).
|
|
63
|
+
* Automatically unregisters on component unmount.
|
|
64
|
+
*
|
|
65
|
+
* Pass a stable runner reference (defined outside the component or wrapped in useMemo)
|
|
66
|
+
* to prevent unnecessary re-registrations on each render.
|
|
67
|
+
*
|
|
68
|
+
* @example
|
|
69
|
+
* m.useActions('calendar', instanceId, {
|
|
70
|
+
* showWeek: () => ok(undefined),
|
|
71
|
+
* });
|
|
72
|
+
*/
|
|
73
|
+
useActions: <Id extends VesselIds<T>>(vesselId: Id, instanceId: string, runner: ActionRunnerLookup<T>[Id]) => void;
|
|
74
|
+
/**
|
|
75
|
+
* Untyped escape hatch — returns props for any instance regardless of vessel type.
|
|
76
|
+
* Works for both statically and dynamically registered vessels.
|
|
77
|
+
* variantProps is `Record<string, unknown>` and action names are `string`.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const props = m.useInstance(instanceId);
|
|
81
|
+
* if (!props) return null;
|
|
82
|
+
* // props.vesselId tells you which vessel this is
|
|
83
|
+
*/
|
|
84
|
+
useInstance: (instanceId: string) => UntypedVesselProps | null;
|
|
85
|
+
/**
|
|
86
|
+
* Dynamically register a vessel at runtime. Returns a typed handle with
|
|
87
|
+
* scoped `useVessel`, `useActions`, `update()`, and `unregister()`.
|
|
88
|
+
* Throws if the vessel fails validation.
|
|
89
|
+
*
|
|
90
|
+
* Must be called while a Provider is mounted. The vessel becomes available
|
|
91
|
+
* for subsequent engine decisions (processIntent calls).
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const handle = m.registerVessel(widgetEntry);
|
|
95
|
+
* // In component:
|
|
96
|
+
* const props = handle.useVessel(instanceId);
|
|
97
|
+
* // Cleanup:
|
|
98
|
+
* handle.unregister();
|
|
99
|
+
*/
|
|
100
|
+
registerVessel: <V extends VesselDefinition>(entry: AnyVesselEntry<V>) => DynamicVesselHandle<V>;
|
|
101
|
+
/**
|
|
102
|
+
* Republish a registered vessel's definition — its description, variants,
|
|
103
|
+
* and action parameters — without touching its component registration.
|
|
104
|
+
*
|
|
105
|
+
* Use this to keep the LLM-facing contract in sync with live data, e.g.
|
|
106
|
+
* re-declaring an action parameter's `enum` as the underlying list changes.
|
|
107
|
+
* Unlike `registerVessel`, this never re-wraps the component, so the vessel
|
|
108
|
+
* does not remount and keeps any DOM/canvas state it owns.
|
|
109
|
+
*
|
|
110
|
+
* `updateVessel` replaces the definition wholesale — it does not merge —
|
|
111
|
+
* so a rebuild that keeps only the variant or action being edited silently
|
|
112
|
+
* drops every other one, and reports a conflict if any live instance's
|
|
113
|
+
* current variant is missing from the rebuild. Map over every variant and
|
|
114
|
+
* every action instead, as below, so nothing but the targeted parameter
|
|
115
|
+
* changes.
|
|
116
|
+
*
|
|
117
|
+
* For a vessel id declared in `createMaelstrom({ vessels })`, every
|
|
118
|
+
* variant's `props` must match the shape of some variant on that
|
|
119
|
+
* vessel's factory-declared entry — the entry passed to
|
|
120
|
+
* `createMaelstrom({ vessels })`, fixed at compile time — which is what
|
|
121
|
+
* stops a rebuild from silently handing a mounted component a
|
|
122
|
+
* `variantProps` object missing a field it destructures. That check is
|
|
123
|
+
* per-vessel, not per-variant-key: it does not catch swapping two
|
|
124
|
+
* variants' `props` shapes with each other. `actions`, `enum` values,
|
|
125
|
+
* `description`, and `minSize` are not checked and stay free to change;
|
|
126
|
+
* that is exactly the workflow the example below relies on.
|
|
127
|
+
*
|
|
128
|
+
* For a vessel id registered only at runtime via `registerVessel()`, `Id`
|
|
129
|
+
* is outside `VesselIds<T>` and this function cannot name it — call
|
|
130
|
+
* `update()` on the handle `registerVessel()` returns instead. That
|
|
131
|
+
* handle is typed to its own inferred vessel definition, so it gets the
|
|
132
|
+
* same `props`-shape check as above, just checked against the handle's
|
|
133
|
+
* `V` rather than a factory-declared entry.
|
|
134
|
+
*
|
|
135
|
+
* The republish is lazy: it updates the local store immediately, but
|
|
136
|
+
* nothing schedules a fresh engine request on its own. The engine keeps
|
|
137
|
+
* working from the previous definition until some other event sends a
|
|
138
|
+
* request — an intent, an action, a resize. If the change raises a
|
|
139
|
+
* variant's `minSize`, live tiles on that variant also keep their old
|
|
140
|
+
* rect until then.
|
|
141
|
+
*
|
|
142
|
+
* @returns `{ ok: true }` once the definition is committed. `{ ok: false,
|
|
143
|
+
* conflict }` when the republish was refused for a recoverable,
|
|
144
|
+
* user-triggerable reason — not a bug — and the previous definition
|
|
145
|
+
* stays in force: `conflict.code === 'variant_dropped'` means a live
|
|
146
|
+
* instance's current variant is absent from the new definition;
|
|
147
|
+
* `'action_dropped'` means the new definition drops an action the
|
|
148
|
+
* current definition declares on that instance's variant (for example a
|
|
149
|
+
* `detail` variant that only exists while its record does, and the user
|
|
150
|
+
* just deleted that record); `'batch_in_flight'` means a command batch
|
|
151
|
+
* was already queued or executing, so the instance snapshot this check
|
|
152
|
+
* would scan cannot be trusted yet — retry once it settles. The
|
|
153
|
+
* variant/action scan covers every instance in the command-processor
|
|
154
|
+
* store, including instances not currently rendered as a tile. Branch on
|
|
155
|
+
* `conflict.code`, not on `conflict.message` text, which this package is
|
|
156
|
+
* free to reword.
|
|
157
|
+
*
|
|
158
|
+
* @throws `Error` if no Provider is mounted, if the vessel id is not
|
|
159
|
+
* already registered, or if the definition fails validation — those are
|
|
160
|
+
* caller mistakes, not recoverable states.
|
|
161
|
+
*
|
|
162
|
+
* @example
|
|
163
|
+
* const titles = ['Sprint kickoff', 'Architecture review'];
|
|
164
|
+
* const result = m.updateVessel({
|
|
165
|
+
* ...journalVessel,
|
|
166
|
+
* variants: Object.fromEntries(
|
|
167
|
+
* Object.entries(journalVessel.variants).map(([variantName, variant]) => [
|
|
168
|
+
* variantName,
|
|
169
|
+
* {
|
|
170
|
+
* ...variant,
|
|
171
|
+
* actions: variant.actions.map((action) =>
|
|
172
|
+
* action.name === 'openEntry' && action.parameters
|
|
173
|
+
* ? {
|
|
174
|
+
* ...action,
|
|
175
|
+
* parameters: action.parameters.map((parameter) =>
|
|
176
|
+
* parameter.name === 'title'
|
|
177
|
+
* ? { ...parameter, enum: titles }
|
|
178
|
+
* : parameter,
|
|
179
|
+
* ),
|
|
180
|
+
* }
|
|
181
|
+
* : action,
|
|
182
|
+
* ),
|
|
183
|
+
* },
|
|
184
|
+
* ]),
|
|
185
|
+
* ),
|
|
186
|
+
* });
|
|
187
|
+
* if (!result.ok) {
|
|
188
|
+
* switch (result.conflict.code) {
|
|
189
|
+
* case 'variant_dropped':
|
|
190
|
+
* case 'action_dropped':
|
|
191
|
+
* // A live instance would be stranded by this republish — skip it,
|
|
192
|
+
* // or surface a message and retry once the record exists again.
|
|
193
|
+
* break;
|
|
194
|
+
* case 'batch_in_flight':
|
|
195
|
+
* // A batch was already in flight — retry on the next render.
|
|
196
|
+
* break;
|
|
197
|
+
* }
|
|
198
|
+
* }
|
|
199
|
+
*/
|
|
200
|
+
updateVessel: <Id extends VesselIds<T>>(vessel: UpdateVesselPayload<T, Id>) => UpdateVesselResult;
|
|
201
|
+
/**
|
|
202
|
+
* Apply an extension to the instance, returning a new instance with the
|
|
203
|
+
* extension's fields merged onto the public surface.
|
|
204
|
+
*
|
|
205
|
+
* The returned instance is fresh — calling `.with()` does not mutate the
|
|
206
|
+
* receiver, so branched chains like
|
|
207
|
+
* `const a = m.with(extA); const b = m.with(extB);` produce independent
|
|
208
|
+
* instances that do not share each other's extension fields.
|
|
209
|
+
*
|
|
210
|
+
* Reserved keys (`vessels`, `Provider`, `Chart`, the hook surface,
|
|
211
|
+
* `with`) are rejected at compile time. When two extensions in the same
|
|
212
|
+
* chain define the same custom key, the later wins at runtime and a
|
|
213
|
+
* one-shot `console.warn` flags the collision.
|
|
214
|
+
*
|
|
215
|
+
* @example
|
|
216
|
+
* const analytics: MaelstromExtension<{ track: (event: string) => void }> = () => ({
|
|
217
|
+
* track: (event) => console.log('[analytics]', event),
|
|
218
|
+
* });
|
|
219
|
+
*
|
|
220
|
+
* const m = createMaelstrom({ vessels }).with(analytics);
|
|
221
|
+
* m.track('app:start');
|
|
222
|
+
*/
|
|
223
|
+
with<NewExt extends ExtensionOutput>(ext: ExtensionRejectsReserved<NewExt>): MaelstromInstance<T, Ext & NewExt>;
|
|
224
|
+
}
|
|
225
|
+
/** Return type of createMaelstrom() — core fields plus any applied extensions. */
|
|
226
|
+
export type MaelstromInstance<T extends readonly AnyVesselEntry[], Ext extends ExtensionOutput = object> = MaelstromInstanceCore<T, Ext> & Ext;
|
|
227
|
+
export {};
|
|
228
|
+
//# sourceMappingURL=maelstrom-instance-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maelstrom-instance-types.d.ts","sourceRoot":"","sources":["../../src/lib/maelstrom-instance-types.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ConnectionStatus, EnqueueIntentOptions, IntentSchedulerState, IntentSubmission } from '@maelstrom-co/client';
|
|
2
|
+
import { MaelstromResponse, SessionId } from '@maelstrom-co/protocol';
|
|
3
|
+
/** Return type of m.useMaelstrom() */
|
|
4
|
+
export interface MaelstromState {
|
|
5
|
+
/** Send a user intent to the engine. Never rejects — errors surface via lastError. */
|
|
6
|
+
processIntent: (intent: string) => Promise<void>;
|
|
7
|
+
/**
|
|
8
|
+
* Admit immediately to the client-owned FIFO, including while busy. Operational
|
|
9
|
+
* outcomes resolve on the ticket; they do not update lastError/lastResponse.
|
|
10
|
+
* Observe it with useIntentSubmission. No retry is performed for unknown work.
|
|
11
|
+
* A foreign options.scope throws synchronously. Unmounting this hook does not
|
|
12
|
+
* cancel accepted work; use a client IntentScope for owner-lifetime retirement.
|
|
13
|
+
*/
|
|
14
|
+
enqueueIntent: (intent: string, options?: EnqueueIntentOptions) => IntentSubmission;
|
|
15
|
+
/** Shared admission state, including queued voice work and atomic application. */
|
|
16
|
+
intentScheduler: IntentSchedulerState;
|
|
17
|
+
/** Current connection status */
|
|
18
|
+
connectionStatus: ConnectionStatus;
|
|
19
|
+
/** Last connection error, if connectionStatus is 'error' */
|
|
20
|
+
connectionError: Error | null;
|
|
21
|
+
/** Whether a request is currently in flight */
|
|
22
|
+
isProcessing: boolean;
|
|
23
|
+
/** Last error from processIntent — auto-clears on next call */
|
|
24
|
+
lastError: Error | null;
|
|
25
|
+
/** Last successful engine response — clears when the next call starts */
|
|
26
|
+
lastResponse: MaelstromResponse | null;
|
|
27
|
+
/** Current session ID */
|
|
28
|
+
sessionId: SessionId;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=maelstrom-state-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maelstrom-state-types.d.ts","sourceRoot":"","sources":["../../src/lib/maelstrom-state-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,EACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAE3E,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,sFAAsF;IACtF,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjD;;;;;;OAMG;IACH,aAAa,EAAE,CACb,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,oBAAoB,KAC3B,gBAAgB,CAAC;IACtB,kFAAkF;IAClF,eAAe,EAAE,oBAAoB,CAAC;IACtC,gCAAgC;IAChC,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,4DAA4D;IAC5D,eAAe,EAAE,KAAK,GAAG,IAAI,CAAC;IAC9B,+CAA+C;IAC/C,YAAY,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,SAAS,EAAE,KAAK,GAAG,IAAI,CAAC;IACxB,yEAAyE;IACzE,YAAY,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACvC,yBAAyB;IACzB,SAAS,EAAE,SAAS,CAAC;CACtB"}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { EngineConnector, IntentQueueOptions } from '@maelstrom-co/client';
|
|
2
|
+
import { TilingLayout } from '@maelstrom-co/protocol';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { ChartMotionConfig } from './chart/motion/motion-config.js';
|
|
5
|
+
import { ConfigOverrides } from './config-types.js';
|
|
6
|
+
import { MaelstromContextPair } from './context.js';
|
|
7
|
+
import { AnyVesselEntry } from './vessel-entry-types.js';
|
|
8
|
+
/**
|
|
9
|
+
* Props for the Maelstrom Provider component.
|
|
10
|
+
*
|
|
11
|
+
* Split by `layoutMode` so the one combination the Orchestrator can only
|
|
12
|
+
* reject at runtime — a first-screen seed under `layoutMode: 'grid'` — is
|
|
13
|
+
* unrepresentable in TypeScript rather than a guaranteed construction
|
|
14
|
+
* failure that typechecks.
|
|
15
|
+
*/
|
|
16
|
+
export type MaelstromProviderProps = TilingProviderProps | GridProviderProps;
|
|
17
|
+
/** Props shared by both `layoutMode` branches. */
|
|
18
|
+
interface MaelstromProviderBaseProps {
|
|
19
|
+
/**
|
|
20
|
+
* Engine connector. Changing the identity of this prop swaps the
|
|
21
|
+
* transport on the live Orchestrator (`Orchestrator.setConnector`) rather
|
|
22
|
+
* than rebuilding it — the arranged board, vessel registry, and chart
|
|
23
|
+
* dimensions all survive. Use this for re-auth; it does not start a new
|
|
24
|
+
* session.
|
|
25
|
+
*/
|
|
26
|
+
connector: EngineConnector;
|
|
27
|
+
/**
|
|
28
|
+
* Session ID for conversation continuity. Auto-generated if omitted.
|
|
29
|
+
* Captured once on mount — changing it afterwards is ignored (a console
|
|
30
|
+
* warning says so). To switch sessions, remount the Provider with a new
|
|
31
|
+
* `key`.
|
|
32
|
+
*/
|
|
33
|
+
sessionId?: string;
|
|
34
|
+
/** Grid cell size in pixels. Overrides the factory default. */
|
|
35
|
+
cellSizePx?: number;
|
|
36
|
+
/** Tiling layout gap in pixels. Overrides the factory default. */
|
|
37
|
+
tilingPaddingPx?: number;
|
|
38
|
+
/** Enable debug logging. Overrides the factory default. */
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Chart motion/choreography settings. Overrides the factory default as a
|
|
42
|
+
* whole object — when provided, the factory's `motion` is ignored entirely
|
|
43
|
+
* rather than merged per-field. Pass a stable reference (hoist or memoize
|
|
44
|
+
* it): a new object identity on every render re-resolves the config and
|
|
45
|
+
* re-renders all Maelstrom consumers.
|
|
46
|
+
*/
|
|
47
|
+
motion?: ChartMotionConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Mount-time shared FIFO policy, replacing the factory object. Defaults:
|
|
50
|
+
* 8 pending, 30s wait, 10s disconnected grace, 60s active result deadline.
|
|
51
|
+
* Invalid limits fail construction. Later changes are ignored; remount with
|
|
52
|
+
* a new key to change policy. Deadlines do not cancel active work.
|
|
53
|
+
*/
|
|
54
|
+
intentQueue?: IntentQueueOptions;
|
|
55
|
+
/**
|
|
56
|
+
* Called on Orchestrator startup failures, connection failures,
|
|
57
|
+
* processIntent failures, executeAction failures, and command-processing
|
|
58
|
+
* failures — both of `CommandProcessor`'s failure events route here:
|
|
59
|
+
* `processing_error` (a command threw, a refused `set_layout` being the
|
|
60
|
+
* common case) and `batch_abandoned` (the trailing commands of that
|
|
61
|
+
* command's atomic batch never ran), the latter wrapped in an error naming
|
|
62
|
+
* the abandoned command kinds. One failing command inside a batch therefore
|
|
63
|
+
* calls this twice, once per half of the damage. Errors from `processIntent`
|
|
64
|
+
* also surface via `useMaelstrom()`; a refused command does not, because it
|
|
65
|
+
* has no call to attach to.
|
|
66
|
+
*/
|
|
67
|
+
onError?: (error: Error) => void;
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
}
|
|
70
|
+
/** Provider props under the default tiling mode, the only seedable one. */
|
|
71
|
+
interface TilingProviderProps extends MaelstromProviderBaseProps {
|
|
72
|
+
/**
|
|
73
|
+
* Layout algorithm used by the engine. Changing this pushes the new mode
|
|
74
|
+
* into the live Orchestrator (`Orchestrator.setLayoutMode`) rather than
|
|
75
|
+
* rebuilding it. Omitting it after having set it falls back to the
|
|
76
|
+
* Orchestrator's own default rather than freezing on the last mode.
|
|
77
|
+
*/
|
|
78
|
+
layoutMode?: 'tiling';
|
|
79
|
+
/**
|
|
80
|
+
* Layout applied once when the Provider mounts, before any engine
|
|
81
|
+
* round-trip — a *proposed* first screen. The engine sees it in the next
|
|
82
|
+
* chart request and may reshape or drop tiles to fit the real viewport.
|
|
83
|
+
*
|
|
84
|
+
* Requires `layoutMode: 'tiling'` (the default): a grid layout can only
|
|
85
|
+
* reposition instances that already exist (none do at construction), and a
|
|
86
|
+
* tiling layout mismatches `layoutMode: 'grid'` outright. There is no way
|
|
87
|
+
* to seed a first screen in grid mode, which is why the two are split
|
|
88
|
+
* across the prop union; the Orchestrator still throws on the combination
|
|
89
|
+
* for untyped callers that route around the types.
|
|
90
|
+
*
|
|
91
|
+
* Every instance the seed names must resolve against the *static* vessel
|
|
92
|
+
* list passed to `createMaelstrom`: a `vesselId` that list registers, and
|
|
93
|
+
* a variant that vessel declares. Vessels registered later through
|
|
94
|
+
* `m.registerVessel()` or `useVessel` are not eligible — they register
|
|
95
|
+
* after the Orchestrator has already been built and validated, so a seed
|
|
96
|
+
* naming one can never resolve. The seed must also carry no duplicate
|
|
97
|
+
* `instanceId`, and every leaf of `tree` must appear in `instances`.
|
|
98
|
+
*
|
|
99
|
+
* The tree is held to the strict spelling of the grammar: no instance may
|
|
100
|
+
* appear in two leaves (weight the split token instead of repeating it),
|
|
101
|
+
* and every weight suffix must be well formed. A suffix an engine response
|
|
102
|
+
* would have repaired — `"V:1,5000"`, `"V:01,1"` — is rejected here rather
|
|
103
|
+
* than silently rewritten, so an author is never handed geometry they did
|
|
104
|
+
* not write.
|
|
105
|
+
*
|
|
106
|
+
* Validated during construction, and a validation failure is fatal to the
|
|
107
|
+
* Provider: the error goes to `onError` and `console.error`, but the
|
|
108
|
+
* Orchestrator is never created and everything under `<MaelstromProvider>`
|
|
109
|
+
* renders nothing. A seed naming an unregistered vessel id, an undeclared
|
|
110
|
+
* variant, or any seed under `layoutMode: 'grid'` white-screens the app —
|
|
111
|
+
* it does not silently fall back to an unseeded boot. Treat `initialLayout`
|
|
112
|
+
* as configuration to verify at build time, not as a best-effort hint.
|
|
113
|
+
*
|
|
114
|
+
* Captured once: changing this prop after mount is ignored (a console
|
|
115
|
+
* warning says so); remount with a new `key` to seed a different screen.
|
|
116
|
+
*/
|
|
117
|
+
initialLayout?: TilingLayout;
|
|
118
|
+
}
|
|
119
|
+
/** Provider props under grid mode, where no first screen can be seeded. */
|
|
120
|
+
interface GridProviderProps extends MaelstromProviderBaseProps {
|
|
121
|
+
/**
|
|
122
|
+
* Layout algorithm used by the engine — see the tiling branch for how a
|
|
123
|
+
* change is pushed into the live Orchestrator. Selecting `'grid'` forbids
|
|
124
|
+
* `initialLayout`.
|
|
125
|
+
*/
|
|
126
|
+
layoutMode: 'grid';
|
|
127
|
+
/**
|
|
128
|
+
* Unavailable under `layoutMode: 'grid'` — see the tiling branch's
|
|
129
|
+
* `initialLayout` for why a grid board cannot be seeded.
|
|
130
|
+
*/
|
|
131
|
+
initialLayout?: never;
|
|
132
|
+
}
|
|
133
|
+
export declare function createProvider(contextPair: MaelstromContextPair, vesselEntries: readonly AnyVesselEntry[], factoryConfig: ConfigOverrides): ({ connector, sessionId, layoutMode, cellSizePx, tilingPaddingPx, debug, motion, intentQueue, onError, initialLayout, children, }: MaelstromProviderProps) => import("react").JSX.Element | null;
|
|
134
|
+
export {};
|
|
135
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/lib/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,kBAAkB,EAEnB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,YAAY,EAAY,MAAM,wBAAwB,CAAC;AAErE,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,OAAO,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEzD,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EACV,cAAc,EAGf,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;GAOG;AACH,MAAM,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,iBAAiB,CAAC;AAE7E,kDAAkD;AAClD,UAAU,0BAA0B;IAClC;;;;;;OAMG;IACH,SAAS,EAAE,eAAe,CAAC;IAC3B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+DAA+D;IAC/D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kEAAkE;IAClE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,2DAA2D;IAC3D,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,iBAAiB,CAAC;IAC3B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;;;;;;;;;OAWG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,2EAA2E;AAC3E,UAAU,mBAAoB,SAAQ,0BAA0B;IAC9D;;;;;OAKG;IACH,UAAU,CAAC,EAAE,QAAQ,CAAC;IACtB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAqCG;IACH,aAAa,CAAC,EAAE,YAAY,CAAC;CAC9B;AAED,2EAA2E;AAC3E,UAAU,iBAAkB,SAAQ,0BAA0B;IAC5D;;;;OAIG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,KAAK,CAAC;CACvB;AAED,wBAAgB,cAAc,CAC5B,WAAW,EAAE,oBAAoB,EACjC,aAAa,EAAE,SAAS,cAAc,EAAE,EACxC,aAAa,EAAE,eAAe,IAII,kIAY/B,sBAAsB,wCA0Q1B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { VesselDefinition } from '@maelstrom-co/protocol';
|
|
2
|
+
import { MaelstromContextPair } from './context.js';
|
|
3
|
+
import { DynamicVesselHandle } from './dynamic-vessel-types.js';
|
|
4
|
+
import { AnyVesselEntry } from './vessel-entry-types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Factory that creates m.registerVessel() bound to a specific Maelstrom context.
|
|
7
|
+
*
|
|
8
|
+
* registerVessel is a plain function (not a hook). It reads the current context from a mutable ref
|
|
9
|
+
* that the Provider keeps in sync. On success it registers the vessel with the orchestrator
|
|
10
|
+
* and adds the component to the UI registries. Throws if the vessel fails validation.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createRegisterVessel(contextPair: MaelstromContextPair): <V extends VesselDefinition>(entry: AnyVesselEntry<V>) => DynamicVesselHandle<V>;
|
|
13
|
+
//# sourceMappingURL=register-vessel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-vessel.d.ts","sourceRoot":"","sources":["../../src/lib/register-vessel.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAY,MAAM,wBAAwB,CAAC;AAIzE,OAAO,KAAK,EAAE,oBAAoB,EAAyB,MAAM,cAAc,CAAC;AAChF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAIrE,OAAO,KAAK,EACV,cAAc,EAIf,MAAM,yBAAyB,CAAC;AAIjC;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,WAAW,EAAE,oBAAoB,IAIrC,CAAC,SAAS,gBAAgB,EACvD,OAAO,cAAc,CAAC,CAAC,CAAC,KACvB,mBAAmB,CAAC,CAAC,CAAC,CAuF1B"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MaelstromContextPair, MaelstromContextValue } from './context.js';
|
|
2
|
+
type RequireContextCaller = 'registerVessel' | 'unregister' | 'updateVessel' | 'handle.update';
|
|
3
|
+
/**
|
|
4
|
+
* Reads the Provider-synced context ref for the non-hook APIs — these call
|
|
5
|
+
* sites are plain functions, not hooks, and cannot use `useContext`.
|
|
6
|
+
*/
|
|
7
|
+
export declare function requireContext(contextRef: MaelstromContextPair['contextRef'], caller: RequireContextCaller): MaelstromContextValue;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=require-context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"require-context.d.ts","sourceRoot":"","sources":["../../src/lib/require-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEhF,KAAK,oBAAoB,GACrB,gBAAgB,GAChB,YAAY,GACZ,cAAc,GACd,eAAe,CAAC;AAEpB;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,UAAU,EAAE,oBAAoB,CAAC,YAAY,CAAC,EAC9C,MAAM,EAAE,oBAAoB,GAC3B,qBAAqB,CAQvB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { VesselDefinition } from '@maelstrom-co/protocol';
|
|
2
|
+
import { MaelstromContextPair, MaelstromContextValue } from './context.js';
|
|
3
|
+
import { AnyVesselEntry, UpdateVesselPayload, UpdateVesselResult, VesselIds } from './vessel-entry-types.js';
|
|
4
|
+
/** Identifies which public API triggered a republish, for error messages. */
|
|
5
|
+
type RepublishCaller = 'updateVessel' | 'handle.update';
|
|
6
|
+
/**
|
|
7
|
+
* Runtime guards + republish shared by `m.updateVessel()` and
|
|
8
|
+
* `handle.update()` — the two call sites differ only in how `Id`/`V` gets
|
|
9
|
+
* checked at compile time before this ever runs, so the resolved-context
|
|
10
|
+
* caller passes in an already-`requireContext`'d `ctx`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function republishVesselDefinition(ctx: MaelstromContextValue, vessel: VesselDefinition, caller: RepublishCaller): UpdateVesselResult;
|
|
13
|
+
/**
|
|
14
|
+
* Factory that creates m.updateVessel() bound to a specific Maelstrom context.
|
|
15
|
+
*
|
|
16
|
+
* Component registries are deliberately untouched — that is what keeps
|
|
17
|
+
* stateful components alive across a republish.
|
|
18
|
+
*/
|
|
19
|
+
export declare function createUpdateVessel<T extends readonly AnyVesselEntry[]>(contextPair: MaelstromContextPair): <Id extends VesselIds<T>>(vessel: UpdateVesselPayload<T, Id>) => UpdateVesselResult;
|
|
20
|
+
export {};
|
|
21
|
+
//# sourceMappingURL=update-vessel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"update-vessel.d.ts","sourceRoot":"","sources":["../../src/lib/update-vessel.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAGvE,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,KAAK,EACV,cAAc,EAEd,mBAAmB,EACnB,kBAAkB,EAClB,SAAS,EACV,MAAM,yBAAyB,CAAC;AAEjC,6EAA6E;AAC7E,KAAK,eAAe,GAAG,cAAc,GAAG,eAAe,CAAC;AAExD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,qBAAqB,EAC1B,MAAM,EAAE,gBAAgB,EACxB,MAAM,EAAE,eAAe,GACtB,kBAAkB,CAkFpB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACpE,WAAW,EAAE,oBAAoB,IAIJ,EAAE,SAAS,SAAS,CAAC,CAAC,CAAC,EAClD,QAAQ,mBAAmB,CAAC,CAAC,EAAE,EAAE,CAAC,KACjC,kBAAkB,CAItB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ActionRunner } from '@maelstrom-co/client';
|
|
2
|
+
import { MaelstromContextPair } from './context.js';
|
|
3
|
+
import { AnyVesselEntry, ExtractVesselByIdFromEntries, VesselIds } from './vessel-entry-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Factory that creates the m.useActions() hook bound to a specific Maelstrom context.
|
|
6
|
+
*
|
|
7
|
+
* The returned hook registers typed side-effect handlers for actions dispatched to an instance
|
|
8
|
+
* (both engine-initiated and user-initiated via executeAction).
|
|
9
|
+
* Handlers are registered with the CommandProcessor on mount and unregistered on unmount.
|
|
10
|
+
*
|
|
11
|
+
* Pass a stable runner reference (defined outside the component or wrapped in useMemo)
|
|
12
|
+
* to prevent unnecessary re-registrations on each render.
|
|
13
|
+
*
|
|
14
|
+
* Limitation: only one useActions call per instanceId is supported. If two components
|
|
15
|
+
* register runners for the same instanceId, the second overwrites the first.
|
|
16
|
+
* Disposal is identity-checked, so unmounting the first will not affect the second's runner.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createUseActions<const T extends readonly AnyVesselEntry[]>(contextPair: MaelstromContextPair): <Id extends VesselIds<T>>(vesselId: Id, instanceId: string, runner: ActionRunner<ExtractVesselByIdFromEntries<T, Id>>) => void;
|
|
19
|
+
//# sourceMappingURL=use-actions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-actions.d.ts","sourceRoot":"","sources":["../../src/lib/use-actions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAKzD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC5B,SAAS,EACV,MAAM,yBAAyB,CAAC;AAGjC;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACxE,WAAW,EAAE,oBAAoB,IAIN,EAAE,SAAS,SAAS,CAAC,CAAC,CAAC,EAChD,UAAU,EAAE,EACZ,YAAY,MAAM,EAClB,QAAQ,YAAY,CAAC,4BAA4B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KACxD,IAAI,CA8BR"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { MaelstromContextPair } from './context.js';
|
|
2
|
+
import { UntypedVesselProps } from './dynamic-vessel-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Factory that creates the m.useInstance() hook — an untyped escape hatch.
|
|
5
|
+
*
|
|
6
|
+
* Unlike useVessel, this hook does not require a vesselId parameter and works
|
|
7
|
+
* for both statically and dynamically registered vessels. The trade-off is
|
|
8
|
+
* that variantProps is `Record<string, unknown>` and action names are `string`.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createUseInstance(contextPair: MaelstromContextPair): (instanceId: string) => UntypedVesselProps | null;
|
|
11
|
+
//# sourceMappingURL=use-instance.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-instance.d.ts","sourceRoot":"","sources":["../../src/lib/use-instance.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,oBAAoB,IAIrC,YAAY,MAAM,KAAG,kBAAkB,GAAG,IAAI,CAiC3E"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { IntentSnapshot, IntentSubmission } from '@maelstrom-co/client';
|
|
2
|
+
/**
|
|
3
|
+
* Observe a client ticket through atomic application settlement, or null before
|
|
4
|
+
* submission. Subscription cleanup never cancels work. Operational failures are
|
|
5
|
+
* terminal snapshots, not thrown errors; unknown must not be retried automatically.
|
|
6
|
+
*/
|
|
7
|
+
export declare function useIntentSubmission(submission: IntentSubmission | null): IntentSnapshot | null;
|
|
8
|
+
//# sourceMappingURL=use-intent-submission.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-intent-submission.d.ts","sourceRoot":"","sources":["../../src/lib/use-intent-submission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7E;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,gBAAgB,GAAG,IAAI,GAClC,cAAc,GAAG,IAAI,CAavB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-latest-ref.d.ts","sourceRoot":"","sources":["../../src/lib/use-latest-ref.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAU,MAAM,OAAO,CAAC;AAE/C,8FAA8F;AAC9F,wBAAgB,YAAY,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAItD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaelstromContextPair } from './context.js';
|
|
2
|
+
import { MaelstromState } from './maelstrom-state-types.js';
|
|
3
|
+
export declare function createUseMaelstrom(contextPair: MaelstromContextPair): {
|
|
4
|
+
(): MaelstromState;
|
|
5
|
+
<T>(selector: (state: MaelstromState) => T): T;
|
|
6
|
+
};
|
|
7
|
+
//# sourceMappingURL=use-maelstrom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-maelstrom.d.ts","sourceRoot":"","sources":["../../src/lib/use-maelstrom.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAEjE,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,oBAAoB;QAGzC,cAAc;KACjB,CAAC,YAAY,CAAC,KAAK,EAAE,cAAc,KAAK,CAAC,GAAG,CAAC;EA0EpE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Callback takes no args — getSnapshot reads .state directly, not the subscriber value. */
|
|
2
|
+
interface Subscribable {
|
|
3
|
+
subscribe: (cb: () => void) => {
|
|
4
|
+
unsubscribe: () => void;
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Subscribes to one or more TanStack stores via `useSyncExternalStore`.
|
|
9
|
+
* On each store notification, `buildSnapshot` composes a fresh value.
|
|
10
|
+
* If `selector` is provided, it narrows the snapshot before returning.
|
|
11
|
+
* Shallow equality prevents re-renders when the derived value hasn't changed.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useStoreSelector<T>(stores: Subscribable[], buildSnapshot: () => T): T;
|
|
14
|
+
export declare function useStoreSelector<T, S>(stores: Subscribable[], buildSnapshot: () => T, selector: (snapshot: T) => S): S;
|
|
15
|
+
export declare function useStoreSelector<T, S>(stores: Subscribable[], buildSnapshot: () => T, selector: ((snapshot: T) => S) | undefined): T | S;
|
|
16
|
+
export {};
|
|
17
|
+
//# sourceMappingURL=use-store-selector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-store-selector.d.ts","sourceRoot":"","sources":["../../src/lib/use-store-selector.ts"],"names":[],"mappings":"AAIA,4FAA4F;AAC5F,UAAU,YAAY;IACpB,SAAS,EAAE,CAAC,EAAE,EAAE,MAAM,IAAI,KAAK;QAAE,WAAW,EAAE,MAAM,IAAI,CAAA;KAAE,CAAC;CAC5D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,EAChC,MAAM,EAAE,YAAY,EAAE,EACtB,aAAa,EAAE,MAAM,CAAC,GACrB,CAAC,CAAC;AACL,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACnC,MAAM,EAAE,YAAY,EAAE,EACtB,aAAa,EAAE,MAAM,CAAC,EACtB,QAAQ,EAAE,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,GAC3B,CAAC,CAAC;AACL,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EACnC,MAAM,EAAE,YAAY,EAAE,EACtB,aAAa,EAAE,MAAM,CAAC,EACtB,QAAQ,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,SAAS,GACzC,CAAC,GAAG,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { InstanceId, VariantName, VesselId } from '@maelstrom-co/protocol';
|
|
2
|
+
import { MaelstromContextPair } from './context.js';
|
|
3
|
+
export interface VesselCoreResult {
|
|
4
|
+
instanceId: InstanceId;
|
|
5
|
+
vesselId: VesselId;
|
|
6
|
+
currentVariant: VariantName;
|
|
7
|
+
variantProps: Record<string, unknown>;
|
|
8
|
+
executeAction: (name: string, params?: Record<string, unknown>) => void;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Factory that creates a useVesselCore hook bound to a specific Maelstrom context.
|
|
12
|
+
*
|
|
13
|
+
* The returned hook subscribes to a vessel instance from the client store.
|
|
14
|
+
* Variant transitions are owned by the client (see `Orchestrator.invokeAction`),
|
|
15
|
+
* so this hook simply reflects the store's authoritative variant.
|
|
16
|
+
*/
|
|
17
|
+
export declare function createUseVesselCore(contextPair: MaelstromContextPair): (vesselId: string | undefined, instanceId: string) => VesselCoreResult | null;
|
|
18
|
+
//# sourceMappingURL=use-vessel-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-vessel-core.d.ts","sourceRoot":"","sources":["../../src/lib/use-vessel-core.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,KAAK,WAAW,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAKhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAGzD,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,UAAU,CAAC;IACvB,QAAQ,EAAE,QAAQ,CAAC;IACnB,cAAc,EAAE,WAAW,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACtC,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;CACzE;AAED;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,oBAAoB,IAIjE,UAAU,MAAM,GAAG,SAAS,EAC5B,YAAY,MAAM,KACjB,gBAAgB,GAAG,IAAI,CA0D3B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { MaelstromContextPair } from './context.js';
|
|
2
|
+
import { AnyVesselEntry, ExtractVesselByIdFromEntries, TypedVesselProps, VesselIds } from './vessel-entry-types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Factory that creates the m.useVessel() hook bound to a specific Maelstrom context.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createUseVessel<const T extends readonly AnyVesselEntry[]>(contextPair: MaelstromContextPair): <Id extends VesselIds<T>>(vesselId: Id, instanceId: string) => TypedVesselProps<ExtractVesselByIdFromEntries<T, Id>> | null;
|
|
7
|
+
//# sourceMappingURL=use-vessel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-vessel.d.ts","sourceRoot":"","sources":["../../src/lib/use-vessel.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEzD,OAAO,KAAK,EACV,cAAc,EACd,4BAA4B,EAC5B,gBAAgB,EAChB,SAAS,EACV,MAAM,yBAAyB,CAAC;AAGjC;;GAEG;AACH,wBAAgB,eAAe,CAAC,KAAK,CAAC,CAAC,SAAS,SAAS,cAAc,EAAE,EACvE,WAAW,EAAE,oBAAoB,IAKP,EAAE,SAAS,SAAS,CAAC,CAAC,CAAC,EAC/C,UAAU,EAAE,EACZ,YAAY,MAAM,KACjB,gBAAgB,CAAC,4BAA4B,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CA0BhE"}
|