@needle-tools/engine 4.7.0-next.da47826 → 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.
Files changed (60) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/dist/{gltf-progressive-Bl4okF1b.min.js → gltf-progressive-60Qk5ebF.min.js} +6 -6
  3. package/dist/{gltf-progressive-DSpdn0QT.js → gltf-progressive-DM5ZiecW.js} +176 -170
  4. package/dist/gltf-progressive-wxtaVmio.umd.cjs +8 -0
  5. package/dist/{needle-engine.bundle-CO1Ub9sm.js → needle-engine.bundle-9cpwwMWz.js} +3929 -3906
  6. package/dist/{needle-engine.bundle-Bu88IoKB.umd.cjs → needle-engine.bundle-B5YoLPqw.umd.cjs} +117 -114
  7. package/dist/{needle-engine.bundle-D95XN5pP.min.js → needle-engine.bundle-DlHpd9LP.min.js} +115 -112
  8. package/dist/needle-engine.js +3 -3
  9. package/dist/needle-engine.min.js +1 -1
  10. package/dist/needle-engine.umd.cjs +1 -1
  11. package/lib/engine/engine_addressables.d.ts +1 -3
  12. package/lib/engine/engine_addressables.js +5 -12
  13. package/lib/engine/engine_addressables.js.map +1 -1
  14. package/lib/engine/engine_context.js +4 -3
  15. package/lib/engine/engine_context.js.map +1 -1
  16. package/lib/engine/engine_lightdata.js +12 -2
  17. package/lib/engine/engine_lightdata.js.map +1 -1
  18. package/lib/engine/engine_lods.d.ts +4 -0
  19. package/lib/engine/engine_lods.js +19 -5
  20. package/lib/engine/engine_lods.js.map +1 -1
  21. package/lib/engine/engine_three_utils.js +4 -0
  22. package/lib/engine/engine_three_utils.js.map +1 -1
  23. package/lib/engine/webcomponents/needle-engine.attributes.d.ts +1 -1
  24. package/lib/engine-components/Camera.js +1 -1
  25. package/lib/engine-components/Camera.js.map +1 -1
  26. package/lib/engine-components/CameraUtils.js +5 -3
  27. package/lib/engine-components/CameraUtils.js.map +1 -1
  28. package/lib/engine-components/Skybox.js +4 -4
  29. package/lib/engine-components/Skybox.js.map +1 -1
  30. package/lib/engine-components/postprocessing/Effects/Antialiasing.js +8 -1
  31. package/lib/engine-components/postprocessing/Effects/Antialiasing.js.map +1 -1
  32. package/lib/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.js +1 -1
  33. package/lib/engine-components/postprocessing/PostProcessingHandler.js +15 -1
  34. package/lib/engine-components/postprocessing/PostProcessingHandler.js.map +1 -1
  35. package/lib/engine-components/postprocessing/Volume.js +1 -1
  36. package/lib/engine-components/postprocessing/Volume.js.map +1 -1
  37. package/package.json +2 -2
  38. package/plugins/common/logger.js +328 -0
  39. package/plugins/types/userconfig.d.ts +6 -2
  40. package/plugins/vite/alias.js +55 -40
  41. package/plugins/vite/imports-logger.js +1 -1
  42. package/plugins/vite/index.js +4 -0
  43. package/plugins/vite/logger.client.js +272 -0
  44. package/plugins/vite/logger.js +101 -0
  45. package/plugins/vite/materialx.js +32 -0
  46. package/plugins/vite/transform.js +1 -0
  47. package/src/engine/engine_addressables.ts +6 -15
  48. package/src/engine/engine_context.ts +4 -3
  49. package/src/engine/engine_lightdata.ts +10 -2
  50. package/src/engine/engine_lods.ts +23 -5
  51. package/src/engine/engine_three_utils.ts +3 -0
  52. package/src/engine/webcomponents/needle-engine.attributes.ts +1 -1
  53. package/src/engine-components/Camera.ts +1 -1
  54. package/src/engine-components/CameraUtils.ts +5 -3
  55. package/src/engine-components/Skybox.ts +5 -5
  56. package/src/engine-components/postprocessing/Effects/Antialiasing.ts +8 -1
  57. package/src/engine-components/postprocessing/Effects/ScreenspaceAmbientOcclusionN8.ts +1 -1
  58. package/src/engine-components/postprocessing/PostProcessingHandler.ts +14 -2
  59. package/src/engine-components/postprocessing/Volume.ts +1 -1
  60. package/dist/gltf-progressive-P8b8a0qY.umd.cjs +0 -8
