@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.
Files changed (150) hide show
  1. package/components.needle.json +1 -1
  2. package/dist/{gltf-progressive-CTlvpS3A.js → gltf-progressive-Bm_6aEi4.js} +1 -1
  3. package/dist/{gltf-progressive-CMwJPwEt.umd.cjs → gltf-progressive-BttGBXw6.umd.cjs} +1 -1
  4. package/dist/{gltf-progressive-DYL3SLVb.min.js → gltf-progressive-T5WKTux5.min.js} +1 -1
  5. package/dist/materialx-CJyQZtjt.min.js +90 -0
  6. package/dist/materialx-DMs1E08Z.js +4636 -0
  7. package/dist/materialx-DaKKOoVk.umd.cjs +90 -0
  8. package/dist/{needle-engine.bundle-DsTdfmeb.min.js → needle-engine.bundle-CBq_OMnI.min.js} +122 -124
  9. package/dist/{needle-engine.bundle-DB4kLWO_.js → needle-engine.bundle-DGyiwNWR.js} +3226 -3232
  10. package/dist/{needle-engine.bundle-C1BFRZDF.umd.cjs → needle-engine.bundle-JN3eiiYc.umd.cjs} +113 -115
  11. package/dist/needle-engine.d.ts +52 -33
  12. package/dist/needle-engine.js +288 -287
  13. package/dist/needle-engine.min.js +1 -1
  14. package/dist/needle-engine.umd.cjs +1 -1
  15. package/dist/{postprocessing-BN-f4viE.min.js → postprocessing-06AXuvdv.min.js} +1 -1
  16. package/dist/{postprocessing-De9ZpJrk.js → postprocessing-CI2x8Cln.js} +1 -1
  17. package/dist/{postprocessing-DYmYOVm4.umd.cjs → postprocessing-CPDcA21P.umd.cjs} +1 -1
  18. package/dist/{three-examples-BHqRVpO_.umd.cjs → three-examples-BMmNgNCN.umd.cjs} +12 -12
  19. package/dist/{three-examples-C0ZCCA_K.js → three-examples-CMYCd5nH.js} +192 -182
  20. package/dist/{three-examples-DmTY8tGr.min.js → three-examples-CQl1fFZp.min.js} +14 -14
  21. package/lib/engine/api.d.ts +2 -0
  22. package/lib/engine/api.js +2 -0
  23. package/lib/engine/api.js.map +1 -1
  24. package/lib/engine/debug/debug.js +1 -1
  25. package/lib/engine/debug/debug.js.map +1 -1
  26. package/lib/engine/debug/debug_spatial_console.js +1 -1
  27. package/lib/engine/debug/debug_spatial_console.js.map +1 -1
  28. package/lib/engine/engine_accessibility.d.ts +1 -1
  29. package/lib/engine/engine_accessibility.js +1 -1
  30. package/lib/engine/engine_accessibility.js.map +1 -1
  31. package/lib/engine/engine_context.d.ts +1 -1
  32. package/lib/engine/engine_context.js +2 -2
  33. package/lib/engine/engine_context.js.map +1 -1
  34. package/lib/engine/engine_create_objects.js +1 -1
  35. package/lib/engine/engine_create_objects.js.map +1 -1
  36. package/lib/engine/engine_gizmos.js +1 -1
  37. package/lib/engine/engine_gizmos.js.map +1 -1
  38. package/lib/engine/engine_license.js +2 -7
  39. package/lib/engine/engine_license.js.map +1 -1
  40. package/lib/engine/engine_test_utils.d.ts +39 -0
  41. package/lib/engine/engine_test_utils.js +84 -0
  42. package/lib/engine/engine_test_utils.js.map +1 -0
  43. package/lib/engine/engine_utils.js +2 -2
  44. package/lib/engine/engine_utils.js.map +1 -1
  45. package/lib/engine/export/gltf/index.js +1 -1
  46. package/lib/engine/export/gltf/index.js.map +1 -1
  47. package/lib/engine/webcomponents/logo-element.d.ts +3 -6
  48. package/lib/engine/webcomponents/logo-element.js +0 -18
  49. package/lib/engine/webcomponents/logo-element.js.map +1 -1
  50. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js +2 -2
  51. package/lib/engine/webcomponents/needle menu/needle-menu-spatial.js.map +1 -1
  52. package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +7 -10
  53. package/lib/engine/webcomponents/needle menu/needle-menu.js +4 -14
  54. package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
  55. package/lib/engine/webcomponents/needle-engine.ar-overlay.js +1 -10
  56. package/lib/engine/webcomponents/needle-engine.ar-overlay.js.map +1 -1
  57. package/lib/engine/webcomponents/needle-engine.d.ts +0 -3
  58. package/lib/engine/webcomponents/needle-engine.js +0 -10
  59. package/lib/engine/webcomponents/needle-engine.js.map +1 -1
  60. package/lib/engine-components/Component.js +1 -0
  61. package/lib/engine-components/Component.js.map +1 -1
  62. package/lib/engine-components/ReflectionProbe.d.ts +2 -24
  63. package/lib/engine-components/ReflectionProbe.js +2 -28
  64. package/lib/engine-components/ReflectionProbe.js.map +1 -1
  65. package/lib/engine-components/Skybox.js +2 -4
  66. package/lib/engine-components/Skybox.js.map +1 -1
  67. package/lib/engine-components/export/gltf/GltfExport.js +1 -1
  68. package/lib/engine-components/export/gltf/GltfExport.js.map +1 -1
  69. package/lib/engine-components/export/usdz/ThreeUSDZExporter.js +2 -2
  70. package/lib/engine-components/export/usdz/USDZExporter.js +1 -1
  71. package/lib/engine-components/export/usdz/USDZExporter.js.map +1 -1
  72. package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js +2 -2
  73. package/lib/engine-components/export/usdz/extensions/behavior/PhysicsExtension.js.map +1 -1
  74. package/lib/engine-components/postprocessing/Effects/Tonemapping.utils.d.ts +1 -1
  75. package/lib/include/three/EXT_mesh_gpu_instancing_exporter.js.map +1 -0
  76. package/package.json +14 -18
  77. package/plugins/common/buildinfo.js +10 -46
  78. package/plugins/common/files.js +1 -2
  79. package/plugins/common/license.js +69 -144
  80. package/plugins/common/logger.js +11 -172
  81. package/plugins/common/worker.js +4 -5
  82. package/plugins/types/userconfig.d.ts +2 -40
  83. package/plugins/vite/alias.js +5 -6
  84. package/plugins/vite/asap.js +5 -6
  85. package/plugins/vite/build-pipeline.js +41 -224
  86. package/plugins/vite/buildinfo.js +6 -66
  87. package/plugins/vite/copyfiles.js +12 -41
  88. package/plugins/vite/custom-element-data.js +16 -26
  89. package/plugins/vite/defines.js +5 -8
  90. package/plugins/vite/dependencies.js +10 -16
  91. package/plugins/vite/dependency-watcher.js +7 -35
  92. package/plugins/vite/drop-client.js +5 -7
  93. package/plugins/vite/drop.js +14 -16
  94. package/plugins/vite/editor-connection.js +16 -18
  95. package/plugins/vite/imports-logger.js +2 -12
  96. package/plugins/vite/index.js +3 -8
  97. package/plugins/vite/local-files.js +441 -2
  98. package/plugins/vite/logger.client.js +35 -45
  99. package/plugins/vite/logger.js +3 -6
  100. package/plugins/vite/meta.js +4 -18
  101. package/plugins/vite/needle-app.js +3 -4
  102. package/plugins/vite/peer.js +1 -2
  103. package/plugins/vite/pwa.js +17 -33
  104. package/plugins/vite/reload.js +2 -24
  105. package/src/engine/api.ts +3 -0
  106. package/src/engine/debug/debug.ts +1 -1
  107. package/src/engine/debug/debug_spatial_console.ts +1 -5
  108. package/src/engine/engine_accessibility.ts +1 -2
  109. package/src/engine/engine_context.ts +2 -2
  110. package/src/engine/engine_create_objects.ts +1 -1
  111. package/src/engine/engine_gizmos.ts +5 -9
  112. package/src/engine/engine_license.ts +2 -7
  113. package/src/engine/engine_test_utils.ts +109 -0
  114. package/src/engine/engine_utils.ts +2 -2
  115. package/src/engine/export/gltf/index.ts +1 -1
  116. package/src/engine/webcomponents/logo-element.ts +3 -20
  117. package/src/engine/webcomponents/needle menu/needle-menu-spatial.ts +2 -6
  118. package/src/engine/webcomponents/needle menu/needle-menu.ts +11 -23
  119. package/src/engine/webcomponents/needle-engine.ar-overlay.ts +2 -13
  120. package/src/engine/webcomponents/needle-engine.ts +1 -13
  121. package/src/engine-components/Component.ts +2 -1
  122. package/src/engine-components/ReflectionProbe.ts +9 -33
  123. package/src/engine-components/Skybox.ts +2 -4
  124. package/src/engine-components/export/gltf/GltfExport.ts +1 -1
  125. package/src/engine-components/export/usdz/ThreeUSDZExporter.ts +2 -2
  126. package/src/engine-components/export/usdz/USDZExporter.ts +1 -1
  127. package/src/engine-components/export/usdz/extensions/behavior/PhysicsExtension.ts +2 -2
  128. package/src/include/draco/draco_decoder.js +34 -0
  129. package/src/include/draco/draco_decoder.wasm +0 -0
  130. package/src/include/draco/draco_wasm_wrapper.js +117 -0
  131. package/src/include/ktx2/basis_transcoder.js +19 -0
  132. package/src/include/ktx2/basis_transcoder.wasm +0 -0
  133. package/src/include/needle/arial-msdf.json +1472 -0
  134. package/src/include/needle/arial.png +0 -0
  135. package/src/include/needle/poweredbyneedle.webp +0 -0
  136. package/dist/materialx-4jJLLe9Q.js +0 -4174
  137. package/dist/materialx-Bt9FHwco.min.js +0 -158
  138. package/dist/materialx-NDD0y4JY.umd.cjs +0 -158
  139. package/lib/engine/export/gltf/EXT_mesh_gpu_instancing_exporter.js.map +0 -1
  140. package/plugins/common/needle-engine-skill.md +0 -175
  141. package/plugins/vite/ai.js +0 -71
  142. package/plugins/vite/local-files-analysis.js +0 -789
  143. package/plugins/vite/local-files-core.js +0 -992
  144. package/plugins/vite/local-files-internals.js +0 -28
  145. package/plugins/vite/local-files-types.d.ts +0 -111
  146. package/plugins/vite/local-files-utils.js +0 -359
  147. package/plugins/vite/logging.js +0 -129
  148. /package/lib/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.d.ts +0 -0
  149. /package/lib/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.js +0 -0
  150. /package/src/{engine/export/gltf → include/three}/EXT_mesh_gpu_instancing_exporter.js +0 -0
