Update storybook to v9 (#4645)

* chore: Update storybook to v9

* Pin next-export-i18n + remove outdated mock library

* Replace old mocking library with MSW

* Resolve knip unused code warnings
This commit is contained in:
Gabe Kangas
2025-10-20 21:26:32 -07:00
committed by GitHub
parent 72d5ee8754
commit cc9286416c
68 changed files with 40881 additions and 44059 deletions
+3
View File
@@ -3,3 +3,6 @@ node_modules
out out
../static/web ../static/web
public/styles/admin/config-public-details.css public/styles/admin/config-public-details.css
# Ignore Storybook files during Next.js builds
**/*.stories.*
+3 -7
View File
@@ -22,7 +22,6 @@
"sharp", "sharp",
"workbox-precaching", "workbox-precaching",
"workbox-window", "workbox-window",
"@storybook/addon-postcss",
"@storybook/cli", "@storybook/cli",
"@storybook/mdx2-csf", "@storybook/mdx2-csf",
"@mdx-js/react", "@mdx-js/react",
@@ -37,20 +36,15 @@
"install", "install",
"mdx-mermaid", "mdx-mermaid",
"mermaid", "mermaid",
"storybook-preset-less",
"ts-jest", "ts-jest",
"stylelint-config-standard", "stylelint-config-standard",
"@babel/core", "@babel/core",
"npm", "npm",
"eslint-config-next", "eslint-config-next",
"@storybook/addon-postcss",
"@storybook/cli",
"@storybook/mdx2-csf",
"@commitlint/cli", "@commitlint/cli",
"@commitlint/config-conventional", "@commitlint/config-conventional",
"babel-plugin-dynamic-import-node", "babel-plugin-dynamic-import-node",
"@babel/preset-react", "@babel/preset-react",
"@babel/core",
"i18next-scanner", "i18next-scanner",
"@types/video.js", "@types/video.js",
"@testing-library/jest-dom", "@testing-library/jest-dom",
@@ -58,6 +52,8 @@
"jest-environment-jsdom", "jest-environment-jsdom",
"@babel/parser", "@babel/parser",
"@babel/traverse", "@babel/traverse",
"glob" "glob",
"style-loader",
"css-loader"
] ]
} }
+18 -86
View File
@@ -7,93 +7,8 @@ module.exports = {
addons: [ addons: [
'@storybook/addon-links', '@storybook/addon-links',
'@storybook/addon-essentials',
'@storybook/preset-scss',
'@storybook/addon-a11y', '@storybook/addon-a11y',
'storybook-addon-fetch-mock', '@storybook/addon-docs'
'@storybook/addon-mdx-gfm',
'@storybook/addon-styling-webpack',
{
name: '@storybook/addon-styling-webpack',
options: {
rules: [
{
test: /\.css$/,
sideEffects: true,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
// Want to add more CSS Modules options? Read more here: https://github.com/webpack-contrib/css-loader#modules
modules: {
auto: true,
},
},
},
],
},
{
test: /\.s[ac]ss$/,
sideEffects: true,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
// Want to add more CSS Modules options? Read more here: https://github.com/webpack-contrib/css-loader#modules
modules: {
auto: true,
namedExport: false,
},
importLoaders: 2,
},
},
require.resolve('resolve-url-loader'),
{
loader: require.resolve('sass-loader'),
options: {
// Want to add more Sass options? Read more here: https://webpack.js.org/loaders/sass-loader/#options
implementation: require.resolve('sass'),
sourceMap: true,
sassOptions: {},
},
},
],
},
{
test: /\.less$/,
sideEffects: true,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
// Want to add more CSS Modules options? Read more here: https://github.com/webpack-contrib/css-loader#modules
modules: {
auto: true,
},
importLoaders: 1,
},
},
{
loader: require.resolve('less-loader'),
options: {
// Want to add more Less options? Read more here: https://webpack.js.org/loaders/less-loader/#options
implementation: require.resolve('less'),
sourceMap: true,
lessOptions: {
javascriptEnabled: true,
},
},
},
],
},
],
},
},
'@chromatic-com/storybook'
], ],
webpackFinal: async (config, { configType }) => { webpackFinal: async (config, { configType }) => {
@@ -107,6 +22,23 @@ module.exports = {
use: ['@svgr/webpack'], use: ['@svgr/webpack'],
}); });
// Configure LESS loader for Ant Design
config.module.rules.push({
test: /\.less$/,
use: [
'style-loader',
'css-loader',
{
loader: 'less-loader',
options: {
lessOptions: {
javascriptEnabled: true,
},
},
},
],
});
return config; return config;
}, },
+10 -10
View File
@@ -2,10 +2,11 @@ import '../styles/variables.css';
import '../styles/global.less'; import '../styles/global.less';
import '../styles/theme.less'; import '../styles/theme.less';
import './preview.scss'; import './preview.scss';
import { themes } from '@storybook/theming'; import { themes } from 'storybook/theming';
import { DocsContainer } from './storybook-theme'; import { DocsContainer } from './storybook-theme';
import { INITIAL_VIEWPORTS } from '@storybook/addon-viewport'; import { INITIAL_VIEWPORTS } from 'storybook/viewport';
import _ from 'lodash'; import _ from 'lodash';
import { initialize, mswLoader } from 'msw-storybook-addon';
/** /**
* Takes an entry of a viewport (from Object.entries()) and converts it * Takes an entry of a viewport (from Object.entries()) and converts it
@@ -13,8 +14,8 @@ import _ from 'lodash';
* *
* @template {string} Key * @template {string} Key
* *
* @param {[Key, import('@storybook/addon-viewport/dist/ts3.9/models').Viewport]} entry * @param {[Key, import('storybook/viewport/dist/ts3.9/models').Viewport]} entry
* @returns {Array<[`${Key}${'Portrait' | 'Landscape'}`, import('@storybook/addon-viewport/dist/ts3.9/models').Viewport]>} * @returns {Array<[`${Key}${'Portrait' | 'Landscape'}`, import('storybook/viewport/dist/ts3.9/models').Viewport]>}
*/ */
const convertToLandscapeAndPortraitEntries = ([objectKey, viewport]) => { const convertToLandscapeAndPortraitEntries = ([objectKey, viewport]) => {
const pixelStringToNumber = str => parseInt(str.split('px')[0]); const pixelStringToNumber = str => parseInt(str.split('px')[0]);
@@ -67,15 +68,14 @@ const convertToLandscapeAndPortraitEntries = ([objectKey, viewport]) => {
*/ */
const flatMapObject = (obj, f) => Object.fromEntries(Object.entries(obj).flatMap(f)); const flatMapObject = (obj, f) => Object.fromEntries(Object.entries(obj).flatMap(f));
// Initialize MSW
initialize();
export const parameters = { export const parameters = {
fetchMock: {
mocks: [],
},
// actions: { argTypesRegex: '^on[A-Z].*' }, // actions: { argTypesRegex: '^on[A-Z].*' },
docs: { docs: {
container: DocsContainer, container: DocsContainer,
}, },
// actions: { argTypesRegex: '^on[A-Z].*' },
viewMode: 'docs', viewMode: 'docs',
controls: { controls: {
matchers: { matchers: {
@@ -99,8 +99,8 @@ export const parameters = {
light: { ...themes.normal }, light: { ...themes.normal },
}, },
viewport: { viewport: {
// Take a bunch of viewports from the storybook addon and convert them
// to portrait + landscape. Keys are appended with 'Landscape' or 'Portrait'.
viewports: flatMapObject(INITIAL_VIEWPORTS, convertToLandscapeAndPortraitEntries), viewports: flatMapObject(INITIAL_VIEWPORTS, convertToLandscapeAndPortraitEntries),
}, },
}; };
export const loaders = [mswLoader];
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Documentation/Design" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/> <Meta title="owncast/Documentation/Design" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/>
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Documentation/Get Started with Owncast Development" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/> <Meta title="owncast/Documentation/Get Started with Owncast Development" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/>
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, IconGallery, IconItem } from '@storybook/addon-docs'; import { Canvas, Meta, Story, IconGallery, IconItem } from '@storybook/addon-docs/blocks';
import { Image, ImageRow } from './ImageAsset'; import { Image, ImageRow } from './ImageAsset';
<Meta title="owncast/Frontend Assets/Emoji" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} /> <Meta title="owncast/Frontend Assets/Emoji" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} />
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, IconItem, IconGallery } from '@storybook/addon-docs'; import { Canvas, Meta, Story, IconItem, IconGallery } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Frontend Assets/Images" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} /> <Meta title="owncast/Frontend Assets/Images" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} />
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
import { Image, ImageRow } from './ImageAsset'; import { Image, ImageRow } from './ImageAsset';
<Meta <Meta
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Documentation/Product Definition" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/> <Meta title="owncast/Documentation/Product Definition" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/>
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, IconItem, IconGallery } from '@storybook/addon-docs'; import { Canvas, Meta, Story, IconItem, IconGallery } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Frontend Assets/Social Platform Images" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} /> <Meta title="owncast/Frontend Assets/Social Platform Images" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}} />
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
import { Image, ImageRow } from './ImageAsset'; import { Image, ImageRow } from './ImageAsset';
<Meta title="owncast/Project Assets/T-Shirt" parameters={{chromatic: { disableSnapshot: true }}} /> <Meta title="owncast/Project Assets/T-Shirt" parameters={{chromatic: { disableSnapshot: true }}} />
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, Typeset, Source } from '@storybook/blocks'; import { Canvas, Meta, Story, Typeset, Source } from '@storybook/addon-docs/blocks';
<Meta <Meta
title="owncast/Styles/Typography" title="owncast/Styles/Typography"
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story } from '@storybook/addon-docs'; import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks';
<Meta title="owncast/Documentation/Building Frontend Components" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/> <Meta title="owncast/Documentation/Building Frontend Components" parameters={{previewTabs: { canvas: { hidden: true } }, chromatic: { disableSnapshot: true }}}/>
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, ColorPalette, ColorItem } from '@storybook/blocks'; import { Canvas, Meta, Story, ColorPalette, ColorItem } from '@storybook/addon-docs/blocks';
import { ColorRow, getColor } from './Color'; import { ColorRow, getColor } from './Color';
<Meta <Meta
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, ColorPalette, ColorItem, Description } from '@storybook/blocks'; import { Canvas, Meta, Story, ColorPalette, ColorItem, Description } from '@storybook/addon-docs/blocks';
import { ColorRow, getColor } from './Color'; import { ColorRow, getColor } from './Color';
<Meta <Meta
@@ -1,4 +1,4 @@
import { Canvas, Meta, Story, ColorPalette, ColorItem } from '@storybook/blocks'; import { Canvas, Meta, Story, ColorPalette, ColorItem } from '@storybook/addon-docs/blocks';
import { ColorRow, getColor } from './Color'; import { ColorRow, getColor } from './Color';
<Meta <Meta
+2 -2
View File
@@ -1,6 +1,6 @@
import React from 'react'; import React from 'react';
import { DocsContainer as BaseContainer } from '@storybook/addon-docs'; import { DocsContainer as BaseContainer } from '@storybook/addon-docs/blocks';
import { themes } from '@storybook/theming'; import { themes } from 'storybook/theming';
export const DocsContainer = ({ children, context }) => { export const DocsContainer = ({ children, context }) => {
return ( return (
@@ -1,5 +1,5 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { action } from '@storybook/addon-actions'; import { action } from 'storybook/actions';
import { ActionButton } from './ActionButton'; import { ActionButton } from './ActionButton';
const meta = { const meta = {
@@ -1,5 +1,5 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { action } from '@storybook/addon-actions'; import { action } from 'storybook/actions';
import { ActionButtonMenu } from './ActionButtonMenu'; import { ActionButtonMenu } from './ActionButtonMenu';
const meta = { const meta = {
@@ -1,5 +1,5 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { action } from '@storybook/addon-actions'; import { action } from 'storybook/actions';
import { ActionButtonRow } from './ActionButtonRow'; import { ActionButtonRow } from './ActionButtonRow';
import { ActionButton } from '../ActionButton/ActionButton'; import { ActionButton } from '../ActionButton/ActionButton';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatActionMessage } from './ChatActionMessage'; import { ChatActionMessage } from './ChatActionMessage';
import Mock from '../../../stories/assets/mocks/chatmessage-action.png'; import Mock from '../../../stories/assets/mocks/chatmessage-action.png';
@@ -1,5 +1,5 @@
import { useState } from 'react'; import { useState } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { ChatContainer } from './ChatContainer'; import { ChatContainer } from './ChatContainer';
import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatJoinMessage } from './ChatJoinMessage'; import { ChatJoinMessage } from './ChatJoinMessage';
import Mock from '../../../stories/assets/mocks/chatmessage-action.png'; import Mock from '../../../stories/assets/mocks/chatmessage-action.png';
@@ -1,23 +1,9 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { http, HttpResponse } from 'msw';
import { ChatModerationActionMenu } from './ChatModerationActionMenu'; import { ChatModerationActionMenu } from './ChatModerationActionMenu';
const mocks = { const mockUserData = {
mocks: [
{
// The "matcher" determines if this
// mock should respond to the current
// call to fetch().
matcher: {
name: 'response',
url: 'glob:/api/moderation/chat/user/*',
},
// If the "matcher" matches the current
// fetch() call, the fetch response is
// built using this "response".
response: {
status: 200,
body: {
user: { user: {
id: 'hjFPU967R', id: 'hjFPU967R',
displayName: 'focused-snyder', displayName: 'focused-snyder',
@@ -57,17 +43,19 @@ const mocks = {
body: 'test message 1', body: 'test message 1',
}, },
], ],
}, };
},
},
],
};
const meta = { const meta = {
title: 'owncast/Chat/Moderation menu', title: 'owncast/Chat/Moderation menu',
component: ChatModerationActionMenu, component: ChatModerationActionMenu,
parameters: { parameters: {
fetchMock: mocks, msw: {
handlers: [
http.get('/api/moderation/chat/user/*', () => {
return HttpResponse.json(mockUserData);
}),
],
},
docs: { docs: {
description: { description: {
component: `This should be a popup that is activated from a user's chat message. It should have actions to: component: `This should be a popup that is activated from a user's chat message. It should have actions to:
@@ -1,23 +1,9 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { http, HttpResponse } from 'msw';
import { ChatModerationDetailsModal } from './ChatModerationDetailsModal'; import { ChatModerationDetailsModal } from './ChatModerationDetailsModal';
const mocks = { const mockUserData = {
mocks: [
{
// The "matcher" determines if this
// mock should respond to the current
// call to fetch().
matcher: {
name: 'response',
url: 'glob:/api/moderation/chat/user/*',
},
// If the "matcher" matches the current
// fetch() call, the fetch response is
// built using this "response".
response: {
status: 200,
body: {
user: { user: {
id: 'hjFPU967R', id: 'hjFPU967R',
displayName: 'focused-snyder', displayName: 'focused-snyder',
@@ -57,17 +43,19 @@ const mocks = {
body: 'test message 1', body: 'test message 1',
}, },
], ],
}, };
},
},
],
};
const meta = { const meta = {
title: 'owncast/Chat/Moderation modal', title: 'owncast/Chat/Moderation modal',
component: ChatModerationDetailsModal, component: ChatModerationDetailsModal,
parameters: { parameters: {
fetchMock: mocks, msw: {
handlers: [
http.get('/api/moderation/chat/user/*', () => {
return HttpResponse.json(mockUserData);
}),
],
},
docs: { docs: {
description: { description: {
component: `This should be a modal that gives the moderator more details about the user such as: component: `This should be a modal that gives the moderator more details about the user such as:
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatModeratorNotification } from './ChatModeratorNotification'; import { ChatModeratorNotification } from './ChatModeratorNotification';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatNameChangeMessage } from './ChatNameChangeMessage'; import { ChatNameChangeMessage } from './ChatNameChangeMessage';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatPartMessage } from './ChatPartMessage'; import { ChatPartMessage } from './ChatPartMessage';
import Mock from '../../../stories/assets/mocks/chatmessage-action.png'; import Mock from '../../../stories/assets/mocks/chatmessage-action.png';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatSocialMessage } from './ChatSocialMessage'; import { ChatSocialMessage } from './ChatSocialMessage';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ChatSystemMessage } from './ChatSystemMessage'; import { ChatSystemMessage } from './ChatSystemMessage';
import Mock from '../../../stories/assets/mocks/chatmessage-system.png'; import Mock from '../../../stories/assets/mocks/chatmessage-system.png';
import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -1,37 +1,24 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { http, HttpResponse } from 'msw';
import { ChatTextField } from './ChatTextField'; import { ChatTextField } from './ChatTextField';
import Mockup from '../../../stories/assets/mocks/chatinput-mock.png'; import Mockup from '../../../stories/assets/mocks/chatinput-mock.png';
const mockResponse = JSON.parse( const mockResponse = JSON.parse(
`[{"name":"Reaper-gg.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=OC"},{"name":"Reaper-hi.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=XX"},{"name":"Reaper-hype.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=TX"},{"name":"Reaper-lol.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=CA"},{"name":"Reaper-love.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=OK"}]`, `[{"name":"Reaper-gg.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=OC"},{"name":"Reaper-hi.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=XX"},{"name":"Reaper-hype.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=TX"},{"name":"Reaper-lol.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=CA"},{"name":"Reaper-love.png","url":"https://ui-avatars.com/api/?background=0D8ABC&color=fff&name=OK"}]`,
); );
const mocks = {
mocks: [
{
// The "matcher" determines if this
// mock should respond to the current
// call to fetch().
matcher: {
name: 'response',
url: 'glob:/api/emoji',
},
// If the "matcher" matches the current
// fetch() call, the fetch response is
// built using this "response".
response: {
status: 200,
body: mockResponse,
},
},
],
};
const meta = { const meta = {
title: 'owncast/Chat/Input text field', title: 'owncast/Chat/Input text field',
component: ChatTextField, component: ChatTextField,
parameters: { parameters: {
fetchMock: mocks, msw: {
handlers: [
http.get('/api/emoji', () => {
return HttpResponse.json(mockResponse);
}),
],
},
chromatic: { diffThreshold: 0.9 }, chromatic: { diffThreshold: 0.9 },
design: { design: {
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { ChatUserBadge } from './ChatUserBadge'; import { ChatUserBadge } from './ChatUserBadge';
import { ModerationBadge } from './ModerationBadge'; import { ModerationBadge } from './ModerationBadge';
import { AuthedUserBadge } from './AuthedUserBadge'; import { AuthedUserBadge } from './AuthedUserBadge';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { ChatUserMessage } from './ChatUserMessage'; import { ChatUserMessage } from './ChatUserMessage';
import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ContentHeader } from './ContentHeader'; import { ContentHeader } from './ContentHeader';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { OwncastLogo } from './OwncastLogo'; import { OwncastLogo } from './OwncastLogo';
const meta = { const meta = {
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useSetRecoilState } from 'recoil'; import { RecoilRoot, useSetRecoilState } from 'recoil';
import { UserDropdown } from './UserDropdown'; import { UserDropdown } from './UserDropdown';
import { CurrentUser } from '../../../interfaces/current-user'; import { CurrentUser } from '../../../interfaces/current-user';
+17 -13
View File
@@ -1,4 +1,4 @@
import { Meta, StoryFn, StoryObj } from '@storybook/react'; import { Meta, StoryFn, StoryObj } from '@storybook/nextjs';
import { MutableSnapshot, RecoilRoot } from 'recoil'; import { MutableSnapshot, RecoilRoot } from 'recoil';
import { makeEmptyClientConfig } from '../../../interfaces/client-config.model'; import { makeEmptyClientConfig } from '../../../interfaces/client-config.model';
import { ServerStatus, makeEmptyServerStatus } from '../../../interfaces/server-status.model'; import { ServerStatus, makeEmptyServerStatus } from '../../../interfaces/server-status.model';
@@ -129,20 +129,22 @@ export const OfflineMobile: StoryObj<typeof Template> = {
}, },
}, },
parameters: { globals: {
viewport: { viewport: {
defaultViewport: 'mobile1', value: 'mobile1',
}, isRotated: false
}
}, },
}; };
export const OfflineTablet: StoryObj<typeof Template> = { export const OfflineTablet: StoryObj<typeof Template> = {
render: Template, render: Template,
parameters: { globals: {
viewport: { viewport: {
defaultViewport: 'tablet', value: 'tablet',
}, isRotated: false
}
}, },
}; };
@@ -168,10 +170,11 @@ export const OnlineMobile: StoryObj<typeof Template> = {
}, },
}, },
parameters: { globals: {
viewport: { viewport: {
defaultViewport: 'mobile1', value: 'mobile1',
}, isRotated: false
}
}, },
}; };
@@ -182,9 +185,10 @@ export const OnlineTablet: StoryObj<typeof Template> = {
ServerStatusServiceMock: OnlineServerStatusServiceMock, ServerStatusServiceMock: OnlineServerStatusServiceMock,
}, },
parameters: { globals: {
viewport: { viewport: {
defaultViewport: 'tablet', value: 'tablet',
}, isRotated: false
}
}, },
}; };
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useSetRecoilState } from 'recoil'; import { RecoilRoot, useSetRecoilState } from 'recoil';
import { AuthModal } from './AuthModal'; import { AuthModal } from './AuthModal';
import { currentUserAtom } from '../../stores/ClientConfigStore'; import { currentUserAtom } from '../../stores/ClientConfigStore';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { BrowserNotifyModal } from './BrowserNotifyModal'; import { BrowserNotifyModal } from './BrowserNotifyModal';
import BrowserNotifyModalMock from '../../../stories/assets/mocks/notify-modal.png'; import BrowserNotifyModalMock from '../../../stories/assets/mocks/notify-modal.png';
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useSetRecoilState } from 'recoil'; import { RecoilRoot, useSetRecoilState } from 'recoil';
import { ChatModal, ChatModalProps } from './ChatModal'; import { ChatModal, ChatModalProps } from './ChatModal';
import { ChatMessage } from '../../../interfaces/chat-message.model'; import { ChatMessage } from '../../../interfaces/chat-message.model';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { FatalErrorStateModal } from './FatalErrorStateModal'; import { FatalErrorStateModal } from './FatalErrorStateModal';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { FediAuthModal } from './FediAuthModal'; import { FediAuthModal } from './FediAuthModal';
import FediAuthModalMock from '../../../stories/assets/mocks/fediauth-modal.png'; import FediAuthModalMock from '../../../stories/assets/mocks/fediauth-modal.png';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { FollowModal } from './FollowModal'; import { FollowModal } from './FollowModal';
import FollowModalMock from '../../../stories/assets/mocks/follow-modal.png'; import FollowModalMock from '../../../stories/assets/mocks/follow-modal.png';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { IndieAuthModal } from './IndieAuthModal'; import { IndieAuthModal } from './IndieAuthModal';
import Mock from '../../../stories/assets/mocks/indieauth-modal.png'; import Mock from '../../../stories/assets/mocks/indieauth-modal.png';
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useSetRecoilState } from 'recoil'; import { RecoilRoot, useSetRecoilState } from 'recoil';
import { NameChangeModal } from './NameChangeModal'; import { NameChangeModal } from './NameChangeModal';
import { CurrentUser } from '../../../interfaces/current-user'; import { CurrentUser } from '../../../interfaces/current-user';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { ComponentError } from './ComponentError'; import { ComponentError } from './ComponentError';
const meta = { const meta = {
@@ -1,5 +1,5 @@
/* eslint-disable no-useless-escape */ /* eslint-disable no-useless-escape */
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { CustomPageContent } from './CustomPageContent'; import { CustomPageContent } from './CustomPageContent';
+1 -1
View File
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { Footer } from './Footer'; import { Footer } from './Footer';
+1 -1
View File
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { Header } from './Header'; import { Header } from './Header';
+1 -1
View File
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { Modal } from './Modal'; import { Modal } from './Modal';
const meta = { const meta = {
@@ -1,5 +1,5 @@
/* eslint-disable no-alert */ /* eslint-disable no-alert */
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { NotifyReminderPopup } from './NotifyReminderPopup'; import { NotifyReminderPopup } from './NotifyReminderPopup';
import Mock from '../../../stories/assets/mocks/notify-popup.png'; import Mock from '../../../stories/assets/mocks/notify-popup.png';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { OfflineBanner } from './OfflineBanner'; import { OfflineBanner } from './OfflineBanner';
import OfflineState from '../../../stories/assets/mocks/offline-state.png'; import OfflineState from '../../../stories/assets/mocks/offline-state.png';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { OfflineEmbed } from './OfflineEmbed'; import { OfflineEmbed } from './OfflineEmbed';
import OfflineState from '../../../stories/assets/mocks/offline-state.png'; import OfflineState from '../../../stories/assets/mocks/offline-state.png';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { SocialLinks } from './SocialLinks'; import { SocialLinks } from './SocialLinks';
const meta = { const meta = {
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { subHours, subMinutes, subSeconds } from 'date-fns'; import { subHours, subMinutes, subSeconds } from 'date-fns';
import { Statusbar } from './Statusbar'; import { Statusbar } from './Statusbar';
@@ -1,24 +1,9 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { action } from '@storybook/addon-actions'; import { http, HttpResponse } from 'msw';
import { FollowerCollection } from './FollowerCollection'; import { FollowerCollection } from './FollowerCollection';
const mocks = { const mockFollowersData = {
mocks: [
{
// The "matcher" determines if this
// mock should respond to the current
// call to fetch().
matcher: {
name: 'response',
url: 'glob:/api/followers*',
},
// If the "matcher" matches the current
// fetch() call, the fetch response is
// built using this "response".
response: {
status: 200,
body: {
total: 100, total: 100,
results: [ results: [
{ {
@@ -227,34 +212,11 @@ const mocks = {
disabledAt: null, disabledAt: null,
}, },
], ],
}, };
},
},
],
};
const noFollowersMock = { const noFollowersData = {
mocks: [ total: 0,
{ results: [],
// The "matcher" determines if this
// mock should respond to the current
// call to fetch().
matcher: {
name: 'response',
url: 'glob:/api/followers*',
},
// If the "matcher" matches the current
// fetch() call, the fetch response is
// built using this "response".
response: {
status: 200,
body: {
total: 0,
results: [],
},
},
},
],
}; };
const meta = { const meta = {
@@ -270,9 +232,7 @@ export default meta;
const Template: StoryFn<typeof FollowerCollection> = (args: object) => ( const Template: StoryFn<typeof FollowerCollection> = (args: object) => (
<RecoilRoot> <RecoilRoot>
<FollowerCollection <FollowerCollection
onFollowButtonClick={() => { onFollowButtonClick={() => {}}
action('Follow button clicked');
}}
name="Example stream name" name="Example stream name"
{...args} {...args}
/> />
@@ -283,7 +243,13 @@ export const NoFollowers = {
render: Template, render: Template,
parameters: { parameters: {
fetchMock: noFollowersMock, msw: {
handlers: [
http.get('/api/followers*', () => {
return HttpResponse.json(noFollowersData);
}),
],
},
}, },
}; };
@@ -291,6 +257,12 @@ export const Example = {
render: Template, render: Template,
parameters: { parameters: {
fetchMock: mocks, msw: {
handlers: [
http.get('/api/followers*', () => {
return HttpResponse.json(mockFollowersData);
}),
],
},
}, },
}; };
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { SingleFollower } from './SingleFollower'; import { SingleFollower } from './SingleFollower';
import SingleFollowerMock from '../../../../stories/assets/mocks/single-follower.png'; import SingleFollowerMock from '../../../../stories/assets/mocks/single-follower.png';
@@ -1,4 +1,4 @@
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot } from 'recoil'; import { RecoilRoot } from 'recoil';
import { OwncastPlayer } from './OwncastPlayer'; import { OwncastPlayer } from './OwncastPlayer';
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { VideoPoster } from './VideoPoster'; import { VideoPoster } from './VideoPoster';
const meta = { const meta = {
+40218 -43610
View File
File diff suppressed because it is too large Load Diff
+149 -154
View File
@@ -1,156 +1,151 @@
{ {
"name": "owncast-web", "name": "owncast-web",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"resolutions": { "resolutions": {
"babel-preset-current-node-syntax": "1.1.1" "babel-preset-current-node-syntax": "1.1.1"
}, },
"scripts": { "scripts": {
"dev": "next dev", "dev": "next dev",
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "eslint --fix --ext .js,.ts,.tsx types/ pages/ components/ stories/ && npm run stylelint", "lint": "eslint --fix --ext .js,.ts,.tsx types/ pages/ components/ stories/ && npm run stylelint",
"stylelint": "stylelint **/*.scss", "stylelint": "stylelint **/*.scss",
"storybook": "storybook dev -p 6006", "storybook": "storybook dev -p 6006",
"build-storybook": "storybook build", "build-storybook": "storybook build",
"build-styles": "cd ./style-definitions && style-dictionary build && ./build.sh && cd -", "build-styles": "cd ./style-definitions && style-dictionary build && ./build.sh && cd -",
"test": "jest", "test": "jest",
"format": "prettier --write **/*.{js,ts,jsx,tsx,css,md,scss}", "format": "prettier --write **/*.{js,ts,jsx,tsx,css,md,scss}",
"translate": "node scripts/i18n-extract.js" "translate": "node scripts/i18n-extract.js"
}, },
"dependencies": { "dependencies": {
"@ant-design/icons": "4.8.3", "@ant-design/icons": "4.8.3",
"@babel/parser": "^7.28.0", "@babel/parser": "^7.28.0",
"@babel/traverse": "^7.28.0", "@babel/traverse": "^7.28.0",
"@codemirror/lang-css": "6.3.1", "@codemirror/lang-css": "6.3.1",
"@codemirror/lang-html": "^6.4.2", "@codemirror/lang-html": "^6.4.2",
"@codemirror/lang-javascript": "^6.1.2", "@codemirror/lang-javascript": "^6.1.2",
"@codemirror/lang-markdown": "6.4.0", "@codemirror/lang-markdown": "6.4.0",
"@codemirror/language-data": "6.5.1", "@codemirror/language-data": "6.5.1",
"@emoji-mart/data": "^1.2.1", "@emoji-mart/data": "^1.2.1",
"@emoji-mart/react": "^1.1.1", "@emoji-mart/react": "^1.1.1",
"@fontsource/inter": "^5.0.0", "@fontsource/inter": "^5.0.0",
"@fontsource/poppins": "5.2.7", "@fontsource/poppins": "5.2.7",
"@next/bundle-analyzer": "^14.0.0", "@next/bundle-analyzer": "^14.0.0",
"@testing-library/jest-dom": "^6.6.3", "@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.3.0", "@testing-library/react": "^16.3.0",
"@uiw/codemirror-theme-bbedit": "4.25.2", "@uiw/codemirror-theme-bbedit": "4.25.2",
"@uiw/react-codemirror": "4.25.2", "@uiw/react-codemirror": "4.25.2",
"@xstate/react": "3.2.2", "@xstate/react": "3.2.2",
"antd": "4.24.16", "antd": "4.24.16",
"autoprefixer": "^10.4.14", "autoprefixer": "^10.4.14",
"babel-plugin-dynamic-import-node": "^2.3.3", "babel-plugin-dynamic-import-node": "^2.3.3",
"chart.js": "^4.2.0", "chart.js": "^4.2.0",
"classnames": "2.5.1", "classnames": "2.5.1",
"date-fns": "^4.0.0", "date-fns": "^4.0.0",
"glob": "^11.0.3", "emoji-mart": "^5.2.2",
"graphemer": "^1.4.0", "glob": "^11.0.3",
"i18next-scanner": "^4.6.0", "graphemer": "^1.4.0",
"interweave": "^13.0.0", "i18next-scanner": "^4.6.0",
"interweave-autolink": "^5.1.0", "interweave": "^13.0.0",
"lodash": "4.17.21", "interweave-autolink": "^5.1.0",
"next": "14.2.33", "lodash": "4.17.21",
"next-export-i18n": "^2.0.0", "next": "14.2.33",
"next-pwa": "^5.6.0", "next-export-i18n": "2.3.5",
"next-with-less": "3.0.1", "next-pwa": "^5.6.0",
"postcss-flexbugs-fixes": "5.0.2", "next-with-less": "3.0.1",
"react": "18.3.1", "postcss-flexbugs-fixes": "5.0.2",
"react-chartjs-2": "^5.2.0", "react": "18.3.1",
"react-dom": "18.3.1", "react-chartjs-2": "^5.2.0",
"react-error-boundary": "^5.0.0", "react-dom": "18.3.1",
"react-hotkeys-hook": "5.2.1", "react-error-boundary": "^5.0.0",
"react-linkify": "1.0.0-alpha", "react-hotkeys-hook": "5.2.1",
"react-markdown": "10.1.0", "react-linkify": "1.0.0-alpha",
"react-virtuoso": "4.14.1", "react-markdown": "10.1.0",
"recoil": "0.7.7", "react-virtuoso": "4.14.1",
"regexpu-core": "^5.3.2", "recoil": "0.7.7",
"sanitize-html": "^2.11.0", "regexpu-core": "^5.3.2",
"semver": "^7.6.3", "sanitize-html": "^2.11.0",
"sharp": "0.34.4", "semver": "^7.6.3",
"ua-parser-js": "1.0.41", "sharp": "0.34.4",
"video.js": "^8.3.0", "ua-parser-js": "1.0.41",
"workbox-precaching": "^7.0.0", "video.js": "^8.3.0",
"workbox-window": "^7.0.0", "workbox-precaching": "^7.0.0",
"xstate": "4.38.3", "workbox-window": "^7.0.0",
"yaml": "2.8.1" "xstate": "4.38.3",
}, "yaml": "2.8.1"
"devDependencies": { },
"@babel/core": "7.28.4", "devDependencies": {
"@babel/preset-react": "^7.25.7", "@babel/core": "7.28.4",
"@commitlint/cli": "^20.0.0", "@babel/preset-react": "^7.25.7",
"@commitlint/config-conventional": "^20.0.0", "@commitlint/cli": "^20.0.0",
"@mdx-js/react": "3.1.1", "@commitlint/config-conventional": "^20.0.0",
"@storybook/addon-a11y": "^8.3.6", "@mdx-js/react": "3.1.1",
"@storybook/addon-actions": "^8.3.6", "@storybook/addon-a11y": "^9.1.13",
"@storybook/addon-docs": "^8.3.6", "@storybook/addon-docs": "^9.1.13",
"@storybook/addon-essentials": "^8.3.6", "@storybook/addon-links": "^9.1.13",
"@storybook/addon-links": "^8.3.6", "@storybook/cli": "^9.1.13",
"@storybook/addon-mdx-gfm": "^8.3.6", "@storybook/mdx2-csf": "1.1.0",
"@storybook/addon-postcss": "2.0.0", "@storybook/nextjs": "^9.1.13",
"@storybook/addon-styling-webpack": "^1.0.0", "@svgr/webpack": "8.1.0",
"@storybook/addon-viewport": "^8.3.6", "@testing-library/react": "^16.3.0",
"@storybook/cli": "^8.3.6", "@types/jest": "^30.0.0",
"@storybook/mdx2-csf": "1.1.0", "@types/markdown-it": "14.1.2",
"@storybook/nextjs": "^8.3.6", "@types/node": "22.18.11",
"@storybook/preset-scss": "^1.0.3", "@types/prop-types": "15.7.15",
"@storybook/react": "^8.3.6", "@types/react": "18.3.26",
"@storybook/theming": "^8.3.6", "@types/react-linkify": "1.0.4",
"@svgr/webpack": "8.1.0", "@types/sanitize-html": "^2.9.0",
"@testing-library/react": "^16.3.0", "@types/ua-parser-js": "0.7.39",
"@types/jest": "^30.0.0", "@types/video.js": "^7.3.50",
"@types/markdown-it": "14.1.2", "@typescript-eslint/eslint-plugin": "8.46.1",
"@types/node": "22.18.11", "@typescript-eslint/parser": "8.46.1",
"@types/prop-types": "15.7.15", "babel-loader": "10.0.0",
"@types/react": "18.3.26", "chromatic": "13.3.0",
"@types/react-linkify": "1.0.4", "css-loader": "7.1.2",
"@types/sanitize-html": "^2.9.0", "cypress": "^14.0.0",
"@types/ua-parser-js": "0.7.39", "eslint": "8.57.1",
"@types/video.js": "^7.3.50", "eslint-config-airbnb": "19.0.4",
"@typescript-eslint/eslint-plugin": "8.46.1", "eslint-config-next": "14.2.33",
"@typescript-eslint/parser": "8.46.1", "eslint-config-prettier": "10.1.8",
"babel-loader": "10.0.0", "eslint-plugin-import": "^2.27.5",
"chromatic": "13.3.0", "eslint-plugin-jsx-a11y": "6.10.2",
"css-loader": "7.1.2", "eslint-plugin-prettier": "^5.0.0",
"cypress": "^14.0.0", "eslint-plugin-react": "7.37.5",
"eslint": "8.57.1", "eslint-plugin-react-hooks": "4.6.2",
"eslint-config-airbnb": "19.0.4", "eslint-plugin-storybook": "9.1.13",
"eslint-config-next": "14.2.33", "handlebars": "^4.7.7",
"eslint-config-prettier": "10.1.8", "html-webpack-plugin": "5.6.4",
"eslint-plugin-import": "^2.27.5", "install": "^0.13.0",
"eslint-plugin-jsx-a11y": "6.10.2", "jest-environment-jsdom": "^30.0.4",
"eslint-plugin-prettier": "^5.0.0", "knip": "^5.0.0",
"eslint-plugin-react": "7.37.5", "less": "4.4.2",
"eslint-plugin-react-hooks": "4.6.2", "less-loader": "12.3.0",
"eslint-plugin-storybook": "0.12.0", "mdx-mermaid": "^2.0.0",
"handlebars": "^4.7.7", "mermaid": "^11.10.0",
"html-webpack-plugin": "5.6.4", "msw": "^2.11.6",
"install": "^0.13.0", "msw-storybook-addon": "^2.0.6",
"jest-environment-jsdom": "^30.0.4", "npm": "^11.0.0",
"knip": "^5.0.0", "postcss": "^8.4.31",
"less": "4.4.2", "prettier": "3.5.3",
"less-loader": "12.3.0", "sass": "1.93.2",
"mdx-mermaid": "^2.0.0", "storybook": "^9.1.13",
"mermaid": "^11.10.0", "style-dictionary": "3.9.2",
"npm": "^11.0.0", "style-loader": "4.0.0",
"postcss": "^8.4.31", "stylelint": "^16.0.0",
"prettier": "3.5.3", "stylelint-config-standard": "^39.0.0",
"resolve-url-loader": "^5.0.0", "stylelint-config-standard-scss": "^16.0.0",
"sass": "1.93.2", "ts-jest": "^29.1.0",
"sass-loader": "^16.0.0", "typescript": "^5.7.3"
"storybook": "^8.3.6", },
"storybook-addon-fetch-mock": "^2.0.1", "overrides": {
"storybook-preset-less": "1.1.3", "@emoji-mart/react": {
"style-dictionary": "3.9.2", "emoji-mart": "5.2.2"
"style-loader": "4.0.0", }
"stylelint": "^16.0.0", },
"stylelint-config-standard": "^39.0.0", "msw": {
"stylelint-config-standard-scss": "^16.0.0", "workerDirectory": [
"ts-jest": "^29.1.0", "public/"
"typescript": "^5.7.3" ]
}, }
"overrides": {
"@emoji-mart/react": {
"emoji-mart": "5.2.2"
}
}
} }
+349
View File
@@ -0,0 +1,349 @@
/* eslint-disable */
/* tslint:disable */
/**
* Mock Service Worker.
* @see https://github.com/mswjs/msw
* - Please do NOT modify this file.
*/
const PACKAGE_VERSION = '2.11.6'
const INTEGRITY_CHECKSUM = '4db4a41e972cec1b64cc569c66952d82'
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
const activeClientIds = new Set()
addEventListener('install', function () {
self.skipWaiting()
})
addEventListener('activate', function (event) {
event.waitUntil(self.clients.claim())
})
addEventListener('message', async function (event) {
const clientId = Reflect.get(event.source || {}, 'id')
if (!clientId || !self.clients) {
return
}
const client = await self.clients.get(clientId)
if (!client) {
return
}
const allClients = await self.clients.matchAll({
type: 'window',
})
switch (event.data) {
case 'KEEPALIVE_REQUEST': {
sendToClient(client, {
type: 'KEEPALIVE_RESPONSE',
})
break
}
case 'INTEGRITY_CHECK_REQUEST': {
sendToClient(client, {
type: 'INTEGRITY_CHECK_RESPONSE',
payload: {
packageVersion: PACKAGE_VERSION,
checksum: INTEGRITY_CHECKSUM,
},
})
break
}
case 'MOCK_ACTIVATE': {
activeClientIds.add(clientId)
sendToClient(client, {
type: 'MOCKING_ENABLED',
payload: {
client: {
id: client.id,
frameType: client.frameType,
},
},
})
break
}
case 'CLIENT_CLOSED': {
activeClientIds.delete(clientId)
const remainingClients = allClients.filter((client) => {
return client.id !== clientId
})
// Unregister itself when there are no more clients
if (remainingClients.length === 0) {
self.registration.unregister()
}
break
}
}
})
addEventListener('fetch', function (event) {
const requestInterceptedAt = Date.now()
// Bypass navigation requests.
if (event.request.mode === 'navigate') {
return
}
// Opening the DevTools triggers the "only-if-cached" request
// that cannot be handled by the worker. Bypass such requests.
if (
event.request.cache === 'only-if-cached' &&
event.request.mode !== 'same-origin'
) {
return
}
// Bypass all requests when there are no active clients.
// Prevents the self-unregistered worked from handling requests
// after it's been terminated (still remains active until the next reload).
if (activeClientIds.size === 0) {
return
}
const requestId = crypto.randomUUID()
event.respondWith(handleRequest(event, requestId, requestInterceptedAt))
})
/**
* @param {FetchEvent} event
* @param {string} requestId
* @param {number} requestInterceptedAt
*/
async function handleRequest(event, requestId, requestInterceptedAt) {
const client = await resolveMainClient(event)
const requestCloneForEvents = event.request.clone()
const response = await getResponse(
event,
client,
requestId,
requestInterceptedAt,
)
// Send back the response clone for the "response:*" life-cycle events.
// Ensure MSW is active and ready to handle the message, otherwise
// this message will pend indefinitely.
if (client && activeClientIds.has(client.id)) {
const serializedRequest = await serializeRequest(requestCloneForEvents)
// Clone the response so both the client and the library could consume it.
const responseClone = response.clone()
sendToClient(
client,
{
type: 'RESPONSE',
payload: {
isMockedResponse: IS_MOCKED_RESPONSE in response,
request: {
id: requestId,
...serializedRequest,
},
response: {
type: responseClone.type,
status: responseClone.status,
statusText: responseClone.statusText,
headers: Object.fromEntries(responseClone.headers.entries()),
body: responseClone.body,
},
},
},
responseClone.body ? [serializedRequest.body, responseClone.body] : [],
)
}
return response
}
/**
* Resolve the main client for the given event.
* Client that issues a request doesn't necessarily equal the client
* that registered the worker. It's with the latter the worker should
* communicate with during the response resolving phase.
* @param {FetchEvent} event
* @returns {Promise<Client | undefined>}
*/
async function resolveMainClient(event) {
const client = await self.clients.get(event.clientId)
if (activeClientIds.has(event.clientId)) {
return client
}
if (client?.frameType === 'top-level') {
return client
}
const allClients = await self.clients.matchAll({
type: 'window',
})
return allClients
.filter((client) => {
// Get only those clients that are currently visible.
return client.visibilityState === 'visible'
})
.find((client) => {
// Find the client ID that's recorded in the
// set of clients that have registered the worker.
return activeClientIds.has(client.id)
})
}
/**
* @param {FetchEvent} event
* @param {Client | undefined} client
* @param {string} requestId
* @param {number} requestInterceptedAt
* @returns {Promise<Response>}
*/
async function getResponse(event, client, requestId, requestInterceptedAt) {
// Clone the request because it might've been already used
// (i.e. its body has been read and sent to the client).
const requestClone = event.request.clone()
function passthrough() {
// Cast the request headers to a new Headers instance
// so the headers can be manipulated with.
const headers = new Headers(requestClone.headers)
// Remove the "accept" header value that marked this request as passthrough.
// This prevents request alteration and also keeps it compliant with the
// user-defined CORS policies.
const acceptHeader = headers.get('accept')
if (acceptHeader) {
const values = acceptHeader.split(',').map((value) => value.trim())
const filteredValues = values.filter(
(value) => value !== 'msw/passthrough',
)
if (filteredValues.length > 0) {
headers.set('accept', filteredValues.join(', '))
} else {
headers.delete('accept')
}
}
return fetch(requestClone, { headers })
}
// Bypass mocking when the client is not active.
if (!client) {
return passthrough()
}
// Bypass initial page load requests (i.e. static assets).
// The absence of the immediate/parent client in the map of the active clients
// means that MSW hasn't dispatched the "MOCK_ACTIVATE" event yet
// and is not ready to handle requests.
if (!activeClientIds.has(client.id)) {
return passthrough()
}
// Notify the client that a request has been intercepted.
const serializedRequest = await serializeRequest(event.request)
const clientMessage = await sendToClient(
client,
{
type: 'REQUEST',
payload: {
id: requestId,
interceptedAt: requestInterceptedAt,
...serializedRequest,
},
},
[serializedRequest.body],
)
switch (clientMessage.type) {
case 'MOCK_RESPONSE': {
return respondWithMock(clientMessage.data)
}
case 'PASSTHROUGH': {
return passthrough()
}
}
return passthrough()
}
/**
* @param {Client} client
* @param {any} message
* @param {Array<Transferable>} transferrables
* @returns {Promise<any>}
*/
function sendToClient(client, message, transferrables = []) {
return new Promise((resolve, reject) => {
const channel = new MessageChannel()
channel.port1.onmessage = (event) => {
if (event.data && event.data.error) {
return reject(event.data.error)
}
resolve(event.data)
}
client.postMessage(message, [
channel.port2,
...transferrables.filter(Boolean),
])
})
}
/**
* @param {Response} response
* @returns {Response}
*/
function respondWithMock(response) {
// Setting response status code to 0 is a no-op.
// However, when responding with a "Response.error()", the produced Response
// instance will have status code set to 0. Since it's not possible to create
// a Response instance with status code 0, handle that use-case separately.
if (response.status === 0) {
return Response.error()
}
const mockedResponse = new Response(response.body, response)
Reflect.defineProperty(mockedResponse, IS_MOCKED_RESPONSE, {
value: true,
enumerable: true,
})
return mockedResponse
}
/**
* @param {Request} request
*/
async function serializeRequest(request) {
return {
url: request.url,
mode: request.mode,
method: request.method,
headers: Object.fromEntries(request.headers.entries()),
cache: request.cache,
credentials: request.credentials,
destination: request.destination,
integrity: request.integrity,
redirect: request.redirect,
referrer: request.referrer,
referrerPolicy: request.referrerPolicy,
body: await request.arrayBuffer(),
keepalive: request.keepalive,
}
}
+1 -1
View File
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import { Logo } from '../components/ui/Logo/Logo'; import { Logo } from '../components/ui/Logo/Logo';
const meta = { const meta = {
+1 -1
View File
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useSetRecoilState } from 'recoil'; import { RecoilRoot, useSetRecoilState } from 'recoil';
import ReadOnlyPage from '../pages/embed/chat/readonly/index'; import ReadOnlyPage from '../pages/embed/chat/readonly/index';
import { ChatMessage } from '../interfaces/chat-message.model'; import { ChatMessage } from '../interfaces/chat-message.model';
+1 -1
View File
@@ -1,5 +1,5 @@
import { useEffect } from 'react'; import { useEffect } from 'react';
import { StoryFn, Meta } from '@storybook/react'; import { StoryFn, Meta } from '@storybook/nextjs';
import { RecoilRoot, useRecoilState, useSetRecoilState } from 'recoil'; import { RecoilRoot, useRecoilState, useSetRecoilState } from 'recoil';
import ReadWritePage from '../pages/embed/chat/readwrite/index'; import ReadWritePage from '../pages/embed/chat/readwrite/index';
import { ChatMessage } from '../interfaces/chat-message.model'; import { ChatMessage } from '../interfaces/chat-message.model';
+1 -1
View File
@@ -1,4 +1,4 @@
import { Meta, StoryObj } from '@storybook/react'; import { Meta, StoryObj } from '@storybook/nextjs';
import { Translation } from '../components/ui/Translation/Translation'; import { Translation } from '../components/ui/Translation/Translation';
import { Localization } from '../types/localization'; import { Localization } from '../types/localization';
+1 -1
View File
@@ -1,4 +1,4 @@
import { Meta } from '@storybook/react'; import { Meta } from '@storybook/nextjs';
import ConfigFederation from '../pages/admin/config-federation'; import ConfigFederation from '../pages/admin/config-federation';
const meta = { const meta = {