@almadar/ui 6.8.0 → 6.9.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.
@@ -9,23 +9,50 @@ import { ClassValue } from 'clsx';
9
9
  * E2); this module only computes offsets and text.
10
10
  *
11
11
  * Caret convention: an integer offset in `[0, text.length]`, a gap position
12
- * (matches `textarea.selectionStart`) — except `word-end` and `line-end`,
13
- * which land ON the index of their target character (vim's `e`/`$` block-
14
- * cursor convention), so `motionRange` widens those by one to make an
15
- * operator's range inclusive of that char.
12
+ * (matches `textarea.selectionStart`) — except `word-end`, `line-end` and
13
+ * `match-bracket`, which land ON the index of their target character (vim's
14
+ * `e`/`$`/`%` block-cursor convention), so `motionRange` widens those by one
15
+ * to make an operator's range inclusive of that char.
16
+ *
17
+ * `EDITOR_MOTIONS` / `EDITOR_OPERATORS` are the single source of truth for
18
+ * the closed vocabularies — `CodeBlock.tsx`'s `motions`/`operators` prop
19
+ * defaults must list the same members (kept as JSON literals there for the
20
+ * pattern-registry parser; `test/CodeBlock.editable.test.tsx` asserts they
21
+ * stay in sync).
16
22
  */
17
- type EditorMotion = 'left' | 'right' | 'up' | 'down' | 'word-forward' | 'word-back' | 'word-end' | 'line-start' | 'line-end' | 'first-nonblank' | 'doc-start' | 'doc-end' | 'paragraph-forward' | 'paragraph-back' | 'line' | 'selection';
18
- type EditorOperator = 'delete' | 'yank' | 'change';
23
+ declare const EDITOR_MOTIONS: readonly ["left", "right", "up", "down", "word-forward", "word-back", "word-end", "line-start", "line-end", "first-nonblank", "doc-start", "doc-end", "paragraph-forward", "paragraph-back", "line", "selection", "match-bracket"];
24
+ type EditorMotion = (typeof EDITOR_MOTIONS)[number];
25
+ declare const EDITOR_OPERATORS: readonly ["delete", "yank", "change", "put", "put-before", "undo", "redo", "join", "toggle-case", "indent", "dedent", "replace"];
26
+ type EditorOperator = (typeof EDITOR_OPERATORS)[number];
27
+ declare function isEditorMotion(value: string): value is EditorMotion;
28
+ declare function isEditorOperator(value: string): value is EditorOperator;
29
+ /** Fixed indent unit for the `indent`/`dedent` operators (two spaces). */
30
+ declare const INDENT_UNIT = " ";
19
31
  /** New caret offset after applying `motion` `count` times. `line`/`selection` are range-only — caret is unchanged. */
20
32
  declare function applyMotion(text: string, caret: number, motion: EditorMotion, count: number): number;
21
33
  /** The `[start, end)` range an operator acts on for `motion`. */
22
34
  declare function motionRange(text: string, caret: number, motion: EditorMotion, count: number, selection?: [number, number]): [number, number];
23
- /** Apply `operator` over `range`. `delete`/`change` remove and store; `yank` only stores. */
24
- declare function applyOperator(text: string, range: [number, number], operator: EditorOperator, register: string): {
35
+ interface ApplyOperatorInput {
25
36
  text: string;
37
+ /** `textarea.selectionStart` at the time the operator fired — the anchor for caret-based operators (put/put-before/join) that don't act over `range`. */
26
38
  caret: number;
39
+ /** The `[start, end)` range from `motionRange` — the anchor for range-based operators (delete/yank/change/toggle-case/indent/dedent/replace). */
40
+ range: [number, number];
41
+ operator: EditorOperator;
42
+ /** The motion paired with this operator. `change` special-cases `line`; delete/yank/change use it to set the returned `registerLinewise`. */
43
+ motion: EditorMotion;
44
+ count: number;
27
45
  register: string;
28
- };
46
+ registerLinewise: boolean;
47
+ }
48
+ interface ApplyOperatorResult {
49
+ text: string;
50
+ caret: number;
51
+ register: string;
52
+ registerLinewise: boolean;
53
+ }
54
+ /** Apply `operator`. `undo`/`redo` never reach here — they're history-stack operations handled by `useEditorCapabilities`. */
55
+ declare function applyOperator(input: ApplyOperatorInput): ApplyOperatorResult;
29
56
 
