Skip to content

Commit e662374

Browse files
committed
load
1 parent b24edd1 commit e662374

File tree

2 files changed

+80
-32
lines changed

2 files changed

+80
-32
lines changed

ember_debug/utils/ember.js

+68-30
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ try {
1111
let {
1212
ArrayProxy,
1313
Namespace,
14-
ActionHandler,
14+
_captureRenderTree: captureRenderTree,
1515
ControllerMixin,
1616
CoreObject,
1717
Application,
1818
MutableArray,
1919
MutableEnumerable,
2020
NativeArray,
21-
Component,
21+
Component: EmberComponent,
2222
Observable,
2323
Evented,
2424
PromiseProxyMixin,
@@ -30,63 +30,103 @@ let {
3030
get,
3131
set,
3232
runloop,
33-
computed,
34-
_metal: metal,
35-
_captureRenderTree: captureRenderTree,
36-
inspect,
33+
cacheFor,
34+
metal,
35+
guidFor,
3736
getOwner,
37+
isTrackedProperty,
38+
isCachedProperty,
39+
isMandatorySetter,
40+
isTesting,
41+
inspect,
42+
registerDeprecationHandler,
43+
TargetActionSupport,
44+
GlimmerComponent,
45+
instrumentation,
46+
RSVP,
3847
} = Ember || {};
3948

4049
let getEnv = () => Ember.ENV;
4150
let cacheFor = () => null;
4251

4352
if (!Ember) {
44-
captureRenderTree = emberSafeRequire('@ember/debug')?.captureRenderTree;
45-
getEnv = emberSafeRequire('@ember/-internals/environment')?.getENV;
46-
ArrayProxy = emberSafeRequire('@ember/array/proxy')?.default;
47-
ObjectProxy = emberSafeRequire('@ember/object/proxy')?.default;
4853
MutableArray = emberSafeRequire('@ember/array/mutable')?.default;
4954
Namespace = emberSafeRequire('@ember/application/namespace')?.default;
5055
MutableEnumerable = emberSafeRequire('@ember/enumerable/mutable')?.default;
5156
NativeArray = emberSafeRequire('@ember/array')?.NativeArray;
5257
ControllerMixin = emberSafeRequire('@ember/controller')?.ControllerMixin;
5358
CoreObject = emberSafeRequire('@ember/object/core')?.default;
5459
Application = emberSafeRequire('@ember/application')?.default;
55-
Component = emberSafeRequire('@ember/component')?.default;
60+
EmberComponent = emberSafeRequire('@ember/component')?.default;
61+
GlimmerComponent = emberSafeRequire('@glimmer/component')?.default;
5662
Observable = emberSafeRequire('@ember/object/observable')?.default;
5763
Evented = emberSafeRequire('@ember/object/evented')?.default;
5864
PromiseProxyMixin = emberSafeRequire(
5965
'@ember/object/promise-proxy-mixin'
6066
)?.default;
61-
Service = emberSafeRequire('@ember/service')?.default;
6267
EmberObject = emberSafeRequire('@ember/object')?.default;
6368
VERSION = emberSafeRequire('ember/version')?.default;
64-
metal = emberSafeRequire(
65-
'@ember/-internals/metal'
66-
);
69+
metal = emberSafeRequire('@ember/-internals/metal');
70+
TargetActionSupport = emberSafeRequire(
71+
'@ember/-internals/runtime'
72+
)?.TargetActionSupport;
6773
meta = emberSafeRequire('@ember/-internals/meta')?.meta;
6874
set = emberSafeRequire('@ember/object')?.set;
6975
get = emberSafeRequire('@ember/object')?.get;
7076
runloop = emberSafeRequire('@ember/runloop');
71-
cacheFor = emberSafeRequire('@ember/object/internals').cacheFor;
72-
guidFor = emberSafeRequire('@ember/object/internals').guidFor;
73-
getOwner = emberSafeRequire('@ember/owner').getOwner;
74-
inspect = emberSafeRequire('@ember/debug').inspect;
77+
cacheFor = emberSafeRequire('@ember/object/internals')?.cacheFor;
78+
guidFor = emberSafeRequire('@ember/object/internals')?.guidFor;
79+
getOwner = emberSafeRequire('@ember/owner')?.getOwner;
80+
inspect =
81+
emberSafeRequire('@ember/debug')?.inspect ||
82+
emberSafeRequire('@ember/-internals/utils')?.inspect;
83+
registerDeprecationHandler =
84+
emberSafeRequire('@ember/debug')?.registerDeprecationHandler;
85+
instrumentation = emberSafeRequire('@ember/instrumentation');
86+
RSVP = emberSafeRequire('rsvp');
7587
}
7688

77-
const { ComputedProperty, isComputed, descriptorForProperty, descriptorForDecorator, tagForProperty } = metal;
78-
const { _backburner, cancel, debounce, join, later, scheduleOnce } = runloop;
79-
export const ember = {
89+
const {
90+
ComputedProperty,
91+
isComputed,
92+
descriptorForProperty,
93+
descriptorForDecorator,
94+
tagForProperty,
95+
} = (metal || {});
96+
97+
const { _backburner, cancel, debounce, join, later, scheduleOnce } = (runloop || {});
98+
const {
99+
ViewStateSupport,
100+
ViewMixin,
101+
ActionSupport,
102+
ClassNamesSupport,
103+
ChildViewsSupport,
104+
CoreView,
105+
} = emberSafeRequire('@ember/-internals/views') || Ember || {};
106+
107+
const GlimmerValidator = emberSafeRequire('@glimmer/validator');
108+
const GlimmerRuntime = emberSafeRequire('@glimmer/runtime');
109+
110+
export function assignEmberInfo(data) {
111+
Object.assign(ember, data);
112+
}
113+
114+
export const ember = {
80115
runloop: {
81-
_backburner, cancel, debounce, join, later, scheduleOnce
116+
_backburner,
117+
cancel,
118+
debounce,
119+
join,
120+
later,
121+
scheduleOnce,
82122
},
83123
object: {
84124
cacheFor,
85125
guidFor,
86126
getOwner,
87127
set,
88128
get,
89-
meta
129+
meta,
90130
},
91131
debug: {
92132
isComputed,
@@ -120,21 +160,19 @@ export const ember = {
120160
PromiseProxyMixin,
121161
},
122162
VERSION,
123-
instrumentation: {
124-
subscribe
125-
},
163+
instrumentation: instrumentation,
126164
Views: {
127165
ViewStateSupport,
128166
ViewMixin,
129167
ActionSupport,
130168
ClassNamesSupport,
131169
ChildViewsSupport,
132-
CoreView
170+
CoreView,
133171
},
134172
GlimmerValidator,
135173
GlimmerRuntime,
136174
RSVP,
137-
getEnv
138-
}
175+
getEnv,
176+
};
139177

140178
export default Ember;

ember_debug/vendor/startup-wrapper.js

+12-2
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,19 @@ var EMBER_VERSIONS_SUPPORTED = {{EMBER_VERSIONS_SUPPORTED}};
105105

106106
function onEmberReady(callback) {
107107
var triggered = false;
108-
var triggerOnce = function(string) {
108+
const event = new Event("ember-inspector-debug-request");
109+
var triggerOnce = function(e) {
109110
if (triggered) {
110111
return;
111112
}
112113

114+
if (e && typeof e.detail === 'object') {
115+
triggered = true;
116+
requireModule('ember-debug/utils/ember').assignEmberInfo(e.detail);
117+
callback();
118+
}
119+
window.dispatchEvent(event);
120+
113121
if (!Ember) {
114122
try {
115123
Ember = requireModule('ember')['default'];
@@ -132,8 +140,10 @@ var EMBER_VERSIONS_SUPPORTED = {{EMBER_VERSIONS_SUPPORTED}};
132140

133141
// Newest Ember versions >= 1.10
134142

135-
const later = () => setTimeout(triggerOnce, 0);
143+
const later = (data) => setTimeout(() => triggerOnce(data), 0);
136144
window.addEventListener('Ember', later, { once: true });
145+
window.addEventListener('ember-inspector-debug-response', later, { once: true });
146+
window.dispatchEvent(event);
137147
// Oldest Ember versions or if this was injected after Ember has loaded.
138148
onReady(triggerOnce);
139149
}

0 commit comments

Comments
 (0)