@manyducks.co/dolla 2.0.0-alpha.6 → 2.0.0-alpha.60

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 (104) hide show
  1. package/README.md +86 -591
  2. package/dist/core/context.d.ts +144 -0
  3. package/dist/core/env.d.ts +3 -0
  4. package/dist/core/index.d.ts +22 -0
  5. package/dist/core/logger.d.ts +42 -0
  6. package/dist/core/markup.d.ts +125 -0
  7. package/dist/core/mount.d.ts +15 -0
  8. package/dist/core/nodes/dom.d.ts +14 -0
  9. package/dist/core/nodes/dynamic.d.ts +29 -0
  10. package/dist/core/nodes/html.d.ts +24 -0
  11. package/dist/core/nodes/portal.d.ts +19 -0
  12. package/dist/core/nodes/repeat.d.ts +25 -0
  13. package/dist/core/nodes/view.d.ts +24 -0
  14. package/dist/core/ref.d.ts +18 -0
  15. package/dist/core/signals.d.ts +43 -0
  16. package/dist/core/symbols.d.ts +2 -0
  17. package/dist/{views → core/views}/default-crash-view.d.ts +6 -2
  18. package/dist/core/views/fragment.d.ts +7 -0
  19. package/dist/fragment-BahD_BJA.js +7 -0
  20. package/dist/fragment-BahD_BJA.js.map +1 -0
  21. package/dist/{modules/http.d.ts → http/index.d.ts} +3 -5
  22. package/dist/http.js +163 -0
  23. package/dist/http.js.map +1 -0
  24. package/dist/i18n/index.d.ts +134 -0
  25. package/dist/i18n.js +318 -0
  26. package/dist/i18n.js.map +1 -0
  27. package/dist/index.js +105 -1385
  28. package/dist/index.js.map +1 -1
  29. package/dist/jsx-dev-runtime.d.ts +3 -2
  30. package/dist/jsx-dev-runtime.js +5 -12
  31. package/dist/jsx-dev-runtime.js.map +1 -1
  32. package/dist/jsx-runtime.d.ts +4 -3
  33. package/dist/jsx-runtime.js +9 -15
  34. package/dist/jsx-runtime.js.map +1 -1
  35. package/dist/logger-MPwl-Xqu.js +524 -0
  36. package/dist/logger-MPwl-Xqu.js.map +1 -0
  37. package/dist/markup-BGlfQYQk.js +996 -0
  38. package/dist/markup-BGlfQYQk.js.map +1 -0
  39. package/dist/router/index.d.ts +2 -0
  40. package/dist/router/router.d.ts +149 -0
  41. package/dist/{routing.d.ts → router/router.utils.d.ts} +17 -3
  42. package/dist/router/router.utils.test.d.ts +1 -0
  43. package/dist/router-BpuJQ6OA.js +516 -0
  44. package/dist/router-BpuJQ6OA.js.map +1 -0
  45. package/dist/router.js +8 -0
  46. package/dist/router.js.map +1 -0
  47. package/dist/typeChecking-CbltMOUt.js +71 -0
  48. package/dist/typeChecking-CbltMOUt.js.map +1 -0
  49. package/dist/typeChecking.d.ts +2 -98
  50. package/dist/typeChecking.test.d.ts +1 -0
  51. package/dist/types.d.ts +98 -25
  52. package/dist/utils.d.ts +20 -3
  53. package/docs/http.md +29 -0
  54. package/docs/i18n.md +43 -0
  55. package/docs/index.md +10 -0
  56. package/docs/markup.md +16 -0
  57. package/docs/mixins.md +32 -0
  58. package/docs/ref.md +93 -0
  59. package/docs/router.md +80 -0
  60. package/docs/setup.md +31 -0
  61. package/docs/signals.md +166 -0
  62. package/docs/state.md +141 -0
  63. package/docs/stores.md +62 -0
  64. package/docs/views.md +208 -0
  65. package/examples/webcomponent/index.html +14 -0
  66. package/examples/webcomponent/main.js +165 -0
  67. package/index.d.ts +2 -2
  68. package/notes/TODO.md +6 -0
  69. package/notes/atomic.md +452 -0
  70. package/notes/context-routes.md +61 -0
  71. package/notes/custom-nodes.md +17 -0
  72. package/notes/effection-idea.md +34 -0
  73. package/notes/elimination.md +33 -0
  74. package/notes/mixins.md +22 -0
  75. package/notes/molecule.md +35 -0
  76. package/notes/observable.md +180 -0
  77. package/notes/readme-scratch.md +45 -7
  78. package/notes/route-middleware.md +42 -0
  79. package/notes/scratch.md +353 -6
  80. package/notes/splitting.md +5 -0
  81. package/notes/stores.md +79 -0
  82. package/package.json +27 -12
  83. package/vite.config.js +5 -11
  84. package/build.js +0 -34
  85. package/dist/index.d.ts +0 -21
  86. package/dist/markup.d.ts +0 -100
  87. package/dist/modules/dolla.d.ts +0 -111
  88. package/dist/modules/language.d.ts +0 -41
  89. package/dist/modules/render.d.ts +0 -17
  90. package/dist/modules/router.d.ts +0 -152
  91. package/dist/nodes/cond.d.ts +0 -26
  92. package/dist/nodes/html.d.ts +0 -31
  93. package/dist/nodes/observer.d.ts +0 -29
  94. package/dist/nodes/outlet.d.ts +0 -22
  95. package/dist/nodes/portal.d.ts +0 -19
  96. package/dist/nodes/repeat.d.ts +0 -34
  97. package/dist/nodes/text.d.ts +0 -19
  98. package/dist/passthrough-CW8Ezjg-.js +0 -1244
  99. package/dist/passthrough-CW8Ezjg-.js.map +0 -1
  100. package/dist/state.d.ts +0 -101
  101. package/dist/view.d.ts +0 -50
  102. package/dist/views/passthrough.d.ts +0 -5
  103. package/tests/state.test.js +0 -135
  104. /package/dist/{routing.test.d.ts → core/signals.test.d.ts} +0 -0
