@tempots/dom 23.0.2 → 24.0.0-next.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tempots/dom",
3
- "version": "23.0.2",
3
+ "version": "24.0.0-next.0",
4
4
  "type": "module",
5
5
  "main": "./index.cjs",
6
6
  "module": "./index.js",
@@ -1,3 +1,4 @@
1
+ import { BrowserContext } from '../dom/browser-context';
1
2
  import { Renderable } from '../types/domain';
2
3
  /**
3
4
  * Creates a renderable DOM node.
@@ -7,4 +8,4 @@ import { Renderable } from '../types/domain';
7
8
  * @returns A function that can be called to remove the rendered node from the DOM.
8
9
  * @public
9
10
  */
10
- export declare const DOMNode: (node: Node) => Renderable;
11
+ export declare const DOMNode: (node: Node) => Renderable<BrowserContext>;
@@ -158,19 +158,19 @@ export declare const input: {
158
158
  number: (...children: TNode[]) => Renderable;
159
159
  text: (...children: TNode[]) => Renderable;
160
160
  color: (...children: TNode[]) => Renderable;
161
- image: (...children: TNode[]) => Renderable;
161
+ hidden: (...children: TNode[]) => Renderable;
162
162
  button: (...children: TNode[]) => Renderable;
163
163
  search: (...children: TNode[]) => Renderable;
164
164
  time: (...children: TNode[]) => Renderable;
165
+ image: (...children: TNode[]) => Renderable;
166
+ reset: (...children: TNode[]) => Renderable;
167
+ submit: (...children: TNode[]) => Renderable;
165
168
  checkbox: (...children: TNode[]) => Renderable;
166
169
  radio: (...children: TNode[]) => Renderable;
167
170
  file: (...children: TNode[]) => Renderable;
168
171
  password: (...children: TNode[]) => Renderable;
169
- submit: (...children: TNode[]) => Renderable;
170
- reset: (...children: TNode[]) => Renderable;
171
172
  date: (...children: TNode[]) => Renderable;
172
173
  range: (...children: TNode[]) => Renderable;
173
- hidden: (...children: TNode[]) => Renderable;
174
174
  month: (...children: TNode[]) => Renderable;
175
175
  week: (...children: TNode[]) => Renderable;
176
176
  email: (...children: TNode[]) => Renderable;
@@ -0,0 +1,10 @@
1
+ import { BrowserContext } from '../dom/browser-context';
2
+ import { Clear, Renderable } from '../types/domain';
3
+ /**
4
+ * Returns a renderable function that executes the given function with the current DOMContext as argument.
5
+ *
6
+ * @param fn - The function to be executed with the DOMContext argument.
7
+ * @returns A Clear function that can be used to clean up any resources associated with the execution.
8
+ * @public
9
+ */
10
+ export declare const OnBrowserCtx: (fn: (ctx: BrowserContext) => Clear) => Renderable;
@@ -6,4 +6,4 @@ import { DOMContext } from '../dom/dom-context';
6
6
  * @returns A renderable function that takes a DOMContext and returns a function that takes a boolean indicating whether to remove the tree.
7
7
  * @public
8
8
  */
9
- export declare const OnUnmount: (fn: (removeTree: boolean, ctx: DOMContext) => void) => Renderable;
9
+ export declare const OnDispose: (fn: (removeTree: boolean, ctx: DOMContext) => void) => Renderable;
@@ -7,4 +7,4 @@ import { Clear, Renderable } from '../types/domain';
7
7
  * @returns - The renderable function.
8
8
  * @public
9
9
  */
10
- export declare const OnMount: <T extends Element>(fn: (element: T) => Clear | undefined | void) => Renderable;
10
+ export declare const OnElement: <T extends HTMLElement>(fn: (element: T) => Clear | undefined | void) => Renderable;
@@ -0,0 +1,10 @@
1
+ import { HeadlessContext } from '../dom/headless-context';
2
+ import { Clear, Renderable } from '../types/domain';
3
+ /**
4
+ * Returns a renderable function that executes the given function with the current DOMContext as argument.
5
+ *
6
+ * @param fn - The function to be executed with the DOMContext argument.
7
+ * @returns A Clear function that can be used to clean up any resources associated with the execution.
8
+ * @public
9
+ */
10
+ export declare const OnHeadlessCtx: (fn: (ctx: HeadlessContext) => Clear) => Renderable;
@@ -0,0 +1,46 @@
1
+ import { Renderable, TNode } from '../types/domain';
2
+ /**
3
+ * A provider mark for a signal representing the current appearance type.
4
+ * @public
5
+ */
6
+ export declare const probeMarker: import('../types/domain').ProviderMark<(identifier: symbol) => void>;
7
+ /**
8
+ * Provides a child component with a probe, which can be used to trigger a callback when all probes with the same identifier are resolved.
9
+ * To resolve a probe, call the `done` function passed using the `UseProbe` renderable.
10
+ *
11
+ * @param identifier - The identifier for the probe.
12
+ * @param callback - The callback to be triggered when the probe is no longer needed.
13
+ * @param child - The child component to be provided with the probe.
14
+ * @returns The child component with the probe.
15
+ * @public
16
+ */
17
+ export declare const ProvideProbe: (identifier: symbol, callback: () => void, child: TNode) => Renderable;
18
+ /**
19
+ * Uses a probe, which can be used to trigger a callback when all probes with the same identifier are resolved.
20
+ * To resolve a probe, call the `done` function.
21
+ *
22
+ * @param identifier - The identifier for the probe.
23
+ * @param fn - The callback to be triggered when the probe is no longer needed.
24
+ * @returns The child component with the probe.
25
+ * @public
26
+ */
27
+ export declare const UseProbe: (identifier: symbol, fn: (done: () => void) => TNode) => Renderable;
28
+ /**
29
+ * Provides a global probe, which can be used to trigger a callback when all probes with the same identifier are resolved.
30
+ * To resolve a probe, call the `done` function passed using the `UseProbe` renderable.
31
+ *
32
+ * @param callback - The callback to be triggered when the probe is no longer needed.
33
+ * @param child - The child component to be provided with the probe.
34
+ * @returns The child component with the probe.
35
+ * @public
36
+ */
37
+ export declare const ProvideGlobalProbe: (callback: () => void, child: TNode) => Renderable;
38
+ /**
39
+ * Uses a global probe, which can be used to trigger a callback when all probes with the same identifier are resolved.
40
+ * To resolve a probe, call the `done` function.
41
+ *
42
+ * @param fn - The callback to be triggered when the probe is no longer needed.
43
+ * @returns The child component with the probe.
44
+ * @public
45
+ */
46
+ export declare const UseGlobalProbe: (fn: (done: () => void) => TNode) => Renderable;
@@ -1,5 +1,6 @@
1
1
  import { Renderable } from '../types/domain';
2
2
  import { DOMContext } from '../dom/dom-context';
3
+ import { HeadlessPortal } from '../dom/headless-context';
3
4
  /**
4
5
  * Renders the given `renderable` with the provided `ctx` DOM context.
5
6
  *
@@ -34,6 +35,11 @@ export type RenderOptions = {
34
35
  * @public
35
36
  */
36
37
  export declare const render: (node: Renderable, parent: Node | string, { doc, clear }?: RenderOptions) => () => void;
38
+ export declare const runHeadless: (node: Renderable, currentUrl: string) => {
39
+ clear: () => void;
40
+ root: HeadlessPortal;
41
+ currentURL: import('../std/signal').Prop<string>;
42
+ };
37
43
  /**
38
44
  * Represents an error that occurs during rendering.
39
45
  * @public
package/types/domain.d.ts CHANGED
@@ -6,7 +6,7 @@ import { Value } from '../std/value';
6
6
  * @returns A function that clears the rendered content.
7
7
  * @public
8
8
  */
9
- export type Renderable = (ctx: DOMContext) => Clear;
9
+ export type Renderable<CTX extends DOMContext = DOMContext> = (ctx: CTX) => Clear;
10
10
  /**
11
11
  * Represents a node in the rendering tree.
12
12
  * It can be a renderable element, a string value, undefined, null, or an array of renderable elements.
File without changes