@fiddle-digital/string-tune 1.1.51 → 1.1.53

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
  }
@@ -2028,6 +2029,7 @@ declare class StringScrollbar extends StringModule {
2028
2029
  */
2029
2030
  declare class StringSplit extends StringModule {
2030
2031
  constructor(context: StringContext);
2032
+ onInit(): void;
2031
2033
  onResizeWidth(): void;
2032
2034
  onObjectConnected(object: StringObject): void;
2033
2035
  split(element: HTMLElement, options: ISplitOptions): {
@@ -2670,130 +2672,105 @@ declare class ScrollController {
2670
2672
  }
2671
2673
 
2672
2674
  /**
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
- }>;
2675
+ * What the trigger does when activated.
2676
+ * Defaults to "toggle" when not specified.
2677
+ */
2678
+ type RulersTriggerAction = "toggle" | "show" | "hide";
2679
+ /**
2680
+ * Keyboard shortcut trigger.
2681
+ *
2682
+ * @example
2683
+ * { type: "keyboard", key: "R", shiftKey: true }
2684
+ */
2685
+ interface KeyboardRulersTrigger {
2686
+ type: "keyboard";
2687
+ /** The KeyboardEvent.key value (case-sensitive, e.g. "R", "g", "F2"). */
2688
+ key: string;
2689
+ shiftKey?: boolean;
2690
+ ctrlKey?: boolean;
2691
+ altKey?: boolean;
2692
+ metaKey?: boolean;
2693
+ action?: RulersTriggerAction;
2717
2694
  }
2718
- interface UIFieldToggle {
2719
- readonly type: "toggle";
2720
- readonly key: string;
2721
- readonly label: string;
2722
- readonly default: boolean;
2695
+ /**
2696
+ * DOM element trigger — binds to one or more elements matching a CSS selector.
2697
+ * The element(s) must exist in the DOM when the module subscribes (at `start()` time).
2698
+ * For dynamically-added controls, prefer `type: "event"` instead.
2699
+ *
2700
+ * @example
2701
+ * { type: "element", selector: "#rulers-toggle-btn" }
2702
+ * { type: "element", selector: ".dev-toolbar [data-action='rulers']", event: "pointerdown" }
2703
+ */
2704
+ interface ElementRulersTrigger {
2705
+ type: "element";
2706
+ /** CSS selector. All matching elements are bound. */
2707
+ selector: string;
2708
+ /** DOM event type. Defaults to "click". */
2709
+ event?: string;
2710
+ action?: RulersTriggerAction;
2723
2711
  }
2724
- interface UIFieldDivider {
2725
- readonly type: "divider";
2726
- readonly label?: string;
2712
+ /**
2713
+ * StringTune event-bus trigger — reacts to a named event emitted via the event manager.
2714
+ * Useful for toolbar integrations, programmatic control, and cross-module communication.
2715
+ *
2716
+ * @example
2717
+ * { type: "event", name: "dev:rulers:toggle" }
2718
+ *
2719
+ * Activate via:
2720
+ * stringTune.emit("dev:rulers:toggle", null)
2721
+ */
2722
+ interface EventRulersTrigger {
2723
+ type: "event";
2724
+ /** Event name on the StringTune event bus. */
2725
+ name: string;
2726
+ action?: RulersTriggerAction;
2727
2727
  }
2728
+ /**
2729
+ * Discriminated union of all supported ruler trigger descriptors.
2730
+ */
2731
+ type StringRulersTrigger = KeyboardRulersTrigger | ElementRulersTrigger | EventRulersTrigger;
2728
2732
 
2729
2733
  /**
2730
- * Abstract base class for all grid adapters.
2734
+ * Column-based layout grid.
2735
+ *
2736
+ * Displays a fixed set of equally-spaced column bands across the viewport.
2737
+ * Column width is derived from the viewport width, margins, count, and gap.
2731
2738
  *
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
2739
+ * @example
2740
+ * { type: "columns", count: 12, marginLeft: 40, marginRight: 40, gap: 20 }
2741
+ */
2742
+ interface ColumnsLayoutGrid {
2743
+ type: "columns";
2744
+ /** Number of columns. */
2745
+ count: number;
2746
+ /** Space reserved on the left edge of the viewport (px). Default: 0. */
2747
+ marginLeft?: number;
2748
+ /** Space reserved on the right edge of the viewport (px). Default: 0. */
2749
+ marginRight?: number;
2750
+ /** Gutter between columns (px). Default: 0. */
2751
+ gap?: number;
2752
+ /** Fill color for column bands. Default: "rgba(255, 0, 80, 0.08)". */
2753
+ color?: string;
2754
+ }
2755
+ /**
2756
+ * Row-based layout grid.
2736
2757
  *
2737
- * To create a new grid type, extend this class and implement
2738
- * all abstract members. The system handles everything else.
2758
+ * Displays repeating horizontal stripes across the full document height.
2759
+ * Stripes scroll with the page content.
2760
+ *
2761
+ * @example
2762
+ * { type: "rows", height: 8, gap: 0 }
2739
2763
  */
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;
2764
+ interface RowsLayoutGrid {
2765
+ type: "rows";
2766
+ /** Height of each row band (px). */
2767
+ height: number;
2768
+ /** Gap between row bands (px). Default: 0. */
2769
+ gap?: number;
2770
+ /** Fill color for row bands. Default: "rgba(0, 120, 255, 0.06)". */
2771
+ color?: string;
2796
2772
  }
2773
+ type RulersLayoutGrid = ColumnsLayoutGrid | RowsLayoutGrid;
2797
2774
 
2798
2775
  interface ModuleBatchContext {
2799
2776
  module: StringModule;
@@ -3094,4 +3071,4 @@ declare class StringTune {
3094
3071
  destroy(): void;
3095
3072
  }
3096
3073
 
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 };
3074
+ 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
  }
@@ -2028,6 +2029,7 @@ declare class StringScrollbar extends StringModule {
2028
2029
  */
2029
2030
  declare class StringSplit extends StringModule {
2030
2031
  constructor(context: StringContext);
2032
+ onInit(): void;
2031
2033
  onResizeWidth(): void;
2032
2034
  onObjectConnected(object: StringObject): void;
2033
2035
  split(element: HTMLElement, options: ISplitOptions): {
@@ -2670,130 +2672,105 @@ declare class ScrollController {
2670
2672
  }
2671
2673
 
2672
2674
  /**
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
- }>;
2675
+ * What the trigger does when activated.
2676
+ * Defaults to "toggle" when not specified.
2677
+ */
2678
+ type RulersTriggerAction = "toggle" | "show" | "hide";
2679
+ /**
2680
+ * Keyboard shortcut trigger.
2681
+ *
2682
+ * @example
2683
+ * { type: "keyboard", key: "R", shiftKey: true }
2684
+ */
2685
+ interface KeyboardRulersTrigger {
2686
+ type: "keyboard";
2687
+ /** The KeyboardEvent.key value (case-sensitive, e.g. "R", "g", "F2"). */
2688
+ key: string;
2689
+ shiftKey?: boolean;
2690
+ ctrlKey?: boolean;
2691
+ altKey?: boolean;
2692
+ metaKey?: boolean;
2693
+ action?: RulersTriggerAction;
2717
2694
  }
2718
- interface UIFieldToggle {
2719
- readonly type: "toggle";
2720
- readonly key: string;
2721
- readonly label: string;
2722
- readonly default: boolean;
2695
+ /**
2696
+ * DOM element trigger — binds to one or more elements matching a CSS selector.
2697
+ * The element(s) must exist in the DOM when the module subscribes (at `start()` time).
2698
+ * For dynamically-added controls, prefer `type: "event"` instead.
2699
+ *
2700
+ * @example
2701
+ * { type: "element", selector: "#rulers-toggle-btn" }
2702
+ * { type: "element", selector: ".dev-toolbar [data-action='rulers']", event: "pointerdown" }
2703
+ */
2704
+ interface ElementRulersTrigger {
2705
+ type: "element";
2706
+ /** CSS selector. All matching elements are bound. */
2707
+ selector: string;
2708
+ /** DOM event type. Defaults to "click". */
2709
+ event?: string;
2710
+ action?: RulersTriggerAction;
2723
2711
  }
2724
- interface UIFieldDivider {
2725
- readonly type: "divider";
2726
- readonly label?: string;
2712
+ /**
2713
+ * StringTune event-bus trigger — reacts to a named event emitted via the event manager.
2714
+ * Useful for toolbar integrations, programmatic control, and cross-module communication.
2715
+ *
2716
+ * @example
2717
+ * { type: "event", name: "dev:rulers:toggle" }
2718
+ *
2719
+ * Activate via:
2720
+ * stringTune.emit("dev:rulers:toggle", null)
2721
+ */
2722
+ interface EventRulersTrigger {
2723
+ type: "event";
2724
+ /** Event name on the StringTune event bus. */
2725
+ name: string;
2726
+ action?: RulersTriggerAction;
2727
2727
  }
2728
+ /**
2729
+ * Discriminated union of all supported ruler trigger descriptors.
2730
+ */
2731
+ type StringRulersTrigger = KeyboardRulersTrigger | ElementRulersTrigger | EventRulersTrigger;
2728
2732
 
2729
2733
  /**
2730
- * Abstract base class for all grid adapters.
2734
+ * Column-based layout grid.
2735
+ *
2736
+ * Displays a fixed set of equally-spaced column bands across the viewport.
2737
+ * Column width is derived from the viewport width, margins, count, and gap.
2731
2738
  *
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
2739
+ * @example
2740
+ * { type: "columns", count: 12, marginLeft: 40, marginRight: 40, gap: 20 }
2741
+ */
2742
+ interface ColumnsLayoutGrid {
2743
+ type: "columns";
2744
+ /** Number of columns. */
2745
+ count: number;
2746
+ /** Space reserved on the left edge of the viewport (px). Default: 0. */
2747
+ marginLeft?: number;
2748
+ /** Space reserved on the right edge of the viewport (px). Default: 0. */
2749
+ marginRight?: number;
2750
+ /** Gutter between columns (px). Default: 0. */
2751
+ gap?: number;
2752
+ /** Fill color for column bands. Default: "rgba(255, 0, 80, 0.08)". */
2753
+ color?: string;
2754
+ }
2755
+ /**
2756
+ * Row-based layout grid.
2736
2757
  *
2737
- * To create a new grid type, extend this class and implement
2738
- * all abstract members. The system handles everything else.
2758
+ * Displays repeating horizontal stripes across the full document height.
2759
+ * Stripes scroll with the page content.
2760
+ *
2761
+ * @example
2762
+ * { type: "rows", height: 8, gap: 0 }
2739
2763
  */
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;
2764
+ interface RowsLayoutGrid {
2765
+ type: "rows";
2766
+ /** Height of each row band (px). */
2767
+ height: number;
2768
+ /** Gap between row bands (px). Default: 0. */
2769
+ gap?: number;
2770
+ /** Fill color for row bands. Default: "rgba(0, 120, 255, 0.06)". */
2771
+ color?: string;
2796
2772
  }
2773
+ type RulersLayoutGrid = ColumnsLayoutGrid | RowsLayoutGrid;
2797
2774
 
2798
2775
  interface ModuleBatchContext {
2799
2776
  module: StringModule;
@@ -3094,4 +3071,4 @@ declare class StringTune {
3094
3071
  destroy(): void;
3095
3072
  }
3096
3073
 
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 };
3074
+ 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 };