30
57
  /**
31
58
  * Content Segment Parsing Utilities
@@ -400,4 +427,4 @@ declare function clearVerification(): void;
400
427
  */
401
428
  declare function cn(...inputs: ClassValue[]): string;
402
429
 
403
- export { type BloomLevel as $, getTraitSnapshots as A, getTransitions as B, type ContentSegment as C, DEFAULT_CONFIG as D, type EditorMotion as E, getTransitionsForTrait as F, motionRange as G, parseContentSegments as H, parseLessonSegments as I, parseMarkdownWithCodeBlocks$1 as J, recordServerResponse as K, type LessonSegment as L, recordTransition as M, registerCheck as N, registerTraitSnapshot as O, renderStateMachineToDomData as P, renderStateMachineToSvg as Q, type RenderOptions as R, type StateDefinition as S, type TraitSnapshotGetter as T, subscribeToVerification as U, type VisualizerConfig as V, updateAssetStatus as W, updateBridgeHealth as X, updateCheck as Y, waitForTransition as Z, type InteractiveOrbitalType as _, type DomEntityBox as a, BloomQuizBlock as a0, type BloomQuizBlockProps as a1, type MixedSegment as a2, parseMarkdownWithCodeBlocks as a3, type DomLayoutData as b, type DomOutputsBox as c, type DomStateNode as d, type DomTransitionLabel as e, type DomTransitionPath as f, type EditorOperator as g, type EntityDefinition as h, type StateMachineDefinition as i, type TransitionDefinition as j, applyMotion as k, applyOperator as l, bindCanvasCapture as m, bindEventBus as n, bindLastDrawables as o, bindTraitStateGetter as p, clearVerification as q, cn as r, extractOutputsFromTransitions as s, extractStateMachine as t, formatGuard as u, getAllChecks as v, getBridgeHealth as w, getEffectSummary as x, getSnapshot as y, getSummary as z };
430
+ export { renderStateMachineToSvg as $, type ApplyOperatorInput as A, getEffectSummary as B, type ContentSegment as C, DEFAULT_CONFIG as D, EDITOR_MOTIONS as E, getSnapshot as F, getSummary as G, getTraitSnapshots as H, INDENT_UNIT as I, getTransitions as J, getTransitionsForTrait as K, type LessonSegment as L, isEditorMotion as M, isEditorOperator as N, motionRange as O, parseContentSegments as P, parseLessonSegments as Q, type RenderOptions as R, type StateDefinition as S, type TraitSnapshotGetter as T, parseMarkdownWithCodeBlocks$1 as U, type VisualizerConfig as V, recordServerResponse as W, recordTransition as X, registerCheck as Y, registerTraitSnapshot as Z, renderStateMachineToDomData as _, type ApplyOperatorResult as a, subscribeToVerification as a0, updateAssetStatus as a1, updateBridgeHealth as a2, updateCheck as a3, waitForTransition as a4, type InteractiveOrbitalType as a5, type BloomLevel as a6, BloomQuizBlock as a7, type BloomQuizBlockProps as a8, type MixedSegment as a9, parseMarkdownWithCodeBlocks as aa, type DomEntityBox as b, type DomLayoutData as c, type DomOutputsBox as d, type DomStateNode as e, type DomTransitionLabel as f, type DomTransitionPath as g, EDITOR_OPERATORS as h, type EditorMotion as i, type EditorOperator as j, type EntityDefinition as k, type StateMachineDefinition as l, type TransitionDefinition as m, applyMotion as n, applyOperator as o, bindCanvasCapture as p, bindEventBus as q, bindLastDrawables as r, bindTraitStateGetter as s, clearVerification as t, cn as u, extractOutputsFromTransitions as v, extractStateMachine as w, formatGuard as x, getAllChecks as y, getBridgeHealth as z };
@@ -9,23 +9,50 @@ import { ClassValue } from 'clsx';
9
9
  * E2); this module only computes offsets and text.
