فهرست منبع

Introduce the module specifics to handle multi namespaces
Fixed the empty declaration fixer (!!)

David Catuhe 6 سال پیش
والد
کامیت
8bf8607d99

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 14140 - 14152
Playground/babylon.d.txt


+ 6 - 0
Tools/Gulp/config.json

@@ -2060,6 +2060,12 @@
                 "filename": "babylon.gui.module.d.ts",
                 "packageName": "babylonjs-gui",
                 "moduleName": "BABYLON.GUI",
+                "moduleSpecifics": [
+                    {
+                        "path": "babylonjs-loaders/glTF/2.0/Extensions",
+                        "namespace": "BABYLON.GLTF2.Loader.Extensions"
+                    }
+                ],
                 "importsToRemove": [],
                 "classMap": {
                     "babylonjs": "BABYLON",

+ 45 - 21
Tools/Gulp/helpers/processViewerDeclaration.js

@@ -1,26 +1,37 @@
-module.exports = function (data, options) {
-
-    /*
-    {
-        packageName: string,
-        moduleName: string,
-        importsToRemove: Array<string>,
-        classMap
-    }
-    */
-
+module.exports = function(data, options) {
     var str = "" + data;
 
-    // this regex is not working on node 6 for some reason:
-    // str = str.replace(/declare module 'babylonjs-viewer\/' {((?!(declare))(.|\n))*\n}/g, '');
-
+    // Start process
     let lines = str.split('\n');
     var firstIndex = lines.findIndex((line => { return line.indexOf(`'${options.packageName}/'`) !== -1 }));
     var lastIndex = lines.findIndex(((line, idx) => { return line.trim() === '}' && idx > firstIndex }));
     lines.splice(firstIndex, lastIndex - firstIndex + 1);
-    str = lines.join('\n');
 
-    str = str.replace(/declare module (.*) {/g, `declare module ${options.moduleName} {`);
+    // Let's go line by line and check if we have special folder replacements
+    for (var index = 0; index < lines.length; index++) {
+        var namespace = options.moduleName;
+        var regex = /declare module '(.*)' {/g;
+
+        if (options.moduleSpecifics) {
+            var match = regex.exec(lines[index]);
+
+            if (!match) {
+                continue;
+            }
+
+            var module = match[1];
+
+            options.moduleSpecifics.forEach(function(specific) {
+                if (module.indexOf(specific.path) > -1) {
+                    namespace = specific.namespace;
+                }
+            });
+        }
+
+        lines[index] = lines[index].replace(regex, `declare module ${namespace} {`);
+    }
+
+    str = lines.join('\n');
 
     str = str.replace("import * as BABYLON from 'babylonjs';", "");
     let regexp = new RegExp(`import {(.*)} from ['"]${options.packageName}(.*)['"];`, 'g');
@@ -33,8 +44,7 @@ module.exports = function (data, options) {
         }
     }
 
-    //find all used BABYLON and BABYLON-Loaders classes:
-
+    // Find all used BABYLON and BABYLON-Loaders classes:
     if ((options.classMap)) {
         Object.keys(options.classMap).forEach(package => {
             var babylonRegex = new RegExp(`import {(.*)} from ['"](${package})['"];`, "g");
@@ -63,10 +73,24 @@ module.exports = function (data, options) {
 
     str = str.split("\n").filter(line => line.trim()).filter(line => line.indexOf("export * from") === -1).join("\n");
 
-    //empty declare regex
-    let emptyDeclareRegexp = new RegExp("declare module " + options.moduleName + " {\n}", "g");
+    // Remove empty module declaration
 
-    str = str.replace(emptyDeclareRegexp, "");
+    var cleanEmptyNamespace = function(str, moduleName) {
+        let emptyDeclareRegexp = new RegExp("declare module " + moduleName + " {\n}\n", "g");
+        str = str.replace(emptyDeclareRegexp, "");
+        emptyDeclareRegexp = new RegExp("declare module " + moduleName + " {\r\n}\r\n", "g");
+        str = str.replace(emptyDeclareRegexp, "");
+
+        return str;
+    }
+
+    str = cleanEmptyNamespace(str, options.moduleName);
+
+    if (options.moduleSpecifics) {
+        options.moduleSpecifics.forEach(function(specific) {
+            str = cleanEmptyNamespace(str, specific.namespace);
+        });
+    }
 
     return str;
 }

+ 17 - 17
Viewer/tests/package.json

@@ -1,17 +1,17 @@
-{
-    "name": "babylonjsviewerunittest",
-    "version": "7.7.7",
-    "description": "Unit Tests Suite For Babylon.js' viewer",
-    "main": "",
-    "repository": {
-        "url": "https://github.com/BabylonJS/Babylon.js/"
-    },
-    "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
-    "license": "(Apache-2.0)",
-    "devDependencies": {
-        "@types/mocha": "2.2.46",
-        "@types/chai": "^4.1.0",
-        "@types/sinon": "^4.1.3",
-        "typescript": "~3.0.1"
-    }
-}
+{
+    "name": "babylonjsviewerunittest",
+    "version": "7.7.7",
+    "description": "Unit Tests Suite For Babylon.js' viewer",
+    "main": "",
+    "repository": {
+        "url": "https://github.com/BabylonJS/Babylon.js/"
+    },
+    "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
+    "license": "(Apache-2.0)",
+    "devDependencies": {
+        "@types/mocha": "2.2.46",
+        "@types/chai": "^4.1.0",
+        "@types/sinon": "^4.1.3",
+        "typescript": "~3.0.1"
+    }
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 16193 - 16193
dist/preview release/babylon.d.ts


+ 0 - 12
dist/preview release/gui/babylon.gui.d.ts

@@ -2,14 +2,6 @@
 // Dependencies for this module:
 //   ../../../../Tools/Gulp/babylonjs
 declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
     /**
         * Interface used to define a control that can receive focus
         */
@@ -490,10 +482,6 @@ declare module BABYLON.GUI {
     }
 }
 declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
     /**
         * Class used to manage 3D user interface
         * @see http://doc.babylonjs.com/how_to/gui3d

+ 0 - 12
dist/preview release/gui/babylon.gui.module.d.ts

@@ -2829,14 +2829,6 @@ declare module 'babylonjs-gui/3D/materials/fluentMaterial' {
 // Dependencies for this module:
 //   ../../../../Tools/Gulp/babylonjs
 declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
     /**
         * Interface used to define a control that can receive focus
         */
@@ -3317,10 +3309,6 @@ declare module BABYLON.GUI {
     }
 }
 declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
-}
-declare module BABYLON.GUI {
     /**
         * Class used to manage 3D user interface
         * @see http://doc.babylonjs.com/how_to/gui3d

+ 0 - 20
dist/preview release/inspector/babylon.inspector.d.ts

@@ -2,26 +2,6 @@
 // Dependencies for this module:
 //   ../../../../Tools/Gulp/babylonjs
 declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
     export class Inspector {
             /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
             static DOCUMENT: HTMLDocument;

+ 0 - 20
dist/preview release/inspector/babylon.inspector.module.d.ts

@@ -1345,26 +1345,6 @@ declare module 'babylonjs-inspector/treetools/SoundInteractions' {
 // Dependencies for this module:
 //   ../../../../Tools/Gulp/babylonjs
 declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
-}
-declare module INSPECTOR {
     export class Inspector {
             /** The HTML document relative to this inspector (the window or the popup depending on its mode) */
             static DOCUMENT: HTMLDocument;

+ 0 - 4
dist/preview release/viewer/babylon.viewer.d.ts

@@ -941,8 +941,6 @@ declare module BabylonViewer {
     export function InitTags(selector?: string): void;
 }
 declare module BabylonViewer {
-}
-declare module BabylonViewer {
     export function getConfigurationKey(key: string, configObject: any): any;
     export interface ViewerConfiguration {
             version?: string;
@@ -1558,8 +1556,6 @@ declare module BabylonViewer {
     export function addLoaderPlugin(name: string, plugin: ILoaderPlugin): void;
 }
 declare module BabylonViewer {
-}
-declare module BabylonViewer {
     export interface IEnvironmentMapConfiguration {
             /**
                 * Environment map texture path in relative to the asset folder.

+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js

@@ -872,7 +872,7 @@ eval("\r\nObject.defineProperty(exports, \"__esModule\", { value: true });\r\nva
 /*! no static exports found */
 /***/ (function(module, exports, __webpack_require__) {
 
-eval("module.exports = __webpack_require__(/*! c:\\Dev\\Babylon\\Babylon.js\\Viewer\\src\\index.ts */\"./src/index.ts\");\n\n\n//# sourceURL=webpack://BabylonViewer/multi_./src/index.ts?");
+eval("module.exports = __webpack_require__(/*! D:\\Repos\\Babylon.js\\Viewer\\src\\index.ts */\"./src/index.ts\");\n\n\n//# sourceURL=webpack://BabylonViewer/multi_./src/index.ts?");
 
 /***/ }),
 

+ 16 - 16
tests/unit/package.json

@@ -1,16 +1,16 @@
-{
-  "name": "babylonjsunittest",
-  "version": "6.6.6",
-  "description": "Unit Tests Suite For Babylon.js",
-  "main": "",
-  "repository": {
-    "url": "https://github.com/BabylonJS/Babylon.js/"
-  },
-  "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
-  "license": "(Apache-2.0)",
-  "devDependencies": {
-    "@types/mocha": "2.2.46",
-    "@types/chai": "^4.1.0",
-    "@types/sinon": "^4.1.3"
-  }
-}
+{
+  "name": "babylonjsunittest",
+  "version": "6.6.6",
+  "description": "Unit Tests Suite For Babylon.js",
+  "main": "",
+  "repository": {
+    "url": "https://github.com/BabylonJS/Babylon.js/"
+  },
+  "readme": "https://github.com/BabylonJS/Babylon.js/edit/master/readme.md",
+  "license": "(Apache-2.0)",
+  "devDependencies": {
+    "@types/mocha": "2.2.46",
+    "@types/chai": "^4.1.0",
+    "@types/sinon": "^4.1.3"
+  }
+}