@tempots/dom 23.0.2 → 24.0.0-next.1

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.1",
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,7 @@
1
1
  import { Renderable } from '../types/domain';
2
2
  import { DOMContext } from '../dom/dom-context';
3
+ import { HeadlessPortal } from '../dom/headless-context';
4
+ import { Value } from '../std/value';
3
5
  /**
4
6
  * Renders the given `renderable` with the provided `ctx` DOM context.
5
7
  *
@@ -34,6 +36,14 @@ export type RenderOptions = {
34
36
  * @public
35
37
  */
36
38
  export declare const render: (node: Renderable, parent: Node | string, { doc, clear }?: RenderOptions) => () => void;
39
+ export declare const runHeadless: (makeRenderable: () => Renderable, { startUrl, selector, }?: {
40
+ startUrl?: Value<string>;
41
+ selector?: string;
42
+ }) => {
43
+ clear: () => void;
44
+ root: HeadlessPortal;
45
+ currentURL: import('..').Prop<string>;
46
+ };
37
47
  /**
38
48
  * Represents an error that occurs during rendering.
39
49
  * @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.
package/dom/ssr.d.ts DELETED
@@ -1,50 +0,0 @@
1
- import { TNode, Renderable } from '../types/domain';
2
- import { DOMContext } from './dom-context';
3
- /**
4
- * @internal
5
- */
6
- export declare const _maybeAddAttributeTracker: (ctx: DOMContext, name: string) => void;
7
- /**
8
- * @internal
9
- */
10
- export declare const _maybeAddClassTracker: (ctx: DOMContext) => void;
11
- /**
12
- * @internal
13
- */
14
- export declare const _addNodeTracker: (element: Element) => void;
15
- /**
16
- * @internal
17
- */
18
- export declare const _maybeAddTextTracker: (ctx: DOMContext) => void;
19
- export declare const removeTextTrackers: (doc: Document) => void;
20
- /**
21
- * @internal
22
- */
23
- export declare const _clearSSR: (doc: Document) => void;
24
- /**
25
- * Prepares for server-side rendering (SSR) by setting a timeout. The returned
26
- * promise resolves when all the `useSSRDone` calls have been completed.
27
- *
28
- * @param timeoutSeconds - The timeout duration in seconds (default: 30 seconds).
29
- * @returns A promise that resolves when all useSSRDone calls have been completed.
30
- * @public
31
- */
32
- export declare const prepareSSR: (timeoutSeconds?: number) => Promise<void>;
33
- /**
34
- * Provides a way to signal that a renderable has been rendered on the server.
35
- * Multiple ussSSRDone calls can be made in parallel, and the promise returned
36
- * by `prepareSSR` will resolve when all the `useSSRDone` calls have been completed.
37
- *
38
- * @param child - A function that takes a `done` callback and returns a `TNode`.
39
- * @returns A renderable value.
40
- * @public
41
- */
42
- export declare const UseSSRDone: (child: (done: () => void) => TNode) => Renderable;
43
- /**
44
- * Checks if the code is running on the server-side (SSR - Server-Side Rendering).
45
- * The flag is set by running the `prepareSSR` function.
46
- *
47
- * @returns Returns true if the code is running on the server-side, false otherwise.
48
- * @public
49
- */
50
- export declare const isSSR: () => boolean;
File without changes