@manyducks.co/dolla 2.0.0-alpha.4 → 2.0.0-alpha.40

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 (75) hide show
  1. package/README.md +31 -964
  2. package/dist/core/context.d.ts +53 -0
  3. package/dist/{modules → core}/dolla.d.ts +43 -26
  4. package/dist/core/markup.d.ts +90 -0
  5. package/dist/core/nodes/dom.d.ts +13 -0
  6. package/dist/core/nodes/dynamic.d.ts +28 -0
  7. package/dist/core/nodes/html.d.ts +33 -0
  8. package/dist/core/nodes/list.d.ts +28 -0
  9. package/dist/core/nodes/outlet.d.ts +19 -0
  10. package/dist/core/nodes/portal.d.ts +22 -0
  11. package/dist/core/nodes/view.d.ts +78 -0
  12. package/dist/core/ref.d.ts +28 -0
  13. package/dist/core/signals.d.ts +125 -0
  14. package/dist/core/store.d.ts +52 -0
  15. package/dist/core/symbols.d.ts +4 -0
  16. package/dist/{views → core/views}/passthrough.d.ts +1 -1
  17. package/dist/{modules/http.d.ts → http/index.d.ts} +3 -5
  18. package/dist/index.d.ts +14 -11
  19. package/dist/index.js +986 -1216
  20. package/dist/index.js.map +1 -1
  21. package/dist/jsx-dev-runtime.d.ts +2 -2
  22. package/dist/jsx-dev-runtime.js +2 -2
  23. package/dist/jsx-dev-runtime.js.map +1 -1
  24. package/dist/jsx-runtime.d.ts +3 -3
  25. package/dist/jsx-runtime.js +2 -2
  26. package/dist/jsx-runtime.js.map +1 -1
  27. package/dist/markup-DIfh0nwz.js +1442 -0
  28. package/dist/markup-DIfh0nwz.js.map +1 -0
  29. package/dist/{modules/router.d.ts → router/index.d.ts} +37 -48
  30. package/dist/router/router.utils.test.d.ts +1 -0
  31. package/dist/translate/index.d.ts +133 -0
  32. package/dist/typeChecking.d.ts +2 -98
  33. package/dist/typeChecking.test.d.ts +1 -0
  34. package/dist/types.d.ts +12 -14
  35. package/dist/utils.d.ts +18 -3
  36. package/docs/http.md +29 -0
  37. package/docs/i18n.md +38 -0
  38. package/docs/index.md +10 -0
  39. package/docs/router.md +80 -0
  40. package/docs/setup.md +31 -0
  41. package/docs/signals.md +149 -0
  42. package/docs/state.md +141 -0
  43. package/docs/stores.md +62 -0
  44. package/docs/views.md +208 -0
  45. package/index.d.ts +2 -2
  46. package/notes/TODO.md +6 -0
  47. package/notes/atomic.md +146 -0
  48. package/notes/context-routes.md +56 -0
  49. package/notes/context-vars.md +21 -0
  50. package/notes/elimination.md +33 -0
  51. package/notes/readme-scratch.md +244 -0
  52. package/notes/route-middleware.md +42 -0
  53. package/notes/scratch.md +330 -7
  54. package/notes/stores.md +53 -0
  55. package/package.json +14 -10
  56. package/vite.config.js +5 -10
  57. package/build.js +0 -34
  58. package/dist/markup.d.ts +0 -100
  59. package/dist/modules/language.d.ts +0 -41
  60. package/dist/modules/render.d.ts +0 -17
  61. package/dist/nodes/cond.d.ts +0 -26
  62. package/dist/nodes/html.d.ts +0 -31
  63. package/dist/nodes/observer.d.ts +0 -29
  64. package/dist/nodes/outlet.d.ts +0 -22
  65. package/dist/nodes/portal.d.ts +0 -19
  66. package/dist/nodes/repeat.d.ts +0 -34
  67. package/dist/nodes/text.d.ts +0 -19
  68. package/dist/passthrough-BSLd3foL.js +0 -1245
  69. package/dist/passthrough-BSLd3foL.js.map +0 -1
  70. package/dist/signals.d.ts +0 -101
  71. package/dist/view.d.ts +0 -50
  72. package/tests/signals.test.js +0 -135
  73. /package/dist/{routing.test.d.ts → core/signals.test.d.ts} +0 -0
  74. /package/dist/{views → core/views}/default-crash-view.d.ts +0 -0
  75. /package/dist/{routing.d.ts → router/router.utils.d.ts} +0 -0
