2
0
Переглянути джерело

amber loads without amber.js

uses output of `amber config`
Herbert Vojčík 10 роки тому
батько
коміт
819f9783f3

+ 3 - 2
internal/index.html

@@ -5,15 +5,16 @@
     <title>Amber Smalltalk</title>
     <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
     <meta name="author" content="Nicolas Petton"/>
-    <script type='text/javascript' src='../support/amber.js'></script>
     <script type='text/javascript' src='../support/requirejs/require.min.js'></script>
+    <script type='text/javascript' src='../config.js'></script>
 </head>
 
 <body>
 <script type='text/javascript'>
     require.config({
+        baseUrl: '..',
         paths: {
-            'amber_cli': '../external/amber-cli/src'
+            'amber_cli': 'external/amber-cli/src'
         }
     });
     require(

+ 0 - 114
support/amber.js

@@ -1,114 +0,0 @@
-/* Amber package loading.
-  Load this script as well as require.js (works in any order;
-    either defines 'require', thus passing config, if loaded prior require.js;
-    or calls require.config, if loaded post require.js).
-  Usage example:
-    require(['amber/devel'], function(amber) {
-        amber.initialize({"transport.defaultAmdNamespace": "com_example_myproject"});
-
-        amber.globals.Browser._open(); // for legacy IDE
-        amber.popupHelios(); // for Helios IDE
-    });
-  For detailed explanation of amber loading, see:
-  https://github.com/amber-smalltalk/amber/wiki/How-to-load-amber
- */
-
-var require;
-
-require = function (require) {
-    function uniquelyMapped(symbolicPath) {
-        if (require && typeof define !== "undefined" && define.amd) {
-            var mappedPath = require.toUrl(symbolicPath),
-                basePath = require.toUrl('') + symbolicPath;
-            if (resolveViaDOM(mappedPath) !== resolveViaDOM(basePath)) {
-                return mappedPath;
-            }
-        }
-    }
-    function myTag() {
-        // To be able to use its path and attributes
-        // to map other parts of Amber, this code must find its path.
-        // It first looks if require is already present && 'amber' path mapped.
-        // It not, it looks for id 'amber-path-mapper'.
-        // When loading amber.js asynchronously, you must include this id,
-        // or the code can not reliably find its <script>.
-        // If neither 'amber' mapping, nor script#amber-path-mapper is present,
-        // (the id is not necessary for inline <script> tag in HTML),
-        // it uses the "find the last <script> tag present in the moment" method.
-        var result = uniquelyMapped('amber/amber');
-        if (result) {
-            return {src: result, hasAttribute: function () { return false; }};
-        }
-        var me = document.getElementById("amber-path-mapper");
-        if (me && me.tagName.toLowerCase() === "script") {
-            return me;
-        }
-        var scripts = document.getElementsByTagName("script");
-        return scripts[scripts.length - 1];
-    }
-    var me = myTag();
-    var src = me.src;
-    // strip the last two elements from the URL
-    // e.g. http://app.com/amber/support/amber.js -> http://app.com/amber
-    var amber_home = resolveViaDOM(src).replace(/\/[^\/]+\/[^\/]+$/, "");
-    // In case of nonstandard deployment, you can specify libraries placement directly ...
-    var library_home = uniquelyMapped('amber_lib') || me.hasAttribute('data-libs') && me.getAttribute('data-libs');
-
-    // ... otherwise, this heuristics is used:
-    if (!library_home) {
-        // At the present moment, bower tries to have flat hierarchy,
-        // which leads to two possible scenarios:
-        // 1. amber itself was deployed via bower,
-        //    its libraries are at the same bower dir
-        //    where amber itself is placed
-        // 2. amber was deployed in different fashion,
-        //    its libraries are included by bower locally, inside amber
-        // The detection is done by looking for '/bower_components/' in amber path.
-        var match = amber_home.match(/^(.*\/bower_components)\//);
-        library_home = match ? match[1] : amber_home + '/bower_components';
-    }
-
-    function resolveViaDOM(url) {
-        var a = document.createElement("a");
-        a.href = url;
-        return a.href;
-    }
-
-    var config = {
-        paths: {
-            'amber': amber_home + '/support',
-            'amber_vm': amber_home + '/support/deprecated-vm-files',
-            'amber_vm/_st': amber_home + '/support/deprecated-vm-files/as-receiver',
-            'amber_css': amber_home + '/support/resources', // deprecated
-            'amber_lib': library_home,
-            'amber_core': amber_home + '/src',
-            'helios': amber_home + '/support/helios/src',
-            'helios/all': amber_home + '/support/helios/all',
-            'helios/resources': amber_home + '/support/helios/resources',
-            'helios/index': amber_home + '/support/helios/index',
-            'jquery': library_home + '/jquery/jquery.min'
-        },
-        map: {
-            '*': {
-                'css': 'amber_lib/require-css/css'
-            }
-        },
-        shim: {
-            'ensure-console': {
-                exports: 'console'
-            }
-        }
-    };
-
-    // This is to allow both alternatives of loading:
-    // before require.js as well as after require.js
-    // See http://requirejs.org/docs/api.html#config for details
-    // of usage of 'require' global to allow to pre-define configuration
-    // before require.js is loaded.
-    if (require) {
-        require.config(config);
-        return require;
-    } else {
-        return config;
-    }
-}(require);

+ 0 - 12
support/codemirror-inner.js

@@ -1,12 +0,0 @@
-// Loading this in nested file so that require.config
-// with shim dependencies is in effect.
-// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
-
-define([
-    'amber_lib/codemirror/lib/codemirror',
-    'amber_lib/codemirror/mode/smalltalk/smalltalk',
-    'amber_lib/codemirror/addon/hint/show-hint',
-    'css!amber_lib/codemirror/theme/ambiance',
-    'css!amber_lib/codemirror/lib/codemirror',
-    'css!amber_lib/codemirror/addon/hint/show-hint'
-]);

+ 8 - 15
support/codemirror.js

@@ -1,15 +1,8 @@
-require.config({
-	shim: {
-		'amber_lib/codemirror/lib/codemirror': {
-			deps: [ 'css!amber_lib/codemirror/lib/codemirror' ]
-		},
-		'amber_lib/codemirror/mode/smalltalk/smalltalk': {
-			deps: [ '../../lib/codemirror' ]
-		},
-		'amber_lib/codemirror/addon/hint/show-hint': {
-			deps: [ '../../lib/codemirror' ]
-		}
-	}
-});
-
-define(['./codemirror-inner']);
+define([
+    'amber_lib/codemirror/lib/codemirror',
+    'amber_lib/codemirror/mode/smalltalk/smalltalk',
+    'amber_lib/codemirror/addon/hint/show-hint',
+    'css!amber_lib/codemirror/theme/ambiance',
+    'css!amber_lib/codemirror/lib/codemirror',
+    'css!amber_lib/codemirror/addon/hint/show-hint'
+]);

+ 0 - 11
support/devel-inner.js

@@ -1,11 +0,0 @@
-// Loading this in nested file so that require.config
-// with shim dependencies is in effect.
-// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
-
-define([
-	'jquery-ui',
-    'amber_lib/jquery-tabby/jquery.textarea',
-    'amber_core/IDE',
-    'amber_core/Examples',
-    'amber_core/Benchfib'
-]);

+ 5 - 15
support/devel.js

@@ -1,22 +1,12 @@
-require.config({
-	paths: {
-		'jquery-ui': require.toUrl('amber_lib/jquery-ui/ui/minified/jquery-ui.min')
-	},
-	shim: {
-		'jquery-ui': {
-			deps: [ 'jquery' ]
-		},
-		'amber_lib/jquery-tabby/jquery.textarea': {
-			deps: [ 'jquery' ]
-		}
-	}
-});
-
 define([
 	'./helpers', // pre-fetch, dep of ./deploy
 	'./deploy', // pre-fetch, dep of ./lang
 	'./lang',
 	'./codemirror',
-	'./devel-inner',
+    'jquery-ui',
+    'amber_lib/jquery-tabby/jquery.textarea',
+    'amber_core/IDE',
+    'amber_core/Examples',
+    'amber_core/Benchfib',
 	'css!amber/resources/amber'
 ], function (smalltalk) { return smalltalk; });

+ 26 - 20
support/helios/all.js

@@ -1,28 +1,34 @@
-require.config({
-	paths: {
-		'bootstrap2.3.2': require.toUrl('amber_lib') + '/bootstrap2.3.2/bootstrap',
-		'jquery-ui': require.toUrl('amber_lib/jquery-ui/ui/minified/jquery-ui.min')
-	},
-	shim: {
-		'jquery-ui': {
-			deps: [ 'jquery' ]
-		},
-		'bootstrap2.3.2/js/bootstrap': {
-			deps: [ 'jquery', 'css!bootstrap2.3.2/css/bootstrap' ]
-		},
-		'amber_lib/jquery-tabby/jquery.textarea': {
-			deps: [ 'jquery' ]
-		}
-	}
-});
-
 define([
 	'amber/helpers', // pre-fetch, dep of amber/deploy
 	'amber/deploy', // pre-fetch, dep of amber/lang
 	'amber/lang',
 	'amber/codemirror',
-	'amber/devel-inner', // pre-fetch, dep of ./all-inner
-	'./resources/all-inner',
+    'jquery-ui',
+    'amber_lib/jquery-tabby/jquery.textarea',
+    'amber_core/IDE',
+    'amber_core/Examples',
+    'amber_core/Benchfib',
+    'bootstrap2.3.2/js/bootstrap',
+    'amber_lib/showdown/compressed/showdown',
+    './Helios-Core',
+    './Helios-Exceptions',
+    './Helios-Helpers',
+    './Helios-Commands-Core',
+    './Helios-Commands-Tools',
+    './Helios-Commands-Browser',
+    './Helios-Commands-SUnit',
+    './Helios-Layout',
+    './Helios-KeyBindings',
+    './Helios-Browser',
+    './Helios-Workspace',
+    './Helios-Transcript',
+    './Helios-SUnit',
+    './Helios-SUnit-Tests',
+    './Helios-Debugger',
+    './Helios-Inspector',
+    './Helios-References',
+    './Helios-Announcements',
+    './Helios-Workspace-Tests',
     'css!./resources/helios',
 	'css!./resources/helios-niflheim',
     'css!./resources/niflheim'

+ 3 - 2
support/helios/index.html

@@ -10,9 +10,10 @@
     <div id="helper">Loading Helios...</div>
 
     <div id="includes">
-      <script type='text/javascript' src='../amber.js'></script>
       <script type='text/javascript' src='../requirejs/require.min.js'></script>
-      <script type='text/javascript'>
+        <script type='text/javascript' src='../../config.js'></script>
+        <script type='text/javascript'>
+          require.config({baseUrl: '../..'});
           require(
                   ["helios/all"],
                   function (smalltalk) {

+ 0 - 28
support/helios/resources/all-inner.js

@@ -1,28 +0,0 @@
-// Loading this in nested file so that require.config
-// with shim dependencies is in effect.
-// See http://stackoverflow.com/questions/21647956/how-to-config-requirejs-shim-dependencies-just-in-time/
-
-define([
-	'amber/devel-inner',
-	'bootstrap2.3.2/js/bootstrap',
-	'amber_lib/showdown/compressed/showdown',
-	'helios/Helios-Core',
-	'helios/Helios-Exceptions',
-	'helios/Helios-Helpers',
-	'helios/Helios-Commands-Core',
-	'helios/Helios-Commands-Tools',
-	'helios/Helios-Commands-Browser',
-	'helios/Helios-Commands-SUnit',
-	'helios/Helios-Layout',
-	'helios/Helios-KeyBindings',
-	'helios/Helios-Browser',
-	'helios/Helios-Workspace',
-	'helios/Helios-Transcript',
-	'helios/Helios-SUnit',
-	'helios/Helios-SUnit-Tests',
-	'helios/Helios-Debugger',
-	'helios/Helios-Inspector',
-	'helios/Helios-References',
-	'helios/Helios-Announcements',
-	'helios/Helios-Workspace-Tests'
-]);