sigmx 0.1.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/LICENSE +21 -0
- package/README.md +173 -0
- package/dist/auto.d.ts +1 -0
- package/dist/auto.js +7 -0
- package/dist/auto.js.map +7 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +26 -0
- package/dist/cli.js.map +7 -0
- package/dist/core/csp.d.ts +7 -0
- package/dist/core/csp.js +20 -0
- package/dist/core/csp.js.map +7 -0
- package/dist/core/engine.d.ts +10 -0
- package/dist/core/engine.js +200 -0
- package/dist/core/engine.js.map +7 -0
- package/dist/core/expr.d.ts +12 -0
- package/dist/core/expr.js +94 -0
- package/dist/core/expr.js.map +7 -0
- package/dist/core/index.d.ts +16 -0
- package/dist/core/index.js +46 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/signals.d.ts +42 -0
- package/dist/core/signals.js +195 -0
- package/dist/core/signals.js.map +7 -0
- package/dist/core/store.d.ts +32 -0
- package/dist/core/store.js +185 -0
- package/dist/core/store.js.map +7 -0
- package/dist/core/types.d.ts +101 -0
- package/dist/core/types.js +1 -0
- package/dist/core/types.js.map +7 -0
- package/dist/kernel/compile.d.ts +16 -0
- package/dist/kernel/compile.js +96 -0
- package/dist/kernel/compile.js.map +7 -0
- package/dist/kernel/contracts.d.ts +121 -0
- package/dist/kernel/contracts.js +1 -0
- package/dist/kernel/contracts.js.map +7 -0
- package/dist/kernel/index.d.ts +20 -0
- package/dist/kernel/index.js +54 -0
- package/dist/kernel/index.js.map +7 -0
- package/dist/kernel/precompile.d.ts +25 -0
- package/dist/kernel/precompile.js +111 -0
- package/dist/kernel/precompile.js.map +7 -0
- package/dist/kernel/precompiled.d.ts +11 -0
- package/dist/kernel/precompiled.js +13 -0
- package/dist/kernel/precompiled.js.map +7 -0
- package/dist/kernel/reactive.d.ts +42 -0
- package/dist/kernel/reactive.js +201 -0
- package/dist/kernel/reactive.js.map +7 -0
- package/dist/kernel/runtime.d.ts +11 -0
- package/dist/kernel/runtime.js +210 -0
- package/dist/kernel/runtime.js.map +7 -0
- package/dist/kernel/scan.d.ts +42 -0
- package/dist/kernel/scan.js +68 -0
- package/dist/kernel/scan.js.map +7 -0
- package/dist/kernel/state.d.ts +32 -0
- package/dist/kernel/state.js +186 -0
- package/dist/kernel/state.js.map +7 -0
- package/dist/kernel/strict-csp.d.ts +7 -0
- package/dist/kernel/strict-csp.js +20 -0
- package/dist/kernel/strict-csp.js.map +7 -0
- package/dist/lib/casing.d.ts +7 -0
- package/dist/lib/casing.js +16 -0
- package/dist/lib/casing.js.map +7 -0
- package/dist/lib/objects.d.ts +9 -0
- package/dist/lib/objects.js +26 -0
- package/dist/lib/objects.js.map +7 -0
- package/dist/lib/schedule.d.ts +14 -0
- package/dist/lib/schedule.js +51 -0
- package/dist/lib/schedule.js.map +7 -0
- package/dist/lib/sse.d.ts +10 -0
- package/dist/lib/sse.js +55 -0
- package/dist/lib/sse.js.map +7 -0
- package/dist/plugins/actions/clipboard.d.ts +2 -0
- package/dist/plugins/actions/clipboard.js +11 -0
- package/dist/plugins/actions/clipboard.js.map +7 -0
- package/dist/plugins/actions/fit.d.ts +2 -0
- package/dist/plugins/actions/fit.js +14 -0
- package/dist/plugins/actions/fit.js.map +7 -0
- package/dist/plugins/actions/intl.d.ts +2 -0
- package/dist/plugins/actions/intl.js +21 -0
- package/dist/plugins/actions/intl.js.map +7 -0
- package/dist/plugins/actions/peek.d.ts +2 -0
- package/dist/plugins/actions/peek.js +6 -0
- package/dist/plugins/actions/peek.js.map +7 -0
- package/dist/plugins/actions/setAll.d.ts +2 -0
- package/dist/plugins/actions/setAll.js +11 -0
- package/dist/plugins/actions/setAll.js.map +7 -0
- package/dist/plugins/actions/toggleAll.d.ts +2 -0
- package/dist/plugins/actions/toggleAll.js +11 -0
- package/dist/plugins/actions/toggleAll.js.map +7 -0
- package/dist/plugins/attributes/attr.d.ts +2 -0
- package/dist/plugins/attributes/attr.js +20 -0
- package/dist/plugins/attributes/attr.js.map +7 -0
- package/dist/plugins/attributes/bind.d.ts +6 -0
- package/dist/plugins/attributes/bind.js +81 -0
- package/dist/plugins/attributes/bind.js.map +7 -0
- package/dist/plugins/attributes/class.d.ts +2 -0
- package/dist/plugins/attributes/class.js +22 -0
- package/dist/plugins/attributes/class.js.map +7 -0
- package/dist/plugins/attributes/computed.d.ts +2 -0
- package/dist/plugins/attributes/computed.js +20 -0
- package/dist/plugins/attributes/computed.js.map +7 -0
- package/dist/plugins/attributes/customValidity.d.ts +2 -0
- package/dist/plugins/attributes/customValidity.js +14 -0
- package/dist/plugins/attributes/customValidity.js.map +7 -0
- package/dist/plugins/attributes/effect.d.ts +2 -0
- package/dist/plugins/attributes/effect.js +12 -0
- package/dist/plugins/attributes/effect.js.map +7 -0
- package/dist/plugins/attributes/indicator.d.ts +2 -0
- package/dist/plugins/attributes/indicator.js +20 -0
- package/dist/plugins/attributes/indicator.js.map +7 -0
- package/dist/plugins/attributes/init.d.ts +2 -0
- package/dist/plugins/attributes/init.js +14 -0
- package/dist/plugins/attributes/init.js.map +7 -0
- package/dist/plugins/attributes/jsonSignals.d.ts +2 -0
- package/dist/plugins/attributes/jsonSignals.js +15 -0
- package/dist/plugins/attributes/jsonSignals.js.map +7 -0
- package/dist/plugins/attributes/matchMedia.d.ts +2 -0
- package/dist/plugins/attributes/matchMedia.js +19 -0
- package/dist/plugins/attributes/matchMedia.js.map +7 -0
- package/dist/plugins/attributes/on.d.ts +5 -0
- package/dist/plugins/attributes/on.js +28 -0
- package/dist/plugins/attributes/on.js.map +7 -0
- package/dist/plugins/attributes/onIntersect.d.ts +2 -0
- package/dist/plugins/attributes/onIntersect.js +28 -0
- package/dist/plugins/attributes/onIntersect.js.map +7 -0
- package/dist/plugins/attributes/onInterval.d.ts +2 -0
- package/dist/plugins/attributes/onInterval.js +18 -0
- package/dist/plugins/attributes/onInterval.js.map +7 -0
- package/dist/plugins/attributes/onRaf.d.ts +1 -0
- package/dist/plugins/attributes/onRaf.js +19 -0
- package/dist/plugins/attributes/onRaf.js.map +7 -0
- package/dist/plugins/attributes/onResize.d.ts +1 -0
- package/dist/plugins/attributes/onResize.js +17 -0
- package/dist/plugins/attributes/onResize.js.map +7 -0
- package/dist/plugins/attributes/onSignalPatch.d.ts +5 -0
- package/dist/plugins/attributes/onSignalPatch.js +35 -0
- package/dist/plugins/attributes/onSignalPatch.js.map +7 -0
- package/dist/plugins/attributes/persist.d.ts +6 -0
- package/dist/plugins/attributes/persist.js +16 -0
- package/dist/plugins/attributes/persist.js.map +7 -0
- package/dist/plugins/attributes/queryString.d.ts +5 -0
- package/dist/plugins/attributes/queryString.js +54 -0
- package/dist/plugins/attributes/queryString.js.map +7 -0
- package/dist/plugins/attributes/ref.d.ts +2 -0
- package/dist/plugins/attributes/ref.js +13 -0
- package/dist/plugins/attributes/ref.js.map +7 -0
- package/dist/plugins/attributes/replaceUrl.d.ts +1 -0
- package/dist/plugins/attributes/replaceUrl.js +11 -0
- package/dist/plugins/attributes/replaceUrl.js.map +7 -0
- package/dist/plugins/attributes/scrollIntoView.d.ts +2 -0
- package/dist/plugins/attributes/scrollIntoView.js +19 -0
- package/dist/plugins/attributes/scrollIntoView.js.map +7 -0
- package/dist/plugins/attributes/show.d.ts +2 -0
- package/dist/plugins/attributes/show.js +19 -0
- package/dist/plugins/attributes/show.js.map +7 -0
- package/dist/plugins/attributes/signals.d.ts +2 -0
- package/dist/plugins/attributes/signals.js +13 -0
- package/dist/plugins/attributes/signals.js.map +7 -0
- package/dist/plugins/attributes/style.d.ts +2 -0
- package/dist/plugins/attributes/style.js +25 -0
- package/dist/plugins/attributes/style.js.map +7 -0
- package/dist/plugins/attributes/text.d.ts +1 -0
- package/dist/plugins/attributes/text.js +13 -0
- package/dist/plugins/attributes/text.js.map +7 -0
- package/dist/plugins/attributes/viewTransition.d.ts +1 -0
- package/dist/plugins/attributes/viewTransition.js +11 -0
- package/dist/plugins/attributes/viewTransition.js.map +7 -0
- package/dist/plugins/directives/attribute-sync.d.ts +2 -0
- package/dist/plugins/directives/attribute-sync.js +20 -0
- package/dist/plugins/directives/attribute-sync.js.map +7 -0
- package/dist/plugins/directives/boost.d.ts +6 -0
- package/dist/plugins/directives/boost.js +35 -0
- package/dist/plugins/directives/boost.js.map +7 -0
- package/dist/plugins/directives/busy-flag.d.ts +2 -0
- package/dist/plugins/directives/busy-flag.js +21 -0
- package/dist/plugins/directives/busy-flag.js.map +7 -0
- package/dist/plugins/directives/class-toggle.d.ts +2 -0
- package/dist/plugins/directives/class-toggle.js +22 -0
- package/dist/plugins/directives/class-toggle.js.map +7 -0
- package/dist/plugins/directives/cloak.d.ts +5 -0
- package/dist/plugins/directives/cloak.js +11 -0
- package/dist/plugins/directives/cloak.js.map +7 -0
- package/dist/plugins/directives/collapse.d.ts +5 -0
- package/dist/plugins/directives/collapse.js +42 -0
- package/dist/plugins/directives/collapse.js.map +7 -0
- package/dist/plugins/directives/declare.d.ts +2 -0
- package/dist/plugins/directives/declare.js +13 -0
- package/dist/plugins/directives/declare.js.map +7 -0
- package/dist/plugins/directives/derive.d.ts +2 -0
- package/dist/plugins/directives/derive.js +20 -0
- package/dist/plugins/directives/derive.js.map +7 -0
- package/dist/plugins/directives/element-ref.d.ts +2 -0
- package/dist/plugins/directives/element-ref.js +13 -0
- package/dist/plugins/directives/element-ref.js.map +7 -0
- package/dist/plugins/directives/event-listener.d.ts +5 -0
- package/dist/plugins/directives/event-listener.js +28 -0
- package/dist/plugins/directives/event-listener.js.map +7 -0
- package/dist/plugins/directives/frame-loop.d.ts +1 -0
- package/dist/plugins/directives/frame-loop.js +19 -0
- package/dist/plugins/directives/frame-loop.js.map +7 -0
- package/dist/plugins/directives/html.d.ts +2 -0
- package/dist/plugins/directives/html.js +13 -0
- package/dist/plugins/directives/html.js.map +7 -0
- package/dist/plugins/directives/inline-style.d.ts +2 -0
- package/dist/plugins/directives/inline-style.js +25 -0
- package/dist/plugins/directives/inline-style.js.map +7 -0
- package/dist/plugins/directives/mask.d.ts +7 -0
- package/dist/plugins/directives/mask.js +47 -0
- package/dist/plugins/directives/mask.js.map +7 -0
- package/dist/plugins/directives/media-query.d.ts +2 -0
- package/dist/plugins/directives/media-query.js +19 -0
- package/dist/plugins/directives/media-query.js.map +7 -0
- package/dist/plugins/directives/on-mount.d.ts +2 -0
- package/dist/plugins/directives/on-mount.js +14 -0
- package/dist/plugins/directives/on-mount.js.map +7 -0
- package/dist/plugins/directives/patch-listener.d.ts +5 -0
- package/dist/plugins/directives/patch-listener.js +35 -0
- package/dist/plugins/directives/patch-listener.js.map +7 -0
- package/dist/plugins/directives/remove-me.d.ts +2 -0
- package/dist/plugins/directives/remove-me.js +13 -0
- package/dist/plugins/directives/remove-me.js.map +7 -0
- package/dist/plugins/directives/scroll-to.d.ts +2 -0
- package/dist/plugins/directives/scroll-to.js +19 -0
- package/dist/plugins/directives/scroll-to.js.map +7 -0
- package/dist/plugins/directives/size-watch.d.ts +1 -0
- package/dist/plugins/directives/size-watch.js +17 -0
- package/dist/plugins/directives/size-watch.js.map +7 -0
- package/dist/plugins/directives/state-dump.d.ts +2 -0
- package/dist/plugins/directives/state-dump.js +15 -0
- package/dist/plugins/directives/state-dump.js.map +7 -0
- package/dist/plugins/directives/storage-sync.d.ts +6 -0
- package/dist/plugins/directives/storage-sync.js +16 -0
- package/dist/plugins/directives/storage-sync.js.map +7 -0
- package/dist/plugins/directives/teleport.d.ts +5 -0
- package/dist/plugins/directives/teleport.js +19 -0
- package/dist/plugins/directives/teleport.js.map +7 -0
- package/dist/plugins/directives/text-content.d.ts +1 -0
- package/dist/plugins/directives/text-content.js +13 -0
- package/dist/plugins/directives/text-content.js.map +7 -0
- package/dist/plugins/directives/timer.d.ts +2 -0
- package/dist/plugins/directives/timer.js +18 -0
- package/dist/plugins/directives/timer.js.map +7 -0
- package/dist/plugins/directives/transition-name.d.ts +1 -0
- package/dist/plugins/directives/transition-name.js +11 -0
- package/dist/plugins/directives/transition-name.js.map +7 -0
- package/dist/plugins/directives/transition.d.ts +5 -0
- package/dist/plugins/directives/transition.js +40 -0
- package/dist/plugins/directives/transition.js.map +7 -0
- package/dist/plugins/directives/trap.d.ts +5 -0
- package/dist/plugins/directives/trap.js +48 -0
- package/dist/plugins/directives/trap.js.map +7 -0
- package/dist/plugins/directives/tween.d.ts +6 -0
- package/dist/plugins/directives/tween.js +58 -0
- package/dist/plugins/directives/tween.js.map +7 -0
- package/dist/plugins/directives/two-way-bind.d.ts +6 -0
- package/dist/plugins/directives/two-way-bind.js +82 -0
- package/dist/plugins/directives/two-way-bind.js.map +7 -0
- package/dist/plugins/directives/url-params.d.ts +13 -0
- package/dist/plugins/directives/url-params.js +76 -0
- package/dist/plugins/directives/url-params.js.map +7 -0
- package/dist/plugins/directives/url-replace.d.ts +1 -0
- package/dist/plugins/directives/url-replace.js +11 -0
- package/dist/plugins/directives/url-replace.js.map +7 -0
- package/dist/plugins/directives/validity.d.ts +2 -0
- package/dist/plugins/directives/validity.js +14 -0
- package/dist/plugins/directives/validity.js.map +7 -0
- package/dist/plugins/directives/viewport.d.ts +2 -0
- package/dist/plugins/directives/viewport.js +28 -0
- package/dist/plugins/directives/viewport.js.map +7 -0
- package/dist/plugins/directives/visibility.d.ts +2 -0
- package/dist/plugins/directives/visibility.js +19 -0
- package/dist/plugins/directives/visibility.js.map +7 -0
- package/dist/plugins/directives/watch.d.ts +2 -0
- package/dist/plugins/directives/watch.js +12 -0
- package/dist/plugins/directives/watch.js.map +7 -0
- package/dist/plugins/functions/bulk-set.d.ts +2 -0
- package/dist/plugins/functions/bulk-set.js +11 -0
- package/dist/plugins/functions/bulk-set.js.map +7 -0
- package/dist/plugins/functions/bulk-toggle.d.ts +2 -0
- package/dist/plugins/functions/bulk-toggle.js +11 -0
- package/dist/plugins/functions/bulk-toggle.js.map +7 -0
- package/dist/plugins/functions/confirm.d.ts +2 -0
- package/dist/plugins/functions/confirm.js +6 -0
- package/dist/plugins/functions/confirm.js.map +7 -0
- package/dist/plugins/functions/copy-text.d.ts +2 -0
- package/dist/plugins/functions/copy-text.js +11 -0
- package/dist/plugins/functions/copy-text.js.map +7 -0
- package/dist/plugins/functions/dispatch.d.ts +2 -0
- package/dist/plugins/functions/dispatch.js +9 -0
- package/dist/plugins/functions/dispatch.js.map +7 -0
- package/dist/plugins/functions/locale-format.d.ts +2 -0
- package/dist/plugins/functions/locale-format.js +21 -0
- package/dist/plugins/functions/locale-format.js.map +7 -0
- package/dist/plugins/functions/range-map.d.ts +2 -0
- package/dist/plugins/functions/range-map.js +14 -0
- package/dist/plugins/functions/range-map.js.map +7 -0
- package/dist/plugins/functions/request.d.ts +30 -0
- package/dist/plugins/functions/request.js +152 -0
- package/dist/plugins/functions/request.js.map +7 -0
- package/dist/plugins/functions/untracked-read.d.ts +2 -0
- package/dist/plugins/functions/untracked-read.js +6 -0
- package/dist/plugins/functions/untracked-read.js.map +7 -0
- package/dist/plugins/functions/websocket.d.ts +11 -0
- package/dist/plugins/functions/websocket.js +35 -0
- package/dist/plugins/functions/websocket.js.map +7 -0
- package/dist/plugins/index.d.ts +52 -0
- package/dist/plugins/index.js +108 -0
- package/dist/plugins/index.js.map +7 -0
- package/dist/plugins/server-events/apply-elements.d.ts +2 -0
- package/dist/plugins/server-events/apply-elements.js +62 -0
- package/dist/plugins/server-events/apply-elements.js.map +7 -0
- package/dist/plugins/server-events/apply-state.d.ts +2 -0
- package/dist/plugins/server-events/apply-state.js +18 -0
- package/dist/plugins/server-events/apply-state.js.map +7 -0
- package/dist/plugins/server-events/morph.d.ts +12 -0
- package/dist/plugins/server-events/morph.js +124 -0
- package/dist/plugins/server-events/morph.js.map +7 -0
- package/dist/presets/all.d.ts +3 -0
- package/dist/presets/all.js +112 -0
- package/dist/presets/all.js.map +7 -0
- package/dist/presets/essentials.d.ts +3 -0
- package/dist/presets/essentials.js +18 -0
- package/dist/presets/essentials.js.map +7 -0
- package/dist/presets/minimal.d.ts +3 -0
- package/dist/presets/minimal.js +9 -0
- package/dist/presets/minimal.js.map +7 -0
- package/dist/sigmx.auto.js +5 -0
- package/dist/sigmx.standalone.js +1 -0
- package/dist/standalone.d.ts +1 -0
- package/dist/standalone.js +8 -0
- package/dist/standalone.js.map +7 -0
- package/dist/utils/object.d.ts +9 -0
- package/dist/utils/object.js +26 -0
- package/dist/utils/object.js.map +7 -0
- package/dist/utils/text.d.ts +7 -0
- package/dist/utils/text.js +15 -0
- package/dist/utils/text.js.map +7 -0
- package/dist/utils/timing.d.ts +14 -0
- package/dist/utils/timing.js +58 -0
- package/dist/utils/timing.js.map +7 -0
- package/dist/vite.d.ts +42 -0
- package/dist/vite.js +79 -0
- package/dist/vite.js.map +7 -0
- package/package.json +111 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { attribute, expand, toPredicate } from "../../kernel/index.js";
|
|
2
|
+
const parse = (s) => {
|
|
3
|
+
try {
|
|
4
|
+
return JSON.parse(s);
|
|
5
|
+
} catch {
|
|
6
|
+
return s;
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
10
|
+
const queryString = attribute({
|
|
11
|
+
name: "query-string",
|
|
12
|
+
mount({ key, value, mods, evaluate, cased, store, listen, effect }) {
|
|
13
|
+
const history = mods.has("history");
|
|
14
|
+
const push = (url) => {
|
|
15
|
+
if (url !== location.pathname + location.search + location.hash) window.history[history ? "pushState" : "replaceState"](null, "", url);
|
|
16
|
+
};
|
|
17
|
+
const urlWith = (q) => `${location.pathname}${q.size ? `?${q}` : ""}${location.hash}`;
|
|
18
|
+
let restoring = false;
|
|
19
|
+
const restore = (fn) => {
|
|
20
|
+
restoring = true;
|
|
21
|
+
try {
|
|
22
|
+
fn();
|
|
23
|
+
} finally {
|
|
24
|
+
restoring = false;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
if (key) {
|
|
28
|
+
const path = cased();
|
|
29
|
+
const fallback = value ? evaluate() : "";
|
|
30
|
+
const fromUrl2 = () => {
|
|
31
|
+
const raw = new URLSearchParams(location.search).get(key);
|
|
32
|
+
store.set(path, raw === null ? fallback : parse(raw));
|
|
33
|
+
};
|
|
34
|
+
if (!store.has(path) || new URLSearchParams(location.search).has(key)) fromUrl2();
|
|
35
|
+
effect(() => {
|
|
36
|
+
const v = store.get(path);
|
|
37
|
+
if (restoring) return;
|
|
38
|
+
const q = new URLSearchParams(location.search);
|
|
39
|
+
if (v === void 0 || same(v, fallback)) q.delete(key);
|
|
40
|
+
else q.set(key, typeof v === "string" ? v : JSON.stringify(v));
|
|
41
|
+
push(urlWith(q));
|
|
42
|
+
});
|
|
43
|
+
if (history) listen(window, "popstate", () => restore(fromUrl2));
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const filter = value ? evaluate() : void 0;
|
|
47
|
+
const ok = toPredicate(filter);
|
|
48
|
+
const fromUrl = () => {
|
|
49
|
+
const patch = {};
|
|
50
|
+
for (const [k, v] of new URLSearchParams(location.search)) if (ok(k)) expand(patch, k, parse(v));
|
|
51
|
+
store.merge(patch);
|
|
52
|
+
};
|
|
53
|
+
fromUrl();
|
|
54
|
+
effect(() => {
|
|
55
|
+
const snap = store.snapshot(filter, { computed: false });
|
|
56
|
+
if (restoring) return;
|
|
57
|
+
const q = new URLSearchParams(location.search);
|
|
58
|
+
const walk = (obj, prefix) => {
|
|
59
|
+
for (const k in obj) {
|
|
60
|
+
const p = prefix ? `${prefix}.${k}` : k;
|
|
61
|
+
const v = obj[k];
|
|
62
|
+
if (v && typeof v === "object" && !Array.isArray(v)) walk(v, p);
|
|
63
|
+
else if (mods.has("filter") && (v === "" || v == null)) q.delete(p);
|
|
64
|
+
else q.set(p, typeof v === "string" ? v : JSON.stringify(v));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
walk(snap, "");
|
|
68
|
+
push(urlWith(q));
|
|
69
|
+
});
|
|
70
|
+
if (history) listen(window, "popstate", () => restore(fromUrl));
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export {
|
|
74
|
+
queryString
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=url-params.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/url-params.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, expand, toPredicate } from '../../kernel/index.js'\n\nconst parse = (s: string): unknown => {\n try {\n return JSON.parse(s)\n } catch {\n return s\n }\n}\nconst same = (a: unknown, b: unknown) => JSON.stringify(a) === JSON.stringify(b)\n\n/**\n * Keeps signals and the URL query string in step.\n *\n * Keyed form declares one signal with a default: `query-string:page=\"1\"` creates `page`, reads\n * `?page=` on load when present (otherwise uses the default), writes it whenever it changes, and\n * drops the parameter again when the value is back at the default. The parameter name is the key\n * as written; the signal name is recased as usual.\n *\n * Bare form syncs existing signals: `query-string=\"{ include: /^(q|sort)$/ }\"` mirrors matching\n * paths both ways. `__history` pushes an entry per change and restores on back/forward;\n * `__filter` drops empty values from the URL.\n */\nexport const queryString = attribute({\n name: 'query-string',\n mount({ key, value, mods, evaluate, cased, store, listen, effect }) {\n const history = mods.has('history')\n const push = (url: string) => {\n if (url !== location.pathname + location.search + location.hash) window.history[history ? 'pushState' : 'replaceState'](null, '', url)\n }\n const urlWith = (q: URLSearchParams) => `${location.pathname}${q.size ? `?${q}` : ''}${location.hash}`\n let restoring = false\n const restore = (fn: () => void) => {\n restoring = true\n try {\n fn()\n } finally {\n restoring = false\n }\n }\n\n if (key) {\n const path = cased()\n const fallback = value ? evaluate() : ''\n const fromUrl = () => {\n const raw = new URLSearchParams(location.search).get(key)\n store.set(path, raw === null ? fallback : parse(raw))\n }\n if (!store.has(path) || new URLSearchParams(location.search).has(key)) fromUrl()\n effect(() => {\n const v = store.get(path)\n if (restoring) return\n const q = new URLSearchParams(location.search)\n if (v === undefined || same(v, fallback)) q.delete(key)\n else q.set(key, typeof v === 'string' ? v : JSON.stringify(v))\n push(urlWith(q))\n })\n if (history) listen(window, 'popstate', () => restore(fromUrl))\n return\n }\n\n const filter = value ? evaluate() : undefined\n const ok = toPredicate(filter)\n const fromUrl = () => {\n const patch = {}\n for (const [k, v] of new URLSearchParams(location.search)) if (ok(k)) expand(patch, k, parse(v))\n store.merge(patch)\n }\n fromUrl()\n effect(() => {\n const snap = store.snapshot(filter, { computed: false })\n if (restoring) return\n const q = new URLSearchParams(location.search)\n const walk = (obj: Record<string, any>, prefix: string) => {\n for (const k in obj) {\n const p = prefix ? `${prefix}.${k}` : k\n const v = obj[k]\n if (v && typeof v === 'object' && !Array.isArray(v)) walk(v, p)\n else if (mods.has('filter') && (v === '' || v == null)) q.delete(p)\n else q.set(p, typeof v === 'string' ? v : JSON.stringify(v))\n }\n }\n walk(snap, '')\n push(urlWith(q))\n })\n if (history) listen(window, 'popstate', () => restore(fromUrl))\n },\n})\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": ["fromUrl"]
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const replaceUrl: import("../../kernel/contracts.js").AttributePlugin;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { attribute } from "../../kernel/index.js";
|
|
2
|
+
const replaceUrl = attribute({
|
|
3
|
+
name: "replace-url",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
mount: ({ evaluate, effect }) => effect(() => history.replaceState(history.state, "", new URL(String(evaluate()), location.href)))
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
replaceUrl
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=url-replace.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/url-replace.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\nexport const replaceUrl = attribute({\n name: 'replace-url',\n key: 'forbidden',\n value: 'required',\n mount: ({ evaluate, effect }) =>\n effect(() => history.replaceState(history.state, '', new URL(String(evaluate()), location.href))),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAEnB,MAAM,aAAa,UAAU;AAAA,EAClC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,OAAO,CAAC,EAAE,UAAU,OAAO,MACzB,OAAO,MAAM,QAAQ,aAAa,QAAQ,OAAO,IAAI,IAAI,IAAI,OAAO,SAAS,CAAC,GAAG,SAAS,IAAI,CAAC,CAAC;AACpG,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { attribute } from "../../kernel/index.js";
|
|
2
|
+
const customValidity = attribute({
|
|
3
|
+
name: "custom-validity",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
mount({ el, evaluate, effect, error }) {
|
|
7
|
+
if (!("setCustomValidity" in el)) throw error("only works on form fields");
|
|
8
|
+
effect(() => el.setCustomValidity(String(evaluate() ?? "")));
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
customValidity
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=validity.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/validity.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** The expression's string becomes the field's validity message; '' means valid. */\nexport const customValidity = attribute({\n name: 'custom-validity',\n key: 'forbidden',\n value: 'required',\n mount({ el, evaluate, effect, error }) {\n if (!('setCustomValidity' in el)) throw error('only works on form fields')\n effect(() => (el as HTMLInputElement).setCustomValidity(String(evaluate() ?? '')))\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,iBAAiB,UAAU;AAAA,EACtC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,UAAU,QAAQ,MAAM,GAAG;AACrC,QAAI,EAAE,uBAAuB,IAAK,OAAM,MAAM,2BAA2B;AACzE,WAAO,MAAO,GAAwB,kBAAkB,OAAO,SAAS,KAAK,EAAE,CAAC,CAAC;AAAA,EACnF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { attribute, withTiming, withViewTransition } from "../../kernel/index.js";
|
|
2
|
+
const onIntersect = attribute({
|
|
3
|
+
name: "on-intersect",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount({ el, mods, evaluate }) {
|
|
8
|
+
const t = mods.get("threshold")?.[0];
|
|
9
|
+
const threshold = mods.has("full") ? 1 : mods.has("half") ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0;
|
|
10
|
+
const run = withTiming(withViewTransition(() => evaluate(), mods), mods);
|
|
11
|
+
const io = new IntersectionObserver(
|
|
12
|
+
(entries) => {
|
|
13
|
+
for (const e of entries) {
|
|
14
|
+
if (e.isIntersecting === mods.has("exit")) continue;
|
|
15
|
+
run();
|
|
16
|
+
if (mods.has("once")) io.disconnect();
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{ threshold }
|
|
20
|
+
);
|
|
21
|
+
io.observe(el);
|
|
22
|
+
return () => io.disconnect();
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
export {
|
|
26
|
+
onIntersect
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=viewport.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/viewport.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute, withTiming, withViewTransition } from '../../kernel/index.js'\n\n/** Runs when the element enters the viewport. Modifiers: once, exit, full, half, threshold.N. */\nexport const onIntersect = attribute({\n name: 'on-intersect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount({ el, mods, evaluate }) {\n const t = mods.get('threshold')?.[0]\n const threshold = mods.has('full') ? 1 : mods.has('half') ? 0.5 : t ? Math.min(100, Math.max(0, +t)) / 100 : 0\n const run = withTiming(withViewTransition(() => evaluate(), mods), mods)\n const io = new IntersectionObserver(\n (entries) => {\n for (const e of entries) {\n if (e.isIntersecting === mods.has('exit')) continue\n run()\n if (mods.has('once')) io.disconnect()\n }\n },\n { threshold },\n )\n io.observe(el)\n return () => io.disconnect()\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,WAAW,YAAY,0BAA0B;AAGnD,MAAM,cAAc,UAAU;AAAA,EACnC,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,MAAM,EAAE,IAAI,MAAM,SAAS,GAAG;AAC5B,UAAM,IAAI,KAAK,IAAI,WAAW,IAAI,CAAC;AACnC,UAAM,YAAY,KAAK,IAAI,MAAM,IAAI,IAAI,KAAK,IAAI,MAAM,IAAI,MAAM,IAAI,KAAK,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,MAAM;AAC7G,UAAM,MAAM,WAAW,mBAAmB,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI;AACvE,UAAM,KAAK,IAAI;AAAA,MACb,CAAC,YAAY;AACX,mBAAW,KAAK,SAAS;AACvB,cAAI,EAAE,mBAAmB,KAAK,IAAI,MAAM,EAAG;AAC3C,cAAI;AACJ,cAAI,KAAK,IAAI,MAAM,EAAG,IAAG,WAAW;AAAA,QACtC;AAAA,MACF;AAAA,MACA,EAAE,UAAU;AAAA,IACd;AACA,OAAG,QAAQ,EAAE;AACb,WAAO,MAAM,GAAG,WAAW;AAAA,EAC7B;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { attribute } from "../../kernel/index.js";
|
|
2
|
+
const show = attribute({
|
|
3
|
+
name: "show",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
mount({ el, evaluate, effect }) {
|
|
7
|
+
const initial = el.style.display === "none" ? "" : el.style.display;
|
|
8
|
+
effect(() => {
|
|
9
|
+
el.style.display = evaluate() ? initial : "none";
|
|
10
|
+
});
|
|
11
|
+
return () => {
|
|
12
|
+
el.style.display = initial;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
export {
|
|
17
|
+
show
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=visibility.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/visibility.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Toggles `display: none`, restoring whatever inline display the element had. */\nexport const show = attribute({\n name: 'show',\n key: 'forbidden',\n value: 'required',\n mount({ el, evaluate, effect }) {\n const initial = el.style.display === 'none' ? '' : el.style.display\n effect(() => {\n el.style.display = evaluate() ? initial : 'none'\n })\n return () => {\n el.style.display = initial\n }\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,OAAO,UAAU;AAAA,EAC5B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,MAAM,EAAE,IAAI,UAAU,OAAO,GAAG;AAC9B,UAAM,UAAU,GAAG,MAAM,YAAY,SAAS,KAAK,GAAG,MAAM;AAC5D,WAAO,MAAM;AACX,SAAG,MAAM,UAAU,SAAS,IAAI,UAAU;AAAA,IAC5C,CAAC;AACD,WAAO,MAAM;AACX,SAAG,MAAM,UAAU;AAAA,IACrB;AAAA,EACF;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { attribute } from "../../kernel/index.js";
|
|
2
|
+
const effect = attribute({
|
|
3
|
+
name: "effect",
|
|
4
|
+
key: "forbidden",
|
|
5
|
+
value: "required",
|
|
6
|
+
returns: false,
|
|
7
|
+
mount: (ctx) => ctx.effect(() => ctx.evaluate())
|
|
8
|
+
});
|
|
9
|
+
export {
|
|
10
|
+
effect
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=watch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/directives/watch.ts"],
|
|
4
|
+
"sourcesContent": ["import { attribute } from '../../kernel/index.js'\n\n/** Runs the expression now and whenever a signal it read changes. */\nexport const effect = attribute({\n name: 'effect',\n key: 'forbidden',\n value: 'required',\n returns: false,\n mount: (ctx) => ctx.effect(() => ctx.evaluate()),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iBAAiB;AAGnB,MAAM,SAAS,UAAU;AAAA,EAC9B,MAAM;AAAA,EACN,KAAK;AAAA,EACL,OAAO;AAAA,EACP,SAAS;AAAA,EACT,OAAO,CAAC,QAAQ,IAAI,OAAO,MAAM,IAAI,SAAS,CAAC;AACjD,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { action, batch, untracked } from "../../kernel/index.js";
|
|
2
|
+
const setAll = action({
|
|
3
|
+
name: "setAll",
|
|
4
|
+
call: ({ store }, value, filter) => batch(() => untracked(() => {
|
|
5
|
+
for (const p of store.paths(filter)) store.set(p, value);
|
|
6
|
+
}))
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
setAll
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=bulk-set.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/bulk-set.ts"],
|
|
4
|
+
"sourcesContent": ["import { action, batch, untracked, type Filter } from '../../kernel/index.js'\n\n/** `@setAll(value, { include: /^form\\./ })` assigns every matching signal. */\nexport const setAll = action({\n name: 'setAll',\n call: ({ store }, value: unknown, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, value) })),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,SAAS,OAAO;AAAA,EAC3B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,OAAgB,WAChC,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,KAAK;AAAA,EAAE,CAAC,CAAC;AAC7F,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { action, batch, untracked } from "../../kernel/index.js";
|
|
2
|
+
const toggleAll = action({
|
|
3
|
+
name: "toggleAll",
|
|
4
|
+
call: ({ store }, filter) => batch(() => untracked(() => {
|
|
5
|
+
for (const p of store.paths(filter)) store.set(p, !store.get(p));
|
|
6
|
+
}))
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
toggleAll
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=bulk-toggle.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/bulk-toggle.ts"],
|
|
4
|
+
"sourcesContent": ["import { action, batch, untracked, type Filter } from '../../kernel/index.js'\n\n/** `@toggleAll({ include: /^flags\\./ })` negates every matching boolean signal. */\nexport const toggleAll = action({\n name: 'toggleAll',\n call: ({ store }, filter?: Filter) =>\n batch(() => untracked(() => { for (const p of store.paths(filter)) store.set(p, !store.get(p)) })),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,OAAO,iBAA8B;AAG/C,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,WAChB,MAAM,MAAM,UAAU,MAAM;AAAE,eAAW,KAAK,MAAM,MAAM,MAAM,EAAG,OAAM,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAAA,EAAE,CAAC,CAAC;AACrG,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/confirm.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@confirm('Delete?') && @delete('/x')` asks before continuing. */\nexport const confirm = action({ name: 'confirm', call: (_, message: string) => window.confirm(message) })\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,UAAU,OAAO,EAAE,MAAM,WAAW,MAAM,CAAC,GAAG,YAAoB,OAAO,QAAQ,OAAO,EAAE,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { action } from "../../kernel/index.js";
|
|
2
|
+
const clipboard = action({
|
|
3
|
+
name: "clipboard",
|
|
4
|
+
call: (_, text, base64 = false) => navigator.clipboard.writeText(
|
|
5
|
+
base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text
|
|
6
|
+
)
|
|
7
|
+
});
|
|
8
|
+
export {
|
|
9
|
+
clipboard
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=copy-text.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/copy-text.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@clipboard(text, isBase64?)` copies text; base64 input is decoded first. */\nexport const clipboard = action({\n name: 'clipboard',\n call: (_, text: string, base64 = false) =>\n navigator.clipboard.writeText(\n base64 ? new TextDecoder().decode(Uint8Array.from(atob(text), (c) => c.charCodeAt(0))) : text,\n ),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,YAAY,OAAO;AAAA,EAC9B,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,MAAc,SAAS,UAC/B,UAAU,UAAU;AAAA,IAClB,SAAS,IAAI,YAAY,EAAE,OAAO,WAAW,KAAK,KAAK,IAAI,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,IAAI;AAAA,EAC3F;AACJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { action } from "../../kernel/index.js";
|
|
2
|
+
const dispatch = action({
|
|
3
|
+
name: "dispatch",
|
|
4
|
+
call: ({ el }, name, detail) => el.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }))
|
|
5
|
+
});
|
|
6
|
+
export {
|
|
7
|
+
dispatch
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=dispatch.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/dispatch.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** `@dispatch('name', detail)` fires a bubbling CustomEvent from the element. */\nexport const dispatch = action({\n name: 'dispatch',\n call: ({ el }, name: string, detail?: unknown) => el.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true })),\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,WAAW,OAAO;AAAA,EAC7B,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,GAAG,GAAG,MAAc,WAAqB,GAAG,cAAc,IAAI,YAAY,MAAM,EAAE,QAAQ,SAAS,MAAM,UAAU,KAAK,CAAC,CAAC;AACrI,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { action } from "../../kernel/index.js";
|
|
2
|
+
const formats = {
|
|
3
|
+
number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),
|
|
4
|
+
datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),
|
|
5
|
+
pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),
|
|
6
|
+
relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),
|
|
7
|
+
list: (l, v, o) => new Intl.ListFormat(l, o).format(v),
|
|
8
|
+
displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? ""
|
|
9
|
+
};
|
|
10
|
+
const intl = action({
|
|
11
|
+
name: "intl",
|
|
12
|
+
call: ({ error }, type, value, options, locale) => {
|
|
13
|
+
const f = formats[type];
|
|
14
|
+
if (!f) throw error(`unknown @intl type "${type}"`);
|
|
15
|
+
return f(locale, value, options);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
export {
|
|
19
|
+
intl
|
|
20
|
+
};
|
|
21
|
+
//# sourceMappingURL=locale-format.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/locale-format.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../kernel/index.js'\n\ntype Fmt = (locale: string | string[] | undefined, value: any, options: any) => string\nconst formats: Record<string, Fmt> = {\n number: (l, v, o) => new Intl.NumberFormat(l, o).format(v),\n datetime: (l, v, o) => new Intl.DateTimeFormat(l, o).format(v),\n pluralRules: (l, v, o) => new Intl.PluralRules(l, o).select(v),\n relativeTime: (l, v, o) => new Intl.RelativeTimeFormat(l, o).format(v[0], v[1]),\n list: (l, v, o) => new Intl.ListFormat(l, o).format(v),\n displayNames: (l, v, o) => new Intl.DisplayNames(l, o).of(v) ?? '',\n}\n\n/** `@intl('number', 1234.5, { style: 'currency', currency: 'USD' }, 'en-US')`. */\nexport const intl = action({\n name: 'intl',\n call: ({ error }, type: string, value: unknown, options?: Record<string, unknown>, locale?: string | string[]) => {\n const f = formats[type]\n if (!f) throw error(`unknown @intl type \"${type}\"`)\n return f(locale, value, options)\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGvB,MAAM,UAA+B;AAAA,EACnC,QAAQ,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACzD,UAAU,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,eAAe,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,aAAa,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,YAAY,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EAC7D,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,mBAAmB,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;AAAA,EAC9E,MAAM,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,WAAW,GAAG,CAAC,EAAE,OAAO,CAAC;AAAA,EACrD,cAAc,CAAC,GAAG,GAAG,MAAM,IAAI,KAAK,aAAa,GAAG,CAAC,EAAE,GAAG,CAAC,KAAK;AAClE;AAGO,MAAM,OAAO,OAAO;AAAA,EACzB,MAAM;AAAA,EACN,MAAM,CAAC,EAAE,MAAM,GAAG,MAAc,OAAgB,SAAmC,WAA+B;AAChH,UAAM,IAAI,QAAQ,IAAI;AACtB,QAAI,CAAC,EAAG,OAAM,MAAM,uBAAuB,IAAI,GAAG;AAClD,WAAO,EAAE,QAAQ,OAAO,OAAO;AAAA,EACjC;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { action } from "../../kernel/index.js";
|
|
2
|
+
const fit = action({
|
|
3
|
+
name: "fit",
|
|
4
|
+
call: (_, v, inMin, inMax, outMin, outMax, clamp = false, round = false) => {
|
|
5
|
+
let t = (v - inMin) / (inMax - inMin);
|
|
6
|
+
if (clamp) t = Math.min(1, Math.max(0, t));
|
|
7
|
+
const out = outMin + t * (outMax - outMin);
|
|
8
|
+
return round ? Math.round(out) : out;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
export {
|
|
12
|
+
fit
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=range-map.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/functions/range-map.ts"],
|
|
4
|
+
"sourcesContent": ["import { action } from '../../kernel/index.js'\n\n/** Map `v` from [inMin, inMax] onto [outMin, outMax]; optionally clamp and round. */\nexport const fit = action({\n name: 'fit',\n call: (_, v: number, inMin: number, inMax: number, outMin: number, outMax: number, clamp = false, round = false) => {\n let t = (v - inMin) / (inMax - inMin)\n if (clamp) t = Math.min(1, Math.max(0, t))\n const out = outMin + t * (outMax - outMin)\n return round ? Math.round(out) : out\n },\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,cAAc;AAGhB,MAAM,MAAM,OAAO;AAAA,EACxB,MAAM;AAAA,EACN,MAAM,CAAC,GAAG,GAAW,OAAe,OAAe,QAAgB,QAAgB,QAAQ,OAAO,QAAQ,UAAU;AAClH,QAAI,KAAK,IAAI,UAAU,QAAQ;AAC/B,QAAI,MAAO,KAAI,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,CAAC,CAAC;AACzC,UAAM,MAAM,SAAS,KAAK,SAAS;AACnC,WAAO,QAAQ,KAAK,MAAM,GAAG,IAAI;AAAA,EACnC;AACF,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Filter } from '../../kernel/index.js';
|
|
2
|
+
export type RequestOptions = {
|
|
3
|
+
headers?: Record<string, string>;
|
|
4
|
+
/** 'json' (default) sends filtered signals; 'form' serialises the closest (or `selector`) form. */
|
|
5
|
+
contentType?: 'json' | 'form';
|
|
6
|
+
selector?: string;
|
|
7
|
+
/** Which signals to send. Default: everything except paths starting with `_`. */
|
|
8
|
+
filter?: Filter;
|
|
9
|
+
/** Explicit body instead of signals. */
|
|
10
|
+
payload?: unknown;
|
|
11
|
+
/** 'replace' (default) aborts an earlier request with the same method and URL; 'none' lets them overlap. */
|
|
12
|
+
abort?: 'replace' | 'none' | AbortController;
|
|
13
|
+
/** Keep the connection open while the tab is hidden. Default: true except for GET streams. */
|
|
14
|
+
openWhenHidden?: boolean;
|
|
15
|
+
/** Reconnect after a stream closes normally (long-lived event streams). */
|
|
16
|
+
reconnect?: boolean;
|
|
17
|
+
retry?: {
|
|
18
|
+
attempts?: number;
|
|
19
|
+
interval?: number;
|
|
20
|
+
factor?: number;
|
|
21
|
+
max?: number;
|
|
22
|
+
onStatusError?: boolean;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
/** `@get(url, options)`: signals travel in the `sigmx` query parameter. */
|
|
26
|
+
export declare const httpGet: import("../../kernel/contracts.js").ActionPlugin;
|
|
27
|
+
export declare const httpPost: import("../../kernel/contracts.js").ActionPlugin;
|
|
28
|
+
export declare const httpPut: import("../../kernel/contracts.js").ActionPlugin;
|
|
29
|
+
export declare const httpPatch: import("../../kernel/contracts.js").ActionPlugin;
|
|
30
|
+
export declare const httpDelete: import("../../kernel/contracts.js").ActionPlugin;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { action, untracked } from "../../kernel/index.js";
|
|
2
|
+
import { camel } from "../../lib/casing.js";
|
|
3
|
+
import { parseFields, readEvents } from "../../lib/sse.js";
|
|
4
|
+
const inflight = /* @__PURE__ */ new Map();
|
|
5
|
+
let seq = 0;
|
|
6
|
+
const sleep = (ms, signal) => new Promise((resolve) => {
|
|
7
|
+
const t = setTimeout(resolve, ms);
|
|
8
|
+
signal.addEventListener("abort", () => (clearTimeout(t), resolve()), { once: true });
|
|
9
|
+
});
|
|
10
|
+
const untilVisible = () => new Promise((resolve) => document.addEventListener("visibilitychange", () => !document.hidden && resolve(), { once: true }));
|
|
11
|
+
const headerArgs = (res, names, data) => {
|
|
12
|
+
for (const n of names) {
|
|
13
|
+
const v = res.headers.get(`sigmx-${n}`);
|
|
14
|
+
if (v) data[camel(n)] = v;
|
|
15
|
+
}
|
|
16
|
+
return data;
|
|
17
|
+
};
|
|
18
|
+
const runScript = (text) => {
|
|
19
|
+
const s = document.createElement("script");
|
|
20
|
+
s.text = text;
|
|
21
|
+
document.head.append(s);
|
|
22
|
+
s.remove();
|
|
23
|
+
};
|
|
24
|
+
const send = async (method, ctx, url, o = {}) => {
|
|
25
|
+
const { el, evt, store, runtime, error } = ctx;
|
|
26
|
+
if (!url) throw error(`@${method.toLowerCase()} needs a URL`);
|
|
27
|
+
const key = `${method} ${url}`;
|
|
28
|
+
const ac = o.abort instanceof AbortController ? o.abort : new AbortController();
|
|
29
|
+
if (o.abort !== "none") {
|
|
30
|
+
inflight.get(key)?.abort();
|
|
31
|
+
inflight.set(key, ac);
|
|
32
|
+
}
|
|
33
|
+
ctx.cleanup(() => ac.abort());
|
|
34
|
+
const rid = ++seq;
|
|
35
|
+
const emit = (type, extra = {}) => runtime.emit("fetch", { el, type, method, url, rid, ...extra });
|
|
36
|
+
const retry = { attempts: 5, interval: 1e3, factor: 2, max: 3e4, onStatusError: false, ...o.retry };
|
|
37
|
+
const pauseWhenHidden = !(o.openWhenHidden ?? method !== "GET");
|
|
38
|
+
const bodyAllowed = method !== "GET" && method !== "DELETE";
|
|
39
|
+
const build = () => {
|
|
40
|
+
const u = new URL(url, location.href);
|
|
41
|
+
const headers = {
|
|
42
|
+
Accept: "text/event-stream, text/html, application/json",
|
|
43
|
+
"Sigmx-Request": "true",
|
|
44
|
+
...o.headers
|
|
45
|
+
};
|
|
46
|
+
let body;
|
|
47
|
+
if ((o.contentType ?? "json") === "json") {
|
|
48
|
+
const payload = o.payload ?? untracked(() => store.snapshot(o.filter ?? { exclude: /(^|\.)_/ }));
|
|
49
|
+
const json = JSON.stringify(payload);
|
|
50
|
+
if (bodyAllowed) {
|
|
51
|
+
body = json;
|
|
52
|
+
headers["Content-Type"] ??= "application/json";
|
|
53
|
+
} else u.searchParams.set("sigmx", json);
|
|
54
|
+
} else {
|
|
55
|
+
const form = o.selector ? document.querySelector(o.selector) : el.closest("form");
|
|
56
|
+
if (!form) throw error("no form found", { selector: o.selector });
|
|
57
|
+
if (!form.noValidate && !form.checkValidity()) {
|
|
58
|
+
form.reportValidity();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const submitter = evt instanceof SubmitEvent ? evt.submitter : el instanceof HTMLButtonElement ? el : null;
|
|
62
|
+
const fd = new FormData(form, submitter);
|
|
63
|
+
const multipart = form.enctype === "multipart/form-data";
|
|
64
|
+
if (bodyAllowed) {
|
|
65
|
+
body = multipart ? fd : new URLSearchParams(fd);
|
|
66
|
+
if (!multipart) headers["Content-Type"] = "application/x-www-form-urlencoded";
|
|
67
|
+
} else {
|
|
68
|
+
for (const [k, v] of new URLSearchParams(fd)) u.searchParams.append(k, v);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return { url: u.toString(), init: { method, headers, body } };
|
|
72
|
+
};
|
|
73
|
+
const route = (event, data) => {
|
|
74
|
+
const fields = parseFields(data);
|
|
75
|
+
runtime.emit("server-event", { el, event, data: fields });
|
|
76
|
+
runtime.handle(event, fields);
|
|
77
|
+
};
|
|
78
|
+
let attempt = 0;
|
|
79
|
+
let wait = retry.interval;
|
|
80
|
+
let lastId;
|
|
81
|
+
const backoff = async () => {
|
|
82
|
+
if (attempt++ >= retry.attempts) throw new Error("retries exhausted");
|
|
83
|
+
emit("retrying", { attempt });
|
|
84
|
+
await sleep(wait, ac.signal);
|
|
85
|
+
wait = Math.min(wait * retry.factor, retry.max);
|
|
86
|
+
};
|
|
87
|
+
emit("started");
|
|
88
|
+
try {
|
|
89
|
+
while (!ac.signal.aborted) {
|
|
90
|
+
const req = build();
|
|
91
|
+
if (!req) return;
|
|
92
|
+
if (lastId) req.init.headers["Last-Event-ID"] = lastId;
|
|
93
|
+
const hide = new AbortController();
|
|
94
|
+
const onHide = () => document.hidden && hide.abort();
|
|
95
|
+
if (pauseWhenHidden) document.addEventListener("visibilitychange", onHide);
|
|
96
|
+
try {
|
|
97
|
+
const res = await fetch(req.url, { ...req.init, signal: AbortSignal.any([ac.signal, hide.signal]) });
|
|
98
|
+
const ct = res.headers.get("content-type") ?? "";
|
|
99
|
+
if (res.status >= 400) {
|
|
100
|
+
emit("error", { status: res.status });
|
|
101
|
+
if (!retry.onStatusError) return;
|
|
102
|
+
await backoff();
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
if (res.status === 204 || res.status === 304 || !res.body) return;
|
|
106
|
+
if (ct.includes("text/event-stream")) {
|
|
107
|
+
attempt = 0;
|
|
108
|
+
wait = retry.interval;
|
|
109
|
+
await readEvents(res.body, (e) => {
|
|
110
|
+
if (e.id !== void 0) lastId = e.id;
|
|
111
|
+
if (e.retry) wait = retry.interval = e.retry;
|
|
112
|
+
route(e.event, e.data);
|
|
113
|
+
});
|
|
114
|
+
if (!o.reconnect) return;
|
|
115
|
+
await backoff();
|
|
116
|
+
continue;
|
|
117
|
+
}
|
|
118
|
+
const text = await res.text();
|
|
119
|
+
if (ct.includes("text/html")) runtime.handle("patch-elements", headerArgs(res, ["selector", "mode", "use-view-transition"], { elements: text }));
|
|
120
|
+
else if (ct.includes("application/json")) runtime.handle("patch-signals", headerArgs(res, ["only-if-missing"], { signals: text }));
|
|
121
|
+
else if (ct.includes("javascript")) runScript(text);
|
|
122
|
+
return;
|
|
123
|
+
} catch {
|
|
124
|
+
if (ac.signal.aborted) return;
|
|
125
|
+
if (hide.signal.aborted) await untilVisible();
|
|
126
|
+
else await backoff();
|
|
127
|
+
} finally {
|
|
128
|
+
document.removeEventListener("visibilitychange", onHide);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
} catch (e) {
|
|
132
|
+
emit("error", { message: e?.message });
|
|
133
|
+
throw error(`${method} ${url}: ${e?.message ?? e}`);
|
|
134
|
+
} finally {
|
|
135
|
+
emit("finished");
|
|
136
|
+
if (inflight.get(key) === ac) inflight.delete(key);
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
const make = (name, method) => action({ name, call: (ctx, url, o) => send(method, ctx, url, o) });
|
|
140
|
+
const httpGet = make("get", "GET");
|
|
141
|
+
const httpPost = make("post", "POST");
|
|
142
|
+
const httpPut = make("put", "PUT");
|
|
143
|
+
const httpPatch = make("patch", "PATCH");
|
|
144
|
+
const httpDelete = make("delete", "DELETE");
|
|
145
|
+
export {
|
|
146
|
+
httpDelete,
|
|
147
|
+
httpGet,
|
|
148
|
+
httpPatch,
|
|
149
|
+
httpPost,
|
|
150
|
+
httpPut
|
|
151
|
+
};
|
|
152
|
+
//# sourceMappingURL=request.js.map
|