@threenative/core 0.3.3 → 0.3.5
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/capabilities.json +2019 -59
- package/dist/{assets-CYKk2WTu.d.ts → assets-CqvE429w.d.ts} +45 -3
- package/dist/{audio-7i3Xl0l3.d.ts → audio-DIJE5HTr.d.ts} +43 -3
- package/dist/{canvas-layer-C1SnMoJ-.d.ts → canvas-layer-C1-5CviZ.d.ts} +5 -1
- package/dist/{game-D_6r-k4Y.d.ts → game-Bj8G1wmD.d.ts} +242 -17
- package/dist/hot.d.ts +5 -5
- package/dist/index.d.ts +1131 -105
- package/dist/index.js +15201 -4782
- package/dist/model-lod-BDAUYgsS.d.ts +197 -0
- package/dist/playtest.d.ts +6 -4
- package/dist/playtest.js +84 -11
- package/dist/react-css.d.ts +62 -0
- package/dist/react-css.js +591 -0
- package/dist/react.d.ts +2 -2
- package/dist/{renderer-Cy4qeBOA.d.ts → renderer-9yEo9hPa.d.ts} +676 -21
- package/dist/terrain-jobs-worker.d.ts +2 -0
- package/dist/terrain-jobs-worker.js +130 -0
- package/dist/ui-layer.d.ts +5 -3
- package/dist/ui-layer.js +59 -8
- package/dist/world.d.ts +1596 -17
- package/dist/world.js +17035 -521
- package/gpl/fixtures/make_world_fixture.py +184 -0
- package/gpl/recipes/_common.py +11 -0
- package/gpl/recipes/decimate.py +11 -5
- package/gpl/recipes/export_world.py +699 -0
- package/mcp/blender-server.mjs +61 -4
- package/mcp/blender.mjs +3 -4
- package/mcp/engine-server.mjs +55 -21
- package/mcp/servers.mjs +4 -4
- package/package.json +15 -9
- package/patches/three@0.185.1-prd269-upgrade.patch +22418 -0
- package/patches/three@0.185.1.patch +8246 -389
- package/scripts/apply-three-patch.mjs +123 -41
- package/src/animation-blend.ts +264 -0
- package/src/animation-composition.ts +362 -0
- package/src/animation-layers.ts +260 -0
- package/src/animation-root-motion.ts +283 -0
- package/src/animation.ts +896 -0
- package/src/assets.ts +1303 -0
- package/src/atmosphere/index.ts +335 -0
- package/src/atmosphere/luts.ts +298 -0
- package/src/atmosphere/params.ts +323 -0
- package/src/audio.ts +912 -0
- package/src/billboard.ts +124 -0
- package/src/bone-lengths.ts +157 -0
- package/src/camera-shake.ts +116 -0
- package/src/canvas-layer.ts +47 -0
- package/src/clip-audit.ts +401 -0
- package/src/clustered-batch.ts +492 -0
- package/src/clustered-mesh.ts +638 -0
- package/src/compute-driven.ts +176 -0
- package/src/compute-timing.ts +318 -0
- package/src/config.ts +593 -0
- package/src/debug.ts +82 -0
- package/src/engine-render-hook.ts +25 -0
- package/src/entities.ts +79 -0
- package/src/entity-snapshot.ts +53 -0
- package/src/flight.ts +683 -0
- package/src/fluid-field.ts +748 -0
- package/src/fluid-particles.ts +1253 -0
- package/src/frame-budget.ts +1368 -0
- package/src/game.ts +2390 -0
- package/src/geometry-capture.ts +1098 -0
- package/src/gpu-class.ts +160 -0
- package/src/gpu-frame-observation.ts +424 -0
- package/src/gpu-readback.ts +143 -0
- package/src/gpu-scene-bvh.ts +464 -0
- package/src/grounding.ts +100 -0
- package/src/hot.ts +161 -0
- package/src/import-meta.d.ts +13 -0
- package/src/index.ts +1536 -0
- package/src/input.ts +690 -0
- package/src/instanced-batch-lod.ts +283 -0
- package/src/instanced-batch.ts +274 -0
- package/src/interpolation.ts +129 -0
- package/src/launch-diagnostics.ts +161 -0
- package/src/loop.ts +564 -0
- package/src/matrix-world.ts +245 -0
- package/src/merge-parts.ts +812 -0
- package/src/model-lod.ts +1315 -0
- package/src/net-protocol.ts +333 -0
- package/src/net-session.ts +477 -0
- package/src/net.ts +80 -0
- package/src/ocean/fft.ts +72 -0
- package/src/ocean/spectral.ts +728 -0
- package/src/particle-significance.ts +102 -0
- package/src/particles.ts +648 -0
- package/src/path-follow.ts +175 -0
- package/src/picking.ts +250 -0
- package/src/pipeline-census.ts +1566 -0
- package/src/platform.ts +210 -0
- package/src/playtest.ts +839 -0
- package/src/pointer-events.ts +411 -0
- package/src/pose-measure.ts +435 -0
- package/src/profiling/FrameCounters.ts +231 -0
- package/src/profiling/Spans.ts +548 -0
- package/src/profiling/opacity-convention.ts +21 -0
- package/src/profiling/render-list-validate.ts +175 -0
- package/src/profiling/render-trap-audit.ts +84 -0
- package/src/profiling/scene-warning.ts +190 -0
- package/src/profiling/span-probes.ts +191 -0
- package/src/profiling/unlit-foliage-warning.ts +149 -0
- package/src/projection-apply.ts +1529 -0
- package/src/projection-marker.ts +142 -0
- package/src/projection-plan.ts +1258 -0
- package/src/projection-skinned.ts +419 -0
- package/src/projection-stability.ts +409 -0
- package/src/projection-uniform.ts +328 -0
- package/src/random.ts +41 -0
- package/src/react-css.ts +604 -0
- package/src/react-glyphs.ts +114 -0
- package/src/react-host.ts +576 -0
- package/src/react-layout.ts +265 -0
- package/src/react.ts +60 -0
- package/src/render/alpha-antialiasing.ts +159 -0
- package/src/render/batched-velocity.ts +126 -0
- package/src/render/chain.ts +1021 -0
- package/src/render/daylight.ts +189 -0
- package/src/render/depth-pyramid.ts +596 -0
- package/src/render/foliage-alpha.ts +166 -0
- package/src/render/material-key.ts +60 -0
- package/src/render/mesh-pool.ts +144 -0
- package/src/render/probe-volume.ts +1668 -0
- package/src/render/resolution-subrect.ts +253 -0
- package/src/render/velocity.ts +442 -0
- package/src/render/virtual-shadow-pages.ts +827 -0
- package/src/render/virtual-shadow-partial.ts +174 -0
- package/src/render/virtual-shadow.ts +3330 -0
- package/src/render/world-impostor-surface.ts +722 -0
- package/src/render/world-impostor.ts +558 -0
- package/src/render-camera-cull.ts +441 -0
- package/src/render-pass-budget.ts +501 -0
- package/src/renderProjection.ts +758 -0
- package/src/renderer-config.ts +127 -0
- package/src/renderer.ts +1847 -0
- package/src/replay-protocol.ts +85 -0
- package/src/replay.ts +205 -0
- package/src/resolution-scaler.ts +819 -0
- package/src/rig-preparation.ts +271 -0
- package/src/ripple-field.ts +432 -0
- package/src/scale.ts +109 -0
- package/src/scene.ts +239 -0
- package/src/schedule.ts +155 -0
- package/src/skeletal-mesh.ts +61 -0
- package/src/skeleton.ts +100 -0
- package/src/snow-field.ts +744 -0
- package/src/softbody-topology.ts +269 -0
- package/src/softbody.ts +516 -0
- package/src/sprite-animator.ts +222 -0
- package/src/startup-readiness.ts +386 -0
- package/src/state.ts +66 -0
- package/src/static-transform.ts +274 -0
- package/src/storage-buffer.ts +253 -0
- package/src/streaming.ts +308 -0
- package/src/target-fps.ts +92 -0
- package/src/terrain-jobs-worker.ts +17 -0
- package/src/terrain-jobs.ts +353 -0
- package/src/textures.ts +39 -0
- package/src/tracers.ts +237 -0
- package/src/ui-bridge.ts +368 -0
- package/src/ui-hit-regions.ts +380 -0
- package/src/ui-layer.ts +83 -0
- package/src/ui-state.ts +220 -0
- package/src/version.ts +2 -0
- package/src/viewport.ts +253 -0
- package/src/warmup.ts +1357 -0
- package/src/water-surface.ts +384 -0
- package/src/wave-field.ts +524 -0
- package/src/world-capabilities.ts +131 -0
- package/src/world-cell-proxy.ts +392 -0
- package/src/world-cells.ts +10564 -0
- package/src/world-gpu-scene.ts +3354 -0
- package/src/world-heightmap.ts +82 -0
- package/src/world-package.ts +469 -0
- package/src/world-passes.ts +582 -0
- package/src/world-region.ts +17 -0
- package/src/world-terrain-splat.ts +564 -0
- package/src/world-tiles.ts +3826 -0
- package/src/world-topology.ts +370 -0
- package/src/world-validate.ts +48 -0
- package/src/world.ts +805 -0
- package/dist/gpu-readback-CMklJs6r.d.ts +0 -112
|
@@ -0,0 +1,591 @@
|
|
|
1
|
+
import ReactReconciler from 'react-reconciler';
|
|
2
|
+
import { DiscreteEventPriority, NoEventPriority } from 'react-reconciler/constants.js';
|
|
3
|
+
|
|
4
|
+
// src/react-css.ts
|
|
5
|
+
|
|
6
|
+
// src/ui-bridge.ts
|
|
7
|
+
var UI_BRIDGE_GLOBALS = {
|
|
8
|
+
/** UI end, inbound: the host calls this with one JSON string. */
|
|
9
|
+
uiReceive: "__tnUiReceive",
|
|
10
|
+
/** UI end, outbound: an injected object with `postMessage(string)`. */
|
|
11
|
+
uiHost: "tnHost",
|
|
12
|
+
/** Game end, inbound: the runtime calls this with one JSON string. */
|
|
13
|
+
gameReceive: "__tnUiGameReceive",
|
|
14
|
+
/** Game end, outbound: the runtime installs this and forwards to the web view. */
|
|
15
|
+
gamePost: "__tnUiPost"
|
|
16
|
+
};
|
|
17
|
+
var stateFrames = /* @__PURE__ */ new WeakMap();
|
|
18
|
+
function assertSendable(message) {
|
|
19
|
+
if (typeof message !== "object" || message === null || Array.isArray(message)) {
|
|
20
|
+
throw new Error("TN_UI_BRIDGE_MESSAGE_INVALID: a bridge message must be a JSON object.");
|
|
21
|
+
}
|
|
22
|
+
if (typeof message.type !== "string" || message.type.length === 0) {
|
|
23
|
+
throw new Error("TN_UI_BRIDGE_MESSAGE_INVALID: a bridge message must carry a string 'type'.");
|
|
24
|
+
}
|
|
25
|
+
let frame;
|
|
26
|
+
try {
|
|
27
|
+
frame = stateFrames.get(message) ?? JSON.stringify(message);
|
|
28
|
+
} catch (error) {
|
|
29
|
+
throw new Error(
|
|
30
|
+
`TN_UI_BRIDGE_MESSAGE_INVALID: '${message.type}' is not JSON-serialisable: ${error instanceof Error ? error.message : String(error)}`
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
if (frame === void 0) {
|
|
34
|
+
throw new Error(`TN_UI_BRIDGE_MESSAGE_INVALID: '${message.type}' serialised to nothing.`);
|
|
35
|
+
}
|
|
36
|
+
return frame;
|
|
37
|
+
}
|
|
38
|
+
function parseFrame(frame) {
|
|
39
|
+
const text = typeof frame === "string" ? frame : frame?.data;
|
|
40
|
+
if (typeof text !== "string") {
|
|
41
|
+
throw new Error("TN_UI_BRIDGE_FRAME_INVALID: expected a JSON string from the host.");
|
|
42
|
+
}
|
|
43
|
+
let parsed;
|
|
44
|
+
try {
|
|
45
|
+
parsed = JSON.parse(text);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
`TN_UI_BRIDGE_FRAME_INVALID: not JSON: ${error instanceof Error ? error.message : String(error)}`
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
52
|
+
throw new Error("TN_UI_BRIDGE_FRAME_INVALID: a bridge frame must be a JSON object.");
|
|
53
|
+
}
|
|
54
|
+
if (typeof parsed.type !== "string") {
|
|
55
|
+
throw new Error("TN_UI_BRIDGE_FRAME_INVALID: a bridge frame must carry a string 'type'.");
|
|
56
|
+
}
|
|
57
|
+
return parsed;
|
|
58
|
+
}
|
|
59
|
+
function findOutbound(scope, end) {
|
|
60
|
+
if (end === "game") {
|
|
61
|
+
const post = scope[UI_BRIDGE_GLOBALS.gamePost];
|
|
62
|
+
return typeof post === "function" ? (frame) => post(frame) : void 0;
|
|
63
|
+
}
|
|
64
|
+
const injected = scope[UI_BRIDGE_GLOBALS.uiHost];
|
|
65
|
+
if (typeof injected?.postMessage === "function") {
|
|
66
|
+
return (frame) => injected.postMessage(frame);
|
|
67
|
+
}
|
|
68
|
+
const webkit = scope.webkit;
|
|
69
|
+
const handler = webkit?.messageHandlers?.[UI_BRIDGE_GLOBALS.uiHost];
|
|
70
|
+
if (typeof handler?.postMessage === "function") {
|
|
71
|
+
return (frame) => handler.postMessage(frame);
|
|
72
|
+
}
|
|
73
|
+
const ipc = scope.ipc;
|
|
74
|
+
if (typeof ipc?.postMessage === "function") {
|
|
75
|
+
return (frame) => ipc.postMessage(frame);
|
|
76
|
+
}
|
|
77
|
+
return void 0;
|
|
78
|
+
}
|
|
79
|
+
var BROKER_KEY = "__tnUiBridgeBroker";
|
|
80
|
+
function broker(scope) {
|
|
81
|
+
const existing = scope[BROKER_KEY];
|
|
82
|
+
if (existing !== void 0) return existing;
|
|
83
|
+
const created = { game: /* @__PURE__ */ new Set(), ui: /* @__PURE__ */ new Set(), inbound: /* @__PURE__ */ new Map() };
|
|
84
|
+
scope[BROKER_KEY] = created;
|
|
85
|
+
return created;
|
|
86
|
+
}
|
|
87
|
+
function installInbound(scope, key, deliver) {
|
|
88
|
+
const bus = broker(scope);
|
|
89
|
+
let slot = bus.inbound.get(key);
|
|
90
|
+
if (slot === void 0) {
|
|
91
|
+
const receivers = /* @__PURE__ */ new Set();
|
|
92
|
+
slot = {
|
|
93
|
+
receivers,
|
|
94
|
+
dispatch: (frame) => {
|
|
95
|
+
let firstError;
|
|
96
|
+
let failed = false;
|
|
97
|
+
for (const receiver of [...receivers]) {
|
|
98
|
+
try {
|
|
99
|
+
receiver(frame);
|
|
100
|
+
} catch (error) {
|
|
101
|
+
if (!failed) {
|
|
102
|
+
failed = true;
|
|
103
|
+
firstError = error;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
if (failed) throw firstError;
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
bus.inbound.set(key, slot);
|
|
111
|
+
}
|
|
112
|
+
slot.receivers.add(deliver);
|
|
113
|
+
scope[key] = slot.dispatch;
|
|
114
|
+
const installed = slot;
|
|
115
|
+
return () => {
|
|
116
|
+
installed.receivers.delete(deliver);
|
|
117
|
+
if (installed.receivers.size === 0 && scope[key] === installed.dispatch) scope[key] = void 0;
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
function connectUiBridge(options) {
|
|
121
|
+
const { end } = options;
|
|
122
|
+
if (end !== "game" && end !== "ui") {
|
|
123
|
+
throw new Error(`TN_UI_BRIDGE_END_INVALID: expected 'game' or 'ui', got '${String(end)}'.`);
|
|
124
|
+
}
|
|
125
|
+
const scope = options.scope ?? globalThis;
|
|
126
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
127
|
+
const deliver = (frame) => {
|
|
128
|
+
const message = parseFrame(frame);
|
|
129
|
+
for (const listener of [...listeners]) listener(message);
|
|
130
|
+
};
|
|
131
|
+
const outbound = findOutbound(scope, end);
|
|
132
|
+
const inboundKey = end === "ui" ? UI_BRIDGE_GLOBALS.uiReceive : UI_BRIDGE_GLOBALS.gameReceive;
|
|
133
|
+
let closed = false;
|
|
134
|
+
if (outbound === void 0) {
|
|
135
|
+
const bus = broker(scope);
|
|
136
|
+
const peer = end === "ui" ? "game" : "ui";
|
|
137
|
+
const own = (message) => {
|
|
138
|
+
for (const listener of [...listeners]) listener(message);
|
|
139
|
+
};
|
|
140
|
+
bus[end].add(own);
|
|
141
|
+
return {
|
|
142
|
+
end,
|
|
143
|
+
transport: "in-process",
|
|
144
|
+
hasPeer: () => bus[peer].size > 0,
|
|
145
|
+
post(message) {
|
|
146
|
+
const frame = assertSendable(message);
|
|
147
|
+
if (closed) throw new Error("TN_UI_BRIDGE_CLOSED: post on a closed bridge.");
|
|
148
|
+
const copy = JSON.parse(frame);
|
|
149
|
+
for (const listener of [...bus[peer]]) listener(copy);
|
|
150
|
+
},
|
|
151
|
+
onMessage(listener) {
|
|
152
|
+
listeners.add(listener);
|
|
153
|
+
return () => listeners.delete(listener);
|
|
154
|
+
},
|
|
155
|
+
close() {
|
|
156
|
+
closed = true;
|
|
157
|
+
listeners.clear();
|
|
158
|
+
bus[end].delete(own);
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
const uninstall = installInbound(scope, inboundKey, deliver);
|
|
163
|
+
const injected = scope[UI_BRIDGE_GLOBALS.uiHost];
|
|
164
|
+
if (end === "ui" && injected !== void 0 && typeof injected === "object") {
|
|
165
|
+
injected.onmessage = (event) => deliver(event);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
end,
|
|
169
|
+
transport: "host",
|
|
170
|
+
hasPeer() {
|
|
171
|
+
const attached = scope.__tnUiOverlayAttached;
|
|
172
|
+
if (end === "ui") return true;
|
|
173
|
+
return typeof attached === "function" ? attached() === true : false;
|
|
174
|
+
},
|
|
175
|
+
post(message) {
|
|
176
|
+
const frame = assertSendable(message);
|
|
177
|
+
if (closed) throw new Error("TN_UI_BRIDGE_CLOSED: post on a closed bridge.");
|
|
178
|
+
outbound(frame);
|
|
179
|
+
},
|
|
180
|
+
onMessage(listener) {
|
|
181
|
+
listeners.add(listener);
|
|
182
|
+
return () => listeners.delete(listener);
|
|
183
|
+
},
|
|
184
|
+
close() {
|
|
185
|
+
closed = true;
|
|
186
|
+
listeners.clear();
|
|
187
|
+
uninstall();
|
|
188
|
+
if (end === "ui" && injected !== void 0 && typeof injected === "object") {
|
|
189
|
+
injected.onmessage = void 0;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// src/react-css.ts
|
|
196
|
+
var CSS_UI_MESSAGE = "tn:css";
|
|
197
|
+
var CSS_UI_TAGS = [
|
|
198
|
+
"div",
|
|
199
|
+
"section",
|
|
200
|
+
"aside",
|
|
201
|
+
"header",
|
|
202
|
+
"footer",
|
|
203
|
+
"main",
|
|
204
|
+
"nav",
|
|
205
|
+
"article",
|
|
206
|
+
"h1",
|
|
207
|
+
"h2",
|
|
208
|
+
"h3",
|
|
209
|
+
"h4",
|
|
210
|
+
"h5",
|
|
211
|
+
"h6",
|
|
212
|
+
"p",
|
|
213
|
+
"span",
|
|
214
|
+
"button",
|
|
215
|
+
"img",
|
|
216
|
+
"ul",
|
|
217
|
+
"ol",
|
|
218
|
+
"li",
|
|
219
|
+
"a",
|
|
220
|
+
"label",
|
|
221
|
+
"strong",
|
|
222
|
+
"em",
|
|
223
|
+
"b",
|
|
224
|
+
"i",
|
|
225
|
+
"small"
|
|
226
|
+
];
|
|
227
|
+
var ROOT_ID = 0;
|
|
228
|
+
var EVENT_PROPS = {
|
|
229
|
+
onClick: "click",
|
|
230
|
+
onPointerDown: "pointerdown",
|
|
231
|
+
onPointerUp: "pointerup",
|
|
232
|
+
onPointerEnter: "pointerenter",
|
|
233
|
+
onPointerLeave: "pointerleave",
|
|
234
|
+
onFocus: "focus",
|
|
235
|
+
onBlur: "blur"
|
|
236
|
+
};
|
|
237
|
+
var EVENT_NAMES = new Set(Object.values(EVENT_PROPS));
|
|
238
|
+
var PASSTHROUGH_ATTRS = /* @__PURE__ */ new Set([
|
|
239
|
+
"id",
|
|
240
|
+
"role",
|
|
241
|
+
"type",
|
|
242
|
+
"src",
|
|
243
|
+
"alt",
|
|
244
|
+
"title"
|
|
245
|
+
]);
|
|
246
|
+
var RENAMED_ATTRS = {
|
|
247
|
+
className: "class",
|
|
248
|
+
tabIndex: "tabindex"
|
|
249
|
+
};
|
|
250
|
+
var UNITLESS_PROPERTIES = /* @__PURE__ */ new Set([
|
|
251
|
+
"lineHeight",
|
|
252
|
+
"opacity",
|
|
253
|
+
"flex",
|
|
254
|
+
"flexGrow",
|
|
255
|
+
"flexShrink",
|
|
256
|
+
"zIndex",
|
|
257
|
+
"order",
|
|
258
|
+
"fontWeight",
|
|
259
|
+
"zoom",
|
|
260
|
+
"aspectRatio",
|
|
261
|
+
"gridColumn",
|
|
262
|
+
"gridRow",
|
|
263
|
+
"gridRowStart",
|
|
264
|
+
"gridRowEnd",
|
|
265
|
+
"gridColumnStart",
|
|
266
|
+
"gridColumnEnd",
|
|
267
|
+
"lineClamp",
|
|
268
|
+
"WebkitLineClamp",
|
|
269
|
+
"columns",
|
|
270
|
+
"tabSize"
|
|
271
|
+
]);
|
|
272
|
+
function takeId(root) {
|
|
273
|
+
root.nextId += 1;
|
|
274
|
+
return root.nextId;
|
|
275
|
+
}
|
|
276
|
+
function styleProperty(name) {
|
|
277
|
+
return name.startsWith("--") ? name : name.replaceAll(/[A-Z]/gu, (upper) => `-${upper.toLowerCase()}`);
|
|
278
|
+
}
|
|
279
|
+
function styleValue(name, value) {
|
|
280
|
+
if (typeof value === "string") return value;
|
|
281
|
+
return name.startsWith("--") || UNITLESS_PROPERTIES.has(name) ? String(value) : `${value}px`;
|
|
282
|
+
}
|
|
283
|
+
function styleAttribute(style) {
|
|
284
|
+
if (typeof style !== "object" || style === null) return void 0;
|
|
285
|
+
const declarations = [];
|
|
286
|
+
for (const [name, value] of Object.entries(style)) {
|
|
287
|
+
if (typeof value !== "string" && typeof value !== "number") continue;
|
|
288
|
+
declarations.push(`${styleProperty(name)}: ${styleValue(name, value)}`);
|
|
289
|
+
}
|
|
290
|
+
return declarations.length === 0 ? void 0 : declarations.join("; ");
|
|
291
|
+
}
|
|
292
|
+
function attrFor(name, value) {
|
|
293
|
+
if (value === null || value === void 0) return void 0;
|
|
294
|
+
if (name.startsWith("data-") || name.startsWith("aria-")) return [name, String(value)];
|
|
295
|
+
if (name === "disabled") return value ? [name, ""] : void 0;
|
|
296
|
+
if (name === "style") {
|
|
297
|
+
const css = typeof value === "string" ? value : styleAttribute(value);
|
|
298
|
+
return css === void 0 ? void 0 : [name, css];
|
|
299
|
+
}
|
|
300
|
+
const named = PASSTHROUGH_ATTRS.has(name) ? name : RENAMED_ATTRS[name];
|
|
301
|
+
return named === void 0 ? void 0 : [named, String(value)];
|
|
302
|
+
}
|
|
303
|
+
function desiredAttrs(props) {
|
|
304
|
+
const attrs = /* @__PURE__ */ new Map();
|
|
305
|
+
for (const [name, value] of Object.entries(props)) {
|
|
306
|
+
const attr = attrFor(name, value);
|
|
307
|
+
if (attr !== void 0) attrs.set(attr[0], attr[1]);
|
|
308
|
+
}
|
|
309
|
+
return attrs;
|
|
310
|
+
}
|
|
311
|
+
function attrOps(element, props) {
|
|
312
|
+
const desired = desiredAttrs(props);
|
|
313
|
+
const ops = [];
|
|
314
|
+
for (const [name, value] of desired) {
|
|
315
|
+
if (element.attrs.get(name) === value) continue;
|
|
316
|
+
element.attrs.set(name, value);
|
|
317
|
+
ops.push({ op: "attr", id: element.id, name, value });
|
|
318
|
+
}
|
|
319
|
+
for (const name of [...element.attrs.keys()]) {
|
|
320
|
+
if (desired.has(name)) continue;
|
|
321
|
+
element.attrs.delete(name);
|
|
322
|
+
ops.push({ op: "attr", id: element.id, name, value: null });
|
|
323
|
+
}
|
|
324
|
+
return ops;
|
|
325
|
+
}
|
|
326
|
+
function makeElement(id, tag, props) {
|
|
327
|
+
if (!CSS_UI_TAGS.includes(tag)) {
|
|
328
|
+
throw new Error(
|
|
329
|
+
`TN_CSS_UI_ELEMENT_UNSUPPORTED: <${tag}> has no native CSS element, so mounting it would drop the subtree under it. Build it from: ${CSS_UI_TAGS.join(" ")}.`
|
|
330
|
+
);
|
|
331
|
+
}
|
|
332
|
+
if (props.dangerouslySetInnerHTML !== void 0) {
|
|
333
|
+
throw new Error(
|
|
334
|
+
"TN_CSS_UI_PROP_UNSUPPORTED: dangerouslySetInnerHTML has no native CSS equivalent, because the engine is handed a tree and not a string. Render the markup as elements, or send it as a sheet."
|
|
335
|
+
);
|
|
336
|
+
}
|
|
337
|
+
return {
|
|
338
|
+
attrs: /* @__PURE__ */ new Map(),
|
|
339
|
+
children: [],
|
|
340
|
+
handlers: /* @__PURE__ */ new Map(),
|
|
341
|
+
id,
|
|
342
|
+
kind: "element",
|
|
343
|
+
listened: /* @__PURE__ */ new Set(),
|
|
344
|
+
tag
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
function handlerOps(element, props) {
|
|
348
|
+
const ops = [];
|
|
349
|
+
for (const [prop, event] of Object.entries(EVENT_PROPS)) {
|
|
350
|
+
const handler = props[prop];
|
|
351
|
+
if (typeof handler !== "function") {
|
|
352
|
+
element.handlers.delete(event);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
if (!element.listened.has(event)) {
|
|
356
|
+
element.listened.add(event);
|
|
357
|
+
ops.push({ op: "listen", id: element.id, event });
|
|
358
|
+
}
|
|
359
|
+
element.handlers.set(event, handler);
|
|
360
|
+
}
|
|
361
|
+
return ops;
|
|
362
|
+
}
|
|
363
|
+
function free(root, node) {
|
|
364
|
+
root.byId.delete(node.id);
|
|
365
|
+
if (node.kind !== "element") return;
|
|
366
|
+
node.handlers.clear();
|
|
367
|
+
for (const child of node.children) free(root, child);
|
|
368
|
+
}
|
|
369
|
+
function wires(op) {
|
|
370
|
+
return op.op === "append" || op.op === "insertBefore";
|
|
371
|
+
}
|
|
372
|
+
function orderedOps(ops) {
|
|
373
|
+
const made = ops.filter((op) => !wires(op));
|
|
374
|
+
return made.length === ops.length ? [...ops] : [...made, ...ops.filter(wires)];
|
|
375
|
+
}
|
|
376
|
+
var createReconciler = ReactReconciler;
|
|
377
|
+
function hostConfig(root, flush) {
|
|
378
|
+
let priority = NoEventPriority;
|
|
379
|
+
const append = (parent, child) => {
|
|
380
|
+
const existing = parent.children.indexOf(child);
|
|
381
|
+
if (existing >= 0) parent.children.splice(existing, 1);
|
|
382
|
+
parent.children.push(child);
|
|
383
|
+
root.pending.push({ op: "append", parent: parent.id, child: child.id });
|
|
384
|
+
};
|
|
385
|
+
const insert = (parent, child, before) => {
|
|
386
|
+
const existing = parent.children.indexOf(child);
|
|
387
|
+
if (existing >= 0) parent.children.splice(existing, 1);
|
|
388
|
+
parent.children.splice(parent.children.indexOf(before), 0, child);
|
|
389
|
+
root.pending.push({
|
|
390
|
+
op: "insertBefore",
|
|
391
|
+
parent: parent.id,
|
|
392
|
+
child: child.id,
|
|
393
|
+
before: before.id
|
|
394
|
+
});
|
|
395
|
+
};
|
|
396
|
+
const remove = (parent, child) => {
|
|
397
|
+
const at = parent.children.indexOf(child);
|
|
398
|
+
if (at >= 0) parent.children.splice(at, 1);
|
|
399
|
+
free(root, child);
|
|
400
|
+
root.pending.push({ op: "remove", id: child.id });
|
|
401
|
+
};
|
|
402
|
+
return {
|
|
403
|
+
supportsMutation: true,
|
|
404
|
+
supportsPersistence: false,
|
|
405
|
+
supportsHydration: false,
|
|
406
|
+
isPrimaryRenderer: false,
|
|
407
|
+
noTimeout: -1,
|
|
408
|
+
scheduleTimeout: setTimeout,
|
|
409
|
+
cancelTimeout: clearTimeout,
|
|
410
|
+
createInstance: (tag, props) => {
|
|
411
|
+
const element = makeElement(takeId(root), tag, props);
|
|
412
|
+
root.byId.set(element.id, element);
|
|
413
|
+
root.pending.push({ op: "create", id: element.id, tag });
|
|
414
|
+
for (const op of attrOps(element, props)) root.pending.push(op);
|
|
415
|
+
for (const op of handlerOps(element, props)) root.pending.push(op);
|
|
416
|
+
return element;
|
|
417
|
+
},
|
|
418
|
+
createTextInstance: (text) => {
|
|
419
|
+
const node = { id: takeId(root), kind: "text", text };
|
|
420
|
+
root.pending.push({ op: "text", id: node.id, text });
|
|
421
|
+
return node;
|
|
422
|
+
},
|
|
423
|
+
shouldSetTextContent: () => false,
|
|
424
|
+
getPublicInstance: (instance) => instance,
|
|
425
|
+
getRootHostContext: () => HOST_CONTEXT,
|
|
426
|
+
getChildHostContext: () => HOST_CONTEXT,
|
|
427
|
+
// `appendInitialChild` is the same wire op as `appendChild`: React assembles a detached subtree
|
|
428
|
+
// in the render phase, and the engine has to be handed that same subtree before the root's own
|
|
429
|
+
// append, which is the last op of the batch.
|
|
430
|
+
appendInitialChild: (parent, child) => append(parent, child),
|
|
431
|
+
appendChild: (parent, child) => append(parent, child),
|
|
432
|
+
appendChildToContainer: (target, child) => append(target, child),
|
|
433
|
+
insertBefore: (parent, child, before) => insert(parent, child, before),
|
|
434
|
+
insertInContainerBefore: (target, child, before) => insert(target, child, before),
|
|
435
|
+
removeChild: (parent, child) => remove(parent, child),
|
|
436
|
+
removeChildFromContainer: (target, child) => remove(target, child),
|
|
437
|
+
clearContainer: (target) => {
|
|
438
|
+
for (const child of [...target.children]) remove(target, child);
|
|
439
|
+
},
|
|
440
|
+
finalizeInitialChildren: () => false,
|
|
441
|
+
commitUpdate: (instance, _tag, _prev, next) => {
|
|
442
|
+
for (const op of attrOps(instance, next)) root.pending.push(op);
|
|
443
|
+
for (const op of handlerOps(instance, next)) root.pending.push(op);
|
|
444
|
+
},
|
|
445
|
+
commitTextUpdate: (instance, _old, next) => {
|
|
446
|
+
instance.text = next;
|
|
447
|
+
root.pending.push({ op: "setText", id: instance.id, text: next });
|
|
448
|
+
},
|
|
449
|
+
prepareForCommit: () => null,
|
|
450
|
+
resetAfterCommit: () => flush(),
|
|
451
|
+
preparePortalMount: () => void 0,
|
|
452
|
+
detachDeletedInstance: () => void 0,
|
|
453
|
+
beforeActiveInstanceBlur: () => void 0,
|
|
454
|
+
afterActiveInstanceBlur: () => void 0,
|
|
455
|
+
prepareScopeUpdate: () => void 0,
|
|
456
|
+
getInstanceFromNode: () => null,
|
|
457
|
+
getInstanceFromScope: () => null,
|
|
458
|
+
setCurrentUpdatePriority: (value) => {
|
|
459
|
+
priority = value;
|
|
460
|
+
},
|
|
461
|
+
getCurrentUpdatePriority: () => priority,
|
|
462
|
+
// Discrete, as in the quad backend: an update lands on the sync lane, so a game loop's
|
|
463
|
+
// `flushSyncWork()` is all that is ever needed and the UI never waits on a scheduler.
|
|
464
|
+
resolveUpdatePriority: () => priority !== NoEventPriority ? priority : DiscreteEventPriority,
|
|
465
|
+
getCurrentEventPriority: () => DiscreteEventPriority,
|
|
466
|
+
shouldAttemptEagerTransition: () => false,
|
|
467
|
+
requestPostPaintCallback: () => void 0,
|
|
468
|
+
maySuspendCommit: () => false,
|
|
469
|
+
preloadInstance: () => true,
|
|
470
|
+
startSuspendingCommit: () => void 0,
|
|
471
|
+
suspendInstance: () => void 0,
|
|
472
|
+
waitForCommitToBeReady: () => null,
|
|
473
|
+
resetFormInstance: () => void 0,
|
|
474
|
+
trackSchedulerEvent: () => void 0,
|
|
475
|
+
resolveEventType: () => null,
|
|
476
|
+
resolveEventTimeStamp: () => -1.1,
|
|
477
|
+
// quality-allow: the key is react-reconciler's own host API spelling and cannot be renamed.
|
|
478
|
+
// biome-ignore lint/style/useNamingConvention: exact React reconciler host API name.
|
|
479
|
+
NotPendingTransition: null,
|
|
480
|
+
// quality-allow: the key is react-reconciler's own host API spelling and cannot be renamed.
|
|
481
|
+
// biome-ignore lint/style/useNamingConvention: exact React reconciler host API name.
|
|
482
|
+
HostTransitionContext: {
|
|
483
|
+
$$typeof: /* @__PURE__ */ Symbol.for("react.context"),
|
|
484
|
+
// quality-allow: the key is react-reconciler's own host API spelling and cannot be renamed.
|
|
485
|
+
// biome-ignore lint/style/useNamingConvention: exact React context API name.
|
|
486
|
+
Provider: null,
|
|
487
|
+
// quality-allow: the key is react-reconciler's own host API spelling and cannot be renamed.
|
|
488
|
+
// biome-ignore lint/style/useNamingConvention: exact React context API name.
|
|
489
|
+
Consumer: null,
|
|
490
|
+
_currentValue: null,
|
|
491
|
+
_currentValue2: null,
|
|
492
|
+
_threadCount: 0
|
|
493
|
+
},
|
|
494
|
+
flush
|
|
495
|
+
};
|
|
496
|
+
}
|
|
497
|
+
var HOST_CONTEXT = {};
|
|
498
|
+
function createCssUiRoot(options = {}) {
|
|
499
|
+
const bridge = connectUiBridge({ end: "game", scope: options.scope });
|
|
500
|
+
const root = {
|
|
501
|
+
byId: /* @__PURE__ */ new Map(),
|
|
502
|
+
nextId: ROOT_ID,
|
|
503
|
+
opCount: 0,
|
|
504
|
+
pending: [],
|
|
505
|
+
postCount: 0,
|
|
506
|
+
root: {
|
|
507
|
+
attrs: /* @__PURE__ */ new Map(),
|
|
508
|
+
children: [],
|
|
509
|
+
handlers: /* @__PURE__ */ new Map(),
|
|
510
|
+
id: ROOT_ID,
|
|
511
|
+
kind: "element",
|
|
512
|
+
listened: /* @__PURE__ */ new Set(),
|
|
513
|
+
tag: "body"
|
|
514
|
+
}
|
|
515
|
+
};
|
|
516
|
+
const report = (error) => {
|
|
517
|
+
const named = error instanceof Error ? error : new Error(String(error));
|
|
518
|
+
if (options.onError !== void 0) options.onError(named);
|
|
519
|
+
else console.error(named.message);
|
|
520
|
+
};
|
|
521
|
+
const flush = () => {
|
|
522
|
+
const ops = orderedOps(root.pending);
|
|
523
|
+
if (ops.length === 0) return;
|
|
524
|
+
root.pending.length = 0;
|
|
525
|
+
root.opCount += ops.length;
|
|
526
|
+
root.postCount += 1;
|
|
527
|
+
bridge.post({ ops, type: CSS_UI_MESSAGE });
|
|
528
|
+
};
|
|
529
|
+
const reconciler = createReconciler(hostConfig(root, flush));
|
|
530
|
+
const fiberRoot = reconciler.createContainer(
|
|
531
|
+
root.root,
|
|
532
|
+
0,
|
|
533
|
+
null,
|
|
534
|
+
false,
|
|
535
|
+
null,
|
|
536
|
+
"tn",
|
|
537
|
+
report,
|
|
538
|
+
report,
|
|
539
|
+
report,
|
|
540
|
+
null
|
|
541
|
+
);
|
|
542
|
+
let eventDispatch;
|
|
543
|
+
let propagationStopped = false;
|
|
544
|
+
const unsubscribe = bridge.onMessage((message) => {
|
|
545
|
+
const { type } = message;
|
|
546
|
+
if (!EVENT_NAMES.has(type)) return;
|
|
547
|
+
const id = message.id;
|
|
548
|
+
if (typeof id !== "number") return;
|
|
549
|
+
const dispatch = typeof message.dispatch === "string" ? message.dispatch : void 0;
|
|
550
|
+
if (dispatch === void 0 || dispatch !== eventDispatch) {
|
|
551
|
+
eventDispatch = dispatch;
|
|
552
|
+
propagationStopped = false;
|
|
553
|
+
}
|
|
554
|
+
if (propagationStopped) return;
|
|
555
|
+
const handler = root.byId.get(id)?.handlers.get(type);
|
|
556
|
+
if (handler === void 0) return;
|
|
557
|
+
try {
|
|
558
|
+
handler({
|
|
559
|
+
preventDefault: () => void 0,
|
|
560
|
+
stopPropagation: () => {
|
|
561
|
+
if (dispatch !== void 0 && dispatch === eventDispatch) propagationStopped = true;
|
|
562
|
+
},
|
|
563
|
+
target: { id },
|
|
564
|
+
type
|
|
565
|
+
});
|
|
566
|
+
} catch (error) {
|
|
567
|
+
report(error);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
return {
|
|
571
|
+
render(element) {
|
|
572
|
+
reconciler.updateContainerSync(element, fiberRoot, null, null);
|
|
573
|
+
reconciler.flushSyncWork();
|
|
574
|
+
},
|
|
575
|
+
dispose() {
|
|
576
|
+
reconciler.updateContainerSync(null, fiberRoot, null, null);
|
|
577
|
+
reconciler.flushSyncWork();
|
|
578
|
+
unsubscribe();
|
|
579
|
+
bridge.close();
|
|
580
|
+
root.byId.clear();
|
|
581
|
+
},
|
|
582
|
+
get opCount() {
|
|
583
|
+
return root.opCount;
|
|
584
|
+
},
|
|
585
|
+
get postCount() {
|
|
586
|
+
return root.postCount;
|
|
587
|
+
}
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
export { CSS_UI_MESSAGE, CSS_UI_TAGS, createCssUiRoot };
|
package/dist/react.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
-
import { C as CanvasLayer } from './canvas-layer-
|
|
2
|
+
import { C as CanvasLayer } from './canvas-layer-C1-5CviZ.js';
|
|
3
3
|
import 'three';
|
|
4
|
-
import './renderer-
|
|
4
|
+
import './renderer-9yEo9hPa.js';
|
|
5
5
|
import 'three/webgpu';
|
|
6
6
|
|
|
7
7
|
/**
|