ember-source 5.11.0 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build-metadata.json +3 -3
- package/dist/ember-template-compiler.js +48 -42
- package/dist/ember-testing.js +1 -1
- package/dist/ember.debug.js +23102 -23100
- package/dist/ember.prod.js +31562 -31563
- package/dist/packages/@ember/-internals/container/index.js +1 -1
- package/dist/packages/@ember/-internals/deprecations/index.js +2 -1
- package/dist/packages/@ember/-internals/glimmer/index.js +2 -1
- package/dist/packages/@ember/-internals/meta/lib/meta.js +4 -3
- package/dist/packages/@ember/-internals/metal/index.js +9 -8
- package/dist/packages/@ember/-internals/routing/index.js +6 -5
- package/dist/packages/@ember/-internals/runtime/lib/ext/rsvp.js +3 -2
- package/dist/packages/@ember/-internals/runtime/lib/mixins/-proxy.js +6 -5
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +4 -3
- package/dist/packages/@ember/-internals/runtime/lib/mixins/container_proxy.js +1 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/registry_proxy.js +2 -1
- package/dist/packages/@ember/-internals/runtime/lib/mixins/target_action_support.js +4 -3
- package/dist/packages/@ember/-internals/string/index.js +1 -1
- package/dist/packages/@ember/-internals/utils/index.js +4 -4
- package/dist/packages/@ember/-internals/views/index.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/compat/fallback-view-registry.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/component_lookup.js +1 -1
- package/dist/packages/@ember/-internals/views/lib/mixins/action_support.js +5 -3
- package/dist/packages/@ember/-internals/views/lib/mixins/child_views_support.js +3 -3
- package/dist/packages/@ember/-internals/views/lib/mixins/class_names_support.js +4 -3
- package/dist/packages/@ember/-internals/views/lib/mixins/view_support.js +4 -3
- package/dist/packages/@ember/-internals/views/lib/system/event_dispatcher.js +6 -12
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +3 -2
- package/dist/packages/@ember/-internals/views/lib/views/core_view.js +76 -8
- package/dist/packages/@ember/-internals/views/lib/views/states.js +4 -3
- package/dist/packages/@ember/application/index.js +16 -7
- package/dist/packages/@ember/application/instance.js +13 -9
- package/dist/packages/@ember/application/namespace.js +7 -6
- package/dist/packages/@ember/array/index.js +617 -11
- package/dist/packages/@ember/array/make.js +1 -0
- package/dist/packages/@ember/array/mutable.js +1 -1
- package/dist/packages/@ember/array/proxy.js +8 -5
- package/dist/packages/@ember/component/helper.js +4 -4
- package/dist/packages/@ember/component/index.js +4 -4
- package/dist/packages/@ember/controller/index.js +6 -6
- package/dist/packages/@ember/debug/container-debug-adapter.js +5 -4
- package/dist/packages/@ember/debug/data-adapter.js +7 -4
- package/dist/packages/@ember/debug/index.js +213 -4
- package/dist/packages/@ember/debug/lib/assert.js +47 -0
- package/dist/packages/@ember/debug/lib/deprecate.js +194 -4
- package/dist/packages/@ember/debug/lib/inspect.js +120 -2
- package/dist/packages/@ember/debug/lib/warn.js +94 -3
- package/dist/packages/@ember/engine/index.js +440 -17
- package/dist/packages/@ember/engine/instance.js +175 -11
- package/dist/packages/@ember/engine/parent.js +1 -0
- package/dist/packages/@ember/helper/index.js +4 -4
- package/dist/packages/@ember/instrumentation/index.js +2 -1
- package/dist/packages/@ember/modifier/index.js +13 -5
- package/dist/packages/@ember/modifier/on.js +15 -0
- package/dist/packages/@ember/object/-internals.js +6 -5
- package/dist/packages/@ember/object/compat.js +4 -3
- package/dist/packages/@ember/object/computed.js +4 -4
- package/dist/packages/@ember/object/core.js +861 -14
- package/dist/packages/@ember/object/evented.js +4 -4
- package/dist/packages/@ember/object/events.js +3 -3
- package/dist/packages/@ember/object/index.js +260 -9
- package/dist/packages/@ember/object/internals.js +1 -1
- package/dist/packages/@ember/object/lib/computed/computed_macros.js +8 -6
- package/dist/packages/@ember/object/lib/computed/reduce_computed_macros.js +8 -4
- package/dist/packages/@ember/object/mixin.js +6 -5
- package/dist/packages/@ember/object/observable.js +103 -9
- package/dist/packages/@ember/object/observers.js +3 -3
- package/dist/packages/@ember/object/promise-proxy-mixin.js +5 -5
- package/dist/packages/@ember/renderer/index.js +4 -4
- package/dist/packages/@ember/routing/-internals.js +3 -1
- package/dist/packages/@ember/routing/hash-location.js +2 -2
- package/dist/packages/@ember/routing/history-location.js +3 -2
- package/dist/packages/@ember/routing/index.js +4 -4
- package/dist/packages/@ember/routing/lib/dsl.js +2 -1
- package/dist/packages/@ember/routing/lib/generate_controller.js +4 -3
- package/dist/packages/@ember/routing/lib/router_state.js +26 -1
- package/dist/packages/@ember/routing/lib/routing-service.js +107 -9
- package/dist/packages/@ember/routing/lib/utils.js +238 -7
- package/dist/packages/@ember/routing/none-location.js +3 -2
- package/dist/packages/@ember/routing/route.js +1618 -22
- package/dist/packages/@ember/routing/router-service.js +638 -12
- package/dist/packages/@ember/routing/router.js +1449 -14
- package/dist/packages/@ember/runloop/index.js +760 -6
- package/dist/packages/@ember/service/index.js +3 -3
- package/dist/packages/@ember/template/index.js +4 -4
- package/dist/packages/@ember/utils/index.js +2 -1
- package/dist/packages/@ember/utils/lib/compare.js +159 -4
- package/dist/packages/@ember/utils/lib/is_empty.js +4 -4
- package/dist/packages/@ember/utils/lib/type-of.js +110 -1
- package/dist/packages/@glimmer/tracking/index.js +3 -3
- package/dist/packages/@glimmer/tracking/primitives/cache.js +3 -3
- package/dist/packages/ember/barrel.js +28 -13
- package/dist/packages/ember/version.js +1 -1
- package/dist/packages/ember-testing/lib/adapters/adapter.js +1 -1
- package/dist/packages/ember-testing/lib/adapters/qunit.js +2 -1
- package/dist/packages/ember-testing/lib/ext/application.js +2 -1
- package/dist/packages/ember-testing/lib/ext/rsvp.js +1 -1
- package/dist/packages/ember-testing/lib/helpers/and_then.js +2 -1
- package/dist/packages/ember-testing/lib/helpers/current_path.js +8 -6
- package/dist/packages/ember-testing/lib/helpers/current_route_name.js +8 -6
- package/dist/packages/ember-testing/lib/helpers/current_url.js +6 -5
- package/dist/packages/ember-testing/lib/helpers/pause_test.js +2 -1
- package/dist/packages/ember-testing/lib/helpers/visit.js +4 -3
- package/dist/packages/ember-testing/lib/helpers/wait.js +4 -3
- package/dist/packages/ember-testing/lib/initializers.js +15 -8
- package/dist/packages/ember-testing/lib/setup_for_testing.js +1 -1
- package/dist/packages/ember-testing/lib/test/run.js +1 -1
- package/dist/packages/router_js/index.js +2 -1
- package/dist/packages/shared-chunks/{alias-By_2yu5c.js → alias-Dri0koi2.js} +5 -3
- package/dist/packages/shared-chunks/array-3xbmc_4J.js +119 -0
- package/dist/packages/shared-chunks/{cache-gDE3bkXq.js → cache-BESCGvbE.js} +667 -1529
- package/dist/packages/shared-chunks/{core_view-Cxne2_wu.js → chunk-3SQBS3Y5-Cj4eryg1.js} +1 -88
- package/dist/packages/shared-chunks/{index-BXPoca1S.js → index-Llq6dmgX.js} +40 -4660
- package/dist/packages/shared-chunks/{is_proxy-Dmis-70B.js → is_proxy-DjvCKvd5.js} +1 -1
- package/dist/packages/shared-chunks/{mandatory-setter-1UQhiJOb.js → mandatory-setter-BiXq-dpN.js} +2 -1
- package/dist/packages/shared-chunks/{name-z9D9Yibn.js → name-Dx2bGFVv.js} +1 -1
- package/dist/packages/shared-chunks/{namespace_search-CBgHTkDh.js → namespace_search-btMaPM-_.js} +2 -2
- package/dist/packages/shared-chunks/{property_set-CW4q-uo4.js → property_set-BapAkp3X.js} +5 -4
- package/dist/packages/shared-chunks/{registry-DzfcDwii.js → registry-B8WARvkP.js} +3 -2
- package/dist/packages/shared-chunks/{router-B-Q1aYBn.js → router-DrLZsJeE.js} +2 -482
- package/dist/packages/shared-chunks/{set_properties-DvalyQdu.js → set_properties-BScfxzvI.js} +2 -2
- package/dist/packages/shared-chunks/setup-registry-du4pSGZi.js +48 -0
- package/dist/packages/shared-chunks/{to-string-D8i3mjEU.js → to-string-B1BmwUkt.js} +1 -1
- package/dist/packages/shared-chunks/unrecognized-url-error-zpz-JEoG.js +484 -0
- package/docs/data.json +152 -142
- package/package.json +2 -2
- package/types/stable/@ember/-internals/metal/lib/array.d.ts +1 -2
- package/types/stable/@ember/-internals/metal/lib/object-at.d.ts +4 -0
- package/types/stable/@ember/-internals/metal/lib/observer.d.ts +2 -1
- package/types/stable/@ember/array/index.d.ts +1 -1
- package/types/stable/@ember/array/make.d.ts +3 -0
- package/types/stable/@ember/debug/index.d.ts +3 -7
- package/types/stable/@ember/debug/lib/assert.d.ts +8 -0
- package/types/stable/@ember/engine/index.d.ts +1 -1
- package/types/stable/@ember/engine/instance.d.ts +2 -2
- package/types/stable/@ember/engine/parent.d.ts +3 -0
- package/types/stable/@ember/modifier/index.d.ts +1 -3
- package/types/stable/@ember/modifier/on.d.ts +5 -0
- package/types/stable/@ember/routing/lib/routing-service.d.ts +1 -1
- package/types/stable/@ember/routing/route.d.ts +2 -3
- package/types/stable/@ember/routing/router-service.d.ts +1 -1
- package/types/stable/@ember/routing/router.d.ts +4 -4
- package/types/stable/ember/barrel.d.ts +1 -1
- package/types/stable/ember/index.d.ts +1 -1
- package/types/stable/index.d.ts +5 -0
- package/dist/packages/shared-chunks/index-DTxy4Zgx.js +0 -641
- package/dist/packages/shared-chunks/index-PYiGj1jp.js +0 -2071
|
@@ -1,37 +1,41 @@
|
|
|
1
1
|
export { getEngineParent, setEngineParent } from './lib/engine-parent.js';
|
|
2
|
-
import '../../shared-chunks/mandatory-setter-
|
|
3
|
-
import '@embroider/macros';
|
|
4
|
-
import '../../shared-chunks/invoke-BjRgvK2V.js';
|
|
5
|
-
import '../controller/index.js';
|
|
6
|
-
import '../application/namespace.js';
|
|
7
|
-
import '../../shared-chunks/registry-
|
|
8
|
-
import '../../dag-map/index.js';
|
|
9
|
-
import '
|
|
10
|
-
import '../debug/container-debug-adapter.js';
|
|
11
|
-
import '
|
|
12
|
-
|
|
2
|
+
import '../../shared-chunks/mandatory-setter-BiXq-dpN.js';
|
|
3
|
+
import { isDevelopingApp } from '@embroider/macros';
|
|
4
|
+
import { c as canInvoke } from '../../shared-chunks/invoke-BjRgvK2V.js';
|
|
5
|
+
import Controller from '../controller/index.js';
|
|
6
|
+
import Namespace from '../application/namespace.js';
|
|
7
|
+
import { R as Registry } from '../../shared-chunks/registry-B8WARvkP.js';
|
|
8
|
+
import DAG from '../../dag-map/index.js';
|
|
9
|
+
import '../debug/index.js';
|
|
10
|
+
import ContainerDebugAdapter from '../debug/container-debug-adapter.js';
|
|
11
|
+
import '../object/index.js';
|
|
12
|
+
import EngineInstance from './instance.js';
|
|
13
13
|
import '../-internals/meta/lib/meta.js';
|
|
14
14
|
import '../../@glimmer/destroyable/index.js';
|
|
15
15
|
import '../../@glimmer/validator/index.js';
|
|
16
|
-
import '../../shared-chunks/cache-gDE3bkXq.js';
|
|
17
16
|
import '../../@glimmer/manager/index.js';
|
|
18
|
-
import '../../shared-chunks/
|
|
17
|
+
import { g as get } from '../../shared-chunks/cache-BESCGvbE.js';
|
|
18
|
+
import { s as set } from '../../shared-chunks/property_set-BapAkp3X.js';
|
|
19
19
|
import '../../shared-chunks/env-BJLX2Arx.js';
|
|
20
20
|
import '../../route-recognizer/index.js';
|
|
21
21
|
import '../../shared-chunks/rsvp-DaQAFb0W.js';
|
|
22
|
-
import '../../shared-chunks/
|
|
22
|
+
import '../../shared-chunks/unrecognized-url-error-zpz-JEoG.js';
|
|
23
|
+
import RoutingService from '../routing/lib/routing-service.js';
|
|
23
24
|
import '../-internals/views/lib/system/action_manager.js';
|
|
24
|
-
import '../-internals/views/lib/component_lookup.js';
|
|
25
|
-
import '
|
|
25
|
+
import ComponentLookup from '../-internals/views/lib/component_lookup.js';
|
|
26
|
+
import '../-internals/views/lib/views/core_view.js';
|
|
26
27
|
import '../-internals/views/lib/mixins/class_names_support.js';
|
|
27
28
|
import '../-internals/views/lib/mixins/child_views_support.js';
|
|
28
29
|
import '../-internals/views/lib/mixins/view_state_support.js';
|
|
29
30
|
import '../-internals/views/lib/mixins/view_support.js';
|
|
30
31
|
import '../-internals/views/lib/mixins/action_support.js';
|
|
31
32
|
import '../../@glimmer/opcode-compiler/index.js';
|
|
33
|
+
import '../../shared-chunks/index-Llq6dmgX.js';
|
|
34
|
+
import { s as setupEngineRegistry } from '../../shared-chunks/setup-registry-du4pSGZi.js';
|
|
32
35
|
import '../../@glimmer/runtime/index.js';
|
|
36
|
+
import '../runloop/index.js';
|
|
33
37
|
import '../../@glimmer/reference/index.js';
|
|
34
|
-
import '../-internals/runtime/lib/mixins/registry_proxy.js';
|
|
38
|
+
import RegistryProxyMixin from '../-internals/runtime/lib/mixins/registry_proxy.js';
|
|
35
39
|
import '../-internals/runtime/lib/mixins/container_proxy.js';
|
|
36
40
|
import '../-internals/runtime/lib/mixins/comparable.js';
|
|
37
41
|
import '../-internals/runtime/lib/mixins/action_handler.js';
|
|
@@ -39,3 +43,422 @@ import '../-internals/runtime/lib/mixins/-proxy.js';
|
|
|
39
43
|
import '../enumerable/mutable.js';
|
|
40
44
|
import '../-internals/runtime/lib/mixins/target_action_support.js';
|
|
41
45
|
import '../-internals/runtime/lib/ext/rsvp.js';
|
|
46
|
+
import { assert } from '../debug/lib/assert.js';
|
|
47
|
+
|
|
48
|
+
function props(obj) {
|
|
49
|
+
let properties = [];
|
|
50
|
+
for (let key in obj) {
|
|
51
|
+
properties.push(key);
|
|
52
|
+
}
|
|
53
|
+
return properties;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
@module @ember/engine
|
|
58
|
+
*/
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
The `Engine` class contains core functionality for both applications and
|
|
62
|
+
engines.
|
|
63
|
+
|
|
64
|
+
Each engine manages a registry that's used for dependency injection and
|
|
65
|
+
exposed through `RegistryProxy`.
|
|
66
|
+
|
|
67
|
+
Engines also manage initializers and instance initializers.
|
|
68
|
+
|
|
69
|
+
Engines can spawn `EngineInstance` instances via `buildInstance()`.
|
|
70
|
+
|
|
71
|
+
@class Engine
|
|
72
|
+
@extends Ember.Namespace
|
|
73
|
+
@uses RegistryProxyMixin
|
|
74
|
+
@public
|
|
75
|
+
*/
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
77
|
+
|
|
78
|
+
class Engine extends Namespace.extend(RegistryProxyMixin) {
|
|
79
|
+
static initializers = Object.create(null);
|
|
80
|
+
static instanceInitializers = Object.create(null);
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
The goal of initializers should be to register dependencies and injections.
|
|
84
|
+
This phase runs once. Because these initializers may load code, they are
|
|
85
|
+
allowed to defer application readiness and advance it. If you need to access
|
|
86
|
+
the container or store you should use an InstanceInitializer that will be run
|
|
87
|
+
after all initializers and therefore after all code is loaded and the app is
|
|
88
|
+
ready.
|
|
89
|
+
Initializer receives an object which has the following attributes:
|
|
90
|
+
`name`, `before`, `after`, `initialize`. The only required attribute is
|
|
91
|
+
`initialize`, all others are optional.
|
|
92
|
+
* `name` allows you to specify under which name the initializer is registered.
|
|
93
|
+
This must be a unique name, as trying to register two initializers with the
|
|
94
|
+
same name will result in an error.
|
|
95
|
+
```app/initializer/named-initializer.js
|
|
96
|
+
import { debug } from '@ember/debug';
|
|
97
|
+
export function initialize() {
|
|
98
|
+
debug('Running namedInitializer!');
|
|
99
|
+
}
|
|
100
|
+
export default {
|
|
101
|
+
name: 'named-initializer',
|
|
102
|
+
initialize
|
|
103
|
+
};
|
|
104
|
+
```
|
|
105
|
+
* `before` and `after` are used to ensure that this initializer is ran prior
|
|
106
|
+
or after the one identified by the value. This value can be a single string
|
|
107
|
+
or an array of strings, referencing the `name` of other initializers.
|
|
108
|
+
An example of ordering initializers, we create an initializer named `first`:
|
|
109
|
+
```app/initializer/first.js
|
|
110
|
+
import { debug } from '@ember/debug';
|
|
111
|
+
export function initialize() {
|
|
112
|
+
debug('First initializer!');
|
|
113
|
+
}
|
|
114
|
+
export default {
|
|
115
|
+
name: 'first',
|
|
116
|
+
initialize
|
|
117
|
+
};
|
|
118
|
+
```
|
|
119
|
+
```bash
|
|
120
|
+
// DEBUG: First initializer!
|
|
121
|
+
```
|
|
122
|
+
We add another initializer named `second`, specifying that it should run
|
|
123
|
+
after the initializer named `first`:
|
|
124
|
+
```app/initializer/second.js
|
|
125
|
+
import { debug } from '@ember/debug';
|
|
126
|
+
export function initialize() {
|
|
127
|
+
debug('Second initializer!');
|
|
128
|
+
}
|
|
129
|
+
export default {
|
|
130
|
+
name: 'second',
|
|
131
|
+
after: 'first',
|
|
132
|
+
initialize
|
|
133
|
+
};
|
|
134
|
+
```
|
|
135
|
+
```
|
|
136
|
+
// DEBUG: First initializer!
|
|
137
|
+
// DEBUG: Second initializer!
|
|
138
|
+
```
|
|
139
|
+
Afterwards we add a further initializer named `pre`, this time specifying
|
|
140
|
+
that it should run before the initializer named `first`:
|
|
141
|
+
```app/initializer/pre.js
|
|
142
|
+
import { debug } from '@ember/debug';
|
|
143
|
+
export function initialize() {
|
|
144
|
+
debug('Pre initializer!');
|
|
145
|
+
}
|
|
146
|
+
export default {
|
|
147
|
+
name: 'pre',
|
|
148
|
+
before: 'first',
|
|
149
|
+
initialize
|
|
150
|
+
};
|
|
151
|
+
```
|
|
152
|
+
```bash
|
|
153
|
+
// DEBUG: Pre initializer!
|
|
154
|
+
// DEBUG: First initializer!
|
|
155
|
+
// DEBUG: Second initializer!
|
|
156
|
+
```
|
|
157
|
+
Finally we add an initializer named `post`, specifying it should run after
|
|
158
|
+
both the `first` and the `second` initializers:
|
|
159
|
+
```app/initializer/post.js
|
|
160
|
+
import { debug } from '@ember/debug';
|
|
161
|
+
export function initialize() {
|
|
162
|
+
debug('Post initializer!');
|
|
163
|
+
}
|
|
164
|
+
export default {
|
|
165
|
+
name: 'post',
|
|
166
|
+
after: ['first', 'second'],
|
|
167
|
+
initialize
|
|
168
|
+
};
|
|
169
|
+
```
|
|
170
|
+
```bash
|
|
171
|
+
// DEBUG: Pre initializer!
|
|
172
|
+
// DEBUG: First initializer!
|
|
173
|
+
// DEBUG: Second initializer!
|
|
174
|
+
// DEBUG: Post initializer!
|
|
175
|
+
```
|
|
176
|
+
* `initialize` is a callback function that receives one argument,
|
|
177
|
+
`application`, on which you can operate.
|
|
178
|
+
Example of using `application` to register an adapter:
|
|
179
|
+
```app/initializer/api-adapter.js
|
|
180
|
+
import ApiAdapter from '../utils/api-adapter';
|
|
181
|
+
export function initialize(application) {
|
|
182
|
+
application.register('api-adapter:main', ApiAdapter);
|
|
183
|
+
}
|
|
184
|
+
export default {
|
|
185
|
+
name: 'post',
|
|
186
|
+
after: ['first', 'second'],
|
|
187
|
+
initialize
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
@method initializer
|
|
191
|
+
@param initializer {Object}
|
|
192
|
+
@public
|
|
193
|
+
*/
|
|
194
|
+
|
|
195
|
+
static initializer = buildInitializerMethod('initializers', 'initializer');
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
Instance initializers run after all initializers have run. Because
|
|
199
|
+
instance initializers run after the app is fully set up. We have access
|
|
200
|
+
to the store, container, and other items. However, these initializers run
|
|
201
|
+
after code has loaded and are not allowed to defer readiness.
|
|
202
|
+
Instance initializer receives an object which has the following attributes:
|
|
203
|
+
`name`, `before`, `after`, `initialize`. The only required attribute is
|
|
204
|
+
`initialize`, all others are optional.
|
|
205
|
+
* `name` allows you to specify under which name the instanceInitializer is
|
|
206
|
+
registered. This must be a unique name, as trying to register two
|
|
207
|
+
instanceInitializer with the same name will result in an error.
|
|
208
|
+
```app/initializer/named-instance-initializer.js
|
|
209
|
+
import { debug } from '@ember/debug';
|
|
210
|
+
export function initialize() {
|
|
211
|
+
debug('Running named-instance-initializer!');
|
|
212
|
+
}
|
|
213
|
+
export default {
|
|
214
|
+
name: 'named-instance-initializer',
|
|
215
|
+
initialize
|
|
216
|
+
};
|
|
217
|
+
```
|
|
218
|
+
* `before` and `after` are used to ensure that this initializer is ran prior
|
|
219
|
+
or after the one identified by the value. This value can be a single string
|
|
220
|
+
or an array of strings, referencing the `name` of other initializers.
|
|
221
|
+
* See Application.initializer for discussion on the usage of before
|
|
222
|
+
and after.
|
|
223
|
+
Example instanceInitializer to preload data into the store.
|
|
224
|
+
```app/initializer/preload-data.js
|
|
225
|
+
export function initialize(application) {
|
|
226
|
+
var userConfig, userConfigEncoded, store;
|
|
227
|
+
// We have a HTML escaped JSON representation of the user's basic
|
|
228
|
+
// configuration generated server side and stored in the DOM of the main
|
|
229
|
+
// index.html file. This allows the app to have access to a set of data
|
|
230
|
+
// without making any additional remote calls. Good for basic data that is
|
|
231
|
+
// needed for immediate rendering of the page. Keep in mind, this data,
|
|
232
|
+
// like all local models and data can be manipulated by the user, so it
|
|
233
|
+
// should not be relied upon for security or authorization.
|
|
234
|
+
// Grab the encoded data from the meta tag
|
|
235
|
+
userConfigEncoded = document.querySelector('head meta[name=app-user-config]').attr('content');
|
|
236
|
+
// Unescape the text, then parse the resulting JSON into a real object
|
|
237
|
+
userConfig = JSON.parse(unescape(userConfigEncoded));
|
|
238
|
+
// Lookup the store
|
|
239
|
+
store = application.lookup('service:store');
|
|
240
|
+
// Push the encoded JSON into the store
|
|
241
|
+
store.pushPayload(userConfig);
|
|
242
|
+
}
|
|
243
|
+
export default {
|
|
244
|
+
name: 'named-instance-initializer',
|
|
245
|
+
initialize
|
|
246
|
+
};
|
|
247
|
+
```
|
|
248
|
+
@method instanceInitializer
|
|
249
|
+
@param instanceInitializer
|
|
250
|
+
@public
|
|
251
|
+
*/
|
|
252
|
+
static instanceInitializer = buildInitializerMethod('instanceInitializers', 'instance initializer');
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
This creates a registry with the default Ember naming conventions.
|
|
256
|
+
It also configures the registry:
|
|
257
|
+
* registered views are created every time they are looked up (they are
|
|
258
|
+
not singletons)
|
|
259
|
+
* registered templates are not factories; the registered value is
|
|
260
|
+
returned directly.
|
|
261
|
+
* the router receives the application as its `namespace` property
|
|
262
|
+
* all controllers receive the router as their `target` and `controllers`
|
|
263
|
+
properties
|
|
264
|
+
* all controllers receive the application as their `namespace` property
|
|
265
|
+
* the application view receives the application controller as its
|
|
266
|
+
`controller` property
|
|
267
|
+
* the application view receives the application template as its
|
|
268
|
+
`defaultTemplate` property
|
|
269
|
+
@method buildRegistry
|
|
270
|
+
@static
|
|
271
|
+
@param {Application} namespace the application for which to
|
|
272
|
+
build the registry
|
|
273
|
+
@return {Ember.Registry} the built registry
|
|
274
|
+
@private
|
|
275
|
+
*/
|
|
276
|
+
static buildRegistry(namespace) {
|
|
277
|
+
let registry = new Registry({
|
|
278
|
+
resolver: resolverFor(namespace)
|
|
279
|
+
});
|
|
280
|
+
registry.set = set;
|
|
281
|
+
registry.register('application:main', namespace, {
|
|
282
|
+
instantiate: false
|
|
283
|
+
});
|
|
284
|
+
commonSetupRegistry(registry);
|
|
285
|
+
setupEngineRegistry(registry);
|
|
286
|
+
return registry;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
Set this to provide an alternate class to `DefaultResolver`
|
|
291
|
+
@property resolver
|
|
292
|
+
@public
|
|
293
|
+
*/
|
|
294
|
+
|
|
295
|
+
init(properties) {
|
|
296
|
+
super.init(properties);
|
|
297
|
+
this.buildRegistry();
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
/**
|
|
301
|
+
A private flag indicating whether an engine's initializers have run yet.
|
|
302
|
+
@private
|
|
303
|
+
@property _initializersRan
|
|
304
|
+
*/
|
|
305
|
+
_initializersRan = false;
|
|
306
|
+
|
|
307
|
+
/**
|
|
308
|
+
Ensure that initializers are run once, and only once, per engine.
|
|
309
|
+
@private
|
|
310
|
+
@method ensureInitializers
|
|
311
|
+
*/
|
|
312
|
+
ensureInitializers() {
|
|
313
|
+
if (!this._initializersRan) {
|
|
314
|
+
this.runInitializers();
|
|
315
|
+
this._initializersRan = true;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
Create an EngineInstance for this engine.
|
|
321
|
+
@public
|
|
322
|
+
@method buildInstance
|
|
323
|
+
@return {EngineInstance} the engine instance
|
|
324
|
+
*/
|
|
325
|
+
buildInstance(options = {}) {
|
|
326
|
+
this.ensureInitializers();
|
|
327
|
+
return EngineInstance.create({
|
|
328
|
+
...options,
|
|
329
|
+
base: this
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
Build and configure the registry for the current engine.
|
|
335
|
+
@private
|
|
336
|
+
@method buildRegistry
|
|
337
|
+
@return {Ember.Registry} the configured registry
|
|
338
|
+
*/
|
|
339
|
+
buildRegistry() {
|
|
340
|
+
let registry = this.__registry__ = this.constructor.buildRegistry(this);
|
|
341
|
+
return registry;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
@private
|
|
346
|
+
@method initializer
|
|
347
|
+
*/
|
|
348
|
+
initializer(initializer) {
|
|
349
|
+
this.constructor.initializer(initializer);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
@private
|
|
354
|
+
@method instanceInitializer
|
|
355
|
+
*/
|
|
356
|
+
instanceInitializer(initializer) {
|
|
357
|
+
this.constructor.instanceInitializer(initializer);
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
@private
|
|
362
|
+
@method runInitializers
|
|
363
|
+
*/
|
|
364
|
+
runInitializers() {
|
|
365
|
+
this._runInitializer('initializers', (name, initializer) => {
|
|
366
|
+
(isDevelopingApp() && !(initializer) && assert(`No application initializer named '${name}'`, initializer));
|
|
367
|
+
initializer.initialize(this);
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/**
|
|
372
|
+
@private
|
|
373
|
+
@since 1.12.0
|
|
374
|
+
@method runInstanceInitializers
|
|
375
|
+
*/
|
|
376
|
+
runInstanceInitializers(instance) {
|
|
377
|
+
this._runInitializer('instanceInitializers', (name, initializer) => {
|
|
378
|
+
(isDevelopingApp() && !(initializer) && assert(`No instance initializer named '${name}'`, initializer));
|
|
379
|
+
initializer.initialize(instance);
|
|
380
|
+
});
|
|
381
|
+
}
|
|
382
|
+
_runInitializer(bucketName, cb) {
|
|
383
|
+
let initializersByName = get(this.constructor, bucketName);
|
|
384
|
+
let initializers = props(initializersByName);
|
|
385
|
+
let graph = new DAG();
|
|
386
|
+
let initializer;
|
|
387
|
+
for (let name of initializers) {
|
|
388
|
+
initializer = initializersByName[name];
|
|
389
|
+
(isDevelopingApp() && !(initializer) && assert(`missing ${bucketName}: ${name}`, initializer));
|
|
390
|
+
graph.add(initializer.name, initializer, initializer.before, initializer.after);
|
|
391
|
+
}
|
|
392
|
+
graph.topsort(cb);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
This function defines the default lookup rules for container lookups:
|
|
398
|
+
|
|
399
|
+
* templates are looked up on `Ember.TEMPLATES`
|
|
400
|
+
* other names are looked up on the application after classifying the name.
|
|
401
|
+
For example, `controller:post` looks up `App.PostController` by default.
|
|
402
|
+
* if the default lookup fails, look for registered classes on the container
|
|
403
|
+
|
|
404
|
+
This allows the application to register default injections in the container
|
|
405
|
+
that could be overridden by the normal naming convention.
|
|
406
|
+
|
|
407
|
+
@private
|
|
408
|
+
@method resolverFor
|
|
409
|
+
@param {Ember.Enginer} namespace the namespace to look for classes
|
|
410
|
+
@return {*} the resolved value for a given lookup
|
|
411
|
+
*/
|
|
412
|
+
function resolverFor(namespace) {
|
|
413
|
+
let ResolverClass = namespace.Resolver;
|
|
414
|
+
let props = {
|
|
415
|
+
namespace
|
|
416
|
+
};
|
|
417
|
+
return ResolverClass.create(props);
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/** @internal */
|
|
421
|
+
function buildInitializerMethod(bucketName, humanName) {
|
|
422
|
+
return function (initializer) {
|
|
423
|
+
// If this is the first initializer being added to a subclass, we are going to reopen the class
|
|
424
|
+
// to make sure we have a new `initializers` object, which extends from the parent class' using
|
|
425
|
+
// prototypal inheritance. Without this, attempting to add initializers to the subclass would
|
|
426
|
+
// pollute the parent class as well as other subclasses.
|
|
427
|
+
// SAFETY: The superclass may be an Engine, we don't call unless we confirmed it was ok.
|
|
428
|
+
let superclass = this.superclass;
|
|
429
|
+
if (superclass[bucketName] !== undefined && superclass[bucketName] === this[bucketName]) {
|
|
430
|
+
let attrs = {
|
|
431
|
+
[bucketName]: Object.create(this[bucketName])
|
|
432
|
+
};
|
|
433
|
+
this.reopenClass(attrs);
|
|
434
|
+
}
|
|
435
|
+
(isDevelopingApp() && !(!this[bucketName][initializer.name]) && assert(`The ${humanName} '${initializer.name}' has already been registered`, !this[bucketName][initializer.name]));
|
|
436
|
+
(isDevelopingApp() && !(canInvoke(initializer, 'initialize')) && assert(`An ${humanName} cannot be registered without an initialize function`, canInvoke(initializer, 'initialize')));
|
|
437
|
+
(isDevelopingApp() && !(initializer.name !== undefined) && assert(`An ${humanName} cannot be registered without a name property`, initializer.name !== undefined));
|
|
438
|
+
let initializers = this[bucketName];
|
|
439
|
+
initializers[initializer.name] = initializer;
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
function commonSetupRegistry(registry) {
|
|
443
|
+
registry.optionsForType('component', {
|
|
444
|
+
singleton: false
|
|
445
|
+
});
|
|
446
|
+
registry.optionsForType('view', {
|
|
447
|
+
singleton: false
|
|
448
|
+
});
|
|
449
|
+
registry.register('controller:basic', Controller, {
|
|
450
|
+
instantiate: false
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
// Register the routing service...
|
|
454
|
+
registry.register('service:-routing', RoutingService);
|
|
455
|
+
|
|
456
|
+
// DEBUGGING
|
|
457
|
+
registry.register('resolver-for-debugging:main', registry.resolver, {
|
|
458
|
+
instantiate: false
|
|
459
|
+
});
|
|
460
|
+
registry.register('container-debug-adapter:main', ContainerDebugAdapter);
|
|
461
|
+
registry.register('component-lookup:main', ComponentLookup);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
export { buildInitializerMethod, Engine as default };
|
|
@@ -1,17 +1,181 @@
|
|
|
1
|
-
import '
|
|
2
|
-
import '../-internals/runtime/lib/mixins/registry_proxy.js';
|
|
3
|
-
import '../-internals/runtime/lib/mixins/container_proxy.js';
|
|
1
|
+
import EmberObject from '../object/index.js';
|
|
2
|
+
import RegistryProxyMixin from '../-internals/runtime/lib/mixins/registry_proxy.js';
|
|
3
|
+
import ContainerProxyMixin from '../-internals/runtime/lib/mixins/container_proxy.js';
|
|
4
4
|
import '../-internals/runtime/lib/mixins/comparable.js';
|
|
5
5
|
import '../-internals/runtime/lib/mixins/action_handler.js';
|
|
6
6
|
import '../-internals/runtime/lib/mixins/-proxy.js';
|
|
7
7
|
import '../enumerable/mutable.js';
|
|
8
8
|
import '../-internals/runtime/lib/mixins/target_action_support.js';
|
|
9
9
|
import '../-internals/runtime/lib/ext/rsvp.js';
|
|
10
|
-
import '
|
|
11
|
-
import '../../shared-chunks/registry-
|
|
12
|
-
import '../../shared-chunks/mandatory-setter-
|
|
13
|
-
import '@embroider/macros';
|
|
14
|
-
import './lib/engine-parent.js';
|
|
15
|
-
import '../-internals/owner/index.js';
|
|
16
|
-
|
|
17
|
-
import '../../shared-chunks/rsvp-DaQAFb0W.js';
|
|
10
|
+
import '../debug/index.js';
|
|
11
|
+
import { R as Registry, p as privatize } from '../../shared-chunks/registry-B8WARvkP.js';
|
|
12
|
+
import { g as guidFor } from '../../shared-chunks/mandatory-setter-BiXq-dpN.js';
|
|
13
|
+
import { isDevelopingApp } from '@embroider/macros';
|
|
14
|
+
import { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent.js';
|
|
15
|
+
import { isFactory } from '../-internals/owner/index.js';
|
|
16
|
+
import { assert } from '../debug/lib/assert.js';
|
|
17
|
+
import { R as RSVP } from '../../shared-chunks/rsvp-DaQAFb0W.js';
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
@module @ember/engine
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
class EngineInstance extends EmberObject.extend(RegistryProxyMixin, ContainerProxyMixin) {
|
|
24
|
+
/**
|
|
25
|
+
@private
|
|
26
|
+
@method setupRegistry
|
|
27
|
+
@param {Registry} registry
|
|
28
|
+
@param {BootOptions} options
|
|
29
|
+
*/
|
|
30
|
+
// This is effectively an "abstract" method: it defines the contract a
|
|
31
|
+
// subclass (e.g. `ApplicationInstance`) must follow to implement this
|
|
32
|
+
// behavior, but an `EngineInstance` has no behavior of its own here.
|
|
33
|
+
static setupRegistry(_registry, _options) {}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
The base `Engine` for which this is an instance.
|
|
37
|
+
@property {Engine} engine
|
|
38
|
+
@private
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
[ENGINE_PARENT];
|
|
42
|
+
_booted = false;
|
|
43
|
+
init(properties) {
|
|
44
|
+
super.init(properties);
|
|
45
|
+
|
|
46
|
+
// Ensure the guid gets setup for this instance
|
|
47
|
+
guidFor(this);
|
|
48
|
+
this.base ??= this.application;
|
|
49
|
+
|
|
50
|
+
// Create a per-instance registry that will use the application's registry
|
|
51
|
+
// as a fallback for resolving registrations.
|
|
52
|
+
let registry = this.__registry__ = new Registry({
|
|
53
|
+
fallback: this.base.__registry__
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// Create a per-instance container from the instance's registry
|
|
57
|
+
this.__container__ = registry.container({
|
|
58
|
+
owner: this
|
|
59
|
+
});
|
|
60
|
+
this._booted = false;
|
|
61
|
+
}
|
|
62
|
+
_bootPromise = null;
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
Initialize the `EngineInstance` and return a promise that resolves
|
|
66
|
+
with the instance itself when the boot process is complete.
|
|
67
|
+
The primary task here is to run any registered instance initializers.
|
|
68
|
+
See the documentation on `BootOptions` for the options it takes.
|
|
69
|
+
@public
|
|
70
|
+
@method boot
|
|
71
|
+
@param options {Object}
|
|
72
|
+
@return {Promise<EngineInstance,Error>}
|
|
73
|
+
*/
|
|
74
|
+
boot(options) {
|
|
75
|
+
if (this._bootPromise) {
|
|
76
|
+
return this._bootPromise;
|
|
77
|
+
}
|
|
78
|
+
this._bootPromise = new RSVP.Promise(resolve => {
|
|
79
|
+
resolve(this._bootSync(options));
|
|
80
|
+
});
|
|
81
|
+
return this._bootPromise;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
Unfortunately, a lot of existing code assumes booting an instance is
|
|
86
|
+
synchronous – specifically, a lot of tests assume the last call to
|
|
87
|
+
`app.advanceReadiness()` or `app.reset()` will result in a new instance
|
|
88
|
+
being fully-booted when the current runloop completes.
|
|
89
|
+
We would like new code (like the `visit` API) to stop making this
|
|
90
|
+
assumption, so we created the asynchronous version above that returns a
|
|
91
|
+
promise. But until we have migrated all the code, we would have to expose
|
|
92
|
+
this method for use *internally* in places where we need to boot an instance
|
|
93
|
+
synchronously.
|
|
94
|
+
@private
|
|
95
|
+
*/
|
|
96
|
+
_bootSync(options) {
|
|
97
|
+
if (this._booted) {
|
|
98
|
+
return this;
|
|
99
|
+
}
|
|
100
|
+
(isDevelopingApp() && !(getEngineParent(this)) && assert("An engine instance's parent must be set via `setEngineParent(engine, parent)` prior to calling `engine.boot()`.", getEngineParent(this)));
|
|
101
|
+
this.cloneParentDependencies();
|
|
102
|
+
this.setupRegistry(options);
|
|
103
|
+
this.base.runInstanceInitializers(this);
|
|
104
|
+
this._booted = true;
|
|
105
|
+
return this;
|
|
106
|
+
}
|
|
107
|
+
setupRegistry(options = this.__container__.lookup('-environment:main')) {
|
|
108
|
+
this.constructor.setupRegistry(this.__registry__, options);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
Unregister a factory.
|
|
113
|
+
Overrides `RegistryProxy#unregister` in order to clear any cached instances
|
|
114
|
+
of the unregistered factory.
|
|
115
|
+
@public
|
|
116
|
+
@method unregister
|
|
117
|
+
@param {String} fullName
|
|
118
|
+
*/
|
|
119
|
+
unregister(fullName) {
|
|
120
|
+
this.__container__.reset(fullName);
|
|
121
|
+
|
|
122
|
+
// We overwrote this method from RegistryProxyMixin.
|
|
123
|
+
this.__registry__.unregister(fullName);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
Build a new `EngineInstance` that's a child of this instance.
|
|
128
|
+
Engines must be registered by name with their parent engine
|
|
129
|
+
(or application).
|
|
130
|
+
@private
|
|
131
|
+
@method buildChildEngineInstance
|
|
132
|
+
@param name {String} the registered name of the engine.
|
|
133
|
+
@param options {Object} options provided to the engine instance.
|
|
134
|
+
@return {EngineInstance,Error}
|
|
135
|
+
*/
|
|
136
|
+
buildChildEngineInstance(name, options = {}) {
|
|
137
|
+
let ChildEngine = this.lookup(`engine:${name}`);
|
|
138
|
+
if (!ChildEngine) {
|
|
139
|
+
throw new Error(`You attempted to mount the engine '${name}', but it is not registered with its parent.`);
|
|
140
|
+
}
|
|
141
|
+
let engineInstance = ChildEngine.buildInstance(options);
|
|
142
|
+
setEngineParent(engineInstance, this);
|
|
143
|
+
return engineInstance;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
Clone dependencies shared between an engine instance and its parent.
|
|
148
|
+
@private
|
|
149
|
+
@method cloneParentDependencies
|
|
150
|
+
*/
|
|
151
|
+
cloneParentDependencies() {
|
|
152
|
+
const parent = getEngineParent(this);
|
|
153
|
+
(isDevelopingApp() && !(parent) && assert('expected parent', parent));
|
|
154
|
+
let registrations = ['route:basic', 'service:-routing'];
|
|
155
|
+
registrations.forEach(key => {
|
|
156
|
+
let registration = parent.resolveRegistration(key);
|
|
157
|
+
(isDevelopingApp() && !(isFactory(registration)) && assert('expected registration to be a factory', isFactory(registration)));
|
|
158
|
+
this.register(key, registration);
|
|
159
|
+
});
|
|
160
|
+
let env = parent.lookup('-environment:main');
|
|
161
|
+
this.register('-environment:main', env, {
|
|
162
|
+
instantiate: false
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
// The type annotation forces TS to (a) validate that these match and (b)
|
|
166
|
+
// *notice* that they match, e.g. below on the `singletons.push()`.
|
|
167
|
+
let singletons = ['router:main', privatize`-bucket-cache:main`, '-view-registry:main', `renderer:-dom`, 'service:-document'];
|
|
168
|
+
if (env['isInteractive']) {
|
|
169
|
+
singletons.push('event_dispatcher:main');
|
|
170
|
+
}
|
|
171
|
+
singletons.forEach(key => {
|
|
172
|
+
// SAFETY: We already expect this to be a singleton
|
|
173
|
+
let singleton = parent.lookup(key);
|
|
174
|
+
this.register(key, singleton, {
|
|
175
|
+
instantiate: false
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export { EngineInstance as default };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ENGINE_PARENT, getEngineParent, setEngineParent } from './lib/engine-parent.js';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { helperCapabilities, setHelperManager as setHelperManager$1 } from '../../@glimmer/manager/index.js';
|
|
2
2
|
import { invokeHelper as invokeHelper$1, hash as hash$1, array as array$1, concat as concat$1, get as get$1, fn as fn$1 } from '../../@glimmer/runtime/index.js';
|
|
3
3
|
import '../../@glimmer/opcode-compiler/index.js';
|
|
4
|
-
import { u as uniqueId$1 } from '../../shared-chunks/index-
|
|
5
|
-
import '../../shared-chunks/registry-
|
|
6
|
-
import '
|
|
7
|
-
import '
|
|
4
|
+
import { u as uniqueId$1 } from '../../shared-chunks/index-Llq6dmgX.js';
|
|
5
|
+
import '../../shared-chunks/registry-B8WARvkP.js';
|
|
6
|
+
import '../debug/index.js';
|
|
7
|
+
import '../runloop/index.js';
|
|
8
8
|
import '../../@glimmer/reference/index.js';
|
|
9
9
|
import '../../@glimmer/validator/index.js';
|
|
10
10
|
import '@embroider/macros';
|