@@ -0,0 +1,144 @@
1
+ import type { Store } from "../types";
2
+ import { type Logger, type LoggerOptions } from "./logger";
3
+ import { type EffectFn, type MaybeSignal, type UnsubscribeFn } from "./signals";
4
+ export declare enum LifecycleEvent {
5
+ WILL_MOUNT = 0,
6
+ DID_MOUNT = 1,
7
+ WILL_UNMOUNT = 2,
8
+ DID_UNMOUNT = 3,
9
+ DISPOSE = 4
10
+ }
11
+ type LifecycleListener = () => void;
12
+ declare enum LifecycleState {
13
+ Unmounted = 0,
14
+ WillMount = 1,
15
+ DidMount = 2,
16
+ WillUnmount = 3,
17
+ DidUnmount = 4,
18
+ Disposed = 5
19
+ }
20
+ declare const NAME: unique symbol;
21
+ declare const LIFECYCLE: unique symbol;
22
+ declare const PARENT: unique symbol;
23
+ declare const STORES: unique symbol;
24
+ declare const STATE: unique symbol;
25
+ /**
26
+ * Manages lifecycle events for a Context.
27
+ */
28
+ declare class ContextLifecycle {
29
+ private context;
30
+ state: LifecycleState;
31
+ listeners: Map<LifecycleEvent, Set<LifecycleListener>>;
32
+ bound?: Set<Context>;
33
+ constructor(context: Context);
34
+ /**
35
+ * Listen for a certain event to be emitted. Listeners are called when the event results in a state change.
36
+ */
37
+ on<E extends LifecycleEvent>(event: E, listener: LifecycleListener): void;
38
+ /**
39
+ * Stop a particular listener from being called when an event is emitted.
40
+ */
41
+ off<E extends LifecycleEvent>(event: E, listener: LifecycleListener): void;
42
+ /**
43
+ * Advance the lifecycle state machine.
44
+ */
45
+ emit<E extends LifecycleEvent>(event: E): void;
46
+ /**
47
+ * Bind `context` to this lifecycle; when any event is emitted here it will be emitted for `context` as well.
48
+ */
49
+ bind(context: Context): void;
50
+ /**
51
+ * Call all the event's listeners and re-emit to bound contexts.
52
+ */
53
+ private notify;
54
+ }
55
+ export interface ContextOptions {
56
+ logger?: LoggerOptions;
57
+ }
58
+ export interface LinkedContextOptions extends ContextOptions {
59
+ bindLifecycleToParent?: boolean;
60
+ }
61
+ export interface Context extends Logger {
62
+ }
63
+ export declare class Context implements Logger {
64
+ #private;
65
+ [NAME]: string;
66
+ [LIFECYCLE]: ContextLifecycle;
67
+ [PARENT]?: Context;
68
+ [STORES]?: Map<Store<any, any>, any>;
69
+ [STATE]?: Map<any, any>;
70
+ get isMounted(): boolean;
71
+ /**
72
+ * Returns a new Context with this one as its parent.
73
+ */
74
+ static linked(parent: Context, name: MaybeSignal<string>, options?: LinkedContextOptions): Context;
75
+ /**
76
+ * Emit a lifecycle event to `context`.
77
+ */
78
+ static emit(context: Context, event: LifecycleEvent): void;
79
+ /**
80
+ * Traverses _parent contexts until arriving at one that doesn't have a parent itself.
81
+ * Returns null if this context is the parent.
82
+ */
83
+ static getRoot(context: Context): Context | null;
84
+ constructor(name: MaybeSignal<string>, options?: ContextOptions);
85
+ /**
86
+ * Returns the current name of this context.
87
+ */
88
+ getName(): string;
89
+ /**
90
+ * Sets a new name for this context.
91
+ */
92
+ setName(name: MaybeSignal<string>): void;
93
+ /**
94
+ * Creates an instance of a store and attaches it to this context.
95
+ */
96
+ addStore<T>(store: Store<any, T>, options?: any): this;
97
+ /**
98
+ * Retrieves the nearest instance of `store`. If this context doesn't have it, the parent context is checked. This process continues until either:
99
+ * 1. An instance of the store is found and returned.
100
+ * 2. No instance is found and an error is thrown.
101
+ */
102
+ getStore<T>(store: Store<any, T>): T;
103
+ /**
104
+ * Schedule a callback function to run just before this context is mounted.
105
+ */
106
+ beforeMount(listener: LifecycleListener): () => void;
107
+ /**
108
+ * Schedule a callback function to run after this context is mounted.
109
+ */
110
+ onMount(listener: LifecycleListener): () => void;
111
+ /**
112
+ * Schedule a callback function to run just before this context is unmounted.
113
+ */
114
+ beforeUnmount(listener: LifecycleListener): () => void;
115
+ /**
116
+ * Schedule a callback function to run after this context is unmounted.
117
+ */
118
+ onUnmount(listener: LifecycleListener): () => void;
119
+ effect(callback: EffectFn): UnsubscribeFn;
120
+ /**
121
+ * Gets the value stored at `key`, or returns the `defaultValue` if none is set.
122
+ */
123
+ getState<T>(key: any, defaultValue: T): T;
124
+ /**
125
+ * Gets the value stored at `key`, or throws an error if none is set.
126
+ */
127
+ getState<T>(key: any): T;
128
+ /**
129
+ * Returns a Map containing all state values available to this context.
130
+ */
131
+ getState(): Map<any, any>;
132
+ /**
133
+ * Stores `value` at `key` in this context's state.
134
+ */
135
+ setState<T>(key: any, value: T): void;
136
+ /**
137
+ * For each tuple in `entries`, stores `value` at `key` in this context's state.
138
+ */
139
+ setState(entries: [key: any, value: any][]): void;
140
+ }
141
+ export declare function createContext(name: MaybeSignal<string>, options?: ContextOptions): Context;
142
+ export declare class StoreError extends Error {
143
+ }
144
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { Env } from "../types";
2
+ export declare function getEnv(): string;
3
+ export declare function setEnv(value: Env): void;
@@ -0,0 +1,22 @@
1
+ export { $, effect, get, untracked, batch } from "./signals.js";
2
+ export type { MaybeSignal, Signal, Source } from "./signals.js";
3
+ export { createContext } from "./context.js";
4
+ export type { Context } from "./context.js";
5
+ export { m, portal, render, repeat, unless, when } from "./markup.js";
6
+ export type { MarkupNode } from "./markup.js";
7
+ export { ref, type Ref } from "./ref.js";
8
+ export { mount, type UnmountFn } from "./mount.js";
9
+ export { deepEqual, shallowEqual, strictEqual } from "../utils.js";
10
+ export { getEnv, setEnv } from "./env.js";
11
+ export { createLogger, setLogFilter, setLogLevels, onLoggerCrash } from "./logger.js";
12
+ export type { Logger, LoggerCrashProps, LoggerOptions, LogLevels } from "./logger.js";
13
+ export type { View, Store, Mixin, InputType, Renderable, Env, CSSProperties } from "../types.js";
14
+ export type { CrashViewProps } from "./views/default-crash-view.js";
15
+ import type { IntrinsicElements as Elements } from "../types.js";
16
+ declare global {
17
+ namespace JSX {
18
+ interface IntrinsicElements extends Elements {
19
+ [tag: string]: any;
20
+ }
21
+ }
22
+ }
@@ -0,0 +1,42 @@
1
+ import type { Env } from "../types.js";
2
+ import { type MaybeSignal } from "./signals.js";
3
+ export interface LogLevels {
4
+ info: boolean | Env;
5
+ log: boolean | Env;
6
+ warn: boolean | Env;
7
+ error: boolean | Env;
8
+ }
9
+ export interface Logger {
10
+ info(...args: any[]): void;
11
+ log(...args: any[]): void;
12
+ warn(...args: any[]): void;
13
+ error(...args: any[]): void;
14
+ crash(error: Error): Error;
15
+ }
16
+ export interface LoggerOptions {
17
+ /**
18
+ * Tag value to print with logs.
19
+ */
20
+ tag?: string;
21
+ /**
22
+ * Label for tag value. Will be printed without a label if not specified.
23
+ */
24
+ tagName?: string;
25
+ /**
26
+ * Console object to use for logging (mostly for testing). Uses window.console by default.
27
+ */
28
+ console?: any;
29
+ }
30
+ export interface LoggerCrashProps {
31
+ error: Error;
32
+ loggerName: string;
33
+ tag?: string;
34
+ tagName?: string;
35
+ }
36
+ /**
37
+ * Listen for logged crashes.
38
+ */
39
+ export declare function onLoggerCrash(listener: (context: LoggerCrashProps) => void): () => void;
40
+ export declare function createLogger(name: MaybeSignal<string>, options?: LoggerOptions): Logger;
41
+ export declare function setLogFilter(filter: string | RegExp): void;
42
+ export declare function setLogLevels(options: Partial<LogLevels>): void;
@@ -0,0 +1,125 @@
1
+ import type { IntrinsicElements, Renderable, View } from "../types.js";
2
+ import { Context } from "./context.js";
3
+ import { KeyFn, RenderFn } from "./nodes/repeat.js";
4
+ import { type MaybeSignal, type Signal } from "./signals.js";
5
+ /**
6
+ * Markup is a set of element metadata that hasn't been constructed into a MarkupElement yet.
7
+ */
8
+ export declare class Markup<P = any> {
9
+ /**
10
+ * 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.
11
+ * DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
12
+ */
13
+ type: string | View<P>;
14
+ /**
15
+ * Data that will be passed to a new MarkupNode instance when it is constructed.
16
+ * Includes a `children` prop if children were passed.
17
+ */
18
+ props: P | undefined;
19
+ constructor(type: string | View<P>, props?: P);
20
+ }
21
+ /**
22
+ * A mountable node that has been constructed from Markup metadata.
23
+ */
24
+ export interface MarkupNode {
25
+ /**
26
+ *
27
+ */
28
+ readonly root?: Node;
29
+ /**
30
+ * Returns true when this MarkupNode is mounted.
31
+ */
32
+ isMounted(): boolean;
33
+ /**
34
+ * Mount this MarkupNode to a `parent` element.
35
+ * If passed, this MarkupNode will be mounted as the next sibling of `after`.
36
+ */
37
+ mount(parent: Element, after?: Node): void;
38
+ /**
39
+ * Unmount this MarkupNode from its parent element.
40
+ *
41
+ * The `skipDOM` option can be passed as an optimization when unmounting a parent node.
42
+ * A value of `true` indicates that no DOM operations need to happen because the parent is already being unmounted.
43
+ *
44
+ * @param skipDOM - No DOM updates will be performed when true. Lifecycle methods will be called regardless.
45
+ */
46
+ unmount(skipDOM?: boolean): void;
47
+ /**
48
+ * Moves a node without unmounting and remounting (if the browser supports Element.moveBefore).
49
+ */
50
+ move(parent: Element, after?: Node): void;
51
+ }
52
+ export declare function isMarkupNode(value: any): value is MarkupNode;
53
+ export declare enum MarkupType {
54
+ DOM = "$dom",
55
+ Dynamic = "$dynamic",
56
+ Portal = "$portal",
57
+ Repeat = "$repeat"
58
+ }
59
+ export interface MarkupNodeProps {
60
+ [MarkupType.DOM]: {
61
+ value: Node;
62
+ };
63
+ [MarkupType.Dynamic]: {
64
+ source: Signal<any>;
65
+ };
66
+ [MarkupType.Portal]: {
67
+ content: Renderable;
68
+ parent: Element;
69
+ };
70
+ [MarkupType.Repeat]: {
71
+ items: Signal<any[]>;
72
+ key: KeyFn<any>;
73
+ render: RenderFn<any>;
74
+ };
75
+ }
76
+ export interface MarkupCustomElementProps {
77
+ /**
78
+ * Custom element tagName pattern (must include a hyphen).
79
+ */
80
+ [tag: `${string}-${string}`]: Record<string, any>;
81
+ }
82
+ /**
83
+ * Creates a Markup element that defines an HTML element.
84
+ */
85
+ export declare function m<T extends keyof IntrinsicElements>(tag: T, attrs: IntrinsicElements[T] & {
86
+ children?: Renderable;
87
+ }): Markup;
88
+ /**
89
+ * Creates a Markup element that defines an HTML custom element.
90
+ */
91
+ export declare function m<T extends keyof MarkupCustomElementProps>(type: T, props: MarkupCustomElementProps[T]): Markup;
92
+ /**
93
+ * Creates a Markup element that defines a MarkupNode.
94
+ */
95
+ export declare function m<T extends keyof MarkupNodeProps>(type: T, props: MarkupNodeProps[T]): Markup;
96
+ /**
97
+ * Creates a Markup element that defines a view.
98
+ */
99
+ export declare function m<P extends {}>(type: View<P>, props?: P): Markup;
100
+ /**
101
+ * Creates a Markup element that defines a view.
102
+ */
103
+ export declare function m<P>(type: View<P>, props: P): Markup;
104
+ /**
105
+ * If `condition` is truthy, displays `thenContent`, otherwise `elseContent`.
106
+ */
107
+ export declare function when(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
108
+ /**
109
+ * Inverted `when`. If `condition` is falsy, displays `thenContent`, otherwise `elseContent`.
110
+ */
111
+ export declare function unless(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
112
+ /**
113
+ * Calls `render` for each item in `items`. Dynamically adds and removes views as items change.
114
+ * The result of `key` is used to compare items and decide if item was added, removed or updated.
115
+ */
116
+ export declare function repeat<T>(items: MaybeSignal<T[]>, key: KeyFn<T>, render: RenderFn<T>): Markup;
117
+ /**
118
+ * Renders `content` into a `parent` node anywhere in the page, rather than its usual position in the view.
119
+ */
120
+ export declare function portal(parent: Element, content: Renderable): Markup;
121
+ export declare function render(content: Renderable, context?: Context): MarkupNode;
122
+ /**
123
+ * Convert basically anything into a set of MarkupElements.
124
+ */
125
+ export declare function toMarkupNodes(context: Context, ...content: any[]): MarkupNode[];
@@ -0,0 +1,15 @@
1
+ import { Router } from "../router/router";
2
+ import type { View } from "../types";
3
+ import { Context } from "./context";
4
+ import { type LoggerCrashProps } from "./logger";
5
+ export type UnmountFn = () => Promise<void>;
6
+ export interface MountOptions {
7
+ crashView?: View<LoggerCrashProps>;
8
+ /**
9
+ * An existing Context to use as the root, otherwise a new one will be created.
10
+ * Use this to provide top-level stores and state to the whole app.
11
+ */
12
+ context?: Context;
13
+ }
14
+ export declare function mount(view: View<{}>, domNode: Element, options?: MountOptions): Promise<UnmountFn>;
15
+ export declare function mount(router: Router, domNode: Element, options?: MountOptions): Promise<UnmountFn>;
@@ -0,0 +1,14 @@
1
+ import type { MarkupNode } from "../markup";
2
+ import { TYPE } from "../symbols";
3
+ /**
4
+ * Lightweight MarkupNode wrapper for a plain DOM node.
5
+ */
6
+ export declare class DOMNode implements MarkupNode {
7
+ [TYPE]: symbol;
8
+ root: Node;
9
+ constructor(node: Node);
10
+ isMounted(): boolean;
11
+ mount(parent: Element, after?: Node): void;
12
+ unmount(skipDOM?: boolean): void;
13
+ move(parent: Element, after?: Node): void;
14
+ }
@@ -0,0 +1,29 @@
1
+ import type { Context } from "../context.js";
2
+ import { type MarkupNode } from "../markup.js";
3
+ import { type Signal } from "../signals.js";
4
+ import { TYPE } from "../symbols.js";
5
+ /**
6
+ * Displays dynamic children without a parent element.
7
+ * Renders a Reactive value via a render function.
8
+ *
9
+ * This is probably the most used element type aside from HTML.
10
+ */
11
+ export declare class Dynamic implements MarkupNode {
12
+ [TYPE]: symbol;
13
+ root: Text;
14
+ private children;
15
+ private context;
16
+ private $slot;
17
+ private unsubscribe?;
18
+ constructor(context: Context, $slot: Signal<any>);
19
+ isMounted(): boolean;
20
+ mount(parent: Node, after?: Node): void;
21
+ unmount(skipDOM?: boolean): void;
22
+ move(parent: Element, after?: Node): void;
23
+ private cleanup;
24
+ private update;
25
+ /**
26
+ * Move marker node to end of children.
27
+ */
28
+ private moveMarker;
29
+ }
@@ -0,0 +1,24 @@
1
+ import { Context } from "../context.js";
2
+ import { type MarkupNode } from "../markup.js";
3
+ import { TYPE } from "../symbols.js";
4
+ export declare class HTML implements MarkupNode {
5
+ [TYPE]: symbol;
6
+ root: HTMLElement | SVGElement;
7
+ private parentContext;
8
+ private context;
9
+ tag: string;
10
+ props: Record<string, any>;
11
+ private childNodes;
12
+ private unsubscribers;
13
+ private ref?;
14
+ private canClickAway;
15
+ constructor(context: Context, tag: string, props: Record<string, any>);
16
+ isMounted(): boolean;
17
+ mount(parent: Node, after?: Node): void;
18
+ unmount(skipDOM?: boolean): void;
19
+ move(parent: Element, after?: Node): void;
20
+ private attachProp;
21
+ private applyProps;
22
+ private applyStyles;
23
+ private applyClasses;
24
+ }
@@ -0,0 +1,19 @@
1
+ import type { Renderable } from "../../types.js";
2
+ import { Context } from "../context.js";
3
+ import { type MarkupNode } from "../markup.js";
4
+ import { TYPE } from "../symbols.js";
5
+ /**
6
+ * Renders content into a specified parent node.
7
+ */
8
+ export declare class Portal implements MarkupNode {
9
+ [TYPE]: symbol;
10
+ private context;
11
+ private content;
12
+ private parent;
13
+ private element?;
14
+ constructor(context: Context, content: Renderable, parent: Element);
15
+ isMounted(): boolean;
16
+ mount(_parent: Element, _after?: Node): void;
17
+ unmount(skipDOM?: boolean): void;
18
+ move(_parent: Element, _after?: Node): void;
19
+ }
@@ -0,0 +1,25 @@
1
+ import type { Renderable } from "../../types.js";
2
+ import type { Context } from "../context.js";
3
+ import type { MarkupNode } from "../markup.js";
4
+ import { type Signal } from "../signals.js";
5
+ import { TYPE } from "../symbols.js";
6
+ export type Key = string | number | symbol;
7
+ export type KeyFn<T> = (item: T, index: number) => Key;
8
+ export type RenderFn<T> = (item: Signal<T>, index: Signal<number>, ctx: Context) => Renderable;
9
+ export declare class Repeat<T> implements MarkupNode {
10
+ [TYPE]: symbol;
11
+ root: Text;
12
+ private context;
13
+ private items;
14
+ private key;
15
+ private render;
16
+ private unsubscribe;
17
+ private connectedItems;
18
+ constructor(context: Context, items: Signal<T[]>, key: KeyFn<T>, render: RenderFn<T>);
19
+ isMounted(): boolean;
20
+ mount(parent: Element, after?: Node): void;
21
+ unmount(skipDOM?: boolean): void;
22
+ move(parent: Element, after?: Node): void;
23
+ private _cleanup;
24
+ private _update;
25
+ }
@@ -0,0 +1,24 @@
1
+ import type { View } from "../../types.js";
2
+ import { Context } from "../context.js";
3
+ import { type MarkupNode } from "../markup.js";
4
+ import { TYPE } from "../symbols.js";
5
+ export declare const VIEW: unique symbol;
6
+ export declare class ViewInstance<P> implements MarkupNode {
7
+ [TYPE]: symbol;
8
+ uniqueId: string;
9
+ context: Context;
10
+ props: P;
11
+ view: View<P>;
12
+ node?: MarkupNode;
13
+ get root(): Node;
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
+ isMounted(): boolean;
21
+ mount(parent: Element, after?: Node): void;
22
+ unmount(skipDOM?: boolean): void;
23
+ move(parent: Element, after?: Node): void;
24
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * A hybrid getter/setter function that stores the last value it was called with.
3
+ * Guarantees a value is held at runtime by throwing an error if no value is set.
4
+ */
5
+ export interface Ref<T> {
6
+ /**
7
+ * Returns the currently stored value of the ref, or throws an error if no value has been set.
8
+ */
9
+ (): T;
10
+ /**
11
+ * Stores a new value to the ref and returns that value.
12
+ */
13
+ (value: T): T;
14
+ }
15
+ /**
16
+ * Creates a Ref.
17
+ */
18
+ export declare function ref<T>(value?: T): Ref<T>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * A getter that returns the current value held within the signal.
3
+ * If called inside a trackable scope this signal will be tracked as a dependency.
4
+ */
5
+ export interface Signal<T> {
6
+ (): T;
7
+ }
8
+ /**
9
+ * Extends Signal with the ability to pass a value or an updater function to change the Signal's value.
10
+ */
11
+ export interface Source<T> extends Signal<T> {
12
+ (value: T): void;
13
+ (updater: (value: T) => T): void;
14
+ }
15
+ export type MaybeSignal<T> = Signal<T> | T;
16
+ export type EqualityFn<T> = (current: T, next: T) => boolean;
17
+ export interface SignalOptions<T> {
18
+ /**
19
+ * A function to compare the current and next values. Returning `true` means the value has changed.
20
+ */
21
+ equals?: EqualityFn<T>;
22
+ }
23
+ export declare function isSource<T>(value: MaybeSignal<T>): value is Source<T>;
24
+ export declare function batch(fn: () => void): void;
25
+ export declare function untracked<T>(value: MaybeSignal<T>): T;
26
+ export declare function get<T>(value: MaybeSignal<T>): T;
27
+ /**
28
+ * Function to be invoked for the effect. Can return an optional cleanup function to be called between invocations.
29
+ */
30
+ export type EffectFn = () => void | (() => void);
31
+ export type UnsubscribeFn = () => void;
32
+ /**
33
+ * Creates a tracked scope that re-runs whenever the values of any tracked reactives changes.
34
+ * Reactives are tracked by accessing their `value` within the body of the function.
35
+ *
36
+ * NOTE: You must call the unsubscribe function to stop watching for changes.
37
+ * If you are using an effect inside a View or Store, use `ctx.effect` instead, which cleans up automatically when the component unmounts.
38
+ */
39
+ export declare function effect(fn: EffectFn): UnsubscribeFn;
40
+ export declare function $<T>(compute: (previousValue: T) => MaybeSignal<T>, options?: SignalOptions<T>): Signal<T>;
41
+ export declare function $<T>(value: T, options?: SignalOptions<T>): Source<T>;
42
+ export declare function $<T>(value: undefined, options?: SignalOptions<T>): Source<T | undefined>;
43
+ export declare function $<T>(): Source<T | undefined>;
@@ -0,0 +1,2 @@
1
+ export declare const TYPE: unique symbol;
2
+ export declare const MARKUP_NODE: unique symbol;
@@ -13,6 +13,10 @@ export type CrashViewProps = {
13
13
  /**
14
14
  * Unique identifier to pinpoint the specific view that reported the crash.
15
15
  */
16
- uid?: string;
16
+ tag?: string;
17
+ /**
18
+ * Label for the tag.
19
+ */
20
+ tagName?: string;
17
21
  };
18
- export declare function DefaultCrashView(props: CrashViewProps): import("../markup.js").Markup | import("../markup.js").Markup[];
22
+ export declare function DefaultCrashView(props: CrashViewProps): import("../markup.js").Markup<any>;
@@ -0,0 +1,7 @@
1
+ import type { Renderable } from "../../types.js";
2
+ /**
3
+ * A utility view that displays its children.
4
+ */
5
+ export declare function Fragment(props: {
6
+ children?: Renderable;
7
+ }): Renderable;
@@ -0,0 +1,7 @@
1
+ function r(n) {
2
+ return n.children;
3
+ }
4
+ export {
5
+ r as F
6
+ };
7
+ //# sourceMappingURL=fragment-BahD_BJA.js.map
@@ -0,0 +1 @@
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;"}
@@ -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 {