@fiddle-digital/string-tune 1.1.51 → 1.1.52

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/dist/index.d.mts CHANGED
@@ -1737,6 +1737,7 @@ declare class StringCursor extends StringModule {
1737
1737
  private getFrameAdjustedLerp;
1738
1738
  private getObjectDimensions;
1739
1739
  private calculateOffset;
1740
+ private reverseOffset;
1740
1741
  removeObject(id: string): void;
1741
1742
  destroy(): void;
1742
1743
  }
@@ -2670,130 +2671,105 @@ declare class ScrollController {
2670
2671
  }
2671
2672
 
2672
2673
  /**
2673
- * Discriminated union of all UI field descriptors.
2674
- * Each adapter returns an array of these to describe its settings panel.
2675
- */
2676
- type UIFieldDescriptor = UIFieldNumber | UIFieldRange | UIFieldColor | UIFieldSelect | UIFieldToggle | UIFieldDivider;
2677
- interface UIFieldNumber {
2678
- readonly type: "number";
2679
- readonly key: string;
2680
- readonly label: string;
2681
- readonly default: number;
2682
- readonly min?: number;
2683
- readonly max?: number;
2684
- readonly step?: number;
2685
- }
2686
- interface UIFieldRange {
2687
- readonly type: "range";
2688
- readonly key: string;
2689
- readonly label: string;
2690
- readonly default: number;
2691
- readonly min: number;
2692
- readonly max: number;
2693
- readonly step?: number;
2694
- /** When provided, a compact unit dropdown is shown next to the value input. */
2695
- readonly units?: ReadonlyArray<{
2696
- value: string;
2697
- label: string;
2698
- }>;
2699
- /** Default unit value (used when no persisted unit exists). */
2700
- readonly defaultUnit?: string;
2701
- }
2702
- interface UIFieldColor {
2703
- readonly type: "color";
2704
- readonly key: string;
2705
- readonly label: string;
2706
- readonly default: string;
2707
- }
2708
- interface UIFieldSelect {
2709
- readonly type: "select";
2710
- readonly key: string;
2711
- readonly label: string;
2712
- readonly default: string;
2713
- readonly options: ReadonlyArray<{
2714
- value: string;
2715
- label: string;
2716
- }>;
2674
+ * What the trigger does when activated.
2675
+ * Defaults to "toggle" when not specified.
2676
+ */
2677
+ type RulersTriggerAction = "toggle" | "show" | "hide";
2678
+ /**
2679
+ * Keyboard shortcut trigger.
2680
+ *
2681
+ * @example
2682
+ * { type: "keyboard", key: "R", shiftKey: true }
2683
+ */
2684
+ interface KeyboardRulersTrigger {
2685
+ type: "keyboard";
2686
+ /** The KeyboardEvent.key value (case-sensitive, e.g. "R", "g", "F2"). */
2687
+ key: string;
2688
+ shiftKey?: boolean;
2689
+ ctrlKey?: boolean;
2690
+ altKey?: boolean;
2691
+ metaKey?: boolean;
2692
+ action?: RulersTriggerAction;
2717
2693
  }
2718
- interface UIFieldToggle {
2719
- readonly type: "toggle";
2720
- readonly key: string;
2721
- readonly label: string;
2722
- readonly default: boolean;
2694
+ /**
2695
+ * DOM element trigger — binds to one or more elements matching a CSS selector.
2696
+ * The element(s) must exist in the DOM when the module subscribes (at `start()` time).
2697
+ * For dynamically-added controls, prefer `type: "event"` instead.
2698
+ *
2699
+ * @example
2700
+ * { type: "element", selector: "#rulers-toggle-btn" }
2701
+ * { type: "element", selector: ".dev-toolbar [data-action='rulers']", event: "pointerdown" }
2702
+ */
2703
+ interface ElementRulersTrigger {
2704
+ type: "element";
2705
+ /** CSS selector. All matching elements are bound. */
2706
+ selector: string;
2707
+ /** DOM event type. Defaults to "click". */
2708
+ event?: string;
2709
+ action?: RulersTriggerAction;
2723
2710
  }
2724
- interface UIFieldDivider {
2725
- readonly type: "divider";
2726
- readonly label?: string;
2711
+ /**
2712
+ * StringTune event-bus trigger — reacts to a named event emitted via the event manager.
2713
+ * Useful for toolbar integrations, programmatic control, and cross-module communication.
2714
+ *
2715
+ * @example
2716
+ * { type: "event", name: "dev:rulers:toggle" }
2717
+ *
2718
+ * Activate via:
2719
+ * stringTune.emit("dev:rulers:toggle", null)
2720
+ */
2721
+ interface EventRulersTrigger {
2722
+ type: "event";
2723
+ /** Event name on the StringTune event bus. */
2724
+ name: string;
2725
+ action?: RulersTriggerAction;
2727
2726
  }
2727
+ /**
2728
+ * Discriminated union of all supported ruler trigger descriptors.
2729
+ */
2730
+ type StringRulersTrigger = KeyboardRulersTrigger | ElementRulersTrigger | EventRulersTrigger;
2728
2731
 
2729
2732
  /**
2730
- * Abstract base class for all grid adapters.
2733
+ * Column-based layout grid.
2734
+ *
2735
+ * Displays a fixed set of equally-spaced column bands across the viewport.
2736
+ * Column width is derived from the viewport width, margins, count, and gap.
2731
2737
  *
2732
- * Each adapter is a self-contained unit that:
2733
- * - Declares its own default settings
2734
- * - Describes its UI schema for the settings panel
2735
- * - Renders itself into an SVG overlay
2738
+ * @example
2739
+ * { type: "columns", count: 12, marginLeft: 40, marginRight: 40, gap: 20 }
2740
+ */
2741
+ interface ColumnsLayoutGrid {
2742
+ type: "columns";
2743
+ /** Number of columns. */
2744
+ count: number;
2745
+ /** Space reserved on the left edge of the viewport (px). Default: 0. */
2746
+ marginLeft?: number;
2747
+ /** Space reserved on the right edge of the viewport (px). Default: 0. */
2748
+ marginRight?: number;
2749
+ /** Gutter between columns (px). Default: 0. */
2750
+ gap?: number;
2751
+ /** Fill color for column bands. Default: "rgba(255, 0, 80, 0.08)". */
2752
+ color?: string;
2753
+ }
2754
+ /**
2755
+ * Row-based layout grid.
2736
2756
  *
2737
- * To create a new grid type, extend this class and implement
2738
- * all abstract members. The system handles everything else.
2757
+ * Displays repeating horizontal stripes across the full document height.
2758
+ * Stripes scroll with the page content.
2759
+ *
2760
+ * @example
2761
+ * { type: "rows", height: 8, gap: 0 }
2739
2762
  */
2740
- declare abstract class GridAdapter {
2741
- /** Unique type key used for serialization and registry lookup */
2742
- abstract readonly type: string;
2743
- /** Human-readable label shown in the HUD menu */
2744
- abstract readonly label: string;
2745
- /** SVG icon string (inline SVG markup) */
2746
- abstract readonly icon: string;
2747
- /**
2748
- * Returns the default settings for this adapter.
2749
- * These are used when a new grid instance is created.
2750
- */
2751
- abstract getDefaults(): Record<string, any>;
2752
- /**
2753
- * Returns the UI field descriptors that GridUIBuilder
2754
- * uses to construct the settings panel.
2755
- */
2756
- abstract getUISchema(): UIFieldDescriptor[];
2757
- /**
2758
- * Renders the grid into the given SVG element.
2759
- *
2760
- * @param svg The SVG overlay element (same size as target)
2761
- * @param width Element width in px
2762
- * @param height Element height in px
2763
- * @param settings Current settings for this instance
2764
- */
2765
- abstract render(svg: SVGSVGElement, width: number, height: number, settings: Record<string, any>): void;
2766
- /**
2767
- * Removes all elements previously rendered by this adapter.
2768
- * Default implementation clears the adapter's group element.
2769
- */
2770
- clear(svg: SVGSVGElement, instanceId: string): void;
2771
- /**
2772
- * Creates or retrieves a <g> group element scoped to a grid instance.
2773
- * All rendering should happen inside this group for clean cleanup.
2774
- */
2775
- protected getGroup(svg: SVGSVGElement, instanceId: string): SVGGElement;
2776
- /**
2777
- * Helper: creates an SVG line element.
2778
- */
2779
- protected createLine(x1: number, y1: number, x2: number, y2: number, color: string, opacity: number, strokeWidth?: number): SVGLineElement;
2780
- /**
2781
- * Helper: creates an SVG rect element.
2782
- */
2783
- protected createRect(x: number, y: number, width: number, height: number, fill: string, opacity: number): SVGRectElement;
2784
- /**
2785
- * Converts a value from the given unit to pixels.
2786
- *
2787
- * @param value Raw numeric value
2788
- * @param unit "px" | "%" | "vw" | "vh"
2789
- * @param dimension Reference dimension (element width or height) for "%" mode
2790
- */
2791
- protected resolveUnit(value: number, unit: string, dimension: number): number;
2792
- /**
2793
- * Helper: creates an SVG path element.
2794
- */
2795
- protected createPath(d: string, stroke: string, opacity: number, strokeWidth?: number, fill?: string): SVGPathElement;
2763
+ interface RowsLayoutGrid {
2764
+ type: "rows";
2765
+ /** Height of each row band (px). */
2766
+ height: number;
2767
+ /** Gap between row bands (px). Default: 0. */
2768
+ gap?: number;
2769
+ /** Fill color for row bands. Default: "rgba(0, 120, 255, 0.06)". */
2770
+ color?: string;
2796
2771
  }
2772
+ type RulersLayoutGrid = ColumnsLayoutGrid | RowsLayoutGrid;
2797
2773
 
2798
2774
  interface ModuleBatchContext {
2799
2775
  module: StringModule;
@@ -3094,4 +3070,4 @@ declare class StringTune {
3094
3070
  destroy(): void;
3095
3071
  }
3096
3072
 
3097
- export { CursorReactiveModule, DOMBatcher, GridAdapter, ScrollController, type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringImpulse, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringMasonry, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringProgressPart, StringRandom, StringResponsive, StringScrollContainer, StringScrollbar, StringScroller, StringSequence, StringSplit, StringSpotlight, StringTune, StringVideoAutoplay, StringTune as default, frameDOM, styleTxn };
3073
+ export { CursorReactiveModule, DOMBatcher, type RulersLayoutGrid, type RulersTriggerAction, ScrollController, type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringImpulse, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringMasonry, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringProgressPart, StringRandom, StringResponsive, type StringRulersTrigger, StringScrollContainer, StringScrollbar, StringScroller, StringSequence, StringSplit, StringSpotlight, StringTune, StringVideoAutoplay, StringTune as default, frameDOM, styleTxn };
package/dist/index.d.ts CHANGED
@@ -1737,6 +1737,7 @@ declare class StringCursor extends StringModule {
1737
1737
  private getFrameAdjustedLerp;
1738
1738
  private getObjectDimensions;
1739
1739
  private calculateOffset;
1740
+ private reverseOffset;
1740
1741
  removeObject(id: string): void;
1741
1742
  destroy(): void;
1742
1743
  }
@@ -2670,130 +2671,105 @@ declare class ScrollController {
2670
2671
  }
2671
2672
 
2672
2673
  /**
2673
- * Discriminated union of all UI field descriptors.
2674
- * Each adapter returns an array of these to describe its settings panel.
2675
- */
2676
- type UIFieldDescriptor = UIFieldNumber | UIFieldRange | UIFieldColor | UIFieldSelect | UIFieldToggle | UIFieldDivider;
2677
- interface UIFieldNumber {
2678
- readonly type: "number";
2679
- readonly key: string;
2680
- readonly label: string;
2681
- readonly default: number;
2682
- readonly min?: number;
2683
- readonly max?: number;
2684
- readonly step?: number;
2685
- }
2686
- interface UIFieldRange {
2687
- readonly type: "range";
2688
- readonly key: string;
2689
- readonly label: string;
2690
- readonly default: number;
2691
- readonly min: number;
2692
- readonly max: number;
2693
- readonly step?: number;
2694
- /** When provided, a compact unit dropdown is shown next to the value input. */
2695
- readonly units?: ReadonlyArray<{
2696
- value: string;
2697
- label: string;
2698
- }>;
2699
- /** Default unit value (used when no persisted unit exists). */
2700
- readonly defaultUnit?: string;
2701
- }
2702
- interface UIFieldColor {
2703
- readonly type: "color";
2704
- readonly key: string;
2705
- readonly label: string;
2706
- readonly default: string;
2707
- }
2708
- interface UIFieldSelect {
2709
- readonly type: "select";
2710
- readonly key: string;
2711
- readonly label: string;
2712
- readonly default: string;
2713
- readonly options: ReadonlyArray<{
2714
- value: string;
2715
- label: string;
2716
- }>;
2674
+ * What the trigger does when activated.
2675
+ * Defaults to "toggle" when not specified.
2676
+ */
2677
+ type RulersTriggerAction = "toggle" | "show" | "hide";
2678
+ /**
2679
+ * Keyboard shortcut trigger.
2680
+ *
2681
+ * @example
2682
+ * { type: "keyboard", key: "R", shiftKey: true }
2683
+ */
2684
+ interface KeyboardRulersTrigger {
2685
+ type: "keyboard";
2686
+ /** The KeyboardEvent.key value (case-sensitive, e.g. "R", "g", "F2"). */
2687
+ key: string;
2688
+ shiftKey?: boolean;
2689
+ ctrlKey?: boolean;
2690
+ altKey?: boolean;
2691
+ metaKey?: boolean;
2692
+ action?: RulersTriggerAction;
2717
2693
  }
2718
- interface UIFieldToggle {
2719
- readonly type: "toggle";
2720
- readonly key: string;
2721
- readonly label: string;
2722
- readonly default: boolean;
2694
+ /**
2695
+ * DOM element trigger — binds to one or more elements matching a CSS selector.
2696
+ * The element(s) must exist in the DOM when the module subscribes (at `start()` time).
2697
+ * For dynamically-added controls, prefer `type: "event"` instead.
2698
+ *
2699
+ * @example
2700
+ * { type: "element", selector: "#rulers-toggle-btn" }
2701
+ * { type: "element", selector: ".dev-toolbar [data-action='rulers']", event: "pointerdown" }
2702
+ */
2703
+ interface ElementRulersTrigger {
2704
+ type: "element";
2705
+ /** CSS selector. All matching elements are bound. */
2706
+ selector: string;
2707
+ /** DOM event type. Defaults to "click". */
2708
+ event?: string;
2709
+ action?: RulersTriggerAction;
2723
2710
  }
2724
- interface UIFieldDivider {
2725
- readonly type: "divider";
2726
- readonly label?: string;
2711
+ /**
2712
+ * StringTune event-bus trigger — reacts to a named event emitted via the event manager.
2713
+ * Useful for toolbar integrations, programmatic control, and cross-module communication.
2714
+ *
2715
+ * @example
2716
+ * { type: "event", name: "dev:rulers:toggle" }
2717
+ *
2718
+ * Activate via:
2719
+ * stringTune.emit("dev:rulers:toggle", null)
2720
+ */
2721
+ interface EventRulersTrigger {
2722
+ type: "event";
2723
+ /** Event name on the StringTune event bus. */
2724
+ name: string;
2725
+ action?: RulersTriggerAction;
2727
2726
  }
2727
+ /**
2728
+ * Discriminated union of all supported ruler trigger descriptors.
2729
+ */
2730
+ type StringRulersTrigger = KeyboardRulersTrigger | ElementRulersTrigger | EventRulersTrigger;
2728
2731
 
2729
2732
  /**
2730
- * Abstract base class for all grid adapters.
2733
+ * Column-based layout grid.
2734
+ *
2735
+ * Displays a fixed set of equally-spaced column bands across the viewport.
2736
+ * Column width is derived from the viewport width, margins, count, and gap.
2731
2737
  *
2732
- * Each adapter is a self-contained unit that:
2733
- * - Declares its own default settings
2734
- * - Describes its UI schema for the settings panel
2735
- * - Renders itself into an SVG overlay
2738
+ * @example
2739
+ * { type: "columns", count: 12, marginLeft: 40, marginRight: 40, gap: 20 }
2740
+ */
2741
+ interface ColumnsLayoutGrid {
2742
+ type: "columns";
2743
+ /** Number of columns. */
2744
+ count: number;
2745
+ /** Space reserved on the left edge of the viewport (px). Default: 0. */
2746
+ marginLeft?: number;
2747
+ /** Space reserved on the right edge of the viewport (px). Default: 0. */
2748
+ marginRight?: number;
2749
+ /** Gutter between columns (px). Default: 0. */
2750
+ gap?: number;
2751
+ /** Fill color for column bands. Default: "rgba(255, 0, 80, 0.08)". */
2752
+ color?: string;
2753
+ }
2754
+ /**
2755
+ * Row-based layout grid.
2736
2756
  *
2737
- * To create a new grid type, extend this class and implement
2738
- * all abstract members. The system handles everything else.
2757
+ * Displays repeating horizontal stripes across the full document height.
2758
+ * Stripes scroll with the page content.
2759
+ *
2760
+ * @example
2761
+ * { type: "rows", height: 8, gap: 0 }
2739
2762
  */
2740
- declare abstract class GridAdapter {
2741
- /** Unique type key used for serialization and registry lookup */
2742
- abstract readonly type: string;
2743
- /** Human-readable label shown in the HUD menu */
2744
- abstract readonly label: string;
2745
- /** SVG icon string (inline SVG markup) */
2746
- abstract readonly icon: string;
2747
- /**
2748
- * Returns the default settings for this adapter.
2749
- * These are used when a new grid instance is created.
2750
- */
2751
- abstract getDefaults(): Record<string, any>;
2752
- /**
2753
- * Returns the UI field descriptors that GridUIBuilder
2754
- * uses to construct the settings panel.
2755
- */
2756
- abstract getUISchema(): UIFieldDescriptor[];
2757
- /**
2758
- * Renders the grid into the given SVG element.
2759
- *
2760
- * @param svg The SVG overlay element (same size as target)
2761
- * @param width Element width in px
2762
- * @param height Element height in px
2763
- * @param settings Current settings for this instance
2764
- */
2765
- abstract render(svg: SVGSVGElement, width: number, height: number, settings: Record<string, any>): void;
2766
- /**
2767
- * Removes all elements previously rendered by this adapter.
2768
- * Default implementation clears the adapter's group element.
2769
- */
2770
- clear(svg: SVGSVGElement, instanceId: string): void;
2771
- /**
2772
- * Creates or retrieves a <g> group element scoped to a grid instance.
2773
- * All rendering should happen inside this group for clean cleanup.
2774
- */
2775
- protected getGroup(svg: SVGSVGElement, instanceId: string): SVGGElement;
2776
- /**
2777
- * Helper: creates an SVG line element.
2778
- */
2779
- protected createLine(x1: number, y1: number, x2: number, y2: number, color: string, opacity: number, strokeWidth?: number): SVGLineElement;
2780
- /**
2781
- * Helper: creates an SVG rect element.
2782
- */
2783
- protected createRect(x: number, y: number, width: number, height: number, fill: string, opacity: number): SVGRectElement;
2784
- /**
2785
- * Converts a value from the given unit to pixels.
2786
- *
2787
- * @param value Raw numeric value
2788
- * @param unit "px" | "%" | "vw" | "vh"
2789
- * @param dimension Reference dimension (element width or height) for "%" mode
2790
- */
2791
- protected resolveUnit(value: number, unit: string, dimension: number): number;
2792
- /**
2793
- * Helper: creates an SVG path element.
2794
- */
2795
- protected createPath(d: string, stroke: string, opacity: number, strokeWidth?: number, fill?: string): SVGPathElement;
2763
+ interface RowsLayoutGrid {
2764
+ type: "rows";
2765
+ /** Height of each row band (px). */
2766
+ height: number;
2767
+ /** Gap between row bands (px). Default: 0. */
2768
+ gap?: number;
2769
+ /** Fill color for row bands. Default: "rgba(0, 120, 255, 0.06)". */
2770
+ color?: string;
2796
2771
  }
2772
+ type RulersLayoutGrid = ColumnsLayoutGrid | RowsLayoutGrid;
2797
2773
 
2798
2774
  interface ModuleBatchContext {
2799
2775
  module: StringModule;
@@ -3094,4 +3070,4 @@ declare class StringTune {
3094
3070
  destroy(): void;
3095
3071
  }
3096
3072
 
3097
- export { CursorReactiveModule, DOMBatcher, GridAdapter, ScrollController, type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringImpulse, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringMasonry, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringProgressPart, StringRandom, StringResponsive, StringScrollContainer, StringScrollbar, StringScroller, StringSequence, StringSplit, StringSpotlight, StringTune, StringVideoAutoplay, StringTune as default, frameDOM, styleTxn };
3073
+ export { CursorReactiveModule, DOMBatcher, type RulersLayoutGrid, type RulersTriggerAction, ScrollController, type ScrollMarkRule as ScrollTriggerRule, StringAnchor, type StringContext, StringCursor, StringData, StringDelayLerpTracker, StringFPSTracker, StringForm, StringGlide, StringImpulse, StringLazy, StringLerp, StringLerpTracker, StringLoading, StringMagnetic, StringMasonry, StringModule, StringObject, StringParallax, StringPositionTracker, StringProgress, StringProgressPart, StringRandom, StringResponsive, type StringRulersTrigger, StringScrollContainer, StringScrollbar, StringScroller, StringSequence, StringSplit, StringSpotlight, StringTune, StringVideoAutoplay, StringTune as default, frameDOM, styleTxn };