@manyducks.co/dolla 2.0.0-alpha.21 → 2.0.0-alpha.23

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 (43) hide show
  1. package/dist/{modules/render.d.ts → core/batch.d.ts} +4 -1
  2. package/dist/{modules → core}/dolla.d.ts +25 -9
  3. package/dist/{markup.d.ts → core/markup.d.ts} +6 -6
  4. package/dist/{nodes → core/nodes}/cond.d.ts +4 -2
  5. package/dist/{nodes → core/nodes}/html.d.ts +2 -0
  6. package/dist/{nodes → core/nodes}/observer.d.ts +4 -1
  7. package/dist/core/nodes/outlet.d.ts +18 -0
  8. package/dist/{nodes → core/nodes}/portal.d.ts +4 -2
  9. package/dist/{nodes → core/nodes}/repeat.d.ts +5 -3
  10. package/dist/{nodes → core/nodes}/text.d.ts +2 -0
  11. package/dist/{view.d.ts → core/nodes/view.d.ts} +8 -6
  12. package/dist/{state.d.ts → core/state.d.ts} +3 -4
  13. package/dist/core/symbols.d.ts +5 -0
  14. package/dist/index.d.ts +9 -8
  15. package/dist/index.js +670 -1038
  16. package/dist/index.js.map +1 -1
  17. package/dist/jsx-dev-runtime.d.ts +2 -2
  18. package/dist/jsx-dev-runtime.js +2 -2
  19. package/dist/jsx-dev-runtime.js.map +1 -1
  20. package/dist/jsx-runtime.d.ts +3 -3
  21. package/dist/jsx-runtime.js +2 -2
  22. package/dist/jsx-runtime.js.map +1 -1
  23. package/dist/modules/http.d.ts +2 -0
  24. package/dist/modules/i18n.d.ts +2 -2
  25. package/dist/modules/router.d.ts +27 -48
  26. package/dist/{passthrough-6Lrg96Id.js → passthrough-C9975ULD.js} +636 -576
  27. package/dist/passthrough-C9975ULD.js.map +1 -0
  28. package/dist/typeChecking.d.ts +2 -2
  29. package/dist/types.d.ts +2 -2
  30. package/dist/utils.d.ts +14 -1
  31. package/dist/views/default-crash-view.d.ts +1 -1
  32. package/dist/views/passthrough.d.ts +2 -2
  33. package/docs/http.md +16 -0
  34. package/docs/router.md +19 -0
  35. package/index.d.ts +2 -2
  36. package/notes/TODO.md +6 -0
  37. package/notes/scratch.md +2 -2
  38. package/package.json +3 -6
  39. package/vite.config.js +0 -10
  40. package/dist/nodes/outlet.d.ts +0 -22
  41. package/dist/passthrough-6Lrg96Id.js.map +0 -1
  42. /package/dist/{routing.d.ts → modules/router.utils.d.ts} +0 -0
  43. /package/dist/{routing.test.d.ts → modules/router.utils.test.d.ts} +0 -0