@@ -0,0 +1,328 @@
1
+ import { createWriteStream, existsSync, mkdirSync, readdirSync, rmSync, statSync, write } from "fs";
2
+
3
+ const filename_timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, 19);
4
+ const debug = false;
5
+
6
+ // #region public api
7
+
8
+ /**
9
+ * @typedef {"server" | "client" | "client-http"} ProcessType
10
+ */
11
+
12
+ let originalConsoleLog = console.log;
13
+ let originalConsoleError = console.error;
14
+ let originalConsoleWarn = console.warn;
15
+ let originalConsoleInfo = console.info;
16
+ let originalConsoleDebug = console.debug;
17
+ let didPatch = false;
18
+ let unpatchFunction = null;
19
+
20
+ export function patchConsoleLogs() {
21
+ if (didPatch) return unpatchFunction;
22
+ didPatch = true;
23
+
24
+ console.log = (...args) => {
25
+ originalConsoleLog(...args);
26
+ captureLogMessage("server", 'log', args, null);
27
+ };
28
+ console.error = (...args) => {
29
+ originalConsoleError(...args);
30
+ captureLogMessage("server", 'error', args, null);
31
+ };
32
+ console.warn = (...args) => {
33
+ originalConsoleWarn(...args);
34
+ captureLogMessage("server", 'warn', args, null);
35
+ };
36
+ console.info = (...args) => {
37
+ originalConsoleInfo(...args);
38
+ captureLogMessage("server", 'info', args, null);
39
+ };
40
+ console.debug = (...args) => {
41
+ originalConsoleDebug(...args);
42
+ captureLogMessage("server", 'debug', args, null);
43
+ };
44
+
45
+ // Restore original console methods
46
+ unpatchFunction = () => {
47
+ didPatch = false;
48
+ console.log = originalConsoleLog;
49
+ console.error = originalConsoleError;
50
+ console.warn = originalConsoleWarn;
51
+ console.info = originalConsoleInfo;
52
+ console.debug = originalConsoleDebug;
53
+ }
54
+ return unpatchFunction;
55
+ }
56
+
57
+
58
+ let isCapturing = false;
59
+ /** @type {Set<string>} */
60
+ const isCapturingLogMessage = new Set();
61
+
62
+ /** @type {Array<{ process: ProcessType, key: string, log:any, timestamp:number, connectionId: string | null }>} */
63
+ const queue = new Array();
64
+
65
+ /**
66
+ * @param {ProcessType} process
67
+ * @param {string} key
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.
71
+ */
72
+ export function captureLogMessage(process, key, log, connectionId, time = Date.now()) {
73
+
74
+ if (isCapturingLogMessage.has(log)) {
75
+ return; // prevent circular logs
76
+ }
77
+
78
+ if (isCapturing) {
79
+ queue.push({ process, key, log, timestamp: Date.now(), connectionId });
80
+ return;
81
+ }
82
+ isCapturing = true;
83
+ isCapturingLogMessage.add(log);
84
+
85
+ try {
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
+ }
94
+ } finally {
95
+ isCapturing = false;
96
+ isCapturingLogMessage.delete(log);
97
+ }
98
+
99
+ let queued = queue.pop();
100
+ if (queued) {
101
+ captureLogMessage(queued.process, queued.key, queued.log, queued.connectionId, queued.timestamp);
102
+ }
103
+ }
104
+
105
+
106
+ // #region stringify log
107
+
108
+
109
+ /**
110
+ * Stringifies a log message, handling circular references and formatting.
111
+ * @param {any} log
112
+ * @param {Set<any>} [seen]
113
+ */
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
+ }
123
+
124
+ if (typeof log === "string") {
125
+ if (log.length > stringify_limits.string) log = `${log.slice(0, stringify_limits.string)}... <truncated ${log.length - stringify_limits.string} characters>`;
126
+ return log;
127
+ }
128
+ if (typeof log === "number" || typeof log === "boolean") {
129
+ return String(log);
130
+ }
131
+ if (log === null) {
132
+ return "null";
133
+ }
134
+ if (log === undefined) {
135
+ return "undefined";
136
+ }
137
+ if (typeof log === "function") {
138
+ return "<function>";
139
+ }
140
+
141
+ if (seen.has(log)) return "<circular>";
142
+
143
+ if (Array.isArray(log)) {
144
+ seen.add(log);
145
+ return stringifyArray(log);
146
+ }
147
+ if (typeof log === "object") {
148
+
149
+ if (depth > stringify_limits.object_depth) {
150
+ return "<object too deep>";
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 += "}";
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(", ")} }`;
193
+ }
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;
208
+ }
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
225
+ }
226
+ return now.toISOString();
227
+ }
228
+
229
+
230
+ /**
231
+ * Indents a string by a specified length.
232
+ * @param {string} str - The string to indent.
233
+ * @param {number} length - The number of spaces to indent each line.
234
+ * @returns {string} The indented string.
235
+ */
236
+ function indent(str, length, separator = "") {
237
+ const lines = str.split("\n");
238
+ const prefixStr = " ".repeat(length) + separator;
239
+ for (let i = 1; i < lines.length; i++) {
240
+ let entry = lines[i].trim();
241
+ if (entry.length === 0) continue; // skip empty lines
242
+ // indent the line
243
+ lines[i] = prefixStr + entry;
244
+ }
245
+ return lines.join("\n");
246
+ }
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
+
273
+
274
+ // #region log to file
275
+
276
+ /** @type {Map<string, import("fs").WriteStream>} */
277
+ const filestreams = new Map();
278
+ const fileLogDirectory = "node_modules/.needle/logs";
279
+ // cleanup old log files
280
+ if (existsSync(fileLogDirectory)) {
281
+ const files = readdirSync(fileLogDirectory);
282
+ // sort by age and keep the last 10 files
283
+ files.sort((a, b) => {
284
+ const aStat = statSync(`${fileLogDirectory}/${a}`);
285
+ const bStat = statSync(`${fileLogDirectory}/${b}`);
286
+ return aStat.mtimeMs - bStat.mtimeMs;
287
+ });
288
+ // remove all but the last 30 files
289
+ const filesToKeep = 30;
290
+ for (let i = 0; i < files.length - filesToKeep; i++) {
291
+ rmSync(`${fileLogDirectory}/${files[i]}`, { force: true });
292
+ }
293
+ }
294
+
295
+ /**
296
+ * Writes a log message to the file.
297
+ * @param {ProcessType} process
298
+ * @param {string} log
299
+ * @param {string | null} connectionId - Optional connection ID for client logs.
300
+ */
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)) {
305
+ if (!existsSync(fileLogDirectory)) {
306
+ mkdirSync(fileLogDirectory, { recursive: true });
307
+ }
308
+ filestreams.set(filename, createWriteStream(`${fileLogDirectory}/${filename_timestamp}.${filename}`, { flags: 'a' }));
309
+ }
310
+ const writeStream = filestreams.get(filename);
311
+ if (!writeStream) {
312
+ if (debug) console.error(`No write stream for process: ${filename}`);
313
+ return;
314
+ }
315
+ writeStream.write(log + '\n');
316
+ }
317
+
318
+
319
+
320
+ // #region process exit
321
+ function onExit() {
322
+ filestreams.forEach((stream) => stream.end());
323
+ filestreams.clear();
324
+ }
325
+ const events = ['SIGTERM', 'SIGINT', 'beforeExit', 'rejectionHandled', 'uncaughtException', 'exit'];
326
+ for (const event of events) {
327
+ process.on(event, onExit);
328
+ }
@@ -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
@@ -49,7 +48,7 @@ export type userSettings = {
49
48
  /** Custom configuration for facebook instant games. */
50
49
  facebookInstantGames?: {}
51
50
  /** Set to true to create an imports.log file that shows all module imports. The file is generated when stopping the server. */
52
- logModuleImportChains?: boolean;
51
+ debugImportChains?: boolean;
53
52
 
54
53
  /** Set to true to disable generating the buildinfo.json file in your output directory */
55
54
  noBuildInfo?: boolean;
@@ -117,4 +116,9 @@ export type userSettings = {
117
116
  * @default undefined
118
117
  */
119
118
  openBrowser?: boolean;
119
+
120
+ /** Automatically import MaterialX for needle engine in 'main.ts' */
121
+ loadMaterialX?: boolean;
122
+
123
+ disableLogging?: boolean;
120
124
  }
@@ -3,14 +3,33 @@ import path from 'path';
3
3
 
4
4
  const projectDir = process.cwd() + "/";
5
5
 
6
+ /**
7
+ * @typedef {"auto-resolve" | ((res: string, packageName: string, index: number, path: string) => string | null | void)} PackageResolveValue
8
+ */
9
+
6
10
  /** these are alias callbacks as in the vite.alias dictionary
7
11
  * the first argument is the already resoled absolute path (it is only invoked if the path was found in node_modules)
8
12
  * the 2,3,4 args are the same as in vite.alias (packageName, index, path);
9
13
  */
10
14
  /**
11
- * @type {Record<string, null | ((res: string, packageName: string, index: number, path: string) => string | null | void)>}
15
+ * @type {Record<string, PackageResolveValue>}
12
16
  */
13
17
  const packages_to_resolve = {
18
+ // We are currently overriding "three" resolution to ensure that all dependencies resolve to the same three.js version.
19
+ // This is hacky, but the alternative is potentially having conflicting three.js versions since some packages are
20
+ // stubborn with their peer dependencies or just slow (slower as we) with updating.
21
+ // NOT adding this allows node.js to correctly resolve `exports` specified in three.js package.json;
22
+ // since we're overriding resolution here we need to manually resolve the subset of exports that we use.
23
+ 'three/addons': (res, packageName, index, path) => {
24
+ return "three/examples/jsm";
25
+ },
26
+ 'three/nodes': (res, packageName, index, path) => {
27
+ return "three/examples/jsm/nodes/Nodes.js";
28
+ },
29
+ 'three': (res, packageName, index, _path) => {
30
+ return path.resolve(projectDir, 'node_modules', 'three');
31
+ },
32
+
14
33
  // Handle all previous imports where users did import using @needle-engine/src
15
34
  '@needle-tools/engine/src': (res, packageName, index, path) => {
16
35
  // resolve old engine/src imports UNLESS it's the asap plugin (the asap plugin currently only exists in the src folder)
@@ -23,21 +42,25 @@ const packages_to_resolve = {
23
42
  because this is automatically done by vite according to whatever we define in our package.json exports
24
43
  This did previously prevent us from declaring proper exports in package.json
25
44
  */
26
- '@needle-tools/engine': (res, packageName, index, path) => {
45
+ '@needle-tools/engine': (res, packageName, index, _path) => {
27
46
  // Check if the import is something like @needle-tools/engine/engine/engine_utils
28
47
  // in which case we want to resolve into the lib directory
29
- if (path.startsWith("@needle-tools/engine/engine")) {
48
+ if (_path.startsWith("@needle-tools/engine/engine")) {
30
49
  return res + "/lib";
31
50
  }
51
+ const node_modules_path = path.resolve(projectDir, 'node_modules', '@needle-tools/engine');
52
+ if (existsSync(node_modules_path)) {
53
+ return node_modules_path;
54
+ }
32
55
  },
33
56
 
34
- /*
35
- Removed. Three.js is manually resolved below to ensure all dependencies resolve to the same three.js version.
36
- 'three': null,
37
- */
38
- 'peerjs': null,
39
- 'websocket-ts': null,
40
- 'md5': null,
57
+ // Auto resolve to 'node_modules/<name>' or '@needle-tools/engine/node_modules/<name>'
58
+ 'peerjs': "auto-resolve",
59
+ 'websocket-ts': "auto-resolve",
60
+ 'md5': "auto-resolve",
61
+ 'three-mesh-bvh': "auto-resolve",
62
+ 'postprocessing': "auto-resolve",
63
+ '@dimforge/rapier3d-compat': "auto-resolve",
41
64
  }
42
65
 
43
66
  /**
@@ -67,6 +90,7 @@ export const needleViteAlias = (command, config, userSettings) => {
67
90
  }
68
91
 
69
92
 
93
+ /** @type {import("vite").Plugin} */
70
94
  const aliasPlugin = {
71
95
  name: "needle-alias",
72
96
  config(config) {
@@ -75,11 +99,9 @@ export const needleViteAlias = (command, config, userSettings) => {
75
99
  if (!config.resolve.alias) config.resolve.alias = {};
76
100
  const aliasDict = config.resolve.alias;
77
101
 
78
- addThreeJSResolvers(aliasDict);
79
-
80
102
  for (const name in packages_to_resolve) {
81
103
  if (!aliasDict[name]) {
82
- addPathResolver(name, aliasDict, packages_to_resolve[name]);
104
+ addPathResolver(name, aliasDict, packages_to_resolve[name], debug ?? false);
83
105
  }
84
106
  }
85
107
 
@@ -127,43 +149,36 @@ export const needleViteAlias = (command, config, userSettings) => {
127
149
  if (debug) return [debuggingPlugin, aliasPlugin];
128
150
  return [aliasPlugin];
129
151
 
130
- function addThreeJSResolvers(aliasDict) {
131
- // We are currently overriding "three" resolution to ensure that all dependencies resolve to the same three.js version.
132
- // This is hacky, but the alternative is potentially having conflicting three.js versions since some packages are
133
- // stubborn with their peer dependencies or just slow (slower as we) with updating.
134
- // NOT adding this allows node.js to correctly resolve `exports` specified in three.js package.json;
135
- // since we're overriding resolution here we need to manually resolve the subset of exports that we use.
136
- aliasDict['three/addons'] = (res, packageName, index, path) => {
137
- return "three/examples/jsm";
138
- };
139
- aliasDict['three/nodes'] = (res, packageName, index, path) => {
140
- return "three/examples/jsm/nodes/Nodes.js";
141
- };
142
- aliasDict['three'] = (res, packageName, index, _path) => {
143
- return path.resolve(projectDir, 'node_modules', 'three');
144
- };
145
- }
146
-
147
- function addPathResolver(name, aliasDict, cb) {
152
+ /**
153
+ * Adds a path resolver to the alias dictionary.
154
+ * @param {string} name - The name of the package to resolve.
155
+ * @param {import("vite").AliasOptions} aliasDict - The alias dictionary to add the resolver to.
156
+ * @param {PackageResolveValue | null} value - A callback function to override the default resolution behavior.
157
+ * @param {boolean} debug - Whether to log debug information.
158
+ * @returns {void}
159
+ */
160
+ function addPathResolver(name, aliasDict, value, debug) {
148
161
  // If a package at the node_modules path exist we resolve the request there
149
162
  // introduced in 89a50718c38940abb99ee16c5e029065e41d7d65
150
- const fullpath = path.resolve(projectDir, 'node_modules', name);
151
- if (typeof cb !== "function") cb = null;
152
- const isDevEnvironment = process.env.NODE_ENV === "development";
163
+ const callback = typeof value === "function" ? value : null;
164
+
165
+ let fullpath = path.resolve(projectDir, 'node_modules', name);
166
+ if (!existsSync(fullpath)) {
167
+ fullpath = path.resolve(projectDir, 'node_modules', "@needle-tools/engine", "node_modules", name);
168
+ }
153
169
 
154
170
  if (existsSync(fullpath)) {
155
171
  aliasDict[name] = (packageName, index, path) => {
156
- if (cb !== null && !isDevEnvironment) {
157
- const overrideResult = cb(fullpath, packageName, index, path);
158
- if (overrideResult !== undefined)
172
+ if (callback !== null) {
173
+ const overrideResult = callback(fullpath, packageName, index, path);
174
+ if (typeof overrideResult === "string")
159
175
  if (existsSync(overrideResult)) {
160
- console.warn(`[needle-alias] \"${path}\" was requested and resolved to \"${overrideResult}\"`);
176
+ if (debug) console.warn(`[needle-alias] \"${path}\" was requested and resolved to \"${overrideResult}\"`);
161
177
  return overrideResult;
