sigmx 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/dist/kernel/compile.d.ts +8 -9
- package/dist/kernel/compile.js +102 -67
- package/dist/kernel/compile.js.map +2 -2
- package/dist/kernel/contracts.d.ts +11 -5
- package/dist/kernel/index.d.ts +2 -2
- package/dist/kernel/index.js +5 -6
- package/dist/kernel/index.js.map +2 -2
- package/dist/kernel/precompile.d.ts +8 -10
- package/dist/kernel/precompile.js +25 -75
- package/dist/kernel/precompile.js.map +2 -2
- package/dist/kernel/precompiled.d.ts +7 -4
- package/dist/kernel/precompiled.js +5 -5
- package/dist/kernel/precompiled.js.map +2 -2
- package/dist/kernel/reactive.d.ts +8 -2
- package/dist/kernel/reactive.js +91 -62
- package/dist/kernel/reactive.js.map +3 -3
- package/dist/kernel/runtime.js +78 -68
- package/dist/kernel/runtime.js.map +3 -3
- package/dist/kernel/scan.d.ts +1 -1
- package/dist/kernel/scan.js +3 -3
- package/dist/kernel/scan.js.map +2 -2
- package/dist/kernel/state.d.ts +4 -3
- package/dist/kernel/state.js +91 -80
- package/dist/kernel/state.js.map +2 -2
- package/dist/kernel/strict-csp.d.ts +0 -5
- package/dist/kernel/strict-csp.js +2 -2
- package/dist/kernel/strict-csp.js.map +2 -2
- package/dist/lib/casing.d.ts +4 -1
- package/dist/lib/casing.js +8 -1
- package/dist/lib/casing.js.map +2 -2
- package/dist/lib/objects.d.ts +5 -3
- package/dist/lib/objects.js +10 -5
- package/dist/lib/objects.js.map +2 -2
- package/dist/lib/schedule.d.ts +3 -3
- package/dist/lib/schedule.js +12 -10
- package/dist/lib/schedule.js.map +2 -2
- package/dist/lib/sse.d.ts +10 -0
- package/dist/lib/sse.js +32 -29
- package/dist/lib/sse.js.map +2 -2
- package/dist/plugins/def.d.ts +5 -0
- package/dist/plugins/def.js +22 -0
- package/dist/plugins/def.js.map +7 -0
- package/dist/plugins/directives/attribute-sync.js +8 -12
- package/dist/plugins/directives/attribute-sync.js.map +2 -2
- package/dist/plugins/directives/boost.d.ts +1 -1
- package/dist/plugins/directives/boost.js +34 -31
- package/dist/plugins/directives/boost.js.map +2 -2
- package/dist/plugins/directives/busy-flag.js +13 -16
- package/dist/plugins/directives/busy-flag.js.map +2 -2
- package/dist/plugins/directives/class-toggle.js +17 -16
- package/dist/plugins/directives/class-toggle.js.map +2 -2
- package/dist/plugins/directives/cloak.js +2 -7
- package/dist/plugins/directives/cloak.js.map +2 -2
- package/dist/plugins/directives/collapse.js +36 -37
- package/dist/plugins/directives/collapse.js.map +2 -2
- package/dist/plugins/directives/declare.js +5 -8
- package/dist/plugins/directives/declare.js.map +2 -2
- package/dist/plugins/directives/derive.js +9 -18
- package/dist/plugins/directives/derive.js.map +2 -2
- package/dist/plugins/directives/element-ref.js +8 -8
- package/dist/plugins/directives/element-ref.js.map +2 -2
- package/dist/plugins/directives/event-listener.js +18 -26
- package/dist/plugins/directives/event-listener.js.map +2 -2
- package/dist/plugins/directives/frame-loop.js +9 -14
- package/dist/plugins/directives/frame-loop.js.map +2 -2
- package/dist/plugins/directives/html.js +6 -7
- package/dist/plugins/directives/html.js.map +2 -2
- package/dist/plugins/directives/inline-style.js +17 -20
- package/dist/plugins/directives/inline-style.js.map +2 -2
- package/dist/plugins/directives/mask.js +19 -23
- package/dist/plugins/directives/mask.js.map +2 -2
- package/dist/plugins/directives/media-query.d.ts +4 -1
- package/dist/plugins/directives/media-query.js +13 -13
- package/dist/plugins/directives/media-query.js.map +2 -2
- package/dist/plugins/directives/on-mount.js +4 -12
- package/dist/plugins/directives/on-mount.js.map +2 -2
- package/dist/plugins/directives/patch-listener.js +24 -19
- package/dist/plugins/directives/patch-listener.js.map +2 -2
- package/dist/plugins/directives/remove-me.js +7 -8
- package/dist/plugins/directives/remove-me.js.map +2 -2
- package/dist/plugins/directives/scroll-to.d.ts +4 -1
- package/dist/plugins/directives/scroll-to.js +8 -14
- package/dist/plugins/directives/scroll-to.js.map +2 -2
- package/dist/plugins/directives/size-watch.js +7 -12
- package/dist/plugins/directives/size-watch.js.map +2 -2
- package/dist/plugins/directives/state-dump.js +6 -10
- package/dist/plugins/directives/state-dump.js.map +2 -2
- package/dist/plugins/directives/storage-sync.js +13 -9
- package/dist/plugins/directives/storage-sync.js.map +2 -2
- package/dist/plugins/directives/teleport.js +8 -14
- package/dist/plugins/directives/teleport.js.map +2 -2
- package/dist/plugins/directives/text-content.js +6 -7
- package/dist/plugins/directives/text-content.js.map +2 -2
- package/dist/plugins/directives/timer.js +7 -13
- package/dist/plugins/directives/timer.js.map +2 -2
- package/dist/plugins/directives/transition.d.ts +1 -2
- package/dist/plugins/directives/transition.js +32 -34
- package/dist/plugins/directives/transition.js.map +2 -2
- package/dist/plugins/directives/tween.d.ts +2 -2
- package/dist/plugins/directives/tween.js +34 -50
- package/dist/plugins/directives/tween.js.map +2 -2
- package/dist/plugins/directives/two-way-bind.d.ts +1 -1
- package/dist/plugins/directives/two-way-bind.js +70 -97
- package/dist/plugins/directives/two-way-bind.js.map +2 -2
- package/dist/plugins/directives/url-params.js +35 -59
- package/dist/plugins/directives/url-params.js.map +3 -3
- package/dist/plugins/directives/url-replace.js +6 -7
- package/dist/plugins/directives/url-replace.js.map +2 -2
- package/dist/plugins/directives/validity.js +6 -9
- package/dist/plugins/directives/validity.js.map +2 -2
- package/dist/plugins/directives/viewport.js +18 -26
- package/dist/plugins/directives/viewport.js.map +2 -2
- package/dist/plugins/directives/visibility.js +9 -14
- package/dist/plugins/directives/visibility.js.map +2 -2
- package/dist/plugins/directives/watch.js +2 -8
- package/dist/plugins/directives/watch.js.map +2 -2
- package/dist/plugins/functions/bulk-set.js +7 -6
- package/dist/plugins/functions/bulk-set.js.map +2 -2
- package/dist/plugins/functions/bulk-toggle.js +7 -6
- package/dist/plugins/functions/bulk-toggle.js.map +2 -2
- package/dist/plugins/functions/confirm.js +2 -2
- package/dist/plugins/functions/confirm.js.map +2 -2
- package/dist/plugins/functions/copy-text.js +5 -5
- package/dist/plugins/functions/copy-text.js.map +2 -2
- package/dist/plugins/functions/dispatch.js +5 -5
- package/dist/plugins/functions/dispatch.js.map +2 -2
- package/dist/plugins/functions/locale-format.d.ts +4 -1
- package/dist/plugins/functions/locale-format.js +9 -16
- package/dist/plugins/functions/locale-format.js.map +2 -2
- package/dist/plugins/functions/range-map.js +6 -6
- package/dist/plugins/functions/range-map.js.map +2 -2
- package/dist/plugins/functions/request.d.ts +7 -3
- package/dist/plugins/functions/request.js +77 -86
- package/dist/plugins/functions/request.js.map +2 -2
- package/dist/plugins/functions/untracked-read.js +3 -2
- package/dist/plugins/functions/untracked-read.js.map +2 -2
- package/dist/plugins/functions/websocket.d.ts +3 -3
- package/dist/plugins/functions/websocket.js +13 -24
- package/dist/plugins/functions/websocket.js.map +2 -2
- package/dist/plugins/index.d.ts +0 -2
- package/dist/plugins/index.js +0 -4
- package/dist/plugins/index.js.map +2 -2
- package/dist/plugins/server-events/apply-elements.d.ts +1 -1
- package/dist/plugins/server-events/apply-elements.js +41 -43
- package/dist/plugins/server-events/apply-elements.js.map +2 -2
- package/dist/plugins/server-events/apply-state.js +9 -12
- package/dist/plugins/server-events/apply-state.js.map +2 -2
- package/dist/plugins/server-events/morph.js +46 -66
- package/dist/plugins/server-events/morph.js.map +3 -3
- package/dist/presets/all.js +0 -4
- package/dist/presets/all.js.map +2 -2
- package/dist/server.d.ts +10 -4
- package/dist/server.js +42 -14
- package/dist/server.js.map +2 -2
- package/dist/sigmx.standalone.js +1 -1
- package/dist/vite.js +17 -7
- package/dist/vite.js.map +2 -2
- package/package.json +4 -2
- package/dist/plugins/directives/transition-name.d.ts +0 -1
- package/dist/plugins/directives/transition-name.js +0 -11
- package/dist/plugins/directives/transition-name.js.map +0 -7
- package/dist/plugins/directives/trap.d.ts +0 -5
- package/dist/plugins/directives/trap.js +0 -54
- package/dist/plugins/directives/trap.js.map +0 -7
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const pick = (mods,
|
|
3
|
-
const scrollIntoView =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
behavior: pick(mods, ["smooth", "instant", "auto"], "smooth"),
|
|
10
|
-
block: pick(mods, ["vstart", "vcenter", "vend", "vnearest"], "vcenter").slice(1),
|
|
11
|
-
inline: pick(mods, ["hstart", "hcenter", "hend", "hnearest"], "hcenter").slice(1)
|
|
12
|
-
});
|
|
13
|
-
if (mods.has("focus")) el.focus?.();
|
|
14
|
-
}
|
|
1
|
+
import { dir } from "../def.js";
|
|
2
|
+
const pick = (mods, re, fallback) => [...mods.keys()].find((n) => re.test(n)) ?? fallback;
|
|
3
|
+
const scrollIntoView = dir("scroll-into-view", 10, ({ el, mods }) => {
|
|
4
|
+
el.scrollIntoView({
|
|
5
|
+
behavior: pick(mods, /^(smooth|instant|auto)$/, "smooth"),
|
|
6
|
+
block: pick(mods, /^v(start|center|end|nearest)$/, "vcenter").slice(1)
|
|
7
|
+
});
|
|
8
|
+
if (mods.has("focus")) el.focus?.();
|
|
15
9
|
});
|
|
16
10
|
export {
|
|
17
11
|
scrollIntoView
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/scroll-to.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { dir } from '../def.js';\n\nconst pick = (mods: Map<string, string[]>, re: RegExp, fallback: string) =>\n [...mods.keys()].find((n) => re.test(n)) ?? fallback;\n\n/**\n * Scrolls the element into view when it mounts: `scroll-into-view__smooth__vcenter__focus`.\n * Modifiers: `smooth|instant|auto`, `vstart|vcenter|vend|vnearest`, `focus`.\n */\nexport const scrollIntoView = dir('scroll-into-view', 10, ({ el, mods }) => {\n el.scrollIntoView({\n behavior: pick(mods, /^(smooth|instant|auto)$/, 'smooth') as ScrollBehavior,\n block: pick(mods, /^v(start|center|end|nearest)$/, 'vcenter').slice(1) as ScrollLogicalPosition,\n });\n if (mods.has('focus')) (el as HTMLElement).focus?.();\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AAEpB,MAAM,OAAO,CAAC,MAA6B,IAAY,aACrD,CAAC,GAAG,KAAK,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,CAAC,CAAC,KAAK;AAMvC,MAAM,iBAAiB,IAAI,oBAAoB,IAAI,CAAC,EAAE,IAAI,KAAK,MAAM;AAC1E,KAAG,eAAe;AAAA,IAChB,UAAU,KAAK,MAAM,2BAA2B,QAAQ;AAAA,IACxD,OAAO,KAAK,MAAM,iCAAiC,SAAS,EAAE,MAAM,CAAC;AAAA,EACvE,CAAC;AACD,MAAI,KAAK,IAAI,OAAO,EAAG,CAAC,GAAmB,QAAQ;AACrD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const run = withTiming(() => evaluate(), mods);
|
|
9
|
-
const ro = new ResizeObserver(() => run());
|
|
10
|
-
ro.observe(el);
|
|
11
|
-
return () => ro.disconnect();
|
|
12
|
-
}
|
|
1
|
+
import { withTiming } from "../../kernel/index.js";
|
|
2
|
+
import { dir } from "../def.js";
|
|
3
|
+
const onResize = dir("on-resize", 22, ({ el, mods, evaluate, cleanup }) => {
|
|
4
|
+
const run = withTiming(() => evaluate(), mods, cleanup);
|
|
5
|
+
const ro = new ResizeObserver(() => run());
|
|
6
|
+
ro.observe(el);
|
|
7
|
+
return () => ro.disconnect();
|
|
13
8
|
});
|
|
14
9
|
export {
|
|
15
10
|
onResize
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/size-watch.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { withTiming } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\nexport const onResize = dir('on-resize', 22, ({ el, mods, evaluate, cleanup }) => {\n const run = withTiming(() => evaluate(), mods, cleanup);\n const ro = new ResizeObserver(() => run());\n ro.observe(el);\n return () => ro.disconnect();\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,WAAW;AAEb,MAAM,WAAW,IAAI,aAAa,IAAI,CAAC,EAAE,IAAI,MAAM,UAAU,QAAQ,MAAM;AAChF,QAAM,MAAM,WAAW,MAAM,SAAS,GAAG,MAAM,OAAO;AACtD,QAAM,KAAK,IAAI,eAAe,MAAM,IAAI,CAAC;AACzC,KAAG,QAAQ,EAAE;AACb,SAAO,MAAM,GAAG,WAAW;AAC7B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const jsonSignals =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
effect(() => {
|
|
8
|
-
el.textContent = JSON.stringify(store.snapshot(filter), null, mods.has("terse") ? 0 : 2);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
1
|
+
import { dir } from "../def.js";
|
|
2
|
+
const jsonSignals = dir("json-signals", 2, ({ el, value, evaluate, effect, store }) => {
|
|
3
|
+
const filter = value ? evaluate() : void 0;
|
|
4
|
+
effect(() => {
|
|
5
|
+
el.textContent = JSON.stringify(store.snapshot(filter), null, 2);
|
|
6
|
+
});
|
|
11
7
|
});
|
|
12
8
|
export {
|
|
13
9
|
jsonSignals
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/state-dump.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { dir } from '../def.js';\n\n/** Renders the store (or a filtered part) as JSON. `__terse` for single-line output. */\nexport const jsonSignals = dir('json-signals', 2, ({ el, value, evaluate, effect, store }) => {\n const filter = value ? evaluate() : undefined;\n effect(() => {\n el.textContent = JSON.stringify(store.snapshot(filter), null, 2);\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AAGb,MAAM,cAAc,IAAI,gBAAgB,GAAG,CAAC,EAAE,IAAI,OAAO,UAAU,QAAQ,MAAM,MAAM;AAC5F,QAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,SAAO,MAAM;AACX,OAAG,cAAc,KAAK,UAAU,MAAM,SAAS,MAAM,GAAG,MAAM,CAAC;AAAA,EACjE,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const persist =
|
|
3
|
-
name
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
const filter = value ? evaluate() : void 0;
|
|
8
|
-
const saved = storage.getItem(name);
|
|
1
|
+
import { dir } from "../def.js";
|
|
2
|
+
const persist = dir("persist", 0, ({ key, value, evaluate, store, effect }) => {
|
|
3
|
+
const name = key || "sigmx";
|
|
4
|
+
const filter = value ? evaluate() : void 0;
|
|
5
|
+
try {
|
|
6
|
+
const saved = localStorage.getItem(name);
|
|
9
7
|
if (saved) store.merge(JSON.parse(saved));
|
|
10
|
-
|
|
8
|
+
} catch {
|
|
11
9
|
}
|
|
10
|
+
effect(() => {
|
|
11
|
+
try {
|
|
12
|
+
localStorage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false })));
|
|
13
|
+
} catch {
|
|
14
|
+
}
|
|
15
|
+
});
|
|
12
16
|
});
|
|
13
17
|
export {
|
|
14
18
|
persist
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/storage-sync.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { dir } from '../def.js';\n\n/**\n * Saves matching signals to localStorage (`__session` for sessionStorage) and restores them on\n * mount. `persist:key` sets the storage key; the value is an optional `{ include, exclude }` filter.\n * Declare defaults with `signals:x__ifmissing` so restored values are not overwritten.\n */\nexport const persist = dir('persist', 0, ({ key, value, evaluate, store, effect }) => {\n const name = key || 'sigmx';\n const filter = value ? evaluate() : undefined;\n try {\n const saved = localStorage.getItem(name);\n if (saved) store.merge(JSON.parse(saved));\n } catch {} // corrupted or blocked storage: start from the declared defaults\n effect(() => {\n try {\n localStorage.setItem(name, JSON.stringify(store.snapshot(filter, { computed: false })));\n } catch {} // quota exceeded or storage disabled: keep working in memory\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AAOb,MAAM,UAAU,IAAI,WAAW,GAAG,CAAC,EAAE,KAAK,OAAO,UAAU,OAAO,OAAO,MAAM;AACpF,QAAM,OAAO,OAAO;AACpB,QAAM,SAAS,QAAQ,SAAS,IAAI;AACpC,MAAI;AACF,UAAM,QAAQ,aAAa,QAAQ,IAAI;AACvC,QAAI,MAAO,OAAM,MAAM,KAAK,MAAM,KAAK,CAAC;AAAA,EAC1C,QAAQ;AAAA,EAAC;AACT,SAAO,MAAM;AACX,QAAI;AACF,mBAAa,QAAQ,MAAM,KAAK,UAAU,MAAM,SAAS,QAAQ,EAAE,UAAU,MAAM,CAAC,CAAC,CAAC;AAAA,IACxF,QAAQ;AAAA,IAAC;AAAA,EACX,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,17 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const teleport =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (el.parentElement === target) return;
|
|
10
|
-
const before = mods.has("prepend") ? target.firstChild : null;
|
|
11
|
-
const t = target;
|
|
12
|
-
if (t.moveBefore) t.moveBefore(el, before);
|
|
13
|
-
else target.insertBefore(el, before);
|
|
14
|
-
}
|
|
1
|
+
import { dir } from "../def.js";
|
|
2
|
+
const teleport = dir("teleport", 38, ({ el, evaluate, error }) => {
|
|
3
|
+
const selector = String(evaluate());
|
|
4
|
+
const target = document.querySelector(selector);
|
|
5
|
+
if (!target) throw error(`no element matches "${selector}"`);
|
|
6
|
+
if (el.parentElement === target) return;
|
|
7
|
+
const t = target;
|
|
8
|
+
(t.moveBefore ?? t.insertBefore).call(t, el, null);
|
|
15
9
|
});
|
|
16
10
|
export {
|
|
17
11
|
teleport
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/teleport.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { dir } from '../def.js';\n\n/**\n * Moves the element to another place in the document: `teleport=\"body\"` (a selector).\n * `__prepend` inserts at the start. The element and its signals keep working where it lands.\n */\nexport const teleport = dir('teleport', 38, ({ el, evaluate, error }) => {\n const selector = String(evaluate()); // a literal selector, or an expression with `__dynamic`\n const target = document.querySelector(selector);\n if (!target) throw error(`no element matches \"${selector}\"`);\n if (el.parentElement === target) return;\n const t = target as Node & { moveBefore?: (n: Node, b: Node | null) => void };\n // `moveBefore` keeps state and avoids an unmount/remount; fall back to a plain move.\n (t.moveBefore ?? t.insertBefore).call(t, el, null);\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AAMb,MAAM,WAAW,IAAI,YAAY,IAAI,CAAC,EAAE,IAAI,UAAU,MAAM,MAAM;AACvE,QAAM,WAAW,OAAO,SAAS,CAAC;AAClC,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,MAAI,CAAC,OAAQ,OAAM,MAAM,uBAAuB,QAAQ,GAAG;AAC3D,MAAI,GAAG,kBAAkB,OAAQ;AACjC,QAAM,IAAI;AAEV,GAAC,EAAE,cAAc,EAAE,cAAc,KAAK,GAAG,IAAI,IAAI;AACnD,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const text =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
mount: ({ el, evaluate, effect }) => effect(() => {
|
|
1
|
+
import { dir } from "../def.js";
|
|
2
|
+
const text = dir(
|
|
3
|
+
"text",
|
|
4
|
+
6,
|
|
5
|
+
({ el, evaluate, effect }) => effect(() => {
|
|
7
6
|
el.textContent = String(evaluate() ?? "");
|
|
8
7
|
})
|
|
9
|
-
|
|
8
|
+
);
|
|
10
9
|
export {
|
|
11
10
|
text
|
|
12
11
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/text-content.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { dir } from '../def.js';\n\nexport const text = dir('text', 6, ({ el, evaluate, effect }) =>\n effect(() => {\n el.textContent = String(evaluate() ?? '');\n }),\n);\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW;AAEb,MAAM,OAAO;AAAA,EAAI;AAAA,EAAQ;AAAA,EAAG,CAAC,EAAE,IAAI,UAAU,OAAO,MACzD,OAAO,MAAM;AACX,OAAG,cAAc,OAAO,SAAS,KAAK,EAAE;AAAA,EAC1C,CAAC;AACH;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const d = mods.get("duration");
|
|
9
|
-
const run = withViewTransition(() => evaluate(), mods);
|
|
10
|
-
if (d?.includes("leading")) run();
|
|
11
|
-
const id = setInterval(run, toMs(d, 1e3));
|
|
12
|
-
return () => clearInterval(id);
|
|
13
|
-
}
|
|
1
|
+
import { toMs } from "../../kernel/index.js";
|
|
2
|
+
import { dir } from "../def.js";
|
|
3
|
+
const onInterval = dir("on-interval", 22, ({ mods, evaluate }) => {
|
|
4
|
+
const d = mods.get("duration");
|
|
5
|
+
const run = () => evaluate();
|
|
6
|
+
const id = setInterval(run, toMs(d, 1e3));
|
|
7
|
+
return () => clearInterval(id);
|
|
14
8
|
});
|
|
15
9
|
export {
|
|
16
10
|
onInterval
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/timer.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { toMs } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/** `on-interval__duration.5s.leading=\"expr\"`. Default one second. */\nexport const onInterval = dir('on-interval', 22, ({ mods, evaluate }) => {\n const d = mods.get('duration');\n const run = () => evaluate();\n const id = setInterval(run, toMs(d, 1000));\n return () => clearInterval(id);\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,WAAW;AAGb,MAAM,aAAa,IAAI,eAAe,IAAI,CAAC,EAAE,MAAM,SAAS,MAAM;AACvE,QAAM,IAAI,KAAK,IAAI,UAAU;AAC7B,QAAM,MAAM,MAAM,SAAS;AAC3B,QAAM,KAAK,YAAY,KAAK,KAAK,GAAG,GAAI,CAAC;AACzC,SAAO,MAAM,cAAc,EAAE;AAC/B,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Shows and hides with a fade
|
|
3
|
-
* Modifiers: `__duration.200ms`, `__scale` (from 95%) or `__scale.90`, `__origin.top`.
|
|
2
|
+
* Shows and hides with a fade: `transition="$open"`. Modifier: `__duration.200ms`.
|
|
4
3
|
*/
|
|
5
4
|
export declare const transition: import("../../kernel/contracts.js").AttributePlugin;
|
|
@@ -1,38 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { toMs } from "../../kernel/index.js";
|
|
2
|
+
import { dir } from "../def.js";
|
|
3
|
+
const transition = dir("transition", 6, ({ el, mods, evaluate, effect, cleanup }) => {
|
|
4
|
+
const style = el.style;
|
|
5
|
+
const duration = matchMedia("(prefers-reduced-motion: reduce)").matches ? 0 : toMs(mods.get("duration"), 200);
|
|
6
|
+
const hidden = { opacity: 0 };
|
|
7
|
+
const shown = { opacity: 1 };
|
|
8
|
+
const own = style.display;
|
|
9
|
+
const initial = own === "none" ? "" : own;
|
|
10
|
+
let anim;
|
|
11
|
+
let first = true;
|
|
12
|
+
let last;
|
|
13
|
+
effect(() => {
|
|
14
|
+
const open = !!evaluate();
|
|
15
|
+
if (open === last) return;
|
|
16
|
+
last = open;
|
|
17
|
+
anim?.cancel();
|
|
18
|
+
if (first || !el.animate) {
|
|
19
|
+
first = false;
|
|
20
|
+
style.display = open ? initial : "none";
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (open) style.display = initial;
|
|
24
|
+
anim = el.animate(open ? [hidden, shown] : [shown, hidden], { duration, easing: "ease-out", fill: "forwards" });
|
|
25
|
+
anim.onfinish = () => {
|
|
22
26
|
anim?.cancel();
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
anim.onfinish = () => {
|
|
31
|
-
anim?.cancel();
|
|
32
|
-
if (!open) style.display = "none";
|
|
33
|
-
};
|
|
34
|
-
});
|
|
35
|
-
}
|
|
27
|
+
if (!open) style.display = "none";
|
|
28
|
+
};
|
|
29
|
+
});
|
|
30
|
+
cleanup(() => {
|
|
31
|
+
anim?.cancel();
|
|
32
|
+
style.display = own;
|
|
33
|
+
});
|
|
36
34
|
});
|
|
37
35
|
export {
|
|
38
36
|
transition
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/transition.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { toMs } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/**\n * Shows and hides with a fade: `transition=\"$open\"`. Modifier: `__duration.200ms`.\n */\nexport const transition = dir('transition', 6, ({ el, mods, evaluate, effect, cleanup }) => {\n const style = (el as HTMLElement).style;\n const duration = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : toMs(mods.get('duration'), 200);\n const hidden = { opacity: 0 };\n const shown = { opacity: 1 };\n const own = style.display;\n const initial = own === 'none' ? '' : own;\n let anim: Animation | undefined;\n let first = true;\n let last: boolean | undefined;\n effect(() => {\n const open = !!evaluate();\n if (open === last) return; // a dependency changed but the outcome did not: leave the element alone\n last = open;\n anim?.cancel();\n if (first || !el.animate) {\n first = false;\n style.display = open ? initial : 'none';\n return;\n }\n if (open) style.display = initial;\n anim = el.animate(open ? [hidden, shown] : [shown, hidden], { duration, easing: 'ease-out', fill: 'forwards' });\n anim.onfinish = () => {\n anim?.cancel();\n if (!open) style.display = 'none';\n };\n });\n cleanup(() => {\n anim?.cancel();\n style.display = own; // the element's own inline display comes back when the directive goes\n });\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,WAAW;AAKb,MAAM,aAAa,IAAI,cAAc,GAAG,CAAC,EAAE,IAAI,MAAM,UAAU,QAAQ,QAAQ,MAAM;AAC1F,QAAM,QAAS,GAAmB;AAClC,QAAM,WAAW,WAAW,kCAAkC,EAAE,UAAU,IAAI,KAAK,KAAK,IAAI,UAAU,GAAG,GAAG;AAC5G,QAAM,SAAS,EAAE,SAAS,EAAE;AAC5B,QAAM,QAAQ,EAAE,SAAS,EAAE;AAC3B,QAAM,MAAM,MAAM;AAClB,QAAM,UAAU,QAAQ,SAAS,KAAK;AACtC,MAAI;AACJ,MAAI,QAAQ;AACZ,MAAI;AACJ,SAAO,MAAM;AACX,UAAM,OAAO,CAAC,CAAC,SAAS;AACxB,QAAI,SAAS,KAAM;AACnB,WAAO;AACP,UAAM,OAAO;AACb,QAAI,SAAS,CAAC,GAAG,SAAS;AACxB,cAAQ;AACR,YAAM,UAAU,OAAO,UAAU;AACjC;AAAA,IACF;AACA,QAAI,KAAM,OAAM,UAAU;AAC1B,WAAO,GAAG,QAAQ,OAAO,CAAC,QAAQ,KAAK,IAAI,CAAC,OAAO,MAAM,GAAG,EAAE,UAAU,QAAQ,YAAY,MAAM,WAAW,CAAC;AAC9G,SAAK,WAAW,MAAM;AACpB,YAAM,OAAO;AACb,UAAI,CAAC,KAAM,OAAM,UAAU;AAAA,IAC7B;AAAA,EACF,CAAC;AACD,UAAQ,MAAM;AACZ,UAAM,OAAO;AACb,UAAM,UAAU;AAAA,EAClB,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `animate:opacity="$open ? 1 : 0"` tweens a numeric CSS property
|
|
2
|
+
* `animate:opacity="$open ? 1 : 0"` tweens a numeric CSS property from its
|
|
3
3
|
* current value to the expression's value whenever the expression changes.
|
|
4
|
-
*
|
|
4
|
+
* `__duration.300ms` sets the length; the tween eases out. Non-numeric values apply immediately.
|
|
5
5
|
*/
|
|
6
6
|
export declare const animate: import("../../kernel/contracts.js").AttributePlugin;
|
|
@@ -1,56 +1,40 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
linear: (t) => t,
|
|
4
|
-
"ease-in": (t) => t * t,
|
|
5
|
-
"ease-out": (t) => 1 - (1 - t) * (1 - t),
|
|
6
|
-
"ease-in-out": (t) => t < 0.5 ? 2 * t * t : 1 - (-2 * t + 2) ** 2 / 2
|
|
7
|
-
};
|
|
1
|
+
import { toMs } from "../../kernel/index.js";
|
|
2
|
+
import { dir } from "../def.js";
|
|
8
3
|
const num = (s) => {
|
|
9
4
|
const m = /^\s*(-?\d*\.?\d+)([a-z%]*)\s*$/i.exec(s);
|
|
10
|
-
return m ?
|
|
5
|
+
return m ? [+m[1], m[2]] : void 0;
|
|
11
6
|
};
|
|
12
|
-
const animate =
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const b = target.n;
|
|
44
|
-
const start = performance.now();
|
|
45
|
-
const tick = (now) => {
|
|
46
|
-
const p = Math.min(1, (now - start) / duration);
|
|
47
|
-
write(`${a + (b - a) * ease(p)}${target.unit}`);
|
|
48
|
-
if (p < 1) frame = requestAnimationFrame(tick);
|
|
49
|
-
};
|
|
50
|
-
frame = requestAnimationFrame(tick);
|
|
51
|
-
});
|
|
52
|
-
cleanup(() => cancelAnimationFrame(frame));
|
|
53
|
-
}
|
|
7
|
+
const animate = dir("animate", 5, ({ el, mods, cased, evaluate, effect, cleanup }) => {
|
|
8
|
+
const prop = cased("kebab");
|
|
9
|
+
const duration = toMs(mods.get("duration"), 300);
|
|
10
|
+
const instant = matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
11
|
+
const read = () => el.style.getPropertyValue(prop) || getComputedStyle(el).getPropertyValue(prop);
|
|
12
|
+
const write = (v) => el.style.setProperty(prop, v);
|
|
13
|
+
let frame = 0;
|
|
14
|
+
let first = true;
|
|
15
|
+
let last;
|
|
16
|
+
effect(() => {
|
|
17
|
+
const to = String(evaluate());
|
|
18
|
+
if (to === last) return;
|
|
19
|
+
last = to;
|
|
20
|
+
cancelAnimationFrame(frame);
|
|
21
|
+
const from = num(read());
|
|
22
|
+
const target = num(to);
|
|
23
|
+
if (first || instant || duration <= 0 || !from || !target || from[1] !== target[1]) {
|
|
24
|
+
first = false;
|
|
25
|
+
return write(to);
|
|
26
|
+
}
|
|
27
|
+
const [a, unit] = from;
|
|
28
|
+
const b = target[0];
|
|
29
|
+
const start = performance.now();
|
|
30
|
+
const tick = (now) => {
|
|
31
|
+
const p = Math.min(1, (now - start) / duration);
|
|
32
|
+
write(`${a + (b - a) * (1 - (1 - p) ** 2)}${unit}`);
|
|
33
|
+
if (p < 1) frame = requestAnimationFrame(tick);
|
|
34
|
+
};
|
|
35
|
+
frame = requestAnimationFrame(tick);
|
|
36
|
+
});
|
|
37
|
+
cleanup(() => cancelAnimationFrame(frame));
|
|
54
38
|
});
|
|
55
39
|
export {
|
|
56
40
|
animate
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/plugins/directives/tween.ts"],
|
|
4
|
-
"sourcesContent": ["import {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
4
|
+
"sourcesContent": ["import { toMs } from '../../kernel/index.js';\nimport { dir } from '../def.js';\n\n/** '12.5px' \u2192 [12.5, 'px']; undefined when not numeric. */\nconst num = (s: string): [number, string] | undefined => {\n const m = /^\\s*(-?\\d*\\.?\\d+)([a-z%]*)\\s*$/i.exec(s);\n return m ? [+m[1], m[2]] : undefined;\n};\n\n/**\n * `animate:opacity=\"$open ? 1 : 0\"` tweens a numeric CSS property from its\n * current value to the expression's value whenever the expression changes.\n * `__duration.300ms` sets the length; the tween eases out. Non-numeric values apply immediately.\n */\nexport const animate = dir('animate', 5, ({ el, mods, cased, evaluate, effect, cleanup }) => {\n const prop = cased('kebab');\n const duration = toMs(mods.get('duration'), 300);\n const instant = matchMedia('(prefers-reduced-motion: reduce)').matches;\n // Prefer the inline value (which this directive wrote last time); computed styles report px only.\n const read = () => el.style.getPropertyValue(prop) || getComputedStyle(el).getPropertyValue(prop);\n const write = (v: string) => el.style.setProperty(prop, v);\n let frame = 0;\n let first = true;\n let last: string | undefined;\n effect(() => {\n const to = String(evaluate());\n if (to === last) return;\n last = to;\n cancelAnimationFrame(frame);\n const from = num(read());\n const target = num(to);\n if (first || instant || duration <= 0 || !from || !target || from[1] !== target[1]) {\n first = false;\n return write(to);\n }\n const [a, unit] = from;\n const b = target[0];\n const start = performance.now();\n const tick = (now: number) => {\n const p = Math.min(1, (now - start) / duration);\n write(`${a + (b - a) * (1 - (1 - p) ** 2)}${unit}`);\n if (p < 1) frame = requestAnimationFrame(tick);\n };\n frame = requestAnimationFrame(tick);\n });\n cleanup(() => cancelAnimationFrame(frame));\n});\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,YAAY;AACrB,SAAS,WAAW;AAGpB,MAAM,MAAM,CAAC,MAA4C;AACvD,QAAM,IAAI,kCAAkC,KAAK,CAAC;AAClD,SAAO,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI;AAC7B;AAOO,MAAM,UAAU,IAAI,WAAW,GAAG,CAAC,EAAE,IAAI,MAAM,OAAO,UAAU,QAAQ,QAAQ,MAAM;AAC3F,QAAM,OAAO,MAAM,OAAO;AAC1B,QAAM,WAAW,KAAK,KAAK,IAAI,UAAU,GAAG,GAAG;AAC/C,QAAM,UAAU,WAAW,kCAAkC,EAAE;AAE/D,QAAM,OAAO,MAAM,GAAG,MAAM,iBAAiB,IAAI,KAAK,iBAAiB,EAAE,EAAE,iBAAiB,IAAI;AAChG,QAAM,QAAQ,CAAC,MAAc,GAAG,MAAM,YAAY,MAAM,CAAC;AACzD,MAAI,QAAQ;AACZ,MAAI,QAAQ;AACZ,MAAI;AACJ,SAAO,MAAM;AACX,UAAM,KAAK,OAAO,SAAS,CAAC;AAC5B,QAAI,OAAO,KAAM;AACjB,WAAO;AACP,yBAAqB,KAAK;AAC1B,UAAM,OAAO,IAAI,KAAK,CAAC;AACvB,UAAM,SAAS,IAAI,EAAE;AACrB,QAAI,SAAS,WAAW,YAAY,KAAK,CAAC,QAAQ,CAAC,UAAU,KAAK,CAAC,MAAM,OAAO,CAAC,GAAG;AAClF,cAAQ;AACR,aAAO,MAAM,EAAE;AAAA,IACjB;AACA,UAAM,CAAC,GAAG,IAAI,IAAI;AAClB,UAAM,IAAI,OAAO,CAAC;AAClB,UAAM,QAAQ,YAAY,IAAI;AAC9B,UAAM,OAAO,CAAC,QAAgB;AAC5B,YAAM,IAAI,KAAK,IAAI,IAAI,MAAM,SAAS,QAAQ;AAC9C,YAAM,GAAG,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,EAAE,GAAG,IAAI,EAAE;AAClD,UAAI,IAAI,EAAG,SAAQ,sBAAsB,IAAI;AAAA,IAC/C;AACA,YAAQ,sBAAsB,IAAI;AAAA,EACpC,CAAC;AACD,UAAQ,MAAM,qBAAqB,KAAK,CAAC;AAC3C,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Two-way binding: `bind:name` or `bind="name"`. Creates the signal from the element when missing.
|
|
3
3
|
* Checkbox groups bind to arrays, radios to the checked value, `select multiple` to arrays.
|
|
4
|
-
* `
|
|
4
|
+
* `__event.change` picks the events to listen for.
|
|
5
5
|
*/
|
|
6
6
|
export declare const bind: import("../../kernel/contracts.js").AttributePlugin;
|