@manyducks.co/dolla 2.0.0-alpha.55 → 2.0.0-alpha.57

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 (49) hide show
  1. package/README.md +5 -2
  2. package/dist/core/context.d.ts +38 -25
  3. package/dist/core/env.d.ts +2 -8
  4. package/dist/core/index.d.ts +3 -5
  5. package/dist/core/logger.d.ts +2 -2
  6. package/dist/core/markup.d.ts +43 -42
  7. package/dist/core/mount.d.ts +1 -1
  8. package/dist/core/nodes/dom.d.ts +6 -6
  9. package/dist/core/nodes/dynamic.d.ts +13 -15
  10. package/dist/core/nodes/html.d.ts +9 -21
  11. package/dist/core/nodes/portal.d.ts +8 -12
  12. package/dist/core/nodes/repeat.d.ts +13 -18
  13. package/dist/core/nodes/view.d.ts +10 -23
  14. package/dist/core/ref.d.ts +2 -6
  15. package/dist/core/symbols.d.ts +1 -1
  16. package/dist/core/views/default-crash-view.d.ts +1 -1
  17. package/dist/core/views/fragment.d.ts +1 -2
  18. package/dist/fragment-BahD_BJA.js +7 -0
  19. package/dist/fragment-BahD_BJA.js.map +1 -0
  20. package/dist/http.js +1 -1
  21. package/dist/i18n.js +2 -2
  22. package/dist/index.js +41 -41
  23. package/dist/index.js.map +1 -1
  24. package/dist/jsx-dev-runtime.d.ts +1 -1
  25. package/dist/jsx-dev-runtime.js +2 -2
  26. package/dist/jsx-runtime.d.ts +2 -2
  27. package/dist/jsx-runtime.js +2 -2
  28. package/dist/{logger-CXdzxt1e.js → logger-sSxIw5od.js} +100 -100
  29. package/dist/logger-sSxIw5od.js.map +1 -0
  30. package/dist/markup-CAJd0zdA.js +937 -0
  31. package/dist/markup-CAJd0zdA.js.map +1 -0
  32. package/dist/router/index.d.ts +1 -1
  33. package/dist/router/router.d.ts +6 -6
  34. package/dist/{router-B-rtBG7i.js → router-ClSFnmRK.js} +184 -183
  35. package/dist/router-ClSFnmRK.js.map +1 -0
  36. package/dist/router.js +1 -1
  37. package/dist/router.js.map +1 -1
  38. package/dist/{typeChecking-lgllKIVq.js → typeChecking-BJ-ymQ2F.js} +5 -10
  39. package/dist/{typeChecking-lgllKIVq.js.map → typeChecking-BJ-ymQ2F.js.map} +1 -1
  40. package/dist/types.d.ts +40 -22
  41. package/package.json +1 -1
  42. package/dist/core/nodes/fragment.d.ts +0 -19
  43. package/dist/core/nodes/outlet.d.ts +0 -19
  44. package/dist/fragment-VXM-P2tT.js +0 -7
  45. package/dist/fragment-VXM-P2tT.js.map +0 -1
  46. package/dist/logger-CXdzxt1e.js.map +0 -1
  47. package/dist/markup-yTuFdC0t.js +0 -923
  48. package/dist/markup-yTuFdC0t.js.map +0 -1
  49. package/dist/router-B-rtBG7i.js.map +0 -1
package/README.md CHANGED
@@ -101,7 +101,10 @@ function MessageStore(options, ctx) {
101
101
  }
102
102
 
