@needle-tools/engine 4.16.1 → 4.16.2
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 +7 -0
- package/components.needle.json +1 -1
- package/dist/{needle-engine.bundle-C3aSGlMn.min.js → needle-engine.bundle-BOzZVXHu.min.js} +132 -132
- package/dist/{needle-engine.bundle-CKIxz09L.js → needle-engine.bundle-VXttgVve.js} +5357 -5342
- package/dist/{needle-engine.bundle-DSHShuiJ.umd.cjs → needle-engine.bundle-nJtehyVz.umd.cjs} +131 -131
- package/dist/needle-engine.d.ts +45 -23
- 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-components/EventType.d.ts +1 -13
- package/lib/engine-components/EventType.js +13 -12
- package/lib/engine-components/EventType.js.map +1 -1
- package/lib/engine-components/ReflectionProbe.d.ts +31 -8
- package/lib/engine-components/ReflectionProbe.js +57 -15
- package/lib/engine-components/ReflectionProbe.js.map +1 -1
- package/package.json +15 -6
- package/plugins/next/next.d.ts +8 -0
- package/plugins/next/next.js +7 -6
- package/plugins/types/userconfig.d.ts +4 -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-components/EventType.ts +13 -12
- package/src/engine-components/ReflectionProbe.ts +65 -20
- package/plugins/types/next.d.ts +0 -3
- package/plugins/types/vite.d.ts +0 -14
|
@@ -4,16 +4,19 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { CubeTexture, EquirectangularReflectionMapping, LinearSRGBColorSpace, Texture, Vector3 } from "three";
|
|
7
|
+
import { Box3, CubeTexture, EquirectangularReflectionMapping, LinearSRGBColorSpace, Quaternion, Texture, Vector3 } from "three";
|
|
8
|
+
import { CreateWireCube } from "../engine/engine_gizmos.js";
|
|
8
9
|
import { MaterialPropertyBlock } from "../engine/engine_materialpropertyblock.js";
|
|
9
10
|
import { loadPMREM } from "../engine/engine_pmrem.js";
|
|
10
11
|
import { serializable } from "../engine/engine_serialization.js";
|
|
12
|
+
import { getBoundingBox } from "../engine/engine_three_utils.js";
|
|
11
13
|
import { getParam, resolveUrl } from "../engine/engine_utils.js";
|
|
12
|
-
import { BoxHelperComponent } from "./BoxHelperComponent.js";
|
|
13
14
|
import { Behaviour } from "./Component.js";
|
|
14
15
|
import { EventList } from "./EventList.js";
|
|
15
16
|
export const debug = getParam("debugreflectionprobe");
|
|
16
17
|
const disable = getParam("noreflectionprobe");
|
|
18
|
+
let box = null;
|
|
19
|
+
const _identityRotation = new Quaternion();
|
|
17
20
|
const $reflectionProbeKey = Symbol("reflectionProbeKey");
|
|
18
21
|
/**
|
|
19
22
|
* The [ReflectionProbe](https://engine.needle.tools/docs/api/ReflectionProbe) provides environment reflection data to materials within its defined area.
|
|
@@ -41,8 +44,10 @@ const $reflectionProbeKey = Symbol("reflectionProbeKey");
|
|
|
41
44
|
*/
|
|
42
45
|
export class ReflectionProbe extends Behaviour {
|
|
43
46
|
static _probes = new Map();
|
|
47
|
+
static testBox = new Box3();
|
|
44
48
|
/**
|
|
45
|
-
* Checks if the given material is currently using a reflection probe.
|
|
49
|
+
* Checks if the given material is currently using a reflection probe.
|
|
50
|
+
* This is determined by checking for an override on the material's "envMap" property, which is set by the Renderer component when applying a reflection probe.
|
|
46
51
|
*/
|
|
47
52
|
static isUsingReflectionProbe(material) {
|
|
48
53
|
return !!material[$reflectionProbeKey];
|
|
@@ -99,7 +104,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
99
104
|
_texture;
|
|
100
105
|
_textureUrlInFlight;
|
|
101
106
|
/**
|
|
102
|
-
* The cubemap or HDR texture used for reflections. Can be assigned directly or via a URL string.
|
|
107
|
+
* The cubemap or HDR texture used for reflections. Can be assigned directly or via a URL string.
|
|
108
|
+
* When assigning via URL, the texture will be loaded asynchronously and applied once ready.
|
|
109
|
+
* @param tex The texture or URL to assign to this reflection probe
|
|
110
|
+
* @default null
|
|
103
111
|
*/
|
|
104
112
|
set texture(tex) {
|
|
105
113
|
if (this._texture === tex)
|
|
@@ -140,22 +148,38 @@ export class ReflectionProbe extends Behaviour {
|
|
|
140
148
|
get texture() {
|
|
141
149
|
return this._texture;
|
|
142
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* The intensity of the reflection probe's influence.
|
|
153
|
+
* Higher values will make reflections brighter, while lower values will make them dimmer.
|
|
154
|
+
* The default value is 1, which means the reflections will be applied at their original brightness. Adjust this value to achieve the desired look for your scene.
|
|
155
|
+
* @default 1
|
|
156
|
+
*/
|
|
143
157
|
intensity = 1;
|
|
144
158
|
/**
|
|
145
|
-
* Defines the center
|
|
159
|
+
* Defines the center of the reflection probe's influence area relative to the GameObject's position.
|
|
160
|
+
* The probe will affect objects within a box defined by this center and the `size` property.
|
|
161
|
+
* Note: The actual influence area is determined by both the `center` and `size` properties. The `center` defines the offset from the GameObject's position, while the `size` defines the dimensions of the box around that center. Objects within this box will be influenced by the reflection probe.
|
|
146
162
|
*/
|
|
147
|
-
center;
|
|
163
|
+
center = new Vector3();
|
|
148
164
|
/**
|
|
149
165
|
* Defines the size of the reflection probe's influence area. Objects within this box will be affected by the probe's reflections.
|
|
166
|
+
* Note: The actual influence area is determined by both the `center` and `size` properties. The `center` defines the offset from the GameObject's position, while the `size` defines the dimensions of the box around that center. Objects within this box will be influenced by the reflection probe.
|
|
150
167
|
*/
|
|
151
|
-
size;
|
|
168
|
+
size = new Vector3(1, 1, 1);
|
|
152
169
|
/**
|
|
153
170
|
* Workaround for lightmap. Compensates for the fact that lightmaps are pre-multiplied by intensity, while reflection probes are not. This means that if you use both lightmaps and reflection probes, you may need to adjust this value to get the correct balance between them. The default value of `Math.PI` is a good starting point for most cases, but you may need to tweak it based on your specific lighting setup and artistic needs.
|
|
154
171
|
*/
|
|
155
172
|
__lightmapIntensityScale = true;
|
|
156
|
-
_boxHelper;
|
|
157
173
|
isInBox(obj) {
|
|
158
|
-
|
|
174
|
+
box ??= new Box3();
|
|
175
|
+
box.setFromCenterAndSize(this.gameObject.worldPosition.add(this.center), this.gameObject.worldScale.multiply(this.size));
|
|
176
|
+
getBoundingBox([obj], undefined, undefined, ReflectionProbe.testBox);
|
|
177
|
+
if (ReflectionProbe.testBox.isEmpty()) {
|
|
178
|
+
return box.containsPoint(obj.worldPosition);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
return box?.intersectsBox(ReflectionProbe.testBox);
|
|
182
|
+
}
|
|
159
183
|
}
|
|
160
184
|
constructor() {
|
|
161
185
|
super();
|
|
@@ -164,12 +188,14 @@ export class ReflectionProbe extends Behaviour {
|
|
|
164
188
|
}
|
|
165
189
|
ReflectionProbe._probes.get(this.context)?.push(this);
|
|
166
190
|
}
|
|
191
|
+
_gizmo = null;
|
|
192
|
+
_color = null;
|
|
167
193
|
/** @internal */
|
|
168
194
|
awake() {
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
195
|
+
if (debug) {
|
|
196
|
+
this._gizmo = CreateWireCube(0x555500);
|
|
197
|
+
this.gameObject.add(this._gizmo);
|
|
198
|
+
}
|
|
173
199
|
if (this._texture) {
|
|
174
200
|
this._texture.mapping = EquirectangularReflectionMapping;
|
|
175
201
|
this._texture.colorSpace = LinearSRGBColorSpace;
|
|
@@ -177,6 +203,16 @@ export class ReflectionProbe extends Behaviour {
|
|
|
177
203
|
}
|
|
178
204
|
}
|
|
179
205
|
/** @internal */
|
|
206
|
+
update() {
|
|
207
|
+
if (this._gizmo) {
|
|
208
|
+
if (this.center)
|
|
209
|
+
this._gizmo.position.copy(this.center);
|
|
210
|
+
if (this.size)
|
|
211
|
+
this._gizmo.scale.copy(this.size);
|
|
212
|
+
this._gizmo.worldQuaternion = _identityRotation.identity();
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
/** @internal */
|
|
180
216
|
onEnable() {
|
|
181
217
|
ReflectionProbe.onEnabled?.invoke(this);
|
|
182
218
|
}
|
|
@@ -201,7 +237,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
201
237
|
}
|
|
202
238
|
}
|
|
203
239
|
/**
|
|
204
|
-
* Applies this reflection probe to the given object by setting material property overrides for "envMap", "envMapRotation", and "envMapIntensity".
|
|
240
|
+
* Applies this reflection probe to the given object by setting material property overrides for "envMap", "envMapRotation", and "envMapIntensity".
|
|
241
|
+
* This is typically called by the Renderer component when determining which reflection probe to use for a given object.
|
|
242
|
+
* @param object The object to apply the reflection probe to
|
|
243
|
+
* @see {@link unapply} for the corresponding method to remove the probe's influence from an object.
|
|
205
244
|
*/
|
|
206
245
|
apply(object) {
|
|
207
246
|
if (disable)
|
|
@@ -221,7 +260,10 @@ export class ReflectionProbe extends Behaviour {
|
|
|
221
260
|
propertyBlock.setOverride("envMapIntensity", intensity);
|
|
222
261
|
}
|
|
223
262
|
/**
|
|
224
|
-
* Removes the reflection probe overrides from the given object.
|
|
263
|
+
* Removes the reflection probe overrides from the given object.
|
|
264
|
+
* This is typically called by the Renderer component when an object is no longer influenced by this probe or when the probe is disabled.
|
|
265
|
+
* @param object The object to remove the reflection probe overrides from
|
|
266
|
+
* @see {@link apply} for the corresponding method to apply the probe's influence to an object.
|
|
225
267
|
*/
|
|
226
268
|
unapply(obj) {
|
|
227
269
|
const block = MaterialPropertyBlock.get(obj);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReflectionProbe.js","sourceRoot":"","sources":["../../src/engine-components/ReflectionProbe.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,WAAW,EAAE,gCAAgC,EAAE,oBAAoB,
|
|
1
|
+
{"version":3,"file":"ReflectionProbe.js","sourceRoot":"","sources":["../../src/engine-components/ReflectionProbe.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,IAAI,EAAS,WAAW,EAAE,gCAAgC,EAAE,oBAAoB,EAAoC,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEzK,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,2CAA2C,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAEjE,OAAO,EAAE,cAAc,EAAoB,MAAM,iCAAiC,CAAC;AACnF,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,2BAA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|
2
2
|
"name": "@needle-tools/engine",
|
|
3
|
-
"version": "4.16.
|
|
3
|
+
"version": "4.16.2",
|
|
4
4
|
"description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development with great integrations into editors like Unity or Blender - and can be deployed onto any device! It is flexible, extensible and networking and XR are built-in.",
|
|
5
5
|
"main": "dist/needle-engine.min.js",
|
|
6
6
|
"exports": {
|
|
@@ -13,21 +13,29 @@
|
|
|
13
13
|
"./components.json": "./components.needle.json",
|
|
14
14
|
"./asap": "./lib/asap/needle-asap.js",
|
|
15
15
|
"./vite": {
|
|
16
|
-
"types": "./plugins/
|
|
16
|
+
"types": "./plugins/vite/index.d.ts",
|
|
17
17
|
"import": "./plugins/vite/index.js",
|
|
18
18
|
"require": "./plugins/vite/index.js"
|
|
19
19
|
},
|
|
20
20
|
"./next": {
|
|
21
|
-
"types": "./plugins/
|
|
21
|
+
"types": "./plugins/next/next.d.ts",
|
|
22
22
|
"import": "./plugins/next/index.js",
|
|
23
23
|
"require": "./plugins/next/index.js"
|
|
24
24
|
},
|
|
25
|
+
"./plugins/vite": {
|
|
26
|
+
"types": "./plugins/vite/index.d.ts",
|
|
27
|
+
"default": "./plugins/vite/index.js"
|
|
28
|
+
},
|
|
25
29
|
"./plugins/vite/index.js": {
|
|
26
|
-
"types": "./plugins/
|
|
30
|
+
"types": "./plugins/vite/index.d.ts",
|
|
27
31
|
"default": "./plugins/vite/index.js"
|
|
28
32
|
},
|
|
33
|
+
"./plugins/next": {
|
|
34
|
+
"types": "./plugins/next/next.d.ts",
|
|
35
|
+
"default": "./plugins/next/index.js"
|
|
36
|
+
},
|
|
29
37
|
"./plugins/next/index.js": {
|
|
30
|
-
"types": "./plugins/
|
|
38
|
+
"types": "./plugins/next/next.d.ts",
|
|
31
39
|
"default": "./plugins/next/index.js"
|
|
32
40
|
}
|
|
33
41
|
},
|
|
@@ -48,10 +56,11 @@
|
|
|
48
56
|
"readme": "README.md",
|
|
49
57
|
"scripts": {
|
|
50
58
|
"dev": "npm-watch",
|
|
51
|
-
"build": "npm run build:src && npm run build:dist",
|
|
59
|
+
"build": "npm run build:plugin-types && npm run build:src && npm run build:dist",
|
|
52
60
|
"build:dist": "vite build",
|
|
53
61
|
"build:src": "tsc -p tsconfig.build.json --rootDir ./src --outDir ./lib --noEmit false --declaration",
|
|
54
62
|
"build:license": "node plugins/publish/create-license.mjs",
|
|
63
|
+
"build:plugin-types": "tsc -p tsconfig.plugins.json && cp .plugin-types-tmp/plugins/vite/*.d.ts plugins/vite/ && cp .plugin-types-tmp/plugins/next/*.d.ts plugins/next/ && rm -rf .plugin-types-tmp",
|
|
55
64
|
"build:components-data": "node plugins/publish/create-component-types.now.mjs",
|
|
56
65
|
"test": "node plugins/test/test.mjs",
|
|
57
66
|
"test:circular-imports": "node plugins/test/check-circular-imports.mjs",
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Integrates Needle Engine into a Next.js project.
|
|
2
|
+
* Pass a nextConfig object in to add the needle specific settings.
|
|
3
|
+
* Optionally omit nextConfig and it will be created for you.
|
|
4
|
+
* @param {import('next').NextConfig} [nextConfig]
|
|
5
|
+
* @param {import('../types').userSettings} [userSettings]
|
|
6
|
+
* @returns {Promise<import('next').NextConfig>}
|
|
7
|
+
*/
|
|
8
|
+
export function needleNext(nextConfig?: any, userSettings?: import("../types").userSettings): Promise<any>;
|
package/plugins/next/next.js
CHANGED
|
@@ -12,13 +12,14 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
12
12
|
const __dirname = dirname(__filename);
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
/**
|
|
15
|
+
/** Integrates Needle Engine into a Next.js project.
|
|
16
|
+
* Pass a nextConfig object in to add the needle specific settings.
|
|
16
17
|
* Optionally omit nextConfig and it will be created for you.
|
|
17
|
-
* @param {import('next').NextConfig} nextConfig
|
|
18
|
-
* @param {import('../types').userSettings} userSettings
|
|
19
|
-
* @returns {import('next').NextConfig}
|
|
18
|
+
* @param {import('next').NextConfig} [nextConfig]
|
|
19
|
+
* @param {import('../types').userSettings} [userSettings]
|
|
20
|
+
* @returns {Promise<import('next').NextConfig>}
|
|
20
21
|
*/
|
|
21
|
-
export
|
|
22
|
+
export async function needleNext(nextConfig, userSettings) {
|
|
22
23
|
console.log("Apply 🌵 needle next config");
|
|
23
24
|
|
|
24
25
|
if (!nextConfig) {
|
|
@@ -138,4 +139,4 @@ export const needleNext = async (nextConfig, userSettings) => {
|
|
|
138
139
|
|
|
139
140
|
|
|
140
141
|
return nextConfig;
|
|
141
|
-
}
|
|
142
|
+
}
|
|
@@ -98,9 +98,10 @@ export type userSettings = {
|
|
|
98
98
|
*/
|
|
99
99
|
posterGenerationMode?: "default" | "once";
|
|
100
100
|
|
|
101
|
-
/** Pass in
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
/** Pass in PWA options, `true` to enable with defaults, or `false` to disable.
|
|
102
|
+
* Options are forwarded to `vite-plugin-pwa`.
|
|
103
|
+
*/
|
|
104
|
+
pwa?: Record<string, unknown> | boolean;
|
|
104
105
|
|
|
105
106
|
/** used by nextjs config to forward the webpack module */
|
|
106
107
|
modules?: needleModules;
|
|
@@ -164,9 +165,6 @@ export type userSettings = {
|
|
|
164
165
|
*/
|
|
165
166
|
openBrowser?: boolean;
|
|
166
167
|
|
|
167
|
-
/** Automatically import MaterialX for needle engine in 'main.ts' */
|
|
168
|
-
loadMaterialX?: boolean;
|
|
169
|
-
|
|
170
168
|
disableLogging?: boolean;
|
|
171
169
|
|
|
172
170
|
/** Set to true to disable the plugin that ensures VSCode workspace settings for custom-elements.json data */
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Needle Engine Claude skill installer.
|
|
3
|
+
*
|
|
4
|
+
* Writes a Needle Engine skill to `.claude/skills/needle-engine/SKILL.md`.
|
|
5
|
+
* Claude Code auto-loads skills based on their description frontmatter, so
|
|
6
|
+
* Claude will automatically have Needle Engine context when working in the project.
|
|
7
|
+
*
|
|
8
|
+
* The skill is only written if `.claude/` already exists in the project root
|
|
9
|
+
* (i.e. the developer is already using Claude Code). Old skill files are
|
|
10
|
+
* always overwritten so the skill stays up to date with the engine version.
|
|
11
|
+
*
|
|
12
|
+
* @param {"build" | "serve"} command
|
|
13
|
+
* @param {{} | undefined | null} config
|
|
14
|
+
* @param {import('../types/index.js').userSettings} userSettings
|
|
15
|
+
* @returns {import('vite').Plugin | null}
|
|
16
|
+
*/
|
|
17
|
+
export function needleAI(command: "build" | "serve", config: {} | undefined | null, userSettings: import("../types/index.js").userSettings): import("vite").Plugin | null;
|
package/plugins/vite/ai.js
CHANGED
|
@@ -23,7 +23,7 @@ const pluginName = "needle-ai";
|
|
|
23
23
|
* @param {import('../types/index.js').userSettings} userSettings
|
|
24
24
|
* @returns {import('vite').Plugin | null}
|
|
25
25
|
*/
|
|
26
|
-
export
|
|
26
|
+
export function needleAI(command, config, userSettings) {
|
|
27
27
|
return {
|
|
28
28
|
name: pluginName,
|
|
29
29
|
enforce: "pre",
|
|
@@ -34,7 +34,7 @@ export const needleAI = (command, config, userSettings) => {
|
|
|
34
34
|
installClaudeSkill();
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
|
-
}
|
|
37
|
+
}
|
|
38
38
|
|
|
39
39
|
function writeSkill(claudeDir) {
|
|
40
40
|
const skillDir = join(claudeDir, "skills", "needle-engine");
|
|
@@ -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
|
+
* @returns {import('vite').Plugin | import('vite').Plugin[] | undefined}
|
|
6
|
+
*/
|
|
7
|
+
export function needleViteAlias(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): import("vite").Plugin | import("vite").Plugin[] | undefined;
|
|
8
|
+
export type PackageResolveValue = "auto-resolve" | ((res: string, packageName: string, index: number, path: string) => string | null | void);
|
package/plugins/vite/alias.js
CHANGED
|
@@ -67,9 +67,12 @@ const packages_to_resolve = {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/**
|
|
70
|
+
* @param {"build" | "serve"} command
|
|
71
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
70
72
|
* @param {import('../types').userSettings} userSettings
|
|
73
|
+
* @returns {import('vite').Plugin | import('vite').Plugin[] | undefined}
|
|
71
74
|
*/
|
|
72
|
-
export
|
|
75
|
+
export function needleViteAlias(command, config, userSettings) {
|
|
73
76
|
|
|
74
77
|
if (config?.noAlias === true || userSettings?.noAlias === true)
|
|
75
78
|
return;
|
|
@@ -199,4 +202,4 @@ export const needleViteAlias = (command, config, userSettings) => {
|
|
|
199
202
|
}
|
|
200
203
|
}
|
|
201
204
|
}
|
|
202
|
-
}
|
|
205
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Injects needle asap script into the index.html for when the main needle engine bundle is still being downloaded.
|
|
2
|
+
* @param {"build" | "serve"} command
|
|
3
|
+
* @param {import('../types/needleConfig').needleMeta | null | undefined} config
|
|
4
|
+
* @param {import('../types').userSettings} userSettings
|
|
5
|
+
* @returns {Promise<import('vite').Plugin[] | null>}
|
|
6
|
+
*/
|
|
7
|
+
export function needleAsap(command: "build" | "serve", config: import("../types/needleConfig").needleMeta | null | undefined, userSettings: import("../types").userSettings): Promise<import("vite").Plugin[] | null>;
|
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[];
|