From fbfa466c9c105adf4747dd0f48453fc4ebb2bd54 Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Fri, 26 Jun 2015 09:22:13 -0700 Subject: [PATCH 1/8] lazy --- index.html | 20 +++++++++ packages/ember-metal/lib/core.js | 39 +++++++++++++++++ packages/ember-metal/lib/main.js | 74 ++++++++++---------------------- 3 files changed, 81 insertions(+), 52 deletions(-) create mode 100644 index.html diff --git a/index.html b/index.html new file mode 100644 index 00000000000..198aacc69dc --- /dev/null +++ b/index.html @@ -0,0 +1,20 @@ + + + + + + + diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index 9556ae6ea6d..bcb92f9d3fb 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -170,4 +170,43 @@ export { K }; Ember.K = K; //TODO: ES6 GLOBAL TODO +// Stub out the methods defined by the ember-debug package in case it's not loaded + +if ('undefined' === typeof Ember.assert) { Ember.assert = K; } +if ('undefined' === typeof Ember.warn) { Ember.warn = K; } +if ('undefined' === typeof Ember.debug) { Ember.debug = K; } +if ('undefined' === typeof Ember.runInDebug) { Ember.runInDebug = K; } +if ('undefined' === typeof Ember.deprecate) { Ember.deprecate = K; } +if ('undefined' === typeof Ember.deprecateFunc) { + Ember.deprecateFunc = function(_, func) { return func; }; +} + +const CACHE = Object.create(null); +function reexport(moduleName, properties) { + properties.forEach((property) => { + let importAs, exportAs; + + if (Array.isArray(property)) { + [importAs, exportAs] = property; + } else { + importAs = exportAs = property; + } + + Object.defineProperty(Ember, exportAs, { + get() { + var key = moduleName + '_' + importAs; + if (CACHE[key]) { + return CACHE[key]; + } + return (CACHE[key] = Ember.__loader.require(moduleName)[importAs]); + }, + set(value) { + var key = moduleName + '_' + importAs; + return (CACHE[key] = value); + } + }); + }); +} +Ember.__reexport = reexport; + export default Ember; diff --git a/packages/ember-metal/lib/main.js b/packages/ember-metal/lib/main.js index cbd84d1e116..fd3eebd88a5 100644 --- a/packages/ember-metal/lib/main.js +++ b/packages/ember-metal/lib/main.js @@ -14,35 +14,7 @@ import { subscribe as instrumentationSubscribe, unsubscribe as instrumentationUnsubscribe } from 'ember-metal/instrumentation'; -import { - GUID_KEY, - apply, - applyStr, - canInvoke, - generateGuid, - guidFor, - inspect, - makeArray, - deprecatedTryCatchFinally, - tryInvoke, - uuid, - wrap -} from 'ember-metal/utils'; -import { - EMPTY_META, - META_DESC, - meta -} from 'ember-metal/meta'; -import EmberError from 'ember-metal/error'; import Cache from 'ember-metal/cache'; -import Logger from 'ember-metal/logger'; - -import { - _getPath, - get, - getWithDefault, - normalizeTuple -} from 'ember-metal/property_get'; import { accumulateListeners, @@ -199,34 +171,32 @@ Ember.subscribe = instrumentationSubscribe; Ember._Cache = Cache; -Ember.generateGuid = generateGuid; -Ember.GUID_KEY = GUID_KEY; -Ember.platform = { +Ember.platform = { defineProperty: true, hasPropertyAccessors: true }; -Ember.Error = EmberError; -Ember.guidFor = guidFor; -Ember.META_DESC = META_DESC; -Ember.EMPTY_META = EMPTY_META; -Ember.meta = meta; -Ember.inspect = inspect; -Ember.tryCatchFinally = deprecatedTryCatchFinally; -Ember.makeArray = makeArray; -Ember.canInvoke = canInvoke; -Ember.tryInvoke = tryInvoke; -Ember.wrap = wrap; -Ember.apply = apply; -Ember.applyStr = applyStr; -Ember.uuid = uuid; - -Ember.Logger = Logger; - -Ember.get = get; -Ember.getWithDefault = getWithDefault; -Ember.normalizeTuple = normalizeTuple; -Ember._getPath = _getPath; +var reexport = Ember._reexport; + +reexport('ember-metal/error', [['default', 'Error']]); +reexport('ember-metal/meta', ['EMPTY_META', 'META_DESC', 'meta']); +reexport('ember-metal/utils', [ + 'GUID_KEY', + 'guidFor', + 'inspect', + 'apply', + 'applyStr', + 'canInvoke', + 'tryInovke', + 'generateGuid', + ['deprecatedTryCatchFinally', 'tryCatchFinally'], + 'makeArray', + 'uuid', + 'wrap' +]); + +reexport('ember-metal/logger', [['default', 'Logger']]); +reexport('ember-metal/property_get', ['get', '_getPath', 'getWithDefault', 'normalizeTuple']); Ember.on = on; Ember.addListener = addListener; From 7510fd843c4fdb36c1957d382de6d2f3324b24d4 Mon Sep 17 00:00:00 2001 From: "David J. Hamilton" Date: Sat, 27 Jun 2015 18:50:51 -0700 Subject: [PATCH 2/8] _ -> __ --- packages/ember-metal/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ember-metal/lib/main.js b/packages/ember-metal/lib/main.js index fd3eebd88a5..875e695370d 100644 --- a/packages/ember-metal/lib/main.js +++ b/packages/ember-metal/lib/main.js @@ -176,7 +176,7 @@ Ember.platform = { hasPropertyAccessors: true }; -var reexport = Ember._reexport; +var reexport = Ember.__reexport; reexport('ember-metal/error', [['default', 'Error']]); reexport('ember-metal/meta', ['EMPTY_META', 'META_DESC', 'meta']); From 2821e3b606049938013a8c111a41a8509c1d2773 Mon Sep 17 00:00:00 2001 From: "David J. Hamilton" Date: Sat, 27 Jun 2015 20:24:33 -0700 Subject: [PATCH 3/8] more rexport --- packages/ember-metal/lib/core.js | 43 +++++++- packages/ember-runtime/lib/main.js | 161 +++++++++-------------------- packages/ember-testing/lib/main.js | 14 ++- packages/ember-views/lib/main.js | 63 ++++------- 4 files changed, 118 insertions(+), 163 deletions(-) diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index bcb92f9d3fb..c727998ebcd 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -182,7 +182,44 @@ if ('undefined' === typeof Ember.deprecateFunc) { } const CACHE = Object.create(null); -function reexport(moduleName, properties) { +function reexport(moduleName, exportsProperty, properties) { + if (arguments.length === 2) { + properties = exportsProperty; + exportsProperty = undefined; + } + + let exportObj = exportsProperty ? Ember[exportsProperty] : Ember; + const tail = array => array.slice(1); + const head = array => array[0]; + const pathLookUp = (paths, obj) => { + if (!Array.isArray(paths)) { + paths = paths.split('.'); + } + + if (paths.length > 1) { + let assignment = paths[paths.length - 1]; + let node = head(paths); + + if (node === assignment) { + return obj; + } + + Ember.assert('Attempted to assign at ${node}, but it does not exist.', !obj[node]); + + pathLookUp(tail(paths), obj[node]); + } else { + return obj; + } + }; + + if (exportsProperty === 'string') { + exportObj = pathLookUp(exportsProperty, exportObj); + } + + if (typeof properties === 'string') { + properties = [['default', properties]]; + } + properties.forEach((property) => { let importAs, exportAs; @@ -192,7 +229,9 @@ function reexport(moduleName, properties) { importAs = exportAs = property; } - Object.defineProperty(Ember, exportAs, { + Ember.assert(`Import exists ${moduleName}{${importAs}}`, typeof Ember.__loader.require(moduleName)[importAs] !== 'undefined'); + + Object.defineProperty(exportObj, exportAs, { get() { var key = moduleName + '_' + importAs; if (CACHE[key]) { diff --git a/packages/ember-runtime/lib/main.js b/packages/ember-runtime/lib/main.js index fe90033c31e..28c433ada89 100644 --- a/packages/ember-runtime/lib/main.js +++ b/packages/ember-runtime/lib/main.js @@ -5,137 +5,76 @@ // BEGIN IMPORTS import Ember from 'ember-metal'; -import isEqual from 'ember-runtime/is-equal'; -import compare from 'ember-runtime/compare'; -import copy from 'ember-runtime/copy'; -import inject from 'ember-runtime/inject'; - -import Namespace from 'ember-runtime/system/namespace'; -import EmberObject from 'ember-runtime/system/object'; -import { Container, Registry } from 'ember-runtime/system/container'; -import ArrayProxy from 'ember-runtime/system/array_proxy'; -import ObjectProxy from 'ember-runtime/system/object_proxy'; -import CoreObject from 'ember-runtime/system/core_object'; - -import NativeArray from 'ember-runtime/system/native_array'; -import EmberStringUtils from 'ember-runtime/system/string'; -import { - onLoad, - runLoadHooks -} from 'ember-runtime/system/lazy_load'; - -import EmberArray from 'ember-runtime/mixins/array'; -import Comparable from 'ember-runtime/mixins/comparable'; -import Copyable from 'ember-runtime/mixins/copyable'; -import Enumerable from 'ember-runtime/mixins/enumerable'; -import { - Freezable, - FROZEN_ERROR -} from 'ember-runtime/mixins/freezable'; -import _ProxyMixin from 'ember-runtime/mixins/-proxy'; - -import Observable from 'ember-runtime/mixins/observable'; -import ActionHandler from 'ember-runtime/mixins/action_handler'; -import MutableEnumerable from 'ember-runtime/mixins/mutable_enumerable'; -import MutableArray from 'ember-runtime/mixins/mutable_array'; -import TargetActionSupport from 'ember-runtime/mixins/target_action_support'; -import Evented from 'ember-runtime/mixins/evented'; -import PromiseProxyMixin from 'ember-runtime/mixins/promise_proxy'; - -import { - sum, - min, - max, - map, - sort, - setDiff, - mapBy, - filter, - filterBy, - uniq, - union, - intersect -} from 'ember-runtime/computed/reduce_computed_macros'; - import Controller from 'ember-runtime/controllers/controller'; import ControllerMixin from 'ember-runtime/mixins/controller'; - import Service from 'ember-runtime/system/service'; import RSVP from 'ember-runtime/ext/rsvp'; // just for side effect of extending Ember.RSVP import 'ember-runtime/ext/string'; // just for side effect of extending String.prototype import 'ember-runtime/ext/function'; // just for side effect of extending Function.prototype - -import { isArray, typeOf } from 'ember-runtime/utils'; // END IMPORTS // BEGIN EXPORTS -Ember.compare = compare; -Ember.copy = copy; -Ember.isEqual = isEqual; - -Ember.inject = inject; - -Ember.Array = EmberArray; - -Ember.Comparable = Comparable; -Ember.Copyable = Copyable; - -Ember.Freezable = Freezable; -Ember.FROZEN_ERROR = FROZEN_ERROR; - -Ember.MutableEnumerable = MutableEnumerable; -Ember.MutableArray = MutableArray; - -Ember.TargetActionSupport = TargetActionSupport; -Ember.Evented = Evented; - -Ember.PromiseProxyMixin = PromiseProxyMixin; - -Ember.Observable = Observable; - -Ember.typeOf = typeOf; -Ember.isArray = isArray; +var reexport = Ember.__reexport; + +reexport('ember-runtime/utils', ['isArray', 'typeOf']); +reexport('ember-runtime/compare', 'compare'); +reexport('ember-runtime/copy', 'copy'); +reexport('ember-runtime/core', ['isEqual']); +reexport('ember-runtime/inject', 'inject'); +reexport('ember-runtime/mixins/array', [['default', 'Array']]); +reexport('ember-runtime/mixins/comparable', 'Comparable'); +reexport('ember-runtime/mixins/copyable', 'Copyable'); +reexport('ember-runtime/mixins/sortable', 'SortableMixin'); +reexport('ember-runtime/mixins/freezable', ['Freezable', 'FROZEN_ERROR']); +reexport('ember-runtime/mixins/mutable_enumerable', 'MutableEnumerable'); +reexport('ember-runtime/mixins/mutable_array', 'MutableArray'); +reexport('ember-runtime/mixins/target_action_support', 'TargetActionSupport'); +reexport('ember-runtime/mixins/evented', 'Evented'); +reexport('ember-runtime/mixins/promise_proxy', 'PromiseProxyMixin'); +reexport('ember-runtime/mixins/observable', 'Observable'); +reexport('ember-runtime/mixins/-proxy', '_ProxyMixin'); +reexport('ember-runtime/computed/array_computed', ['arrayComputed', 'ArrayComputedProperty']); +reexport('ember-runtime/computed/reduce_computed', ['reduceComputed', 'ReduceComputedProperty']); +reexport('ember-runtime/utils', ['typeOf']); // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed -var EmComputed = Ember.computed; - -EmComputed.sum = sum; -EmComputed.min = min; -EmComputed.max = max; -EmComputed.map = map; -EmComputed.sort = sort; -EmComputed.setDiff = setDiff; -EmComputed.mapBy = mapBy; -EmComputed.filter = filter; -EmComputed.filterBy = filterBy; -EmComputed.uniq = uniq; -EmComputed.union = union; -EmComputed.intersect = intersect; - -Ember.String = EmberStringUtils; -Ember.Object = EmberObject; -Ember.Container = Container; -Ember.Registry = Registry; -Ember.Namespace = Namespace; -Ember.Enumerable = Enumerable; -Ember.ArrayProxy = ArrayProxy; -Ember.ObjectProxy = ObjectProxy; -Ember.ActionHandler = ActionHandler; -Ember.CoreObject = CoreObject; -Ember.NativeArray = NativeArray; +reexport('ember-runtime/computed/reduce_computed_macros', 'computed', [ + 'sum', + 'min', + 'max', + 'map', + 'sort', + 'setDiff', + 'mapBy', + 'mapProperty', + 'filter', + 'filterBy', + 'filterProperty', + 'uniq', + 'union', + 'intersect' +]); + +reexport('ember-runtime/system/string', [['default', 'String']]); +reexport('ember-runtime/system/object', [['default', 'Object']]); +reexport('ember-runtime/system/container', ['Container', 'Registry']); +reexport('ember-runtime/system/namespace', 'Namespace'); +reexport('ember-runtime/mixins/enumerable', 'Enumerable'); +reexport('ember-runtime/system/array_proxy', 'ArrayProxy'); +reexport('ember-runtime/system/object_proxy', 'ObjectProxy'); +reexport('ember-runtime/mixins/action_handler', 'ActionHandler'); +reexport('ember-runtime/system/core_object', 'CoreObject'); +reexport('ember-runtime/system/native_array', 'NativeArray'); // ES6TODO: Currently we must rely on the global from ember-metal/core to avoid circular deps // Ember.A = A; -Ember.onLoad = onLoad; -Ember.runLoadHooks = runLoadHooks; +reexport('ember-runtime/system/lazy_load', ['onLoad', 'runLoadHooks']); Ember.Controller = Controller; Ember.ControllerMixin = ControllerMixin; Ember.Service = Service; -Ember._ProxyMixin = _ProxyMixin; - Ember.RSVP = RSVP; // END EXPORTS diff --git a/packages/ember-testing/lib/main.js b/packages/ember-testing/lib/main.js index 37ed4ad4c6b..d3bdc0d55ad 100644 --- a/packages/ember-testing/lib/main.js +++ b/packages/ember-testing/lib/main.js @@ -3,10 +3,6 @@ import Ember from 'ember-metal/core'; import 'ember-testing/initializers'; // to setup initializer import 'ember-testing/support'; // to handle various edge cases -import setupForTesting from 'ember-testing/setup_for_testing'; -import Test from 'ember-testing/test'; -import Adapter from 'ember-testing/adapters/adapter'; -import QUnitAdapter from 'ember-testing/adapters/qunit'; import 'ember-testing/helpers'; // adds helpers to helpers object in Test /** @@ -14,7 +10,9 @@ import 'ember-testing/helpers'; // adds helpers to helpers object in Test @submodule ember-testing */ -Ember.Test = Test; -Ember.Test.Adapter = Adapter; -Ember.Test.QUnitAdapter = QUnitAdapter; -Ember.setupForTesting = setupForTesting; +var reexport = Ember.__reexport; + +reexport('ember-testing/test', 'Test'); +reexport('ember-testing/adapters/adapter', 'Test', 'Adapter'); +reexport('ember-testing/adapters/qunit', 'Test', 'QUnitAdapter'); +reexport('ember-testing/setup_for_testing', 'setupForTesting '); diff --git a/packages/ember-views/lib/main.js b/packages/ember-views/lib/main.js index d4cd31e7d7c..308a760289b 100644 --- a/packages/ember-views/lib/main.js +++ b/packages/ember-views/lib/main.js @@ -12,31 +12,9 @@ import { getViewBoundingClientRect } from 'ember-views/system/utils'; import 'ember-views/system/ext'; // for the side effect of extending Ember.run.queues -import { - cloneStates, - states -} from 'ember-views/views/states'; - -import Renderer from 'ember-metal-views/renderer'; -import { DeprecatedCoreView } from 'ember-views/views/core_view'; -import { DeprecatedView } from 'ember-views/views/view'; -import { DeprecatedContainerView } from 'ember-views/views/container_view'; -import CollectionView from 'ember-views/views/collection_view'; -import Component from 'ember-views/components/component'; - -import EventDispatcher from 'ember-views/system/event_dispatcher'; + import ViewTargetActionSupport from 'ember-views/mixins/view_target_action_support'; -import ComponentLookup from 'ember-views/component_lookup'; -import Checkbox from 'ember-views/views/checkbox'; -import TextSupport from 'ember-views/mixins/text_support'; -import TextField from 'ember-views/views/text_field'; -import TextArea from 'ember-views/views/text_area'; -import { - Select, - SelectOption, - SelectOptgroup -} from 'ember-views/views/select'; import _MetamorphView, { _Metamorph } from 'ember-views/compat/metamorph_view'; import LegacyEachView from 'ember-views/views/legacy_each_view'; @@ -60,33 +38,34 @@ ViewUtils.isSimpleClick = isSimpleClick; ViewUtils.getViewClientRects = getViewClientRects; ViewUtils.getViewBoundingClientRect = getViewBoundingClientRect; +var reexport = Ember.__reexport; + if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - Ember.CoreView = DeprecatedCoreView; - Ember.View = DeprecatedView; - Ember.View.states = states; - Ember.View.cloneStates = cloneStates; - Ember.View._Renderer = Renderer; - Ember.ContainerView = DeprecatedContainerView; - Ember.CollectionView = CollectionView; + reexport('ember-views/views/core_view', [['DeprecatedCoreView', 'CoreView']]); + reexport('ember-views/views/view', [['DeprecatedView', 'View']]); + reexport('ember-views/views/states', 'Ember.View', ['states', 'cloneStates']); + reexport('ember-metal-views/renderer', 'Ember.View', [['default', '_Renderer']]); + reexport('ember-views/views/container_view', 'ContainerView'); + reexport('ember-views/views/collection_view', 'CollectionView'); } -Ember._Renderer = Renderer; - -Ember.Checkbox = Checkbox; -Ember.TextField = TextField; -Ember.TextArea = TextArea; +reexport('ember-views/views/checkbox', 'Checkbox'); +reexport('ember-views/views/text_field', 'TextField'); +reexport('ember-views/views/text_area', 'TextArea'); if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - Ember.Select = Select; + reexport('ember-views/views/select', 'Select'); } -Ember.SelectOption = SelectOption; -Ember.SelectOptgroup = SelectOptgroup; +reexport('ember-views/views/select', [ + 'SelectOption', + 'SelectOptgroup' +]); -Ember.TextSupport = TextSupport; -Ember.ComponentLookup = ComponentLookup; -Ember.Component = Component; -Ember.EventDispatcher = EventDispatcher; +reexport('ember-views/mixins/text_support', 'TextSupport'); +reexport('ember-views/component_lookup', 'ComponentLookup'); +reexport('ember-views/views/component', 'Component'); +reexport('ember-views/system/event_dispatcher', 'EventDispatcher'); // Deprecated: if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { From b2eaed62475796aeba3e06cb87555562d17ffd69 Mon Sep 17 00:00:00 2001 From: "David J. Hamilton" Date: Sat, 27 Jun 2015 21:05:35 -0700 Subject: [PATCH 4/8] more rexport --- packages/ember-metal/lib/main.js | 208 ++++++++--------------------- packages/ember-routing/lib/main.js | 38 ++---- 2 files changed, 69 insertions(+), 177 deletions(-) diff --git a/packages/ember-metal/lib/main.js b/packages/ember-metal/lib/main.js index 875e695370d..51d9dc9cb43 100644 --- a/packages/ember-metal/lib/main.js +++ b/packages/ember-metal/lib/main.js @@ -16,117 +16,31 @@ import { } from 'ember-metal/instrumentation'; import Cache from 'ember-metal/cache'; -import { - accumulateListeners, - addListener, - hasListeners, - listenersFor, - on, - removeListener, - sendEvent, - suspendListener, - suspendListeners, - watchedEvents -} from 'ember-metal/events'; - -import ObserverSet from 'ember-metal/observer_set'; - -import { - beginPropertyChanges, - changeProperties, - endPropertyChanges, - overrideChains, - propertyDidChange, - propertyWillChange -} from 'ember-metal/property_events'; - -import { - defineProperty -} from 'ember-metal/properties'; -import { - set, - trySet -} from 'ember-metal/property_set'; - -import { - Map, - MapWithDefault, - OrderedSet -} from 'ember-metal/map'; -import getProperties from 'ember-metal/get_properties'; -import setProperties from 'ember-metal/set_properties'; -import { - watchKey, - unwatchKey -} from 'ember-metal/watch_key'; -import { - ChainNode, - finishChains, - flushPendingChains, - removeChainWatcher -} from 'ember-metal/chains'; -import { - watchPath, - unwatchPath -} from 'ember-metal/watch_path'; -import { - destroy, - isWatching, - rewatch, - unwatch, - watch -} from 'ember-metal/watching'; -import expandProperties from 'ember-metal/expand_properties'; -import { - ComputedProperty, - computed, - cacheFor -} from 'ember-metal/computed'; +var reexport = Ember.__reexport; -import alias from 'ember-metal/alias'; -import { - empty, - notEmpty, - none, - not, - bool, - match, - equal, - gt, - gte, - lt, - lte, - oneWay as computedOneWay, - readOnly, - defaultTo, - deprecatingAlias, - and, - or, - any, - collect -} from 'ember-metal/computed_macros'; - -computed.empty = empty; -computed.notEmpty = notEmpty; -computed.none = none; -computed.not = not; -computed.bool = bool; -computed.match = match; -computed.equal = equal; -computed.gt = gt; -computed.gte = gte; -computed.lt = lt; -computed.lte = lte; -computed.alias = alias; -computed.oneWay = computedOneWay; -computed.reads = computedOneWay; -computed.readOnly = readOnly; -computed.defaultTo = defaultTo; -computed.deprecatingAlias = deprecatingAlias; -computed.and = and; -computed.or = or; -computed.any = any; -computed.collect = collect; +reexport('ember-metal/computed', 'computed'); +reexport('ember-metal/computed_macros', 'computed', [ + 'empty', + 'notEmpty', + 'none', + 'not', + 'bool', + 'match', + 'equal', + 'gt', + 'gte', + 'lt', + 'lte', + 'computedOneWay', + 'readOnly', + 'defaultTo', + 'deprecatingAlias', + 'and', + 'or', + 'any', + 'collect' +]); +reexport('ember-metal/alias', 'computed', 'alias'); import { _suspendObserver, @@ -198,60 +112,50 @@ reexport('ember-metal/utils', [ reexport('ember-metal/logger', [['default', 'Logger']]); reexport('ember-metal/property_get', ['get', '_getPath', 'getWithDefault', 'normalizeTuple']); -Ember.on = on; -Ember.addListener = addListener; -Ember.removeListener = removeListener; -Ember._suspendListener = suspendListener; -Ember._suspendListeners = suspendListeners; -Ember.sendEvent = sendEvent; -Ember.hasListeners = hasListeners; -Ember.watchedEvents = watchedEvents; -Ember.listenersFor = listenersFor; -Ember.accumulateListeners = accumulateListeners; +reexport('ember-metal/events', [ + 'on', + 'addListener', + 'removeListener', + 'suspendListener', + 'suspendListeners', + 'sendEvent', + 'hasListeners', + 'watchedEvents', + 'listenersFor', + 'accumulateListeners' +]); -Ember._ObserverSet = ObserverSet; +reexport('ember-metal/observer_set', [['default', '_ObserverSet']]); -Ember.propertyWillChange = propertyWillChange; -Ember.propertyDidChange = propertyDidChange; -Ember.overrideChains = overrideChains; -Ember.beginPropertyChanges = beginPropertyChanges; -Ember.endPropertyChanges = endPropertyChanges; -Ember.changeProperties = changeProperties; +reexport('ember-metal/property_events', [ + 'propertyWillChange', + 'propertyDidChange', + 'overrideChains', + 'beginPropertyChanges', + 'endPropertyChanges', + 'changeProperties' +]); -Ember.defineProperty = defineProperty; +reexport('ember-metal/properties', ['defineProperty']); -Ember.set = set; -Ember.trySet = trySet; +reexport('ember-metal/property_set', ['set', 'trySet']); -Ember.OrderedSet = OrderedSet; -Ember.Map = Map; -Ember.MapWithDefault = MapWithDefault; +reexport('ember-metal/map', ['OrderedSet', 'Map', 'MapWithDefault']); -Ember.getProperties = getProperties; -Ember.setProperties = setProperties; +reexport('ember-metal/get_properties', 'getProperties'); +reexport('ember-metal/set_properties', 'setProperties'); -Ember.watchKey = watchKey; -Ember.unwatchKey = unwatchKey; +reexport('ember-metal/watch_key', ['watchKey', 'unwatchKey']); -Ember.flushPendingChains = flushPendingChains; -Ember.removeChainWatcher = removeChainWatcher; -Ember._ChainNode = ChainNode; -Ember.finishChains = finishChains; +reexport('ember-metal/chains', ['flushPendingChains', 'removeChainWatcher', ['_ChainNode', 'ChainNode'], 'finishChains']); -Ember.watchPath = watchPath; -Ember.unwatchPath = unwatchPath; +reexport('ember-metal/watch_path', ['watchPath', 'unwatchPath']); -Ember.watch = watch; -Ember.isWatching = isWatching; -Ember.unwatch = unwatch; -Ember.rewatch = rewatch; -Ember.destroy = destroy; +reexport('ember-metal/watching', ['watch', 'isWatching', 'unwatch', 'rewatch', 'destroy']); -Ember.expandProperties = expandProperties; +reexport('ember-metal/expand_properties', 'expandProperties'); -Ember.ComputedProperty = ComputedProperty; -Ember.computed = computed; -Ember.cacheFor = cacheFor; +reexport('ember-metal/computed', ['ComputedProperty', 'cacheFor']); Ember.addObserver = addObserver; Ember.observersFor = observersFor; diff --git a/packages/ember-routing/lib/main.js b/packages/ember-routing/lib/main.js index eb01dca34e8..fc543978b64 100644 --- a/packages/ember-routing/lib/main.js +++ b/packages/ember-routing/lib/main.js @@ -8,33 +8,21 @@ import Ember from 'ember-metal/core'; // ES6TODO: Cleanup modules with side-effects below import 'ember-routing/ext/run_loop'; import 'ember-routing/ext/controller'; +import 'ember-routing/initializers/routing-service'; -import EmberLocation from 'ember-routing/location/api'; -import NoneLocation from 'ember-routing/location/none_location'; -import HashLocation from 'ember-routing/location/hash_location'; -import HistoryLocation from 'ember-routing/location/history_location'; -import AutoLocation from 'ember-routing/location/auto_location'; +var reexport = Ember.__reexport; -import generateController from 'ember-routing/system/generate_controller'; -import { - generateControllerFactory -} from 'ember-routing/system/generate_controller'; -import controllerFor from 'ember-routing/system/controller_for'; -import RouterDSL from 'ember-routing/system/dsl'; -import Router from 'ember-routing/system/router'; -import Route from 'ember-routing/system/route'; +reexport('ember-routing/location/api', [['default', 'Location']]); +reexport('ember-routing/location/auto_location', [['default', 'AutoLocation']]); +reexport('ember-routing/location/hash_location', [['default', 'HashLocation']]); +reexport('ember-routing/location/history_location', [['default', 'HistoryLocation']]); +reexport('ember-routing/location/none_location', [['default', 'NoneLocation']]); -Ember.Location = EmberLocation; -Ember.AutoLocation = AutoLocation; -Ember.HashLocation = HashLocation; -Ember.HistoryLocation = HistoryLocation; -Ember.NoneLocation = NoneLocation; - -Ember.controllerFor = controllerFor; -Ember.generateControllerFactory = generateControllerFactory; -Ember.generateController = generateController; -Ember.RouterDSL = RouterDSL; -Ember.Router = Router; -Ember.Route = Route; +reexport('ember-routing/system/controller_for', 'controllerFor'); +reexport('ember-routing/system/generate_controller', ['generateControllerFactory']); +reexport('ember-routing/system/generate_controller', 'generateController'); +reexport('ember-routing/system/dsl', 'RouterDSL'); +reexport('ember-routing/system/router', 'Router'); +reexport('ember-routing/system/route', 'Route'); export default Ember; From b01a5b4e6abc9f9ab852a315be198f22d899e01d Mon Sep 17 00:00:00 2001 From: Stefan Penner Date: Sun, 28 Jun 2015 13:15:11 -0700 Subject: [PATCH 5/8] =?UTF-8?q?play=20with=20making=20more=20things=20lazy?= =?UTF-8?q?.=20HTMLBars=20stuff=20still=20is=20quite=20costly=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 4 +- packages/container/lib/main.js | 6 +- packages/ember-application/lib/main.js | 16 +- .../lib/system/application.js | 109 ++++++----- packages/ember-extension-support/lib/main.js | 8 +- .../ember-htmlbars/lib/system/bootstrap.js | 23 ++- packages/ember-metal-views/lib/main.js | 3 +- packages/ember-metal/lib/computed.js | 23 +++ packages/ember-metal/lib/core.js | 24 +-- packages/ember-metal/lib/inspect.js | 41 +++++ packages/ember-metal/lib/main.js | 171 +++++++++--------- packages/ember-routing-views/lib/main.js | 13 +- packages/ember-runtime/lib/ext/function.js | 18 +- packages/ember-runtime/lib/ext/rsvp.js | 14 +- packages/ember-runtime/lib/main.js | 15 +- .../ember-runtime/lib/system/lazy_load.js | 9 +- packages/ember-runtime/lib/system/string.js | 12 +- packages/ember-views/lib/main.js | 41 ++--- 18 files changed, 305 insertions(+), 245 deletions(-) create mode 100644 packages/ember-metal/lib/inspect.js diff --git a/index.html b/index.html index 198aacc69dc..ea5bcc1a784 100644 --- a/index.html +++ b/index.html @@ -13,8 +13,8 @@ writeTime("jquery:" + (new Date() - jqueryStart)); var emberStart = new Date(); - - diff --git a/packages/container/lib/main.js b/packages/container/lib/main.js index f80c8bdacc1..2a456b412f8 100644 --- a/packages/container/lib/main.js +++ b/packages/container/lib/main.js @@ -18,7 +18,5 @@ if (Ember.ENV && typeof Ember.ENV.MODEL_FACTORY_INJECTIONS !== 'undefined') { Ember.MODEL_FACTORY_INJECTIONS = !!Ember.ENV.MODEL_FACTORY_INJECTIONS; } -import Registry from 'container/registry'; -import Container from 'container/container'; - -export { Registry, Container }; +export { default as Registry } from 'container/registry'; +export { default as Container } from 'container/container'; diff --git a/packages/ember-application/lib/main.js b/packages/ember-application/lib/main.js index ba7379c31fe..7b2436c1b3d 100644 --- a/packages/ember-application/lib/main.js +++ b/packages/ember-application/lib/main.js @@ -1,20 +1,24 @@ import Ember from 'ember-metal/core'; -import { runLoadHooks } from 'ember-runtime/system/lazy_load'; /** @module ember @submodule ember-application */ +<<<<<<< HEAD import DefaultResolver from 'ember-application/system/resolver'; import { Resolver } from 'ember-application/system/resolver'; import Application from 'ember-application/system/application'; +======= +Ember.onLoad('Ember.Application', function() { + Ember.__loader.require('ember-application/ext/controller'); +}); +>>>>>>> play with making more things lazy. HTMLBars stuff still is quite costly… -Ember.Application = Application; -Ember.Resolver = Resolver; -Ember.DefaultResolver = DefaultResolver; +var reexport = Ember.__reexport; - -runLoadHooks('Ember.Application', Application); +reexport('ember-application/system/application', 'Application'); +reexport('ember-application/system/resolver', ['Resolver']); +reexport('ember-application/system/resolver', 'DefaultResolver'); diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index 7329cbd1776..d28ca764df9 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -3,7 +3,6 @@ @submodule ember-application */ import DAG from 'dag-map'; -import Registry from 'container/registry'; import Ember from 'ember-metal'; // Ember.libraries, LOG_VERSION, Namespace, BOOTED import { assert, deprecate, debug } from 'ember-metal/debug'; @@ -13,36 +12,13 @@ import { set } from 'ember-metal/property_set'; import EmptyObject from 'ember-metal/empty_object'; import { runLoadHooks } from 'ember-runtime/system/lazy_load'; import Namespace from 'ember-runtime/system/namespace'; -import DefaultResolver from 'ember-application/system/resolver'; -import run from 'ember-metal/run_loop'; -import { canInvoke } from 'ember-metal/utils'; -import Controller from 'ember-runtime/controllers/controller'; -import Renderer from 'ember-metal-views/renderer'; -import DOMHelper from 'ember-htmlbars/system/dom-helper'; -import SelectView from 'ember-views/views/select'; -import { OutletView } from 'ember-routing-views/views/outlet'; -import EmberView from 'ember-views/views/view'; -import EventDispatcher from 'ember-views/system/event_dispatcher'; -import jQuery from 'ember-views/system/jquery'; -import Route from 'ember-routing/system/route'; -import Router from 'ember-routing/system/router'; -import HashLocation from 'ember-routing/location/hash_location'; -import HistoryLocation from 'ember-routing/location/history_location'; -import AutoLocation from 'ember-routing/location/auto_location'; -import NoneLocation from 'ember-routing/location/none_location'; -import BucketCache from 'ember-routing/system/cache'; -import ApplicationInstance from 'ember-application/system/application-instance'; -import TextField from 'ember-views/views/text_field'; -import TextArea from 'ember-views/views/text_area'; -import Checkbox from 'ember-views/views/checkbox'; -import LegacyEachView from 'ember-views/views/legacy_each_view'; -import LinkToComponent from 'ember-routing-views/components/link-to'; -import RoutingService from 'ember-routing/services/routing'; -import ContainerDebugAdapter from 'ember-extension-support/container_debug_adapter'; -import { _loaded } from 'ember-runtime/system/lazy_load'; -import RegistryProxy, { buildFakeRegistryWithDeprecations } from 'ember-runtime/mixins/registry_proxy'; + import environment from 'ember-metal/environment'; +function require(path, key = 'default') { + return Ember.__loader.require(path)[key]; +} + function props(obj) { var properties = []; @@ -308,8 +284,9 @@ var Application = Namespace.extend(RegistryProxy, { init() { this._super(...arguments); + this._run = require('ember-metal/run_loop'); if (!this.$) { - this.$ = jQuery; + this.$ = require('ember-views/system/jquery'); } this.buildRegistry(); @@ -318,9 +295,10 @@ var Application = Namespace.extend(RegistryProxy, { logLibraryVersions(); // Start off the number of deferrals at 1. This will be - // decremented by the Application's own `initialize` method. + // decremented by the Application's own `unitialize` method. this._readinessDeferrals = 1; + var Router = require('ember-routing/system/router'); if (isEnabled('ember-application-visit')) { if (this.autoboot) { // Create subclass of Ember.Router for this Application instance. @@ -359,6 +337,7 @@ var Application = Namespace.extend(RegistryProxy, { @return {Ember.Container} the configured container */ buildInstance() { + var ApplicationInstance = require('ember-application/system/application-instance'); return ApplicationInstance.create({ application: this }); @@ -367,6 +346,7 @@ var Application = Namespace.extend(RegistryProxy, { buildDefaultInstance() { var instance = this.buildInstance(); + var EmberView = require('ember-views/views/view'); // For the default instance only, set the view registry to the global // Ember.View.views hash for backwards-compatibility. EmberView.views = instance.lookup('-view-registry:main'); @@ -398,9 +378,9 @@ var Application = Namespace.extend(RegistryProxy, { */ waitForDOMReady() { if (!this.$ || this.$.isReady) { - run.schedule('actions', this, 'domReady'); + this._run.schedule('actions', this, 'domReady'); } else { - this.$().ready(run.bind(this, 'domReady')); + this.$().ready(this._run.bind(this, 'domReady')); } }, @@ -450,7 +430,7 @@ var Application = Namespace.extend(RegistryProxy, { this._readinessDeferrals--; if (this._readinessDeferrals === 0) { - run.once(this, this.didBecomeReady); + this._run.once(this, this.didBecomeReady); } }, @@ -576,6 +556,7 @@ var Application = Namespace.extend(RegistryProxy, { this._readinessDeferrals = 1; this._bootPromise = null; this._bootResolver = null; + var run = this._run; function handleReset() { run(instance, 'destroy'); @@ -977,6 +958,7 @@ Application.reopenClass({ @public */ buildRegistry(namespace) { + var Registry = require('container/registry'); var registry = new Registry(); registry.set = set; @@ -991,51 +973,57 @@ Application.reopenClass({ registry.register('application:main', namespace, { instantiate: false }); - registry.register('controller:basic', Controller, { instantiate: false }); + registry.register('controller:basic', require('ember-runtime/controllers/controller'), { instantiate: false }); + registry.register('controller:object', require('ember-runtime/controllers/object_controller'), { instantiate: false }); + registry.register('controller:array', require('ember-runtime/controllers/array_controller'), { instantiate: false }); - registry.register('renderer:-dom', { create() { return new Renderer(new DOMHelper()); } }); + registry.register('renderer:-dom', { + create() { + var Renderer = require('ember-metal-views/renderer'); + var DOMHelper = require('ember-htmlbars/system/dom-helper'); + + return new Renderer(new DOMHelper()); + } + }); registry.injection('view', 'renderer', 'renderer:-dom'); - if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - registry.register('view:select', SelectView); - } - registry.register('view:-outlet', OutletView); + registry.register('view:select', require('ember-views/views/select')); + registry.register('view:-outlet', require('ember-routing-views/views/outlet', 'OutletView')); registry.register('-view-registry:main', { create() { return {}; } }); registry.injection('view', '_viewRegistry', '-view-registry:main'); - registry.register('view:toplevel', EmberView.extend()); + registry.register('view:toplevel', require('ember-views/views/view')); - registry.register('route:basic', Route, { instantiate: false }); - registry.register('event_dispatcher:main', EventDispatcher); + registry.register('route:basic', require('ember-routing/system/route'), { instantiate: false }); + registry.register('event_dispatcher:main', require('ember-views/system/event_dispatcher')); registry.injection('router:main', 'namespace', 'application:main'); registry.injection('view:-outlet', 'namespace', 'application:main'); - registry.register('location:auto', AutoLocation); - registry.register('location:hash', HashLocation); - registry.register('location:history', HistoryLocation); - registry.register('location:none', NoneLocation); + registry.register('location:auto', require('ember-routing/location/auto_location')); + registry.register('location:hash', require('ember-routing/location/hash_location')); + registry.register('location:history', require('ember-routing/location/history_location')); + registry.register('location:none', require('ember-routing/location/none_location')); registry.injection('controller', 'target', 'router:main'); registry.injection('controller', 'namespace', 'application:main'); - - registry.register('-bucket-cache:main', BucketCache); + registry.register('-bucket-cache:main', require('ember-routing/system/cache')); registry.injection('router', '_bucketCache', '-bucket-cache:main'); registry.injection('route', '_bucketCache', '-bucket-cache:main'); registry.injection('controller', '_bucketCache', '-bucket-cache:main'); registry.injection('route', 'router', 'router:main'); - registry.register('component:-text-field', TextField); - registry.register('component:-text-area', TextArea); - registry.register('component:-checkbox', Checkbox); - registry.register('view:-legacy-each', LegacyEachView); - registry.register('component:link-to', LinkToComponent); + registry.register('component:-text-field', require('ember-views/views/text_field')); + registry.register('component:-text-area', require('ember-views/views/text_area')); + registry.register('component:-checkbox', require('ember-views/views/checkbox')); + registry.register('view:-legacy-each', require('ember-views/views/legacy_each_view')); + registry.register('component:-link-to', require('ember-routing-views/views/link')); // Register the routing service... - registry.register('service:-routing', RoutingService); + registry.register('service:-routing', require('ember-routing/services/routing')); // Then inject the app router into it registry.injection('service:-routing', 'router', 'router:main'); @@ -1045,7 +1033,7 @@ Application.reopenClass({ registry.injection('data-adapter:main', 'containerDebugAdapter', 'container-debug-adapter:main'); // Custom resolver authors may want to register their own ContainerDebugAdapter with this key - registry.register('container-debug-adapter:main', ContainerDebugAdapter); + registry.register('container-debug-adapter:main', require('ember-extension-support/container_debug_adapter')); return registry; } @@ -1068,7 +1056,9 @@ Application.reopenClass({ @return {*} the resolved value for a given lookup */ function resolverFor(namespace) { - var ResolverClass = namespace.get('Resolver') || DefaultResolver; + Ember.deprecate('Application.resolver is deprecated in favor of Application.Resolver', !namespace.get('resolver')); + + var ResolverClass = namespace.get('resolver') || namespace.get('Resolver') || require('ember-application/system/resolver'); var resolver = ResolverClass.create({ namespace: namespace }); @@ -1109,7 +1099,7 @@ function registerLibraries() { librariesRegistered = true; if (environment.hasDOM) { - Ember.libraries.registerCoreLibrary('jQuery', jQuery().jquery); + Ember.libraries.registerCoreLibrary('jQuery'. require('ember-views/system/jquery')); } } } @@ -1147,6 +1137,7 @@ function buildInitializerMethod(bucketName, humanName) { attrs[bucketName] = Object.create(this[bucketName]); this.reopenClass(attrs); } + var canInvoke = require('ember-metal/utils', 'canInvoke'); assert('The ' + humanName + ' \'' + initializer.name + '\' has already been registered', !this[bucketName][initializer.name]); assert('An ' + humanName + ' cannot be registered without an initialize function', canInvoke(initializer, 'initialize')); @@ -1157,3 +1148,5 @@ function buildInitializerMethod(bucketName, humanName) { } export default Application; + +runLoadHooks('Ember.Application', Application); diff --git a/packages/ember-extension-support/lib/main.js b/packages/ember-extension-support/lib/main.js index aaa6008c5bd..e952c2a8c59 100644 --- a/packages/ember-extension-support/lib/main.js +++ b/packages/ember-extension-support/lib/main.js @@ -4,8 +4,8 @@ */ import Ember from 'ember-metal/core'; -import DataAdapter from 'ember-extension-support/data_adapter'; -import ContainerDebugAdapter from 'ember-extension-support/container_debug_adapter'; -Ember.DataAdapter = DataAdapter; -Ember.ContainerDebugAdapter = ContainerDebugAdapter; +var reexport = Ember.__reexport; + +reexport('ember-extension-support/data_adapter', 'DataAdapter'); +reexport('ember-extension-support/container_debug_adapter', 'ContainerDebugAdapter'); diff --git a/packages/ember-htmlbars/lib/system/bootstrap.js b/packages/ember-htmlbars/lib/system/bootstrap.js index 89bb889f694..64b8ba51d05 100644 --- a/packages/ember-htmlbars/lib/system/bootstrap.js +++ b/packages/ember-htmlbars/lib/system/bootstrap.js @@ -6,12 +6,11 @@ */ import Ember from 'ember-metal/core'; -import ComponentLookup from 'ember-views/component_lookup'; -import jQuery from 'ember-views/system/jquery'; -import EmberError from 'ember-metal/error'; import { onLoad } from 'ember-runtime/system/lazy_load'; -import htmlbarsCompile from 'ember-template-compiler/system/compile'; -import environment from 'ember-metal/environment'; + +function require(path, name = 'default') { + return Ember.__loader.require(path)[name]; +} /** @module ember @@ -37,6 +36,7 @@ import environment from 'ember-metal/environment'; function bootstrap(ctx) { var selectors = 'script[type="text/x-handlebars"], script[type="text/x-raw-handlebars"]'; + var jQuery = require('ember-views/system/jquery')(document); jQuery(selectors, ctx) .each(function() { // Get a reference to the script tag @@ -52,11 +52,14 @@ function bootstrap(ctx) { compile = jQuery.proxy(Handlebars.compile, Handlebars); template = compile(script.html()); } else { + + var htmlbarsCompile = require('ember-template-compiler/system/compile'); template = htmlbarsCompile(script.html(), { moduleName: templateName }); } + var EmberError = require('ember-metal/error'); // Check if template of same name already exists if (Ember.TEMPLATES[templateName] !== undefined) { throw new EmberError('Template named "' + templateName + '" already exists.'); @@ -71,11 +74,11 @@ function bootstrap(ctx) { } function _bootstrap() { - bootstrap(jQuery(document)); + bootstrap(require('ember-views/system/jquery')(document)); } function registerComponentLookup(app) { - app.register('component-lookup:main', ComponentLookup); + app.registry.register('component-lookup:main', require('ember-views/component_lookupComponentLookup')); } /* @@ -90,12 +93,14 @@ function registerComponentLookup(app) { */ onLoad('Ember.Application', function(Application) { - Application.initializer({ + var environment = require('ember-metal/environment'); + + Ember.Application.initializer({ name: 'domTemplates', initialize: environment.hasDOM ? _bootstrap : function() { } }); - Application.instanceInitializer({ + Ember.Application.instanceInitializer({ name: 'registerComponentLookup', initialize: registerComponentLookup }); diff --git a/packages/ember-metal-views/lib/main.js b/packages/ember-metal-views/lib/main.js index c69b4fcf637..1dc412a9187 100755 --- a/packages/ember-metal-views/lib/main.js +++ b/packages/ember-metal-views/lib/main.js @@ -1,2 +1 @@ -import Renderer from 'ember-metal-views/renderer'; -export { Renderer }; +export { Renderer } from 'ember-metal-views/renderer'; diff --git a/packages/ember-metal/lib/computed.js b/packages/ember-metal/lib/computed.js index 59f333d4cc4..33d7ad26311 100644 --- a/packages/ember-metal/lib/computed.js +++ b/packages/ember-metal/lib/computed.js @@ -624,6 +624,29 @@ cacheFor.get = function(cache, key) { cacheFor.remove = function(cache, key) { cache[key] = undefined; }; +var reexport = Ember.__reexport; +reexport('ember-metal/computed_macros', 'computed', [ + 'empty', + 'notEmpty', + 'none', + 'not', + 'bool', + 'match', + 'equal', + 'gt', + 'gte', + 'lt', + 'lte', + 'computedOneWay', + 'readOnly', + 'defaultTo', + 'deprecatingAlias', + 'and', + 'or', + 'any', + 'collect' +]); +reexport('ember-metal/alias', 'computed', 'alias'); export { ComputedProperty, diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index c727998ebcd..deedddd8aa0 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -181,7 +181,6 @@ if ('undefined' === typeof Ember.deprecateFunc) { Ember.deprecateFunc = function(_, func) { return func; }; } -const CACHE = Object.create(null); function reexport(moduleName, exportsProperty, properties) { if (arguments.length === 2) { properties = exportsProperty; @@ -220,8 +219,9 @@ function reexport(moduleName, exportsProperty, properties) { properties = [['default', properties]]; } - properties.forEach((property) => { - let importAs, exportAs; + for (var i =0; i< properties.length; i++) { + var property = properties[i]; + var importAs, exportAs; if (Array.isArray(property)) { [importAs, exportAs] = property; @@ -229,22 +229,18 @@ function reexport(moduleName, exportsProperty, properties) { importAs = exportAs = property; } - Ember.assert(`Import exists ${moduleName}{${importAs}}`, typeof Ember.__loader.require(moduleName)[importAs] !== 'undefined'); + var exportObj = exportsProperty ? Ember[exportsProperty] : Ember; + //Ember.assert(`Do you really think Ember.${exportsProperty} exists? wtf`, typeof exportObj !== 'undefined'); + //Ember.assert(`Import exists ${moduleName}{${importAs}}`, typeof Ember.__loader.require(moduleName)[importAs] !== 'undefined'); + + //exportObj[exportAs] = Ember.__loader.require(moduleName)[importAs]; Object.defineProperty(exportObj, exportAs, { get() { - var key = moduleName + '_' + importAs; - if (CACHE[key]) { - return CACHE[key]; - } - return (CACHE[key] = Ember.__loader.require(moduleName)[importAs]); - }, - set(value) { - var key = moduleName + '_' + importAs; - return (CACHE[key] = value); + return (this[moduleName + '_' + importAs] = Ember.__loader.require(moduleName)[importAs]); } }); - }); + } } Ember.__reexport = reexport; diff --git a/packages/ember-metal/lib/inspect.js b/packages/ember-metal/lib/inspect.js new file mode 100644 index 00000000000..453bf922a17 --- /dev/null +++ b/packages/ember-metal/lib/inspect.js @@ -0,0 +1,41 @@ +var toString = Object.prototype.toString; + +export default function inspect(obj) { + if (obj === null) { + return 'null'; + } + if (obj === undefined) { + return 'undefined'; + } + if (Array.isArray(obj)) { + return '[' + obj + ']'; + } + // for non objects + var type = typeof obj; + if (type !== 'object' && type !== 'symbol') { + return ''+obj; + } + // overridden toString + if (typeof obj.toString === 'function' && obj.toString !== toString) { + return obj.toString(); + } + + // Object.prototype.toString === {}.toString + var v; + var ret = []; + for (var key in obj) { + if (obj.hasOwnProperty(key)) { + v = obj[key]; + if (v === 'toString') { continue; } // ignore useless items + if (typeof v === 'function') { v = 'function() { ... }'; } + + if (v && typeof v.toString !== 'function') { + ret.push(key + ': ' + toString.call(v)); + } else { + ret.push(key + ': ' + v); + } + } + } + return '{' + ret.join(', ') + '}'; +} + diff --git a/packages/ember-metal/lib/main.js b/packages/ember-metal/lib/main.js index 51d9dc9cb43..ebd6ca15b9f 100644 --- a/packages/ember-metal/lib/main.js +++ b/packages/ember-metal/lib/main.js @@ -7,7 +7,6 @@ import Ember from 'ember-metal/core'; import { deprecateFunc } from 'ember-metal/debug'; import isEnabled, { FEATURES } from 'ember-metal/features'; -import merge from 'ember-metal/merge'; import { instrument, reset as instrumentationReset, @@ -19,57 +18,7 @@ import Cache from 'ember-metal/cache'; var reexport = Ember.__reexport; reexport('ember-metal/computed', 'computed'); -reexport('ember-metal/computed_macros', 'computed', [ - 'empty', - 'notEmpty', - 'none', - 'not', - 'bool', - 'match', - 'equal', - 'gt', - 'gte', - 'lt', - 'lte', - 'computedOneWay', - 'readOnly', - 'defaultTo', - 'deprecatingAlias', - 'and', - 'or', - 'any', - 'collect' -]); -reexport('ember-metal/alias', 'computed', 'alias'); - -import { - _suspendObserver, - _suspendObservers, - addObserver, - observersFor, - removeObserver -} from 'ember-metal/observer'; -import { - IS_BINDING, - Mixin, - aliasMethod, - _immediateObserver, - mixin, - observer, - required -} from 'ember-metal/mixin'; -import { - Binding, - bind, - isGlobalPath -} from 'ember-metal/binding'; -import run from 'ember-metal/run_loop'; import Libraries from 'ember-metal/libraries'; -import isNone from 'ember-metal/is_none'; -import isEmpty from 'ember-metal/is_empty'; -import isBlank from 'ember-metal/is_blank'; -import isPresent from 'ember-metal/is_present'; -import Backburner from 'backburner'; // END IMPORTS @@ -138,64 +87,120 @@ reexport('ember-metal/property_events', [ reexport('ember-metal/properties', ['defineProperty']); -reexport('ember-metal/property_set', ['set', 'trySet']); +reexport('ember-metal/property_set', [ + 'set', + 'trySet' +]); -reexport('ember-metal/map', ['OrderedSet', 'Map', 'MapWithDefault']); +reexport('ember-metal/map', [ + 'OrderedSet', + 'Map', + 'MapWithDefault' +]); reexport('ember-metal/get_properties', 'getProperties'); reexport('ember-metal/set_properties', 'setProperties'); -reexport('ember-metal/watch_key', ['watchKey', 'unwatchKey']); +reexport('ember-metal/watch_key', [ + 'watchKey', + 'unwatchKey' +]); -reexport('ember-metal/chains', ['flushPendingChains', 'removeChainWatcher', ['_ChainNode', 'ChainNode'], 'finishChains']); +reexport('ember-metal/chains', [ + 'flushPendingChains', + 'removeChainWatcher', + ['_ChainNode', 'ChainNode'], + 'finishChains' +]); -reexport('ember-metal/watch_path', ['watchPath', 'unwatchPath']); +reexport('ember-metal/watch_path', [ + 'watchPath', + 'unwatchPath' +]); -reexport('ember-metal/watching', ['watch', 'isWatching', 'unwatch', 'rewatch', 'destroy']); +reexport('ember-metal/watching', [ + 'watch', + 'isWatching', + 'unwatch', + 'rewatch', + 'destroy' +]); reexport('ember-metal/expand_properties', 'expandProperties'); -reexport('ember-metal/computed', ['ComputedProperty', 'cacheFor']); - -Ember.addObserver = addObserver; -Ember.observersFor = observersFor; -Ember.removeObserver = removeObserver; -Ember._suspendObserver = _suspendObserver; -Ember._suspendObservers = _suspendObservers; +reexport('ember-metal/computed', [ + 'ComputedProperty', + 'cacheFor' +]); -Ember.IS_BINDING = IS_BINDING; -Ember.required = required; -Ember.aliasMethod = aliasMethod; -Ember.observer = observer; -Ember.immediateObserver = _immediateObserver; -Ember.mixin = mixin; -Ember.Mixin = Mixin; +reexport('ember-metal/observer', [ + 'addObserver', + 'observersFor', + 'removeObserver', + 'addBeforeObserver', + '_suspendBeforeObserver', + '_suspendBeforeObservers', + '_suspendObserver', + '_suspendObservers', + 'beforeObserversFor', + 'removeBeforeObserver' +]); -Ember.bind = bind; -Ember.Binding = Binding; -Ember.isGlobalPath = isGlobalPath; +reexport('ember-metal/mixin', [ + 'IS_BINDING', + 'required', + 'aliasMethod', + 'observer', + 'immediateObserver', + 'beforeObserver', + 'mixin', + 'Mixin' +]); -Ember.run = run; +reexport('ember-metal/binding', [ + 'oneWay', + 'bind', + 'Binding', + 'isGlobalPath' +]); /** @class Backburner @for Ember @private */ -Ember.Backburner = Backburner; +reexport('backburner', 'Backburner'); // this is the new go forward, once Ember Data updates to using `_Backburner` we // can remove the non-underscored version. -Ember._Backburner = Backburner; +reexport('backburner', '_Backburner'); Ember.libraries = new Libraries(); Ember.libraries.registerCoreLibrary('Ember', Ember.VERSION); -Ember.isNone = isNone; -Ember.isEmpty = isEmpty; -Ember.isBlank = isBlank; -Ember.isPresent = isPresent; - -Ember.merge = merge; +reexport('ember-metal/run_loop', 'run'); +reexport('ember-metal/is_none', 'isNone'); +reexport('ember-metal/is_empty', 'isEmpty'); +reexport('ember-metal/is_blank', 'isBlank'); +reexport('ember-metal/is_present', 'isPresent'); +reexport('ember-metal/merge', 'merge'); + +<<<<<<< HEAD +if (isEnabled('ember-metal-stream')) { + reexport('ember-metal/streams/stream', 'stream'); + reexport('ember-metal/streams/utils', 'stream', [ + 'Stream', + 'isStream', + 'subscribe', + 'unsubscribe', + 'read', + 'readHash', + 'readArray', + 'scanArray', + 'scanHash', + 'concat', + 'chain' + ]); +} Ember.FEATURES = FEATURES; Ember.FEATURES.isEnabled = isEnabled; diff --git a/packages/ember-routing-views/lib/main.js b/packages/ember-routing-views/lib/main.js index aeda1db2306..7cb56733c73 100644 --- a/packages/ember-routing-views/lib/main.js +++ b/packages/ember-routing-views/lib/main.js @@ -4,10 +4,15 @@ */ import Ember from 'ember-metal/core'; -import LinkComponent from 'ember-routing-views/components/link-to'; -import { OutletView } from 'ember-routing-views/views/outlet'; +import isEnabled from 'ember-metal/features'; -Ember.LinkComponent = LinkComponent; -Ember.OutletView = OutletView; +var reexport = Ember.__reexport; + +reexport('ember-routing-views/views/link', 'LinkComponent'); +reexport('ember-routing-views/views/outlet', ['OutletView']); + +if (isEnabled('ember-routing-core-outlet')) { + reexport('ember-routing-views/views/outlet', ['CoreOutletView']); +} export default Ember; diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index c89bf9abc0c..08fc4af06c7 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -3,10 +3,16 @@ @submodule ember-runtime */ -import Ember from 'ember-metal/core'; // Ember.EXTEND_PROTOTYPES -import { assert, deprecateFunc } from 'ember-metal/debug'; -import { computed } from 'ember-metal/computed'; -import { observer } from 'ember-metal/mixin'; +import Ember from 'ember-metal/core'; // Ember.EXTEND_PROTOTYPES, Ember.assert +import expandProperties from 'ember-metal/expand_properties'; + +function computed() { + return Ember.__loader.require('ember-metal/computed'); +} + +function observer() { + return Ember.__loader.require('ember-metal/observer'); +} var a_slice = Array.prototype.slice; var FunctionPrototype = Function.prototype; @@ -72,7 +78,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { @public */ FunctionPrototype.property = function () { - var ret = computed(this); + var ret = computed()(this); // ComputedProperty.prototype.property expands properties; no need for us to // do so here. return ret.property(...arguments); @@ -105,7 +111,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { */ FunctionPrototype.observes = function(...args) { args.push(this); - return observer.apply(this, args); + return observer().apply(this, args); }; diff --git a/packages/ember-runtime/lib/ext/rsvp.js b/packages/ember-runtime/lib/ext/rsvp.js index 493710e0353..7ec3413d5c5 100644 --- a/packages/ember-runtime/lib/ext/rsvp.js +++ b/packages/ember-runtime/lib/ext/rsvp.js @@ -1,11 +1,11 @@ /* globals RSVP:true */ import Ember from 'ember-metal/core'; -import { assert } from 'ember-metal/debug'; -import Logger from 'ember-metal/logger'; -import run from 'ember-metal/run_loop'; import * as RSVP from 'rsvp'; +function run() { + return Ember.__loader.require('ember-metal/run_loop'); +} var testModuleName = 'ember-testing/test'; var Test; @@ -22,11 +22,11 @@ var asyncEnd = function() { }; RSVP.configure('async', function(callback, promise) { - var async = !run.currentRunLoop; + var async = !run().currentRunLoop; if (Ember.testing && async) { asyncStart(); } - run.backburner.schedule('actions', function() { + run().backburner.schedule('actions', function() { if (Ember.testing && async) { asyncEnd(); } callback(promise); }); @@ -63,14 +63,14 @@ export function onerrorDefault(reason) { if (Test && Test.adapter) { Test.adapter.exception(error); - Logger.error(error.stack); + Ember.Logger.error(error.stack); } else { throw error; } } else if (Ember.onerror) { Ember.onerror(error); } else { - Logger.error(error.stack); + Ember.Logger.error(error.stack); } } } diff --git a/packages/ember-runtime/lib/main.js b/packages/ember-runtime/lib/main.js index 28c433ada89..7f1dac24f40 100644 --- a/packages/ember-runtime/lib/main.js +++ b/packages/ember-runtime/lib/main.js @@ -5,11 +5,8 @@ // BEGIN IMPORTS import Ember from 'ember-metal'; -import Controller from 'ember-runtime/controllers/controller'; -import ControllerMixin from 'ember-runtime/mixins/controller'; -import Service from 'ember-runtime/system/service'; -import RSVP from 'ember-runtime/ext/rsvp'; // just for side effect of extending Ember.RSVP +import RSVP from 'ember-runtime/ext/rsvp'; // just for side effect of extending Ember.RSVP import 'ember-runtime/ext/string'; // just for side effect of extending String.prototype import 'ember-runtime/ext/function'; // just for side effect of extending Function.prototype // END IMPORTS @@ -70,10 +67,12 @@ reexport('ember-runtime/system/native_array', 'NativeArray'); // Ember.A = A; reexport('ember-runtime/system/lazy_load', ['onLoad', 'runLoadHooks']); -Ember.Controller = Controller; -Ember.ControllerMixin = ControllerMixin; - -Ember.Service = Service; +reexport('ember-runtime/controllers/array_controller', 'ArrayController'); +reexport('ember-runtime/controllers/object_controller', 'ObjectController'); +reexport('ember-runtime/controllers/controller', 'Controller'); +reexport('ember-runtime/mixins/controller', 'ControllerMixin'); +reexport('ember-runtime/system/service', 'Service'); +reexport('ember-runtime/mixins/-proxy', '_ProxyMixin'); Ember.RSVP = RSVP; // END EXPORTS diff --git a/packages/ember-runtime/lib/system/lazy_load.js b/packages/ember-runtime/lib/system/lazy_load.js index 6de926c5069..b1ca0e2d5c4 100644 --- a/packages/ember-runtime/lib/system/lazy_load.js +++ b/packages/ember-runtime/lib/system/lazy_load.js @@ -1,7 +1,6 @@ /*globals CustomEvent */ import Ember from 'ember-metal/core'; // Ember.ENV.EMBER_LOAD_HOOKS -import 'ember-runtime/system/native_array'; // make sure Ember.A is setup. /** @module ember @@ -34,8 +33,8 @@ export var _loaded = loaded; export function onLoad(name, callback) { var object = loaded[name]; - loadHooks[name] = loadHooks[name] || Ember.A(); - loadHooks[name].pushObject(callback); + loadHooks[name] = loadHooks[name] || []; + loadHooks[name].push(callback); if (object) { callback(object); @@ -55,7 +54,9 @@ export function onLoad(name, callback) { export function runLoadHooks(name, object) { loaded[name] = object; - if (typeof window === 'object' && typeof window.dispatchEvent === 'function' && typeof CustomEvent === 'function') { + if (typeof window === 'object' && + typeof window.dispatchEvent === 'function' && + typeof CustomEvent === 'function') { var event = new CustomEvent(name, { detail: object, name: name }); window.dispatchEvent(event); } diff --git a/packages/ember-runtime/lib/system/string.js b/packages/ember-runtime/lib/system/string.js index 2b9f7952068..2f5e035bc1e 100644 --- a/packages/ember-runtime/lib/system/string.js +++ b/packages/ember-runtime/lib/system/string.js @@ -3,11 +3,7 @@ @submodule ember-runtime */ import Ember from 'ember-metal/core'; // Ember.STRINGS -import { deprecate } from 'ember-metal/debug'; -import { - inspect as emberInspect -} from 'ember-metal/utils'; -import { isArray } from 'ember-runtime/utils'; +import inspect from 'ember-metal/inspect'; import Cache from 'ember-metal/cache'; @@ -64,7 +60,7 @@ var DECAMELIZE_CACHE = new Cache(1000, function(str) { function _fmt(str, formats) { var cachedFormats = formats; - if (!isArray(cachedFormats) || arguments.length > 2) { + if (!Array.isArray(cachedFormats) || arguments.length > 2) { cachedFormats = new Array(arguments.length - 1); for (var i = 1, l = arguments.length; i < l; i++) { @@ -77,7 +73,7 @@ function _fmt(str, formats) { return str.replace(/%@([0-9]+)?/g, function(s, argIndex) { argIndex = (argIndex) ? parseInt(argIndex, 10) - 1 : idx++; s = cachedFormats[argIndex]; - return (s === null) ? '(null)' : (s === undefined) ? '' : emberInspect(s); + return (s === null) ? '(null)' : (s === undefined) ? '' : inspect(s); }); } @@ -91,7 +87,7 @@ function fmt(str, formats) { } function loc(str, formats) { - if (!isArray(formats) || arguments.length > 2) { + if (!Array.isArray(formats) || arguments.length > 2) { formats = Array.prototype.slice.call(arguments, 1); } diff --git a/packages/ember-views/lib/main.js b/packages/ember-views/lib/main.js index 308a760289b..402ae1c66b9 100644 --- a/packages/ember-views/lib/main.js +++ b/packages/ember-views/lib/main.js @@ -5,21 +5,10 @@ // BEGIN IMPORTS import Ember from 'ember-runtime'; -import jQuery from 'ember-views/system/jquery'; -import { - isSimpleClick, - getViewClientRects, - getViewBoundingClientRect -} from 'ember-views/system/utils'; -import 'ember-views/system/ext'; // for the side effect of extending Ember.run.queues - -import ViewTargetActionSupport from 'ember-views/mixins/view_target_action_support'; - -import _MetamorphView, { _Metamorph } from 'ember-views/compat/metamorph_view'; -import LegacyEachView from 'ember-views/views/legacy_each_view'; // END IMPORTS +var reexport = Ember.__reexport; /** Alias for jQuery @@ -27,18 +16,17 @@ import LegacyEachView from 'ember-views/views/legacy_each_view'; @for Ember @public */ +reexport('ember-views/system/jquery', '$'); -// BEGIN EXPORTS -Ember.$ = jQuery; - -Ember.ViewTargetActionSupport = ViewTargetActionSupport; +reexport('ember-views/mixins/view_target_action_support', 'ViewTargetActionSupport'); +reexport('ember-views/compat/render_buffer', 'RenderBuffer'); -var ViewUtils = Ember.ViewUtils = {}; -ViewUtils.isSimpleClick = isSimpleClick; -ViewUtils.getViewClientRects = getViewClientRects; -ViewUtils.getViewBoundingClientRect = getViewBoundingClientRect; - -var reexport = Ember.__reexport; +reexport('ember-views/system/utils', [ + 'isSimpleClick', + 'getViewClientRects', + 'getViewBoundingClientRect' +]); +Ember.ViewUtils = {}; if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { reexport('ember-views/views/core_view', [['DeprecatedCoreView', 'CoreView']]); @@ -69,11 +57,12 @@ reexport('ember-views/system/event_dispatcher', 'EventDispatcher'); // Deprecated: if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { - Ember._Metamorph = _Metamorph; - Ember._MetamorphView = _MetamorphView; - Ember._LegacyEachView = LegacyEachView; + reexport('ember-views/compat/metamorph_view', [ + ['default', '_MetamorphView'], + '_Metamorph' + ]); } -// END EXPORTS +reexport('ember-views/views/legacy_each_view', ['LegacyEachView', '_LegacyEachView']); export default Ember; From 18f1e4c5dfc0fb9d2a1f2bf36446ebf6a090eb2a Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 11 Sep 2015 14:19:43 -0700 Subject: [PATCH 6/8] Rebase --- packages/ember-application/lib/main.js | 8 -------- .../lib/system/application.js | 1 + packages/ember-metal/lib/core.js | 2 -- packages/ember-metal/lib/main.js | 18 ------------------ packages/ember-routing/lib/main.js | 2 +- packages/ember-runtime/lib/ext/function.js | 18 ++++++------------ packages/ember-runtime/lib/main.js | 2 -- 7 files changed, 8 insertions(+), 43 deletions(-) diff --git a/packages/ember-application/lib/main.js b/packages/ember-application/lib/main.js index 7b2436c1b3d..26d1741f9d3 100644 --- a/packages/ember-application/lib/main.js +++ b/packages/ember-application/lib/main.js @@ -5,17 +5,9 @@ import Ember from 'ember-metal/core'; @submodule ember-application */ -<<<<<<< HEAD -import DefaultResolver from 'ember-application/system/resolver'; -import { - Resolver -} from 'ember-application/system/resolver'; -import Application from 'ember-application/system/application'; -======= Ember.onLoad('Ember.Application', function() { Ember.__loader.require('ember-application/ext/controller'); }); ->>>>>>> play with making more things lazy. HTMLBars stuff still is quite costly… var reexport = Ember.__reexport; diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index d28ca764df9..e693a07b7e1 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -12,6 +12,7 @@ import { set } from 'ember-metal/property_set'; import EmptyObject from 'ember-metal/empty_object'; import { runLoadHooks } from 'ember-runtime/system/lazy_load'; import Namespace from 'ember-runtime/system/namespace'; +import RegistryProxy, { buildFakeRegistryWithDeprecations } from 'ember-runtime/mixins/registry_proxy'; import environment from 'ember-metal/environment'; diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index deedddd8aa0..661552abcb3 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -229,8 +229,6 @@ function reexport(moduleName, exportsProperty, properties) { importAs = exportAs = property; } - var exportObj = exportsProperty ? Ember[exportsProperty] : Ember; - //Ember.assert(`Do you really think Ember.${exportsProperty} exists? wtf`, typeof exportObj !== 'undefined'); //Ember.assert(`Import exists ${moduleName}{${importAs}}`, typeof Ember.__loader.require(moduleName)[importAs] !== 'undefined'); diff --git a/packages/ember-metal/lib/main.js b/packages/ember-metal/lib/main.js index ebd6ca15b9f..0ef59081741 100644 --- a/packages/ember-metal/lib/main.js +++ b/packages/ember-metal/lib/main.js @@ -184,24 +184,6 @@ reexport('ember-metal/is_blank', 'isBlank'); reexport('ember-metal/is_present', 'isPresent'); reexport('ember-metal/merge', 'merge'); -<<<<<<< HEAD -if (isEnabled('ember-metal-stream')) { - reexport('ember-metal/streams/stream', 'stream'); - reexport('ember-metal/streams/utils', 'stream', [ - 'Stream', - 'isStream', - 'subscribe', - 'unsubscribe', - 'read', - 'readHash', - 'readArray', - 'scanArray', - 'scanHash', - 'concat', - 'chain' - ]); -} - Ember.FEATURES = FEATURES; Ember.FEATURES.isEnabled = isEnabled; diff --git a/packages/ember-routing/lib/main.js b/packages/ember-routing/lib/main.js index fc543978b64..68e16d87e48 100644 --- a/packages/ember-routing/lib/main.js +++ b/packages/ember-routing/lib/main.js @@ -8,7 +8,7 @@ import Ember from 'ember-metal/core'; // ES6TODO: Cleanup modules with side-effects below import 'ember-routing/ext/run_loop'; import 'ember-routing/ext/controller'; -import 'ember-routing/initializers/routing-service'; +import 'ember-routing/services/routing'; var reexport = Ember.__reexport; diff --git a/packages/ember-runtime/lib/ext/function.js b/packages/ember-runtime/lib/ext/function.js index 08fc4af06c7..c89bf9abc0c 100644 --- a/packages/ember-runtime/lib/ext/function.js +++ b/packages/ember-runtime/lib/ext/function.js @@ -3,16 +3,10 @@ @submodule ember-runtime */ -import Ember from 'ember-metal/core'; // Ember.EXTEND_PROTOTYPES, Ember.assert -import expandProperties from 'ember-metal/expand_properties'; - -function computed() { - return Ember.__loader.require('ember-metal/computed'); -} - -function observer() { - return Ember.__loader.require('ember-metal/observer'); -} +import Ember from 'ember-metal/core'; // Ember.EXTEND_PROTOTYPES +import { assert, deprecateFunc } from 'ember-metal/debug'; +import { computed } from 'ember-metal/computed'; +import { observer } from 'ember-metal/mixin'; var a_slice = Array.prototype.slice; var FunctionPrototype = Function.prototype; @@ -78,7 +72,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { @public */ FunctionPrototype.property = function () { - var ret = computed()(this); + var ret = computed(this); // ComputedProperty.prototype.property expands properties; no need for us to // do so here. return ret.property(...arguments); @@ -111,7 +105,7 @@ if (Ember.EXTEND_PROTOTYPES === true || Ember.EXTEND_PROTOTYPES.Function) { */ FunctionPrototype.observes = function(...args) { args.push(this); - return observer().apply(this, args); + return observer.apply(this, args); }; diff --git a/packages/ember-runtime/lib/main.js b/packages/ember-runtime/lib/main.js index 7f1dac24f40..38973154927 100644 --- a/packages/ember-runtime/lib/main.js +++ b/packages/ember-runtime/lib/main.js @@ -33,7 +33,6 @@ reexport('ember-runtime/mixins/observable', 'Observable'); reexport('ember-runtime/mixins/-proxy', '_ProxyMixin'); reexport('ember-runtime/computed/array_computed', ['arrayComputed', 'ArrayComputedProperty']); reexport('ember-runtime/computed/reduce_computed', ['reduceComputed', 'ReduceComputedProperty']); -reexport('ember-runtime/utils', ['typeOf']); // ES6TODO: this seems a less than ideal way/place to add properties to Ember.computed reexport('ember-runtime/computed/reduce_computed_macros', 'computed', [ @@ -72,7 +71,6 @@ reexport('ember-runtime/controllers/object_controller', 'ObjectController'); reexport('ember-runtime/controllers/controller', 'Controller'); reexport('ember-runtime/mixins/controller', 'ControllerMixin'); reexport('ember-runtime/system/service', 'Service'); -reexport('ember-runtime/mixins/-proxy', '_ProxyMixin'); Ember.RSVP = RSVP; // END EXPORTS From e1b8e1085f38514ebd531ccb7f5b016416ebf0c9 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 11 Sep 2015 14:24:49 -0700 Subject: [PATCH 7/8] Remove legacy views --- packages/ember-views/lib/main.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/ember-views/lib/main.js b/packages/ember-views/lib/main.js index 402ae1c66b9..4f90ad9699c 100644 --- a/packages/ember-views/lib/main.js +++ b/packages/ember-views/lib/main.js @@ -17,15 +17,14 @@ var reexport = Ember.__reexport; @public */ reexport('ember-views/system/jquery', '$'); - reexport('ember-views/mixins/view_target_action_support', 'ViewTargetActionSupport'); reexport('ember-views/compat/render_buffer', 'RenderBuffer'); - reexport('ember-views/system/utils', [ 'isSimpleClick', 'getViewClientRects', 'getViewBoundingClientRect' ]); + Ember.ViewUtils = {}; if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { @@ -63,6 +62,4 @@ if (Ember.ENV._ENABLE_LEGACY_VIEW_SUPPORT) { ]); } -reexport('ember-views/views/legacy_each_view', ['LegacyEachView', '_LegacyEachView']); - export default Ember; From a4e9a9e3c29455b964d15254f18109296240c4a7 Mon Sep 17 00:00:00 2001 From: Chad Hietala Date: Fri, 11 Sep 2015 14:33:59 -0700 Subject: [PATCH 8/8] Fix JSCS and errors --- .../lib/system/application.js | 2 +- .../ember-htmlbars/lib/system/bootstrap.js | 1 - packages/ember-metal/lib/core.js | 2 +- packages/ember-metal/lib/inspect.js | 41 ------------------- packages/ember-runtime/lib/ext/rsvp.js | 1 + packages/ember-runtime/lib/system/string.js | 1 + 6 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 packages/ember-metal/lib/inspect.js diff --git a/packages/ember-application/lib/system/application.js b/packages/ember-application/lib/system/application.js index e693a07b7e1..f61b161b1d7 100644 --- a/packages/ember-application/lib/system/application.js +++ b/packages/ember-application/lib/system/application.js @@ -1100,7 +1100,7 @@ function registerLibraries() { librariesRegistered = true; if (environment.hasDOM) { - Ember.libraries.registerCoreLibrary('jQuery'. require('ember-views/system/jquery')); + Ember.libraries.registerCoreLibrary('jQuery', require('ember-views/system/jquery')); } } } diff --git a/packages/ember-htmlbars/lib/system/bootstrap.js b/packages/ember-htmlbars/lib/system/bootstrap.js index 64b8ba51d05..94ff9dcc37e 100644 --- a/packages/ember-htmlbars/lib/system/bootstrap.js +++ b/packages/ember-htmlbars/lib/system/bootstrap.js @@ -52,7 +52,6 @@ function bootstrap(ctx) { compile = jQuery.proxy(Handlebars.compile, Handlebars); template = compile(script.html()); } else { - var htmlbarsCompile = require('ember-template-compiler/system/compile'); template = htmlbarsCompile(script.html(), { moduleName: templateName diff --git a/packages/ember-metal/lib/core.js b/packages/ember-metal/lib/core.js index 661552abcb3..b16811281aa 100644 --- a/packages/ember-metal/lib/core.js +++ b/packages/ember-metal/lib/core.js @@ -219,7 +219,7 @@ function reexport(moduleName, exportsProperty, properties) { properties = [['default', properties]]; } - for (var i =0; i< properties.length; i++) { + for (var i = 0; i < properties.length; i++) { var property = properties[i]; var importAs, exportAs; diff --git a/packages/ember-metal/lib/inspect.js b/packages/ember-metal/lib/inspect.js deleted file mode 100644 index 453bf922a17..00000000000 --- a/packages/ember-metal/lib/inspect.js +++ /dev/null @@ -1,41 +0,0 @@ -var toString = Object.prototype.toString; - -export default function inspect(obj) { - if (obj === null) { - return 'null'; - } - if (obj === undefined) { - return 'undefined'; - } - if (Array.isArray(obj)) { - return '[' + obj + ']'; - } - // for non objects - var type = typeof obj; - if (type !== 'object' && type !== 'symbol') { - return ''+obj; - } - // overridden toString - if (typeof obj.toString === 'function' && obj.toString !== toString) { - return obj.toString(); - } - - // Object.prototype.toString === {}.toString - var v; - var ret = []; - for (var key in obj) { - if (obj.hasOwnProperty(key)) { - v = obj[key]; - if (v === 'toString') { continue; } // ignore useless items - if (typeof v === 'function') { v = 'function() { ... }'; } - - if (v && typeof v.toString !== 'function') { - ret.push(key + ': ' + toString.call(v)); - } else { - ret.push(key + ': ' + v); - } - } - } - return '{' + ret.join(', ') + '}'; -} - diff --git a/packages/ember-runtime/lib/ext/rsvp.js b/packages/ember-runtime/lib/ext/rsvp.js index 7ec3413d5c5..81a707e6a79 100644 --- a/packages/ember-runtime/lib/ext/rsvp.js +++ b/packages/ember-runtime/lib/ext/rsvp.js @@ -1,6 +1,7 @@ /* globals RSVP:true */ import Ember from 'ember-metal/core'; +import { assert } from 'ember-metal/debug'; import * as RSVP from 'rsvp'; function run() { diff --git a/packages/ember-runtime/lib/system/string.js b/packages/ember-runtime/lib/system/string.js index 2f5e035bc1e..4c589bdbca8 100644 --- a/packages/ember-runtime/lib/system/string.js +++ b/packages/ember-runtime/lib/system/string.js @@ -4,6 +4,7 @@ */ import Ember from 'ember-metal/core'; // Ember.STRINGS import inspect from 'ember-metal/inspect'; +import { deprecate } from 'ember-metal/debug'; import Cache from 'ember-metal/cache';