11import { ENV } from '@ember/-internals/environment' ;
2- import { get , set , _getProp , _setProp } from '@ember/-internals/metal' ;
3- import type { InternalOwner } from '@ember/-internals/owner' ;
42import { getDebugName } from '@ember/-internals/utils' ;
5- import { constructStyleDeprecationMessage } from '@ember/-internals/views' ;
6- import { assert , deprecate , warn } from '@ember/debug' ;
7- import type { DeprecationOptions } from '@ember/debug' ;
83import { schedule , _backburner } from '@ember/runloop' ;
4+ import { setDestructionSchedulers } from '@glimmer/destroyable' ;
95import { DEBUG } from '@glimmer/env' ;
10- import setGlobalContext from '@glimmer/global-context' ;
116import type { EnvironmentDelegate } from '@glimmer/runtime' ;
12- import { debug } from '@glimmer/validator' ;
13- import toIterator from './utils/iterator' ;
14- import { isHTMLSafe } from './utils/string' ;
15- import toBool from './utils/to-bool' ;
7+ import { debug , setScheduleRevalidate } from '@glimmer/validator' ;
168
17- ///////////
18-
19- // Setup global context
20-
21- setGlobalContext ( {
22- scheduleRevalidate ( ) {
23- _backburner . ensureInstance ( ) ;
24- } ,
25-
26- toBool,
27- toIterator,
28-
29- getProp : _getProp ,
30- setProp : _setProp ,
31- getPath : get ,
32- setPath : set ,
33-
34- scheduleDestroy ( destroyable , destructor ) {
35- schedule ( 'actions' , null , destructor , destroyable ) ;
36- } ,
37-
38- scheduleDestroyed ( finalizeDestructor ) {
39- schedule ( 'destroy' , null , finalizeDestructor ) ;
40- } ,
41-
42- warnIfStyleNotTrusted ( value : unknown ) {
43- warn (
44- constructStyleDeprecationMessage ( String ( value ) ) ,
45- ( ( ) => {
46- if ( value === null || value === undefined || isHTMLSafe ( value ) ) {
47- return true ;
48- }
49- return false ;
50- } ) ( ) ,
51- { id : 'ember-htmlbars.style-xss-warning' }
52- ) ;
53- } ,
54-
55- assert ( test : unknown , msg : string , options ?: { id : string } ) {
56- if ( DEBUG ) {
57- let id = options ?. id ;
58-
59- let override = VM_ASSERTION_OVERRIDES . filter ( ( o ) => o . id === id ) [ 0 ] ;
60-
61- assert ( override ?. message ?? msg , test ) ;
62- }
63- } ,
64-
65- deprecate ( msg : string , test : unknown , options : { id : string } ) {
66- if ( DEBUG ) {
67- let { id } = options ;
68-
69- if ( id === 'argument-less-helper-paren-less-invocation' ) {
70- throw new Error (
71- `A resolved helper cannot be passed as a named argument as the syntax is ` +
72- `ambiguously a pass-by-reference or invocation. Use the ` +
73- `\`{{helper 'foo-helper}}\` helper to pass by reference or explicitly ` +
74- `invoke the helper with parens: \`{{(fooHelper)}}\`.`
75- ) ;
76- }
77-
78- let override = VM_DEPRECATION_OVERRIDES . filter ( ( o ) => o . id === id ) [ 0 ] ;
79-
80- if ( ! override ) throw new Error ( `deprecation override for ${ id } not found` ) ;
81-
82- // allow deprecations to be disabled in the VM_DEPRECATION_OVERRIDES array below
83- if ( ! override . disabled ) {
84- deprecate ( override . message ?? msg , Boolean ( test ) , override ) ;
85- }
86- }
87- } ,
88- } ) ;
9+ setScheduleRevalidate ( ( ) => _backburner . ensureInstance ( ) ) ;
10+ setDestructionSchedulers (
11+ ( destroyable , destructor ) => schedule ( 'actions' , null , destructor , destroyable ) ,
12+ ( finalizer ) => schedule ( 'destroy' , null , finalizer )
13+ ) ;
8914
9015if ( DEBUG ) {
9116 debug ?. setTrackingTransactionEnv ?.( {
@@ -99,38 +24,10 @@ if (DEBUG) {
9924 } ) ;
10025}
10126
102- ///////////
103-
104- // VM Assertion/Deprecation overrides
105-
106- const VM_DEPRECATION_OVERRIDES : ( DeprecationOptions & {
107- disabled ?: boolean ;
108- message ?: string ;
109- } ) [ ] = [
110- {
111- id : 'setting-on-hash' ,
112- until : '4.4.0' ,
113- for : 'ember-source' ,
114- since : {
115- available : '3.28.0' ,
116- enabled : '3.28.0' ,
117- } ,
118- } ,
119- ] ;
120-
121- const VM_ASSERTION_OVERRIDES : { id : string ; message : string } [ ] = [ ] ;
122-
123- ///////////
124-
125- // Define environment delegate
126-
12727export class EmberEnvironmentDelegate implements EnvironmentDelegate {
12828 public enableDebugTooling : boolean = ENV . _DEBUG_RENDER_TREE ;
12929
130- constructor (
131- public owner : InternalOwner ,
132- public isInteractive : boolean
133- ) { }
30+ constructor ( public isInteractive : boolean ) { }
13431
13532 onTransactionCommit ( ) : void { }
13633}
0 commit comments