sia-reactor 0.0.57 → 0.0.58
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/README.md +1 -1
- package/dist/{TimeTravelConsole-Cof4tji7.d.ts → TimeTravelConsole-Bdf2USu0.d.ts} +1 -1
- package/dist/{TimeTravelConsole-CrTYhT1B.d.cts → TimeTravelConsole-CBb0dE9h.d.cts} +1 -1
- package/dist/adapters/react.d.cts +2 -2
- package/dist/adapters/react.d.ts +2 -2
- package/dist/adapters/react.js +3 -3
- package/dist/adapters/vanilla.d.cts +2 -2
- package/dist/adapters/vanilla.d.ts +2 -2
- package/dist/adapters/vanilla.js +3 -3
- package/dist/{chunk-5E7VHA7E.js → chunk-3XANIODP.js} +9 -3
- package/dist/chunk-3XANIODP.js.map +1 -0
- package/dist/{chunk-H5UCZPAC.js → chunk-5L6BFMUJ.js} +3 -3
- package/dist/{chunk-BJDQLZ2J.js → chunk-XM6ELUFF.js} +2 -2
- package/dist/{index-Cc5CaM9q.d.cts → index-CBhEZiRU.d.cts} +1 -1
- package/dist/{index-CwE3FzCU.d.ts → index-DBXTSNml.d.ts} +1 -1
- package/dist/modules.cjs +8 -8
- package/dist/modules.cjs.map +1 -1
- package/dist/modules.d.cts +2 -2
- package/dist/modules.d.ts +2 -2
- package/dist/modules.js +6 -9
- package/dist/modules.js.map +1 -1
- package/dist/super.d.ts +5 -3
- package/dist/super.global.js +8 -8
- package/dist/super.global.js.map +1 -1
- package/dist/utils.cjs +4 -2
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +4 -2
- package/dist/utils.d.ts +4 -2
- package/dist/utils.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-5E7VHA7E.js.map +0 -1
- /package/dist/{chunk-H5UCZPAC.js.map → chunk-5L6BFMUJ.js.map} +0 -0
- /package/dist/{chunk-BJDQLZ2J.js.map → chunk-XM6ELUFF.js.map} +0 -0
package/README.md
CHANGED
|
@@ -104,7 +104,7 @@ import { setPath, getPath, mergeObjs } from "sia-reactor/utils";
|
|
|
104
104
|
|
|
105
105
|
```javascript
|
|
106
106
|
import { reactive, Reactor } from "sia-reactor";
|
|
107
|
-
import "sia-reactor/utils"; // deep object helpers (setPath/getPath/deletePath/hasPath/parsePathObj/fanout/force/mergeObjs/deepClone/nuke...) take note of `fanout`!
|
|
107
|
+
import "sia-reactor/utils"; // deep object helpers (setPath/getPath/deletePath/hasPath/mirror/parsePathObj/fanout/force/mergeObjs/deepClone/nuke...) take note of `fanout` & `mirror`!
|
|
108
108
|
import "sia-reactor/modules"; // built-in modules + storage adapters
|
|
109
109
|
import "sia-reactor/adapters/vanilla"; // Autotracker + effect API + TimeTravelConsole class
|
|
110
110
|
import "sia-reactor/adapters/react"; // useReactor/useSelector/usePath hooks
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { W as Reactive } from './consts-RJWw9ugh.js';
|
|
2
|
-
import { h as TimeTravelModule } from './index-
|
|
2
|
+
import { h as TimeTravelModule } from './index-DBXTSNml.js';
|
|
3
3
|
|
|
4
4
|
/** Reactive options for the TimeTravel console instance. */
|
|
5
5
|
interface TimeTravelConsoleConfig {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { W as Reactive } from './consts-RJWw9ugh.cjs';
|
|
2
|
-
import { h as TimeTravelModule } from './index-
|
|
2
|
+
import { h as TimeTravelModule } from './index-CBhEZiRU.cjs';
|
|
3
3
|
|
|
4
4
|
/** Reactive options for the TimeTravel console instance. */
|
|
5
5
|
interface TimeTravelConsoleConfig {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { k as EffectOptions, Y as Reactor, W as Reactive, Z as ReactorBuild, e as DeepReadonly, ai as WildPaths, F as PathValue } from '../consts-RJWw9ugh.cjs';
|
|
2
2
|
import { useLayoutEffect } from 'react';
|
|
3
|
-
import { h as TimeTravelModule } from '../index-
|
|
4
|
-
import { T as TimeTravelConsoleConfig } from '../TimeTravelConsole-
|
|
3
|
+
import { h as TimeTravelModule } from '../index-CBhEZiRU.cjs';
|
|
4
|
+
import { T as TimeTravelConsoleConfig } from '../TimeTravelConsole-CBb0dE9h.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Subscribes a component to desired Reactor state and returns it.
|
package/dist/adapters/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { k as EffectOptions, Y as Reactor, W as Reactive, Z as ReactorBuild, e as DeepReadonly, ai as WildPaths, F as PathValue } from '../consts-RJWw9ugh.js';
|
|
2
2
|
import { useLayoutEffect } from 'react';
|
|
3
|
-
import { h as TimeTravelModule } from '../index-
|
|
4
|
-
import { T as TimeTravelConsoleConfig } from '../TimeTravelConsole-
|
|
3
|
+
import { h as TimeTravelModule } from '../index-DBXTSNml.js';
|
|
4
|
+
import { T as TimeTravelConsoleConfig } from '../TimeTravelConsole-Bdf2USu0.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Subscribes a component to desired Reactor state and returns it.
|
package/dist/adapters/react.js
CHANGED
|
@@ -2,9 +2,9 @@ import {
|
|
|
2
2
|
Autotracker,
|
|
3
3
|
TimeTravelConsole,
|
|
4
4
|
withTracker
|
|
5
|
-
} from "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
5
|
+
} from "../chunk-5L6BFMUJ.js";
|
|
6
|
+
import "../chunk-XM6ELUFF.js";
|
|
7
|
+
import "../chunk-3XANIODP.js";
|
|
8
8
|
import {
|
|
9
9
|
CTX,
|
|
10
10
|
NIL,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { k as EffectOptions } from '../consts-RJWw9ugh.cjs';
|
|
2
2
|
export { b3 as Autotracker, b4 as withTracker } from '../consts-RJWw9ugh.cjs';
|
|
3
|
-
export { a as TimeTravelConsole, T as TimeTravelConsoleConfig } from '../TimeTravelConsole-
|
|
4
|
-
import '../index-
|
|
3
|
+
export { a as TimeTravelConsole, T as TimeTravelConsoleConfig } from '../TimeTravelConsole-CBb0dE9h.cjs';
|
|
4
|
+
import '../index-CBhEZiRU.cjs';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Runs a reactive side effect in vanilla JavaScript.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { k as EffectOptions } from '../consts-RJWw9ugh.js';
|
|
2
2
|
export { b3 as Autotracker, b4 as withTracker } from '../consts-RJWw9ugh.js';
|
|
3
|
-
export { a as TimeTravelConsole, T as TimeTravelConsoleConfig } from '../TimeTravelConsole-
|
|
4
|
-
import '../index-
|
|
3
|
+
export { a as TimeTravelConsole, T as TimeTravelConsoleConfig } from '../TimeTravelConsole-Bdf2USu0.js';
|
|
4
|
+
import '../index-DBXTSNml.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Runs a reactive side effect in vanilla JavaScript.
|
package/dist/adapters/vanilla.js
CHANGED
|
@@ -3,9 +3,9 @@ import {
|
|
|
3
3
|
TimeTravelConsole,
|
|
4
4
|
effect,
|
|
5
5
|
withTracker
|
|
6
|
-
} from "../chunk-
|
|
7
|
-
import "../chunk-
|
|
8
|
-
import "../chunk-
|
|
6
|
+
} from "../chunk-5L6BFMUJ.js";
|
|
7
|
+
import "../chunk-XM6ELUFF.js";
|
|
8
|
+
import "../chunk-3XANIODP.js";
|
|
9
9
|
import "../chunk-K4LEJA2I.js";
|
|
10
10
|
export {
|
|
11
11
|
Autotracker,
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
hasPath
|
|
3
|
+
} from "./chunk-K4LEJA2I.js";
|
|
4
|
+
|
|
1
5
|
// src/ts/utils/methd.ts
|
|
2
6
|
function onAllMethods(owner, callback, skipOwn = true, nested = false) {
|
|
3
7
|
let proto = owner;
|
|
@@ -32,8 +36,10 @@ function guardMethod(fn, onError = (e) => console.error(e)) {
|
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
// src/ts/utils/str.ts
|
|
35
|
-
function mirror(path, read = true) {
|
|
36
|
-
|
|
39
|
+
function mirror(path, obj, read = true) {
|
|
40
|
+
if ("boolean" === typeof obj) read = obj, obj = void 0;
|
|
41
|
+
const m = read ? !path.includes("intent") ? path : path.replace("intent", "state") : !path.includes("state") ? path : path.replace("state", "intent");
|
|
42
|
+
return !obj || hasPath(obj, m) ? m : path;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
// src/ts/utils/dom.ts
|
|
@@ -173,4 +179,4 @@ export {
|
|
|
173
179
|
formatKeyShortcutsTooltip,
|
|
174
180
|
parseForARIAKS
|
|
175
181
|
};
|
|
176
|
-
//# sourceMappingURL=chunk-
|
|
182
|
+
//# sourceMappingURL=chunk-3XANIODP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/ts/utils/methd.ts","../src/ts/utils/str.ts","../src/ts/utils/dom.ts","../src/ts/utils/keys.ts"],"sourcesContent":["// \"THE METHODIST\": A mixin method expert often used to manipulate or bind all methods of a class to an instance\n\n/**\n * Walks an instance and its prototype chain, invoking a callback for each callable method.\n * @param owner Instance whose methods are inspected.\n * @param callback Invoked for each method name found.\n * @param skipOwn Skips owner-level methods when traversing own or parent prototypes.\n * @param nested Internal traversal flag, Override to `true` to avoid skipping own methods when `skipOwn` is `true`.\n */\nexport function onAllMethods(owner: any, callback: (method: string, owner: any) => void, skipOwn = true, nested = false): void {\n let proto = owner;\n while (proto && proto !== Object.prototype) {\n for (const method of Object.getOwnPropertyNames(proto)) {\n if (method === \"constructor\") continue;\n if (nested && skipOwn && Object.prototype.hasOwnProperty.call(owner, method)) continue;\n if (\"function\" === typeof Object.getOwnPropertyDescriptor(proto, method)?.value) callback(method, owner);\n }\n (proto = Object.getPrototypeOf(proto)), (nested = true);\n }\n}\n\n/**\n * Binds all discovered methods on an owner to the owner instance.\n * @param owner Instance whose methods should be bound.\n */\nexport function bindAllMethods(owner: any): void {\n onAllMethods(owner, (method: string, owner: any) => {\n owner[method] = owner[method].bind(owner);\n });\n}\n\n/**\n * Wraps all discovered methods in a guard function, optionally binding before wrapping.\n * @param owner Instance whose methods should be wrapped.\n * @param guardFn Wrapper factory used for each method.\n * @param bound Binds methods to owner before wrapping when true.\n */\nexport function guardAllMethods(owner: any, guardFn: (fn: Function) => Function = guardMethod, bound = true): void {\n onAllMethods(owner, (method: string, owner: any) => {\n owner[method] = guardFn(bound ? owner[method].bind(owner) : owner[method]);\n });\n}\n\n/**\n * Wraps a function with try/catch and async rejection handling.\n * @template T Function type to preserve.\n * @param fn Function to wrap.\n * @param onError Error handler for sync throws and async rejections.\n * @returns Guarded function with the same call signature.\n */\nexport function guardMethod<T extends Function>(fn: T, onError: (e: any) => void = (e) => console.error(e)): T {\n return ((...args: any[]) => {\n try {\n const result = fn(...args);\n return result instanceof Promise ? result.catch((e) => onError(e)) : result;\n } catch (e) {\n onError(e);\n }\n }) as unknown as T;\n}\n","import { hasPath } from \"./obj\";\n\n// String/Path manipulations\n\n/**\n * Mirrors paths between intent (write) and state (read) representations if applicable.\n * @param path The path to mirror.\n * @param obj Object to verify path existence against via `hasPath`. If provided and the mirrored path does not exist, returns the original path.\n * @param read If true (default), mirrors from 'intent' to 'state'. If false, mirrors from 'state' to 'intent'.\n * @returns The mirrored path, or the original path if no substitution was made or target path is not in obj.\n */\nexport function mirror<T extends string>(path: T, obj?: object, read?: true): T extends `${infer P}intent${infer S}` ? `${P}state${S}` : T;\nexport function mirror<T extends string>(path: T, obj?: object, read?: false): T extends `${infer P}state${infer S}` ? `${P}intent${S}` : T;\nexport function mirror<T extends string>(path: T, read: false): T extends `${infer P}state${infer S}` ? `${P}intent${S}` : T;\nexport function mirror(path: string, obj?: object | boolean, read = true): string {\n if (\"boolean\" === typeof obj) (read = obj), (obj = undefined);\n const m = read ? (!path.includes(\"intent\") ? path : path.replace(\"intent\", \"state\")) : !path.includes(\"state\") ? path : path.replace(\"state\", \"intent\");\n return !obj || hasPath(obj, m) ? m : path;\n}\n","// Types\ntype Dataset = Record<string, string | number>;\ntype Style = Partial<CSSStyleDeclaration>;\n\n// Element Factory\n\n/**\n * Creates an HTML element with the specified tag and properties.\n * @param tag The tag name of the element to create.\n * @param props Optional properties to set on the element.\n * @param dataset Optional dataset attributes for the element.\n * @param styles Optional CSS styles for the element.\n * @returns The created HTML element.\n */\nexport function createEl<K extends keyof HTMLElementTagNameMap>(tag: K, props?: Partial<HTMLElementTagNameMap[K]>, dataset?: Dataset, styles?: Style): HTMLElementTagNameMap[K];\nexport function createEl(tag: string, props?: Partial<HTMLElement>, dataset?: Dataset, styles?: Style): HTMLElement | null;\nexport function createEl(tag: string, props?: Record<string, unknown>, dataset?: Dataset, styles?: Style, el = tag ? document?.createElement(tag) : null): HTMLElement | null {\n return assignEl(el, props, dataset, styles);\n}\n\n/**\n * Assigns properties, dataset attributes, and styles to an HTML element.\n * @param el The HTML element to assign properties to.\n * @param props Optional properties to set on the element.\n * @param dataset Optional dataset attributes for the element.\n * @param styles Optional CSS styles for the element.\n * @return The modified HTML element to allow signature swaps with `createEl()`.\n */\nexport function assignEl<El extends HTMLElement>(el?: El | null, props?: Partial<El>, dataset?: Dataset, styles?: Style, nodiff?: boolean): El | null;\nexport function assignEl<El extends HTMLElement>(el?: El | null, props?: Partial<El>, dataset?: Dataset, styles?: Style, nodiff?: boolean): El | null;\nexport function assignEl(el?: HTMLElement | null, props?: Record<string, unknown>, dataset?: Dataset, styles?: Style, nodiff = true): HTMLElement | null {\n if (!el) return null;\n if (props) for (const k of Object.keys(props)) if (props[k] !== undefined) if (nodiff || (el as any)[k] !== props[k]) (el as unknown as Record<string, unknown>)[k] = props[k];\n if (dataset) for (const k of Object.keys(dataset)) if (dataset[k] !== undefined) if (nodiff || (el.dataset as any)[k] !== dataset[k]) (el.dataset as DOMStringMap)[k] = String(dataset[k]);\n if (styles) for (const k of Object.keys(styles)) if (styles[k as keyof Style] !== undefined) if (nodiff || (el.style as any)[k] !== styles[k as any]) (el.style as unknown as Record<string, unknown>)[k] = styles[k as keyof Style];\n return el;\n}\n\n/** Get the currently active element, traversing into shadow roots if necessary.\n * @param root Root node to start searching from, defaults to the main document.\n * @param noBody If `true`, will return `null` if the active element is the body element.\n * @returns The active element or null if none found.\n */\nexport function getActiveEl(root?: Document | ShadowRoot | null, noBody = true): Element | null {\n const activeEl = (root ?? document).activeElement;\n return !activeEl || (noBody && activeEl === document.body) ? null : activeEl.shadowRoot ? getActiveEl(activeEl.shadowRoot) : activeEl;\n}\n","import { getActiveEl } from \"./dom\";\r\n\r\n/** Keyboard matching configuration used by utility helpers. */\r\nexport interface KeysSettings {\r\n /** Disables key handling when true. Defaults to `false`. */\r\n disabled?: boolean;\r\n /** Combos that should call `preventDefault` when matched. */\r\n overrides?: string[];\r\n /** Action map from action id to combo or combo list. */\r\n shortcuts?: Record<string, string | string[]>;\r\n /** Combos that should be rejected immediately. Defaults to `KEYS_BLOCKS`. */\r\n blocks?: string[];\r\n /** Enables exact combo matching instead of subset matching. Defaults to `false`. */\r\n strictMatch?: boolean;\r\n /** Ranks shortcut matches by exactness before insertion order. Defaults to `true`. */\r\n rankedMatch?: boolean;\r\n /** Links keyup events to their pair keydown event, returning `false` if propagation was stopped. Defaults to `false`. */\r\n linkedPhase?: boolean;\r\n /** Combos that are allowed as pass-through key actions. */\r\n whitelist?: readonly string[];\r\n /** Actions or clean keys permitted to match even when heavy modifiers are held. */\r\n moddedlist?: string[];\r\n}\r\n\r\n/** Canonical key-combo structure used by parser and serializer helpers. */\r\nexport type KeyStruct = Record<\"ctrlKey\" | \"shiftKey\" | \"altKey\" | \"metaKey\", boolean> & { key: string };\r\n\r\n/**\r\n * Global registry of native browser hotkeys and shortcut combinations, pass as `.blocks` in `Settings` config for `keyEventAllowed()` for better UX.\r\n * Used by the system to prevent default browser behaviors (e.g., zooming, tab switching, refreshing, or opening dev tools) inside the listener context.\r\n */\r\n// prettier-ignore\r\nexport const KEYS_BLOCKS = [\"Ctrl+Tab\", \"Ctrl+Shift+Tab\", \"Ctrl+PageUp\", \"Ctrl+PageDown\", \"Cmd+Option+ArrowRight\", \"Cmd+Option+ArrowLeft\", \"Ctrl+1\", \"Ctrl+2\", \"Ctrl+3\", \"Ctrl+4\", \"Ctrl+5\", \"Ctrl+6\", \"Ctrl+7\", \"Ctrl+8\", \"Ctrl+9\", \"Cmd+1\", \"Cmd+2\", \"Cmd+3\", \"Cmd+4\", \"Cmd+5\", \"Cmd+6\", \"Cmd+7\", \"Cmd+8\", \"Cmd+9\", \"Alt+ArrowLeft\", \"Alt+ArrowRight\", \"Cmd+ArrowLeft\", \"Cmd+ArrowRight\", \"Ctrl+r\", \"Ctrl+Shift+r\", \"F5\", \"Shift+F5\", \"Cmd+r\", \"Cmd+Shift+r\", \"Ctrl+h\", \"Ctrl+j\", \"Ctrl+d\", \"Ctrl+f\", \"Cmd+y\", \"Cmd+Option+b\", \"Cmd+d\", \"Cmd+f\", \"Ctrl+Shift+i\", \"Ctrl+Shift+j\", \"Ctrl+Shift+c\", \"Ctrl+u\", \"F12\", \"Cmd+Option+i\", \"Cmd+Option+j\", \"Cmd+Option+c\", \"Cmd+Option+u\", \"Ctrl+=\", \"Ctrl+-\", \"Ctrl+0\", \"Cmd+=\", \"Cmd+-\", \"Cmd+0\", \"Ctrl+p\", \"Ctrl+s\", \"Ctrl+o\", \"Cmd+p\", \"Cmd+s\", \"Cmd+o\"], // JIT eats loops :)\r\n KEYS_MODS = [\"ctrl\", \"shift\", \"alt\", \"meta\"] as const,\r\n KEYS_CMODS = [\"ctrl\", \"alt\", \"meta\"] as const,\r\n KEYS_ALIAS: Record<string, string> = { cmd: \"meta\", space: \" \" };\r\n\r\n/**\r\n * Parses a combo string into modifier flags + terminal key.\r\n * @param combo Key combo string (for example: `\"ctrl+shift+z\"`).\r\n * @returns Parsed key structure with boolean modifier flags.\r\n * @example\r\n * parseKeyCombo(\"ctrl+shift+z\")\r\n * // => { ctrlKey: true, shiftKey: true, altKey: false, metaKey: false, key: \"z\" }\r\n */\r\nexport function parseKeyCombo(combo: string): KeyStruct {\r\n const parts = cleanKeyCombo(combo).toLowerCase().split(\"+\");\r\n return { ctrlKey: parts.includes(\"ctrl\"), shiftKey: parts.includes(\"shift\"), altKey: parts.includes(\"alt\"), metaKey: parts.includes(\"meta\") || parts.includes(\"cmd\"), key: parts.find((p) => !/^(ctrl|shift|alt|meta|cmd)$/.test(p)) || \"\" };\r\n}\r\n\r\n/**\r\n * Serializes a key structure or keyboard event into canonical combo form.\r\n * @param e KeyboardEvent-like object or parsed key structure.\r\n * @returns Canonical combo string (for example: `\"ctrl+shift+z\"`).\r\n */\r\nexport function stringifyKeyEvent(e: KeyStruct | KeyboardEvent): string {\r\n const parts: string[] = [];\r\n e.ctrlKey && parts.push(\"ctrl\"), e.altKey && parts.push(\"alt\"), e.shiftKey && parts.push(\"shift\"), e.metaKey && parts.push(\"meta\"), parts.push(e.key?.toLowerCase() ?? \"\");\r\n return parts.join(\"+\");\r\n}\r\n\r\n/**\r\n * Normalizes combo(s) by:\r\n * - lowercasing,\r\n * - aliasing `cmd -> meta`, `space -> \" \"`,\r\n * - preserving literal space/plus edge cases,\r\n * - sorting modifiers as `ctrl, alt, shift, meta`.\r\n * @param combo Raw combo or list of combos.\r\n * @param mods Optional list of modifier keys to sort and filter by (default: `[\"ctrl\", \"shift\", \"alt\", \"meta\"]`).\r\n * @returns Canonical combo string or list.\r\n * @example\r\n * cleanKeyCombo([\"Shift+Alt+Ctrl+Z\", \"cmd+y\"])\r\n * // => [\"ctrl+shift+alt+z\", \"meta+y\"]\r\n */\r\nexport function cleanKeyCombo(combo: string, mods?: string[]): string;\r\nexport function cleanKeyCombo(combo: string[], mods?: string[]): string[];\r\nexport function cleanKeyCombo(combo: string | string[], mods: string[] = KEYS_MODS as any): string | string[] {\r\n const clean = (combo: string): string => {\r\n if (combo === \" \" || combo === \"+\") return combo;\r\n combo = combo.replace(/\\+\\s*\\+$/, \"+plus\");\r\n const p = combo\r\n .toLowerCase()\r\n .split(\"+\")\r\n .filter((k) => k !== \"\")\r\n .map((k, _, __, tk = k.trim()) => KEYS_ALIAS[tk] || (tk === \"plus\" ? \"+\" : tk || \" \"));\r\n return [...p.filter((k) => mods.includes(k)).sort((a, b) => mods.indexOf(a) - mods.indexOf(b)), ...(p.filter((k) => !mods.includes(k)) || \"\")].join(\"+\");\r\n };\r\n return Array.isArray(combo) ? combo.map(clean) : clean(combo);\r\n}\r\n\r\n/**\r\n * Determines if actual combo satisfies required combo rule(s).\r\n * Non-strict mode performs subset matching (required keys must all be present).\r\n * Strict mode requires exact canonical equality.\r\n * @param required Required combo or combo list.\r\n * @param actual Actual combo string.\r\n * @param strict Whether to require exact match.\r\n * @param clean Whether to clean the actual combo.\r\n * @param modded Allow modifiers in non-strict mode. \"Shift\" is always allowed.\r\n * @returns `true` when match succeeds.\r\n */\r\nexport function matchKeys(required: string | string[], actual: string, strict = false, clean = true, modded = false): boolean {\r\n if (clean) actual = cleanKeyCombo(actual);\r\n const match = (req: string, actual: string): boolean => {\r\n req = cleanKeyCombo(req);\r\n if (strict) return req === actual;\r\n const reqs = req.split(\"+\"),\r\n reals = actual.split(\"+\");\r\n if (!modded) for (const mod of KEYS_CMODS) if (reals.includes(mod) && !reqs.includes(mod)) return false; // no unrequested heavy mods\r\n return reqs.every((k) => reals.includes(k));\r\n };\r\n return Array.isArray(required) ? required.some((req) => match(req, actual)) : match(required, actual);\r\n}\r\n\r\n/**\r\n * Resolves key-combo terms against settings:\r\n * - override, block, whitelist, and matched action id.\r\n * @param combo Canonical combo string.\r\n * @param settings Matching settings.\r\n * @returns Match resolution record.\r\n */\r\nexport function getTermsForKey(combo: string, settings: KeysSettings): { override: boolean; block: boolean; whitelisted: boolean; action: string | null } {\r\n const terms = { override: false, block: false, whitelisted: false, action: null as string | null },\r\n { overrides = [], shortcuts = {}, blocks = [], strictMatch: stm = false, rankedMatch: ram = true, whitelist = [], moddedlist = [] } = settings || {};\r\n combo = cleanKeyCombo(combo);\r\n if (matchKeys(overrides, combo, stm, false)) terms.override = true;\r\n if (matchKeys(blocks, combo, stm, false)) terms.block = true;\r\n if (whitelist.some((w, _, __, cw = cleanKeyCombo(w)) => matchKeys(cw, combo, stm, false, moddedlist.includes(cw)))) terms.whitelisted = true;\r\n if (!ram) return (terms.action = Object.keys(shortcuts).find((id) => shortcuts[id] && matchKeys(shortcuts[id], combo, stm, false, moddedlist.includes(id))) || null), terms;\r\n // prettier-ignore\r\n let bestA: string | null = null, bestE = false, bestL = 0;\r\n for (const id of Object.keys(shortcuts))\r\n for (const c of Array.isArray(shortcuts[id]) ? shortcuts[id] : [shortcuts[id]]) {\r\n // prettier-ignore\r\n const req = c && cleanKeyCombo(c), isE = req === combo, len = req ? req.split(\"+\").length : 0;\r\n if (c && matchKeys(req, combo, stm, false, moddedlist.includes(id)) && (!bestA || (isE && !bestE) || (isE === bestE && len > bestL))) (bestA = id), (bestE = isE), (bestL = len);\r\n }\r\n return (terms.action = bestA), terms;\r\n}\r\n\r\n/**\r\n * Evaluates whether a keyboard event is allowed and maps it to an action id.\r\n * Behavior order:\r\n * 1. hard gate checks (`disabled`, focused editable, button-space/enter),\r\n * 2. blocked combos,\r\n * 3. override combos (`preventDefault`),\r\n * 4. shortcut action match,\r\n * 5. whitelist pass-through.\r\n * @param e Browser keyboard event.\r\n * @param settings Matching settings.\r\n * @returns Action id, pass-through key, or `false` when denied.\r\n */\r\nexport function keyEventAllowed<const S extends KeysSettings>(e: KeyboardEvent, settings: S): false | (S[\"shortcuts\"] extends object ? keyof S[\"shortcuts\"] : never) | (S[\"whitelist\"] extends readonly string[] ? (string[] extends S[\"whitelist\"] ? never : Lowercase<S[\"whitelist\"][number]>) : never) {\r\n if (settings.disabled) return false;\r\n if (settings.linkedPhase)\r\n if (e.type === \"keydown\") downKeys.set(e.code, e);\r\n else if (e.type === \"keyup\") {\r\n const down = downKeys.get(e.code);\r\n setTimeout(() => downKeys.delete(e.code), 0); // Delay deletion so peer/parent listeners in the event chain can still read it\r\n if (!down || down.cancelBubble) return false; // If !down, a child element stopped the keydown before it reached us. If down.cancelBubble, a peer listener stopped it.\r\n }\r\n const activeEl = getActiveEl((e.target as Node)?.ownerDocument); // shadow DOM proof\r\n if ((e.key === \" \" || e.key === \"Enter\") && activeEl?.matches(\"button,input[type='button'],input[type='submit']\")) return false;\r\n if (e.currentTarget !== activeEl && activeEl?.matches(\"input,textarea,[contenteditable]\") && !(e.key === \"Escape\" && !e.ctrlKey && !e.shiftKey && !e.altKey && !e.metaKey)) return false;\r\n const combo = stringifyKeyEvent(e),\r\n { override, block, action, whitelisted } = getTermsForKey(combo, settings);\r\n if (block) return false;\r\n if (override) e.preventDefault();\r\n if (action) return action as any;\r\n if (whitelisted) return e.key.toLowerCase() as any;\r\n return false;\r\n}\r\nconst downKeys = new Map<string, KeyboardEvent>();\r\n\r\n/**\r\n * Formats one or many combos for human-readable UI labels, prepends \" \" for fluid appending.\r\n * @param combo Combo or combo list.\r\n * @param keyFn Function to format each combo.\r\n * @returns Display label (for example: `\" (ctrl+z) or (meta+z)\"`).\r\n */\r\nexport const formatKeyTooltip = (combo: string | string[] = \"\", keyFn = (c = \"\") => cleanKeyCombo(c).replace(\" \", \"space\")): string => {\r\n const combined = combo?.length ? (Array.isArray(combo) ? combo.map(keyFn).join(\" or \") : keyFn(combo)) : \"\";\r\n return combined ? ` (${combined})` : \"\";\r\n};\r\n\r\n/**\r\n * Formats an action-shortcuts map for display labels.\r\n * @param keyShortcuts Action to combo(s) map.\r\n * @returns Action to display-label map.\r\n */\r\nexport function formatKeyShortcutsTooltip(keyShortcuts: Record<string, string | string[]> = {}, formatter = formatKeyTooltip): Record<string, string> {\r\n const shortcuts: Record<string, string> = {};\r\n for (const action of Object.keys(keyShortcuts)) shortcuts[action] = formatter(keyShortcuts[action]);\r\n return shortcuts;\r\n}\r\n\r\n/**\r\n * Converts combo text into WAI-ARIA `aria-keyshortcuts` format.\r\n * @param s Combo text or combo list.\r\n * @param format Whether to format to tooltip first.\r\n * @returns Normalized aria-keyshortcuts string.\r\n * @example\r\n * parseForARIAKS(\" (ctrl+z) or (meta+z)\")\r\n * // => \"Control+z Meta+z\"\r\n * @example\r\n * parseForARIAKS([\"ctrl+z\", \"meta+z\"], false)\r\n * // => \"Control+z Meta+z\"\r\n */\r\nexport function parseForARIAKS(s: string | string[] = \"\", format = true) {\r\n const m = { ctrl: \"Control\", cmd: \"Meta\", space: \"Space\", plus: \"+\" };\r\n return (!format && !Array.isArray(s) ? s : formatKeyTooltip(s))\r\n .toLowerCase()\r\n .replace(/[()]/g, \"\") // 1. Remove parens\r\n .replace(/\\bor\\b/g, \" \") // 2. Replace \"or\" with the REQUIRED space\r\n .replace(/\\w+/g, (k: any) => m[k as keyof typeof m] || k) // 3. Map keys (ctrl -> Control)\r\n .replace(/\\s+/g, \" \")\r\n .trim(); // 4. Cleanup extra spaces\r\n} // W3 ARIA Key Shortcut\r\n"],"mappings":";;;;;AASO,SAAS,aAAa,OAAY,UAAgD,UAAU,MAAM,SAAS,OAAa;AAC7H,MAAI,QAAQ;AACZ,SAAO,SAAS,UAAU,OAAO,WAAW;AAC1C,eAAW,UAAU,OAAO,oBAAoB,KAAK,GAAG;AACtD,UAAI,WAAW,cAAe;AAC9B,UAAI,UAAU,WAAW,OAAO,UAAU,eAAe,KAAK,OAAO,MAAM,EAAG;AAC9E,UAAI,eAAe,OAAO,OAAO,yBAAyB,OAAO,MAAM,GAAG,MAAO,UAAS,QAAQ,KAAK;AAAA,IACzG;AACA,IAAC,QAAQ,OAAO,eAAe,KAAK,GAAK,SAAS;AAAA,EACpD;AACF;AAMO,SAAS,eAAe,OAAkB;AAC/C,eAAa,OAAO,CAAC,QAAgBA,WAAe;AAClD,IAAAA,OAAM,MAAM,IAAIA,OAAM,MAAM,EAAE,KAAKA,MAAK;AAAA,EAC1C,CAAC;AACH;AAQO,SAAS,gBAAgB,OAAY,UAAsC,aAAa,QAAQ,MAAY;AACjH,eAAa,OAAO,CAAC,QAAgBA,WAAe;AAClD,IAAAA,OAAM,MAAM,IAAI,QAAQ,QAAQA,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
|
|
8
8
|
keyEventAllowed,
|
|
9
9
|
parseForARIAKS
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-3XANIODP.js";
|
|
11
11
|
import {
|
|
12
12
|
CTX,
|
|
13
13
|
NIL,
|
|
@@ -289,4 +289,4 @@ export {
|
|
|
289
289
|
effect,
|
|
290
290
|
TimeTravelConsole
|
|
291
291
|
};
|
|
292
|
-
//# sourceMappingURL=chunk-
|
|
292
|
+
//# sourceMappingURL=chunk-5L6BFMUJ.js.map
|
|
@@ -2,7 +2,7 @@ import {
|
|
|
2
2
|
guardAllMethods,
|
|
3
3
|
guardMethod,
|
|
4
4
|
mirror
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-3XANIODP.js";
|
|
6
6
|
import {
|
|
7
7
|
getPath,
|
|
8
8
|
getReactor,
|
|
@@ -145,4 +145,4 @@ export {
|
|
|
145
145
|
BaseReactorModule,
|
|
146
146
|
wpArr
|
|
147
147
|
};
|
|
148
|
-
//# sourceMappingURL=chunk-
|
|
148
|
+
//# sourceMappingURL=chunk-XM6ELUFF.js.map
|
|
@@ -213,7 +213,7 @@ declare class TimeTravelModule<T extends object = any, P extends Paths<T> = Path
|
|
|
213
213
|
pause(): void;
|
|
214
214
|
/**
|
|
215
215
|
* Export the current time-travel session state as a JSON string.
|
|
216
|
-
|
|
216
|
+
* @param replacer Optional replacer function used by `JSON.stringify`.
|
|
217
217
|
* @param space Optional spacing parameter for pretty-printing.
|
|
218
218
|
* @returns The serialized session JSON.
|
|
219
219
|
*/
|
|
@@ -213,7 +213,7 @@ declare class TimeTravelModule<T extends object = any, P extends Paths<T> = Path
|
|
|
213
213
|
pause(): void;
|
|
214
214
|
/**
|
|
215
215
|
* Export the current time-travel session state as a JSON string.
|
|
216
|
-
|
|
216
|
+
* @param replacer Optional replacer function used by `JSON.stringify`.
|
|
217
217
|
* @param space Optional spacing parameter for pretty-printing.
|
|
218
218
|
* @returns The serialized session JSON.
|
|
219
219
|
*/
|
package/dist/modules.cjs
CHANGED
|
@@ -1055,8 +1055,10 @@ function guardMethod(fn, onError = (e) => console.error(e)) {
|
|
|
1055
1055
|
}
|
|
1056
1056
|
|
|
1057
1057
|
// src/ts/utils/str.ts
|
|
1058
|
-
function mirror(path, read = true) {
|
|
1059
|
-
|
|
1058
|
+
function mirror(path, obj, read = true) {
|
|
1059
|
+
if ("boolean" === typeof obj) read = obj, obj = void 0;
|
|
1060
|
+
const m = read ? !path.includes("intent") ? path : path.replace("intent", "state") : !path.includes("state") ? path : path.replace("state", "intent");
|
|
1061
|
+
return !obj || hasPath(obj, m) ? m : path;
|
|
1060
1062
|
}
|
|
1061
1063
|
|
|
1062
1064
|
// src/ts/modules/base/index.ts
|
|
@@ -1663,8 +1665,7 @@ var PersistModule = class extends BaseReactorModule {
|
|
|
1663
1665
|
let ticks = this.tickMap.get(rid);
|
|
1664
1666
|
for (let i = 0, len = blacks.length; i < len; i++) deletePath(entry, blacks[i]);
|
|
1665
1667
|
for (let i = 0, len = whites.length; i < len; i++) {
|
|
1666
|
-
|
|
1667
|
-
const _path = whites[i], path = !this.config.mirrorWrites || (_mirror = mirror(_path, false)) === _path || !hasPath(rtr.core, _mirror) ? _path : _mirror, value = getPath(entry, _path);
|
|
1668
|
+
const _path = whites[i], path = !this.config.mirrorWrites ? _path : mirror(_path, rtr.core, false), value = getPath(entry, _path);
|
|
1668
1669
|
value !== void 0 && (set(path, getPath(rtr.core, path), value), (ticks || (this.tickMap.set(rid, ticks = []), ticks)).push(path));
|
|
1669
1670
|
}
|
|
1670
1671
|
tick && (rtr.tick(depth || !this.config.whitelist ? "*" : ticks || []), this.tickMap.delete(rid));
|
|
@@ -1731,7 +1732,7 @@ var TimeTravelModule = class extends BaseReactorModule {
|
|
|
1731
1732
|
if (!this.state.paused || !(this.tracked ?? this.state.tracking) || e.silent) return;
|
|
1732
1733
|
this.prune();
|
|
1733
1734
|
const timestamp = e.timestamp ?? performance.now();
|
|
1734
|
-
let _mirror, en = { path: e.target.path, to: e.reactor.snapshot(false, e.target.value), from: e.reactor.snapshot(false, !this.config.mirrorReads || (_mirror = mirror(e.target.path)) === e.target.path
|
|
1735
|
+
let _mirror, en = { path: e.target.path, to: e.reactor.snapshot(false, e.target.value), from: e.reactor.snapshot(false, !this.config.mirrorReads || (_mirror = mirror(e.target.path, e.reactor.core)) === e.target.path ? e.target.oldValue : getPath(e.reactor.core, _mirror)), type: e.staticType ?? e.type, rid, deltat: timestamp - this.timestamp };
|
|
1735
1736
|
!e.target.hadKey && (en.hadKey = false);
|
|
1736
1737
|
const px = e.tx && this.txMap.get(e.tx) || null;
|
|
1737
1738
|
if (this.config.beforeEntry) {
|
|
@@ -1801,8 +1802,7 @@ var TimeTravelModule = class extends BaseReactorModule {
|
|
|
1801
1802
|
applyNode(node, forward = true) {
|
|
1802
1803
|
if ("nodes" in node) for (let len = node.nodes.length, i = forward ? 0 : len - 1; forward ? i < len : i >= 0; forward ? i++ : i--) this.applyNode(node.nodes[i], forward);
|
|
1803
1804
|
else {
|
|
1804
|
-
|
|
1805
|
-
const rtr = this.deps.get(node.rid) || this.deps.values().next().value, path = !this.config.mirrorWrites || (_mirror = mirror(node.path, false)) === node.path || !hasPath(rtr.core, _mirror) ? node.path : _mirror;
|
|
1805
|
+
const rtr = this.deps.get(node.rid) || this.deps.values().next().value, path = !this.config.mirrorWrites ? node.path : mirror(node.path, rtr.core, false);
|
|
1806
1806
|
(forward ? node.type === "delete" : node.hadKey === false) ? deletePath(rtr.core, path) : setPath(rtr.core, path, deepClone(forward ? node.to : node.from, rtr.config));
|
|
1807
1807
|
}
|
|
1808
1808
|
}
|
|
@@ -1879,7 +1879,7 @@ var TimeTravelModule = class extends BaseReactorModule {
|
|
|
1879
1879
|
// ===========================================================================
|
|
1880
1880
|
/**
|
|
1881
1881
|
* Export the current time-travel session state as a JSON string.
|
|
1882
|
-
|
|
1882
|
+
* @param replacer Optional replacer function used by `JSON.stringify`.
|
|
1883
1883
|
* @param space Optional spacing parameter for pretty-printing.
|
|
1884
1884
|
* @returns The serialized session JSON.
|
|
1885
1885
|
*/
|