@@ -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
- const buildOutputState = {
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<unknown>} */
59
+ /** @type {Set<string>} */
213
60
  const isCapturingLogMessage = new Set();
214
61
 
215
- /** @type {Array<{ process: ProcessType, key: string, log:unknown, timestamp:number, connectionId: string | null }>} */
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 {unknown} log
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 {unknown} log
266
- * @param {Set<unknown>} [seen]
112
+ * @param {any} log
113
+ * @param {Set<any>} [seen]
267
114
  */
268
- function stringifyLog(log, seen = /** @type {Set<unknown>} */ (new Set()), depth = 0) {
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
- const logArr = /** @type {ArrayLike<unknown>} */ (/** @type {unknown} */ (log));
311
- seen.add(logArr);
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 logObj = /** @type {Record<string, unknown>} */ (log);
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 = logObj[key];
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);
@@ -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
- needleLog("rollup", `Rewrite worker import in ${chunk.fileName}`, "log", { leadingNewline: true, dimBody: false });
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
- needleLog("rollup", "Did rewrite worker output to: " + output, "log", { leadingNewline: true });
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
- needleLog("rollup", `Worker import in ${chunk.fileName} was not rewritten: ${str}`, "warn", { leadingNewline: true, dimBody: false });
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
- needleLog("rollup", `Rewrite worker 'self.location' to 'import.meta.url' in ${filename}`, "log", { leadingNewline: true, dimBody: false });
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, external CDN URLs are downloaded at build time and bundled locally.
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 | "auto" | {
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
  /**
@@ -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
- needleLog("needle-alias", msg.join(" "));
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: ' + JSON.stringify(testResults));
135
+ console.log('[needle-alias] Aliases: ', testResults);
137
136
  }
138
137
  },
139
138
  }
@@ -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
- needleLog("needle:asap", "Could not load needle logo svg: " + err.message, "warn", { dimBody: false });
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
- needleLog("needle:asap", "Changed main.ts and replaced needle engine import with async import", "log", { dimBody: false });
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
- needleLog("needle:asap", "Error generating script preload links: " + err.message, "error", { dimBody: false });
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
- needleLog("needle:asap", `Could not insert head preload link: file not found at \"${filepath}\"`, "warn", { dimBody: false });
204
+ console.warn(`[needle:asap] Could not insert head preload link: file not found at \"${filepath}\"`);
206
205
  continue;
207
206
  }
208
207
  }
209
- needleLog("needle:asap", `Insert head glTF preload link: ${value}`);
208
+ console.log(`[needle:asap] Insert head glTF preload link: ${value}`);
210
209
  insertPreloadLink(tags, value, "model/gltf+json");
211
210
  }
212
211
  }