10
10
  *
11
11
  * Caret convention: an integer offset in `[0, text.length]`, a gap position
12
- * (matches `textarea.selectionStart`) — except `word-end` and `line-end`,
13
- * which land ON the index of their target character (vim's `e`/`$` block-
14
- * cursor convention), so `motionRange` widens those by one to make an
15
- * operator's range inclusive of that char.
12
+ * (matches `textarea.selectionStart`) — except `word-end`, `line-end` and
13
+ * `match-bracket`, which land ON the index of their target character (vim's
14
+ * `e`/`$`/`%` block-cursor convention), so `motionRange` widens those by one
15
+ * to make an operator's range inclusive of that char.
16
+ *
17
+ * `EDITOR_MOTIONS` / `EDITOR_OPERATORS` are the single source of truth for
18
+ * the closed vocabularies — `CodeBlock.tsx`'s `motions`/`operators` prop
19
+ * defaults must list the same members (kept as JSON literals there for the
20
+ * pattern-registry parser; `test/CodeBlock.editable.test.tsx` asserts they
21
+ * stay in sync).
16
22
  */
17
- type EditorMotion = 'left' | 'right' | 'up' | 'down' | 'word-forward' | 'word-back' | 'word-end' | 'line-start' | 'line-end' | 'first-nonblank' | 'doc-start' | 'doc-end' | 'paragraph-forward' | 'paragraph-back' | 'line' | 'selection';
18
- type EditorOperator = 'delete' | 'yank' | 'change';
23
+ declare const EDITOR_MOTIONS: readonly ["left", "right", "up", "down", "word-forward", "word-back", "word-end", "line-start", "line-end", "first-nonblank", "doc-start", "doc-end", "paragraph-forward", "paragraph-back", "line", "selection", "match-bracket"];
24
+ type EditorMotion = (typeof EDITOR_MOTIONS)[number];
25
+ declare const EDITOR_OPERATORS: readonly ["delete", "yank", "change", "put", "put-before", "undo", "redo", "join", "toggle-case", "indent", "dedent", "replace"];
26
+ type EditorOperator = (typeof EDITOR_OPERATORS)[number];
27
+ declare function isEditorMotion(value: string): value is EditorMotion;
28
+ declare function isEditorOperator(value: string): value is EditorOperator;
29
+ /** Fixed indent unit for the `indent`/`dedent` operators (two spaces). */
30
+ declare const INDENT_UNIT = " ";
19
31
  /** New caret offset after applying `motion` `count` times. `line`/`selection` are range-only — caret is unchanged. */
20
32
  declare function applyMotion(text: string, caret: number, motion: EditorMotion, count: number): number;
21
33
  /** The `[start, end)` range an operator acts on for `motion`. */
22
34
  declare function motionRange(text: string, caret: number, motion: EditorMotion, count: number, selection?: [number, number]): [number, number];
23
- /** Apply `operator` over `range`. `delete`/`change` remove and store; `yank` only stores. */
24
- declare function applyOperator(text: string, range: [number, number], operator: EditorOperator, register: string): {
35
+ interface ApplyOperatorInput {
25
36
  text: string;
37
+ /** `textarea.selectionStart` at the time the operator fired — the anchor for caret-based operators (put/put-before/join) that don't act over `range`. */
26
38
  caret: number;
39
+ /** The `[start, end)` range from `motionRange` — the anchor for range-based operators (delete/yank/change/toggle-case/indent/dedent/replace). */
40
+ range: [number, number];
41
+ operator: EditorOperator;
42
+ /** The motion paired with this operator. `change` special-cases `line`; delete/yank/change use it to set the returned `registerLinewise`. */
43
+ motion: EditorMotion;
44
+ count: number;
27
45
  register: string;
28
- };
46
+ registerLinewise: boolean;
47
+ }
48
+ interface ApplyOperatorResult {
49
+ text: string;
50
+ caret: number;
51
+ register: string;
52
+ registerLinewise: boolean;
53
+ }
54
+ /** Apply `operator`. `undo`/`redo` never reach here — they're history-stack operations handled by `useEditorCapabilities`. */
55
+ declare function applyOperator(input: ApplyOperatorInput): ApplyOperatorResult;
29
56
 
