@manyducks.co/dolla 2.0.0-alpha.4 → 2.0.0-alpha.6
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 +162 -513
- package/dist/index.d.ts +10 -10
- package/dist/index.js +171 -172
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.js +2 -2
- package/dist/jsx-runtime.js +2 -2
- package/dist/markup.d.ts +11 -11
- package/dist/modules/dolla.d.ts +7 -7
- package/dist/modules/language.d.ts +4 -4
- package/dist/modules/router.d.ts +4 -4
- package/dist/nodes/cond.d.ts +3 -3
- package/dist/nodes/html.d.ts +1 -1
- package/dist/nodes/observer.d.ts +4 -4
- package/dist/nodes/outlet.d.ts +3 -3
- package/dist/nodes/repeat.d.ts +9 -9
- package/dist/nodes/text.d.ts +3 -3
- package/dist/{passthrough-BSLd3foL.js → passthrough-CW8Ezjg-.js} +168 -169
- package/dist/passthrough-CW8Ezjg-.js.map +1 -0
- package/dist/state.d.ts +101 -0
- package/dist/types.d.ts +11 -11
- package/dist/view.d.ts +4 -4
- package/notes/readme-scratch.md +222 -0
- package/notes/scratch.md +1 -1
- package/package.json +1 -1
- package/tests/{signals.test.js → state.test.js} +6 -6
- package/dist/passthrough-BSLd3foL.js.map +0 -1
- package/dist/signals.d.ts +0 -101
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as s } from "./passthrough-
|
|
2
|
-
import { P as m } from "./passthrough-
|
|
1
|
+
import { r as s } from "./passthrough-CW8Ezjg-.js";
|
|
2
|
+
import { P as m } from "./passthrough-CW8Ezjg-.js";
|
|
3
3
|
function d(n, r, t, e, a, l) {
|
|
4
4
|
const i = { ...o(["children", "key"], r) }, c = Array.isArray(r.children) ? r.children : [r.children];
|
|
5
5
|
return s(n, i, ...c);
|
package/dist/jsx-runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as t } from "./passthrough-
|
|
2
|
-
import { P as l } from "./passthrough-
|
|
1
|
+
import { r as t } from "./passthrough-CW8Ezjg-.js";
|
|
2
|
+
import { P as l } from "./passthrough-CW8Ezjg-.js";
|
|
3
3
|
function d(n, e, r) {
|
|
4
4
|
return t(n, e ? { ...u(["children", "key"], e) } : void 0, e.children);
|
|
5
5
|
}
|
package/dist/markup.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dolla } from "./modules/dolla.js";
|
|
2
|
-
import {
|
|
2
|
+
import { MaybeState, type State } from "./state.js";
|
|
3
3
|
import type { Renderable, Stringable } from "./types.js";
|
|
4
4
|
import { type ViewFunction, type ViewContext, type ViewResult } from "./view.js";
|
|
5
5
|
export interface ElementContext {
|
|
@@ -34,24 +34,24 @@ export declare function isNode(value: unknown): value is MarkupNode;
|
|
|
34
34
|
export declare function toMarkup(renderables: Renderable | Renderable[]): Markup[];
|
|
35
35
|
export interface MarkupAttributes {
|
|
36
36
|
$text: {
|
|
37
|
-
value:
|
|
37
|
+
value: MaybeState<Stringable>;
|
|
38
38
|
};
|
|
39
39
|
$cond: {
|
|
40
|
-
$predicate:
|
|
40
|
+
$predicate: State<any>;
|
|
41
41
|
thenContent?: Renderable;
|
|
42
42
|
elseContent?: Renderable;
|
|
43
43
|
};
|
|
44
44
|
$repeat: {
|
|
45
|
-
$items:
|
|
45
|
+
$items: State<any[]>;
|
|
46
46
|
keyFn: (value: any, index: number) => string | number | symbol;
|
|
47
|
-
renderFn: ($item:
|
|
47
|
+
renderFn: ($item: State<any>, $index: State<number>, c: ViewContext) => ViewResult;
|
|
48
48
|
};
|
|
49
49
|
$observer: {
|
|
50
|
-
|
|
50
|
+
states: State<any>[];
|
|
51
51
|
renderFn: (...items: any) => Renderable;
|
|
52
52
|
};
|
|
53
53
|
$outlet: {
|
|
54
|
-
$children:
|
|
54
|
+
$children: State<MarkupNode[]>;
|
|
55
55
|
};
|
|
56
56
|
$node: {
|
|
57
57
|
value: Node;
|
|
@@ -71,22 +71,22 @@ export declare const html: (strings: TemplateStringsArray, ...values: any[]) =>
|
|
|
71
71
|
/**
|
|
72
72
|
* Displays content conditionally. When `predicate` holds a truthy value, `thenContent` is displayed; when `predicate` holds a falsy value, `elseContent` is displayed.
|
|
73
73
|
*/
|
|
74
|
-
export declare function cond(predicate:
|
|
74
|
+
export declare function cond(predicate: MaybeState<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
|
|
75
75
|
/**
|
|
76
76
|
* Calls `renderFn` for each item in `items`. Dynamically adds and removes views as items change.
|
|
77
77
|
* The result of `keyFn` is used to compare items and decide if item was added, removed or updated.
|
|
78
78
|
*/
|
|
79
|
-
export declare function repeat<T>(items:
|
|
79
|
+
export declare function repeat<T>(items: MaybeState<T[]>, keyFn: (value: T, index: number) => string | number | symbol, renderFn: ($value: State<T>, $index: State<number>, ctx: ViewContext) => ViewResult): Markup;
|
|
80
80
|
/**
|
|
81
81
|
* Render `content` into a `parent` node anywhere in the page, rather than at its position in the view.
|
|
82
82
|
*/
|
|
83
83
|
export declare function portal(parent: Node, content: Renderable): Markup;
|
|
84
84
|
/**
|
|
85
|
-
* A special kind of
|
|
85
|
+
* A special kind of State exclusively for storing references to DOM nodes.
|
|
86
86
|
*/
|
|
87
87
|
export declare function createRef<T extends Node>(): Ref<T>;
|
|
88
88
|
export declare function isRef<T extends Node>(value: any): value is Ref<T>;
|
|
89
|
-
export interface Ref<T extends Node> extends
|
|
89
|
+
export interface Ref<T extends Node> extends State<T | undefined> {
|
|
90
90
|
node: T | undefined;
|
|
91
91
|
}
|
|
92
92
|
/**
|
package/dist/modules/dolla.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRef, isRef, MarkupNode, type Markup } from "../markup.js";
|
|
2
|
-
import {
|
|
2
|
+
import { createSettableState, createState, derive, toSettableState, toState, valueOf, watch, type State } from "../state.js";
|
|
3
3
|
import { type ViewFunction, type ViewNode } from "../view.js";
|
|
4
4
|
import { type CrashViewProps } from "../views/default-crash-view.js";
|
|
5
5
|
import { HTTP } from "./http.js";
|
|
@@ -45,11 +45,11 @@ export declare class Dolla {
|
|
|
45
45
|
readonly render: Render;
|
|
46
46
|
readonly router: Router;
|
|
47
47
|
constructor();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
createState: typeof createState;
|
|
49
|
+
createSettableState: typeof createSettableState;
|
|
50
|
+
toSettableState: typeof toSettableState;
|
|
51
|
+
toState: typeof toState;
|
|
52
|
+
valueOf: typeof valueOf;
|
|
53
53
|
derive: typeof derive;
|
|
54
54
|
watch: typeof watch;
|
|
55
55
|
createRef: typeof createRef;
|
|
@@ -99,7 +99,7 @@ export declare class Dolla {
|
|
|
99
99
|
*/
|
|
100
100
|
setLoggles(options: Partial<Loggles>): void;
|
|
101
101
|
setLogFilter(filter: string | RegExp): void;
|
|
102
|
-
createLogger(name: string |
|
|
102
|
+
createLogger(name: string | State<string>, options?: LoggerOptions): Logger;
|
|
103
103
|
/**
|
|
104
104
|
*
|
|
105
105
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type State } from "../state.js";
|
|
2
2
|
import type { Stringable } from "../types.js";
|
|
3
3
|
import type { Dolla } from "./dolla.js";
|
|
4
4
|
/**
|
|
@@ -25,17 +25,17 @@ export type LanguageSetupOptions = {
|
|
|
25
25
|
};
|
|
26
26
|
export declare class Language {
|
|
27
27
|
#private;
|
|
28
|
-
$current:
|
|
28
|
+
$current: State<string | undefined>;
|
|
29
29
|
constructor(dolla: Dolla);
|
|
30
30
|
get supportedLanguages(): string[];
|
|
31
31
|
setup(options: LanguageSetupOptions): void;
|
|
32
32
|
setLanguage(name: string): Promise<void>;
|
|
33
33
|
/**
|
|
34
|
-
* Returns a
|
|
34
|
+
* Returns a State containing the value at `key`.
|
|
35
35
|
|
|
36
36
|
* @param key - Key to the translated value.
|
|
37
37
|
* @param values - A map of {{placeholder}} names and the values to replace them with.
|
|
38
38
|
*/
|
|
39
|
-
t(key: string, values?: Record<string, Stringable |
|
|
39
|
+
t(key: string, values?: Record<string, Stringable | State<Stringable>>): State<string>;
|
|
40
40
|
}
|
|
41
41
|
export {};
|
package/dist/modules/router.d.ts
CHANGED
|
@@ -107,19 +107,19 @@ export declare class Router {
|
|
|
107
107
|
/**
|
|
108
108
|
* The currently matched route pattern, if any.
|
|
109
109
|
*/
|
|
110
|
-
$pattern: import("../
|
|
110
|
+
$pattern: import("../state.js").State<string | null>;
|
|
111
111
|
/**
|
|
112
112
|
* The current URL path.
|
|
113
113
|
*/
|
|
114
|
-
$path: import("../
|
|
114
|
+
$path: import("../state.js").State<string>;
|
|
115
115
|
/**
|
|
116
116
|
* The current named path params.
|
|
117
117
|
*/
|
|
118
|
-
$params: import("../
|
|
118
|
+
$params: import("../state.js").State<ParsedParams>;
|
|
119
119
|
/**
|
|
120
120
|
* The current query params. Changes to this object will be reflected in the URL.
|
|
121
121
|
*/
|
|
122
|
-
$query: import("../
|
|
122
|
+
$query: import("../state.js").State<ParsedQuery>;
|
|
123
123
|
constructor(dolla: Dolla, elements: RouterElements);
|
|
124
124
|
setup(options: RouterSetupOptions): void;
|
|
125
125
|
/**
|
package/dist/nodes/cond.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type MarkupNode, type ElementContext, type Markup } from "../markup.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type State, type StopFunction } from "../state.js";
|
|
3
3
|
import { type Renderable } from "../types.js";
|
|
4
4
|
export interface ConditionalConfig {
|
|
5
|
-
$predicate:
|
|
5
|
+
$predicate: State<any>;
|
|
6
6
|
thenContent?: Renderable;
|
|
7
7
|
elseContent?: Renderable;
|
|
8
8
|
elementContext: ElementContext;
|
|
@@ -10,7 +10,7 @@ export interface ConditionalConfig {
|
|
|
10
10
|
export declare class Conditional implements MarkupNode {
|
|
11
11
|
node: Node;
|
|
12
12
|
endNode: Node;
|
|
13
|
-
$predicate:
|
|
13
|
+
$predicate: State<any>;
|
|
14
14
|
stopCallback?: StopFunction;
|
|
15
15
|
thenContent?: Markup[];
|
|
16
16
|
elseContent?: Markup[];
|
package/dist/nodes/html.d.ts
CHANGED
package/dist/nodes/observer.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type
|
|
1
|
+
import { type ElementContext, type MarkupNode } from "../markup.js";
|
|
2
|
+
import { type State } from "../state.js";
|
|
3
3
|
import type { Renderable } from "../types.js";
|
|
4
4
|
interface ObserverOptions {
|
|
5
5
|
elementContext: ElementContext;
|
|
6
|
-
|
|
6
|
+
states: State<any>[];
|
|
7
7
|
renderFn: (...values: any) => Renderable;
|
|
8
8
|
}
|
|
9
9
|
/**
|
|
@@ -20,7 +20,7 @@ export declare class Observer implements MarkupNode {
|
|
|
20
20
|
stop: () => void;
|
|
21
21
|
};
|
|
22
22
|
get isMounted(): boolean;
|
|
23
|
-
constructor({
|
|
23
|
+
constructor({ states, renderFn, elementContext }: ObserverOptions);
|
|
24
24
|
mount(parent: Node, after?: Node): void;
|
|
25
25
|
unmount(): void;
|
|
26
26
|
cleanup(): void;
|
package/dist/nodes/outlet.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MarkupNode, type ElementContext } from "../markup.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type State, type StopFunction } from "../state.js";
|
|
3
3
|
export interface OutletConfig {
|
|
4
|
-
$children:
|
|
4
|
+
$children: State<MarkupNode[]>;
|
|
5
5
|
elementContext: ElementContext;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
@@ -10,7 +10,7 @@ export interface OutletConfig {
|
|
|
10
10
|
export declare class Outlet implements MarkupNode {
|
|
11
11
|
node: Node;
|
|
12
12
|
endNode: Node;
|
|
13
|
-
$children:
|
|
13
|
+
$children: State<MarkupNode[]>;
|
|
14
14
|
stopCallback?: StopFunction;
|
|
15
15
|
connectedChildren: MarkupNode[];
|
|
16
16
|
elementContext: ElementContext;
|
package/dist/nodes/repeat.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import { type MarkupNode, type ElementContext } from "../markup.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type State, type Setter, type StopFunction } from "../state.js";
|
|
3
3
|
import { type ViewContext, type ViewResult } from "../view.js";
|
|
4
4
|
interface RepeatOptions<T> {
|
|
5
5
|
elementContext: ElementContext;
|
|
6
|
-
$items:
|
|
6
|
+
$items: State<T[]>;
|
|
7
7
|
keyFn: (value: T, index: number) => string | number | symbol;
|
|
8
|
-
renderFn: ($value:
|
|
8
|
+
renderFn: ($value: State<T>, $index: State<number>, ctx: ViewContext) => ViewResult;
|
|
9
9
|
}
|
|
10
10
|
type ConnectedItem<T> = {
|
|
11
11
|
key: any;
|
|
12
|
-
$value:
|
|
13
|
-
setValue:
|
|
14
|
-
$index:
|
|
15
|
-
setIndex:
|
|
12
|
+
$value: State<T>;
|
|
13
|
+
setValue: Setter<T>;
|
|
14
|
+
$index: State<number>;
|
|
15
|
+
setIndex: Setter<number>;
|
|
16
16
|
handle: MarkupNode;
|
|
17
17
|
};
|
|
18
18
|
export declare class Repeat<T> implements MarkupNode {
|
|
19
19
|
node: Node;
|
|
20
20
|
endNode: Node;
|
|
21
|
-
$items:
|
|
21
|
+
$items: State<T[]>;
|
|
22
22
|
stopCallback?: StopFunction;
|
|
23
23
|
connectedItems: ConnectedItem<T>[];
|
|
24
24
|
elementContext: ElementContext;
|
|
25
|
-
renderFn: ($value:
|
|
25
|
+
renderFn: ($value: State<T>, $index: State<number>, ctx: ViewContext) => ViewResult;
|
|
26
26
|
keyFn: (value: T, index: number) => string | number | symbol;
|
|
27
27
|
get isMounted(): boolean;
|
|
28
28
|
constructor({ elementContext, $items, renderFn, keyFn }: RepeatOptions<T>);
|
package/dist/nodes/text.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type MarkupNode } from "../markup.js";
|
|
2
|
-
import { type
|
|
2
|
+
import { type MaybeState, type StopFunction } from "../state.js";
|
|
3
3
|
interface Stringable {
|
|
4
4
|
toString(): string;
|
|
5
5
|
}
|
|
6
6
|
interface TextOptions {
|
|
7
|
-
value:
|
|
7
|
+
value: MaybeState<Stringable>;
|
|
8
8
|
}
|
|
9
9
|
export declare class Text implements MarkupNode {
|
|
10
10
|
node: globalThis.Text;
|
|
11
|
-
value:
|
|
11
|
+
value: MaybeState<Stringable>;
|
|
12
12
|
stopCallback?: StopFunction;
|
|
13
13
|
get isMounted(): boolean;
|
|
14
14
|
constructor({ value }: TextOptions);
|