pelican-engine 0.0.0-stage → 0.3.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/AGENTS.md +147 -0
- package/LICENSE +22 -0
- package/README.md +129 -2
- package/distribution.json +197 -0
- package/docs/AI-WORKFLOW.md +517 -0
- package/docs/ARCHITECTURE.md +268 -0
- package/docs/CAPABILITIES.md +264 -0
- package/docs/DECISIONS.md +107 -0
- package/docs/M3-USAGE.md +192 -0
- package/docs/PELICAN-MIGRATION.md +38 -0
- package/docs/RENDER-BACKENDS.md +50 -0
- package/docs/ROADMAP.md +239 -0
- package/docs/THIRD-PARTY-NOTICES.md +151 -0
- package/docs/api/REFERENCE.md +1435 -0
- package/docs/api/index.json +1139 -0
- package/docs/npm/DISTRIBUTION.md +130 -0
- package/docs/npm/GAME-AUTHOR.md +147 -0
- package/engine.manifest.json +15 -0
- package/lib/assets/audio.js +67 -0
- package/lib/assets/errors.js +36 -0
- package/lib/assets/glb.js +277 -0
- package/lib/assets/index.js +53 -0
- package/lib/assets/jpeg.js +199 -0
- package/lib/assets/model.js +558 -0
- package/lib/assets/optimize.js +95 -0
- package/lib/assets/texture.js +187 -0
- package/lib/compiler/distribution.js +17 -0
- package/lib/compiler/extract.js +425 -0
- package/lib/compiler/graph.js +366 -0
- package/lib/compiler/index.js +574 -0
- package/lib/compiler/normalize.js +1194 -0
- package/lib/compiler/source-map.js +25 -0
- package/lib/compiler/types.js +2 -0
- package/lib/compiler/version.js +93 -0
- package/lib/experiments/simulation/index.js +2 -0
- package/lib/experiments/simulation/math.js +41 -0
- package/lib/experiments/simulation/probe.js +215 -0
- package/lib/experiments/simulation/scenes.js +192 -0
- package/lib/experiments/simulation/solver.js +346 -0
- package/lib/experiments/simulation/types.js +1 -0
- package/lib/experiments/world/adapters.js +30 -0
- package/lib/experiments/world/geometry.js +180 -0
- package/lib/experiments/world/index.js +2 -0
- package/lib/experiments/world/probe.js +288 -0
- package/lib/experiments/world/types.js +1 -0
- package/lib/experiments/world/world.js +599 -0
- package/lib/navigation/index.js +157 -0
- package/lib/physics/index.js +909 -0
- package/lib/protocol/index.js +92 -0
- package/lib/renderer/acceleration.js +609 -0
- package/lib/renderer/browser.js +2015 -0
- package/lib/renderer/bsdf.js +260 -0
- package/lib/renderer/checkpoint.js +88 -0
- package/lib/renderer/compute-executor.js +1034 -0
- package/lib/renderer/compute-texture-assets.js +49 -0
- package/lib/renderer/compute-view-contract.js +1 -0
- package/lib/renderer/denoiser.js +361 -0
- package/lib/renderer/dielectric.js +360 -0
- package/lib/renderer/embedded-image-pixels.js +368 -0
- package/lib/renderer/emissive-lights.js +67 -0
- package/lib/renderer/environment-importance.js +55 -0
- package/lib/renderer/environment.js +346 -0
- package/lib/renderer/gameplay.js +464 -0
- package/lib/renderer/geometry.js +103 -0
- package/lib/renderer/graph-expressions.js +485 -0
- package/lib/renderer/graph-tsl.js +141 -0
- package/lib/renderer/graph.js +214 -0
- package/lib/renderer/managed-texture-sampling.js +29 -0
- package/lib/renderer/material-graphs.js +297 -0
- package/lib/renderer/medium.js +348 -0
- package/lib/renderer/models.js +1053 -0
- package/lib/renderer/motion-shader.js +40 -0
- package/lib/renderer/path-shader.js +196 -0
- package/lib/renderer/pathtrace.js +324 -0
- package/lib/renderer/postprocess-contract.js +1 -0
- package/lib/renderer/postprocess.js +494 -0
- package/lib/renderer/render-buffers.js +132 -0
- package/lib/renderer/render-textures.js +155 -0
- package/lib/renderer/startup.js +50 -0
- package/lib/renderer/surface-capture.js +199 -0
- package/lib/renderer/surface-gpu.js +270 -0
- package/lib/renderer/surface-motion.js +84 -0
- package/lib/renderer/surface-ray-shader.js +91 -0
- package/lib/renderer/surface-shader.js +88 -0
- package/lib/renderer/surface-tracer.js +1720 -0
- package/lib/renderer/surface.js +1425 -0
- package/lib/renderer/temporal-filter.js +512 -0
- package/lib/renderer/texture-pixels.js +207 -0
- package/lib/renderer/traversal-nodes.js +54 -0
- package/lib/renderer/ui.js +446 -0
- package/lib/renderer/vertex-bounds.js +127 -0
- package/lib/renderer/vertex-contract.js +1 -0
- package/lib/renderer/vertex-graphs.js +197 -0
- package/lib/renderer/volume-shader.js +50 -0
- package/lib/runtime/compute-contract.js +1 -0
- package/lib/runtime/compute-service.js +674 -0
- package/lib/runtime/contracts.js +1 -0
- package/lib/runtime/error.js +37 -0
- package/lib/runtime/events.js +189 -0
- package/lib/runtime/game-services.js +772 -0
- package/lib/runtime/host.js +839 -0
- package/lib/runtime/material-parameters.js +145 -0
- package/lib/runtime/plugins.js +1 -0
- package/lib/runtime/postprocess-contract.js +1 -0
- package/lib/runtime/postprocess.js +189 -0
- package/lib/runtime/prefabs.js +13 -0
- package/lib/runtime/random.js +88 -0
- package/lib/runtime/render-buffer-contract.js +1 -0
- package/lib/runtime/render-buffers.js +243 -0
- package/lib/runtime/render-capabilities.js +17 -0
- package/lib/runtime/render-settings.js +249 -0
- package/lib/runtime/render-texture-contract.js +1 -0
- package/lib/runtime/render-textures.js +271 -0
- package/lib/runtime/resources.js +648 -0
- package/lib/runtime/scheduler.js +765 -0
- package/lib/runtime/storage.js +169 -0
- package/lib/runtime/world.js +594 -0
- package/lib/schema/index.js +24 -0
- package/lib/sdk/graph-values.js +16 -0
- package/lib/sdk/index.d.ts +800 -0
- package/lib/sdk/index.js +82 -0
- package/lib/tools/api-index.js +113 -0
- package/lib/tools/browser-session.js +89 -0
- package/lib/tools/cli.js +513 -0
- package/lib/tools/compress-dist.js +59 -0
- package/lib/tools/control-client.js +153 -0
- package/lib/tools/control-server.js +633 -0
- package/lib/tools/diagnostic-code.js +3 -0
- package/lib/tools/doctor.js +496 -0
- package/lib/tools/npm/browser-cli.js +6 -0
- package/lib/tools/npm/entry.js +40 -0
- package/lib/tools/npm/layout.js +195 -0
- package/lib/tools/setup.js +153 -0
- package/licenses/@dimforge/rapier2d-compat/LICENSE +201 -0
- package/licenses/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@gltf-transform/core/LICENSE.md +21 -0
- package/licenses/@gltf-transform/extensions/LICENSE.md +21 -0
- package/licenses/@gltf-transform/functions/LICENSE.md +21 -0
- package/licenses/@img/colour/LICENSE.md +82 -0
- package/licenses/@img/sharp-win32-x64/LICENSE +191 -0
- package/licenses/@oxc-project/types/LICENSE +22 -0
- package/licenses/@rolldown/pluginutils/LICENSE +21 -0
- package/licenses/@tweenjs/tween.js/LICENSE +23 -0
- package/licenses/@types/ndarray/LICENSE +21 -0
- package/licenses/@types/node/LICENSE +21 -0
- package/licenses/@types/stats.js/LICENSE +21 -0
- package/licenses/@types/three/@dimforge/rapier3d-compat/LICENSE +201 -0
- package/licenses/@types/three/LICENSE +21 -0
- package/licenses/@types/webxr/LICENSE +21 -0
- package/licenses/@webgpu/types/LICENSE +26 -0
- package/licenses/THIRD-PARTY-NOTICES.md +139 -0
- package/licenses/cwise-compiler/LICENSE +22 -0
- package/licenses/detect-libc/LICENSE +201 -0
- package/licenses/esbuild/LICENSE.md +21 -0
- package/licenses/fast-png/LICENSE +21 -0
- package/licenses/fdir/LICENSE +7 -0
- package/licenses/fflate/LICENSE +21 -0
- package/licenses/iobuffer/LICENSE +22 -0
- package/licenses/iota-array/LICENSE +22 -0
- package/licenses/is-buffer/LICENSE +21 -0
- package/licenses/ktx-parse/LICENSE +21 -0
- package/licenses/lightningcss/LICENSE +373 -0
- package/licenses/lightningcss-win32-x64-msvc/LICENSE +373 -0
- package/licenses/meshoptimizer/LICENSE.md +21 -0
- package/licenses/nanoid/LICENSE +20 -0
- package/licenses/ndarray/LICENSE +22 -0
- package/licenses/ndarray-lanczos/LICENSE +21 -0
- package/licenses/ndarray-ops/LICENSE +22 -0
- package/licenses/ndarray-pixels/LICENSE +21 -0
- package/licenses/ngraph.path/LICENSE +21 -0
- package/licenses/picocolors/LICENSE +15 -0
- package/licenses/picomatch/LICENSE +21 -0
- package/licenses/playwright/LICENSE +202 -0
- package/licenses/playwright/NOTICE +5 -0
- package/licenses/playwright-core/LICENSE +202 -0
- package/licenses/playwright-core/NOTICE +5 -0
- package/licenses/postcss/LICENSE +20 -0
- package/licenses/prettier/LICENSE +7 -0
- package/licenses/property-graph/LICENSE +21 -0
- package/licenses/rolldown/LICENSE +25 -0
- package/licenses/semver/LICENSE +15 -0
- package/licenses/sharp/LICENSE +191 -0
- package/licenses/source-map-js/LICENSE +28 -0
- package/licenses/three/LICENSE +21 -0
- package/licenses/tinyglobby/LICENSE +21 -0
- package/licenses/tsx/LICENSE +21 -0
- package/licenses/typescript/LICENSE.txt +55 -0
- package/licenses/undici-types/LICENSE +21 -0
- package/licenses/uniq/LICENSE +22 -0
- package/licenses/vite/LICENSE.md +2084 -0
- package/package.json +49 -4
- package/web/index.html +34 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { parseCommand, PROTOCOL_VERSION, result, } from "../protocol/index.js";
|
|
3
|
+
const MAX_BODY = 1024 * 1024;
|
|
4
|
+
const MAX_RESPONSE = 8 * MAX_BODY;
|
|
5
|
+
const statuses = [
|
|
6
|
+
"queued",
|
|
7
|
+
"running",
|
|
8
|
+
"succeeded",
|
|
9
|
+
"failed",
|
|
10
|
+
"cancelled",
|
|
11
|
+
"timed_out",
|
|
12
|
+
];
|
|
13
|
+
function failure(taskId, code, status = "failed") {
|
|
14
|
+
return result(taskId, status, { stateUnknown: true }, [
|
|
15
|
+
{
|
|
16
|
+
code,
|
|
17
|
+
severity: "error",
|
|
18
|
+
message: "Control request did not yield a confirmed result. Runtime state must not be assumed preserved.",
|
|
19
|
+
remediation: "Inspect server task status using the same taskId; explicitly reset the session when its state is discarded or uncertain.",
|
|
20
|
+
},
|
|
21
|
+
]);
|
|
22
|
+
}
|
|
23
|
+
function loopback(host) {
|
|
24
|
+
return (host === "localhost" ||
|
|
25
|
+
host === "[::1]" ||
|
|
26
|
+
/^127(?:\.\d{1,3}){3}$/.test(host));
|
|
27
|
+
}
|
|
28
|
+
/** Node-side client; imports do not start services, browsers, or command execution. */
|
|
29
|
+
export function createControlClient(options) {
|
|
30
|
+
let base;
|
|
31
|
+
try {
|
|
32
|
+
base = new URL(options.url);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
throw new Error("TC_CONTROL_URL_INVALID: Expected a local HTTP development server URL.");
|
|
36
|
+
}
|
|
37
|
+
if (base.protocol !== "http:" ||
|
|
38
|
+
!loopback(base.hostname) ||
|
|
39
|
+
base.username ||
|
|
40
|
+
base.password ||
|
|
41
|
+
base.search ||
|
|
42
|
+
base.hash)
|
|
43
|
+
throw new Error("TC_CONTROL_URL_INVALID: Expected a loopback HTTP development server URL without credentials.");
|
|
44
|
+
const timeoutMs = options.timeoutMs ?? 35_000;
|
|
45
|
+
if (!Number.isInteger(timeoutMs) || timeoutMs < 10 || timeoutMs > 120_000)
|
|
46
|
+
throw new Error("TC_CONTROL_TIMEOUT_RANGE: timeoutMs must be an integer in [10,120000].");
|
|
47
|
+
async function request(route, body, sendOptions = {}) {
|
|
48
|
+
const taskId = sendOptions.taskId ?? `control-${randomUUID()}`;
|
|
49
|
+
if (!/^[a-zA-Z0-9_-]{1,96}$/.test(taskId))
|
|
50
|
+
return failure(`control-${randomUUID()}`, "TC_CONTROL_TASK_ID_INVALID");
|
|
51
|
+
let serialized;
|
|
52
|
+
try {
|
|
53
|
+
if (body !== undefined)
|
|
54
|
+
serialized = JSON.stringify(body);
|
|
55
|
+
if (serialized && Buffer.byteLength(serialized) > MAX_BODY)
|
|
56
|
+
return failure(taskId, "TC_CONTROL_BODY_TOO_LARGE");
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return failure(taskId, "TC_CONTROL_JSON_INVALID");
|
|
60
|
+
}
|
|
61
|
+
const abort = new AbortController();
|
|
62
|
+
const externalAbort = () => abort.abort();
|
|
63
|
+
let timedOut = false;
|
|
64
|
+
const timer = setTimeout(() => {
|
|
65
|
+
timedOut = true;
|
|
66
|
+
abort.abort();
|
|
67
|
+
}, timeoutMs);
|
|
68
|
+
sendOptions.signal?.addEventListener("abort", externalAbort, {
|
|
69
|
+
once: true,
|
|
70
|
+
});
|
|
71
|
+
if (sendOptions.signal?.aborted)
|
|
72
|
+
abort.abort();
|
|
73
|
+
try {
|
|
74
|
+
const response = await fetch(new URL(route, base.origin), {
|
|
75
|
+
method: body === undefined ? "GET" : "POST",
|
|
76
|
+
headers: {
|
|
77
|
+
"Content-Type": "application/json",
|
|
78
|
+
"X-Pelican-Task-Id": taskId,
|
|
79
|
+
},
|
|
80
|
+
body: serialized,
|
|
81
|
+
signal: abort.signal,
|
|
82
|
+
redirect: "error",
|
|
83
|
+
credentials: "omit",
|
|
84
|
+
cache: "no-store",
|
|
85
|
+
});
|
|
86
|
+
if (response.headers
|
|
87
|
+
.get("content-type")
|
|
88
|
+
?.split(";", 1)[0]
|
|
89
|
+
.trim()
|
|
90
|
+
.toLowerCase() !== "application/json") {
|
|
91
|
+
await response.body?.cancel();
|
|
92
|
+
return failure(taskId, "TC_CONTROL_RESPONSE_INVALID");
|
|
93
|
+
}
|
|
94
|
+
const reader = response.body?.getReader();
|
|
95
|
+
if (!reader)
|
|
96
|
+
return failure(taskId, "TC_CONTROL_RESPONSE_INVALID");
|
|
97
|
+
const chunks = [];
|
|
98
|
+
let bytes = 0;
|
|
99
|
+
for (;;) {
|
|
100
|
+
const chunk = await reader.read();
|
|
101
|
+
if (chunk.done)
|
|
102
|
+
break;
|
|
103
|
+
bytes += chunk.value.byteLength;
|
|
104
|
+
if (bytes > MAX_RESPONSE) {
|
|
105
|
+
await reader.cancel();
|
|
106
|
+
return failure(taskId, "TC_CONTROL_RESPONSE_TOO_LARGE");
|
|
107
|
+
}
|
|
108
|
+
chunks.push(chunk.value);
|
|
109
|
+
}
|
|
110
|
+
const payload = JSON.parse(Buffer.concat(chunks).toString("utf8"));
|
|
111
|
+
if (!payload ||
|
|
112
|
+
payload.protocolVersion !== PROTOCOL_VERSION ||
|
|
113
|
+
payload.taskId !== taskId ||
|
|
114
|
+
!statuses.includes(payload.status) ||
|
|
115
|
+
!Array.isArray(payload.diagnostics) ||
|
|
116
|
+
!Array.isArray(payload.artifacts) ||
|
|
117
|
+
!("data" in payload))
|
|
118
|
+
return failure(taskId, "TC_CONTROL_RESPONSE_INVALID");
|
|
119
|
+
if (!response.ok && payload.status === "succeeded")
|
|
120
|
+
return failure(taskId, "TC_CONTROL_RESPONSE_INVALID");
|
|
121
|
+
return payload;
|
|
122
|
+
}
|
|
123
|
+
catch {
|
|
124
|
+
return failure(taskId, timedOut
|
|
125
|
+
? "TC_CONTROL_CLIENT_TIMEOUT"
|
|
126
|
+
: sendOptions.signal?.aborted
|
|
127
|
+
? "TC_CONTROL_CLIENT_CANCELLED"
|
|
128
|
+
: "TC_CONTROL_TRANSPORT_FAILURE", timedOut
|
|
129
|
+
? "timed_out"
|
|
130
|
+
: sendOptions.signal?.aborted
|
|
131
|
+
? "cancelled"
|
|
132
|
+
: "failed");
|
|
133
|
+
}
|
|
134
|
+
finally {
|
|
135
|
+
clearTimeout(timer);
|
|
136
|
+
sendOptions.signal?.removeEventListener("abort", externalAbort);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
send: async (command, sendOptions) => {
|
|
141
|
+
try {
|
|
142
|
+
parseCommand(command);
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return failure(sendOptions?.taskId ?? `control-${randomUUID()}`, "TC_CONTROL_COMMAND_INVALID");
|
|
146
|
+
}
|
|
147
|
+
return request("/__pelican/control", command, sendOptions);
|
|
148
|
+
},
|
|
149
|
+
status: () => request("/__pelican/status", undefined),
|
|
150
|
+
cancel: (taskId) => request("/__pelican/cancel", { taskId }),
|
|
151
|
+
reset: () => request("/__pelican/session", { action: "reset" }),
|
|
152
|
+
};
|
|
153
|
+
}
|