-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove most usages of classes from global Namespace #1346
Labels
Comments
Something ended up breaking the keyboard fuzzer, and I don't have time to investigate. I will need to come back to things. Index: js/accessibility/pdom/PDOMInstance.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMInstance.js b/js/accessibility/pdom/PDOMInstance.js
--- a/js/accessibility/pdom/PDOMInstance.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/accessibility/pdom/PDOMInstance.js (date 1643664521055)
@@ -30,7 +30,7 @@
import cleanArray from '../../../../phet-core/js/cleanArray.js';
import platform from '../../../../phet-core/js/platform.js';
import Poolable from '../../../../phet-core/js/Poolable.js';
-import { scenery, TransformTracker, PDOMPeer, PDOMUtils } from '../../imports.js';
+import { scenery, TransformTracker, PDOMPeer, PDOMUtils, FocusManager, Trail } from '../../imports.js';
import { Node } from '../../imports.js'; // eslint-disable-line no-unused-vars
let globalId = 1;
@@ -311,15 +311,16 @@
*/
updateVisibility() {
this.peer.setVisible( this.invisibleCount <= 0 );
+ assert && assert( FocusManager, 'FocusManager should be there' );
// if we hid a parent element, blur focus if active element was an ancestor
- if ( !this.peer.isVisible() && scenery.FocusManager.pdomFocusedNode ) {
- assert && assert( scenery.FocusManager.pdomFocusedNode.pdomInstances.length === 1,
+ if ( !this.peer.isVisible() && FocusManager.pdomFocusedNode ) {
+ assert && assert( FocusManager.pdomFocusedNode.pdomInstances.length === 1,
'focusable Nodes do not support DAG, and should be connected with an instance if focused.' );
// NOTE: We don't seem to be able to import normally here
- if ( scenery.FocusManager.pdomFocusedNode.pdomInstances[ 0 ].trail.containsNode( this.node ) ) {
- scenery.FocusManager.pdomFocus = null;
+ if ( FocusManager.pdomFocusedNode.pdomInstances[ 0 ].trail.containsNode( this.node ) ) {
+ FocusManager.pdomFocus = null;
}
}
@@ -412,7 +413,7 @@
sortChildren() {
// It's simpler/faster to just grab our order directly with one recursion, rather than specifying a sorting
// function (since a lot gets re-evaluated in that case).
- const targetChildren = this.getChildOrdering( new scenery.Trail( this.isRootInstance ? this.display.rootNode : this.node ) );
+ const targetChildren = this.getChildOrdering( new Trail( this.isRootInstance ? this.display.rootNode : this.node ) );
assert && assert( targetChildren.length === this.children.length, 'sorting should not change number of children' );
Index: js/accessibility/pdom/PDOMPeer.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMPeer.js b/js/accessibility/pdom/PDOMPeer.js
--- a/js/accessibility/pdom/PDOMPeer.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/accessibility/pdom/PDOMPeer.js (date 1643664232162)
@@ -14,7 +14,7 @@
import merge from '../../../../phet-core/js/merge.js';
import Poolable from '../../../../phet-core/js/Poolable.js';
import stripEmbeddingMarks from '../../../../phet-core/js/stripEmbeddingMarks.js';
-import { scenery, FocusManager, PDOMSiblingStyle, PDOMUtils } from '../../imports.js';
+import { FocusManager, PDOMInstance, PDOMSiblingStyle, PDOMUtils, scenery } from '../../imports.js';
// constants
const PRIMARY_SIBLING = 'PRIMARY_SIBLING';
@@ -771,7 +771,8 @@
* @returns {boolean}
*/
isFocused() {
- const visualFocusTrail = scenery.PDOMInstance.guessVisualTrail( this.trail, this.display.rootNode );
+ console.log( PDOMInstance, 'should be defined' );
+ const visualFocusTrail = PDOMInstance.guessVisualTrail( this.trail, this.display.rootNode );
return FocusManager.pdomFocusProperty.value && FocusManager.pdomFocusProperty.value.trail.equals( visualFocusTrail );
}
Index: js/accessibility/pdom/PDOMUtils.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMUtils.js b/js/accessibility/pdom/PDOMUtils.js
--- a/js/accessibility/pdom/PDOMUtils.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/accessibility/pdom/PDOMUtils.js (date 1643664408839)
@@ -14,7 +14,7 @@
import ValidatorDef from '../../../../axon/js/ValidatorDef.js';
import merge from '../../../../phet-core/js/merge.js';
import stripEmbeddingMarks from '../../../../phet-core/js/stripEmbeddingMarks.js';
-import { scenery, PDOMSiblingStyle } from '../../imports.js';
+import { Node, PDOMSiblingStyle, scenery } from '../../imports.js';
// constants
const NEXT = 'NEXT';
@@ -508,7 +508,7 @@
}
}
- assert && assert( associationObject.otherNode instanceof scenery.Node );
+ assert && assert( associationObject.otherNode instanceof Node );
assert && assert( typeof associationObject.thisElementName === 'string' );
assert && assert( typeof associationObject.otherElementName === 'string' );
},
Index: js/display/Drawable.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/display/Drawable.js b/js/display/Drawable.js
--- a/js/display/Drawable.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/display/Drawable.js (date 1643664006815)
@@ -54,7 +54,7 @@
*/
import TinyProperty from '../../../axon/js/TinyProperty.js';
-import { scenery, Renderer } from '../imports.js';
+import { Block, Renderer, scenery } from '../imports.js';
let globalId = 1;
@@ -213,7 +213,7 @@
this.toString()} with ${backboneInstance.toString()}` );
// if this is being called, Block will be guaranteed to be loaded
- assert && assert( this instanceof scenery.Block );
+ assert && assert( this instanceof Block );
this.parentDrawable = backboneInstance;
this.backbone = backboneInstance;
@@ -237,7 +237,7 @@
backbone ? backbone.toString() : '-'}` );
assert && assert( backbone !== undefined, 'backbone can be either null or a backbone' );
- assert && assert( block instanceof scenery.Block );
+ assert && assert( block instanceof Block );
this.pendingParentDrawable = block;
this.pendingBackbone = backbone;
@@ -281,7 +281,7 @@
sceneryLog && sceneryLog.Drawable && sceneryLog.Drawable( `[${this.constructor.name}*] notePendingMove ${
this.toString()} with ${block.toString()}` );
- assert && assert( block instanceof scenery.Block );
+ assert && assert( block instanceof Block );
this.pendingParentDrawable = block;
Index: js/accessibility/pdom/PDOMTree.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMTree.js b/js/accessibility/pdom/PDOMTree.js
--- a/js/accessibility/pdom/PDOMTree.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/accessibility/pdom/PDOMTree.js (date 1643664006748)
@@ -7,7 +7,7 @@
*/
import arrayDifference from '../../../../phet-core/js/arrayDifference.js';
-import { scenery, Node, Trail, PartialPDOMTrail, PDOMInstance } from '../../imports.js';
+import { scenery, Node, Trail, PartialPDOMTrail, PDOMInstance, FocusManager } from '../../imports.js';
// globals (for restoring focus)
let focusedNode = null;
@@ -391,8 +391,8 @@
* @param {Node} node - root of Node subtree whose PDOMInstance tree is being rearranged.
*/
beforeOp( node ) {
- // paranoia about initialization order (should be safe)
- focusedNode = scenery.Display && scenery.FocusManager.pdomFocusedNode;
+ assert && assert( FocusManager, 'should be defined by now' );
+ focusedNode = FocusManager.pdomFocusedNode;
// list of displays to stop blocking focus callbacks in afterOp
const displays = [];
Index: js/accessibility/voicing/voicingManager.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/voicing/voicingManager.js b/js/accessibility/voicing/voicingManager.js
--- a/js/accessibility/voicing/voicingManager.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/accessibility/voicing/voicingManager.js (date 1643664006781)
@@ -20,7 +20,7 @@
import stripEmbeddingMarks from '../../../../phet-core/js/stripEmbeddingMarks.js';
import Announcer from '../../../../utterance-queue/js/Announcer.js';
import Utterance from '../../../../utterance-queue/js/Utterance.js';
-import { globalKeyStateTracker, KeyboardUtils, scenery } from '../../imports.js';
+import { globalKeyStateTracker, KeyboardUtils, scenery, Display } from '../../imports.js';
// In ms, how frequently we will use SpeechSynthesis to keep the feature active. After long intervals without
// using SpeechSynthesis Chromebooks will take a long time to produce the next speech. Presumably it is disabling
@@ -203,9 +203,9 @@
this.timeSinceWakingEngine = ENGINE_WAKE_INTERVAL;
// Display is on the namespace but cannot be imported due to circular dependencies
- scenery.Display.userGestureEmitter.removeListener( startEngineListener );
+ Display.userGestureEmitter.removeListener( startEngineListener );
};
- scenery.Display.userGestureEmitter.addListener( startEngineListener );
+ Display.userGestureEmitter.addListener( startEngineListener );
this.initialized = true;
}
Index: js/imports.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/imports.ts b/js/imports.ts
--- a/js/imports.ts (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/imports.ts (date 1643664274634)
@@ -148,7 +148,6 @@
export { default as ReadingBlockHighlight } from './accessibility/voicing/ReadingBlockHighlight.js';
export { default as ReadingBlock } from './accessibility/voicing/ReadingBlock.js';
export { default as KeyboardZoomUtils } from './accessibility/KeyboardZoomUtils.js';
-export { default as KeyboardFuzzer } from './accessibility/KeyboardFuzzer.js';
export { default as GroupFocusHighlightFromNode } from './accessibility/GroupFocusHighlightFromNode.js';
export { default as ReadingBlockNode } from './accessibility/voicing/ReadingBlockNode.js';
export { default as ActivatedReadingBlockHighlight } from './accessibility/voicing/ActivatedReadingBlockHighlight.js';
@@ -159,6 +158,8 @@
export { default as PDOMTree } from './accessibility/pdom/PDOMTree.js';
export { default as PDOMFuzzer } from './accessibility/pdom/PDOMFuzzer.js';
+export { default as KeyboardFuzzer } from './accessibility/KeyboardFuzzer.js';
+
export type { default as IInputListener } from './input/IInputListener.js';
export type { SceneryListenerFunction } from './input/IInputListener.js';
export { default as Pointer } from './input/Pointer.js';
Index: js/input/EventIO.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/input/EventIO.js b/js/input/EventIO.js
--- a/js/input/EventIO.js (revision 45263615a75f2ff2bd2f2ef1132873e87bad7865)
+++ b/js/input/EventIO.js (date 1643664006822)
@@ -16,13 +16,13 @@
import NumberIO from '../../../tandem/js/types/NumberIO.js';
import ObjectLiteralIO from '../../../tandem/js/types/ObjectLiteralIO.js';
import StringIO from '../../../tandem/js/types/StringIO.js';
-import { scenery } from '../imports.js';
+import { Input, scenery } from '../imports.js';
const EventIO = new IOType( 'EventIO', {
valueType: window.Event,
documentation: 'A DOM Event',
- toStateObject: domEvent => scenery.Input.serializeDomEvent( domEvent ),
- fromStateObject: stateObject => scenery.Input.deserializeDomEvent( stateObject ),
+ toStateObject: domEvent => Input.serializeDomEvent( domEvent ),
+ fromStateObject: stateObject => Input.deserializeDomEvent( stateObject ),
// This should remain the same as Input.domEventPropertiesToSerialize (local var). Each key can be null depending on
// what Event interface is being serialized (which depends on what DOM Event the instance is). |
New patch without conflicts: Index: js/accessibility/pdom/PDOMInstance.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMInstance.js b/js/accessibility/pdom/PDOMInstance.js
--- a/js/accessibility/pdom/PDOMInstance.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/accessibility/pdom/PDOMInstance.js (date 1646331792367)
@@ -30,7 +30,7 @@
import cleanArray from '../../../../phet-core/js/cleanArray.js';
import platform from '../../../../phet-core/js/platform.js';
import Poolable from '../../../../phet-core/js/Poolable.js';
-import { scenery, TransformTracker, PDOMPeer, PDOMUtils } from '../../imports.js';
+import { scenery, TransformTracker, PDOMPeer, PDOMUtils, FocusManager, Trail } from '../../imports.js';
import { Node } from '../../imports.js'; // eslint-disable-line no-unused-vars
let globalId = 1;
@@ -311,15 +311,16 @@
*/
updateVisibility() {
this.peer.setVisible( this.invisibleCount <= 0 );
+ assert && assert( FocusManager, 'FocusManager should be there' );
// if we hid a parent element, blur focus if active element was an ancestor
- if ( !this.peer.isVisible() && scenery.FocusManager.pdomFocusedNode ) {
- assert && assert( scenery.FocusManager.pdomFocusedNode.pdomInstances.length === 1,
+ if ( !this.peer.isVisible() && FocusManager.pdomFocusedNode ) {
+ assert && assert( FocusManager.pdomFocusedNode.pdomInstances.length === 1,
'focusable Nodes do not support DAG, and should be connected with an instance if focused.' );
// NOTE: We don't seem to be able to import normally here
- if ( scenery.FocusManager.pdomFocusedNode.pdomInstances[ 0 ].trail.containsNode( this.node ) ) {
- scenery.FocusManager.pdomFocus = null;
+ if ( FocusManager.pdomFocusedNode.pdomInstances[ 0 ].trail.containsNode( this.node ) ) {
+ FocusManager.pdomFocus = null;
}
}
@@ -412,7 +413,7 @@
sortChildren() {
// It's simpler/faster to just grab our order directly with one recursion, rather than specifying a sorting
// function (since a lot gets re-evaluated in that case).
- const targetChildren = this.getChildOrdering( new scenery.Trail( this.isRootInstance ? this.display.rootNode : this.node ) );
+ const targetChildren = this.getChildOrdering( new Trail( this.isRootInstance ? this.display.rootNode : this.node ) );
assert && assert( targetChildren.length === this.children.length, 'sorting should not change number of children' );
Index: js/accessibility/pdom/PDOMPeer.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMPeer.js b/js/accessibility/pdom/PDOMPeer.js
--- a/js/accessibility/pdom/PDOMPeer.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/accessibility/pdom/PDOMPeer.js (date 1646331792390)
@@ -14,7 +14,7 @@
import merge from '../../../../phet-core/js/merge.js';
import Poolable from '../../../../phet-core/js/Poolable.js';
import stripEmbeddingMarks from '../../../../phet-core/js/stripEmbeddingMarks.js';
-import { scenery, FocusManager, PDOMSiblingStyle, PDOMUtils } from '../../imports.js';
+import { FocusManager, PDOMInstance, PDOMSiblingStyle, PDOMUtils, scenery } from '../../imports.js';
// constants
const PRIMARY_SIBLING = 'PRIMARY_SIBLING';
@@ -771,7 +771,8 @@
* @returns {boolean}
*/
isFocused() {
- const visualFocusTrail = scenery.PDOMInstance.guessVisualTrail( this.trail, this.display.rootNode );
+ console.log( PDOMInstance, 'should be defined' );
+ const visualFocusTrail = PDOMInstance.guessVisualTrail( this.trail, this.display.rootNode );
return FocusManager.pdomFocusProperty.value && FocusManager.pdomFocusProperty.value.trail.equals( visualFocusTrail );
}
Index: js/accessibility/pdom/PDOMUtils.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMUtils.js b/js/accessibility/pdom/PDOMUtils.js
--- a/js/accessibility/pdom/PDOMUtils.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/accessibility/pdom/PDOMUtils.js (date 1646331792429)
@@ -14,7 +14,7 @@
import ValidatorDef from '../../../../axon/js/ValidatorDef.js';
import merge from '../../../../phet-core/js/merge.js';
import stripEmbeddingMarks from '../../../../phet-core/js/stripEmbeddingMarks.js';
-import { scenery, PDOMSiblingStyle } from '../../imports.js';
+import { Node, PDOMSiblingStyle, scenery } from '../../imports.js';
// constants
const NEXT = 'NEXT';
@@ -508,7 +508,7 @@
}
}
- assert && assert( associationObject.otherNode instanceof scenery.Node );
+ assert && assert( associationObject.otherNode instanceof Node );
assert && assert( typeof associationObject.thisElementName === 'string' );
assert && assert( typeof associationObject.otherElementName === 'string' );
},
Index: js/display/Drawable.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/display/Drawable.js b/js/display/Drawable.js
--- a/js/display/Drawable.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/display/Drawable.js (date 1646331577261)
@@ -54,7 +54,7 @@
*/
import TinyProperty from '../../../axon/js/TinyProperty.js';
-import { scenery, Renderer } from '../imports.js';
+import { Block, Renderer, scenery } from '../imports.js';
let globalId = 1;
@@ -213,7 +213,7 @@
this.toString()} with ${backboneInstance.toString()}` );
// if this is being called, Block will be guaranteed to be loaded
- assert && assert( this instanceof scenery.Block );
+ assert && assert( this instanceof Block );
this.parentDrawable = backboneInstance;
this.backbone = backboneInstance;
@@ -237,7 +237,7 @@
backbone ? backbone.toString() : '-'}` );
assert && assert( backbone !== undefined, 'backbone can be either null or a backbone' );
- assert && assert( block instanceof scenery.Block );
+ assert && assert( block instanceof Block );
this.pendingParentDrawable = block;
this.pendingBackbone = backbone;
@@ -281,7 +281,7 @@
sceneryLog && sceneryLog.Drawable && sceneryLog.Drawable( `[${this.constructor.name}*] notePendingMove ${
this.toString()} with ${block.toString()}` );
- assert && assert( block instanceof scenery.Block );
+ assert && assert( block instanceof Block );
this.pendingParentDrawable = block;
Index: js/accessibility/pdom/PDOMTree.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/accessibility/pdom/PDOMTree.js b/js/accessibility/pdom/PDOMTree.js
--- a/js/accessibility/pdom/PDOMTree.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/accessibility/pdom/PDOMTree.js (date 1646331792403)
@@ -7,7 +7,7 @@
*/
import arrayDifference from '../../../../phet-core/js/arrayDifference.js';
-import { scenery, Node, Trail, PartialPDOMTrail, PDOMInstance } from '../../imports.js';
+import { scenery, Node, Trail, PartialPDOMTrail, PDOMInstance, FocusManager } from '../../imports.js';
// globals (for restoring focus)
let focusedNode = null;
@@ -391,8 +391,8 @@
* @param {Node} node - root of Node subtree whose PDOMInstance tree is being rearranged.
*/
beforeOp( node ) {
- // paranoia about initialization order (should be safe)
- focusedNode = scenery.Display && scenery.FocusManager.pdomFocusedNode;
+ assert && assert( FocusManager, 'should be defined by now' );
+ focusedNode = FocusManager.pdomFocusedNode;
// list of displays to stop blocking focus callbacks in afterOp
const displays = [];
Index: js/input/EventIO.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/js/input/EventIO.js b/js/input/EventIO.js
--- a/js/input/EventIO.js (revision 6a8529162c34442599006099ef729e3956fc67c5)
+++ b/js/input/EventIO.js (date 1646331577262)
@@ -16,13 +16,13 @@
import NumberIO from '../../../tandem/js/types/NumberIO.js';
import ObjectLiteralIO from '../../../tandem/js/types/ObjectLiteralIO.js';
import StringIO from '../../../tandem/js/types/StringIO.js';
-import { scenery } from '../imports.js';
+import { Input, scenery } from '../imports.js';
const EventIO = new IOType( 'EventIO', {
valueType: window.Event,
documentation: 'A DOM Event',
- toStateObject: domEvent => scenery.Input.serializeDomEvent( domEvent ),
- fromStateObject: stateObject => scenery.Input.deserializeDomEvent( stateObject ),
+ toStateObject: domEvent => Input.serializeDomEvent( domEvent ),
+ fromStateObject: stateObject => Input.deserializeDomEvent( stateObject ),
// This should remain the same as Input.domEventPropertiesToSerialize (local var). Each key can be null depending on
// what Event interface is being serialized (which depends on what DOM Event the instance is). |
zepumph
added a commit
that referenced
this issue
Mar 3, 2022
Alright. I got it to work. The issue was importing Node from PDOMUtils. Makes sense to me! We can remove that anyways. |
zepumph
added a commit
that referenced
this issue
Mar 3, 2022
Removed, since there is a Typescript type for Association now. |
zepumph
added a commit
that referenced
this issue
Mar 3, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
While working on #1340, @jonathanolson recommending removing global namespace usages because our new importing strategy (using imports.ts) solves almost all circular dependency issues.
The text was updated successfully, but these errors were encountered: