@manyducks.co/dolla 0.67.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 +643 -0
- package/build.js +34 -0
- package/index.d.ts +12 -0
- package/jsx-dev-runtime.d.ts +1 -0
- package/jsx-runtime.d.ts +1 -0
- package/lib/app.d.ts +138 -0
- package/lib/classes/CrashCollector.d.ts +30 -0
- package/lib/classes/DebugHub.d.ts +60 -0
- package/lib/index.d.ts +23 -0
- package/lib/index.js +4062 -0
- package/lib/index.js.map +7 -0
- package/lib/jsx/jsx-dev-runtime.d.ts +3 -0
- package/lib/jsx/jsx-dev-runtime.js +20 -0
- package/lib/jsx/jsx-dev-runtime.js.map +7 -0
- package/lib/jsx/jsx-runtime.d.ts +10 -0
- package/lib/jsx/jsx-runtime.js +22 -0
- package/lib/jsx/jsx-runtime.js.map +7 -0
- package/lib/markup.d.ts +81 -0
- package/lib/nodes/cond.d.ts +28 -0
- package/lib/nodes/html.d.ts +30 -0
- package/lib/nodes/observer.d.ts +33 -0
- package/lib/nodes/outlet.d.ts +26 -0
- package/lib/nodes/portal.d.ts +22 -0
- package/lib/nodes/repeat.d.ts +36 -0
- package/lib/nodes/text.d.ts +20 -0
- package/lib/spring.d.ts +40 -0
- package/lib/state.d.ts +84 -0
- package/lib/store.d.ts +67 -0
- package/lib/stores/dialog.d.ts +30 -0
- package/lib/stores/document.d.ts +10 -0
- package/lib/stores/http.d.ts +60 -0
- package/lib/stores/language.d.ts +39 -0
- package/lib/stores/render.d.ts +18 -0
- package/lib/stores/router.d.ts +118 -0
- package/lib/testing/classes/MockHTTP.d.ts +10 -0
- package/lib/testing/index.d.ts +4 -0
- package/lib/testing/makeMockDOMNode.d.ts +10 -0
- package/lib/testing/makeMockFetch.d.ts +36 -0
- package/lib/testing/makeMockFetch.test.d.ts +1 -0
- package/lib/testing/stores/dialog.d.ts +6 -0
- package/lib/testing/stores/http.d.ts +13 -0
- package/lib/testing/stores/page.d.ts +7 -0
- package/lib/testing/stores/router.d.ts +12 -0
- package/lib/testing/wrapStore.d.ts +8 -0
- package/lib/testing/wrapStore.test.d.ts +1 -0
- package/lib/testing/wrapView.d.ts +0 -0
- package/lib/types.d.ts +3388 -0
- package/lib/utils.d.ts +14 -0
- package/lib/view.d.ts +80 -0
- package/lib/views/fragment.d.ts +2 -0
- package/lib/views/store-scope.d.ts +10 -0
- package/package.json +56 -0
- package/tests/state.test.js +290 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Readable } from "../state.js";
|
|
2
|
+
import { type StoreContext } from "../store.js";
|
|
3
|
+
import { type Stringable } from "../types.js";
|
|
4
|
+
/**
|
|
5
|
+
* An object where values are either a translated string or another nested Translation object.
|
|
6
|
+
*/
|
|
7
|
+
type Translation = Record<string, string | Record<string, string | Record<string, string | Record<string, string>>>>;
|
|
8
|
+
export interface LanguageConfig {
|
|
9
|
+
/**
|
|
10
|
+
* The translated strings for this language, or a callback function that returns them.
|
|
11
|
+
*/
|
|
12
|
+
translation: Translation | (() => Translation) | (() => Promise<Translation>);
|
|
13
|
+
}
|
|
14
|
+
type LanguageOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Languages supported by the app (as added with App.language())
|
|
17
|
+
*/
|
|
18
|
+
languages: {
|
|
19
|
+
[tag: string]: LanguageConfig;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Default language to load on startup
|
|
23
|
+
*/
|
|
24
|
+
currentLanguage?: string;
|
|
25
|
+
};
|
|
26
|
+
export declare function LanguageStore(ctx: StoreContext<LanguageOptions>): {
|
|
27
|
+
$isLoaded: Readable<boolean>;
|
|
28
|
+
$currentLanguage: Readable<string | undefined>;
|
|
29
|
+
supportedLanguages: string[];
|
|
30
|
+
setLanguage(tag: string): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a Readable of the translated value.
|
|
33
|
+
|
|
34
|
+
* @param key - Key to the translated value.
|
|
35
|
+
* @param values - A map of {{placeholder}} names and the values to replace them with.
|
|
36
|
+
*/
|
|
37
|
+
translate(key: string, values?: Record<string, Stringable | Readable<Stringable>>): Readable<string>;
|
|
38
|
+
};
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type StoreContext } from "../store.js";
|
|
2
|
+
/**
|
|
3
|
+
* Batches DOM updates for better performance.
|
|
4
|
+
*/
|
|
5
|
+
export declare function RenderStore(ctx: StoreContext): {
|
|
6
|
+
/**
|
|
7
|
+
* Queues a callback to run in the next render batch.
|
|
8
|
+
* Running your DOM mutations in update callbacks reduces layout thrashing.
|
|
9
|
+
* Returns a Promise that resolves once the callback has run.
|
|
10
|
+
*/
|
|
11
|
+
update(callback: () => void, key?: string): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Queues a callback that reads DOM information to run after the next render batch,
|
|
14
|
+
* ensuring all writes have been performed before reading.
|
|
15
|
+
* Returns a Promise that resolves once the callback has run.
|
|
16
|
+
*/
|
|
17
|
+
read(callback: () => void): Promise<void>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { type Route } from "@borf/bedrock";
|
|
2
|
+
import { type History } from "history";
|
|
3
|
+
import { type Stringable } from "../types.js";
|
|
4
|
+
import { type Markup } from "../markup.js";
|
|
5
|
+
import { type StoreContext } from "../store.js";
|
|
6
|
+
export interface RouterOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Use hash-based routing if true.
|
|
9
|
+
*/
|
|
10
|
+
hash?: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A history object from the `history` package.
|
|
13
|
+
*
|
|
14
|
+
* @see https://www.npmjs.com/package/history
|
|
15
|
+
*/
|
|
16
|
+
history?: History;
|
|
17
|
+
}
|
|
18
|
+
export interface RouteConfig {
|
|
19
|
+
pattern: string;
|
|
20
|
+
meta: {
|
|
21
|
+
redirect?: string | ((ctx: RedirectContext) => void);
|
|
22
|
+
pattern?: string;
|
|
23
|
+
layers?: RouteLayer[];
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export interface RouteLayer {
|
|
27
|
+
id: number;
|
|
28
|
+
markup: Markup;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Properties passed to a redirect function.
|
|
32
|
+
*/
|
|
33
|
+
export interface RedirectContext {
|
|
34
|
+
/**
|
|
35
|
+
* The path as it appears in the URL bar.
|
|
36
|
+
*/
|
|
37
|
+
path: string;
|
|
38
|
+
/**
|
|
39
|
+
* The pattern that this path was matched with.
|
|
40
|
+
*/
|
|
41
|
+
pattern: string;
|
|
42
|
+
/**
|
|
43
|
+
* Named route params parsed from `path`.
|
|
44
|
+
*/
|
|
45
|
+
params: Record<string, string | number | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* Query params parsed from `path`.
|
|
48
|
+
*/
|
|
49
|
+
query: Record<string, string | number | boolean | undefined>;
|
|
50
|
+
}
|
|
51
|
+
interface ParsedParams {
|
|
52
|
+
[key: string]: string | number | boolean | (string | number | boolean | null)[] | null;
|
|
53
|
+
}
|
|
54
|
+
interface ParsedQuery extends ParsedParams {
|
|
55
|
+
}
|
|
56
|
+
interface NavigateOptions {
|
|
57
|
+
/**
|
|
58
|
+
* Replace the current item in the history stack instead of adding a new one.
|
|
59
|
+
* The back button will send the user to the page they visited before this.
|
|
60
|
+
*/
|
|
61
|
+
replace?: boolean;
|
|
62
|
+
}
|
|
63
|
+
interface RouterStoreOptions extends RouterOptions {
|
|
64
|
+
/**
|
|
65
|
+
* An instance of Router with the app's routes preloaded.
|
|
66
|
+
*/
|
|
67
|
+
routes: Route<RouteConfig["meta"]>[];
|
|
68
|
+
}
|
|
69
|
+
export declare function RouterStore(ctx: StoreContext<RouterStoreOptions>): {
|
|
70
|
+
/**
|
|
71
|
+
* The currently matched route pattern, if any.
|
|
72
|
+
*/
|
|
73
|
+
$pattern: import("../state.js").Readable<string | null>;
|
|
74
|
+
/**
|
|
75
|
+
* The current URL path.
|
|
76
|
+
*/
|
|
77
|
+
$path: import("../state.js").Readable<string>;
|
|
78
|
+
/**
|
|
79
|
+
* The current named path params.
|
|
80
|
+
*/
|
|
81
|
+
$params: import("../state.js").Readable<ParsedParams>;
|
|
82
|
+
/**
|
|
83
|
+
* The current query params. Changes to this object will be reflected in the URL.
|
|
84
|
+
*/
|
|
85
|
+
$$query: import("../state.js").Writable<ParsedQuery>;
|
|
86
|
+
/**
|
|
87
|
+
* Navigate backward. Pass a number of steps to hit the back button that many times.
|
|
88
|
+
*/
|
|
89
|
+
back(steps?: number): void;
|
|
90
|
+
/**
|
|
91
|
+
* Navigate forward. Pass a number of steps to hit the forward button that many times.
|
|
92
|
+
*/
|
|
93
|
+
forward(steps?: number): void;
|
|
94
|
+
/**
|
|
95
|
+
* Navigates to another route.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* navigate("/login"); // navigate to `/login`
|
|
99
|
+
* navigate(["/users", 215], { replace: true }); // replace current history entry with `/users/215`
|
|
100
|
+
*
|
|
101
|
+
* @param args - One or more path segments optionally followed by an options object.
|
|
102
|
+
*/
|
|
103
|
+
navigate: {
|
|
104
|
+
(path: Stringable, options?: NavigateOptions): void;
|
|
105
|
+
(fragments: Stringable[], options?: NavigateOptions): void;
|
|
106
|
+
};
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Intercepts links within the root node.
|
|
110
|
+
*
|
|
111
|
+
* This is adapted from https://github.com/choojs/nanohref/blob/master/index.js
|
|
112
|
+
*
|
|
113
|
+
* @param root - Element under which to intercept link clicks
|
|
114
|
+
* @param callback - Function to call when a click event is intercepted
|
|
115
|
+
* @param _window - (optional) Override for global window object
|
|
116
|
+
*/
|
|
117
|
+
export declare function catchLinks(root: HTMLElement, callback: (anchor: HTMLAnchorElement) => void, _window?: Window & typeof globalThis): () => void;
|
|
118
|
+
export {};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a `fetch`-compatible function that responds with its own mock handlers.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* import { makeMockFetch } from "woofe/testing";
|
|
6
|
+
*
|
|
7
|
+
* // Create a mock HTTP instance
|
|
8
|
+
* const fetch = makeMockFetch((on) => {
|
|
9
|
+
* on.get("/example/route", (ctx) => {
|
|
10
|
+
* // Respond with JSON
|
|
11
|
+
* return {
|
|
12
|
+
* message: "success"
|
|
13
|
+
* }
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* on.put("/users/:id", (ctx) => {
|
|
17
|
+
* ctx.response.status = 200;
|
|
18
|
+
*
|
|
19
|
+
* return {
|
|
20
|
+
* message: `user ${ctx.request.params.id} updated`
|
|
21
|
+
* }
|
|
22
|
+
* });
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* fetch("/example/route")
|
|
26
|
+
* .then(res => res.json())
|
|
27
|
+
* .then(json => {
|
|
28
|
+
* console.log(json.message); // "success"
|
|
29
|
+
* });
|
|
30
|
+
*/
|
|
31
|
+
export function makeMockFetch(fn: any): {
|
|
32
|
+
(url: any, options?: {}): Promise<any>;
|
|
33
|
+
mock: {
|
|
34
|
+
calls: any[];
|
|
35
|
+
};
|
|
36
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps a store in a test adapter that lets you call its lifecycle methods and access its exports.
|
|
3
|
+
* You can pass any 'stores' or 'inputs' this store relies on through the config object.
|
|
4
|
+
*/
|
|
5
|
+
export function wrapStore(store: any, config?: {}): Promise<{
|
|
6
|
+
exports: any;
|
|
7
|
+
teardown(): Promise<void>;
|
|
8
|
+
}>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|