@manyducks.co/dolla 2.0.0-alpha.13 → 2.0.0-alpha.14
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/dist/index.d.ts +4 -2
- package/dist/index.js +548 -539
- 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 +18 -8
- package/dist/modules/dolla.d.ts +7 -6
- package/dist/modules/i18n.d.ts +22 -2
- package/dist/modules/router.d.ts +2 -2
- package/dist/nodes/cond.d.ts +3 -3
- package/dist/nodes/html.d.ts +3 -3
- package/dist/nodes/observer.d.ts +4 -3
- package/dist/nodes/outlet.d.ts +6 -6
- package/dist/nodes/portal.d.ts +3 -3
- package/dist/nodes/repeat.d.ts +3 -3
- package/dist/nodes/text.d.ts +2 -2
- package/dist/passthrough-MfPKbG0F.js +1303 -0
- package/dist/passthrough-MfPKbG0F.js.map +1 -0
- package/dist/state.d.ts +14 -1
- package/dist/view.d.ts +4 -4
- package/notes/scratch.md +50 -0
- package/package.json +1 -1
- package/dist/passthrough-Bz5ZF4jn.js +0 -1279
- package/dist/passthrough-Bz5ZF4jn.js.map +0 -1
package/dist/jsx-dev-runtime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { P as m } from "./passthrough-
|
|
1
|
+
import { s } from "./passthrough-MfPKbG0F.js";
|
|
2
|
+
import { P as m } from "./passthrough-MfPKbG0F.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 {
|
|
2
|
-
import { P as l } from "./passthrough-
|
|
1
|
+
import { s as t } from "./passthrough-MfPKbG0F.js";
|
|
2
|
+
import { P as l } from "./passthrough-MfPKbG0F.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
|
@@ -21,24 +21,34 @@ export interface ElementContext {
|
|
|
21
21
|
isSVG?: boolean;
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
|
-
* Markup is a set of element metadata that hasn't been constructed into a
|
|
24
|
+
* Markup is a set of element metadata that hasn't been constructed into a MarkupElement yet.
|
|
25
25
|
*/
|
|
26
26
|
export interface Markup {
|
|
27
|
+
/**
|
|
28
|
+
* In the case of a view, type will be the View function itself. It can also hold an identifier for special nodes like "$cond", "$repeat", etc.
|
|
29
|
+
* DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
|
|
30
|
+
*/
|
|
27
31
|
type: string | ViewFunction<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Data that will be passed to a new MarkupElement instance when it is constructed.
|
|
34
|
+
*/
|
|
28
35
|
props?: Record<string, any>;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
*/
|
|
29
39
|
children?: Markup[];
|
|
30
40
|
}
|
|
31
41
|
/**
|
|
32
42
|
* A DOM node that has been constructed from a Markup object.
|
|
33
43
|
*/
|
|
34
|
-
export interface
|
|
44
|
+
export interface MarkupElement {
|
|
35
45
|
readonly node?: Node;
|
|
36
46
|
readonly isMounted: boolean;
|
|
37
47
|
mount(parent: Node, after?: Node): void;
|
|
38
48
|
unmount(): void;
|
|
39
49
|
}
|
|
40
50
|
export declare function isMarkup(value: unknown): value is Markup;
|
|
41
|
-
export declare function
|
|
51
|
+
export declare function isMarkupElement(value: unknown): value is MarkupElement;
|
|
42
52
|
export declare function toMarkup(renderables: Renderable | Renderable[]): Markup[];
|
|
43
53
|
export interface MarkupAttributes {
|
|
44
54
|
$text: {
|
|
@@ -59,7 +69,7 @@ export interface MarkupAttributes {
|
|
|
59
69
|
renderFn: (...items: any) => Renderable;
|
|
60
70
|
};
|
|
61
71
|
$outlet: {
|
|
62
|
-
$children: State<
|
|
72
|
+
$children: State<MarkupElement[]>;
|
|
63
73
|
};
|
|
64
74
|
$node: {
|
|
65
75
|
value: Node;
|
|
@@ -98,11 +108,11 @@ export interface Ref<T extends Node> extends State<T | undefined> {
|
|
|
98
108
|
node: T | undefined;
|
|
99
109
|
}
|
|
100
110
|
/**
|
|
101
|
-
* Construct Markup metadata into a set of
|
|
111
|
+
* Construct Markup metadata into a set of MarkupElements.
|
|
102
112
|
*/
|
|
103
|
-
export declare function constructMarkup(elementContext: ElementContext, markup: Markup | Markup[]):
|
|
113
|
+
export declare function constructMarkup(elementContext: ElementContext, markup: Markup | Markup[]): MarkupElement[];
|
|
104
114
|
/**
|
|
105
|
-
* Combines one or more
|
|
115
|
+
* Combines one or more MarkupElements into a single MarkupElement.
|
|
106
116
|
*/
|
|
107
|
-
export declare function
|
|
117
|
+
export declare function mergeElements(nodes: MarkupElement[]): MarkupElement;
|
|
108
118
|
export declare function isRenderable(value: unknown): value is Renderable;
|
package/dist/modules/dolla.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createRef, isRef,
|
|
2
|
-
import { createSettableState, createState, derive, toSettableState, toState, valueOf,
|
|
3
|
-
import { type ViewFunction, type
|
|
1
|
+
import { createRef, isRef, MarkupElement, type Markup } from "../markup.js";
|
|
2
|
+
import { createSettableState, createState, derive, toSettableState, toState, valueOf, createWatcher, type State } from "../state.js";
|
|
3
|
+
import { type ViewFunction, type ViewElement } from "../view.js";
|
|
4
4
|
import { type CrashViewProps } from "../views/default-crash-view.js";
|
|
5
5
|
import { HTTP } from "./http.js";
|
|
6
6
|
import { I18n } from "./i18n.js";
|
|
@@ -45,13 +45,14 @@ export declare class Dolla {
|
|
|
45
45
|
readonly render: Render;
|
|
46
46
|
readonly router: Router;
|
|
47
47
|
constructor();
|
|
48
|
+
watch: <I extends import("../state.js").MaybeState<any>[]>(states: [...I], fn: (...currentValues: import("../state.js").StateValues<I>) => void) => import("../state.js").StopFunction;
|
|
48
49
|
createState: typeof createState;
|
|
49
50
|
createSettableState: typeof createSettableState;
|
|
50
51
|
toSettableState: typeof toSettableState;
|
|
51
52
|
toState: typeof toState;
|
|
52
53
|
valueOf: typeof valueOf;
|
|
53
54
|
derive: typeof derive;
|
|
54
|
-
|
|
55
|
+
createWatcher: typeof createWatcher;
|
|
55
56
|
createRef: typeof createRef;
|
|
56
57
|
isRef: typeof isRef;
|
|
57
58
|
/**
|
|
@@ -103,9 +104,9 @@ export declare class Dolla {
|
|
|
103
104
|
/**
|
|
104
105
|
*
|
|
105
106
|
*/
|
|
106
|
-
constructView<P>(view: ViewFunction<P>, props: P, children?: Markup[]):
|
|
107
|
+
constructView<P>(view: ViewFunction<P>, props: P, children?: Markup[]): ViewElement;
|
|
107
108
|
/**
|
|
108
109
|
*
|
|
109
110
|
*/
|
|
110
|
-
constructMarkup(markup: Markup | Markup[]):
|
|
111
|
+
constructMarkup(markup: Markup | Markup[]): MarkupElement;
|
|
111
112
|
}
|
package/dist/modules/i18n.d.ts
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { type MaybeState, type State } from "../state.js";
|
|
2
2
|
import type { Dolla } from "./dolla.js";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* A JSON object of translated strings. Values can be string templates or nested objects.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
interface LocalizedStrings extends Record<string, string | LocalizedStrings> {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A formatter to be applied to a variable.
|
|
10
|
+
*/
|
|
11
|
+
type Format = {
|
|
12
|
+
name: string;
|
|
13
|
+
options: Record<string, any>;
|
|
14
|
+
};
|
|
7
15
|
export interface TranslationConfig {
|
|
8
16
|
/**
|
|
9
17
|
* Name of the locale this translation is for (BCP 47 locale names recommended).
|
|
@@ -34,6 +42,18 @@ export type TOptions = {
|
|
|
34
42
|
*
|
|
35
43
|
*/
|
|
36
44
|
context?: MaybeState<string>;
|
|
45
|
+
/**
|
|
46
|
+
* Override formats specified in the template with the ones in the array for each named variable.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* t("example_key", {
|
|
50
|
+
* count: 5,
|
|
51
|
+
* formatOverrides: {
|
|
52
|
+
* count: [ { name: "datetime", options: { style: "currency", currency: "JPY" } } ]
|
|
53
|
+
* }
|
|
54
|
+
* });
|
|
55
|
+
*/
|
|
56
|
+
formatOverrides?: MaybeState<Record<string, Record<string, Format[]>>>;
|
|
37
57
|
[value: string]: MaybeState<any>;
|
|
38
58
|
};
|
|
39
59
|
export type Formatter = (locale: string, value: unknown, options: Record<string, any>) => string;
|
package/dist/modules/router.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Stringable } from "../types.js";
|
|
2
|
-
import {
|
|
2
|
+
import { type ViewElement, type ViewFunction } from "../view.js";
|
|
3
3
|
import type { Dolla } from "./dolla.js";
|
|
4
4
|
export interface RouteMatchContext {
|
|
5
5
|
/**
|
|
@@ -100,7 +100,7 @@ export interface RouterSetupOptions {
|
|
|
100
100
|
}
|
|
101
101
|
export interface RouterElements {
|
|
102
102
|
readonly rootElement?: HTMLElement;
|
|
103
|
-
readonly rootView?:
|
|
103
|
+
readonly rootView?: ViewElement;
|
|
104
104
|
}
|
|
105
105
|
export declare class Router {
|
|
106
106
|
#private;
|
package/dist/nodes/cond.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MarkupElement, type ElementContext, type Markup } from "../markup.js";
|
|
2
2
|
import { type State, type StopFunction } from "../state.js";
|
|
3
3
|
import { type Renderable } from "../types.js";
|
|
4
4
|
export interface ConditionalConfig {
|
|
@@ -7,14 +7,14 @@ export interface ConditionalConfig {
|
|
|
7
7
|
elseContent?: Renderable;
|
|
8
8
|
elementContext: ElementContext;
|
|
9
9
|
}
|
|
10
|
-
export declare class Conditional implements
|
|
10
|
+
export declare class Conditional implements MarkupElement {
|
|
11
11
|
node: Node;
|
|
12
12
|
endNode: Node;
|
|
13
13
|
$predicate: State<any>;
|
|
14
14
|
stopCallback?: StopFunction;
|
|
15
15
|
thenContent?: Markup[];
|
|
16
16
|
elseContent?: Markup[];
|
|
17
|
-
connectedContent:
|
|
17
|
+
connectedContent: MarkupElement[];
|
|
18
18
|
elementContext: ElementContext;
|
|
19
19
|
initialUpdateHappened: boolean;
|
|
20
20
|
previousValue?: any;
|
package/dist/nodes/html.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ElementContext, type Markup, type
|
|
1
|
+
import { type ElementContext, type Markup, type MarkupElement, type Ref } from "../markup.js";
|
|
2
2
|
import { type StopFunction } from "../state.js";
|
|
3
3
|
type HTMLOptions = {
|
|
4
4
|
elementContext: ElementContext;
|
|
@@ -6,10 +6,10 @@ type HTMLOptions = {
|
|
|
6
6
|
props: Record<string, any>;
|
|
7
7
|
children?: Markup[];
|
|
8
8
|
};
|
|
9
|
-
export declare class HTML implements
|
|
9
|
+
export declare class HTML implements MarkupElement {
|
|
10
10
|
node: HTMLElement | SVGElement;
|
|
11
11
|
props: Record<string, any>;
|
|
12
|
-
children:
|
|
12
|
+
children: MarkupElement[];
|
|
13
13
|
stopCallbacks: StopFunction[];
|
|
14
14
|
elementContext: ElementContext;
|
|
15
15
|
uniqueId: string;
|
package/dist/nodes/observer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type ElementContext, type
|
|
1
|
+
import { type ElementContext, type MarkupElement } from "../markup.js";
|
|
2
2
|
import { type State } from "../state.js";
|
|
3
3
|
import type { Renderable } from "../types.js";
|
|
4
4
|
interface ObserverOptions {
|
|
@@ -9,16 +9,17 @@ interface ObserverOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Displays dynamic children without a parent element.
|
|
11
11
|
*/
|
|
12
|
-
export declare class Observer implements
|
|
12
|
+
export declare class Observer implements MarkupElement {
|
|
13
13
|
node: Node;
|
|
14
14
|
endNode: Node;
|
|
15
|
-
connectedViews:
|
|
15
|
+
connectedViews: MarkupElement[];
|
|
16
16
|
renderFn: (...values: any) => Renderable;
|
|
17
17
|
elementContext: ElementContext;
|
|
18
18
|
observerControls: {
|
|
19
19
|
start: () => void;
|
|
20
20
|
stop: () => void;
|
|
21
21
|
};
|
|
22
|
+
watcher: import("../state.js").StateWatcher;
|
|
22
23
|
get isMounted(): boolean;
|
|
23
24
|
constructor({ states, renderFn, elementContext }: ObserverOptions);
|
|
24
25
|
mount(parent: Node, after?: Node): void;
|
package/dist/nodes/outlet.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MarkupElement, type ElementContext } from "../markup.js";
|
|
2
2
|
import { type State, type StopFunction } from "../state.js";
|
|
3
3
|
export interface OutletConfig {
|
|
4
|
-
$children: State<
|
|
4
|
+
$children: State<MarkupElement[]>;
|
|
5
5
|
elementContext: ElementContext;
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* Manages an array of DOMHandles.
|
|
9
9
|
*/
|
|
10
|
-
export declare class Outlet implements
|
|
10
|
+
export declare class Outlet implements MarkupElement {
|
|
11
11
|
node: Node;
|
|
12
12
|
endNode: Node;
|
|
13
|
-
$children: State<
|
|
13
|
+
$children: State<MarkupElement[]>;
|
|
14
14
|
stopCallback?: StopFunction;
|
|
15
|
-
|
|
15
|
+
mountedChildren: MarkupElement[];
|
|
16
16
|
elementContext: ElementContext;
|
|
17
17
|
constructor(config: OutletConfig);
|
|
18
18
|
get isMounted(): boolean;
|
|
19
19
|
mount(parent: Node, after?: Node | undefined): void;
|
|
20
20
|
unmount(): void;
|
|
21
|
-
update(newChildren:
|
|
21
|
+
update(newChildren: MarkupElement[]): void;
|
|
22
22
|
}
|
package/dist/nodes/portal.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MarkupElement, type ElementContext } from "../markup.js";
|
|
2
2
|
import { type Renderable } from "../types.js";
|
|
3
3
|
interface PortalConfig {
|
|
4
4
|
content: Renderable;
|
|
@@ -8,9 +8,9 @@ interface PortalConfig {
|
|
|
8
8
|
/**
|
|
9
9
|
* Renders content into a specified parent node.
|
|
10
10
|
*/
|
|
11
|
-
export declare class Portal implements
|
|
11
|
+
export declare class Portal implements MarkupElement {
|
|
12
12
|
config: PortalConfig;
|
|
13
|
-
|
|
13
|
+
element?: MarkupElement;
|
|
14
14
|
get isMounted(): boolean;
|
|
15
15
|
constructor(config: PortalConfig);
|
|
16
16
|
mount(_parent: Node, _after?: Node): void;
|
package/dist/nodes/repeat.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MarkupElement, type ElementContext } from "../markup.js";
|
|
2
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> {
|
|
@@ -13,9 +13,9 @@ type ConnectedItem<T> = {
|
|
|
13
13
|
setValue: Setter<T>;
|
|
14
14
|
$index: State<number>;
|
|
15
15
|
setIndex: Setter<number>;
|
|
16
|
-
|
|
16
|
+
element: MarkupElement;
|
|
17
17
|
};
|
|
18
|
-
export declare class Repeat<T> implements
|
|
18
|
+
export declare class Repeat<T> implements MarkupElement {
|
|
19
19
|
node: Node;
|
|
20
20
|
endNode: Node;
|
|
21
21
|
$items: State<T[]>;
|
package/dist/nodes/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MarkupElement } from "../markup.js";
|
|
2
2
|
import { type MaybeState, type StopFunction } from "../state.js";
|
|
3
3
|
interface Stringable {
|
|
4
4
|
toString(): string;
|
|
@@ -6,7 +6,7 @@ interface Stringable {
|
|
|
6
6
|
interface TextOptions {
|
|
7
7
|
value: MaybeState<Stringable>;
|
|
8
8
|
}
|
|
9
|
-
export declare class Text implements
|
|
9
|
+
export declare class Text implements MarkupElement {
|
|
10
10
|
node: globalThis.Text;
|
|
11
11
|
value: MaybeState<Stringable>;
|
|
12
12
|
stopCallback?: StopFunction;
|