@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.
Files changed (53) hide show
  1. package/README.md +643 -0
  2. package/build.js +34 -0
  3. package/index.d.ts +12 -0
  4. package/jsx-dev-runtime.d.ts +1 -0
  5. package/jsx-runtime.d.ts +1 -0
  6. package/lib/app.d.ts +138 -0
  7. package/lib/classes/CrashCollector.d.ts +30 -0
  8. package/lib/classes/DebugHub.d.ts +60 -0
  9. package/lib/index.d.ts +23 -0
  10. package/lib/index.js +4062 -0
  11. package/lib/index.js.map +7 -0
  12. package/lib/jsx/jsx-dev-runtime.d.ts +3 -0
  13. package/lib/jsx/jsx-dev-runtime.js +20 -0
  14. package/lib/jsx/jsx-dev-runtime.js.map +7 -0
  15. package/lib/jsx/jsx-runtime.d.ts +10 -0
  16. package/lib/jsx/jsx-runtime.js +22 -0
  17. package/lib/jsx/jsx-runtime.js.map +7 -0
  18. package/lib/markup.d.ts +81 -0
  19. package/lib/nodes/cond.d.ts +28 -0
  20. package/lib/nodes/html.d.ts +30 -0
  21. package/lib/nodes/observer.d.ts +33 -0
  22. package/lib/nodes/outlet.d.ts +26 -0
  23. package/lib/nodes/portal.d.ts +22 -0
  24. package/lib/nodes/repeat.d.ts +36 -0
  25. package/lib/nodes/text.d.ts +20 -0
  26. package/lib/spring.d.ts +40 -0
  27. package/lib/state.d.ts +84 -0
  28. package/lib/store.d.ts +67 -0
  29. package/lib/stores/dialog.d.ts +30 -0
  30. package/lib/stores/document.d.ts +10 -0
  31. package/lib/stores/http.d.ts +60 -0
  32. package/lib/stores/language.d.ts +39 -0
  33. package/lib/stores/render.d.ts +18 -0
  34. package/lib/stores/router.d.ts +118 -0
  35. package/lib/testing/classes/MockHTTP.d.ts +10 -0
  36. package/lib/testing/index.d.ts +4 -0
  37. package/lib/testing/makeMockDOMNode.d.ts +10 -0
  38. package/lib/testing/makeMockFetch.d.ts +36 -0
  39. package/lib/testing/makeMockFetch.test.d.ts +1 -0
  40. package/lib/testing/stores/dialog.d.ts +6 -0
  41. package/lib/testing/stores/http.d.ts +13 -0
  42. package/lib/testing/stores/page.d.ts +7 -0
  43. package/lib/testing/stores/router.d.ts +12 -0
  44. package/lib/testing/wrapStore.d.ts +8 -0
  45. package/lib/testing/wrapStore.test.d.ts +1 -0
  46. package/lib/testing/wrapView.d.ts +0 -0
  47. package/lib/types.d.ts +3388 -0
  48. package/lib/utils.d.ts +14 -0
  49. package/lib/view.d.ts +80 -0
  50. package/lib/views/fragment.d.ts +2 -0
  51. package/lib/views/store-scope.d.ts +10 -0
  52. package/package.json +56 -0
  53. 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,10 @@
1
+ export class MockHTTP {
2
+ static label: string;
3
+ setup(ctx: any): any;
4
+ respond(to: any): void;
5
+ beforeConnect(): Promise<void>;
6
+ afterConnect(): void;
7
+ beforeDisconnect(): Promise<void>;
8
+ afterDisconnect(): void;
9
+ #private;
10
+ }
@@ -0,0 +1,4 @@
1
+ export { wrapStore } from "./wrapStore.js";
2
+ export { makeMockDOMNode } from "./makeMockDOMNode.js";
3
+ export { makeMockFetch } from "./makeMockFetch.js";
4
+ export { MockHTTP } from "./classes/MockHTTP.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Creates a mock DOM node for testing.
3
+ */
4
+ export function makeMockDOMNode(): {
5
+ isDOM: boolean;
6
+ parentNode: null;
7
+ insertBefore: any;
8
+ removeChild: any;
9
+ children: never[];
10
+ };
@@ -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,6 @@
1
+ export class MockDialogStore {
2
+ static label: string;
3
+ setup(ctx: any): {
4
+ makeDialog(...args: any[]): void;
5
+ };
6
+ }
@@ -0,0 +1,13 @@
1
+ export class MockHTTPStore {
2
+ static label: string;
3
+ setup(ctx: any): {
4
+ request: () => void;
5
+ use: () => void;
6
+ get: () => void;
7
+ put: () => void;
8
+ patch: () => void;
9
+ post: () => void;
10
+ delete: () => void;
11
+ head: () => void;
12
+ };
13
+ }
@@ -0,0 +1,7 @@
1
+ export class MockPageStore {
2
+ static label: string;
3
+ setup(ctx: any): {
4
+ $$title: any;
5
+ $visibility: any;
6
+ };
7
+ }
@@ -0,0 +1,12 @@
1
+ export class MockRouterStore {
2
+ static label: string;
3
+ setup(ctx: any): {
4
+ $path: any;
5
+ $route: any;
6
+ $params: any;
7
+ $$query: any;
8
+ back(): void;
9
+ forward(): void;
10
+ navigate(): void;
11
+ };
12
+ }
@@ -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