@needle-tools/engine 4.15.0-next.f391a30 → 4.15.0
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/components.needle.json +1 -1
- package/dist/{gltf-progressive-CTlvpS3A.js → gltf-progressive-Bm_6aEi4.js} +1 -1
- package/dist/{gltf-progressive-CMwJPwEt.umd.cjs → gltf-progressive-BttGBXw6.umd.cjs} +1 -1
- package/dist/{gltf-progressive-DYL3SLVb.min.js → gltf-progressive-T5WKTux5.min.js} +1 -1
- package/dist/materialx-CJyQZtjt.min.js +90 -0
- package/dist/materialx-DMs1E08Z.js +4636 -0
- package/dist/materialx-DaKKOoVk.umd.cjs +90 -0
- package/dist/{needle-engine.bundle-DsTdfmeb.min.js → needle-engine.bundle-CBq_OMnI.min.js} +122 -124
- package/dist/{needle-engine.bundle-DB4kLWO_.js → needle-engine.bundle-DGyiwNWR.js} +3226 -3232
- package/dist/{needle-engine.bundle-C1BFRZDF.umd.cjs → needle-engine.bundle-JN3eiiYc.umd.cjs} +113 -115
- package/dist/needle-engine.d.ts +52 -33
- package/dist/needle-engine.js +288 -287
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/dist/{postprocessing-BN-f4viE.min.js → postprocessing-06AXuvdv.min.js} +1 -1
- package/dist/{postprocessing-De9ZpJrk.js → postprocessing-CI2x8Cln.js} +1 -1
- package/dist/{postprocessing-DYmYOVm4.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +1 -1
- package/dist/{three-examples-BHqRVpO_.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +12 -12
- package/dist/{three-examples-C0ZCCA_K.js → three-examples-CMYCd5nH.js} +192 -182
- package/dist/{three-examples-DmTY8tGr.min.js → three-examples-CQl1fFZp.min.js} +14 -14
- package/lib/engine/api.d.ts +2 -0
- package/lib/engine/api.js +2 -0
- package/lib/engine/api.js.map +1 -1
- package/lib/engine/debug/debug.js +1 -1
- package/lib/engine/debug/debug.js.map +1 -1
- package/lib/engine/debug/debug_spatial_console.js +1 -1
- package/lib/engine/debug/debug_spatial_console.js.map +1 -1
- package/lib/engine/engine_accessibility.d.ts +1 -1
- package/lib/engine/engine_accessibility.js +1 -1
- package/lib/engine/engine_accessibility.js.map +1 -1
- package/lib/engine/engine_context.d.ts +1 -1
- package/lib/engine/engine_context.js +2 -2
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/engine_create_objects.js +1 -1
- package/lib/engine/engine_create_objects.js.map +1 -1
- package/lib/engine/engine_gizmos.js +1 -1
- package/lib/engine/engine_gizmos.js.map +1 -1
- package/lib/engine/engine_license.js +2 -7
- package/lib/engine/engine_license.js.map +1 -1
- package/lib/engine/engine_test_utils.d.ts +39 -0
- package/lib/engine/engine_test_utils.js +84 -0
- package/lib/engine/engine_test_utils.js.map +1 -0
- package/lib/engine/engine_utils.js +2 -2
- package/lib/engine/engine_utils.js.map +1 -1
- package/lib/engine/export/gltf/index.js +1 -1
- package/lib/engine/export/gltf/index.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +3 -6
- package/lib/engine/webcomponents/logo-element.js +0 -18
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
- package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +7 -10
- package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -14
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js +1 -10
- package/lib/engine/webcomponents/needle-engine.ar-overlay.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +0 -3
- package/lib/engine/webcomponents/needle-engine.js +0 -10
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine-components/Component.js +1 -0
- package/lib/engine-components/Component.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +2 -24
- package/lib/engine-components/ReflectionProbe.js +2 -28
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/lib/engine-components/Skybox.js +2 -4
- package/lib/engine-components/Skybox.js.map +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js +1 -1
- package/lib/engine-components/export/gltf/GltfExport.js.map +1 -1
- package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +2 -2
- package/lib/engine-components/export/usdz/USDZExporter.js +1 -1
- package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +2 -2
- package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js.map +1 -1
- package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
- package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
- package/package.json +14 -18
- package/plugins/common/buildinfo.js +10 -46
- package/plugins/common/files.js +1 -2
- package/plugins/common/license.js +69 -144
- package/plugins/common/logger.js +11 -172
- package/plugins/common/worker.js +4 -5
- package/plugins/types/userconfig.d.ts +2 -40
- package/plugins/vite/alias.js +5 -6
- package/plugins/vite/asap.js +5 -6
- package/plugins/vite/build-pipeline.js +41 -224
- package/plugins/vite/buildinfo.js +6 -66
- package/plugins/vite/copyfiles.js +12 -41
- package/plugins/vite/custom-element-data.js +16 -26
- package/plugins/vite/defines.js +5 -8
- package/plugins/vite/dependencies.js +10 -16
- package/plugins/vite/dependency-watcher.js +7 -35
- package/plugins/vite/drop-client.js +5 -7
- package/plugins/vite/drop.js +14 -16
- package/plugins/vite/editor-connection.js +16 -18
- package/plugins/vite/imports-logger.js +2 -12
- package/plugins/vite/index.js +3 -8
- package/plugins/vite/local-files.js +441 -2
- package/plugins/vite/logger.client.js +35 -45
- package/plugins/vite/logger.js +3 -6
- package/plugins/vite/meta.js +4 -18
- package/plugins/vite/needle-app.js +3 -4
- package/plugins/vite/peer.js +1 -2
- package/plugins/vite/pwa.js +17 -33
- package/plugins/vite/reload.js +2 -24
- package/src/engine/api.ts +3 -0
- package/src/engine/debug/debug.ts +1 -1
- package/src/engine/debug/debug_spatial_console.ts +1 -5
- package/src/engine/engine_accessibility.ts +1 -2
- package/src/engine/engine_context.ts +2 -2
- package/src/engine/engine_create_objects.ts +1 -1
- package/src/engine/engine_gizmos.ts +5 -9
- package/src/engine/engine_license.ts +2 -7
- package/src/engine/engine_test_utils.ts +109 -0
- package/src/engine/engine_utils.ts +2 -2
- package/src/engine/export/gltf/index.ts +1 -1
- package/src/engine/webcomponents/logo-element.ts +3 -20
- package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -6
- package/src/engine/webcomponents/needle menu/needle-menu.ts +11 -23
- package/src/engine/webcomponents/needle-engine.ar-overlay.ts +2 -13
- package/src/engine/webcomponents/needle-engine.ts +1 -13
- package/src/engine-components/Component.ts +2 -1
- package/src/engine-components/ReflectionProbe.ts +9 -33
- package/src/engine-components/Skybox.ts +2 -4
- package/src/engine-components/export/gltf/GltfExport.ts +1 -1
- package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2 -2
- package/src/engine-components/export/usdz/USDZExporter.ts +1 -1
- package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +2 -2
- package/src/include/draco/draco_decoder.js +34 -0
- package/src/include/draco/draco_decoder.wasm +0 -0
- package/src/include/draco/draco_wasm_wrapper.js +117 -0
- package/src/include/ktx2/basis_transcoder.js +19 -0
- package/src/include/ktx2/basis_transcoder.wasm +0 -0
- package/src/include/needle/arial-msdf.json +1472 -0
- package/src/include/needle/arial.png +0 -0
- package/src/include/needle/poweredbyneedle.webp +0 -0
- package/dist/materialx-4jJLLe9Q.js +0 -4174
- package/dist/materialx-Bt9FHwco.min.js +0 -158
- package/dist/materialx-NDD0y4JY.umd.cjs +0 -158
- package/lib/engine/export/gltf/EXT_mesh_gpu_instancing_exporter.js.map +0 -1
- package/plugins/common/needle-engine-skill.md +0 -175
- package/plugins/vite/ai.js +0 -71
- package/plugins/vite/local-files-analysis.js +0 -789
- package/plugins/vite/local-files-core.js +0 -992
- package/plugins/vite/local-files-internals.js +0 -28
- package/plugins/vite/local-files-types.d.ts +0 -111
- package/plugins/vite/local-files-utils.js +0 -359
- package/plugins/vite/logging.js +0 -129
- /package/lib/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.d.ts +0 -0
- /package/lib/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.js +0 -0
- /package/src/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.js +0 -0
package/plugins/common/logger.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { createWriteStream, existsSync, mkdirSync, readdirSync, rmSync, statSync, write } from "fs";
|
|
3
2
|
|
|
4
3
|
const filename_timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
@@ -16,209 +15,57 @@ let originalConsoleWarn = console.warn;
|
|
|
16
15
|
let originalConsoleInfo = console.info;
|
|
17
16
|
let originalConsoleDebug = console.debug;
|
|
18
17
|
let didPatch = false;
|
|
19
|
-
/** @type {(() => void) | null} */
|
|
20
18
|
let unpatchFunction = null;
|
|
21
19
|
|
|
22
|
-
|
|
23
|
-
mode: "serve",
|
|
24
|
-
progressActive: false,
|
|
25
|
-
assetFiles: 0,
|
|
26
|
-
assetTotalKb: 0,
|
|
27
|
-
assetGzipKb: 0,
|
|
28
|
-
compressionFiles: 0,
|
|
29
|
-
compressionTotalKb: 0,
|
|
30
|
-
compressionGzipKb: 0,
|
|
31
|
-
compressionCaptureActive: false,
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
/** @param {unknown} value @returns {number} */
|
|
35
|
-
function parseKb(value) {
|
|
36
|
-
const numeric = Number.parseFloat(String(value ?? "0").replace(/[^0-9.]/g, ""));
|
|
37
|
-
return Number.isFinite(numeric) ? numeric : 0;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
function clearBuildProgressLine() {
|
|
41
|
-
if (!process.stdout.isTTY || !buildOutputState.progressActive) return;
|
|
42
|
-
process.stdout.write("\r\x1b[2K");
|
|
43
|
-
buildOutputState.progressActive = false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
/** @param {string} text */
|
|
47
|
-
function writeBuildProgressLine(text) {
|
|
48
|
-
if (!process.stdout.isTTY) return;
|
|
49
|
-
const maxLength = Math.max(24, (process.stdout.columns || 120) - 1);
|
|
50
|
-
const line = text.length > maxLength ? `${text.slice(0, Math.max(0, maxLength - 1))}…` : text;
|
|
51
|
-
process.stdout.write(`\r\x1b[2K${line}\x1b[0K`);
|
|
52
|
-
buildOutputState.progressActive = true;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
function resetBuildOutputState() {
|
|
56
|
-
buildOutputState.progressActive = false;
|
|
57
|
-
buildOutputState.assetFiles = 0;
|
|
58
|
-
buildOutputState.assetTotalKb = 0;
|
|
59
|
-
buildOutputState.assetGzipKb = 0;
|
|
60
|
-
buildOutputState.compressionFiles = 0;
|
|
61
|
-
buildOutputState.compressionTotalKb = 0;
|
|
62
|
-
buildOutputState.compressionGzipKb = 0;
|
|
63
|
-
buildOutputState.compressionCaptureActive = false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function flushBuildOutputSummaries() {
|
|
67
|
-
if (buildOutputState.mode !== "build") return;
|
|
68
|
-
clearBuildProgressLine();
|
|
69
|
-
|
|
70
|
-
if (buildOutputState.assetFiles > 0) {
|
|
71
|
-
const msg = formatBuildInfoSummaryMessage(`✓ Bundled ${buildOutputState.assetFiles} files (${buildOutputState.assetTotalKb.toFixed(2)} kB${buildOutputState.assetGzipKb > 0 ? `, gzip ${buildOutputState.assetGzipKb.toFixed(2)} kB` : ""})`);
|
|
72
|
-
originalConsoleLog(msg);
|
|
73
|
-
captureLogMessage("server", "log", msg, null);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (buildOutputState.compressionFiles > 0) {
|
|
77
|
-
const msg = formatBuildInfoSummaryMessage(`✓ Gzip compressed ${buildOutputState.compressionFiles} files (${buildOutputState.compressionTotalKb.toFixed(2)} kB → ${buildOutputState.compressionGzipKb.toFixed(2)} kB)`);
|
|
78
|
-
originalConsoleLog(msg);
|
|
79
|
-
captureLogMessage("server", "log", msg, null);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
resetBuildOutputState();
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
function supportsColorOutput() {
|
|
86
|
-
return !!process.stdout?.isTTY && process.env.NO_COLOR !== "1";
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/** @param {string} name @returns {string} */
|
|
90
|
-
function formatNeedleHeader(name) {
|
|
91
|
-
if (!supportsColorOutput()) return `[${name}]`;
|
|
92
|
-
if (name.startsWith("needle-")) {
|
|
93
|
-
const suffix = name.substring("needle-".length);
|
|
94
|
-
return `\x1b[32m[\x1b[0m\x1b[32mneedle-\x1b[0m\x1b[1;32m${suffix}\x1b[0m\x1b[32m]\x1b[0m`;
|
|
95
|
-
}
|
|
96
|
-
if (name.startsWith("needle:")) {
|
|
97
|
-
const suffix = name.substring("needle:".length);
|
|
98
|
-
return `\x1b[32m[\x1b[0m\x1b[32mneedle:\x1b[0m\x1b[1;32m${suffix}\x1b[0m\x1b[32m]\x1b[0m`;
|
|
99
|
-
}
|
|
100
|
-
return `\x1b[32m[\x1b[0m\x1b[1;32m${name}\x1b[0m\x1b[32m]\x1b[0m`;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** @param {string} body @returns {string} */
|
|
104
|
-
function formatBuildInfoSummaryMessage(body) {
|
|
105
|
-
return `${formatNeedleHeader("needle-buildinfo")}\n${body}`;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
/** @param {unknown[]} args @returns {string} */
|
|
109
|
-
function normalizeConsoleArgs(args) {
|
|
110
|
-
return args.map(arg => typeof arg === "string" ? arg : stringifyLog(arg)).join(" ");
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
/** @param {unknown[]} args @returns {boolean} */
|
|
114
|
-
function tryHandleBuildConsoleOutput(args) {
|
|
115
|
-
if (buildOutputState.mode !== "build") return false;
|
|
116
|
-
|
|
117
|
-
const raw = normalizeConsoleArgs(args);
|
|
118
|
-
const message = raw.replace(/\u001b\[[0-9;]*m/g, "").trim();
|
|
119
|
-
if (!message.length) return true;
|
|
120
|
-
|
|
121
|
-
if (/^transforming\s*\(/i.test(message)) {
|
|
122
|
-
writeBuildProgressLine(`⏳ ${message}`);
|
|
123
|
-
return true;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (message.includes("[vite-plugin-compression]:algorithm=")) {
|
|
127
|
-
buildOutputState.compressionCaptureActive = true;
|
|
128
|
-
return true;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const assetMatch = message.match(/^dist\/.*?\s+([0-9.,]+)\s*kB(?:\s*[│|]\s*gzip:\s*([0-9.,]+)\s*kB)?$/i);
|
|
132
|
-
if (assetMatch) {
|
|
133
|
-
buildOutputState.assetFiles++;
|
|
134
|
-
buildOutputState.assetTotalKb += parseKb(assetMatch[1]);
|
|
135
|
-
if (assetMatch[2]) buildOutputState.assetGzipKb += parseKb(assetMatch[2]);
|
|
136
|
-
writeBuildProgressLine(`📦 Bundling assets: ${buildOutputState.assetFiles} files`);
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
if (buildOutputState.compressionCaptureActive) {
|
|
141
|
-
const compressionMatch = message.match(/^dist\/.*?\s+([0-9.]+)\s*kb\s*\/\s*gzip:\s*([0-9.]+)\s*kb$/i);
|
|
142
|
-
if (compressionMatch) {
|
|
143
|
-
buildOutputState.compressionFiles++;
|
|
144
|
-
buildOutputState.compressionTotalKb += parseKb(compressionMatch[1]);
|
|
145
|
-
buildOutputState.compressionGzipKb += parseKb(compressionMatch[2]);
|
|
146
|
-
writeBuildProgressLine(`🗜️ Compressing: ${buildOutputState.compressionFiles} files`);
|
|
147
|
-
return true;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (message.startsWith("✓ built in")) {
|
|
152
|
-
flushBuildOutputSummaries();
|
|
153
|
-
return false;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
flushBuildOutputSummaries();
|
|
157
|
-
return false;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* @param {{command?: string} | undefined} [options]
|
|
162
|
-
* @returns {(() => void) | undefined}
|
|
163
|
-
*/
|
|
164
|
-
export function patchConsoleLogs(options = undefined) {
|
|
20
|
+
export function patchConsoleLogs() {
|
|
165
21
|
if (didPatch) return unpatchFunction;
|
|
166
22
|
didPatch = true;
|
|
167
|
-
buildOutputState.mode = options?.command === "build" ? "build" : "serve";
|
|
168
|
-
resetBuildOutputState();
|
|
169
23
|
|
|
170
24
|
console.log = (...args) => {
|
|
171
|
-
if (tryHandleBuildConsoleOutput(args)) return;
|
|
172
25
|
originalConsoleLog(...args);
|
|
173
26
|
captureLogMessage("server", 'log', args, null);
|
|
174
27
|
};
|
|
175
28
|
console.error = (...args) => {
|
|
176
|
-
flushBuildOutputSummaries();
|
|
177
29
|
originalConsoleError(...args);
|
|
178
30
|
captureLogMessage("server", 'error', args, null);
|
|
179
31
|
};
|
|
180
32
|
console.warn = (...args) => {
|
|
181
|
-
flushBuildOutputSummaries();
|
|
182
33
|
originalConsoleWarn(...args);
|
|
183
34
|
captureLogMessage("server", 'warn', args, null);
|
|
184
35
|
};
|
|
185
36
|
console.info = (...args) => {
|
|
186
|
-
if (tryHandleBuildConsoleOutput(args)) return;
|
|
187
37
|
originalConsoleInfo(...args);
|
|
188
38
|
captureLogMessage("server", 'info', args, null);
|
|
189
39
|
};
|
|
190
40
|
console.debug = (...args) => {
|
|
191
|
-
if (tryHandleBuildConsoleOutput(args)) return;
|
|
192
41
|
originalConsoleDebug(...args);
|
|
193
42
|
captureLogMessage("server", 'debug', args, null);
|
|
194
43
|
};
|
|
195
44
|
|
|
196
45
|
// Restore original console methods
|
|
197
46
|
unpatchFunction = () => {
|
|
198
|
-
flushBuildOutputSummaries();
|
|
199
47
|
didPatch = false;
|
|
200
48
|
console.log = originalConsoleLog;
|
|
201
49
|
console.error = originalConsoleError;
|
|
202
50
|
console.warn = originalConsoleWarn;
|
|
203
51
|
console.info = originalConsoleInfo;
|
|
204
52
|
console.debug = originalConsoleDebug;
|
|
205
|
-
buildOutputState.mode = "serve";
|
|
206
53
|
}
|
|
207
54
|
return unpatchFunction;
|
|
208
55
|
}
|
|
209
56
|
|
|
210
57
|
|
|
211
58
|
let isCapturing = false;
|
|
212
|
-
/** @type {Set<
|
|
59
|
+
/** @type {Set<string>} */
|
|
213
60
|
const isCapturingLogMessage = new Set();
|
|
214
61
|
|
|
215
|
-
/** @type {Array<{ process: ProcessType, key: string, log:
|
|
62
|
+
/** @type {Array<{ process: ProcessType, key: string, log:any, timestamp:number, connectionId: string | null }>} */
|
|
216
63
|
const queue = new Array();
|
|
217
64
|
|
|
218
65
|
/**
|
|
219
66
|
* @param {ProcessType} process
|
|
220
67
|
* @param {string} key
|
|
221
|
-
* @param {
|
|
68
|
+
* @param {any} log
|
|
222
69
|
* @param {string | null} connectionId - Optional connection ID for client logs.
|
|
223
70
|
* @param {number} [time] - Optional timestamp, defaults to current time.
|
|
224
71
|
*/
|
|
@@ -262,10 +109,10 @@ export function captureLogMessage(process, key, log, connectionId, time = Date.n
|
|
|
262
109
|
|
|
263
110
|
/**
|
|
264
111
|
* Stringifies a log message, handling circular references and formatting.
|
|
265
|
-
* @param {
|
|
266
|
-
* @param {Set<
|
|
112
|
+
* @param {any} log
|
|
113
|
+
* @param {Set<any>} [seen]
|
|
267
114
|
*/
|
|
268
|
-
function stringifyLog(log, seen =
|
|
115
|
+
function stringifyLog(log, seen = new Set(), depth = 0) {
|
|
269
116
|
const isServer = typeof window === "undefined";
|
|
270
117
|
const stringify_limits = {
|
|
271
118
|
string: isServer ? 100_000 : 1_000,
|
|
@@ -307,9 +154,8 @@ function stringifyLog(log, seen = /** @type {Set<unknown>} */ (new Set()), depth
|
|
|
307
154
|
|| log instanceof BigUint64Array
|
|
308
155
|
|| log instanceof Float64Array
|
|
309
156
|
) {
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
return stringifyArray(logArr);
|
|
157
|
+
seen.add(log);
|
|
158
|
+
return stringifyArray(log);
|
|
313
159
|
}
|
|
314
160
|
if (typeof log === "object") {
|
|
315
161
|
|
|
@@ -323,12 +169,11 @@ function stringifyLog(log, seen = /** @type {Set<unknown>} */ (new Set()), depth
|
|
|
323
169
|
return `<Error: ${log.message}\nStack: ${log.stack}>`;
|
|
324
170
|
}
|
|
325
171
|
|
|
326
|
-
const
|
|
327
|
-
const keys = Object.keys(logObj);
|
|
172
|
+
const keys = Object.keys(log);
|
|
328
173
|
let res = "{";
|
|
329
174
|
for (let i = 0; i < keys.length; i++) {
|
|
330
175
|
const key = keys[i];
|
|
331
|
-
let value =
|
|
176
|
+
let value = log[key];
|
|
332
177
|
if (i >= stringify_limits.object_keys) {
|
|
333
178
|
res += `, ... <truncated ${keys.length - i} keys>`;
|
|
334
179
|
break;
|
|
@@ -363,7 +208,6 @@ function stringifyLog(log, seen = /** @type {Set<unknown>} */ (new Set()), depth
|
|
|
363
208
|
|
|
364
209
|
return String(log);
|
|
365
210
|
|
|
366
|
-
/** @param {ArrayLike<unknown>} arr @returns {string} */
|
|
367
211
|
function stringifyArray(arr) {
|
|
368
212
|
let res = "";
|
|
369
213
|
for (let i = 0; i < arr.length; i++) {
|
|
@@ -496,11 +340,6 @@ function onExit() {
|
|
|
496
340
|
filestreams.forEach((stream) => stream.end());
|
|
497
341
|
filestreams.clear();
|
|
498
342
|
}
|
|
499
|
-
|
|
500
|
-
export function closeLogStreams() {
|
|
501
|
-
onExit();
|
|
502
|
-
}
|
|
503
|
-
|
|
504
343
|
const events = ['SIGTERM', 'SIGINT', 'beforeExit', 'rejectionHandled', 'uncaughtException', 'exit'];
|
|
505
344
|
for (const event of events) {
|
|
506
345
|
process.on(event, onExit);
|
package/plugins/common/worker.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { needleLog } from '../vite/logging.js';
|
|
2
1
|
|
|
3
2
|
|
|
4
3
|
|
|
@@ -52,12 +51,12 @@ export function rollupFixWorkerImport(opts = { logFail: true }) {
|
|
|
52
51
|
regexMatchedWorkerCode = true;
|
|
53
52
|
// console.log("WORKER?", url)
|
|
54
53
|
if (url?.startsWith("/")) {
|
|
55
|
-
|
|
54
|
+
console.log(`[rollup] Rewrite worker import in ${chunk.fileName}`);
|
|
56
55
|
// Make url file-relative
|
|
57
56
|
const newUrl = url.replace(/^\//, "");
|
|
58
57
|
// For CORS issues we need to use importScripts: https://linear.app/needle/issue/NE-6572#comment-ea5dc65e
|
|
59
58
|
const output = `/* new-worker */ new Worker(URL.createObjectURL(new Blob(["import '" + \`\${new URL('./${newUrl}', import.meta.url).toString()}\` + "';"], { type: 'text/javascript' }))`;
|
|
60
|
-
|
|
59
|
+
console.log("[rollup] Did rewrite worker output to:", output);
|
|
61
60
|
return output;
|
|
62
61
|
// return `new Worker(new URL("./${newUrl}", import.meta.url)`;
|
|
63
62
|
}
|
|
@@ -71,7 +70,7 @@ export function rollupFixWorkerImport(opts = { logFail: true }) {
|
|
|
71
70
|
}
|
|
72
71
|
if (opts?.logFail !== false) {
|
|
73
72
|
const str = `[...]${code.substring(newWorkerStartIndex, newWorkerStartIndex + 200)}[...]`
|
|
74
|
-
|
|
73
|
+
console.warn(`\n[rollup] Worker import in ${chunk.fileName} was not rewritten: ${str}`);
|
|
75
74
|
}
|
|
76
75
|
}
|
|
77
76
|
return res;
|
|
@@ -117,7 +116,7 @@ function fixWorkerSelfLocation(filename, code) {
|
|
|
117
116
|
const fixedCode = workerCode.replace("self.location", "import.meta.url");
|
|
118
117
|
code = code.substring(0, startIndex) + fixedCode + code.substring(endIndex + 1);
|
|
119
118
|
lastIndex = startIndex + fixedCode.length;
|
|
120
|
-
|
|
119
|
+
console.log(`[rollup] Rewrite worker 'self.location' to 'import.meta.url' in ${filename}`);
|
|
121
120
|
} else {
|
|
122
121
|
lastIndex = endIndex;
|
|
123
122
|
}
|
|
@@ -112,48 +112,10 @@ export type userSettings = {
|
|
|
112
112
|
debugLicense?: boolean;
|
|
113
113
|
|
|
114
114
|
/**
|
|
115
|
-
* When enabled
|
|
116
|
-
* This creates fully self-contained deployments that work without internet access.
|
|
117
|
-
*
|
|
118
|
-
* - `true` — enable with all features (download everything)
|
|
119
|
-
* - `"auto"` — automatically detect which features the project uses and only include those
|
|
120
|
-
* - `{ enabled: true }` — same as `true`
|
|
121
|
-
* - `{ enabled: true, features: "auto" }` — same as `"auto"`
|
|
122
|
-
* - `{ enabled: true, features: ["draco", "ktx2"] }` — only include specific features
|
|
123
|
-
* - `{ enabled: true, excludeFeatures: ["xr"] }` — include all except specific features
|
|
124
|
-
* - `{ enabled: true, features: "auto", excludeFeatures: ["skybox"] }` — auto-detect but exclude specific features
|
|
125
|
-
*
|
|
126
|
-
* Available features:
|
|
127
|
-
* - `"draco"` — Draco mesh decoders
|
|
128
|
-
* - `"ktx2"` — KTX2/Basis texture transcoders
|
|
129
|
-
* - `"materialx"` — MaterialX WASM shader compiler
|
|
130
|
-
* - `"xr"` — WebXR input profiles (controllers/hands)
|
|
131
|
-
* - `"skybox"` — Skybox/environment textures
|
|
132
|
-
* - `"fonts"` — Google Fonts CSS + font files
|
|
133
|
-
* - `"needle-fonts"` — Needle font assets (MSDF, etc.)
|
|
134
|
-
* - `"needle-models"` — Needle models
|
|
135
|
-
* - `"needle-avatars"` — Needle avatars
|
|
136
|
-
* - `"polyhaven"` — Polyhaven HDRIs/models
|
|
137
|
-
* - `"cdn-scripts"` — Third-party scripts (QRCode.js, vConsole, HLS.js)
|
|
138
|
-
* - `"github-content"` — GitHub raw content files
|
|
139
|
-
* - `"threejs-models"` — three.js example models
|
|
140
|
-
* - `"needle-uploads"` — Needle uploads assets
|
|
115
|
+
* Experimental: When enabled then fonts from google fonts will be downloaded and copied to the output directory
|
|
141
116
|
*/
|
|
142
|
-
makeFilesLocal?: boolean |
|
|
117
|
+
makeFilesLocal?: boolean | {
|
|
143
118
|
enabled: boolean;
|
|
144
|
-
/** URL patterns to exclude from making local */
|
|
145
|
-
exclude?: string[];
|
|
146
|
-
/** Target platform preset */
|
|
147
|
-
platform?: "discord" | "facebook-instant" | null;
|
|
148
|
-
/**
|
|
149
|
-
* Feature categories to include.
|
|
150
|
-
* - `"auto"` — Automatically detect which features the project uses.
|
|
151
|
-
* - `FeatureName[]` — Explicit list. When set, ONLY these features are processed.
|
|
152
|
-
* - When omitted, ALL features are included.
|
|
153
|
-
*/
|
|
154
|
-
features?: "auto" | Array<"draco" | "ktx2" | "materialx" | "xr" | "skybox" | "fonts" | "needle-fonts" | "needle-models" | "needle-avatars" | "polyhaven" | "cdn-scripts" | "github-content" | "threejs-models" | "needle-uploads">;
|
|
155
|
-
/** Feature categories to exclude. Applied after `features` (including after auto-detection). */
|
|
156
|
-
excludeFeatures?: Array<"draco" | "ktx2" | "materialx" | "xr" | "skybox" | "fonts" | "needle-fonts" | "needle-models" | "needle-avatars" | "polyhaven" | "cdn-scripts" | "github-content" | "threejs-models" | "needle-uploads">;
|
|
157
119
|
}
|
|
158
120
|
|
|
159
121
|
/**
|
package/plugins/vite/alias.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { createWriteStream, existsSync, mkdirSync, rmSync, writeFileSync } from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import { needleLog } from './logging.js';
|
|
4
3
|
|
|
5
4
|
const projectDir = process.cwd() + "/";
|
|
6
5
|
|
|
@@ -78,7 +77,7 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
78
77
|
|
|
79
78
|
let outputDebugFile = null;
|
|
80
79
|
function log(...msg) {
|
|
81
|
-
|
|
80
|
+
console.log(...msg);
|
|
82
81
|
if (debug) logToFile(...msg);
|
|
83
82
|
}
|
|
84
83
|
function logToFile(...msg) {
|
|
@@ -92,7 +91,7 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
92
91
|
const timestamp = new Date().toISOString();
|
|
93
92
|
outputDebugFile.write("\n\n\n--------------------------\n");
|
|
94
93
|
outputDebugFile.write(`[needle-alias] Logging to: ${outputFilePath} (${timestamp})\n`);
|
|
95
|
-
log("Logging to:", outputFilePath);
|
|
94
|
+
log("[needle-alias] Logging to: ", outputFilePath);
|
|
96
95
|
}
|
|
97
96
|
|
|
98
97
|
|
|
@@ -100,7 +99,7 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
100
99
|
const aliasPlugin = {
|
|
101
100
|
name: "needle-alias",
|
|
102
101
|
config(config) {
|
|
103
|
-
if (debug) log('ProjectDirectory: ' + projectDir);
|
|
102
|
+
if (debug) console.log('[needle-alias] ProjectDirectory: ' + projectDir);
|
|
104
103
|
if (!config.resolve) config.resolve = {};
|
|
105
104
|
if (!config.resolve.alias) config.resolve.alias = {};
|
|
106
105
|
const aliasDict = config.resolve.alias;
|
|
@@ -120,7 +119,7 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
120
119
|
config.optimizeDeps.exclude ??= [];
|
|
121
120
|
if (!config.optimizeDeps.include?.includes('@needle-tools/engine')) {
|
|
122
121
|
config.optimizeDeps.exclude.push('@needle-tools/engine');
|
|
123
|
-
log("Detected local @needle-tools/engine package → will exclude it from optimization");
|
|
122
|
+
log("[needle-alias] Detected local @needle-tools/engine package → will exclude it from optimization");
|
|
124
123
|
}
|
|
125
124
|
}
|
|
126
125
|
|
|
@@ -133,7 +132,7 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
133
132
|
if (typeof entry === "function") res = entry(name, 0, name);
|
|
134
133
|
testResults.push({ name, entry: res });
|
|
135
134
|
}
|
|
136
|
-
log('Aliases: '
|
|
135
|
+
console.log('[needle-alias] Aliases: ', testResults);
|
|
137
136
|
}
|
|
138
137
|
},
|
|
139
138
|
}
|
package/plugins/vite/asap.js
CHANGED
|
@@ -3,7 +3,6 @@ import path from 'path';
|
|
|
3
3
|
import { tryParseNeedleEngineSrcAttributeFromHtml } from '../common/needle-engine.js';
|
|
4
4
|
import { preloadScriptPaths } from './dependencies.js';
|
|
5
5
|
import { makeFilesLocalIsEnabled } from './local-files.js';
|
|
6
|
-
import { needleLog } from './logging.js';
|
|
7
6
|
|
|
8
7
|
const code = `import('@needle-tools/engine/src/asap/needle-asap.ts');`
|
|
9
8
|
|
|
@@ -31,7 +30,7 @@ export const needleAsap = async (command, config, userSettings) => {
|
|
|
31
30
|
logoSvg = assets.NEEDLE_LOGO_SVG_URL;
|
|
32
31
|
}
|
|
33
32
|
catch (err) {
|
|
34
|
-
|
|
33
|
+
console.warn("Could not load needle logo svg", err.message);
|
|
35
34
|
}
|
|
36
35
|
|
|
37
36
|
/** @type {import("vite").ResolvedConfig | null} */
|
|
@@ -123,7 +122,7 @@ function fixMainTs() {
|
|
|
123
122
|
if (existsSync(mainTsFilePath)) {
|
|
124
123
|
let code = readFileSync(mainTsFilePath, 'utf-8');
|
|
125
124
|
if (code.includes('import \"@needle-tools/engine\"')) {
|
|
126
|
-
|
|
125
|
+
console.log("Change main.ts and replace needle engine import with async import");
|
|
127
126
|
code = code.replace(/import \"@needle-tools\/engine\"/g, 'import("@needle-tools/engine") /* async import of needle engine */');
|
|
128
127
|
writeFileSync(mainTsFilePath, code);
|
|
129
128
|
}
|
|
@@ -152,7 +151,7 @@ function generateScriptPreloadLinks(_config, tags) {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
catch (err) {
|
|
155
|
-
|
|
154
|
+
console.error("Error generating script preload links", err);
|
|
156
155
|
}
|
|
157
156
|
}
|
|
158
157
|
|
|
@@ -202,11 +201,11 @@ function generateGltfPreloadLinks(config, html, tags) {
|
|
|
202
201
|
filepath = decodeURIComponent(filepath);
|
|
203
202
|
const fullpath = path.join(process.cwd(), filepath);
|
|
204
203
|
if (!existsSync(fullpath)) {
|
|
205
|
-
|
|
204
|
+
console.warn(`[needle:asap] Could not insert head preload link: file not found at \"${filepath}\"`);
|
|
206
205
|
continue;
|
|
207
206
|
}
|
|
208
207
|
}
|
|
209
|
-
|
|
208
|
+
console.log(`[needle:asap] Insert head glTF preload link: ${value}`);
|
|
210
209
|
insertPreloadLink(tags, value, "model/gltf+json");
|
|
211
210
|
}
|
|
212
211
|
}
|