@@ -1,2 +1,2 @@
1
- export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): import("./markup.ts").Markup;
2
- export { Passthrough as Fragment } from "./views/passthrough.ts";
1
+ export function jsxDEV(element: any, props: any, key: any, isStaticChildren: any, source: any, self: any): import("./core/markup").Markup;
2
+ export { Passthrough as Fragment } from "./views/passthrough";
@@ -1,5 +1,5 @@
1
- import { s } from "./passthrough-6Lrg96Id.js";
2
- import { P as m } from "./passthrough-6Lrg96Id.js";
1
+ import { w as s } from "./passthrough-C9975ULD.js";
2
+ import { P as m } from "./passthrough-C9975ULD.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);
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-dev-runtime.js","sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createMarkup } from \"./markup.ts\";\nexport { Passthrough as Fragment } from \"./views/passthrough.ts\";\n\nexport function jsxDEV(element, props, key, isStaticChildren, source, self) {\n const attributes = { ...omit([\"children\", \"key\"], props) };\n const children = Array.isArray(props.children) ? props.children : [props.children];\n\n return createMarkup(element, attributes, ...children);\n}\n\nfunction omit(keys, object) {\n const result = {};\n for (const key in object) {\n if (!keys.includes(key)) {\n result[key] = object[key];\n }\n }\n return result;\n}\n"],"names":["jsxDEV","element","props","key","isStaticChildren","source","self","attributes","omit","children","createMarkup","keys","object","result"],"mappings":";;AAGO,SAASA,EAAOC,GAASC,GAAOC,GAAKC,GAAkBC,GAAQC,GAAM;AAC1E,QAAMC,IAAa,EAAE,GAAGC,EAAK,CAAC,YAAY,KAAK,GAAGN,CAAK,EAAG,GACpDO,IAAW,MAAM,QAAQP,EAAM,QAAQ,IAAIA,EAAM,WAAW,CAACA,EAAM,QAAQ;AAEjF,SAAOQ,EAAaT,GAASM,GAAY,GAAGE,CAAQ;AACtD;AAEA,SAASD,EAAKG,GAAMC,GAAQ;AAC1B,QAAMC,IAAS,CAAE;AACjB,aAAWV,KAAOS;AAChB,IAAKD,EAAK,SAASR,CAAG,MACpBU,EAAOV,CAAG,IAAIS,EAAOT,CAAG;AAG5B,SAAOU;AACT;"}
1
+ {"version":3,"file":"jsx-dev-runtime.js","sources":["../src/jsx-dev-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup\";\nexport { Passthrough as Fragment } from \"./views/passthrough\";\n\nexport function jsxDEV(element, props, key, isStaticChildren, source, self) {\n const attributes = { ...omit([\"children\", \"key\"], props) };\n const children = Array.isArray(props.children) ? props.children : [props.children];\n\n return createMarkup(element, attributes, ...children);\n}\n\nfunction omit(keys, object) {\n const result = {};\n for (const key in object) {\n if (!keys.includes(key)) {\n result[key] = object[key];\n }\n }\n return result;\n}\n"],"names":["jsxDEV","element","props","key","isStaticChildren","source","self","attributes","omit","children","createMarkup","keys","object","result"],"mappings":";;AAGO,SAASA,EAAOC,GAASC,GAAOC,GAAKC,GAAkBC,GAAQC,GAAM;AAC1E,QAAMC,IAAa,EAAE,GAAGC,EAAK,CAAC,YAAY,KAAK,GAAGN,CAAK,EAAG,GACpDO,IAAW,MAAM,QAAQP,EAAM,QAAQ,IAAIA,EAAM,WAAW,CAACA,EAAM,QAAQ;AAEjF,SAAOQ,EAAaT,GAASM,GAAY,GAAGE,CAAQ;AACtD;AAEA,SAASD,EAAKG,GAAMC,GAAQ;AAC1B,QAAMC,IAAS,CAAE;AACjB,aAAWV,KAAOS;AAChB,IAAKD,EAAK,SAASR,CAAG,MACpBU,EAAOV,CAAG,IAAIS,EAAOT,CAAG;AAG5B,SAAOU;AACT;"}
@@ -1,9 +1,9 @@
1
1
  /**
2
2
  * JSX function for elements with dynamic children.
3
3
  */
4
- export function jsx(element: any, props: any, key: any): import("./markup.ts").Markup;
4
+ export function jsx(element: any, props: any, key: any): import("./core/markup").Markup;
5
5
  /**
6
6
  * JSX function for elements with static children.
7
7
  */
8
- export function jsxs(element: any, props: any, key: any): import("./markup.ts").Markup;
9
- export { Passthrough as Fragment } from "./views/passthrough.ts";
8
+ export function jsxs(element: any, props: any, key: any): import("./core/markup").Markup;
9
+ export { Passthrough as Fragment } from "./views/passthrough";
@@ -1,5 +1,5 @@
1
- import { s as t } from "./passthrough-6Lrg96Id.js";
2
- import { P as l } from "./passthrough-6Lrg96Id.js";
1
+ import { w as t } from "./passthrough-C9975ULD.js";
2
+ import { P as l } from "./passthrough-C9975ULD.js";
3
3
  function d(n, e, r) {
4
4
  return t(n, e ? { ...u(["children", "key"], e) } : void 0, e.children);
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.js"],"sourcesContent":["import { createMarkup } from \"./markup.ts\";\nexport { Passthrough as Fragment } from \"./views/passthrough.ts\";\n\n/**\n * JSX function for elements with dynamic children.\n */\nexport function jsx(element, props, key) {\n return createMarkup(element, props ? { ...omit([\"children\", \"key\"], props) } : undefined, ...[props.children]);\n}\n\n/**\n * JSX function for elements with static children.\n */\nexport function jsxs(element, props, key) {\n return createMarkup(element, props ? { ...omit([\"children\", \"key\"], props) } : undefined, props.children);\n}\n\nfunction omit(keys, object) {\n const result = {};\n for (const key in object) {\n if (!keys.includes(key)) {\n result[key] = object[key];\n }\n }\n return result;\n}\n"],"names":["jsx","element","props","key","createMarkup","omit","jsxs","keys","object","result"],"mappings":";;AAMO,SAASA,EAAIC,GAASC,GAAOC,GAAK;AACvC,SAAOC,EAAaH,GAASC,IAAQ,EAAE,GAAGG,EAAK,CAAC,YAAY,KAAK,GAAGH,CAAK,EAAC,IAAK,QAAeA,EAAM,QAAS;AAC/G;AAKO,SAASI,EAAKL,GAASC,GAAOC,GAAK;AACxC,SAAOC,EAAaH,GAASC,IAAQ,EAAE,GAAGG,EAAK,CAAC,YAAY,KAAK,GAAGH,CAAK,EAAC,IAAK,QAAWA,EAAM,QAAQ;AAC1G;AAEA,SAASG,EAAKE,GAAMC,GAAQ;AAC1B,QAAMC,IAAS,CAAE;AACjB,aAAWN,KAAOK;AAChB,IAAKD,EAAK,SAASJ,CAAG,MACpBM,EAAON,CAAG,IAAIK,EAAOL,CAAG;AAG5B,SAAOM;AACT;"}
1
+ {"version":3,"file":"jsx-runtime.js","sources":["../src/jsx-runtime.js"],"sourcesContent":["import { createMarkup } from \"./core/markup\";\nexport { Passthrough as Fragment } from \"./views/passthrough\";\n\n/**\n * JSX function for elements with dynamic children.\n */\nexport function jsx(element, props, key) {\n return createMarkup(element, props ? { ...omit([\"children\", \"key\"], props) } : undefined, ...[props.children]);\n}\n\n/**\n * JSX function for elements with static children.\n */\nexport function jsxs(element, props, key) {\n return createMarkup(element, props ? { ...omit([\"children\", \"key\"], props) } : undefined, props.children);\n}\n\nfunction omit(keys, object) {\n const result = {};\n for (const key in object) {\n if (!keys.includes(key)) {\n result[key] = object[key];\n }\n }\n return result;\n}\n"],"names":["jsx","element","props","key","createMarkup","omit","jsxs","keys","object","result"],"mappings":";;AAMO,SAASA,EAAIC,GAASC,GAAOC,GAAK;AACvC,SAAOC,EAAaH,GAASC,IAAQ,EAAE,GAAGG,EAAK,CAAC,YAAY,KAAK,GAAGH,CAAK,EAAC,IAAK,QAAeA,EAAM,QAAS;AAC/G;AAKO,SAASI,EAAKL,GAASC,GAAOC,GAAK;AACxC,SAAOC,EAAaH,GAASC,IAAQ,EAAE,GAAGG,EAAK,CAAC,YAAY,KAAK,GAAGH,CAAK,EAAC,IAAK,QAAWA,EAAM,QAAQ;AAC1G;AAEA,SAASG,EAAKE,GAAMC,GAAQ;AAC1B,QAAMC,IAAS,CAAE;AACjB,aAAWN,KAAOK;AAChB,IAAKD,EAAK,SAASJ,CAAG,MACpBM,EAAON,CAAG,IAAIK,EAAOL,CAAG;AAG5B,SAAOM;AACT;"}
@@ -1,9 +1,11 @@
1
+ import type { Dolla } from "../core/dolla.js";
1
2
  /**
2
3
  * A simple HTTP client with middleware support. Middleware applies to all requests made through this store,
3
4
  * so it's the perfect way to handle things like auth headers and permission checks for API calls.
4
5
  */
