Skip to content

Commit

Permalink
Merge pull request #20184 from storybookjs/norbert/sb-1063-vite-in-de…
Browse files Browse the repository at this point in the history
…v-mode-with-storystorev6

Tech: improve global types
  • Loading branch information
ndelangen authored Dec 20, 2022
2 parents 671546d + bb2e680 commit d772d38
Show file tree
Hide file tree
Showing 313 changed files with 953 additions and 750 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global window */
/* eslint-disable global-require, import/no-dynamic-require */

import React from 'react';
Expand Down
1 change: 0 additions & 1 deletion code/__mocks__/inject-decorator.ugly-comments-stories.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* global window */
/* eslint-disable global-require, import/no-dynamic-require */

import React from 'react';
Expand Down
2 changes: 1 addition & 1 deletion code/addons/a11y/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
9 changes: 7 additions & 2 deletions code/addons/a11y/src/a11yRunner.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion code/addons/a11y/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
declare module 'global';
/* eslint-disable @typescript-eslint/naming-convention */
declare var __STORYBOOK_STORY_STORE__: any;
2 changes: 1 addition & 1 deletion code/addons/a11y/template/stories/parameters.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Html,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/a11y/template/stories/tests.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Html,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/src/decorator.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
1 change: 0 additions & 1 deletion code/addons/actions/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// TODO: following packages need definition files or a TS migration
declare module 'global';
declare module 'uuid-browser/v4';
2 changes: 1 addition & 1 deletion code/addons/actions/template/stories/argtype.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/template/stories/basics.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

import { action } from '@storybook/addon-actions';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/template/stories/configs.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

import { actions, configureActions } from '@storybook/addon-actions';

Expand Down
2 changes: 1 addition & 1 deletion code/addons/actions/template/stories/parameters.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import { withActions } from '@storybook/addon-actions/decorator';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/backgrounds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion code/addons/backgrounds/src/helpers/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import global from 'global';
import { global } from '@storybook/global';
import { dedent } from 'ts-dedent';

import { logger } from '@storybook/client-logger';
Expand Down
1 change: 0 additions & 1 deletion code/addons/backgrounds/src/typings.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion code/addons/backgrounds/template/stories/grid.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

const COLORS = [
{ name: 'red', value: '#FB001D' },
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/basics.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/disable.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/filters.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/issues.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/matchers.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
2 changes: 1 addition & 1 deletion code/addons/controls/template/stories/sorting.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import type { PartialStoryFn, StoryContext } from '@storybook/types';

export default {
Expand Down
4 changes: 2 additions & 2 deletions code/addons/docs/angular/index.js
Original file line number Diff line number Diff line change
@@ -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;
};
4 changes: 2 additions & 2 deletions code/addons/docs/ember/index.js
Original file line number Diff line number Diff line change
@@ -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;
};
2 changes: 1 addition & 1 deletion code/addons/docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,14 +108,14 @@
"@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",
"@storybook/preview-api": "7.0.0-beta.12",
"@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"
Expand Down
1 change: 0 additions & 1 deletion code/addons/docs/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
declare module 'global';
declare module '@egoist/vue-to-react';
declare module 'remark-slug';
declare module 'remark-external-links';
Expand Down
2 changes: 1 addition & 1 deletion code/addons/docs/template/stories/docs2/button.stories.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Pre,
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

export default {
component: globalThis.Components.Button,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

<Meta component={globalThis.Components.Button} />

Expand Down
Original file line number Diff line number Diff line change
@@ -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';

<Meta component={globalThis.Components.Button} />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

<Meta component={globalThis.Components.Button} />

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Meta, Story, Canvas, ArgsTable } from '@storybook/addon-docs';
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';

<Meta component={globalThis.Components.Button} play={() => console.log('component play')} />

Expand Down
4 changes: 2 additions & 2 deletions code/addons/highlight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion code/addons/highlight/src/preview.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion code/addons/highlight/src/typings.d.ts

This file was deleted.

2 changes: 1 addition & 1 deletion code/addons/interactions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions code/addons/interactions/src/Panel.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion code/addons/interactions/src/typings.d.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import globalThis from 'global';
import { global as globalThis } from '@storybook/global';
import {
within,
waitFor,
Expand Down
2 changes: 1 addition & 1 deletion code/addons/jest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 0 additions & 2 deletions code/addons/jest/src/typings.d.ts

This file was deleted.

Loading

0 comments on commit d772d38

Please sign in to comment.