@ultrst-armada/floks 1.4.0 → 1.5.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.
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "packageName": "@ultrst-armada/floks",
4
- "version": "1.4.0",
5
- "sourceCommit": "f5694262a7ac70965397c1bc69e93e460cecd913",
4
+ "version": "1.5.0",
5
+ "sourceCommit": "f044650dce5f4d30e1e4804ad2e06624b29f461f",
6
6
  "releaseWorkflow": "npm Release",
7
- "workflowRunId": "40208603605"
7
+ "workflowRunId": "40212520644"
8
8
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultrst-armada/floks",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -0,0 +1,64 @@
1
+ import React__default from 'react';
2
+
3
+ type UIAuthoringContext = 'service' | 'general-component' | 'application';
4
+ type UIAuthoringNodeKind = 'page' | 'section' | 'component';
5
+ interface AuthoringAssetRef {
6
+ packageId: string;
7
+ packageVersion: string;
8
+ exportPath: string;
9
+ assetId: string;
10
+ assetVersion: string;
11
+ }
12
+ interface UIAuthoringNode {
13
+ id: string;
14
+ kind: UIAuthoringNodeKind;
15
+ name: string;
16
+ componentId?: string;
17
+ assetRef?: AuthoringAssetRef;
18
+ parentId?: string;
19
+ props: Record<string, string | number | boolean>;
20
+ }
21
+ interface UIAuthoringSession {
22
+ sessionId: string;
23
+ context: UIAuthoringContext;
24
+ nodes: UIAuthoringNode[];
25
+ bindings: Array<{
26
+ componentId: string;
27
+ property: string;
28
+ target: {
29
+ kind: string;
30
+ apiId: string;
31
+ field: string;
32
+ fieldType?: string;
33
+ };
34
+ }>;
35
+ operations: Array<{
36
+ operationId: string;
37
+ name: string;
38
+ description?: string;
39
+ }>;
40
+ metadata: Record<string, string>;
41
+ }
42
+
43
+ declare function getAuthoringDepth(node: UIAuthoringNode, nodes: UIAuthoringNode[]): number;
44
+ declare function getAuthoringChildren(nodeId: string, nodes: UIAuthoringNode[]): UIAuthoringNode[];
45
+
46
+ declare function UiAuthoringTree(props: {
47
+ nodes: UIAuthoringNode[];
48
+ selectedNodeId?: string;
49
+ onSelect: (nodeId: string) => void;
50
+ }): React__default.JSX.Element;
51
+
52
+ declare function UiAuthoringInspector(props: {
53
+ node?: UIAuthoringNode;
54
+ onChange: (patch: Partial<UIAuthoringNode>) => void;
55
+ }): React__default.JSX.Element;
56
+
57
+ declare function UiAuthoringWorkspace(props: {
58
+ session: UIAuthoringSession;
59
+ availableAssets: AuthoringAssetRef[];
60
+ onChange: (session: UIAuthoringSession) => void;
61
+ onValidate?: () => void;
62
+ }): React__default.JSX.Element;
63
+
64
+ export { type AuthoringAssetRef, type UIAuthoringContext, type UIAuthoringNode, type UIAuthoringNodeKind, type UIAuthoringSession, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth };
@@ -0,0 +1,14 @@
1
+ import {
2
+ UiAuthoringInspector,
3
+ UiAuthoringTree,
4
+ UiAuthoringWorkspace,
5
+ getAuthoringChildren,
6
+ getAuthoringDepth
7
+ } from "../chunk-MFZKZ76J.js";
8
+ export {
9
+ UiAuthoringInspector,
10
+ UiAuthoringTree,
11
+ UiAuthoringWorkspace,
12
+ getAuthoringChildren,
13
+ getAuthoringDepth
14
+ };
@@ -58,13 +58,28 @@ function MonacoEditor({
58
58
  minimap = false,
59
59
  theme = "skipo-dark",
60
60
  fontSize = 14,
61
+ sessionId,
62
+ uri,
63
+ ideService,
61
64
  onChange,
62
65
  height = "100%",
63
66
  width = "100%"
64
67
  }) {
65
68
  const containerRef = useRef(null);
66
69
  const editorRef = useRef(null);
70
+ const sessionRef = useRef(sessionId);
67
71
  const monaco = useMonaco();
72
+ const service = ideService || { execute: async () => void 0 };
73
+ useEffect2(() => {
74
+ if (!sessionRef.current) sessionRef.current = sessionId || `editor-${Date.now().toString(36)}`;
75
+ void service.execute("createSession", {
76
+ sessionId: sessionRef.current,
77
+ uri: uri || `inmemory://${sessionRef.current}`,
78
+ language,
79
+ value,
80
+ options: { readOnly, minimap, fontSize }
81
+ });
82
+ }, []);
68
83
  useEffect2(() => {
69
84
  if (!monaco || !containerRef.current) return;
70
85
  if (!editorRef.current) {
@@ -79,11 +94,15 @@ function MonacoEditor({
79
94
  scrollBeyondLastLine: false,
80
95
  padding: { top: 16, bottom: 16 }
81
96
  });
82
- if (onChange) {
83
- editorRef.current.onDidChangeModelContent(() => {
84
- onChange(editorRef.current.getValue());
97
+ editorRef.current.onDidChangeModelContent(() => {
98
+ const nextValue = editorRef.current.getValue();
99
+ void service.execute("updateDocument", {
100
+ sessionId: sessionRef.current,
101
+ value: nextValue,
102
+ language
85
103
  });
86
- }
104
+ onChange?.(nextValue);
105
+ });
87
106
  }
88
107
  return () => {
89
108
  if (editorRef.current) {
@@ -93,15 +112,18 @@ function MonacoEditor({
93
112
  };
94
113
  }, [monaco]);
95
114
  useEffect2(() => {
96
- if (editorRef.current && value !== editorRef.current.getValue()) {
97
- editorRef.current.setValue(value);
98
- }
115
+ if (editorRef.current && value !== editorRef.current.getValue()) editorRef.current.setValue(value);
99
116
  }, [value]);
100
117
  useEffect2(() => {
101
- if (editorRef.current) {
102
- monaco?.editor.setModelLanguage(editorRef.current.getModel(), language);
103
- editorRef.current.updateOptions({ readOnly, fontSize, minimap: { enabled: minimap } });
104
- if (theme) monaco?.editor.setTheme(theme);
118
+ if (!editorRef.current) return;
119
+ monaco?.editor.setModelLanguage(editorRef.current.getModel(), language);
120
+ editorRef.current.updateOptions({ readOnly, fontSize, minimap: { enabled: minimap } });
121
+ if (theme) monaco?.editor.setTheme(theme);
122
+ if (sessionRef.current) {
123
+ void service.execute("setOptions", {
124
+ sessionId: sessionRef.current,
125
+ options: { readOnly, minimap, fontSize }
126
+ });
105
127
  }
106
128
  }, [language, readOnly, fontSize, minimap, theme, monaco]);
107
129
  return /* @__PURE__ */ jsx("div", { ref: containerRef, style: { width, height, overflow: "hidden", borderRadius: "8px" } });
@@ -0,0 +1,136 @@
1
+ // src/authoring/authoringModel.ts
2
+ function getAuthoringDepth(node, nodes) {
3
+ let depth = 0;
4
+ let parentId = node.parentId;
5
+ while (parentId) {
6
+ const parent = nodes.find((item) => item.id === parentId);
7
+ if (!parent) break;
8
+ depth += 1;
9
+ parentId = parent.parentId;
10
+ }
11
+ return depth;
12
+ }
13
+ function getAuthoringChildren(nodeId, nodes) {
14
+ return nodes.filter((node) => node.parentId === nodeId);
15
+ }
16
+
17
+ // src/authoring/UiAuthoringTree.tsx
18
+ import { jsx, jsxs } from "react/jsx-runtime";
19
+ function UiAuthoringTree(props) {
20
+ return /* @__PURE__ */ jsxs("div", { className: "min-h-0 flex-1 overflow-auto", children: [
21
+ props.nodes.map((node) => /* @__PURE__ */ jsxs(
22
+ "button",
23
+ {
24
+ type: "button",
25
+ onClick: () => props.onSelect(node.id),
26
+ className: `flex w-full items-center gap-2 border-b border-black/10 px-2 py-1.5 text-left text-xs ${props.selectedNodeId === node.id ? "bg-black/10" : ""}`,
27
+ style: { paddingLeft: 8 + getAuthoringDepth(node, props.nodes) * 14 },
28
+ children: [
29
+ /* @__PURE__ */ jsx("span", { className: "font-semibold", children: node.name }),
30
+ /* @__PURE__ */ jsx("span", { className: "ml-auto opacity-50", children: node.kind })
31
+ ]
32
+ },
33
+ node.id
34
+ )),
35
+ !props.nodes.length && /* @__PURE__ */ jsx("div", { className: "p-4 text-xs opacity-60", children: "No authored nodes." })
36
+ ] });
37
+ }
38
+
39
+ // src/authoring/UiAuthoringInspector.tsx
40
+ import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
41
+ function UiAuthoringInspector(props) {
42
+ if (!props.node) return /* @__PURE__ */ jsx2("aside", { className: "w-72 border-l border-black/10 p-3 text-xs opacity-60", children: "Select a node." });
43
+ const description = String(props.node.props.description || "");
44
+ return /* @__PURE__ */ jsxs2("aside", { className: "w-72 border-l border-black/10 p-3", children: [
45
+ /* @__PURE__ */ jsx2("div", { className: "mb-3 text-xs font-bold uppercase tracking-wide", children: props.node.kind }),
46
+ /* @__PURE__ */ jsxs2("label", { className: "block text-xs", children: [
47
+ "Name",
48
+ /* @__PURE__ */ jsx2("input", { className: "mt-1 w-full rounded border px-2 py-1.5", value: props.node.name, onChange: (e) => props.onChange({ name: e.target.value }) })
49
+ ] }),
50
+ /* @__PURE__ */ jsxs2("label", { className: "mt-3 block text-xs", children: [
51
+ "Description",
52
+ /* @__PURE__ */ jsx2("textarea", { className: "mt-1 min-h-20 w-full rounded border px-2 py-1.5", value: description, onChange: (e) => props.onChange({ props: { ...props.node?.props, description: e.target.value } }) })
53
+ ] })
54
+ ] });
55
+ }
56
+
57
+ // src/authoring/UiAuthoringWorkspace.tsx
58
+ import React from "react";
59
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
60
+ function UiAuthoringWorkspace(props) {
61
+ const [selectedNodeId, setSelectedNodeId] = React.useState();
62
+ const selectedNode = props.session.nodes.find((node) => node.id === selectedNodeId);
63
+ const addNode = (kind, assetRef) => {
64
+ const parent = kind === "section" ? props.session.nodes.find((node2) => node2.kind === "page") : kind === "component" ? props.session.nodes.find((node2) => node2.kind === "section") : void 0;
65
+ const node = {
66
+ id: `authoring-${kind}-${Date.now().toString(36)}`,
67
+ kind,
68
+ name: kind === "component" ? assetRef?.assetId || "Component" : kind[0].toUpperCase() + kind.slice(1),
69
+ componentId: kind === "component" ? assetRef?.assetId : void 0,
70
+ assetRef,
71
+ parentId: parent?.id,
72
+ props: {}
73
+ };
74
+ props.onChange({ ...props.session, nodes: [...props.session.nodes, node] });
75
+ setSelectedNodeId(node.id);
76
+ };
77
+ const updateSelected = (patch) => {
78
+ if (!selectedNode) return;
79
+ props.onChange({
80
+ ...props.session,
81
+ nodes: props.session.nodes.map((node) => node.id === selectedNode.id ? { ...node, ...patch } : node)
82
+ });
83
+ };
84
+ const removeSelected = () => {
85
+ if (!selectedNode) return;
86
+ props.onChange({
87
+ ...props.session,
88
+ nodes: props.session.nodes.filter((node) => node.id !== selectedNode.id && node.parentId !== selectedNode.id)
89
+ });
90
+ setSelectedNodeId(void 0);
91
+ };
92
+ const contextLabel = {
93
+ service: "Service UI",
94
+ "general-component": "General Component",
95
+ application: "Application UI"
96
+ };
97
+ return /* @__PURE__ */ jsxs3("section", { className: "flex h-full min-h-0 flex-col overflow-hidden border border-black/10 bg-white", children: [
98
+ /* @__PURE__ */ jsxs3("header", { className: "flex shrink-0 items-center gap-2 border-b border-black/10 px-3 py-2", children: [
99
+ /* @__PURE__ */ jsxs3("strong", { className: "text-xs", children: [
100
+ contextLabel[props.session.context],
101
+ " Authoring"
102
+ ] }),
103
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => addNode("page"), className: "rounded border px-2 py-1 text-xs", children: "Page" }),
104
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: () => addNode("section"), className: "rounded border px-2 py-1 text-xs", children: "Section" }),
105
+ /* @__PURE__ */ jsxs3(
106
+ "select",
107
+ {
108
+ className: "rounded border px-2 py-1 text-xs",
109
+ value: "",
110
+ onChange: (e) => {
111
+ const asset = props.availableAssets.find((item) => item.assetId === e.target.value);
112
+ if (asset) addNode("component", asset);
113
+ },
114
+ children: [
115
+ /* @__PURE__ */ jsx3("option", { value: "", children: "Add component\u2026" }),
116
+ props.availableAssets.map((asset) => /* @__PURE__ */ jsx3("option", { value: asset.assetId, children: asset.assetId }, asset.assetId))
117
+ ]
118
+ }
119
+ ),
120
+ /* @__PURE__ */ jsx3("button", { type: "button", disabled: !selectedNode, onClick: removeSelected, className: "ml-auto rounded border px-2 py-1 text-xs disabled:opacity-40", children: "Remove" }),
121
+ /* @__PURE__ */ jsx3("button", { type: "button", onClick: props.onValidate, className: "rounded border px-2 py-1 text-xs", children: "Validate" })
122
+ ] }),
123
+ /* @__PURE__ */ jsxs3("div", { className: "flex min-h-0 flex-1", children: [
124
+ /* @__PURE__ */ jsx3(UiAuthoringTree, { nodes: props.session.nodes, selectedNodeId, onSelect: setSelectedNodeId }),
125
+ /* @__PURE__ */ jsx3(UiAuthoringInspector, { node: selectedNode, onChange: updateSelected })
126
+ ] })
127
+ ] });
128
+ }
129
+
130
+ export {
131
+ getAuthoringDepth,
132
+ getAuthoringChildren,
133
+ UiAuthoringTree,
134
+ UiAuthoringInspector,
135
+ UiAuthoringWorkspace
136
+ };
@@ -34,11 +34,17 @@ declare const skipoDarkTheme: {
34
34
 
35
35
  declare function useMonaco(): any;
36
36
 
37
+ interface MonacoIdeServicePort {
38
+ execute<TIn = unknown, TOut = unknown>(operation: string, input?: TIn): Promise<TOut>;
39
+ }
37
40
  interface MonacoEditorProps extends EditorConfig {
41
+ sessionId?: string;
42
+ uri?: string;
43
+ ideService?: MonacoIdeServicePort;
38
44
  onChange?: (value: string) => void;
39
45
  height?: string | number;
40
46
  width?: string | number;
41
47
  }
42
- declare function MonacoEditor({ value, language, readOnly, minimap, theme, fontSize, onChange, height, width }: MonacoEditorProps): React.JSX.Element;
48
+ declare function MonacoEditor({ value, language, readOnly, minimap, theme, fontSize, sessionId, uri, ideService, onChange, height, width, }: MonacoEditorProps): React.JSX.Element;
43
49
 
44
- export { type EditorConfig, MonacoEditor, skipoDarkTheme, useMonaco };
50
+ export { type EditorConfig, MonacoEditor, type MonacoEditorProps, type MonacoIdeServicePort, skipoDarkTheme, useMonaco };
@@ -2,7 +2,7 @@ import {
2
2
  MonacoEditor,
3
3
  skipoDarkTheme,
4
4
  useMonaco
5
- } from "../chunk-QTTWWBNN.js";
5
+ } from "../chunk-46UQIH47.js";
6
6
  export {
7
7
  MonacoEditor,
8
8
  skipoDarkTheme,
@@ -1,7 +1,7 @@
1
1
  export { CanvasItem, CanvasViewport, InfiniteCanvas, MiniMap, Transform, useCanvas } from './canvas/index.js';
2
2
  export { DockBar, DockItem, DockItemConfig, DockPosition, useDock } from './dock/index.js';
3
3
  export { Tile, TileAction, TileConfig, TileCreateButton, TileGrid, useTileMenu } from './tile-menu/index.js';
4
- export { EditorConfig, MonacoEditor, skipoDarkTheme, useMonaco } from './editor/index.js';
4
+ export { EditorConfig, MonacoEditor, MonacoEditorProps, MonacoIdeServicePort, skipoDarkTheme, useMonaco } from './editor/index.js';
5
5
  import * as React from 'react';
6
6
  import React__default from 'react';
7
7
  import { NodeDefinition, GraphSettings, Socket, GraphNode } from '@ultrst-armada/kloks/state-graph';
@@ -10,6 +10,7 @@ export { FrnlEditableNodeGraph, FrnlEditableNodeGraphProps, frnlEditableNodeGrap
10
10
  export { B as BIOME_CONFIGS, C as COORD_SCALE, a as CameraState, b as Canvas2DViewerProps, c as ConnectingWireState } from './types-D3RRfQUo.js';
11
11
  export { CanvasBackground2D, CanvasErrorBoundary, ContainerNode2D, EffectNode2D, MagneticTraces2D, ModuleNode2D, NODE_CARD_WIDTH, Node2DBase, Node2DBaseProps, NodeRenderer2D, NodeRenderer2DProps, RecorderWaveformDisplay, RecorderWaveformDisplayProps, RotaryKnob, RotaryKnobProps, SOCKET_ROW_HEIGHT, Socket2D, Socket2DProps, SocketScreenPosition, TriggerNode2D, Wire2D, Wire2DProps, getSocketLocalOffset, getSocketScreenPosition, renderSpriteIcon, useCanvas2DCoordinates, useCanvas2DMagnetic } from './graph-2d/index.js';
12
12
  export { PredictiveGhostNodeCard, PredictiveGhostNodeCardProps, PredictiveHudToolbar, PredictiveLayer2D, PredictiveLayer2DProps, UsePredictiveGraph2DProps, UseViewer2DPredictiveProps, usePredictiveGraph2D } from './predictive/index.js';
13
+ export { AuthoringAssetRef, UIAuthoringContext, UIAuthoringNode, UIAuthoringNodeKind, UIAuthoringSession, UiAuthoringInspector, UiAuthoringTree, UiAuthoringWorkspace, getAuthoringChildren, getAuthoringDepth } from './authoring/index.js';
13
14
 
14
15
  interface MidpointWidgetsProps {
15
16
  x: number;
@@ -1,3 +1,16 @@
1
+ import {
2
+ Tile,
3
+ TileCreateButton,
4
+ TileGrid,
5
+ useTileMenu
6
+ } from "./chunk-SA3JADUG.js";
7
+ import {
8
+ UiAuthoringInspector,
9
+ UiAuthoringTree,
10
+ UiAuthoringWorkspace,
11
+ getAuthoringChildren,
12
+ getAuthoringDepth
13
+ } from "./chunk-MFZKZ76J.js";
1
14
  import {
2
15
  CanvasViewport,
3
16
  InfiniteCanvas,
@@ -13,7 +26,7 @@ import {
13
26
  MonacoEditor,
14
27
  skipoDarkTheme,
15
28
  useMonaco
16
- } from "./chunk-QTTWWBNN.js";
29
+ } from "./chunk-46UQIH47.js";
17
30
  import {
18
31
  CanvasContextMenu,
19
32
  CompatibleNodePicker,
@@ -57,12 +70,6 @@ import {
57
70
  getSocketScreenPosition,
58
71
  renderSpriteIcon
59
72
  } from "./chunk-U2SC3RMJ.js";
60
- import {
61
- Tile,
62
- TileCreateButton,
63
- TileGrid,
64
- useTileMenu
65
- } from "./chunk-SA3JADUG.js";
66
73
 
67
74
  // src/node-graph-ui/widgets/MidpointWidgets.tsx
68
75
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
@@ -730,9 +737,14 @@ export {
730
737
  TileCreateButton,
731
738
  TileGrid,
732
739
  TriggerNode2D,
740
+ UiAuthoringInspector,
741
+ UiAuthoringTree,
742
+ UiAuthoringWorkspace,
733
743
  Viewer2DNodes,
734
744
  Wire2D,
735
745
  frnlEditableNodeGraphDefinition,
746
+ getAuthoringChildren,
747
+ getAuthoringDepth,
736
748
  getSocketLocalOffset,
737
749
  getSocketScreenPosition,
738
750
  menuCategory,
@@ -52,10 +52,15 @@
52
52
  "import": "./dist/frnl-editable-node-graph/index.js",
53
53
  "types": "./dist/frnl-editable-node-graph/index.d.ts",
54
54
  "default": "./dist/frnl-editable-node-graph/index.js"
55
+ },
56
+ "./authoring": {
57
+ "import": "./dist/authoring/index.js",
58
+ "types": "./dist/authoring/index.d.ts",
59
+ "default": "./dist/authoring/index.js"
55
60
  }
56
61
  },
57
62
  "scripts": {
58
- "build": "tsup src/index.ts src/canvas/index.ts src/dock/index.ts src/tile-menu/index.ts src/editor/index.ts src/graph-2d/index.ts src/predictive/index.ts src/frnl-editable-node-graph/index.ts --format esm --dts --clean --external react --external react-dom --external lucide-react --external @floks/ui --external @ultrst-armada/frnlts --external @kloks/state-graph --external @kloks/audio-midi --external monaco-editor --external @dnd-kit/core --external @dnd-kit/sortable --external @dnd-kit/utilities"
63
+ "build": "tsup src/index.ts src/canvas/index.ts src/dock/index.ts src/tile-menu/index.ts src/editor/index.ts src/authoring/index.ts src/graph-2d/index.ts src/predictive/index.ts src/frnl-editable-node-graph/index.ts --format esm --dts --clean --external react --external react-dom --external lucide-react --external @floks/ui --external @ultrst-armada/frnlts --external @kloks/state-graph --external @kloks/audio-midi --external monaco-editor --external @dnd-kit/core --external @dnd-kit/sortable --external @dnd-kit/utilities"
59
64
  },
60
65
  "dependencies": {
61
66
  "@floks/ui": "workspace:*",
@@ -67,7 +72,8 @@
67
72
  "@dnd-kit/sortable": "^8.0.0 || ^9.0.0",
68
73
  "@dnd-kit/utilities": "^3.0.0",
69
74
  "monaco-editor": "^0.50.0",
70
- "react": "^18.0.0 || ^19.0.0"
75
+ "react": "^18.0.0 || ^19.0.0",
76
+ "@ultrst-armada/kloks": "^1.0.2 || ^1.4.0"
71
77
  },
72
78
  "peerDependenciesMeta": {
73
79
  "@dnd-kit/core": {