@woosh/meep-engine 2.47.17 → 2.47.19

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
@@ -5,7 +5,7 @@
5
5
  "description": "Fully featured ECS game engine written in JavaScript",
6
6
  "type": "module",
7
7
  "author": "Alexander Goldring",
8
- "version": "2.47.17",
8
+ "version": "2.47.19",
9
9
  "main": "build/meep.module.js",
10
10
  "module": "build/meep.module.js",
11
11
  "exports": {
@@ -38,8 +38,10 @@
38
38
  "gl-matrix": "3.4.3",
39
39
  "opentype.js": "1.3.3",
40
40
  "robust-predicates": "3.0.1",
41
- "simplex-noise": "2.4.0",
42
- "three": "0.135.0 - 0.136.0"
41
+ "simplex-noise": "2.4.0"
42
+ },
43
+ "peerDependencies": {
44
+ "three": ">=0.135.0"
43
45
  },
44
46
  "devDependencies": {
45
47
  "@babel/core": "7.20.12",
@@ -3,8 +3,9 @@
3
3
  * @param {T} source
4
4
  * @param {Map<string, function(v:Object):Object>} serializers
5
5
  * @param {Map<*,string>} classNames
6
+ * @param {boolean} [constructorNameFallback]
6
7
  */
7
- export function abstractJSONSerializer(source, serializers, classNames) {
8
+ export function abstractJSONSerializer(source, serializers, classNames, constructorNameFallback = true) {
8
9
 
9
10
 
10
11
  if (typeof source !== "object") {
@@ -23,6 +24,28 @@ export function abstractJSONSerializer(source, serializers, classNames) {
23
24
  typeName = Klass.typeName;
24
25
  }
25
26
 
27
+ if (typeName === undefined && constructorNameFallback) {
28
+ typeName = Klass.name;
29
+
30
+ console.warn(`No type name could be resolved, using constructor name '${typeName}' as a fallback.`);
31
+
32
+ const matching_class_entries = [];
33
+ classNames.forEach((value, key) => {
34
+ if (value === typeName) {
35
+ matching_class_entries.push(key);
36
+ }
37
+ });
38
+
39
+ if (matching_class_entries.length > 0) {
40
+ console.error(
41
+ `Found a class that resolved to name ${typeName}. className registry might be corrupted, possible reason is multiple versions of the same class being imported.`,
42
+ "offending object:", source,
43
+ "matching class name entries:", matching_class_entries,
44
+ "Note that constructor of offending object does not match any of these classes (!==)"
45
+ );
46
+ }
47
+ }
48
+
26
49
  if (typeName === undefined) {
27
50
  throw new Error(`Failed to resolve type name. No name found in classNames registry and no .typeName field on the constructor {name: '${Klass.name}}'`);
28
51
  }