@manyducks.co/dolla 2.0.0-alpha.54 → 2.0.0-alpha.56

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 (59) hide show
  1. package/README.md +1 -12
  2. package/dist/core/context.d.ts +81 -42
  3. package/dist/core/env.d.ts +2 -8
  4. package/dist/core/index.d.ts +7 -9
  5. package/dist/core/logger.d.ts +3 -3
  6. package/dist/core/markup.d.ts +44 -43
  7. package/dist/core/mount.d.ts +11 -6
  8. package/dist/core/nodes/dom.d.ts +6 -6
  9. package/dist/core/nodes/dynamic.d.ts +15 -17
  10. package/dist/core/nodes/html.d.ts +11 -23
  11. package/dist/core/nodes/portal.d.ts +9 -13
  12. package/dist/core/nodes/repeat.d.ts +13 -18
  13. package/dist/core/nodes/view.d.ts +14 -95
  14. package/dist/core/ref.d.ts +2 -6
  15. package/dist/core/symbols.d.ts +1 -3
  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 +14 -14
  22. package/dist/i18n.js.map +1 -1
  23. package/dist/index.js +50 -64
  24. package/dist/index.js.map +1 -1
  25. package/dist/jsx-dev-runtime.d.ts +1 -1
  26. package/dist/jsx-dev-runtime.js +8 -8
  27. package/dist/jsx-dev-runtime.js.map +1 -1
  28. package/dist/jsx-runtime.d.ts +2 -2
  29. package/dist/jsx-runtime.js +9 -9
  30. package/dist/jsx-runtime.js.map +1 -1
  31. package/dist/{logger-CBfhf3fA.js → logger-sSxIw5od.js} +143 -142
  32. package/dist/logger-sSxIw5od.js.map +1 -0
  33. package/dist/markup-DS7yYBga.js +844 -0
  34. package/dist/markup-DS7yYBga.js.map +1 -0
  35. package/dist/router/index.d.ts +1 -1
  36. package/dist/router/router.d.ts +10 -7
  37. package/dist/router-D43DV_bv.js +489 -0
  38. package/dist/router-D43DV_bv.js.map +1 -0
  39. package/dist/router.js +1 -1
  40. package/dist/router.js.map +1 -1
  41. package/dist/{typeChecking-EAVNeFyB.js → typeChecking-BJ-ymQ2F.js} +7 -12
  42. package/dist/{typeChecking-EAVNeFyB.js.map → typeChecking-BJ-ymQ2F.js.map} +1 -1
  43. package/dist/types.d.ts +13 -14
  44. package/docs/mixins.md +1 -1
  45. package/docs/ref.md +93 -0
  46. package/notes/scratch.md +24 -0
  47. package/package.json +2 -2
  48. package/dist/core/mixin.d.ts +0 -62
  49. package/dist/core/nodes/fragment.d.ts +0 -19
  50. package/dist/core/nodes/outlet.d.ts +0 -20
  51. package/dist/core/store.d.ts +0 -57
  52. package/dist/core/views/passthrough.d.ts +0 -5
  53. package/dist/fragment-CmWsN-4Y.js +0 -8
  54. package/dist/fragment-CmWsN-4Y.js.map +0 -1
  55. package/dist/logger-CBfhf3fA.js.map +0 -1
  56. package/dist/router-BoJac1lD.js +0 -482
  57. package/dist/router-BoJac1lD.js.map +0 -1
  58. package/dist/view-BKpHFpWG.js +0 -1044
  59. package/dist/view-BKpHFpWG.js.map +0 -1
package/README.md CHANGED
@@ -73,22 +73,11 @@ function Counter(props, ctx) {
73
73
  $(() => $count() > 10),
74
74
  <span>That's a lot of clicks!</span>,
75
75
  )}
