boot.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /* ====================================================================
  2. |
  3. | Amber Smalltalk
  4. | http://amber-lang.net
  5. |
  6. ======================================================================
  7. ======================================================================
  8. |
  9. | Copyright (c) 2010-2014
  10. | Nicolas Petton <petton.nicolas@gmail.com>
  11. |
  12. | Copyright (c) 2012-2016
  13. | The Amber team https://lolg.it/org/amber/members
  14. | Amber contributors (see /CONTRIBUTORS)
  15. |
  16. | Amber is released under the MIT license
  17. |
  18. | Permission is hereby granted, free of charge, to any person obtaining
  19. | a copy of this software and associated documentation files (the
  20. | 'Software'), to deal in the Software without restriction, including
  21. | without limitation the rights to use, copy, modify, merge, publish,
  22. | distribute, sublicense, and/or sell copies of the Software, and to
  23. | permit persons to whom the Software is furnished to do so, subject to
  24. | the following conditions:
  25. |
  26. | The above copyright notice and this permission notice shall be
  27. | included in all copies or substantial portions of the Software.
  28. |
  29. | THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  30. | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  31. | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  32. | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  33. | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  34. | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  35. | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  36. |
  37. ==================================================================== */
  38. //jshint eqnull:true
  39. define([
  40. 'require', './brikz', './kernel-fundamentals', './kernel-language', './compatibility'
  41. ], function (require, Brikz, configureWithFundamentals, configureWithHierarchy) {
  42. "use strict";
  43. require(['./kernel-runtime']); // preload
  44. SmalltalkInitBrik.deps = ["classes"];
  45. function SmalltalkInitBrik (brikz, st) {
  46. var bootstrapHierarchy = brikz.classes.bootstrapHierarchy;
  47. var initialized = false;
  48. var runtimeLoadedPromise = new Promise(function (resolve, reject) {
  49. require(['./kernel-runtime'], resolve, reject);
  50. });
  51. /* Smalltalk initialization. Called on page load */
  52. st.initialize = function () {
  53. return runtimeLoadedPromise.then(function (configureWithRuntime) {
  54. if (initialized) return;
  55. bootstrapHierarchy();
  56. configureWithRuntime(brikz);
  57. initialized = true;
  58. });
  59. };
  60. }
  61. /* Adds AMD and requirejs related methods to the api */
  62. function AMDBrik (brikz, st) {
  63. st.amdRequire = require;
  64. st.defaultTransportType = st.defaultTransportType || "amd";
  65. st.defaultAmdNamespace = st.defaultAmdNamespace || "amber_core";
  66. }
  67. var api = {};
  68. var brikz = new Brikz(api);
  69. configureWithFundamentals(brikz);
  70. configureWithHierarchy(brikz);
  71. brikz.stInit = SmalltalkInitBrik;
  72. brikz.amd = AMDBrik;
  73. brikz.rebuild();
  74. return {
  75. api: api,
  76. nil/* TODO deprecate */: brikz.nil.nilAsReceiver,
  77. nilAsReceiver: brikz.nil.nilAsReceiver,
  78. dnu/* TODO deprecate */: brikz.classes.nilAsClass,
  79. nilAsClass: brikz.classes.nilAsClass,
  80. globals: brikz.smalltalkGlobals.globals,
  81. asReceiver: brikz.asReceiver.asReceiver
  82. };
  83. });