5
6
  export declare class HTTP {
6
7
  #private;
8
+ constructor(dolla: Dolla);
7
9
  /**
8
10
  * Adds a new middleware that will apply to subsequent requests.
9
11
  * Returns a function to remove this middleware.
@@ -1,5 +1,5 @@
1
- import { type MaybeState, type State } from "../state.js";
2
- import type { Dolla } from "./dolla.js";
1
+ import type { Dolla } from "../core/dolla.js";
2
+ import { type MaybeState, type State } from "../core/state.js";
3
3
  /**
4
4
  * A JSON object of translated strings. Values can be string templates or nested objects.
5
5
  */
@@ -1,6 +1,6 @@
1
- import { type Stringable } from "../types.js";
2
- import { type ViewElement, type ViewFunction } from "../view.js";
3
- import type { Dolla } from "./dolla.js";
1
+ import type { Dolla } from "../core/dolla.js";
2
+ import type { ViewFunction } from "../core/nodes/view.js";
3
+ import type { Stringable } from "../types.js";
4
4
  export interface RouteMatchContext {
5
5
  /**
6
6
  * Redirects the user to a different route instead of matching the current one.
@@ -29,14 +29,15 @@ export interface Route {
29
29
  */
30
30
  beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
31
31
  }
32
+ export interface RouteMeta {
33
+ redirect?: string | ((ctx: RouteRedirectContext) => string) | ((ctx: RouteRedirectContext) => Promise<string>);
34
+ pattern?: string;
35
+ layers?: RouteLayer[];
36
+ beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
37
+ }
32
38
  export interface RouteConfig {
33
39
  pattern: string;
34
- meta: {
35
- redirect?: string | ((ctx: RouteRedirectContext) => string) | ((ctx: RouteRedirectContext) => Promise<string>);
36
- pattern?: string;
37
- layers?: RouteLayer[];
38
- beforeMatch?: (ctx: RouteMatchContext) => void | Promise<void>;
39
- };
40
+ meta: RouteMeta;
40
41
  }
41
42
  export interface RouteLayer {
42
43
  id: number;
@@ -63,11 +64,6 @@ export interface RouteRedirectContext {
63
64
  */
64
65
  query: Record<string, string | number | boolean | undefined>;
65
66
  }
66
- interface ParsedParams {
67
- [key: string]: string | number | boolean | (string | number | boolean | null)[] | null;
68
- }
69
- interface ParsedQuery extends ParsedParams {
70
- }
71
67
  export interface NavigateOptions {
72
68
  /**
73
69
  * Replace the current item in the history stack instead of adding a new one.
@@ -79,57 +75,33 @@ export interface NavigateOptions {
79
75
  */
80
76
  preserveQuery?: boolean;
81
77
  }
82
- export declare enum RoutingStyle {
83
- /**
84
- * Constructs routes like "https://www.example.com/#/sub/route" which work without any server-side setup.
85
- * A good choice if your app has no backend.
86
- */
87
- hash = "hash",
88
- /**
89
- * Constructs routes like "https://www.example.com/sub/route" which look nicer (subjective?) than hash routes and are what most users will expect URLs to look like, but require additional backend setup.
90
- * Path routing requires you to configure your backend to redirect to the app's index.html when subpaths are requested.
91
- */
92
- path = "path"
93
- }
94
- export interface RouterSetupOptions {
78
+ export interface RouterOptions {
95
79
  routes: Route[];
96
80
  /**
97
- * The routing style to use; "hash" will construct routes like "https://www.example.com/#/sub/route" which work without any server-side setup, while "path" will construct routes that use paths directly.
81
+ * When true, the router will construct routes like "https://www.example.com/#/sub/route" which work without any backend intervention.
98
82
  */
99
- style?: RoutingStyle;
100
- }
101
- export interface RouterElements {
102
- readonly rootElement?: HTMLElement;
103
- readonly rootView?: ViewElement;
83
+ hash?: boolean;
104
84
  }
105
85
  export declare class Router {
106
86
  #private;
107
87
  /**
108
88
  * The currently matched route pattern, if any.
109
89
  */
110
- $pattern: import("../state.js").State<string | null>;
90
+ $pattern: import("../core/state.js").State<string | undefined>;
111
91
  /**
112
92
  * The current URL path.
113
93
  */
114
- $path: import("../state.js").State<string>;
94
+ $path: import("../core/state.js").State<string>;
115
95
  /**
116
96
  * The current named path params.
117
97
  */
118
- $params: import("../state.js").State<ParsedParams>;
98
+ $params: import("../core/state.js").State<Record<string, string | number>>;
119
99
  /**
120
100
  * The current query params. Changes to this object will be reflected in the URL.
121
101
  */
122
- $query: import("../state.js").State<ParsedQuery>;
123
- constructor(dolla: Dolla, elements: RouterElements);
124
- setup(options: RouterSetupOptions): void;
125
- /**
126
- * Navigates to another route.
127
- *
128
- * @example
129
- * Dolla.router.go("/login"); // navigate to `/login`
130
- * Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
131
- */
132
- go(path: Stringable | Stringable[], options?: NavigateOptions): void;
102
+ $query: import("../core/state.js").State<Record<string, string | number | boolean>>;
103
+ constructor(dolla: Dolla);
104
+ setup(options: RouterOptions): Promise<void>;
133
105
  /**
134
106
  * Navigate backward. Pass a number of steps to hit the back button that many times.
135
107
  */
@@ -138,6 +110,14 @@ export declare class Router {
138
110
  * Navigate forward. Pass a number of steps to hit the forward button that many times.
139
111
  */
140
112
  forward(steps?: number): void;
113
+ /**
114
+ * Navigates to another route.
115
+ *
116
+ * @example
117
+ * Dolla.router.go("/login"); // navigate to `/login`
118
+ * Dolla.router.go["/users", 215], { replace: true }); // replace current history entry with `/users/215`
119
+ */
120
+ go(path: Stringable | Stringable[], options?: NavigateOptions): void;
141
121
  }
142
122
  /**
143
123
  * Intercepts links within the root node.
@@ -149,4 +129,3 @@ export declare class Router {
149
129
  * @param _window - (optional) Override for global window object
150
130
  */
151
131
  export declare function catchLinks(root: HTMLElement, callback: (anchor: HTMLAnchorElement) => void, _window?: Window & typeof globalThis): () => void;
152
- export {};