sigmx 0.1.0 → 0.1.1
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 +52 -41
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +2 -2
- package/dist/kernel/compile.js.map +2 -2
- package/dist/kernel/contracts.d.ts +1 -8
- package/dist/kernel/index.d.ts +10 -11
- package/dist/kernel/index.js +10 -7
- package/dist/kernel/index.js.map +3 -3
- package/dist/kernel/precompile.d.ts +0 -2
- package/dist/kernel/precompile.js +11 -4
- package/dist/kernel/precompile.js.map +2 -2
- package/dist/kernel/precompiled.js.map +2 -2
- package/dist/kernel/reactive.d.ts +6 -10
- package/dist/kernel/reactive.js +4 -8
- package/dist/kernel/reactive.js.map +2 -2
- package/dist/kernel/runtime.js +19 -7
- package/dist/kernel/runtime.js.map +2 -2
- package/dist/kernel/scan.d.ts +1 -10
- package/dist/kernel/scan.js +24 -7
- package/dist/kernel/scan.js.map +2 -2
- package/dist/kernel/state.d.ts +1 -5
- package/dist/kernel/state.js +49 -22
- package/dist/kernel/state.js.map +2 -2
- package/dist/kernel/strict-csp.js.map +1 -1
- package/dist/lib/casing.js.map +2 -2
- package/dist/lib/objects.d.ts +0 -1
- package/dist/lib/objects.js +4 -1
- package/dist/lib/objects.js.map +2 -2
- package/dist/lib/schedule.d.ts +0 -2
- package/dist/lib/schedule.js.map +2 -2
- package/dist/lib/sse.d.ts +0 -1
- package/dist/lib/sse.js +3 -2
- package/dist/lib/sse.js.map +2 -2
- package/dist/plugins/directives/attribute-sync.js.map +1 -1
- package/dist/plugins/directives/boost.js +2 -1
- package/dist/plugins/directives/boost.js.map +2 -2
- package/dist/plugins/directives/busy-flag.js.map +1 -1
- package/dist/plugins/directives/class-toggle.js.map +1 -1
- package/dist/plugins/directives/cloak.js.map +1 -1
- package/dist/plugins/directives/collapse.js.map +1 -1
- package/dist/plugins/directives/declare.js.map +1 -1
- package/dist/plugins/directives/derive.js +4 -1
- package/dist/plugins/directives/derive.js.map +2 -2
- package/dist/plugins/directives/element-ref.js.map +1 -1
- package/dist/plugins/directives/event-listener.js +4 -1
- package/dist/plugins/directives/event-listener.js.map +2 -2
- package/dist/plugins/directives/frame-loop.js.map +1 -1
- package/dist/plugins/directives/html.js.map +1 -1
- package/dist/plugins/directives/inline-style.js +1 -1
- package/dist/plugins/directives/inline-style.js.map +2 -2
- package/dist/plugins/directives/mask.js.map +1 -1
- package/dist/plugins/directives/media-query.js +2 -1
- package/dist/plugins/directives/media-query.js.map +2 -2
- package/dist/plugins/directives/on-mount.js +4 -1
- package/dist/plugins/directives/on-mount.js.map +2 -2
- package/dist/plugins/directives/patch-listener.js.map +1 -1
- package/dist/plugins/directives/remove-me.js.map +1 -1
- package/dist/plugins/directives/scroll-to.js.map +1 -1
- package/dist/plugins/directives/size-watch.js.map +1 -1
- package/dist/plugins/directives/state-dump.js.map +1 -1
- package/dist/plugins/directives/storage-sync.js.map +1 -1
- package/dist/plugins/directives/teleport.js.map +1 -1
- package/dist/plugins/directives/text-content.js.map +1 -1
- package/dist/plugins/directives/timer.js.map +1 -1
- package/dist/plugins/directives/transition-name.js.map +1 -1
- package/dist/plugins/directives/transition.js.map +1 -1
- package/dist/plugins/directives/trap.js +8 -2
- package/dist/plugins/directives/trap.js.map +2 -2
- package/dist/plugins/directives/tween.js.map +2 -2
- package/dist/plugins/directives/two-way-bind.js +37 -7
- package/dist/plugins/directives/two-way-bind.js.map +2 -2
- package/dist/plugins/directives/url-params.js +2 -1
- package/dist/plugins/directives/url-params.js.map +2 -2
- package/dist/plugins/directives/url-replace.js.map +1 -1
- package/dist/plugins/directives/validity.js.map +1 -1
- package/dist/plugins/directives/viewport.js +4 -1
- package/dist/plugins/directives/viewport.js.map +2 -2
- package/dist/plugins/directives/visibility.js.map +1 -1
- package/dist/plugins/directives/watch.d.ts +0 -1
- package/dist/plugins/directives/watch.js.map +2 -2
- package/dist/plugins/functions/bulk-set.js +5 -3
- package/dist/plugins/functions/bulk-set.js.map +2 -2
- package/dist/plugins/functions/bulk-toggle.js +5 -3
- package/dist/plugins/functions/bulk-toggle.js.map +2 -2
- package/dist/plugins/functions/confirm.js.map +1 -1
- package/dist/plugins/functions/copy-text.js.map +1 -1
- package/dist/plugins/functions/dispatch.js.map +2 -2
- package/dist/plugins/functions/locale-format.js.map +1 -1
- package/dist/plugins/functions/range-map.js.map +1 -1
- package/dist/plugins/functions/request.js +19 -5
- package/dist/plugins/functions/request.js.map +2 -2
- package/dist/plugins/functions/untracked-read.js.map +1 -1
- package/dist/plugins/functions/websocket.js +5 -1
- package/dist/plugins/functions/websocket.js.map +2 -2
- package/dist/plugins/index.d.ts +36 -36
- package/dist/plugins/index.js +33 -33
- package/dist/plugins/index.js.map +2 -2
- package/dist/plugins/server-events/apply-elements.js +4 -1
- package/dist/plugins/server-events/apply-elements.js.map +2 -2
- package/dist/plugins/server-events/apply-state.js.map +1 -1
- package/dist/plugins/server-events/morph.d.ts +0 -2
- package/dist/plugins/server-events/morph.js +31 -8
- package/dist/plugins/server-events/morph.js.map +2 -2
- package/dist/presets/all.d.ts +0 -1
- package/dist/presets/all.js +23 -23
- package/dist/presets/all.js.map +2 -2
- package/dist/presets/essentials.d.ts +0 -1
- package/dist/presets/essentials.js +27 -9
- package/dist/presets/essentials.js.map +2 -2
- package/dist/presets/minimal.d.ts +0 -1
- package/dist/presets/minimal.js +2 -2
- package/dist/presets/minimal.js.map +2 -2
- package/dist/server.d.ts +102 -0
- package/dist/server.js +190 -0
- package/dist/server.js.map +7 -0
- package/dist/sigmx.standalone.js +1 -1
- package/dist/standalone.js.map +2 -2
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +31 -8
- package/dist/vite.js.map +2 -2
- package/package.json +19 -2
- package/dist/auto.d.ts +0 -1
- package/dist/auto.js +0 -7
- package/dist/auto.js.map +0 -7
- package/dist/core/csp.d.ts +0 -7
- package/dist/core/csp.js +0 -20
- package/dist/core/csp.js.map +0 -7
- package/dist/core/engine.d.ts +0 -10
- package/dist/core/engine.js +0 -200
- package/dist/core/engine.js.map +0 -7
- package/dist/core/expr.d.ts +0 -12
- package/dist/core/expr.js +0 -94
- package/dist/core/expr.js.map +0 -7
- package/dist/core/index.d.ts +0 -16
- package/dist/core/index.js +0 -46
- package/dist/core/index.js.map +0 -7
- package/dist/core/signals.d.ts +0 -42
- package/dist/core/signals.js +0 -195
- package/dist/core/signals.js.map +0 -7
- package/dist/core/store.d.ts +0 -32
- package/dist/core/store.js +0 -185
- package/dist/core/store.js.map +0 -7
- package/dist/core/types.d.ts +0 -101
- package/dist/core/types.js +0 -1
- package/dist/core/types.js.map +0 -7
- package/dist/plugins/actions/clipboard.d.ts +0 -2
- package/dist/plugins/actions/clipboard.js +0 -11
- package/dist/plugins/actions/clipboard.js.map +0 -7
- package/dist/plugins/actions/fit.d.ts +0 -2
- package/dist/plugins/actions/fit.js +0 -14
- package/dist/plugins/actions/fit.js.map +0 -7
- package/dist/plugins/actions/intl.d.ts +0 -2
- package/dist/plugins/actions/intl.js +0 -21
- package/dist/plugins/actions/intl.js.map +0 -7
- package/dist/plugins/actions/peek.d.ts +0 -2
- package/dist/plugins/actions/peek.js +0 -6
- package/dist/plugins/actions/peek.js.map +0 -7
- package/dist/plugins/actions/setAll.d.ts +0 -2
- package/dist/plugins/actions/setAll.js +0 -11
- package/dist/plugins/actions/setAll.js.map +0 -7
- package/dist/plugins/actions/toggleAll.d.ts +0 -2
- package/dist/plugins/actions/toggleAll.js +0 -11
- package/dist/plugins/actions/toggleAll.js.map +0 -7
- package/dist/plugins/attributes/attr.d.ts +0 -2
- package/dist/plugins/attributes/attr.js +0 -20
- package/dist/plugins/attributes/attr.js.map +0 -7
- package/dist/plugins/attributes/bind.d.ts +0 -6
- package/dist/plugins/attributes/bind.js +0 -81
- package/dist/plugins/attributes/bind.js.map +0 -7
- package/dist/plugins/attributes/class.d.ts +0 -2
- package/dist/plugins/attributes/class.js +0 -22
- package/dist/plugins/attributes/class.js.map +0 -7
- package/dist/plugins/attributes/computed.d.ts +0 -2
- package/dist/plugins/attributes/computed.js +0 -20
- package/dist/plugins/attributes/computed.js.map +0 -7
- package/dist/plugins/attributes/customValidity.d.ts +0 -2
- package/dist/plugins/attributes/customValidity.js +0 -14
- package/dist/plugins/attributes/customValidity.js.map +0 -7
- package/dist/plugins/attributes/effect.d.ts +0 -2
- package/dist/plugins/attributes/effect.js +0 -12
- package/dist/plugins/attributes/effect.js.map +0 -7
- package/dist/plugins/attributes/indicator.d.ts +0 -2
- package/dist/plugins/attributes/indicator.js +0 -20
- package/dist/plugins/attributes/indicator.js.map +0 -7
- package/dist/plugins/attributes/init.d.ts +0 -2
- package/dist/plugins/attributes/init.js +0 -14
- package/dist/plugins/attributes/init.js.map +0 -7
- package/dist/plugins/attributes/jsonSignals.d.ts +0 -2
- package/dist/plugins/attributes/jsonSignals.js +0 -15
- package/dist/plugins/attributes/jsonSignals.js.map +0 -7
- package/dist/plugins/attributes/matchMedia.d.ts +0 -2
- package/dist/plugins/attributes/matchMedia.js +0 -19
- package/dist/plugins/attributes/matchMedia.js.map +0 -7
- package/dist/plugins/attributes/on.d.ts +0 -5
- package/dist/plugins/attributes/on.js +0 -28
- package/dist/plugins/attributes/on.js.map +0 -7
- package/dist/plugins/attributes/onIntersect.d.ts +0 -2
- package/dist/plugins/attributes/onIntersect.js +0 -28
- package/dist/plugins/attributes/onIntersect.js.map +0 -7
- package/dist/plugins/attributes/onInterval.d.ts +0 -2
- package/dist/plugins/attributes/onInterval.js +0 -18
- package/dist/plugins/attributes/onInterval.js.map +0 -7
- package/dist/plugins/attributes/onRaf.d.ts +0 -1
- package/dist/plugins/attributes/onRaf.js +0 -19
- package/dist/plugins/attributes/onRaf.js.map +0 -7
- package/dist/plugins/attributes/onResize.d.ts +0 -1
- package/dist/plugins/attributes/onResize.js +0 -17
- package/dist/plugins/attributes/onResize.js.map +0 -7
- package/dist/plugins/attributes/onSignalPatch.d.ts +0 -5
- package/dist/plugins/attributes/onSignalPatch.js +0 -35
- package/dist/plugins/attributes/onSignalPatch.js.map +0 -7
- package/dist/plugins/attributes/persist.d.ts +0 -6
- package/dist/plugins/attributes/persist.js +0 -16
- package/dist/plugins/attributes/persist.js.map +0 -7
- package/dist/plugins/attributes/queryString.d.ts +0 -5
- package/dist/plugins/attributes/queryString.js +0 -54
- package/dist/plugins/attributes/queryString.js.map +0 -7
- package/dist/plugins/attributes/ref.d.ts +0 -2
- package/dist/plugins/attributes/ref.js +0 -13
- package/dist/plugins/attributes/ref.js.map +0 -7
- package/dist/plugins/attributes/replaceUrl.d.ts +0 -1
- package/dist/plugins/attributes/replaceUrl.js +0 -11
- package/dist/plugins/attributes/replaceUrl.js.map +0 -7
- package/dist/plugins/attributes/scrollIntoView.d.ts +0 -2
- package/dist/plugins/attributes/scrollIntoView.js +0 -19
- package/dist/plugins/attributes/scrollIntoView.js.map +0 -7
- package/dist/plugins/attributes/show.d.ts +0 -2
- package/dist/plugins/attributes/show.js +0 -19
- package/dist/plugins/attributes/show.js.map +0 -7
- package/dist/plugins/attributes/signals.d.ts +0 -2
- package/dist/plugins/attributes/signals.js +0 -13
- package/dist/plugins/attributes/signals.js.map +0 -7
- package/dist/plugins/attributes/style.d.ts +0 -2
- package/dist/plugins/attributes/style.js +0 -25
- package/dist/plugins/attributes/style.js.map +0 -7
- package/dist/plugins/attributes/text.d.ts +0 -1
- package/dist/plugins/attributes/text.js +0 -13
- package/dist/plugins/attributes/text.js.map +0 -7
- package/dist/plugins/attributes/viewTransition.d.ts +0 -1
- package/dist/plugins/attributes/viewTransition.js +0 -11
- package/dist/plugins/attributes/viewTransition.js.map +0 -7
- package/dist/sigmx.auto.js +0 -5
- package/dist/utils/object.d.ts +0 -9
- package/dist/utils/object.js +0 -26
- package/dist/utils/object.js.map +0 -7
- package/dist/utils/text.d.ts +0 -7
- package/dist/utils/text.js +0 -15
- package/dist/utils/text.js.map +0 -7
- package/dist/utils/timing.d.ts +0 -14
- package/dist/utils/timing.js +0 -58
- package/dist/utils/timing.js.map +0 -7
package/dist/kernel/state.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/kernel/state.ts"],
|
|
4
|
-
"sourcesContent": ["
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import { expand, type Filter, isPlain, toPredicate } from '../lib/objects.js';\nimport { batch, Computed, onSettled, Signal } from './reactive.js';\n\nexport type Patch = Record<string, any>;\n\nexport interface Store {\n /** Value at a dotted path: a leaf value, a namespace proxy, or undefined. Reads subscribe. */\n get(path: string): any;\n /** Replace the value at a path. Plain objects become namespaces; null/undefined removes. */\n set(path: string, value: any): void;\n /** JSON merge-patch (RFC 7396): objects merge, null removes, everything else replaces. */\n merge(patch: Patch, options?: { at?: string; ifMissing?: boolean }): void;\n remove(path: string): void;\n has(path: string): boolean;\n define(path: string, node: Signal<any>): void;\n paths(filter?: Filter): string[];\n snapshot(filter?: Filter, options?: { at?: string; computed?: boolean }): Patch;\n /** Called after each settled batch with the nested object of changed paths (null = removed). */\n onPatch(fn: (patch: Patch) => void): () => void;\n readonly $: any;\n /** Identifier scope for compiled expressions: resolves `$count`, `$user`, and `$`. */\n readonly scope: object;\n}\n\nconst parentOf = (p: string): string => p.slice(0, Math.max(0, p.lastIndexOf('.')));\nconst nameOf = (p: string): string => p.slice(p.lastIndexOf('.') + 1);\nconst join = (a: string, b: string): string => (a ? `${a}.${b}` : b);\nconst under = (p: string, at: string): boolean => !at || p === at || p.startsWith(`${at}.`);\nconst str = (k: unknown): k is string => typeof k === 'string';\n\nexport const createStore = (): Store => {\n const leaves = new Map<string, Signal<any>>();\n const kids = new Map<string, Set<string>>([['', new Set()]]);\n const shape = new Signal(0); // bumped on any structural change; enumerations subscribe to it\n const pending = new Map<string, any>();\n const listeners = new Set<(p: Patch) => void>();\n const nsCache = new Map<string, any>();\n const arrCache = new WeakMap<object, any>();\n\n const ensureNs = (p: string): Set<string> => {\n let set = kids.get(p);\n if (!set) {\n if (leaves.has(p)) dropLeaf(p);\n set = new Set();\n kids.set(p, set);\n ensureNs(parentOf(p)).add(nameOf(p));\n shape.bump();\n }\n return set;\n };\n\n const dropLeaf = (p: string): void => {\n const s = leaves.get(p);\n if (!s) return;\n leaves.delete(p);\n kids.get(parentOf(p))?.delete(nameOf(p));\n pending.set(p, null);\n s.bump();\n shape.bump();\n };\n\n const dropNs = (p: string): void => {\n const set = kids.get(p);\n if (!set) return;\n for (const k of [...set]) remove(join(p, k));\n if (p) {\n kids.delete(p);\n kids.get(parentOf(p))?.delete(nameOf(p));\n nsCache.delete(p);\n }\n shape.bump();\n };\n\n const remove = (p: string): void =>\n batch(() => {\n dropLeaf(p);\n dropNs(p);\n });\n\n const define = (p: string, node: Signal<any>): void =>\n batch(() => {\n if (kids.has(p)) dropNs(p);\n const old = leaves.get(p);\n leaves.set(p, node);\n ensureNs(parentOf(p)).add(nameOf(p));\n old?.bump();\n shape.bump();\n });\n\n const set = (p: string, v: any): void =>\n batch(() => {\n if (v == null) return remove(p);\n if (isPlain(v)) {\n const names = ensureNs(p);\n for (const k of [...names]) if (!(k in v)) remove(join(p, k));\n for (const k in v) set(join(p, k), v[k]);\n return;\n }\n if (kids.has(p)) dropNs(p);\n const s = leaves.get(p);\n if (s instanceof Computed) throw new Error(`\"${p}\" is a computed signal and cannot be assigned`);\n if (s) {\n if (Object.is(s.peek(), v)) return;\n s.value = v;\n } else {\n define(p, new Signal(v));\n }\n pending.set(p, v);\n });\n\n const merge = (patch: Patch, { at = '', ifMissing = false } = {}): void =>\n batch(() => {\n if (!isPlain(patch)) return;\n ensureNs(at);\n for (const k in patch) {\n const p = join(at, k);\n const v = patch[k];\n if (v === null) {\n if (!ifMissing) remove(p);\n } else if (isPlain(v)) {\n merge(v, { at: p, ifMissing });\n } else if (!(ifMissing && (leaves.has(p) || kids.has(p))) && !(leaves.get(p) instanceof Computed)) {\n set(p, v); // computed leaves are skipped: patches from storage or a server cannot overwrite them\n }\n }\n });\n\n /** Arrays are returned through a proxy so in-place mutation notifies the leaf. */\n const wrapArray = (raw: any[], s: Signal<any>, p: string): any => {\n let px = arrCache.get(raw);\n if (!px) {\n const touch = () => {\n pending.set(p, raw);\n s.bump();\n };\n px = new Proxy(raw, {\n set: (t, k, v) => {\n (t as any)[k] = v;\n touch();\n return true;\n },\n deleteProperty: (t, k) => {\n delete (t as any)[k];\n touch();\n return true;\n },\n });\n arrCache.set(raw, px);\n }\n return px;\n };\n\n const get = (p: string): any => {\n const s = leaves.get(p);\n if (s) {\n const v = s.value;\n return Array.isArray(v) ? wrapArray(v, s, p) : v;\n }\n if (kids.has(p)) return ns(p);\n shape.value; // subscribe, so creating this path later re-runs the reader\n return undefined;\n };\n\n const ns = (p: string): any => {\n let px = nsCache.get(p);\n if (!px) {\n const names = () => {\n shape.value; // read so the effect tracks shape changes\n return kids.get(p);\n };\n px = new Proxy(\n {},\n {\n get: (_, k) =>\n !str(k) ? undefined : k === 'toJSON' ? () => snapshot(undefined, { at: p }) : get(join(p, k)),\n set: (_, k, v) => {\n if (str(k)) set(join(p, k), v);\n return true;\n },\n deleteProperty: (_, k) => {\n if (str(k)) remove(join(p, k));\n return true;\n },\n has: (_, k) => str(k) && !!names()?.has(k),\n ownKeys: () => [...(names() ?? [])],\n getOwnPropertyDescriptor: (_, k) =>\n str(k) && names()?.has(k)\n ? { enumerable: true, configurable: true, writable: true, value: get(join(p, k)) }\n : undefined,\n },\n );\n nsCache.set(p, px);\n }\n return px;\n };\n\n const scope = new Proxy(\n {},\n {\n has: (_, k) => str(k) && k[0] === '$',\n get: (_, k) => (!str(k) ? undefined : k === '$' ? ns('') : get(k.slice(1))),\n set: (_, k, v) => {\n if (str(k)) k === '$' ? merge(v) : set(k.slice(1), v);\n return true;\n },\n },\n );\n\n const paths = (filter?: Filter): string[] => {\n shape.value;\n const ok = toPredicate(filter);\n return [...leaves.keys()].filter(ok);\n };\n\n const snapshot = (filter?: Filter, { at = '', computed = true } = {}): Patch => {\n shape.value;\n const ok = toPredicate(filter);\n const out: Patch = {};\n const rel = (p: string) => (at ? p.slice(at.length + 1) : p);\n for (const [p, s] of leaves) {\n if (!under(p, at) || !ok(p) || (!computed && s instanceof Computed)) continue;\n expand(out, rel(p), s.value);\n }\n // Empty namespaces still appear as `{}`.\n for (const p of kids.keys()) {\n if (p && p !== at && under(p, at) && ok(p) && !kids.get(p)?.size) expand(out, rel(p), {});\n }\n return out;\n };\n\n onSettled(() => {\n if (!pending.size) return;\n const patch: Patch = {};\n for (const [p, v] of pending) expand(patch, p, v);\n pending.clear();\n for (const fn of listeners) fn(patch);\n });\n\n return {\n get,\n set,\n merge,\n remove,\n has: (p) => leaves.has(p) || kids.has(p),\n define,\n paths,\n snapshot,\n onPatch: (fn) => {\n listeners.add(fn);\n return () => listeners.delete(fn);\n },\n get $() {\n return ns('');\n },\n scope,\n };\n};\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAqB,SAAS,mBAAmB;AAC1D,SAAS,OAAO,UAAU,WAAW,cAAc;AAuBnD,MAAM,WAAW,CAAC,MAAsB,EAAE,MAAM,GAAG,KAAK,IAAI,GAAG,EAAE,YAAY,GAAG,CAAC,CAAC;AAClF,MAAM,SAAS,CAAC,MAAsB,EAAE,MAAM,EAAE,YAAY,GAAG,IAAI,CAAC;AACpE,MAAM,OAAO,CAAC,GAAW,MAAuB,IAAI,GAAG,CAAC,IAAI,CAAC,KAAK;AAClE,MAAM,QAAQ,CAAC,GAAW,OAAwB,CAAC,MAAM,MAAM,MAAM,EAAE,WAAW,GAAG,EAAE,GAAG;AAC1F,MAAM,MAAM,CAAC,MAA4B,OAAO,MAAM;AAE/C,MAAM,cAAc,MAAa;AACtC,QAAM,SAAS,oBAAI,IAAyB;AAC5C,QAAM,OAAO,oBAAI,IAAyB,CAAC,CAAC,IAAI,oBAAI,IAAI,CAAC,CAAC,CAAC;AAC3D,QAAM,QAAQ,IAAI,OAAO,CAAC;AAC1B,QAAM,UAAU,oBAAI,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,IACA,IAAI,IAAI;AACN,aAAO,GAAG,EAAE;AAAA,IACd;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["set"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/kernel/strict-csp.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Compiler } from './compile.js'
|
|
4
|
+
"sourcesContent": ["import type { Compiler } from './compile.js';\n\n/**\n * Compiler for pages with a strict Content-Security-Policy: compiles through a nonce-bearing\n * inline `<script>` (and a Trusted Types policy when present) instead of `new Function`.\n * Pass as `createSigmx({ compile: cspCompiler(nonce) })`.\n */\nexport const cspCompiler = (nonce: string): Compiler => {\n if (!nonce) throw new Error('cspCompiler needs the page nonce');\n const tt = (window as any).trustedTypes;\n const policy = tt?.createPolicy('sigmx', { createScript: (s: string) => s });\n return (params, body) => {\n const script = document.createElement('script');\n script.nonce = nonce;\n const text = `document.currentScript.f=function(${params.join(',')}){${body}}`;\n script.text = policy ? policy.createScript(text) : text;\n document.head.append(script);\n script.remove();\n const fn = (script as any).f;\n if (!fn) throw new Error('the Content-Security-Policy blocked expression compilation');\n return fn;\n };\n};\n"],
|
|
5
5
|
"mappings": "AAOO,MAAM,cAAc,CAAC,UAA4B;AACtD,MAAI,CAAC,MAAO,OAAM,IAAI,MAAM,kCAAkC;AAC9D,QAAM,KAAM,OAAe;AAC3B,QAAM,SAAS,IAAI,aAAa,SAAS,EAAE,cAAc,CAAC,MAAc,EAAE,CAAC;AAC3E,SAAO,CAAC,QAAQ,SAAS;AACvB,UAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,WAAO,QAAQ;AACf,UAAM,OAAO,qCAAqC,OAAO,KAAK,GAAG,CAAC,KAAK,IAAI;AAC3E,WAAO,OAAO,SAAS,OAAO,aAAa,IAAI,IAAI;AACnD,aAAS,KAAK,OAAO,MAAM;AAC3B,WAAO,OAAO;AACd,UAAM,KAAM,OAAe;AAC3B,QAAI,CAAC,GAAI,OAAM,IAAI,MAAM,4DAA4D;AACrF,WAAO;AAAA,EACT;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/casing.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/casing.ts"],
|
|
4
|
-
"sourcesContent": ["export type CaseStyle = 'camel' | 'kebab' | 'snake' | 'pascal'
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export type CaseStyle = 'camel' | 'kebab' | 'snake' | 'pascal';\n\nconst words = (s: string): string[] =>\n s\n .replace(/([a-z0-9])([A-Z])|([A-Z]+)([A-Z][a-z])/g, '$1$3 $2$4')\n .split(/[^A-Za-z0-9]+/)\n .filter(Boolean)\n .map((w) => w.toLowerCase());\n\nconst cap = (w: string): string => w[0].toUpperCase() + w.slice(1);\n\nexport const kebab = (s: string): string => words(s).join('-');\nexport const snake = (s: string): string => words(s).join('_');\nexport const camel = (s: string): string =>\n words(s)\n .map((w, i) => (i ? cap(w) : w))\n .join('');\nexport const pascal = (s: string): string => words(s).map(cap).join('');\n\nconst styles = { camel, kebab, snake, pascal };\n\n/** Recase a dotted path segment by segment so `user.first-name` becomes `user.firstName`. */\nexport const recase = (path: string, style: CaseStyle): string => path.split('.').map(styles[style]).join('.');\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,QAAQ,CAAC,MACb,EACG,QAAQ,2CAA2C,WAAW,EAC9D,MAAM,eAAe,EACrB,OAAO,OAAO,EACd,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC;AAE/B,MAAM,MAAM,CAAC,MAAsB,EAAE,CAAC,EAAE,YAAY,IAAI,EAAE,MAAM,CAAC;AAE1D,MAAM,QAAQ,CAAC,MAAsB,MAAM,CAAC,EAAE,KAAK,GAAG;AACtD,MAAM,QAAQ,CAAC,MAAsB,MAAM,CAAC,EAAE,KAAK,GAAG;AACtD,MAAM,QAAQ,CAAC,MACpB,MAAM,CAAC,EACJ,IAAI,CAAC,GAAG,MAAO,IAAI,IAAI,CAAC,IAAI,CAAE,EAC9B,KAAK,EAAE;AACL,MAAM,SAAS,CAAC,MAAsB,MAAM,CAAC,EAAE,IAAI,GAAG,EAAE,KAAK,EAAE;AAEtE,MAAM,SAAS,EAAE,OAAO,OAAO,OAAO,OAAO;AAGtC,MAAM,SAAS,CAAC,MAAc,UAA6B,KAAK,MAAM,GAAG,EAAE,IAAI,OAAO,KAAK,CAAC,EAAE,KAAK,GAAG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/objects.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export declare const isPlain: (v: unknown) => v is Record<string, any>;
|
|
2
|
-
/** Write `value` at a dotted path inside `out`, creating intermediate objects. */
|
|
3
2
|
export declare const expand: (out: Record<string, any>, path: string, value: any) => Record<string, any>;
|
|
4
3
|
export type Filter = {
|
|
5
4
|
include?: RegExp | string;
|
package/dist/lib/objects.js
CHANGED
|
@@ -7,7 +7,10 @@ const expand = (out, path, value) => {
|
|
|
7
7
|
const keys = path.split(".");
|
|
8
8
|
const last = keys.pop();
|
|
9
9
|
let cur = out;
|
|
10
|
-
for (const k of keys)
|
|
10
|
+
for (const k of keys) {
|
|
11
|
+
if (!isPlain(cur[k])) cur[k] = {};
|
|
12
|
+
cur = cur[k];
|
|
13
|
+
}
|
|
11
14
|
cur[last] = value;
|
|
12
15
|
return out;
|
|
13
16
|
};
|
package/dist/lib/objects.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/objects.ts"],
|
|
4
|
-
"sourcesContent": ["export const isPlain = (v: unknown): v is Record<string, any> => {\n if (v === null || typeof v !== 'object') return false
|
|
5
|
-
"mappings": "AAAO,MAAM,UAAU,CAAC,MAAyC;AAC/D,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAU,QAAO;AAChD,QAAM,QAAQ,OAAO,eAAe,CAAC;AACrC,SAAO,UAAU,OAAO,aAAa,UAAU;AACjD;
|
|
4
|
+
"sourcesContent": ["export const isPlain = (v: unknown): v is Record<string, any> => {\n if (v === null || typeof v !== 'object') return false;\n const proto = Object.getPrototypeOf(v);\n return proto === Object.prototype || proto === null;\n};\n\nexport const expand = (out: Record<string, any>, path: string, value: any): Record<string, any> => {\n const keys = path.split('.');\n const last = keys.pop() as string;\n let cur = out;\n for (const k of keys) {\n if (!isPlain(cur[k])) cur[k] = {};\n cur = cur[k];\n }\n cur[last] = value;\n return out;\n};\n\nexport type Filter = { include?: RegExp | string; exclude?: RegExp | string } | ((path: string) => boolean);\n\nconst re = (v: RegExp | string | undefined, fallback: RegExp): RegExp =>\n v === undefined ? fallback : typeof v === 'string' ? new RegExp(v.replace(/^\\/|\\/$/g, '')) : v;\n\n/** Turn `{ include, exclude }` (regex or string) or a predicate into a path predicate. */\nexport const toPredicate = (f?: Filter): ((path: string) => boolean) => {\n if (typeof f === 'function') return f;\n const inc = re(f?.include, /(?:)/);\n const exc = re(f?.exclude, /(?!)/);\n return (p) => inc.test(p) && !exc.test(p);\n};\n"],
|
|
5
|
+
"mappings": "AAAO,MAAM,UAAU,CAAC,MAAyC;AAC/D,MAAI,MAAM,QAAQ,OAAO,MAAM,SAAU,QAAO;AAChD,QAAM,QAAQ,OAAO,eAAe,CAAC;AACrC,SAAO,UAAU,OAAO,aAAa,UAAU;AACjD;AAEO,MAAM,SAAS,CAAC,KAA0B,MAAc,UAAoC;AACjG,QAAM,OAAO,KAAK,MAAM,GAAG;AAC3B,QAAM,OAAO,KAAK,IAAI;AACtB,MAAI,MAAM;AACV,aAAW,KAAK,MAAM;AACpB,QAAI,CAAC,QAAQ,IAAI,CAAC,CAAC,EAAG,KAAI,CAAC,IAAI,CAAC;AAChC,UAAM,IAAI,CAAC;AAAA,EACb;AACA,MAAI,IAAI,IAAI;AACZ,SAAO;AACT;AAIA,MAAM,KAAK,CAAC,GAAgC,aAC1C,MAAM,SAAY,WAAW,OAAO,MAAM,WAAW,IAAI,OAAO,EAAE,QAAQ,YAAY,EAAE,CAAC,IAAI;AAGxF,MAAM,cAAc,CAAC,MAA4C;AACtE,MAAI,OAAO,MAAM,WAAY,QAAO;AACpC,QAAM,MAAM,GAAG,GAAG,SAAS,MAAM;AACjC,QAAM,MAAM,GAAG,GAAG,SAAS,MAAM;AACjC,SAAO,CAAC,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/schedule.d.ts
CHANGED
|
@@ -7,8 +7,6 @@ export declare const delay: (fn: Fn, ms: number) => Fn;
|
|
|
7
7
|
export declare const debounce: (fn: Fn, ms: number, leading?: boolean, trailing?: boolean) => Fn;
|
|
8
8
|
/** Throttle: at most one call per window. `leading` fires immediately, `trailing` fires once at the end. */
|
|
9
9
|
export declare const throttle: (fn: Fn, ms: number, leading?: boolean, trailing?: boolean) => Fn;
|
|
10
|
-
/** Apply `__delay`, `__debounce` and `__throttle` modifiers to a callback. */
|
|
11
10
|
export declare const withTiming: (fn: Fn, mods: Mods) => Fn;
|
|
12
|
-
/** Wrap a callback in `document.startViewTransition` when `__viewtransition` is present and supported. */
|
|
13
11
|
export declare const withViewTransition: (fn: Fn, mods: Mods) => Fn;
|
|
14
12
|
export {};
|
package/dist/lib/schedule.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/schedule.ts"],
|
|
4
|
-
"sourcesContent": ["export type Mods = Map<string, string[]
|
|
5
|
-
"mappings": "AAIO,MAAM,OAAO,CAAC,MAA4B,WAAW,MAAc;AACxE,aAAW,KAAK,QAAQ,CAAC,GAAG;AAC1B,UAAM,IAAI,2BAA2B,KAAK,CAAC;AAC3C,QAAI,EAAG,QAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,MAAM,MAAO;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,
|
|
4
|
+
"sourcesContent": ["export type Mods = Map<string, string[]>;\ntype Fn = (...args: any[]) => void;\n\n/** '300ms' \u2192 300, '2s' \u2192 2000, '150' \u2192 150. */\nexport const toMs = (args: string[] | undefined, fallback = 0): number => {\n for (const a of args ?? []) {\n const m = /^(\\d+(?:\\.\\d+)?)(ms|s)?$/.exec(a);\n if (m) return +m[1] * (m[2] === 's' ? 1000 : 1);\n }\n return fallback;\n};\n\nexport const delay =\n (fn: Fn, ms: number): Fn =>\n (...args) =>\n void setTimeout(fn, ms, ...args);\n\n/** Shared rate limiter. `restart` makes it a debounce (the window restarts on every call). */\nconst limit = (fn: Fn, ms: number, leading: boolean, trailing: boolean, restart: boolean): Fn => {\n let timer: ReturnType<typeof setTimeout> | undefined;\n let last: any[] | undefined;\n const fire = () => {\n timer = undefined;\n if (trailing && last) fn(...last);\n last = undefined;\n };\n return (...args) => {\n if (timer) {\n last = args;\n if (restart) {\n clearTimeout(timer);\n timer = setTimeout(fire, ms);\n }\n return;\n }\n if (leading) fn(...args);\n else last = args;\n timer = setTimeout(fire, ms);\n };\n};\n\n/** Debounce: wait for a quiet period. `leading` fires on the first call, `trailing` on the last. */\nexport const debounce = (fn: Fn, ms: number, leading = false, trailing = true): Fn =>\n limit(fn, ms, leading, trailing, true);\n\n/** Throttle: at most one call per window. `leading` fires immediately, `trailing` fires once at the end. */\nexport const throttle = (fn: Fn, ms: number, leading = true, trailing = false): Fn =>\n limit(fn, ms, leading, trailing, false);\n\nexport const withTiming = (fn: Fn, mods: Mods): Fn => {\n const d = mods.get('delay');\n if (d) fn = delay(fn, toMs(d));\n const db = mods.get('debounce');\n if (db) fn = debounce(fn, toMs(db, 300), db.includes('leading'), !db.includes('notrailing'));\n const th = mods.get('throttle');\n if (th) fn = throttle(fn, toMs(th, 300), !th.includes('noleading'), th.includes('trailing'));\n return fn;\n};\n\nexport const withViewTransition = (fn: Fn, mods: Mods): Fn =>\n mods.has('viewtransition') && 'startViewTransition' in document\n ? (...args) => void document.startViewTransition(() => fn(...args))\n : fn;\n"],
|
|
5
|
+
"mappings": "AAIO,MAAM,OAAO,CAAC,MAA4B,WAAW,MAAc;AACxE,aAAW,KAAK,QAAQ,CAAC,GAAG;AAC1B,UAAM,IAAI,2BAA2B,KAAK,CAAC;AAC3C,QAAI,EAAG,QAAO,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC,MAAM,MAAM,MAAO;AAAA,EAC/C;AACA,SAAO;AACT;AAEO,MAAM,QACX,CAAC,IAAQ,OACT,IAAI,SACF,KAAK,WAAW,IAAI,IAAI,GAAG,IAAI;AAGnC,MAAM,QAAQ,CAAC,IAAQ,IAAY,SAAkB,UAAmB,YAAyB;AAC/F,MAAI;AACJ,MAAI;AACJ,QAAM,OAAO,MAAM;AACjB,YAAQ;AACR,QAAI,YAAY,KAAM,IAAG,GAAG,IAAI;AAChC,WAAO;AAAA,EACT;AACA,SAAO,IAAI,SAAS;AAClB,QAAI,OAAO;AACT,aAAO;AACP,UAAI,SAAS;AACX,qBAAa,KAAK;AAClB,gBAAQ,WAAW,MAAM,EAAE;AAAA,MAC7B;AACA;AAAA,IACF;AACA,QAAI,QAAS,IAAG,GAAG,IAAI;AAAA,QAClB,QAAO;AACZ,YAAQ,WAAW,MAAM,EAAE;AAAA,EAC7B;AACF;AAGO,MAAM,WAAW,CAAC,IAAQ,IAAY,UAAU,OAAO,WAAW,SACvE,MAAM,IAAI,IAAI,SAAS,UAAU,IAAI;AAGhC,MAAM,WAAW,CAAC,IAAQ,IAAY,UAAU,MAAM,WAAW,UACtE,MAAM,IAAI,IAAI,SAAS,UAAU,KAAK;AAEjC,MAAM,aAAa,CAAC,IAAQ,SAAmB;AACpD,QAAM,IAAI,KAAK,IAAI,OAAO;AAC1B,MAAI,EAAG,MAAK,MAAM,IAAI,KAAK,CAAC,CAAC;AAC7B,QAAM,KAAK,KAAK,IAAI,UAAU;AAC9B,MAAI,GAAI,MAAK,SAAS,IAAI,KAAK,IAAI,GAAG,GAAG,GAAG,SAAS,SAAS,GAAG,CAAC,GAAG,SAAS,YAAY,CAAC;AAC3F,QAAM,KAAK,KAAK,IAAI,UAAU;AAC9B,MAAI,GAAI,MAAK,SAAS,IAAI,KAAK,IAAI,GAAG,GAAG,CAAC,GAAG,SAAS,WAAW,GAAG,GAAG,SAAS,UAAU,CAAC;AAC3F,SAAO;AACT;AAEO,MAAM,qBAAqB,CAAC,IAAQ,SACzC,KAAK,IAAI,gBAAgB,KAAK,yBAAyB,WACnD,IAAI,SAAS,KAAK,SAAS,oBAAoB,MAAM,GAAG,GAAG,IAAI,CAAC,IAChE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/lib/sse.d.ts
CHANGED
|
@@ -4,7 +4,6 @@ export type ServerEvent = {
|
|
|
4
4
|
id?: string;
|
|
5
5
|
retry?: number;
|
|
6
6
|
};
|
|
7
|
-
/** Read a `text/event-stream` body, calling `onEvent` for each complete event. Resolves when the stream ends. */
|
|
8
7
|
export declare const readEvents: (body: ReadableStream<Uint8Array>, onEvent: (e: ServerEvent) => void) => Promise<void>;
|
|
9
8
|
/** Event payloads: each data line is `key value`; repeated keys join with newlines. */
|
|
10
9
|
export declare const parseFields: (data: string) => Record<string, string>;
|
package/dist/lib/sse.js
CHANGED
|
@@ -27,8 +27,9 @@ const readEvents = async (body, onEvent) => {
|
|
|
27
27
|
const { value, done } = await reader.read();
|
|
28
28
|
if (done) break;
|
|
29
29
|
buffer += decoder.decode(value, { stream: true });
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
for (; ; ) {
|
|
31
|
+
const i = buffer.search(/\r\n|\r|\n/);
|
|
32
|
+
if (i < 0) break;
|
|
32
33
|
const l = buffer.slice(0, i);
|
|
33
34
|
buffer = buffer.slice(i + (buffer[i] === "\r" && buffer[i + 1] === "\n" ? 2 : 1));
|
|
34
35
|
line(l);
|
package/dist/lib/sse.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/sse.ts"],
|
|
4
|
-
"sourcesContent": ["export type ServerEvent = { event: string; data: string; id?: string; retry?: number }
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["export type ServerEvent = { event: string; data: string; id?: string; retry?: number };\n\nexport const readEvents = async (\n body: ReadableStream<Uint8Array>,\n onEvent: (e: ServerEvent) => void,\n): Promise<void> => {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buffer = '';\n let event = '';\n let data: string[] = [];\n let id: string | undefined;\n let retry: number | undefined;\n const flush = () => {\n if (data.length) onEvent({ event: event || 'message', data: data.join('\\n'), id, retry });\n event = '';\n data = [];\n };\n const line = (l: string) => {\n if (!l) return flush();\n if (l[0] === ':') return;\n const c = l.indexOf(':');\n const field = c < 0 ? l : l.slice(0, c);\n let v = c < 0 ? '' : l.slice(c + 1);\n if (v[0] === ' ') v = v.slice(1);\n if (field === 'event') event = v;\n else if (field === 'data') data.push(v);\n else if (field === 'id') id = v;\n else if (field === 'retry' && /^\\d+$/.test(v)) retry = +v;\n };\n for (;;) {\n const { value, done } = await reader.read();\n if (done) break;\n buffer += decoder.decode(value, { stream: true });\n for (;;) {\n const i = buffer.search(/\\r\\n|\\r|\\n/);\n if (i < 0) break;\n const l = buffer.slice(0, i);\n buffer = buffer.slice(i + (buffer[i] === '\\r' && buffer[i + 1] === '\\n' ? 2 : 1));\n line(l);\n }\n }\n if (buffer) line(buffer);\n flush();\n};\n\n/** Event payloads: each data line is `key value`; repeated keys join with newlines. */\nexport const parseFields = (data: string): Record<string, string> => {\n const out: Record<string, string> = {};\n for (const l of data.split('\\n')) {\n const i = l.indexOf(' ');\n const k = i < 0 ? l : l.slice(0, i);\n const v = i < 0 ? '' : l.slice(i + 1);\n out[k] = k in out ? `${out[k]}\\n${v}` : v;\n }\n return out;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E;AAChF,WAAK,CAAC;AAAA,IACR;AAAA,EACF;AACA,MAAI,OAAQ,MAAK,MAAM;AACvB,QAAM;AACR;AAGO,MAAM,cAAc,CAAC,SAAyC;AACnE,QAAM,MAA8B,CAAC;AACrC,aAAW,KAAK,KAAK,MAAM,IAAI,GAAG;AAChC,UAAM,IAAI,EAAE,QAAQ,GAAG;AACvB,UAAM,IAAI,IAAI,IAAI,IAAI,EAAE,MAAM,GAAG,CAAC;AAClC,UAAM,IAAI,IAAI,IAAI,KAAK,EAAE,MAAM,IAAI,CAAC;AACpC,QAAI,CAAC,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC;AAAA,EAAK,CAAC,KAAK;AAAA,EAC1C;AACA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/attribute-sync.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\nconst put = (el: Element, name: string, v: unknown) => {\n if (v === false || v == null) el.removeAttribute(name);\n else el.setAttribute(name, v === true ? '' : typeof v === 'object' ? JSON.stringify(v) : String(v));\n};\n\n/** `attr:title=\"expr\"` or `attr=\"{ title: expr }\"`. true \u2192 present, false/null \u2192 removed. */\nexport const attr = attribute({\n name: 'attr',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n effect(() => {\n if (key) return put(el, cased('kebab'), evaluate());\n const map = evaluate();\n for (const k in map) put(el, k, map[k]);\n });\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAE1B,MAAM,MAAM,CAAC,IAAa,MAAc,MAAe;AACrD,MAAI,MAAM,SAAS,KAAK,KAAM,IAAG,gBAAgB,IAAI;AAAA,MAChD,IAAG,aAAa,MAAM,MAAM,OAAO,KAAK,OAAO,MAAM,WAAW,KAAK,UAAU,CAAC,IAAI,OAAO,CAAC,CAAC;AACpG;AAGO,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,WAAO,MAAM;AACX,UAAI,IAAK,QAAO,IAAI,IAAI,MAAM,OAAO,GAAG,SAAS,CAAC;AAClD,YAAM,MAAM,SAAS;AACrB,iBAAW,KAAK,IAAK,KAAI,IAAI,GAAG,IAAI,CAAC,CAAC;AAAA,IACxC,CAAC;AAAA,EACH;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,7 +13,8 @@ const boost = attribute({
|
|
|
13
13
|
};
|
|
14
14
|
listen(el, "click", (e) => {
|
|
15
15
|
const a = e.target.closest("a[href]");
|
|
16
|
-
if (!a || e.defaultPrevented || e.button || e.metaKey || e.ctrlKey || e.shiftKey || a.target || a.hasAttribute("download"))
|
|
16
|
+
if (!a || e.defaultPrevented || e.button || e.metaKey || e.ctrlKey || e.shiftKey || a.target || a.hasAttribute("download"))
|
|
17
|
+
return;
|
|
17
18
|
if (a.origin !== location.origin || a.hash && a.pathname === location.pathname) return;
|
|
18
19
|
e.preventDefault();
|
|
19
20
|
go(a.href, "get", e);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/boost.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,
|
|
4
|
+
"sourcesContent": ["import { type ActionCtx, attribute } from '../../kernel/index.js';\n\n/**\n * Turns same-origin links and forms inside the element into requests whose full-document response\n * is morphed into the current page, with history entries: `boost` on a container (or `body`).\n * Needs `httpGet`, `httpPost` and `applyElements`. `__replace` replaces the history entry instead.\n */\nexport const boost = attribute({\n name: 'boost',\n key: 'forbidden',\n value: 'forbidden',\n mount({ el, mods, store, runtime, listen, error, cleanup }) {\n const ctx: ActionCtx = { el, store, runtime, error, cleanup };\n const go = (url: string, method = 'get', evt?: Event, form?: HTMLFormElement) => {\n const o = form ? { contentType: 'form', selector: undefined, openWhenHidden: true } : { openWhenHidden: true };\n const p = runtime.call(method, { ...ctx, el: form ?? el, evt }, [url, o]);\n history[mods.has('replace') ? 'replaceState' : 'pushState'](null, '', url);\n Promise.resolve(p).then(() => scrollTo(0, 0));\n };\n listen(el, 'click', (e: MouseEvent) => {\n const a = (e.target as Element).closest('a[href]') as HTMLAnchorElement | null;\n if (\n !a ||\n e.defaultPrevented ||\n e.button ||\n e.metaKey ||\n e.ctrlKey ||\n e.shiftKey ||\n a.target ||\n a.hasAttribute('download')\n )\n return;\n if (a.origin !== location.origin || (a.hash && a.pathname === location.pathname)) return;\n e.preventDefault();\n go(a.href, 'get', e);\n });\n listen(el, 'submit', (e: SubmitEvent) => {\n const form = e.target as HTMLFormElement;\n if (e.defaultPrevented || form.target) return;\n const url = new URL(form.action || location.href);\n if (url.origin !== location.origin) return;\n e.preventDefault();\n go(url.href, form.method.toLowerCase() === 'post' ? 'post' : 'get', e, form);\n });\n listen(window, 'popstate', () => runtime.call('get', ctx, [location.href, { openWhenHidden: true }]));\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAyB,iBAAiB;AAOnC,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,MAAM,OAAO,SAAS,QAAQ,OAAO,QAAQ,GAAG;AAC1D,UAAM,MAAiB,EAAE,IAAI,OAAO,SAAS,OAAO,QAAQ;AAC5D,UAAM,KAAK,CAAC,KAAa,SAAS,OAAO,KAAa,SAA2B;AAC/E,YAAM,IAAI,OAAO,EAAE,aAAa,QAAQ,UAAU,QAAW,gBAAgB,KAAK,IAAI,EAAE,gBAAgB,KAAK;AAC7G,YAAM,IAAI,QAAQ,KAAK,QAAQ,EAAE,GAAG,KAAK,IAAI,QAAQ,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,CAAC;AACxE,cAAQ,KAAK,IAAI,SAAS,IAAI,iBAAiB,WAAW,EAAE,MAAM,IAAI,GAAG;AACzE,cAAQ,QAAQ,CAAC,EAAE,KAAK,MAAM,SAAS,GAAG,CAAC,CAAC;AAAA,IAC9C;AACA,WAAO,IAAI,SAAS,CAAC,MAAkB;AACrC,YAAM,IAAK,EAAE,OAAmB,QAAQ,SAAS;AACjD,UACE,CAAC,KACD,EAAE,oBACF,EAAE,UACF,EAAE,WACF,EAAE,WACF,EAAE,YACF,EAAE,UACF,EAAE,aAAa,UAAU;AAEzB;AACF,UAAI,EAAE,WAAW,SAAS,UAAW,EAAE,QAAQ,EAAE,aAAa,SAAS,SAAW;AAClF,QAAE,eAAe;AACjB,SAAG,EAAE,MAAM,OAAO,CAAC;AAAA,IACrB,CAAC;AACD,WAAO,IAAI,UAAU,CAAC,MAAmB;AACvC,YAAM,OAAO,EAAE;AACf,UAAI,EAAE,oBAAoB,KAAK,OAAQ;AACvC,YAAM,MAAM,IAAI,IAAI,KAAK,UAAU,SAAS,IAAI;AAChD,UAAI,IAAI,WAAW,SAAS,OAAQ;AACpC,QAAE,eAAe;AACjB,SAAG,IAAI,MAAM,KAAK,OAAO,YAAY,MAAM,SAAS,SAAS,OAAO,GAAG,IAAI;AAAA,IAC7E,CAAC;AACD,WAAO,QAAQ,YAAY,MAAM,QAAQ,KAAK,OAAO,KAAK,CAAC,SAAS,MAAM,EAAE,gBAAgB,KAAK,CAAC,CAAC,CAAC;AAAA,EACtG;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/busy-flag.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/** A boolean signal that is true while a request started from this element (or one inside it) is in flight. */\nexport const indicator = attribute({\n name: 'indicator',\n mount({ el, key, value, cased, store, listen }) {\n const path = key ? cased() : value.trim();\n // Requests are remembered by id at `started`, because the element that made one may have been\n // morphed away by the time it finishes.\n const mine = new Set<number>();\n store.set(path, false);\n listen(document, 'sigmx-fetch', (e: CustomEvent<{ el: Element; type: string; rid: number }>) => {\n const { el: from, type, rid } = e.detail;\n if (type === 'started' && (from === el || el.contains(from))) mine.add(rid);\n else if (type === 'finished') mine.delete(rid);\n else return;\n store.set(path, mine.size > 0);\n });\n return () => store.set(path, false);\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,YAAY,UAAU;AAAA,EACjC,MAAM;AAAA,EACN,MAAM,EAAE,IAAI,KAAK,OAAO,OAAO,OAAO,OAAO,GAAG;AAC9C,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,KAAK;AAGxC,UAAM,OAAO,oBAAI,IAAY;AAC7B,UAAM,IAAI,MAAM,KAAK;AACrB,WAAO,UAAU,eAAe,CAAC,MAA+D;AAC9F,YAAM,EAAE,IAAI,MAAM,MAAM,IAAI,IAAI,EAAE;AAClC,UAAI,SAAS,cAAc,SAAS,MAAM,GAAG,SAAS,IAAI,GAAI,MAAK,IAAI,GAAG;AAAA,eACjE,SAAS,WAAY,MAAK,OAAO,GAAG;AAAA,UACxC;AACL,YAAM,IAAI,MAAM,KAAK,OAAO,CAAC;AAAA,IAC/B,CAAC;AACD,WAAO,MAAM,MAAM,IAAI,MAAM,KAAK;AAAA,EACpC;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/class-toggle.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/** `class:active=\"expr\"` or `class=\"{ active: expr, 'a b': expr }\"`. */\nexport const className = attribute({\n name: 'class',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n const applied = new Set<string>();\n effect(() => {\n const map: Record<string, unknown> = key ? { [cased('kebab')]: evaluate() } : evaluate();\n for (const k in map) {\n for (const name of k.split(/\\s+/).filter(Boolean)) {\n el.classList.toggle(name, !!map[k]);\n map[k] ? applied.add(name) : applied.delete(name);\n }\n }\n });\n return () => el.classList.remove(...applied);\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,YAAY,UAAU;AAAA,EACjC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,UAAM,UAAU,oBAAI,IAAY;AAChC,WAAO,MAAM;AACX,YAAM,MAA+B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,SAAS;AACvF,iBAAW,KAAK,KAAK;AACnB,mBAAW,QAAQ,EAAE,MAAM,KAAK,EAAE,OAAO,OAAO,GAAG;AACjD,aAAG,UAAU,OAAO,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC;AAClC,cAAI,CAAC,IAAI,QAAQ,IAAI,IAAI,IAAI,QAAQ,OAAO,IAAI;AAAA,QAClD;AAAA,MACF;AAAA,IACF,CAAC;AACD,WAAO,MAAM,GAAG,UAAU,OAAO,GAAG,OAAO;AAAA,EAC7C;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/cloak.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/**\n * Removed as soon as the element mounts. Pair it with CSS that hides cloaked markup until then:\n * `[data-cloak] { display: none !important }`.\n */\nexport const cloak = attribute({\n name: 'cloak',\n key: 'forbidden',\n value: 'forbidden',\n mount: ({ el, attr }) => el.removeAttribute(attr),\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAMnB,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,CAAC,EAAE,IAAI,KAAK,MAAM,GAAG,gBAAgB,IAAI;AAClD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/collapse.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, toMs } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute, toMs } from '../../kernel/index.js';\n\n/**\n * Animates the element's height open and closed: `collapse=\"$open\"`.\n * Modifiers: `__duration.250ms`, `__min.40px` (collapsed height, default 0).\n */\nexport const collapse = attribute({\n name: 'collapse',\n key: 'forbidden',\n value: 'required',\n mount({ el, mods, evaluate, effect, cleanup }) {\n const style = (el as HTMLElement).style;\n const ms = toMs(mods.get('duration'), 250);\n const min = mods.get('min')?.[0] ?? '0px';\n const instant = matchMedia('(prefers-reduced-motion: reduce)').matches;\n let timer: ReturnType<typeof setTimeout> | undefined;\n let first = true;\n let last: boolean | undefined;\n const settle = (open: boolean) => {\n style.transition = '';\n style.overflow = open ? '' : 'hidden';\n style.height = open ? '' : min;\n };\n effect(() => {\n const open = !!evaluate();\n if (open === last) return;\n last = open;\n clearTimeout(timer);\n if (first || instant) {\n first = false;\n return settle(open);\n }\n const from = `${el.getBoundingClientRect().height}px`;\n style.overflow = 'hidden';\n style.height = open ? min : from;\n void el.getBoundingClientRect(); // commit the start height before transitioning\n style.transition = `height ${ms}ms ease`;\n style.height = open ? `${el.scrollHeight}px` : min;\n timer = setTimeout(() => settle(open), ms + 20);\n });\n cleanup(() => clearTimeout(timer));\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,WAAW,YAAY;AAMzB,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,MAAM,UAAU,QAAQ,QAAQ,GAAG;AAC7C,UAAM,QAAS,GAAmB;AAClC,UAAM,KAAK,KAAK,KAAK,IAAI,UAAU,GAAG,GAAG;AACzC,UAAM,MAAM,KAAK,IAAI,KAAK,IAAI,CAAC,KAAK;AACpC,UAAM,UAAU,WAAW,kCAAkC,EAAE;AAC/D,QAAI;AACJ,QAAI,QAAQ;AACZ,QAAI;AACJ,UAAM,SAAS,CAAC,SAAkB;AAChC,YAAM,aAAa;AACnB,YAAM,WAAW,OAAO,KAAK;AAC7B,YAAM,SAAS,OAAO,KAAK;AAAA,IAC7B;AACA,WAAO,MAAM;AACX,YAAM,OAAO,CAAC,CAAC,SAAS;AACxB,UAAI,SAAS,KAAM;AACnB,aAAO;AACP,mBAAa,KAAK;AAClB,UAAI,SAAS,SAAS;AACpB,gBAAQ;AACR,eAAO,OAAO,IAAI;AAAA,MACpB;AACA,YAAM,OAAO,GAAG,GAAG,sBAAsB,EAAE,MAAM;AACjD,YAAM,WAAW;AACjB,YAAM,SAAS,OAAO,MAAM;AAC5B,WAAK,GAAG,sBAAsB;AAC9B,YAAM,aAAa,UAAU,EAAE;AAC/B,YAAM,SAAS,OAAO,GAAG,GAAG,YAAY,OAAO;AAC/C,cAAQ,WAAW,MAAM,OAAO,IAAI,GAAG,KAAK,EAAE;AAAA,IAChD,CAAC;AACD,YAAQ,MAAM,aAAa,KAAK,CAAC;AAAA,EACnC;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/declare.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, expand } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute, expand } from '../../kernel/index.js';\n\n/** `signals:name=\"expr\"` or `signals=\"{ ... }\"`. `__ifmissing` keeps existing values. */\nexport const signals = attribute({\n name: 'signals',\n value: 'required',\n mount({ key, cased, evaluate, store, mods }) {\n const v = evaluate();\n store.merge(key ? expand({}, cased(), v) : v, { ifMissing: mods.has('ifmissing') });\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,WAAW,cAAc;AAG3B,MAAM,UAAU,UAAU;AAAA,EAC/B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,KAAK,OAAO,UAAU,OAAO,KAAK,GAAG;AAC3C,UAAM,IAAI,SAAS;AACnB,UAAM,MAAM,MAAM,OAAO,CAAC,GAAG,MAAM,GAAG,CAAC,IAAI,GAAG,EAAE,WAAW,KAAK,IAAI,WAAW,EAAE,CAAC;AAAA,EACpF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -4,7 +4,10 @@ const computed = attribute({
|
|
|
4
4
|
value: "required",
|
|
5
5
|
mount({ key, cased, evaluate, store, error }) {
|
|
6
6
|
if (key) {
|
|
7
|
-
store.define(
|
|
7
|
+
store.define(
|
|
8
|
+
cased(),
|
|
9
|
+
makeComputed(() => evaluate())
|
|
10
|
+
);
|
|
8
11
|
return;
|
|
9
12
|
}
|
|
10
13
|
const obj = evaluate();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/derive.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, computed as makeComputed } from '../../kernel/index.js'
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,YAAY,oBAAoB;AAG7C,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,KAAK,OAAO,UAAU,OAAO,MAAM,GAAG;AAC5C,QAAI,KAAK;AACP,YAAM,
|
|
4
|
+
"sourcesContent": ["import { attribute, computed as makeComputed } from '../../kernel/index.js';\n\n/** `computed:name=\"expr\"` or `computed=\"{ name: () => expr }\"`. */\nexport const computed = attribute({\n name: 'computed',\n value: 'required',\n mount({ key, cased, evaluate, store, error }) {\n if (key) {\n store.define(\n cased(),\n makeComputed(() => evaluate()),\n );\n return;\n }\n const obj = evaluate();\n for (const k in obj) {\n if (typeof obj[k] !== 'function') throw error(`\"${k}\" must be a function`);\n store.define(k, makeComputed(obj[k]));\n }\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,oBAAoB;AAG7C,MAAM,WAAW,UAAU;AAAA,EAChC,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,KAAK,OAAO,UAAU,OAAO,MAAM,GAAG;AAC5C,QAAI,KAAK;AACP,YAAM;AAAA,QACJ,MAAM;AAAA,QACN,aAAa,MAAM,SAAS,CAAC;AAAA,MAC/B;AACA;AAAA,IACF;AACA,UAAM,MAAM,SAAS;AACrB,eAAW,KAAK,KAAK;AACnB,UAAI,OAAO,IAAI,CAAC,MAAM,WAAY,OAAM,MAAM,IAAI,CAAC,sBAAsB;AACzE,YAAM,OAAO,GAAG,aAAa,IAAI,CAAC,CAAC,CAAC;AAAA,IACtC;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/element-ref.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/** Stores the element in a signal: `ref:dialog` or `ref=\"dialog\"`. */\nexport const ref = attribute({\n name: 'ref',\n mount({ el, key, value, cased, store }) {\n const path = key ? cased() : value.trim();\n store.set(path, el);\n return () => store.remove(path);\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,MAAM,UAAU;AAAA,EAC3B,MAAM;AAAA,EACN,MAAM,EAAE,IAAI,KAAK,OAAO,OAAO,MAAM,GAAG;AACtC,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,KAAK;AACxC,UAAM,IAAI,MAAM,EAAE;AAClB,WAAO,MAAM,MAAM,OAAO,IAAI;AAAA,EAChC;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -8,7 +8,10 @@ const on = attribute({
|
|
|
8
8
|
const type = cased("kebab");
|
|
9
9
|
const outside = mods.has("outside");
|
|
10
10
|
const target = mods.has("window") ? window : mods.has("document") || outside || type.startsWith("sigmx-") ? document : el;
|
|
11
|
-
const run = withTiming(
|
|
11
|
+
const run = withTiming(
|
|
12
|
+
withViewTransition((e) => evaluate(e), mods),
|
|
13
|
+
mods
|
|
14
|
+
);
|
|
12
15
|
listen(
|
|
13
16
|
target,
|
|
14
17
|
type,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/event-listener.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js'
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAMnD,MAAM,KAAK,UAAU;AAAA,EAC1B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,OAAO,UAAU,OAAO,GAAG;AAC3C,UAAM,OAAO,MAAM,OAAO;AAC1B,UAAM,UAAU,KAAK,IAAI,SAAS;AAClC,UAAM,
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js';\n\n/**\n * `on:click=\"expr\"`. Modifiers: window, document, outside, prevent, stop, capture, passive, once,\n * delay/debounce/throttle, viewtransition, case.\n */\nexport const on = attribute({\n name: 'on',\n key: 'required',\n value: 'required',\n returns: false,\n mount({ el, mods, cased, evaluate, listen }) {\n const type = cased('kebab');\n const outside = mods.has('outside');\n const target: EventTarget = mods.has('window')\n ? window\n : mods.has('document') || outside || type.startsWith('sigmx-')\n ? document\n : el;\n const run = withTiming(\n withViewTransition((e: Event) => evaluate(e), mods),\n mods,\n );\n listen(\n target,\n type,\n (e: Event) => {\n if (outside && el.contains(e.target as Node)) return;\n if (mods.has('prevent') || (type === 'submit' && el instanceof HTMLFormElement)) e.preventDefault();\n if (mods.has('stop')) e.stopPropagation();\n run(e);\n },\n { capture: mods.has('capture'), passive: mods.has('passive'), once: mods.has('once') },\n );\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAMnD,MAAM,KAAK,UAAU;AAAA,EAC1B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,OAAO,UAAU,OAAO,GAAG;AAC3C,UAAM,OAAO,MAAM,OAAO;AAC1B,UAAM,UAAU,KAAK,IAAI,SAAS;AAClC,UAAM,SAAsB,KAAK,IAAI,QAAQ,IACzC,SACA,KAAK,IAAI,UAAU,KAAK,WAAW,KAAK,WAAW,QAAQ,IACzD,WACA;AACN,UAAM,MAAM;AAAA,MACV,mBAAmB,CAAC,MAAa,SAAS,CAAC,GAAG,IAAI;AAAA,MAClD;AAAA,IACF;AACA;AAAA,MACE;AAAA,MACA;AAAA,MACA,CAAC,MAAa;AACZ,YAAI,WAAW,GAAG,SAAS,EAAE,MAAc,EAAG;AAC9C,YAAI,KAAK,IAAI,SAAS,KAAM,SAAS,YAAY,cAAc,gBAAkB,GAAE,eAAe;AAClG,YAAI,KAAK,IAAI,MAAM,EAAG,GAAE,gBAAgB;AACxC,YAAI,CAAC;AAAA,MACP;AAAA,MACA,EAAE,SAAS,KAAK,IAAI,SAAS,GAAG,SAAS,KAAK,IAAI,SAAS,GAAG,MAAM,KAAK,IAAI,MAAM,EAAE;AAAA,IACvF;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/frame-loop.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, withTiming } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming } from '../../kernel/index.js';\n\nexport const onRaf = attribute({\n name: 'on-raf',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ mods, evaluate }) {\n const run = withTiming(() => evaluate(), mods);\n let id = requestAnimationFrame(function tick() {\n run();\n id = requestAnimationFrame(tick);\n });\n return () => cancelAnimationFrame(id);\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,WAAW,kBAAkB;AAE/B,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,MAAM,SAAS,GAAG;AACxB,UAAM,MAAM,WAAW,MAAM,SAAS,GAAG,IAAI;AAC7C,QAAI,KAAK,sBAAsB,SAAS,OAAO;AAC7C,UAAI;AACJ,WAAK,sBAAsB,IAAI;AAAA,IACjC,CAAC;AACD,WAAO,MAAM,qBAAqB,EAAE;AAAA,EACtC;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/html.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/** Sets `innerHTML` from an expression: `html=\"$markup\"`. Scripts inside are not executed. */\nexport const html = attribute({\n name: 'html',\n key: 'forbidden',\n value: 'required',\n mount: ({ el, evaluate, effect }) =>\n effect(() => {\n el.innerHTML = String(evaluate() ?? '');\n }),\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,CAAC,EAAE,IAAI,UAAU,OAAO,MAC7B,OAAO,MAAM;AACX,OAAG,YAAY,OAAO,SAAS,KAAK,EAAE;AAAA,EACxC,CAAC;AACL,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -7,7 +7,7 @@ const style = attribute({
|
|
|
7
7
|
const put = (prop, v) => {
|
|
8
8
|
if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop));
|
|
9
9
|
if (v || v === 0) el.style.setProperty(prop, String(v));
|
|
10
|
-
else el.style.setProperty(prop, original.get(prop));
|
|
10
|
+
else el.style.setProperty(prop, original.get(prop) ?? "");
|
|
11
11
|
};
|
|
12
12
|
effect(() => {
|
|
13
13
|
const map = key ? { [cased("kebab")]: evaluate() } : evaluate();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/inline-style.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, kebab } from '../../kernel/index.js'
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,aAAa;AAG1B,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,UAAM,WAAW,oBAAI,IAAoB;AACzC,UAAM,MAAM,CAAC,MAAc,MAAe;AACxC,UAAI,CAAC,SAAS,IAAI,IAAI,EAAG,UAAS,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,CAAC;AAC3E,UAAI,KAAK,MAAM,EAAG,IAAG,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,UACjD,IAAG,MAAM,YAAY,MAAM,SAAS,IAAI,IAAI,
|
|
4
|
+
"sourcesContent": ["import { attribute, kebab } from '../../kernel/index.js';\n\n/** `style:color=\"expr\"` or `style=\"{ color: expr }\"`. Falsy values (except 0) restore the original. */\nexport const style = attribute({\n name: 'style',\n value: 'required',\n mount({ el, key, cased, evaluate, effect }) {\n const original = new Map<string, string>();\n const put = (prop: string, v: unknown) => {\n if (!original.has(prop)) original.set(prop, el.style.getPropertyValue(prop));\n if (v || v === 0) el.style.setProperty(prop, String(v));\n else el.style.setProperty(prop, original.get(prop) ?? '');\n };\n effect(() => {\n const map: Record<string, unknown> = key ? { [cased('kebab')]: evaluate() } : evaluate();\n for (const prop of original.keys()) if (!(prop in map)) put(prop, '');\n for (const prop in map) put(kebab(prop), map[prop]);\n });\n return () => {\n for (const [prop, v] of original) el.style.setProperty(prop, v);\n };\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,aAAa;AAG1B,MAAM,QAAQ,UAAU;AAAA,EAC7B,MAAM;AAAA,EACN,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,KAAK,OAAO,UAAU,OAAO,GAAG;AAC1C,UAAM,WAAW,oBAAI,IAAoB;AACzC,UAAM,MAAM,CAAC,MAAc,MAAe;AACxC,UAAI,CAAC,SAAS,IAAI,IAAI,EAAG,UAAS,IAAI,MAAM,GAAG,MAAM,iBAAiB,IAAI,CAAC;AAC3E,UAAI,KAAK,MAAM,EAAG,IAAG,MAAM,YAAY,MAAM,OAAO,CAAC,CAAC;AAAA,UACjD,IAAG,MAAM,YAAY,MAAM,SAAS,IAAI,IAAI,KAAK,EAAE;AAAA,IAC1D;AACA,WAAO,MAAM;AACX,YAAM,MAA+B,MAAM,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,EAAE,IAAI,SAAS;AACvF,iBAAW,QAAQ,SAAS,KAAK,EAAG,KAAI,EAAE,QAAQ,KAAM,KAAI,MAAM,EAAE;AACpE,iBAAW,QAAQ,IAAK,KAAI,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;AAAA,IACpD,CAAC;AACD,WAAO,MAAM;AACX,iBAAW,CAAC,MAAM,CAAC,KAAK,SAAU,IAAG,MAAM,YAAY,MAAM,CAAC;AAAA,IAChE;AAAA,EACF;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/mask.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\nconst slots: Record<string, RegExp> = { '9': /\\d/, a: /[a-zA-Z]/, '*': /[a-zA-Z0-9]/ };\n\n/** Format raw input against a mask: `9` digit, `a` letter, `*` either, anything else literal. */\nexport const applyMask = (mask: string, raw: string): string => {\n let out = '';\n let i = 0;\n for (const m of mask) {\n if (i >= raw.length) break;\n const slot = slots[m];\n if (slot) {\n while (i < raw.length && !slot.test(raw[i])) i++;\n if (i >= raw.length) break;\n out += raw[i++];\n } else {\n out += m;\n if (raw[i] === m) i++;\n }\n }\n return out;\n};\n\n/**\n * Formats the input as the user types: `mask=\"(999) 999-9999\"`. The value is the mask itself;\n * add `__dynamic` to evaluate it as an expression instead (`mask__dynamic=\"$isUS ? '999-999' : '9999'\"`).\n */\nexport const mask = attribute({\n name: 'mask',\n key: 'forbidden',\n value: 'required',\n mount({ el, value, mods, evaluate, listen, effect }) {\n const input = el as HTMLInputElement;\n let pattern = value;\n const format = () => {\n const next = applyMask(pattern, input.value);\n if (next !== input.value) {\n input.value = next;\n input.dispatchEvent(new Event('input', { bubbles: true })); // let `bind` see the formatted value\n }\n };\n listen(input, 'input', format);\n if (mods.has('dynamic')) {\n effect(() => {\n pattern = String(evaluate() ?? '');\n format();\n });\n } else format();\n },\n});\n"],
|
|
5
5
|
"mappings": "AAAA,SAAS,iBAAiB;AAE1B,MAAM,QAAgC,EAAE,KAAK,MAAM,GAAG,YAAY,KAAK,cAAc;AAG9E,MAAM,YAAY,CAACA,OAAc,QAAwB;AAC9D,MAAI,MAAM;AACV,MAAI,IAAI;AACR,aAAW,KAAKA,OAAM;AACpB,QAAI,KAAK,IAAI,OAAQ;AACrB,UAAM,OAAO,MAAM,CAAC;AACpB,QAAI,MAAM;AACR,aAAO,IAAI,IAAI,UAAU,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,EAAG;AAC7C,UAAI,KAAK,IAAI,OAAQ;AACrB,aAAO,IAAI,GAAG;AAAA,IAChB,OAAO;AACL,aAAO;AACP,UAAI,IAAI,CAAC,MAAM,EAAG;AAAA,IACpB;AAAA,EACF;AACA,SAAO;AACT;AAMO,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,OAAO,MAAM,UAAU,QAAQ,OAAO,GAAG;AACnD,UAAM,QAAQ;AACd,QAAI,UAAU;AACd,UAAM,SAAS,MAAM;AACnB,YAAM,OAAO,UAAU,SAAS,MAAM,KAAK;AAC3C,UAAI,SAAS,MAAM,OAAO;AACxB,cAAM,QAAQ;AACd,cAAM,cAAc,IAAI,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC,CAAC;AAAA,MAC3D;AAAA,IACF;AACA,WAAO,OAAO,SAAS,MAAM;AAC7B,QAAI,KAAK,IAAI,SAAS,GAAG;AACvB,aAAO,MAAM;AACX,kBAAU,OAAO,SAAS,KAAK,EAAE;AACjC,eAAO;AAAA,MACT,CAAC;AAAA,IACH,MAAO,QAAO;AAAA,EAChB;AACF,CAAC;",
|
|
6
6
|
"names": ["mask"]
|
|
7
7
|
}
|
|
@@ -5,7 +5,8 @@ const matchMedia = attribute({
|
|
|
5
5
|
value: "required",
|
|
6
6
|
mount({ cased, evaluate, store, listen }) {
|
|
7
7
|
let q = String(evaluate()).trim();
|
|
8
|
-
if (!/^[(a-z]/.test(q) || !q.startsWith("(") && q.includes(":") && !/^(not|only|all|screen|print)\b/.test(q))
|
|
8
|
+
if (!/^[(a-z]/.test(q) || !q.startsWith("(") && q.includes(":") && !/^(not|only|all|screen|print)\b/.test(q))
|
|
9
|
+
q = `(${q})`;
|
|
9
10
|
const mql = window.matchMedia(q);
|
|
10
11
|
const path = cased();
|
|
11
12
|
const sync = () => store.set(path, mql.matches);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/media-query.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute } from '../../kernel/index.js'
|
|
5
|
-
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,GAAG;AACxC,QAAI,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK;AAChC,QAAI,CAAC,UAAU,KAAK,CAAC,KAAM,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,iCAAiC,KAAK,CAAC,
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js';\n\n/** `match-media:is-dark=\"'prefers-color-scheme: dark'\"` keeps a boolean signal in sync. */\nexport const matchMedia = attribute({\n name: 'match-media',\n key: 'required',\n value: 'required',\n mount({ cased, evaluate, store, listen }) {\n let q = String(evaluate()).trim();\n if (!/^[(a-z]/.test(q) || (!q.startsWith('(') && q.includes(':') && !/^(not|only|all|screen|print)\\b/.test(q)))\n q = `(${q})`;\n const mql = window.matchMedia(q);\n const path = cased();\n const sync = () => store.set(path, mql.matches);\n sync();\n listen(mql, 'change', sync);\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,OAAO,UAAU,OAAO,OAAO,GAAG;AACxC,QAAI,IAAI,OAAO,SAAS,CAAC,EAAE,KAAK;AAChC,QAAI,CAAC,UAAU,KAAK,CAAC,KAAM,CAAC,EAAE,WAAW,GAAG,KAAK,EAAE,SAAS,GAAG,KAAK,CAAC,iCAAiC,KAAK,CAAC;AAC1G,UAAI,IAAI,CAAC;AACX,UAAM,MAAM,OAAO,WAAW,CAAC;AAC/B,UAAM,OAAO,MAAM;AACnB,UAAM,OAAO,MAAM,MAAM,IAAI,MAAM,IAAI,OAAO;AAC9C,SAAK;AACL,WAAO,KAAK,UAAU,IAAI;AAAA,EAC5B;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -5,7 +5,10 @@ const init = attribute({
|
|
|
5
5
|
value: "required",
|
|
6
6
|
returns: false,
|
|
7
7
|
mount({ mods, evaluate }) {
|
|
8
|
-
withTiming(
|
|
8
|
+
withTiming(
|
|
9
|
+
withViewTransition(() => evaluate(), mods),
|
|
10
|
+
mods
|
|
11
|
+
)();
|
|
9
12
|
}
|
|
10
13
|
});
|
|
11
14
|
export {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/on-mount.ts"],
|
|
4
|
-
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js'
|
|
5
|
-
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,MAAM,SAAS,GAAG;AACxB,
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js';\n\n/** Runs once when the element is mounted. Supports `__delay.500ms` and `__viewtransition`. */\nexport const init = attribute({\n name: 'init',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ mods, evaluate }) {\n withTiming(\n withViewTransition(() => evaluate(), mods),\n mods,\n )();\n },\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,MAAM,SAAS,GAAG;AACxB;AAAA,MACE,mBAAmB,MAAM,SAAS,GAAG,IAAI;AAAA,MACzC;AAAA,IACF,EAAE;AAAA,EACJ;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|