@firsthandjs/dom 0.8.0 → 0.9.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/dist/chunk-6BRSYQCI.js +1 -0
- package/dist/chunk-E4GAI5XA.js +1 -0
- package/dist/chunk-P4PXTIUD.js +1 -0
- package/dist/claim.d.ts +86 -0
- package/dist/claim.d.ts.map +1 -0
- package/dist/dev-chunk-6V32MCOI.js +45 -0
- package/dist/dev-chunk-ADHDPKZW.js +525 -0
- package/dist/{dev-chunk-2CKM3OGC.js → dev-chunk-MKONDKMD.js} +152 -450
- package/dist/dev.d.ts +11 -0
- package/dist/dev.d.ts.map +1 -1
- package/dist/dev.prod.d.ts +1 -0
- package/dist/dev.prod.d.ts.map +1 -1
- package/dist/hydrate.d.ts +102 -0
- package/dist/hydrate.d.ts.map +1 -0
- package/dist/hydrate.dev.js +160 -0
- package/dist/hydrate.js +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.dev.js +19 -35
- package/dist/index.js +1 -1
- package/dist/insert.d.ts +64 -1
- package/dist/insert.d.ts.map +1 -1
- package/dist/internal.d.ts +1 -0
- package/dist/internal.d.ts.map +1 -1
- package/dist/internal.dev.js +30 -12
- package/dist/internal.js +1 -1
- package/dist/list.d.ts.map +1 -1
- package/dist/props.d.ts.map +1 -1
- package/dist/render.d.ts +9 -0
- package/dist/render.d.ts.map +1 -1
- package/dist/template.d.ts.map +1 -1
- package/package.json +7 -2
- package/dist/chunk-EWYTWH5D.js +0 -1
package/dist/dev.d.ts
CHANGED
|
@@ -61,4 +61,15 @@ export declare function devRan(store: {
|
|
|
61
61
|
export declare function devHandedNewFunction(store: {
|
|
62
62
|
name: string;
|
|
63
63
|
}, value: unknown): void;
|
|
64
|
+
/**
|
|
65
|
+
* Reports markup a server sent that is not the markup this run describes.
|
|
66
|
+
*
|
|
67
|
+
* Only the element's own attributes are compared, and only in development:
|
|
68
|
+
* what is inside it may already have been hydrated, and parsing the template
|
|
69
|
+
* to compare more is the cost hydration exists to avoid. That is enough to
|
|
70
|
+
* name the mistake, which is always the same mistake — a view that renders
|
|
71
|
+
* one thing on a server and another in a browser, from props or state that
|
|
72
|
+
* differ between them.
|
|
73
|
+
*/
|
|
74
|
+
export declare function devHydrationMismatch(node: Element, html: string): void;
|
|
64
75
|
//# sourceMappingURL=dev.d.ts.map
|
package/dist/dev.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.d.ts","sourceRoot":"","sources":["../src/dev.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,wBAAgB,OAAO,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAE7C;AAID,6EAA6E;AAC7E,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAK9D;AAED;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAWzD;AAkBD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE5D;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAKhE;AAKD;;;;;;;GAOG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkBpF;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,E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ts
CHANGED
|
@@ -13,4 +13,5 @@ export declare function devRan(_store: {
|
|
|
13
13
|
export declare function devHandedNewFunction(_store: {
|
|
14
14
|
name: string;
|
|
15
15
|
}, _value: unknown): void;
|
|
16
|
+
export declare function devHydrationMismatch(_node: Element, _html: string): void;
|
|
16
17
|
//# sourceMappingURL=dev.prod.d.ts.map
|
package/dist/dev.prod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAErF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAEpF"}
|
|
1
|
+
{"version":3,"file":"dev.prod.d.ts","sourceRoot":"","sources":["../src/dev.prod.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,wBAAgB,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAE9C;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAE1D;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAE9D;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAEhE;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC,CAElE;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAErF;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAEpF;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAExE"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adopting server-rendered markup instead of building it.
|
|
3
|
+
*
|
|
4
|
+
* ```ts
|
|
5
|
+
* import { hydrate } from '@firsthandjs/dom/hydrate';
|
|
6
|
+
*
|
|
7
|
+
* hydrate(() => <App />, document.getElementById('app')!);
|
|
8
|
+
* ```
|
|
9
|
+
*
|
|
10
|
+
* Its own entry point, not part of `@firsthandjs/dom`, for one reason: an
|
|
11
|
+
* application without a server must not carry this. Nothing in the render
|
|
12
|
+
* path imports this module — `template` and `insert` read the holder in
|
|
13
|
+
* `claim.ts`, which stays empty — so a bundle that never imports it never
|
|
14
|
+
* contains it.
|
|
15
|
+
*
|
|
16
|
+
* A hydrating render runs exactly the same compiled code as a fresh one. What
|
|
17
|
+
* changes is where nodes come from: `template()` hands back a node the server
|
|
18
|
+
* already sent rather than a clone, and a dynamic child finds its content in
|
|
19
|
+
* place rather than creating it. Nothing else in the render path knows.
|
|
20
|
+
*
|
|
21
|
+
* The only thing that makes that possible is knowing which nodes belong to
|
|
22
|
+
* which dynamic child, and the server says so: it wraps every dynamic child in
|
|
23
|
+
* `<!--[-->` … marker, where the marker is the same comment the browser's own
|
|
24
|
+
* template has at that position. Two consequences follow, and they are the
|
|
25
|
+
* whole design:
|
|
26
|
+
*
|
|
27
|
+
* - **Navigation still works.** `firstChild.nextSibling` would walk into the
|
|
28
|
+
* content of a dynamic child, because the content has a length the template
|
|
29
|
+
* does not. Compiled with `hydratable`, navigation goes through `first` and
|
|
30
|
+
* `next` instead, which step over a whole region in one move — landing on
|
|
31
|
+
* the marker, which is the node the template has there.
|
|
32
|
+
* - **Text does not run together.** The parser would read `Hello, ` and a
|
|
33
|
+
* dynamic `Ada` as one text node. The opening comment sits between them, so
|
|
34
|
+
* the part gets a text node of its own to write to.
|
|
35
|
+
*
|
|
36
|
+
* The comments are in the server's markup only. A build without SSR emits
|
|
37
|
+
* neither them nor the navigation helpers, and pays nothing at all.
|
|
38
|
+
*/
|
|
39
|
+
import type { Dispose } from '@firsthandjs/core';
|
|
40
|
+
import { type Claimed, type Region } from './claim.js';
|
|
41
|
+
import type { View } from './component.js';
|
|
42
|
+
/**
|
|
43
|
+
* Takes over markup a server already sent.
|
|
44
|
+
*
|
|
45
|
+
* The same call as `render`, against the same view, with the same result — a
|
|
46
|
+
* live application and a disposer. What it does not do is build anything that
|
|
47
|
+
* is already there: every element is adopted, every text node is kept, and the
|
|
48
|
+
* only writes are the listeners and the properties markup cannot express.
|
|
49
|
+
*
|
|
50
|
+
* The view has to be the view the server rendered — same props, same state,
|
|
51
|
+
* same answer. Where it is not:
|
|
52
|
+
*
|
|
53
|
+
* - A **dynamic** value that disagrees is written, as it would be on any other
|
|
54
|
+
* change. The page ends up right; the work hydration saved is spent.
|
|
55
|
+
* - A **different element** is not adopted. The browser builds its own and the
|
|
56
|
+
* part it belongs to puts it in place of what was sent.
|
|
57
|
+
* - **Static markup** that disagrees is kept as the server wrote it, because
|
|
58
|
+
* static markup is the markup nothing ever writes again. Development says so
|
|
59
|
+
* by name; production cannot, and a view that renders two different things
|
|
60
|
+
* from the same props is a bug this cannot repair.
|
|
61
|
+
*/
|
|
62
|
+
export declare function hydrate(view: () => View, container?: ParentNode): Dispose;
|
|
63
|
+
/**
|
|
64
|
+
* Runs `body` against server markup already in `container`.
|
|
65
|
+
*
|
|
66
|
+
* Nested calls are counted rather than nested: an island inside an island is
|
|
67
|
+
* one hydration as far as the markup is concerned, and the outer one finishes
|
|
68
|
+
* the sweep.
|
|
69
|
+
*/
|
|
70
|
+
export declare function hydrateWith<T>(container: Node, body: () => T): T;
|
|
71
|
+
/**
|
|
72
|
+
* The next node this region has not handed out yet, if it is a `tag`.
|
|
73
|
+
*
|
|
74
|
+
* A node that is not what was asked for is left where it is rather than
|
|
75
|
+
* consumed: the caller builds its own, and the part it belongs to replaces
|
|
76
|
+
* what is there. Nothing is adopted on a guess.
|
|
77
|
+
*/
|
|
78
|
+
export declare function adopt(tag: string): Node | null;
|
|
79
|
+
/**
|
|
80
|
+
* Finds the region belonging to the next dynamic child of `parent`.
|
|
81
|
+
*
|
|
82
|
+
* Dynamic children are claimed in document order, which is the order the
|
|
83
|
+
* compiled code reaches them in, so this is a cursor and never a search.
|
|
84
|
+
* `marker` is what navigation landed on, and it has to be where the region
|
|
85
|
+
* ends: if it is not, the server and the client disagree about this subtree
|
|
86
|
+
* and the caller renders it from nothing instead.
|
|
87
|
+
*/
|
|
88
|
+
export declare function claimRegion(parent: Node, marker: Node | null): Claimed | null;
|
|
89
|
+
/**
|
|
90
|
+
* Puts an anchor where hydration has got to, and hands back its parent.
|
|
91
|
+
*
|
|
92
|
+
* A keyed list's row that is a view is bound here rather than with the rest,
|
|
93
|
+
* because by then the reconciler would have put the list's anchors where the
|
|
94
|
+
* server's rows are and taken the rows out. The anchor goes in at the point
|
|
95
|
+
* the region has reached, and the row runs there — which adopts the nodes the
|
|
96
|
+
* server sent for it, in row order, because that is the order the markup is
|
|
97
|
+
* in.
|
|
98
|
+
*/
|
|
99
|
+
export declare function place(anchor: Node): Node | null;
|
|
100
|
+
/** Makes `region` the one nodes are adopted from while `body` runs. */
|
|
101
|
+
export declare function within<T>(region: Region, body: () => T): T;
|
|
102
|
+
//# sourceMappingURL=hydrate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hydrate.d.ts","sourceRoot":"","sources":["../src/hydrate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAa,KAAK,OAAO,EAAe,KAAK,MAAM,EAAE,MAAM,YAAY,CAAC;AAC/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AA0B3C;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,EAAE,SAAS,GAAE,UAA0B,GAAG,OAAO,CAIxF;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAgBhE;AAaD;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAW9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAqD7E;AAED;;;;;;;;;GASG;AACH,wBAAgB,KAAK,CAAC,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,CAK/C;AAED,uEAAuE;AACvE,wBAAgB,MAAM,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAQ1D"}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
import {
|
|
2
|
+
mount
|
|
3
|
+
} from "./dev-chunk-6V32MCOI.js";
|
|
4
|
+
import {
|
|
5
|
+
hydration
|
|
6
|
+
} from "./dev-chunk-ADHDPKZW.js";
|
|
7
|
+
|
|
8
|
+
// packages/dom/src/hydrate.ts
|
|
9
|
+
var COMMENT_NODE = 8;
|
|
10
|
+
var TEXT_NODE = 3;
|
|
11
|
+
var OPEN = "[";
|
|
12
|
+
var claim = null;
|
|
13
|
+
var depth = 0;
|
|
14
|
+
var cursors = /* @__PURE__ */ new WeakMap();
|
|
15
|
+
var openers = [];
|
|
16
|
+
var offers = /* @__PURE__ */ new Map();
|
|
17
|
+
function hydrate(view, container = document.body) {
|
|
18
|
+
return mount(view, container, (body) => {
|
|
19
|
+
hydrateWith(container, body);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function hydrateWith(container, body) {
|
|
23
|
+
const outer = claim;
|
|
24
|
+
const previous = depth;
|
|
25
|
+
depth++;
|
|
26
|
+
hydration.current = claimer;
|
|
27
|
+
claim = { node: container.firstChild, end: null };
|
|
28
|
+
try {
|
|
29
|
+
return body();
|
|
30
|
+
} finally {
|
|
31
|
+
claim = outer;
|
|
32
|
+
depth = previous;
|
|
33
|
+
if (depth === 0) {
|
|
34
|
+
hydration.current = null;
|
|
35
|
+
finish();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function finish() {
|
|
40
|
+
for (let i = 0; i < openers.length; i++) {
|
|
41
|
+
const node = openers[i];
|
|
42
|
+
node.parentNode?.removeChild(node);
|
|
43
|
+
}
|
|
44
|
+
openers = [];
|
|
45
|
+
cursors = /* @__PURE__ */ new WeakMap();
|
|
46
|
+
offers = /* @__PURE__ */ new Map();
|
|
47
|
+
}
|
|
48
|
+
function adopt(tag) {
|
|
49
|
+
if (claim === null) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const node = claim.node;
|
|
53
|
+
if (node === null || node.nodeName !== tag) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
const after = node.nextSibling;
|
|
57
|
+
claim.node = after === claim.end ? null : after;
|
|
58
|
+
return node;
|
|
59
|
+
}
|
|
60
|
+
function claimRegion(parent, marker) {
|
|
61
|
+
if (marker !== null) {
|
|
62
|
+
const offered = offers.get(marker);
|
|
63
|
+
if (offered !== void 0) {
|
|
64
|
+
offers.delete(marker);
|
|
65
|
+
return offered;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const held = cursors.get(parent);
|
|
69
|
+
const fromTheTop = held === void 0;
|
|
70
|
+
const node = fromTheTop ? parent.firstChild : held;
|
|
71
|
+
let start;
|
|
72
|
+
let end;
|
|
73
|
+
const stop = fromTheTop ? marker : null;
|
|
74
|
+
let open = node;
|
|
75
|
+
while (open !== null && open !== stop && !isOpen(open)) {
|
|
76
|
+
open = open.nextSibling;
|
|
77
|
+
}
|
|
78
|
+
if (open !== null && open !== stop) {
|
|
79
|
+
end = closeOf(open);
|
|
80
|
+
if (marker !== null && marker !== end) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
openers.push(open);
|
|
84
|
+
start = open.nextSibling;
|
|
85
|
+
} else if (fromTheTop) {
|
|
86
|
+
start = node;
|
|
87
|
+
end = marker;
|
|
88
|
+
} else {
|
|
89
|
+
return null;
|
|
90
|
+
}
|
|
91
|
+
cursors.set(parent, end === null ? null : end.nextSibling);
|
|
92
|
+
if (start === end) {
|
|
93
|
+
start = null;
|
|
94
|
+
}
|
|
95
|
+
const nodes = [];
|
|
96
|
+
for (let one = start; one !== null && one !== end; one = one.nextSibling) {
|
|
97
|
+
nodes.push(one);
|
|
98
|
+
}
|
|
99
|
+
const only = nodes.length === 1 ? nodes[0] : null;
|
|
100
|
+
return {
|
|
101
|
+
nodes: nodes.length === 0 ? null : only ?? nodes,
|
|
102
|
+
text: only !== null && only.nodeType === TEXT_NODE ? only.data : void 0,
|
|
103
|
+
region: { node: start, end }
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function place(anchor) {
|
|
107
|
+
const node = claim === null ? null : claim.node;
|
|
108
|
+
const parent = node?.parentNode ?? null;
|
|
109
|
+
parent?.insertBefore(anchor, node);
|
|
110
|
+
return parent;
|
|
111
|
+
}
|
|
112
|
+
function within(region, body) {
|
|
113
|
+
const outer = claim;
|
|
114
|
+
claim = region;
|
|
115
|
+
try {
|
|
116
|
+
return body();
|
|
117
|
+
} finally {
|
|
118
|
+
claim = outer;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function isOpen(node) {
|
|
122
|
+
return node !== null && node.nodeType === COMMENT_NODE && node.nodeValue === OPEN;
|
|
123
|
+
}
|
|
124
|
+
function closeOf(open) {
|
|
125
|
+
let level = 0;
|
|
126
|
+
for (let node = open.nextSibling; node !== null; node = node.nextSibling) {
|
|
127
|
+
if (node.nodeType !== COMMENT_NODE) {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
if (isOpen(node)) {
|
|
131
|
+
level++;
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (level === 0) {
|
|
135
|
+
return node;
|
|
136
|
+
}
|
|
137
|
+
level--;
|
|
138
|
+
}
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
function step(node) {
|
|
142
|
+
return isOpen(node) ? closeOf(node) : node;
|
|
143
|
+
}
|
|
144
|
+
function tagOf(html) {
|
|
145
|
+
return html.slice(1, html.search(/[\s/>]/)).toUpperCase();
|
|
146
|
+
}
|
|
147
|
+
function keep(slot, parent, anchor, claimed) {
|
|
148
|
+
parent.insertBefore(anchor, claimed.region.end);
|
|
149
|
+
slot.node = claimed.nodes === null ? anchor : [...Array.isArray(claimed.nodes) ? claimed.nodes : [claimed.nodes], anchor];
|
|
150
|
+
offers.set(anchor, claimed);
|
|
151
|
+
}
|
|
152
|
+
var claimer = { tag: tagOf, adopt, claim: claimRegion, within, keep, step, place };
|
|
153
|
+
export {
|
|
154
|
+
adopt,
|
|
155
|
+
claimRegion,
|
|
156
|
+
hydrate,
|
|
157
|
+
hydrateWith,
|
|
158
|
+
place,
|
|
159
|
+
within
|
|
160
|
+
};
|
package/dist/hydrate.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as T}from"./chunk-6BRSYQCI.js";import{b as a}from"./chunk-P4PXTIUD.js";var m=8,C=3,w="[",t=null,p=0,g=new WeakMap,c=[],N=new Map;function F(e,n=document.body){return T(e,n,o=>{M(n,o)})}function M(e,n){let o=t,l=p;p++,a.current=j,t={node:e.firstChild,end:null};try{return n()}finally{t=o,p=l,p===0&&(a.current=null,O())}}function O(){for(let e=0;e<c.length;e++){let n=c[e];n.parentNode?.removeChild(n)}c=[],g=new WeakMap,N=new Map}function S(e){if(t===null)return null;let n=t.node;if(n===null||n.nodeName!==e)return null;let o=n.nextSibling;return t.node=o===t.end?null:o,n}function v(e,n){if(n!==null){let r=N.get(n);if(r!==void 0)return N.delete(n),r}let o=g.get(e),l=o===void 0,h=l?e.firstChild:o,d,u,x=l?n:null,i=h;for(;i!==null&&i!==x&&!y(i);)i=i.nextSibling;if(i!==null&&i!==x){if(u=b(i),n!==null&&n!==u)return null;c.push(i),d=i.nextSibling}else if(l)d=h,u=n;else return null;g.set(e,u===null?null:u.nextSibling),d===u&&(d=null);let s=[];for(let r=d;r!==null&&r!==u;r=r.nextSibling)s.push(r);let f=s.length===1?s[0]:null;return{nodes:s.length===0?null:f??s,text:f!==null&&f.nodeType===C?f.data:void 0,region:{node:d,end:u}}}function E(e){let n=t===null?null:t.node,o=n?.parentNode??null;return o?.insertBefore(e,n),o}function D(e,n){let o=t;t=e;try{return n()}finally{t=o}}function y(e){return e!==null&&e.nodeType===m&&e.nodeValue===w}function b(e){let n=0;for(let o=e.nextSibling;o!==null;o=o.nextSibling)if(o.nodeType===m){if(y(o)){n++;continue}if(n===0)return o;n--}return null}function R(e){return y(e)?b(e):e}function W(e){return e.slice(1,e.search(/[\s/>]/)).toUpperCase()}function V(e,n,o,l){n.insertBefore(o,l.region.end),e.node=l.nodes===null?o:[...Array.isArray(l.nodes)?l.nodes:[l.nodes],o],N.set(o,l)}var j={tag:W,adopt:S,claim:v,within:D,keep:V,step:R,place:E};export{S as adopt,v as claimRegion,F as hydrate,M as hydrateWith,E as place,D as within};
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Re-exports the reactive core so that applications have one import site.
|
|
5
5
|
*/
|
|
6
|
-
export { component, defineElement, setElementPrefix, createComponent } from './component.js';
|
|
6
|
+
export { component, defineElement, setElementPrefix, createComponent, view } from './component.js';
|
|
7
7
|
export { setComponentAdapter, FirsthandComponentError } from './adapter.js';
|
|
8
8
|
export type { ComponentAdapter } from './adapter.js';
|
|
9
9
|
export type { Component, ComponentOptions, AttributeCodec, View, Render } from './component.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,gBAAgB,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AACnG,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AAC5E,YAAY,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAChG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAExC,OAAO,EACL,MAAM,EACN,QAAQ,EACR,MAAM,EACN,KAAK,EACL,OAAO,EACP,SAAS,EACT,UAAU,EACV,UAAU,EACV,YAAY,EACZ,aAAa,EACb,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,GACvB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EACV,WAAW,EACX,OAAO,EACP,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,aAAa,EACb,MAAM,GACP,MAAM,mBAAmB,CAAC"}
|
package/dist/index.dev.js
CHANGED
|
@@ -1,47 +1,30 @@
|
|
|
1
1
|
import {
|
|
2
2
|
FirsthandComponentError,
|
|
3
|
-
applyChild,
|
|
4
3
|
component,
|
|
5
4
|
createComponent,
|
|
6
5
|
defineElement,
|
|
7
|
-
insert,
|
|
8
6
|
list,
|
|
9
7
|
mergeProps,
|
|
10
8
|
off,
|
|
11
9
|
on,
|
|
12
10
|
setComponentAdapter,
|
|
13
|
-
setElementPrefix
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
createRoot((stop) => {
|
|
21
|
-
dispose = stop;
|
|
22
|
-
const result = untrack(view);
|
|
23
|
-
if (typeof result === "function") {
|
|
24
|
-
insert(container, result);
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
let slot = null;
|
|
28
|
-
slot = applyChild(container, null, null, result);
|
|
29
|
-
onCleanup(() => {
|
|
30
|
-
applyChild(container, null, slot, null);
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
return dispose;
|
|
34
|
-
}
|
|
11
|
+
setElementPrefix,
|
|
12
|
+
view
|
|
13
|
+
} from "./dev-chunk-MKONDKMD.js";
|
|
14
|
+
import {
|
|
15
|
+
render
|
|
16
|
+
} from "./dev-chunk-6V32MCOI.js";
|
|
17
|
+
import "./dev-chunk-ADHDPKZW.js";
|
|
35
18
|
|
|
36
19
|
// packages/dom/src/portal.ts
|
|
37
|
-
import { onCleanup
|
|
38
|
-
function portal(
|
|
20
|
+
import { onCleanup } from "@firsthandjs/core";
|
|
21
|
+
function portal(view2, target) {
|
|
39
22
|
const nodes = [];
|
|
40
|
-
collectNodes(
|
|
23
|
+
collectNodes(view2, nodes);
|
|
41
24
|
for (let i = 0; i < nodes.length; i++) {
|
|
42
25
|
target.appendChild(nodes[i]);
|
|
43
26
|
}
|
|
44
|
-
|
|
27
|
+
onCleanup(() => {
|
|
45
28
|
for (let i = 0; i < nodes.length; i++) {
|
|
46
29
|
const node = nodes[i];
|
|
47
30
|
node.parentNode?.removeChild(node);
|
|
@@ -72,9 +55,9 @@ import {
|
|
|
72
55
|
computed,
|
|
73
56
|
effect,
|
|
74
57
|
batch,
|
|
75
|
-
untrack
|
|
76
|
-
onCleanup as
|
|
77
|
-
createRoot
|
|
58
|
+
untrack,
|
|
59
|
+
onCleanup as onCleanup2,
|
|
60
|
+
createRoot,
|
|
78
61
|
catchError,
|
|
79
62
|
runWithOwner,
|
|
80
63
|
createContext,
|
|
@@ -95,14 +78,14 @@ export {
|
|
|
95
78
|
computed,
|
|
96
79
|
createComponent,
|
|
97
80
|
createContext,
|
|
98
|
-
|
|
81
|
+
createRoot,
|
|
99
82
|
defineElement,
|
|
100
83
|
effect,
|
|
101
84
|
list,
|
|
102
85
|
mergeProps,
|
|
103
86
|
off,
|
|
104
87
|
on,
|
|
105
|
-
|
|
88
|
+
onCleanup2 as onCleanup,
|
|
106
89
|
portal,
|
|
107
90
|
provide,
|
|
108
91
|
render,
|
|
@@ -110,6 +93,7 @@ export {
|
|
|
110
93
|
setComponentAdapter,
|
|
111
94
|
setElementPrefix,
|
|
112
95
|
signal,
|
|
113
|
-
|
|
114
|
-
useContext
|
|
96
|
+
untrack,
|
|
97
|
+
useContext,
|
|
98
|
+
view
|
|
115
99
|
};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{a as d,b as i,e as f,f as s,h as a,i as m,j as l,k as x,l as C,m as h,x as y}from"./chunk-E4GAI5XA.js";import{a as c}from"./chunk-6BRSYQCI.js";import"./chunk-P4PXTIUD.js";import{onCleanup as u}from"@firsthandjs/core";function N(e,t){let o=[];p(e,o);for(let r=0;r<o.length;r++)t.appendChild(o[r]);return u(()=>{for(let r=0;r<o.length;r++){let n=o[r];n.parentNode?.removeChild(n)}}),null}function p(e,t){if(!(e==null||typeof e=="boolean")){if(Array.isArray(e)){for(let o=0;o<e.length;o++)p(e[o],t);return}if(typeof e=="object"&&typeof e.nodeType=="number"){t.push(e);return}t.push(document.createTextNode(String(e)))}}import{signal as D,computed as S,effect as T,batch as V,untrack as W,onCleanup as q,createRoot as z,catchError as B,runWithOwner as G,createContext as H,provide as I,useContext as J,FirsthandContextError as K,FirsthandCycleError as L,FirsthandReadonlyError as M}from"@firsthandjs/core";export{i as FirsthandComponentError,K as FirsthandContextError,L as FirsthandCycleError,M as FirsthandReadonlyError,V as batch,B as catchError,s as component,S as computed,m as createComponent,H as createContext,z as createRoot,l as defineElement,T as effect,x as list,y as mergeProps,h as off,C as on,q as onCleanup,N as portal,I as provide,c as render,G as runWithOwner,d as setComponentAdapter,f as setElementPrefix,D as signal,W as untrack,J as useContext,a as view};
|
package/dist/insert.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { type Owner, type Signal } from '@firsthandjs/core';
|
|
2
|
+
import { type Claimed } from './claim.js';
|
|
2
3
|
/** What a child part currently owns in the DOM. */
|
|
3
4
|
export type ChildSlot = Node | Node[] | null;
|
|
5
|
+
/**
|
|
6
|
+
* Runs `body` with the parts inside it excused from removing their nodes.
|
|
7
|
+
*
|
|
8
|
+
* The caller is promising that the nodes those parts wrote into are about to
|
|
9
|
+
* be removed wholesale. `list` is the only caller, and `reconcile` is the
|
|
10
|
+
* promise it is keeping.
|
|
11
|
+
*/
|
|
12
|
+
export declare function discard(body: () => void): void;
|
|
4
13
|
declare const PART: unique symbol;
|
|
14
|
+
/**
|
|
15
|
+
* Marks an array as nodes, in order, with nothing to unpack.
|
|
16
|
+
*
|
|
17
|
+
* `applyChild` accepts arrays of anything — nested arrays, thunks, strings,
|
|
18
|
+
* dynamic children — so it walks what it is given and builds a flat list of
|
|
19
|
+
* nodes out of it. A keyed list has already done that walk: it has the nodes,
|
|
20
|
+
* it made the array, and nobody else can reach it. Walking it again is one
|
|
21
|
+
* allocation and ten thousand steps for a list of ten thousand rows.
|
|
22
|
+
*/
|
|
23
|
+
export declare const FLAT: unique symbol;
|
|
24
|
+
/**
|
|
25
|
+
* What a keyed list still has to do once its nodes are in the document.
|
|
26
|
+
*
|
|
27
|
+
* A row whose component handed back a render function is a part like any
|
|
28
|
+
* other, and a part cannot be bound where it is made: the list has an array,
|
|
29
|
+
* not a place in the document. So the list puts the row's anchor among its
|
|
30
|
+
* nodes and leaves the binding here, to be run with the parent that was
|
|
31
|
+
* missing — the same two steps `flatten` takes for a fragment's children.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PENDING: unique symbol;
|
|
5
34
|
/**
|
|
6
35
|
* A dynamic child inside an array, carrying the scope it was written in.
|
|
7
36
|
*
|
|
@@ -24,6 +53,7 @@ export type DynamicChild = {
|
|
|
24
53
|
};
|
|
25
54
|
/** Marks a dynamic child of a fragment. Emitted by the compiler. */
|
|
26
55
|
export declare function part(thunk: () => unknown): DynamicChild;
|
|
56
|
+
export declare function isDynamicChild(value: object): value is DynamicChild;
|
|
27
57
|
/**
|
|
28
58
|
* One place a run writes to, and what it last put there.
|
|
29
59
|
*
|
|
@@ -114,9 +144,42 @@ export declare function writeChild(store: Store, index: number, parent: Node, ma
|
|
|
114
144
|
* The thunk is evaluated once inside a tracking scope; if it read nothing
|
|
115
145
|
* reactive, no effect is retained (ADR-0009).
|
|
116
146
|
*/
|
|
117
|
-
export declare function insert(parent: Node, value: unknown, marker?: Node | null
|
|
147
|
+
export declare function insert(parent: Node, value: unknown, marker?: Node | null,
|
|
148
|
+
/**
|
|
149
|
+
* A region already claimed, handed down rather than looked up.
|
|
150
|
+
*
|
|
151
|
+
* The compiler never passes this. It is how a part that turns out to
|
|
152
|
+
* produce another part gives the markup it claimed to the part that will
|
|
153
|
+
* actually own it — see the `function` branch below.
|
|
154
|
+
*/
|
|
155
|
+
seed?: Claimed | null,
|
|
156
|
+
/**
|
|
157
|
+
* Told what this part currently has in the document, after every run.
|
|
158
|
+
*
|
|
159
|
+
* The compiler never passes this either. A keyed list needs it: a row that
|
|
160
|
+
* is a view owns nodes that change without the list running, and a reorder
|
|
161
|
+
* has to move what the row has now rather than what it had when it was
|
|
162
|
+
* made.
|
|
163
|
+
*/
|
|
164
|
+
report?: Report): void;
|
|
165
|
+
/** Told what a part has in the document, when somebody needs to know. */
|
|
166
|
+
export type Report = (nodes: Node[]) => void;
|
|
118
167
|
/** Applies one value to a child slot and returns the slot's new contents. */
|
|
119
168
|
export declare function applyChild(parent: Node, marker: Node | null, current: ChildSlot, value: unknown): ChildSlot;
|
|
169
|
+
/**
|
|
170
|
+
* Binds parts whose anchors are now in the document.
|
|
171
|
+
*
|
|
172
|
+
* Each runs under the owner it was written in, which is what keeps context,
|
|
173
|
+
* disposal and error ownership lexical. A part created outside any scope —
|
|
174
|
+
* runtime JSX at module level, say — is bound under the scope doing the
|
|
175
|
+
* inserting, so that it is still disposed by something rather than by nothing.
|
|
176
|
+
*
|
|
177
|
+
* A part that is already mounted is left alone. A run hands back what it made
|
|
178
|
+
* rather than making it again, so the same part arrives here on every run of
|
|
179
|
+
* the run that owns it, and binding it twice would put a second copy of the
|
|
180
|
+
* whole child on the page beside the first.
|
|
181
|
+
*/
|
|
182
|
+
export declare function bindPart(child: DynamicChild, parent: Node, report?: Report): void;
|
|
120
183
|
/**
|
|
121
184
|
* Reconciles two node lists in place, by node identity.
|
|
122
185
|
*
|
package/dist/insert.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"insert.d.ts","sourceRoot":"","sources":["../src/insert.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,KAAK,EACV,KAAK,MAAM,EACZ,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAa,KAAK,OAAO,EAAE,MAAM,YAAY,CAAC;AAErD,mDAAmD;AACnD,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC;AAiB7C;;;;;;GAMG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,IAAI,GAAG,IAAI,CAO9C;AAQD,QAAA,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAErD;;;;;;;;GAQG;AACH,eAAO,MAAM,IAAI,EAAE,OAAO,MAAiC,CAAC;AAE5D;;;;;;;;GAQG;AACH,eAAO,MAAM,OAAO,EAAE,OAAO,MAAoC,CAAC;AAElE;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,QAA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,EAClB,KAAK,EAAE,OAAO,GACb,SAAS,CAyEX;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAajF;AA4FD;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,CAqEvF"}
|
package/dist/internal.d.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
export declare const PROTOCOL_VERSION = 1;
|
|
13
13
|
export { template, path } from './template.js';
|
|
14
|
+
export { first, next } from './claim.js';
|
|
14
15
|
export { insert, applyChild, reconcile, part, store, site, open, close, ran, wrote, cell, writeChild, } from './insert.js';
|
|
15
16
|
export type { DynamicChild, ChildSlot, Slot, Store } from './insert.js';
|
|
16
17
|
export { setAttribute, setAttributeNS, setProperty, setBoolean, setClass, setClassList, setStyle, setStyleObject, } from './attributes.js';
|
package/dist/internal.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAElC,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,IAAI,EACJ,KAAK,EACL,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,GAAG,EACH,KAAK,EACL,IAAI,EACJ,UAAU,GACX,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,YAAY,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,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AC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/internal.dev.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
COMPONENT,
|
|
3
3
|
VIEW,
|
|
4
|
-
applyChild,
|
|
5
4
|
applyProp,
|
|
6
|
-
cell,
|
|
7
|
-
close,
|
|
8
5
|
createComponent,
|
|
9
|
-
insert,
|
|
10
6
|
isComponent,
|
|
11
|
-
label,
|
|
12
7
|
list,
|
|
13
8
|
mergeProps,
|
|
14
9
|
off,
|
|
15
10
|
on,
|
|
16
|
-
open,
|
|
17
|
-
part,
|
|
18
|
-
ran,
|
|
19
|
-
reconcile,
|
|
20
11
|
rest,
|
|
21
12
|
setAttribute,
|
|
22
13
|
setAttributeNS,
|
|
@@ -26,18 +17,43 @@ import {
|
|
|
26
17
|
setProperty,
|
|
27
18
|
setStyle,
|
|
28
19
|
setStyleObject,
|
|
29
|
-
site,
|
|
30
20
|
spread,
|
|
21
|
+
view
|
|
22
|
+
} from "./dev-chunk-MKONDKMD.js";
|
|
23
|
+
import {
|
|
24
|
+
applyChild,
|
|
25
|
+
cell,
|
|
26
|
+
close,
|
|
27
|
+
devHydrationMismatch,
|
|
28
|
+
first,
|
|
29
|
+
hydration,
|
|
30
|
+
insert,
|
|
31
|
+
label,
|
|
32
|
+
next,
|
|
33
|
+
open,
|
|
34
|
+
part,
|
|
35
|
+
ran,
|
|
36
|
+
reconcile,
|
|
37
|
+
site,
|
|
31
38
|
store,
|
|
32
|
-
view,
|
|
33
39
|
writeChild,
|
|
34
40
|
wrote
|
|
35
|
-
} from "./dev-chunk-
|
|
41
|
+
} from "./dev-chunk-ADHDPKZW.js";
|
|
36
42
|
|
|
37
43
|
// packages/dom/src/template.ts
|
|
38
44
|
function template(html, isFragment = false) {
|
|
39
45
|
let source;
|
|
46
|
+
let expected;
|
|
40
47
|
return () => {
|
|
48
|
+
const claimer = hydration.current;
|
|
49
|
+
if (claimer !== null) {
|
|
50
|
+
expected ??= claimer.tag(html);
|
|
51
|
+
const claimed = claimer.adopt(expected);
|
|
52
|
+
if (claimed !== null) {
|
|
53
|
+
devHydrationMismatch(claimed, html);
|
|
54
|
+
return claimed;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
41
57
|
if (source === void 0) {
|
|
42
58
|
const element = document.createElement("template");
|
|
43
59
|
element.innerHTML = html;
|
|
@@ -71,11 +87,13 @@ export {
|
|
|
71
87
|
cell,
|
|
72
88
|
close,
|
|
73
89
|
createComponent,
|
|
90
|
+
first,
|
|
74
91
|
insert,
|
|
75
92
|
isComponent,
|
|
76
93
|
label,
|
|
77
94
|
list,
|
|
78
95
|
mergeProps,
|
|
96
|
+
next,
|
|
79
97
|
off,
|
|
80
98
|
on,
|
|
81
99
|
open,
|
package/dist/internal.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{c as O,d as g,g as E,h as P,i as T,k as w,l as L,m as M,n as j,o as v,p as A,q as F,r as H,s as I,t as R,u as V,v as B,w as D,x as W,y as _}from"./chunk-E4GAI5XA.js";import{a as p,b as i,c as s,d as a,h as d,j as m,k as f,l as c,m as u,n as x,o as y,p as C,q as N,r as h,s as b,u as S}from"./chunk-P4PXTIUD.js";function k(n,l=!1){let t,o;return()=>{let r=i.current;if(r!==null){o??=r.tag(n);let e=r.adopt(o);if(e!==null)return e}if(t===void 0){let e=document.createElement("template");e.innerHTML=n,t=l?e.content:e.content.firstChild}return t.cloneNode(!0)}}function q(n,...l){let t=n;for(let o=0;o<l.length;o++){let r=t.firstChild;for(let e=l[o];e>0;e--)r=r.nextSibling;t=r}return t}import{bind as oe}from"@firsthandjs/core";var Q=1;export{O as COMPONENT,Q as PROTOCOL_VERSION,g as VIEW,b as applyChild,B as applyProp,oe as bind,C as cell,x as close,T as createComponent,s as first,h as insert,E as isComponent,p as label,w as list,W as mergeProps,a as next,M as off,L as on,u as open,d as part,q as path,y as ran,S as reconcile,_ as rest,j as setAttribute,v as setAttributeNS,F as setBoolean,H as setClass,I as setClassList,A as setProperty,R as setStyle,V as setStyleObject,c as site,D as spread,m as store,k as template,P as view,N as writeChild,f as wrote};
|
package/dist/list.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../src/list.ts"],"names":[],"mappings":"AAAA,OAAO,EASL,KAAK,YAAY,EAElB,MAAM,mBAAmB,CAAC;AAmC3B;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,IAAI,EAAE,MAAM,SAAS,CAAC,EAAE,EACxB,KAAK,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,EAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,YAAY,CAAC,MAAM,CAAC,KAAK,OAAO,GACtE,MAAM,IAAI,EAAE,CA2Gd"}
|