@needle-tools/engine 3.0.1-alpha → 3.0.1-alpha.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/package.json CHANGED
@@ -1,9 +1,16 @@
1
1
  {
2
2
  "name": "@needle-tools/engine",
3
- "version": "3.0.1-alpha",
3
+ "version": "3.0.1-alpha.2",
4
4
  "description": "Needle Engine is a web-based runtime for 3D apps. It runs on your machine for development, and can be deployed anywhere. It is flexible, extensible, and collaboration and XR come naturally.",
5
5
  "main": "dist/needle-engine.umd.cjs",
6
- "module": "lib/needle-engine.js",
6
+ "exports": {
7
+ ".": {
8
+ "import": "./lib/needle-engine.js",
9
+ "require": "./dist/needle-engine.umd.cjs"
10
+ },
11
+ "./package.json": "./package.json",
12
+ "./plugins/vite/index.js": "./plugins/vite/index.js"
13
+ },
7
14
  "type": "module",
8
15
  "repository": {
9
16
  "type": "git",
@@ -102,6 +109,7 @@
102
109
  "quiet": false
103
110
  }
104
111
  },
112
+ "module": "lib/needle-engine.js",
105
113
  "typings": "lib/needle-engine.d.ts",
106
114
  "types": "lib/needle-engine.d.ts"
107
115
  }
@@ -3,12 +3,26 @@ import path from 'path';
3
3
 
4
4
  const projectDir = process.cwd() + "/";
5
5
 
6
+ /** these are alias callbacks as in the vite.alias dictionary
7
+ * the first argument is the already resoled absolute path (it is only invoked if the path was found in node_modules)
8
+ * the 2,3,4 args are the same as in vite.alias (packageName, index, path);
9
+ */
6
10
  const packages_to_resolve = {
7
- 'three': {},
8
- '@needle-tools/engine': {},
9
- 'peerjs': {},
10
- 'websocket-ts': {},
11
- 'md5': {},
11
+ // Handle all previous imports where users did import using @needle-engine/src
12
+ '@needle-tools/engine/src': (res, packageName, index, path) => {
13
+ return res + "/../lib";
14
+ },
15
+ '@needle-tools/engine': (res, packageName, index, path) => {
16
+ // Check if the import is something like @needle-tools/engine/engine/engine_utils
17
+ // in which case we want to resolve into the lib directory
18
+ if (path.startsWith("@needle-tools/engine/engine")) {
19
+ return res + "/lib";
20
+ }
21
+ },
22
+ 'three': null,
23
+ 'peerjs': null,
24
+ 'websocket-ts': null,
25
+ 'md5': null,
12
26
  }
13
27
 
14
28
  export const needleViteAlias = (command, config, userSettings) => {
@@ -28,18 +42,26 @@ export const needleViteAlias = (command, config, userSettings) => {
28
42
  const aliasDict = config.resolve.alias;
29
43
  for (const name in packages_to_resolve) {
30
44
  if (!aliasDict[name]) {
31
- addPathResolver(name, aliasDict);
45
+ addPathResolver(name, aliasDict, packages_to_resolve[name]);
32
46
  }
33
47
  }
34
48
  }
35
49
  }
36
50
 
37
- function addPathResolver(name, aliasList) {
51
+ function addPathResolver(name, aliasDict, cb) {
38
52
  // If a package at the node_modules path exist we resolve the request there
39
53
  // introduced in 89a50718c38940abb99ee16c5e029065e41d7d65
40
54
  const res = path.resolve(projectDir, 'node_modules', name);
55
+ if (typeof cb !== "function") cb = null;
41
56
  if (existsSync(res)) {
42
- aliasList[name] = () => res;
57
+ aliasDict[name] = (packageName, index, path) => {
58
+ if (cb !== null) {
59
+ const overrideResult = cb(res, packageName, index, path);
60
+ if (overrideResult !== undefined)
61
+ return overrideResult;
62
+ }
63
+ return res;
64
+ }
43
65
  }
44
66
  }
45
67
  };
@@ -1,5 +1,5 @@
1
1
 
2
- export const activeInHierarchyFieldName = Symbol("isActiveInHierarchy");
2
+ export const activeInHierarchyFieldName = "needle_isActiveInHierarchy";
3
3
  export const builtinComponentKeyName = "builtin_components";
4
4
  // It's easier to use a string than a symbol here because the symbol might not be the same when imported in other packages
5
5
  export const editorGuidKeyName = "needle_editor_guid";
@@ -292,6 +292,19 @@ function updateIsActiveInHierarchyRecursiveRuntime(go: THREE.Object3D, activeInH
292
292
  return success;
293
293
  }
294
294
 
295
+ // function tryFindActiveStateInParent(obj: Object3D): boolean {
296
+ // let current: Object3D | undefined | null = obj;
297
+ // while (current) {
298
+ // const activeState = current[constants.activeInHierarchyFieldName];
299
+ // if (activeState !== undefined) return activeState;
300
+ // if (current instanceof Scene && !current.parent) {
301
+ // return true;
302
+ // }
303
+ // current = current.parent;
304
+ // }
305
+ // return false;
306
+ // }
307
+
295
308
  // let isRunning = false;
296
309
  // // Prevent: https://github.com/needle-tools/needle-tiny/issues/641
297
310
  // const temporyChildArrayBuffer: Array<Array<THREE.Object3D>> = [];