@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.14
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/server.dev.js +705 -151
- package/dist/server.js +604 -123
- package/dist/server.observe.js +617 -124
- package/dist/web.dev.js +102 -41
- package/dist/web.js +75 -37
- package/dist/web.observe.js +75 -39
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +693 -919
- package/frames/dist/client.js +636 -917
- package/frames/dist/client.observe.js +637 -917
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +607 -212
- package/frames/dist/server.js +554 -212
- package/frames/dist/server.observe.js +554 -212
- package/frames/dist/trace.js +42 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +30 -3
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +37 -8
- package/serialization/dist/serialization.js +39 -10
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +178 -72
- package/server-functions/dist/client.js +99 -61
- package/server-functions/dist/client.observe.js +178 -72
- package/server-functions/dist/server.dev.js +117 -56
- package/server-functions/dist/server.js +117 -56
- package/server-functions/dist/server.observe.js +117 -56
- package/skills/server-components/SKILL.md +228 -0
- package/types/client.d.ts +37 -2
- package/types/constants.d.ts +2 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -96
- package/types/frames/frame-container-plugin.d.ts +2 -10
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +53 -1
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/index.d.ts +38 -0
- package/types/index.server.d.ts +10 -1
- package/types/jsx.d.ts +11 -1
- package/types/observe.d.ts +182 -12
- package/types/request-error-hook.d.ts +5 -0
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +26 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +13 -1
- package/types/server-observe.d.ts +8 -0
- package/types/server.d.ts +125 -12
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createFrame } from '@solidjs/web/frames';
|
|
2
|
+
import 'solid-js';
|
|
3
|
+
|
|
4
|
+
const ELEMENT_NODE = 1;
|
|
5
|
+
const COMMENT_NODE = 8;
|
|
6
|
+
const slotEnd = id => `slot:${id}:end`;
|
|
7
|
+
const FRAME_TAG = "solid-frame";
|
|
8
|
+
const FRAME_ID_ATTR = "data-fid";
|
|
9
|
+
function makeFrameElement(id) {
|
|
10
|
+
const el = document.createElement(FRAME_TAG);
|
|
11
|
+
el.style.display = "contents";
|
|
12
|
+
if (id !== undefined) el.setAttribute(FRAME_ID_ATTR, id);
|
|
13
|
+
return el;
|
|
14
|
+
}
|
|
15
|
+
function isFrameElement(node) {
|
|
16
|
+
return node.nodeType === ELEMENT_NODE && node.hasAttribute(FRAME_ID_ATTR);
|
|
17
|
+
}
|
|
18
|
+
function eachInRange(start, key, cb) {
|
|
19
|
+
const end = slotEnd(key);
|
|
20
|
+
let n = start.nextSibling;
|
|
21
|
+
while (n && !(n.nodeType === COMMENT_NODE && n.data === end)) {
|
|
22
|
+
const next = n.nextSibling;
|
|
23
|
+
cb(n);
|
|
24
|
+
n = next;
|
|
25
|
+
}
|
|
26
|
+
return n;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const byFrame = new WeakMap();
|
|
30
|
+
const regionsFor = (frame, occurrence) => {
|
|
31
|
+
let slots = byFrame.get(frame);
|
|
32
|
+
if (!slots) byFrame.set(frame, slots = new Map());
|
|
33
|
+
let regions = slots.get(occurrence);
|
|
34
|
+
if (!regions) slots.set(occurrence, regions = new Map());
|
|
35
|
+
return regions;
|
|
36
|
+
};
|
|
37
|
+
function collectRegionElements(node, regions) {
|
|
38
|
+
if (node.nodeType !== 1) return;
|
|
39
|
+
if (isFrameElement(node)) {
|
|
40
|
+
const childId = node.getAttribute(FRAME_ID_ATTR);
|
|
41
|
+
if (childId && childId.includes(".")) {
|
|
42
|
+
const argKey = childId.slice(childId.lastIndexOf(".") + 1);
|
|
43
|
+
if (!regions.has(argKey)) regions.set(argKey, {
|
|
44
|
+
childId,
|
|
45
|
+
element: node,
|
|
46
|
+
frame: undefined,
|
|
47
|
+
adopt: true
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
for (let c = node.firstChild; c; c = c.nextSibling) collectRegionElements(c, regions);
|
|
53
|
+
}
|
|
54
|
+
function discover(frame, occurrence, start) {
|
|
55
|
+
if (!start || Array.isArray(start)) return;
|
|
56
|
+
const regions = regionsFor(frame, occurrence);
|
|
57
|
+
eachInRange(start, occurrence, n => collectRegionElements(n, regions));
|
|
58
|
+
}
|
|
59
|
+
function rename(entry, childId) {
|
|
60
|
+
entry.childId = childId;
|
|
61
|
+
if (entry.frame) entry.frame.rebind(childId);else entry.element.setAttribute(FRAME_ID_ATTR, childId);
|
|
62
|
+
}
|
|
63
|
+
function resolve(frame, occurrence, regions, props, start) {
|
|
64
|
+
if (start) discover(frame, occurrence, start);
|
|
65
|
+
const cache = regionsFor(frame, occurrence);
|
|
66
|
+
for (const key in regions) {
|
|
67
|
+
const childId = regions[key];
|
|
68
|
+
let entry = cache.get(key);
|
|
69
|
+
if (!entry) cache.set(key, entry = {
|
|
70
|
+
childId,
|
|
71
|
+
element: makeFrameElement(childId),
|
|
72
|
+
frame: undefined
|
|
73
|
+
});else if (entry.childId !== childId) rename(entry, childId);
|
|
74
|
+
props[key] = entry.element;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
function bind(frame, occurrence) {
|
|
78
|
+
const regions = byFrame.get(frame)?.get(occurrence);
|
|
79
|
+
if (!regions) return;
|
|
80
|
+
const o = frame.options;
|
|
81
|
+
for (const entry of regions.values()) {
|
|
82
|
+
if (!entry.frame) {
|
|
83
|
+
entry.frame = createFrame(entry.element, {
|
|
84
|
+
id: entry.childId,
|
|
85
|
+
host: o.host,
|
|
86
|
+
adopt: entry.adopt,
|
|
87
|
+
claimScope: o.claimScope ?? o.id,
|
|
88
|
+
ownerScope: o.ownerScope,
|
|
89
|
+
parent: frame
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function unmount(frame, occurrence) {
|
|
95
|
+
const slots = byFrame.get(frame);
|
|
96
|
+
if (!slots) return;
|
|
97
|
+
const dispose = regions => {
|
|
98
|
+
for (const {
|
|
99
|
+
frame: bound
|
|
100
|
+
} of regions.values()) bound?.dispose();
|
|
101
|
+
};
|
|
102
|
+
if (occurrence === undefined) {
|
|
103
|
+
for (const regions of slots.values()) dispose(regions);
|
|
104
|
+
byFrame.delete(frame);
|
|
105
|
+
} else {
|
|
106
|
+
const regions = slots.get(occurrence);
|
|
107
|
+
if (regions) {
|
|
108
|
+
dispose(regions);
|
|
109
|
+
slots.delete(occurrence);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
function changed(frame, occurrence, record) {
|
|
114
|
+
const regions = byFrame.get(frame)?.get(occurrence);
|
|
115
|
+
for (const key in record.regions) {
|
|
116
|
+
const entry = regions && regions.get(key);
|
|
117
|
+
if (!(entry && entry.childId === record.regions[key])) return true;
|
|
118
|
+
}
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
function frames(frame) {
|
|
122
|
+
const out = [];
|
|
123
|
+
const slots = byFrame.get(frame);
|
|
124
|
+
if (slots) for (const regions of slots.values()) for (const {
|
|
125
|
+
frame: bound
|
|
126
|
+
} of regions.values()) if (bound) out.push(bound);
|
|
127
|
+
return out;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export { bind, changed, frames, resolve, unmount };
|