Skip to content

Commit

Permalink
use globalThis to access feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
yannbf committed Jan 7, 2025
1 parent b1bd157 commit ea5b8cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/addons/actions/src/runtime/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export function action(name: string, options: ActionOptions = {}): HandlerFuncti
);

if (storyRenderer) {
const deprecated = !window?.FEATURES?.disallowImplicitActionsInRenderV8;
const deprecated = !globalThis?.FEATURES?.disallowImplicitActionsInRenderV8;
const error = new ImplicitActionsDuringRendering({
phase: storyRenderer.phase!,
name,
Expand Down
8 changes: 5 additions & 3 deletions code/addons/backgrounds/src/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { withBackground } from './legacy/withBackgroundLegacy';
import { withGrid } from './legacy/withGridLegacy';
import type { Config, GlobalState } from './types';

export const decorators: Addon_DecoratorFunction[] = FEATURES?.backgroundsStoryGlobals
export const decorators: Addon_DecoratorFunction[] = globalThis.FEATURES?.backgroundsStoryGlobals
? [withBackgroundAndGrid]
: [withGrid, withBackground];

Expand All @@ -20,7 +20,7 @@ export const parameters = {
},
disable: false,
// TODO: remove in 9.0
...(!FEATURES?.backgroundsStoryGlobals && {
...(!globalThis.FEATURES?.backgroundsStoryGlobals && {
values: Object.values(DEFAULT_BACKGROUNDS),
}),
} satisfies Partial<Config>,
Expand All @@ -30,4 +30,6 @@ const modern: Record<string, GlobalState> = {
[KEY]: { value: undefined, grid: false },
};

export const initialGlobals = FEATURES?.backgroundsStoryGlobals ? modern : { [KEY]: null };
export const initialGlobals = globalThis.FEATURES?.backgroundsStoryGlobals
? modern
: { [KEY]: null };
3 changes: 1 addition & 2 deletions code/addons/viewport/src/preview.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { PARAM_KEY as KEY } from './constants';
import { MINIMAL_VIEWPORTS } from './defaults';
import type { GlobalState } from './types';

const modern: Record<string, GlobalState> = {
Expand All @@ -9,4 +8,4 @@ const modern: Record<string, GlobalState> = {
// TODO: remove in 9.0
const legacy = { viewport: 'reset', viewportRotated: false };

export const initialGlobals = FEATURES?.viewportStoryGlobals ? modern : legacy;
export const initialGlobals = globalThis.FEATURES?.viewportStoryGlobals ? modern : legacy;

0 comments on commit ea5b8cb

Please sign in to comment.