76
-
77
- {/* ALT: Or slot a getter function into the DOM and have it conditionally render an element */}
78
- {() => {
79
- // DEV NOTE
80
- // If we get Dynamic to track its rendered elements and diff them by keys
81
- // then we may be able to do away with repeat and when and just do things like:
82
- // <ul>{() => items().map(item => <li>{item}</li>)}</ul>
83
- if ($count() > 10) {
84
- return <span>That's a lot of clicks!</span>;
85
- }
86
- }}
87
76
  </div>
88
77
  );
89
78
  }
90
79
 
91
- mount(document.body, Counter);
80
+ mount(Counter, document.body);
92
81
  ```
93
82
 
94
83
  > TODO: Show small examples for routing and stores.
@@ -1,69 +1,108 @@
1
- import type { View } from "./nodes/view";
2
- import type { Source } from "./signals";
3
- import type { Store, StoreFunction } from "./store";
4
- export interface ElementContext {
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
+ type StoreMap = Map<Store<any, any>, any>;
5
+ export declare enum LifecycleEvent {
6
+ WILL_MOUNT = 0,
7
+ DID_MOUNT = 1,
8
+ WILL_UNMOUNT = 2,
9
+ DID_UNMOUNT = 3
10
+ }
11
+ type LifecycleListener = () => void;
12
+ declare enum LifecycleState {
13
+ Unmounted = 0,
14
+ WillMount = 1,
15
+ WillMountByDependent = 2,
16
+ DidMount = 3,
17
+ DidMountByDependent = 4,
18
+ WillUnmount = 5,
19
+ WillUnmountByDependent = 6,
20
+ DidUnmount = 7
21
+ }
22
+ /**
23
+ * Manages lifecycle events for a Context.
24
+ */
25
+ declare class ContextLifecycle {
26
+ #private;
27
+ state: LifecycleState;
28
+ dependents: number;
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;
33
+ dispose(): void;
34
+ }
35
+ export interface ContextOptions {
36
+ logger?: LoggerOptions;
37
+ }
38
+ export interface LinkedContextOptions extends ContextOptions {
39
+ bindLifecycleToParent?: boolean;
40
+ }
41
+ export interface Context extends Logger {
42
+ }
43
+ export declare class Context implements Logger {
44
+ #private;
45
+ _name: string;
46
+ _lifecycle: ContextLifecycle;
47
+ _parent?: Context;
48
+ _stores?: StoreMap;
49
+ _state?: Map<any, any>;
50
+ get isMounted(): boolean;
5
51
  /**
6
- * The root Dolla instance this element belongs to.
52
+ * Returns a new Context with this one as its parent.
7
53
  */
54
+ static linked(parent: Context, name: MaybeSignal<string>, options?: LinkedContextOptions): Context;
55
+ static emit(event: LifecycleEvent, context: Context): void;
56
+ constructor(name: MaybeSignal<string>, options?: ContextOptions);
8
57
  /**
9
- * Stores attached to this context.
58
+ * Returns the current name of this context.
10
59
  */
11
- stores: Map<StoreFunction<any, any>, Store<any, any>>;
60
+ getName(): string;
12
61
  /**
13
- * The nearest view.
62
+ * Sets a new name for this context.
14
63
  */
15
- view?: View<any>;
64
+ setName(name: MaybeSignal<string>): void;
65
+ addStore<T>(store: Store<any, T>, options?: any): this;
66
+ getStore<T>(store: Store<any, T>): T;
16
67
  /**
17
- * A reference to the parent context.
68
+ * Schedule a callback function to run just before this context is mounted.
18
69
  */
19
- parent?: ElementContext;
70
+ beforeMount(listener: LifecycleListener): () => void;
20
71
  /**
21
- * Whether to create DOM nodes in the SVG namespace. An `<svg>` element will set this to true and pass it down to children.
72
+ * Schedule a callback function to run after this context is mounted.
22
73
  */
23
- isSVG?: boolean;
74
+ onMount(listener: LifecycleListener): () => void;
24
75
  /**
25
- * The name of the nearest parent view.
76
+ * Schedule a callback function to run just before this context is unmounted.
26
77
  */
78
+ beforeUnmount(listener: LifecycleListener): () => void;
27
79
  /**
28
- * The context of the nearest parent view.
80
+ * Schedule a callback function to run after this context is unmounted.
29
81
  */
82
+ onUnmount(listener: LifecycleListener): () => void;
83
+ effect(callback: EffectFn): UnsubscribeFn;
30
84
  /**
31
- * Current route layer of the nearest view.
85
+ * Gets the value stored at `key`, or returns the `defaultValue` if none is set.
32
86
  */
33
- route?: Source<View<{}> | undefined>;
34
- }
35
- export interface ComponentContext {
87
+ getState<T>(key: any, defaultValue: T): T;
36
88
  /**
37
- * A name for debugging purposes. Prepended to log messages.
89
+ * Gets the value stored at `key`, or throws an error if none is set.
38
90
  */
39
- name: string;
40
- }
41
- /**
42
- * A context capable of providing stores.
43
- */
44
- export interface StoreProviderContext {
91
+ getState<T>(key: any): T;
45
92
  /**
46
- * Attaches a new store to this context and returns it.
93
+ * Returns a Map containing all state values available to this context.
47
94
  */
48
- provide<Value>(store: StoreFunction<{}, Value>): Value;
95
+ getState(): Map<any, any>;
49
96
  /**
50
- * Attaches a new store to this context and returns it.
97
+ * Stores `value` at `key` in this context's state.
51
98
  */
52
- provide<Value>(store: StoreFunction<undefined, Value>): Value;
99
+ setState<T>(key: any, value: T): void;
53
100
  /**
54
- * Attaches a new store to this context and returns it.
101
+ * For each tuple in `entries`, stores `value` at `key` in this context's state.
55
102
  */
56
- provide<Options, Value>(store: StoreFunction<Options, Value>, options: Options): Value;
103
+ setState(entries: [key: any, value: any][]): void;
57
104
  }
58
- export interface StoreConsumerContext {
59
- /**
60
- * Gets the closest instance of a store. Throws an error if the store isn't provided higher in the tree.
61
- */
62
- get<Value>(store: StoreFunction<any, Value>): Value;
105
+ export declare function createContext(name: MaybeSignal<string>, options?: ContextOptions): Context;
106
+ export declare class StoreError extends Error {
63
107
  }
64
- type StoreMap = Map<any, any>;
65
- export declare const globalStores: StoreMap;
66
- export declare const rootElementContext: {
67
- stores: StoreMap;
68
- };
69
108
  export {};
@@ -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,20 +1,18 @@
1
1
  export { $, effect, get, peek } from "./signals.js";
2
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 { type Mixin } from "./nodes/html.js";
3
8
  export { ref, type Ref } from "./ref.js";
4
- export { constructView } from "./nodes/view.js";
9
+ export { mount, type UnmountFn } from "./mount.js";
5
10
  export { deepEqual, shallowEqual, strictEqual } from "../utils.js";
6
- export { Stores, type StoreContext, type StoreFunction } from "./store.js";
7
- export { type Mixin, type MixinContext } from "./mixin.js";
8
- export { markup, portal, repeat, unless, when, constructMarkup } from "./markup.js";
9
- export type { Markup, MarkupElement } from "./markup.js";
10
11
  export { getEnv, setEnv } from "./env.js";
11
- export type { Env } from "./env.js";
12
12
  export { createLogger, setLogFilter, setLogLevels } from "./logger.js";
13
13
  export type { Logger, LoggerErrorContext, LoggerOptions, LogLevels } from "./logger.js";
14
- export { mount, type UnmountFn } from "./mount.js";
15
- export type { ViewContext, ViewElement, ViewFunction } from "./nodes/view.js";
14
+ export type { View, Store, InputType, Renderable, Env } from "../types.js";
16
15
  export type { CrashViewProps } from "./views/default-crash-view.js";
17
- export type { InputType, Renderable } from "../types.js";
18
16
  import type { IntrinsicElements as Elements } from "../types.js";
19
17
  declare global {
20
18
  namespace JSX {
@@ -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;
@@ -11,7 +11,7 @@ export interface Logger {
11
11
  log(...args: any[]): void;
12
12
  warn(...args: any[]): void;
13
13
  error(...args: any[]): void;
14
- crash(error: Error): void;
14
+ crash(error: Error): Error;
15
15
  }
16
16
  export interface LoggerOptions {
17
17
  /**
@@ -1,64 +1,68 @@
1
- import type { Mountable, Renderable } from "../types.js";
2
- import { type ElementContext } from "./context.js";
3
- import { View, type ViewContext, type ViewFunction, type ViewResult } from "./nodes/view.js";
1
+ import type { Renderable, View } from "../types.js";
2
+ import { Context } from "./context.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 | ViewFunction<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[];
33
- export declare function constructMarkup(markup: Markup | Markup[]): MarkupElement;
45
+ export declare function isMarkupNode(value: any): value is MarkupNode;
34
46
  export declare enum MarkupType {
35
47
  Text = "$text",
36
48
  Repeat = "$repeat",
37
49
  Dynamic = "$dynamic",
38
- Outlet = "$outlet",
39
- Fragment = "$fragment",
40
- Node = "$node",
50
+ DOM = "$dom",
41
51
  Portal = "$portal"
42
52
  }
43
- export interface MarkupAttributes {
53
+ export interface MarkupProps {
44
54
  [MarkupType.Text]: {
45
55
  value: any;
46
56
  };
47
57
  [MarkupType.Repeat]: {
48
58
  items: Signal<any[]>;
49
- keyFn: (value: any, index: number) => string | number | symbol;
50
- renderFn: (item: Signal<any>, index: Signal<number>, ctx: ViewContext) => ViewResult;
59
+ key: KeyFn<any>;
60
+ render: RenderFn<any>;
51
61
  };
52
62
  [MarkupType.Dynamic]: {
53
- source: Signal<Renderable>;
63
+ source: Signal<any>;
54
64
  };
55
- [MarkupType.Outlet]: {
56
- view: Signal<View<{}> | undefined>;
57
- };
58
- [MarkupType.Fragment]: {
59
- children: MaybeSignal<MarkupElement[]>;
60
- };
61
- [MarkupType.Node]: {
65
+ [MarkupType.DOM]: {
62
66
  value: Node;
63
67
  };
64
68
  [MarkupType.Portal]: {
@@ -67,31 +71,28 @@ export interface MarkupAttributes {
67
71
  };
68
72
  [tag: string]: Record<string, any>;
69
73
  }
70
- export declare function markup<T extends keyof MarkupAttributes>(type: T, attributes: MarkupAttributes[T], ...children: Renderable[]): Markup;
71
- export declare function markup<I>(type: ViewFunction<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;
72
77
  /**
73
- * Displays `thenContent` when `condition` is truthy and `elseContent` when falsy.
78
+ * If `condition` is truthy, displays `thenContent`, otherwise `elseContent`.
74
79
  */
75
80
  export declare function when(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
76
81
  /**
77
- * Inverted `when`. Displays `thenContent` when `condition` is falsy and `elseContent` when truthy.
82
+ * Inverted `when`. If `condition` is falsy, displays `thenContent`, otherwise `elseContent`.
78
83
  */
79
84
  export declare function unless(condition: MaybeSignal<any>, thenContent?: Renderable, elseContent?: Renderable): Markup;
80
85
  /**
81
- * Calls `renderFn` for each item in `items`. Dynamically adds and removes views as items change.
82
- * 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.
83
88
  */
84
- export declare function repeat<T>(items: MaybeSignal<T[]>, keyFn: (value: T, index: number) => string | number | symbol, renderFn: (item: Signal<T>, index: Signal<number>, ctx: ViewContext) => ViewResult): Markup;
89
+ export declare function repeat<T>(items: MaybeSignal<T[]>, key: KeyFn<T>, render: RenderFn<T>): Markup;
85
90
  /**
86
91
  * Renders `content` into a `parent` node anywhere in the page, rather than its usual position in the view.
87
92
  */
88
93
  export declare function portal(parent: Node, content: Renderable): Markup;
94
+ export declare function render(content: Renderable, context?: Context): MarkupNode;
89
95
  /**
90
- * Construct Markup metadata into a set of MarkupElements.
91
- */
92
- export declare function toMarkupElements(elementContext: ElementContext, markup: Markup | Markup[]): MarkupElement[];
93
- /**
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,10 +1,15 @@
1
+ import { Router } from "../router/router";
2
+ import type { View } from "../types";
3
+ import { Context } from "./context";
1
4
  import { type LoggerErrorContext } from "./logger";
2
- import { type ViewFunction } from "./nodes/view";
3
5
  export type UnmountFn = () => Promise<void>;
4
6
  export interface MountOptions {
5
- crashView?: ViewFunction<LoggerErrorContext>;
7
+ crashView?: View<LoggerErrorContext>;
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;
6
13
  }
7
- export declare function mount(parent: Element, view: any, options?: MountOptions): Promise<UnmountFn>;
8
- export declare function mount(parent: Element, router: any, options?: MountOptions): Promise<UnmountFn>;
9
- export declare function mount(parent: string, view: any, options?: MountOptions): Promise<UnmountFn>;
10
- export declare function mount(parent: string, router: any, options?: MountOptions): Promise<UnmountFn>;
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>;
@@ -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
- import type { ElementContext } from "../context.js";
3
- import { type MarkupElement } from "../markup.js";
1
+ import type { Context } from "../context.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
- elementContext: ElementContext;
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
- private elementContext;
21
- private source;
15
+ private context;
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
- import { type ElementContext } from "../context.js";
2
- import { type MarkupElement } from "../markup.js";
3
- import { IS_MARKUP_ELEMENT } from "../symbols.js";
4
- type HTMLOptions = {
5
- elementContext: ElementContext;
6
- tag: string;
7
- props: Record<string, any>;
8
- children?: any[];
9
- };
10
- export declare class HTML implements MarkupElement {
11
- [IS_MARKUP_ELEMENT]: boolean;
12
- domNode: SVGElement | HTMLElement;
13
- elementContext: ElementContext;
1
+ import { Context } from "../context.js";
2
+ import { type MarkupNode } from "../markup.js";
3
+ import { IS_MARKUP_NODE } from "../symbols.js";
4
+ export type Mixin<E extends Element = Element> = (element: E, context: Context) => void;
5
+ export declare class HTML implements MarkupNode {
6
+ [IS_MARKUP_NODE]: boolean;
7
+ root: HTMLElement | SVGElement;
8
+ private context;
14
9
  private props;
15
- private childMarkup;
16
- private children;
10
+ private children?;
11
+ private childNodes;
17
12
  private unsubscribers;
18
- private mixin?;
19
- private logger;
20
13
  private ref?;
21
14
  private canClickAway;
22
15
  get isMounted(): boolean;
23
- constructor({ tag, props, children, elementContext }: 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
- import type { ElementContext } 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
- elementContext: ElementContext;
9
- }
2
+ import { Context } from "../context.js";
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 ElementContext } 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 ViewContext, type ViewResult } from "./view.js";
6
- interface RepeatOptions<T> {
7
- elementContext: ElementContext;
8
- items: Signal<T[]>;
9
- keyFn: (item: T, index: number) => string | number | symbol;
10
- renderFn: (item: Signal<T>, index: Signal<number>, ctx: ViewContext) => 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 elementContext;
19
- private renderFn;
20
- private keyFn;
21
17
  get isMounted(): boolean;
22
- constructor({ elementContext, 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 {};