Repository: playcanvas/engine
Pull request #4706 (2022-10-07 16:41:02)

Moved /script folder to /framework/script
- in order to reorganize the engine folder structure to layered approach
- no other changes other than move + automated import paths fixed up


Patch:
diff --git a/src/framework/app-base.js b/src/framework/app-base.js
index 84936e18a..479c99aa9 100644
--- a/src/framework/app-base.js
+++ b/src/framework/app-base.js
@@ -46,7 +46,7 @@ import { AssetRegistry } from '../asset/asset-registry.js';
 
 import { BundleRegistry } from '../bundles/bundle-registry.js';
 
-import { ScriptRegistry } from '../script/script-registry.js';
+import { ScriptRegistry } from './script/script-registry.js';
 
 import { I18n } from '../i18n/i18n.js';
 
diff --git a/src/framework/components/script/component.js b/src/framework/components/script/component.js
index 0c18c55f5..840e13c53 100644
--- a/src/framework/components/script/component.js
+++ b/src/framework/components/script/component.js
@@ -1,12 +1,12 @@
 import { SortedLoopArray } from '../../../core/sorted-loop-array.js';
 
-import { ScriptAttributes } from '../../../script/script-attributes.js';
+import { ScriptAttributes } from '../../script/script-attributes.js';
 
 import { Component } from '../component.js';
 import { Entity } from '../../entity.js';
 
 /* eslint-disable-next-line no-unused-vars */
-import { ScriptType } from '../../../script/script-type.js';
+import { ScriptType } from '../../script/script-type.js';
 import { Debug } from '../../../core/debug.js';
 
 /** @typedef {import('./system.js').ScriptComponentSystem} ScriptComponentSystem */
diff --git a/src/script/script-attributes.js b/src/framework/script/script-attributes.js
similarity index 96%
rename from src/script/script-attributes.js
rename to src/framework/script/script-attributes.js
index 02bbc0668..820e9ca63 100644
--- a/src/script/script-attributes.js
+++ b/src/framework/script/script-attributes.js
@@ -1,15 +1,15 @@
-import { Debug } from '../core/debug.js';
+import { Debug } from '../../core/debug.js';
 
-import { Color } from '../core/math/color.js';
-import { Curve } from '../core/math/curve.js';
-import { CurveSet } from '../core/math/curve-set.js';
-import { Vec2 } from '../core/math/vec2.js';
-import { Vec3 } from '../core/math/vec3.js';
-import { Vec4 } from '../core/math/vec4.js';
+import { Color } from '../../core/math/color.js';
+import { Curve } from '../../core/math/curve.js';
+import { CurveSet } from '../../core/math/curve-set.js';
+import { Vec2 } from '../../core/math/vec2.js';
+import { Vec3 } from '../../core/math/vec3.js';
+import { Vec4 } from '../../core/math/vec4.js';
 
-import { GraphNode } from '../scene/graph-node.js';
+import { GraphNode } from '../../scene/graph-node.js';
 
-import { Asset } from '../asset/asset.js';
+import { Asset } from '../../asset/asset.js';
 
 /* eslint-disable-next-line no-unused-vars */
 import { ScriptType } from './script-type.js';
diff --git a/src/script/script-registry.js b/src/framework/script/script-registry.js
similarity index 98%
rename from src/script/script-registry.js
rename to src/framework/script/script-registry.js
index 4341aea2c..9b741b474 100644
--- a/src/script/script-registry.js
+++ b/src/framework/script/script-registry.js
@@ -1,9 +1,9 @@
-import { EventHandler } from '../core/event-handler.js';
+import { EventHandler } from '../../core/event-handler.js';
 
 /* eslint-disable-next-line no-unused-vars */
 import { ScriptType } from './script-type.js';
 
-/** @typedef {import('../framework/app-base.js').AppBase} AppBase */
+/** @typedef {import('../app-base.js').AppBase} AppBase */
 
 /**
  * Container for all {@link ScriptType}s that are available to this application. Note that
diff --git a/src/script/script-type.js b/src/framework/script/script-type.js
similarity index 97%
rename from src/script/script-type.js
rename to src/framework/script/script-type.js
index 8bcf1982d..986b1054d 100644
--- a/src/script/script-type.js
+++ b/src/framework/script/script-type.js
@@ -1,12 +1,12 @@
-import { Debug } from '../core/debug.js';
-import { EventHandler } from '../core/event-handler.js';
+import { Debug } from '../../core/debug.js';
+import { EventHandler } from '../../core/event-handler.js';
 
-import { ScriptComponent } from '../framework/components/script/component.js';
+import { ScriptComponent } from '../components/script/component.js';
 
 import { ScriptAttributes } from './script-attributes.js';
 
-/** @typedef {import('../framework/app-base.js').AppBase} AppBase */
-/** @typedef {import('../framework/entity.js').Entity} Entity */
+/** @typedef {import('../app-base.js').AppBase} AppBase */
+/** @typedef {import('../entity.js').Entity} Entity */
 
 const funcNameRegex = new RegExp('^\\s*function(?:\\s|\\s*\\/\\*.*\\*\\/\\s*)+([^\\(\\s\\/]*)\\s*');
 
