Skip to content

Commit

Permalink
graceful support for QSM, #1654
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Kauzmann <[email protected]>
  • Loading branch information
zepumph committed Sep 9, 2024
1 parent 0363fa9 commit 88a4d23
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions js/SceneryQueryParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@

import scenery from './scenery.js';

const sceneryQueryParameters = QueryStringMachine.getAll( {
// All scenery query parameters MUST have a default value, since we do not always support QSM as a global.
const schema = {

/**
* If this is a finite number AND assertions are enabled, it will track maximum Node parent counts, and
Expand All @@ -29,7 +30,14 @@ const sceneryQueryParameters = QueryStringMachine.getAll( {
defaultValue: Number.POSITIVE_INFINITY,
public: false
}
} );
} satisfies Record<string, QueryStringMachineSchema>;

// Scenery doesn't depend on QSM, so be graceful here, and take default values.
const sceneryQueryParameters = window.hasOwnProperty( 'QueryStringMachine' ) ?
QueryStringMachine.getAll( schema ) :
( Object.keys( schema ) as ( keyof typeof schema )[] ).map( key => {
return { [ key ]: schema[ key ].defaultValue };
} );

scenery.register( 'sceneryQueryParameters', sceneryQueryParameters );

Expand Down

0 comments on commit 88a4d23

Please sign in to comment.