@manyducks.co/dolla 2.0.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -284
- package/dist/context-B5blupD2.js +363 -0
- package/dist/context-B5blupD2.js.map +1 -0
- package/dist/core/context.d.ts +29 -144
- package/dist/core/debug.d.ts +19 -0
- package/dist/core/index.d.ts +15 -16
- package/dist/core/markup/helpers.d.ts +34 -0
- package/dist/core/markup/html.d.ts +3 -0
- package/dist/core/{nodes → markup/nodes}/dom.d.ts +5 -4
- package/dist/core/markup/nodes/dynamic.d.ts +16 -0
- package/dist/core/markup/nodes/element.d.ts +14 -0
- package/dist/core/markup/nodes/portal.d.ts +15 -0
- package/dist/core/markup/nodes/repeat.d.ts +21 -0
- package/dist/core/markup/nodes/view.d.ts +17 -0
- package/dist/core/markup/scheduler.d.ts +1 -0
- package/dist/core/markup/types.d.ts +62 -0
- package/dist/core/markup/utils.d.ts +22 -0
- package/dist/core/ref.d.ts +6 -12
- package/dist/core/root.d.ts +36 -0
- package/dist/core/signals.d.ts +46 -76
- package/dist/core/symbols.d.ts +2 -0
- package/dist/core-JHktdqjt.js +242 -0
- package/dist/core-JHktdqjt.js.map +1 -0
- package/dist/http/index.d.ts +21 -33
- package/dist/http.js +89 -149
- package/dist/http.js.map +1 -1
- package/dist/index.js +4 -174
- package/dist/jsx-dev-runtime.d.ts +4 -3
- package/dist/jsx-dev-runtime.js +12 -9
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +5 -4
- package/dist/jsx-runtime.js +17 -12
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/router/index.d.ts +4 -3
- package/dist/router/router.d.ts +19 -162
- package/dist/router/store.d.ts +12 -0
- package/dist/router/types.d.ts +152 -0
- package/dist/router/utils.d.ts +99 -0
- package/dist/router/utils.test.d.ts +1 -0
- package/dist/router.js +428 -5
- package/dist/router.js.map +1 -1
- package/dist/signals-CMJPGr_M.js +354 -0
- package/dist/signals-CMJPGr_M.js.map +1 -0
- package/dist/translate/index.d.ts +82 -0
- package/dist/translate.js +125 -0
- package/dist/translate.js.map +1 -0
- package/dist/types.d.ts +21 -39
- package/dist/utils.d.ts +41 -29
- package/dist/utils.test.d.ts +1 -0
- package/dist/virtual/index.d.ts +1 -0
- package/dist/virtual/list.d.ts +53 -0
- package/package.json +19 -16
- package/dist/core/app.d.ts +0 -24
- package/dist/core/env.d.ts +0 -3
- package/dist/core/hooks.d.ts +0 -70
- package/dist/core/logger.d.ts +0 -42
- package/dist/core/logger.test.d.ts +0 -0
- package/dist/core/markup.d.ts +0 -82
- package/dist/core/markup.test.d.ts +0 -0
- package/dist/core/nodes/_markup.d.ts +0 -36
- package/dist/core/nodes/dynamic.d.ts +0 -22
- package/dist/core/nodes/element.d.ts +0 -27
- package/dist/core/nodes/portal.d.ts +0 -18
- package/dist/core/nodes/repeat.d.ts +0 -27
- package/dist/core/nodes/view.d.ts +0 -25
- package/dist/core/views/default-crash-view.d.ts +0 -25
- package/dist/core/views/for.d.ts +0 -21
- package/dist/core/views/fragment.d.ts +0 -7
- package/dist/core/views/portal.d.ts +0 -16
- package/dist/core/views/show.d.ts +0 -25
- package/dist/fragment-BahD_BJA.js +0 -7
- package/dist/fragment-BahD_BJA.js.map +0 -1
- package/dist/i18n/index.d.ts +0 -134
- package/dist/i18n.js +0 -309
- package/dist/i18n.js.map +0 -1
- package/dist/index-DRJlxs-Q.js +0 -535
- package/dist/index-DRJlxs-Q.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger-Aqi9m1CF.js +0 -565
- package/dist/logger-Aqi9m1CF.js.map +0 -1
- package/dist/markup-8jNhoqDe.js +0 -1089
- package/dist/markup-8jNhoqDe.js.map +0 -1
- package/dist/router/hooks.d.ts +0 -2
- package/dist/router/router.utils.d.ts +0 -93
- package/dist/typeChecking-5kmX0ulW.js +0 -65
- package/dist/typeChecking-5kmX0ulW.js.map +0 -1
- package/dist/typeChecking.d.ts +0 -95
- package/docs/buildless.md +0 -132
- package/docs/components.md +0 -238
- package/docs/hooks.md +0 -356
- package/docs/http.md +0 -178
- package/docs/i18n.md +0 -220
- package/docs/index.md +0 -10
- package/docs/markup.md +0 -136
- package/docs/mixins.md +0 -176
- package/docs/ref.md +0 -77
- package/docs/router.md +0 -281
- package/docs/setup.md +0 -137
- package/docs/signals.md +0 -262
- package/docs/stores.md +0 -113
- package/docs/views.md +0 -356
- package/notes/atomic.md +0 -452
- package/notes/elimination.md +0 -33
- package/notes/observable.md +0 -180
- package/notes/scratch.md +0 -565
- package/notes/splitting.md +0 -5
- package/notes/views.md +0 -195
- package/vite.config.js +0 -22
- /package/dist/core/{hooks.test.d.ts → markup/html.test.d.ts} +0 -0
- /package/dist/core/{ref.test.d.ts → markup/utils.test.d.ts} +0 -0
- /package/dist/router/{router.utils.test.d.ts → matcher.test.d.ts} +0 -0
- /package/dist/{typeChecking.test.d.ts → router/router.test.d.ts} +0 -0
package/dist/core/markup.d.ts
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import type { IntrinsicElements, Renderable, View } from "../types.js";
|
|
2
|
-
import { Context } from "./context.js";
|
|
3
|
-
import { MarkupNode } from "./nodes/_markup.js";
|
|
4
|
-
import { KeyFn, RenderFn } from "./nodes/repeat.js";
|
|
5
|
-
import { type Signal } from "./signals.js";
|
|
6
|
-
export { MarkupNode };
|
|
7
|
-
type PropsOf<V extends string | View<any>> = V extends View<infer U> ? U : any;
|
|
8
|
-
/**
|
|
9
|
-
* `Markup` is a set of metadata that will be constructed into a `MarkupNode`.
|
|
10
|
-
*/
|
|
11
|
-
export declare class Markup<Type extends string | View<any> = string | View<any>> {
|
|
12
|
-
/**
|
|
13
|
-
* 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.
|
|
14
|
-
* DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
|
|
15
|
-
*/
|
|
16
|
-
type: Type;
|
|
17
|
-
/**
|
|
18
|
-
* Data that will be passed to a new MarkupNode instance when it is constructed.
|
|
19
|
-
* Includes a `children` prop if children were passed.
|
|
20
|
-
*/
|
|
21
|
-
props: PropsOf<Type>;
|
|
22
|
-
constructor(type: Type, props: PropsOf<Type>);
|
|
23
|
-
}
|
|
24
|
-
export declare enum MarkupType {
|
|
25
|
-
DOM = "$dom",
|
|
26
|
-
Dynamic = "$dynamic",
|
|
27
|
-
Portal = "$portal",
|
|
28
|
-
Repeat = "$repeat"
|
|
29
|
-
}
|
|
30
|
-
export interface MarkupNodeProps {
|
|
31
|
-
[MarkupType.DOM]: {
|
|
32
|
-
value: Node;
|
|
33
|
-
};
|
|
34
|
-
[MarkupType.Dynamic]: {
|
|
35
|
-
source: Signal<any>;
|
|
36
|
-
};
|
|
37
|
-
[MarkupType.Portal]: {
|
|
38
|
-
content: Renderable;
|
|
39
|
-
parent: Element;
|
|
40
|
-
};
|
|
41
|
-
[MarkupType.Repeat]: {
|
|
42
|
-
items: Signal<any[]>;
|
|
43
|
-
key: KeyFn<any>;
|
|
44
|
-
render: RenderFn<any>;
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
export interface MarkupCustomElementProps {
|
|
48
|
-
/**
|
|
49
|
-
* Custom element tagName pattern (must include a hyphen).
|
|
50
|
-
*/
|
|
51
|
-
[tag: `${string}-${string}`]: Record<string, any>;
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Creates a `Markup` element that defines an HTML element.
|
|
55
|
-
*/
|
|
56
|
-
export declare function createMarkup<T extends keyof IntrinsicElements>(tag: T, attrs: IntrinsicElements[T] & {
|
|
57
|
-
children?: Renderable;
|
|
58
|
-
}): Markup;
|
|
59
|
-
/**
|
|
60
|
-
* Creates a `Markup` element that defines an HTML custom element.
|
|
61
|
-
*/
|
|
62
|
-
export declare function createMarkup<T extends keyof MarkupCustomElementProps>(type: T, props: MarkupCustomElementProps[T]): Markup;
|
|
63
|
-
/**
|
|
64
|
-
* Creates a `Markup` element that defines a `MarkupNode`.
|
|
65
|
-
*/
|
|
66
|
-
export declare function createMarkup<T extends keyof MarkupNodeProps>(type: T, props: MarkupNodeProps[T]): Markup;
|
|
67
|
-
/**
|
|
68
|
-
* Creates a `Markup` element that defines a view.
|
|
69
|
-
*/
|
|
70
|
-
export declare function createMarkup<P extends {}>(type: View<P>, props?: P): Markup;
|
|
71
|
-
/**
|
|
72
|
-
* Creates a `Markup` element that defines a view.
|
|
73
|
-
*/
|
|
74
|
-
export declare function createMarkup<P>(type: View<P>, props: P): Markup;
|
|
75
|
-
/**
|
|
76
|
-
* Takes any `Renderable` value and returns a `MarkupNode` that will display it.
|
|
77
|
-
*/
|
|
78
|
-
export declare function render(content: Renderable, context?: Context): MarkupNode;
|
|
79
|
-
/**
|
|
80
|
-
* Convert basically anything into a set of `MarkupNode`s.
|
|
81
|
-
*/
|
|
82
|
-
export declare function toMarkupNodes(context: Context, ...content: any[]): MarkupNode[];
|
|
File without changes
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A node that can be mounted by the Markup layout engine. Can be extended to create new custom node types.
|
|
3
|
-
*
|
|
4
|
-
* A `MarkupNode` instance can be passed anywhere a `Renderable` is required.
|
|
5
|
-
*/
|
|
6
|
-
export declare abstract class MarkupNode {
|
|
7
|
-
/**
|
|
8
|
-
* Returns a single DOM node to represent this MarkupNode's position in the DOM.
|
|
9
|
-
* Usually the parent element, but it can be an empty Text node used as a marker.
|
|
10
|
-
*
|
|
11
|
-
* It only needs to be defined while the node is mounted, so it can be created in the `mount` function.
|
|
12
|
-
*/
|
|
13
|
-
getRoot(): Node | undefined;
|
|
14
|
-
/**
|
|
15
|
-
* Returns true while this node is mounted.
|
|
16
|
-
*/
|
|
17
|
-
isMounted(): boolean;
|
|
18
|
-
/**
|
|
19
|
-
* Mount this node to a `parent` element.
|
|
20
|
-
* If passed, this node will be mounted as the next sibling of `after`.
|
|
21
|
-
*/
|
|
22
|
-
mount(parent: Element, after?: Node): void;
|
|
23
|
-
/**
|
|
24
|
-
* Unmount this MarkupNode from its parent element.
|
|
25
|
-
*
|
|
26
|
-
* The `skipDOM` option can be passed as an optimization when unmounting a parent node.
|
|
27
|
-
* A value of `true` indicates that no DOM operations need to happen because the parent is already being unmounted.
|
|
28
|
-
*
|
|
29
|
-
* @param skipDOM - No DOM updates will be performed when true. Lifecycle methods will be called regardless.
|
|
30
|
-
*/
|
|
31
|
-
unmount(skipDOM?: boolean): void;
|
|
32
|
-
/**
|
|
33
|
-
* Moves a node without unmounting and remounting (if the browser supports Element.moveBefore).
|
|
34
|
-
*/
|
|
35
|
-
move(parent: Element, after?: Node): void;
|
|
36
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { Context } from "../context.js";
|
|
2
|
-
import { type Signal } from "../signals.js";
|
|
3
|
-
import { MarkupNode } from "./_markup.js";
|
|
4
|
-
/**
|
|
5
|
-
* Renders any kind of content; markup, signals, DOM nodes, etc.
|
|
6
|
-
* If it can be rendered by Dolla then Dynamic will do it.
|
|
7
|
-
*/
|
|
8
|
-
export declare class DynamicNode extends MarkupNode {
|
|
9
|
-
private root;
|
|
10
|
-
private children;
|
|
11
|
-
private context;
|
|
12
|
-
private $slot;
|
|
13
|
-
private unsubscribe?;
|
|
14
|
-
constructor(context: Context, $slot: Signal<any>);
|
|
15
|
-
getRoot(): Text;
|
|
16
|
-
isMounted(): boolean;
|
|
17
|
-
mount(parent: Node, after?: Node): void;
|
|
18
|
-
unmount(skipDOM?: boolean): void;
|
|
19
|
-
move(parent: Element, after?: Node): void;
|
|
20
|
-
private cleanup;
|
|
21
|
-
private update;
|
|
22
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Context } from "../context.js";
|
|
2
|
-
import { MarkupNode } from "./_markup.js";
|
|
3
|
-
/**
|
|
4
|
-
* Renders an HTML or SVG element.
|
|
5
|
-
*/
|
|
6
|
-
export declare class ElementNode extends MarkupNode {
|
|
7
|
-
private root;
|
|
8
|
-
private id;
|
|
9
|
-
readonly tag: string;
|
|
10
|
-
readonly props: Record<string, any>;
|
|
11
|
-
private context;
|
|
12
|
-
private childNodes;
|
|
13
|
-
private unsubscribers;
|
|
14
|
-
private ref?;
|
|
15
|
-
private canClickAway;
|
|
16
|
-
constructor(context: Context, tag: string, props: Record<string, any>);
|
|
17
|
-
getRoot(): HTMLElement | SVGElement;
|
|
18
|
-
isMounted(): boolean;
|
|
19
|
-
mount(parent: Node, after?: Node): void;
|
|
20
|
-
unmount(skipDOM?: boolean): void;
|
|
21
|
-
move(parent: Element, after?: Node): void;
|
|
22
|
-
private attachProp;
|
|
23
|
-
private getKey;
|
|
24
|
-
private applyProps;
|
|
25
|
-
private applyStyles;
|
|
26
|
-
private applyClasses;
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { Renderable } from "../../types.js";
|
|
2
|
-
import { Context } from "../context.js";
|
|
3
|
-
import { MarkupNode } from "./_markup.js";
|
|
4
|
-
/**
|
|
5
|
-
* Renders content into a specified parent node.
|
|
6
|
-
*/
|
|
7
|
-
export declare class PortalNode extends MarkupNode {
|
|
8
|
-
private context;
|
|
9
|
-
private value;
|
|
10
|
-
private parent;
|
|
11
|
-
private node?;
|
|
12
|
-
constructor(context: Context, value: Renderable, parent: Element);
|
|
13
|
-
getRoot(): Node | undefined;
|
|
14
|
-
isMounted(): boolean;
|
|
15
|
-
mount(_parent: Element, _after?: Node): void;
|
|
16
|
-
unmount(skipDOM?: boolean): void;
|
|
17
|
-
move(_parent: Element, _after?: Node): void;
|
|
18
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { Renderable } from "../../types.js";
|
|
2
|
-
import type { Context } from "../context.js";
|
|
3
|
-
import { type Signal } from "../signals.js";
|
|
4
|
-
import { MarkupNode } from "./_markup.js";
|
|
5
|
-
export type Key = any;
|
|
6
|
-
export type KeyFn<T> = (item: T, index: number) => Key;
|
|
7
|
-
export type RenderFn<T> = (item: Signal<T>, index: Signal<number>) => Renderable;
|
|
8
|
-
/**
|
|
9
|
-
* Renders a list of items.
|
|
10
|
-
*/
|
|
11
|
-
export declare class RepeatNode<T> extends MarkupNode {
|
|
12
|
-
private root;
|
|
13
|
-
private context;
|
|
14
|
-
private items;
|
|
15
|
-
private key;
|
|
16
|
-
private render;
|
|
17
|
-
private unsubscribe;
|
|
18
|
-
private connectedItems;
|
|
19
|
-
constructor(context: Context, items: Signal<T[]>, key: KeyFn<T>, render: RenderFn<T>);
|
|
20
|
-
getRoot(): Text;
|
|
21
|
-
isMounted(): boolean;
|
|
22
|
-
mount(parent: Element, after?: Node): void;
|
|
23
|
-
unmount(skipDOM?: boolean): void;
|
|
24
|
-
move(parent: Element, after?: Node): void;
|
|
25
|
-
private _cleanup;
|
|
26
|
-
private _update;
|
|
27
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { View } from "../../types.js";
|
|
2
|
-
import { Context } from "../context.js";
|
|
3
|
-
import { MarkupNode } from "./_markup.js";
|
|
4
|
-
export declare const VIEW: unique symbol;
|
|
5
|
-
/**
|
|
6
|
-
* Renders a View.
|
|
7
|
-
*/
|
|
8
|
-
export declare class ViewNode<P> extends MarkupNode {
|
|
9
|
-
readonly id: string;
|
|
10
|
-
readonly props: P;
|
|
11
|
-
readonly context: Context;
|
|
12
|
-
readonly view: View<P>;
|
|
13
|
-
node?: MarkupNode;
|
|
14
|
-
/**
|
|
15
|
-
* @param context - Parent contenxt to link to.
|
|
16
|
-
* @param view - View function to mount.
|
|
17
|
-
* @param props - Props to pass to view function.
|
|
18
|
-
*/
|
|
19
|
-
constructor(context: Context, view: View<P>, props: P);
|
|
20
|
-
getRoot(): Node | undefined;
|
|
21
|
-
isMounted(): boolean;
|
|
22
|
-
mount(parent: Element, after?: Node): void;
|
|
23
|
-
unmount(skipDOM?: boolean): void;
|
|
24
|
-
move(parent: Element, after?: Node): void;
|
|
25
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Props passed to the crash view when a crash occurs.
|
|
3
|
-
*/
|
|
4
|
-
export interface CrashViewProps {
|
|
5
|
-
/**
|
|
6
|
-
* JavaScript Error object.
|
|
7
|
-
*/
|
|
8
|
-
error: Error;
|
|
9
|
-
/**
|
|
10
|
-
* A string to identify the logger that reported this error.
|
|
11
|
-
*/
|
|
12
|
-
loggerName: string;
|
|
13
|
-
/**
|
|
14
|
-
* Unique identifier to pinpoint the specific view that reported the crash.
|
|
15
|
-
*/
|
|
16
|
-
tag?: string;
|
|
17
|
-
/**
|
|
18
|
-
* Label for the tag.
|
|
19
|
-
*/
|
|
20
|
-
tagName?: string;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* The crash view displayed unless you specify your own.
|
|
24
|
-
*/
|
|
25
|
-
export declare function DefaultCrashView(props: CrashViewProps): import("../markup.js").Markup<string | import("../index.js").View<any>>;
|
package/dist/core/views/for.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type Key, RenderFn, RepeatNode } from "../nodes/repeat";
|
|
2
|
-
import { type MaybeSignal } from "../signals";
|
|
3
|
-
export interface ForProps<T> {
|
|
4
|
-
/**
|
|
5
|
-
* An array of items to render.
|
|
6
|
-
*/
|
|
7
|
-
each: MaybeSignal<T[]>;
|
|
8
|
-
/**
|
|
9
|
-
* A function to extract a unique key that identifies each item.
|
|
10
|
-
* If no `key` function is passed, object identity (===) will be used.
|
|
11
|
-
*/
|
|
12
|
-
key?: (item: T, index: number) => Key;
|
|
13
|
-
/**
|
|
14
|
-
* A render function. Takes the item and its index in signal form and returns something to display for each item.
|
|
15
|
-
*/
|
|
16
|
-
children: RenderFn<T>;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
export declare function For<T>(props: ForProps<T>): RepeatNode<T>;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { Renderable } from "../../types";
|
|
2
|
-
import { Markup, MarkupType } from "../markup";
|
|
3
|
-
export interface PortalProps {
|
|
4
|
-
/**
|
|
5
|
-
* The parent element or a selector that will match it.
|
|
6
|
-
*/
|
|
7
|
-
into: Element | string;
|
|
8
|
-
/**
|
|
9
|
-
* Content to render inside the `into` element.
|
|
10
|
-
*/
|
|
11
|
-
children: Renderable;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Render content into any element on the page.
|
|
15
|
-
*/
|
|
16
|
-
export declare function Portal(props: PortalProps): Markup<MarkupType.Portal>;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { Renderable } from "../../types";
|
|
2
|
-
import { DynamicNode } from "../nodes/dynamic";
|
|
3
|
-
import { type MaybeSignal } from "../signals";
|
|
4
|
-
export interface ShowProps {
|
|
5
|
-
/**
|
|
6
|
-
* If present, children will be rendered only when this signal holds a truthy value.
|
|
7
|
-
*/
|
|
8
|
-
when?: MaybeSignal<any>;
|
|
9
|
-
/**
|
|
10
|
-
* If present, children will be rendered only when this signal holds a falsy value.
|
|
11
|
-
*/
|
|
12
|
-
unless?: MaybeSignal<any>;
|
|
13
|
-
/**
|
|
14
|
-
* Content to render if conditions permit.
|
|
15
|
-
*/
|
|
16
|
-
children: Renderable;
|
|
17
|
-
/**
|
|
18
|
-
* Content to render when conditions don't permit `children` to render.
|
|
19
|
-
*/
|
|
20
|
-
fallback?: Renderable;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Conditionally display children.
|
|
24
|
-
*/
|
|
25
|
-
export declare function Show(props: ShowProps): DynamicNode;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fragment-BahD_BJA.js","sources":["../src/core/views/fragment.ts"],"sourcesContent":["import type { Renderable } from \"../../types.js\";\n\n/**\n * A utility view that displays its children.\n */\nexport function Fragment(props: { children?: Renderable }) {\n return props.children;\n}\n"],"names":["Fragment","props"],"mappings":"AAKO,SAASA,EAASC,GAAkC;AACzD,SAAOA,EAAM;AACf;"}
|
package/dist/i18n/index.d.ts
DELETED
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { type MaybeSignal, type Signal } from "../core/signals.js";
|
|
2
|
-
/**
|
|
3
|
-
* A JSON object of translated strings. Values can be string templates or nested objects.
|
|
4
|
-
*/
|
|
5
|
-
interface LocalizedStrings extends Record<string, string | LocalizedStrings> {
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* A formatter to be applied to a variable.
|
|
9
|
-
*/
|
|
10
|
-
type Format = {
|
|
11
|
-
name: string;
|
|
12
|
-
options: Record<string, any>;
|
|
13
|
-
};
|
|
14
|
-
export interface TranslationConfig {
|
|
15
|
-
/**
|
|
16
|
-
* Name of the locale this translation is for (BCP 47 locale names recommended).
|
|
17
|
-
*/
|
|
18
|
-
locale: string;
|
|
19
|
-
/**
|
|
20
|
-
* An object with translated strings for this language.
|
|
21
|
-
*/
|
|
22
|
-
strings?: LocalizedStrings;
|
|
23
|
-
/**
|
|
24
|
-
* A callback function that returns a Promise that resolves to the translation object for this language.
|
|
25
|
-
*/
|
|
26
|
-
fetch?: () => Promise<LocalizedStrings>;
|
|
27
|
-
/**
|
|
28
|
-
* Path to a JSON file with translated strings for this language.
|
|
29
|
-
*/
|
|
30
|
-
path?: string;
|
|
31
|
-
}
|
|
32
|
-
export type I18nSetupOptions = {
|
|
33
|
-
/**
|
|
34
|
-
* Default locale to load on startup
|
|
35
|
-
*/
|
|
36
|
-
locale?: string | null;
|
|
37
|
-
translations: TranslationConfig[];
|
|
38
|
-
};
|
|
39
|
-
export type TOptions = {
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
*/
|
|
43
|
-
count?: MaybeSignal<number>;
|
|
44
|
-
/**
|
|
45
|
-
*
|
|
46
|
-
*/
|
|
47
|
-
context?: MaybeSignal<string>;
|
|
48
|
-
/**
|
|
49
|
-
* Override formats specified in the template with the ones in the array for each named variable.
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* t("example_key", {
|
|
53
|
-
* count: 5,
|
|
54
|
-
* formatOverrides: {
|
|
55
|
-
* count: [ { name: "datetime", options: { style: "currency", currency: "JPY" } } ]
|
|
56
|
-
* }
|
|
57
|
-
* });
|
|
58
|
-
*/
|
|
59
|
-
formatOverrides?: MaybeSignal<Record<string, Record<string, Format[]>>>;
|
|
60
|
-
[value: string]: MaybeSignal<any>;
|
|
61
|
-
};
|
|
62
|
-
export type Formatter = (locale: string, value: unknown, options: Record<string, any>) => string;
|
|
63
|
-
/**
|
|
64
|
-
* Dolla's I(nternationalizatio)n module. Manages language translations and locale-based formatting.
|
|
65
|
-
*/
|
|
66
|
-
declare class I18n {
|
|
67
|
-
#private;
|
|
68
|
-
readonly $locale: Signal<string>;
|
|
69
|
-
constructor();
|
|
70
|
-
get locales(): string[];
|
|
71
|
-
setup(options: I18nSetupOptions): Promise<void>;
|
|
72
|
-
setLocale(name: string): Promise<void>;
|
|
73
|
-
/**
|
|
74
|
-
* Returns a State containing the value at `key`.
|
|
75
|
-
|
|
76
|
-
* @param selector - Key to the translated value.
|
|
77
|
-
* @param options - A map of `{{placeholder}}` names and the values to replace them with.
|
|
78
|
-
*
|
|
79
|
-
* @example
|
|
80
|
-
* const $value = t("your.key.here", { count: 5 });
|
|
81
|
-
*/
|
|
82
|
-
t(selector: string, options?: TOptions): Signal<string>;
|
|
83
|
-
/**
|
|
84
|
-
* Add a custom format callback.
|
|
85
|
-
*
|
|
86
|
-
* @example
|
|
87
|
-
* Dolla.i18n.addFormat("uppercase", (locale, value, options) => {
|
|
88
|
-
* return value.toUpperCase();
|
|
89
|
-
* });
|
|
90
|
-
*
|
|
91
|
-
* {
|
|
92
|
-
* "greeting": "Hello, {{name|uppercase}}!"
|
|
93
|
-
* }
|
|
94
|
-
*
|
|
95
|
-
* t("greeting", {name: "world"}); // State<"Hello, WORLD!">
|
|
96
|
-
*/
|
|
97
|
-
addFormat(name: string, callback: (locale: string, value: unknown, options: Record<string, any>) => string): void;
|
|
98
|
-
/**
|
|
99
|
-
* Creates an `Intl.Collator` configured for the current locale.
|
|
100
|
-
* NOTE: The locale is tracked if called within a signal tracking context.
|
|
101
|
-
*
|
|
102
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/Collator#options
|
|
103
|
-
*/
|
|
104
|
-
collator(options?: Intl.CollatorOptions): Intl.Collator;
|
|
105
|
-
/**
|
|
106
|
-
* Formats a number for the current locale. Uses `Intl.NumberFormat` under the hood.
|
|
107
|
-
*
|
|
108
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#options
|
|
109
|
-
*/
|
|
110
|
-
number(count: MaybeSignal<number | bigint>, options?: Intl.NumberFormatOptions): Signal<string>;
|
|
111
|
-
/**
|
|
112
|
-
* Formats a date for the current locale. Uses `Intl.DateTimeFormat` under the hood.
|
|
113
|
-
*
|
|
114
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options
|
|
115
|
-
*
|
|
116
|
-
* @example
|
|
117
|
-
* const date = new Date();
|
|
118
|
-
* const $formatted = Dolla.i18n.dateTime(date, { dateFormat: "short" });
|
|
119
|
-
*/
|
|
120
|
-
dateTime(date?: MaybeSignal<string | number | Date | undefined>, options?: Intl.DateTimeFormatOptions): Signal<string>;
|
|
121
|
-
/**
|
|
122
|
-
* Formats a list for the current locale. Uses `Intl.ListFormat` under the hood.
|
|
123
|
-
*
|
|
124
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/DateTimeFormat/DateTimeFormat#options
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* const list = new Date();
|
|
128
|
-
* const $formatted = Dolla.i18n.list(list, { });
|
|
129
|
-
*/
|
|
130
|
-
list(list: MaybeSignal<Iterable<string>>, options?: Intl.ListFormatOptions): Signal<string>;
|
|
131
|
-
}
|
|
132
|
-
export declare const i18n: I18n;
|
|
133
|
-
export declare const t: (selector: string, options?: TOptions) => Signal<string>;
|
|
134
|
-
export {};
|