Skip to content

Commit 344fd45

Browse files
refactor(scenerystack): standardize namespace, StringManager, main, and Colors
Align all simulations to canonical SceneryStack registration patterns: PascalCase namespace modules with matching package identifiers (no self-registration), module-scoped StringManager properties, screen backgroundColorProperty from Colors, scenerystack/scenery imports, and profileColor() color factories. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 2c361f8 commit 344fd45

43 files changed

Lines changed: 279 additions & 288 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/TrackLabColors.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* support for different color profiles (default and projector mode).
66
*/
77

8-
import { Color, ProfileColorProperty } from "scenerystack";
9-
import trackLab from "./TrackLabNamespace.js";
8+
import { Color, ProfileColorProperty } from "scenerystack/scenery";
9+
import TrackLabNamespace from "./TrackLabNamespace.js";
1010

1111
// ── Base colors ───────────────────────────────────────────────────────────
1212
const BLACK = new Color(0, 0, 0);
@@ -18,7 +18,7 @@ function profileColor(
1818
defaultColor: Color | string,
1919
projectorColor: Color | string,
2020
): ProfileColorProperty {
21-
return new ProfileColorProperty(trackLab, name, {
21+
return new ProfileColorProperty(TrackLabNamespace, name, {
2222
default: defaultColor,
2323
projector: projectorColor,
2424
});
@@ -316,7 +316,4 @@ const TrackLabColors = {
316316
),
317317
};
318318

319-
// Register the namespace
320-
trackLab.register("TrackLabColors", TrackLabColors);
321-
322319
export default TrackLabColors;

src/TrackLabNamespace.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
/**
22
* TrackLabNamespace.ts
33
*
4-
* Creates and exports the global trackLab namespace for registering tandem-tracked singletons.
4+
* The SceneryStack Namespace for this simulation. It is used as the first
5+
* argument to ProfileColorProperty (so color names are scoped to this sim)
6+
* and optionally for registering objects with the PhET-iO API.
7+
*
8+
* ── How to customize ─────────────────────────────────────────────────────────
9+
* Change the string argument to match your simulation's identifier, using the
10+
* same kebab-case name as in package.json and src/init.ts.
511
*/
6-
712
import { Namespace } from "scenerystack/phet-core";
813

9-
export default new Namespace("trackLab");
14+
const TrackLabNamespace = new Namespace("track-lab");
15+
16+
export default TrackLabNamespace;

src/i18n/StringManager.ts

Lines changed: 187 additions & 200 deletions
Large diffs are not rendered by default.

src/init.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { init, madeWithSceneryStackSplashDataURI } from "scenerystack/init";
1818
init({
1919
// Internal identifier used by SceneryStack for URL parameters and phetmarks.
2020
// Use kebab-case matching the package.json "name" field.
21-
name: "trackLab",
21+
name: "track-lab",
2222

2323
// Displayed in the About dialog (Help menu → About).
2424
version: "0.1.0",

src/preferences/TrackLabPreferencesModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*/
88

99
import { BooleanProperty } from "scenerystack/axon";
10-
import trackLab from "../TrackLabNamespace.js";
10+
import TrackLabNamespace from "../TrackLabNamespace.js";
1111
import trackLabQueryParameters from "./trackLabQueryParameters.js";
1212

1313
export class TrackLabPreferencesModel {
@@ -53,4 +53,4 @@ export class TrackLabPreferencesModel {
5353
}
5454
}
5555

56-
trackLab.register("TrackLabPreferencesModel", TrackLabPreferencesModel);
56+
TrackLabNamespace.register("TrackLabPreferencesModel", TrackLabPreferencesModel);

src/preferences/TrackLabPreferencesNode.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { PhetFont } from "scenerystack/scenery-phet";
1313
import { Checkbox } from "scenerystack/sun";
1414
import { StringManager } from "../i18n/StringManager.js";
1515
import TrackLabColors from "../TrackLabColors.js";
16-
import trackLab from "../TrackLabNamespace.js";
16+
import TrackLabNamespace from "../TrackLabNamespace.js";
1717
import type { TrackLabPreferencesModel } from "./TrackLabPreferencesModel.js";
1818

1919
export class TrackLabPreferencesNode extends VBox {
@@ -141,4 +141,4 @@ export class TrackLabPreferencesNode extends VBox {
141141
}
142142
}
143143

144-
trackLab.register("TrackLabPreferencesNode", TrackLabPreferencesNode);
144+
TrackLabNamespace.register("TrackLabPreferencesNode", TrackLabPreferencesNode);

src/preferences/trackLabQueryParameters.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*/
44

55
import { QueryStringMachine } from "scenerystack/query-string-machine";
6-
import trackLab from "../TrackLabNamespace.js";
6+
import TrackLabNamespace from "../TrackLabNamespace.js";
77

88
const trackLabQueryParameters = QueryStringMachine.getAll({
99
enableAutoTracking: {
@@ -31,6 +31,6 @@ const trackLabQueryParameters = QueryStringMachine.getAll({
3131
},
3232
});
3333

34-
trackLab.register("trackLabQueryParameters", trackLabQueryParameters);
34+
TrackLabNamespace.register("trackLabQueryParameters", trackLabQueryParameters);
3535

3636
export default trackLabQueryParameters;

src/screen-name/SimScreen.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { Screen, type ScreenOptions } from "scenerystack/sim";
99
import type { TrackLabPreferencesModel } from "../preferences/TrackLabPreferencesModel.js";
10-
import trackLab from "../TrackLabNamespace.js";
10+
import TrackLabNamespace from "../TrackLabNamespace.js";
1111
import { SimModel } from "./model/SimModel.js";
1212
import { SimScreenView } from "./view/SimScreenView.js";
1313

@@ -30,4 +30,4 @@ export class SimScreen extends Screen<SimModel, SimScreenView> {
3030
}
3131
}
3232

33-
trackLab.register("SimScreen", SimScreen);
33+
TrackLabNamespace.register("SimScreen", SimScreen);

src/screen-name/graph/AxisGestureHandler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import type { ChartRectangle, ChartTransform } from "scenerystack/bamboo";
1818
import { Range, Vector2 } from "scenerystack/dot";
1919
import { DragListener, type Pointer, type Rectangle } from "scenerystack/scenery";
2020
import { GRAPH_ZOOM_FACTOR } from "../../TrackLabConstants.js";
21-
import trackLab from "../../TrackLabNamespace.js";
21+
import TrackLabNamespace from "../../TrackLabNamespace.js";
2222
import type GraphDataManager from "./GraphDataManager.js";
2323
import type { ChartConfig, GraphDimensions } from "./GraphInteractionHandler.js";
2424

@@ -284,4 +284,4 @@ export default class AxisGestureHandler {
284284
}
285285
}
286286

287-
trackLab.register("AxisGestureHandler", AxisGestureHandler);
287+
TrackLabNamespace.register("AxisGestureHandler", AxisGestureHandler);

src/screen-name/graph/ConfigurableGraph.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ import { ChartTransform, LinePlot } from "scenerystack/bamboo";
5858
import { Range } from "scenerystack/dot";
5959
import { Node } from "scenerystack/scenery";
6060
import { StringManager } from "../../i18n/StringManager.js";
61-
import trackLab from "../../TrackLabNamespace.js";
61+
import TrackLabNamespace from "../../TrackLabNamespace.js";
6262
import GraphControlsPanel from "./GraphControlsPanel.js";
6363
import GraphDataManager from "./GraphDataManager.js";
6464
import GraphInteractionHandler from "./GraphInteractionHandler.js";
@@ -421,4 +421,4 @@ export default class ConfigurableGraph extends Node {
421421
}
422422

423423
// Register with namespace for debugging accessibility
424-
trackLab.register("ConfigurableGraph", ConfigurableGraph);
424+
TrackLabNamespace.register("ConfigurableGraph", ConfigurableGraph);

0 commit comments

Comments
 (0)