@needle-tools/engine 4.16.0 → 4.16.1-next.b4c9779
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-B5gYfP-3.umd.cjs} +121 -121
- package/dist/{needle-engine.bundle-Cx8Qrpbp.js → needle-engine.bundle-BGxftKpt.js} +5386 -5356
- package/dist/{needle-engine.bundle-mHgaFC2W.min.js → needle-engine.bundle-Bpn20g7P.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 +17 -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
package/plugins/vite/asap.js
CHANGED
|
@@ -9,13 +9,13 @@ const code = `import('@needle-tools/engine/src/asap/needle-asap.ts');`
|
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
/**
|
|
13
|
-
* Injects needle asap script into the index.html for when the main needle engine bundle is still being downloaded
|
|
12
|
+
/** Injects needle asap script into the index.html for when the main needle engine bundle is still being downloaded.
|
|
14
13
|
* @param {"build" | "serve"} command
|
|
14
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
15
15
|
* @param {import('../types').userSettings} userSettings
|
|
16
16
|
* @returns {Promise<import('vite').Plugin[] | null>}
|
|
17
17
|
*/
|
|
18
|
-
export
|
|
18
|
+
export async function needleAsap(command, config, userSettings) {
|
|
19
19
|
|
|
20
20
|
if (userSettings.noAsap) return null;
|
|
21
21
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export function waitForBuildPipelineToFinish(): Promise<void>;
|
|
2
|
+
/** Runs the needle build pipeline as part of the vite build process.
|
|
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}
|
|
7
|
+
*/
|
|
8
|
+
export function needleBuildPipeline(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin;
|
|
9
|
+
export type BuildPipelinePayload = {
|
|
10
|
+
event?: string;
|
|
11
|
+
phase?: string;
|
|
12
|
+
target?: string;
|
|
13
|
+
message?: string;
|
|
14
|
+
level?: string;
|
|
15
|
+
};
|
|
@@ -75,14 +75,13 @@ function increaseMaxWaitTime(debugLog) {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
/**
|
|
79
|
-
*
|
|
80
|
-
* @param {
|
|
81
|
-
* @param {import('vite').UserConfig} config
|
|
78
|
+
/** Runs the needle build pipeline as part of the vite build process.
|
|
79
|
+
* @param {"build" | "serve"} command
|
|
80
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
82
81
|
* @param {import('../types').userSettings} userSettings
|
|
83
|
-
* @returns {
|
|
82
|
+
* @returns {import('vite').Plugin}
|
|
84
83
|
*/
|
|
85
|
-
export
|
|
84
|
+
export async function needleBuildPipeline(command, config, userSettings) {
|
|
86
85
|
|
|
87
86
|
// we only want to run compression here if this is a distribution build
|
|
88
87
|
// this is handled however in the `apply` hook
|
|
@@ -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}
|
|
6
|
+
*/
|
|
7
|
+
export function needleBuild(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin;
|
package/plugins/vite/build.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
|
|
2
|
-
/**
|
|
2
|
+
/**
|
|
3
|
+
* @param {"build" | "serve"} command
|
|
4
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
5
|
+
* @param {import('../types').userSettings} userSettings
|
|
3
6
|
* @returns {import('vite').Plugin}
|
|
4
7
|
*/
|
|
5
|
-
export
|
|
8
|
+
export function needleBuild(command, config, userSettings) {
|
|
6
9
|
|
|
7
10
|
// TODO: need to set this when building a dist
|
|
8
11
|
const isDeployOnlyBuild = config?.deployOnly === true;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Create a buildinfo file in the build directory.
|
|
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 | null}
|
|
6
|
+
*/
|
|
7
|
+
export function needleBuildInfo(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
@@ -6,11 +6,13 @@ import { needleBlue, needleDim, needleLog, needleSupportsColor } from './logging
|
|
|
6
6
|
|
|
7
7
|
let level = 0;
|
|
8
8
|
|
|
9
|
-
/** Create a buildinfo file in the build directory
|
|
9
|
+
/** Create a buildinfo file in the build directory.
|
|
10
|
+
* @param {"build" | "serve"} command
|
|
11
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
10
12
|
* @param {import('../types').userSettings} userSettings
|
|
11
13
|
* @returns {import('vite').Plugin | null}
|
|
12
14
|
*/
|
|
13
|
-
export
|
|
15
|
+
export function needleBuildInfo(command, config, userSettings) {
|
|
14
16
|
|
|
15
17
|
if (userSettings?.noBuildInfo) return null;
|
|
16
18
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Load the codegen meta file.
|
|
2
|
+
* @param {string | null} path
|
|
3
|
+
* @returns {Promise<import("../types/needleConfig").needleMeta | null>}
|
|
4
|
+
*/
|
|
5
|
+
export function loadConfig(path?: string | null): Promise<import("../types/needleConfig").needleMeta | null>;
|
|
6
|
+
/** get the needle.config.json
|
|
7
|
+
* @returns {import("../types/needleConfig").needleConfig | null}
|
|
8
|
+
*/
|
|
9
|
+
export function tryLoadProjectConfig(): import("../types/needleConfig").needleConfig | null;
|
|
10
|
+
/** "assets" -> the directory name inside the output directory to put e.g. glb files into */
|
|
11
|
+
export function builtAssetsDirectory(): string;
|
|
12
|
+
/** @returns the fullpath of the build */
|
|
13
|
+
export function getOutputDirectory(): string;
|
package/plugins/vite/config.js
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Copy files on build from assets to dist.
|
|
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 | null}
|
|
6
|
+
*/
|
|
7
|
+
export function needleCopyFiles(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
@@ -8,11 +8,13 @@ import { needleBlue, needleDim, needleLog, needleSupportsColor } from './logging
|
|
|
8
8
|
const pluginName = "needle-copy-files";
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
/**
|
|
11
|
+
/** Copy files on build from assets to dist.
|
|
12
|
+
* @param {"build" | "serve"} command
|
|
13
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
12
14
|
* @param {import('../types').userSettings} userSettings
|
|
13
15
|
* @returns {import('vite').Plugin | null}
|
|
14
16
|
*/
|
|
15
|
-
export
|
|
17
|
+
export function needleCopyFiles(command, config, userSettings) {
|
|
16
18
|
|
|
17
19
|
if (config?.noCopy === true || userSettings?.noCopy === true) {
|
|
18
20
|
return null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensure the repo workspace or .vscode settings include Needle Engine custom HTML data if they exist.
|
|
3
|
+
* Copies custom-elements.json to the project and merges with existing user content.
|
|
4
|
+
* - Copies/merges `custom-elements.json` to project root
|
|
5
|
+
* - Adds `./custom-elements.json` to `.code-workspace settings.html.customData`
|
|
6
|
+
* - Adds `./custom-elements.json` to `.vscode/settings.json html.customData`
|
|
7
|
+
* @param {"build" | "serve"} _command
|
|
8
|
+
* @param {import('../types').needleMeta | null} _config
|
|
9
|
+
* @param {import('../types').userSettings} userSettings
|
|
10
|
+
* @returns {import('vite').Plugin | null}
|
|
11
|
+
*/
|
|
12
|
+
export function needleCustomElementData(_command: "build" | "serve", _config: import("../types").needleMeta | null, userSettings?: import("../types").userSettings): import("vite").Plugin | null;
|
|
13
|
+
export default needleCustomElementData;
|
|
14
|
+
export type CustomElementData = {
|
|
15
|
+
version?: number;
|
|
16
|
+
tags?: {
|
|
17
|
+
name: string;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
valueSets?: {
|
|
21
|
+
name: string;
|
|
22
|
+
[key: string]: unknown;
|
|
23
|
+
}[];
|
|
24
|
+
globalAttributes?: unknown[];
|
|
25
|
+
};
|
|
@@ -64,8 +64,9 @@ function mergeCustomElementData(sourceData, targetData) {
|
|
|
64
64
|
* @param {"build" | "serve"} _command
|
|
65
65
|
* @param {import('../types').needleMeta | null} _config
|
|
66
66
|
* @param {import('../types').userSettings} userSettings
|
|
67
|
+
* @returns {import('vite').Plugin | null}
|
|
67
68
|
*/
|
|
68
|
-
export
|
|
69
|
+
export function needleCustomElementData(_command, _config, userSettings = {}) {
|
|
69
70
|
// Allow disabling the workspace updater
|
|
70
71
|
if (userSettings?.noCustomElementData === true) return null;
|
|
71
72
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** used to pass config variables into vite.config.define
|
|
2
|
+
* for example "useRapier"
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @param {"build" | "serve"} command
|
|
6
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} needleEngineConfig
|
|
7
|
+
* @param {import('../types').userSettings} userSettings
|
|
8
|
+
* @returns {import('vite').Plugin}
|
|
9
|
+
*/
|
|
10
|
+
export function needleDefines(command: "build" | "serve", needleEngineConfig: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin;
|
package/plugins/vite/defines.js
CHANGED
|
@@ -12,11 +12,12 @@ import { needleLog } from "./logging.js";
|
|
|
12
12
|
// https://vitejs.dev/config/#using-environment-variables-in-config
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* @param {
|
|
16
|
-
* @param {
|
|
15
|
+
* @param {"build" | "serve"} command
|
|
16
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} needleEngineConfig
|
|
17
17
|
* @param {import('../types').userSettings} userSettings
|
|
18
|
+
* @returns {import('vite').Plugin}
|
|
18
19
|
*/
|
|
19
|
-
export
|
|
20
|
+
export function needleDefines(command, needleEngineConfig, userSettings) {
|
|
20
21
|
|
|
21
22
|
if (!userSettings) userSettings = {};
|
|
22
23
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when \`@needle-tools/engine\` is installed as a local package
|
|
3
|
+
* (i.e. it has its own nested `node_modules`). Vite's optimiser must skip such
|
|
4
|
+
* packages, otherwise it tries to pre-bundle source that was never meant to be
|
|
5
|
+
* pre-bundled and fails at dev-server start.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} [root] – project root; defaults to `process.cwd()`.
|
|
8
|
+
* @returns {boolean}
|
|
9
|
+
*/
|
|
10
|
+
export function isLocalNeedleEngineInstalled(root?: string): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* @param {"build" | "serve"} command
|
|
13
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
14
|
+
* @param {import('../types').userSettings} userSettings
|
|
15
|
+
* @returns {import('vite').Plugin[]}
|
|
16
|
+
*/
|
|
17
|
+
export function needleDependencies(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin[];
|
|
18
|
+
/**
|
|
19
|
+
* @type {string[]}
|
|
20
|
+
*/
|
|
21
|
+
export const preloadScriptPaths: string[];
|
|
@@ -24,10 +24,12 @@ export function isLocalNeedleEngineInstalled(root = process.cwd()) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
|
+
* @param {"build" | "serve"} command
|
|
28
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
27
29
|
* @param {import('../types').userSettings} userSettings
|
|
28
30
|
* @returns {import('vite').Plugin[]}
|
|
29
31
|
*/
|
|
30
|
-
export
|
|
32
|
+
export function needleDependencies(command, config, userSettings) {
|
|
31
33
|
|
|
32
34
|
/**
|
|
33
35
|
* @type {import('vite').Plugin}
|
|
@@ -0,0 +1,11 @@
|
|
|
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 needleDependencyWatcher(command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
8
|
+
export type PackageJson = {
|
|
9
|
+
dependencies?: Record<string, string>;
|
|
10
|
+
devDependencies?: Record<string, string>;
|
|
11
|
+
};
|
|
@@ -15,8 +15,9 @@ function log(...msg) {
|
|
|
15
15
|
* @param {"build" | "serve"} command
|
|
16
16
|
* @param {unknown} _config
|
|
17
17
|
* @param {import('../types').userSettings} userSettings
|
|
18
|
+
* @returns {import('vite').Plugin | null}
|
|
18
19
|
*/
|
|
19
|
-
export
|
|
20
|
+
export function needleDependencyWatcher(command, _config, userSettings) {
|
|
20
21
|
if (command === "build") return null;
|
|
21
22
|
|
|
22
23
|
if (userSettings?.noDependencyWatcher === true) return null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Experimental, allow dropping files from Unity into the running scene.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
4
|
+
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin | null | undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function needleDrop(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types/userconfig.js").userSettings): import("vite").Plugin | null | undefined;
|
package/plugins/vite/drop.js
CHANGED
|
@@ -6,13 +6,13 @@ import { fileURLToPath } from 'url';
|
|
|
6
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
7
7
|
const __dirname = path.dirname(__filename);
|
|
8
8
|
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
* @param {string} command
|
|
9
|
+
/** Experimental, allow dropping files from Unity into the running scene.
|
|
10
|
+
* @param {"build" | "serve"} command
|
|
12
11
|
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
13
12
|
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
13
|
+
* @returns {import('vite').Plugin | null | undefined}
|
|
14
14
|
*/
|
|
15
|
-
export
|
|
15
|
+
export function needleDrop(command, config, userSettings) {
|
|
16
16
|
if (command === "build") return;
|
|
17
17
|
|
|
18
18
|
if(userSettings.useDrop !== true) return null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @param {import('vite').Plugin[]} [pluginsArray]
|
|
6
|
+
* @returns {Promise<import('vite').Plugin | undefined>}
|
|
7
|
+
*/
|
|
8
|
+
export function editorConnection(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings, pluginsArray?: import("vite").Plugin[]): Promise<import("vite").Plugin | undefined>;
|
|
@@ -14,9 +14,13 @@ const editorSyncPackageName = "@needle-tools/editor-sync"
|
|
|
14
14
|
let editorSyncEnabled = false;
|
|
15
15
|
|
|
16
16
|
/**
|
|
17
|
-
* @
|
|
17
|
+
* @param {"build" | "serve"} command
|
|
18
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
19
|
+
* @param {import('../types').userSettings} userSettings
|
|
20
|
+
* @param {import('vite').Plugin[]} [pluginsArray]
|
|
21
|
+
* @returns {Promise<import('vite').Plugin | undefined>}
|
|
18
22
|
*/
|
|
19
|
-
export
|
|
23
|
+
export async function editorConnection(command, config, userSettings, pluginsArray) {
|
|
20
24
|
if (command === "build") return;
|
|
21
25
|
|
|
22
26
|
// Editor sync currently only supports Unity
|
|
@@ -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 needleFacebookInstantGames(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | undefined;
|
|
@@ -31,10 +31,12 @@ function log(...any) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
* @param {
|
|
34
|
+
* @param {"build" | "serve"} command
|
|
35
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
35
36
|
* @param {import('../types').userSettings} userSettings
|
|
37
|
+
* @returns {import('vite').Plugin | undefined}
|
|
36
38
|
*/
|
|
37
|
-
export
|
|
39
|
+
export function needleFacebookInstantGames(command, config, userSettings) {
|
|
38
40
|
|
|
39
41
|
if (userSettings.noFacebookInstantGames === true) return;
|
|
40
42
|
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Returns `true` when the Needle project is configured to serve gzip-compressed assets.
|
|
2
|
+
* Reads the `gzip` field from the config object.
|
|
3
|
+
* @param {import('../types/needleConfig').needleConfig | undefined} config
|
|
4
|
+
* @returns {boolean}
|
|
5
|
+
*/
|
|
6
|
+
export function useGzip(config: import("../types/needleConfig").needleConfig | undefined): boolean;
|
package/plugins/vite/gzip.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
|
|
2
2
|
// import { existsSync } from 'fs';
|
|
3
3
|
|
|
4
|
+
/** Returns `true` when the Needle project is configured to serve gzip-compressed assets.
|
|
5
|
+
* Reads the `gzip` field from the config object.
|
|
6
|
+
* @param {import('../types/needleConfig').needleConfig | undefined} config
|
|
7
|
+
* @returns {boolean}
|
|
8
|
+
*/
|
|
4
9
|
export function useGzip(config) {
|
|
5
10
|
return config?.gzip ? true : false;
|
|
6
11
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** @typedef {{ id: string, imports: GraphNode[], importedBy: GraphNode[] }} GraphNode */
|
|
2
|
+
/**
|
|
3
|
+
* @param {"build" | "serve"} _command
|
|
4
|
+
* @param {unknown} _config
|
|
5
|
+
* @param {import('../types').userSettings} userSettings
|
|
6
|
+
* @returns {import('vite').Plugin | null}
|
|
7
|
+
*/
|
|
8
|
+
export function needleImportsLogger(_command: "build" | "serve", _config: unknown, userSettings: import("../types").userSettings): import("vite").Plugin | null;
|
|
9
|
+
export type GraphNode = {
|
|
10
|
+
id: string;
|
|
11
|
+
imports: GraphNode[];
|
|
12
|
+
importedBy: GraphNode[];
|
|
13
|
+
};
|
|
@@ -8,8 +8,9 @@ import fs from 'fs';
|
|
|
8
8
|
* @param {"build" | "serve"} _command
|
|
9
9
|
* @param {unknown} _config
|
|
10
10
|
* @param {import('../types').userSettings} userSettings
|
|
11
|
+
* @returns {import('vite').Plugin | null}
|
|
11
12
|
*/
|
|
12
|
-
export
|
|
13
|
+
export function needleImportsLogger(_command, _config, userSettings) {
|
|
13
14
|
|
|
14
15
|
if (!userSettings.debugImportChains) return null;
|
|
15
16
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** # Needle Engine plugins for Vite
|
|
2
|
+
* Plugins include hot reload support, meta tags, defines, build pipeline, PWA, and more.
|
|
3
|
+
* ## Using PWA
|
|
4
|
+
* How to add PWA support to your vite project:
|
|
5
|
+
* 1) Install the [vite pwa plugin](https://vite-pwa-org.netlify.app/): `npm install vite-plugin-pwa --save-dev`
|
|
6
|
+
* 2) Add the following to your vite.config.js:
|
|
7
|
+
* You first pass the PWAOptions to the needlePlugins function, then you pass the same PWAOptions to the VitePWA plugin.
|
|
8
|
+
* You *can* use also add a `.webmanifest` file to your web project and edit the [PWA manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) settings there.
|
|
9
|
+
* ```js
|
|
10
|
+
* export default defineConfig(async ({ command }) => {
|
|
11
|
+
* // @type {import("vite-plugin-pwa").VitePWAOptions}
|
|
12
|
+
* const PWAOptions = {};
|
|
13
|
+
* ...
|
|
14
|
+
* return {
|
|
15
|
+
* plugins: [
|
|
16
|
+
* ...
|
|
17
|
+
* needlePlugins(command, needleConfig, { pwaOptions: PWAOptions }),
|
|
18
|
+
* VitePWA(PWAOptions),
|
|
19
|
+
* ],
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
* @param {"build" | "serve"} command
|
|
23
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
24
|
+
* @param {import('../types/index.js').userSettings} [userSettings]
|
|
25
|
+
* @returns {Promise<import('vite').Plugin[]>}
|
|
26
|
+
*/
|
|
27
|
+
export function needlePlugins(command: "build" | "serve", config?: import("../types/needleConfig").needleMeta | null | undefined, userSettings?: import("../types/index.js").userSettings): Promise<import("vite").Plugin[]>;
|
|
28
|
+
export { needleAI } from "./ai.js";
|
|
29
|
+
export { needleAsap } from "./asap.js";
|
|
30
|
+
export { needleDefines } from "./defines.js";
|
|
31
|
+
export { needleBuildPipeline } from "./build-pipeline.js";
|
|
32
|
+
export { needleBuild } from "./build.js";
|
|
33
|
+
export { needleMeta } from "./meta.js";
|
|
34
|
+
export { needlePoster } from "./poster.js";
|
|
35
|
+
export { needlePWA } from "./pwa.js";
|
|
36
|
+
export { needleReload } from "./reload.js";
|
|
37
|
+
export { needleDrop } from "./drop.js";
|
|
38
|
+
export { editorConnection } from "./editor-connection.js";
|
|
39
|
+
export { needleCopyFiles } from "./copyfiles.js";
|
|
40
|
+
export { needleViteAlias } from "./alias.js";
|
|
41
|
+
export { needleCustomElementData } from "./custom-element-data.js";
|
|
42
|
+
export { needleTransformCodegen } from "./transform-codegen.js";
|
|
43
|
+
export { needleLicense } from "./license.js";
|
|
44
|
+
export { needlePeerjs } from "./peer.js";
|
|
45
|
+
export { needleDependencyWatcher } from "./dependency-watcher.js";
|
|
46
|
+
export { needleDependencies } from "./dependencies.js";
|
|
47
|
+
export { needleFacebookInstantGames } from "./facebook-instant-games.js";
|
|
48
|
+
export { needleImportsLogger } from "./imports-logger.js";
|
|
49
|
+
export { needleBuildInfo } from "./buildinfo.js";
|
|
50
|
+
export { needleApp } from "./needle-app.js";
|
|
51
|
+
export { needleServer } from "./server.js";
|
|
52
|
+
export * from "./gzip.js";
|
|
53
|
+
export * from "./config.js";
|
|
54
|
+
export { needleMakeFilesLocal, needleLocalFilesSceneAnalysis } from "./local-files.js";
|
package/plugins/vite/index.js
CHANGED
|
@@ -94,27 +94,28 @@ const defaultUserSettings = {
|
|
|
94
94
|
* ## Using PWA
|
|
95
95
|
* How to add PWA support to your vite project:
|
|
96
96
|
* 1) Install the [vite pwa plugin](https://vite-pwa-org.netlify.app/): `npm install vite-plugin-pwa --save-dev`
|
|
97
|
-
* 2) Add the following to your vite.config.js:
|
|
97
|
+
* 2) Add the following to your vite.config.js:
|
|
98
98
|
* You first pass the PWAOptions to the needlePlugins function, then you pass the same PWAOptions to the VitePWA plugin.
|
|
99
99
|
* You *can* use also add a `.webmanifest` file to your web project and edit the [PWA manifest](https://developer.mozilla.org/en-US/docs/Web/Manifest) settings there.
|
|
100
|
-
* ```js
|
|
100
|
+
* ```js
|
|
101
101
|
* export default defineConfig(async ({ command }) => {
|
|
102
|
-
//
|
|
103
|
-
const PWAOptions = {};
|
|
104
|
-
...
|
|
105
|
-
return {
|
|
106
|
-
plugins: [
|
|
107
|
-
...
|
|
108
|
-
needlePlugins(command, needleConfig, { pwaOptions: PWAOptions }),
|
|
109
|
-
VitePWA(PWAOptions),
|
|
110
|
-
],
|
|
111
|
-
}
|
|
102
|
+
* // @type {import("vite-plugin-pwa").VitePWAOptions}
|
|
103
|
+
* const PWAOptions = {};
|
|
104
|
+
* ...
|
|
105
|
+
* return {
|
|
106
|
+
* plugins: [
|
|
107
|
+
* ...
|
|
108
|
+
* needlePlugins(command, needleConfig, { pwaOptions: PWAOptions }),
|
|
109
|
+
* VitePWA(PWAOptions),
|
|
110
|
+
* ],
|
|
111
|
+
* }
|
|
112
112
|
* ```
|
|
113
113
|
* @param {"build" | "serve"} command
|
|
114
|
-
* @param {
|
|
115
|
-
* @param {import('../types/index.js').userSettings} userSettings
|
|
114
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
115
|
+
* @param {import('../types/index.js').userSettings} [userSettings]
|
|
116
|
+
* @returns {Promise<import('vite').Plugin[]>}
|
|
116
117
|
*/
|
|
117
|
-
export
|
|
118
|
+
export async function needlePlugins(command, config = undefined, userSettings = {}) {
|
|
118
119
|
|
|
119
120
|
if (!config) config = {}
|
|
120
121
|
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** This plugin is used to apply the license to the needle engine.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
4
|
+
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
5
|
+
* @returns {import('vite').Plugin}
|
|
6
|
+
*/
|
|
7
|
+
export function needleLicense(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types/userconfig.js").userSettings): import("vite").Plugin;
|
package/plugins/vite/license.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { resolveLicense } from '../common/license.js';
|
|
2
2
|
import { loadConfig } from './config.js';
|
|
3
3
|
|
|
4
|
-
/**
|
|
5
|
-
*
|
|
6
|
-
* @param {
|
|
7
|
-
* @param {object} config - The config object
|
|
4
|
+
/** This plugin is used to apply the license to the needle engine.
|
|
5
|
+
* @param {"build" | "serve"} command
|
|
6
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
8
7
|
* @param {import('../types/userconfig.js').userSettings} userSettings
|
|
8
|
+
* @returns {import('vite').Plugin}
|
|
9
9
|
*/
|
|
10
|
-
export
|
|
10
|
+
export function needleLicense(command, config, userSettings) {
|
|
11
11
|
let license = undefined;
|
|
12
12
|
|
|
13
13
|
return {
|
|
@@ -53,4 +53,4 @@ export const needleLicense = (command, config, userSettings) => {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
}
|
|
56
|
+
}
|