diff --git a/src/script/script.js b/src/framework/script/script.js
similarity index 96%
rename from src/script/script.js
rename to src/framework/script/script.js
index 9778055ad..c9e7e4ba9 100644
--- a/src/script/script.js
+++ b/src/framework/script/script.js
@@ -1,10 +1,10 @@
-import { Debug } from '../core/debug.js';
-import { EventHandler } from '../core/event-handler.js';
+import { Debug } from '../../core/debug.js';
+import { EventHandler } from '../../core/event-handler.js';
 
-import { ScriptHandler } from '../resources/script.js';
+import { ScriptHandler } from '../../resources/script.js';
 
-import { script } from '../framework/script.js';
-import { AppBase } from '../framework/app-base.js';
+import { script } from '../script.js';
+import { AppBase } from '../app-base.js';
 
 import { ScriptAttributes } from './script-attributes.js';
 import { ScriptType } from './script-type.js';
diff --git a/src/index.js b/src/index.js
index b1fd55b18..6f32ba728 100644
--- a/src/index.js
+++ b/src/index.js
@@ -193,10 +193,10 @@ export { AssetRegistry } from './asset/asset-registry.js';
 export { LocalizedAsset } from './asset/asset-localized.js';
 
 // SCRIPTS
-export { createScript, registerScript } from './script/script.js';
-export { ScriptAttributes } from './script/script-attributes.js';
-export { ScriptRegistry } from './script/script-registry.js';
-export { ScriptType } from './script/script-type.js';
+export { createScript, registerScript } from './framework/script/script.js';
+export { ScriptAttributes } from './framework/script/script-attributes.js';
+export { ScriptRegistry } from './framework/script/script-registry.js';
+export { ScriptType } from './framework/script/script-type.js';
 
 // LOCALIZATION
 export { I18n } from './i18n/i18n.js';
diff --git a/types-fixup.mjs b/types-fixup.mjs
index abe5d30ac..d437088de 100644
--- a/types-fixup.mjs
+++ b/types-fixup.mjs
@@ -4,9 +4,9 @@ import fs from 'fs';
 const regex = /Class<(.*?)>/g;
 const paths = [
     './types/framework/components/script/component.d.ts',
-    './types/script/script-attributes.d.ts',
-    './types/script/script-registry.d.ts',
-    './types/script/script.d.ts'
+    './types/framework/script/script-attributes.d.ts',
+    './types/framework/script/script-registry.d.ts',
+    './types/framework/script/script.d.ts'
 ];
 
 paths.forEach(path => {
@@ -471,7 +471,7 @@ dts = fs.readFileSync(path, 'utf8');
 dts = dts.replace('reset(): void;', 'reset(): void;\n' + getDeclarations(standardMaterialProps));
 fs.writeFileSync(path, dts);
 
-path = './types/script/script-type.d.ts';
+path = './types/framework/script/script-type.d.ts';
 dts = fs.readFileSync(path, 'utf8');
 dts = dts.replace('get enabled(): boolean;', 'get enabled(): boolean;\n' + `
     /**


Test patch:
diff --git a/test/framework/application.test.mjs b/test/framework/application.test.mjs
index 871426537..80c8004f8 100644
--- a/test/framework/application.test.mjs
+++ b/test/framework/application.test.mjs
@@ -10,7 +10,7 @@ import { Lightmapper } from '../../src/scene/lightmapper/lightmapper.js';
 import { ResourceLoader } from '../../src/resources/loader.js';
 import { Scene } from '../../src/scene/scene.js';
 import { SceneRegistry } from '../../src/framework/scene-registry.js';
-import { ScriptRegistry } from '../../src/script/script-registry.js';
+import { ScriptRegistry } from '../../src/framework/script/script-registry.js';
 import { XrManager } from '../../src/xr/xr-manager.js';
 
 import { HTMLCanvasElement } from '@playcanvas/canvas-mock';
diff --git a/test/framework/entity.test.mjs b/test/framework/entity.test.mjs
index 1e75e6f9b..b3fa293ff 100644
--- a/test/framework/entity.test.mjs
+++ b/test/framework/entity.test.mjs
@@ -1,4 +1,4 @@
-import { createScript } from '../../src/script/script.js';
+import { createScript } from '../../src/framework/script/script.js';
 import { Color } from '../../src/core/math/color.js';
 
 import { AnimComponent } from '../../src/framework/components/anim/component.js';