30
57
  /**
31
58
  * Content Segment Parsing Utilities
@@ -400,4 +427,4 @@ declare function clearVerification(): void;
400
427
  */
401
428
  declare function cn(...inputs: ClassValue[]): string;
402
429
 
403
- export { type BloomLevel as $, getTraitSnapshots as A, getTransitions as B, type ContentSegment as C, DEFAULT_CONFIG as D, type EditorMotion as E, getTransitionsForTrait as F, motionRange as G, parseContentSegments as H, parseLessonSegments as I, parseMarkdownWithCodeBlocks$1 as J, recordServerResponse as K, type LessonSegment as L, recordTransition as M, registerCheck as N, registerTraitSnapshot as O, renderStateMachineToDomData as P, renderStateMachineToSvg as Q, type RenderOptions as R, type StateDefinition as S, type TraitSnapshotGetter as T, subscribeToVerification as U, type VisualizerConfig as V, updateAssetStatus as W, updateBridgeHealth as X, updateCheck as Y, waitForTransition as Z, type InteractiveOrbitalType as _, type DomEntityBox as a, BloomQuizBlock as a0, type BloomQuizBlockProps as a1, type MixedSegment as a2, parseMarkdownWithCodeBlocks as a3, type DomLayoutData as b, type DomOutputsBox as c, type DomStateNode as d, type DomTransitionLabel as e, type DomTransitionPath as f, type EditorOperator as g, type EntityDefinition as h, type StateMachineDefinition as i, type TransitionDefinition as j, applyMotion as k, applyOperator as l, bindCanvasCapture as m, bindEventBus as n, bindLastDrawables as o, bindTraitStateGetter as p, clearVerification as q, cn as r, extractOutputsFromTransitions as s, extractStateMachine as t, formatGuard as u, getAllChecks as v, getBridgeHealth as w, getEffectSummary as x, getSnapshot as y, getSummary as z };
430
+ export { renderStateMachineToSvg as $, type ApplyOperatorInput as A, getEffectSummary as B, type ContentSegment as C, DEFAULT_CONFIG as D, EDITOR_MOTIONS as E, getSnapshot as F, getSummary as G, getTraitSnapshots as H, INDENT_UNIT as I, getTransitions as J, getTransitionsForTrait as K, type LessonSegment as L, isEditorMotion as M, isEditorOperator as N, motionRange as O, parseContentSegments as P, parseLessonSegments as Q, type RenderOptions as R, type StateDefinition as S, type TraitSnapshotGetter as T, parseMarkdownWithCodeBlocks$1 as U, type VisualizerConfig as V, recordServerResponse as W, recordTransition as X, registerCheck as Y, registerTraitSnapshot as Z, renderStateMachineToDomData as _, type ApplyOperatorResult as a, subscribeToVerification as a0, updateAssetStatus as a1, updateBridgeHealth as a2, updateCheck as a3, waitForTransition as a4, type InteractiveOrbitalType as a5, type BloomLevel as a6, BloomQuizBlock as a7, type BloomQuizBlockProps as a8, type MixedSegment as a9, parseMarkdownWithCodeBlocks as aa, type DomEntityBox as b, type DomLayoutData as c, type DomOutputsBox as d, type DomStateNode as e, type DomTransitionLabel as f, type DomTransitionPath as g, EDITOR_OPERATORS as h, type EditorMotion as i, type EditorOperator as j, type EntityDefinition as k, type StateMachineDefinition as l, type TransitionDefinition as m, applyMotion as n, applyOperator as o, bindCanvasCapture as p, bindEventBus as q, bindLastDrawables as r, bindTraitStateGetter as s, clearVerification as t, cn as u, extractOutputsFromTransitions as v, extractStateMachine as w, formatGuard as x, getAllChecks as y, getBridgeHealth as z };