sigmx 0.1.0 → 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 +54 -43
- package/dist/cli.js +3 -1
- package/dist/cli.js.map +2 -2
- 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 +12 -13
- package/dist/kernel/index.d.ts +11 -12
- package/dist/kernel/index.js +14 -12
- package/dist/kernel/index.js.map +3 -3
- package/dist/kernel/precompile.d.ts +8 -12
- package/dist/kernel/precompile.js +33 -76
- 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 +13 -11
- package/dist/kernel/reactive.js +96 -71
- package/dist/kernel/reactive.js.map +3 -3
- package/dist/kernel/runtime.js +85 -63
- package/dist/kernel/runtime.js.map +3 -3
- package/dist/kernel/scan.d.ts +2 -11
- package/dist/kernel/scan.js +26 -9
- package/dist/kernel/scan.js.map +2 -2
- package/dist/kernel/state.d.ts +5 -8
- package/dist/kernel/state.js +114 -76
- 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 -4
- package/dist/lib/objects.js +13 -5
- package/dist/lib/objects.js.map +2 -2
- package/dist/lib/schedule.d.ts +3 -5
- package/dist/lib/schedule.js +12 -10
- package/dist/lib/schedule.js.map +2 -2
- package/dist/lib/sse.d.ts +10 -1
- package/dist/lib/sse.js +32 -28
- 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 -30
- 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 -15
- 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 -23
- 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 -12
- package/dist/plugins/directives/media-query.js.map +2 -2
- package/dist/plugins/directives/on-mount.js +4 -9
- 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 -67
- package/dist/plugins/directives/two-way-bind.js.map +2 -2
- package/dist/plugins/directives/url-params.js +36 -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 -23
- 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.d.ts +0 -1
- package/dist/plugins/directives/watch.js +2 -8
- package/dist/plugins/directives/watch.js.map +2 -2
- package/dist/plugins/functions/bulk-set.js +10 -7
- package/dist/plugins/functions/bulk-set.js.map +2 -2
- package/dist/plugins/functions/bulk-toggle.js +10 -7
- 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 +85 -80
- 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 +18 -25
- package/dist/plugins/functions/websocket.js.map +2 -2
- package/dist/plugins/index.d.ts +34 -36
- package/dist/plugins/index.js +31 -35
- 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 -40
- 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.d.ts +0 -2
- package/dist/plugins/server-events/morph.js +58 -55
- package/dist/plugins/server-events/morph.js.map +3 -3
- package/dist/presets/all.d.ts +0 -1
- package/dist/presets/all.js +22 -26
- 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 +108 -0
- package/dist/server.js +218 -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 +48 -15
- package/dist/vite.js.map +2 -2
- package/package.json +21 -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/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 -48
- package/dist/plugins/directives/trap.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/index.d.ts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export
|
|
1
|
+
export { camel, kebab, pascal, recase, snake } from '../lib/casing.js';
|
|
2
|
+
export type { Filter } from '../lib/objects.js';
|
|
3
|
+
export { expand, isPlain, toPredicate } from '../lib/objects.js';
|
|
4
|
+
export { debounce, delay, throttle, toMs, withTiming } from '../lib/schedule.js';
|
|
5
5
|
export type { Compiler } from './compile.js';
|
|
6
|
-
export {
|
|
7
|
-
export { createStore } from './state.js';
|
|
8
|
-
export type { Patch, Store } from './state.js';
|
|
6
|
+
export { compile, compileBody, functionCompiler, runtimeExpressions, transform } from './compile.js';
|
|
9
7
|
export type * from './contracts.js';
|
|
10
|
-
export {
|
|
11
|
-
export
|
|
12
|
-
export {
|
|
13
|
-
export {
|
|
8
|
+
export type { ExpressionTable } from './precompiled.js';
|
|
9
|
+
export { expressionKey, precompiled } from './precompiled.js';
|
|
10
|
+
export { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from './reactive.js';
|
|
11
|
+
export { createRuntime, parseAttr } from './runtime.js';
|
|
12
|
+
export type { Patch, Store } from './state.js';
|
|
13
|
+
export { createStore } from './state.js';
|
|
14
14
|
import type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js';
|
|
15
15
|
/** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */
|
|
16
16
|
export declare const createSigmx: (options?: SigmxOptions) => Sigmx;
|
|
17
|
-
/** Type a plugin definition. Pure: registration is `createSigmx({ plugins })` or `sigmx.use()`. */
|
|
18
17
|
export declare const attribute: (p: Omit<AttributePlugin, "type">) => AttributePlugin;
|
|
19
18
|
export declare const action: (p: Omit<ActionPlugin, "type">) => ActionPlugin;
|
|
20
19
|
export declare const handler: (p: Omit<HandlerPlugin, "type">) => HandlerPlugin;
|
package/dist/kernel/index.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { camel, kebab, pascal, recase, snake } from "../lib/casing.js";
|
|
2
|
+
import { expand, isPlain, toPredicate } from "../lib/objects.js";
|
|
3
|
+
import { debounce, delay, throttle, toMs, withTiming } from "../lib/schedule.js";
|
|
4
|
+
import { compile, compileBody, functionCompiler, runtimeExpressions, transform } from "./compile.js";
|
|
3
5
|
import { expressionKey, precompiled } from "./precompiled.js";
|
|
4
|
-
import {
|
|
6
|
+
import { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from "./reactive.js";
|
|
7
|
+
import { createRuntime, parseAttr } from "./runtime.js";
|
|
5
8
|
import { createStore } from "./state.js";
|
|
6
|
-
import { expand, isPlain, toPredicate } from "../lib/objects.js";
|
|
7
|
-
import { camel, kebab, pascal, recase, snake } from "../lib/casing.js";
|
|
8
|
-
import { debounce, delay, throttle, toMs, withTiming, withViewTransition } from "../lib/schedule.js";
|
|
9
|
-
import { createRuntime as createRuntime2 } from "./runtime.js";
|
|
10
9
|
import { functionCompiler as functionCompiler2, runtimeExpressions as runtimeExpressions2 } from "./compile.js";
|
|
11
|
-
|
|
10
|
+
import { createRuntime as createRuntime2 } from "./runtime.js";
|
|
11
|
+
const createSigmx = (options = {}) => createRuntime2({
|
|
12
|
+
...options,
|
|
13
|
+
expressions: options.expressions ?? runtimeExpressions2(options.compile ?? functionCompiler2)
|
|
14
|
+
});
|
|
12
15
|
const attribute = (p) => ({ type: "attribute", ...p });
|
|
13
16
|
const action = (p) => ({ type: "action", ...p });
|
|
14
17
|
const handler = (p) => ({ type: "handler", ...p });
|
|
@@ -20,6 +23,7 @@ export {
|
|
|
20
23
|
batch,
|
|
21
24
|
camel,
|
|
22
25
|
compile,
|
|
26
|
+
compileBody,
|
|
23
27
|
computed,
|
|
24
28
|
createRuntime,
|
|
25
29
|
createSigmx,
|
|
@@ -39,16 +43,14 @@ export {
|
|
|
39
43
|
pascal,
|
|
40
44
|
precompiled,
|
|
41
45
|
recase,
|
|
42
|
-
rewriteActions,
|
|
43
46
|
runtimeExpressions,
|
|
44
47
|
signal,
|
|
45
48
|
snake,
|
|
46
|
-
splitStatements,
|
|
47
49
|
throttle,
|
|
48
50
|
toMs,
|
|
49
51
|
toPredicate,
|
|
52
|
+
transform,
|
|
50
53
|
untracked,
|
|
51
|
-
withTiming
|
|
52
|
-
withViewTransition
|
|
54
|
+
withTiming
|
|
53
55
|
};
|
|
54
56
|
//# sourceMappingURL=index.js.map
|
package/dist/kernel/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/kernel/index.ts"],
|
|
4
|
-
"sourcesContent": ["export {
|
|
5
|
-
"mappings": "AAAA,SAAS,
|
|
6
|
-
"names": ["
|
|
4
|
+
"sourcesContent": ["export { camel, kebab, pascal, recase, snake } from '../lib/casing.js';\nexport type { Filter } from '../lib/objects.js';\nexport { expand, isPlain, toPredicate } from '../lib/objects.js';\nexport { debounce, delay, throttle, toMs, withTiming } from '../lib/schedule.js';\nexport type { Compiler } from './compile.js';\nexport { compile, compileBody, functionCompiler, runtimeExpressions, transform } from './compile.js';\nexport type * from './contracts.js';\nexport type { ExpressionTable } from './precompiled.js';\nexport { expressionKey, precompiled } from './precompiled.js';\nexport { batch, Computed, computed, effect, flush, onSettled, Signal, signal, untracked } from './reactive.js';\nexport { createRuntime, parseAttr } from './runtime.js';\nexport type { Patch, Store } from './state.js';\nexport { createStore } from './state.js';\n\nimport { functionCompiler, runtimeExpressions } from './compile.js';\nimport type { ActionPlugin, AttributePlugin, HandlerPlugin, Sigmx, SigmxOptions } from './contracts.js';\nimport { createRuntime } from './runtime.js';\n\n/** Create an instance. Expressions compile at runtime unless you pass `expressions` (see `precompiled`). */\nexport const createSigmx = (options: SigmxOptions = {}): Sigmx =>\n createRuntime({\n ...options,\n expressions: options.expressions ?? runtimeExpressions(options.compile ?? functionCompiler),\n });\n\nexport const attribute = (p: Omit<AttributePlugin, 'type'>): AttributePlugin => ({ type: 'attribute', ...p });\nexport const action = (p: Omit<ActionPlugin, 'type'>): ActionPlugin => ({ type: 'action', ...p });\nexport const handler = (p: Omit<HandlerPlugin, 'type'>): HandlerPlugin => ({ type: 'handler', ...p });\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,OAAO,OAAO,QAAQ,QAAQ,aAAa;AAEpD,SAAS,QAAQ,SAAS,mBAAmB;AAC7C,SAAS,UAAU,OAAO,UAAU,MAAM,kBAAkB;AAE5D,SAAS,SAAS,aAAa,kBAAkB,oBAAoB,iBAAiB;AAGtF,SAAS,eAAe,mBAAmB;AAC3C,SAAS,OAAO,UAAU,UAAU,QAAQ,OAAO,WAAW,QAAQ,QAAQ,iBAAiB;AAC/F,SAAS,eAAe,iBAAiB;AAEzC,SAAS,mBAAmB;AAE5B,SAAS,oBAAAA,mBAAkB,sBAAAC,2BAA0B;AAErD,SAAS,iBAAAC,sBAAqB;AAGvB,MAAM,cAAc,CAAC,UAAwB,CAAC,MACnDA,eAAc;AAAA,EACZ,GAAG;AAAA,EACH,aAAa,QAAQ,eAAeD,oBAAmB,QAAQ,WAAWD,iBAAgB;AAC5F,CAAC;AAEI,MAAM,YAAY,CAAC,OAAuD,EAAE,MAAM,aAAa,GAAG,EAAE;AACpG,MAAM,SAAS,CAAC,OAAiD,EAAE,MAAM,UAAU,GAAG,EAAE;AACxF,MAAM,UAAU,CAAC,OAAmD,EAAE,MAAM,WAAW,GAAG,EAAE;",
|
|
6
|
+
"names": ["functionCompiler", "runtimeExpressions", "createRuntime"]
|
|
7
7
|
}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Rewrite `$name` and `$a.b` into `$.name` / `$.a.b` so the expression runs in strict mode without
|
|
3
|
-
* `with`. Skips strings and comments, recurses into template-literal interpolations, and leaves
|
|
4
|
-
* `$` alone, `$[...]` alone, and `obj.$prop` alone.
|
|
5
|
-
*/
|
|
6
|
-
export declare const rewriteSignals: (src: string) => string;
|
|
7
|
-
/** The strict-mode function body for one expression: same semantics as the runtime compiler. */
|
|
8
|
-
export declare const compileBody: (src: string, returns: boolean) => string;
|
|
9
1
|
export type Extracted = {
|
|
10
2
|
src: string;
|
|
11
3
|
params: string[];
|
|
12
|
-
returns: boolean;
|
|
13
4
|
};
|
|
14
|
-
/** JavaScript source for a module exporting `table`, from a list of extracted expressions. */
|
|
15
5
|
export declare const generateTable: (items: Extracted[]) => string;
|
|
16
6
|
export type PluginMeta = {
|
|
17
7
|
name: string;
|
|
18
|
-
returns?: boolean;
|
|
19
8
|
args?: string[];
|
|
9
|
+
literal?: boolean;
|
|
20
10
|
};
|
|
21
11
|
/**
|
|
22
12
|
* Find directive attributes with literal values in template source. Values must be plain quoted
|
|
23
|
-
* strings; anything interpolated at render time is left to the runtime fallback.
|
|
13
|
+
* strings; anything interpolated at render time is left to the runtime fallback. Plugins whose value
|
|
14
|
+
* is a literal (mask, teleport, …) are skipped unless the attribute carries `__dynamic`.
|
|
24
15
|
*/
|
|
25
16
|
export declare const extractExpressions: (source: string, plugins: PluginMeta[], prefixes?: string[]) => Extracted[];
|
|
17
|
+
/**
|
|
18
|
+
* Keyed directive attributes whose key contains an uppercase letter. HTML lowercases attribute names,
|
|
19
|
+
* so `data-bind:firstName` reaches the runtime as `firstname`: write `data-bind:first-name`.
|
|
20
|
+
*/
|
|
21
|
+
export declare const lintSource: (source: string, prefixes?: string[]) => string[];
|
|
@@ -1,80 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { compileBody, functionCompiler } from "./compile.js";
|
|
2
2
|
import { expressionKey } from "./precompiled.js";
|
|
3
|
-
const ident = /[A-Za-z0-9_$]/;
|
|
4
|
-
const rewriteSignals = (src) => {
|
|
5
|
-
let out = "";
|
|
6
|
-
let i = 0;
|
|
7
|
-
const n = src.length;
|
|
8
|
-
const prevCode = () => {
|
|
9
|
-
for (let j = out.length - 1; j >= 0; j--) if (!/\s/.test(out[j])) return out[j];
|
|
10
|
-
return "";
|
|
11
|
-
};
|
|
12
|
-
while (i < n) {
|
|
13
|
-
const c = src[i];
|
|
14
|
-
const next = src[i + 1];
|
|
15
|
-
if (c === '"' || c === "'") {
|
|
16
|
-
let j = i + 1;
|
|
17
|
-
while (j < n && src[j] !== c) j += src[j] === "\\" ? 2 : 1;
|
|
18
|
-
out += src.slice(i, j + 1);
|
|
19
|
-
i = j + 1;
|
|
20
|
-
} else if (c === "`") {
|
|
21
|
-
out += c;
|
|
22
|
-
i++;
|
|
23
|
-
while (i < n && src[i] !== "`") {
|
|
24
|
-
if (src[i] === "\\") {
|
|
25
|
-
out += src.slice(i, i + 2);
|
|
26
|
-
i += 2;
|
|
27
|
-
} else if (src[i] === "$" && src[i + 1] === "{") {
|
|
28
|
-
let depth = 1;
|
|
29
|
-
let j = i + 2;
|
|
30
|
-
while (j < n && depth) {
|
|
31
|
-
if (src[j] === "{") depth++;
|
|
32
|
-
else if (src[j] === "}") depth--;
|
|
33
|
-
if (depth) j++;
|
|
34
|
-
}
|
|
35
|
-
out += "${" + rewriteSignals(src.slice(i + 2, j)) + "}";
|
|
36
|
-
i = j + 1;
|
|
37
|
-
} else out += src[i++];
|
|
38
|
-
}
|
|
39
|
-
out += "`";
|
|
40
|
-
i++;
|
|
41
|
-
} else if (c === "/" && next === "/") {
|
|
42
|
-
const j = src.indexOf("\n", i);
|
|
43
|
-
i = j < 0 ? n : j;
|
|
44
|
-
} else if (c === "/" && next === "*") {
|
|
45
|
-
const j = src.indexOf("*/", i + 2);
|
|
46
|
-
i = j < 0 ? n : j + 2;
|
|
47
|
-
} else if (c === "$" && next !== void 0 && ident.test(next) && next !== "$" && prevCode() !== "." && !ident.test(out[out.length - 1] ?? "")) {
|
|
48
|
-
let j = i + 1;
|
|
49
|
-
while (j < n && ident.test(src[j])) j++;
|
|
50
|
-
out += "$." + src.slice(i + 1, j);
|
|
51
|
-
i = j;
|
|
52
|
-
} else {
|
|
53
|
-
out += c;
|
|
54
|
-
i++;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
return out;
|
|
58
|
-
};
|
|
59
|
-
const compileBody = (src, returns) => {
|
|
60
|
-
const code = rewriteSignals(rewriteActions(src.trim()));
|
|
61
|
-
if (!returns) return code;
|
|
62
|
-
const parts = splitStatements(code);
|
|
63
|
-
const last = parts.pop() ?? "";
|
|
64
|
-
return `${parts.length ? parts.join(";") + ";" : ""}return (${last}
|
|
65
|
-
)`;
|
|
66
|
-
};
|
|
67
3
|
const generateTable = (items) => {
|
|
68
4
|
const seen = /* @__PURE__ */ new Set();
|
|
69
5
|
const lines = [];
|
|
70
|
-
for (const { src, params
|
|
71
|
-
const key = expressionKey(src
|
|
6
|
+
for (const { src, params } of items) {
|
|
7
|
+
const key = expressionKey(src);
|
|
72
8
|
if (seen.has(key)) continue;
|
|
73
9
|
seen.add(key);
|
|
74
10
|
let body;
|
|
75
11
|
try {
|
|
76
|
-
body = compileBody(src,
|
|
77
|
-
Function("$", "__a", ...params, body);
|
|
12
|
+
[body] = compileBody(functionCompiler, src, params);
|
|
78
13
|
} catch {
|
|
79
14
|
continue;
|
|
80
15
|
}
|
|
@@ -85,8 +20,23 @@ ${lines.join("\n")}
|
|
|
85
20
|
}
|
|
86
21
|
`;
|
|
87
22
|
};
|
|
88
|
-
const entities = {
|
|
89
|
-
|
|
23
|
+
const entities = {
|
|
24
|
+
""": '"',
|
|
25
|
+
"'": "'",
|
|
26
|
+
"'": "'",
|
|
27
|
+
"<": "<",
|
|
28
|
+
">": ">",
|
|
29
|
+
"&": "&"
|
|
30
|
+
};
|
|
31
|
+
const decode = (s) => s.replace(
|
|
32
|
+
/&(?:quot|apos|lt|gt|amp|#\d+|#x[\da-f]+);/gi,
|
|
33
|
+
(m) => m[1] === "#" ? String.fromCodePoint(
|
|
34
|
+
Number.parseInt(
|
|
35
|
+
m[2] === "x" || m[2] === "X" ? m.slice(3, -1) : m.slice(2, -1),
|
|
36
|
+
m[2] === "x" || m[2] === "X" ? 16 : 10
|
|
37
|
+
)
|
|
38
|
+
) : entities[m.toLowerCase()] ?? m
|
|
39
|
+
);
|
|
90
40
|
const extractExpressions = (source, plugins, prefixes = ["data-"]) => {
|
|
91
41
|
const byName = new Map(plugins.map((p) => [p.name, p]));
|
|
92
42
|
const out = [];
|
|
@@ -96,16 +46,23 @@ const extractExpressions = (source, plugins, prefixes = ["data-"]) => {
|
|
|
96
46
|
const value = decode(m[2] ?? m[3] ?? "");
|
|
97
47
|
const prefix = prefixes.find((p) => attr.startsWith(p));
|
|
98
48
|
if (!prefix || !value.trim()) continue;
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
|
|
49
|
+
const [head, ...mods] = attr.slice(prefix.length).split("__");
|
|
50
|
+
const plugin = byName.get(head.split(":")[0]);
|
|
51
|
+
if (!plugin || plugin.literal && !mods.some((x) => x.split(".")[0] === "dynamic")) continue;
|
|
52
|
+
out.push({ src: value, params: ["el", "evt", ...plugin.args ?? []] });
|
|
102
53
|
}
|
|
103
54
|
return out;
|
|
104
55
|
};
|
|
56
|
+
const lintSource = (source, prefixes = ["data-"]) => {
|
|
57
|
+
const out = [];
|
|
58
|
+
for (const p of prefixes)
|
|
59
|
+
for (const m of source.matchAll(new RegExp(`(?<![\\w-])(${p}[a-z-]+:[^\\s="'<>]*[A-Z][^\\s="'<>]*)`, "g")))
|
|
60
|
+
out.push(`${m[1]}: attribute names are lowercased by HTML; write the key in kebab-case`);
|
|
61
|
+
return out;
|
|
62
|
+
};
|
|
105
63
|
export {
|
|
106
|
-
compileBody,
|
|
107
64
|
extractExpressions,
|
|
108
65
|
generateTable,
|
|
109
|
-
|
|
66
|
+
lintSource
|
|
110
67
|
};
|
|
111
68
|
//# sourceMappingURL=precompile.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/kernel/precompile.ts"],
|
|
4
|
-
"sourcesContent": ["// Build-time expression compiler. Not for the browser: import it from a Vite/Astro plugin.\
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["// Build-time expression compiler. Not for the browser: import it from a Vite/Astro plugin.\n// It emits the very same strict-mode bodies the runtime compiles, keyed by source text.\nimport { compileBody, functionCompiler } from './compile.js';\nimport { expressionKey } from './precompiled.js';\n\nexport type Extracted = { src: string; params: string[] };\n\nexport const generateTable = (items: Extracted[]): string => {\n const seen = new Set<string>();\n const lines: string[] = [];\n for (const { src, params } of items) {\n const key = expressionKey(src);\n if (seen.has(key)) continue;\n seen.add(key);\n let body: string;\n try {\n [body] = compileBody(functionCompiler, src, params); // also the syntax check\n } catch {\n continue; // leave it to the runtime fallback (or fail there)\n }\n lines.push(` ${JSON.stringify(key)}: function($, __a, ${params.join(', ')}) { ${body} },`);\n }\n return `export const table = {\\n${lines.join('\\n')}\\n}\\n`;\n};\n\nconst entities: Record<string, string> = {\n '"': '\"',\n ''': \"'\",\n ''': \"'\",\n '<': '<',\n '>': '>',\n '&': '&',\n};\nconst decode = (s: string) =>\n s.replace(/&(?:quot|apos|lt|gt|amp|#\\d+|#x[\\da-f]+);/gi, (m) =>\n m[1] === '#'\n ? String.fromCodePoint(\n Number.parseInt(\n m[2] === 'x' || m[2] === 'X' ? m.slice(3, -1) : m.slice(2, -1),\n m[2] === 'x' || m[2] === 'X' ? 16 : 10,\n ),\n )\n : (entities[m.toLowerCase()] ?? m),\n );\n\nexport type PluginMeta = { name: string; args?: string[]; literal?: boolean };\n\n/**\n * Find directive attributes with literal values in template source. Values must be plain quoted\n * strings; anything interpolated at render time is left to the runtime fallback. Plugins whose value\n * is a literal (mask, teleport, \u2026) are skipped unless the attribute carries `__dynamic`.\n */\nexport const extractExpressions = (\n source: string,\n plugins: PluginMeta[],\n prefixes: string[] = ['data-'],\n): Extracted[] => {\n const byName = new Map(plugins.map((p) => [p.name, p]));\n const out: Extracted[] = [];\n const re = /([a-z][\\w-]*(?::[^\\s=\"'<>]+)?(?:__[^\\s=\"'<>]+)*)=(?:\"([^\"]*)\"|'([^']*)')/g;\n for (const m of source.matchAll(re)) {\n const attr = m[1];\n const value = decode(m[2] ?? m[3] ?? '');\n const prefix = prefixes.find((p) => attr.startsWith(p));\n if (!prefix || !value.trim()) continue;\n const [head, ...mods] = attr.slice(prefix.length).split('__');\n const plugin = byName.get(head.split(':')[0]);\n if (!plugin || (plugin.literal && !mods.some((x) => x.split('.')[0] === 'dynamic'))) continue;\n out.push({ src: value, params: ['el', 'evt', ...(plugin.args ?? [])] });\n }\n return out;\n};\n\n/**\n * Keyed directive attributes whose key contains an uppercase letter. HTML lowercases attribute names,\n * so `data-bind:firstName` reaches the runtime as `firstname`: write `data-bind:first-name`.\n */\nexport const lintSource = (source: string, prefixes: string[] = ['data-']): string[] => {\n const out: string[] = [];\n for (const p of prefixes)\n for (const m of source.matchAll(new RegExp(`(?<![\\\\w-])(${p}[a-z-]+:[^\\\\s=\"'<>]*[A-Z][^\\\\s=\"'<>]*)`, 'g')))\n out.push(`${m[1]}: attribute names are lowercased by HTML; write the key in kebab-case`);\n return out;\n};\n"],
|
|
5
|
+
"mappings": "AAEA,SAAS,aAAa,wBAAwB;AAC9C,SAAS,qBAAqB;AAIvB,MAAM,gBAAgB,CAAC,UAA+B;AAC3D,QAAM,OAAO,oBAAI,IAAY;AAC7B,QAAM,QAAkB,CAAC;AACzB,aAAW,EAAE,KAAK,OAAO,KAAK,OAAO;AACnC,UAAM,MAAM,cAAc,GAAG;AAC7B,QAAI,KAAK,IAAI,GAAG,EAAG;AACnB,SAAK,IAAI,GAAG;AACZ,QAAI;AACJ,QAAI;AACF,OAAC,IAAI,IAAI,YAAY,kBAAkB,KAAK,MAAM;AAAA,IACpD,QAAQ;AACN;AAAA,IACF;AACA,UAAM,KAAK,KAAK,KAAK,UAAU,GAAG,CAAC,sBAAsB,OAAO,KAAK,IAAI,CAAC,OAAO,IAAI,KAAK;AAAA,EAC5F;AACA,SAAO;AAAA,EAA2B,MAAM,KAAK,IAAI,CAAC;AAAA;AAAA;AACpD;AAEA,MAAM,WAAmC;AAAA,EACvC,UAAU;AAAA,EACV,SAAS;AAAA,EACT,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,SAAS;AACX;AACA,MAAM,SAAS,CAAC,MACd,EAAE;AAAA,EAAQ;AAAA,EAA+C,CAAC,MACxD,EAAE,CAAC,MAAM,MACL,OAAO;AAAA,IACL,OAAO;AAAA,MACL,EAAE,CAAC,MAAM,OAAO,EAAE,CAAC,MAAM,MAAM,EAAE,MAAM,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,EAAE;AAAA,MAC7D,EAAE,CAAC,MAAM,OAAO,EAAE,CAAC,MAAM,MAAM,KAAK;AAAA,IACtC;AAAA,EACF,IACC,SAAS,EAAE,YAAY,CAAC,KAAK;AACpC;AASK,MAAM,qBAAqB,CAChC,QACA,SACA,WAAqB,CAAC,OAAO,MACb;AAChB,QAAM,SAAS,IAAI,IAAI,QAAQ,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACtD,QAAM,MAAmB,CAAC;AAC1B,QAAM,KAAK;AACX,aAAW,KAAK,OAAO,SAAS,EAAE,GAAG;AACnC,UAAM,OAAO,EAAE,CAAC;AAChB,UAAM,QAAQ,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,EAAE;AACvC,UAAM,SAAS,SAAS,KAAK,CAAC,MAAM,KAAK,WAAW,CAAC,CAAC;AACtD,QAAI,CAAC,UAAU,CAAC,MAAM,KAAK,EAAG;AAC9B,UAAM,CAAC,MAAM,GAAG,IAAI,IAAI,KAAK,MAAM,OAAO,MAAM,EAAE,MAAM,IAAI;AAC5D,UAAM,SAAS,OAAO,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC;AAC5C,QAAI,CAAC,UAAW,OAAO,WAAW,CAAC,KAAK,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,CAAC,MAAM,SAAS,EAAI;AACrF,QAAI,KAAK,EAAE,KAAK,OAAO,QAAQ,CAAC,MAAM,OAAO,GAAI,OAAO,QAAQ,CAAC,CAAE,EAAE,CAAC;AAAA,EACxE;AACA,SAAO;AACT;AAMO,MAAM,aAAa,CAAC,QAAgB,WAAqB,CAAC,OAAO,MAAgB;AACtF,QAAM,MAAgB,CAAC;AACvB,aAAW,KAAK;AACd,eAAW,KAAK,OAAO,SAAS,IAAI,OAAO,eAAe,CAAC,0CAA0C,GAAG,CAAC;AACvG,UAAI,KAAK,GAAG,EAAE,CAAC,CAAC,uEAAuE;AAC3F,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ExpressionCompiler } from './contracts.js';
|
|
2
2
|
export type ExpressionTable = Record<string, (root: any, actions: any, el: any, evt: any, ...args: any[]) => any>;
|
|
3
|
-
/** Key used by the build plugin and the lookup: returns flag, parameter names, trimmed source. */
|
|
4
|
-
export declare const expressionKey: (src: string, params: string[], returns: boolean) => string;
|
|
5
3
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Key used by the build plugin and the lookup: the trimmed source text. Parameter names are not part
|
|
5
|
+
* of it, so a plugin gaining an argument (arguments are only ever appended) keeps old tables valid.
|
|
6
|
+
*/
|
|
7
|
+
export declare const expressionKey: (src: string) => string;
|
|
8
|
+
/**
|
|
9
|
+
* Look expressions up in a table generated at build time (see `sigmx/precompile`). Table functions
|
|
10
|
+
* take the root store proxy as `$`, exactly like runtime-compiled ones. Pass a `fallback` (for example
|
|
8
11
|
* `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime
|
|
9
12
|
* compiler is not bundled at all.
|
|
10
13
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
const expressionKey = (src
|
|
2
|
-
const precompiled = (table, fallback, onMiss) => (src, params
|
|
3
|
-
const fn = table[expressionKey(src
|
|
4
|
-
if (fn) return ((store, actions,
|
|
1
|
+
const expressionKey = (src) => src.trim();
|
|
2
|
+
const precompiled = (table, fallback, onMiss) => (src, params) => {
|
|
3
|
+
const fn = table[expressionKey(src)];
|
|
4
|
+
if (fn) return ((store, actions, ...rest) => fn(store.$, actions, ...rest));
|
|
5
5
|
onMiss?.(src);
|
|
6
6
|
if (!fallback) throw new Error(`expression not precompiled: ${src}`);
|
|
7
|
-
return fallback(src, params
|
|
7
|
+
return fallback(src, params);
|
|
8
8
|
};
|
|
9
9
|
export {
|
|
10
10
|
expressionKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/kernel/precompiled.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Evaluator, ExpressionCompiler } from './contracts.js'
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["import type { Evaluator, ExpressionCompiler } from './contracts.js';\n\nexport type ExpressionTable = Record<string, (root: any, actions: any, el: any, evt: any, ...args: any[]) => any>;\n\n/**\n * Key used by the build plugin and the lookup: the trimmed source text. Parameter names are not part\n * of it, so a plugin gaining an argument (arguments are only ever appended) keeps old tables valid.\n */\nexport const expressionKey = (src: string): string => src.trim();\n\n/**\n * Look expressions up in a table generated at build time (see `sigmx/precompile`). Table functions\n * take the root store proxy as `$`, exactly like runtime-compiled ones. Pass a `fallback` (for example\n * `runtimeExpressions(functionCompiler)`) for markup assembled at runtime; omit it and the runtime\n * compiler is not bundled at all.\n */\nexport const precompiled =\n (table: ExpressionTable, fallback?: ExpressionCompiler, onMiss?: (src: string) => void): ExpressionCompiler =>\n (src, params) => {\n const fn = table[expressionKey(src)];\n if (fn) return ((store, actions, ...rest) => fn(store.$, actions, ...rest)) as Evaluator;\n onMiss?.(src);\n if (!fallback) throw new Error(`expression not precompiled: ${src}`);\n return fallback(src, params);\n };\n"],
|
|
5
|
+
"mappings": "AAQO,MAAM,gBAAgB,CAAC,QAAwB,IAAI,KAAK;AAQxD,MAAM,cACX,CAAC,OAAwB,UAA+B,WACxD,CAAC,KAAK,WAAW;AACf,QAAM,KAAK,MAAM,cAAc,GAAG,CAAC;AACnC,MAAI,GAAI,SAAQ,CAAC,OAAO,YAAY,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI;AACzE,WAAS,GAAG;AACZ,MAAI,CAAC,SAAU,OAAM,IAAI,MAAM,+BAA+B,GAAG,EAAE;AACnE,SAAO,SAAS,KAAK,MAAM;AAC7B;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -3,27 +3,27 @@ interface Tracker {
|
|
|
3
3
|
_invalidate(): void;
|
|
4
4
|
}
|
|
5
5
|
export declare class Signal<T> {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
_v: T;
|
|
7
|
+
_ver: number;
|
|
8
|
+
_subs: Set<Tracker>;
|
|
9
9
|
constructor(v: T);
|
|
10
10
|
get value(): T;
|
|
11
11
|
set value(x: T);
|
|
12
|
-
/** Read without subscribing. */
|
|
13
12
|
peek(): T;
|
|
14
13
|
/** Notify subscribers without replacing the value (after mutating an array or object in place). */
|
|
15
14
|
bump(): void;
|
|
16
15
|
}
|
|
17
16
|
export declare class Computed<T> extends Signal<T> implements Tracker {
|
|
17
|
+
_fn: () => T;
|
|
18
18
|
_deps: Map<Signal<any>, number>;
|
|
19
|
-
|
|
20
|
-
/** @internal */ _fn: () => T;
|
|
19
|
+
_dirty: boolean;
|
|
21
20
|
constructor(fn: () => T);
|
|
22
|
-
|
|
21
|
+
_refresh(): void;
|
|
23
22
|
get value(): T;
|
|
24
23
|
set value(_: T);
|
|
25
|
-
peek(): T;
|
|
26
24
|
_invalidate(): void;
|
|
25
|
+
/** Unsubscribe from every dependency; the computed is no longer recalculated. Public: the store calls it. */
|
|
26
|
+
dispose(): void;
|
|
27
27
|
}
|
|
28
28
|
export declare const signal: <T>(value: T) => Signal<T>;
|
|
29
29
|
export declare const computed: <T>(fn: () => T) => Computed<T>;
|
|
@@ -32,11 +32,13 @@ export declare const computed: <T>(fn: () => T) => Computed<T>;
|
|
|
32
32
|
* effect are disposed when the parent re-runs. Returns a disposer.
|
|
33
33
|
*/
|
|
34
34
|
export declare const effect: (fn: () => void, onError?: (e: unknown) => void) => (() => void);
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Like `effect`, but never owned by the effect that happens to be running: for long-lived effects
|
|
37
|
+
* such as mounted attributes, which must not die when an unrelated parent effect re-runs.
|
|
38
|
+
*/
|
|
39
|
+
export declare const rootEffect: (fn: () => void, onError?: (e: unknown) => void) => (() => void);
|
|
36
40
|
export declare const batch: <R>(fn: () => R) => R;
|
|
37
|
-
/** Read signals inside `fn` without subscribing the current effect to them. */
|
|
38
41
|
export declare const untracked: <R>(fn: () => R) => R;
|
|
39
|
-
/** Called after each flush once every queued effect has run. */
|
|
40
42
|
export declare const onSettled: (fn: () => void) => (() => void);
|
|
41
43
|
export declare const flush: () => void;
|
|
42
44
|
export {};
|