lumiverse-spindle-types 0.6.3 → 0.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lumiverse-spindle-types",
3
- "version": "0.6.3",
3
+ "version": "0.6.4",
4
4
  "types": "./src/index.ts",
5
5
  "keywords": [
6
6
  "lumiverse",
package/src/components.ts CHANGED
@@ -22,6 +22,33 @@
22
22
  * Components inherit the active Lumiverse theme via CSS variables, so they
23
23
  * visually match the rest of the host UI without any additional wiring.
24
24
  */
25
+ import type { PromptBlockDTO, PromptVariableValuesDTO } from "./api";
26
+
27
+ // ──────────────────────────────────────────────────────────────────────────
28
+ // Loom block editor
29
+ // ──────────────────────────────────────────────────────────────────────────
30
+
31
+ /** Editable public value rendered by the native Loom block editor. */
32
+ export interface SpindleLoomBlockEditorValue {
33
+ blocks: PromptBlockDTO[];
34
+ promptVariableValues: PromptVariableValuesDTO;
35
+ }
36
+
37
+ /** Controlled options for the native Loom block editor. */
38
+ export interface SpindleLoomBlockEditorOptions {
39
+ value: SpindleLoomBlockEditorValue;
40
+ onChange?: (value: SpindleLoomBlockEditorValue) => void;
41
+ readOnly?: boolean;
42
+ compact?: boolean;
43
+ }
44
+
45
+ /** Handle returned by `mountLoomBlockEditor`. */
46
+ export interface SpindleLoomBlockEditorHandle
47
+ extends SpindleMountedComponent<SpindleLoomBlockEditorOptions> {
48
+ getValue(): SpindleLoomBlockEditorValue;
49
+ refreshMacros(): Promise<void>;
50
+ }
51
+
25
52
 
26
53
  // ──────────────────────────────────────────────────────────────────────────
27
54
  // Shared base shapes
@@ -39,10 +66,7 @@ export interface SpindleMountedComponent<TOptions> {
39
66
  readonly componentId: string;
40
67
  /** The container element the component was mounted into. Same node passed as `target`. */
41
68
  readonly element: HTMLElement;
42
- /**
43
- * Merge a partial set of options into the live component. Pass any subset of
44
- * the original mount options — undefined fields are ignored.
45
- */
69
+ /** Merge supplied option fields into the live component. Omitted fields remain unchanged. */
46
70
  update(patch: Partial<TOptions>): void;
47
71
  /** Unmount the React tree and release host resources. The target element is left in place. */
48
72
  destroy(): void;
@@ -655,4 +679,9 @@ export interface SpindleComponentsHelper {
655
679
  mountCollapsibleSection(target: SpindleComponentTarget, options: SpindleCollapsibleSectionOptions): SpindleCollapsibleSectionHandle;
656
680
  mountPagination(target: SpindleComponentTarget, options: SpindlePaginationOptions): SpindlePaginationHandle;
657
681
  mountCloseButton(target: SpindleComponentTarget, options?: SpindleCloseButtonOptions): SpindleCloseButtonHandle;
682
+ // Loom editor
683
+ mountLoomBlockEditor(
684
+ target: SpindleComponentTarget,
685
+ options: SpindleLoomBlockEditorOptions,
686
+ ): SpindleLoomBlockEditorHandle;
658
687
  }
package/src/index.ts CHANGED
@@ -319,6 +319,9 @@ export type {
319
319
  SpindlePaginationHandle,
320
320
  SpindleCloseButtonOptions,
321
321
  SpindleCloseButtonHandle,
322
+ SpindleLoomBlockEditorValue,
323
+ SpindleLoomBlockEditorOptions,
324
+ SpindleLoomBlockEditorHandle,
322
325
  SpindleComponentsHelper,
323
326
  } from "./components";
324
327
 
@@ -0,0 +1,39 @@
1
+ import type {
2
+ SpindleComponentTarget,
3
+ SpindleComponentsHelper,
4
+ SpindleLoomBlockEditorHandle,
5
+ SpindleLoomBlockEditorOptions,
6
+ SpindleLoomBlockEditorValue,
7
+ } from "lumiverse-spindle-types";
8
+
9
+ /**
10
+ * Package-root consumer fixture: this function is never called at runtime.
11
+ * Its body intentionally exercises the complete controlled Loom editor API so
12
+ * a consumer is checked against the package entry point rather than an
13
+ * internal source module.
14
+ */
15
+ export function compileLoomBlockEditorContract(
16
+ helper: SpindleComponentsHelper,
17
+ target: SpindleComponentTarget,
18
+ options: SpindleLoomBlockEditorOptions,
19
+ ): Promise<void> {
20
+ const handle: SpindleLoomBlockEditorHandle = helper.mountLoomBlockEditor(target, options);
21
+ const initial: SpindleLoomBlockEditorValue = handle.getValue();
22
+
23
+ handle.update({
24
+ value: initial,
25
+ onChange: (next: SpindleLoomBlockEditorValue) => {
26
+ const checked: SpindleLoomBlockEditorValue = next;
27
+ void checked;
28
+ },
29
+ readOnly: !options.readOnly,
30
+ compact: !options.compact,
31
+ });
32
+
33
+ const updated: SpindleLoomBlockEditorValue = handle.getValue();
34
+ const refreshed: Promise<void> = handle.refreshMacros();
35
+ handle.destroy();
36
+
37
+ void updated;
38
+ return refreshed;
39
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "rootDir": ".",
5
+ "outDir": "./.consumer-dist",
6
+ "declaration": false
7
+ },
8
+ "include": ["test/loom-block-editor-consumer.ts"]
9
+ }
package/tsconfig.json CHANGED
@@ -6,7 +6,8 @@
6
6
  "strict": true,
7
7
  "declaration": true,
8
8
  "skipLibCheck": true,
9
- "outDir": "./dist"
9
+ "outDir": "./dist",
10
+ "rootDir": "./src"
10
11
  },
11
12
  "include": ["src"]
12
13
  }