103
103
  function App(props, ctx) {
104
- const { message, setMessage } = ctx.provide(MessageStore);
104
+ // Provide a store for this and all child views.
105
+ ctx.addStore(MessageStore);
106
+
107
+ const { message, setMessage } = ctx.getStore(MessageStore);
105
108
  // Provides a MessageStore on this context and any child contexts.
106
109
  // When a store is provided its value is returned right away.
107
110
 
@@ -123,7 +126,7 @@ function App(props, ctx) {
123
126
  }
124
127
 
125
128
  function MessageView(props, ctx) {
126
- const { message } = ctx.get(MessageStore);
129
+ const { message } = ctx.getStore(MessageStore);
127
130
  // Gets the nearest instance of MessageStore. In this case the one provided at the parent.
128
131
 
129
132
  return <span>{message}</span>;
@@ -1,18 +1,14 @@
1
- import { Logger, LoggerOptions } from "./logger";
1
+ import type { Store } from "../types";
2
+ import { type Logger, type LoggerOptions } from "./logger";
2
3
  import { type EffectFn, type MaybeSignal, type UnsubscribeFn } from "./signals";
3
- /**
4
- *
5
- */
6
- export type Store<Options, Value> = (this: Context, options: Options, context: Context) => Value;
7
4
  type StoreMap = Map<Store<any, any>, any>;
8
- export declare const globalStores: StoreMap;
5
+ export declare enum LifecycleEvent {
6
+ WILL_MOUNT = 0,
7
+ DID_MOUNT = 1,
8
+ WILL_UNMOUNT = 2,
9
+ DID_UNMOUNT = 3
10
+ }
9
11
  type LifecycleListener = () => void;
10
- type ContextLifecycleListeners = {
11
- willMount?: LifecycleListener[];
12
- didMount?: LifecycleListener[];
13
- willUnmount?: LifecycleListener[];
14
- didUnmount?: LifecycleListener[];
15
- };
16
12
  declare enum LifecycleState {
17
13
  Unmounted = 0,
18
14
  WillMount = 1,
@@ -30,18 +26,16 @@ declare class ContextLifecycle {
30
26
  #private;
31
27
  state: LifecycleState;
32
28
  dependents: number;
33
- on<E extends keyof ContextLifecycleListeners>(event: E, listener: LifecycleListener): void;
34
- off<E extends keyof ContextLifecycleListeners>(event: E, listener: LifecycleListener): void;
35
- willMount(dependent?: boolean): void;
36
- didMount(dependent?: boolean): void;
37
- willUnmount(dependent?: boolean): void;
38
- didUnmount(dependent?: boolean): void;
29
+ on<E extends LifecycleEvent>(event: E, listener: LifecycleListener): void;
30
+ off<E extends LifecycleEvent>(event: E, listener: LifecycleListener): void;
31
+ notify<E extends LifecycleEvent>(event: E): void;
32
+ emit<E extends LifecycleEvent>(event: E, dependent?: boolean): void;
39
33
  dispose(): void;
40
34
  }
41
35
  export interface ContextOptions {
42
36
  logger?: LoggerOptions;
43
37
  }
44
- export interface InheritedContextOptions extends ContextOptions {
38
+ export interface LinkedContextOptions extends ContextOptions {
45
39
  bindLifecycleToParent?: boolean;
46
40
  }
47
41
  export interface Context extends Logger {
@@ -49,15 +43,16 @@ export interface Context extends Logger {
49
43
  export declare class Context implements Logger {
50
44
  #private;
51
45
  _name: string;
52
- _parent?: Context;
53
46
  _lifecycle: ContextLifecycle;
54
- _stores: StoreMap;
55
- _state: Map<any, any>;
47
+ _parent?: Context;
48
+ _stores?: StoreMap;
49
+ _state?: Map<any, any>;
56
50
  get isMounted(): boolean;
57
51
  /**
58
52
  * Returns a new Context with this one as its parent.
59
53
  */
60
- static inherit(parent: Context, name: MaybeSignal<string>, options?: InheritedContextOptions): Context;
54
+ static linked(parent: Context, name: MaybeSignal<string>, options?: LinkedContextOptions): Context;
55
+ static emit(event: LifecycleEvent, context: Context): void;
61
56
  constructor(name: MaybeSignal<string>, options?: ContextOptions);
62
57
  /**
63
58
  * Returns the current name of this context.
@@ -69,9 +64,21 @@ export declare class Context implements Logger {
69
64
  setName(name: MaybeSignal<string>): void;
70
65
  addStore<T>(store: Store<any, T>, options?: any): this;
71
66
  getStore<T>(store: Store<any, T>): T;
67
+ /**
68
+ * Schedule a callback function to run just before this context is mounted.
69
+ */
72
70
  beforeMount(listener: LifecycleListener): () => void;
71
+ /**
72
+ * Schedule a callback function to run after this context is mounted.
73
+ */
73
74
  onMount(listener: LifecycleListener): () => void;
75
+ /**
76
+ * Schedule a callback function to run just before this context is unmounted.
77
+ */
74
78
  beforeUnmount(listener: LifecycleListener): () => void;
79
+ /**
80
+ * Schedule a callback function to run after this context is unmounted.
81
+ */
75
82
  onUnmount(listener: LifecycleListener): () => void;
76
83
  effect(callback: EffectFn): UnsubscribeFn;
77
84
  /**
@@ -83,11 +90,17 @@ export declare class Context implements Logger {
83
90
  */
84
91
  getState<T>(key: any): T;
85
92
  /**
86
- * Gets all values available to this context.
93
+ * Returns a Map containing all state values available to this context.
87
94
  */
88
95
  getState(): Map<any, any>;
96
+ /**
97
+ * Stores `value` at `key` in this context's state.
98
+ */
89
99
  setState<T>(key: any, value: T): void;
90
- setState(entries: [any, any][]): void;
100
+ /**
101
+ * For each tuple in `entries`, stores `value` at `key` in this context's state.
102
+ */
103
+ setState(entries: [key: any, value: any][]): void;
91
104
  }
92
105
  export declare function createContext(name: MaybeSignal<string>, options?: ContextOptions): Context;
93
106
  export declare class StoreError extends Error {
@@ -1,9 +1,3 @@
1
- export type Env = "production" | "development";
2
- /**
3
- * Gets the current environment value.
4
- */
5
- export declare function getEnv(): Env;
6
- /**
7
- * Sets the environment value. Affects which log messages will print and how much debugging info is included in the DOM.
8
- */
1
+ import type { Env } from "../types";
2
+ export declare function getEnv(): string;
9
3
  export declare function setEnv(value: Env): void;
@@ -1,19 +1,17 @@
1
1
  export { $, effect, get, peek } from "./signals.js";
2
2
  export type { MaybeSignal, Signal, Source } from "./signals.js";
3
3
  export { createContext } from "./context.js";
4
- export type { Context, Store } from "./context.js";
4
+ export type { Context } from "./context.js";
5
5
  export { m, portal, render, repeat, unless, when } from "./markup.js";
6
- export type { Markup, MarkupElement } from "./markup.js";
6
+ export type { MarkupNode } from "./markup.js";
7
7
  export { type Mixin } from "./nodes/html.js";
8
8
  export { ref, type Ref } from "./ref.js";
9
9
  export { mount, type UnmountFn } from "./mount.js";
10
10
  export { deepEqual, shallowEqual, strictEqual } from "../utils.js";
11
11
  export { getEnv, setEnv } from "./env.js";
12
- export type { Env } from "./env.js";
13
12
  export { createLogger, setLogFilter, setLogLevels } from "./logger.js";
14
13
  export type { Logger, LoggerErrorContext, LoggerOptions, LogLevels } from "./logger.js";
15
- export type { InputType, Renderable } from "../types.js";
16
- export type { View } from "./nodes/view.js";
14
+ export type { View, Store, InputType, Renderable, Env } from "../types.js";
17
15
  export type { CrashViewProps } from "./views/default-crash-view.js";
18
16
  import type { IntrinsicElements as Elements } from "../types.js";
19
17
  declare global {
@@ -1,5 +1,5 @@
1
- import { type Env } from "./env";
2
- import { type MaybeSignal } from "./signals";
1
+ import type { Env } from "../types.js";
2
+ import { type MaybeSignal } from "./signals.js";
3
3
  export interface LogLevels {
4
4
  info: boolean | Env;
5
5
  log: boolean | Env;
@@ -1,63 +1,68 @@
1
- import type { Mountable, Renderable } from "../types.js";
1
+ import type { Renderable, View } from "../types.js";
2
2
  import { Context } from "./context.js";
3
- import { ViewInstance, type View, type ViewResult } from "./nodes/view.js";
3
+ import { KeyFn, RenderFn } from "./nodes/repeat.js";
4
4
  import { type MaybeSignal, type Signal } from "./signals.js";
5
5
  /**
6
6
  * Markup is a set of element metadata that hasn't been constructed into a MarkupElement yet.
7
7
  */
8
- export interface Markup {
8
+ export declare class Markup<P extends Record<any, any> = Record<any, any>> {
9
9
  /**
10
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
11
  * DOM nodes can be created by name, such as HTML elements like "div", "ul" or "span", SVG elements like ""
12
12
  */
13
- type: string | View<any>;
13
+ type: string | View<P>;
14
14
  /**
15
- * Data that will be passed to a new MarkupElement instance when it is constructed.
15
+ * Data that will be passed to a new MarkupNode instance when it is constructed.
16
16
  */
17
- props?: Record<string, any>;
17
+ props: P | undefined;
18
18
  /**
19
19
  *
20
20
  */
21
- children?: any[];
21
+ children: Renderable[];
22
+ constructor(type: string | View<P>, props?: P, ...children: Renderable[]);
22
23
  }
23
24
  /**
24
- * A DOM node that has been constructed from a Markup object.
25
+ * A mountable node that has been constructed from Markup metadata.
25
26
  */
26
- export interface MarkupElement extends Mountable {
27
- readonly domNode?: Node;
27
+ export interface MarkupNode {
28
+ /**
29
+ *
30
+ */
31
+ readonly root?: Node;
32
+ /**
33
+ *
34
+ */
28
35
  readonly isMounted: boolean;
36
+ /**
37
+ *
38
+ */
39
+ mount(parent: Node, after?: Node): void;
40
+ /**
41
+ *
42
+ */
43
+ unmount(parentIsUnmounting?: boolean): void;
29
44
  }
30
- export declare function isMarkup(value: any): value is Markup;
31
- export declare function isMarkupElement(value: any): value is MarkupElement;
32
- export declare function toMarkup(renderables: Renderable | Renderable[]): Markup[];
45
+ export declare function isMarkupNode(value: any): value is MarkupNode;
33
46
  export declare enum MarkupType {
34
47
  Text = "$text",
35
48
  Repeat = "$repeat",
36
49
  Dynamic = "$dynamic",
37
- Outlet = "$outlet",
38
- Fragment = "$fragment",
39
- Node = "$node",
50
+ DOM = "$dom",
40
51
  Portal = "$portal"
41
52
  }
42
- export interface MarkupAttributes {
53
+ export interface MarkupProps {
43
54
  [MarkupType.Text]: {
44
55
  value: any;
45
56
  };
46
57
  [MarkupType.Repeat]: {
47
58
  items: Signal<any[]>;
48
- keyFn: (value: any, index: number) => string | number | symbol;
49
- renderFn: (item: Signal<any>, index: Signal<number>, ctx: Context) => ViewResult;
59
+ key: KeyFn<any>;
60
+ render: RenderFn<any>;
50
61
  };
51
62
  [MarkupType.Dynamic]: {
52
- source: Signal<Renderable>;
63
+ source: Signal<any>;
53
64
  };
54
- [MarkupType.Outlet]: {
55
- view: Signal<ViewInstance<{}> | undefined>;
56
- };
57
- [MarkupType.Fragment]: {
58
- children: MaybeSignal<MarkupElement[]>;
59
- };
60
- [MarkupType.Node]: {
65
+ [MarkupType.DOM]: {
61
66
  value: Node;
62
67
  };
63
68
  [MarkupType.Portal]: {
@@ -66,32 +71,28 @@ export interface MarkupAttributes {
66
71
  };
67
72
  [tag: string]: Record<string, any>;
68
73
  }
69
- export declare function m<T extends keyof MarkupAttributes>(type: T, attributes: MarkupAttributes[T], ...children: Renderable[]): Markup;
70
- export declare function m<I>(type: View<I>, attributes?: I, ...children: any[]): Markup;
74
+ export declare function m<T extends keyof MarkupProps>(type: T, props: MarkupProps[T], ...children: Renderable[]): Markup;
75
+ export declare function m<P extends {}>(type: View<P>, props?: P, ...children: Renderable[]): Markup;
76
+ export declare function m<P>(type: View<P>, props: P, ...children: any[]): Markup;
71
77
  /**
72
- * Displays `thenContent` when `condition` is truthy and `elseContent` when falsy.
78
+ * If `condition` is truthy, displays `thenContent`, otherwise `elseContent`.
73
79
  */
74
80
  export declare function when(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
75
81
  /**
76
- * Inverted `when`. Displays `thenContent` when `condition` is falsy and `elseContent` when truthy.
82
+ * Inverted `when`. If `condition` is falsy, displays `thenContent`, otherwise `elseContent`.
77
83
  */
78
84
  export declare function unless(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
79
85
  /**
80
- * Calls `renderFn` for each item in `items`. Dynamically adds and removes views as items change.
81
- * The result of `keyFn` is used to compare items and decide if item was added, removed or updated.
86
+ * Calls `render` for each item in `items`. Dynamically adds and removes views as items change.
87
+ * The result of `key` is used to compare items and decide if item was added, removed or updated.
82
88
  */
83
- export declare function repeat<T>(items: MaybeSignal<T[]>, keyFn: (value: T, index: number) => string | number | symbol, renderFn: (item: Signal<T>, index: Signal<number>, ctx: Context) => ViewResult): Markup;
89
+ export declare function repeat<T>(items: MaybeSignal<T[]>, key: KeyFn<T>, render: RenderFn<T>): Markup;
84
90
  /**
85
91
  * Renders `content` into a `parent` node anywhere in the page, rather than its usual position in the view.
86
92
  */
87
93
  export declare function portal(parent: Node, content: Renderable): Markup;
88
- export declare function render(content: Renderable, context?: Context): MarkupElement;
89
- /**
90
- * Construct Markup metadata into a set of MarkupElements.
91
- */
92
- export declare function toMarkupElements(context: Context, markup: Markup | Markup[]): MarkupElement[];
94
+ export declare function render(content: Renderable, context?: Context): MarkupNode;
93
95
  /**
94
- * Combines one or more MarkupElements into a single MarkupElement.
96
+ * Convert basically anything into a set of MarkupElements.
95
97
  */
96
- export declare function groupElements(elements: MarkupElement[]): MarkupElement;
97
- export declare function isRenderable(value: unknown): value is Renderable;
98
+ export declare function toMarkupNodes(context: Context, ...content: any[]): MarkupNode[];
@@ -1,7 +1,7 @@
1
1
  import { Router } from "../router/router";
2
+ import type { View } from "../types";
2
3
  import { Context } from "./context";
3
4
  import { type LoggerErrorContext } from "./logger";
4
- import { type View } from "./nodes/view";
5
5
  export type UnmountFn = () => Promise<void>;
6
6
  export interface MountOptions {
7
7
  crashView?: View<LoggerErrorContext>;
@@ -1,11 +1,11 @@
1
- import type { MarkupElement } from "../markup";
2
- import { IS_MARKUP_ELEMENT } from "../symbols";
1
+ import type { MarkupNode } from "../markup";
2
+ import { IS_MARKUP_NODE } from "../symbols";
3
3
  /**
4
- * Wraps any plain DOM node in a MarkupElement interface.
4
+ * Wraps any plain DOM node in a MarkupNode interface.
5
5
  */
6
- export declare class DOMNode implements MarkupElement {
7
- [IS_MARKUP_ELEMENT]: boolean;
8
- domNode: Node;
6
+ export declare class DOMNode implements MarkupNode {
7
+ [IS_MARKUP_NODE]: boolean;
8
+ root: Node;
9
9
  get isMounted(): boolean;
10
10
  constructor(node: Node);
11
11
  mount(parent: Node, after?: Node): void;
@@ -1,30 +1,28 @@
1
- import type { Renderable } from "../../types.js";
2
1
  import type { Context } from "../context.js";
3
- import { type MarkupElement } from "../markup.js";
2
+ import { type MarkupNode } from "../markup.js";
4
3
  import { Signal } from "../signals.js";
5
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
6
- interface DynamicOptions {
7
- source: Signal<Renderable>;
8
- context: Context;
9
- }
4
+ import { IS_MARKUP_NODE } from "../symbols.js";
10
5
  /**
11
6
  * Displays dynamic children without a parent element.
12
7
  * Renders a Reactive value via a render function.
13
8
  *
14
9
  * This is probably the most used element type aside from HTML.
15
10
  */
16
- export declare class Dynamic implements MarkupElement {
17
- [IS_MARKUP_ELEMENT]: boolean;
18
- domNode: Text;
11
+ export declare class Dynamic implements MarkupNode {
12
+ [IS_MARKUP_NODE]: boolean;
13
+ root: Text;
19
14
  private children;
20
15
  private context;
21
- private source;
16
+ private $slot;
22
17
  private unsubscribe?;
23
18
  get isMounted(): boolean;
24
- constructor(options: DynamicOptions);
19
+ constructor(context: Context, $slot: Signal<any>);
25
20
  mount(parent: Node, after?: Node): void;
26
21
  unmount(parentIsUnmounting?: boolean): void;
27
- cleanup(parentIsUnmounting: boolean): void;
28
- update(children: Renderable[]): void;
22
+ private cleanup;
23
+ private update;
24
+ /**
25
+ * Move marker node to end of children.
26
+ */
27
+ private moveMarker;
29
28
  }
30
- export {};
@@ -1,26 +1,19 @@
1
1
  import { Context } from "../context.js";
2
- import { type MarkupElement } from "../markup.js";
3
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
2
+ import { type MarkupNode } from "../markup.js";
3
+ import { IS_MARKUP_NODE } from "../symbols.js";
4
4
  export type Mixin<E extends Element = Element> = (element: E, context: Context) => void;
5
- type HTMLOptions = {
6
- context: Context;
7
- tag: string;
8
- props: Record<string, any>;
9
- children?: any[];
10
- };
11
- export declare class HTML implements MarkupElement {
12
- [IS_MARKUP_ELEMENT]: boolean;
13
- domNode: SVGElement | HTMLElement;
14
- context: Context;
5
+ export declare class HTML implements MarkupNode {
6
+ [IS_MARKUP_NODE]: boolean;
7
+ root: HTMLElement | SVGElement;
8
+ private context;
15
9
  private props;
16
- private childMarkup;
17
- private children;
10
+ private children?;
11
+ private childNodes;
18
12
  private unsubscribers;
19
- private logger;
20
13
  private ref?;
21
14
  private canClickAway;
22
15
  get isMounted(): boolean;
23
- constructor({ tag, props, children, context }: HTMLOptions);
16
+ constructor(context: Context, tag: string, props: Record<string, any>, children?: any[]);
24
17
  mount(parent: Node, after?: Node): void;
25
18
  unmount(parentIsUnmounting?: boolean): void;
26
19
  private attachProp;
@@ -28,8 +21,3 @@ export declare class HTML implements MarkupElement {
28
21
  private applyStyles;
29
22
  private applyClasses;
30
23
  }
31
- /**
32
- * Converts a camelCase string to kebab-case.
33
- */
34
- export declare function camelToKebab(value: string): string;
35
- export {};
@@ -1,22 +1,18 @@
1
1
  import type { Renderable } from "../../types.js";
2
2
  import { Context } from "../context.js";
3
- import { type MarkupElement } from "../markup.js";
4
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
5
- interface PortalConfig {
6
- content: Renderable;
7
- parent: Node;
8
- context: Context;
9
- }
3
+ import { type MarkupNode } from "../markup.js";
4
+ import { IS_MARKUP_NODE } from "../symbols.js";
10
5
  /**
11
6
  * Renders content into a specified parent node.
12
7
  */
13
- export declare class Portal implements MarkupElement {
14
- [IS_MARKUP_ELEMENT]: boolean;
15
- private config;
8
+ export declare class Portal implements MarkupNode {
9
+ [IS_MARKUP_NODE]: boolean;
10
+ private context;
11
+ private content;
12
+ private parent;
16
13
  private element?;
17
14
  get isMounted(): boolean;
18
- constructor(config: PortalConfig);
15
+ constructor(context: Context, content: Renderable, parent: Node);
19
16
  mount(_parent: Node, _after?: Node): void;
20
17
  unmount(parentIsUnmounting?: boolean): void;
21
18
  }
22
- export {};
@@ -1,28 +1,23 @@
1
- import { type Context } from "../context.js";
2
- import { type MarkupElement } from "../markup.js";
1
+ import type { Renderable } from "../../types.js";
2
+ import type { Context } from "../context.js";
3
+ import type { MarkupNode } from "../markup.js";
3
4
  import { type Signal } from "../signals.js";
4
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
5
- import { type ViewResult } from "./view.js";
6
- interface RepeatOptions<T> {
7
- context: Context;
8
- items: Signal<T[]>;
9
- keyFn: (item: T, index: number) => string | number | symbol;
10
- renderFn: (item: Signal<T>, index: Signal<number>, ctx: Context) => ViewResult;
11
- }
12
- export declare class Repeat<T> implements MarkupElement {
13
- [IS_MARKUP_ELEMENT]: boolean;
14
- domNode: Text;
5
+ import { IS_MARKUP_NODE } from "../symbols.js";
6
+ export type KeyFn<T> = (item: T, index: number) => string | number | symbol;
7
+ export type RenderFn<T> = (item: Signal<T>, index: Signal<number>, ctx: Context) => Renderable;
8
+ export declare class Repeat<T> implements MarkupNode {
9
+ [IS_MARKUP_NODE]: boolean;
10
+ root: Text;
11
+ private context;
15
12
  private items;
13
+ private key;
14
+ private render;
16
15
  private unsubscribe;
17
16
  private connectedItems;
18
- private context;
19
- private renderFn;
20
- private keyFn;
21
17
  get isMounted(): boolean;
22
- constructor({ context, items, renderFn, keyFn }: RepeatOptions<T>);
18
+ constructor(context: Context, items: Signal<T[]>, key: KeyFn<T>, render: RenderFn<T>);
23
19
  mount(parent: Node, after?: Node): void;
24
20
  unmount(parentIsUnmounting?: boolean): void;
25
21
  private _cleanup;
26
22
  private _update;
27
23
  }
28
- export {};
@@ -1,33 +1,20 @@
1
+ import type { View } from "../../types.js";
1
2
  import { Context } from "../context.js";
2
- import { type Markup, type MarkupElement } from "../markup.js";
3
- import { type Signal } from "../signals.js";
4
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
5
- export declare const ROUTE: unique symbol;
3
+ import { type MarkupNode } from "../markup.js";
4
+ import { IS_MARKUP_NODE } from "../symbols.js";
6
5
  export declare const VIEW: unique symbol;
7
- /**
8
- * Any valid value that a View can return.
9
- */
10
- export type ViewResult = Node | Signal<any> | Markup | Markup[] | null;
11
- /**
12
- *
13
- */
14
- export type View<P> = (this: Context, props: P, context: Context) => ViewResult;
15
- /**
16
- * A view that has been constructed into DOM nodes.
17
- */
18
- export declare class ViewInstance<P> implements MarkupElement {
19
- [IS_MARKUP_ELEMENT]: boolean;
6
+ export declare class ViewInstance<P> implements MarkupNode {
7
+ [IS_MARKUP_NODE]: boolean;
20
8
  uniqueId: string;
21
9
  context: Context;
22
10
  props: P & {
23
- children: Markup[] | undefined;
11
+ children: any[] | undefined;
24
12
  };
25
13
  fn: View<P>;
26
- element?: MarkupElement;
27
- $name: import("../signals.js").Source<string>;
28
- constructor(context: Context, fn: View<P>, props: P, children?: Markup[]);
29
- get domNode(): Node;
30
- isMounted: boolean;
14
+ node?: MarkupNode;
15
+ constructor(context: Context, fn: View<P>, props: P, children?: any[]);
16
+ get root(): Node;
17
+ get isMounted(): boolean;
31
18
  mount(parent: Node, after?: Node): void;
32
19
  unmount(parentIsUnmounting?: boolean): void;
33
20
  private _initialize;
@@ -13,10 +13,6 @@ export interface Ref<T> {
13
13
  (value: T): T;
14
14
  }
15
15
  /**
16
- * Creates a ref with no initial value.
16
+ * Creates a Ref.
17
17
  */
18
- export declare function ref<T>(): Ref<T>;
19
- /**
20
- * Creates a ref with an initial value.
21
- */
22
- export declare function ref<T>(value: T): Ref<T>;
18
+ export declare function ref<T>(value?: T): Ref<T>;
@@ -1,2 +1,2 @@
1
1
  export declare const IS_MARKUP: unique symbol;
2
- export declare const IS_MARKUP_ELEMENT: unique symbol;
2
+ export declare const IS_MARKUP_NODE: unique symbol;
@@ -19,4 +19,4 @@ export type CrashViewProps = {
19
19
  */
20
20
  tagName?: string;
21
21
  };
22
- export declare function DefaultCrashView(props: CrashViewProps): import("../markup.js").Markup;
22
+ export declare function DefaultCrashView(props: CrashViewProps): import("../markup.js").Markup<Record<any, any>>;
@@ -1,8 +1,7 @@
1
1
  import type { Renderable } from "../../types.js";
2
- import { Context } from "../context.js";
3
2
  /**
4
3
  * A utility view that displays its children.
5
4
  */
6
5
  export declare function Fragment(props: {
7
6
  children?: Renderable;
8
- }, ctx: Context): string | number | false | import("../signals.js").Signal<any> | import("../markup.js").Markup | (string | number | false | import("../signals.js").Signal<any> | import("../markup.js").Markup | null | undefined)[] | null;
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;"}
package/dist/http.js CHANGED
@@ -6,7 +6,7 @@ var g = (r, e, t) => e in r ? b(r, e, { enumerable: !0, configurable: !0, writab
6
6
  var a = (r, e, t) => g(r, typeof e != "symbol" ? e + "" : e, t), m = (r, e, t) => e.has(r) || f("Cannot " + t);
7
7
  var d = (r, e, t) => (m(r, e, "read from private field"), t ? t.call(r) : e.get(r)), c = (r, e, t) => e.has(r) ? f("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t);
8
8
  var o = (r, e, t) => (m(r, e, "access private method"), t);
9
- import { i as w } from "./typeChecking-lgllKIVq.js";
9
+ import { i as w } from "./typeChecking-BJ-ymQ2F.js";
10
10
  var l, p, i, h;
11
11
  class O {
12
12
  constructor() {
package/dist/i18n.js CHANGED
@@ -5,8 +5,8 @@ var D = (o) => {
5
5
  var J = (o, t, e) => t in o ? B(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
6
6
  var O = (o, t, e) => J(o, typeof t != "symbol" ? t + "" : t, e), _ = (o, t, e) => t.has(o) || D("Cannot " + e);
7
7
  var i = (o, t, e) => (_(o, t, "read from private field"), e ? e.call(o) : t.get(o)), m = (o, t, e) => t.has(o) ? D("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(o) : t.set(o, e), N = (o, t, e, n) => (_(o, t, "write to private field"), n ? n.call(o, e) : t.set(o, e), e), g = (o, t, e) => (_(o, t, "access private method"), e);
8
- import { $, f as K, d as Q, g as x } from "./logger-CXdzxt1e.js";
9
- import { b as C, i as j, c as U, t as P } from "./typeChecking-lgllKIVq.js";
8
+ import { $, f as K, d as Q, g as x } from "./logger-sSxIw5od.js";
9
+ import { b as C, i as j, c as U, t as P } from "./typeChecking-BJ-ymQ2F.js";
10
10
  var I, F, p, S, G;
11
11
  class W {
12
12
  constructor(t) {