@continuum-dev/react 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -343,6 +343,34 @@ Scans current snapshot values for suggestions and provides accept-all / reject-a
343
343
  const { hasSuggestions, acceptAll, rejectAll } = useContinuumSuggestions();
344
344
  ```
345
345
 
346
+ #### `useContinuumAction(intentId)`
347
+
348
+ Handles action dispatch with built-in loading and result state.
349
+
350
+ ```ts
351
+ const { dispatch, isDispatching, lastResult } = useContinuumAction('submit_form');
352
+ ```
353
+
354
+ Example action component:
355
+
356
+ ```tsx
357
+ function SubmitButton({ definition }: ContinuumNodeProps) {
358
+ const intentId = definition.intentId ?? '';
359
+ const { dispatch, isDispatching, lastResult } = useContinuumAction(intentId);
360
+
361
+ return (
362
+ <div>
363
+ <button disabled={isDispatching} onClick={() => dispatch(definition.id)}>
364
+ {isDispatching ? 'Working...' : definition.label}
365
+ </button>
366
+ {lastResult && (
367
+ <span>{lastResult.success ? 'Done' : 'Failed'}</span>
368
+ )}
369
+ </div>
370
+ );
371
+ }
372
+ ```
373
+
346
374
  ---
347
375
 
348
376
  ## The node contract
package/lib/context.d.ts CHANGED
@@ -2,22 +2,48 @@ import type { Session } from '@continuum-dev/session';
2
2
  import type { ContinuitySnapshot, NodeValue, ViewportState } from '@continuum-dev/contract';
3
3
  import type { ContinuumNodeMap, ContinuumProviderProps } from './types.js';
4
4
  type Listener = () => void;
5
+ /**
6
+ * Subscription-oriented store facade over Continuum session state.
7
+ */
5
8
  export interface ContinuumStore {
9
+ /** Returns the latest continuity snapshot. */
6
10
  getSnapshot(): ContinuitySnapshot | null;
11
+ /** Subscribes to snapshot updates. */
7
12
  subscribeSnapshot(listener: Listener): () => void;
13
+ /** Subscribes to diagnostics-related updates. */
8
14
  subscribeDiagnostics(listener: Listener): () => void;
15
+ /** Returns a node value by canonical id. */
9
16
  getNodeValue(nodeId: string): NodeValue | undefined;
17
+ /** Returns viewport state by canonical node id. */
10
18
  getNodeViewport(nodeId: string): ViewportState | undefined;
19
+ /** Subscribes to updates for a specific node id. */
11
20
  subscribeNode(nodeId: string, listener: Listener): () => void;
21
+ /** Releases store subscriptions and listeners. */
12
22
  destroy(): void;
13
23
  }
24
+ /**
25
+ * Value shape exposed through `ContinuumContext`.
26
+ */
14
27
  export interface ContinuumContextValue {
28
+ /** Backing Continuum session instance. */
15
29
  session: Session;
30
+ /** Subscription-friendly store facade over session state. */
16
31
  store: ContinuumStore;
32
+ /** Resolved node type to component map. */
17
33
  componentMap: ContinuumNodeMap;
34
+ /** True when provider loaded from existing persisted state. */
18
35
  wasHydrated: boolean;
19
36
  }
37
+ /**
38
+ * React context backing all `@continuum-dev/react` hooks and renderer behavior.
39
+ */
20
40
  export declare const ContinuumContext: import("react").Context<ContinuumContextValue | null>;
41
+ /**
42
+ * Initializes and provides Continuum session context to the React subtree.
43
+ *
44
+ * Creates (or hydrates) a session once, wires optional persistence, and
45
+ * provides a reactive store used by hooks and renderer components.
46
+ */
21
47
  export declare function ContinuumProvider({ components, persist, storageKey, maxPersistBytes, onPersistError, sessionOptions, children, }: ContinuumProviderProps): import("react/jsx-runtime").JSX.Element;
22
48
  export {};
23
49
  //# sourceMappingURL=context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/context.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACxF,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAE3E,KAAK,QAAQ,GAAG,MAAM,IAAI,CAAC;AA+C3B,MAAM,WAAW,cAAc;IAC7B,WAAW,IAAI,kBAAkB,GAAG,IAAI,CAAC;IACzC,iBAAiB,CAAC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iD;IACjD,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IACrD,4CAA4C;IAC5C,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS,CAAC;IACpD,mDAAmD;IACnD,eAAe,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAAC;IAC3D,oDAAoD;IACpD,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI,CAAC;IAC9D,kDAAkD;IAClD,OAAO,IAAI,IAAI,CAAC;CACjB;AAoFD;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,0CAA0C;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,6DAA6D;IAC7D,KAAK,EAAE,cAAc,CAAC;IACtB,2CAA2C;IAC3C,YAAY,EAAE,gBAAgB,CAAC;IAC/B,+DAA+D;IAC/D,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,gBAAgB,uDAAoD,CAAC;AAuClF;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,UAAU,EACV,OAAe,EACf,UAAgC,EAChC,eAAe,EACf,cAAc,EACd,cAAc,EACd,QAAQ,GACT,EAAE,sBAAsB,2CAsDxB"}
package/lib/context.js CHANGED
@@ -112,6 +112,9 @@ function createContinuumStore(session) {
112
112
  },
113
113
  };
114
114
  }
115
+ /**
116
+ * React context backing all `@continuum-dev/react` hooks and renderer behavior.
117
+ */
115
118
  export const ContinuumContext = createContext(null);
116
119
  const DEFAULT_STORAGE_KEY = 'continuum_session';
117
120
  function resolveStorage(persist) {
@@ -143,6 +146,12 @@ function useStableMap(map) {
143
146
  ref.current = map;
144
147
  return map;
145
148
  }
149
+ /**
150
+ * Initializes and provides Continuum session context to the React subtree.
151
+ *
152
+ * Creates (or hydrates) a session once, wires optional persistence, and
153
+ * provides a reactive store used by hooks and renderer components.
154
+ */
146
155
  export function ContinuumProvider({ components, persist = false, storageKey = DEFAULT_STORAGE_KEY, maxPersistBytes, onPersistError, sessionOptions, children, }) {
147
156
  const storage = resolveStorage(persist);
148
157
  const stableComponents = useStableMap(components);
@@ -7,6 +7,9 @@ interface NodeErrorBoundaryState {
7
7
  hasError: boolean;
8
8
  message: string;
9
9
  }
10
+ /**
11
+ * Per-node error boundary used by the renderer to isolate component failures.
12
+ */
10
13
  export declare class NodeErrorBoundary extends Component<NodeErrorBoundaryProps, NodeErrorBoundaryState> {
11
14
  state: NodeErrorBoundaryState;
12
15
  static getDerivedStateFromError(error: unknown): NodeErrorBoundaryState;
@@ -1 +1 @@
1
- {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,UAAU,sBAAsB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,iBAAkB,SAAQ,SAAS,CAC9C,sBAAsB,EACtB,sBAAsB,CACvB;IACU,KAAK,EAAE,sBAAsB,CAGpC;IAEF,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB;IAO9D,MAAM;CAUhB"}
1
+ {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAElD,UAAU,sBAAsB;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,UAAU,sBAAsB;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS,CAC9C,sBAAsB,EACtB,sBAAsB,CACvB;IACU,KAAK,EAAE,sBAAsB,CAGpC;IAEF,MAAM,CAAC,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,sBAAsB;IAO9D,MAAM;CAUhB"}
@@ -1,5 +1,8 @@
1
1
  import { jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { Component } from 'react';
3
+ /**
4
+ * Per-node error boundary used by the renderer to isolate component failures.
5
+ */
3
6
  export class NodeErrorBoundary extends Component {
4
7
  state = {
5
8
  hasError: false,
package/lib/fallback.d.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  import type { ContinuumNodeProps } from './types.js';
2
+ /**
3
+ * Default renderer used when no component exists for a node type.
4
+ */
2
5
  export declare function FallbackComponent({ value, onChange, definition, }: ContinuumNodeProps): import("react/jsx-runtime").JSX.Element;
3
6
  //# sourceMappingURL=fallback.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/fallback.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,UAAU,GACX,EAAE,kBAAkB,2CAoCpB"}
1
+ {"version":3,"file":"fallback.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/fallback.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAChC,KAAK,EACL,QAAQ,EACR,UAAU,GACX,EAAE,kBAAkB,2CAoCpB"}
package/lib/fallback.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * Default renderer used when no component exists for a node type.
4
+ */
2
5
  export function FallbackComponent({ value, onChange, definition, }) {
3
6
  const raw = value;
4
7
  const textValue = typeof raw?.['value'] === 'string' || typeof raw?.['value'] === 'number'
package/lib/hooks.d.ts CHANGED
@@ -1,32 +1,76 @@
1
1
  import type { Session } from '@continuum-dev/session';
2
- import type { ContinuitySnapshot, NodeValue, ViewportState, ProposedValue } from '@continuum-dev/contract';
2
+ import type { ContinuitySnapshot, NodeValue, ViewportState, ProposedValue, ActionResult } from '@continuum-dev/contract';
3
3
  interface NodeStateScope {
4
4
  subscribeNode: (nodeId: string, listener: () => void) => () => void;
5
5
  getNodeValue: (nodeId: string) => NodeValue | undefined;
6
6
  setNodeValue: (nodeId: string, value: NodeValue) => void;
7
7
  }
8
+ /**
9
+ * Internal scope context used by collection item renderers to map local node ids
10
+ * onto collection-backed values.
11
+ */
8
12
  export declare const NodeStateScopeContext: import("react").Context<NodeStateScope | null>;
13
+ /**
14
+ * Returns the active Continuum session from provider context.
15
+ */
9
16
  export declare function useContinuumSession(): Session;
17
+ /**
18
+ * Subscribes to and updates a specific node value by canonical node id.
19
+ *
20
+ * @param nodeId Canonical node id.
21
+ */
10
22
  export declare function useContinuumState(nodeId: string): [NodeValue | undefined, (value: NodeValue) => void];
23
+ /**
24
+ * Subscribes to the full continuity snapshot.
25
+ */
11
26
  export declare function useContinuumSnapshot(): ContinuitySnapshot | null;
27
+ /**
28
+ * Subscribes to and updates viewport state for a specific node.
29
+ *
30
+ * @param nodeId Canonical node id.
31
+ */
12
32
  export declare function useContinuumViewport(nodeId: string): [ViewportState | undefined, (state: ViewportState) => void];
33
+ /**
34
+ * Subscribes to session diagnostics (`issues`, `diffs`, `resolutions`, checkpoints).
35
+ */
13
36
  export declare function useContinuumDiagnostics(): {
14
37
  issues: ReturnType<Session["getIssues"]>;
15
38
  diffs: ReturnType<Session["getDiffs"]>;
16
39
  resolutions: ReturnType<Session["getResolutions"]>;
17
40
  checkpoints: ReturnType<Session["getCheckpoints"]>;
18
41
  };
42
+ /**
43
+ * Indicates whether the provider session was restored from persistence.
44
+ */
19
45
  export declare function useContinuumHydrated(): boolean;
46
+ /**
47
+ * Returns conflict state and resolution actions for one node.
48
+ *
49
+ * @param nodeId Canonical node id.
50
+ */
20
51
  export declare function useContinuumConflict(nodeId: string): {
21
52
  hasConflict: boolean;
22
53
  proposal: ProposedValue | null;
23
54
  accept: () => void;
24
55
  reject: () => void;
25
56
  };
57
+ /**
58
+ * Aggregates suggestion state and exposes bulk accept/reject operations.
59
+ */
26
60
  export declare function useContinuumSuggestions(): {
27
61
  hasSuggestions: boolean;
28
62
  acceptAll: () => void;
29
63
  rejectAll: () => void;
30
64
  };
65
+ /**
66
+ * Returns an action dispatcher bound to an intent id with dispatch state.
67
+ *
68
+ * @param intentId Registered action intent id to dispatch.
69
+ */
70
+ export declare function useContinuumAction(intentId: string): {
71
+ dispatch: (nodeId: string) => Promise<ActionResult>;
72
+ isDispatching: boolean;
73
+ lastResult: ActionResult | null;
74
+ };
31
75
  export {};
32
76
  //# sourceMappingURL=hooks.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/hooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAwDvG,UAAU,cAAc;IACtB,aAAa,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,IAAI,KAAK,MAAM,IAAI,CAAC;IACpE,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,SAAS,GAAG,SAAS,CAAC;IACxD,YAAY,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CAC1D;AAED,eAAO,MAAM,qBAAqB,gDAA6C,CAAC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AC;IACnB,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAsCA;AAED;;GAEG;AACH,wBAAgB,uBAAuB,IAAI;IACzC,cAAc,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,IAAI,CAAC;CACvB,CAgEA;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG;IACpD,QAAQ,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,YAAY,CAAC,CAAC;IACpD,aAAa,EAAE,OAAO,CAAC;IACvB,UAAU,EAAE,YAAY,GAAG,IAAI,CAAC;CACjC,CA0BA"}
package/lib/hooks.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createContext, useContext, useCallback, useRef, useSyncExternalStore } from 'react';
1
+ import { createContext, useContext, useCallback, useRef, useState, useSyncExternalStore } from 'react';
2
2
  import { ContinuumContext } from './context.js';
3
3
  function shallowArrayEqual(left, right) {
4
4
  if (left.length !== right.length) {
@@ -38,7 +38,14 @@ function shallowViewportEqual(left, right) {
38
38
  left.isExpanded === right.isExpanded &&
39
39
  left.isFocused === right.isFocused);
40
40
  }
41
+ /**
42
+ * Internal scope context used by collection item renderers to map local node ids
43
+ * onto collection-backed values.
44
+ */
41
45
  export const NodeStateScopeContext = createContext(null);
46
+ /**
47
+ * Returns the active Continuum session from provider context.
48
+ */
42
49
  export function useContinuumSession() {
43
50
  const ctx = useContext(ContinuumContext);
44
51
  if (!ctx) {
@@ -46,6 +53,11 @@ export function useContinuumSession() {
46
53
  }
47
54
  return ctx.session;
48
55
  }
56
+ /**
57
+ * Subscribes to and updates a specific node value by canonical node id.
58
+ *
59
+ * @param nodeId Canonical node id.
60
+ */
49
61
  export function useContinuumState(nodeId) {
50
62
  const ctx = useContext(ContinuumContext);
51
63
  const scope = useContext(NodeStateScopeContext);
@@ -81,6 +93,9 @@ export function useContinuumState(nodeId) {
81
93
  }, [scope, session, nodeId]);
82
94
  return [value, setValue];
83
95
  }
96
+ /**
97
+ * Subscribes to the full continuity snapshot.
98
+ */
84
99
  export function useContinuumSnapshot() {
85
100
  const ctx = useContext(ContinuumContext);
86
101
  if (!ctx) {
@@ -114,6 +129,11 @@ export function useContinuumSnapshot() {
114
129
  }, [store]);
115
130
  return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
116
131
  }
132
+ /**
133
+ * Subscribes to and updates viewport state for a specific node.
134
+ *
135
+ * @param nodeId Canonical node id.
136
+ */
117
137
  export function useContinuumViewport(nodeId) {
118
138
  const ctx = useContext(ContinuumContext);
119
139
  if (!ctx) {
@@ -137,6 +157,9 @@ export function useContinuumViewport(nodeId) {
137
157
  }, [session, nodeId]);
138
158
  return [viewport, setViewport];
139
159
  }
160
+ /**
161
+ * Subscribes to session diagnostics (`issues`, `diffs`, `resolutions`, checkpoints).
162
+ */
140
163
  export function useContinuumDiagnostics() {
141
164
  const ctx = useContext(ContinuumContext);
142
165
  if (!ctx) {
@@ -165,6 +188,9 @@ export function useContinuumDiagnostics() {
165
188
  const subscribe = useCallback((onStoreChange) => store.subscribeDiagnostics(onStoreChange), [store]);
166
189
  return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
167
190
  }
191
+ /**
192
+ * Indicates whether the provider session was restored from persistence.
193
+ */
168
194
  export function useContinuumHydrated() {
169
195
  const ctx = useContext(ContinuumContext);
170
196
  if (!ctx) {
@@ -172,6 +198,11 @@ export function useContinuumHydrated() {
172
198
  }
173
199
  return ctx.wasHydrated;
174
200
  }
201
+ /**
202
+ * Returns conflict state and resolution actions for one node.
203
+ *
204
+ * @param nodeId Canonical node id.
205
+ */
175
206
  export function useContinuumConflict(nodeId) {
176
207
  const ctx = useContext(ContinuumContext);
177
208
  if (!ctx) {
@@ -203,6 +234,9 @@ export function useContinuumConflict(nodeId) {
203
234
  reject,
204
235
  };
205
236
  }
237
+ /**
238
+ * Aggregates suggestion state and exposes bulk accept/reject operations.
239
+ */
206
240
  export function useContinuumSuggestions() {
207
241
  const ctx = useContext(ContinuumContext);
208
242
  if (!ctx) {
@@ -260,3 +294,29 @@ export function useContinuumSuggestions() {
260
294
  rejectAll,
261
295
  };
262
296
  }
297
+ /**
298
+ * Returns an action dispatcher bound to an intent id with dispatch state.
299
+ *
300
+ * @param intentId Registered action intent id to dispatch.
301
+ */
302
+ export function useContinuumAction(intentId) {
303
+ const ctx = useContext(ContinuumContext);
304
+ if (!ctx) {
305
+ throw new Error('useContinuumAction must be used within a <ContinuumProvider>');
306
+ }
307
+ const { session } = ctx;
308
+ const [isDispatching, setIsDispatching] = useState(false);
309
+ const [lastResult, setLastResult] = useState(null);
310
+ const dispatch = useCallback(async (nodeId) => {
311
+ setIsDispatching(true);
312
+ try {
313
+ const result = await session.dispatchAction(intentId, nodeId);
314
+ setLastResult(result);
315
+ return result;
316
+ }
317
+ finally {
318
+ setIsDispatching(false);
319
+ }
320
+ }, [session, intentId]);
321
+ return { dispatch, isDispatching, lastResult };
322
+ }
package/lib/renderer.d.ts CHANGED
@@ -1,4 +1,7 @@
1
1
  import type { ViewDefinition } from '@continuum-dev/contract';
2
+ /**
3
+ * Renders a `ViewDefinition` tree using components registered in `ContinuumProvider`.
4
+ */
2
5
  export declare function ContinuumRenderer({ view }: {
3
6
  view: ViewDefinition;
4
7
  }): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/renderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AA+W7B,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,2CAQnE"}
1
+ {"version":3,"file":"renderer.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/renderer.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAIV,cAAc,EAEf,MAAM,qBAAqB,CAAC;AA+W7B;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,EAAE,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,2CAQnE"}
package/lib/renderer.js CHANGED
@@ -201,6 +201,9 @@ const NodeRenderer = memo(function NodeRenderer({ definition, parentPath }) {
201
201
  }
202
202
  return _jsx(StatefulNodeRenderer, { definition: definition, parentPath: parentPath });
203
203
  });
204
+ /**
205
+ * Renders a `ViewDefinition` tree using components registered in `ContinuumProvider`.
206
+ */
204
207
  export function ContinuumRenderer({ view }) {
205
208
  return (_jsx("div", { "data-continuum-view": view.viewId, children: (view.nodes ?? []).map((node) => (_jsx(NodeRenderer, { definition: node, parentPath: "" }, node.id))) }));
206
209
  }
package/lib/types.d.ts CHANGED
@@ -1,31 +1,71 @@
1
1
  import type { ViewNode, NodeValue } from '@continuum-dev/contract';
2
2
  import type { SessionOptions } from '@continuum-dev/session';
3
3
  import type { ComponentType } from 'react';
4
+ /**
5
+ * Props passed to node renderer components in the Continuum map.
6
+ *
7
+ * @template T Node value shape consumed by the component.
8
+ */
4
9
  export interface ContinuumNodeProps<T = NodeValue> {
10
+ /** Current node value from session state. */
5
11
  value: T | undefined;
12
+ /** Writes a new node value into session state. */
6
13
  onChange: (value: T) => void;
14
+ /** Raw node definition from the active view. */
7
15
  definition: ViewNode;
16
+ /** Canonical node id, including parent path for nested nodes. */
8
17
  nodeId?: string;
18
+ /** Rendered children for container-like nodes. */
9
19
  children?: React.ReactNode;
20
+ /** Additional mapped props provided by renderers/integrations. */
10
21
  [prop: string]: unknown;
11
22
  }
23
+ /**
24
+ * Component registry keyed by Continuum node `type`.
25
+ */
12
26
  export type ContinuumNodeMap = Record<string, ComponentType<ContinuumNodeProps<any>>>;
27
+ /**
28
+ * Backward-compatible alias for `ContinuumNodeProps`.
29
+ *
30
+ * @template T Node value shape consumed by the component.
31
+ */
13
32
  export type ContinuumComponentProps<T = NodeValue> = ContinuumNodeProps<T>;
33
+ /**
34
+ * Backward-compatible alias for `ContinuumNodeMap`.
35
+ */
14
36
  export type ContinuumComponentMap = ContinuumNodeMap;
37
+ /**
38
+ * Error metadata emitted when persistence fails in the provider.
39
+ */
15
40
  export interface ContinuumPersistError {
41
+ /** Persistence failure category. */
16
42
  reason: 'size_limit' | 'storage_error';
43
+ /** Storage key used for persistence. */
17
44
  key: string;
45
+ /** Serialized payload size in bytes. */
18
46
  attemptedBytes?: number;
47
+ /** Configured max byte limit for persistence. */
19
48
  maxBytes?: number;
49
+ /** Original error/cause when available. */
20
50
  cause?: unknown;
21
51
  }
52
+ /**
53
+ * Props for `ContinuumProvider`.
54
+ */
22
55
  export interface ContinuumProviderProps {
56
+ /** Node type to component map used by `ContinuumRenderer`. */
23
57
  components: ContinuumNodeMap;
58
+ /** Optional browser persistence mode. */
24
59
  persist?: 'sessionStorage' | 'localStorage' | false;
60
+ /** Storage key for persisted session data. */
25
61
  storageKey?: string;
62
+ /** Maximum serialized bytes allowed for persisted payloads. */
26
63
  maxPersistBytes?: number;
64
+ /** Callback invoked when persistence errors occur. */
27
65
  onPersistError?: (error: ContinuumPersistError) => void;
66
+ /** Options forwarded to `@continuum-dev/session`. */
28
67
  sessionOptions?: SessionOptions;
68
+ /** React subtree that consumes Continuum context. */
29
69
  children: React.ReactNode;
30
70
  }
31
71
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../packages/react/src/lib/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE3C,MAAM,WAAW,kBAAkB,CAAC,CAAC,GAAG,SAAS;IAC/C,KAAK,EAAE,CAAC,GAAG,SAAS,CAAC;IACrB,QAAQ,EAAE,CAAC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;IACpD,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,+DAA+D;IAC/D,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sDAAsD;IACtD,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACxD,iDAAiD;IACjD,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,qDAAqD;IACrD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@continuum-dev/react",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -44,7 +44,7 @@
44
44
  "react": ">=18"
45
45
  },
46
46
  "dependencies": {
47
- "@continuum-dev/contract": "^0.1.1",
48
- "@continuum-dev/session": "^0.1.1"
47
+ "@continuum-dev/contract": "^0.1.2",
48
+ "@continuum-dev/session": "^0.1.2"
49
49
  }
50
50
  }