Skip to content

Commit

Permalink
Add RequiredTandem, phetsims/phet-io#1843
Browse files Browse the repository at this point in the history
  • Loading branch information
zepumph committed Feb 24, 2022
1 parent 07349bf commit 4f1b769
Show file tree
Hide file tree
Showing 12 changed files with 24 additions and 15 deletions.
3 changes: 2 additions & 1 deletion js/common/CASScreen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ import CASColors from '../common/CASColors.js';
import centerAndSpread from '../centerAndSpread.js';
import CASModel from './model/CASModel.js';
import CASScreenView from './view/CASScreenView.js';
import { RequiredTandem } from '../../../tandem/js/PhetioObject.js';

type CASScreenSelfOptions = {};
export type CASScreenOptions = CASScreenSelfOptions & ScreenOptions & Required<Pick<ScreenOptions, 'tandem'>>;
export type CASScreenOptions = CASScreenSelfOptions & ScreenOptions & RequiredTandem<ScreenOptions>;

class CASScreen<M extends CASModel, V extends CASScreenView> extends Screen<M, V> {

Expand Down
4 changes: 2 additions & 2 deletions js/common/model/CASObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import centerAndSpread from '../../centerAndSpread.js';
import Vector2Property from '../../../../dot/js/Vector2Property.js';
import PhetioObject, { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import PhetioObject, { PhetioObjectOptions, RequiredTandem } from '../../../../tandem/js/PhetioObject.js';
import Tandem from '../../../../tandem/js/Tandem.js';
import Vector2 from '../../../../dot/js/Vector2.js';
import optionize from '../../../../phet-core/js/optionize.js';
Expand All @@ -30,7 +30,7 @@ type CASObjectSelfOptions = {
export type CASObjectOptions =
CASObjectSelfOptions
& PhetioObjectOptions
& Required<Pick<PhetioObjectOptions, 'tandem'>>;
& RequiredTandem<PhetioObjectOptions>;

class CASObject extends PhetioObject {

Expand Down
4 changes: 2 additions & 2 deletions js/common/model/CardModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
import CASObject from './CASObject.js';
import centerAndSpread from '../../centerAndSpread.js';
import PhetioObject, { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import PhetioObject, { PhetioObjectOptions, RequiredTandem } from '../../../../tandem/js/PhetioObject.js';
import IOType from '../../../../tandem/js/types/IOType.js';
import StringIO from '../../../../tandem/js/types/StringIO.js';
import ReferenceIO from '../../../../tandem/js/types/ReferenceIO.js';
Expand All @@ -18,7 +18,7 @@ import CASObjectType from './CASObjectType.js';
const CASObjectReferenceIO = ReferenceIO( CASObject.CASObjectIO );

type CardModelSelfOptions = {};
type CardModelOptions = CardModelSelfOptions & PhetioObjectOptions & Required<Pick<PhetioObjectOptions, 'tandem'>>;
type CardModelOptions = CardModelSelfOptions & PhetioObjectOptions & RequiredTandem<PhetioObjectOptions>;

class CardModel extends PhetioObject {

Expand Down
4 changes: 2 additions & 2 deletions js/common/model/SoccerPlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import centerAndSpread from '../../centerAndSpread.js';
import BooleanProperty from '../../../../axon/js/BooleanProperty.js';
import PhetioObject, { PhetioObjectOptions } from '../../../../tandem/js/PhetioObject.js';
import PhetioObject, { PhetioObjectOptions, RequiredTandem } from '../../../../tandem/js/PhetioObject.js';
import NumberProperty from '../../../../axon/js/NumberProperty.js';
import IOType from '../../../../tandem/js/types/IOType.js';
import NumberIO from '../../../../tandem/js/types/NumberIO.js';
Expand All @@ -20,7 +20,7 @@ type SoccerPlayerSelfOptions = {};
type SoccerPlayerOptions =
SoccerPlayerSelfOptions
& PhetioObjectOptions
& Required<Pick<PhetioObjectOptions, 'tandem'>>;
& RequiredTandem<PhetioObjectOptions>;

class SoccerPlayer extends PhetioObject {
readonly isKickingProperty: BooleanProperty;
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/CASAccordionBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import centerAndSpread from '../../centerAndSpread.js';
import TopRepresentationCheckboxGroup from './TopRepresentationCheckboxGroup.js';
import CASModel from '../model/CASModel.js';
import ValueReadoutsNode from './ValueReadoutsNode.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

type CASAccordionBoxSelfOptions = {
titleString: string;
Expand All @@ -26,7 +27,7 @@ type CASAccordionBoxSelfOptions = {
export type CASAccordionBoxOptions =
CASAccordionBoxSelfOptions
& Omit<AccordionBoxOptions, 'titleNode' | 'expandedProperty'>
& Required<Pick<NodeOptions, 'tandem'>>;
& RequiredTandem<NodeOptions>;

// constants
const CONTENT_MARGIN = 10;
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/CASObjectNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import IReadOnlyProperty from '../../../../axon/js/IReadOnlyProperty.js';
import Property from '../../../../axon/js/Property.js';
import CASColors from '../CASColors.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

type CASObjectNodeSelfOptions = {
objectViewType?: CASObjectType;
draggingEnabled?: boolean;
};
export type CASObjectNodeOptions = CASObjectNodeSelfOptions & NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type CASObjectNodeOptions = CASObjectNodeSelfOptions & NodeOptions & RequiredTandem<NodeOptions>;

class CASObjectNode extends Node {

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/CardNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import Animation from '../../../../twixt/js/Animation.js';
import Range from '../../../../dot/js/Range.js';
import Easing from '../../../../twixt/js/Easing.js';
import CardModel from '../model/CardModel.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

// TODO: Rename options
type NumberCardSelfOptions = {};
export type NumberCardOptions = NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type NumberCardOptions = NodeOptions & RequiredTandem<NodeOptions>;

class CardNode extends Node {
readonly positionProperty: Vector2Property;
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/DotPlotNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import Bounds2 from '../../../../dot/js/Bounds2.js';
import MedianBarsNode from './MedianBarsNode.js';
import PhetFont from '../../../../scenery-phet/js/PhetFont.js';
import centerAndSpreadStrings from '../../centerAndSpreadStrings.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

// constants

type DotPlotNodeSelfOptions = {};
export type DotPlotNodeOptions = NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type DotPlotNodeOptions = NodeOptions & RequiredTandem<NodeOptions>;

class DotPlotNode extends Node {

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/KickButtonGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import SoccerModel from '../model/SoccerModel.js';
import CASConstants from '../CASConstants.js';
import DerivedProperty from '../../../../axon/js/DerivedProperty.js';
import CASObject from '../model/CASObject.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

type KickButtonGroupSelfOptions = {};
export type KickButtonGroupOptions = KickButtonGroupSelfOptions & VBoxOptions & Required<Pick<VBoxOptions, 'tandem'>>;
export type KickButtonGroupOptions = KickButtonGroupSelfOptions & VBoxOptions & RequiredTandem<VBoxOptions>;

// constants
const TEXT_MAX_WIDTH = 80;
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NumberCardContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ import CASConstants from '../CASConstants.js';
import centerAndSpreadStrings from '../../centerAndSpreadStrings.js';
import StringUtils from '../../../../phetcommon/js/util/StringUtils.js';
import MedianBarsNode from './MedianBarsNode.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

// constants
const CARD_SPACING = 10;
const getCardPositionX = ( index: number ) => index * ( CardNode.CARD_WIDTH + CARD_SPACING );

type NumberCardContainerSelfOptions = {};
export type NumberCardOptions = NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type NumberCardOptions = NodeOptions & RequiredTandem<NodeOptions>;

// TODO: Rename CardNodeContainer
class NumberCardContainer extends Node {
Expand Down
3 changes: 2 additions & 1 deletion js/common/view/NumberLineNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import Vector2 from '../../../../dot/js/Vector2.js';
import ModelViewTransform2 from '../../../../phetcommon/js/view/ModelViewTransform2.js';
import Property from '../../../../axon/js/Property.js';
import Bounds2 from '../../../../dot/js/Bounds2.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

// constants
const TICK_MARK_EXTENT = 10;
Expand All @@ -32,7 +33,7 @@ type NumberLineNodeSelfOptions = {
color?: PaintDef;
includeXAxis?: boolean;
};
export type NumberLineNodeOptions = NumberLineNodeSelfOptions & NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type NumberLineNodeOptions = NumberLineNodeSelfOptions & NodeOptions & RequiredTandem<NodeOptions>;

class NumberLineNode extends Node {

Expand Down
3 changes: 2 additions & 1 deletion js/common/view/PredictionNode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import ShadedSphereNode from '../../../../scenery-phet/js/ShadedSphereNode.js';
import ArrowNode from '../../../../scenery-phet/js/ArrowNode.js';
import Range from '../../../../dot/js/Range.js';
import Utils from '../../../../dot/js/Utils.js';
import { RequiredTandem } from '../../../../tandem/js/PhetioObject.js';

type PredictionNodeSelfOptions = {
color: ColorDef,
Expand All @@ -26,7 +27,7 @@ type PredictionNodeSelfOptions = {
roundToInterval: number | null
};

export type PredictionNodeOptions = PredictionNodeSelfOptions & NodeOptions & Required<Pick<NodeOptions, 'tandem'>>;
export type PredictionNodeOptions = PredictionNodeSelfOptions & NodeOptions & RequiredTandem<NodeOptions>;

class PredictionNode extends Node {

Expand Down

0 comments on commit 4f1b769

Please sign in to comment.