@needle-tools/engine 4.16.0 → 4.16.1-next.98e87e6
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 +3 -0
- package/README.md +92 -46
- package/SKILL.md +25 -33
- package/dist/{needle-engine.bundle-CXVjO2uF.umd.cjs → needle-engine.bundle-B2rk-2Z5.umd.cjs} +121 -121
- package/dist/{needle-engine.bundle-Cx8Qrpbp.js → needle-engine.bundle-DdPHeBrV.js} +5386 -5356
- package/dist/{needle-engine.bundle-mHgaFC2W.min.js → needle-engine.bundle-_tTBG92u.min.js} +131 -131
- package/dist/needle-engine.d.ts +16 -287
- package/dist/needle-engine.js +2 -2
- package/dist/needle-engine.min.js +1 -1
- package/dist/needle-engine.umd.cjs +1 -1
- package/lib/engine/engine_context.js +2 -0
- package/lib/engine/engine_context.js.map +1 -1
- package/lib/engine/webcomponents/logo-element.d.ts +6 -3
- package/lib/engine/webcomponents/logo-element.js +18 -0
- package/lib/engine/webcomponents/logo-element.js.map +1 -1
- package/lib/engine/webcomponents/needle menu/needle-menu.d.ts +10 -7
- package/lib/engine/webcomponents/needle menu/needle-menu.js +13 -2
- package/lib/engine/webcomponents/needle menu/needle-menu.js.map +1 -1
- package/lib/engine/webcomponents/needle-engine.d.ts +4 -1
- package/lib/engine/webcomponents/needle-engine.js +22 -15
- package/lib/engine/webcomponents/needle-engine.js.map +1 -1
- package/lib/engine/xr/NeedleXRSession.js +15 -3
- package/lib/engine/xr/NeedleXRSession.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +10 -3
- package/lib/engine-components/ReflectionProbe.js +34 -10
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/package.json +9 -9
- package/plugins/next/next.d.ts +8 -0
- package/plugins/next/next.js +7 -6
- package/plugins/vite/ai.d.ts +17 -0
- package/plugins/vite/ai.js +2 -2
- package/plugins/vite/alias.d.ts +8 -0
- package/plugins/vite/alias.js +5 -2
- package/plugins/vite/asap.d.ts +7 -0
- package/plugins/vite/asap.js +3 -3
- package/plugins/vite/build-pipeline.d.ts +15 -0
- package/plugins/vite/build-pipeline.js +5 -6
- package/plugins/vite/build.d.ts +7 -0
- package/plugins/vite/build.js +5 -2
- package/plugins/vite/buildinfo.d.ts +7 -0
- package/plugins/vite/buildinfo.js +4 -2
- package/plugins/vite/config.d.ts +13 -0
- package/plugins/vite/config.js +1 -1
- package/plugins/vite/copyfiles.d.ts +7 -0
- package/plugins/vite/copyfiles.js +4 -2
- package/plugins/vite/custom-element-data.d.ts +25 -0
- package/plugins/vite/custom-element-data.js +2 -1
- package/plugins/vite/defines.d.ts +10 -0
- package/plugins/vite/defines.js +4 -3
- package/plugins/vite/dependencies.d.ts +21 -0
- package/plugins/vite/dependencies.js +3 -1
- package/plugins/vite/dependency-watcher.d.ts +11 -0
- package/plugins/vite/dependency-watcher.js +2 -1
- package/plugins/vite/drop-client.d.ts +1 -0
- package/plugins/vite/drop.d.ts +7 -0
- package/plugins/vite/drop.js +4 -4
- package/plugins/vite/editor-connection.d.ts +8 -0
- package/plugins/vite/editor-connection.js +6 -2
- package/plugins/vite/facebook-instant-games.d.ts +7 -0
- package/plugins/vite/facebook-instant-games.js +4 -2
- package/plugins/vite/gzip.d.ts +6 -0
- package/plugins/vite/gzip.js +5 -0
- package/plugins/vite/imports-logger.d.ts +13 -0
- package/plugins/vite/imports-logger.js +2 -1
- package/plugins/vite/index.d.ts +54 -0
- package/plugins/vite/index.js +16 -15
- package/plugins/vite/license.d.ts +7 -0
- package/plugins/vite/license.js +6 -6
- package/plugins/vite/local-files-analysis.d.ts +95 -0
- package/plugins/vite/local-files-analysis.js +2 -1
- package/plugins/vite/local-files-core.d.ts +51 -0
- package/plugins/vite/local-files-core.js +2 -2
- package/plugins/vite/local-files-internals.d.ts +3 -0
- package/plugins/vite/local-files-utils.d.ts +77 -0
- package/plugins/vite/local-files.d.ts +2 -0
- package/plugins/vite/logger.d.ts +8 -0
- package/plugins/vite/logger.js +1 -1
- package/plugins/vite/logging.d.ts +31 -0
- package/plugins/vite/meta.d.ts +7 -0
- package/plugins/vite/meta.js +4 -3
- package/plugins/vite/needle-app.d.ts +7 -0
- package/plugins/vite/needle-app.js +1 -1
- package/plugins/vite/npm.d.ts +4 -0
- package/plugins/vite/npm.js +1 -1
- package/plugins/vite/peer.d.ts +7 -0
- package/plugins/vite/peer.js +3 -1
- package/plugins/vite/poster-client.d.ts +1 -0
- package/plugins/vite/poster.d.ts +8 -0
- package/plugins/vite/poster.js +5 -2
- package/plugins/vite/pwa.d.ts +7 -0
- package/plugins/vite/pwa.js +4 -4
- package/plugins/vite/reload-client.d.ts +1 -0
- package/plugins/vite/reload.d.ts +7 -0
- package/plugins/vite/reload.js +7 -6
- package/plugins/vite/server.d.ts +7 -0
- package/plugins/vite/server.js +5 -5
- package/plugins/vite/transform-codegen.d.ts +8 -0
- package/plugins/vite/transform-codegen.js +6 -4
- package/plugins/vite/transform.d.ts +5 -0
- package/plugins/vite/transform.js +1 -1
- package/plugins/vite/vite-4.4-hack.d.ts +8 -0
- package/plugins/vite/vite-4.4-hack.js +1 -1
- package/src/engine/engine_context.ts +1 -0
- package/src/engine/webcomponents/logo-element.ts +20 -3
- package/src/engine/webcomponents/needle menu/needle-menu.ts +22 -9
- package/src/engine/webcomponents/needle-engine.ts +42 -35
- package/src/engine/xr/NeedleXRSession.ts +16 -3
- package/src/engine-components/ReflectionProbe.ts +38 -11
- package/plugins/types/next.d.ts +0 -3
- package/plugins/types/vite.d.ts +0 -14
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {unknown} _config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin | null}
|
|
6
|
+
*/
|
|
7
|
+
export function needleLocalFilesSceneAnalysis(command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
8
|
+
/**
|
|
9
|
+
* @param {string} projectDir
|
|
10
|
+
* @returns {AutoPolicy | null}
|
|
11
|
+
*/
|
|
12
|
+
export function getLocalFilesAutoPolicy(projectDir: string): AutoPolicy | null;
|
|
13
|
+
/**
|
|
14
|
+
* @param {import('../types').userSettings | undefined | null} userSettings
|
|
15
|
+
* @returns {boolean}
|
|
16
|
+
*/
|
|
17
|
+
export function makeFilesLocalIsEnabled(userSettings: import("../types").userSettings | undefined | null): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* @param {import('../types').userSettings | undefined | null} userSettings
|
|
20
|
+
* @returns {LocalizationOptions}
|
|
21
|
+
*/
|
|
22
|
+
export function resolveOptions(userSettings: import("../types").userSettings | undefined | null): LocalizationOptions;
|
|
23
|
+
/**
|
|
24
|
+
* @param {string | string[] | undefined} features
|
|
25
|
+
* @returns {boolean}
|
|
26
|
+
*/
|
|
27
|
+
export function hasAutoFeatureSelection(features: string | string[] | undefined): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* @param {LocalizationOptions} options
|
|
30
|
+
* @param {string} projectDir
|
|
31
|
+
* @returns {AutoPolicy | null}
|
|
32
|
+
*/
|
|
33
|
+
export function buildAutoPolicy(options: LocalizationOptions, projectDir: string): AutoPolicy | null;
|
|
34
|
+
/**
|
|
35
|
+
* @param {string} projectDir
|
|
36
|
+
* @param {LocalizationOptions} options
|
|
37
|
+
* @param {SceneAnalysisReport | null} [cachedAnalysis]
|
|
38
|
+
* @returns {AutoPolicy}
|
|
39
|
+
*/
|
|
40
|
+
export function detectAutoPolicy(projectDir: string, options: LocalizationOptions, cachedAnalysis?: SceneAnalysisReport | null): AutoPolicy;
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} projectDir
|
|
43
|
+
* @returns {SceneAnalysisReport}
|
|
44
|
+
*/
|
|
45
|
+
export function analyzeProjectGlbs(projectDir: string): SceneAnalysisReport;
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} projectDir
|
|
48
|
+
* @returns {string[]}
|
|
49
|
+
*/
|
|
50
|
+
export function collectAssetGlbs(projectDir: string): string[];
|
|
51
|
+
/**
|
|
52
|
+
* @param {string} filePath
|
|
53
|
+
* @returns {Record<string, unknown>}
|
|
54
|
+
*/
|
|
55
|
+
export function readGlbJsonChunk(filePath: string): Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* @param {unknown} json
|
|
58
|
+
* @returns {string[]}
|
|
59
|
+
*/
|
|
60
|
+
export function collectNeedleComponentExtensionBlobs(json: unknown): string[];
|
|
61
|
+
/**
|
|
62
|
+
* @param {string} indexHtml
|
|
63
|
+
* @returns {Set<string>}
|
|
64
|
+
*/
|
|
65
|
+
export function collectIndexHtmlSkyboxUrls(indexHtml: string): Set<string>;
|
|
66
|
+
/**
|
|
67
|
+
* @param {string | string[] | undefined | null} skyboxOption
|
|
68
|
+
* @param {Set<string>} indexSkyboxUrls
|
|
69
|
+
* @returns {Set<string> | null}
|
|
70
|
+
*/
|
|
71
|
+
export function resolveSkyboxSelectionUrls(skyboxOption: string | string[] | undefined | null, indexSkyboxUrls: Set<string>): Set<string> | null;
|
|
72
|
+
/**
|
|
73
|
+
* @param {string | null | undefined} value
|
|
74
|
+
* @returns {string | null}
|
|
75
|
+
*/
|
|
76
|
+
export function resolveSkyboxValueToUrl(value: string | null | undefined): string | null;
|
|
77
|
+
/**
|
|
78
|
+
* @param {string | undefined} mode
|
|
79
|
+
* @returns {string[]}
|
|
80
|
+
*/
|
|
81
|
+
export function getWebXRProfilesForMode(mode: string | undefined): string[];
|
|
82
|
+
/**
|
|
83
|
+
* @param {string} url
|
|
84
|
+
* @param {UrlHandler} handler
|
|
85
|
+
* @param {LocalizationContext} context
|
|
86
|
+
* @returns {boolean}
|
|
87
|
+
*/
|
|
88
|
+
export function shouldHandleUrlInAutoMode(url: string, handler: UrlHandler, context: LocalizationContext): boolean;
|
|
89
|
+
export const SKYBOX_MAGIC_KEYWORDS: string[];
|
|
90
|
+
export type LocalizationOptions = import("./local-files-types.js").LocalizationOptions;
|
|
91
|
+
export type AutoPolicy = import("./local-files-types.js").AutoPolicy;
|
|
92
|
+
export type SceneAnalysisReport = import("./local-files-types.js").SceneAnalysisReport;
|
|
93
|
+
export type SceneFile = import("./local-files-types.js").SceneFile;
|
|
94
|
+
export type UrlHandler = import("./local-files-types.js").UrlHandler;
|
|
95
|
+
export type LocalizationContext = import("./local-files-types.js").LocalizationContext;
|
|
@@ -19,9 +19,10 @@ const HLS_CDN_SEGMENT = "/npm/hls.js@";
|
|
|
19
19
|
const analysisByProject = new Map();
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
* @param {
|
|
22
|
+
* @param {"build" | "serve"} command
|
|
23
23
|
* @param {unknown} _config
|
|
24
24
|
* @param {import('../types').userSettings} userSettings
|
|
25
|
+
* @returns {import('vite').Plugin | null}
|
|
25
26
|
*/
|
|
26
27
|
export function needleLocalFilesSceneAnalysis(command, _config, userSettings) {
|
|
27
28
|
if (!makeFilesLocalIsEnabled(userSettings)) return null;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {unknown} _config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin | null}
|
|
6
|
+
*/
|
|
7
|
+
export function needleMakeFilesLocal(command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
8
|
+
/**
|
|
9
|
+
* @param {LocalizationOptions} options
|
|
10
|
+
* @param {AutoPolicy | null} autoPolicy
|
|
11
|
+
* @returns {UrlHandler[]}
|
|
12
|
+
*/
|
|
13
|
+
export function getActiveHandlers(options: LocalizationOptions, autoPolicy: AutoPolicy | null): UrlHandler[];
|
|
14
|
+
/**
|
|
15
|
+
* @param {string} src
|
|
16
|
+
* @param {string} basePath
|
|
17
|
+
* @param {string} currentDir
|
|
18
|
+
* @param {LocalizationContext} context
|
|
19
|
+
* @param {UrlHandler[]} [handlers]
|
|
20
|
+
* @returns {Promise<string>}
|
|
21
|
+
*/
|
|
22
|
+
export function makeLocal(src: string, basePath: string, currentDir: string, context: LocalizationContext, handlers?: UrlHandler[]): Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} html
|
|
25
|
+
* @param {string} basePath
|
|
26
|
+
* @param {LocalizationContext} context
|
|
27
|
+
* @param {UrlHandler[]} [handlers]
|
|
28
|
+
* @returns {Promise<string>}
|
|
29
|
+
*/
|
|
30
|
+
export function makeLocalHtml(html: string, basePath: string, context: LocalizationContext, handlers?: UrlHandler[]): Promise<string>;
|
|
31
|
+
/**
|
|
32
|
+
* @param {string} basePath
|
|
33
|
+
* @param {string} feature
|
|
34
|
+
* @returns {string}
|
|
35
|
+
*/
|
|
36
|
+
export function getFeatureBasePath(basePath: string, feature: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* @param {string} baseUrl
|
|
39
|
+
* @param {string} basePath
|
|
40
|
+
* @param {string} currentDir
|
|
41
|
+
* @param {LocalizationContext} context
|
|
42
|
+
* @returns {Promise<string>}
|
|
43
|
+
*/
|
|
44
|
+
export function handleWebXRProfiles(baseUrl: string, basePath: string, currentDir: string, context: LocalizationContext): Promise<string>;
|
|
45
|
+
export { makeFilesLocalIsEnabled };
|
|
46
|
+
export type LocalizationContext = import("./local-files-types.js").LocalizationContext;
|
|
47
|
+
export type LocalizationOptions = import("./local-files-types.js").LocalizationOptions;
|
|
48
|
+
export type LocalizationStats = import("./local-files-types.js").LocalizationStats;
|
|
49
|
+
export type AutoPolicy = import("./local-files-types.js").AutoPolicy;
|
|
50
|
+
export type UrlHandler = import("./local-files-types.js").UrlHandler;
|
|
51
|
+
import { makeFilesLocalIsEnabled } from './local-files-analysis.js';
|
|
@@ -213,7 +213,7 @@ function recordLocalizedAsset(stats, url, sizeBytes, mimeType) {
|
|
|
213
213
|
* @param {import('../types').userSettings} userSettings
|
|
214
214
|
* @returns {import('vite').Plugin | null}
|
|
215
215
|
*/
|
|
216
|
-
export
|
|
216
|
+
export function needleMakeFilesLocal(command, _config, userSettings) {
|
|
217
217
|
if (!makeFilesLocalIsEnabled(userSettings)) {
|
|
218
218
|
return null;
|
|
219
219
|
}
|
|
@@ -373,7 +373,7 @@ export const needleMakeFilesLocal = (command, _config, userSettings) => {
|
|
|
373
373
|
}
|
|
374
374
|
});
|
|
375
375
|
return plugin;
|
|
376
|
-
}
|
|
376
|
+
}
|
|
377
377
|
|
|
378
378
|
/**
|
|
379
379
|
* @param {LocalizationOptions} options
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { getActiveHandlers, getFeatureBasePath, handleWebXRProfiles, makeLocal, makeLocalHtml } from "./local-files-core.js";
|
|
2
|
+
export { analyzeProjectGlbs, buildAutoPolicy, collectAssetGlbs, collectIndexHtmlSkyboxUrls, collectNeedleComponentExtensionBlobs, detectAutoPolicy, getWebXRProfilesForMode, hasAutoFeatureSelection, readGlbJsonChunk, resolveSkyboxSelectionUrls, resolveSkyboxValueToUrl, shouldHandleUrlInAutoMode } from "./local-files-analysis.js";
|
|
3
|
+
export { fixDracoRangeQueryProbe, fixRelativeNewURL, getRelativeToBasePath } from "./local-files-utils.js";
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function finishMakeLocalProgress(): void;
|
|
2
|
+
/**
|
|
3
|
+
* @param {string} src
|
|
4
|
+
* @param {string} search
|
|
5
|
+
* @param {string} replacement
|
|
6
|
+
* @returns {string}
|
|
7
|
+
*/
|
|
8
|
+
export function replaceAll(src: string, search: string, replacement: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* @param {string} path
|
|
11
|
+
* @param {string} basePath
|
|
12
|
+
* @returns {string}
|
|
13
|
+
*/
|
|
14
|
+
export function getRelativeToBasePath(path: string, basePath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* @param {string} path
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeWebPath(path: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* @param {string} path
|
|
22
|
+
* @returns {string}
|
|
23
|
+
*/
|
|
24
|
+
export function ensureTrailingSlash(path: string): string;
|
|
25
|
+
/**
|
|
26
|
+
* @param {string} src
|
|
27
|
+
* @returns {string}
|
|
28
|
+
*/
|
|
29
|
+
export function fixRelativeNewURL(src: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} src
|
|
32
|
+
* @returns {string}
|
|
33
|
+
*/
|
|
34
|
+
export function fixDracoRangeQueryProbe(src: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* @param {string} path
|
|
37
|
+
* @param {string|Buffer} content
|
|
38
|
+
* @returns {string}
|
|
39
|
+
*/
|
|
40
|
+
export function getValidFilename(path: string, content: string | Buffer): string;
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} url
|
|
43
|
+
* @returns {Promise<string>}
|
|
44
|
+
*/
|
|
45
|
+
export function downloadText(url: string): Promise<string>;
|
|
46
|
+
/**
|
|
47
|
+
* @param {string} url
|
|
48
|
+
* @returns {Promise<Buffer>}
|
|
49
|
+
*/
|
|
50
|
+
export function downloadBinary(url: string): Promise<Buffer>;
|
|
51
|
+
/**
|
|
52
|
+
* @param {LocalizationContext} context
|
|
53
|
+
* @param {string} url
|
|
54
|
+
* @param {unknown} err
|
|
55
|
+
*/
|
|
56
|
+
export function recordFailedDownload(context: LocalizationContext, url: string, err: unknown): void;
|
|
57
|
+
/**
|
|
58
|
+
* @param {string} url
|
|
59
|
+
* @returns {string}
|
|
60
|
+
*/
|
|
61
|
+
export function getShortUrlName(url: string): string;
|
|
62
|
+
export class Cache {
|
|
63
|
+
/** @type {Map<string, Buffer|string>} */
|
|
64
|
+
__cache: Map<string, Buffer | string>;
|
|
65
|
+
/**
|
|
66
|
+
* @param {string} key
|
|
67
|
+
* @param {Buffer|string} value
|
|
68
|
+
*/
|
|
69
|
+
addToCache(key: string, value: Buffer | string): void;
|
|
70
|
+
/**
|
|
71
|
+
* @param {string} key
|
|
72
|
+
* @returns {Buffer|string|null}
|
|
73
|
+
*/
|
|
74
|
+
getFromCache(key: string): Buffer | string | null;
|
|
75
|
+
get map(): Map<string, string | Buffer<ArrayBufferLike>>;
|
|
76
|
+
}
|
|
77
|
+
export type LocalizationContext = import("./local-files-types.js").LocalizationContext;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* write logs to local file
|
|
3
|
+
* @param {string} command
|
|
4
|
+
* @param {unknown} _config
|
|
5
|
+
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
6
|
+
* @returns {import('vite').Plugin | null}
|
|
7
|
+
*/
|
|
8
|
+
export function needleLogger(command: string, _config: unknown, userSettings: import("../types/userconfig.js").userSettings): import("vite").Plugin | null;
|
package/plugins/vite/logger.js
CHANGED
|
@@ -15,7 +15,7 @@ const __dirname = path.dirname(__filename);
|
|
|
15
15
|
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
16
16
|
* @returns {import('vite').Plugin | null}
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export function needleLogger(command, _config, userSettings) {
|
|
19
19
|
|
|
20
20
|
if (userSettings?.disableLogging === true) {
|
|
21
21
|
return null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resets the sticky-header state so the next needleLog call always emits its
|
|
3
|
+
* [plugin-name] header. Call this at the start of a new build or any logical
|
|
4
|
+
* output section where you want a guaranteed fresh header.
|
|
5
|
+
*/
|
|
6
|
+
export function resetLastLoggedPlugin(): void;
|
|
7
|
+
/**
|
|
8
|
+
* @param {string} pluginName
|
|
9
|
+
* @param {string | string[]} message
|
|
10
|
+
* @param {'log' | 'warn' | 'error'} [level='log']
|
|
11
|
+
* @param {{ dimBody?: boolean, leadingNewline?: boolean, showHeader?: boolean }} [options]
|
|
12
|
+
*/
|
|
13
|
+
export function needleLog(pluginName: string, message: string | string[], level?: "log" | "warn" | "error", options?: {
|
|
14
|
+
dimBody?: boolean;
|
|
15
|
+
leadingNewline?: boolean;
|
|
16
|
+
showHeader?: boolean;
|
|
17
|
+
}): void;
|
|
18
|
+
/**
|
|
19
|
+
* @param {string} pluginName
|
|
20
|
+
* @param {string[]} lines
|
|
21
|
+
* @param {'log' | 'warn' | 'error'} [level='log']
|
|
22
|
+
*/
|
|
23
|
+
export function needleLogLines(pluginName: string, lines: string[], level?: "log" | "warn" | "error"): void;
|
|
24
|
+
export function needleSupportsColor(): boolean;
|
|
25
|
+
export function needleBlue(text: any): string;
|
|
26
|
+
export function needleDim(text: any): string;
|
|
27
|
+
export function needleGreenBold(text: any): string;
|
|
28
|
+
/**
|
|
29
|
+
* @param {(() => void) | null} cleaner
|
|
30
|
+
*/
|
|
31
|
+
export function setTransientLogLineCleaner(cleaner: (() => void) | null): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin}
|
|
6
|
+
*/
|
|
7
|
+
export function needleMeta(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin;
|
package/plugins/vite/meta.js
CHANGED
|
@@ -6,11 +6,12 @@ import { getPosterPath } from './poster.js';
|
|
|
6
6
|
import { needleGreenBold, needleLog } from './logging.js';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* @param {
|
|
10
|
-
* @param {import('../types').needleMeta | null} config
|
|
9
|
+
* @param {"build" | "serve"} command
|
|
10
|
+
* @param {import('../types/needleConfig').needleMeta | null} config
|
|
11
11
|
* @param {import('../types').userSettings} userSettings
|
|
12
|
+
* @returns {import('vite').Plugin}
|
|
12
13
|
*/
|
|
13
|
-
export
|
|
14
|
+
export function needleMeta(command, config, userSettings) {
|
|
14
15
|
|
|
15
16
|
// we can check if this is a build
|
|
16
17
|
const isBuild = command === 'build';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {'serve' | 'build'} command
|
|
3
|
+
* @param {{} | undefined | null} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin[] | null}
|
|
6
|
+
*/
|
|
7
|
+
export function needleApp(command: "serve" | "build", config: {} | undefined | null, userSettings: import("../types").userSettings): import("vite").Plugin[] | null;
|
|
@@ -10,7 +10,7 @@ import { needleLog } from './logging.js';
|
|
|
10
10
|
* @param {import('../types').userSettings} userSettings
|
|
11
11
|
* @returns {import('vite').Plugin[] | null}
|
|
12
12
|
*/
|
|
13
|
-
export
|
|
13
|
+
export function needleApp(command, config, userSettings) {
|
|
14
14
|
|
|
15
15
|
if (command !== "build") {
|
|
16
16
|
return null;
|
package/plugins/vite/npm.js
CHANGED
|
@@ -3,6 +3,6 @@ import { ensureNpmDirectoryExists } from '../common/npm.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* @param {import('../types').userSettings} userSettings
|
|
5
5
|
*/
|
|
6
|
-
export
|
|
6
|
+
export function needleNPM(command, config, userSettings) {
|
|
7
7
|
ensureNpmDirectoryExists();
|
|
8
8
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import("vite").Plugin | undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function needlePeerjs(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
package/plugins/vite/peer.js
CHANGED
|
@@ -2,10 +2,12 @@ const peerjsString = `/* needle: fix for peerjs */ window.global = window; var p
|
|
|
2
2
|
import { needleLog } from './logging.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* @param {"build" | "serve"} command
|
|
6
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
5
7
|
* @param {import('../types').userSettings} userSettings
|
|
6
8
|
* @returns {import("vite").Plugin | undefined}
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
10
|
+
export function needlePeerjs(command, config, userSettings) {
|
|
9
11
|
|
|
10
12
|
if (userSettings.noPeer === true) return;
|
|
11
13
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function getPosterPath(): string;
|
|
2
|
+
/**
|
|
3
|
+
* @param {"build" | "serve"} command
|
|
4
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
5
|
+
* @param {import('../types').userSettings} userSettings
|
|
6
|
+
* @returns {import('vite').Plugin | undefined}
|
|
7
|
+
*/
|
|
8
|
+
export function needlePoster(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
package/plugins/vite/poster.js
CHANGED
|
@@ -10,9 +10,12 @@ export function getPosterPath() {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
+
* @param {"build" | "serve"} command
|
|
14
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
13
15
|
* @param {import('../types').userSettings} userSettings
|
|
16
|
+
* @returns {import('vite').Plugin | undefined}
|
|
14
17
|
*/
|
|
15
|
-
export
|
|
18
|
+
export function needlePoster(command, config, userSettings) {
|
|
16
19
|
// only relevant for local development
|
|
17
20
|
if (command === 'build') return [];
|
|
18
21
|
|
|
@@ -76,4 +79,4 @@ export const needlePoster = (command, config, userSettings) => {
|
|
|
76
79
|
},
|
|
77
80
|
},
|
|
78
81
|
}
|
|
79
|
-
}
|
|
82
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Provides reasonable defaults for a PWA manifest and workbox settings.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import("../types/needleConfig").needleMeta | null} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin | undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function needlePWA(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
package/plugins/vite/pwa.js
CHANGED
|
@@ -8,12 +8,12 @@ import { needleLog } from './logging.js';
|
|
|
8
8
|
const pwaErrorWithInstructions = "It seems that you're trying to build a PWA using 'vite-plugin-pwa'!\nNeedle can manage PWA settings for you – just pass the same 'pwaOptions' to the needlePlugins and VitePWA plugins:\n\n1. Install the vite PWA plugin: npm install vite-plugin-pwa --save-dev\n\n2. Then update your vite.config.js:\n\n import { VitePWA } from 'vite-plugin-pwa';\n ...\n needlePlugins(command, needleConfig, { pwa: pwaOptions }),\n VitePWA(pwaOptions),\n\nIf you want to manage PWA building yourself and skip this check, please pass '{ pwa: false }' to needlePlugins.";
|
|
9
9
|
|
|
10
10
|
/** Provides reasonable defaults for a PWA manifest and workbox settings.
|
|
11
|
-
* @param {
|
|
12
|
-
* @param {import('../types').userSettings} userSettings
|
|
11
|
+
* @param {"build" | "serve"} command
|
|
13
12
|
* @param {import("../types/needleConfig").needleMeta | null} config
|
|
14
|
-
* @
|
|
13
|
+
* @param {import('../types').userSettings} userSettings
|
|
14
|
+
* @returns {import('vite').Plugin | undefined}
|
|
15
15
|
*/
|
|
16
|
-
export
|
|
16
|
+
export function needlePWA(command, config, userSettings) {
|
|
17
17
|
// @ts-ignore // TODO correctly type the userSettings.pwaOptions object
|
|
18
18
|
/** @type {import("vite-plugin-pwa").VitePWAOptions | false} */
|
|
19
19
|
const pwaOptions = userSettings.pwa === true
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin | undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function needleReload(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
package/plugins/vite/reload.js
CHANGED
|
@@ -16,10 +16,11 @@ let assetsDirectory = "";
|
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* @param {"build" | "serve"} command
|
|
19
|
-
* @param {import('../types').
|
|
19
|
+
* @param {import('../types/needleConfig').needleMeta | null} config
|
|
20
20
|
* @param {import('../types').userSettings} userSettings
|
|
21
|
+
* @returns {import('vite').Plugin | undefined}
|
|
21
22
|
*/
|
|
22
|
-
export
|
|
23
|
+
export function needleReload(command, config, userSettings) {
|
|
23
24
|
if (command === "build") return undefined;
|
|
24
25
|
|
|
25
26
|
if (userSettings?.noReload === true) return undefined;
|
|
@@ -31,7 +32,7 @@ export const needleReload = (command, config, userSettings) => {
|
|
|
31
32
|
isUpdatingConfig = true;
|
|
32
33
|
const res = await loadConfig();
|
|
33
34
|
isUpdatingConfig = false;
|
|
34
|
-
if (res) config = /** @type {import('../types').
|
|
35
|
+
if (res) config = /** @type {import('../types/needleConfig').needleMeta} */ (res);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
const projectConfig = tryLoadProjectConfig();
|
|
@@ -61,7 +62,7 @@ export const needleReload = (command, config, userSettings) => {
|
|
|
61
62
|
if (userSettings?.debug === true)
|
|
62
63
|
setTimeout(() => needleLog("needle-reload", "Updated server ignore patterns: " + JSON.stringify(config.server?.watch?.ignored)), 100);
|
|
63
64
|
},
|
|
64
|
-
/** @param {
|
|
65
|
+
/** @param {import('vite').HmrContext & {buildDirectory?: string}} args */
|
|
65
66
|
handleHotUpdate(args) {
|
|
66
67
|
args.buildDirectory = buildDirectory;
|
|
67
68
|
return handleReload(args);
|
|
@@ -118,7 +119,7 @@ function notifyClientWillReload(server, file) {
|
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
|
-
* @param {
|
|
122
|
+
* @param {import('vite').HmrContext & {buildDirectory?: string}} param0
|
|
122
123
|
* @returns {Promise<any>}
|
|
123
124
|
*/
|
|
124
125
|
async function handleReload({ file, server, modules: _modules, read, buildDirectory }) {
|
|
@@ -255,7 +256,7 @@ function getFileNameLog(file) {
|
|
|
255
256
|
const hashes = new Map();
|
|
256
257
|
const hash256 = crypto.createHash('sha256');
|
|
257
258
|
|
|
258
|
-
/** @param {string} file @param {(file?: string) => Promise<string>} read @returns {Promise<boolean>} */
|
|
259
|
+
/** @param {string} file @param {(file?: string) => string | Promise<string>} read @returns {Promise<boolean>} */
|
|
259
260
|
async function testIfFileContentChanged(file, read) {
|
|
260
261
|
let content = await read(file);
|
|
261
262
|
content = removeVersionQueryArgument(content);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Can open the network server in the browser.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types').needleMeta | null} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin}
|
|
6
|
+
*/
|
|
7
|
+
export function needleServer(command: "build" | "serve", config: import("../types").needleMeta | null, userSettings: import("../types").userSettings): import("vite").Plugin;
|
package/plugins/vite/server.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param {string} command
|
|
1
|
+
/** Can open the network server in the browser.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
4
3
|
* @param {import('../types').needleMeta | null} config
|
|
5
4
|
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin}
|
|
6
6
|
*/
|
|
7
|
-
export
|
|
7
|
+
export function needleServer(command, config, userSettings) {
|
|
8
8
|
|
|
9
9
|
const shouldOpenBrowser = userSettings.openBrowser === true;
|
|
10
10
|
|
|
@@ -64,4 +64,4 @@ export const needleServer = (command, config, userSettings) => {
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
}
|
|
67
|
-
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Modify the glb load path in codegen files.
|
|
2
|
+
* This is necessary if the assets directory is not the default (changed by the user in needle.config.json).
|
|
3
|
+
* @param {"build" | "serve"} command
|
|
4
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
5
|
+
* @param {import('../types').userSettings} userSettings
|
|
6
|
+
* @returns {import('vite').Plugin | undefined}
|
|
7
|
+
*/
|
|
8
|
+
export function needleTransformCodegen(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { builtAssetsDirectory, tryLoadProjectConfig } from './config.js';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
/** Modify the glb load path in codegen files.
|
|
4
|
+
* This is necessary if the assets directory is not the default (changed by the user in needle.config.json).
|
|
5
|
+
* @param {"build" | "serve"} command
|
|
6
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
6
7
|
* @param {import('../types').userSettings} userSettings
|
|
8
|
+
* @returns {import('vite').Plugin | undefined}
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
10
|
+
export function needleTransformCodegen(command, config, userSettings) {
|
|
9
11
|
|
|
10
12
|
if (config?.noCodegenTransform === true || userSettings?.noCodegenTransform === true) {
|
|
11
13
|
return;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Make sure we dont have vite 4.4.x installed when needle engine is used locally
|
|
3
|
+
* @param {import('../types').userSettings} userSettings
|
|
4
|
+
*/
|
|
5
|
+
export function vite_4_4_hack(command: any, config: any, userSettings: import("../types").userSettings): {
|
|
6
|
+
name: string;
|
|
7
|
+
configureServer(server: any): Promise<void>;
|
|
8
|
+
};
|
|
@@ -6,7 +6,7 @@ import { execSync } from 'child_process';
|
|
|
6
6
|
* Make sure we dont have vite 4.4.x installed when needle engine is used locally
|
|
7
7
|
* @param {import('../types').userSettings} userSettings
|
|
8
8
|
*/
|
|
9
|
-
export
|
|
9
|
+
export function vite_4_4_hack(command, config, userSettings) {
|
|
10
10
|
if (userSettings.vite44Hack === false) return;
|
|
11
11
|
return {
|
|
12
12
|
name: "needle-vite-4.4-hack",
|
|
@@ -613,6 +613,7 @@ export class Context implements IContext {
|
|
|
613
613
|
console.log("Using canvas from shadow root", canvas);
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
|
+
else if(debug) console.warn("No canvas found in shadow root, creating new canvas. This may cause input events to not work correctly. To fix this, make sure to use the canvas provided by the Needle Engine Web Component (e.g. by using context.createNewRenderer() without parameters or passing the canvas from the shadow root explicitly).")
|
|
616
617
|
}
|
|
617
618
|
if (debug) console.log("Using Renderer Parameters:", params, this.domElement)
|
|
618
619
|
|