@needle-tools/engine 4.7.0-next.ef983f9 → 4.7.0-next.fe38209
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/CHANGELOG.md +5 -0
- package/dist/{gltf-progressive-Bl4okF1b.min.js → gltf-progressive-60Qk5ebF.min.js} +6 -6
- package/dist/{gltf-progressive-DSpdn0QT.js → gltf-progressive-DM5ZiecW.js} +176 -170
- package/dist/gltf-progressive-wxtaVmio.umd.cjs +8 -0
- package/dist/{needle-engine.bundle-450ujan4.js → needle-engine.bundle-9cpwwMWz.js} +3451 -3439
- package/dist/{needle-engine.bundle-CbNroJbN.umd.cjs → needle-engine.bundle-B5YoLPqw.umd.cjs} +115 -115
- package/dist/{needle-engine.bundle-BDMr_I34.min.js → needle-engine.bundle-DlHpd9LP.min.js} +113 -113
- package/dist/needle-engine.js +3 -3
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_addressables.d.ts +1 -3
- package/lib/engine/engine_addressables.js +5 -12
- package/lib/engine/engine_addressables.js.map +1 -1
- package/lib/engine/engine_lightdata.js +12 -2
- package/lib/engine/engine_lightdata.js.map +1 -1
- package/lib/engine/engine_lods.d.ts +4 -0
- package/lib/engine/engine_lods.js +19 -5
- package/lib/engine/engine_lods.js.map +1 -1
- package/package.json +2 -2
- package/plugins/common/logger.js +156 -51
- package/plugins/types/userconfig.d.ts +3 -1
- package/plugins/vite/logger.client.js +80 -24
- package/plugins/vite/logger.js +22 -6
- package/src/engine/engine_addressables.ts +6 -15
- package/src/engine/engine_lightdata.ts +10 -2
- package/src/engine/engine_lods.ts +23 -5
- package/dist/gltf-progressive-P8b8a0qY.umd.cjs +0 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine_lods.js","sourceRoot":"","sources":["../../src/engine/engine_lods.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,IAAI,YAAY,EAAE,kB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AQ,EAAE,GAAG,CAAC,CAAC;iBAC3G;aACJ;SAEJ;IACL,CAAC;CAEJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.7.0-next.
|
|
3
|
+
"version": "4.7.0-next.fe38209",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
],
|
|
94
94
|
"dependencies": {
|
|
95
95
|
"@dimforge/rapier3d-compat": "^0.14.0",
|
|
96
|
-
"@needle-tools/gltf-progressive": "^2.1.
|
|
96
|
+
"@needle-tools/gltf-progressive": "^2.1.6",
|
|
97
97
|
"@webxr-input-profiles/motion-controllers": "^1.0.0",
|
|
98
98
|
"flatbuffers": "2.0.4",
|
|
99
99
|
"md5": "^2.3.0",
|
package/plugins/common/logger.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { createWriteStream, existsSync, mkdirSync, readdirSync, rmSync, statSync, write } from "fs";
|
|
2
2
|
|
|
3
3
|
const filename_timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
|
|
4
|
+
const debug = false;
|
|
4
5
|
|
|
6
|
+
// #region public api
|
|
5
7
|
|
|
6
8
|
/**
|
|
7
9
|
* @typedef {"server" | "client" | "client-http"} ProcessType
|
|
@@ -21,23 +23,23 @@ export function patchConsoleLogs() {
|
|
|
21
23
|
|
|
22
24
|
console.log = (...args) => {
|
|
23
25
|
originalConsoleLog(...args);
|
|
24
|
-
captureLogMessage("server", 'log', args);
|
|
26
|
+
captureLogMessage("server", 'log', args, null);
|
|
25
27
|
};
|
|
26
28
|
console.error = (...args) => {
|
|
27
29
|
originalConsoleError(...args);
|
|
28
|
-
captureLogMessage("server", 'error', args);
|
|
30
|
+
captureLogMessage("server", 'error', args, null);
|
|
29
31
|
};
|
|
30
32
|
console.warn = (...args) => {
|
|
31
33
|
originalConsoleWarn(...args);
|
|
32
|
-
captureLogMessage("server", 'warn', args);
|
|
34
|
+
captureLogMessage("server", 'warn', args, null);
|
|
33
35
|
};
|
|
34
36
|
console.info = (...args) => {
|
|
35
37
|
originalConsoleInfo(...args);
|
|
36
|
-
captureLogMessage("server", 'info', args);
|
|
38
|
+
captureLogMessage("server", 'info', args, null);
|
|
37
39
|
};
|
|
38
40
|
console.debug = (...args) => {
|
|
39
41
|
originalConsoleDebug(...args);
|
|
40
|
-
captureLogMessage("server", 'debug', args);
|
|
42
|
+
captureLogMessage("server", 'debug', args, null);
|
|
41
43
|
};
|
|
42
44
|
|
|
43
45
|
// Restore original console methods
|
|
@@ -54,51 +56,54 @@ export function patchConsoleLogs() {
|
|
|
54
56
|
|
|
55
57
|
|
|
56
58
|
let isCapturing = false;
|
|
59
|
+
/** @type {Set<string>} */
|
|
60
|
+
const isCapturingLogMessage = new Set();
|
|
57
61
|
|
|
58
|
-
/** @type {Array<{ process: ProcessType, key: string, log:any, timestamp:number }>} */
|
|
62
|
+
/** @type {Array<{ process: ProcessType, key: string, log:any, timestamp:number, connectionId: string | null }>} */
|
|
59
63
|
const queue = new Array();
|
|
60
64
|
|
|
61
65
|
/**
|
|
62
66
|
* @param {ProcessType} process
|
|
63
67
|
* @param {string} key
|
|
64
68
|
* @param {any} log
|
|
69
|
+
* @param {string | null} connectionId - Optional connection ID for client logs.
|
|
70
|
+
* @param {number} [time] - Optional timestamp, defaults to current time.
|
|
65
71
|
*/
|
|
66
|
-
export function captureLogMessage(process, key, log, time = Date.now()) {
|
|
72
|
+
export function captureLogMessage(process, key, log, connectionId, time = Date.now()) {
|
|
73
|
+
|
|
74
|
+
if (isCapturingLogMessage.has(log)) {
|
|
75
|
+
return; // prevent circular logs
|
|
76
|
+
}
|
|
77
|
+
|
|
67
78
|
if (isCapturing) {
|
|
68
|
-
queue.push({ process, key, log, timestamp: Date.now() });
|
|
79
|
+
queue.push({ process, key, log, timestamp: Date.now(), connectionId });
|
|
69
80
|
return;
|
|
70
81
|
}
|
|
71
82
|
isCapturing = true;
|
|
83
|
+
isCapturingLogMessage.add(log);
|
|
72
84
|
|
|
73
85
|
try {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
86
|
+
let str = stringifyLog(log);
|
|
87
|
+
if (str.trim().length > 0) {
|
|
88
|
+
// if(process === "server") str = stripAnsiColors(str);
|
|
89
|
+
const prefix = `${getTimestamp(time, true)}, ${process}${connectionId ? (`[${connectionId}]`) : ""}.${key}: `;
|
|
90
|
+
const separator = "";
|
|
91
|
+
const finalLog = indent(`${prefix}${separator}${removeEmptyLinesAtStart(str)}`, prefix.length, separator)
|
|
92
|
+
writeToFile(process, finalLog, connectionId);
|
|
93
|
+
}
|
|
78
94
|
} finally {
|
|
79
95
|
isCapturing = false;
|
|
96
|
+
isCapturingLogMessage.delete(log);
|
|
80
97
|
}
|
|
81
98
|
|
|
82
99
|
let queued = queue.pop();
|
|
83
100
|
if (queued) {
|
|
84
|
-
captureLogMessage(queued.process, queued.key, queued.log, queued.timestamp);
|
|
101
|
+
captureLogMessage(queued.process, queued.key, queued.log, queued.connectionId, queued.timestamp);
|
|
85
102
|
}
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
|
|
89
|
-
// #region
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Returns the current timestamp in ISO format.
|
|
93
|
-
* @param {number} [date] - Optional date to format, defaults to current date.
|
|
94
|
-
*/
|
|
95
|
-
function getTimestamp(date, timeOnly = false) {
|
|
96
|
-
const now = date ? new Date(date) : new Date();
|
|
97
|
-
if (timeOnly) {
|
|
98
|
-
return now.toTimeString().split(' ')[0]; // HH:MM:SS
|
|
99
|
-
}
|
|
100
|
-
return now.toISOString();
|
|
101
|
-
}
|
|
106
|
+
// #region stringify log
|
|
102
107
|
|
|
103
108
|
|
|
104
109
|
/**
|
|
@@ -106,10 +111,18 @@ function getTimestamp(date, timeOnly = false) {
|
|
|
106
111
|
* @param {any} log
|
|
107
112
|
* @param {Set<any>} [seen]
|
|
108
113
|
*/
|
|
109
|
-
function stringifyLog(log, seen = new Set()) {
|
|
114
|
+
function stringifyLog(log, seen = new Set(), depth = 0) {
|
|
115
|
+
|
|
116
|
+
const isServer = typeof window === "undefined";
|
|
117
|
+
const stringify_limits = {
|
|
118
|
+
string: isServer ? 100_000 : 2000,
|
|
119
|
+
object_keys: isServer ? 300 : 100,
|
|
120
|
+
object_depth: isServer ? 10 : 3,
|
|
121
|
+
array_items: isServer ? 2_000 : 100,
|
|
122
|
+
}
|
|
110
123
|
|
|
111
124
|
if (typeof log === "string") {
|
|
112
|
-
if (log.length >
|
|
125
|
+
if (log.length > stringify_limits.string) log = `${log.slice(0, stringify_limits.string)}... <truncated ${log.length - stringify_limits.string} characters>`;
|
|
113
126
|
return log;
|
|
114
127
|
}
|
|
115
128
|
if (typeof log === "number" || typeof log === "boolean") {
|
|
@@ -121,32 +134,96 @@ function stringifyLog(log, seen = new Set()) {
|
|
|
121
134
|
if (log === undefined) {
|
|
122
135
|
return "undefined";
|
|
123
136
|
}
|
|
137
|
+
if (typeof log === "function") {
|
|
138
|
+
return "<function>";
|
|
139
|
+
}
|
|
124
140
|
|
|
125
|
-
if (seen.has(log)) return "
|
|
126
|
-
seen.add(log);
|
|
141
|
+
if (seen.has(log)) return "<circular>";
|
|
127
142
|
|
|
128
143
|
if (Array.isArray(log)) {
|
|
144
|
+
seen.add(log);
|
|
145
|
+
return stringifyArray(log);
|
|
146
|
+
}
|
|
147
|
+
if (typeof log === "object") {
|
|
129
148
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
let item = log[i];
|
|
133
|
-
if (res) res += ", ";
|
|
134
|
-
if (i > 100) res += "[truncated: " + (log.length - i) + " more items]";
|
|
135
|
-
res += stringifyLog(item, seen);
|
|
149
|
+
if (depth > stringify_limits.object_depth) {
|
|
150
|
+
return "<object too deep>";
|
|
136
151
|
}
|
|
152
|
+
|
|
153
|
+
seen.add(log);
|
|
154
|
+
// const str = JSON.stringify(log, (key, value) => {
|
|
155
|
+
// if (typeof value === "function") return "<function>";
|
|
156
|
+
// if (typeof value === "string") return stringifyLog(value, seen, depth + 1);
|
|
157
|
+
// if (typeof value === "object") {
|
|
158
|
+
// if (seen.has(value)) return "<circular>";
|
|
159
|
+
// seen.add(value);
|
|
160
|
+
// }
|
|
161
|
+
// return value;
|
|
162
|
+
// });
|
|
163
|
+
// return str;
|
|
164
|
+
const keys = Object.keys(log);
|
|
165
|
+
let res = "{";
|
|
166
|
+
for (let i = 0; i < keys.length; i++) {
|
|
167
|
+
const key = keys[i];
|
|
168
|
+
let value = log[key];
|
|
169
|
+
|
|
170
|
+
if (typeof value === "number") {
|
|
171
|
+
// clamp precision for numbers
|
|
172
|
+
value = Number(value.toFixed(6));
|
|
173
|
+
}
|
|
174
|
+
let str = stringifyLog(value, seen, depth + 1);
|
|
175
|
+
if (typeof value === "object") {
|
|
176
|
+
if (Array.isArray(value)) {
|
|
177
|
+
str = `[${str}]`;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else if (typeof value === "string") {
|
|
181
|
+
str = `"${str}"`;
|
|
182
|
+
}
|
|
183
|
+
if (i > 0) res += ", ";
|
|
184
|
+
res += `"${key}":${str}`;
|
|
185
|
+
}
|
|
186
|
+
res += "}";
|
|
137
187
|
return res;
|
|
188
|
+
// let entries = Object.entries(log).map(([key, value], index) => {
|
|
189
|
+
// if (index > stringify_limits.object_keys) return `"${key}": <truncated>`;
|
|
190
|
+
// return `"${key}": ${stringifyLog(value, seen, depth + 1)}`;
|
|
191
|
+
// });
|
|
192
|
+
// return `{ ${entries.join(", ")} }`;
|
|
138
193
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
194
|
+
return String(log);
|
|
195
|
+
|
|
196
|
+
function stringifyArray(arr) {
|
|
197
|
+
let res = "";
|
|
198
|
+
for (let i = 0; i < arr.length; i++) {
|
|
199
|
+
let entry = arr[i];
|
|
200
|
+
if (res && i > 0) res += ", ";
|
|
201
|
+
if (i > stringify_limits.array_items) {
|
|
202
|
+
res += "<truncated " + (arr.length - i) + ">";
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
res += stringifyLog(entry, seen, depth + 1);
|
|
206
|
+
}
|
|
207
|
+
return res;
|
|
145
208
|
}
|
|
146
|
-
|
|
147
|
-
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
// #region utility functions
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Returns the current timestamp in ISO format.
|
|
219
|
+
* @param {number} [date] - Optional date to format, defaults to current date.
|
|
220
|
+
*/
|
|
221
|
+
function getTimestamp(date, timeOnly = false) {
|
|
222
|
+
const now = date ? new Date(date) : new Date();
|
|
223
|
+
if (timeOnly) {
|
|
224
|
+
return now.toTimeString().split(' ')[0]; // HH:MM:SS
|
|
148
225
|
}
|
|
149
|
-
return
|
|
226
|
+
return now.toISOString();
|
|
150
227
|
}
|
|
151
228
|
|
|
152
229
|
|
|
@@ -168,10 +245,35 @@ function indent(str, length, separator = "") {
|
|
|
168
245
|
return lines.join("\n");
|
|
169
246
|
}
|
|
170
247
|
|
|
248
|
+
/**
|
|
249
|
+
* Removes empty lines at the start of a string.
|
|
250
|
+
* @param {string} str - The string to process.
|
|
251
|
+
*/
|
|
252
|
+
function removeEmptyLinesAtStart(str) {
|
|
253
|
+
const lines = str.split("\n");
|
|
254
|
+
for (let i = 0; i < lines.length; i++) {
|
|
255
|
+
const line = lines[i].trim();
|
|
256
|
+
if (line.length > 0) {
|
|
257
|
+
lines[i] = line; // keep the first non-empty line
|
|
258
|
+
return lines.slice(i).join("\n");
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return "";
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* Strips ANSI color codes from a string.
|
|
266
|
+
* @param {string} str - The string to process.
|
|
267
|
+
*/
|
|
268
|
+
function stripAnsiColors(str) {
|
|
269
|
+
// This pattern catches most ANSI escape sequences
|
|
270
|
+
return str.replace(/\x1b\[[0-9;]*[a-zA-Z]/g, '');
|
|
271
|
+
}
|
|
272
|
+
|
|
171
273
|
|
|
172
274
|
// #region log to file
|
|
173
275
|
|
|
174
|
-
/** @type {Map<
|
|
276
|
+
/** @type {Map<string, import("fs").WriteStream>} */
|
|
175
277
|
const filestreams = new Map();
|
|
176
278
|
const fileLogDirectory = "node_modules/.needle/logs";
|
|
177
279
|
// cleanup old log files
|
|
@@ -194,17 +296,20 @@ if (existsSync(fileLogDirectory)) {
|
|
|
194
296
|
* Writes a log message to the file.
|
|
195
297
|
* @param {ProcessType} process
|
|
196
298
|
* @param {string} log
|
|
299
|
+
* @param {string | null} connectionId - Optional connection ID for client logs.
|
|
197
300
|
*/
|
|
198
|
-
function writeToFile(process, log) {
|
|
199
|
-
|
|
301
|
+
function writeToFile(process, log, connectionId) {
|
|
302
|
+
const filename = `${process}.needle.log`; //connectionId && process === "client" ? `${process}-${connectionId}.needle.log` : `${process}.needle.log`;
|
|
303
|
+
|
|
304
|
+
if (!filestreams.has(filename)) {
|
|
200
305
|
if (!existsSync(fileLogDirectory)) {
|
|
201
306
|
mkdirSync(fileLogDirectory, { recursive: true });
|
|
202
307
|
}
|
|
203
|
-
filestreams.set(
|
|
308
|
+
filestreams.set(filename, createWriteStream(`${fileLogDirectory}/${filename_timestamp}.${filename}`, { flags: 'a' }));
|
|
204
309
|
}
|
|
205
|
-
const writeStream = filestreams.get(
|
|
310
|
+
const writeStream = filestreams.get(filename);
|
|
206
311
|
if (!writeStream) {
|
|
207
|
-
console.error(`No write stream for process: ${
|
|
312
|
+
if (debug) console.error(`No write stream for process: ${filename}`);
|
|
208
313
|
return;
|
|
209
314
|
}
|
|
210
315
|
writeStream.write(log + '\n');
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { License } from "./license";
|
|
2
|
-
import { NeedlePWAOptions } from "./webmanifest.js";
|
|
3
2
|
|
|
4
3
|
export type needleModules = {
|
|
5
4
|
webpack: object | undefined
|
|
@@ -118,5 +117,8 @@ export type userSettings = {
|
|
|
118
117
|
*/
|
|
119
118
|
openBrowser?: boolean;
|
|
120
119
|
|
|
120
|
+
/** Automatically import MaterialX for needle engine in 'main.ts' */
|
|
121
121
|
loadMaterialX?: boolean;
|
|
122
|
+
|
|
123
|
+
disableLogging?: boolean;
|
|
122
124
|
}
|
|
@@ -8,12 +8,15 @@
|
|
|
8
8
|
function sendLogToServer(level, ...message) {
|
|
9
9
|
if ("hot" in import.meta) {
|
|
10
10
|
message = stringifyLog(message);
|
|
11
|
+
// keep messages below payload limit
|
|
12
|
+
if(message.length > 100_000) {
|
|
13
|
+
message = message.slice(0, 100_000) + "... <truncated>";
|
|
14
|
+
}
|
|
11
15
|
// @ts-ignore
|
|
12
16
|
import.meta.hot.send("needle:client-log", { level, message: message });
|
|
13
17
|
}
|
|
14
18
|
}
|
|
15
19
|
|
|
16
|
-
|
|
17
20
|
// const obj = {
|
|
18
21
|
// hello: "world"
|
|
19
22
|
// }
|
|
@@ -165,17 +168,23 @@ User Activation: ${"userActivation" in navigator ? JSON.stringify(navigator.user
|
|
|
165
168
|
// #region copied from common/logger.js
|
|
166
169
|
|
|
167
170
|
|
|
168
|
-
|
|
169
|
-
|
|
170
171
|
/**
|
|
171
172
|
* Stringifies a log message, handling circular references and formatting.
|
|
172
173
|
* @param {any} log
|
|
173
174
|
* @param {Set<any>} [seen]
|
|
174
175
|
*/
|
|
175
|
-
function stringifyLog(log, seen = new Set()) {
|
|
176
|
+
function stringifyLog(log, seen = new Set(), depth = 0) {
|
|
177
|
+
|
|
178
|
+
const isServer = typeof window === "undefined";
|
|
179
|
+
const stringify_limits = {
|
|
180
|
+
string: isServer ? 100_000 : 2000,
|
|
181
|
+
object_keys: isServer ? 300 : 100,
|
|
182
|
+
object_depth: isServer ? 10 : 3,
|
|
183
|
+
array_items: isServer ? 2_000 : 100,
|
|
184
|
+
}
|
|
176
185
|
|
|
177
186
|
if (typeof log === "string") {
|
|
178
|
-
if (log.length >
|
|
187
|
+
if (log.length > stringify_limits.string) log = `${log.slice(0, stringify_limits.string)}... <truncated ${log.length - stringify_limits.string} characters>`;
|
|
179
188
|
return log;
|
|
180
189
|
}
|
|
181
190
|
if (typeof log === "number" || typeof log === "boolean") {
|
|
@@ -187,30 +196,77 @@ function stringifyLog(log, seen = new Set()) {
|
|
|
187
196
|
if (log === undefined) {
|
|
188
197
|
return "undefined";
|
|
189
198
|
}
|
|
199
|
+
if (typeof log === "function") {
|
|
200
|
+
return "<function>";
|
|
201
|
+
}
|
|
190
202
|
|
|
191
|
-
if (seen.has(log)) return "
|
|
192
|
-
seen.add(log);
|
|
203
|
+
if (seen.has(log)) return "<circular>";
|
|
193
204
|
|
|
194
205
|
if (Array.isArray(log)) {
|
|
206
|
+
seen.add(log);
|
|
207
|
+
return stringifyArray(log);
|
|
208
|
+
}
|
|
209
|
+
if (typeof log === "object") {
|
|
195
210
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
let item = log[i];
|
|
199
|
-
if (res) res += ", ";
|
|
200
|
-
if (i > 100) res += "[truncated: " + (log.length - i) + " more items]";
|
|
201
|
-
res += stringifyLog(item, seen);
|
|
211
|
+
if (depth > stringify_limits.object_depth) {
|
|
212
|
+
return "<object too deep>";
|
|
202
213
|
}
|
|
214
|
+
|
|
215
|
+
seen.add(log);
|
|
216
|
+
// const str = JSON.stringify(log, (key, value) => {
|
|
217
|
+
// if (typeof value === "function") return "<function>";
|
|
218
|
+
// if (typeof value === "string") return stringifyLog(value, seen, depth + 1);
|
|
219
|
+
// if (typeof value === "object") {
|
|
220
|
+
// if (seen.has(value)) return "<circular>";
|
|
221
|
+
// seen.add(value);
|
|
222
|
+
// }
|
|
223
|
+
// return value;
|
|
224
|
+
// });
|
|
225
|
+
// return str;
|
|
226
|
+
const keys = Object.keys(log);
|
|
227
|
+
let res = "{";
|
|
228
|
+
for (let i = 0; i < keys.length; i++) {
|
|
229
|
+
const key = keys[i];
|
|
230
|
+
let value = log[key];
|
|
231
|
+
|
|
232
|
+
if (typeof value === "number") {
|
|
233
|
+
// clamp precision for numbers
|
|
234
|
+
value = Number(value.toFixed(6));
|
|
235
|
+
}
|
|
236
|
+
let str = stringifyLog(value, seen, depth + 1);
|
|
237
|
+
if (typeof value === "object") {
|
|
238
|
+
if (Array.isArray(value)) {
|
|
239
|
+
str = `[${str}]`;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
else if (typeof value === "string") {
|
|
243
|
+
str = `"${str}"`;
|
|
244
|
+
}
|
|
245
|
+
if (i > 0) res += ", ";
|
|
246
|
+
res += `"${key}":${str}`;
|
|
247
|
+
}
|
|
248
|
+
res += "}";
|
|
203
249
|
return res;
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
});
|
|
210
|
-
return `{ ${entries.join(", ")} }`;
|
|
211
|
-
}
|
|
212
|
-
if (log instanceof Buffer) {
|
|
213
|
-
return `Buffer(${log.length}, ${log.byteLength}, ${log.byteOffset})`;
|
|
250
|
+
// let entries = Object.entries(log).map(([key, value], index) => {
|
|
251
|
+
// if (index > stringify_limits.object_keys) return `"${key}": <truncated>`;
|
|
252
|
+
// return `"${key}": ${stringifyLog(value, seen, depth + 1)}`;
|
|
253
|
+
// });
|
|
254
|
+
// return `{ ${entries.join(", ")} }`;
|
|
214
255
|
}
|
|
215
256
|
return String(log);
|
|
216
|
-
|
|
257
|
+
|
|
258
|
+
function stringifyArray(arr) {
|
|
259
|
+
let res = "";
|
|
260
|
+
for (let i = 0; i < arr.length; i++) {
|
|
261
|
+
let entry = arr[i];
|
|
262
|
+
if (res && i > 0) res += ", ";
|
|
263
|
+
if (i > stringify_limits.array_items) {
|
|
264
|
+
res += "<truncated " + (arr.length - i) + ">";
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
res += stringifyLog(entry, seen, depth + 1);
|
|
268
|
+
}
|
|
269
|
+
return res;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
|
package/plugins/vite/logger.js
CHANGED
|
@@ -10,12 +10,16 @@ const __dirname = path.dirname(__filename);
|
|
|
10
10
|
/**
|
|
11
11
|
* write logs to local file
|
|
12
12
|
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
13
|
-
* @returns {import('vite').Plugin}
|
|
13
|
+
* @returns {import('vite').Plugin | null}
|
|
14
14
|
*/
|
|
15
15
|
export const needleLogger = (command, config, userSettings) => {
|
|
16
16
|
|
|
17
|
+
if (userSettings?.disableLogging === true) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
17
21
|
patchConsoleLogs();
|
|
18
|
-
captureLogMessage("server", "info", "Vite started with command \"" + command + "\" in " + __dirname);
|
|
22
|
+
captureLogMessage("server", "info", "Vite started with command \"" + command + "\" in " + __dirname, null);
|
|
19
23
|
|
|
20
24
|
return {
|
|
21
25
|
name: "needle:logger",
|
|
@@ -58,12 +62,22 @@ export const needleLogger = (command, config, userSettings) => {
|
|
|
58
62
|
* @param {import('vite').PreviewServer | import('vite').ViteDevServer} server
|
|
59
63
|
*/
|
|
60
64
|
function logRequests(server, log_http_requests = false) {
|
|
65
|
+
/**
|
|
66
|
+
* Logs a message to the server console and captures it.
|
|
67
|
+
* @type {Map<import("vite").WebSocket, {id:string}>}
|
|
68
|
+
*/
|
|
69
|
+
const connectedClients = new Map();
|
|
70
|
+
let index = 0;
|
|
71
|
+
|
|
61
72
|
if ("ws" in server) {
|
|
62
73
|
// Clent connections
|
|
63
74
|
server.ws.on('connection', (socket, request) => {
|
|
64
|
-
|
|
75
|
+
const clientId = String(index++);
|
|
76
|
+
connectedClients.set(socket, { id: clientId });
|
|
77
|
+
const ip = request.socket.remoteAddress || 'unknown';
|
|
78
|
+
captureLogMessage("server", "connection", `New websocket connection established ${clientId} from ${ip}`, clientId);
|
|
65
79
|
socket.on('close', () => {
|
|
66
|
-
captureLogMessage("server", "connection",
|
|
80
|
+
captureLogMessage("server", "connection", `Websocket connection closed ${clientId}`, clientId);
|
|
67
81
|
});
|
|
68
82
|
});
|
|
69
83
|
// Client log messages via websocket
|
|
@@ -72,13 +86,15 @@ function logRequests(server, log_http_requests = false) {
|
|
|
72
86
|
console.warn("Received empty log data, ignoring");
|
|
73
87
|
return;
|
|
74
88
|
}
|
|
75
|
-
|
|
89
|
+
const socket = client.socket;
|
|
90
|
+
const info = connectedClients.get(socket);
|
|
91
|
+
captureLogMessage("client", data.level, data.message, info ? info.id : null);
|
|
76
92
|
});
|
|
77
93
|
}
|
|
78
94
|
// Log HTTP requests
|
|
79
95
|
if (log_http_requests) {
|
|
80
96
|
server.middlewares.use((req, res, next) => {
|
|
81
|
-
captureLogMessage("client-http", "info", [req.method, req.url]);
|
|
97
|
+
captureLogMessage("client-http", "info", [req.method, req.url], null);
|
|
82
98
|
next();
|
|
83
99
|
});
|
|
84
100
|
}
|
|
@@ -188,14 +188,11 @@ export class AssetReference {
|
|
|
188
188
|
private _urlName: string;
|
|
189
189
|
private _progressListeners: ProgressCallback[] = [];
|
|
190
190
|
|
|
191
|
-
private _hash?: string;
|
|
192
|
-
private _hashedUri: string;
|
|
193
|
-
|
|
194
191
|
private _isLoadingRawBinary: boolean = false;
|
|
195
192
|
private _rawBinary?: ArrayBufferLike | null;
|
|
196
193
|
|
|
197
194
|
/** @internal */
|
|
198
|
-
constructor(uri: string,
|
|
195
|
+
constructor(uri: string, _hash?: string, asset: any = null) {
|
|
199
196
|
this._url = uri;
|
|
200
197
|
|
|
201
198
|
const lastUriPart = uri.lastIndexOf("/");
|
|
@@ -210,14 +207,8 @@ export class AssetReference {
|
|
|
210
207
|
else {
|
|
211
208
|
this._urlName = uri;
|
|
212
209
|
}
|
|
213
|
-
|
|
214
|
-
this._hash = hash;
|
|
215
|
-
if (uri.includes("?v="))
|
|
216
|
-
this._hashedUri = uri;
|
|
217
|
-
else
|
|
218
|
-
this._hashedUri = hash ? uri + "?v=" + hash : uri;
|
|
210
|
+
|
|
219
211
|
if (asset !== null) this.asset = asset;
|
|
220
|
-
|
|
221
212
|
registerPrefabProvider(this._url, this.onResolvePrefab.bind(this));
|
|
222
213
|
}
|
|
223
214
|
|
|
@@ -263,8 +254,8 @@ export class AssetReference {
|
|
|
263
254
|
if (this._isLoadingRawBinary) return null;
|
|
264
255
|
if (this._rawBinary !== undefined) return this._rawBinary;
|
|
265
256
|
this._isLoadingRawBinary = true;
|
|
266
|
-
if (debug) console.log("Preload", this.
|
|
267
|
-
const res = await BlobStorage.download(this.
|
|
257
|
+
if (debug) console.log("Preload", this.url);
|
|
258
|
+
const res = await BlobStorage.download(this.url, p => {
|
|
268
259
|
this.raiseProgressEvent(p);
|
|
269
260
|
});
|
|
270
261
|
this._rawBinary = res?.buffer ?? null;
|
|
@@ -294,7 +285,7 @@ export class AssetReference {
|
|
|
294
285
|
// console.log("START LOADING");
|
|
295
286
|
if (this._rawBinary) {
|
|
296
287
|
if (!(this._rawBinary instanceof ArrayBuffer)) {
|
|
297
|
-
console.error("Invalid raw binary data"
|
|
288
|
+
console.error("Failed loading: Invalid raw binary data. Must be of type ArrayBuffer. " + (typeof this._rawBinary));
|
|
298
289
|
return null;
|
|
299
290
|
}
|
|
300
291
|
this._loading = getLoader().parseSync(context, this._rawBinary, this.url, null);
|
|
@@ -302,7 +293,7 @@ export class AssetReference {
|
|
|
302
293
|
}
|
|
303
294
|
else {
|
|
304
295
|
if (debug) console.log("Load async", this.url);
|
|
305
|
-
this._loading = getLoader().loadSync(context, this.
|
|
296
|
+
this._loading = getLoader().loadSync(context, this.url, this.url, null, prog => {
|
|
306
297
|
this.raiseProgressEvent(prog);
|
|
307
298
|
});
|
|
308
299
|
}
|
|
@@ -53,10 +53,12 @@ export class LightDataRegistry implements ILightDataRegistry {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
tryGetSkybox(sourceId?: SourceIdentifier | null): Texture | null {
|
|
56
|
+
if (debugLightmap) console.log("[Get Skybox]", sourceId, this._lightmaps)
|
|
56
57
|
return this.tryGet(sourceId, LightmapType.Skybox, 0);
|
|
57
58
|
}
|
|
58
59
|
|
|
59
60
|
tryGetReflection(sourceId?: SourceIdentifier | null): Texture | null {
|
|
61
|
+
if (debugLightmap) console.log("[Get Reflection]", sourceId, this._lightmaps)
|
|
60
62
|
return this.tryGet(sourceId, LightmapType.Reflection, 0);
|
|
61
63
|
}
|
|
62
64
|
|
|
@@ -66,9 +68,15 @@ export class LightDataRegistry implements ILightDataRegistry {
|
|
|
66
68
|
return null;
|
|
67
69
|
}
|
|
68
70
|
const entry = this._lightmaps.get(sourceId);
|
|
69
|
-
if (!entry)
|
|
71
|
+
if (!entry) {
|
|
72
|
+
if (debugLightmap) console.warn(`[Lighting] No ${LightmapType[type]} texture entry for`, sourceId);
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
70
75
|
const arr = entry.get(type);
|
|
71
|
-
if (arr === undefined)
|
|
76
|
+
if (arr === undefined) {
|
|
77
|
+
if (debugLightmap) console.warn(`[Lighting] No ${LightmapType[type]} texture for`, sourceId, "index", index);
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
72
80
|
if (!arr?.length || arr.length <= index) return null;
|
|
73
81
|
return arr[index];
|
|
74
82
|
}
|