synstate-dom 0.0.0-stage → 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/LICENSE +201 -0
- package/README.md +218 -2
- package/dist/bind/bind-props.d.mts +9 -0
- package/dist/bind/bind-props.d.mts.map +1 -0
- package/dist/bind/bind-props.mjs +117 -0
- package/dist/bind/bind-props.mjs.map +1 -0
- package/dist/bind/index.d.mts +2 -0
- package/dist/bind/index.d.mts.map +1 -0
- package/dist/bind/index.mjs +2 -0
- package/dist/bind/index.mjs.map +1 -0
- package/dist/constant/bindable.d.mts +11 -0
- package/dist/constant/bindable.d.mts.map +1 -0
- package/dist/constant/bindable.mjs +2 -0
- package/dist/constant/bindable.mjs.map +1 -0
- package/dist/constant/constant.d.mts +20 -0
- package/dist/constant/constant.d.mts.map +1 -0
- package/dist/constant/constant.mjs +10 -0
- package/dist/constant/constant.mjs.map +1 -0
- package/dist/constant/derive.d.mts +16 -0
- package/dist/constant/derive.d.mts.map +1 -0
- package/dist/constant/derive.mjs +28 -0
- package/dist/constant/derive.mjs.map +1 -0
- package/dist/constant/index.d.mts +7 -0
- package/dist/constant/index.d.mts.map +1 -0
- package/dist/constant/index.mjs +7 -0
- package/dist/constant/index.mjs.map +1 -0
- package/dist/constant/map-bindable.d.mts +10 -0
- package/dist/constant/map-bindable.d.mts.map +1 -0
- package/dist/constant/map-bindable.mjs +16 -0
- package/dist/constant/map-bindable.mjs.map +1 -0
- package/dist/constant/to-observable.d.mts +12 -0
- package/dist/constant/to-observable.d.mts.map +1 -0
- package/dist/constant/to-observable.mjs +16 -0
- package/dist/constant/to-observable.mjs.map +1 -0
- package/dist/constant/view.d.mts +25 -0
- package/dist/constant/view.d.mts.map +1 -0
- package/dist/constant/view.mjs +15 -0
- package/dist/constant/view.mjs.map +1 -0
- package/dist/control/for.d.mts +29 -0
- package/dist/control/for.d.mts.map +1 -0
- package/dist/control/for.mjs +201 -0
- package/dist/control/for.mjs.map +1 -0
- package/dist/control/if.d.mts +16 -0
- package/dist/control/if.d.mts.map +1 -0
- package/dist/control/if.mjs +12 -0
- package/dist/control/if.mjs.map +1 -0
- package/dist/control/index.d.mts +6 -0
- package/dist/control/index.d.mts.map +1 -0
- package/dist/control/index.mjs +6 -0
- package/dist/control/index.mjs.map +1 -0
- package/dist/control/longest-increasing-subsequence.d.mts +7 -0
- package/dist/control/longest-increasing-subsequence.d.mts.map +1 -0
- package/dist/control/longest-increasing-subsequence.mjs +37 -0
- package/dist/control/longest-increasing-subsequence.mjs.map +1 -0
- package/dist/control/match-optional.d.mts +19 -0
- package/dist/control/match-optional.d.mts.map +1 -0
- package/dist/control/match-optional.mjs +21 -0
- package/dist/control/match-optional.mjs.map +1 -0
- package/dist/control/match-result.d.mts +19 -0
- package/dist/control/match-result.d.mts.map +1 -0
- package/dist/control/match-result.mjs +27 -0
- package/dist/control/match-result.mjs.map +1 -0
- package/dist/control/mount-switch.d.mts +18 -0
- package/dist/control/mount-switch.d.mts.map +1 -0
- package/dist/control/mount-switch.mjs +51 -0
- package/dist/control/mount-switch.mjs.map +1 -0
- package/dist/control/portal.d.mts +15 -0
- package/dist/control/portal.d.mts.map +1 -0
- package/dist/control/portal.mjs +22 -0
- package/dist/control/portal.mjs.map +1 -0
- package/dist/index.d.mts +5 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +5 -0
- package/dist/index.mjs.map +1 -0
- package/dist/internal/as-constant.d.mts +9 -0
- package/dist/internal/as-constant.d.mts.map +1 -0
- package/dist/internal/as-constant.mjs +10 -0
- package/dist/internal/as-constant.mjs.map +1 -0
- package/dist/internal/bind-value.d.mts +14 -0
- package/dist/internal/bind-value.d.mts.map +1 -0
- package/dist/internal/bind-value.mjs +39 -0
- package/dist/internal/bind-value.mjs.map +1 -0
- package/dist/internal/dom-tables.d.mts +30 -0
- package/dist/internal/dom-tables.d.mts.map +1 -0
- package/dist/internal/dom-tables.mjs +167 -0
- package/dist/internal/dom-tables.mjs.map +1 -0
- package/dist/internal/index.d.mts +7 -0
- package/dist/internal/index.d.mts.map +1 -0
- package/dist/internal/index.mjs +7 -0
- package/dist/internal/index.mjs.map +1 -0
- package/dist/internal/is-view.d.mts +3 -0
- package/dist/internal/is-view.d.mts.map +1 -0
- package/dist/internal/is-view.mjs +4 -0
- package/dist/internal/is-view.mjs.map +1 -0
- package/dist/internal/mountable-tag.d.mts +6 -0
- package/dist/internal/mountable-tag.d.mts.map +1 -0
- package/dist/internal/mountable-tag.mjs +6 -0
- package/dist/internal/mountable-tag.mjs.map +1 -0
- package/dist/internal/view-tag.d.mts +7 -0
- package/dist/internal/view-tag.d.mts.map +1 -0
- package/dist/internal/view-tag.mjs +7 -0
- package/dist/internal/view-tag.mjs.map +1 -0
- package/dist/jsx/child.d.mts +20 -0
- package/dist/jsx/child.d.mts.map +1 -0
- package/dist/jsx/child.mjs +33 -0
- package/dist/jsx/child.mjs.map +1 -0
- package/dist/jsx/element-props.d.mts +78 -0
- package/dist/jsx/element-props.d.mts.map +1 -0
- package/dist/jsx/element-props.mjs +2 -0
- package/dist/jsx/element-props.mjs.map +1 -0
- package/dist/jsx/event-prop-names.d.mts +120 -0
- package/dist/jsx/event-prop-names.d.mts.map +1 -0
- package/dist/jsx/event-prop-names.mjs +2 -0
- package/dist/jsx/event-prop-names.mjs.map +1 -0
- package/dist/jsx/index.d.mts +7 -0
- package/dist/jsx/index.d.mts.map +1 -0
- package/dist/jsx/index.mjs +7 -0
- package/dist/jsx/index.mjs.map +1 -0
- package/dist/jsx/jsx-namespace.d.mts +11 -0
- package/dist/jsx/jsx-namespace.d.mts.map +1 -0
- package/dist/jsx/jsx-namespace.mjs +2 -0
- package/dist/jsx/jsx-namespace.mjs.map +1 -0
- package/dist/jsx/jsx.d.mts +18 -0
- package/dist/jsx/jsx.d.mts.map +1 -0
- package/dist/jsx/jsx.mjs +46 -0
- package/dist/jsx/jsx.mjs.map +1 -0
- package/dist/jsx/mountable.d.mts +25 -0
- package/dist/jsx/mountable.d.mts.map +1 -0
- package/dist/jsx/mountable.mjs +7 -0
- package/dist/jsx/mountable.mjs.map +1 -0
- package/dist/jsx-dev-runtime.d.mts +7 -0
- package/dist/jsx-dev-runtime.d.mts.map +1 -0
- package/dist/jsx-dev-runtime.mjs +7 -0
- package/dist/jsx-dev-runtime.mjs.map +1 -0
- package/dist/jsx-runtime.d.mts +7 -0
- package/dist/jsx-runtime.d.mts.map +1 -0
- package/dist/jsx-runtime.mjs +7 -0
- package/dist/jsx-runtime.mjs.map +1 -0
- package/dist/render.d.mts +14 -0
- package/dist/render.d.mts.map +1 -0
- package/dist/render.mjs +25 -0
- package/dist/render.mjs.map +1 -0
- package/package.json +97 -3
- package/src/bind/bind-props.mts +174 -0
- package/src/bind/index.mts +1 -0
- package/src/constant/bindable.mts +19 -0
- package/src/constant/constant.mts +24 -0
- package/src/constant/constant.test.mts +70 -0
- package/src/constant/derive.mts +51 -0
- package/src/constant/derive.test.mts +64 -0
- package/src/constant/index.mts +6 -0
- package/src/constant/map-bindable.mts +23 -0
- package/src/constant/map-bindable.test.mts +63 -0
- package/src/constant/to-observable.mts +20 -0
- package/src/constant/to-observable.test.mts +37 -0
- package/src/constant/view.mts +35 -0
- package/src/constant/view.test.mts +40 -0
- package/src/control/for.mts +362 -0
- package/src/control/if.mts +28 -0
- package/src/control/index.mts +5 -0
- package/src/control/longest-increasing-subsequence.mts +59 -0
- package/src/control/longest-increasing-subsequence.test.mts +26 -0
- package/src/control/match-optional.mts +41 -0
- package/src/control/match-result.mts +48 -0
- package/src/control/mount-switch.mts +75 -0
- package/src/control/portal.mts +32 -0
- package/src/index.mts +4 -0
- package/src/internal/as-constant.mts +11 -0
- package/src/internal/bind-value.mts +58 -0
- package/src/internal/dom-tables.mts +176 -0
- package/src/internal/index.mts +6 -0
- package/src/internal/is-view.mts +6 -0
- package/src/internal/mountable-tag.mts +5 -0
- package/src/internal/view-tag.mts +6 -0
- package/src/jsx/child.mts +51 -0
- package/src/jsx/element-props.mts +132 -0
- package/src/jsx/element-props.test.mts +28 -0
- package/src/jsx/event-prop-names.mts +119 -0
- package/src/jsx/index.mts +6 -0
- package/src/jsx/jsx-namespace.mts +11 -0
- package/src/jsx/jsx.mts +63 -0
- package/src/jsx/mountable.mts +31 -0
- package/src/jsx-dev-runtime.mts +6 -0
- package/src/jsx-runtime.mts +11 -0
- package/src/render.mts +32 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.mts","sourceRoot":"","sources":["../../src/constant/derive.mts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAEnD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAG9D;;;;;;;GAOG;AACH,eAAO,MAAM,MAAM,GAAI,KAAK,CAAC,EAAE,SAAS,aAAa,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,aAC9D,EAAE,MACT,CAAC,GAAG,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,KAAK,CAAC,KACvC,QAAQ,CAAC,CAAC,CAmBZ,CAAC;AAEF,6EAA6E;AAC7E,MAAM,MAAM,cAAc,CAAC,EAAE,SAAS,SAAS,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,QAAQ,CAAC;KAC5E,CAAC,IAAI,MAAM,EAAE,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { combine, isObservable, map, } from 'synstate';
|
|
2
|
+
import { Arr } from 'ts-data-forge';
|
|
3
|
+
import { asConstant, isView } from '../internal/index.mjs';
|
|
4
|
+
import { toObservable } from './to-observable.mjs';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
export const derive = (bindables, fn) => {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const apply = (values) =>
|
|
19
|
+
|
|
20
|
+
fn(...values);
|
|
21
|
+
if (Arr.every(bindables, isConstant)) {
|
|
22
|
+
return asConstant(apply(bindables));
|
|
23
|
+
}
|
|
24
|
+
const observables = Arr.map(bindables, toObservable);
|
|
25
|
+
return combine(observables).pipe(map(apply));
|
|
26
|
+
};
|
|
27
|
+
const isConstant = (bindable) => !isView(bindable) && !isObservable(bindable);
|
|
28
|
+
//# sourceMappingURL=derive.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.mjs","sourceRoot":"","sources":["../../src/constant/derive.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,GAAG,GAEJ,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,CACpB,SAAa,EACb,EAAwC,EAC3B,EAAE;IACf,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,oDAAoD;IACpD,MAAM,KAAK,GAAG,CAAC,MAA0B,EAAK,EAAE;IAC9C,iFAAiF;IACjF,EAAE,CAAC,GAAI,MAA6B,CAAC,CAAC;IAExC,IAAI,GAAG,CAAC,KAAK,CAAC,SAAS,EAAE,UAAU,CAAC,EAAE,CAAC;QACrC,OAAO,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC;IACtC,CAAC;IAED,MAAM,WAAW,GAAkD,GAAG,CAAC,GAAG,CACxE,SAAS,EACT,YAAY,CACb,CAAC;IAEF,OAAO,OAAO,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;AAC/C,CAAC,CAAC;AAOF,MAAM,UAAU,GAAG,CAAC,QAA2B,EAAW,EAAE,CAC1D,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/constant/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/constant/index.mts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Bindable } from './bindable.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* Applies `fn` to the value of a {@link Bindable}, keeping its kind.
|
|
4
|
+
*
|
|
5
|
+
* - A constant gives a constant: `fn` runs once and no node is created.
|
|
6
|
+
* - A view gives a view with the two functions composed: no node is created.
|
|
7
|
+
* - An observable gives `bindable.pipe(map(fn))`.
|
|
8
|
+
*/
|
|
9
|
+
export declare const mapBindable: <A, B>(bindable: Bindable<A>, fn: (value: A) => B) => Bindable<B>;
|
|
10
|
+
//# sourceMappingURL=map-bindable.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-bindable.d.mts","sourceRoot":"","sources":["../../src/constant/map-bindable.mts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAG/C;;;;;;GAMG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,YACpB,QAAQ,CAAC,CAAC,CAAC,MACjB,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAClB,QAAQ,CAAC,CAAC,CAOmB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isObservable, map } from 'synstate';
|
|
2
|
+
import { asConstant, isView } from '../internal/index.mjs';
|
|
3
|
+
import { view } from './view.mjs';
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const mapBindable = (bindable, fn) => isView(bindable)
|
|
12
|
+
? bindable.open((source, inner) => view(source, (value) => fn(inner(value))))
|
|
13
|
+
: isObservable(bindable)
|
|
14
|
+
? bindable.pipe(map(fn))
|
|
15
|
+
: asConstant(fn(bindable));
|
|
16
|
+
//# sourceMappingURL=map-bindable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"map-bindable.mjs","sourceRoot":"","sources":["../../src/constant/map-bindable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAE3D,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CACzB,QAAqB,EACrB,EAAmB,EACN,EAAE,CACf,MAAM,CAAC,QAAQ,CAAC;IACd,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAC9B,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAC1C;IACH,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QACtB,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACxB,CAAC,CAAC,UAAU,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type InitializedObservable } from 'synstate';
|
|
2
|
+
import type { Bindable } from './bindable.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Turns a {@link Bindable} into an observable: a constant becomes `just(value)`,
|
|
5
|
+
* a view becomes `source.pipe(map(fn))`, and an observable is returned as is.
|
|
6
|
+
*
|
|
7
|
+
* Only for where an observable is really needed, such as the projection of a
|
|
8
|
+
* `switchMap`: a constant made into an observable joins the graph, which
|
|
9
|
+
* {@link mapBindable} and {@link derive} avoid.
|
|
10
|
+
*/
|
|
11
|
+
export declare const toObservable: <T>(bindable: Bindable<T>) => InitializedObservable<T>;
|
|
12
|
+
//# sourceMappingURL=to-observable.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-observable.d.mts","sourceRoot":"","sources":["../../src/constant/to-observable.mts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,qBAAqB,EAAE,MAAM,UAAU,CAAC;AAE/E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,GAAI,CAAC,YAClB,QAAQ,CAAC,CAAC,CAAC,KACpB,qBAAqB,CAAC,CAAC,CAKJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { isObservable, just, map } from 'synstate';
|
|
2
|
+
import { isView } from '../internal/index.mjs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const toObservable = (bindable) => isView(bindable)
|
|
12
|
+
? bindable.open((source, fn) => source.pipe(map(fn)))
|
|
13
|
+
: isObservable(bindable)
|
|
14
|
+
? bindable
|
|
15
|
+
: just(bindable);
|
|
16
|
+
//# sourceMappingURL=to-observable.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"to-observable.mjs","sourceRoot":"","sources":["../../src/constant/to-observable.mts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAA8B,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAG/C;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,QAAqB,EACK,EAAE,CAC5B,MAAM,CAAC,QAAQ,CAAC;IACd,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;QACtB,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InitializedObservable } from 'synstate';
|
|
2
|
+
import { viewTag } from '../internal/index.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* An observable and a function to apply to each of its values, bound without
|
|
5
|
+
* creating a node in the graph. Made by {@link view}.
|
|
6
|
+
*
|
|
7
|
+
* The source's value type is hidden behind `open`, which hands the pair back
|
|
8
|
+
* to a callback that is generic in it: whoever opens a view sees a source and
|
|
9
|
+
* a function that agree with each other, with no assertion on either side.
|
|
10
|
+
*/
|
|
11
|
+
export type View<T> = Readonly<{
|
|
12
|
+
[viewTag]: true;
|
|
13
|
+
open: <R>(use: <A>(source: InitializedObservable<A>, fn: (value: A) => T) => R) => R;
|
|
14
|
+
}>;
|
|
15
|
+
/**
|
|
16
|
+
* Pairs an observable with a light transformation, for a slot that takes a
|
|
17
|
+
* `Bindable`. The transformation runs in the binding's subscriber, so no node
|
|
18
|
+
* is added to the graph.
|
|
19
|
+
*
|
|
20
|
+
* `fn` runs once per value per binding: a view passed to two slots runs it
|
|
21
|
+
* twice. A heavy transformation, or one shared by several bindings, belongs in
|
|
22
|
+
* `source.pipe(map(fn))`.
|
|
23
|
+
*/
|
|
24
|
+
export declare const view: <A, T>(source: InitializedObservable<A>, fn: (value: A) => T) => View<T>;
|
|
25
|
+
//# sourceMappingURL=view.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.d.mts","sourceRoot":"","sources":["../../src/constant/view.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAEhD;;;;;;;GAOG;AACH,MAAM,MAAM,IAAI,CAAC,CAAC,IAAI,QAAQ,CAAC;IAC7B,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC;IAChB,IAAI,EAAE,CAAC,CAAC,EACN,GAAG,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,KACjE,CAAC,CAAC;CACR,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,GAAI,CAAC,EAAE,CAAC,UACf,qBAAqB,CAAC,CAAC,CAAC,MAC5B,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,KAClB,IAAI,CAAC,CAAC,CAII,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"view.mjs","sourceRoot":"","sources":["../../src/constant/view.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAiBhD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,CAClB,MAAgC,EAChC,EAAmB,EACV,EAAE,CACX,CAAC;IACC,CAAC,OAAO,CAAC,EAAE,IAAI;IACf,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC;CAC/B,CAAU,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type InitializedObservable } from 'synstate';
|
|
2
|
+
import { type Bindable } from '../constant/index.mjs';
|
|
3
|
+
import { type JSX } from '../jsx/index.mjs';
|
|
4
|
+
/**
|
|
5
|
+
* Mounts one row per element of `items`, matched across updates by `key`
|
|
6
|
+
* (SPEC.md 8.4).
|
|
7
|
+
*
|
|
8
|
+
* `children` is called once per key, inside a scope of the row's own, with
|
|
9
|
+
* observables of the element and its index. The index is made only for a
|
|
10
|
+
* `children` that declares a second parameter (`children.length >= 2`); one
|
|
11
|
+
* that reads it otherwise, through a rest parameter or `arguments`, is given
|
|
12
|
+
* `undefined`.
|
|
13
|
+
*
|
|
14
|
+
* A row whose key stays is not rebuilt: its `item$` and `index$` are derived
|
|
15
|
+
* from `items`, so they update in the ordinary propagation, and nothing is
|
|
16
|
+
* written during it. A key that goes disposes its row's scope and removes its
|
|
17
|
+
* nodes; the rows that stay are moved as little as the longest increasing
|
|
18
|
+
* subsequence allows.
|
|
19
|
+
*
|
|
20
|
+
* `key` is required, as in React; `(_, i) => i` matches rows by position. A
|
|
21
|
+
* key that appears twice is reported with `console.error`, and its later
|
|
22
|
+
* occurrences are rebuilt on every update.
|
|
23
|
+
*/
|
|
24
|
+
export declare const For: <T>({ items, key, children, }: Readonly<{
|
|
25
|
+
items: Bindable<readonly T[]>;
|
|
26
|
+
key: (item: T, index: number) => unknown;
|
|
27
|
+
children: (item$: InitializedObservable<T>, index$: InitializedObservable<number>) => JSX.Element;
|
|
28
|
+
}>) => JSX.Element;
|
|
29
|
+
//# sourceMappingURL=for.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for.d.mts","sourceRoot":"","sources":["../../src/control/for.mts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,qBAAqB,EAG3B,MAAM,UAAU,CAAC;AAGlB,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAsB,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGhE;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,GAAG,GAAI,CAAC,6BAIlB,QAAQ,CAAC;IACV,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAC9B,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IACzC,QAAQ,EAAE,CACR,KAAK,EAAE,qBAAqB,CAAC,CAAC,CAAC,EAC/B,MAAM,EAAE,qBAAqB,CAAC,MAAM,CAAC,KAClC,GAAG,CAAC,OAAO,CAAC;CAClB,CAAC,KAAG,GAAG,CAAC,OAwML,CAAC"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { createInitializedSyncChildObservable, createScope, getCurrentScope, map, onScopeDispose, } from 'synstate';
|
|
2
|
+
import { Arr, Optional } from 'ts-data-forge';
|
|
3
|
+
import { toObservable } from '../constant/index.mjs';
|
|
4
|
+
import { bindValue } from '../internal/index.mjs';
|
|
5
|
+
import { mountable, toNodes } from '../jsx/index.mjs';
|
|
6
|
+
import { longestIncreasingSubsequence } from './longest-increasing-subsequence.mjs';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
export const For = ({ items, key, children, }) => mountable(() => {
|
|
28
|
+
const parent = getCurrentScope();
|
|
29
|
+
const anchor = document.createComment('');
|
|
30
|
+
const entries$ = toObservable(items).pipe(map((list) => toEntries(list, key)));
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
const usesIndex = children.length >= 2;
|
|
35
|
+
const callChildren = children;
|
|
36
|
+
const mut_rows = new Map();
|
|
37
|
+
const rowStarts = new WeakSet();
|
|
38
|
+
const mut_initial = { nodes: [] };
|
|
39
|
+
|
|
40
|
+
const createRow = (rowKey, entry) => {
|
|
41
|
+
const scope = createScope(parent);
|
|
42
|
+
const start = document.createComment('');
|
|
43
|
+
rowStarts.add(start);
|
|
44
|
+
const nodes = scope.run(() => {
|
|
45
|
+
const item$ = rowField(entries$, rowKey, entry.item, (e) => e.item);
|
|
46
|
+
return toNodes((usesIndex
|
|
47
|
+
? callChildren(item$, rowField(entries$, rowKey, entry.index, (e) => e.index))
|
|
48
|
+
: callChildren(item$)).mount());
|
|
49
|
+
});
|
|
50
|
+
const row = { scope, start };
|
|
51
|
+
scope.run(() => {
|
|
52
|
+
onScopeDispose(() => {
|
|
53
|
+
for (const node of rowNodes(row)) {
|
|
54
|
+
node.remove();
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
mut_rows.set(rowKey, row);
|
|
59
|
+
return Arr.toUnshifted(start)(nodes);
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const rowNodes = (row) => {
|
|
63
|
+
const mut_nodes = [row.start];
|
|
64
|
+
for (let mut_node = row.start.nextSibling; mut_node !== null && mut_node !== anchor && !rowStarts.has(mut_node); mut_node = mut_node.nextSibling) {
|
|
65
|
+
mut_nodes.push(mut_node);
|
|
66
|
+
}
|
|
67
|
+
return mut_nodes;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
const removeAllAtOnceIfEveryKeyGoes = (previousOrder, entries) => {
|
|
76
|
+
if (!Arr.isNonEmpty(previousOrder) ||
|
|
77
|
+
previousOrder.some((rowKey) => entries.byKey.has(rowKey))) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const first = mut_rows.get(previousOrder[0]);
|
|
81
|
+
if (first === undefined) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const range = document.createRange();
|
|
85
|
+
range.setStartBefore(first.start);
|
|
86
|
+
range.setEndBefore(anchor);
|
|
87
|
+
range.deleteContents();
|
|
88
|
+
};
|
|
89
|
+
bindValue(entries$, (entries) => {
|
|
90
|
+
const previousOrder = Array.from(mut_rows.keys());
|
|
91
|
+
if (anchor.parentNode !== null) {
|
|
92
|
+
removeAllAtOnceIfEveryKeyGoes(previousOrder, entries);
|
|
93
|
+
}
|
|
94
|
+
for (const [rowKey, row] of mut_rows) {
|
|
95
|
+
if (entries.byKey.has(rowKey)) {
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
row.scope.dispose();
|
|
99
|
+
mut_rows.delete(rowKey);
|
|
100
|
+
}
|
|
101
|
+
if (anchor.parentNode === null) {
|
|
102
|
+
mut_initial.nodes = entries.order.flatMap((rowKey) => {
|
|
103
|
+
const entry = entries.byKey.get(rowKey);
|
|
104
|
+
return entry === undefined ? [] : createRow(rowKey, entry);
|
|
105
|
+
});
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (Arr.eq(previousOrder, entries.order)) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const previousPosition = new Map(previousOrder
|
|
112
|
+
.filter((rowKey) => mut_rows.has(rowKey))
|
|
113
|
+
.map((rowKey, position) => [rowKey, position]));
|
|
114
|
+
const positions = entries.order.map((rowKey) => previousPosition.get(rowKey) ?? -1);
|
|
115
|
+
const stay = longestIncreasingSubsequence(positions.filter((position) => position >= 0));
|
|
116
|
+
const staying = new Set(positions
|
|
117
|
+
.filter((position) => position >= 0)
|
|
118
|
+
.filter((_, k) => stay.has(k)));
|
|
119
|
+
let mut_next = anchor;
|
|
120
|
+
for (const rowKey of entries.order.toReversed()) {
|
|
121
|
+
const existing = mut_rows.get(rowKey);
|
|
122
|
+
if (existing === undefined) {
|
|
123
|
+
const entry = entries.byKey.get(rowKey);
|
|
124
|
+
if (entry === undefined) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const [start, ...rest] = createRow(rowKey, entry);
|
|
128
|
+
if (start !== undefined) {
|
|
129
|
+
mut_next.before(start, ...rest);
|
|
130
|
+
mut_next = start;
|
|
131
|
+
}
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (!staying.has(previousPosition.get(rowKey) ?? -1)) {
|
|
135
|
+
mut_next.before(...rowNodes(existing));
|
|
136
|
+
}
|
|
137
|
+
mut_next = existing.start;
|
|
138
|
+
}
|
|
139
|
+
reorderMap(mut_rows, entries.order);
|
|
140
|
+
});
|
|
141
|
+
return Arr.toPushed(mut_initial.nodes, anchor);
|
|
142
|
+
});
|
|
143
|
+
const toEntries = (list, key) => {
|
|
144
|
+
const mut_byKey = new Map();
|
|
145
|
+
const order = list.map((item, index) => {
|
|
146
|
+
const itemKey = key(item, index);
|
|
147
|
+
if (!mut_byKey.has(itemKey)) {
|
|
148
|
+
mut_byKey.set(itemKey, { item, index });
|
|
149
|
+
return itemKey;
|
|
150
|
+
}
|
|
151
|
+
console.error('synstate-dom: For found the key', itemKey, 'more than once; keys must be unique.');
|
|
152
|
+
|
|
153
|
+
const duplicateKey = Symbol('duplicate key');
|
|
154
|
+
mut_byKey.set(duplicateKey, { item, index });
|
|
155
|
+
return duplicateKey;
|
|
156
|
+
});
|
|
157
|
+
return { order, byKey: mut_byKey };
|
|
158
|
+
};
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
const rowField = (entries$, rowKey, initialValue, field) => createInitializedSyncChildObservable({ parents: [entries$], initialValue: Optional.some(initialValue) }, ({ setNext }) => {
|
|
168
|
+
let mut_previous = initialValue;
|
|
169
|
+
return (updateToken) => {
|
|
170
|
+
const sn = entries$.getSnapshot();
|
|
171
|
+
if (entries$.updateToken !== updateToken || Optional.isNone(sn)) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const entry = sn.value.byKey.get(rowKey);
|
|
175
|
+
if (entry === undefined) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
const next = field(entry);
|
|
179
|
+
if (Object.is(next, mut_previous)) {
|
|
180
|
+
return;
|
|
181
|
+
}
|
|
182
|
+
mut_previous = next;
|
|
183
|
+
setNext(next, updateToken);
|
|
184
|
+
};
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const reorderMap = (mut_rows, order) => {
|
|
188
|
+
const rows = Arr.generate(function* () {
|
|
189
|
+
for (const rowKey of order) {
|
|
190
|
+
const row = mut_rows.get(rowKey);
|
|
191
|
+
if (row !== undefined) {
|
|
192
|
+
yield [rowKey, row];
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
mut_rows.clear();
|
|
197
|
+
for (const [rowKey, row] of rows) {
|
|
198
|
+
mut_rows.set(rowKey, row);
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//# sourceMappingURL=for.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"for.mjs","sourceRoot":"","sources":["../../src/control/for.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,oCAAoC,EACpC,WAAW,EACX,eAAe,EACf,GAAG,EACH,cAAc,GAIf,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAiB,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CA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CAAC;QAED,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAEzC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACxB,OAAO;QACT,CAAC;QAED,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC;QAE1B,IAAI,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,EAAE,CAAC;YAClC,OAAO;QACT,CAAC;QAED,YAAY,GAAG,IAAI,CAAC;QAEpB,OAAO,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC;IAC7B,CAAC,CAAC;AACJ,CAAC,CACF,CAAC;AAEJ,+EAA+E;AAC/E,MAAM,UAAU,GAAG,CACjB,QAA2B,EAC3B,KAAyB,EACnB,EAAE;IACR,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;QACjC,KAAK,MAAM,MAAM,IAAI,KAAK,EAAE,CAAC;YAC3B,MAAM,GAAG,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAEjC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;gBACtB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAU,CAAC;YAC/B,CAAC;QACH,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,KAAK,EAAE,CAAC;IAEjB,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC;QACjC,QAAQ,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC5B,CAAC;AACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Bindable } from '../constant/index.mjs';
|
|
2
|
+
import { type JSX } from '../jsx/index.mjs';
|
|
3
|
+
/**
|
|
4
|
+
* Mounts `then` while `cond` is `true` and `else` while it is `false`
|
|
5
|
+
* (SPEC.md 8.2). Nothing is mounted for an omitted `else`.
|
|
6
|
+
*
|
|
7
|
+
* Both branches are descriptions, so only the one chosen is mounted. A branch
|
|
8
|
+
* is rebuilt only when `cond` flips; flipping disposes the previous branch's
|
|
9
|
+
* scope and removes its nodes. A constant `cond` mounts one branch once.
|
|
10
|
+
*/
|
|
11
|
+
export declare const If: ({ cond, then, else: elseBranch, }: Readonly<{
|
|
12
|
+
cond: Bindable<boolean>;
|
|
13
|
+
then: JSX.Element;
|
|
14
|
+
else?: JSX.Element;
|
|
15
|
+
}>) => JSX.Element;
|
|
16
|
+
//# sourceMappingURL=if.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if.d.mts","sourceRoot":"","sources":["../../src/control/if.mts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;GAOG;AACH,eAAO,MAAM,EAAE,sCAIZ,QAAQ,CAAC;IACV,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IACxB,IAAI,EAAE,GAAG,CAAC,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACpB,CAAC,KAAG,GAAG,CAAC,OAON,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { mountable } from '../jsx/index.mjs';
|
|
2
|
+
import { mountSwitch } from './mount-switch.mjs';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export const If = ({ cond, then, else: elseBranch, }) => mountable(() => mountSwitch(cond, (value) => value, (value) => (value ? then : elseBranch)));
|
|
12
|
+
//# sourceMappingURL=if.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"if.mjs","sourceRoot":"","sources":["../../src/control/if.mts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACjB,IAAI,EACJ,IAAI,EACJ,IAAI,EAAE,UAAU,GAKhB,EAAe,EAAE,CACjB,SAAS,CAAC,GAAG,EAAE,CACb,WAAW,CACT,IAAI,EACJ,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAChB,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CACvC,CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.mts","sourceRoot":"","sources":["../../src/control/index.mts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.mjs","sourceRoot":"","sources":["../../src/control/index.mts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The positions in `values` of one longest strictly increasing subsequence,
|
|
3
|
+
* in O(n log n). `For` keeps the rows at these positions in place and moves
|
|
4
|
+
* only the others (SPEC.md 8.4).
|
|
5
|
+
*/
|
|
6
|
+
export declare const longestIncreasingSubsequence: (values: readonly number[]) => ReadonlySet<number>;
|
|
7
|
+
//# sourceMappingURL=longest-increasing-subsequence.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longest-increasing-subsequence.d.mts","sourceRoot":"","sources":["../../src/control/longest-increasing-subsequence.mts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,WAC/B,SAAS,MAAM,EAAE,KACxB,WAAW,CAAC,MAAM,CA6BpB,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
export const longestIncreasingSubsequence = (values) => {
|
|
7
|
+
|
|
8
|
+
const mut_tails = [];
|
|
9
|
+
|
|
10
|
+
const mut_previous = [];
|
|
11
|
+
for (const [i, value] of values.entries()) {
|
|
12
|
+
const k = lowerBound(mut_tails, (position) => (values[position] ?? 0) < value);
|
|
13
|
+
mut_previous[i] = k > 0 ? mut_tails[k - 1] : undefined;
|
|
14
|
+
mut_tails[k] = i;
|
|
15
|
+
}
|
|
16
|
+
const mut_result = new Set();
|
|
17
|
+
for (let mut_i = mut_tails.at(-1); mut_i !== undefined; mut_i = mut_previous[mut_i]) {
|
|
18
|
+
mut_result.add(mut_i);
|
|
19
|
+
}
|
|
20
|
+
return mut_result;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const lowerBound = (sorted, isBefore) => {
|
|
24
|
+
let mut_low = 0;
|
|
25
|
+
let mut_high = sorted.length;
|
|
26
|
+
while (mut_low < mut_high) {
|
|
27
|
+
const middle = Math.floor((mut_low + mut_high) / 2);
|
|
28
|
+
if (isBefore(sorted[middle] ?? 0)) {
|
|
29
|
+
mut_low = middle + 1;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
mut_high = middle;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return mut_low;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=longest-increasing-subsequence.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"longest-increasing-subsequence.mjs","sourceRoot":"","sources":["../../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AO,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QAEpD,IAAI,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YAClC,OAAO,GAAG,MAAM,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,QAAQ,GAAG,MAAM,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type InitializedObservable } from 'synstate';
|
|
2
|
+
import { Optional } from 'ts-data-forge';
|
|
3
|
+
import { type Bindable } from '../constant/index.mjs';
|
|
4
|
+
import { type JSX } from '../jsx/index.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Mounts `some` while `value` holds a value and `none` while it is empty
|
|
7
|
+
* (SPEC.md 8.3).
|
|
8
|
+
*
|
|
9
|
+
* `some` is called once per change from empty to present, with an observable
|
|
10
|
+
* of the value narrowed to `T`. While the value stays present, new values flow
|
|
11
|
+
* through that observable rather than rebuilding the branch. It is derived
|
|
12
|
+
* from `value`, not written to, so nothing is written during propagation.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MatchOptional: <T>({ value, some, none, }: Readonly<{
|
|
15
|
+
value: Bindable<Optional<T>>;
|
|
16
|
+
some: (value$: InitializedObservable<T>) => JSX.Element;
|
|
17
|
+
none?: JSX.Element;
|
|
18
|
+
}>) => JSX.Element;
|
|
19
|
+
//# sourceMappingURL=match-optional.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-optional.d.mts","sourceRoot":"","sources":["../../src/control/match-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,CAAC,0BAI5B,QAAQ,CAAC;IACV,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACxD,IAAI,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;CACpB,CAAC,KAAG,GAAG,CAAC,OAYN,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { filter, map, withInitialValue, } from 'synstate';
|
|
2
|
+
import { Optional } from 'ts-data-forge';
|
|
3
|
+
import { toObservable } from '../constant/index.mjs';
|
|
4
|
+
import { mountable } from '../jsx/index.mjs';
|
|
5
|
+
import { mountSwitch } from './mount-switch.mjs';
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
export const MatchOptional = ({ value, some, none, }) => mountable(() => mountSwitch(value, Optional.isSome, (isSome, current) => isSome && Optional.isSome(current)
|
|
16
|
+
? some(toObservable(value)
|
|
17
|
+
.pipe(filter(Optional.isSome))
|
|
18
|
+
.pipe(map((o) => o.value))
|
|
19
|
+
.pipe(withInitialValue(current.value)))
|
|
20
|
+
: none));
|
|
21
|
+
//# sourceMappingURL=match-optional.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-optional.mjs","sourceRoot":"","sources":["../../src/control/match-optional.mts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,GAAG,EACH,gBAAgB,GAEjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,YAAY,EAAiB,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,SAAS,EAAY,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAK,EAChC,KAAK,EACL,IAAI,EACJ,IAAI,GAKJ,EAAe,EAAE,CACjB,SAAS,CAAC,GAAG,EAAE,CACb,WAAW,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE,CACtD,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC;IAChC,CAAC,CAAC,IAAI,CACF,YAAY,CAAC,KAAK,CAAC;SAChB,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SAC7B,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SACzB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CACzC;IACH,CAAC,CAAC,IAAI,CACT,CACF,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type InitializedObservable } from 'synstate';
|
|
2
|
+
import { Result } from 'ts-data-forge';
|
|
3
|
+
import { type Bindable } from '../constant/index.mjs';
|
|
4
|
+
import { type JSX } from '../jsx/index.mjs';
|
|
5
|
+
/**
|
|
6
|
+
* Mounts `ok` while `value` is `Ok` and `err` while it is `Err`
|
|
7
|
+
* (SPEC.md 8.3).
|
|
8
|
+
*
|
|
9
|
+
* Each branch is called once per change of tag, with an observable of the
|
|
10
|
+
* value narrowed to `S` or `E`; while the tag stays the same, new values flow
|
|
11
|
+
* through that observable rather than rebuilding the branch. It is derived
|
|
12
|
+
* from `value`, not written to, so nothing is written during propagation.
|
|
13
|
+
*/
|
|
14
|
+
export declare const MatchResult: <S, E>({ value, ok, err, }: Readonly<{
|
|
15
|
+
value: Bindable<Result<S, E>>;
|
|
16
|
+
ok: (value$: InitializedObservable<S>) => JSX.Element;
|
|
17
|
+
err: (error$: InitializedObservable<E>) => JSX.Element;
|
|
18
|
+
}>) => JSX.Element;
|
|
19
|
+
//# sourceMappingURL=match-result.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"match-result.d.mts","sourceRoot":"","sources":["../../src/control/match-result.mts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAgB,KAAK,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAa,KAAK,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAGvD;;;;;;;;GAQG;AACH,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,CAAC,uBAI7B,QAAQ,CAAC;IACV,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IAC9B,EAAE,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;IACtD,GAAG,EAAE,CAAC,MAAM,EAAE,qBAAqB,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;CACxD,CAAC,KAAG,GAAG,CAAC,OAmBN,CAAC"}
|