@@ -0,0 +1,52 @@
1
+ import type { StoreConsumerContext, ComponentContext, ElementContext } from "./context.js";
2
+ import type { Logger } from "./dolla.js";
3
+ import { EffectCallback, UnsubscribeFunction } from "./signals.js";
4
+ export type StoreFunction<Options, Value> = (this: StoreContext, options: Options, context: StoreContext) => Value;
5
+ export type StoreFactory<Options, Value> = Options extends undefined ? () => Store<Options, Value> : (options: Options) => Store<Options, Value>;
6
+ export interface StoreContext extends Omit<Logger, "setName">, ComponentContext, StoreConsumerContext {
7
+ /**
8
+ * True while this store is attached to a context that is currently mounted in the view tree.
9
+ */
10
+ readonly isMounted: boolean;
11
+ /**
12
+ * Registers a callback to run just after this store is mounted.
13
+ */
14
+ onMount(callback: () => void): void;
15
+ /**
16
+ * Registers a callback to run just after this store is unmounted.
17
+ */
18
+ onUnmount(callback: () => void): void;
19
+ /**
20
+ * Passes a getter function to `callback` that will track reactive states and return their current values.
21
+ * Callback will be run each time a tracked state gets a new value.
22
+ */
23
+ effect(callback: EffectCallback): UnsubscribeFunction;
24
+ }
25
+ export declare class Store<Options, Value> {
26
+ readonly fn: StoreFunction<Options, Value>;
27
+ private _options;
28
+ /**
29
+ * Value is guaranteed to be set after `attach` is called.
30
+ */
31
+ value: Value;
32
+ isMounted: boolean;
33
+ elementContext: ElementContext;
34
+ lifecycleListeners: {
35
+ mount: (() => any)[];
36
+ unmount: (() => any)[];
37
+ };
38
+ logger: Logger;
39
+ id: string;
40
+ name: string;
41
+ constructor(fn: StoreFunction<Options, Value>, options: Options);
42
+ /**
43
+ * Attaches this Store to the elementContext.
44
+ * Returns false if there was already an instance attached, and true otherwise.
45
+ */
46
+ attach(elementContext: ElementContext): boolean;
47
+ handleMount(): void;
48
+ handleUnmount(): void;
49
+ }
50
+ export declare function isStore<Options, Value>(value: any): value is Store<Options, Value>;
51
+ export declare class StoreError extends Error {
52
+ }
@@ -0,0 +1,4 @@
1
+ export declare const IS_MARKUP: unique symbol;
2
+ export declare const IS_MARKUP_ELEMENT: unique symbol;
3
+ export declare const IS_STORE: unique symbol;
4
+ export declare const IS_ROUTER: unique symbol;
@@ -1,4 +1,4 @@
1
- import { type ViewContext } from "../view.js";
1
+ import { type ViewContext } from "../nodes/view.js";
2
2
  /**
3
3
  * A utility view that simply displays its children.
4
4
  */
@@ -37,18 +37,16 @@ export interface RequestOptions<ReqBody> {
37
37
  }
38
38
  export interface HTTPRequest<Body> {
39
39
  method: string;
40
- uri: string;
41
- readonly sameOrigin: boolean;
40
+ url: URL;
42
41
  headers: Headers;
43
- query: URLSearchParams;
44
42
  body: Body;
45
43
  }
46
44
  export interface HTTPResponse<Body> {
47
45
  method: string;
48
- uri: string;
46
+ url: URL;
47
+ headers: Headers;
49
48
  status: number;
50
49
  statusText: string;
51
- headers: Record<string, string>;
52
50
  body: Body;
53
51
  }
54
52
  export declare class HTTPResponseError extends Error {
package/dist/index.d.ts CHANGED
@@ -1,15 +1,19 @@
1
- export { createSettableSignal, createSignal, createSignalSetter, derive, designalify, signalify, toSettableSignal, watch, } from "./signals.js";
2
- export type { MaybeSignal, SettableSignal, Signal, StopFunction } from "./signals.js";
3
- import { Dolla } from "./modules/dolla.js";
1
+ export { atom, compose, effect, get, set, peek } from "./core/signals.js";
2
+ export type { Reactive, MaybeReactive, Atom } from "./core/signals.js";
3
+ export { deepEqual, shallowEqual, strictEqual } from "./utils.js";
4
+ export { ref, type Ref } from "./core/ref.js";
5
+ export { type StoreFunction, type StoreContext } from "./core/store.js";
6
+ export { createRouter, type Router, type RouterOptions } from "./router/index.js";
7
+ export { cond, createMarkup, html, portal, list } from "./core/markup.js";
8
+ export type { Markup, MarkupElement } from "./core/markup.js";
9
+ import { Dolla } from "./core/dolla.js";
4
10
  declare const dolla: Dolla;
5
- export declare const t: (key: string, values?: Record<string, import("./types.js").Stringable | import("./signals.js").Signal<import("./types.js").Stringable>>) => import("./signals.js").Signal<string>;
6
- export { html, cond, createMarkup, portal, repeat, createRef, isRef } from "./markup.js";
7
- export type { Markup, MarkupNode, Ref } from "./markup.js";
8
- export type { ViewFunction, ViewContext, ViewNode } from "./view.js";
9
- export type { CrashViewProps } from "./views/default-crash-view.js";
11
+ export default dolla;
12
+ export declare const t: (selector: string, options?: import("./translate/index.js").TOptions) => import("./core/signals.js").Reactive<string>;
13
+ export type { Dolla, Environment, Logger, LoggerErrorContext, LoggerOptions, Loggles } from "./core/dolla.js";
14
+ export type { ViewContext, ViewElement, ViewFunction } from "./core/nodes/view.js";
10
15
  export type { InputType, Renderable } from "./types.js";
11
- export type { Environment } from "./modules/dolla.js";
12
- export type { HTTPRequest, HTTPResponse } from "./modules/http.js";
16
+ export type { CrashViewProps } from "./core/views/default-crash-view.js";
13
17
  import type { IntrinsicElements as Elements } from "./types";
14
18
  declare global {
15
19
  namespace JSX {
@@ -18,4 +22,3 @@ declare global {
18
22
  }
19
23
  }
20
24
  }
21
- export default dolla;