162
178
  }
163
179
  }
164
180
 
165
- if (path != packageName) {
166
- // TODO: we might want to check if the package.json exports contains the path to see if it's valid
181
+ if (debug && path != packageName) {
167
182
  console.warn(`[needle-alias] \"${path}\" was requested and resolved to \"${fullpath}\"`);
168
183
  }
169
184
 
@@ -6,7 +6,7 @@ import fs from 'fs';
6
6
  */
7
7
  export const needleImportsLogger = (command, config, userSettings) => {
8
8
 
9
- if (!userSettings.logModuleImportChains) return;
9
+ if (!userSettings.debugImportChains) return;
10
10
 
11
11
  const graph = {
12
12
  allNodes: new Map(),
@@ -66,6 +66,8 @@ export { needleBuildInfo } from "./buildinfo.js";
66
66
  import { needleServer } from "./server.js";
67
67
  import { needleNPM } from "./npm.js";
68
68
  import { needleTransformCode } from "./transform.js";
69
+ import { needleMaterialXLoader } from "./materialx.js";
70
+ import { needleLogger } from "./logger.js";
69
71
  export { needleServer } from "./server.js";
70
72
 
71
73
 
@@ -110,6 +112,7 @@ export const needlePlugins = async (command, config = undefined, userSettings =
110
112
  userSettings = { ...defaultUserSettings, ...userSettings };
111
113
 
112
114
  const array = [
115
+ needleLogger(command, config, userSettings),
113
116
  needleDefines(command, config, userSettings),
114
117
  needleLicense(command, config, userSettings),
115
118
  needleViteAlias(command, config, userSettings),
@@ -133,6 +136,7 @@ export const needlePlugins = async (command, config = undefined, userSettings =
133
136
  needlePWA(command, config, userSettings),
134
137
  needleServer(command, config, userSettings),
135
138
  needleNPM(command, config, userSettings),
139
+ needleMaterialXLoader(command, config, userSettings),
136
140
  ];
137
141
 
138
142
  const asap = await needleAsap(command, config, userSettings);