@elaraai/e3-ui-components 0.0.1-beta.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLA.md +1 -1
- package/CONTRIBUTING.md +3 -3
- package/LICENSE.md +15 -666
- package/README.md +69 -1
- package/dist/components/DataTaskPreview.d.ts +16 -0
- package/dist/components/DataTaskPreview.d.ts.map +1 -0
- package/dist/components/DatasetPreview.d.ts +14 -0
- package/dist/components/DatasetPreview.d.ts.map +1 -0
- package/dist/components/EastValueViewer.d.ts.map +1 -1
- package/dist/components/ErrorBoundary.d.ts +10 -2
- package/dist/components/ErrorBoundary.d.ts.map +1 -1
- package/dist/components/InputPreview.d.ts +1 -7
- package/dist/components/InputPreview.d.ts.map +1 -1
- package/dist/components/TaskLogs.d.ts +13 -0
- package/dist/components/TaskLogs.d.ts.map +1 -0
- package/dist/components/TaskPreview.d.ts +1 -8
- package/dist/components/TaskPreview.d.ts.map +1 -1
- package/dist/components/UITaskPreview.d.ts +16 -0
- package/dist/components/UITaskPreview.d.ts.map +1 -0
- package/dist/components/VirtualizedLogViewer.d.ts.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/diff/format.d.ts +19 -0
- package/dist/diff/format.d.ts.map +1 -0
- package/dist/diff/index.d.ts +10 -0
- package/dist/diff/index.d.ts.map +1 -0
- package/dist/diff/manual.d.ts +25 -0
- package/dist/diff/manual.d.ts.map +1 -0
- package/dist/diff/walker.d.ts +52 -0
- package/dist/diff/walker.d.ts.map +1 -0
- package/dist/hooks/datasets.d.ts +5 -1
- package/dist/hooks/datasets.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/types.d.ts +2 -6
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/hooks/useDatasetStatus.d.ts +20 -0
- package/dist/hooks/useDatasetStatus.d.ts.map +1 -0
- package/dist/hooks/useDatasetValue.d.ts +35 -0
- package/dist/hooks/useDatasetValue.d.ts.map +1 -0
- package/dist/hooks/useInputData.d.ts +5 -1
- package/dist/hooks/useInputData.d.ts.map +1 -1
- package/dist/hooks/useTaskDetails.d.ts +14 -0
- package/dist/hooks/useTaskDetails.d.ts.map +1 -0
- package/dist/hooks/useTaskLogsHook.d.ts +2 -2
- package/dist/hooks/useTaskLogsHook.d.ts.map +1 -1
- package/dist/hooks/useTaskOutput.d.ts +5 -1
- package/dist/hooks/useTaskOutput.d.ts.map +1 -1
- package/dist/index.cjs +50775 -1780
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +50886 -1907
- package/dist/index.js.map +1 -1
- package/dist/ontology/NodePropertiesDrawer.d.ts +19 -0
- package/dist/ontology/NodePropertiesDrawer.d.ts.map +1 -0
- package/dist/ontology/OntologyEdge.d.ts +11 -0
- package/dist/ontology/OntologyEdge.d.ts.map +1 -0
- package/dist/ontology/OntologyNode.d.ts +14 -0
- package/dist/ontology/OntologyNode.d.ts.map +1 -0
- package/dist/ontology/accents.d.ts +20 -0
- package/dist/ontology/accents.d.ts.map +1 -0
- package/dist/ontology/bind-runtime.d.ts +30 -0
- package/dist/ontology/bind-runtime.d.ts.map +1 -0
- package/dist/ontology/flow-state.d.ts +34 -0
- package/dist/ontology/flow-state.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +10 -0
- package/dist/ontology/index.d.ts.map +1 -0
- package/dist/ontology/layout.d.ts +9 -0
- package/dist/ontology/layout.d.ts.map +1 -0
- package/dist/ontology/types.d.ts +46 -0
- package/dist/ontology/types.d.ts.map +1 -0
- package/dist/platform/bind-runtime.d.ts +139 -0
- package/dist/platform/bind-runtime.d.ts.map +1 -0
- package/dist/platform/dataset-hooks.d.ts +175 -0
- package/dist/platform/dataset-hooks.d.ts.map +1 -0
- package/dist/platform/dataset-store.d.ts +251 -0
- package/dist/platform/dataset-store.d.ts.map +1 -0
- package/dist/platform/e3-config.d.ts +59 -0
- package/dist/platform/e3-config.d.ts.map +1 -0
- package/dist/platform/index.d.ts +16 -0
- package/dist/platform/index.d.ts.map +1 -0
- package/dist/platform/staged-store.d.ts +108 -0
- package/dist/platform/staged-store.d.ts.map +1 -0
- package/package.json +47 -24
- package/dist/hooks/useInputDataPreview.d.ts +0 -8
- package/dist/hooks/useInputDataPreview.d.ts.map +0 -1
- package/dist/hooks/useTaskOutputPreview.d.ts +0 -8
- package/dist/hooks/useTaskOutputPreview.d.ts.map +0 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { OntologyNode, OntologyNodeKind } from './types.js';
|
|
2
|
+
export interface NodePropertiesDrawerProps {
|
|
3
|
+
/** Node to edit; `null` closes the drawer. */
|
|
4
|
+
nodeId: string | null;
|
|
5
|
+
/** Resolves a node id to its current ontology entry, or `undefined`. */
|
|
6
|
+
getNode(id: string): OntologyNode | undefined;
|
|
7
|
+
/** Close the drawer without committing pending edits. */
|
|
8
|
+
onClose(): void;
|
|
9
|
+
/** Apply edits to a node. Pass `null` to disable mutation (read-only). */
|
|
10
|
+
onUpdate: ((id: string, updates: {
|
|
11
|
+
type?: OntologyNodeKind;
|
|
12
|
+
name?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}) => void) | null;
|
|
15
|
+
/** Delete a node. Pass `null` to disable. */
|
|
16
|
+
onDelete: ((id: string) => void) | null;
|
|
17
|
+
}
|
|
18
|
+
export declare function NodePropertiesDrawer({ nodeId, getNode, onClose, onUpdate, onDelete }: NodePropertiesDrawerProps): import("react/jsx-runtime").JSX.Element;
|
|
19
|
+
//# sourceMappingURL=NodePropertiesDrawer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NodePropertiesDrawer.d.ts","sourceRoot":"","sources":["../../src/ontology/NodePropertiesDrawer.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAoBH,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIjE,MAAM,WAAW,yBAAyB;IACtC,8CAA8C;IAC9C,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,wEAAwE;IACxE,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;IAC9C,yDAAyD;IACzD,OAAO,IAAI,IAAI,CAAC;IAChB,0EAA0E;IAC1E,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE;QAAE,IAAI,CAAC,EAAE,gBAAgB,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;IACnH,6CAA6C;IAC7C,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC;CAC3C;AAiGD,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,yBAAyB,2CAuC/G"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EdgeProps, Edge } from '@xyflow/react';
|
|
2
|
+
import { OntologyLinkKind } from './types.js';
|
|
3
|
+
/** Data the parent passes through to the ReactFlow edge-renderer. */
|
|
4
|
+
export interface OntologyFlowEdgeData {
|
|
5
|
+
type: OntologyLinkKind;
|
|
6
|
+
label: string;
|
|
7
|
+
attention: 'focused' | 'normal' | 'unfocused';
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}
|
|
10
|
+
export declare const OntologyEdge: import('react').MemoExoticComponent<({ id, sourceX, sourceY, targetX, targetY, sourcePosition, targetPosition, selected, data, }: EdgeProps<Edge<OntologyFlowEdgeData>>) => import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
//# sourceMappingURL=OntologyEdge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OntologyEdge.d.ts","sourceRoot":"","sources":["../../src/ontology/OntologyEdge.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAaH,OAAO,EAAoC,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAE5F,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC9C,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAKD,eAAO,MAAM,YAAY,oIAUtB,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,6CA+EtC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { NodeProps, Node } from '@xyflow/react';
|
|
2
|
+
import { OntologyNodeKind } from './types.js';
|
|
3
|
+
/** Data the parent passes through to the ReactFlow node-renderer. */
|
|
4
|
+
export interface OntologyFlowNodeData {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string | undefined;
|
|
7
|
+
type: OntologyNodeKind;
|
|
8
|
+
attention: 'focused' | 'normal' | 'unfocused';
|
|
9
|
+
/** Optional status pill shown top-right (e.g. a validation flag). */
|
|
10
|
+
flag?: string;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare const OntologyNode: import('react').MemoExoticComponent<({ data, selected }: NodeProps<Node<OntologyFlowNodeData>>) => import("react/jsx-runtime").JSX.Element>;
|
|
14
|
+
//# sourceMappingURL=OntologyNode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OntologyNode.d.ts","sourceRoot":"","sources":["../../src/ontology/OntologyNode.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAeH,OAAO,EAAoB,KAAK,SAAS,EAAE,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAO5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAgBnD,qEAAqE;AACrE,MAAM,WAAW,oBAAoB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,gBAAgB,CAAC;IACvB,SAAS,EAAE,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAC9C,qEAAqE;IACrE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAmBD,eAAO,MAAM,YAAY,2DAA6B,SAAS,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,6CAsHzF,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { OntologyNodeKind, OntologyLinkKind } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Per-kind 2px top-stripe colour, applied to the node card. Card body
|
|
4
|
+
* stays neutral `paper / ink` regardless of kind.
|
|
5
|
+
*
|
|
6
|
+
* Values are literal hex anchored to the shared brand / gray / status
|
|
7
|
+
* palette (`#3a7780` = `brand.600`, `#2f7a5b` = `status.pos`, etc.). Mixed
|
|
8
|
+
* tones for `computation` / `resource` / `policy` / `document` use
|
|
9
|
+
* `color-mix` math against those same anchors (precomputed because Chakra
|
|
10
|
+
* tokens don't natively express `color-mix`).
|
|
11
|
+
*/
|
|
12
|
+
export declare const NODE_KIND_ACCENT: Record<OntologyNodeKind, string>;
|
|
13
|
+
/**
|
|
14
|
+
* Per-link-kind stroke dash pattern. Empty string `'none'` (CSS-friendly)
|
|
15
|
+
* → solid line. Patterns mirror the schematic vocabulary
|
|
16
|
+
* (flow / signal / dependency / constraint / simulation) in
|
|
17
|
+
* `east-ui-showcase/dist-design/configure__pattern__schematic.html`.
|
|
18
|
+
*/
|
|
19
|
+
export declare const EDGE_DASH: Record<OntologyLinkKind, string>;
|
|
20
|
+
//# sourceMappingURL=accents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accents.d.ts","sourceRoot":"","sources":["../../src/ontology/accents.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAErE;;;;;;;;;GASG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAW7D,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAsBtD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { ValueTypeOf } from '@elaraai/east';
|
|
2
|
+
import { DiffBindingType } from '@elaraai/e3-ui';
|
|
3
|
+
import { Ontology } from './types.js';
|
|
4
|
+
type DiffBindingValue = ValueTypeOf<typeof DiffBindingType>;
|
|
5
|
+
export interface UseBindingOntologyResult {
|
|
6
|
+
/** Current ontology value (buffered if staged, otherwise server). `null`
|
|
7
|
+
* if the binding hasn't run yet (no registered types) or the source
|
|
8
|
+
* dataset has no value. */
|
|
9
|
+
ontology: Ontology | null;
|
|
10
|
+
/** True when there is an in-flight staged change. Always false for direct
|
|
11
|
+
* bindings — the handle writes through, never buffers. */
|
|
12
|
+
pending: boolean;
|
|
13
|
+
/** Replace the bound value. In staged mode buffers the write; in direct
|
|
14
|
+
* mode writes through immediately. */
|
|
15
|
+
mutate: (next: Ontology) => void;
|
|
16
|
+
/** Resolve the in-flight change. */
|
|
17
|
+
commit: () => Promise<void>;
|
|
18
|
+
/** Drop the in-flight change. */
|
|
19
|
+
discard: () => void;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve a {@link DiffBindingType} value into a live ontology + the
|
|
23
|
+
* commit / discard / mutate handlers, delegating to the shared bind runtime.
|
|
24
|
+
*
|
|
25
|
+
* Returns `ontology: null` if the binding hasn't run yet (types not
|
|
26
|
+
* registered) or no source value is present.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useBindingOntology(binding: DiffBindingValue): UseBindingOntologyResult;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=bind-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind-runtime.d.ts","sourceRoot":"","sources":["../../src/ontology/bind-runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAsBH,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAUjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,KAAK,gBAAgB,GAAG,WAAW,CAAC,OAAO,eAAe,CAAC,CAAC;AAE5D,MAAM,WAAW,wBAAwB;IACrC;;gCAE4B;IAC5B,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B;+DAC2D;IAC3D,OAAO,EAAE,OAAO,CAAC;IACjB;2CACuC;IACvC,MAAM,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,IAAI,CAAC;IACjC,oCAAoC;IACpC,MAAM,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5B,iCAAiC;IACjC,OAAO,EAAE,MAAM,IAAI,CAAC;CACvB;AA6BD;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,GAAG,wBAAwB,CA0CtF"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Node as FlowNode, Edge as FlowEdge, NodeChange, EdgeChange } from '@xyflow/react';
|
|
2
|
+
import { FlatLink, FlatNode } from './types.js';
|
|
3
|
+
import { OntologyFlowNodeData } from './OntologyNode.js';
|
|
4
|
+
import { OntologyFlowEdgeData } from './OntologyEdge.js';
|
|
5
|
+
/**
|
|
6
|
+
* Mutation callbacks the parent renderer injects. In read-only mode the
|
|
7
|
+
* parent passes no-ops; in editable mode each callback re-derives the
|
|
8
|
+
* next-ontology and writes it back through `binding.write` via
|
|
9
|
+
* `useBindingOntology`'s `mutate`.
|
|
10
|
+
*/
|
|
11
|
+
export interface OntologyMutations {
|
|
12
|
+
deleteNodes(ids: Set<string>): void;
|
|
13
|
+
deleteLinks(ids: Set<string>): void;
|
|
14
|
+
}
|
|
15
|
+
export interface UseFlowStateArgs {
|
|
16
|
+
flatNodes: FlatNode[];
|
|
17
|
+
flatLinks: FlatLink[];
|
|
18
|
+
mutations: OntologyMutations;
|
|
19
|
+
}
|
|
20
|
+
export declare function useFlowState({ flatNodes, flatLinks, mutations }: UseFlowStateArgs): {
|
|
21
|
+
nodes: FlowNode<OntologyFlowNodeData>[];
|
|
22
|
+
edges: FlowEdge<OntologyFlowEdgeData>[];
|
|
23
|
+
onNodesChange: (changes: NodeChange[]) => void;
|
|
24
|
+
onEdgesChange: (changes: EdgeChange[]) => void;
|
|
25
|
+
screenToFlowPosition: (clientPosition: import('@xyflow/react').XYPosition, options?: {
|
|
26
|
+
snapToGrid?: boolean;
|
|
27
|
+
snapGrid?: import('@xyflow/react').SnapGrid;
|
|
28
|
+
}) => import('@xyflow/react').XYPosition;
|
|
29
|
+
setNodePosition: (id: string, pos: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}) => void;
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=flow-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-state.d.ts","sourceRoot":"","sources":["../../src/ontology/flow-state.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAiBH,OAAO,EAIH,KAAK,IAAI,IAAI,QAAQ,EACrB,KAAK,IAAI,IAAI,QAAQ,EACrB,KAAK,UAAU,EACf,KAAK,UAAU,EAClB,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACrD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAC9B,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IACpC,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CACvC;AAED,MAAM,WAAW,gBAAgB;IAC7B,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE,QAAQ,EAAE,CAAC;IACtB,SAAS,EAAE,iBAAiB,CAAC;CAChC;AAgED,wBAAgB,YAAY,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,gBAAgB;;;6BA6ClC,UAAU,EAAE;6BAyBZ,UAAU,EAAE;;kBAhBtB,CAAC;gBACvB,CAAT;;0BA1CsC,MAAM,OAAO;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE;EAsEjF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ValueTypeOf } from '@elaraai/east';
|
|
2
|
+
import { Ontology } from '@elaraai/e3-ui';
|
|
3
|
+
type OntologyValueIR = ValueTypeOf<typeof Ontology.Component.schema>;
|
|
4
|
+
export interface EastChakraOntologyProps {
|
|
5
|
+
value: OntologyValueIR;
|
|
6
|
+
storageKey: string;
|
|
7
|
+
}
|
|
8
|
+
declare const EastChakraOntology: import('react').NamedExoticComponent<EastChakraOntologyProps>;
|
|
9
|
+
export { EastChakraOntology };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/ontology/index.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAkCH,OAAO,EAAuB,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AA8B1C,KAAK,eAAe,GAAG,WAAW,CAAC,OAAO,QAAQ,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;AAoBrE,MAAM,WAAW,uBAAuB;IACpC,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,MAAM,CAAC;CACtB;AAgWD,QAAA,MAAM,kBAAkB,+DAsJtB,CAAC;AAIH,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FlatNode, FlatLink } from './types.js';
|
|
2
|
+
export interface LayoutResult {
|
|
3
|
+
positions: Map<string, {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
}>;
|
|
7
|
+
}
|
|
8
|
+
export declare function calculateLayout(nodes: FlatNode[], links: FlatLink[]): LayoutResult;
|
|
9
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/ontology/layout.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAcH,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIrD,MAAM,WAAW,YAAY;IACzB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACpD;AAoGD,wBAAgB,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,YAAY,CAwElF"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { ValueTypeOf } from '@elaraai/east';
|
|
2
|
+
import { NodeKindType as EastNodeKindType, LinkKindType as EastLinkKindType, OntologyType as EastOntologyType } from '@elaraai/e3-ui';
|
|
3
|
+
/** JS string-union of every `NodeKindType` variant tag. */
|
|
4
|
+
export type OntologyNodeKind = ValueTypeOf<typeof EastNodeKindType>['type'];
|
|
5
|
+
/** JS string-union of every `LinkKindType` variant tag. */
|
|
6
|
+
export type OntologyLinkKind = ValueTypeOf<typeof EastLinkKindType>['type'];
|
|
7
|
+
/** JS-side shape of an `OntologyType` node carrier. */
|
|
8
|
+
export type OntologyNode = ValueTypeOf<typeof EastOntologyType>['nodes'][number];
|
|
9
|
+
/** JS-side shape of an `OntologyType` link carrier. */
|
|
10
|
+
export type OntologyLink = ValueTypeOf<typeof EastOntologyType>['links'][number];
|
|
11
|
+
/** JS-side shape of an `OntologyType` value. */
|
|
12
|
+
export type Ontology = ValueTypeOf<typeof EastOntologyType>;
|
|
13
|
+
/** Flattened node — variant wrappers stripped to plain strings for the
|
|
14
|
+
* layout + ReactFlow render path. `description` is `string | undefined`
|
|
15
|
+
* (not optional) because `exactOptionalPropertyTypes` in tsconfig forbids
|
|
16
|
+
* assigning `undefined` to an optional property. */
|
|
17
|
+
export interface FlatNode {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
description: string | undefined;
|
|
21
|
+
nodeType: OntologyNodeKind;
|
|
22
|
+
}
|
|
23
|
+
/** Flattened link — kind unwrapped to a plain string. */
|
|
24
|
+
export interface FlatLink {
|
|
25
|
+
id: string;
|
|
26
|
+
source: string;
|
|
27
|
+
target: string;
|
|
28
|
+
linkType: OntologyLinkKind;
|
|
29
|
+
}
|
|
30
|
+
/** Strip the variant wrappers off an ontology value for layout / render.
|
|
31
|
+
* Orphan links (source or target missing from the node set) are dropped. */
|
|
32
|
+
export declare function flattenOntology(ontology: Ontology): {
|
|
33
|
+
nodes: FlatNode[];
|
|
34
|
+
links: FlatLink[];
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Default link kind for a `source → target` node-kind pair, or `null` if
|
|
38
|
+
* no conventional relation exists. Typed as
|
|
39
|
+
* `Record<OntologyNodeKind, Record<OntologyNodeKind, OntologyLinkKind | null>>`
|
|
40
|
+
* — if `NodeKindType` or `LinkKindType` gains a tag, TS flags the missing
|
|
41
|
+
* entries here.
|
|
42
|
+
*/
|
|
43
|
+
export declare const ValidLinks: Record<OntologyNodeKind, Record<OntologyNodeKind, OntologyLinkKind | null>>;
|
|
44
|
+
/** All node kinds in display order. */
|
|
45
|
+
export declare const ALL_NODE_KINDS: OntologyNodeKind[];
|
|
46
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ontology/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EACH,YAAY,IAAI,gBAAgB,EAChC,YAAY,IAAI,gBAAgB,EAChC,YAAY,IAAI,gBAAgB,EACnC,MAAM,gBAAgB,CAAC;AAExB,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE5E,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,uDAAuD;AACvD,MAAM,MAAM,YAAY,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,gDAAgD;AAChD,MAAM,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAE5D;;;qDAGqD;AACrD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;IAChC,QAAQ,EAAE,gBAAgB,CAAC;CAC9B;AAED,yDAAyD;AACzD,MAAM,WAAW,QAAQ;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,gBAAgB,CAAC;CAC9B;AAED;6EAC6E;AAC7E,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG;IAAE,KAAK,EAAE,QAAQ,EAAE,CAAC;IAAC,KAAK,EAAE,QAAQ,EAAE,CAAA;CAAE,CAiB5F;AAED;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB,EAAE,gBAAgB,GAAG,IAAI,CAAC,CAWlG,CAAC;AAEF,uCAAuC;AACvC,eAAO,MAAM,cAAc,EAAE,gBAAgB,EAG5C,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { EastTypeValue, ValueTypeOf, OptionType } from '@elaraai/east';
|
|
2
|
+
import { PlatformFunction } from '@elaraai/east/internal';
|
|
3
|
+
import { DataManifest, DataBindModeLiteral, DataBindModeType } from '@elaraai/e3-ui';
|
|
4
|
+
import { TreePath } from '@elaraai/e3-types';
|
|
5
|
+
import { ReactiveDatasetCacheInterface } from './dataset-store.js';
|
|
6
|
+
import { StagedStoreInterface } from './staged-store.js';
|
|
7
|
+
/**
|
|
8
|
+
* Per-binding metadata the Diff renderer needs to materialize a
|
|
9
|
+
* binding's tree. Keyed by `datasetCacheKey(workspace, sourcePath)`.
|
|
10
|
+
*/
|
|
11
|
+
export interface BindingTypes {
|
|
12
|
+
readonly workspace: string;
|
|
13
|
+
readonly sourceType: EastTypeValue;
|
|
14
|
+
readonly patchType: EastTypeValue;
|
|
15
|
+
readonly mode: DataBindModeLiteral;
|
|
16
|
+
readonly hasPatchDataset: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The struct returned by `Data.bind` — an East-side handle on a
|
|
19
|
+
* dataset binding. JS-side test callers use the same shape. */
|
|
20
|
+
export interface BindHandle {
|
|
21
|
+
read: () => unknown;
|
|
22
|
+
write: (value: unknown) => null;
|
|
23
|
+
writeAndStart: (value: unknown) => null;
|
|
24
|
+
source: () => unknown;
|
|
25
|
+
pending: () => boolean;
|
|
26
|
+
commit: () => null;
|
|
27
|
+
discard: () => null;
|
|
28
|
+
has: () => boolean;
|
|
29
|
+
status: () => unknown;
|
|
30
|
+
binding: {
|
|
31
|
+
source: TreePath;
|
|
32
|
+
patch: ValueTypeOf<OptionType<TreePath>>;
|
|
33
|
+
mode: ValueTypeOf<DataBindModeType>;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A `BindRuntime` owns one set of bind-runtime state: pending writes
|
|
38
|
+
* queue, error listeners, cache singleton, tracking context, and
|
|
39
|
+
* binding-types registry. Exists as an instantiable class so tests can
|
|
40
|
+
* construct an isolated runtime per `describe` rather than wrestling
|
|
41
|
+
* with shared module state. The default process-global runtime is
|
|
42
|
+
* {@link defaultBindRuntime}; production callers continue to use the
|
|
43
|
+
* free-function exports.
|
|
44
|
+
*/
|
|
45
|
+
export declare class BindRuntime {
|
|
46
|
+
private cache;
|
|
47
|
+
private readonly staged;
|
|
48
|
+
private readonly pendingWrites;
|
|
49
|
+
private isProcessingWrites;
|
|
50
|
+
private drainPromise;
|
|
51
|
+
private resolveDrain;
|
|
52
|
+
private readonly writeErrorListeners;
|
|
53
|
+
private trackingContext;
|
|
54
|
+
private readonly bindingRegistry;
|
|
55
|
+
private readonly fallbackWarningEmitted;
|
|
56
|
+
private readonly listCache;
|
|
57
|
+
/**
|
|
58
|
+
* @param staged - The staged store this runtime uses for
|
|
59
|
+
* staged-mode buffers. Defaults to the package singleton.
|
|
60
|
+
*/
|
|
61
|
+
constructor(staged?: StagedStoreInterface);
|
|
62
|
+
/** Read the active cache. Throws if none has been initialized. */
|
|
63
|
+
requireCache(): ReactiveDatasetCacheInterface;
|
|
64
|
+
/** Read the active cache, returning null if not yet initialized. */
|
|
65
|
+
getCache(): ReactiveDatasetCacheInterface | null;
|
|
66
|
+
/** Set the active cache. When the reference changes, drops any
|
|
67
|
+
* leftover queued writes that captured the old cache. Same-cache
|
|
68
|
+
* re-init (Strict Mode double-invoke; HMR) preserves the queue. */
|
|
69
|
+
initializeCache(cache: ReactiveDatasetCacheInterface): void;
|
|
70
|
+
/** Clear the active cache and drop any queued writes. */
|
|
71
|
+
clearCache(): void;
|
|
72
|
+
/** Subscribe to write-queue errors. Returns an unsubscribe fn. */
|
|
73
|
+
onWriteError(cb: (error: unknown) => void): () => void;
|
|
74
|
+
/** Resolve once every currently-queued write has finished
|
|
75
|
+
* (success or failure). Errors are NOT thrown — subscribe via
|
|
76
|
+
* {@link onWriteError} for those. */
|
|
77
|
+
awaitPendingWrites(): Promise<void>;
|
|
78
|
+
/** Drop every queued write without running it. */
|
|
79
|
+
clearPendingWrites(): void;
|
|
80
|
+
/** Queue a write — internal API used by the bind-handle closures. */
|
|
81
|
+
private queueWrite;
|
|
82
|
+
private processWriteQueue;
|
|
83
|
+
enableTracking(): Set<string>;
|
|
84
|
+
disableTracking(): string[];
|
|
85
|
+
isTracking(): boolean;
|
|
86
|
+
trackPath(workspace: string, path: TreePath): void;
|
|
87
|
+
getBindingTypes(workspace: string, sourcePath: TreePath): BindingTypes | undefined;
|
|
88
|
+
/** Clear binding-registry entries. Pass a workspace to clear only
|
|
89
|
+
* that workspace's entries. Match is by stored field, not key
|
|
90
|
+
* prefix — workspace names that share a textual prefix never
|
|
91
|
+
* collide. */
|
|
92
|
+
clearBindingRegistry(workspace?: string): void;
|
|
93
|
+
private registerBindingTypes;
|
|
94
|
+
/**
|
|
95
|
+
* Build a bind handle for a single `(sourcePath, mode, patch?)`
|
|
96
|
+
* triple. Public so tests can call this directly without going
|
|
97
|
+
* through East's compile/dispatch pipeline.
|
|
98
|
+
*
|
|
99
|
+
* @throws `EastError` if the cache is uninitialized, the
|
|
100
|
+
* workspace is not configured, or `allowed` is non-null and any
|
|
101
|
+
* referenced path is not in it.
|
|
102
|
+
*/
|
|
103
|
+
buildBindHandle(sourceType: EastTypeValue, sourcePath: TreePath, patchPath: TreePath | undefined, mode: DataBindModeLiteral, allowed?: ReadonlySet<string>): BindHandle;
|
|
104
|
+
/** Build a `Data.bind` PlatformFunction bound to this runtime.
|
|
105
|
+
* Pass `allowed=null` for an unscoped impl (the global
|
|
106
|
+
* `BindPlatform`); pass a Set for manifest scoping. */
|
|
107
|
+
buildPlatform(allowed: ReadonlySet<string> | null): PlatformFunction;
|
|
108
|
+
preloadList(workspace: string, path: TreePath): Promise<string[]>;
|
|
109
|
+
clearListCache(): void;
|
|
110
|
+
}
|
|
111
|
+
/** Process-global runtime backing the `BindPlatform` export and the
|
|
112
|
+
* free-function helpers. */
|
|
113
|
+
export declare const defaultBindRuntime: BindRuntime;
|
|
114
|
+
/** Read the active cache singleton. Throws if no provider has been mounted. */
|
|
115
|
+
export declare function getReactiveDatasetCache(): ReactiveDatasetCacheInterface;
|
|
116
|
+
/** Set the active cache singleton — called by the React provider on mount. */
|
|
117
|
+
export declare function initializeReactiveDatasetCache(cache: ReactiveDatasetCacheInterface): void;
|
|
118
|
+
/** Clear the active cache singleton — called on unmount or test teardown.
|
|
119
|
+
* Also drops any queued writes that captured the old cache. */
|
|
120
|
+
export declare function clearReactiveDatasetCache(): void;
|
|
121
|
+
export declare function enableBindingTracking(): Set<string>;
|
|
122
|
+
export declare function disableBindingTracking(): string[];
|
|
123
|
+
export declare function isBindingTracking(): boolean;
|
|
124
|
+
export declare function trackDatasetPath(workspace: string, path: TreePath): void;
|
|
125
|
+
export declare function getBindingTypes(workspace: string, sourcePath: TreePath): BindingTypes | undefined;
|
|
126
|
+
export declare function clearBindingRegistry(workspace?: string): void;
|
|
127
|
+
/** Subscribe to write-queue errors. Called once for every failed write. */
|
|
128
|
+
export declare function onWriteError(cb: (error: unknown) => void): () => void;
|
|
129
|
+
/** Resolve once every currently-queued write has finished. */
|
|
130
|
+
export declare function awaitPendingWrites(): Promise<void>;
|
|
131
|
+
/** Drop every queued write without running it. */
|
|
132
|
+
export declare function clearPendingWrites(): void;
|
|
133
|
+
/** Global, manifest-unscoped `Data.bind` impl. Registered on module load. */
|
|
134
|
+
export declare const BindPlatform: PlatformFunction[];
|
|
135
|
+
/** Build a manifest-scoped `Data.bind` implementation. */
|
|
136
|
+
export declare function createScopedBindPlatform(manifest: DataManifest): PlatformFunction[];
|
|
137
|
+
export declare function preloadReactiveDatasetList(workspace: string, path: TreePath): Promise<string[]>;
|
|
138
|
+
export declare function clearReactiveDatasetListCache(): void;
|
|
139
|
+
//# sourceMappingURL=bind-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind-runtime.d.ts","sourceRoot":"","sources":["../../src/platform/bind-runtime.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EACH,KAAK,aAAa,EAclB,KAAK,WAAW,EAChB,UAAU,EACb,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAEH,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,gBAAgB,EACnB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAElD,OAAO,EACH,KAAK,6BAA6B,EAGrC,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEH,KAAK,oBAAoB,EAC5B,MAAM,mBAAmB,CAAC;AAuE3B;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,SAAS,EAAG,MAAM,CA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AAE,QAAQ,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAErG;AACD,wBAAgB,6BAA6B,IAAI,IAAI,CAEpD"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TreePath } from '@elaraai/e3-types';
|
|
3
|
+
import { ReactiveDatasetCacheInterface } from './dataset-store.js';
|
|
4
|
+
/**
|
|
5
|
+
* Props for {@link ReactiveDatasetProvider}.
|
|
6
|
+
*
|
|
7
|
+
* @property children - Subtree that should see the dataset cache.
|
|
8
|
+
*/
|
|
9
|
+
export interface ReactiveDatasetProviderProps {
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Provide a {@link ReactiveDatasetCache} to the component tree.
|
|
14
|
+
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Reads server identity from the surrounding `<E3Provider>` to build a
|
|
17
|
+
* default {@link DatasetApi} adapter, then constructs a workspace-scoped
|
|
18
|
+
* cache. Configures the cache's scheduler to use `queueMicrotask` so
|
|
19
|
+
* cache notifications never fire during a React render pass.
|
|
20
|
+
*
|
|
21
|
+
* Must be mounted inside an `<E3Provider>` (which also owns the
|
|
22
|
+
* `<QueryClientProvider>` wrap that this package's TanStack hooks
|
|
23
|
+
* depend on). Throws otherwise.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```tsx
|
|
27
|
+
* <E3Provider config={{ apiUrl: "http://localhost:3000", workspace: "prod", token }}>
|
|
28
|
+
* <ReactiveDatasetProvider>
|
|
29
|
+
* <MyComponent />
|
|
30
|
+
* </ReactiveDatasetProvider>
|
|
31
|
+
* </E3Provider>
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare function ReactiveDatasetProvider({ children, }: ReactiveDatasetProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
35
|
+
/**
|
|
36
|
+
* Hook to access the ReactiveDatasetCache from context.
|
|
37
|
+
*
|
|
38
|
+
* @returns The ReactiveDatasetCache instance
|
|
39
|
+
* @throws Error if used outside of a ReactiveDatasetProvider
|
|
40
|
+
*/
|
|
41
|
+
export declare function useReactiveDatasetCache(): ReactiveDatasetCacheInterface;
|
|
42
|
+
/**
|
|
43
|
+
* Like {@link useReactiveDatasetCache} but returns `null` instead of throwing
|
|
44
|
+
* when used outside a `<ReactiveDatasetProvider>`. Use this when a component
|
|
45
|
+
* has a graceful fallback (e.g. accepts an explicit config prop too).
|
|
46
|
+
*/
|
|
47
|
+
export declare function useReactiveDatasetCacheOptional(): ReactiveDatasetCacheInterface | null;
|
|
48
|
+
/**
|
|
49
|
+
* Hook to subscribe to reactive dataset cache changes using React 18's useSyncExternalStore.
|
|
50
|
+
*
|
|
51
|
+
* @returns The current snapshot version
|
|
52
|
+
*/
|
|
53
|
+
export declare function useReactiveDatasetCacheSubscription(): number;
|
|
54
|
+
/**
|
|
55
|
+
* Hook to subscribe to a specific reactive dataset key.
|
|
56
|
+
*
|
|
57
|
+
* @param workspace - The workspace name
|
|
58
|
+
* @param path - The dataset path
|
|
59
|
+
* @returns The cached value, or undefined if not loaded
|
|
60
|
+
*/
|
|
61
|
+
export declare function useReactiveDatasetKey(workspace: string, path: TreePath): Uint8Array | undefined;
|
|
62
|
+
/**
|
|
63
|
+
* Reactive dataset to preload.
|
|
64
|
+
*/
|
|
65
|
+
export interface ReactiveDatasetToPreload {
|
|
66
|
+
workspace: string;
|
|
67
|
+
path: TreePath;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Result of usePreloadReactiveDatasets hook.
|
|
71
|
+
*/
|
|
72
|
+
export interface PreloadReactiveDatasetsResult {
|
|
73
|
+
/** True while preloading */
|
|
74
|
+
loading: boolean;
|
|
75
|
+
/** Error if preloading failed */
|
|
76
|
+
error: Error | null;
|
|
77
|
+
/** Reload all datasets */
|
|
78
|
+
reload: () => void;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Hook to preload reactive datasets before rendering.
|
|
82
|
+
*
|
|
83
|
+
* @param datasets - Array of datasets to preload
|
|
84
|
+
* @returns Loading state and error
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* import { variant } from "@elaraai/east";
|
|
89
|
+
*
|
|
90
|
+
* function MyComponent() {
|
|
91
|
+
* const { loading, error } = usePreloadReactiveDatasets([
|
|
92
|
+
* { workspace: "production", path: [variant("field", "inputs"), variant("field", "config")] },
|
|
93
|
+
* { workspace: "production", path: [variant("field", "data")] },
|
|
94
|
+
* ]);
|
|
95
|
+
*
|
|
96
|
+
* if (loading) return <Spinner />;
|
|
97
|
+
* if (error) return <ErrorMessage error={error} />;
|
|
98
|
+
*
|
|
99
|
+
* return <EastComponent render={myApp} />;
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*/
|
|
103
|
+
export declare function usePreloadReactiveDatasets(datasets: ReactiveDatasetToPreload[]): PreloadReactiveDatasetsResult;
|
|
104
|
+
/**
|
|
105
|
+
* Props for the ReactiveDatasetLoader component.
|
|
106
|
+
*/
|
|
107
|
+
export interface ReactiveDatasetLoaderProps {
|
|
108
|
+
/** Datasets to preload */
|
|
109
|
+
datasets: ReactiveDatasetToPreload[];
|
|
110
|
+
/** Children to render when loaded */
|
|
111
|
+
children: ReactNode;
|
|
112
|
+
/** Loading fallback */
|
|
113
|
+
fallback?: ReactNode;
|
|
114
|
+
/** Error render function */
|
|
115
|
+
onError?: (error: Error, reload: () => void) => ReactNode;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Component that preloads reactive datasets before rendering children.
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* ```tsx
|
|
122
|
+
* import { variant } from "@elaraai/east";
|
|
123
|
+
*
|
|
124
|
+
* function App() {
|
|
125
|
+
* return (
|
|
126
|
+
* <ReactiveDatasetProvider config={{ apiUrl: "..." }}>
|
|
127
|
+
* <ReactiveDatasetLoader
|
|
128
|
+
* datasets={[
|
|
129
|
+
* { workspace: "production", path: [variant("field", "config")] }
|
|
130
|
+
* ]}
|
|
131
|
+
* fallback={<Spinner />}
|
|
132
|
+
* onError={(err, reload) => <ErrorWithRetry error={err} onRetry={reload} />}
|
|
133
|
+
* >
|
|
134
|
+
* <EastComponent render={myApp} />
|
|
135
|
+
* </ReactiveDatasetLoader>
|
|
136
|
+
* </ReactiveDatasetProvider>
|
|
137
|
+
* );
|
|
138
|
+
* }
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
export declare function ReactiveDatasetLoader({ datasets, children, fallback, onError, }: ReactiveDatasetLoaderProps): import("react/jsx-runtime").JSX.Element;
|
|
142
|
+
/**
|
|
143
|
+
* Hook to write to a reactive dataset from React code.
|
|
144
|
+
*
|
|
145
|
+
* @returns A function to write to a dataset
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* ```tsx
|
|
149
|
+
* import { encodeBeast2For, IntegerType, variant } from "@elaraai/east";
|
|
150
|
+
*
|
|
151
|
+
* function UpdateButton() {
|
|
152
|
+
* const writeDataset = useReactiveDatasetWrite();
|
|
153
|
+
*
|
|
154
|
+
* const handleUpdate = async () => {
|
|
155
|
+
* await writeDataset(
|
|
156
|
+
* "production",
|
|
157
|
+
* [variant("field", "inputs"), variant("field", "count")],
|
|
158
|
+
* encodeBeast2For(IntegerType)(42n)
|
|
159
|
+
* );
|
|
160
|
+
* };
|
|
161
|
+
*
|
|
162
|
+
* return <button onClick={handleUpdate}>Update</button>;
|
|
163
|
+
* }
|
|
164
|
+
* ```
|
|
165
|
+
*/
|
|
166
|
+
export declare function useReactiveDatasetWrite(): (workspace: string, path: TreePath, value: Uint8Array) => Promise<void>;
|
|
167
|
+
/**
|
|
168
|
+
* Hook to check if a reactive dataset is cached.
|
|
169
|
+
*
|
|
170
|
+
* @param workspace - The workspace name
|
|
171
|
+
* @param path - The dataset path
|
|
172
|
+
* @returns True if the dataset is cached
|
|
173
|
+
*/
|
|
174
|
+
export declare function useReactiveDatasetHas(workspace: string, path: TreePath): boolean;
|
|
175
|
+
//# sourceMappingURL=dataset-hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset-hooks.d.ts","sourceRoot":"","sources":["../../src/platform/dataset-hooks.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;GAIG;AAEH,OAAO,EASH,KAAK,SAAS,EACjB,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAEH,KAAK,6BAA6B,EAGrC,MAAM,oBAAoB,CAAC;AAc5B;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IACzC,QAAQ,EAAE,SAAS,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,EACpC,QAAQ,GACX,EAAE,4BAA4B,2CAiE9B;AAMD;;;;;GAKG;AACH,wBAAgB,uBAAuB,IAAI,6BAA6B,CAMvE;AAED;;;;GAIG;AACH,wBAAgB,+BAA+B,IAAI,6BAA6B,GAAG,IAAI,CAEtF;AAED;;;;GAIG;AACH,wBAAgB,mCAAmC,IAAI,MAAM,CAM5D;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,GAAG,UAAU,GAAG,SAAS,CAc/F;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,6BAA6B;IAC1C,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,iCAAiC;IACjC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,0BAA0B;IAC1B,MAAM,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBA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