diff --git a/code/__mocks__/inject-decorator.ts.ugly-comments-stories.txt b/code/__mocks__/inject-decorator.ts.ugly-comments-stories.txt
index ea3a9450889d..b1f6925fba78 100644
--- a/code/__mocks__/inject-decorator.ts.ugly-comments-stories.txt
+++ b/code/__mocks__/inject-decorator.ts.ugly-comments-stories.txt
@@ -1,4 +1,3 @@
-/* global window */
/* eslint-disable global-require, import/no-dynamic-require */
import React from 'react';
diff --git a/code/__mocks__/inject-decorator.ugly-comments-stories.txt b/code/__mocks__/inject-decorator.ugly-comments-stories.txt
index 926e8cd5e97a..93f2875cc1c2 100644
--- a/code/__mocks__/inject-decorator.ugly-comments-stories.txt
+++ b/code/__mocks__/inject-decorator.ugly-comments-stories.txt
@@ -1,4 +1,3 @@
-/* global window */
/* eslint-disable global-require, import/no-dynamic-require */
import React from 'react';
diff --git a/code/addons/a11y/package.json b/code/addons/a11y/package.json
index e2f53ca7774a..a5b94022b42e 100644
--- a/code/addons/a11y/package.json
+++ b/code/addons/a11y/package.json
@@ -67,12 +67,12 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"axe-core": "^4.2.0",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"react-resize-detector": "^7.1.2"
},
diff --git a/code/addons/a11y/src/a11yRunner.ts b/code/addons/a11y/src/a11yRunner.ts
index 88dd78a64660..5a71adee35e1 100644
--- a/code/addons/a11y/src/a11yRunner.ts
+++ b/code/addons/a11y/src/a11yRunner.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { addons } from '@storybook/preview-api';
import { EVENTS } from './constants';
import type { A11yParameters } from './params';
@@ -37,7 +37,12 @@ const run = async (storyId: string) => {
const axe = (await import('axe-core')).default;
const { element = '#storybook-root', config, options = {} } = input;
- const htmlElement = document.querySelector(element);
+ const htmlElement = document.querySelector(element as string);
+
+ if (!htmlElement) {
+ return;
+ }
+
axe.reset();
if (config) {
axe.configure(config);
diff --git a/code/addons/a11y/src/typings.d.ts b/code/addons/a11y/src/typings.d.ts
index 2f4eb9cf4fd9..f2db962c4d60 100644
--- a/code/addons/a11y/src/typings.d.ts
+++ b/code/addons/a11y/src/typings.d.ts
@@ -1 +1,2 @@
-declare module 'global';
+/* eslint-disable @typescript-eslint/naming-convention */
+declare var __STORYBOOK_STORY_STORE__: any;
diff --git a/code/addons/a11y/template/stories/parameters.stories.ts b/code/addons/a11y/template/stories/parameters.stories.ts
index 5b692bf9f87b..0b7f5dcad5b9 100644
--- a/code/addons/a11y/template/stories/parameters.stories.ts
+++ b/code/addons/a11y/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Html,
diff --git a/code/addons/a11y/template/stories/tests.stories.ts b/code/addons/a11y/template/stories/tests.stories.ts
index 03346296518a..407c77bd19f8 100644
--- a/code/addons/a11y/template/stories/tests.stories.ts
+++ b/code/addons/a11y/template/stories/tests.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Html,
diff --git a/code/addons/actions/package.json b/code/addons/actions/package.json
index 9f66ce2d8ff7..ef714d4d483f 100644
--- a/code/addons/actions/package.json
+++ b/code/addons/actions/package.json
@@ -79,12 +79,12 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"dequal": "^2.0.2",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"polished": "^4.2.2",
"prop-types": "^15.7.2",
diff --git a/code/addons/actions/src/decorator.ts b/code/addons/actions/src/decorator.ts
index 1400f15ab250..4851a1bfad85 100644
--- a/code/addons/actions/src/decorator.ts
+++ b/code/addons/actions/src/decorator.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { useEffect, makeDecorator } from '@storybook/preview-api';
import { actions } from './runtime/actions';
diff --git a/code/addons/actions/src/typings.d.ts b/code/addons/actions/src/typings.d.ts
index 74f6623d4787..331fb83df5f4 100644
--- a/code/addons/actions/src/typings.d.ts
+++ b/code/addons/actions/src/typings.d.ts
@@ -1,3 +1,2 @@
// TODO: following packages need definition files or a TS migration
-declare module 'global';
declare module 'uuid-browser/v4';
diff --git a/code/addons/actions/template/stories/argtype.stories.ts b/code/addons/actions/template/stories/argtype.stories.ts
index 1f04316f7dff..352bc74f1311 100644
--- a/code/addons/actions/template/stories/argtype.stories.ts
+++ b/code/addons/actions/template/stories/argtype.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/actions/template/stories/basics.stories.ts b/code/addons/actions/template/stories/basics.stories.ts
index 86523878728e..4b6eba0ae430 100644
--- a/code/addons/actions/template/stories/basics.stories.ts
+++ b/code/addons/actions/template/stories/basics.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { action } from '@storybook/addon-actions';
diff --git a/code/addons/actions/template/stories/configs.stories.ts b/code/addons/actions/template/stories/configs.stories.ts
index 51ccac3b0084..e52c17606bb6 100644
--- a/code/addons/actions/template/stories/configs.stories.ts
+++ b/code/addons/actions/template/stories/configs.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { actions, configureActions } from '@storybook/addon-actions';
diff --git a/code/addons/actions/template/stories/parameters.stories.ts b/code/addons/actions/template/stories/parameters.stories.ts
index 5848c25b8375..e4a5bf0ef9dd 100644
--- a/code/addons/actions/template/stories/parameters.stories.ts
+++ b/code/addons/actions/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { withActions } from '@storybook/addon-actions/decorator';
export default {
diff --git a/code/addons/backgrounds/package.json b/code/addons/backgrounds/package.json
index 550070ecfa40..cea6c155c715 100644
--- a/code/addons/backgrounds/package.json
+++ b/code/addons/backgrounds/package.json
@@ -78,11 +78,11 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"memoizerific": "^1.11.3",
"ts-dedent": "^2.0.0"
},
diff --git a/code/addons/backgrounds/src/helpers/index.ts b/code/addons/backgrounds/src/helpers/index.ts
index e56b147ffc35..39065eec6648 100644
--- a/code/addons/backgrounds/src/helpers/index.ts
+++ b/code/addons/backgrounds/src/helpers/index.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import { logger } from '@storybook/client-logger';
diff --git a/code/addons/backgrounds/src/typings.d.ts b/code/addons/backgrounds/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/addons/backgrounds/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/addons/backgrounds/template/stories/grid.stories.ts b/code/addons/backgrounds/template/stories/grid.stories.ts
index e6a75a1dba76..361c18752ebb 100644
--- a/code/addons/backgrounds/template/stories/grid.stories.ts
+++ b/code/addons/backgrounds/template/stories/grid.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/backgrounds/template/stories/parameters.stories.ts b/code/addons/backgrounds/template/stories/parameters.stories.ts
index 1d57ea959143..e6085424b99e 100644
--- a/code/addons/backgrounds/template/stories/parameters.stories.ts
+++ b/code/addons/backgrounds/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
const COLORS = [
{ name: 'red', value: '#FB001D' },
diff --git a/code/addons/controls/package.json b/code/addons/controls/package.json
index fba7a3de2ddf..4ee2a3042bee 100644
--- a/code/addons/controls/package.json
+++ b/code/addons/controls/package.json
@@ -73,7 +73,7 @@
"@storybook/core-common": "7.0.0-beta.12",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/node-logger": "7.0.0-beta.12",
- "@storybook/preview-api": "7.0.0-beta.12",
+ "@storybook/preview-api": "7.0.0-beta.8",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"lodash": "^4.17.21",
diff --git a/code/addons/controls/template/stories/basics.stories.ts b/code/addons/controls/template/stories/basics.stories.ts
index f5151890fdda..8b7bbebe665f 100644
--- a/code/addons/controls/template/stories/basics.stories.ts
+++ b/code/addons/controls/template/stories/basics.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/conditional.stories.ts b/code/addons/controls/template/stories/conditional.stories.ts
index b08b63f13138..7df82610f16a 100644
--- a/code/addons/controls/template/stories/conditional.stories.ts
+++ b/code/addons/controls/template/stories/conditional.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/disable.stories.ts b/code/addons/controls/template/stories/disable.stories.ts
index f95160a034c9..3d717eca352d 100644
--- a/code/addons/controls/template/stories/disable.stories.ts
+++ b/code/addons/controls/template/stories/disable.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/filters.stories.ts b/code/addons/controls/template/stories/filters.stories.ts
index 4ea5c36316dd..4bc7904aa89a 100644
--- a/code/addons/controls/template/stories/filters.stories.ts
+++ b/code/addons/controls/template/stories/filters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/issues.stories.ts b/code/addons/controls/template/stories/issues.stories.ts
index 0b9cb463309c..462718633c1a 100644
--- a/code/addons/controls/template/stories/issues.stories.ts
+++ b/code/addons/controls/template/stories/issues.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/matchers.stories.ts b/code/addons/controls/template/stories/matchers.stories.ts
index b17b614cc396..266debeff71c 100644
--- a/code/addons/controls/template/stories/matchers.stories.ts
+++ b/code/addons/controls/template/stories/matchers.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/controls/template/stories/sorting.stories.ts b/code/addons/controls/template/stories/sorting.stories.ts
index 510314bceca1..fad557c3ee47 100644
--- a/code/addons/controls/template/stories/sorting.stories.ts
+++ b/code/addons/controls/template/stories/sorting.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
export default {
diff --git a/code/addons/docs/angular/index.js b/code/addons/docs/angular/index.js
index 0236c45fec3a..120597b47b00 100644
--- a/code/addons/docs/angular/index.js
+++ b/code/addons/docs/angular/index.js
@@ -1,7 +1,7 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+import { global } from '@storybook/global';
export const setCompodocJson = (compodocJson) => {
// @ts-expect-error (Converted from ts-ignore)
- window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
+ global.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
};
diff --git a/code/addons/docs/ember/index.js b/code/addons/docs/ember/index.js
index b4ff874067cd..eab68763ab45 100644
--- a/code/addons/docs/ember/index.js
+++ b/code/addons/docs/ember/index.js
@@ -1,6 +1,6 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+import { global } from '@storybook/global';
export const setJSONDoc = (jsondoc) => {
- window.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
+ global.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
};
diff --git a/code/addons/docs/package.json b/code/addons/docs/package.json
index f8071f602206..552adeca0d12 100644
--- a/code/addons/docs/package.json
+++ b/code/addons/docs/package.json
@@ -108,6 +108,7 @@
"@storybook/components": "7.0.0-beta.12",
"@storybook/csf-plugin": "7.0.0-beta.12",
"@storybook/csf-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/mdx2-csf": "next",
"@storybook/node-logger": "7.0.0-beta.12",
"@storybook/postinstall": "7.0.0-beta.12",
@@ -115,7 +116,6 @@
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"fs-extra": "^9.0.1",
- "global": "^4.4.0",
"remark-external-links": "^8.0.0",
"remark-slug": "^6.0.0",
"ts-dedent": "^2.0.0"
diff --git a/code/addons/docs/src/typings.d.ts b/code/addons/docs/src/typings.d.ts
index 09cc7e5fa21a..5528b7d9f1c6 100644
--- a/code/addons/docs/src/typings.d.ts
+++ b/code/addons/docs/src/typings.d.ts
@@ -1,4 +1,3 @@
-declare module 'global';
declare module '@egoist/vue-to-react';
declare module 'remark-slug';
declare module 'remark-external-links';
diff --git a/code/addons/docs/template/stories/docs2/button.stories.ts b/code/addons/docs/template/stories/docs2/button.stories.ts
index 5119c70b7e61..14f45cee42df 100644
--- a/code/addons/docs/template/stories/docs2/button.stories.ts
+++ b/code/addons/docs/template/stories/docs2/button.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/docspage/autoplay.stories.ts b/code/addons/docs/template/stories/docspage/autoplay.stories.ts
index 974837b582c4..50b01ae74504 100644
--- a/code/addons/docs/template/stories/docspage/autoplay.stories.ts
+++ b/code/addons/docs/template/stories/docspage/autoplay.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { expect } from '@storybook/jest';
import { within } from '@storybook/testing-library';
diff --git a/code/addons/docs/template/stories/docspage/basic.stories.ts b/code/addons/docs/template/stories/docspage/basic.stories.ts
index 58a24a2eb472..cf8768751607 100644
--- a/code/addons/docs/template/stories/docspage/basic.stories.ts
+++ b/code/addons/docs/template/stories/docspage/basic.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/docspage/description.stories.ts b/code/addons/docs/template/stories/docspage/description.stories.ts
index 7eb04413a94a..98ed1de51473 100644
--- a/code/addons/docs/template/stories/docspage/description.stories.ts
+++ b/code/addons/docs/template/stories/docspage/description.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/docspage/extract-description.stories.ts b/code/addons/docs/template/stories/docspage/extract-description.stories.ts
index 51ab3513c58d..bc9033127f68 100644
--- a/code/addons/docs/template/stories/docspage/extract-description.stories.ts
+++ b/code/addons/docs/template/stories/docspage/extract-description.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/docspage/iframe.stories.ts b/code/addons/docs/template/stories/docspage/iframe.stories.ts
index df9cf977c9fc..8a087afca04a 100644
--- a/code/addons/docs/template/stories/docspage/iframe.stories.ts
+++ b/code/addons/docs/template/stories/docspage/iframe.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/docspage/overflow.stories.ts b/code/addons/docs/template/stories/docspage/overflow.stories.ts
index a281100c8854..9c3c7f7b70d9 100644
--- a/code/addons/docs/template/stories/docspage/overflow.stories.ts
+++ b/code/addons/docs/template/stories/docspage/overflow.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Pre,
diff --git a/code/addons/docs/template/stories/docspage/override.stories.ts b/code/addons/docs/template/stories/docspage/override.stories.ts
index b96dde24c07a..0f46a108c325 100644
--- a/code/addons/docs/template/stories/docspage/override.stories.ts
+++ b/code/addons/docs/template/stories/docspage/override.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
// FIXME: do this using basic React functions for multi-framework
// once sandbox linking is working
diff --git a/code/addons/docs/template/stories/docspage/source.stories.ts b/code/addons/docs/template/stories/docspage/source.stories.ts
index 62eb646c6a00..84d12fe56f1c 100644
--- a/code/addons/docs/template/stories/docspage/source.stories.ts
+++ b/code/addons/docs/template/stories/docspage/source.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/addons/docs/template/stories/stories-mdx/basic.stories.mdx b/code/addons/docs/template/stories/stories-mdx/basic.stories.mdx
index a8e6ea8ff07a..7aec7745397d 100644
--- a/code/addons/docs/template/stories/stories-mdx/basic.stories.mdx
+++ b/code/addons/docs/template/stories/stories-mdx/basic.stories.mdx
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
diff --git a/code/addons/docs/template/stories/stories-mdx/csf-in-mdx.stories.mdx b/code/addons/docs/template/stories/stories-mdx/csf-in-mdx.stories.mdx
index 8984faa476b9..fda87f38fd6b 100644
--- a/code/addons/docs/template/stories/stories-mdx/csf-in-mdx.stories.mdx
+++ b/code/addons/docs/template/stories/stories-mdx/csf-in-mdx.stories.mdx
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import * as Csf from './csf-in-mdx.stories.js';
diff --git a/code/addons/docs/template/stories/stories-mdx/iframe.stories.mdx b/code/addons/docs/template/stories/stories-mdx/iframe.stories.mdx
index d77b4d5972a8..f947df3b35cf 100644
--- a/code/addons/docs/template/stories/stories-mdx/iframe.stories.mdx
+++ b/code/addons/docs/template/stories/stories-mdx/iframe.stories.mdx
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
diff --git a/code/addons/docs/template/stories/stories-mdx/play-functions.stories.mdx b/code/addons/docs/template/stories/stories-mdx/play-functions.stories.mdx
index 3b194432193b..aef8fe5df0ba 100644
--- a/code/addons/docs/template/stories/stories-mdx/play-functions.stories.mdx
+++ b/code/addons/docs/template/stories/stories-mdx/play-functions.stories.mdx
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
console.log('component play')} />
diff --git a/code/addons/highlight/package.json b/code/addons/highlight/package.json
index d2c2173880fd..49671f0da586 100644
--- a/code/addons/highlight/package.json
+++ b/code/addons/highlight/package.json
@@ -61,8 +61,8 @@
},
"dependencies": {
"@storybook/core-events": "7.0.0-beta.12",
- "@storybook/preview-api": "7.0.0-beta.12",
- "global": "^4.4.0"
+ "@storybook/global": "^5.0.0",
+ "@storybook/preview-api": "7.0.0-beta.12"
},
"devDependencies": {
"@types/webpack-env": "^1.16.0",
diff --git a/code/addons/highlight/src/preview.ts b/code/addons/highlight/src/preview.ts
index 36e486b90f78..9b90e6224122 100644
--- a/code/addons/highlight/src/preview.ts
+++ b/code/addons/highlight/src/preview.ts
@@ -1,5 +1,5 @@
/* eslint-env browser */
-import global from 'global';
+import { global } from '@storybook/global';
import { addons } from '@storybook/preview-api';
import { STORY_CHANGED } from '@storybook/core-events';
import { HIGHLIGHT, RESET_HIGHLIGHT, HIGHLIGHT_STYLE_ID } from './constants';
diff --git a/code/addons/highlight/src/typings.d.ts b/code/addons/highlight/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/addons/highlight/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/addons/interactions/package.json b/code/addons/interactions/package.json
index 5624129cf794..8caba333e27b 100644
--- a/code/addons/interactions/package.json
+++ b/code/addons/interactions/package.json
@@ -75,12 +75,12 @@
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-common": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/instrumenter": "7.0.0-beta.12",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"jest-mock": "^27.0.6",
"polished": "^4.2.2",
"ts-dedent": "^2.2.0"
diff --git a/code/addons/interactions/src/Panel.tsx b/code/addons/interactions/src/Panel.tsx
index e4df36d5474c..b0eaf8c1d093 100644
--- a/code/addons/interactions/src/Panel.tsx
+++ b/code/addons/interactions/src/Panel.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import * as React from 'react';
import { useChannel, useParameter } from '@storybook/manager-api';
import {
@@ -102,10 +102,10 @@ export const Panel: React.FC<{ active: boolean }> = (props) => {
const endRef = React.useRef();
React.useEffect(() => {
let observer: IntersectionObserver;
- if (global.window.IntersectionObserver) {
- observer = new global.window.IntersectionObserver(
+ if (global.IntersectionObserver) {
+ observer = new global.IntersectionObserver(
([end]: any) => setScrollTarget(end.isIntersecting ? undefined : end.target),
- { root: global.window.document.querySelector('#panel-tab-content') }
+ { root: global.document.querySelector('#panel-tab-content') }
);
if (endRef.current) observer.observe(endRef.current);
}
diff --git a/code/addons/interactions/src/typings.d.ts b/code/addons/interactions/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/addons/interactions/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/addons/interactions/template/stories/basics.stories.ts b/code/addons/interactions/template/stories/basics.stories.ts
index 08de4183d9c1..c8ddea0b6ea3 100644
--- a/code/addons/interactions/template/stories/basics.stories.ts
+++ b/code/addons/interactions/template/stories/basics.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import {
within,
waitFor,
diff --git a/code/addons/jest/package.json b/code/addons/jest/package.json
index 309633aedb24..8b631ae8a0b5 100644
--- a/code/addons/jest/package.json
+++ b/code/addons/jest/package.json
@@ -72,10 +72,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
- "global": "^4.4.0",
"react-resize-detector": "^7.1.2",
"upath": "^1.2.0"
},
diff --git a/code/addons/jest/src/typings.d.ts b/code/addons/jest/src/typings.d.ts
deleted file mode 100644
index a41bf8a45b79..000000000000
--- a/code/addons/jest/src/typings.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// TODO: following packages need definition files or a TS migration
-declare module 'global';
diff --git a/code/addons/links/package.json b/code/addons/links/package.json
index e10c907b52e3..c066feab9bbf 100644
--- a/code/addons/links/package.json
+++ b/code/addons/links/package.json
@@ -79,11 +79,11 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
"@storybook/csf": "next",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/router": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"prop-types": "^15.7.2",
"ts-dedent": "^2.0.0"
},
diff --git a/code/addons/links/src/react/components/link.test.tsx b/code/addons/links/src/react/components/link.test.tsx
index 87796da7aca9..b5d444a5ffc6 100644
--- a/code/addons/links/src/react/components/link.test.tsx
+++ b/code/addons/links/src/react/components/link.test.tsx
@@ -6,17 +6,19 @@ import { SELECT_STORY } from '@storybook/core-events';
import LinkTo from './link';
jest.mock('@storybook/preview-api');
-jest.mock('global', () => ({
- document: {
- location: {
- origin: 'origin',
- pathname: 'pathname',
- search: 'search',
+jest.mock('@storybook/global', () => ({
+ global: {
+ document: {
+ location: {
+ origin: 'origin',
+ pathname: 'pathname',
+ search: 'search',
+ },
+ },
+ window: global,
+ __STORYBOOK_STORY_STORE__: {
+ fromId: jest.fn(() => ({})),
},
- },
- window: global,
- __STORYBOOK_STORY_STORE__: {
- fromId: jest.fn(() => ({})),
},
}));
diff --git a/code/addons/links/src/typings.d.ts b/code/addons/links/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/addons/links/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/addons/links/src/utils.test.ts b/code/addons/links/src/utils.test.ts
index 0a77f40bd419..1adbdf329aed 100644
--- a/code/addons/links/src/utils.test.ts
+++ b/code/addons/links/src/utils.test.ts
@@ -4,9 +4,11 @@ import { SELECT_STORY } from '@storybook/core-events';
import { linkTo, hrefTo } from './utils';
jest.mock('@storybook/preview-api');
-jest.mock('global', () => ({
- document: global.document,
- window: global,
+jest.mock('@storybook/global', () => ({
+ global: {
+ document: global.document,
+ window: global,
+ },
}));
const mockAddons = addons as unknown as jest.Mocked;
diff --git a/code/addons/links/src/utils.ts b/code/addons/links/src/utils.ts
index 14d1fcde1ca3..21c04a469ae2 100644
--- a/code/addons/links/src/utils.ts
+++ b/code/addons/links/src/utils.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { addons, makeDecorator } from '@storybook/preview-api';
import { STORY_CHANGED, SELECT_STORY } from '@storybook/core-events';
import type { StoryId, StoryName, ComponentTitle } from '@storybook/types';
diff --git a/code/addons/links/template/stories/decorator.stories.ts b/code/addons/links/template/stories/decorator.stories.ts
index 562633320441..218833a75800 100644
--- a/code/addons/links/template/stories/decorator.stories.ts
+++ b/code/addons/links/template/stories/decorator.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { withLinks } from '@storybook/addon-links';
export default {
diff --git a/code/addons/links/template/stories/linkto.stories.ts b/code/addons/links/template/stories/linkto.stories.ts
index 09066ccfc86a..bdc752c2ae17 100644
--- a/code/addons/links/template/stories/linkto.stories.ts
+++ b/code/addons/links/template/stories/linkto.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { linkTo } from '@storybook/addon-links';
export default {
diff --git a/code/addons/links/template/stories/scroll.stories.ts b/code/addons/links/template/stories/scroll.stories.ts
index 0445506d1a99..a7d6a3937763 100644
--- a/code/addons/links/template/stories/scroll.stories.ts
+++ b/code/addons/links/template/stories/scroll.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { withLinks } from '@storybook/addon-links';
export default {
diff --git a/code/addons/measure/package.json b/code/addons/measure/package.json
index 67d68fec039a..8ce721a423ed 100644
--- a/code/addons/measure/package.json
+++ b/code/addons/measure/package.json
@@ -77,10 +77,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
- "@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0"
+ "@storybook/types": "7.0.0-beta.12"
},
"devDependencies": {
"typescript": "~4.9.3"
diff --git a/code/addons/measure/src/box-model/canvas.ts b/code/addons/measure/src/box-model/canvas.ts
index e35ee8a6eac8..653e3f005ac1 100644
--- a/code/addons/measure/src/box-model/canvas.ts
+++ b/code/addons/measure/src/box-model/canvas.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-param-reassign */
-import global from 'global';
+import { global } from '@storybook/global';
interface Size {
width: number;
diff --git a/code/addons/measure/src/box-model/visualizer.ts b/code/addons/measure/src/box-model/visualizer.ts
index 59904860948c..eba2de27573b 100644
--- a/code/addons/measure/src/box-model/visualizer.ts
+++ b/code/addons/measure/src/box-model/visualizer.ts
@@ -2,7 +2,7 @@
/**
* Based on https://gist.github.com/awestbro/e668c12662ad354f02a413205b65fce7
*/
-import global from 'global';
+import { global } from '@storybook/global';
import { draw } from './canvas';
import type { Label, LabelStack } from './labels';
import { labelStacks } from './labels';
diff --git a/code/addons/measure/src/typings.d.ts b/code/addons/measure/src/typings.d.ts
index 4a8ad58bf897..19bb66f5544f 100644
--- a/code/addons/measure/src/typings.d.ts
+++ b/code/addons/measure/src/typings.d.ts
@@ -1,5 +1,3 @@
-declare module 'global';
-
interface Margin {
top: number;
bottom: number;
diff --git a/code/addons/measure/src/util.ts b/code/addons/measure/src/util.ts
index f4017c41dff7..6ad580df97e8 100644
--- a/code/addons/measure/src/util.ts
+++ b/code/addons/measure/src/util.ts
@@ -1,9 +1,9 @@
-import global from 'global';
+import { global } from '@storybook/global';
export const deepElementFromPoint = (x: number, y: number) => {
- const element = global.document.elementFromPoint(x, y);
+ const element = global.document.elementFromPoint(x, y) as HTMLElement;
- const crawlShadows = (node: Element): Element => {
+ const crawlShadows = (node: HTMLElement): HTMLElement => {
if (node && node.shadowRoot) {
// elementFromPoint() doesn't exist in ShadowRoot type
const nestedElement = (node.shadowRoot as any).elementFromPoint(x, y);
diff --git a/code/addons/outline/package.json b/code/addons/outline/package.json
index 629492d7a9d7..de3b894774d8 100644
--- a/code/addons/outline/package.json
+++ b/code/addons/outline/package.json
@@ -80,10 +80,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
diff --git a/code/addons/outline/src/helpers.ts b/code/addons/outline/src/helpers.ts
index 569a80e21d7b..d427db2fa0b4 100644
--- a/code/addons/outline/src/helpers.ts
+++ b/code/addons/outline/src/helpers.ts
@@ -1,11 +1,12 @@
-import global from 'global';
+import { global } from '@storybook/global';
export const clearStyles = (selector: string | string[]) => {
const selectors = Array.isArray(selector) ? selector : [selector];
selectors.forEach(clearStyle);
};
-const clearStyle = (selector: string | string[]) => {
+const clearStyle = (input: string | string[]) => {
+ const selector = typeof input === 'string' ? input : input.join('');
const element = global.document.getElementById(selector);
if (element && element.parentElement) {
element.parentElement.removeChild(element);
diff --git a/code/addons/outline/src/typings.d.ts b/code/addons/outline/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/addons/outline/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/addons/storyshots/storyshots-core/package.json b/code/addons/storyshots/storyshots-core/package.json
index 928c65511397..b0ddcce18c0c 100644
--- a/code/addons/storyshots/storyshots-core/package.json
+++ b/code/addons/storyshots/storyshots-core/package.json
@@ -42,13 +42,13 @@
"@storybook/client-api": "7.0.0-beta.12",
"@storybook/core-common": "7.0.0-beta.12",
"@storybook/core-webpack": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"@types/glob": "^7.1.3",
"@types/jest-specific-snapshot": "^0.5.6",
"core-js": "^3.8.2",
"glob": "^7.1.6",
- "global": "^4.4.0",
"jest-specific-snapshot": "^7.0.0",
"preact-render-to-string": "^5.1.19",
"pretty-format": "^29.0.0",
diff --git a/code/addons/storyshots/storyshots-core/src/api/index.ts b/code/addons/storyshots/storyshots-core/src/api/index.ts
index c05c2f23a210..301d5cbf8c36 100644
--- a/code/addons/storyshots/storyshots-core/src/api/index.ts
+++ b/code/addons/storyshots/storyshots-core/src/api/index.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { addons, mockChannel } from '@storybook/preview-api';
import ensureOptionsDefaults from './ensureOptionsDefaults';
import snapshotsTests from './snapshotsTestsTemplate';
@@ -16,6 +16,7 @@ function callTestMethodGlobals(
) {
methods.forEach((method) => {
if (typeof testMethod[method] === 'function') {
+ // @ts-expect-error (ignore)
global[method](testMethod[method], testMethod[method].timeout);
}
});
diff --git a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
index d52260268104..b27a8d086f76 100644
--- a/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
+++ b/code/addons/storyshots/storyshots-core/src/api/integrityTestTemplate.ts
@@ -1,7 +1,7 @@
/* eslint-disable jest/no-export */
import fs from 'fs';
import glob from 'glob';
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
const { describe, it } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts b/code/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts
index c22679a11a83..1e2ee8cbf9f4 100644
--- a/code/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts
+++ b/code/addons/storyshots/storyshots-core/src/api/snapshotsTestsTemplate.ts
@@ -1,6 +1,6 @@
/* eslint-disable jest/no-export */
/* eslint-disable jest/expect-expect */
-import global from 'global';
+import { global } from '@storybook/global';
import { addSerializer } from 'jest-specific-snapshot';
const { describe, it } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
index d2a029c27a44..ec54eedab1e7 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/configure.ts
@@ -11,7 +11,7 @@ import type {
import { toRequireContext } from '@storybook/core-webpack';
import { normalizeStoriesEntry } from '@storybook/core-common';
import registerRequireContextHook from '@storybook/babel-plugin-require-context-hook/register';
-import global from 'global';
+import { global } from '@storybook/global';
import type { ClientApi } from './Loader';
import type { StoryshotsOptions } from '../api/StoryshotsOptions';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
index d75c563eef2b..df86afc1961e 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/html/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import configure from '../configure';
import type { Loader } from '../Loader';
import type { StoryshotsOptions } from '../../api/StoryshotsOptions';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/html/renderTree.ts b/code/addons/storyshots/storyshots-core/src/frameworks/html/renderTree.ts
index 102d18e82bcf..2347acb15867 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/html/renderTree.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/html/renderTree.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { document, Node } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
index b02ccaf30412..b938dac3f928 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/preact/loader.ts
@@ -1,7 +1,7 @@
/** @jsxRuntime classic */
/** @jsx h */
-import global from 'global';
+import { global } from '@storybook/global';
import configure from '../configure';
import hasDependency from '../hasDependency';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
index ffe67f771544..178ef3c1d7b5 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/rax/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import configure from '../configure';
import hasDependency from '../hasDependency';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
index 8a174ee11af8..598bfc300601 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/riot/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import hasDependency from '../hasDependency';
import configure from '../configure';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/riot/renderTree.ts b/code/addons/storyshots/storyshots-core/src/frameworks/riot/renderTree.ts
index c4f1ce24419d..085065635acf 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/riot/renderTree.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/riot/renderTree.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { document } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
index 0135af40b649..5bd09594013c 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import hasDependency from '../hasDependency';
import configure from '../configure';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/renderTree.ts b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/renderTree.ts
index 9d75b8b31f59..78c19bd1ab66 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/svelte/renderTree.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/svelte/renderTree.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { set_current_component } from 'svelte/internal';
const { document } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
index 02ef63c066d5..a29a88a2d98b 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/vue/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import hasDependency from '../hasDependency';
import configure from '../configure';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
index 91d40dd35d7c..3fed6869e1a2 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import hasDependency from '../hasDependency';
import configure from '../configure';
import type { Loader } from '../Loader';
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/renderTree.ts b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/renderTree.ts
index bcc8b5b3b165..854cb485b3c1 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/vue3/renderTree.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/vue3/renderTree.ts
@@ -1,5 +1,5 @@
import * as Vue from 'vue';
-import global from 'global';
+import { global } from '@storybook/global';
const { document } = global;
diff --git a/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts b/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
index 41ac97a75117..e3536d85d99d 100644
--- a/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
+++ b/code/addons/storyshots/storyshots-core/src/frameworks/web-components/loader.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import configure from '../configure';
import type { Loader } from '../Loader';
import type { StoryshotsOptions } from '../../api/StoryshotsOptions';
diff --git a/code/addons/storyshots/storyshots-core/src/typings.d.ts b/code/addons/storyshots/storyshots-core/src/typings.d.ts
index 03f1a3f1a323..8a3b5786945d 100644
--- a/code/addons/storyshots/storyshots-core/src/typings.d.ts
+++ b/code/addons/storyshots/storyshots-core/src/typings.d.ts
@@ -1,7 +1,14 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle */
+/* eslint-disable @typescript-eslint/naming-convention */
declare module 'jest-preset-angular/*';
declare module 'preact-render-to-string/jsx';
declare module 'react-test-renderer*';
declare module 'rax-test-renderer*';
declare module '@storybook/babel-plugin-require-context-hook/register';
+
+declare var STORYBOOK_ENV: any;
+declare var STORIES: any;
+declare var FEATURES: any;
+declare var __STORYBOOK_STORY_STORE__: any;
+declare var __requireContext: any;
diff --git a/code/addons/toolbars/template/stories/globals.stories.ts b/code/addons/toolbars/template/stories/globals.stories.ts
index e5567bcb1513..1a99081dd9c0 100644
--- a/code/addons/toolbars/template/stories/globals.stories.ts
+++ b/code/addons/toolbars/template/stories/globals.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';
const greetingForLocale = (locale: string) => {
diff --git a/code/addons/viewport/package.json b/code/addons/viewport/package.json
index 56ab1dcdea63..d12e009b82fe 100644
--- a/code/addons/viewport/package.json
+++ b/code/addons/viewport/package.json
@@ -75,10 +75,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
- "global": "^4.4.0",
"memoizerific": "^1.11.3",
"prop-types": "^15.7.2"
},
diff --git a/code/addons/viewport/template/stories/parameters.stories.ts b/code/addons/viewport/template/stories/parameters.stories.ts
index 03b2b9e264c9..8ea3a1bbc4dc 100644
--- a/code/addons/viewport/template/stories/parameters.stories.ts
+++ b/code/addons/viewport/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { MINIMAL_VIEWPORTS } from '@storybook/addon-viewport';
export default {
diff --git a/code/frameworks/angular/package.json b/code/frameworks/angular/package.json
index db822f080b55..c136c4ccc084 100644
--- a/code/frameworks/angular/package.json
+++ b/code/frameworks/angular/package.json
@@ -42,6 +42,7 @@
"@storybook/core-server": "7.0.0-beta.12",
"@storybook/core-webpack": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/node-logger": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
@@ -53,7 +54,6 @@
"@types/webpack-env": "^1.18.0",
"core-js": "^3.8.2",
"find-up": "^5.0.0",
- "global": "^4.4.0",
"read-pkg-up": "^7.0.1",
"semver": "^7.3.7",
"telejson": "^7.0.3",
diff --git a/code/frameworks/angular/src/client/angular/helpers.ts b/code/frameworks/angular/src/client/angular/helpers.ts
index 10ce71718090..009a02298f9c 100644
--- a/code/frameworks/angular/src/client/angular/helpers.ts
+++ b/code/frameworks/angular/src/client/angular/helpers.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { NgModuleRef, Type, enableProdMode, NgModule, Component, NgZone } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
diff --git a/code/frameworks/angular/src/client/docs/compodoc.ts b/code/frameworks/angular/src/client/docs/compodoc.ts
index 481367ddb704..9785842648d0 100644
--- a/code/frameworks/angular/src/client/docs/compodoc.ts
+++ b/code/frameworks/angular/src/client/docs/compodoc.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+import { global } from '@storybook/global';
import { InputType, ArgTypes, SBType } from '@storybook/types';
import { logger } from '@storybook/client-logger';
@@ -21,12 +21,10 @@ export const isMethod = (methodOrProp: Method | Property): methodOrProp is Metho
};
export const setCompodocJson = (compodocJson: CompodocJson) => {
- // @ts-expect-error (Converted from ts-ignore)
- window.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
+ global.__STORYBOOK_COMPODOC_JSON__ = compodocJson;
};
-// @ts-expect-error (Converted from ts-ignore)
-export const getCompodocJson = (): CompodocJson => window.__STORYBOOK_COMPODOC_JSON__;
+export const getCompodocJson = (): CompodocJson => global.__STORYBOOK_COMPODOC_JSON__;
export const checkValidComponentOrDirective = (component: Component | Directive) => {
if (!component.name) {
@@ -193,7 +191,7 @@ const extractDefaultValueFromComments = (property: Property, value: any) => {
let commentValue = value;
property.jsdoctags.forEach((tag: JsDocTag) => {
if (['default', 'defaultvalue'].includes(tag.tagName.escapedText)) {
- const dom = new window.DOMParser().parseFromString(tag.comment, 'text/html');
+ const dom = new global.DOMParser().parseFromString(tag.comment, 'text/html');
commentValue = dom.body.textContent;
}
});
diff --git a/code/frameworks/angular/src/client/globals.ts b/code/frameworks/angular/src/client/globals.ts
index e6e55cbf924d..9e5f1fcfb9cb 100644
--- a/code/frameworks/angular/src/client/globals.ts
+++ b/code/frameworks/angular/src/client/globals.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
/**
* This file includes polyfills needed by Angular and is loaded before the app.
@@ -68,6 +68,4 @@ import 'zone.js/dist/zone'; // Included with Angular CLI.
*/
// import 'intl/locale-data/jsonp/en';
-const { window: globalWindow } = global;
-
-globalWindow.STORYBOOK_ENV = 'angular';
+global.STORYBOOK_ENV = 'angular';
diff --git a/code/frameworks/angular/src/typings.d.ts b/code/frameworks/angular/src/typings.d.ts
index d8f7c6f660ad..9af3b65be338 100644
--- a/code/frameworks/angular/src/typings.d.ts
+++ b/code/frameworks/angular/src/typings.d.ts
@@ -1,4 +1,19 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
// will be provided by the webpack define plugin
declare var NODE_ENV: string | undefined;
+
+declare var __STORYBOOK_ADDONS_CHANNEL__: any;
+declare var __STORYBOOK_ADDONS_PREVIEW: any;
+declare var __STORYBOOK_COMPODOC_JSON__: any;
+declare var __STORYBOOK_CLIENT_API__: any;
+declare var __STORYBOOK_PREVIEW__: any;
+declare var __STORYBOOK_STORY_STORE__: any;
+declare var CHANNEL_OPTIONS: any;
+declare var DOCS_OPTIONS: any;
+declare var FEATURES: any;
+declare var IS_STORYBOOK: any;
+declare var LOGLEVEL: any;
+declare var STORIES: any;
+declare var STORYBOOK_ENV: 'angular';
+declare var STORYBOOK_HOOKS_CONTEXT: any;
diff --git a/code/frameworks/angular/template/components/index.js b/code/frameworks/angular/template/components/index.js
index 11d1c72443bf..71aafe7204fc 100644
--- a/code/frameworks/angular/template/components/index.js
+++ b/code/frameworks/angular/template/components/index.js
@@ -1,8 +1,8 @@
-import globalThis from 'global';
+import { global } from '@storybook/global';
import Button from './button.component';
import Html from './html.component';
import Pre from './pre.component';
import Form from './form.component';
-globalThis.Components = { Button, Html, Pre, Form };
+global.Components = { Button, Html, Pre, Form };
diff --git a/code/frameworks/angular/template/stories/angular-mdx.stories.mdx b/code/frameworks/angular/template/stories/angular-mdx.stories.mdx
index 025f8c0663fc..afe20c14379b 100644
--- a/code/frameworks/angular/template/stories/angular-mdx.stories.mdx
+++ b/code/frameworks/angular/template/stories/angular-mdx.stories.mdx
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { moduleMetadata } from '@storybook/angular';
import { Meta, Story, Canvas } from '@storybook/addon-docs';
diff --git a/code/frameworks/angular/tsconfig.build.json b/code/frameworks/angular/tsconfig.build.json
index 6aa09e55adac..75efd9abab35 100644
--- a/code/frameworks/angular/tsconfig.build.json
+++ b/code/frameworks/angular/tsconfig.build.json
@@ -4,7 +4,7 @@
"compilerOptions": {
"target": "ES2020",
"module": "CommonJS",
- "lib": ["es2020", "dom"],
+ "lib": ["es2020", "dom", "dom.iterable"],
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"declaration": true,
diff --git a/code/frameworks/ember/package.json b/code/frameworks/ember/package.json
index 085f973c30ce..e79a790690ee 100644
--- a/code/frameworks/ember/package.json
+++ b/code/frameworks/ember/package.json
@@ -34,9 +34,9 @@
"@storybook/builder-webpack5": "7.0.0-beta.12",
"@storybook/core-common": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"read-pkg-up": "^7.0.1",
"ts-dedent": "^2.0.0"
},
diff --git a/code/frameworks/ember/src/client/docs/jsondoc.js b/code/frameworks/ember/src/client/docs/jsondoc.js
index f9e648ebc21b..9e7269af8d45 100644
--- a/code/frameworks/ember/src/client/docs/jsondoc.js
+++ b/code/frameworks/ember/src/client/docs/jsondoc.js
@@ -1,11 +1,11 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+import { global } from '@storybook/global';
export const setJSONDoc = (jsondoc) => {
- window.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
+ global.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
};
export const getJSONDoc = () => {
- return window.__EMBER_GENERATED_DOC_JSON__;
+ return global.__EMBER_GENERATED_DOC_JSON__;
};
export const extractArgTypes = (componentName) => {
diff --git a/code/frameworks/ember/src/client/preview/docs/jsondoc.js b/code/frameworks/ember/src/client/preview/docs/jsondoc.js
index f9e648ebc21b..9e7269af8d45 100644
--- a/code/frameworks/ember/src/client/preview/docs/jsondoc.js
+++ b/code/frameworks/ember/src/client/preview/docs/jsondoc.js
@@ -1,11 +1,11 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+import { global } from '@storybook/global';
export const setJSONDoc = (jsondoc) => {
- window.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
+ global.__EMBER_GENERATED_DOC_JSON__ = jsondoc;
};
export const getJSONDoc = () => {
- return window.__EMBER_GENERATED_DOC_JSON__;
+ return global.__EMBER_GENERATED_DOC_JSON__;
};
export const extractArgTypes = (componentName) => {
diff --git a/code/frameworks/ember/src/client/preview/globals.ts b/code/frameworks/ember/src/client/preview/globals.ts
index 5bb968d5c148..7291f2881442 100644
--- a/code/frameworks/ember/src/client/preview/globals.ts
+++ b/code/frameworks/ember/src/client/preview/globals.ts
@@ -1,6 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
-const { window: globalWindow } = global;
-
-globalWindow.STORYBOOK_NAME = process.env.STORYBOOK_NAME;
-globalWindow.STORYBOOK_ENV = 'ember';
+global.STORYBOOK_NAME = process.env.STORYBOOK_NAME;
+global.STORYBOOK_ENV = 'ember';
diff --git a/code/frameworks/ember/src/client/preview/render.ts b/code/frameworks/ember/src/client/preview/render.ts
index 9c9a61d96933..84121a6cd7bf 100644
--- a/code/frameworks/ember/src/client/preview/render.ts
+++ b/code/frameworks/ember/src/client/preview/render.ts
@@ -1,16 +1,16 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import type { RenderContext } from '@storybook/types';
// @ts-expect-error (Converted from ts-ignore)
import Component from '@ember/component'; // eslint-disable-line import/no-unresolved
import type { OptionsArgs, EmberRenderer } from './types';
-const { window: globalWindow, document } = global;
+const { document } = global;
const rootEl = document.getElementById('storybook-root');
-const config = globalWindow.require(`${globalWindow.STORYBOOK_NAME}/config/environment`);
-const app = globalWindow.require(`${globalWindow.STORYBOOK_NAME}/app`).default.create({
+const config = global.require(`${global.STORYBOOK_NAME}/config/environment`);
+const app = global.require(`${global.STORYBOOK_NAME}/app`).default.create({
autoboot: false,
rootElement: rootEl,
...config.APP,
diff --git a/code/frameworks/ember/src/typings.d.ts b/code/frameworks/ember/src/typings.d.ts
index e05c56b846e3..06750cef4597 100644
--- a/code/frameworks/ember/src/typings.d.ts
+++ b/code/frameworks/ember/src/typings.d.ts
@@ -1,2 +1,4 @@
declare module 'ember-source/dist/ember-template-compiler';
-declare module 'global';
+
+declare var STORYBOOK_ENV: 'ember';
+declare var STORYBOOK_NAME: any;
diff --git a/code/frameworks/html-webpack5/package.json b/code/frameworks/html-webpack5/package.json
index 9a76ea76e311..2408c92529eb 100644
--- a/code/frameworks/html-webpack5/package.json
+++ b/code/frameworks/html-webpack5/package.json
@@ -52,10 +52,10 @@
"dependencies": {
"@storybook/builder-webpack5": "7.0.0-beta.12",
"@storybook/core-common": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/html": "7.0.0-beta.12",
"@storybook/preset-html-webpack": "7.0.0-beta.12",
- "@types/node": "^16.0.0",
- "global": "^4.4.0"
+ "@types/node": "^16.0.0"
},
"devDependencies": {
"typescript": "~4.9.3"
diff --git a/code/frameworks/html-webpack5/src/typings.d.ts b/code/frameworks/html-webpack5/src/typings.d.ts
index d8f7c6f660ad..cbeccdbb15f7 100644
--- a/code/frameworks/html-webpack5/src/typings.d.ts
+++ b/code/frameworks/html-webpack5/src/typings.d.ts
@@ -1,4 +1,2 @@
-declare module 'global';
-
// will be provided by the webpack define plugin
declare var NODE_ENV: string | undefined;
diff --git a/code/frameworks/preact-webpack5/src/typings.d.ts b/code/frameworks/preact-webpack5/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/frameworks/preact-webpack5/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/frameworks/react-webpack5/src/typings.d.ts b/code/frameworks/react-webpack5/src/typings.d.ts
index ce0c26f59d0a..53aa2b04a775 100644
--- a/code/frameworks/react-webpack5/src/typings.d.ts
+++ b/code/frameworks/react-webpack5/src/typings.d.ts
@@ -1,5 +1,3 @@
-declare module 'global';
-
// TODO: Replace, as soon as @types/react-dom 17.0.14 is used
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
declare module 'react-dom/client' {
diff --git a/code/frameworks/svelte-webpack5/src/typings.d.ts b/code/frameworks/svelte-webpack5/src/typings.d.ts
index 153074abe8ca..48e7ba6228fd 100644
--- a/code/frameworks/svelte-webpack5/src/typings.d.ts
+++ b/code/frameworks/svelte-webpack5/src/typings.d.ts
@@ -1,4 +1,3 @@
-declare module 'global';
declare module '@storybook/svelte/templates/SlotDecorator.svelte';
declare module '@storybook/svelte/templates/PreviewRender.svelte';
declare module '@storybook/svelte/templates/HOC.svelte';
diff --git a/code/frameworks/vue-webpack5/src/typings.d.ts b/code/frameworks/vue-webpack5/src/typings.d.ts
index b3f023454b60..45d6411e8736 100644
--- a/code/frameworks/vue-webpack5/src/typings.d.ts
+++ b/code/frameworks/vue-webpack5/src/typings.d.ts
@@ -1,3 +1 @@
-declare module 'global';
-
declare module 'vue-loader/lib/plugin';
diff --git a/code/frameworks/vue3-webpack5/src/typings.d.ts b/code/frameworks/vue3-webpack5/src/typings.d.ts
index 3229acac0222..a045728260a0 100644
--- a/code/frameworks/vue3-webpack5/src/typings.d.ts
+++ b/code/frameworks/vue3-webpack5/src/typings.d.ts
@@ -1,5 +1,3 @@
-declare module 'global';
-
declare module 'vue-loader' {
export const VueLoaderPlugin: any;
}
diff --git a/code/frameworks/web-components-webpack5/src/typings.d.ts b/code/frameworks/web-components-webpack5/src/typings.d.ts
index d8f7c6f660ad..cbeccdbb15f7 100644
--- a/code/frameworks/web-components-webpack5/src/typings.d.ts
+++ b/code/frameworks/web-components-webpack5/src/typings.d.ts
@@ -1,4 +1,2 @@
-declare module 'global';
-
// will be provided by the webpack define plugin
declare var NODE_ENV: string | undefined;
diff --git a/code/lib/builder-vite/src/codegen-modern-iframe-script.ts b/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
index 980ac874a9f7..53061f175d81 100644
--- a/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
+++ b/code/lib/builder-vite/src/codegen-modern-iframe-script.ts
@@ -32,7 +32,7 @@ export async function generateModernIframeScriptCode(options: ExtendedOptions) {
if (import.meta.hot) {
import.meta.hot.accept('${virtualStoriesFile}', (newModule) => {
// importFn has changed so we need to patch the new one in
- preview.onStoriesChanged({ importFn: newModule.importFn });
+ window.__STORYBOOK_PREVIEW__.onStoriesChanged({ importFn: newModule.importFn });
});
import.meta.hot.accept(${JSON.stringify(
@@ -41,7 +41,7 @@ export async function generateModernIframeScriptCode(options: ExtendedOptions) {
const newGetProjectAnnotations = () => composeConfigs(newConfigEntries);
// getProjectAnnotations has changed so we need to patch the new one in
- preview.onGetProjectAnnotationsChanged({ getProjectAnnotations: newGetProjectAnnotations });
+ window.__STORYBOOK_PREVIEW__.onGetProjectAnnotationsChanged({ getProjectAnnotations: newGetProjectAnnotations });
});
}`.trim();
};
@@ -64,13 +64,12 @@ export async function generateModernIframeScriptCode(options: ExtendedOptions) {
return composeConfigs(configs);
}
- const preview = new PreviewWeb();
- window.__STORYBOOK_PREVIEW__ = preview;
- window.__STORYBOOK_STORY_STORE__ = preview.storyStore;
- window.__STORYBOOK_CLIENT_API__ = new ClientApi({ storyStore: preview.storyStore });
-
- preview.initialize({ importFn, getProjectAnnotations });
+ window.__STORYBOOK_PREVIEW__ = window.__STORYBOOK_PREVIEW__ || new PreviewWeb();
+
+ window.__STORYBOOK_STORY_STORE__ = window.__STORYBOOK_STORY_STORE__ || window.__STORYBOOK_PREVIEW__.storyStore;
+ window.__STORYBOOK_CLIENT_API__ = window.__STORYBOOK_CLIENT_API__ || new ClientApi({ storyStore: window.__STORYBOOK_PREVIEW__.storyStore });
+ window.__STORYBOOK_PREVIEW__.initialize({ importFn, getProjectAnnotations });
${generateHMRHandler(frameworkName)};
`.trim();
diff --git a/code/lib/builder-vite/src/optimizeDeps.ts b/code/lib/builder-vite/src/optimizeDeps.ts
index 9546c6fa295e..3d00a7783318 100644
--- a/code/lib/builder-vite/src/optimizeDeps.ts
+++ b/code/lib/builder-vite/src/optimizeDeps.ts
@@ -18,6 +18,7 @@ const INCLUDE_CANDIDATES = [
'@storybook/client-api',
'@storybook/client-logger',
'@storybook/core/client',
+ '@storybook/global',
'@storybook/preview-api',
'@storybook/preview-web',
'@storybook/react > acorn-jsx',
@@ -38,7 +39,6 @@ const INCLUDE_CANDIDATES = [
'escodegen',
'estraverse',
'fast-deep-equal',
- 'global',
'html-tags',
'isobject',
'jest-mock',
diff --git a/code/lib/builder-webpack5/package.json b/code/lib/builder-webpack5/package.json
index 5ac98e069d9b..779d85887c74 100644
--- a/code/lib/builder-webpack5/package.json
+++ b/code/lib/builder-webpack5/package.json
@@ -65,6 +65,7 @@
"@storybook/core-common": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
"@storybook/core-webpack": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/node-logger": "7.0.0-beta.12",
"@storybook/preview": "7.0.0-beta.12",
@@ -82,7 +83,6 @@
"express": "^4.17.3",
"fork-ts-checker-webpack-plugin": "^7.2.8",
"fs-extra": "^9.0.1",
- "global": "^4.4.0",
"html-webpack-plugin": "^5.5.0",
"path-browserify": "^1.0.1",
"process": "^0.11.10",
diff --git a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts
index ecb620baa295..02be5f0053fd 100644
--- a/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts
+++ b/code/lib/builder-webpack5/src/preview/iframe-webpack.config.ts
@@ -25,12 +25,13 @@ import type { BuilderOptions, TypescriptOptions } from '../types';
import { createBabelLoader } from './babel-loader-preview';
const storybookPaths: Record = {
- global: dirname(require.resolve(`global/package.json`)),
+ global: dirname(require.resolve('@storybook/global/package.json')),
...[
// these packages are not pre-bundled because of react dependencies
'api',
- 'manager-api',
'components',
+ 'global',
+ 'manager-api',
'router',
'theming',
].reduce(
@@ -211,6 +212,9 @@ export default async (
{
message: /export '\S+' was not found in 'global'/,
},
+ {
+ message: /export '\S+' was not found in '@storybook\/global'/,
+ },
],
plugins: [
Object.keys(virtualModuleMapping).length > 0
diff --git a/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars b/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars
index 62b3fe1d603c..3f77a83eeca0 100644
--- a/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars
+++ b/code/lib/builder-webpack5/templates/virtualModuleModernEntry.js.handlebars
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { ClientApi, PreviewWeb, addons, composeConfigs } from '@storybook/preview-api';
import { createChannel as createPostMessageChannel } from '@storybook/channel-postmessage';
diff --git a/code/lib/builder-webpack5/typings.d.ts b/code/lib/builder-webpack5/typings.d.ts
index 53e966a9d29e..df888b533e90 100644
--- a/code/lib/builder-webpack5/typings.d.ts
+++ b/code/lib/builder-webpack5/typings.d.ts
@@ -1,3 +1,2 @@
declare module 'lazy-universal-dotenv';
declare module '@storybook/theming/paths';
-declare module 'global';
diff --git a/code/lib/channel-postmessage/package.json b/code/lib/channel-postmessage/package.json
index d432ec183f3b..64be363670b5 100644
--- a/code/lib/channel-postmessage/package.json
+++ b/code/lib/channel-postmessage/package.json
@@ -45,7 +45,7 @@
"@storybook/channels": "7.0.0-beta.12",
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
- "global": "^4.4.0",
+ "@storybook/global": "^5.0.0",
"qs": "^6.10.0",
"telejson": "^7.0.3"
},
diff --git a/code/lib/channel-postmessage/src/index.ts b/code/lib/channel-postmessage/src/index.ts
index 2d697ddf6908..14caf77e13f8 100644
--- a/code/lib/channel-postmessage/src/index.ts
+++ b/code/lib/channel-postmessage/src/index.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import * as EVENTS from '@storybook/core-events';
import { Channel } from '@storybook/channels';
import type { ChannelHandler, ChannelEvent } from '@storybook/channels';
@@ -6,7 +6,7 @@ import { logger, pretty } from '@storybook/client-logger';
import { isJSON, parse, stringify } from 'telejson';
import qs from 'qs';
-const { window: globalWindow, document, location } = global;
+const { document, location } = global;
interface Config {
page: 'manager' | 'preview';
@@ -36,8 +36,9 @@ export class PostmsgTransport {
constructor(private readonly config: Config) {
this.buffer = [];
this.handler = null;
- if (globalWindow) {
- globalWindow.addEventListener('message', this.handleEvent.bind(this), false);
+
+ if (typeof global?.addEventListener === 'function') {
+ global.addEventListener('message', this.handleEvent.bind(this), false);
}
// Check whether the config.page parameter has a valid value
@@ -141,9 +142,9 @@ export class PostmsgTransport {
private getFrames(target?: string): Window[] {
if (this.config.page === 'manager') {
- const nodes: HTMLIFrameElement[] = [
- ...document.querySelectorAll('iframe[data-is-storybook][data-is-loaded]'),
- ];
+ const nodes: HTMLIFrameElement[] = Array.from(
+ document.querySelectorAll('iframe[data-is-storybook][data-is-loaded]')
+ );
const list = nodes
.filter((e) => {
@@ -157,8 +158,8 @@ export class PostmsgTransport {
return list.length ? list : this.getCurrentFrames();
}
- if (globalWindow && globalWindow.parent && globalWindow.parent !== globalWindow) {
- return [globalWindow.parent];
+ if (global && global.parent && global.parent !== global.self) {
+ return [global.parent];
}
return [];
@@ -166,13 +167,13 @@ export class PostmsgTransport {
private getCurrentFrames(): Window[] {
if (this.config.page === 'manager') {
- const list: HTMLIFrameElement[] = [
- ...document.querySelectorAll('[data-is-storybook="true"]'),
- ];
+ const list: HTMLIFrameElement[] = Array.from(
+ document.querySelectorAll('[data-is-storybook="true"]')
+ );
return list.map((e) => e.contentWindow);
}
- if (globalWindow && globalWindow.parent) {
- return [globalWindow.parent];
+ if (global && global.parent) {
+ return [global.parent];
}
return [];
@@ -180,11 +181,13 @@ export class PostmsgTransport {
private getLocalFrame(): Window[] {
if (this.config.page === 'manager') {
- const list: HTMLIFrameElement[] = [...document.querySelectorAll('#storybook-preview-iframe')];
+ const list: HTMLIFrameElement[] = Array.from(
+ document.querySelectorAll('#storybook-preview-iframe')
+ );
return list.map((e) => e.contentWindow);
}
- if (globalWindow && globalWindow.parent) {
- return [globalWindow.parent];
+ if (global && global.parent) {
+ return [global.parent];
}
return [];
@@ -237,7 +240,9 @@ export class PostmsgTransport {
}
const getEventSourceUrl = (event: MessageEvent) => {
- const frames = [...document.querySelectorAll('iframe[data-is-storybook]')];
+ const frames: HTMLIFrameElement[] = Array.from(
+ document.querySelectorAll('iframe[data-is-storybook]')
+ );
// try to find the originating iframe by matching it's contentWindow
// This might not be cross-origin safe
const [frame, ...remainder] = frames.filter((element) => {
@@ -251,7 +256,7 @@ const getEventSourceUrl = (event: MessageEvent) => {
let origin;
try {
- ({ origin } = new URL(src, document.location));
+ ({ origin } = new URL(src, document.location.toString()));
} catch (err) {
return false;
}
@@ -260,7 +265,7 @@ const getEventSourceUrl = (event: MessageEvent) => {
if (frame && remainder.length === 0) {
const src = frame.getAttribute('src');
- const { protocol, host, pathname } = new URL(src, document.location);
+ const { protocol, host, pathname } = new URL(src, document.location.toString());
return `${protocol}//${host}${pathname}`;
}
diff --git a/code/lib/channel-postmessage/src/typings.d.ts b/code/lib/channel-postmessage/src/typings.d.ts
index 2f4eb9cf4fd9..5c3e4f56f641 100644
--- a/code/lib/channel-postmessage/src/typings.d.ts
+++ b/code/lib/channel-postmessage/src/typings.d.ts
@@ -1 +1 @@
-declare module 'global';
+declare var CHANNEL_OPTIONS: any;
diff --git a/code/lib/channel-websocket/package.json b/code/lib/channel-websocket/package.json
index 3272d99834cf..4e12a6058436 100644
--- a/code/lib/channel-websocket/package.json
+++ b/code/lib/channel-websocket/package.json
@@ -44,7 +44,7 @@
"dependencies": {
"@storybook/channels": "7.0.0-beta.12",
"@storybook/client-logger": "7.0.0-beta.12",
- "global": "^4.4.0",
+ "@storybook/global": "^5.0.0",
"telejson": "^7.0.3"
},
"devDependencies": {
diff --git a/code/lib/channel-websocket/src/index.ts b/code/lib/channel-websocket/src/index.ts
index fb5628be5032..c92f857c0cb1 100644
--- a/code/lib/channel-websocket/src/index.ts
+++ b/code/lib/channel-websocket/src/index.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { Channel } from '@storybook/channels';
import type { ChannelHandler } from '@storybook/channels';
import { logger } from '@storybook/client-logger';
diff --git a/code/lib/channel-websocket/src/typings.d.ts b/code/lib/channel-websocket/src/typings.d.ts
index 8f141185b8ae..36dadd3de8aa 100644
--- a/code/lib/channel-websocket/src/typings.d.ts
+++ b/code/lib/channel-websocket/src/typings.d.ts
@@ -1,2 +1 @@
-declare module 'global';
declare module 'json-fn';
diff --git a/code/lib/client-logger/package.json b/code/lib/client-logger/package.json
index 31aa54d3fbd3..f26ce70cc1fc 100644
--- a/code/lib/client-logger/package.json
+++ b/code/lib/client-logger/package.json
@@ -42,7 +42,7 @@
"prep": "../../../scripts/prepare/bundle.ts"
},
"dependencies": {
- "global": "^4.4.0"
+ "@storybook/global": "^5.0.0"
},
"devDependencies": {
"typescript": "~4.9.3"
diff --git a/code/lib/client-logger/src/index.test.ts b/code/lib/client-logger/src/index.test.ts
index f9004a47e7b9..be6b3f74b3e2 100644
--- a/code/lib/client-logger/src/index.test.ts
+++ b/code/lib/client-logger/src/index.test.ts
@@ -1,6 +1,6 @@
import { logger } from '.';
-jest.mock('global', () => ({ ...global, LOGLEVEL: 'debug' }));
+jest.mock('@storybook/global', () => ({ global: { ...global, LOGLEVEL: 'debug' } }));
describe('client-logger default LOGLEVEL', () => {
const initialConsole = { ...global.console };
diff --git a/code/lib/client-logger/src/index.ts b/code/lib/client-logger/src/index.ts
index eceebe077c87..51d61ba5da2b 100644
--- a/code/lib/client-logger/src/index.ts
+++ b/code/lib/client-logger/src/index.ts
@@ -1,6 +1,6 @@
-import global from 'global';
+import { global } from '@storybook/global';
-const { LOGLEVEL, console } = global;
+const { LOGLEVEL } = global;
type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent';
@@ -19,18 +19,24 @@ const currentLogLevelNumber: number = levels[currentLogLevelString] || levels.in
type LoggingFn = (message: any, ...args: any[]) => void;
export const logger = {
- trace: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber <= levels.trace && console.trace(message, ...rest),
- debug: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber <= levels.debug && console.debug(message, ...rest),
- info: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber <= levels.info && console.info(message, ...rest),
- warn: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber <= levels.warn && console.warn(message, ...rest),
- error: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber <= levels.error && console.error(message, ...rest),
- log: (message: any, ...rest: any[]): void =>
- currentLogLevelNumber < levels.silent && console.log(message, ...rest),
+ trace: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber <= levels.trace) console.trace(message, ...rest);
+ },
+ debug: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber <= levels.debug) console.debug(message, ...rest);
+ },
+ info: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber <= levels.info) console.info(message, ...rest);
+ },
+ warn: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber <= levels.warn) console.warn(message, ...rest);
+ },
+ error: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber <= levels.error) console.error(message, ...rest);
+ },
+ log: (message: any, ...rest: any[]): void => {
+ if (currentLogLevelNumber < levels.silent) console.log(message, ...rest);
+ },
} as const;
const logged = new Set();
diff --git a/code/lib/client-logger/src/typings.d.ts b/code/lib/client-logger/src/typings.d.ts
index 2f4eb9cf4fd9..bfd9e55123ff 100644
--- a/code/lib/client-logger/src/typings.d.ts
+++ b/code/lib/client-logger/src/typings.d.ts
@@ -1 +1 @@
-declare module 'global';
+declare var LOGLEVEL: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'silent' | undefined;
diff --git a/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.input.js b/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.input.js
index 252c25e46667..886691243404 100644
--- a/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.input.js
+++ b/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.input.js
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { document } = global;
diff --git a/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.output.snapshot b/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.output.snapshot
index af8fa0a24eb8..3e3458a0f080 100644
--- a/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.output.snapshot
+++ b/code/lib/codemod/src/transforms/__testfixtures__/csf-to-mdx/story-function.output.snapshot
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`csf-to-mdx transforms correctly using "story-function.input.js" data 1`] = `
-"import global from 'global';
+"import { global } from '@storybook/global';
import { Meta, Story } from '@storybook/addon-docs';
const {
diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json
index 59300048324a..2e751bf12203 100644
--- a/code/lib/core-server/package.json
+++ b/code/lib/core-server/package.json
@@ -41,6 +41,7 @@
"@storybook/csf": "next",
"@storybook/csf-tools": "7.0.0-beta.12",
"@storybook/docs-mdx": "next",
+ "@storybook/global": "^5.0.0",
"@storybook/node-logger": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/telemetry": "7.0.0-beta.12",
@@ -57,7 +58,6 @@
"detect-port": "^1.3.0",
"express": "^4.17.3",
"fs-extra": "^9.0.1",
- "global": "^4.4.0",
"globby": "^11.0.2",
"ip": "^2.0.0",
"lodash": "^4.17.21",
diff --git a/code/lib/core-server/src/build-dev.ts b/code/lib/core-server/src/build-dev.ts
index 8296ae245361..309a5747d827 100644
--- a/code/lib/core-server/src/build-dev.ts
+++ b/code/lib/core-server/src/build-dev.ts
@@ -15,7 +15,7 @@ import {
validateFrameworkName,
} from '@storybook/core-common';
import prompts from 'prompts';
-import global from 'global';
+import { global } from '@storybook/global';
import { telemetry } from '@storybook/telemetry';
import { join, resolve } from 'path';
diff --git a/code/lib/core-server/src/build-static.ts b/code/lib/core-server/src/build-static.ts
index 7c444c4ae6fa..58834e7cac80 100644
--- a/code/lib/core-server/src/build-static.ts
+++ b/code/lib/core-server/src/build-static.ts
@@ -2,7 +2,7 @@ import chalk from 'chalk';
import { copy, emptyDir, ensureDir } from 'fs-extra';
import { dirname, isAbsolute, join, resolve } from 'path';
import { dedent } from 'ts-dedent';
-import global from 'global';
+import { global } from '@storybook/global';
import { logger } from '@storybook/node-logger';
import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry';
diff --git a/code/lib/core-server/src/typings.d.ts b/code/lib/core-server/src/typings.d.ts
index b566e70257c4..5ba2b96e7559 100644
--- a/code/lib/core-server/src/typings.d.ts
+++ b/code/lib/core-server/src/typings.d.ts
@@ -1,4 +1,3 @@
-declare module 'global';
declare module 'lazy-universal-dotenv';
declare module 'pnp-webpack-plugin';
declare module '@storybook/theming/paths';
@@ -9,3 +8,5 @@ declare module '@aw-web-design/x-default-browser';
declare module '@storybook/manager';
declare module '@discoveryjs/json-ext';
declare module 'watchpack';
+
+declare var FEATURES: any;
diff --git a/code/lib/instrumenter/package.json b/code/lib/instrumenter/package.json
index 305d02a56df4..c7101b19d646 100644
--- a/code/lib/instrumenter/package.json
+++ b/code/lib/instrumenter/package.json
@@ -45,9 +45,9 @@
"@storybook/channels": "7.0.0-beta.12",
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
- "core-js": "^3.8.2",
- "global": "^4.4.0"
+ "core-js": "^3.8.2"
},
"devDependencies": {
"typescript": "~4.9.3"
diff --git a/code/lib/instrumenter/src/instrumenter.test.ts b/code/lib/instrumenter/src/instrumenter.test.ts
index cb4cc645c14b..c15d5516fd1c 100644
--- a/code/lib/instrumenter/src/instrumenter.test.ts
+++ b/code/lib/instrumenter/src/instrumenter.test.ts
@@ -8,7 +8,7 @@ import {
SET_CURRENT_STORY,
STORY_RENDER_PHASE_CHANGED,
} from '@storybook/core-events';
-import global from 'global';
+import { global } from '@storybook/global';
import { EVENTS, Instrumenter } from './instrumenter';
import type { Options } from './types';
@@ -29,9 +29,11 @@ class HTMLElement {
}
}
-delete global.window.location;
-global.window.location = { reload: jest.fn() };
-global.window.HTMLElement = HTMLElement;
+delete global.location;
+// @ts-expect-error (global scope type conflicts)
+global.location = { reload: jest.fn() };
+// @ts-expect-error (global scope type conflicts)
+global.HTMLElement = HTMLElement;
const storyId = 'kind--story';
global.window.__STORYBOOK_PREVIEW__ = { selectionStore: { selection: { storyId } } };
diff --git a/code/lib/instrumenter/src/instrumenter.ts b/code/lib/instrumenter/src/instrumenter.ts
index 480e47b3404e..2402500b374f 100644
--- a/code/lib/instrumenter/src/instrumenter.ts
+++ b/code/lib/instrumenter/src/instrumenter.ts
@@ -9,7 +9,7 @@ import {
SET_CURRENT_STORY,
STORY_RENDER_PHASE_CHANGED,
} from '@storybook/core-events';
-import global from 'global';
+import { global } from '@storybook/global';
import type { Call, CallRef, ControlStates, LogItem, Options, State, SyncPayload } from './types';
import { CallStates } from './types';
@@ -101,6 +101,7 @@ export class Instrumenter {
this.channel = addons.getChannel();
// Restore state from the parent window in case the iframe was reloaded.
+ // @ts-expect-error (TS doesn't know about this global variable)
this.state = global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ || {};
// When called from `start`, isDebugging will be true.
@@ -241,6 +242,7 @@ export class Instrumenter {
const patch = typeof update === 'function' ? update(state) : update;
this.state = { ...this.state, [storyId]: { ...state, ...patch } };
// Track state on the parent window so we can reload the iframe without losing state.
+ // @ts-expect-error (TS doesn't know about this global variable)
global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
}
@@ -254,6 +256,7 @@ export class Instrumenter {
}, {} as Record);
const payload: SyncPayload = { controlStates: controlsDisabled, logItems: [] };
this.channel.emit(EVENTS.SYNC, payload);
+ // @ts-expect-error (TS doesn't know about this global variable)
global.window.parent.__STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__ = this.state;
}
@@ -333,8 +336,7 @@ export class Instrumenter {
// returns the original result.
track(method: string, fn: Function, args: any[], options: Options) {
const storyId: StoryId =
- args?.[0]?.__storyId__ ||
- global.window.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId;
+ args?.[0]?.__storyId__ || global.__STORYBOOK_PREVIEW__?.selectionStore?.selection?.storyId;
const { cursor, ancestors } = this.getState(storyId);
this.setState(storyId, { cursor: cursor + 1 });
const id = `${ancestors.slice(-1)[0] || storyId} [${cursor}] ${method}`;
diff --git a/code/lib/instrumenter/src/typings.d.ts b/code/lib/instrumenter/src/typings.d.ts
index 2f4eb9cf4fd9..2f4fd5fee113 100644
--- a/code/lib/instrumenter/src/typings.d.ts
+++ b/code/lib/instrumenter/src/typings.d.ts
@@ -1 +1,5 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
+declare var FEATURES: any;
+declare var __STORYBOOK_PREVIEW__: any;
+declare var __STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER_STATE__: any;
+declare var __STORYBOOK_ADDON_INTERACTIONS_INSTRUMENTER__: any;
diff --git a/code/lib/manager-api/package.json b/code/lib/manager-api/package.json
index 65f16477aa7c..8b0756baf78e 100644
--- a/code/lib/manager-api/package.json
+++ b/code/lib/manager-api/package.json
@@ -45,11 +45,11 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
"@storybook/csf": "next",
+ "@storybook/global": "^5.0.0",
"@storybook/router": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"dequal": "^2.0.2",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"memoizerific": "^1.11.3",
"semver": "^7.3.7",
diff --git a/code/lib/manager-api/src/lib/addons.ts b/code/lib/manager-api/src/lib/addons.ts
index fa3c202ebbc8..78411959b197 100644
--- a/code/lib/manager-api/src/lib/addons.ts
+++ b/code/lib/manager-api/src/lib/addons.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { Channel } from '@storybook/channels';
import { SET_CONFIG } from '@storybook/core-events';
diff --git a/code/lib/manager-api/src/lib/shortcut.ts b/code/lib/manager-api/src/lib/shortcut.ts
index 6830ac223435..e61b1cc159f7 100644
--- a/code/lib/manager-api/src/lib/shortcut.ts
+++ b/code/lib/manager-api/src/lib/shortcut.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { API_KeyCollection } from '../modules/shortcuts';
const { navigator } = global;
diff --git a/code/lib/manager-api/src/modules/layout.ts b/code/lib/manager-api/src/modules/layout.ts
index 8c81d8d01663..ec1c4394035e 100644
--- a/code/lib/manager-api/src/modules/layout.ts
+++ b/code/lib/manager-api/src/modules/layout.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import pick from 'lodash/pick';
import { dequal as deepEqual } from 'dequal';
import { create } from '@storybook/theming/create';
@@ -184,7 +184,9 @@ export const init: ModuleFn = ({ store, provider, singleStory, fullAPI }) => {
const element = document.getElementById(elementId);
if (element) {
element.focus();
- if (select) element.select();
+ if (select) {
+ (element as any).select();
+ }
}
},
diff --git a/code/lib/manager-api/src/modules/refs.ts b/code/lib/manager-api/src/modules/refs.ts
index 39a525c5683c..166994b956e6 100644
--- a/code/lib/manager-api/src/modules/refs.ts
+++ b/code/lib/manager-api/src/modules/refs.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import type {
API_ComposedRef,
@@ -62,12 +62,19 @@ const addRefIds = (input: API_StoriesHash, ref: API_ComposedRef): API_StoriesHas
}, {} as API_StoriesHash);
};
-async function handleRequest(request: Response | false): Promise {
+async function handleRequest(
+ request: Response | Promise | boolean
+): Promise {
if (!request) return {};
try {
const response = await request;
- if (!response.ok) return {};
+ if (response === false || response === true) {
+ return {};
+ }
+ if (!response.ok) {
+ return {};
+ }
const json = await response.json();
diff --git a/code/lib/manager-api/src/modules/release-notes.ts b/code/lib/manager-api/src/modules/release-notes.ts
index f8c3da8abd8b..d1546a6f47ce 100644
--- a/code/lib/manager-api/src/modules/release-notes.ts
+++ b/code/lib/manager-api/src/modules/release-notes.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { API_ReleaseNotes } from '@storybook/types';
import memoize from 'memoizerific';
diff --git a/code/lib/manager-api/src/modules/shortcuts.ts b/code/lib/manager-api/src/modules/shortcuts.ts
index 94007b27adfe..1e623123bde8 100644
--- a/code/lib/manager-api/src/modules/shortcuts.ts
+++ b/code/lib/manager-api/src/modules/shortcuts.ts
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/naming-convention */
-import global from 'global';
+import { global } from '@storybook/global';
import { PREVIEW_KEYDOWN } from '@storybook/core-events';
import type { ModuleFn } from '../index';
@@ -217,7 +217,7 @@ export const init: ModuleFn = ({ store, fullAPI }) => {
}
case 'focusIframe': {
- const element = document.getElementById('storybook-preview-iframe');
+ const element = document.getElementById('storybook-preview-iframe') as HTMLIFrameElement;
if (element) {
try {
diff --git a/code/lib/manager-api/src/modules/stories.ts b/code/lib/manager-api/src/modules/stories.ts
index cbf2ac59c6c9..d9a70c6c56da 100644
--- a/code/lib/manager-api/src/modules/stories.ts
+++ b/code/lib/manager-api/src/modules/stories.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { toId, sanitize } from '@storybook/csf';
import {
PRELOAD_ENTRIES,
diff --git a/code/lib/manager-api/src/modules/url.ts b/code/lib/manager-api/src/modules/url.ts
index c55899ff136c..7dc77ecec077 100644
--- a/code/lib/manager-api/src/modules/url.ts
+++ b/code/lib/manager-api/src/modules/url.ts
@@ -8,7 +8,7 @@ import {
import type { NavigateOptions } from '@storybook/router';
import { queryFromLocation, buildArgsParam } from '@storybook/router';
import { dequal as deepEqual } from 'dequal';
-import global from 'global';
+import { global } from '@storybook/global';
import type { API_Layout, API_UI } from '@storybook/types';
import type { ModuleArgs, ModuleFn } from '../index';
diff --git a/code/lib/manager-api/src/modules/versions.ts b/code/lib/manager-api/src/modules/versions.ts
index 07493156b6bd..0ea85ae6d919 100644
--- a/code/lib/manager-api/src/modules/versions.ts
+++ b/code/lib/manager-api/src/modules/versions.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import semver from 'semver';
import memoize from 'memoizerific';
diff --git a/code/lib/manager-api/src/tests/events.test.ts b/code/lib/manager-api/src/tests/events.test.ts
index f0a582d4d05f..ee1c354c2f66 100644
--- a/code/lib/manager-api/src/tests/events.test.ts
+++ b/code/lib/manager-api/src/tests/events.test.ts
@@ -1,8 +1,10 @@
import { getEventMetadata } from '../lib/events';
import type { API } from '../index';
-jest.mock('global', () => ({
- location: { origin: 'http://localhost:6006', pathname: '/' },
+jest.mock('@storybook/global', () => ({
+ global: {
+ location: { origin: 'http://localhost:6006', pathname: '/' },
+ },
}));
describe('getEventMetadata', () => {
diff --git a/code/lib/manager-api/src/tests/refs.test.js b/code/lib/manager-api/src/tests/refs.test.js
index ad25f718ec49..17a7abe9bf90 100644
--- a/code/lib/manager-api/src/tests/refs.test.js
+++ b/code/lib/manager-api/src/tests/refs.test.js
@@ -1,9 +1,9 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { getSourceType, init as initRefs } from '../modules/refs';
const { fetch } = global;
-jest.mock('global', () => {
+jest.mock('@storybook/global', () => {
const globalMock = {
fetch: jest.fn(() => Promise.resolve({})),
REFS: {
@@ -29,7 +29,7 @@ jest.mock('global', () => {
.mockReturnValue(lastLocation),
},
});
- return globalMock;
+ return { global: globalMock };
});
const provider = {
diff --git a/code/lib/manager-api/src/tests/shortcut.test.js b/code/lib/manager-api/src/tests/shortcut.test.js
index 23aeb049236e..982f74856fb8 100644
--- a/code/lib/manager-api/src/tests/shortcut.test.js
+++ b/code/lib/manager-api/src/tests/shortcut.test.js
@@ -2,7 +2,7 @@
* @jest-environment jsdom
*/
-import global from 'global';
+import { global } from '@storybook/global';
import { eventToShortcut, keyToSymbol } from '../lib/shortcut';
const { KeyboardEvent } = global;
diff --git a/code/lib/manager-api/src/tests/stories.test.ts b/code/lib/manager-api/src/tests/stories.test.ts
index 072527e8eb50..02ec87a6800c 100644
--- a/code/lib/manager-api/src/tests/stories.test.ts
+++ b/code/lib/manager-api/src/tests/stories.test.ts
@@ -1,6 +1,6 @@
/// ;
// Need to import jest as mockJest for annoying jest reasons. Is there a better way?
-import { jest, jest as mockJest, it, describe, expect, beforeEach } from '@jest/globals';
+import { jest, it, describe, expect, beforeEach } from '@jest/globals';
import {
STORY_ARGS_UPDATED,
@@ -14,7 +14,7 @@ import {
SET_INDEX,
} from '@storybook/core-events';
import { EventEmitter } from 'events';
-import global from 'global';
+import { global } from '@storybook/global';
import { Channel } from '@storybook/channels';
@@ -37,11 +37,13 @@ function mockChannel() {
const mockGetEntries = jest.fn<() => StoryIndex['entries']>();
jest.mock('../lib/events');
-jest.mock('global', () => ({
- ...(mockJest.requireActual('global') as Record),
- fetch: mockJest.fn(() => ({ json: () => ({ v: 4, entries: mockGetEntries() }) })),
- FEATURES: { storyStoreV7: true },
- CONFIG_TYPE: 'DEVELOPMENT',
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...globalThis,
+ fetch: jest.fn(() => ({ json: () => ({ v: 4, entries: mockGetEntries() }) })),
+ FEATURES: { storyStoreV7: true },
+ CONFIG_TYPE: 'DEVELOPMENT',
+ },
}));
const getEventMetadataMock = getEventMetadata as ReturnType;
@@ -87,9 +89,14 @@ beforeEach(() => {
provider.getConfig.mockReset().mockReturnValue({});
provider.serverChannel = mockChannel();
mockGetEntries.mockReset().mockReturnValue(mockEntries);
- global.fetch
- .mockReset()
- .mockReturnValue({ status: 200, json: () => ({ v: 4, entries: mockGetEntries() }) });
+
+ (global.fetch as ReturnType>).mockReset().mockReturnValue(
+ Promise.resolve({
+ status: 200,
+ ok: true,
+ json: () => ({ v: 4, entries: mockGetEntries() }),
+ } as any as Response)
+ );
getEventMetadataMock.mockReturnValue({ sourceType: 'local' } as any);
getEventMetadataMock.mockReturnValue({ sourceType: 'local' } as any);
@@ -560,7 +567,12 @@ describe('stories API', () => {
const store = createMockStore({});
const fullAPI = Object.assign(new EventEmitter(), {});
- global.fetch.mockReturnValue({ status: 500, text: async () => new Error('sorting error') });
+ (global.fetch as ReturnType>).mockReturnValue(
+ Promise.resolve({
+ status: 500,
+ text: async () => new Error('sorting error'),
+ } as any as Response)
+ );
const { api, init } = initStories({ store, navigate, provider, fullAPI } as any);
Object.assign(fullAPI, api);
@@ -581,11 +593,13 @@ describe('stories API', () => {
const { api, init } = initStories({ store, navigate, provider, fullAPI } as any);
Object.assign(fullAPI, api);
- global.fetch.mockClear();
+ (global.fetch as ReturnType>).mockClear();
await init();
- expect(global.fetch).toHaveBeenCalledTimes(1);
+ expect(global.fetch as ReturnType>).toHaveBeenCalledTimes(
+ 1
+ );
- global.fetch.mockClear();
+ (global.fetch as ReturnType>).mockClear();
mockGetEntries.mockReturnValueOnce({
'component-a--story-1': {
type: 'story',
diff --git a/code/lib/manager-api/src/tests/versions.test.js b/code/lib/manager-api/src/tests/versions.test.js
index 272bd5cc340f..d92809ab65a1 100644
--- a/code/lib/manager-api/src/tests/versions.test.js
+++ b/code/lib/manager-api/src/tests/versions.test.js
@@ -4,19 +4,21 @@ jest.mock('../version', () => ({
version: '3.0.0',
}));
-jest.mock('global', () => ({
- VERSIONCHECK: JSON.stringify({
- success: true,
- data: {
- latest: {
- version: '5.2.3',
- },
- next: {
- version: '5.3.0-alpha.15',
+jest.mock('@storybook/global', () => ({
+ global: {
+ VERSIONCHECK: JSON.stringify({
+ success: true,
+ data: {
+ latest: {
+ version: '5.2.3',
+ },
+ next: {
+ version: '5.3.0-alpha.15',
+ },
},
- },
- time: 1571565216284,
- }),
+ time: 1571565216284,
+ }),
+ },
}));
jest.mock('@storybook/client-logger');
diff --git a/code/lib/manager-api/src/typings.d.ts b/code/lib/manager-api/src/typings.d.ts
index 120e82d8e42f..6c531d799db0 100644
--- a/code/lib/manager-api/src/typings.d.ts
+++ b/code/lib/manager-api/src/typings.d.ts
@@ -1,2 +1,6 @@
-declare module 'global';
-declare module 'preval.macro';
+/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
+declare var RELEASE_NOTES_DATA: any;
+declare var __STORYBOOK_ADDONS_MANAGER: any;
+declare var FEATURES: { storyStoreV7?: boolean } | undefined;
+declare var REFS: any;
+declare var VERSIONCHECK: any;
diff --git a/code/lib/preview-api/package.json b/code/lib/preview-api/package.json
index cbfa3523f33a..8ec28bb6d5ab 100644
--- a/code/lib/preview-api/package.json
+++ b/code/lib/preview-api/package.json
@@ -72,10 +72,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
"@storybook/csf": "next",
+ "@storybook/global": "^5.0.0",
"@storybook/types": "7.0.0-beta.12",
"@types/qs": "^6.9.5",
"dequal": "^2.0.2",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"memoizerific": "^1.11.3",
"qs": "^6.10.0",
diff --git a/code/lib/preview-api/src/addons.ts b/code/lib/preview-api/src/addons.ts
index eab6cf52d111..abff53a4dd10 100644
--- a/code/lib/preview-api/src/addons.ts
+++ b/code/lib/preview-api/src/addons.ts
@@ -1 +1,4 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
export * from './modules/addons';
diff --git a/code/lib/preview-api/src/client-api.ts b/code/lib/preview-api/src/client-api.ts
index 0ba8fe19999d..c133a47e3570 100644
--- a/code/lib/preview-api/src/client-api.ts
+++ b/code/lib/preview-api/src/client-api.ts
@@ -1 +1,4 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
export * from './modules/client-api';
diff --git a/code/lib/preview-api/src/core-client.ts b/code/lib/preview-api/src/core-client.ts
index 86513ed4b7f3..18db05321a65 100644
--- a/code/lib/preview-api/src/core-client.ts
+++ b/code/lib/preview-api/src/core-client.ts
@@ -1 +1,4 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
export * from './modules/core-client';
diff --git a/code/lib/preview-api/src/index.ts b/code/lib/preview-api/src/index.ts
index 872b4f1a6918..c4bb66339e50 100644
--- a/code/lib/preview-api/src/index.ts
+++ b/code/lib/preview-api/src/index.ts
@@ -1,3 +1,6 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
/**
* HOOKS API
*/
diff --git a/code/lib/preview-api/src/modules/addons/hooks.ts b/code/lib/preview-api/src/modules/addons/hooks.ts
index 1135c25bf9b2..6c1c7847bbc8 100644
--- a/code/lib/preview-api/src/modules/addons/hooks.ts
+++ b/code/lib/preview-api/src/modules/addons/hooks.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { logger } from '@storybook/client-logger';
import type {
Renderer,
diff --git a/code/lib/preview-api/src/modules/addons/main.ts b/code/lib/preview-api/src/modules/addons/main.ts
index d312af273af1..dec90e0f2ab7 100644
--- a/code/lib/preview-api/src/modules/addons/main.ts
+++ b/code/lib/preview-api/src/modules/addons/main.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { Channel } from '@storybook/channels';
import { mockChannel } from './storybook-channel-mock';
diff --git a/code/lib/preview-api/src/modules/client-api/ClientApi.ts b/code/lib/preview-api/src/modules/client-api/ClientApi.ts
index e918378a305e..83a2ba0cd6b0 100644
--- a/code/lib/preview-api/src/modules/client-api/ClientApi.ts
+++ b/code/lib/preview-api/src/modules/client-api/ClientApi.ts
@@ -1,7 +1,7 @@
/* eslint-disable no-underscore-dangle */
import { dedent } from 'ts-dedent';
-import global from 'global';
+import { global } from '@storybook/global';
import { logger } from '@storybook/client-logger';
import { toId, sanitize } from '@storybook/csf';
import type {
@@ -29,8 +29,6 @@ import { combineParameters, composeStepRunners, normalizeInputTypes } from '../.
import { StoryStoreFacade } from './StoryStoreFacade';
-const { window: globalWindow } = global;
-
const warningAlternatives = {
addDecorator: `Instead, use \`export const decorators = [];\` in your \`preview.js\`.`,
addParameters: `Instead, use \`export const parameters = {};\` in your \`preview.js\`.`,
@@ -45,7 +43,7 @@ const warningAlternatives = {
};
const checkMethod = (method: keyof typeof warningAlternatives) => {
- if (globalWindow.FEATURES?.storyStoreV7) {
+ if (global.FEATURES?.storyStoreV7) {
throw new Error(
dedent`You cannot use \`${method}\` with the new Story Store.
@@ -53,60 +51,60 @@ const checkMethod = (method: keyof typeof warningAlternatives) => {
);
}
- if (!globalWindow.__STORYBOOK_CLIENT_API__) {
+ if (!global.__STORYBOOK_CLIENT_API__) {
throw new Error(`Singleton client API not yet initialized, cannot call \`${method}\`.`);
}
};
export const addDecorator = (decorator: DecoratorFunction) => {
checkMethod('addDecorator');
- globalWindow.__STORYBOOK_CLIENT_API__?.addDecorator(decorator);
+ global.__STORYBOOK_CLIENT_API__?.addDecorator(decorator);
};
export const addParameters = (parameters: Parameters) => {
checkMethod('addParameters');
- globalWindow.__STORYBOOK_CLIENT_API__?.addParameters(parameters);
+ global.__STORYBOOK_CLIENT_API__?.addParameters(parameters);
};
export const addLoader = (loader: LoaderFunction) => {
checkMethod('addLoader');
- globalWindow.__STORYBOOK_CLIENT_API__?.addLoader(loader);
+ global.__STORYBOOK_CLIENT_API__?.addLoader(loader);
};
export const addArgs = (args: Args) => {
checkMethod('addArgs');
- globalWindow.__STORYBOOK_CLIENT_API__?.addArgs(args);
+ global.__STORYBOOK_CLIENT_API__?.addArgs(args);
};
export const addArgTypes = (argTypes: ArgTypes) => {
checkMethod('addArgTypes');
- globalWindow.__STORYBOOK_CLIENT_API__?.addArgTypes(argTypes);
+ global.__STORYBOOK_CLIENT_API__?.addArgTypes(argTypes);
};
export const addArgsEnhancer = (enhancer: ArgsEnhancer) => {
checkMethod('addArgsEnhancer');
- globalWindow.__STORYBOOK_CLIENT_API__?.addArgsEnhancer(enhancer);
+ global.__STORYBOOK_CLIENT_API__?.addArgsEnhancer(enhancer);
};
export const addArgTypesEnhancer = (enhancer: ArgTypesEnhancer) => {
checkMethod('addArgTypesEnhancer');
- globalWindow.__STORYBOOK_CLIENT_API__?.addArgTypesEnhancer(enhancer);
+ global.__STORYBOOK_CLIENT_API__?.addArgTypesEnhancer(enhancer);
};
export const addStepRunner = (stepRunner: StepRunner) => {
checkMethod('addStepRunner');
- globalWindow.__STORYBOOK_CLIENT_API__?.addStepRunner(stepRunner);
+ global.__STORYBOOK_CLIENT_API__?.addStepRunner(stepRunner);
};
export const getGlobalRender = () => {
checkMethod('getGlobalRender');
- return globalWindow.__STORYBOOK_CLIENT_API__?.facade.projectAnnotations.render;
+ return global.__STORYBOOK_CLIENT_API__?.facade.projectAnnotations.render;
};
export const setGlobalRender = (render: StoryStoreFacade['projectAnnotations']['render']) => {
checkMethod('setGlobalRender');
- if (globalWindow.__STORYBOOK_CLIENT_API__) {
- globalWindow.__STORYBOOK_CLIENT_API__.facade.projectAnnotations.render = render;
+ if (global.__STORYBOOK_CLIENT_API__) {
+ global.__STORYBOOK_CLIENT_API__.facade.projectAnnotations.render = render;
}
};
diff --git a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts
index d65e6aaca534..3dcdb605f707 100644
--- a/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts
+++ b/code/lib/preview-api/src/modules/client-api/StoryStoreFacade.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import { SynchronousPromise } from 'synchronous-promise';
import { toId, isExportStory, storyNameFromExport } from '@storybook/csf';
diff --git a/code/lib/preview-api/src/modules/client-api/queryparams.ts b/code/lib/preview-api/src/modules/client-api/queryparams.ts
index be0c29f201f6..ccaa7193e407 100644
--- a/code/lib/preview-api/src/modules/client-api/queryparams.ts
+++ b/code/lib/preview-api/src/modules/client-api/queryparams.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { parse } from 'qs';
export const getQueryParams = () => {
diff --git a/code/lib/preview-api/src/modules/client-api/typings.d.ts b/code/lib/preview-api/src/modules/client-api/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/lib/preview-api/src/modules/client-api/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/lib/preview-api/src/modules/core-client/start.test.ts b/code/lib/preview-api/src/modules/core-client/start.test.ts
index 96158c8e92a4..5183f13c0775 100644
--- a/code/lib/preview-api/src/modules/core-client/start.test.ts
+++ b/code/lib/preview-api/src/modules/core-client/start.test.ts
@@ -1,12 +1,13 @@
+/* eslint-disable no-underscore-dangle */
/**
* @jest-environment jsdom
*/
-/* global window */
+// import { describe, it, beforeAll, beforeEach, afterAll, afterEach, jest } from '@jest/globals';
import { STORY_RENDERED, STORY_UNCHANGED, SET_INDEX } from '@storybook/core-events';
import type { ModuleExports, Path } from '@storybook/types';
-import global from 'global';
+import { global } from '@storybook/global';
import { setGlobalRender } from '../../client-api';
import {
waitForRender,
@@ -19,23 +20,28 @@ import {
import { start as realStart } from './start';
import type { Loadable } from './executeLoadable';
-jest.mock('global', () => ({
- ...jest.requireActual('global'),
- history: { replaceState: jest.fn() },
- document: {
- location: {
- pathname: 'pathname',
- search: '?id=*',
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...globalThis,
+ window: globalThis,
+ history: { replaceState: jest.fn() },
+ document: {
+ location: {
+ pathname: 'pathname',
+ search: '?id=*',
+ },
+ },
+ FEATURES: {
+ breakingChangesV7: true,
+ },
+ DOCS_OPTIONS: {
+ enabled: true,
},
- },
- FEATURES: {
- breakingChangesV7: true,
- },
- DOCS_OPTIONS: {
- enabled: true,
},
}));
+// console.log(global);
+
jest.mock('@storybook/channel-postmessage', () => ({ createChannel: () => mockChannel }));
jest.mock('react-dom');
@@ -106,6 +112,12 @@ function makeRequireContext(importMap: Record) {
describe('start', () => {
beforeEach(() => {
global.DOCS_OPTIONS = { enabled: false };
+ // @ts-expect-error (setting this to undefined is indeed what we want to do)
+ global.__STORYBOOK_CLIENT_API__ = undefined;
+ // @ts-expect-error (setting this to undefined is indeed what we want to do)
+ global.__STORYBOOK_PREVIEW__ = undefined;
+ // @ts-expect-error (setting this to undefined is indeed what we want to do)
+ global.IS_STORYBOOK = undefined;
});
describe('when configure is called with storiesOf only', () => {
it('loads and renders the first story correctly', async () => {
@@ -325,7 +337,7 @@ describe('start', () => {
'story-root'
);
- expect((window as any).IS_STORYBOOK).toBe(true);
+ expect(global.IS_STORYBOOK).toBe(true);
});
it('supports forceRerender()', async () => {
diff --git a/code/lib/preview-api/src/modules/core-client/start.ts b/code/lib/preview-api/src/modules/core-client/start.ts
index bdfb5698ae3f..1827c1156fe4 100644
--- a/code/lib/preview-api/src/modules/core-client/start.ts
+++ b/code/lib/preview-api/src/modules/core-client/start.ts
@@ -1,16 +1,16 @@
-/* eslint-disable @typescript-eslint/naming-convention */
-import global from 'global';
+/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
+import { global } from '@storybook/global';
import type { Renderer, ArgsStoryFn, Path, ProjectAnnotations } from '@storybook/types';
import { createChannel } from '@storybook/channel-postmessage';
import { FORCE_RE_RENDER } from '@storybook/core-events';
-import { addons } from '../addons';
+import { addons } from '../../addons';
import { PreviewWeb } from '../../preview-web';
import { ClientApi } from '../../client-api';
import { executeLoadableForChanges } from './executeLoadable';
import type { Loadable } from './executeLoadable';
-const { window: globalWindow, FEATURES } = global;
+const { FEATURES } = global;
const removedApi = (name: string) => () => {
throw new Error(`@storybook/client-api:${name} was removed in storyStoreV7.`);
@@ -41,9 +41,9 @@ export function start(
renderToCanvas: ProjectAnnotations['renderToCanvas'],
{ decorateStory, render }: CoreClient_RendererImplementation = {}
): CoreClient_StartReturnValue {
- if (globalWindow) {
+ if (global) {
// To enable user code to detect if it is running in Storybook
- globalWindow.IS_STORYBOOK = true;
+ global.IS_STORYBOOK = true;
}
if (FEATURES?.storyStoreV7) {
@@ -60,8 +60,8 @@ export function start(
const channel = createChannel({ page: 'preview' });
addons.setChannel(channel);
- const clientApi = new ClientApi();
- const preview = new PreviewWeb();
+ const clientApi = global?.__STORYBOOK_CLIENT_API__ || new ClientApi();
+ const preview = global?.__STORYBOOK_PREVIEW__ || new PreviewWeb();
let initialized = false;
const importFn = (path: Path) => clientApi.importFn(path);
@@ -75,12 +75,11 @@ export function start(
clientApi.onImportFnChanged = onStoriesChanged;
clientApi.storyStore = preview.storyStore;
- if (globalWindow) {
- globalWindow.__STORYBOOK_CLIENT_API__ = clientApi;
- globalWindow.__STORYBOOK_ADDONS_CHANNEL__ = channel;
- // eslint-disable-next-line no-underscore-dangle
- globalWindow.__STORYBOOK_PREVIEW__ = preview;
- globalWindow.__STORYBOOK_STORY_STORE__ = preview.storyStore;
+ if (global) {
+ global.__STORYBOOK_CLIENT_API__ = clientApi;
+ global.__STORYBOOK_ADDONS_CHANNEL__ = channel;
+ global.__STORYBOOK_PREVIEW__ = preview;
+ global.__STORYBOOK_STORY_STORE__ = preview.storyStore;
}
return {
@@ -105,7 +104,6 @@ export function start(
// function in case it throws. So we also need to process its output there also
const getProjectAnnotations = () => {
const { added, removed } = executeLoadableForChanges(loadable, m);
- // eslint-disable-next-line no-underscore-dangle
clientApi._loadAddedExports();
Array.from(added.entries()).forEach(([fileName, fileExports]) =>
diff --git a/code/lib/preview-api/src/modules/core-client/typings.d.ts b/code/lib/preview-api/src/modules/core-client/typings.d.ts
deleted file mode 100644
index 8353021fb03d..000000000000
--- a/code/lib/preview-api/src/modules/core-client/typings.d.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-declare module 'global';
-declare module 'lazy-universal-dotenv';
-declare module 'pnp-webpack-plugin';
-declare module '@storybook/manager/paths';
-declare module 'better-opn';
-declare module 'open';
-declare module '@aw-web-design/x-default-browser';
diff --git a/code/lib/preview-api/src/modules/preview-web/Preview.tsx b/code/lib/preview-api/src/modules/preview-web/Preview.tsx
index c2d7b7930bdc..4864dfd8c200 100644
--- a/code/lib/preview-api/src/modules/preview-web/Preview.tsx
+++ b/code/lib/preview-api/src/modules/preview-web/Preview.tsx
@@ -1,5 +1,5 @@
import { dedent } from 'ts-dedent';
-import global from 'global';
+import { global } from '@storybook/global';
import { SynchronousPromise } from 'synchronous-promise';
import {
CONFIG_ERROR,
@@ -174,7 +174,9 @@ export class Preview {
async getStoryIndexFromServer() {
const result = await fetch(STORY_INDEX_PATH);
- if (result.status === 200) return result.json() as StoryIndex;
+ if (result.status === 200) {
+ return result.json() as any as StoryIndex;
+ }
throw new Error(await result.text());
}
diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts
index a6bebfec9ea5..ecfcd58af4c0 100644
--- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts
+++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.integration.test.ts
@@ -3,7 +3,7 @@
*/
import React from 'react';
-import global from 'global';
+import { global } from '@storybook/global';
import type { RenderContext } from '@storybook/types';
import { expect } from '@jest/globals';
import { addons, mockChannel as createMockChannel } from '../addons';
@@ -29,21 +29,23 @@ jest.mock('@storybook/channel-postmessage', () => ({ createChannel: () => mockCh
jest.mock('./WebView');
-const { window, document } = global;
-jest.mock('global', () => ({
- ...jest.requireActual('global'),
- history: { replaceState: jest.fn() },
- document: {
- ...jest.requireActual('global').document,
- location: {
- pathname: 'pathname',
- search: '?id=*',
+const { document } = global;
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...globalThis,
+ history: { replaceState: jest.fn() },
+ document: {
+ createElement: globalThis.document.createElement.bind(globalThis.document),
+ location: {
+ pathname: 'pathname',
+ search: '?id=*',
+ },
},
+ FEATURES: {
+ storyStoreV7: true,
+ },
+ fetch: async () => ({ status: 200, json: async () => mockStoryIndex }),
},
- FEATURES: {
- storyStoreV7: true,
- },
- fetch: async () => ({ status: 200, json: async () => mockStoryIndex }),
}));
beforeEach(() => {
@@ -93,10 +95,10 @@ describe('PreviewWeb', () => {
document.location.search = '?id=component-one--docs&viewMode=docs';
const preview = new PreviewWeb();
- const docsRoot = window.document.createElement('div');
+ const docsRoot = document.createElement('div');
(
preview.view.prepareForDocs as any as jest.Mock
- ).mockReturnValue(docsRoot);
+ ).mockReturnValue(docsRoot as any);
componentOneExports.default.parameters.docs.container.mockImplementationOnce(() =>
React.createElement('div', {}, 'INSIDE')
);
diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts
index 79e9769c728d..9503858ac003 100644
--- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts
+++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.test.ts
@@ -3,7 +3,7 @@
*/
import { jest, jest as mockJest, it, describe, beforeEach, afterEach, expect } from '@jest/globals';
-import global from 'global';
+import { global } from '@storybook/global';
import merge from 'lodash/merge';
import {
CONFIG_ERROR,
@@ -59,21 +59,23 @@ const { history, document } = global;
const mockStoryIndex = jest.fn(() => storyIndex);
let mockFetchResult: any;
-jest.mock('global', () => ({
- ...(mockJest.requireActual('global') as any),
- history: { replaceState: mockJest.fn() },
- document: {
- location: {
- pathname: 'pathname',
- search: '?id=*',
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...(mockJest.requireActual('@storybook/global') as any),
+ history: { replaceState: mockJest.fn() },
+ document: {
+ location: {
+ pathname: 'pathname',
+ search: '?id=*',
+ },
},
+ FEATURES: {
+ storyStoreV7: true,
+ breakingChangesV7: true,
+ // xxx
+ },
+ fetch: async () => mockFetchResult,
},
- FEATURES: {
- storyStoreV7: true,
- breakingChangesV7: true,
- // xxx
- },
- fetch: async () => mockFetchResult,
}));
jest.mock('@storybook/client-logger');
diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.tsx b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.tsx
index a1ed45f445c9..e945320a0f0c 100644
--- a/code/lib/preview-api/src/modules/preview-web/PreviewWeb.tsx
+++ b/code/lib/preview-api/src/modules/preview-web/PreviewWeb.tsx
@@ -1,3 +1,5 @@
+/* eslint-disable no-underscore-dangle */
+import { global } from '@storybook/global';
import type { Renderer } from '@storybook/types';
import { PreviewWithSelection } from './PreviewWithSelection';
@@ -7,5 +9,7 @@ import { WebView } from './WebView';
export class PreviewWeb extends PreviewWithSelection {
constructor() {
super(new UrlStore(), new WebView());
+
+ global.__STORYBOOK_PREVIEW__ = this;
}
}
diff --git a/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx b/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx
index 069d10758d84..20fe1c96397b 100644
--- a/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx
+++ b/code/lib/preview-api/src/modules/preview-web/PreviewWithSelection.tsx
@@ -1,5 +1,5 @@
import { dedent } from 'ts-dedent';
-import global from 'global';
+import { global } from '@storybook/global';
import {
CURRENT_STORY_WAS_SET,
PRELOAD_ENTRIES,
diff --git a/code/lib/preview-api/src/modules/preview-web/UrlStore.test.ts b/code/lib/preview-api/src/modules/preview-web/UrlStore.test.ts
index 9abba8f7c0e2..58784329913c 100644
--- a/code/lib/preview-api/src/modules/preview-web/UrlStore.test.ts
+++ b/code/lib/preview-api/src/modules/preview-web/UrlStore.test.ts
@@ -1,15 +1,17 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { pathToId, setPath, getSelectionSpecifierFromPath } from './UrlStore';
const { history, document } = global;
-jest.mock('global', () => ({
- history: { replaceState: jest.fn() },
- document: {
- location: {
- pathname: 'pathname',
- search: '',
+jest.mock('@storybook/global', () => ({
+ global: {
+ history: { replaceState: jest.fn() },
+ document: {
+ location: {
+ pathname: 'pathname',
+ search: '',
+ },
},
},
}));
diff --git a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts
index d0e692011da5..16d66ba7f6b6 100644
--- a/code/lib/preview-api/src/modules/preview-web/UrlStore.ts
+++ b/code/lib/preview-api/src/modules/preview-web/UrlStore.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import qs from 'qs';
import type { ViewMode } from '@storybook/types';
diff --git a/code/lib/preview-api/src/modules/preview-web/WebView.ts b/code/lib/preview-api/src/modules/preview-web/WebView.ts
index 2ce3c6ecabab..5d038e5230b4 100644
--- a/code/lib/preview-api/src/modules/preview-web/WebView.ts
+++ b/code/lib/preview-api/src/modules/preview-web/WebView.ts
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
-import global from 'global';
+import { global } from '@storybook/global';
import { logger } from '@storybook/client-logger';
import AnsiToHtml from 'ansi-to-html';
import { dedent } from 'ts-dedent';
@@ -78,7 +78,7 @@ export class WebView implements View {
}
storyRoot(): HTMLElement {
- return document.getElementById('storybook-root');
+ return document.getElementById('storybook-root')!;
}
prepareForDocs() {
@@ -89,12 +89,12 @@ export class WebView implements View {
}
docsRoot(): HTMLElement {
- return document.getElementById('storybook-docs');
+ return document.getElementById('storybook-docs')!;
}
applyLayout(layout: Layout = 'padded') {
if (layout === 'none') {
- document.body.classList.remove(this.currentLayoutClass);
+ document.body.classList.remove(this.currentLayoutClass!);
this.currentLayoutClass = null;
return;
}
@@ -103,7 +103,7 @@ export class WebView implements View {
const layoutClass = layoutClassMap[layout];
- document.body.classList.remove(this.currentLayoutClass);
+ document.body.classList.remove(this.currentLayoutClass!);
document.body.classList.add(layoutClass);
this.currentLayoutClass = layoutClass;
}
@@ -137,8 +137,8 @@ export class WebView implements View {
detail = parts.slice(1).join('\n');
}
- document.getElementById('error-message').innerHTML = ansiConverter.toHtml(header);
- document.getElementById('error-stack').innerHTML = ansiConverter.toHtml(detail);
+ document.getElementById('error-message')!.innerHTML = ansiConverter.toHtml(header);
+ document.getElementById('error-stack')!.innerHTML = ansiConverter.toHtml(detail);
this.showMode(Mode.ERROR);
}
diff --git a/code/lib/preview-api/src/modules/preview-web/simulate-pageload.test.ts b/code/lib/preview-api/src/modules/preview-web/simulate-pageload.test.ts
index 12076059ceec..ec5f2051958d 100644
--- a/code/lib/preview-api/src/modules/preview-web/simulate-pageload.test.ts
+++ b/code/lib/preview-api/src/modules/preview-web/simulate-pageload.test.ts
@@ -2,7 +2,7 @@
* @jest-environment jsdom
*/
-import global from 'global';
+import { global } from '@storybook/global';
import { simulatePageLoad } from './simulate-pageload';
const { document } = global;
diff --git a/code/lib/preview-api/src/modules/preview-web/simulate-pageload.ts b/code/lib/preview-api/src/modules/preview-web/simulate-pageload.ts
index 23d40a994ce4..0914968b45f5 100644
--- a/code/lib/preview-api/src/modules/preview-web/simulate-pageload.ts
+++ b/code/lib/preview-api/src/modules/preview-web/simulate-pageload.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { document } = global;
diff --git a/code/lib/preview-api/src/modules/preview-web/typings.d.ts b/code/lib/preview-api/src/modules/preview-web/typings.d.ts
deleted file mode 100644
index 08f7a767bfef..000000000000
--- a/code/lib/preview-api/src/modules/preview-web/typings.d.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-declare module 'global';
-
-declare module 'ansi-to-html';
-declare class AnsiToHtml {
- constructor(options: { escapeHtml: boolean });
-
- toHtml: (ansi: string) => string;
-}
diff --git a/code/lib/preview-api/src/modules/store/StoryStore.test.ts b/code/lib/preview-api/src/modules/store/StoryStore.test.ts
index 7f538cc8ee7c..3bbf2f970906 100644
--- a/code/lib/preview-api/src/modules/store/StoryStore.test.ts
+++ b/code/lib/preview-api/src/modules/store/StoryStore.test.ts
@@ -1,5 +1,5 @@
import type { Renderer, ProjectAnnotations, StoryIndex } from '@storybook/types';
-import global from 'global';
+import { global } from '@storybook/global';
import { expect } from '@jest/globals';
import { prepareStory } from './csf/prepareStory';
@@ -15,10 +15,12 @@ jest.mock('./csf/processCSFFile', () => ({
processCSFFile: jest.fn(jest.requireActual('./csf/processCSFFile').processCSFFile),
}));
-jest.mock('global', () => ({
- ...(jest.requireActual('global') as any),
- FEATURES: {
- breakingChangesV7: true,
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...(jest.requireActual('@storybook/global') as any),
+ FEATURES: {
+ breakingChangesV7: true,
+ },
},
}));
@@ -985,10 +987,10 @@ describe('StoryStore', () => {
describe('getStoriesJsonData', () => {
describe('in back-compat mode', () => {
beforeEach(() => {
- global.FEATURES.breakingChangesV7 = false;
+ global.FEATURES!.breakingChangesV7 = false;
});
afterEach(() => {
- global.FEATURES.breakingChangesV7 = true;
+ global.FEATURES!.breakingChangesV7 = true;
});
it('maps stories list to payload correctly', async () => {
const store = new StoryStore();
diff --git a/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts b/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
index bccf030a7bba..a2d069d70239 100644
--- a/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
+++ b/code/lib/preview-api/src/modules/store/csf/prepareStory.test.ts
@@ -1,6 +1,6 @@
/// ;
-import global from 'global';
+import { global } from '@storybook/global';
import { expect } from '@jest/globals';
import type {
Renderer,
@@ -14,10 +14,12 @@ import { addons, HooksContext } from '../../addons';
import { NO_TARGET_NAME } from '../args';
import { prepareStory } from './prepareStory';
-jest.mock('global', () => ({
- ...(jest.requireActual('global') as any),
- FEATURES: {
- breakingChangesV7: true,
+jest.mock('@storybook/global', () => ({
+ global: {
+ ...(jest.requireActual('@storybook/global') as any),
+ FEATURES: {
+ breakingChangesV7: true,
+ },
},
}));
diff --git a/code/lib/preview-api/src/modules/store/csf/prepareStory.ts b/code/lib/preview-api/src/modules/store/csf/prepareStory.ts
index b23183110dc1..7e65a6010426 100644
--- a/code/lib/preview-api/src/modules/store/csf/prepareStory.ts
+++ b/code/lib/preview-api/src/modules/store/csf/prepareStory.ts
@@ -1,6 +1,6 @@
import { dedent } from 'ts-dedent';
import deprecate from 'util-deprecate';
-import global from 'global';
+import { global } from '@storybook/global';
import type {
Renderer,
@@ -150,6 +150,7 @@ export function prepareStory(
);
// Add some of our metadata into parameters as we used to do this in 6.x and users may be relying on it
+
if (!global.FEATURES?.breakingChangesV7) {
contextForEnhancers.parameters = {
...contextForEnhancers.parameters,
diff --git a/code/lib/preview-api/src/modules/store/typings.d.ts b/code/lib/preview-api/src/modules/store/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/lib/preview-api/src/modules/store/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/lib/preview-api/src/preview-web.ts b/code/lib/preview-api/src/preview-web.ts
index 1f0814fb7af6..a22e9cb03234 100644
--- a/code/lib/preview-api/src/preview-web.ts
+++ b/code/lib/preview-api/src/preview-web.ts
@@ -1 +1,4 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
export * from './modules/preview-web';
diff --git a/code/lib/preview-api/src/store.ts b/code/lib/preview-api/src/store.ts
index 33f273a96034..fa89863e406e 100644
--- a/code/lib/preview-api/src/store.ts
+++ b/code/lib/preview-api/src/store.ts
@@ -1 +1,4 @@
+/* eslint-disable @typescript-eslint/triple-slash-reference */
+///
+
export * from './modules/store';
diff --git a/code/lib/preview-api/src/typings.d.ts b/code/lib/preview-api/src/typings.d.ts
new file mode 100644
index 000000000000..2c963acb62c8
--- /dev/null
+++ b/code/lib/preview-api/src/typings.d.ts
@@ -0,0 +1,37 @@
+/* eslint-disable no-underscore-dangle */
+/* eslint-disable @typescript-eslint/naming-convention */
+declare module 'lazy-universal-dotenv';
+declare module 'pnp-webpack-plugin';
+declare module '@storybook/manager/paths';
+declare module 'better-opn';
+declare module 'open';
+declare module '@aw-web-design/x-default-browser';
+
+type Features = {
+ storyStoreV7?: boolean;
+ breakingChangesV7?: boolean;
+ argTypeTargetsV7?: boolean;
+};
+
+var FEATURES: Features | undefined;
+var STORIES: any;
+var DOCS_OPTIONS: any;
+
+// To enable user code to detect if it is running in Storybook
+var IS_STORYBOOK: boolean;
+
+// ClientApi (and StoreStore) are really singletons. However they are not created until the
+// relevant framework instantiates them via `start.js`. The good news is this happens right away.
+var __STORYBOOK_ADDONS_CHANNEL__: any;
+var __STORYBOOK_ADDONS_PREVIEW: any;
+var __STORYBOOK_CLIENT_API__: import('./modules/client-api/ClientApi').ClientApi;
+var __STORYBOOK_PREVIEW__: import('./modules/preview-web/PreviewWeb').PreviewWeb;
+var __STORYBOOK_STORY_STORE__: any;
+var STORYBOOK_HOOKS_CONTEXT: any;
+
+declare module 'ansi-to-html';
+declare class AnsiToHtml {
+ constructor(options: { escapeHtml: boolean });
+
+ toHtml: (ansi: string) => string;
+}
diff --git a/code/lib/router/package.json b/code/lib/router/package.json
index acfcdc21e384..81db6a403ee5 100644
--- a/code/lib/router/package.json
+++ b/code/lib/router/package.json
@@ -52,8 +52,8 @@
"qs": "^6.10.0"
},
"devDependencies": {
+ "@storybook/global": "^5.0.0",
"dequal": "^2.0.2",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"react-router-dom": "6.0.2",
"ts-dedent": "^2.0.0",
diff --git a/code/lib/router/src/index.ts b/code/lib/router/src/index.ts
index 1026ffcf03e2..a185eddbd096 100644
--- a/code/lib/router/src/index.ts
+++ b/code/lib/router/src/index.ts
@@ -1,6 +1,3 @@
-// eslint-disable-next-line @typescript-eslint/triple-slash-reference
-///
-
export * from './utils';
export * from './router';
export * from './types';
diff --git a/code/lib/router/src/router.tsx b/code/lib/router/src/router.tsx
index 413ed5aba6cc..4005dc4b7804 100644
--- a/code/lib/router/src/router.tsx
+++ b/code/lib/router/src/router.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import React, { useCallback } from 'react';
import type { ReactNode } from 'react';
diff --git a/code/lib/router/src/typings.d.ts b/code/lib/router/src/typings.d.ts
deleted file mode 100644
index 556e4042c702..000000000000
--- a/code/lib/router/src/typings.d.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-// todo the following packages need definition files or a TS migration
-declare module 'global';
diff --git a/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.test.js.snap b/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.test.js.snap
index fe9a7c7180fb..f1d57185b39b 100644
--- a/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.test.js.snap
+++ b/code/lib/source-loader/src/abstract-syntax-tree/__snapshots__/inject-decorator.test.js.snap
@@ -827,7 +827,6 @@ storiesOf('Addons|Info.GitHub issues', module).addParameters({ storySource: { so
exports[`inject-decorator stories with ugly comments in ts should delete ugly comments from the generated story source 1`] = `
"
-
import React from 'react';
@Component({
@@ -865,7 +864,6 @@ storiesOf('Foo', module)
exports[`inject-decorator stories with ugly comments should delete ugly comments from the generated story source 1`] = `
"
-
import React from 'react';
diff --git a/code/lib/store/template/stories/argTypes.stories.ts b/code/lib/store/template/stories/argTypes.stories.ts
index 409e20212a59..2c72888297c8 100644
--- a/code/lib/store/template/stories/argTypes.stories.ts
+++ b/code/lib/store/template/stories/argTypes.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/args.stories.ts b/code/lib/store/template/stories/args.stories.ts
index 5b39fa61e509..80a4e8f26320 100644
--- a/code/lib/store/template/stories/args.stories.ts
+++ b/code/lib/store/template/stories/args.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/autotitle.stories.ts b/code/lib/store/template/stories/autotitle.stories.ts
index dacdc7c7e025..0859431330ae 100644
--- a/code/lib/store/template/stories/autotitle.stories.ts
+++ b/code/lib/store/template/stories/autotitle.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { expect } from '@storybook/jest';
import type { PlayFunctionContext } from '@storybook/types';
diff --git a/code/lib/store/template/stories/decorators.stories.ts b/code/lib/store/template/stories/decorators.stories.ts
index 7eb325160788..5dc104ded1a5 100644
--- a/code/lib/store/template/stories/decorators.stories.ts
+++ b/code/lib/store/template/stories/decorators.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/exportOrder.stories.ts b/code/lib/store/template/stories/exportOrder.stories.ts
index 51cbb77a63fb..cb6221bf5e33 100644
--- a/code/lib/store/template/stories/exportOrder.stories.ts
+++ b/code/lib/store/template/stories/exportOrder.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Pre,
diff --git a/code/lib/store/template/stories/globals.stories.ts b/code/lib/store/template/stories/globals.stories.ts
index f0556452d0a1..a1cdd3224099 100644
--- a/code/lib/store/template/stories/globals.stories.ts
+++ b/code/lib/store/template/stories/globals.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/hooks.stories.ts b/code/lib/store/template/stories/hooks.stories.ts
index d09c21af2115..55e134f4008a 100644
--- a/code/lib/store/template/stories/hooks.stories.ts
+++ b/code/lib/store/template/stories/hooks.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext } from '@storybook/types';
import { useEffect, useState } from '@storybook/preview-api';
import { within, userEvent } from '@storybook/testing-library';
diff --git a/code/lib/store/template/stories/interleavedExports.stories.ts b/code/lib/store/template/stories/interleavedExports.stories.ts
index 8fb77a77be3a..58b3e6eb055e 100644
--- a/code/lib/store/template/stories/interleavedExports.stories.ts
+++ b/code/lib/store/template/stories/interleavedExports.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Pre,
diff --git a/code/lib/store/template/stories/layout.stories.ts b/code/lib/store/template/stories/layout.stories.ts
index 1bc7c0c207e5..b7e45a83de6c 100644
--- a/code/lib/store/template/stories/layout.stories.ts
+++ b/code/lib/store/template/stories/layout.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
const style = {
display: 'block',
diff --git a/code/lib/store/template/stories/loaders.stories.ts b/code/lib/store/template/stories/loaders.stories.ts
index 0067ef218cb9..1cd71d65771c 100644
--- a/code/lib/store/template/stories/loaders.stories.ts
+++ b/code/lib/store/template/stories/loaders.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/names.stories.ts b/code/lib/store/template/stories/names.stories.ts
index 82900557b715..b840cbb1e8c8 100644
--- a/code/lib/store/template/stories/names.stories.ts
+++ b/code/lib/store/template/stories/names.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { expect } from '@storybook/jest';
import type { PlayFunctionContext } from '@storybook/types';
diff --git a/code/lib/store/template/stories/parameters.stories.ts b/code/lib/store/template/stories/parameters.stories.ts
index 99d92ae71be2..fc15f7bb3d61 100644
--- a/code/lib/store/template/stories/parameters.stories.ts
+++ b/code/lib/store/template/stories/parameters.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/rendering.stories.ts b/code/lib/store/template/stories/rendering.stories.ts
index d79f1a3fb0cc..58b7ca91d8f8 100644
--- a/code/lib/store/template/stories/rendering.stories.ts
+++ b/code/lib/store/template/stories/rendering.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PlayFunctionContext } from '@storybook/types';
import { within, waitFor } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/shortcuts.stories.ts b/code/lib/store/template/stories/shortcuts.stories.ts
index 6a0ffec340bc..a55abe8a9a8f 100644
--- a/code/lib/store/template/stories/shortcuts.stories.ts
+++ b/code/lib/store/template/stories/shortcuts.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { userEvent, within } from '@storybook/testing-library';
import { PREVIEW_KEYDOWN } from '@storybook/core-events';
import { jest, expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/tags.stories.ts b/code/lib/store/template/stories/tags.stories.ts
index 57d7b73c80f7..8f0a15a5648e 100644
--- a/code/lib/store/template/stories/tags.stories.ts
+++ b/code/lib/store/template/stories/tags.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, PlayFunctionContext, StoryContext } from '@storybook/types';
import { within } from '@storybook/testing-library';
import { expect } from '@storybook/jest';
diff --git a/code/lib/store/template/stories/title.stories.ts b/code/lib/store/template/stories/title.stories.ts
index 49b5288d732f..8e87740d1bf7 100644
--- a/code/lib/store/template/stories/title.stories.ts
+++ b/code/lib/store/template/stories/title.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { expect } from '@storybook/jest';
import type { PlayFunctionContext } from '@storybook/types';
diff --git a/code/lib/store/template/stories/unicode.stories.ts b/code/lib/store/template/stories/unicode.stories.ts
index 387896d3f234..71282e62f3b2 100644
--- a/code/lib/store/template/stories/unicode.stories.ts
+++ b/code/lib/store/template/stories/unicode.stories.ts
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
export default {
component: globalThis.Components.Button,
diff --git a/code/lib/theming/package.json b/code/lib/theming/package.json
index c7d0086c194f..fb7c558b4661 100644
--- a/code/lib/theming/package.json
+++ b/code/lib/theming/package.json
@@ -50,6 +50,7 @@
"dependencies": {
"@emotion/use-insertion-effect-with-fallbacks": "^1.0.0",
"@storybook/client-logger": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"memoizerific": "^1.11.3"
},
"devDependencies": {
@@ -61,7 +62,6 @@
"@types/node": "^16.0.0",
"deep-object-diff": "^1.1.0",
"fs-extra": "^9.0.1",
- "global": "^4.4.0",
"polished": "^4.2.2",
"ts-dedent": "^2.0.0",
"typescript": "~4.9.3"
diff --git a/code/lib/theming/src/tests/util.test.js b/code/lib/theming/src/tests/util.test.js
index 521cefbfe9df..6580f7458fbf 100644
--- a/code/lib/theming/src/tests/util.test.js
+++ b/code/lib/theming/src/tests/util.test.js
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { lightenColor as lighten, darkenColor as darken, getPreferredColorScheme } from '../utils';
const { window: globalWindow } = global;
@@ -80,7 +80,7 @@ describe('utils', () => {
describe('getPreferredColorScheme', () => {
it('should return "light" if "window" is unavailable', () => {
- jest.mock('global', () => ({ window: undefined }));
+ jest.mock('@storybook/global', () => ({ global: { window: undefined } }));
const colorScheme = getPreferredColorScheme();
expect(colorScheme).toBe('light');
diff --git a/code/lib/theming/src/typings.d.ts b/code/lib/theming/src/typings.d.ts
index ab568e12c7ac..151bb56deda3 100644
--- a/code/lib/theming/src/typings.d.ts
+++ b/code/lib/theming/src/typings.d.ts
@@ -1,3 +1,2 @@
// todo the following packages need definition files or a TS migration
declare module 'react-inspector';
-declare module 'global';
diff --git a/code/lib/theming/src/utils.ts b/code/lib/theming/src/utils.ts
index 2c94ea94e8ce..cbb5d7a2cf07 100644
--- a/code/lib/theming/src/utils.ts
+++ b/code/lib/theming/src/utils.ts
@@ -1,5 +1,5 @@
import { rgba, lighten, darken } from 'polished';
-import global from 'global';
+import { global } from '@storybook/global';
import { logger } from '@storybook/client-logger';
diff --git a/code/lib/types/src/index.ts b/code/lib/types/src/index.ts
index a4b31735daa5..dadfe53704a4 100644
--- a/code/lib/types/src/index.ts
+++ b/code/lib/types/src/index.ts
@@ -1,6 +1,3 @@
-// eslint-disable-next-line @typescript-eslint/triple-slash-reference
-///
-
export * from './modules/csf';
export * from './modules/addons';
export * from './modules/story';
diff --git a/code/lib/types/src/typings.d.ts b/code/lib/types/src/typings.d.ts
deleted file mode 100644
index 2f4eb9cf4fd9..000000000000
--- a/code/lib/types/src/typings.d.ts
+++ /dev/null
@@ -1 +0,0 @@
-declare module 'global';
diff --git a/code/package.json b/code/package.json
index 5f0b154e1eea..2fa1b5359551 100644
--- a/code/package.json
+++ b/code/package.json
@@ -190,6 +190,7 @@
"@storybook/docs-tools": "workspace:*",
"@storybook/ember": "workspace:*",
"@storybook/eslint-config-storybook": "^3.1.2",
+ "@storybook/global": "^5.0.0",
"@storybook/html": "workspace:*",
"@storybook/html-vite": "workspace:*",
"@storybook/html-webpack5": "workspace:*",
@@ -294,7 +295,6 @@
"fs-extra": "^9.0.1",
"github-release-from-changelog": "^2.1.1",
"glob": "^7.1.6",
- "global": "^4.4.0",
"http-server": "^0.12.3",
"husky": "^4.3.7",
"jest": "^29.3.1",
diff --git a/code/presets/react-webpack/src/typings.d.ts b/code/presets/react-webpack/src/typings.d.ts
index ce0c26f59d0a..53aa2b04a775 100644
--- a/code/presets/react-webpack/src/typings.d.ts
+++ b/code/presets/react-webpack/src/typings.d.ts
@@ -1,5 +1,3 @@
-declare module 'global';
-
// TODO: Replace, as soon as @types/react-dom 17.0.14 is used
// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/fb0f14b7a35cde26ffaa82e7536c062e593e9ae6/types/react-dom/client.d.ts
declare module 'react-dom/client' {
diff --git a/code/presets/server-webpack/package.json b/code/presets/server-webpack/package.json
index daf13ef0134d..59abb225045d 100644
--- a/code/presets/server-webpack/package.json
+++ b/code/presets/server-webpack/package.json
@@ -57,9 +57,9 @@
"dependencies": {
"@storybook/core-server": "7.0.0-beta.12",
"@storybook/core-webpack": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/server": "7.0.0-beta.12",
"@types/node": "^16.0.0",
- "global": "^4.4.0",
"safe-identifier": "^0.4.1",
"ts-dedent": "^2.0.0",
"yaml-loader": "^0.8.0"
diff --git a/code/presets/server-webpack/src/typings.d.ts b/code/presets/server-webpack/src/typings.d.ts
index d8f7c6f660ad..cbeccdbb15f7 100644
--- a/code/presets/server-webpack/src/typings.d.ts
+++ b/code/presets/server-webpack/src/typings.d.ts
@@ -1,4 +1,2 @@
-declare module 'global';
-
// will be provided by the webpack define plugin
declare var NODE_ENV: string | undefined;
diff --git a/code/presets/vue3-webpack/src/typings.d.ts b/code/presets/vue3-webpack/src/typings.d.ts
index 3229acac0222..a045728260a0 100644
--- a/code/presets/vue3-webpack/src/typings.d.ts
+++ b/code/presets/vue3-webpack/src/typings.d.ts
@@ -1,5 +1,3 @@
-declare module 'global';
-
declare module 'vue-loader' {
export const VueLoaderPlugin: any;
}
diff --git a/code/renderers/html/package.json b/code/renderers/html/package.json
index 207499142a5e..862063b8a525 100644
--- a/code/renderers/html/package.json
+++ b/code/renderers/html/package.json
@@ -53,9 +53,9 @@
"dependencies": {
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
diff --git a/code/renderers/html/src/docs/sourceDecorator.ts b/code/renderers/html/src/docs/sourceDecorator.ts
index 46d5e0642e3a..459ea267ce9f 100644
--- a/code/renderers/html/src/docs/sourceDecorator.ts
+++ b/code/renderers/html/src/docs/sourceDecorator.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+
import { SNIPPET_RENDERED, SourceType } from '@storybook/docs-tools';
import { addons, useEffect } from '@storybook/preview-api';
import type { PartialStoryFn } from '@storybook/types';
diff --git a/code/renderers/html/src/globals.ts b/code/renderers/html/src/globals.ts
index 7d924c74dd19..ae50d238fbf9 100644
--- a/code/renderers/html/src/globals.ts
+++ b/code/renderers/html/src/globals.ts
@@ -1,6 +1,4 @@
-// eslint-disable-next-line @typescript-eslint/ban-ts-comment
-// @ts-ignore - use ts-ignore instead of ts-expect-error to fix type issues in Angular sandbox
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/html/src/render.ts b/code/renderers/html/src/render.ts
index 752e2283aeda..a15f9b860276 100644
--- a/code/renderers/html/src/render.ts
+++ b/code/renderers/html/src/render.ts
@@ -1,6 +1,5 @@
/* eslint-disable no-param-reassign */
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import { simulatePageLoad, simulateDOMContentLoaded } from '@storybook/preview-api';
diff --git a/code/renderers/html/src/typings.d.ts b/code/renderers/html/src/typings.d.ts
new file mode 100644
index 000000000000..cdcf9483c5fc
--- /dev/null
+++ b/code/renderers/html/src/typings.d.ts
@@ -0,0 +1 @@
+declare var STORYBOOK_ENV: 'HTML';
diff --git a/code/renderers/html/template/components/index.js b/code/renderers/html/template/components/index.js
index 4d08c9813587..45c91d5c8a71 100644
--- a/code/renderers/html/template/components/index.js
+++ b/code/renderers/html/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Button } from './Button';
import { Pre } from './Pre';
diff --git a/code/renderers/preact/package.json b/code/renderers/preact/package.json
index f3424667e52d..d46f5be364e9 100644
--- a/code/renderers/preact/package.json
+++ b/code/renderers/preact/package.json
@@ -52,9 +52,9 @@
},
"dependencies": {
"@storybook/core-client": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
diff --git a/code/renderers/preact/src/globals.ts b/code/renderers/preact/src/globals.ts
index 02a952c2aac0..2d0b4060e445 100644
--- a/code/renderers/preact/src/globals.ts
+++ b/code/renderers/preact/src/globals.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/preact/src/typings.d.ts b/code/renderers/preact/src/typings.d.ts
new file mode 100644
index 000000000000..b091271db976
--- /dev/null
+++ b/code/renderers/preact/src/typings.d.ts
@@ -0,0 +1 @@
+declare var STORYBOOK_ENV: 'preact';
diff --git a/code/renderers/preact/template/components/index.js b/code/renderers/preact/template/components/index.js
index d952d26f9b1f..e487348995ff 100644
--- a/code/renderers/preact/template/components/index.js
+++ b/code/renderers/preact/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Button } from './Button.jsx';
import { Pre } from './Pre.jsx';
diff --git a/code/renderers/react/package.json b/code/renderers/react/package.json
index a4cbfc6fac71..520a85facd8f 100644
--- a/code/renderers/react/package.json
+++ b/code/renderers/react/package.json
@@ -55,6 +55,7 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"@types/estree": "^0.0.51",
@@ -63,7 +64,6 @@
"acorn-jsx": "^5.3.1",
"acorn-walk": "^7.2.0",
"escodegen": "^2.0.0",
- "global": "^4.4.0",
"html-tags": "^3.1.0",
"lodash": "^4.17.21",
"prop-types": "^15.7.2",
diff --git a/code/renderers/react/src/globals.ts b/code/renderers/react/src/globals.ts
index e50560a3c9fe..9df06c57f368 100644
--- a/code/renderers/react/src/globals.ts
+++ b/code/renderers/react/src/globals.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/react/src/render.tsx b/code/renderers/react/src/render.tsx
index cc3f07f3e2c4..383aad4a5313 100644
--- a/code/renderers/react/src/render.tsx
+++ b/code/renderers/react/src/render.tsx
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC, ReactElement } from 'react';
import React, {
diff --git a/code/renderers/react/src/typings.d.ts b/code/renderers/react/src/typings.d.ts
index 53aa2b04a775..440b5a4e24a4 100644
--- a/code/renderers/react/src/typings.d.ts
+++ b/code/renderers/react/src/typings.d.ts
@@ -42,3 +42,6 @@ declare module 'react-dom/client' {
options?: HydrationOptions
): Root;
}
+
+declare var STORYBOOK_ENV: 'react';
+declare var FRAMEWORK_OPTIONS: any;
diff --git a/code/renderers/react/template/components/index.js b/code/renderers/react/template/components/index.js
index dd5fc33a43bc..88212aaa952b 100644
--- a/code/renderers/react/template/components/index.js
+++ b/code/renderers/react/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Button } from './Button.jsx';
import { Pre } from './Pre.jsx';
diff --git a/code/renderers/react/template/stories/react-mdx.stories.mdx b/code/renderers/react/template/stories/react-mdx.stories.mdx
index 8591bc513b25..e8676a0e22d8 100644
--- a/code/renderers/react/template/stories/react-mdx.stories.mdx
+++ b/code/renderers/react/template/stories/react-mdx.stories.mdx
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Meta, Story, Canvas } from '@storybook/addon-docs';
diff --git a/code/renderers/server/package.json b/code/renderers/server/package.json
index 18a5930b1b63..e88aa8448da0 100644
--- a/code/renderers/server/package.json
+++ b/code/renderers/server/package.json
@@ -52,9 +52,9 @@
},
"dependencies": {
"@storybook/core-client": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
diff --git a/code/renderers/server/src/globals.ts b/code/renderers/server/src/globals.ts
index 58f494cf5e56..f207a23048bd 100644
--- a/code/renderers/server/src/globals.ts
+++ b/code/renderers/server/src/globals.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/server/src/render.ts b/code/renderers/server/src/render.ts
index d72538e3ae72..b0276f377013 100644
--- a/code/renderers/server/src/render.ts
+++ b/code/renderers/server/src/render.ts
@@ -1,6 +1,5 @@
/* eslint-disable no-param-reassign */
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import type { RenderContext } from '@storybook/types';
diff --git a/code/renderers/server/src/typings.d.ts b/code/renderers/server/src/typings.d.ts
new file mode 100644
index 000000000000..2517fab3c095
--- /dev/null
+++ b/code/renderers/server/src/typings.d.ts
@@ -0,0 +1 @@
+declare var STORYBOOK_ENV: 'SERVER';
diff --git a/code/renderers/svelte/package.json b/code/renderers/svelte/package.json
index 5e57df2a4add..257c1f588bc9 100644
--- a/code/renderers/svelte/package.json
+++ b/code/renderers/svelte/package.json
@@ -58,9 +58,9 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"sveltedoc-parser": "^4.2.1",
"type-fest": "2.19.0"
},
diff --git a/code/renderers/svelte/src/globals.ts b/code/renderers/svelte/src/globals.ts
index a2fb5c9dad10..a9adc16b0908 100644
--- a/code/renderers/svelte/src/globals.ts
+++ b/code/renderers/svelte/src/globals.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/svelte/src/typings.d.ts b/code/renderers/svelte/src/typings.d.ts
index 2f4eb9cf4fd9..09aff65be53a 100644
--- a/code/renderers/svelte/src/typings.d.ts
+++ b/code/renderers/svelte/src/typings.d.ts
@@ -1 +1 @@
-declare module 'global';
+declare var STORYBOOK_ENV: 'svelte';
diff --git a/code/renderers/svelte/template/components/index.js b/code/renderers/svelte/template/components/index.js
index e01d07856369..5eb0b63bc7a4 100644
--- a/code/renderers/svelte/template/components/index.js
+++ b/code/renderers/svelte/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import Button from './Button.svelte';
import Pre from './Pre.svelte';
diff --git a/code/renderers/svelte/template/stories/svelte-mdx.stories.mdx b/code/renderers/svelte/template/stories/svelte-mdx.stories.mdx
index b8b3cabb51b0..652714619c95 100644
--- a/code/renderers/svelte/template/stories/svelte-mdx.stories.mdx
+++ b/code/renderers/svelte/template/stories/svelte-mdx.stories.mdx
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Meta, Story, Canvas } from '@storybook/addon-docs';
import ButtonView from './views/ButtonView.svelte';
import BorderDecoratorRed from './views/BorderDecoratorRed.svelte';
diff --git a/code/renderers/svelte/template/stories/views/ButtonView.svelte b/code/renderers/svelte/template/stories/views/ButtonView.svelte
index d957e58b21cf..02d21e532347 100644
--- a/code/renderers/svelte/template/stories/views/ButtonView.svelte
+++ b/code/renderers/svelte/template/stories/views/ButtonView.svelte
@@ -3,7 +3,7 @@
* @component Button View
* @wrapper
*/
- import globalThis from 'global';
+ import { global as globalThis } from '@storybook/global';
const Button = globalThis.Components.Button;
/**
diff --git a/code/renderers/vue/package.json b/code/renderers/vue/package.json
index 7f0062ae6354..0ae2d54a0f93 100644
--- a/code/renderers/vue/package.json
+++ b/code/renderers/vue/package.json
@@ -54,9 +54,9 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0",
"type-fest": "2.19.0"
},
diff --git a/code/renderers/vue/src/globals.ts b/code/renderers/vue/src/globals.ts
index 2fec84f69602..f91a342510a2 100644
--- a/code/renderers/vue/src/globals.ts
+++ b/code/renderers/vue/src/globals.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/vue/src/typings.d.ts b/code/renderers/vue/src/typings.d.ts
new file mode 100644
index 000000000000..437680c4e974
--- /dev/null
+++ b/code/renderers/vue/src/typings.d.ts
@@ -0,0 +1 @@
+declare var STORYBOOK_ENV: 'vue';
diff --git a/code/renderers/vue/template/components/index.js b/code/renderers/vue/template/components/index.js
index bc9a1b67a30b..342dc4a7a988 100644
--- a/code/renderers/vue/template/components/index.js
+++ b/code/renderers/vue/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import Vue from 'vue';
import Button from './Button.vue';
diff --git a/code/renderers/vue/template/stories/custom-decorators.stories.js b/code/renderers/vue/template/stories/custom-decorators.stories.js
index 3b061ab7d375..1415f6987614 100644
--- a/code/renderers/vue/template/stories/custom-decorators.stories.js
+++ b/code/renderers/vue/template/stories/custom-decorators.stories.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
const MyButton = globalThis.Components.Button;
diff --git a/code/renderers/vue/template/stories/custom-rendering.stories.js b/code/renderers/vue/template/stories/custom-rendering.stories.js
index 895df94d9d85..39032b05f8f7 100644
--- a/code/renderers/vue/template/stories/custom-rendering.stories.js
+++ b/code/renderers/vue/template/stories/custom-rendering.stories.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
const MyButton = globalThis.Components.Button;
diff --git a/code/renderers/vue/template/stories/vue-mdx.stories.mdx b/code/renderers/vue/template/stories/vue-mdx.stories.mdx
index 8a65cb358062..067d9af4eb6b 100644
--- a/code/renderers/vue/template/stories/vue-mdx.stories.mdx
+++ b/code/renderers/vue/template/stories/vue-mdx.stories.mdx
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Meta, Story, Canvas } from '@storybook/addon-docs';
diff --git a/code/renderers/vue3/package.json b/code/renderers/vue3/package.json
index 7f7916652f16..dd2b610175b8 100644
--- a/code/renderers/vue3/package.json
+++ b/code/renderers/vue3/package.json
@@ -53,9 +53,9 @@
"dependencies": {
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0",
"type-fest": "2.19.0"
},
diff --git a/code/renderers/vue3/src/globals.ts b/code/renderers/vue3/src/globals.ts
index 5a17ebf65326..58d62a43b4b6 100644
--- a/code/renderers/vue3/src/globals.ts
+++ b/code/renderers/vue3/src/globals.ts
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/vue3/src/typings.d.ts b/code/renderers/vue3/src/typings.d.ts
new file mode 100644
index 000000000000..f4beceae1d63
--- /dev/null
+++ b/code/renderers/vue3/src/typings.d.ts
@@ -0,0 +1 @@
+declare var STORYBOOK_ENV: 'vue3';
diff --git a/code/renderers/vue3/template/components/index.js b/code/renderers/vue3/template/components/index.js
index af1301e7e2ae..6ecc6f3997c1 100644
--- a/code/renderers/vue3/template/components/index.js
+++ b/code/renderers/vue3/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import Button from './Button.vue';
import Pre from './Pre.vue';
diff --git a/code/renderers/vue3/template/stories/decorators.stories.js b/code/renderers/vue3/template/stories/decorators.stories.js
index 5835f38eea13..53d64ae0f076 100644
--- a/code/renderers/vue3/template/stories/decorators.stories.js
+++ b/code/renderers/vue3/template/stories/decorators.stories.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { h } from 'vue';
const { Button, Pre } = globalThis.Components;
diff --git a/code/renderers/vue3/template/stories/preview.js b/code/renderers/vue3/template/stories/preview.js
index 1b2cbeae203b..c57ed02a172a 100644
--- a/code/renderers/vue3/template/stories/preview.js
+++ b/code/renderers/vue3/template/stories/preview.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
// eslint-disable-next-line import/no-extraneous-dependencies
import { setup } from '@storybook/vue3';
diff --git a/code/renderers/vue3/template/stories/vue3-mdx.stories.mdx b/code/renderers/vue3/template/stories/vue3-mdx.stories.mdx
index 1656236cf39f..e84f893819d5 100644
--- a/code/renderers/vue3/template/stories/vue3-mdx.stories.mdx
+++ b/code/renderers/vue3/template/stories/vue3-mdx.stories.mdx
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { Meta, Story, Canvas } from '@storybook/addon-docs';
diff --git a/code/renderers/web-components/package.json b/code/renderers/web-components/package.json
index 9545c9409be2..6ae523d36571 100644
--- a/code/renderers/web-components/package.json
+++ b/code/renderers/web-components/package.json
@@ -56,10 +56,10 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/core-client": "7.0.0-beta.12",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
- "global": "^4.4.0",
"ts-dedent": "^2.0.0"
},
"devDependencies": {
diff --git a/code/renderers/web-components/src/docs/__testfixtures__/lit-element-demo-card/input.js b/code/renderers/web-components/src/docs/__testfixtures__/lit-element-demo-card/input.js
index 0631666f8714..68087cf9aa09 100644
--- a/code/renderers/web-components/src/docs/__testfixtures__/lit-element-demo-card/input.js
+++ b/code/renderers/web-components/src/docs/__testfixtures__/lit-element-demo-card/input.js
@@ -1,5 +1,4 @@
-// @ts-expect-error (Converted from ts-ignore)
-import global from 'global';
+import { global } from '@storybook/global';
import { LitElement, html, css } from 'lit-element';
diff --git a/code/renderers/web-components/src/docs/custom-elements.test.ts b/code/renderers/web-components/src/docs/custom-elements.test.ts
index e8ba140e7a54..7ad642756d32 100644
--- a/code/renderers/web-components/src/docs/custom-elements.test.ts
+++ b/code/renderers/web-components/src/docs/custom-elements.test.ts
@@ -1,5 +1,5 @@
/* eslint-disable no-underscore-dangle */
-import global from 'global';
+import { global } from '@storybook/global';
import { extractArgTypes } from './custom-elements';
import customElementsManifest from './__testfixtures__/custom-elements.json';
diff --git a/code/renderers/web-components/src/docs/sourceDecorator.ts b/code/renderers/web-components/src/docs/sourceDecorator.ts
index adc1981f6235..ad9da01a9f8a 100644
--- a/code/renderers/web-components/src/docs/sourceDecorator.ts
+++ b/code/renderers/web-components/src/docs/sourceDecorator.ts
@@ -1,5 +1,4 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
import { render } from 'lit-html';
import type { ArgsStoryFn, PartialStoryFn, StoryContext } from '@storybook/types';
import { addons, useEffect } from '@storybook/preview-api';
diff --git a/code/renderers/web-components/src/framework-api.ts b/code/renderers/web-components/src/framework-api.ts
index 3f1d6c37385a..f1791641b2c6 100644
--- a/code/renderers/web-components/src/framework-api.ts
+++ b/code/renderers/web-components/src/framework-api.ts
@@ -1,5 +1,6 @@
/* eslint-disable no-underscore-dangle */
-/* global window */
+
+import { global } from '@storybook/global';
export function isValidComponent(tagName: string) {
if (!tagName) {
@@ -30,16 +31,13 @@ export function isValidMetaData(customElements: any) {
* @param customElements any for now as spec is not super stable yet
*/
export function setCustomElements(customElements: any) {
- // @ts-expect-error (Converted from ts-ignore)
- window.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
+ global.__STORYBOOK_CUSTOM_ELEMENTS__ = customElements;
}
export function setCustomElementsManifest(customElements: any) {
- // @ts-expect-error (Converted from ts-ignore)
- window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
+ global.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__ = customElements;
}
export function getCustomElements() {
- // @ts-expect-error (Converted from ts-ignore)
- return window.__STORYBOOK_CUSTOM_ELEMENTS__ || window.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__;
+ return global.__STORYBOOK_CUSTOM_ELEMENTS__ || global.__STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__;
}
diff --git a/code/renderers/web-components/src/globals.ts b/code/renderers/web-components/src/globals.ts
index 3a96cebeb784..7f8f0ff9b35e 100644
--- a/code/renderers/web-components/src/globals.ts
+++ b/code/renderers/web-components/src/globals.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/renderers/web-components/src/index.ts b/code/renderers/web-components/src/index.ts
index ffa29ea28b6d..4234d00e0726 100644
--- a/code/renderers/web-components/src/index.ts
+++ b/code/renderers/web-components/src/index.ts
@@ -1,6 +1,6 @@
///
-import global from 'global';
+import { global } from '@storybook/global';
import './globals';
diff --git a/code/renderers/web-components/src/render.ts b/code/renderers/web-components/src/render.ts
index cf8b24546ef5..350128dcd8d2 100644
--- a/code/renderers/web-components/src/render.ts
+++ b/code/renderers/web-components/src/render.ts
@@ -1,7 +1,7 @@
/* eslint-disable no-param-reassign */
/* eslint-disable @typescript-eslint/ban-ts-comment */
-import global from 'global';
+import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';
import { render as litRender } from 'lit-html';
diff --git a/code/renderers/web-components/src/typings.d.ts b/code/renderers/web-components/src/typings.d.ts
index 2f4eb9cf4fd9..5563d6cc27a6 100644
--- a/code/renderers/web-components/src/typings.d.ts
+++ b/code/renderers/web-components/src/typings.d.ts
@@ -1 +1,4 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle, @typescript-eslint/naming-convention */
+declare var STORYBOOK_ENV: 'web-components';
+declare var __STORYBOOK_CUSTOM_ELEMENTS_MANIFEST__: any;
+declare var __STORYBOOK_CUSTOM_ELEMENTS__: any;
diff --git a/code/renderers/web-components/template/components/Button.js b/code/renderers/web-components/template/components/Button.js
index 6baef52d5cc0..b52a4cdc24d2 100644
--- a/code/renderers/web-components/template/components/Button.js
+++ b/code/renderers/web-components/template/components/Button.js
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { html, LitElement } from 'lit';
const { CustomEvent, customElements } = globalThis;
diff --git a/code/renderers/web-components/template/components/Form.js b/code/renderers/web-components/template/components/Form.js
index fe49e5174042..6e5136389610 100644
--- a/code/renderers/web-components/template/components/Form.js
+++ b/code/renderers/web-components/template/components/Form.js
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { html, LitElement } from 'lit';
const { CustomEvent, customElements } = globalThis;
diff --git a/code/renderers/web-components/template/components/Html.js b/code/renderers/web-components/template/components/Html.js
index e32977aafda9..857883c122fb 100644
--- a/code/renderers/web-components/template/components/Html.js
+++ b/code/renderers/web-components/template/components/Html.js
@@ -1,5 +1,5 @@
/* eslint-disable import/no-extraneous-dependencies */
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { LitElement } from 'lit';
const { customElements } = globalThis;
diff --git a/code/renderers/web-components/template/components/Pre.js b/code/renderers/web-components/template/components/Pre.js
index c1a4d11422d1..26da52299801 100644
--- a/code/renderers/web-components/template/components/Pre.js
+++ b/code/renderers/web-components/template/components/Pre.js
@@ -1,5 +1,5 @@
/* eslint-disable import/extensions, import/no-extraneous-dependencies */
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { html, LitElement } from 'lit';
import { styleMap } from 'lit-html/directives/style-map.js';
diff --git a/code/renderers/web-components/template/components/index.js b/code/renderers/web-components/template/components/index.js
index d41925728dd3..98d95bdd8817 100644
--- a/code/renderers/web-components/template/components/index.js
+++ b/code/renderers/web-components/template/components/index.js
@@ -1,4 +1,4 @@
-import globalThis from 'global';
+import { global as globalThis } from '@storybook/global';
import { ButtonTag } from './Button';
import { FormTag } from './Form';
diff --git a/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js b/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js
index d8ef04350983..6be796a5fa4e 100644
--- a/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js
+++ b/code/renderers/web-components/template/stories/demo-wc-card/DemoWcCard.js
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import { LitElement, html } from 'lit';
// eslint-disable-next-line import/extensions
import { demoWcCardStyle } from './demoWcCardStyle.css.js';
diff --git a/code/tsconfig.json b/code/tsconfig.json
index 4dbd32b042c3..48e4547af69b 100644
--- a/code/tsconfig.json
+++ b/code/tsconfig.json
@@ -14,7 +14,7 @@
"esModuleInterop": true,
"isolatedModules": true,
"strictBindCallApply": true,
- "lib": ["dom", "esnext"],
+ "lib": ["dom", "dom.iterable", "esnext"],
"noUnusedLocals": true,
"types": ["jest"]
},
diff --git a/code/ui/.storybook/preview.tsx b/code/ui/.storybook/preview.tsx
index 76f2ec0d4901..f033b0e62ab5 100644
--- a/code/ui/.storybook/preview.tsx
+++ b/code/ui/.storybook/preview.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import React, { Fragment, useEffect } from 'react';
import isChromatic from 'chromatic/isChromatic';
import {
diff --git a/code/ui/blocks/package.json b/code/ui/blocks/package.json
index ddc546fcc4a3..f179968c31a0 100644
--- a/code/ui/blocks/package.json
+++ b/code/ui/blocks/package.json
@@ -49,6 +49,7 @@
"@storybook/core-events": "7.0.0-beta.12",
"@storybook/csf": "next",
"@storybook/docs-tools": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/preview-api": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
@@ -56,7 +57,6 @@
"@types/lodash": "^4.14.167",
"color-convert": "^2.0.1",
"dequal": "^2.0.2",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"markdown-to-jsx": "^7.1.3",
"memoizerific": "^1.11.3",
diff --git a/code/ui/blocks/src/blocks/DocsContainer.tsx b/code/ui/blocks/src/blocks/DocsContainer.tsx
index f80dc3e42dd4..2885838ac926 100644
--- a/code/ui/blocks/src/blocks/DocsContainer.tsx
+++ b/code/ui/blocks/src/blocks/DocsContainer.tsx
@@ -1,6 +1,6 @@
import type { FunctionComponent, ReactNode } from 'react';
import React, { useEffect } from 'react';
-import global from 'global';
+import { global } from '@storybook/global';
import type { ThemeVars } from '@storybook/theming';
import { ThemeProvider, ensure as ensureTheme } from '@storybook/theming';
import type { Renderer } from '@storybook/types';
@@ -26,7 +26,7 @@ export const DocsContainer: FunctionComponent = ({
useEffect(() => {
let url;
try {
- url = new URL(globalWindow.parent.location);
+ url = new URL(globalWindow.parent.location.toString());
if (url.hash) {
const element = document.getElementById(url.hash.substring(1));
if (element) {
diff --git a/code/ui/blocks/src/blocks/DocsContext.ts b/code/ui/blocks/src/blocks/DocsContext.ts
index 17069f1727da..b9cd251d3f13 100644
--- a/code/ui/blocks/src/blocks/DocsContext.ts
+++ b/code/ui/blocks/src/blocks/DocsContext.ts
@@ -1,7 +1,7 @@
/* eslint-disable no-underscore-dangle */
import type { Context } from 'react';
import { createContext } from 'react';
-import { window as globalWindow } from 'global';
+import { global } from '@storybook/global';
import type { DocsContextProps, Renderer } from '@storybook/types';
@@ -12,11 +12,11 @@ export type { DocsContextProps };
// we will have multiple DocsContext definitions - leading to lost context in
// the React component tree.
// This was specifically a problem with the Vite builder.
-if (globalWindow && globalWindow.__DOCS_CONTEXT__ === undefined) {
- globalWindow.__DOCS_CONTEXT__ = createContext(null);
- globalWindow.__DOCS_CONTEXT__.displayName = 'DocsContext';
+if (global && global.__DOCS_CONTEXT__ === undefined) {
+ global.__DOCS_CONTEXT__ = createContext(null);
+ global.__DOCS_CONTEXT__.displayName = 'DocsContext';
}
-export const DocsContext: Context> = globalWindow
- ? globalWindow.__DOCS_CONTEXT__
+export const DocsContext: Context> = global
+ ? global.__DOCS_CONTEXT__
: createContext(null);
diff --git a/code/ui/blocks/src/blocks/mdx.tsx b/code/ui/blocks/src/blocks/mdx.tsx
index c7e14328a6ac..1f62dab2bc1a 100644
--- a/code/ui/blocks/src/blocks/mdx.tsx
+++ b/code/ui/blocks/src/blocks/mdx.tsx
@@ -2,7 +2,7 @@ import type { FC, SyntheticEvent } from 'react';
import React, { useContext } from 'react';
import { NAVIGATE_URL } from '@storybook/core-events';
import { Code, components } from '@storybook/components';
-import global from 'global';
+import { global } from '@storybook/global';
import { styled } from '@storybook/theming';
import { Source } from '../components';
import type { DocsContextProps } from './DocsContext';
diff --git a/code/ui/blocks/src/components/IFrame.tsx b/code/ui/blocks/src/components/IFrame.tsx
index be3460cb7f7b..d3f3dfc0c749 100644
--- a/code/ui/blocks/src/components/IFrame.tsx
+++ b/code/ui/blocks/src/components/IFrame.tsx
@@ -1,5 +1,5 @@
import React, { Component } from 'react';
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/code/ui/blocks/src/components/Preview.stories.tsx b/code/ui/blocks/src/components/Preview.stories.tsx
index baa4bb70f50c..96dceac65f52 100644
--- a/code/ui/blocks/src/components/Preview.stories.tsx
+++ b/code/ui/blocks/src/components/Preview.stories.tsx
@@ -1,14 +1,12 @@
import type { ComponentProps } from 'react';
import React from 'react';
import { styled } from '@storybook/theming';
-import global from 'global';
+import { global } from '@storybook/global';
import { Spaced, Button } from '@storybook/components';
import { Preview, PreviewSkeleton } from './Preview';
import { Story } from './Story';
import * as sourceStories from './Source.stories';
-const { window: globalWindow } = global;
-
export default {
component: Preview,
};
@@ -194,7 +192,7 @@ export const WithAdditionalActions = () => (
{
title: 'Open on GitHub',
onClick: () => {
- globalWindow.location.href =
+ global.location.href =
'https://github.com/storybookjs/storybook/blob/next/code/ui/blocks/src/components/Preview.stories.tsx#L165-L186';
},
},
diff --git a/code/ui/blocks/src/components/Preview.tsx b/code/ui/blocks/src/components/Preview.tsx
index f93ba28cdf2f..a7fa5d298fd0 100644
--- a/code/ui/blocks/src/components/Preview.tsx
+++ b/code/ui/blocks/src/components/Preview.tsx
@@ -3,7 +3,7 @@ import React, { Children, useCallback, useState } from 'react';
import { darken } from 'polished';
import { styled } from '@storybook/theming';
-import global from 'global';
+import { global } from '@storybook/global';
import { ActionBar, Zoom } from '@storybook/components';
import type { ActionItem } from '@storybook/components';
diff --git a/code/ui/blocks/src/components/Story.tsx b/code/ui/blocks/src/components/Story.tsx
index 4719a8ab6f4f..01b677ae6a96 100644
--- a/code/ui/blocks/src/components/Story.tsx
+++ b/code/ui/blocks/src/components/Story.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { ElementType, FunctionComponent } from 'react';
import React, { createElement, Fragment } from 'react';
import type { Parameters } from '@storybook/types';
diff --git a/code/ui/blocks/src/controls/Object.tsx b/code/ui/blocks/src/controls/Object.tsx
index fbd0a91ab9ad..e82dffba166c 100644
--- a/code/ui/blocks/src/controls/Object.tsx
+++ b/code/ui/blocks/src/controls/Object.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import cloneDeep from 'lodash/cloneDeep';
import type { ComponentProps, SyntheticEvent, FC, FocusEvent } from 'react';
import React, { useCallback, useMemo, useState, useEffect, useRef } from 'react';
diff --git a/code/ui/blocks/src/typings.d.ts b/code/ui/blocks/src/typings.d.ts
index 22352f1c3419..da56fcf64777 100644
--- a/code/ui/blocks/src/typings.d.ts
+++ b/code/ui/blocks/src/typings.d.ts
@@ -1,3 +1,7 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle */
+/* eslint-disable @typescript-eslint/naming-convention */
declare module 'markdown-to-jsx';
declare module '*.md';
+
+declare var __DOCS_CONTEXT__: any;
+declare var PREVIEW_URL: any;
diff --git a/code/ui/components/package.json b/code/ui/components/package.json
index b113d8997803..b22b3d05b1b7 100644
--- a/code/ui/components/package.json
+++ b/code/ui/components/package.json
@@ -53,6 +53,7 @@
"dependencies": {
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/csf": "next",
+ "@storybook/global": "^5.0.0",
"@storybook/theming": "7.0.0-beta.12",
"@storybook/types": "7.0.0-beta.12",
"memoizerific": "^1.11.3",
@@ -64,7 +65,6 @@
"@types/react-syntax-highlighter": "11.0.5",
"@types/util-deprecate": "^1.0.0",
"css": "^3.0.0",
- "global": "^4.4.0",
"overlayscrollbars": "^1.13.1",
"polished": "^4.2.2",
"prettier": "^2.8.0",
diff --git a/code/ui/components/scripts/writeCssScript.js b/code/ui/components/scripts/writeCssScript.js
index 011c1e5543e5..4392c6ad3158 100644
--- a/code/ui/components/scripts/writeCssScript.js
+++ b/code/ui/components/scripts/writeCssScript.js
@@ -6,7 +6,7 @@
const fs = require('fs');
const { parse } = require('css');
-const { isNaN } = require('global');
+const { isNaN } = require('@storybook/global');
const INPUT = require.resolve('overlayscrollbars/css/OverlayScrollbars.min.css');
const OUTPUT = `${__dirname}/../src/ScrollArea/ScrollAreaStyles.ts`;
diff --git a/code/ui/components/src/Zoom/browserSupportsCssZoom.ts b/code/ui/components/src/Zoom/browserSupportsCssZoom.ts
index 93b62ac6c0e8..2c8e2e7168e0 100644
--- a/code/ui/components/src/Zoom/browserSupportsCssZoom.ts
+++ b/code/ui/components/src/Zoom/browserSupportsCssZoom.ts
@@ -1,12 +1,9 @@
-import global from 'global';
-
-const { window: globalWindow } = global;
+import { global } from '@storybook/global';
export function browserSupportsCssZoom(): boolean {
try {
- return (
- globalWindow.document.implementation.createHTMLDocument('').body.style.zoom !== undefined
- );
+ // @ts-expect-error (we're testing for browser support)
+ return global.document.implementation.createHTMLDocument('').body.style.zoom !== undefined;
} catch (error) {
return false;
}
diff --git a/code/ui/components/src/syntaxhighlighter/syntaxhighlighter.tsx b/code/ui/components/src/syntaxhighlighter/syntaxhighlighter.tsx
index 4d29727d340b..4a84d4bda34f 100644
--- a/code/ui/components/src/syntaxhighlighter/syntaxhighlighter.tsx
+++ b/code/ui/components/src/syntaxhighlighter/syntaxhighlighter.tsx
@@ -2,7 +2,7 @@ import type { ComponentProps, FC, MouseEvent } from 'react';
import React, { useCallback, useState } from 'react';
import { logger } from '@storybook/client-logger';
import { styled } from '@storybook/theming';
-import global from 'global';
+import { global } from '@storybook/global';
import memoize from 'memoizerific';
import jsx from 'react-syntax-highlighter/dist/esm/languages/prism/jsx';
@@ -56,8 +56,8 @@ export function createCopyToClipboardFunction() {
return (text: string) => navigator.clipboard.writeText(text);
}
return async (text: string) => {
- const tmp = document.createElement('TEXTAREA');
- const focus = document.activeElement;
+ const tmp = document.createElement('TEXTAREA') as HTMLTextAreaElement;
+ const focus = document.activeElement as HTMLTextAreaElement;
tmp.value = text;
diff --git a/code/ui/components/src/tooltip/WithTooltip.tsx b/code/ui/components/src/tooltip/WithTooltip.tsx
index 0d7bf1c3fdb5..78c909e8ecf9 100644
--- a/code/ui/components/src/tooltip/WithTooltip.tsx
+++ b/code/ui/components/src/tooltip/WithTooltip.tsx
@@ -1,7 +1,7 @@
import type { FC, ReactNode } from 'react';
import React, { useCallback, useState, useEffect } from 'react';
import { styled } from '@storybook/theming';
-import global from 'global';
+import { global } from '@storybook/global';
import TooltipTrigger from 'react-popper-tooltip';
import type { Modifier, Placement } from '@popperjs/core';
diff --git a/code/ui/components/src/typings.d.ts b/code/ui/components/src/typings.d.ts
index 68610ec76e0a..78f750cebdde 100644
--- a/code/ui/components/src/typings.d.ts
+++ b/code/ui/components/src/typings.d.ts
@@ -1,4 +1,3 @@
-declare module 'global';
declare module 'markdown-to-jsx';
declare module '*.md';
declare module '*.mdx';
diff --git a/code/ui/manager/package.json b/code/ui/manager/package.json
index 9c2e7709efb7..c4188e5880fe 100644
--- a/code/ui/manager/package.json
+++ b/code/ui/manager/package.json
@@ -61,6 +61,7 @@
"@storybook/client-logger": "7.0.0-beta.12",
"@storybook/components": "7.0.0-beta.12",
"@storybook/core-events": "7.0.0-beta.12",
+ "@storybook/global": "^5.0.0",
"@storybook/manager-api": "7.0.0-beta.12",
"@storybook/router": "7.0.0-beta.12",
"@storybook/theming": "7.0.0-beta.12",
@@ -72,7 +73,6 @@
"enzyme": "^3.11.0",
"fs-extra": "^9.0.1",
"fuse.js": "^3.6.1",
- "global": "^4.4.0",
"lodash": "^4.17.21",
"markdown-to-jsx": "^7.1.3",
"memoizerific": "^1.11.3",
diff --git a/code/ui/manager/src/components/layout/app.mockdata.tsx b/code/ui/manager/src/components/layout/app.mockdata.tsx
index cb40a43eb1d2..505b1ffeee4c 100644
--- a/code/ui/manager/src/components/layout/app.mockdata.tsx
+++ b/code/ui/manager/src/components/layout/app.mockdata.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC } from 'react';
import React, { Component } from 'react';
import { styled } from '@storybook/theming';
diff --git a/code/ui/manager/src/components/preview/preview.tsx b/code/ui/manager/src/components/preview/preview.tsx
index 4e1b0c57df2c..e9d5a21ddf68 100644
--- a/code/ui/manager/src/components/preview/preview.tsx
+++ b/code/ui/manager/src/components/preview/preview.tsx
@@ -1,6 +1,6 @@
import React, { Fragment, useMemo, useEffect, useRef, useState } from 'react';
import { Helmet } from 'react-helmet-async';
-import global from 'global';
+import { global } from '@storybook/global';
import {
type API,
@@ -24,6 +24,8 @@ import { FramesRenderer } from './FramesRenderer';
import type { PreviewProps } from './utils/types';
+const { FEATURES } = global;
+
const getWrappers = (getFn: API['getElements']) => Object.values(getFn(types.PREVIEW));
const getTabs = (getFn: API['getElements']) => Object.values(getFn(types.TAB));
@@ -70,7 +72,7 @@ const createCanvas = (id: string, baseUrl = 'iframe.html', withLoader = true): A
const [progress, setProgress] = useState(undefined);
useEffect(() => {
- if (global.CONFIG_TYPE === 'DEVELOPMENT') {
+ if (FEATURES?.storyStoreV7 && global.CONFIG_TYPE === 'DEVELOPMENT') {
try {
const channel = addons.getServerChannel();
diff --git a/code/ui/manager/src/components/preview/tools/copy.tsx b/code/ui/manager/src/components/preview/tools/copy.tsx
index 82b42596faba..a86d9e03a900 100644
--- a/code/ui/manager/src/components/preview/tools/copy.tsx
+++ b/code/ui/manager/src/components/preview/tools/copy.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import React from 'react';
import copy from 'copy-to-clipboard';
import { getStoryHref, IconButton, Icons } from '@storybook/components';
diff --git a/code/ui/manager/src/components/preview/tools/eject.tsx b/code/ui/manager/src/components/preview/tools/eject.tsx
index 2c638e219e7d..c95aa8a9d666 100644
--- a/code/ui/manager/src/components/preview/tools/eject.tsx
+++ b/code/ui/manager/src/components/preview/tools/eject.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import React from 'react';
import { getStoryHref, IconButton, Icons } from '@storybook/components';
import { Consumer, type Combo } from '@storybook/manager-api';
diff --git a/code/ui/manager/src/components/sidebar/RefBlocks.tsx b/code/ui/manager/src/components/sidebar/RefBlocks.tsx
index 20258736d384..ca3ce0113688 100644
--- a/code/ui/manager/src/components/sidebar/RefBlocks.tsx
+++ b/code/ui/manager/src/components/sidebar/RefBlocks.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC } from 'react';
import React, { useState, useCallback, Fragment } from 'react';
diff --git a/code/ui/manager/src/components/sidebar/RefIndicator.tsx b/code/ui/manager/src/components/sidebar/RefIndicator.tsx
index bb06fa3d4f6d..fad585fabd4c 100644
--- a/code/ui/manager/src/components/sidebar/RefIndicator.tsx
+++ b/code/ui/manager/src/components/sidebar/RefIndicator.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC, ComponentProps } from 'react';
import React, { useMemo, useCallback, forwardRef } from 'react';
diff --git a/code/ui/manager/src/components/sidebar/Search.tsx b/code/ui/manager/src/components/sidebar/Search.tsx
index 3206745634b7..c8fe29fa3d2e 100644
--- a/code/ui/manager/src/components/sidebar/Search.tsx
+++ b/code/ui/manager/src/components/sidebar/Search.tsx
@@ -5,7 +5,7 @@ import type { DownshiftState, StateChangeOptions } from 'downshift';
import Downshift from 'downshift';
import type { FuseOptions } from 'fuse.js';
import Fuse from 'fuse.js';
-import global from 'global';
+import { global } from '@storybook/global';
import React, { useMemo, useRef, useState, useCallback } from 'react';
// eslint-disable-next-line import/no-cycle
diff --git a/code/ui/manager/src/components/sidebar/SearchResults.tsx b/code/ui/manager/src/components/sidebar/SearchResults.tsx
index fa3afdf1d906..fa9a0534d45d 100644
--- a/code/ui/manager/src/components/sidebar/SearchResults.tsx
+++ b/code/ui/manager/src/components/sidebar/SearchResults.tsx
@@ -1,6 +1,6 @@
import { styled } from '@storybook/theming';
import { Icons } from '@storybook/components';
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC, MouseEventHandler, ReactNode } from 'react';
import React, { useCallback, useEffect } from 'react';
import type { ControllerStateAndHelpers } from 'downshift';
diff --git a/code/ui/manager/src/components/sidebar/useExpanded.ts b/code/ui/manager/src/components/sidebar/useExpanded.ts
index eaded1d38fc2..1d7bd6d91ad5 100644
--- a/code/ui/manager/src/components/sidebar/useExpanded.ts
+++ b/code/ui/manager/src/components/sidebar/useExpanded.ts
@@ -1,7 +1,7 @@
import type { StoriesHash } from '@storybook/manager-api';
import { useStorybookApi } from '@storybook/manager-api';
import { STORIES_COLLAPSE_ALL, STORIES_EXPAND_ALL } from '@storybook/core-events';
-import global from 'global';
+import { global } from '@storybook/global';
import throttle from 'lodash/throttle';
import type { Dispatch, MutableRefObject } from 'react';
import type React from 'react';
diff --git a/code/ui/manager/src/components/sidebar/useHighlighted.ts b/code/ui/manager/src/components/sidebar/useHighlighted.ts
index 6a23bbf19259..5ee649081a61 100644
--- a/code/ui/manager/src/components/sidebar/useHighlighted.ts
+++ b/code/ui/manager/src/components/sidebar/useHighlighted.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { Dispatch, MutableRefObject, SetStateAction } from 'react';
import { useCallback, useEffect, useRef, useState } from 'react';
import { useStorybookApi } from '@storybook/manager-api';
diff --git a/code/ui/manager/src/components/sidebar/utils.ts b/code/ui/manager/src/components/sidebar/utils.ts
index ea1d250cfe84..5406989df10d 100644
--- a/code/ui/manager/src/components/sidebar/utils.ts
+++ b/code/ui/manager/src/components/sidebar/utils.ts
@@ -1,5 +1,5 @@
import memoize from 'memoizerific';
-import global from 'global';
+import { global } from '@storybook/global';
import type { SyntheticEvent } from 'react';
import type { HashEntry, StoriesHash } from '@storybook/manager-api';
diff --git a/code/ui/manager/src/containers/preview.tsx b/code/ui/manager/src/containers/preview.tsx
index 54e6a978ca0c..2b77e97db60d 100644
--- a/code/ui/manager/src/containers/preview.tsx
+++ b/code/ui/manager/src/containers/preview.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import React from 'react';
import type { Combo, StoriesHash } from '@storybook/manager-api';
diff --git a/code/ui/manager/src/index.tsx b/code/ui/manager/src/index.tsx
index dff5953f68a1..bc4a6262dbc4 100644
--- a/code/ui/manager/src/index.tsx
+++ b/code/ui/manager/src/index.tsx
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC } from 'react';
import React from 'react';
import ReactDOM from 'react-dom';
diff --git a/code/ui/manager/src/runtime.ts b/code/ui/manager/src/runtime.ts
index ebe5f040457f..7524649c7749 100644
--- a/code/ui/manager/src/runtime.ts
+++ b/code/ui/manager/src/runtime.ts
@@ -1,4 +1,4 @@
-import global from 'global';
+import { global } from '@storybook/global';
import type { Channel } from '@storybook/channels';
import type { AddonStore } from '@storybook/manager-api';
diff --git a/code/ui/manager/src/settings/index.tsx b/code/ui/manager/src/settings/index.tsx
index 3bc72763f72c..773147c991aa 100644
--- a/code/ui/manager/src/settings/index.tsx
+++ b/code/ui/manager/src/settings/index.tsx
@@ -2,7 +2,7 @@ import { useStorybookApi, useStorybookState } from '@storybook/manager-api';
import { IconButton, Icons, FlexBar, TabBar, TabButton, ScrollArea } from '@storybook/components';
import { Location, Route } from '@storybook/router';
import { styled } from '@storybook/theming';
-import global from 'global';
+import { global } from '@storybook/global';
import type { FC, SyntheticEvent } from 'react';
import React, { Fragment } from 'react';
diff --git a/code/ui/manager/src/settings/typings.d.ts b/code/ui/manager/src/settings/typings.d.ts
index e388e48d9c30..176b5f3d014a 100644
--- a/code/ui/manager/src/settings/typings.d.ts
+++ b/code/ui/manager/src/settings/typings.d.ts
@@ -1,2 +1,17 @@
-declare module 'global';
+/* eslint-disable no-underscore-dangle */
+/* eslint-disable @typescript-eslint/naming-convention */
declare module '@storybook/components/src/treeview/utils';
+
+declare var FEATURES: any;
+declare var SERVER_CHANNEL_URL: any;
+
+declare var __REACT__: any;
+declare var __REACTDOM__: any;
+declare var __STORYBOOKCOMPONENTS__: any;
+declare var __STORYBOOKCHANNELS__: any;
+declare var __STORYBOOKCOREEVENTS__: any;
+declare var __STORYBOOKROUTER__: any;
+declare var __STORYBOOKTHEMING__: any;
+declare var __STORYBOOKAPI__: any;
+declare var __STORYBOOKADDONS__: any;
+declare var __STORYBOOKCLIENTLOGGER__: any;
diff --git a/code/ui/manager/src/typings.d.ts b/code/ui/manager/src/typings.d.ts
index 8666686fa2ae..6919b2826ee3 100644
--- a/code/ui/manager/src/typings.d.ts
+++ b/code/ui/manager/src/typings.d.ts
@@ -1,2 +1,5 @@
-declare module 'global';
declare module 'chromatic/isChromatic';
+
+declare var DOCS_OPTIONS: any;
+declare var CONFIG_TYPE: any;
+declare var PREVIEW_URL: any;
diff --git a/code/yarn.lock b/code/yarn.lock
index b027d35325c3..020b2136c5ea 100644
--- a/code/yarn.lock
+++ b/code/yarn.lock
@@ -2603,156 +2603,156 @@ __metadata:
languageName: node
linkType: hard
-"@esbuild/android-arm64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/android-arm64@npm:0.16.9"
+"@esbuild/android-arm64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/android-arm64@npm:0.16.10"
conditions: os=android & cpu=arm64
languageName: node
linkType: hard
-"@esbuild/android-arm@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/android-arm@npm:0.16.9"
+"@esbuild/android-arm@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/android-arm@npm:0.16.10"
conditions: os=android & cpu=arm
languageName: node
linkType: hard
-"@esbuild/android-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/android-x64@npm:0.16.9"
+"@esbuild/android-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/android-x64@npm:0.16.10"
conditions: os=android & cpu=x64
languageName: node
linkType: hard
-"@esbuild/darwin-arm64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/darwin-arm64@npm:0.16.9"
+"@esbuild/darwin-arm64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/darwin-arm64@npm:0.16.10"
conditions: os=darwin & cpu=arm64
languageName: node
linkType: hard
-"@esbuild/darwin-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/darwin-x64@npm:0.16.9"
+"@esbuild/darwin-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/darwin-x64@npm:0.16.10"
conditions: os=darwin & cpu=x64
languageName: node
linkType: hard
-"@esbuild/freebsd-arm64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/freebsd-arm64@npm:0.16.9"
+"@esbuild/freebsd-arm64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/freebsd-arm64@npm:0.16.10"
conditions: os=freebsd & cpu=arm64
languageName: node
linkType: hard
-"@esbuild/freebsd-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/freebsd-x64@npm:0.16.9"
+"@esbuild/freebsd-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/freebsd-x64@npm:0.16.10"
conditions: os=freebsd & cpu=x64
languageName: node
linkType: hard
-"@esbuild/linux-arm64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-arm64@npm:0.16.9"
+"@esbuild/linux-arm64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-arm64@npm:0.16.10"
conditions: os=linux & cpu=arm64
languageName: node
linkType: hard
-"@esbuild/linux-arm@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-arm@npm:0.16.9"
+"@esbuild/linux-arm@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-arm@npm:0.16.10"
conditions: os=linux & cpu=arm
languageName: node
linkType: hard
-"@esbuild/linux-ia32@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-ia32@npm:0.16.9"
+"@esbuild/linux-ia32@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-ia32@npm:0.16.10"
conditions: os=linux & cpu=ia32
languageName: node
linkType: hard
-"@esbuild/linux-loong64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-loong64@npm:0.16.9"
+"@esbuild/linux-loong64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-loong64@npm:0.16.10"
conditions: os=linux & cpu=loong64
languageName: node
linkType: hard
-"@esbuild/linux-mips64el@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-mips64el@npm:0.16.9"
+"@esbuild/linux-mips64el@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-mips64el@npm:0.16.10"
conditions: os=linux & cpu=mips64el
languageName: node
linkType: hard
-"@esbuild/linux-ppc64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-ppc64@npm:0.16.9"
+"@esbuild/linux-ppc64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-ppc64@npm:0.16.10"
conditions: os=linux & cpu=ppc64
languageName: node
linkType: hard
-"@esbuild/linux-riscv64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-riscv64@npm:0.16.9"
+"@esbuild/linux-riscv64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-riscv64@npm:0.16.10"
conditions: os=linux & cpu=riscv64
languageName: node
linkType: hard
-"@esbuild/linux-s390x@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-s390x@npm:0.16.9"
+"@esbuild/linux-s390x@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-s390x@npm:0.16.10"
conditions: os=linux & cpu=s390x
languageName: node
linkType: hard
-"@esbuild/linux-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/linux-x64@npm:0.16.9"
+"@esbuild/linux-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/linux-x64@npm:0.16.10"
conditions: os=linux & cpu=x64
languageName: node
linkType: hard
-"@esbuild/netbsd-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/netbsd-x64@npm:0.16.9"
+"@esbuild/netbsd-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/netbsd-x64@npm:0.16.10"
conditions: os=netbsd & cpu=x64
languageName: node
linkType: hard
-"@esbuild/openbsd-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/openbsd-x64@npm:0.16.9"
+"@esbuild/openbsd-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/openbsd-x64@npm:0.16.10"
conditions: os=openbsd & cpu=x64
languageName: node
linkType: hard
-"@esbuild/sunos-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/sunos-x64@npm:0.16.9"
+"@esbuild/sunos-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/sunos-x64@npm:0.16.10"
conditions: os=sunos & cpu=x64
languageName: node
linkType: hard
-"@esbuild/win32-arm64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/win32-arm64@npm:0.16.9"
+"@esbuild/win32-arm64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/win32-arm64@npm:0.16.10"
conditions: os=win32 & cpu=arm64
languageName: node
linkType: hard
-"@esbuild/win32-ia32@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/win32-ia32@npm:0.16.9"
+"@esbuild/win32-ia32@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/win32-ia32@npm:0.16.10"
conditions: os=win32 & cpu=ia32
languageName: node
linkType: hard
-"@esbuild/win32-x64@npm:0.16.9":
- version: 0.16.9
- resolution: "@esbuild/win32-x64@npm:0.16.9"
+"@esbuild/win32-x64@npm:0.16.10":
+ version: 0.16.10
+ resolution: "@esbuild/win32-x64@npm:0.16.10"
conditions: os=win32 & cpu=x64
languageName: node
linkType: hard
@@ -5275,13 +5275,13 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
"@testing-library/react": ^11.2.2
axe-core: ^4.2.0
- global: ^4.4.0
lodash: ^4.17.21
react-resize-detector: ^7.1.2
resize-observer-polyfill: ^1.5.1
@@ -5304,13 +5304,13 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
"@types/lodash": ^4.14.167
dequal: ^2.0.2
- global: ^4.4.0
lodash: ^4.17.21
polished: ^4.2.2
prop-types: ^15.7.2
@@ -5337,11 +5337,11 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
memoizerific: ^1.11.3
ts-dedent: ^2.0.0
typescript: ~4.9.3
@@ -5366,7 +5366,7 @@ __metadata:
"@storybook/core-common": 7.0.0-beta.12
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/node-logger": 7.0.0-beta.12
- "@storybook/preview-api": 7.0.0-beta.12
+ "@storybook/preview-api": 7.0.0-beta.8
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
lodash: ^4.17.21
@@ -5394,6 +5394,7 @@ __metadata:
"@storybook/components": 7.0.0-beta.12
"@storybook/csf-plugin": 7.0.0-beta.12
"@storybook/csf-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/mdx2-csf": next
"@storybook/node-logger": 7.0.0-beta.12
"@storybook/postinstall": 7.0.0-beta.12
@@ -5401,7 +5402,6 @@ __metadata:
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
fs-extra: ^9.0.1
- global: ^4.4.0
react: ^16.14.0
react-dom: ^16.8.0
remark-external-links: ^8.0.0
@@ -5445,9 +5445,9 @@ __metadata:
resolution: "@storybook/addon-highlight@workspace:addons/highlight"
dependencies:
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@types/webpack-env": ^1.16.0
- global: ^4.4.0
typescript: ~4.9.3
languageName: unknown
linkType: soft
@@ -5461,6 +5461,7 @@ __metadata:
"@storybook/components": 7.0.0-beta.12
"@storybook/core-common": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/instrumenter": 7.0.0-beta.12
"@storybook/jest": ^0.0.10
"@storybook/manager-api": 7.0.0-beta.12
@@ -5470,7 +5471,6 @@ __metadata:
"@storybook/types": 7.0.0-beta.12
"@types/node": ^16.0.0
formik: ^2.2.9
- global: ^4.4.0
jest-mock: ^27.0.6
polished: ^4.2.2
ts-dedent: ^2.2.0
@@ -5493,10 +5493,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
- global: ^4.4.0
react-resize-detector: ^7.1.2
typescript: ~4.9.3
upath: ^1.2.0
@@ -5518,11 +5518,11 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
"@storybook/csf": next
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/router": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
prop-types: ^15.7.2
ts-dedent: ^2.0.0
typescript: ~4.9.3
@@ -5544,10 +5544,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
typescript: ~4.9.3
peerDependencies:
react: ^16.8.0 || ^17.0.0 || ^18.0.0
@@ -5567,10 +5567,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
ts-dedent: ^2.0.0
typescript: ~4.9.3
peerDependencies:
@@ -5619,6 +5619,7 @@ __metadata:
"@storybook/client-api": 7.0.0-beta.12
"@storybook/core-common": 7.0.0-beta.12
"@storybook/core-webpack": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/react": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
@@ -5631,7 +5632,6 @@ __metadata:
enzyme: ^3.11.0
enzyme-to-json: ^3.6.1
glob: ^7.1.6
- global: ^4.4.0
jest-preset-angular: ^8.3.2
jest-specific-snapshot: ^7.0.0
jest-vue-preprocessor: ^1.7.1
@@ -5749,10 +5749,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
- global: ^4.4.0
memoizerific: ^1.11.3
prop-types: ^15.7.2
typescript: ~4.9.3
@@ -5826,6 +5826,7 @@ __metadata:
"@storybook/core-server": 7.0.0-beta.12
"@storybook/core-webpack": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/node-logger": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
@@ -5840,7 +5841,6 @@ __metadata:
core-js: ^3.8.2
cross-spawn: ^7.0.3
find-up: ^5.0.0
- global: ^4.4.0
jest: ^29.3.1
jest-preset-angular: ^12.0.0
jest-specific-snapshot: ^7.0.0
@@ -5937,6 +5937,7 @@ __metadata:
"@storybook/core-events": 7.0.0-beta.12
"@storybook/csf": next
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
@@ -5945,7 +5946,6 @@ __metadata:
"@types/lodash": ^4.14.167
color-convert: ^2.0.1
dequal: ^2.0.2
- global: ^4.4.0
lodash: ^4.17.21
markdown-to-jsx: ^7.1.3
memoizerific: ^1.11.3
@@ -6039,6 +6039,7 @@ __metadata:
"@storybook/core-common": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
"@storybook/core-webpack": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/node-logger": 7.0.0-beta.12
"@storybook/preview": 7.0.0-beta.12
@@ -6061,7 +6062,6 @@ __metadata:
express: ^4.17.3
fork-ts-checker-webpack-plugin: ^7.2.8
fs-extra: ^9.0.1
- global: ^4.4.0
html-webpack-plugin: ^5.5.0
path-browserify: ^1.0.1
pretty-hrtime: ^1.0.3
@@ -6093,20 +6093,34 @@ __metadata:
"@storybook/channels": 7.0.0-beta.12
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
- global: ^4.4.0
+ "@storybook/global": ^5.0.0
qs: ^6.10.0
telejson: ^7.0.3
typescript: ~4.9.3
languageName: unknown
linkType: soft
+"@storybook/channel-postmessage@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/channel-postmessage@npm:7.0.0-beta.8"
+ dependencies:
+ "@storybook/channels": 7.0.0-beta.8
+ "@storybook/client-logger": 7.0.0-beta.8
+ "@storybook/core-events": 7.0.0-beta.8
+ global: ^4.4.0
+ qs: ^6.10.0
+ telejson: ^7.0.3
+ checksum: d0d4488831f13372e68bb7010242762a3102d3c7c069e3a840035ea050c30ad8234af9e81c78de4b0cae8dec20077183f57ba64191229ebd0bd7dbca1f99a262
+ languageName: node
+ linkType: hard
+
"@storybook/channel-websocket@7.0.0-beta.12, @storybook/channel-websocket@workspace:*, @storybook/channel-websocket@workspace:lib/channel-websocket":
version: 0.0.0-use.local
resolution: "@storybook/channel-websocket@workspace:lib/channel-websocket"
dependencies:
"@storybook/channels": 7.0.0-beta.12
"@storybook/client-logger": 7.0.0-beta.12
- global: ^4.4.0
+ "@storybook/global": ^5.0.0
telejson: ^7.0.3
typescript: ~4.9.3
languageName: unknown
@@ -6131,6 +6145,13 @@ __metadata:
languageName: node
linkType: hard
+"@storybook/channels@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/channels@npm:7.0.0-beta.8"
+ checksum: db5289e5eeddb78053d92dd19b5bf5fb245941dc1aff8b5c611483ee3cd41b1d0e68a42ad28735afbde7ec0fd5afd616944185ba6cde7f81b876061a84782824
+ languageName: node
+ linkType: hard
+
"@storybook/cli@7.0.0-beta.12, @storybook/cli@workspace:*, @storybook/cli@workspace:lib/cli":
version: 0.0.0-use.local
resolution: "@storybook/cli@workspace:lib/cli"
@@ -6195,7 +6216,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@storybook/client-logger@workspace:lib/client-logger"
dependencies:
- global: ^4.4.0
+ "@storybook/global": ^5.0.0
typescript: ~4.9.3
languageName: unknown
linkType: soft
@@ -6210,6 +6231,15 @@ __metadata:
languageName: node
linkType: hard
+"@storybook/client-logger@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/client-logger@npm:7.0.0-beta.8"
+ dependencies:
+ global: ^4.4.0
+ checksum: 122028f55597bd698c0f5e0aa4d1f211407c53c9a90797a44a28e897ca5db31143b75b2780737b3037168f7c9349304d52dea6d99b72b4603110c753d90b7a1b
+ languageName: node
+ linkType: hard
+
"@storybook/codemod@7.0.0-beta.12, @storybook/codemod@workspace:*, @storybook/codemod@workspace:lib/codemod":
version: 0.0.0-use.local
resolution: "@storybook/codemod@workspace:lib/codemod"
@@ -6241,13 +6271,13 @@ __metadata:
"@popperjs/core": ^2.6.0
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/csf": next
+ "@storybook/global": ^5.0.0
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
"@types/overlayscrollbars": ^1.12.0
"@types/react-syntax-highlighter": 11.0.5
"@types/util-deprecate": ^1.0.0
css: ^3.0.0
- global: ^4.4.0
memoizerific: ^1.11.3
overlayscrollbars: ^1.13.1
polished: ^4.2.2
@@ -6325,6 +6355,13 @@ __metadata:
languageName: node
linkType: hard
+"@storybook/core-events@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/core-events@npm:7.0.0-beta.8"
+ checksum: 73746cac7a5b68dfac086a8f35cb960428c3dc926c4f1961245c74a58202cde2854d7af479882d15709fab0f99295f8fb2a95762a91fa611aecda9ad1ac58252
+ languageName: node
+ linkType: hard
+
"@storybook/core-server@7.0.0-beta.12, @storybook/core-server@workspace:*, @storybook/core-server@workspace:lib/core-server":
version: 0.0.0-use.local
resolution: "@storybook/core-server@workspace:lib/core-server"
@@ -6337,6 +6374,7 @@ __metadata:
"@storybook/csf": next
"@storybook/csf-tools": 7.0.0-beta.12
"@storybook/docs-mdx": next
+ "@storybook/global": ^5.0.0
"@storybook/node-logger": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/telemetry": 7.0.0-beta.12
@@ -6357,7 +6395,6 @@ __metadata:
detect-port: ^1.3.0
express: ^4.17.3
fs-extra: ^9.0.1
- global: ^4.4.0
globby: ^11.0.2
ip: ^2.0.0
jest-os-detection: ^1.3.1
@@ -6481,10 +6518,10 @@ __metadata:
"@storybook/builder-webpack5": 7.0.0-beta.12
"@storybook/core-common": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
ember-source: ~3.28.1
- global: ^4.4.0
read-pkg-up: ^7.0.1
ts-dedent: ^2.0.0
typescript: ~4.9.3
@@ -6517,6 +6554,13 @@ __metadata:
languageName: node
linkType: hard
+"@storybook/global@npm:^5.0.0":
+ version: 5.0.0
+ resolution: "@storybook/global@npm:5.0.0"
+ checksum: 8f1b61dcdd3a89584540896e659af2ecc700bc740c16909a7be24ac19127ea213324de144a141f7caf8affaed017d064fea0618d453afbe027cf60f54b4a6d0b
+ languageName: node
+ linkType: hard
+
"@storybook/html-vite@workspace:*, @storybook/html-vite@workspace:frameworks/html-vite":
version: 0.0.0-use.local
resolution: "@storybook/html-vite@workspace:frameworks/html-vite"
@@ -6542,10 +6586,10 @@ __metadata:
dependencies:
"@storybook/builder-webpack5": 7.0.0-beta.12
"@storybook/core-common": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/html": 7.0.0-beta.12
"@storybook/preset-html-webpack": 7.0.0-beta.12
"@types/node": ^16.0.0
- global: ^4.4.0
typescript: ~4.9.3
peerDependencies:
"@babel/core": "*"
@@ -6560,9 +6604,9 @@ __metadata:
dependencies:
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
ts-dedent: ^2.0.0
typescript: ~4.9.3
peerDependencies:
@@ -6577,9 +6621,9 @@ __metadata:
"@storybook/channels": 7.0.0-beta.12
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
core-js: ^3.8.2
- global: ^4.4.0
typescript: ~4.9.3
languageName: unknown
linkType: soft
@@ -6673,6 +6717,7 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
"@storybook/csf": next
+ "@storybook/global": ^5.0.0
"@storybook/router": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
@@ -6680,7 +6725,6 @@ __metadata:
"@types/qs": ^6
dequal: ^2.0.2
flush-promises: ^1.0.2
- global: ^4.4.0
lodash: ^4.17.21
memoizerific: ^1.11.3
qs: ^6.10.0
@@ -6708,6 +6752,7 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/components": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/router": 7.0.0-beta.12
"@storybook/theming": 7.0.0-beta.12
@@ -6719,7 +6764,6 @@ __metadata:
enzyme: ^3.11.0
fs-extra: ^9.0.1
fuse.js: ^3.6.1
- global: ^4.4.0
lodash: ^4.17.21
markdown-to-jsx: ^7.1.3
memoizerific: ^1.11.3
@@ -6840,9 +6884,9 @@ __metadata:
resolution: "@storybook/preact@workspace:renderers/preact"
dependencies:
"@storybook/core-client": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
preact: ^10.5.13
ts-dedent: ^2.0.0
typescript: ~4.9.3
@@ -6919,10 +6963,10 @@ __metadata:
dependencies:
"@storybook/core-server": 7.0.0-beta.12
"@storybook/core-webpack": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/server": 7.0.0-beta.12
"@types/node": ^16.0.0
fs-extra: ^9.0.1
- global: ^4.4.0
jest-specific-snapshot: ^7.0.0
safe-identifier: ^0.4.1
ts-dedent: ^2.0.0
@@ -7027,11 +7071,11 @@ __metadata:
"@storybook/core-common": 7.0.0-beta.12
"@storybook/core-events": 7.0.0-beta.12
"@storybook/csf": next
+ "@storybook/global": ^5.0.0
"@storybook/types": 7.0.0-beta.12
"@types/qs": ^6.9.5
ansi-to-html: ^0.6.11
dequal: ^2.0.2
- global: ^4.4.0
lodash: ^4.17.21
memoizerific: ^1.11.3
qs: ^6.10.0
@@ -7043,6 +7087,30 @@ __metadata:
languageName: unknown
linkType: soft
+"@storybook/preview-api@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/preview-api@npm:7.0.0-beta.8"
+ dependencies:
+ "@storybook/channel-postmessage": 7.0.0-beta.8
+ "@storybook/channels": 7.0.0-beta.8
+ "@storybook/client-logger": 7.0.0-beta.8
+ "@storybook/core-events": 7.0.0-beta.8
+ "@storybook/csf": next
+ "@storybook/types": 7.0.0-beta.8
+ "@types/qs": ^6.9.5
+ dequal: ^2.0.2
+ global: ^4.4.0
+ lodash: ^4.17.21
+ memoizerific: ^1.11.3
+ qs: ^6.10.0
+ slash: ^3.0.0
+ synchronous-promise: ^2.0.15
+ ts-dedent: ^2.0.0
+ util-deprecate: ^1.0.2
+ checksum: a808c059fdd7631c2d9a8aeb38a36000b6ea6a6b44041b71242e050a9622202b42ffb6b0dbc1fb35ae8e98780d07481d1b20a0de498cdcfcb0c4fb3dd8f59df5
+ languageName: node
+ linkType: hard
+
"@storybook/preview-web@7.0.0-beta.12, @storybook/preview-web@workspace:*, @storybook/preview-web@workspace:lib/preview-web":
version: 0.0.0-use.local
resolution: "@storybook/preview-web@workspace:lib/preview-web"
@@ -7136,6 +7204,7 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
"@types/estree": ^0.0.51
@@ -7146,7 +7215,6 @@ __metadata:
acorn-walk: ^7.2.0
escodegen: ^2.0.0
expect-type: ^0.14.2
- global: ^4.4.0
html-tags: ^3.1.0
jest-specific-snapshot: ^7.0.0
lodash: ^4.17.21
@@ -7240,6 +7308,7 @@ __metadata:
"@storybook/docs-tools": "workspace:*"
"@storybook/ember": "workspace:*"
"@storybook/eslint-config-storybook": ^3.1.2
+ "@storybook/global": ^5.0.0
"@storybook/html": "workspace:*"
"@storybook/html-vite": "workspace:*"
"@storybook/html-webpack5": "workspace:*"
@@ -7346,7 +7415,6 @@ __metadata:
fs-extra: ^9.0.1
github-release-from-changelog: ^2.1.1
glob: ^7.1.6
- global: ^4.4.0
http-server: ^0.12.3
husky: ^4.3.7
jest: ^29.3.1
@@ -7437,8 +7505,8 @@ __metadata:
resolution: "@storybook/router@workspace:lib/router"
dependencies:
"@storybook/client-logger": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
dequal: ^2.0.2
- global: ^4.4.0
lodash: ^4.17.21
memoizerific: ^1.11.3
qs: ^6.10.0
@@ -7500,9 +7568,9 @@ __metadata:
resolution: "@storybook/server@workspace:renderers/server"
dependencies:
"@storybook/core-client": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
ts-dedent: ^2.0.0
typescript: ~4.9.3
languageName: unknown
@@ -7583,10 +7651,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
expect-type: ^0.14.2
- global: ^4.4.0
svelte: ^3.31.2
svelte-check: ^2.9.2
sveltedoc-parser: ^4.2.1
@@ -7653,11 +7721,11 @@ __metadata:
"@emotion/styled": ^11.10.4
"@emotion/use-insertion-effect-with-fallbacks": ^1.0.0
"@storybook/client-logger": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@types/fs-extra": ^9.0.6
"@types/node": ^16.0.0
deep-object-diff: ^1.1.0
fs-extra: ^9.0.1
- global: ^4.4.0
memoizerific: ^1.11.3
polished: ^4.2.2
ts-dedent: ^2.0.0
@@ -7699,6 +7767,20 @@ __metadata:
languageName: unknown
linkType: soft
+"@storybook/types@npm:7.0.0-beta.8":
+ version: 7.0.0-beta.8
+ resolution: "@storybook/types@npm:7.0.0-beta.8"
+ dependencies:
+ "@babel/core": ^7.12.10
+ "@storybook/channels": 7.0.0-beta.8
+ "@types/babel__core": ^7.0.0
+ "@types/express": ^4.7.0
+ express: ^4.17.3
+ file-system-cache: ^2.0.0
+ checksum: 58b6051468f2d8dabad42e1bb2d3f4da7bc2b68e44d2330894a6be29ba3d6c2ea105b5e4b04167fe388c5efddf4ddc62a55886f57ce9e39c5dbe827be9fe9768
+ languageName: node
+ linkType: hard
+
"@storybook/vue-vite@workspace:frameworks/vue-vite":
version: 0.0.0-use.local
resolution: "@storybook/vue-vite@workspace:frameworks/vue-vite"
@@ -7794,10 +7876,10 @@ __metadata:
"@digitak/esrun": ^3.2.2
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
"@vue/vue3-jest": 29
- global: ^4.4.0
ts-dedent: ^2.0.0
type-fest: 2.19.0
typescript: ~4.9.3
@@ -7815,9 +7897,9 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
ts-dedent: ^2.0.0
type-fest: 2.19.0
typescript: ~4.9.3
@@ -7877,10 +7959,10 @@ __metadata:
"@storybook/client-logger": 7.0.0-beta.12
"@storybook/core-client": 7.0.0-beta.12
"@storybook/docs-tools": 7.0.0-beta.12
+ "@storybook/global": ^5.0.0
"@storybook/manager-api": 7.0.0-beta.12
"@storybook/preview-api": 7.0.0-beta.12
"@storybook/types": 7.0.0-beta.12
- global: ^4.4.0
lit: 2.3.1
lit-html: 2.0.2
ts-dedent: ^2.0.0
@@ -9407,58 +9489,58 @@ __metadata:
languageName: node
linkType: hard
-"@volar/language-core@npm:1.0.14":
- version: 1.0.14
- resolution: "@volar/language-core@npm:1.0.14"
+"@volar/language-core@npm:1.0.16":
+ version: 1.0.16
+ resolution: "@volar/language-core@npm:1.0.16"
dependencies:
- "@volar/source-map": 1.0.14
+ "@volar/source-map": 1.0.16
"@vue/reactivity": ^3.2.45
muggle-string: ^0.1.0
- checksum: 0a2e646aae1677d120277034a28fad6411fb3bee9f4eafca95b684ab8817e52ddb5a64197a369ff8ec3fef96b4197dade9cf347c2ac6a5aac139208775c92280
+ checksum: e7ac9b0e2b92b568e32fb9d392db0d04435eeefeefb12fc88e2df605885775971d87150c138ecef8906d5d8960771e4f647caf2c045d216bc719d69bc4764023
languageName: node
linkType: hard
-"@volar/source-map@npm:1.0.14":
- version: 1.0.14
- resolution: "@volar/source-map@npm:1.0.14"
+"@volar/source-map@npm:1.0.16":
+ version: 1.0.16
+ resolution: "@volar/source-map@npm:1.0.16"
dependencies:
muggle-string: ^0.1.0
- checksum: d73713102e1879074bd1fdb671a1ea138c4262b9e99ba44c2610aef421069eb869f0d11155cbac7e633d4e8d121a63cb638470e7108dbb9dd34eaaa8b0f01334
+ checksum: 8e2e960365b7749c6935e85db37e2d736a8c5ab572ed746a29873b0224d9071add49caf6e2ae956f99f1950fa34ecf9a6e47368a035d2186450b531348fed000
languageName: node
linkType: hard
-"@volar/typescript@npm:1.0.14":
- version: 1.0.14
- resolution: "@volar/typescript@npm:1.0.14"
+"@volar/typescript@npm:1.0.16":
+ version: 1.0.16
+ resolution: "@volar/typescript@npm:1.0.16"
dependencies:
- "@volar/language-core": 1.0.14
- checksum: c853e25926e18463471d10d52cfc82491db86a19e21bf99324981326375c67d59e226e9b4ca380a1e5e75bce8053eea06884e8fe3de12922f10a5c8df8ef9916
+ "@volar/language-core": 1.0.16
+ checksum: 9893a57bd7e960892f29b293a12702249494bc3eadca2bccefe46ab6e846be7d83bb94b0138afd64be252fda2496a35cf36c09f43c9deaf9b98b9be4627db784
languageName: node
linkType: hard
-"@volar/vue-language-core@npm:1.0.14":
- version: 1.0.14
- resolution: "@volar/vue-language-core@npm:1.0.14"
+"@volar/vue-language-core@npm:1.0.16":
+ version: 1.0.16
+ resolution: "@volar/vue-language-core@npm:1.0.16"
dependencies:
- "@volar/language-core": 1.0.14
- "@volar/source-map": 1.0.14
+ "@volar/language-core": 1.0.16
+ "@volar/source-map": 1.0.16
"@vue/compiler-dom": ^3.2.45
"@vue/compiler-sfc": ^3.2.45
"@vue/reactivity": ^3.2.45
"@vue/shared": ^3.2.45
- minimatch: ^5.1.0
+ minimatch: ^5.1.1
vue-template-compiler: ^2.7.14
- checksum: f753ba88a06fea3d7db952fcaa5d4ca6b211aebec021a849112abf5c8946168c252234e9cae816b74bace0cf06cb4c101b3e1e4acea9d91ff6072a0e0ce7f4ca
+ checksum: 776878afe6997c7f22875d3faf36042086afb4b6281704c3c7fa6fc82d30699efada7c7f92953954a707c05de938e4a308a10fe035d085829419722f55f15e32
languageName: node
linkType: hard
-"@volar/vue-typescript@npm:1.0.14":
- version: 1.0.14
- resolution: "@volar/vue-typescript@npm:1.0.14"
+"@volar/vue-typescript@npm:1.0.16":
+ version: 1.0.16
+ resolution: "@volar/vue-typescript@npm:1.0.16"
dependencies:
- "@volar/typescript": 1.0.14
- "@volar/vue-language-core": 1.0.14
- checksum: 9efccaf64588e7c7d9313c6086d6571ea202c25737cd4d9de36be00c2509e47bdbf85fe545ba7ff7556f7d785375afab79d8a0a38d9d28262408fe6c463218c2
+ "@volar/typescript": 1.0.16
+ "@volar/vue-language-core": 1.0.16
+ checksum: 92cf8014e2ea89d5371ededae75b485e6f38c840af3e3d9b993dce2d379f9a6d019a3f3935e9ba02a2c68b97bf7a68ff491b67a8ca12672bb58bfbe761833aee
languageName: node
linkType: hard
@@ -15534,40 +15616,40 @@ __metadata:
linkType: hard
"esbuild-wasm@npm:>=0.13.8":
- version: 0.16.9
- resolution: "esbuild-wasm@npm:0.16.9"
+ version: 0.16.10
+ resolution: "esbuild-wasm@npm:0.16.10"
bin:
esbuild: bin/esbuild
- checksum: 1706f5b3288228cd991a7254c2691f4669ed021f0649cfe1adff541de6184a4713780235fff3cbb4eb4372e8ddd15eb6babbc8a69b7a6b41a730063bddfdd80b
+ checksum: 227cd31969198f630896096a89cf1eaae36f8a607c80e4d2dfa815e454113fc4a84fcbdf3ee0530b715dc1be61e8d442c879f3ef1914498c96d89baa853a86d3
languageName: node
linkType: hard
"esbuild@npm:^0.16.4":
- version: 0.16.9
- resolution: "esbuild@npm:0.16.9"
- dependencies:
- "@esbuild/android-arm": 0.16.9
- "@esbuild/android-arm64": 0.16.9
- "@esbuild/android-x64": 0.16.9
- "@esbuild/darwin-arm64": 0.16.9
- "@esbuild/darwin-x64": 0.16.9
- "@esbuild/freebsd-arm64": 0.16.9
- "@esbuild/freebsd-x64": 0.16.9
- "@esbuild/linux-arm": 0.16.9
- "@esbuild/linux-arm64": 0.16.9
- "@esbuild/linux-ia32": 0.16.9
- "@esbuild/linux-loong64": 0.16.9
- "@esbuild/linux-mips64el": 0.16.9
- "@esbuild/linux-ppc64": 0.16.9
- "@esbuild/linux-riscv64": 0.16.9
- "@esbuild/linux-s390x": 0.16.9
- "@esbuild/linux-x64": 0.16.9
- "@esbuild/netbsd-x64": 0.16.9
- "@esbuild/openbsd-x64": 0.16.9
- "@esbuild/sunos-x64": 0.16.9
- "@esbuild/win32-arm64": 0.16.9
- "@esbuild/win32-ia32": 0.16.9
- "@esbuild/win32-x64": 0.16.9
+ version: 0.16.10
+ resolution: "esbuild@npm:0.16.10"
+ dependencies:
+ "@esbuild/android-arm": 0.16.10
+ "@esbuild/android-arm64": 0.16.10
+ "@esbuild/android-x64": 0.16.10
+ "@esbuild/darwin-arm64": 0.16.10
+ "@esbuild/darwin-x64": 0.16.10
+ "@esbuild/freebsd-arm64": 0.16.10
+ "@esbuild/freebsd-x64": 0.16.10
+ "@esbuild/linux-arm": 0.16.10
+ "@esbuild/linux-arm64": 0.16.10
+ "@esbuild/linux-ia32": 0.16.10
+ "@esbuild/linux-loong64": 0.16.10
+ "@esbuild/linux-mips64el": 0.16.10
+ "@esbuild/linux-ppc64": 0.16.10
+ "@esbuild/linux-riscv64": 0.16.10
+ "@esbuild/linux-s390x": 0.16.10
+ "@esbuild/linux-x64": 0.16.10
+ "@esbuild/netbsd-x64": 0.16.10
+ "@esbuild/openbsd-x64": 0.16.10
+ "@esbuild/sunos-x64": 0.16.10
+ "@esbuild/win32-arm64": 0.16.10
+ "@esbuild/win32-ia32": 0.16.10
+ "@esbuild/win32-x64": 0.16.10
dependenciesMeta:
"@esbuild/android-arm":
optional: true
@@ -15615,7 +15697,7 @@ __metadata:
optional: true
bin:
esbuild: bin/esbuild
- checksum: d4979684269b0f16a32a1e1b544e7435ef706a3d1f4431acf2b5a972f7ef0cc19c2eff0c429deadc5fac65479ed69cf55c6082d77bb7b7afbdec049bd799461a
+ checksum: 60e26fb2f68a19d5fca3b720dde52246ec8f477cf88674abfede42ba96ab08dfcea5bc1c3afd2d50e721aa387f2bf216ddb10b16806dd3edc8b57f29f8308c97
languageName: node
linkType: hard
@@ -17141,9 +17223,9 @@ __metadata:
linkType: hard
"flow-parser@npm:0.*":
- version: 0.196.0
- resolution: "flow-parser@npm:0.196.0"
- checksum: 28d245a7d3d5b7c210260788fe4dfd80f96d0fbdd218311f1910a0e05208ce5d25b047ce61c74ebc4b5e3f41d77edbb3d8ff02eb9ff09e89d0892dde1eac27ab
+ version: 0.196.1
+ resolution: "flow-parser@npm:0.196.1"
+ checksum: d725af6e9b7796bcd823e64b0672427dc4af1cbddd5ba5c6f47e8dde3bf2ebf0591ee42e1d7c9eb06c59694a979aa02cca3f93ca1dfbc1358a0a60b75ae89240
languageName: node
linkType: hard
@@ -23536,7 +23618,7 @@ __metadata:
languageName: node
linkType: hard
-"minimatch@npm:^5.0.1, minimatch@npm:^5.1.0":
+"minimatch@npm:^5.0.1, minimatch@npm:^5.1.1":
version: 5.1.1
resolution: "minimatch@npm:5.1.1"
dependencies:
@@ -24336,8 +24418,8 @@ __metadata:
linkType: hard
"node-gyp@npm:latest":
- version: 9.3.0
- resolution: "node-gyp@npm:9.3.0"
+ version: 9.3.1
+ resolution: "node-gyp@npm:9.3.1"
dependencies:
env-paths: ^2.2.0
glob: ^7.1.4
@@ -24351,7 +24433,7 @@ __metadata:
which: ^2.0.2
bin:
node-gyp: bin/node-gyp.js
- checksum: 3b326bc3accca849c62503820c13d9362d142dbe4189a5a3a2f2b6de4e872303f2d6cc2dd59e044bf4ca967bfd3eeb3d0c5d8d3b77e28e4e4f8d909697ff5a7e
+ checksum: 3285c110768eb65aadd9aa1d056f917e594ea22611d21fd535ab3677ea433d0a281e7f09bc73d53e64b02214f4379dbca476dc33faffe455b0ac1d5ba92802f4
languageName: node
linkType: hard
@@ -33184,16 +33266,16 @@ __metadata:
linkType: hard
"vue-tsc@npm:^1.0.8, vue-tsc@npm:^1.0.9":
- version: 1.0.14
- resolution: "vue-tsc@npm:1.0.14"
+ version: 1.0.16
+ resolution: "vue-tsc@npm:1.0.16"
dependencies:
- "@volar/vue-language-core": 1.0.14
- "@volar/vue-typescript": 1.0.14
+ "@volar/vue-language-core": 1.0.16
+ "@volar/vue-typescript": 1.0.16
peerDependencies:
typescript: "*"
bin:
vue-tsc: bin/vue-tsc.js
- checksum: 72c64c3b29f4b469edbe7f1355ec5a3a707959dc4c62409ac4c63053e3aac1559be3c085ea775739ecf9ad02a2e206314166e37e699b46e3d0d3b341e4fb5951
+ checksum: 272f65bc006a378811491922d75926a1df9ffcc16f44b6b1e4ec2418c8270a2d11cb0a48930e934daecc9f59088f2d80e168db5da75ddff13a2c8644cd1c5658
languageName: node
linkType: hard
diff --git a/docs/snippets/common/storybook-client-globals-example-file.ts.mdx b/docs/snippets/common/storybook-client-globals-example-file.ts.mdx
index 2acf4a679ce3..4d240f124ceb 100644
--- a/docs/snippets/common/storybook-client-globals-example-file.ts.mdx
+++ b/docs/snippets/common/storybook-client-globals-example-file.ts.mdx
@@ -1,7 +1,7 @@
```ts
// vue/src/client/preview/globals.ts
-import global from 'global';
+import { global } from '@storybook/global';
const { window: globalWindow } = global;
diff --git a/scripts/verdaccio.yaml b/scripts/verdaccio.yaml
index 92011f313490..128a29b5baf3 100644
--- a/scripts/verdaccio.yaml
+++ b/scripts/verdaccio.yaml
@@ -31,6 +31,10 @@ packages:
access: $all
publish: $all
proxy: npmjs
+ '@storybook/global':
+ access: $all
+ publish: $all
+ proxy: npmjs
'@storybook/design-system':
access: $all
publish: $all