From a725eda543c052d06a14f26a88b0fa5256950ae8 Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Mon, 6 May 2024 23:27:03 +0100 Subject: [PATCH 01/41] feat: migrate from express to connect Migrates away from express, instead using connect and the underlying node server directly. Both express and connect support the same middleware structure, which means most middleware packages work for both and have remained the same in this change. A few notes: - Express' router has been replaced by basic connect mount points (though the two are not equivalent exactly) - Express static has been replaced by sirv This trims a large sub-tree of dependencies from our packages which express was pulling in. We in fact use very little of the functionality express gives us, only really making use of the connect-style API anyway. --- code/builders/builder-manager/package.json | 2 +- code/builders/builder-manager/src/index.ts | 48 ++++++-- code/builders/builder-vite/package.json | 3 +- code/builders/builder-vite/src/index.ts | 35 ++++-- code/builders/builder-webpack5/package.json | 2 +- code/builders/builder-webpack5/src/index.ts | 22 +++- code/lib/core-server/package.json | 3 +- code/lib/core-server/src/dev-server.ts | 23 ++-- code/lib/core-server/src/utils/doTelemetry.ts | 5 +- .../src/utils/get-caching-middleware.ts | 6 +- .../src/utils/getAccessControlMiddleware.ts | 12 +- .../src/utils/getStoryIndexGenerator.ts | 5 +- code/lib/core-server/src/utils/metadata.ts | 11 +- code/lib/core-server/src/utils/router.ts | 5 - code/lib/core-server/src/utils/server-init.ts | 4 +- .../core-server/src/utils/server-statics.ts | 112 +++++++++++++----- .../src/utils/stories-json.test.ts | 14 +-- .../lib/core-server/src/utils/stories-json.ts | 18 +-- code/lib/types/package.json | 1 - code/lib/types/src/modules/core-common.ts | 10 +- code/package.json | 1 - code/yarn.lock | 79 ++++++++++-- 22 files changed, 290 insertions(+), 131 deletions(-) delete mode 100644 code/lib/core-server/src/utils/router.ts diff --git a/code/builders/builder-manager/package.json b/code/builders/builder-manager/package.json index a472f7c4f339..de3bebff0b5c 100644 --- a/code/builders/builder-manager/package.json +++ b/code/builders/builder-manager/package.json @@ -54,9 +54,9 @@ "ejs": "^3.1.8", "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0", "esbuild-plugin-alias": "^0.2.1", - "express": "^4.17.3", "fs-extra": "^11.1.0", "process": "^0.11.10", + "sirv": "^2.0.4", "util": "^0.12.4" }, "devDependencies": { diff --git a/code/builders/builder-manager/src/index.ts b/code/builders/builder-manager/src/index.ts index 28e6fdd5a55e..cb5346423630 100644 --- a/code/builders/builder-manager/src/index.ts +++ b/code/builders/builder-manager/src/index.ts @@ -1,6 +1,6 @@ import { dirname, join, parse } from 'path'; import fs from 'fs-extra'; -import express from 'express'; +import sirv from 'sirv'; import { logger } from '@storybook/node-logger'; @@ -26,6 +26,7 @@ import { safeResolve } from './utils/safeResolve'; import { readOrderedFiles } from './utils/files'; import { buildFrameworkGlobalsFromOptions } from './utils/framework'; +const isRootPath = /^\/($|\?)/; let compilation: Compilation; let asyncIterator: ReturnType | ReturnType; @@ -124,7 +125,7 @@ export const executor = { const starter: StarterFunction = async function* starterGeneratorFn({ startTime, options, - router, + app, }) { logger.info('=> Starting manager..'); @@ -159,8 +160,33 @@ const starter: StarterFunction = async function* starterGeneratorFn({ const coreDirOrigin = join(dirname(require.resolve('@storybook/manager/package.json')), 'dist'); - router.use(`/sb-addons`, express.static(addonsDir, { immutable: true, maxAge: '5m' })); - router.use(`/sb-manager`, express.static(coreDirOrigin, { immutable: true, maxAge: '5m' })); + const serveAddons = sirv(addonsDir, { + maxAge: 300000, + dev: true, + immutable: true + }); + const serveCore = sirv(coreDirOrigin, { + maxAge: 300000, + dev: true, + immutable: true + }); + // TODO (43081j): maybe abstract this into a reusable function + app.use('/sb-addons', (req, res, next) => { + if (!req.url || req.url === '/') { + next(); + return; + } + + serveAddons(req, res, next); + }); + app.use('/sb-manager', (req, res, next) => { + if (!req.url || req.url === '/') { + next(); + return; + } + + serveCore(req, res, next); + }); const { cssFiles, jsFiles } = await readOrderedFiles(addonsDir, compilation?.outputFiles); @@ -187,15 +213,19 @@ const starter: StarterFunction = async function* starterGeneratorFn({ yield; - router.use(`/`, ({ path }, res, next) => { - if (path === '/') { - res.status(200).send(html); + app.use('/', ({ url }, res, next) => { + if (isRootPath.test(url)) { + res.statusCode = 200; + res.write(html); + res.end(); } else { next(); } }); - router.use(`/index.html`, ({ path }, res) => { - res.status(200).send(html); + app.use(`/index.html`, (req, res) => { + res.statusCode = 200; + res.write(html); + res.end(); }); return { diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index db351000c368..2e44fa1136cb 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -55,14 +55,13 @@ "@types/find-cache-dir": "^3.2.1", "browser-assert": "^1.2.1", "es-module-lexer": "^1.5.0", - "express": "^4.17.3", "find-cache-dir": "^3.0.0", "fs-extra": "^11.1.0", "magic-string": "^0.30.0", + "sirv": "^2.0.4", "ts-dedent": "^2.0.0" }, "devDependencies": { - "@types/express": "^4.17.13", "@types/node": "^18.0.0", "glob": "^10.0.0", "slash": "^5.0.0", diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index 3c0b7591d2cf..798ab03f1471 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -1,9 +1,8 @@ // noinspection JSUnusedGlobalSymbols import * as fs from 'fs-extra'; -import type { RequestHandler } from 'express'; +import type {NextHandleFunction} from 'connect'; import type { ViteDevServer } from 'vite'; -import express from 'express'; import { dirname, join, parse } from 'path'; import { NoStatsForViteDevError } from '@storybook/core-events/server-errors'; import type { Options } from '@storybook/types'; @@ -11,6 +10,7 @@ import { transformIframeHtml } from './transform-iframe-html'; import { createViteServer } from './vite-server'; import { build as viteBuild } from './build'; import type { ViteBuilder } from './types'; +import sirv from 'sirv'; export { withoutVitePlugins } from './utils/without-vite-plugins'; export { hasVitePlugins } from './utils/has-vite-plugins'; @@ -20,16 +20,17 @@ export * from './types'; const getAbsolutePath = (input: I): I => dirname(require.resolve(join(input, 'package.json'))) as any; -function iframeMiddleware(options: Options, server: ViteDevServer): RequestHandler { +function iframeMiddleware(options: Options, server: ViteDevServer): NextHandleFunction { return async (req, res, next) => { - if (!req.url.match(/^\/iframe\.html($|\?)/)) { + if (!req.url || !req.url.match(/^\/iframe\.html($|\?)/)) { next(); return; } + const url = new URL(req.url, 'https://storybook.js.org'); // We need to handle `html-proxy` params for style tag HMR https://github.com/storybookjs/builder-vite/issues/266#issuecomment-1055677865 // e.g. /iframe.html?html-proxy&index=0.css - if (req.query['html-proxy'] !== undefined) { + if (url.searchParams.has('html-proxy')) { next(); return; } @@ -41,7 +42,9 @@ function iframeMiddleware(options: Options, server: ViteDevServer): RequestHandl const generated = await transformIframeHtml(indexHtml, options); const transformed = await server.transformIndexHtml('/iframe.html', generated); res.setHeader('Content-Type', 'text/html'); - res.status(200).send(transformed); + res.statusCode = 200; + res.write(transformed); + res.end(); }; } @@ -54,18 +57,30 @@ export async function bail(): Promise { export const start: ViteBuilder['start'] = async ({ startTime, options, - router, + app, server: devServer, }) => { server = await createViteServer(options as Options, devServer); const previewResolvedDir = getAbsolutePath('@storybook/preview'); const previewDirOrigin = join(previewResolvedDir, 'dist'); + const servePreview = sirv(previewDirOrigin, { + maxAge: 300000, + dev: true, + immutable: true + }); + + app.use('/sb-preview', (req, res, next) => { + if (!req.url || req.url === '/') { + next(); + return; + } - router.use(`/sb-preview`, express.static(previewDirOrigin, { immutable: true, maxAge: '5m' })); + servePreview(req, res, next); + }); - router.use(iframeMiddleware(options as Options, server)); - router.use(server.middlewares); + app.use(iframeMiddleware(options as Options, server)); + app.use(server.middlewares); return { bail, diff --git a/code/builders/builder-webpack5/package.json b/code/builders/builder-webpack5/package.json index 0c346841e92f..4f734d96dc75 100644 --- a/code/builders/builder-webpack5/package.json +++ b/code/builders/builder-webpack5/package.json @@ -79,7 +79,6 @@ "constants-browserify": "^1.0.0", "css-loader": "^6.7.1", "es-module-lexer": "^1.5.0", - "express": "^4.17.3", "fork-ts-checker-webpack-plugin": "^8.0.0", "fs-extra": "^11.1.0", "html-webpack-plugin": "^5.5.0", @@ -87,6 +86,7 @@ "path-browserify": "^1.0.1", "process": "^0.11.10", "semver": "^7.3.7", + "sirv": "^2.0.4", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.3.1", "ts-dedent": "^2.0.0", diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 6473f7db3c3d..0c5baf8c0654 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -6,7 +6,6 @@ import { logger } from '@storybook/node-logger'; import type { Builder, Options } from '@storybook/types'; import { checkWebpackVersion } from '@storybook/core-webpack'; import { dirname, join, parse } from 'path'; -import express from 'express'; import fs from 'fs-extra'; import { PREVIEW_BUILDER_PROGRESS } from '@storybook/core-events'; import { @@ -14,6 +13,7 @@ import { WebpackInvocationError, WebpackMissingStatsError, } from '@storybook/core-events/server-errors'; +import sirv from 'sirv'; import prettyTime from 'pretty-hrtime'; @@ -114,7 +114,7 @@ export const bail: WebpackBuilder['bail'] = async () => { const starter: StarterFunction = async function* starterGeneratorFn({ startTime, options, - router, + app, channel, }) { const webpackInstance = await executor.get(options); @@ -181,11 +181,23 @@ const starter: StarterFunction = async function* starterGeneratorFn({ const previewResolvedDir = getAbsolutePath('@storybook/preview'); const previewDirOrigin = join(previewResolvedDir, 'dist'); + const servePreview = sirv(previewDirOrigin, { + maxAge: 300000, + dev: true, + immutable: true + }); + + app.use('/sb-preview', (req, res, next) => { + if (!req.url || req.url === '/') { + next(); + return; + } - router.use(`/sb-preview`, express.static(previewDirOrigin, { immutable: true, maxAge: '5m' })); + servePreview(req, res, next); + }); - router.use(compilation); - router.use(webpackHotMiddleware(compiler, { log: false })); + app.use(compilation); + app.use(webpackHotMiddleware(compiler, { log: false })); const stats = await new Promise((res, rej) => { compilation?.waitUntilValid(res as any); diff --git a/code/lib/core-server/package.json b/code/lib/core-server/package.json index 9d4850f18142..6ab535ce8cb0 100644 --- a/code/lib/core-server/package.json +++ b/code/lib/core-server/package.json @@ -82,9 +82,9 @@ "chalk": "^4.1.0", "cli-table3": "^0.6.1", "compression": "^1.7.4", + "connect": "^3.7.0", "detect-port": "^1.3.0", "diff": "^5.2.0", - "express": "^4.17.3", "fs-extra": "^11.1.0", "globby": "^14.0.1", "ip": "^2.0.1", @@ -94,6 +94,7 @@ "prompts": "^2.4.0", "read-pkg-up": "^7.0.1", "semver": "^7.3.7", + "sirv": "^2.0.4", "telejson": "^7.2.0", "tiny-invariant": "^1.3.1", "ts-dedent": "^2.0.0", diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts index f8805a75a690..46351e1d2cf2 100644 --- a/code/lib/core-server/src/dev-server.ts +++ b/code/lib/core-server/src/dev-server.ts @@ -1,4 +1,3 @@ -import express from 'express'; import compression from 'compression'; import invariant from 'tiny-invariant'; @@ -19,12 +18,12 @@ import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; import type { StoryIndexGenerator } from './utils/StoryIndexGenerator'; import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; import { doTelemetry } from './utils/doTelemetry'; -import { router } from './utils/router'; import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware'; import { getCachingMiddleware } from './utils/get-caching-middleware'; +import connect, {type NextHandleFunction} from 'connect'; export async function storybookDevServer(options: Options) { - const app = express(); + const app = connect(); const [server, features, core] = await Promise.all([ getServer(app, options), @@ -40,12 +39,12 @@ export async function storybookDevServer(options: Options) { let indexError: Error | undefined; // try get index generator, if failed, send telemetry without storyCount, then rethrow the error const initializedStoryIndexGenerator: Promise = - getStoryIndexGenerator(features ?? {}, options, serverChannel).catch((err) => { + getStoryIndexGenerator(app, features ?? {}, options, serverChannel).catch((err) => { indexError = err; return undefined; }); - app.use(compression({ level: 1 })); + app.use(compression({ level: 1 }) as NextHandleFunction); if (typeof options.extendServer === 'function') { options.extendServer(server); @@ -54,9 +53,7 @@ export async function storybookDevServer(options: Options) { app.use(getAccessControlMiddleware(core?.crossOriginIsolated ?? false)); app.use(getCachingMiddleware()); - getMiddleware(options.configDir)(router); - - app.use(router); + getMiddleware(options.configDir)(app); const { port, host, initialPath } = options; invariant(port, 'expected options to have a port'); @@ -77,7 +74,7 @@ export async function storybookDevServer(options: Options) { const [previewBuilder, managerBuilder] = await Promise.all([ getPreviewBuilder(builderName, options.configDir), getManagerBuilder(), - useStatics(router, options), + useStatics(app, options), ]); if (options.debugWebpack) { @@ -87,7 +84,7 @@ export async function storybookDevServer(options: Options) { const managerResult = await managerBuilder.start({ startTime: process.hrtime(), options, - router, + app, server, channel: serverChannel, }); @@ -100,7 +97,7 @@ export async function storybookDevServer(options: Options) { .start({ startTime: process.hrtime(), options, - router, + app, server, channel: serverChannel, }) @@ -122,7 +119,7 @@ export async function storybookDevServer(options: Options) { // this is a preview route, the builder has to be started before we can serve it // this handler keeps request to that route pending until the builder is ready to serve it, preventing a 404 - router.get('/iframe.html', (req, res, next) => { + app.use('/iframe.html', (req, res, next) => { // We need to catch here or node will treat any errors thrown by `previewStarted` as // unhandled and exit (even though they are very much handled below) previewStarted.catch(() => {}).then(() => next()); @@ -142,7 +139,7 @@ export async function storybookDevServer(options: Options) { const previewResult = await previewStarted; // Now the preview has successfully started, we can count this as a 'dev' event. - doTelemetry(core, initializedStoryIndexGenerator, options); + doTelemetry(app, core, initializedStoryIndexGenerator, options); return { previewResult, managerResult, address, networkAddress }; } diff --git a/code/lib/core-server/src/utils/doTelemetry.ts b/code/lib/core-server/src/utils/doTelemetry.ts index ecb494fc45f5..2c07cb83970c 100644 --- a/code/lib/core-server/src/utils/doTelemetry.ts +++ b/code/lib/core-server/src/utils/doTelemetry.ts @@ -4,11 +4,12 @@ import { telemetry, getPrecedingUpgrade } from '@storybook/telemetry'; import { useStorybookMetadata } from './metadata'; import type { StoryIndexGenerator } from './StoryIndexGenerator'; import { summarizeIndex } from './summarizeIndex'; -import { router } from './router'; import { versionStatus } from './versionStatus'; import { sendTelemetryError } from '../withTelemetry'; +import type { Server } from 'connect'; export async function doTelemetry( + app: Server, core: CoreConfig, initializedStoryIndexGenerator: Promise, options: Options @@ -47,6 +48,6 @@ export async function doTelemetry( } if (!core?.disableProjectJson) { - useStorybookMetadata(router, options.configDir); + useStorybookMetadata(app, options.configDir); } } diff --git a/code/lib/core-server/src/utils/get-caching-middleware.ts b/code/lib/core-server/src/utils/get-caching-middleware.ts index d01cb3e5e922..fe7554def150 100644 --- a/code/lib/core-server/src/utils/get-caching-middleware.ts +++ b/code/lib/core-server/src/utils/get-caching-middleware.ts @@ -1,8 +1,8 @@ -import type { RequestHandler } from 'express'; +import type { NextHandleFunction } from 'connect'; -export function getCachingMiddleware(): RequestHandler { +export function getCachingMiddleware(): NextHandleFunction { return (req, res, next) => { - res.header('Cache-Control', 'no-store'); + res.setHeader('Cache-Control', 'no-store'); next(); }; } diff --git a/code/lib/core-server/src/utils/getAccessControlMiddleware.ts b/code/lib/core-server/src/utils/getAccessControlMiddleware.ts index 9eb8851e6a5c..23e0caf276bd 100644 --- a/code/lib/core-server/src/utils/getAccessControlMiddleware.ts +++ b/code/lib/core-server/src/utils/getAccessControlMiddleware.ts @@ -1,16 +1,16 @@ -import type { RequestHandler } from 'express'; +import type { NextHandleFunction } from 'connect'; -export function getAccessControlMiddleware(crossOriginIsolated: boolean): RequestHandler { +export function getAccessControlMiddleware(crossOriginIsolated: boolean): NextHandleFunction { return (req, res, next) => { - res.header('Access-Control-Allow-Origin', '*'); - res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); + res.setHeader('Access-Control-Allow-Origin', '*'); + res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); // These headers are required to enable SharedArrayBuffer // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer if (crossOriginIsolated) { // These headers are required to enable SharedArrayBuffer // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer - res.header('Cross-Origin-Opener-Policy', 'same-origin'); - res.header('Cross-Origin-Embedder-Policy', 'require-corp'); + res.setHeader('Cross-Origin-Opener-Policy', 'same-origin'); + res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp'); } next(); }; diff --git a/code/lib/core-server/src/utils/getStoryIndexGenerator.ts b/code/lib/core-server/src/utils/getStoryIndexGenerator.ts index f8c1bc97f615..12f9da95fce5 100644 --- a/code/lib/core-server/src/utils/getStoryIndexGenerator.ts +++ b/code/lib/core-server/src/utils/getStoryIndexGenerator.ts @@ -3,9 +3,10 @@ import { normalizeStories } from '@storybook/core-common'; import { useStoriesJson } from './stories-json'; import type { ServerChannel } from './get-server-channel'; import { StoryIndexGenerator } from './StoryIndexGenerator'; -import { router } from './router'; +import type { Server } from 'connect'; export async function getStoryIndexGenerator( + app: Server, features: { argTypeTargetsV7?: boolean; }, @@ -32,7 +33,7 @@ export async function getStoryIndexGenerator( const initializedStoryIndexGenerator = generator.initialize().then(() => generator); useStoriesJson({ - router, + app, initializedStoryIndexGenerator, normalizedStories, serverChannel, diff --git a/code/lib/core-server/src/utils/metadata.ts b/code/lib/core-server/src/utils/metadata.ts index 319b001ea7b9..5aedb18385bf 100644 --- a/code/lib/core-server/src/utils/metadata.ts +++ b/code/lib/core-server/src/utils/metadata.ts @@ -1,5 +1,5 @@ import { writeJSON } from 'fs-extra'; -import type { Request, Response, Router } from 'express'; +import type { Server } from 'connect'; import { getStorybookMetadata } from '@storybook/telemetry'; export async function extractStorybookMetadata(outputFile: string, configDir: string) { @@ -8,10 +8,11 @@ export async function extractStorybookMetadata(outputFile: string, configDir: st await writeJSON(outputFile, storybookMetadata); } -export function useStorybookMetadata(router: Router, configDir?: string) { - router.use('/project.json', async (req: Request, res: Response) => { +export function useStorybookMetadata(app: Server, configDir?: string) { + app.use('/project.json', async (req, res) => { const storybookMetadata = await getStorybookMetadata(configDir); - res.header('Content-Type', 'application/json'); - res.send(JSON.stringify(storybookMetadata)); + res.setHeader('Content-Type', 'application/json'); + res.write(JSON.stringify(storybookMetadata)); + res.end(); }); } diff --git a/code/lib/core-server/src/utils/router.ts b/code/lib/core-server/src/utils/router.ts deleted file mode 100644 index 894388991b5f..000000000000 --- a/code/lib/core-server/src/utils/router.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { Router } from 'express'; - -// @ts-expect-error (Converted from ts-ignore) - -export const router: Router = new Router(); diff --git a/code/lib/core-server/src/utils/server-init.ts b/code/lib/core-server/src/utils/server-init.ts index 176c1e6bfd69..bf2c873a5d38 100644 --- a/code/lib/core-server/src/utils/server-init.ts +++ b/code/lib/core-server/src/utils/server-init.ts @@ -1,11 +1,11 @@ import { logger } from '@storybook/node-logger'; -import type { Express } from 'express'; +import type { Server } from 'connect'; import { readFile } from 'fs-extra'; import http from 'http'; import https from 'https'; export async function getServer( - app: Express, + app: Server, options: { https?: boolean; sslCert?: string; diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index 2a0b93e1ca41..9b264a5dcd99 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -2,51 +2,99 @@ import { logger } from '@storybook/node-logger'; import type { Options } from '@storybook/types'; import { getDirectoryFromWorkingDir } from '@storybook/core-common'; import chalk from 'chalk'; -import type { Router } from 'express'; -import express from 'express'; +import type {NextHandleFunction, Server} from 'connect'; import { pathExists } from 'fs-extra'; import path, { basename, isAbsolute } from 'path'; +import sirv from 'sirv'; +import type {ServerResponse} from 'http'; import { dedent } from 'ts-dedent'; -export async function useStatics(router: Router, options: Options) { +// TODO (43081j): maybe get this from somewhere? +const contentTypes: Record = { + 'css': 'text/css', + 'woff2': 'font/woff2', + 'js': 'text/javascript' +}; +const setContentTypeHeaders = (res: ServerResponse, pathname: string) => { + const base = basename(pathname); + const contentType = contentTypes[base]; + if (contentType) { + res.setHeader('Content-Type', contentType); + } +}; + +export async function useStatics(app: Server, options: Options): Promise { const staticDirs = (await options.presets.apply('staticDirs')) ?? []; const faviconPath = await options.presets.apply('favicon'); - const statics = [ + const statics: Array<{targetEndpoint: string; staticPath: string}> = []; + const userStatics = [ + `${faviconPath}:/${basename(faviconPath)}`, ...staticDirs.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)), ]; - if (statics && statics.length > 0) { - await Promise.all( - statics.map(async (dir) => { - try { - const normalizedDir = - staticDirs && !isAbsolute(dir) - ? getDirectoryFromWorkingDir({ - configDir: options.configDir, - workingDir: process.cwd(), - directory: dir, - }) - : dir; - const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(normalizedDir); - - // Don't log for the internal static dir - if (!targetEndpoint.startsWith('/sb-')) { - logger.info( - chalk`=> Serving static files from {cyan ${staticDir}} at {cyan ${targetEndpoint}}` - ); - } - - router.use(targetEndpoint, express.static(staticPath, { index: false })); - } catch (e) { - if (e instanceof Error) logger.warn(e.message); - } - }) - ); + for (const dir of userStatics) { + try { + const normalizedDir = + staticDirs && !isAbsolute(dir) + ? getDirectoryFromWorkingDir({ + configDir: options.configDir, + workingDir: process.cwd(), + directory: dir, + }) + : dir; + const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(normalizedDir); + + // Don't log for the internal static dir + if (!targetEndpoint.startsWith('/sb-')) { + logger.info( + chalk`=> Serving static files from {cyan ${staticDir}} at {cyan ${targetEndpoint}}` + ); + } + + statics.push({targetEndpoint, staticPath}); + } catch (e) { + if (e instanceof Error) logger.warn(e.message); + } } - router.get(`/${basename(faviconPath)}`, (req, res) => res.sendFile(faviconPath)); + const serve = sirv( + process.cwd(), + { + dev: true, + etag: true, + setHeaders: setContentTypeHeaders + } + ); + + app.use((req, res, next) => { + if (!req.url) { + return next(); + } + + const url = new URL(req.url, 'https://storybook.js.org'); + const pathname = path.normalize(url.pathname); + + // TODO (43081j): this is 'security' so you can't break out of cwd + // Probably need to do something better here + if (pathname.startsWith('..') || pathname.endsWith('/')) { + return next(); + } + + for (const {targetEndpoint, staticPath} of statics) { + if (pathname.startsWith(targetEndpoint)) { + // TODO (43081j): similar as above, this might be doable in a cleaner way + const newPath = path.relative(process.cwd(), path.resolve(staticPath, './' + pathname.slice(targetEndpoint.length))); + url.pathname = newPath; + req.url = url.href.slice(url.origin.length); + serve(req, res, next); + return; + } + } + + next(); + }); } export const parseStaticDir = async (arg: string) => { diff --git a/code/lib/core-server/src/utils/stories-json.test.ts b/code/lib/core-server/src/utils/stories-json.test.ts index a621f5443ce3..9d7d6e2da036 100644 --- a/code/lib/core-server/src/utils/stories-json.test.ts +++ b/code/lib/core-server/src/utils/stories-json.test.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect, vi } from 'vitest'; -import type { Router, Request, Response } from 'express'; +import type { Server } from 'connect'; import Watchpack from 'watchpack'; import path from 'path'; import debounce from 'lodash/debounce.js'; @@ -55,7 +55,7 @@ const getInitializedStoryIndexGenerator = async ( describe('useStoriesJson', () => { const use = vi.fn(); - const router: Router = { use } as any; + const app: Server = { use } as any; const send = vi.fn(); const write = vi.fn(); const response: Response = { @@ -86,7 +86,7 @@ describe('useStoriesJson', () => { const mockServerChannel = { emit: vi.fn() } as any as ServerChannel; console.time('useStoriesJson'); useStoriesJson({ - router, + app, serverChannel: mockServerChannel, workingDir, normalizedStories, @@ -255,7 +255,7 @@ describe('useStoriesJson', () => { const mockServerChannel = { emit: vi.fn() } as any as ServerChannel; useStoriesJson({ - router, + app, serverChannel: mockServerChannel, workingDir, normalizedStories, @@ -287,7 +287,7 @@ describe('useStoriesJson', () => { it('sends invalidate events', async () => { const mockServerChannel = { emit: vi.fn() } as any as ServerChannel; useStoriesJson({ - router, + app, serverChannel: mockServerChannel, workingDir, normalizedStories, @@ -316,7 +316,7 @@ describe('useStoriesJson', () => { it('only sends one invalidation when multiple event listeners are listening', async () => { const mockServerChannel = { emit: vi.fn() } as any as ServerChannel; useStoriesJson({ - router, + app, serverChannel: mockServerChannel, workingDir, normalizedStories, @@ -354,7 +354,7 @@ describe('useStoriesJson', () => { const mockServerChannel = { emit: vi.fn() } as any as ServerChannel; useStoriesJson({ - router, + app, serverChannel: mockServerChannel, workingDir, normalizedStories, diff --git a/code/lib/core-server/src/utils/stories-json.ts b/code/lib/core-server/src/utils/stories-json.ts index 074c0248cb0c..ae9c72c90d1f 100644 --- a/code/lib/core-server/src/utils/stories-json.ts +++ b/code/lib/core-server/src/utils/stories-json.ts @@ -1,4 +1,4 @@ -import type { Router, Request, Response } from 'express'; +import type { Server } from 'connect'; import { writeJSON } from 'fs-extra'; import type { NormalizedStoriesSpecifier, StoryIndex } from '@storybook/types'; @@ -22,13 +22,13 @@ export async function extractStoriesJson( } export function useStoriesJson({ - router, + app, initializedStoryIndexGenerator, workingDir = process.cwd(), serverChannel, normalizedStories, }: { - router: Router; + app: Server; initializedStoryIndexGenerator: Promise; serverChannel: ServerChannel; workingDir?: string; @@ -43,15 +43,17 @@ export function useStoriesJson({ maybeInvalidate(); }); - router.use('/index.json', async (req: Request, res: Response) => { + app.use('/index.json', async (req, res) => { try { const generator = await initializedStoryIndexGenerator; const index = await generator.getIndex(); - res.header('Content-Type', 'application/json'); - res.send(JSON.stringify(index)); + res.setHeader('Content-Type', 'application/json'); + res.write(JSON.stringify(index)); + res.end(); } catch (err) { - res.status(500); - res.send(err instanceof Error ? err.toString() : String(err)); + res.statusCode = 500; + res.write(err instanceof Error ? err.toString() : String(err)); + res.end(); } }); } diff --git a/code/lib/types/package.json b/code/lib/types/package.json index 58824511b291..558e0b19dce7 100644 --- a/code/lib/types/package.json +++ b/code/lib/types/package.json @@ -45,7 +45,6 @@ }, "dependencies": { "@storybook/channels": "workspace:*", - "@types/express": "^4.7.0", "file-system-cache": "2.3.0" }, "devDependencies": { diff --git a/code/lib/types/src/modules/core-common.ts b/code/lib/types/src/modules/core-common.ts index c4aeeacbcf1f..e5e2af12457a 100644 --- a/code/lib/types/src/modules/core-common.ts +++ b/code/lib/types/src/modules/core-common.ts @@ -1,8 +1,8 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { FileSystemCache } from 'file-system-cache'; import type { Options as TelejsonOptions } from 'telejson'; -import type { Router } from 'express'; -import type { Server } from 'http'; +import type { Server } from 'connect'; +import type { Server as HttpServer } from 'http'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; import type { StoriesEntry, Indexer } from './indexer'; @@ -157,7 +157,7 @@ export interface LoadOptions { configDir?: string; cacheKey?: string; ignorePreview?: boolean; - extendServer?: (server: Server) => void; + extendServer?: (server: HttpServer) => void; } export interface CLIOptions { @@ -217,8 +217,8 @@ export interface Builder { start: (args: { options: Options; startTime: ReturnType; - router: Router; - server: Server; + app: Server; + server: HttpServer; channel: ServerChannel; }) => Promise= 1.4.0 < 2": +"statuses@npm:>= 1.4.0 < 2, statuses@npm:~1.5.0": version: 1.5.0 resolution: "statuses@npm:1.5.0" checksum: 10c0/e433900956357b3efd79b1c547da4d291799ac836960c016d10a98f6a810b1b5c0dcc13b5a7aa609a58239b5190e1ea176ad9221c2157d2fd1c747393e6b2940 @@ -27456,6 +27508,13 @@ __metadata: languageName: node linkType: hard +"totalist@npm:^3.0.0": + version: 3.0.1 + resolution: "totalist@npm:3.0.1" + checksum: 10c0/4bb1fadb69c3edbef91c73ebef9d25b33bbf69afe1e37ce544d5f7d13854cda15e47132f3e0dc4cafe300ddb8578c77c50a65004d8b6e97e77934a69aa924863 + languageName: node + linkType: hard + "tough-cookie@npm:^4.1.3": version: 4.1.3 resolution: "tough-cookie@npm:4.1.3" From 9b0b42aebbd41c07488a56f7cdebc76efdce0b92 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 7 May 2024 15:50:56 +0200 Subject: [PATCH 02/41] fix --- code/builders/builder-manager/src/index.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/code/builders/builder-manager/src/index.ts b/code/builders/builder-manager/src/index.ts index cb5346423630..5b0dd2373ea9 100644 --- a/code/builders/builder-manager/src/index.ts +++ b/code/builders/builder-manager/src/index.ts @@ -122,11 +122,7 @@ export const executor = { * * I am sorry for making you read about generators today :') */ -const starter: StarterFunction = async function* starterGeneratorFn({ - startTime, - options, - app, -}) { +const starter: StarterFunction = async function* starterGeneratorFn({ startTime, options, app }) { logger.info('=> Starting manager..'); const { @@ -163,12 +159,12 @@ const starter: StarterFunction = async function* starterGeneratorFn({ const serveAddons = sirv(addonsDir, { maxAge: 300000, dev: true, - immutable: true + immutable: true, }); const serveCore = sirv(coreDirOrigin, { maxAge: 300000, dev: true, - immutable: true + immutable: true, }); // TODO (43081j): maybe abstract this into a reusable function app.use('/sb-addons', (req, res, next) => { @@ -214,7 +210,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ yield; app.use('/', ({ url }, res, next) => { - if (isRootPath.test(url)) { + if (url && isRootPath.test(url)) { res.statusCode = 200; res.write(html); res.end(); From 81292297e8333b57086fae7cae94b6a484df84dc Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 7 May 2024 16:39:37 +0200 Subject: [PATCH 03/41] fix linting --- code/builders/builder-vite/src/index.ts | 4 +-- code/builders/builder-webpack5/src/index.ts | 2 +- code/lib/core-server/src/dev-server.ts | 2 +- .../core-server/src/utils/server-statics.ts | 34 +++++++++---------- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index 798ab03f1471..5500261989d5 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -1,7 +1,7 @@ // noinspection JSUnusedGlobalSymbols import * as fs from 'fs-extra'; -import type {NextHandleFunction} from 'connect'; +import type { NextHandleFunction } from 'connect'; import type { ViteDevServer } from 'vite'; import { dirname, join, parse } from 'path'; import { NoStatsForViteDevError } from '@storybook/core-events/server-errors'; @@ -67,7 +67,7 @@ export const start: ViteBuilder['start'] = async ({ const servePreview = sirv(previewDirOrigin, { maxAge: 300000, dev: true, - immutable: true + immutable: true, }); app.use('/sb-preview', (req, res, next) => { diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 0c5baf8c0654..19e6385feb17 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -184,7 +184,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ const servePreview = sirv(previewDirOrigin, { maxAge: 300000, dev: true, - immutable: true + immutable: true, }); app.use('/sb-preview', (req, res, next) => { diff --git a/code/lib/core-server/src/dev-server.ts b/code/lib/core-server/src/dev-server.ts index 46351e1d2cf2..74d56058571b 100644 --- a/code/lib/core-server/src/dev-server.ts +++ b/code/lib/core-server/src/dev-server.ts @@ -20,7 +20,7 @@ import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; import { doTelemetry } from './utils/doTelemetry'; import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware'; import { getCachingMiddleware } from './utils/get-caching-middleware'; -import connect, {type NextHandleFunction} from 'connect'; +import connect, { type NextHandleFunction } from 'connect'; export async function storybookDevServer(options: Options) { const app = connect(); diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index 9b264a5dcd99..bc664d13132f 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -2,19 +2,19 @@ import { logger } from '@storybook/node-logger'; import type { Options } from '@storybook/types'; import { getDirectoryFromWorkingDir } from '@storybook/core-common'; import chalk from 'chalk'; -import type {NextHandleFunction, Server} from 'connect'; +import type { NextHandleFunction, Server } from 'connect'; import { pathExists } from 'fs-extra'; import path, { basename, isAbsolute } from 'path'; import sirv from 'sirv'; -import type {ServerResponse} from 'http'; +import type { ServerResponse } from 'http'; import { dedent } from 'ts-dedent'; // TODO (43081j): maybe get this from somewhere? const contentTypes: Record = { - 'css': 'text/css', - 'woff2': 'font/woff2', - 'js': 'text/javascript' + css: 'text/css', + woff2: 'font/woff2', + js: 'text/javascript', }; const setContentTypeHeaders = (res: ServerResponse, pathname: string) => { const base = basename(pathname); @@ -28,7 +28,7 @@ export async function useStatics(app: Server, options: Options): Promise { const staticDirs = (await options.presets.apply('staticDirs')) ?? []; const faviconPath = await options.presets.apply('favicon'); - const statics: Array<{targetEndpoint: string; staticPath: string}> = []; + const statics: Array<{ targetEndpoint: string; staticPath: string }> = []; const userStatics = [ `${faviconPath}:/${basename(faviconPath)}`, ...staticDirs.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)), @@ -53,20 +53,17 @@ export async function useStatics(app: Server, options: Options): Promise { ); } - statics.push({targetEndpoint, staticPath}); + statics.push({ targetEndpoint, staticPath }); } catch (e) { if (e instanceof Error) logger.warn(e.message); } } - const serve = sirv( - process.cwd(), - { - dev: true, - etag: true, - setHeaders: setContentTypeHeaders - } - ); + const serve = sirv(process.cwd(), { + dev: true, + etag: true, + setHeaders: setContentTypeHeaders, + }); app.use((req, res, next) => { if (!req.url) { @@ -82,10 +79,13 @@ export async function useStatics(app: Server, options: Options): Promise { return next(); } - for (const {targetEndpoint, staticPath} of statics) { + for (const { targetEndpoint, staticPath } of statics) { if (pathname.startsWith(targetEndpoint)) { // TODO (43081j): similar as above, this might be doable in a cleaner way - const newPath = path.relative(process.cwd(), path.resolve(staticPath, './' + pathname.slice(targetEndpoint.length))); + const newPath = path.relative( + process.cwd(), + path.resolve(staticPath, './' + pathname.slice(targetEndpoint.length)) + ); url.pathname = newPath; req.url = url.href.slice(url.origin.length); serve(req, res, next); From ffa4f0b90896b54b33f04addd13d5d901543ee2a Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Tue, 7 May 2024 21:13:41 +0100 Subject: [PATCH 04/41] test: fix stories-json test assertions --- .../src/utils/stories-json.test.ts | 20 +++++++++---------- .../lib/core-server/src/utils/stories-json.ts | 6 ++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/code/lib/core-server/src/utils/stories-json.test.ts b/code/lib/core-server/src/utils/stories-json.test.ts index 0700cebb11fb..d2370fdcd052 100644 --- a/code/lib/core-server/src/utils/stories-json.test.ts +++ b/code/lib/core-server/src/utils/stories-json.test.ts @@ -56,23 +56,23 @@ const getInitializedStoryIndexGenerator = async ( describe('useStoriesJson', () => { const use = vi.fn(); const app: Server = { use } as any; - const send = vi.fn(); + const end = vi.fn(); const write = vi.fn(); const response: Response = { header: vi.fn(), - send, + send: vi.fn(), status: vi.fn(), setHeader: vi.fn(), flushHeaders: vi.fn(), write, flush: vi.fn(), - end: vi.fn(), + end, on: vi.fn(), } as any; beforeEach(async () => { use.mockClear(); - send.mockClear(); + end.mockClear(); write.mockClear(); vi.mocked(debounce).mockImplementation((cb) => cb as any); Watchpack.mockClear(); @@ -102,8 +102,8 @@ describe('useStoriesJson', () => { await route(request, response); console.timeEnd('route'); - expect(send).toHaveBeenCalledTimes(1); - expect(JSON.parse(send.mock.calls[0][0])).toMatchInlineSnapshot(` + expect(end).toHaveBeenCalledTimes(1); + expect(JSON.parse(end.mock.calls[0][0])).toMatchInlineSnapshot(` { "entries": { "a--metaof": { @@ -283,14 +283,14 @@ describe('useStoriesJson', () => { const route = use.mock.calls[0][1]; const firstPromise = route(request, response); - const secondResponse = { ...response, send: vi.fn(), status: vi.fn() }; + const secondResponse = { ...response, end: vi.fn(), status: vi.fn() }; const secondPromise = route(request, secondResponse); await Promise.all([firstPromise, secondPromise]); - expect(send).toHaveBeenCalledTimes(1); + expect(end).toHaveBeenCalledTimes(1); expect(response.status).not.toEqual(500); - expect(secondResponse.send).toHaveBeenCalledTimes(1); + expect(secondResponse.end).toHaveBeenCalledTimes(1); expect(secondResponse.status).not.toEqual(500); }); }); @@ -298,7 +298,7 @@ describe('useStoriesJson', () => { describe('SSE endpoint', () => { beforeEach(() => { use.mockClear(); - send.mockClear(); + end.mockClear(); }); it('sends invalidate events', async () => { diff --git a/code/lib/core-server/src/utils/stories-json.ts b/code/lib/core-server/src/utils/stories-json.ts index 4bbaaed14fbc..87cef6342dc2 100644 --- a/code/lib/core-server/src/utils/stories-json.ts +++ b/code/lib/core-server/src/utils/stories-json.ts @@ -61,12 +61,10 @@ export function useStoriesJson({ const generator = await initializedStoryIndexGenerator; const index = await generator.getIndex(); res.setHeader('Content-Type', 'application/json'); - res.write(JSON.stringify(index)); - res.end(); + res.end(JSON.stringify(index)); } catch (err) { res.statusCode = 500; - res.write(err instanceof Error ? err.toString() : String(err)); - res.end(); + res.end(err instanceof Error ? err.toString() : String(err)); } }); } From b92d83b7fcd68140d662382ba8538fd9a3e1441d Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Tue, 7 May 2024 21:41:27 +0100 Subject: [PATCH 05/41] fix(core-server): remove unused import --- code/lib/core-server/src/utils/server-statics.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/lib/core-server/src/utils/server-statics.ts b/code/lib/core-server/src/utils/server-statics.ts index bc664d13132f..f63d88cab906 100644 --- a/code/lib/core-server/src/utils/server-statics.ts +++ b/code/lib/core-server/src/utils/server-statics.ts @@ -2,7 +2,7 @@ import { logger } from '@storybook/node-logger'; import type { Options } from '@storybook/types'; import { getDirectoryFromWorkingDir } from '@storybook/core-common'; import chalk from 'chalk'; -import type { NextHandleFunction, Server } from 'connect'; +import type { Server } from 'connect'; import { pathExists } from 'fs-extra'; import path, { basename, isAbsolute } from 'path'; import sirv from 'sirv'; From 29402760543fdb2ab469e13c8b65efea1ff04117 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 1 Jul 2024 17:04:42 +0200 Subject: [PATCH 06/41] update branch with CPC work --- code/builders/builder-vite/package.json | 1 + code/builders/builder-webpack5/src/index.ts | 2 +- code/core/package.json | 2 +- code/core/src/core-server/dev-server.ts | 2 +- .../core/src/core-server/utils/doTelemetry.ts | 2 +- .../utils/get-caching-middleware.ts | 2 +- .../utils/getAccessControlMiddleware.ts | 2 +- .../utils/getStoryIndexGenerator.ts | 2 +- code/core/src/core-server/utils/metadata.ts | 2 +- .../src/core-server/utils/server-connect.ts | 88 +++++++++++++++++++ .../core/src/core-server/utils/server-init.ts | 2 +- .../src/core-server/utils/server-statics.ts | 2 +- .../core-server/utils/stories-json.test.ts | 2 +- .../src/core-server/utils/stories-json.ts | 2 +- code/core/src/types/modules/core-common.ts | 2 +- code/yarn.lock | 43 ++++++++- 16 files changed, 142 insertions(+), 16 deletions(-) create mode 100644 code/core/src/core-server/utils/server-connect.ts diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index b88932fd3551..cf6ebc3beed8 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -46,6 +46,7 @@ "@storybook/csf-plugin": "workspace:*", "@types/find-cache-dir": "^3.2.1", "browser-assert": "^1.2.1", + "connect": "^3.7.0", "es-module-lexer": "^1.5.0", "find-cache-dir": "^3.0.0", "fs-extra": "^11.1.0", diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 599484a4ff67..deb5405d1a46 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -13,7 +13,7 @@ import { WebpackCompilationError, WebpackInvocationError, WebpackMissingStatsError, -} from 'storybook/internal/core-events'; +} from 'storybook/internal/server-errors'; import sirv from 'sirv'; import prettyTime from 'pretty-hrtime'; diff --git a/code/core/package.json b/code/core/package.json index 1f6b9cc92fad..839e867f9aac 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -315,6 +315,7 @@ "cli-table3": "^0.6.1", "comment-parser": "^1.4.1", "compression": "^1.7.4", + "connect": "^3.7.0", "copy-to-clipboard": "^3.3.1", "cross-spawn": "^7.0.3", "css": "^3.0.0", @@ -328,7 +329,6 @@ "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0", "esbuild-plugin-alias": "^0.2.1", "execa": "^8.0.1", - "express": "^4.19.2", "fd-package-json": "^1.2.0", "fetch-retry": "^6.0.0", "file-system-cache": "^2.4.4", diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 3b06865358cb..a83e551b650e 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -20,7 +20,7 @@ import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; import { doTelemetry } from './utils/doTelemetry'; import { getAccessControlMiddleware } from './utils/getAccessControlMiddleware'; import { getCachingMiddleware } from './utils/get-caching-middleware'; -import connect, { type NextHandleFunction } from 'connect'; +import { type NextHandleFunction, connect } from './utils/server-connect'; export async function storybookDevServer(options: Options) { const app = connect(); diff --git a/code/core/src/core-server/utils/doTelemetry.ts b/code/core/src/core-server/utils/doTelemetry.ts index 288cfd0268c8..5f14d50392b6 100644 --- a/code/core/src/core-server/utils/doTelemetry.ts +++ b/code/core/src/core-server/utils/doTelemetry.ts @@ -6,7 +6,7 @@ import type { StoryIndexGenerator } from './StoryIndexGenerator'; import { summarizeIndex } from './summarizeIndex'; import { versionStatus } from './versionStatus'; import { sendTelemetryError } from '../withTelemetry'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; export async function doTelemetry( app: Server, diff --git a/code/core/src/core-server/utils/get-caching-middleware.ts b/code/core/src/core-server/utils/get-caching-middleware.ts index fe7554def150..1489117ba884 100644 --- a/code/core/src/core-server/utils/get-caching-middleware.ts +++ b/code/core/src/core-server/utils/get-caching-middleware.ts @@ -1,4 +1,4 @@ -import type { NextHandleFunction } from 'connect'; +import type { NextHandleFunction } from './server-connect'; export function getCachingMiddleware(): NextHandleFunction { return (req, res, next) => { diff --git a/code/core/src/core-server/utils/getAccessControlMiddleware.ts b/code/core/src/core-server/utils/getAccessControlMiddleware.ts index 23e0caf276bd..f6d2769d6939 100644 --- a/code/core/src/core-server/utils/getAccessControlMiddleware.ts +++ b/code/core/src/core-server/utils/getAccessControlMiddleware.ts @@ -1,4 +1,4 @@ -import type { NextHandleFunction } from 'connect'; +import type { NextHandleFunction } from './server-connect'; export function getAccessControlMiddleware(crossOriginIsolated: boolean): NextHandleFunction { return (req, res, next) => { diff --git a/code/core/src/core-server/utils/getStoryIndexGenerator.ts b/code/core/src/core-server/utils/getStoryIndexGenerator.ts index fd76cf00875f..f67487c60ab4 100644 --- a/code/core/src/core-server/utils/getStoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/getStoryIndexGenerator.ts @@ -3,7 +3,7 @@ import { normalizeStories } from '@storybook/core/common'; import { useStoriesJson } from './stories-json'; import type { ServerChannel } from './get-server-channel'; import { StoryIndexGenerator } from './StoryIndexGenerator'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; export async function getStoryIndexGenerator( app: Server, diff --git a/code/core/src/core-server/utils/metadata.ts b/code/core/src/core-server/utils/metadata.ts index bad118d9920f..9519ddc503f8 100644 --- a/code/core/src/core-server/utils/metadata.ts +++ b/code/core/src/core-server/utils/metadata.ts @@ -1,5 +1,5 @@ import { writeJSON } from 'fs-extra'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; import { getStorybookMetadata } from '@storybook/core/telemetry'; export async function extractStorybookMetadata(outputFile: string, configDir: string) { diff --git a/code/core/src/core-server/utils/server-connect.ts b/code/core/src/core-server/utils/server-connect.ts new file mode 100644 index 000000000000..73dcb7494e0c --- /dev/null +++ b/code/core/src/core-server/utils/server-connect.ts @@ -0,0 +1,88 @@ +import * as http from 'http'; + +import connect from 'connect'; + +export { connect }; + +export type ServerHandle = HandleFunction | http.Server; + +export class IncomingMessage extends http.IncomingMessage { + originalUrl?: http.IncomingMessage['url'] | undefined; +} + +type NextFunction = (err?: any) => void; + +export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void; +export type NextHandleFunction = ( + req: IncomingMessage, + res: http.ServerResponse, + next: NextFunction +) => void; +export type ErrorHandleFunction = ( + err: any, + req: IncomingMessage, + res: http.ServerResponse, + next: NextFunction +) => void; +export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction; + +export interface ServerStackItem { + route: string; + handle: ServerHandle; +} + +export interface Server extends NodeJS.EventEmitter { + (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void; + + route: string; + stack: ServerStackItem[]; + + /** + * Utilize the given middleware `handle` to the given `route`, + * defaulting to _/_. This "route" is the mount-point for the + * middleware, when given a value other than _/_ the middleware + * is only effective when that segment is present in the request's + * pathname. + * + * For example if we were to mount a function at _/admin_, it would + * be invoked on _/admin_, and _/admin/settings_, however it would + * not be invoked for _/_, or _/posts_. + */ + use(fn: NextHandleFunction): Server; + use(fn: HandleFunction): Server; + use(route: string, fn: NextHandleFunction): Server; + use(route: string, fn: HandleFunction): Server; + + /** + * Handle server requests, punting them down + * the middleware stack. + */ + handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void; + + /** + * Listen for connections. + * + * This method takes the same arguments + * as node's `http.Server#listen()`. + * + * HTTP and HTTPS: + * + * If you run your application both as HTTP + * and HTTPS you may wrap them individually, + * since your Connect "server" is really just + * a JavaScript `Function`. + * + * var connect = require('connect') + * , http = require('http') + * , https = require('https'); + * + * var app = connect(); + * + * http.createServer(app).listen(80); + * https.createServer(options, app).listen(443); + */ + listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server; + listen(port: number, hostname?: string, callback?: Function): http.Server; + listen(path: string, callback?: Function): http.Server; + listen(handle: any, listeningListener?: Function): http.Server; +} diff --git a/code/core/src/core-server/utils/server-init.ts b/code/core/src/core-server/utils/server-init.ts index 76623c44659f..3b8b7d844ec4 100644 --- a/code/core/src/core-server/utils/server-init.ts +++ b/code/core/src/core-server/utils/server-init.ts @@ -1,5 +1,5 @@ import { logger } from '@storybook/core/node-logger'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; import { readFile } from 'fs-extra'; import http from 'http'; import https from 'https'; diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index b22eacd3a1d4..4f478f0633f9 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -2,7 +2,7 @@ import { logger } from '@storybook/core/node-logger'; import type { Options } from '@storybook/core/types'; import { getDirectoryFromWorkingDir } from '@storybook/core/common'; import chalk from 'chalk'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; import { pathExists } from 'fs-extra'; import { basename, isAbsolute, normalize, posix, relative, resolve, sep, win32 } from 'node:path'; import sirv from 'sirv'; diff --git a/code/core/src/core-server/utils/stories-json.test.ts b/code/core/src/core-server/utils/stories-json.test.ts index 9f2e327ab04e..0247a8ca39de 100644 --- a/code/core/src/core-server/utils/stories-json.test.ts +++ b/code/core/src/core-server/utils/stories-json.test.ts @@ -1,6 +1,6 @@ import { describe, beforeEach, it, expect, vi } from 'vitest'; -import type { Server } from 'connect'; +import type { Server } from './server-connect'; import Watchpack from 'watchpack'; import path from 'node:path'; import debounce from 'lodash/debounce.js'; diff --git a/code/core/src/core-server/utils/stories-json.ts b/code/core/src/core-server/utils/stories-json.ts index 467bba0f4d77..9c7a3efd1f3a 100644 --- a/code/core/src/core-server/utils/stories-json.ts +++ b/code/core/src/core-server/utils/stories-json.ts @@ -1,4 +1,4 @@ -import type { Server } from 'connect'; +import type { Server } from './server-connect'; import { basename } from 'node:path'; import { writeJSON } from 'fs-extra'; diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index 35d1a245491b..922dab66b469 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { FileSystemCache } from 'file-system-cache'; import type { Options as TelejsonOptions } from 'telejson'; -import type { Server } from 'connect'; +import type { Server } from '../../core-server/utils/server-connect'; import type { Server as HttpServer } from 'http'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; diff --git a/code/yarn.lock b/code/yarn.lock index 6087e5c776a9..ee9a81f4b22d 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -5545,6 +5545,7 @@ __metadata: "@types/find-cache-dir": "npm:^3.2.1" "@types/node": "npm:^18.0.0" browser-assert: "npm:^1.2.1" + connect: "npm:^3.7.0" es-module-lexer: "npm:^1.5.0" find-cache-dir: "npm:^3.0.0" fs-extra: "npm:^11.1.0" @@ -5787,6 +5788,7 @@ __metadata: cli-table3: "npm:^0.6.1" comment-parser: "npm:^1.4.1" compression: "npm:^1.7.4" + connect: "npm:^3.7.0" copy-to-clipboard: "npm:^3.3.1" cross-spawn: "npm:^7.0.3" css: "npm:^3.0.0" @@ -5801,7 +5803,6 @@ __metadata: esbuild-plugin-alias: "npm:^0.2.1" esbuild-register: "npm:^3.5.0" execa: "npm:^8.0.1" - express: "npm:^4.19.2" fd-package-json: "npm:^1.2.0" fetch-retry: "npm:^6.0.0" file-system-cache: "npm:^2.4.4" @@ -11852,6 +11853,18 @@ __metadata: languageName: node linkType: hard +"connect@npm:^3.7.0": + version: 3.7.0 + resolution: "connect@npm:3.7.0" + dependencies: + debug: "npm:2.6.9" + finalhandler: "npm:1.1.2" + parseurl: "npm:~1.3.3" + utils-merge: "npm:1.0.1" + checksum: 10c0/f120c6116bb16a0a7d2703c0b4a0cd7ed787dc5ec91978097bf62aa967289020a9f41a9cd3c3276a7b92aaa36f382d2cd35fed7138fd466a55c8e9fdbed11ca8 + languageName: node + linkType: hard + "console-browserify@npm:^1.2.0": version: 1.2.0 resolution: "console-browserify@npm:1.2.0" @@ -14506,7 +14519,7 @@ __metadata: languageName: node linkType: hard -"express@npm:^4.17.3, express@npm:^4.19.2": +"express@npm:^4.17.3": version: 4.19.2 resolution: "express@npm:4.19.2" dependencies: @@ -14821,6 +14834,21 @@ __metadata: languageName: node linkType: hard +"finalhandler@npm:1.1.2": + version: 1.1.2 + resolution: "finalhandler@npm:1.1.2" + dependencies: + debug: "npm:2.6.9" + encodeurl: "npm:~1.0.2" + escape-html: "npm:~1.0.3" + on-finished: "npm:~2.3.0" + parseurl: "npm:~1.3.3" + statuses: "npm:~1.5.0" + unpipe: "npm:~1.0.0" + checksum: 10c0/6a96e1f5caab085628c11d9fdceb82ba608d5e426c6913d4d918409baa271037a47f28fbba73279e8ad614f0b8fa71ea791d265e408d760793829edd8c2f4584 + languageName: node + linkType: hard + "finalhandler@npm:1.2.0": version: 1.2.0 resolution: "finalhandler@npm:1.2.0" @@ -21384,6 +21412,15 @@ __metadata: languageName: node linkType: hard +"on-finished@npm:~2.3.0": + version: 2.3.0 + resolution: "on-finished@npm:2.3.0" + dependencies: + ee-first: "npm:1.1.1" + checksum: 10c0/c904f9e518b11941eb60279a3cbfaf1289bd0001f600a950255b1dede9fe3df8cd74f38483550b3bb9485165166acb5db500c3b4c4337aec2815c88c96fcc2ea + languageName: node + linkType: hard + "on-headers@npm:~1.0.2": version: 1.0.2 resolution: "on-headers@npm:1.0.2" @@ -25603,7 +25640,7 @@ __metadata: languageName: node linkType: hard -"statuses@npm:>= 1.4.0 < 2": +"statuses@npm:>= 1.4.0 < 2, statuses@npm:~1.5.0": version: 1.5.0 resolution: "statuses@npm:1.5.0" checksum: 10c0/e433900956357b3efd79b1c547da4d291799ac836960c016d10a98f6a810b1b5c0dcc13b5a7aa609a58239b5190e1ea176ad9221c2157d2fd1c747393e6b2940 From 88fbc1b229f6a369c583785b793ca9264e842468 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Thu, 4 Jul 2024 08:56:49 +0200 Subject: [PATCH 07/41] remove express types --- code/core/package.json | 1 - 1 file changed, 1 deletion(-) diff --git a/code/core/package.json b/code/core/package.json index 0ce5a8c2ac27..8a4ec79f08ad 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -246,7 +246,6 @@ }, "dependencies": { "@storybook/csf": "0.1.11", - "@types/express": "^4.17.21", "@types/node": "^18.0.0", "browser-assert": "^1.2.1", "esbuild": "^0.18.0 || ^0.19.0 || ^0.20.0 || ^0.21.0", From 841777d040b3116e06ce265de6e5f41857cd4cd5 Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Fri, 27 Sep 2024 18:50:40 +0700 Subject: [PATCH 08/41] feat: migrate from express to polka Migrates from express to polka 1.x. --- code/builders/builder-vite/package.json | 2 +- code/builders/builder-vite/src/index.ts | 14 +-- code/builders/builder-webpack5/src/index.ts | 10 +- code/core/package.json | 5 +- code/core/src/core-server/dev-server.ts | 14 +-- .../core/src/core-server/utils/doTelemetry.ts | 4 +- .../utils/get-caching-middleware.ts | 4 +- .../utils/getAccessControlMiddleware.ts | 4 +- .../utils/getStoryIndexGenerator.ts | 5 +- code/core/src/core-server/utils/metadata.ts | 4 +- .../src/core-server/utils/server-connect.ts | 87 ----------------- .../core/src/core-server/utils/server-init.ts | 21 ++--- .../src/core-server/utils/server-statics.ts | 5 +- .../core-server/utils/stories-json.test.ts | 4 +- .../src/core-server/utils/stories-json.ts | 4 +- code/core/src/types/modules/core-common.ts | 4 +- code/yarn.lock | 94 +++++++++---------- 17 files changed, 86 insertions(+), 199 deletions(-) delete mode 100644 code/core/src/core-server/utils/server-connect.ts diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index 3c519291210f..17a5a9ae5d15 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -46,10 +46,10 @@ "@storybook/csf-plugin": "workspace:*", "@types/find-cache-dir": "^3.2.1", "browser-assert": "^1.2.1", - "connect": "^3.7.0", "es-module-lexer": "^1.5.0", "find-cache-dir": "^3.0.0", "magic-string": "^0.30.0", + "polka": "^1.0.0-next.28", "sirv": "^2.0.4", "ts-dedent": "^2.0.0" }, diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index 56422068e2be..3aa99e434977 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -5,7 +5,7 @@ import { join, parse } from 'node:path'; import { NoStatsForViteDevError } from 'storybook/internal/server-errors'; import type { Options } from 'storybook/internal/types'; -import type { NextHandleFunction } from 'connect'; +import type Polka from 'polka'; import sirv from 'sirv'; import { corePath } from 'storybook/core-path'; import type { ViteDevServer } from 'vite'; @@ -13,13 +13,14 @@ import type { ViteDevServer } from 'vite'; import { build as viteBuild } from './build'; import { transformIframeHtml } from './transform-iframe-html'; import type { ViteBuilder } from './types'; +import { createViteServer } from './vite-server'; export { withoutVitePlugins } from './utils/without-vite-plugins'; export { hasVitePlugins } from './utils/has-vite-plugins'; export * from './types'; -function iframeMiddleware(options: Options, server: ViteDevServer): NextHandleFunction { +function iframeMiddleware(options: Options, server: ViteDevServer): Polka.Middleware { return async (req, res, next) => { if (!req.url || !req.url.match(/^\/iframe\.html($|\?)/)) { next(); @@ -68,14 +69,7 @@ export const start: ViteBuilder['start'] = async ({ immutable: true, }); - app.use('/sb-preview', (req, res, next) => { - if (!req.url || req.url === '/') { - next(); - return; - } - - servePreview(req, res, next); - }); + app.use('/sb-preview', servePreview); app.use(iframeMiddleware(options as Options, server)); app.use(server.middlewares); diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 97843e519ac1..cd7430cf7685 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -187,15 +187,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ immutable: true, }); - app.use('/sb-preview', (req, res, next) => { - if (!req.url || req.url === '/') { - next(); - return; - } - - servePreview(req, res, next); - }); - + app.use('/sb-preview', servePreview); app.use(compilation); app.use(webpackHotMiddleware(compiler, { log: false })); diff --git a/code/core/package.json b/code/core/package.json index f987bce728ac..2ffa60cb7f42 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -305,6 +305,7 @@ "@emotion/use-insertion-effect-with-fallbacks": "^1.0.1", "@fal-works/esbuild-plugin-global-externals": "^2.1.2", "@ndelangen/get-tarball": "^3.0.7", + "@polka/compression": "^1.0.0-next.28", "@popperjs/core": "^2.6.0", "@radix-ui/react-dialog": "^1.0.5", "@radix-ui/react-scroll-area": "1.2.0-rc.7", @@ -314,7 +315,6 @@ "@storybook/icons": "^1.2.10", "@tanstack/react-virtual": "^3.3.0", "@testing-library/react": "^14.0.0", - "@types/compression": "^1.7.0", "@types/cross-spawn": "^6.0.2", "@types/detect-port": "^1.3.0", "@types/diff": "^5.0.9", @@ -346,8 +346,6 @@ "cli-table3": "^0.6.1", "commander": "^12.1.0", "comment-parser": "^1.4.1", - "compression": "^1.7.4", - "connect": "^3.7.0", "copy-to-clipboard": "^3.3.1", "cross-spawn": "^7.0.3", "css": "^3.0.0", @@ -386,6 +384,7 @@ "open": "^8.4.0", "picomatch": "^2.3.0", "polished": "^4.2.2", + "polka": "^1.0.0-next.28", "prettier": "^3.2.5", "pretty-hrtime": "^1.0.3", "prompts": "^2.4.0", diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 2a4ab7ac262e..0653ceba93d0 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -1,12 +1,13 @@ +import { logConfig } from '@storybook/core/common'; import type { Options } from '@storybook/core/types'; import { logger } from '@storybook/core/node-logger'; import { MissingBuilderError } from '@storybook/core/server-errors'; -import compression from 'compression'; +import compression from '@polka/compression'; +import polka from 'polka'; import invariant from 'tiny-invariant'; -import { logConfig } from '../common'; import type { StoryIndexGenerator } from './utils/StoryIndexGenerator'; import { doTelemetry } from './utils/doTelemetry'; import { getManagerBuilder, getPreviewBuilder } from './utils/get-builders'; @@ -17,19 +18,18 @@ import { getStoryIndexGenerator } from './utils/getStoryIndexGenerator'; import { getMiddleware } from './utils/middleware'; import { openInBrowser } from './utils/open-in-browser'; import { getServerAddresses } from './utils/server-address'; -import { type NextHandleFunction, connect } from './utils/server-connect'; import { getServer } from './utils/server-init'; import { useStatics } from './utils/server-statics'; export async function storybookDevServer(options: Options) { - const app = connect(); - const [server, features, core] = await Promise.all([ - getServer(app, options), + getServer(options), options.presets.apply('features'), options.presets.apply('core'), ]); + const app = polka({ server }); + const serverChannel = await options.presets.apply( 'experimental_serverChannel', getServerChannel(server) @@ -43,7 +43,7 @@ export async function storybookDevServer(options: Options) { return undefined; }); - app.use(compression({ level: 1 }) as NextHandleFunction); + app.use(compression({ level: 1 })); if (typeof options.extendServer === 'function') { options.extendServer(server); diff --git a/code/core/src/core-server/utils/doTelemetry.ts b/code/core/src/core-server/utils/doTelemetry.ts index d7db53f9cab6..0e9b48b8c8f5 100644 --- a/code/core/src/core-server/utils/doTelemetry.ts +++ b/code/core/src/core-server/utils/doTelemetry.ts @@ -1,17 +1,17 @@ import { getPrecedingUpgrade, telemetry } from '@storybook/core/telemetry'; import type { CoreConfig, Options } from '@storybook/core/types'; +import type Polka from 'polka'; import invariant from 'tiny-invariant'; import { sendTelemetryError } from '../withTelemetry'; import type { StoryIndexGenerator } from './StoryIndexGenerator'; import { useStorybookMetadata } from './metadata'; -import type { Server } from './server-connect'; import { summarizeIndex } from './summarizeIndex'; import { versionStatus } from './versionStatus'; export async function doTelemetry( - app: Server, + app: Polka.Polka, core: CoreConfig, initializedStoryIndexGenerator: Promise, options: Options diff --git a/code/core/src/core-server/utils/get-caching-middleware.ts b/code/core/src/core-server/utils/get-caching-middleware.ts index 1489117ba884..dd4d5c747156 100644 --- a/code/core/src/core-server/utils/get-caching-middleware.ts +++ b/code/core/src/core-server/utils/get-caching-middleware.ts @@ -1,6 +1,6 @@ -import type { NextHandleFunction } from './server-connect'; +import type Polka from 'polka'; -export function getCachingMiddleware(): NextHandleFunction { +export function getCachingMiddleware(): Polka.Middleware { return (req, res, next) => { res.setHeader('Cache-Control', 'no-store'); next(); diff --git a/code/core/src/core-server/utils/getAccessControlMiddleware.ts b/code/core/src/core-server/utils/getAccessControlMiddleware.ts index f6d2769d6939..b44046d290bf 100644 --- a/code/core/src/core-server/utils/getAccessControlMiddleware.ts +++ b/code/core/src/core-server/utils/getAccessControlMiddleware.ts @@ -1,6 +1,6 @@ -import type { NextHandleFunction } from './server-connect'; +import type Polka from 'polka'; -export function getAccessControlMiddleware(crossOriginIsolated: boolean): NextHandleFunction { +export function getAccessControlMiddleware(crossOriginIsolated: boolean): Polka.Middleware { return (req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); diff --git a/code/core/src/core-server/utils/getStoryIndexGenerator.ts b/code/core/src/core-server/utils/getStoryIndexGenerator.ts index 11555bf7306f..d6b1d7d1058e 100644 --- a/code/core/src/core-server/utils/getStoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/getStoryIndexGenerator.ts @@ -1,13 +1,14 @@ import { normalizeStories } from '@storybook/core/common'; import type { DocsOptions, Options } from '@storybook/core/types'; +import type Polka from 'polka'; + import { StoryIndexGenerator } from './StoryIndexGenerator'; import type { ServerChannel } from './get-server-channel'; -import type { Server } from './server-connect'; import { useStoriesJson } from './stories-json'; export async function getStoryIndexGenerator( - app: Server, + app: Polka.Polka, features: { argTypeTargetsV7?: boolean; }, diff --git a/code/core/src/core-server/utils/metadata.ts b/code/core/src/core-server/utils/metadata.ts index 16cea6042aaf..a9a2ebb337ba 100644 --- a/code/core/src/core-server/utils/metadata.ts +++ b/code/core/src/core-server/utils/metadata.ts @@ -2,7 +2,7 @@ import { writeFile } from 'node:fs/promises'; import { getStorybookMetadata } from '@storybook/core/telemetry'; -import type { Server } from './server-connect'; +import type Polka from 'polka'; export async function extractStorybookMetadata(outputFile: string, configDir: string) { const storybookMetadata = await getStorybookMetadata(configDir); @@ -10,7 +10,7 @@ export async function extractStorybookMetadata(outputFile: string, configDir: st await writeFile(outputFile, JSON.stringify(storybookMetadata)); } -export function useStorybookMetadata(app: Server, configDir?: string) { +export function useStorybookMetadata(app: Polka.Polka, configDir?: string) { app.use('/project.json', async (req, res) => { const storybookMetadata = await getStorybookMetadata(configDir); res.setHeader('Content-Type', 'application/json'); diff --git a/code/core/src/core-server/utils/server-connect.ts b/code/core/src/core-server/utils/server-connect.ts deleted file mode 100644 index 7bb43409b65b..000000000000 --- a/code/core/src/core-server/utils/server-connect.ts +++ /dev/null @@ -1,87 +0,0 @@ -import connect from 'connect'; -import * as http from 'http'; - -export { connect }; - -export type ServerHandle = HandleFunction | http.Server; - -export class IncomingMessage extends http.IncomingMessage { - originalUrl?: http.IncomingMessage['url'] | undefined; -} - -type NextFunction = (err?: any) => void; - -export type SimpleHandleFunction = (req: IncomingMessage, res: http.ServerResponse) => void; -export type NextHandleFunction = ( - req: IncomingMessage, - res: http.ServerResponse, - next: NextFunction -) => void; -export type ErrorHandleFunction = ( - err: any, - req: IncomingMessage, - res: http.ServerResponse, - next: NextFunction -) => void; -export type HandleFunction = SimpleHandleFunction | NextHandleFunction | ErrorHandleFunction; - -export interface ServerStackItem { - route: string; - handle: ServerHandle; -} - -export interface Server extends NodeJS.EventEmitter { - (req: http.IncomingMessage, res: http.ServerResponse, next?: Function): void; - - route: string; - stack: ServerStackItem[]; - - /** - * Utilize the given middleware `handle` to the given `route`, - * defaulting to _/_. This "route" is the mount-point for the - * middleware, when given a value other than _/_ the middleware - * is only effective when that segment is present in the request's - * pathname. - * - * For example if we were to mount a function at _/admin_, it would - * be invoked on _/admin_, and _/admin/settings_, however it would - * not be invoked for _/_, or _/posts_. - */ - use(fn: NextHandleFunction): Server; - use(fn: HandleFunction): Server; - use(route: string, fn: NextHandleFunction): Server; - use(route: string, fn: HandleFunction): Server; - - /** - * Handle server requests, punting them down - * the middleware stack. - */ - handle(req: http.IncomingMessage, res: http.ServerResponse, next: Function): void; - - /** - * Listen for connections. - * - * This method takes the same arguments - * as node's `http.Server#listen()`. - * - * HTTP and HTTPS: - * - * If you run your application both as HTTP - * and HTTPS you may wrap them individually, - * since your Connect "server" is really just - * a JavaScript `Function`. - * - * var connect = require('connect') - * , http = require('http') - * , https = require('https'); - * - * var app = connect(); - * - * http.createServer(app).listen(80); - * https.createServer(options, app).listen(443); - */ - listen(port: number, hostname?: string, backlog?: number, callback?: Function): http.Server; - listen(port: number, hostname?: string, callback?: Function): http.Server; - listen(path: string, callback?: Function): http.Server; - listen(handle: any, listeningListener?: Function): http.Server; -} diff --git a/code/core/src/core-server/utils/server-init.ts b/code/core/src/core-server/utils/server-init.ts index 53d6b9c5e97b..d06c3421e7bc 100644 --- a/code/core/src/core-server/utils/server-init.ts +++ b/code/core/src/core-server/utils/server-init.ts @@ -5,19 +5,14 @@ import { logger } from '@storybook/core/node-logger'; import http from 'http'; import https from 'https'; -import type { Server } from './server-connect'; - -export async function getServer( - app: Server, - options: { - https?: boolean; - sslCert?: string; - sslKey?: string; - sslCa?: string[]; - } -) { +export async function getServer(options: { + https?: boolean; + sslCert?: string; + sslKey?: string; + sslCa?: string[]; +}) { if (!options.https) { - return http.createServer(app); + return http.createServer(); } if (!options.sslCert) { @@ -36,5 +31,5 @@ export async function getServer( key: await readFile(options.sslKey, { encoding: 'utf8' }), }; - return https.createServer(sslOptions, app); + return https.createServer(sslOptions); } diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index 99d4a10ee282..6d1ffd59f041 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -8,11 +8,10 @@ import { logger } from '@storybook/core/node-logger'; import chalk from 'chalk'; import type { ServerResponse } from 'http'; +import type Polka from 'polka'; import sirv from 'sirv'; import { dedent } from 'ts-dedent'; -import type { Server } from './server-connect'; - // TODO (43081j): maybe get this from somewhere? const contentTypes: Record = { css: 'text/css', @@ -27,7 +26,7 @@ const setContentTypeHeaders = (res: ServerResponse, pathname: string) => { } }; -export async function useStatics(app: Server, options: Options): Promise { +export async function useStatics(app: Polka.Polka, options: Options): Promise { const staticDirs = (await options.presets.apply('staticDirs')) ?? []; const faviconPath = await options.presets.apply('favicon'); diff --git a/code/core/src/core-server/utils/stories-json.test.ts b/code/core/src/core-server/utils/stories-json.test.ts index 3ca7e213df48..cc11d43ba5a3 100644 --- a/code/core/src/core-server/utils/stories-json.test.ts +++ b/code/core/src/core-server/utils/stories-json.test.ts @@ -8,13 +8,13 @@ import { STORY_INDEX_INVALIDATED } from '@storybook/core/core-events'; import { debounce } from 'es-toolkit/compat'; import type { Request, Response } from 'express'; +import type Polka from 'polka'; import Watchpack from 'watchpack'; import { csfIndexer } from '../presets/common-preset'; import type { StoryIndexGeneratorOptions } from './StoryIndexGenerator'; import { StoryIndexGenerator } from './StoryIndexGenerator'; import type { ServerChannel } from './get-server-channel'; -import type { Server } from './server-connect'; import { DEBOUNCE, useStoriesJson } from './stories-json'; vi.mock('watchpack'); @@ -59,7 +59,7 @@ const getInitializedStoryIndexGenerator = async ( describe('useStoriesJson', () => { const use = vi.fn(); - const app: Server = { use } as any; + const app: Polka.Polka = { use } as any; const end = vi.fn(); const write = vi.fn(); const response: Response = { diff --git a/code/core/src/core-server/utils/stories-json.ts b/code/core/src/core-server/utils/stories-json.ts index 2d5b50ead6a1..a33e12eb0393 100644 --- a/code/core/src/core-server/utils/stories-json.ts +++ b/code/core/src/core-server/utils/stories-json.ts @@ -6,10 +6,10 @@ import type { NormalizedStoriesSpecifier, StoryIndex } from '@storybook/core/typ import { STORY_INDEX_INVALIDATED } from '@storybook/core/core-events'; import { debounce } from 'es-toolkit/compat'; +import type Polka from 'polka'; import type { StoryIndexGenerator } from './StoryIndexGenerator'; import type { ServerChannel } from './get-server-channel'; -import type { Server } from './server-connect'; import { watchStorySpecifiers } from './watch-story-specifiers'; import { watchConfig } from './watchConfig'; @@ -33,7 +33,7 @@ export function useStoriesJson({ serverChannel, normalizedStories, }: { - app: Server; + app: Polka.Polka; initializedStoryIndexGenerator: Promise; serverChannel: ServerChannel; workingDir?: string; diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index 3eb0a5a9d798..d5dc8baf0bee 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -2,10 +2,10 @@ import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core import type { Server as HttpServer } from 'http'; +import type Polka from 'polka'; import type { Options as TelejsonOptions } from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; -import type { Server } from '../../core-server/utils/server-connect'; import type { Indexer, StoriesEntry } from './indexer'; /** āš ļø This file contains internal WIP types they MUST NOT be exported outside this package for now! */ @@ -216,7 +216,7 @@ export interface Builder { start: (args: { options: Options; startTime: ReturnType; - app: Server; + app: Polka.Polka; server: HttpServer; channel: ServerChannel; }) => Promise= 1.4.0 < 2, statuses@npm:~1.5.0": +"statuses@npm:>= 1.4.0 < 2": version: 1.5.0 resolution: "statuses@npm:1.5.0" checksum: 10c0/e433900956357b3efd79b1c547da4d291799ac836960c016d10a98f6a810b1b5c0dcc13b5a7aa609a58239b5190e1ea176ad9221c2157d2fd1c747393e6b2940 @@ -27626,6 +27611,15 @@ __metadata: languageName: node linkType: hard +"trouter@npm:^4.0.0": + version: 4.0.0 + resolution: "trouter@npm:4.0.0" + dependencies: + regexparam: "npm:^3.0.0" + checksum: 10c0/e27326a831187c6a47a72b62212364e3f88247fa2a8723e5030e14a0002b69756fb51f97efbda2466deb05f4a78ecb83c2a1a7b343e9659cbfb3f370156f1e12 + languageName: node + linkType: hard + "try-catch@npm:^3.0.0": version: 3.0.1 resolution: "try-catch@npm:3.0.1" From 056a37c2aed4bda1e6865ec42fc1db80e20e13af Mon Sep 17 00:00:00 2001 From: James Garbutt <43081j@users.noreply.github.com> Date: Fri, 27 Sep 2024 19:11:43 +0700 Subject: [PATCH 09/41] fix: revert a few changes --- code/core/src/builder-manager/index.ts | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/code/core/src/builder-manager/index.ts b/code/core/src/builder-manager/index.ts index 26cafb1a117d..592416521a2a 100644 --- a/code/core/src/builder-manager/index.ts +++ b/code/core/src/builder-manager/index.ts @@ -172,23 +172,8 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, dev: true, immutable: true, }); - // TODO (43081j): maybe abstract this into a reusable function - app.use('/sb-addons', (req, res, next) => { - if (!req.url || req.url === '/') { - next(); - return; - } - - serveAddons(req, res, next); - }); - app.use('/sb-manager', (req, res, next) => { - if (!req.url || req.url === '/') { - next(); - return; - } - - serveCore(req, res, next); - }); + app.use('/sb-addons', serveAddons); + app.use('/sb-manager', serveCore); const { cssFiles, jsFiles } = await readOrderedFiles(addonsDir, compilation?.outputFiles); From cce0f14f1e2040094ce9189d419b28451b642987 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 30 Sep 2024 22:35:02 +0200 Subject: [PATCH 10/41] listen for requests, cleanup --- code/builders/builder-vite/src/index.ts | 24 +++++++-------- code/builders/builder-webpack5/src/index.ts | 20 ++++++------- code/core/src/builder-manager/index.ts | 29 ++++++++++--------- code/core/src/core-server/dev-server.ts | 25 ++++++++-------- .../utils/getStoryIndexGenerator.ts | 3 -- .../src/core-server/utils/server-statics.ts | 24 ++++++++------- .../core-server/utils/stories-json.test.ts | 5 ++-- code/core/src/types/modules/core-common.ts | 1 + 8 files changed, 64 insertions(+), 67 deletions(-) diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index 3aa99e434977..9307c07dfed6 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -26,7 +26,8 @@ function iframeMiddleware(options: Options, server: ViteDevServer): Polka.Middle next(); return; } - const url = new URL(req.url, 'https://storybook.js.org'); + // the base isn't used for anything, but it's required by the URL constructor + const url = new URL(req.url, 'http://localhost:6006'); // We need to handle `html-proxy` params for style tag HMR https://github.com/storybookjs/builder-vite/issues/266#issuecomment-1055677865 // e.g. /iframe.html?html-proxy&index=0.css @@ -62,15 +63,14 @@ export const start: ViteBuilder['start'] = async ({ server = await createViteServer(options as Options, devServer); const previewResolvedDir = join(corePath, 'dist/preview'); - const previewDirOrigin = previewResolvedDir; - const servePreview = sirv(previewDirOrigin, { - maxAge: 300000, - dev: true, - immutable: true, - }); - - app.use('/sb-preview', servePreview); - + app.use( + '/sb-preview', + sirv(previewResolvedDir, { + maxAge: 300000, + dev: true, + immutable: true, + }) + ); app.use(iframeMiddleware(options as Options, server)); app.use(server.middlewares); @@ -89,10 +89,8 @@ export const build: ViteBuilder['build'] = async ({ options }) => { const viteCompilation = viteBuild(options as Options); const previewResolvedDir = join(corePath, 'dist/preview'); - const previewDirOrigin = previewResolvedDir; const previewDirTarget = join(options.outputDir || '', `sb-preview`); - - const previewFiles = cp(previewDirOrigin, previewDirTarget, { + const previewFiles = cp(previewResolvedDir, previewDirTarget, { filter: (src) => { const { ext } = parse(src); if (ext) { diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index cd7430cf7685..9e2245fec19c 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -180,14 +180,14 @@ const starter: StarterFunction = async function* starterGeneratorFn({ compilation = webpackDevMiddleware(compiler, middlewareOptions); const previewResolvedDir = join(corePath, 'dist/preview'); - const previewDirOrigin = previewResolvedDir; - const servePreview = sirv(previewDirOrigin, { - maxAge: 300000, - dev: true, - immutable: true, - }); - - app.use('/sb-preview', servePreview); + app.use( + '/sb-preview', + sirv(previewResolvedDir, { + maxAge: 300000, + dev: true, + immutable: true, + }) + ); app.use(compilation); app.use(webpackHotMiddleware(compiler, { log: false })); @@ -293,10 +293,8 @@ const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, }); const previewResolvedDir = join(corePath, 'dist/preview'); - const previewDirOrigin = previewResolvedDir; const previewDirTarget = join(options.outputDir || '', `sb-preview`); - - const previewFiles = cp(previewDirOrigin, previewDirTarget, { + const previewFiles = cp(previewResolvedDir, previewDirTarget, { filter: (src) => { const { ext } = parse(src); if (ext) { diff --git a/code/core/src/builder-manager/index.ts b/code/core/src/builder-manager/index.ts index 592416521a2a..93241012b068 100644 --- a/code/core/src/builder-manager/index.ts +++ b/code/core/src/builder-manager/index.ts @@ -162,18 +162,22 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, 'manager' ); - const serveAddons = sirv(addonsDir, { - maxAge: 300000, - dev: true, - immutable: true, - }); - const serveCore = sirv(coreDirOrigin, { - maxAge: 300000, - dev: true, - immutable: true, - }); - app.use('/sb-addons', serveAddons); - app.use('/sb-manager', serveCore); + app.use( + '/sb-addons', + sirv(addonsDir, { + maxAge: 300000, + dev: true, + immutable: true, + }) + ); + app.use( + '/sb-manager', + sirv(coreDirOrigin, { + maxAge: 300000, + dev: true, + immutable: true, + }) + ); const { cssFiles, jsFiles } = await readOrderedFiles(addonsDir, compilation?.outputFiles); @@ -261,7 +265,6 @@ const builder: BuilderFunction = async function* builderGeneratorFn({ startTime, // TODO: this doesn't watch, we should change this to use the esbuild watch API: https://esbuild.github.io/api/#watch compilation = await instance({ ...config, - minify: true, }); diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 0653ceba93d0..9cf13d96f959 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -22,13 +22,13 @@ import { getServer } from './utils/server-init'; import { useStatics } from './utils/server-statics'; export async function storybookDevServer(options: Options) { - const [server, features, core] = await Promise.all([ - getServer(options), - options.presets.apply('features'), - options.presets.apply('core'), - ]); - + const [server, core] = await Promise.all([getServer(options), options.presets.apply('core')]); + console.log('LOG: starting dev server'); const app = polka({ server }); + // app.use((req, res, next) => { + // console.log('LOG: ', { url: req.url, method: req.method }); + // next(); + // }); const serverChannel = await options.presets.apply( 'experimental_serverChannel', @@ -38,7 +38,7 @@ export async function storybookDevServer(options: Options) { let indexError: Error | undefined; // try get index generator, if failed, send telemetry without storyCount, then rethrow the error const initializedStoryIndexGenerator: Promise = - getStoryIndexGenerator(app, features ?? {}, options, serverChannel).catch((err) => { + getStoryIndexGenerator(app, options, serverChannel).catch((err) => { indexError = err; return undefined; }); @@ -59,11 +59,6 @@ export async function storybookDevServer(options: Options) { const proto = options.https ? 'https' : 'http'; const { address, networkAddress } = getServerAddresses(port, host, proto, initialPath); - const listening = new Promise((resolve, reject) => { - // @ts-expect-error (Following line doesn't match TypeScript signature at all šŸ¤”) - server.listen({ port, host }, (error: Error) => (error ? reject(error) : resolve())); - }); - if (!core?.builder) { throw new MissingBuilderError(); } @@ -84,6 +79,7 @@ export async function storybookDevServer(options: Options) { startTime: process.hrtime(), options, app, + router: app, // back-compatability with express-based API server, channel: serverChannel, }); @@ -99,6 +95,7 @@ export async function storybookDevServer(options: Options) { startTime: process.hrtime(), options, app, + router: app, // back-compatability with express-based API server, channel: serverChannel, }) @@ -126,7 +123,9 @@ export async function storybookDevServer(options: Options) { previewStarted.catch(() => {}).then(() => next()); }); - await Promise.all([initializedStoryIndexGenerator, listening]).then(async ([indexGenerator]) => { + app.listen(port, host); + + await Promise.all([initializedStoryIndexGenerator]).then(async ([indexGenerator]) => { if (indexGenerator && !options.ci && !options.smokeTest && options.open) { openInBrowser(host ? networkAddress : address); } diff --git a/code/core/src/core-server/utils/getStoryIndexGenerator.ts b/code/core/src/core-server/utils/getStoryIndexGenerator.ts index d6b1d7d1058e..d91373d825cf 100644 --- a/code/core/src/core-server/utils/getStoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/getStoryIndexGenerator.ts @@ -9,9 +9,6 @@ import { useStoriesJson } from './stories-json'; export async function getStoryIndexGenerator( app: Polka.Polka, - features: { - argTypeTargetsV7?: boolean; - }, options: Options, serverChannel: ServerChannel ): Promise { diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index 6d1ffd59f041..aa8f4876b4c5 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -74,7 +74,8 @@ export async function useStatics(app: Polka.Polka, options: Options): Promise { const app: Polka.Polka = { use } as any; const end = vi.fn(); const write = vi.fn(); - const response: Response = { + const response: Polka.Response = { header: vi.fn(), send: vi.fn(), status: vi.fn(), @@ -82,7 +81,7 @@ describe('useStoriesJson', () => { Watchpack.mockClear(); }); - const request: Request = { + const request: Polka.Request = { headers: { accept: 'application/json' }, } as any; diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index d5dc8baf0bee..ddecfea2d89d 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -217,6 +217,7 @@ export interface Builder { options: Options; startTime: ReturnType; app: Polka.Polka; + router: Polka.Polka; // back-compatability with express-based API server: HttpServer; channel: ServerChannel; }) => Promise Date: Tue, 1 Oct 2024 13:49:25 +0200 Subject: [PATCH 11/41] comment update --- code/builders/builder-vite/src/plugins/code-generator-plugin.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts index 77509b97cf93..79dba3844060 100644 --- a/code/builders/builder-vite/src/plugins/code-generator-plugin.ts +++ b/code/builders/builder-vite/src/plugins/code-generator-plugin.ts @@ -50,7 +50,7 @@ export function codeGeneratorPlugin(options: Options): Plugin { }, config(config, { command }) { // If we are building the static distribution, add iframe.html as an entry. - // In development mode, it's not an entry - instead, we use an express middleware + // In development mode, it's not an entry - instead, we use a middleware // to serve iframe.html. The reason is that Vite's dev server (at the time of writing) // does not support virtual files as entry points. if (command === 'build') { From e6099804e99077fce2f977f87006775bef578a50 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 1 Oct 2024 16:33:12 +0200 Subject: [PATCH 12/41] remove `file-system-cache` by embedding it into our source --- code/core/package.json | 2 +- code/core/src/common/utils/file-cache.ts | 472 ++++++++++++++++++++- code/core/src/types/modules/core-common.ts | 2 +- code/yarn.lock | 77 +--- 4 files changed, 472 insertions(+), 81 deletions(-) diff --git a/code/core/package.json b/code/core/package.json index 17ec07a21246..c502e9ac845a 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -365,7 +365,6 @@ "express": "^4.19.2", "fd-package-json": "^1.2.0", "fetch-retry": "^6.0.0", - "file-system-cache": "^2.4.4", "find-cache-dir": "^5.0.0", "find-up": "^7.0.0", "flush-promises": "^1.0.2", @@ -390,6 +389,7 @@ "prettier": "^3.2.5", "pretty-hrtime": "^1.0.3", "prompts": "^2.4.0", + "ramda": "^0.30.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-draggable": "^4.4.5", diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index de65cc988383..a788150c4a63 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -1,11 +1,469 @@ -import * as fsc from 'file-system-cache'; +import * as crypto from 'node:crypto'; +import * as fs from 'node:fs'; +import { existsSync, lstatSync } from 'node:fs'; +import * as fsp from 'node:fs/promises'; +import { mkdir, rm, stat } from 'node:fs/promises'; +import * as fsPath from 'node:path'; -// @ts-expect-error (needed due to it's use of `exports.default`) -const Cache = (fsc.default.default || fsc.default) as typeof fsc.default; +import * as R from 'ramda'; -export type Options = Parameters['0']; -export type FileSystemCache = ReturnType; +const pathExists = async (path: string) => { + return stat(path) + .then(() => true) + .catch(() => false); +}; -export function createFileSystemCache(options: Options): FileSystemCache { - return Cache(options); +async function ensureDir(dirPath: string): Promise { + try { + // Attempt to create the directory recursively + await mkdir(dirPath, { recursive: true }); + } catch (err: any) { + // If the error is something other than the directory already existing, throw the error + if (err.code !== 'EEXIST') { + throw err; + } + } +} + +async function remove(path: string): Promise { + try { + // Attempt to remove the file or directory recursively + await rm(path, { recursive: true, force: true }); + } catch (err: any) { + // If the error code is anything other than the path not existing, rethrow the error + if (err.code !== 'ENOENT') { + throw err; + } + } +} + +export type FileSystemCacheOptions = { + basePath?: string; + ns?: any; + ttl?: number; + hash?: HashAlgorithm; + extension?: string; +}; + +export const isNothing = (value: any) => R.isNil(value) || R.isEmpty(value); +export const isString = R.is(String); + +export const toAbsolutePath = (path: string) => { + return path.startsWith('.') ? fsPath.resolve(path) : path; +}; + +export const ensureString = (defaultValue: string, text?: string): string => { + return typeof text === 'string' ? text : defaultValue; +}; + +export const compact = (input: any[]): string[] => { + const flat = [].concat(...input); + return flat.filter((value) => !R.isNil(value)); +}; + +export const toStringArray = R.pipe(compact, R.map(R.toString)); + +export const isFileSync = (path: string) => { + return existsSync(path) ? lstatSync(path).isFile() : false; +}; + +export const readFileSync = (path: string) => { + return existsSync(path) ? fs.readFileSync(path).toString() : undefined; +}; + +export const filePathsP = async (basePath: string, ns: string): Promise => { + if (!(await pathExists(basePath))) { + return []; + } + return (await fsp.readdir(basePath)) + .filter(Boolean) + .filter((name) => (ns ? name.startsWith(ns) : true)) + .filter((name) => (!ns ? !name.includes('-') : true)) + .map((name) => `${basePath}/${name}`); +}; + +/** + * Turns a set of values into a HEX hash code. + * + * @param values: The set of values to hash. + */ +export const hash = (algorithm: HashAlgorithm, ...values: any[]) => { + if (R.pipe(compact, R.isEmpty)(values)) { + return undefined; + } + const resultHash = crypto.createHash(algorithm); + const addValue = (value: any) => resultHash.update(value); + const addValues = R.forEach(addValue); + R.pipe(toStringArray, addValues)(values); + return resultHash.digest('hex'); +}; + +export const hashExists = (algorithm: HashAlgorithm) => { + return crypto.getHashes().includes(algorithm); +}; + +/** Retrieve a value from the given path. */ +export async function getValueP(path: string, defaultValue?: any) { + const exists = await pathExists(path); + + if (!exists) { + return defaultValue; + } + try { + const content = await fsp.readFile(path, 'utf8'); + return toGetValue(JSON.parse(content)); + } catch (error: any) { + if (error.code === 'ENOENT') { + return defaultValue; + } + if (error.message === 'Cache item has expired.') { + fs.rmSync(path); + return defaultValue; + } + throw new Error(`Failed to read cache value at: ${path}. ${error.message}`); + } +} + +/** Format value structure. */ +export const toGetValue = (data: any) => { + if (isExpired(data)) { + return undefined; + } + + if (data.type === 'Date') { + return new Date(data.value); + } + return data.value; +}; + +/** Stringify a value into JSON. */ +export const toJson = (value: any, ttl: number) => + JSON.stringify({ value, type: R.type(value), created: new Date(), ttl }); + +/** Check's a cache item to see if it has expired. */ +export const isExpired = (data: any) => { + const timeElapsed = (new Date().getTime() - new Date(data.created).getTime()) / 1000; + return timeElapsed > data.ttl && data.ttl > 0; +}; + +export type HashAlgorithm = + | 'RSA-MD5' + | 'RSA-RIPEMD160' + | 'RSA-SHA1' + | 'RSA-SHA1-2' + | 'RSA-SHA224' + | 'RSA-SHA256' + | 'RSA-SHA3-224' + | 'RSA-SHA3-256' + | 'RSA-SHA3-384' + | 'RSA-SHA3-512' + | 'RSA-SHA384' + | 'RSA-SHA512' + | 'RSA-SHA512/224' + | 'RSA-SHA512/256' + | 'RSA-SM3' + | 'blake2b512' + | 'blake2s256' + | 'id-rsassa-pkcs1-v1_5-with-sha3-224' + | 'id-rsassa-pkcs1-v1_5-with-sha3-256' + | 'id-rsassa-pkcs1-v1_5-with-sha3-384' + | 'id-rsassa-pkcs1-v1_5-with-sha3-512' + | 'md5' + | 'md5-sha1' + | 'md5WithRSAEncryption' + | 'ripemd' + | 'ripemd160' + | 'ripemd160WithRSA' + | 'rmd160' + | 'sha1' + | 'sha1WithRSAEncryption' + | 'sha224' + | 'sha224WithRSAEncryption' + | 'sha256' + | 'sha256WithRSAEncryption' + | 'sha3-224' + | 'sha3-256' + | 'sha3-384' + | 'sha3-512' + | 'sha384' + | 'sha384WithRSAEncryption' + | 'sha512' + | 'sha512-224' + | 'sha512-224WithRSAEncryption' + | 'sha512-256' + | 'sha512-256WithRSAEncryption' + | 'sha512WithRSAEncryption' + | 'shake128' + | 'shake256' + | 'sm3' + | 'sm3WithRSAEncryption' + | 'ssl3-md5' + | 'ssl3-sha1'; + +export const hashAlgorithms: HashAlgorithm[] = [ + 'RSA-MD5', + 'RSA-RIPEMD160', + 'RSA-SHA1', + 'RSA-SHA1-2', + 'RSA-SHA224', + 'RSA-SHA256', + 'RSA-SHA3-224', + 'RSA-SHA3-256', + 'RSA-SHA3-384', + 'RSA-SHA3-512', + 'RSA-SHA384', + 'RSA-SHA512', + 'RSA-SHA512/224', + 'RSA-SHA512/256', + 'RSA-SM3', + 'blake2b512', + 'blake2s256', + 'id-rsassa-pkcs1-v1_5-with-sha3-224', + 'id-rsassa-pkcs1-v1_5-with-sha3-256', + 'id-rsassa-pkcs1-v1_5-with-sha3-384', + 'id-rsassa-pkcs1-v1_5-with-sha3-512', + 'md5', + 'md5-sha1', + 'md5WithRSAEncryption', + 'ripemd', + 'ripemd160', + 'ripemd160WithRSA', + 'rmd160', + 'sha1', + 'sha1WithRSAEncryption', + 'sha224', + 'sha224WithRSAEncryption', + 'sha256', + 'sha256WithRSAEncryption', + 'sha3-224', + 'sha3-256', + 'sha3-384', + 'sha3-512', + 'sha384', + 'sha384WithRSAEncryption', + 'sha512', + 'sha512-224', + 'sha512-224WithRSAEncryption', + 'sha512-256', + 'sha512-256WithRSAEncryption', + 'sha512WithRSAEncryption', + 'shake128', + 'shake256', + 'sm3', + 'sm3WithRSAEncryption', + 'ssl3-md5', + 'ssl3-sha1', +]; +/** A cache that read/writes to a specific part of the file-system. */ +export class FileSystemCache { + /** The list of all available hash algorithms. */ + static hashAlgorithms: HashAlgorithm[] = hashAlgorithms; + + /** Instance. */ + readonly basePath: string; + + readonly ns?: any; + + readonly extension?: string; + + readonly hash: HashAlgorithm; + + readonly ttl: number; + + basePathExists?: boolean; + + /** + * Constructor. + * + * @param options - BasePath: The folder path to read/write to. Default: './build' - ns: A single + * value, or array, that represents a a unique namespace within which values for this store are + * cached. - extension: An optional file-extension for paths. - ttl: The default time-to-live + * for cached values in seconds. Default: 0 (never expires) - hash: The hashing algorithm to use + * when generating cache keys. Default: "sha1" + */ + constructor(options: FileSystemCacheOptions = {}) { + this.basePath = formatPath(options.basePath); + this.hash = options.hash ?? 'sha1'; + this.ns = hash(this.hash, options.ns); + this.ttl = options.ttl ?? 0; + + if (isString(options.extension)) { + this.extension = options.extension; + } + + if (isFileSync(this.basePath)) { + throw new Error(`The basePath '${this.basePath}' is a file. It should be a folder.`); + } + + if (!hashExists(this.hash)) { + throw new Error(`Hash does not exist: ${this.hash}`); + } + } + + /** + * Generates the path to the cached files. + * + * @param {string} key: The key of the cache item. + */ + public path(key: string): string { + if (isNothing(key)) { + throw new Error(`Path requires a cache key.`); + } + let name = hash(this.hash, key); + + if (this.ns) { + name = `${this.ns}-${name}`; + } + + if (this.extension) { + name = `${name}.${this.extension.replace(/^\./, '')}`; + } + return `${this.basePath}/${name}`; + } + + /** + * Determines whether the file exists. + * + * @param {string} key: The key of the cache item. + */ + public fileExists(key: string) { + return pathExists(this.path(key)); + } + + /** Ensure that the base path exists. */ + public async ensureBasePath() { + if (!this.basePathExists) { + await ensureDir(this.basePath); + } + this.basePathExists = true; + } + + /** + * Gets the contents of the file with the given key. + * + * @param {string} key: The key of the cache item. + * @param defaultValue: Optional. A default value to return if the value does not exist in cache. + * @returns File contents, or undefined if the file does not exis + */ + public get(key: string, defaultValue?: any) { + return getValueP(this.path(key), defaultValue); + } + + /** + * Gets the contents of the file with the given key. + * + * @param {string} key: The key of the cache item. + * @param defaultValue: Optional. A default value to return if the value does not exist in cache. + * @returns The cached value, or undefined. + */ + public getSync(key: string, defaultValue?: any) { + const path = this.path(key); + const content = readFileSync(path) || ''; + return fs.existsSync(path) ? toGetValue(JSON.parse(content)) : defaultValue; + } + + /** + * Writes the given value to the file-system. + * + * @param {string} key: The key of the cache item. + * @param value: The value to write (Primitive or Object). + */ + public async set(key: string, value: any, ttl?: number) { + const path = this.path(key); + ttl = typeof ttl === 'number' ? ttl : this.ttl; + await this.ensureBasePath(); + await fsp.writeFile(path, toJson(value, ttl)); + return { path }; + } + + /** + * Writes the given value to the file-system and memory cache. + * + * @param {string} key: The key of the cache item. + * @param value: The value to write (Primitive or Object). + * @returns The cache. + */ + public setSync(key: string, value: any, ttl?: number) { + ttl = typeof ttl === 'number' ? ttl : this.ttl; + fs.writeFileSync(this.path(key), toJson(value, ttl)); + return this; + } + + /** + * Removes the item from the file-system. + * + * @param {string} key: The key of the cache item. + */ + public remove(key: string) { + return remove(this.path(key)); + } + + /** Removes all items from the cache. */ + public async clear() { + const paths = await filePathsP(this.basePath, this.ns); + await Promise.all(paths.map((path) => remove(path))); + console.groupEnd(); + } + + /** + * Saves several items to the cache in one operation. + * + * @param {array} items: An array of objects of the form { key, value }. + */ + public async save( + input: ({ key: string; value: any } | null | undefined)[] + ): Promise<{ paths: string[] }> { + type Item = { key: string; value: any }; + let items = (Array.isArray(input) ? input : [input]) as Item[]; + + const isValid = (item: any) => { + if (!R.is(Object, item)) { + return false; + } + return item.key && item.value; + }; + + items = items.filter((item) => Boolean(item)); + items + .filter((item) => !isValid(item)) + .forEach(() => { + const err = `Save items not valid, must be an array of {key, value} objects.`; + throw new Error(err); + }); + + if (items.length === 0) { + return { paths: [] }; + } + + const paths = await Promise.all( + items.map(async (item) => (await this.set(item.key, item.value)).path) + ); + + return { paths }; + } + + /** Loads all files within the cache's namespace. */ + public async load(): Promise<{ files: { path: string; value: any }[] }> { + const paths = await filePathsP(this.basePath, this.ns); + + if (paths.length === 0) { + return { files: [] }; + } + const files = await Promise.all( + paths.map(async (path) => ({ path, value: await getValueP(path) })) + ); + return { files }; + } +} + +/** Helpers */ + +function formatPath(path?: string) { + path = ensureString('./.cache', path); + path = toAbsolutePath(path); + return path; +} + +export function createFileSystemCache(options: FileSystemCacheOptions): FileSystemCache { + return new FileSystemCache(options); } diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index 8e71a4cadb2a..82fbfb8c7669 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -1,11 +1,11 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { Router } from 'express'; -import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core import type { Server } from 'http'; import type * as telejson from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; +import type { FileSystemCache } from '../../common/utils/file-cache'; import type { Indexer, StoriesEntry } from './indexer'; /** āš ļø This file contains internal WIP types they MUST NOT be exported outside this package for now! */ diff --git a/code/yarn.lock b/code/yarn.lock index a3ab66666dda..6fdf68f6070c 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6078,7 +6078,6 @@ __metadata: express: "npm:^4.19.2" fd-package-json: "npm:^1.2.0" fetch-retry: "npm:^6.0.0" - file-system-cache: "npm:^2.4.4" find-cache-dir: "npm:^5.0.0" find-up: "npm:^7.0.0" flush-promises: "npm:^1.0.2" @@ -6105,6 +6104,7 @@ __metadata: pretty-hrtime: "npm:^1.0.3" process: "npm:^0.11.10" prompts: "npm:^2.4.0" + ramda: "npm:^0.30.1" react: "npm:^18.2.0" react-dom: "npm:^18.2.0" react-draggable: "npm:^4.4.5" @@ -7844,16 +7844,6 @@ __metadata: languageName: node linkType: hard -"@types/fs-extra@npm:11.0.1": - version: 11.0.1 - resolution: "@types/fs-extra@npm:11.0.1" - dependencies: - "@types/jsonfile": "npm:*" - "@types/node": "npm:*" - checksum: 10c0/a65f1fae47849fe1a17441dcabc9400390303405972ff3cbb3578746cea8916b23d5e7652bf57a87767f75a9b2f37caac499b78b5230ae08fef0ba58b34c3a85 - languageName: node - linkType: hard - "@types/fs-extra@npm:^5.0.5": version: 5.1.0 resolution: "@types/fs-extra@npm:5.1.0" @@ -7988,15 +7978,6 @@ __metadata: languageName: node linkType: hard -"@types/jsonfile@npm:*": - version: 6.1.2 - resolution: "@types/jsonfile@npm:6.1.2" - dependencies: - "@types/node": "npm:*" - checksum: 10c0/c2943f9bfa7867b33fb362b88a932efdc00e9e5f2762b6ef912617cb0a3e3221a98920f8976a4cf817aa576e03d28a25391236e9644e2ebe648081b08df62ef5 - languageName: node - linkType: hard - "@types/loader-utils@npm:^2.0.5": version: 2.0.6 resolution: "@types/loader-utils@npm:2.0.6" @@ -8164,15 +8145,6 @@ __metadata: languageName: node linkType: hard -"@types/ramda@npm:0.29.3": - version: 0.29.3 - resolution: "@types/ramda@npm:0.29.3" - dependencies: - types-ramda: "npm:^0.29.4" - checksum: 10c0/9c62a4600f5df5e65a01ffe4a470500c98f7c0d093fde47e0d4257675f1ec50effe4696cb004a6b53227948db67ea26a2345dbc91819ecc868105c0f64cecd1e - languageName: node - linkType: hard - "@types/range-parser@npm:*": version: 1.2.5 resolution: "@types/range-parser@npm:1.2.5" @@ -15268,18 +15240,6 @@ __metadata: languageName: node linkType: hard -"file-system-cache@npm:^2.4.4": - version: 2.4.4 - resolution: "file-system-cache@npm:2.4.4" - dependencies: - "@types/fs-extra": "npm:11.0.1" - "@types/ramda": "npm:0.29.3" - fs-extra: "npm:11.1.1" - ramda: "npm:0.29.0" - checksum: 10c0/274bd9c2f8f81d0c3b2cc0d077807c969b48cac4857ae77f87b4b480548252aa42d3a43b3e9d4bb54df567eb70f0c384782514fcea74b78765543e9496e27e2d - languageName: node - linkType: hard - "filelist@npm:^1.0.4": version: 1.0.4 resolution: "filelist@npm:1.0.4" @@ -15723,17 +15683,6 @@ __metadata: languageName: node linkType: hard -"fs-extra@npm:11.1.1": - version: 11.1.1 - resolution: "fs-extra@npm:11.1.1" - dependencies: - graceful-fs: "npm:^4.2.0" - jsonfile: "npm:^6.0.1" - universalify: "npm:^2.0.0" - checksum: 10c0/a2480243d7dcfa7d723c5f5b24cf4eba02a6ccece208f1524a2fbde1c629492cfb9a59e4b6d04faff6fbdf71db9fdc8ef7f396417a02884195a625f5d8dc9427 - languageName: node - linkType: hard - "fs-extra@npm:^10.0.0, fs-extra@npm:^10.1.0": version: 10.1.0 resolution: "fs-extra@npm:10.1.0" @@ -23614,10 +23563,10 @@ __metadata: languageName: node linkType: hard -"ramda@npm:0.29.0": - version: 0.29.0 - resolution: "ramda@npm:0.29.0" - checksum: 10c0/b00eaaf1c62b06a99affa1d583e256bd65ad27ab9d0ef512f55d7d93b842e7cd244a4a09179f61fdd8548362e409323867a2b0477cbd0626b5644eb6ac7c53da +"ramda@npm:^0.30.1": + version: 0.30.1 + resolution: "ramda@npm:0.30.1" + checksum: 10c0/3ea3e35c80e1a1b78c23de0c72d3382c3446f42052b113b851f1b7fc421e33a45ce92e7aef3c705cc6de3812a209d03417af5c264f67126cda539fd66c8bea71 languageName: node linkType: hard @@ -27377,13 +27326,6 @@ __metadata: languageName: node linkType: hard -"ts-toolbelt@npm:^9.6.0": - version: 9.6.0 - resolution: "ts-toolbelt@npm:9.6.0" - checksum: 10c0/838f9a2f0fe881d5065257a23b402c41315b33ff987b73db3e2b39fcb70640c4c7220e1ef118ed5676763543724fdbf4eda7b0e2c17acb667ed1401336af9f8c - languageName: node - linkType: hard - "tsconfig-paths-webpack-plugin@npm:^4.0.1": version: 4.1.0 resolution: "tsconfig-paths-webpack-plugin@npm:4.1.0" @@ -27567,15 +27509,6 @@ __metadata: languageName: node linkType: hard -"types-ramda@npm:^0.29.4": - version: 0.29.10 - resolution: "types-ramda@npm:0.29.10" - dependencies: - ts-toolbelt: "npm:^9.6.0" - checksum: 10c0/cc6439341a60a4f2b49e1ac447c8a0279f161464fd0a204abaa57e90e101772c0b1adc185a7c0715c3836c19594a9ec268c1e5c4394d0e409cb71d141def3963 - languageName: node - linkType: hard - "typescript@npm:^3.8.3": version: 3.9.10 resolution: "typescript@npm:3.9.10" From 94a0bf62437249af606e2923c21ef4fbd6a87210 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Tue, 1 Oct 2024 17:07:22 +0200 Subject: [PATCH 13/41] fix dep missing --- code/core/package.json | 1 + code/yarn.lock | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/code/core/package.json b/code/core/package.json index c502e9ac845a..fc1fce7cc28e 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -329,6 +329,7 @@ "@types/prettier": "^3.0.0", "@types/pretty-hrtime": "^1.0.0", "@types/prompts": "^2.0.9", + "@types/ramda": "^0.30.2", "@types/react-syntax-highlighter": "11.0.5", "@types/react-transition-group": "^4", "@types/semver": "^7.5.8", diff --git a/code/yarn.lock b/code/yarn.lock index 6fdf68f6070c..495364337ab2 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6039,6 +6039,7 @@ __metadata: "@types/prettier": "npm:^3.0.0" "@types/pretty-hrtime": "npm:^1.0.0" "@types/prompts": "npm:^2.0.9" + "@types/ramda": "npm:^0.30.2" "@types/react-syntax-highlighter": "npm:11.0.5" "@types/react-transition-group": "npm:^4" "@types/semver": "npm:^7.5.8" @@ -8145,6 +8146,15 @@ __metadata: languageName: node linkType: hard +"@types/ramda@npm:^0.30.2": + version: 0.30.2 + resolution: "@types/ramda@npm:0.30.2" + dependencies: + types-ramda: "npm:^0.30.1" + checksum: 10c0/dda95008860f594eb7b4fd9819adeb2dcd4d4e2baca6cb33f692f6f8ea76d04a7fd81f9a057c5c67555612769e5592cb15f91de6c9f8b619b8b1d806d19dc9ea + languageName: node + linkType: hard + "@types/range-parser@npm:*": version: 1.2.5 resolution: "@types/range-parser@npm:1.2.5" @@ -27326,6 +27336,13 @@ __metadata: languageName: node linkType: hard +"ts-toolbelt@npm:^9.6.0": + version: 9.6.0 + resolution: "ts-toolbelt@npm:9.6.0" + checksum: 10c0/838f9a2f0fe881d5065257a23b402c41315b33ff987b73db3e2b39fcb70640c4c7220e1ef118ed5676763543724fdbf4eda7b0e2c17acb667ed1401336af9f8c + languageName: node + linkType: hard + "tsconfig-paths-webpack-plugin@npm:^4.0.1": version: 4.1.0 resolution: "tsconfig-paths-webpack-plugin@npm:4.1.0" @@ -27509,6 +27526,15 @@ __metadata: languageName: node linkType: hard +"types-ramda@npm:^0.30.1": + version: 0.30.1 + resolution: "types-ramda@npm:0.30.1" + dependencies: + ts-toolbelt: "npm:^9.6.0" + checksum: 10c0/4a8b230ae9772e6534f65b1a154dd5604bcd1d74e27b49686337a215e83aa8fc93e49f8c49af395418d2950cb9fb9b900662077c1d4b73ff6fe4f4bcb83ab2d6 + languageName: node + linkType: hard + "typescript@npm:^3.8.3": version: 3.9.10 resolution: "typescript@npm:3.9.10" From 4fd94e63e9cada9a98b9bd1f8869838e59a6694b Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Wed, 2 Oct 2024 09:05:25 +0200 Subject: [PATCH 14/41] remove custom content-type headers --- .../src/core-server/utils/server-statics.ts | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index aa8f4876b4c5..04f985901ce3 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -7,25 +7,10 @@ import type { Options } from '@storybook/core/types'; import { logger } from '@storybook/core/node-logger'; import chalk from 'chalk'; -import type { ServerResponse } from 'http'; import type Polka from 'polka'; import sirv from 'sirv'; import { dedent } from 'ts-dedent'; -// TODO (43081j): maybe get this from somewhere? -const contentTypes: Record = { - css: 'text/css', - woff2: 'font/woff2', - js: 'text/javascript', -}; -const setContentTypeHeaders = (res: ServerResponse, pathname: string) => { - const base = basename(pathname); - const contentType = contentTypes[base]; - if (contentType) { - res.setHeader('Content-Type', contentType); - } -}; - export async function useStatics(app: Polka.Polka, options: Options): Promise { const staticDirs = (await options.presets.apply('staticDirs')) ?? []; const faviconPath = await options.presets.apply('favicon'); @@ -49,7 +34,7 @@ export async function useStatics(app: Polka.Polka, options: Options): Promise Serving static files from ${chalk.cyan(staticDir)} at ${chalk.cyan(targetEndpoint)}` ); @@ -66,7 +51,6 @@ export async function useStatics(app: Polka.Polka, options: Options): Promise { From 0cafba675b7ccb29fd2001aa07f0012024fc2959 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Wed, 2 Oct 2024 10:11:23 +0200 Subject: [PATCH 15/41] make polka a dev dep of builder-vite --- code/builders/builder-vite/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index 3853291d8916..6487f0cdb097 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -49,7 +49,6 @@ "es-module-lexer": "^1.5.0", "find-cache-dir": "^3.0.0", "magic-string": "^0.30.0", - "polka": "^1.0.0-next.28", "sirv": "^2.0.4", "ts-dedent": "^2.0.0" }, @@ -57,6 +56,7 @@ "@types/express": "^4.17.21", "@types/node": "^22.0.0", "glob": "^10.0.0", + "polka": "^1.0.0-next.28", "slash": "^5.0.0", "typescript": "^5.3.2", "vite": "^4.0.4" From 31ca3f76336a6ea380833fd92fc69f6f05b9130a Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Wed, 2 Oct 2024 10:15:01 +0200 Subject: [PATCH 16/41] prebundle polka, sirv --- code/builders/builder-vite/package.json | 2 +- code/builders/builder-webpack5/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index 6487f0cdb097..da62b3d90d69 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -49,7 +49,6 @@ "es-module-lexer": "^1.5.0", "find-cache-dir": "^3.0.0", "magic-string": "^0.30.0", - "sirv": "^2.0.4", "ts-dedent": "^2.0.0" }, "devDependencies": { @@ -57,6 +56,7 @@ "@types/node": "^22.0.0", "glob": "^10.0.0", "polka": "^1.0.0-next.28", + "sirv": "^2.0.4", "slash": "^5.0.0", "typescript": "^5.3.2", "vite": "^4.0.4" diff --git a/code/builders/builder-webpack5/package.json b/code/builders/builder-webpack5/package.json index e9250474971c..70a2b505be1b 100644 --- a/code/builders/builder-webpack5/package.json +++ b/code/builders/builder-webpack5/package.json @@ -78,7 +78,6 @@ "path-browserify": "^1.0.1", "process": "^0.11.10", "semver": "^7.3.7", - "sirv": "^2.0.4", "style-loader": "^3.3.1", "terser-webpack-plugin": "^5.3.1", "ts-dedent": "^2.0.0", @@ -95,6 +94,7 @@ "@types/terser-webpack-plugin": "^5.2.0", "@types/webpack-hot-middleware": "^2.25.6", "pretty-hrtime": "^1.0.3", + "sirv": "^2.0.4", "slash": "^5.0.0", "typescript": "^5.3.2" }, From eb504091eb80b2cca7b52ebea4cd41cda318fe31 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 13:15:50 +0200 Subject: [PATCH 17/41] replace for https://git.nfp.is/TheThing/fs-cache-fast/src/branch/master/index.mjs --- code/core/package.json | 2 - code/core/src/common/utils/file-cache.ts | 535 +++++------------------ code/yarn.lock | 34 -- 3 files changed, 116 insertions(+), 455 deletions(-) diff --git a/code/core/package.json b/code/core/package.json index fc1fce7cc28e..3f404f11fb26 100644 --- a/code/core/package.json +++ b/code/core/package.json @@ -329,7 +329,6 @@ "@types/prettier": "^3.0.0", "@types/pretty-hrtime": "^1.0.0", "@types/prompts": "^2.0.9", - "@types/ramda": "^0.30.2", "@types/react-syntax-highlighter": "11.0.5", "@types/react-transition-group": "^4", "@types/semver": "^7.5.8", @@ -390,7 +389,6 @@ "prettier": "^3.2.5", "pretty-hrtime": "^1.0.3", "prompts": "^2.4.0", - "ramda": "^0.30.1", "react": "^18.2.0", "react-dom": "^18.2.0", "react-draggable": "^4.4.5", diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index a788150c4a63..6e2a9d545bf9 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -1,469 +1,166 @@ -import * as crypto from 'node:crypto'; -import * as fs from 'node:fs'; -import { existsSync, lstatSync } from 'node:fs'; -import * as fsp from 'node:fs/promises'; -import { mkdir, rm, stat } from 'node:fs/promises'; -import * as fsPath from 'node:path'; - -import * as R from 'ramda'; - -const pathExists = async (path: string) => { - return stat(path) - .then(() => true) - .catch(() => false); -}; - -async function ensureDir(dirPath: string): Promise { - try { - // Attempt to create the directory recursively - await mkdir(dirPath, { recursive: true }); - } catch (err: any) { - // If the error is something other than the directory already existing, throw the error - if (err.code !== 'EEXIST') { - throw err; - } - } +import { createHash, randomBytes } from 'node:crypto'; +import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; +import { promises as fsPromises } from 'node:fs'; +import { tmpdir } from 'node:os'; +import { join } from 'node:path'; + +interface FileSystemCacheOptions { + ns?: string; + prefix?: string; + hash_alg?: string; + basePath?: string; + ttl?: number; } -async function remove(path: string): Promise { - try { - // Attempt to remove the file or directory recursively - await rm(path, { recursive: true, force: true }); - } catch (err: any) { - // If the error code is anything other than the path not existing, rethrow the error - if (err.code !== 'ENOENT') { - throw err; - } - } +interface CacheItem { + key: string; + content?: any; + value?: any; } -export type FileSystemCacheOptions = { - basePath?: string; - ns?: any; +interface CacheSetOptions { ttl?: number; - hash?: HashAlgorithm; - extension?: string; -}; - -export const isNothing = (value: any) => R.isNil(value) || R.isEmpty(value); -export const isString = R.is(String); - -export const toAbsolutePath = (path: string) => { - return path.startsWith('.') ? fsPath.resolve(path) : path; -}; - -export const ensureString = (defaultValue: string, text?: string): string => { - return typeof text === 'string' ? text : defaultValue; -}; + encoding?: BufferEncoding; +} -export const compact = (input: any[]): string[] => { - const flat = [].concat(...input); - return flat.filter((value) => !R.isNil(value)); -}; +export class FileSystemCache { + private id = randomBytes(15).toString('base64').replace(/\//g, '-'); -export const toStringArray = R.pipe(compact, R.map(R.toString)); + private prefix: string; -export const isFileSync = (path: string) => { - return existsSync(path) ? lstatSync(path).isFile() : false; -}; + private hash_alg: string; -export const readFileSync = (path: string) => { - return existsSync(path) ? fs.readFileSync(path).toString() : undefined; -}; + private cache_dir: string; -export const filePathsP = async (basePath: string, ns: string): Promise => { - if (!(await pathExists(basePath))) { - return []; - } - return (await fsp.readdir(basePath)) - .filter(Boolean) - .filter((name) => (ns ? name.startsWith(ns) : true)) - .filter((name) => (!ns ? !name.includes('-') : true)) - .map((name) => `${basePath}/${name}`); -}; + private ttl: number; -/** - * Turns a set of values into a HEX hash code. - * - * @param values: The set of values to hash. - */ -export const hash = (algorithm: HashAlgorithm, ...values: any[]) => { - if (R.pipe(compact, R.isEmpty)(values)) { - return undefined; + constructor(options: FileSystemCacheOptions = {}) { + this.prefix = (options.ns || options.prefix || '') + '-'; + this.hash_alg = options.hash_alg || 'md5'; + this.cache_dir = options.basePath || join(tmpdir(), this.id); + this.ttl = options.ttl || 0; + createHash(this.hash_alg); // Verifies hash algorithm is available + mkdirSync(this.cache_dir, { recursive: true }); } - const resultHash = crypto.createHash(algorithm); - const addValue = (value: any) => resultHash.update(value); - const addValues = R.forEach(addValue); - R.pipe(toStringArray, addValues)(values); - return resultHash.digest('hex'); -}; - -export const hashExists = (algorithm: HashAlgorithm) => { - return crypto.getHashes().includes(algorithm); -}; - -/** Retrieve a value from the given path. */ -export async function getValueP(path: string, defaultValue?: any) { - const exists = await pathExists(path); - if (!exists) { - return defaultValue; + private generateHash(name: string): string { + return join(this.cache_dir, this.prefix + createHash(this.hash_alg).update(name).digest('hex')); } - try { - const content = await fsp.readFile(path, 'utf8'); - return toGetValue(JSON.parse(content)); - } catch (error: any) { - if (error.code === 'ENOENT') { - return defaultValue; - } - if (error.message === 'Cache item has expired.') { - fs.rmSync(path); - return defaultValue; - } - throw new Error(`Failed to read cache value at: ${path}. ${error.message}`); - } -} -/** Format value structure. */ -export const toGetValue = (data: any) => { - if (isExpired(data)) { - return undefined; + private isExpired(parsed: { ttl?: number }, now: number): boolean { + return parsed.ttl != null && now > parsed.ttl; } - if (data.type === 'Date') { - return new Date(data.value); + private parseCacheData( + data: string, + fallback: T | null, + opts: CacheSetOptions = {} + ): T | null { + const parsed = JSON.parse(data); + return this.isExpired(parsed, Date.now()) ? fallback : (parsed.content as T); } - return data.value; -}; - -/** Stringify a value into JSON. */ -export const toJson = (value: any, ttl: number) => - JSON.stringify({ value, type: R.type(value), created: new Date(), ttl }); - -/** Check's a cache item to see if it has expired. */ -export const isExpired = (data: any) => { - const timeElapsed = (new Date().getTime() - new Date(data.created).getTime()) / 1000; - return timeElapsed > data.ttl && data.ttl > 0; -}; - -export type HashAlgorithm = - | 'RSA-MD5' - | 'RSA-RIPEMD160' - | 'RSA-SHA1' - | 'RSA-SHA1-2' - | 'RSA-SHA224' - | 'RSA-SHA256' - | 'RSA-SHA3-224' - | 'RSA-SHA3-256' - | 'RSA-SHA3-384' - | 'RSA-SHA3-512' - | 'RSA-SHA384' - | 'RSA-SHA512' - | 'RSA-SHA512/224' - | 'RSA-SHA512/256' - | 'RSA-SM3' - | 'blake2b512' - | 'blake2s256' - | 'id-rsassa-pkcs1-v1_5-with-sha3-224' - | 'id-rsassa-pkcs1-v1_5-with-sha3-256' - | 'id-rsassa-pkcs1-v1_5-with-sha3-384' - | 'id-rsassa-pkcs1-v1_5-with-sha3-512' - | 'md5' - | 'md5-sha1' - | 'md5WithRSAEncryption' - | 'ripemd' - | 'ripemd160' - | 'ripemd160WithRSA' - | 'rmd160' - | 'sha1' - | 'sha1WithRSAEncryption' - | 'sha224' - | 'sha224WithRSAEncryption' - | 'sha256' - | 'sha256WithRSAEncryption' - | 'sha3-224' - | 'sha3-256' - | 'sha3-384' - | 'sha3-512' - | 'sha384' - | 'sha384WithRSAEncryption' - | 'sha512' - | 'sha512-224' - | 'sha512-224WithRSAEncryption' - | 'sha512-256' - | 'sha512-256WithRSAEncryption' - | 'sha512WithRSAEncryption' - | 'shake128' - | 'shake256' - | 'sm3' - | 'sm3WithRSAEncryption' - | 'ssl3-md5' - | 'ssl3-sha1'; - -export const hashAlgorithms: HashAlgorithm[] = [ - 'RSA-MD5', - 'RSA-RIPEMD160', - 'RSA-SHA1', - 'RSA-SHA1-2', - 'RSA-SHA224', - 'RSA-SHA256', - 'RSA-SHA3-224', - 'RSA-SHA3-256', - 'RSA-SHA3-384', - 'RSA-SHA3-512', - 'RSA-SHA384', - 'RSA-SHA512', - 'RSA-SHA512/224', - 'RSA-SHA512/256', - 'RSA-SM3', - 'blake2b512', - 'blake2s256', - 'id-rsassa-pkcs1-v1_5-with-sha3-224', - 'id-rsassa-pkcs1-v1_5-with-sha3-256', - 'id-rsassa-pkcs1-v1_5-with-sha3-384', - 'id-rsassa-pkcs1-v1_5-with-sha3-512', - 'md5', - 'md5-sha1', - 'md5WithRSAEncryption', - 'ripemd', - 'ripemd160', - 'ripemd160WithRSA', - 'rmd160', - 'sha1', - 'sha1WithRSAEncryption', - 'sha224', - 'sha224WithRSAEncryption', - 'sha256', - 'sha256WithRSAEncryption', - 'sha3-224', - 'sha3-256', - 'sha3-384', - 'sha3-512', - 'sha384', - 'sha384WithRSAEncryption', - 'sha512', - 'sha512-224', - 'sha512-224WithRSAEncryption', - 'sha512-256', - 'sha512-256WithRSAEncryption', - 'sha512WithRSAEncryption', - 'shake128', - 'shake256', - 'sm3', - 'sm3WithRSAEncryption', - 'ssl3-md5', - 'ssl3-sha1', -]; -/** A cache that read/writes to a specific part of the file-system. */ -export class FileSystemCache { - /** The list of all available hash algorithms. */ - static hashAlgorithms: HashAlgorithm[] = hashAlgorithms; - - /** Instance. */ - readonly basePath: string; - - readonly ns?: any; - readonly extension?: string; - - readonly hash: HashAlgorithm; - - readonly ttl: number; - - basePathExists?: boolean; - - /** - * Constructor. - * - * @param options - BasePath: The folder path to read/write to. Default: './build' - ns: A single - * value, or array, that represents a a unique namespace within which values for this store are - * cached. - extension: An optional file-extension for paths. - ttl: The default time-to-live - * for cached values in seconds. Default: 0 (never expires) - hash: The hashing algorithm to use - * when generating cache keys. Default: "sha1" - */ - constructor(options: FileSystemCacheOptions = {}) { - this.basePath = formatPath(options.basePath); - this.hash = options.hash ?? 'sha1'; - this.ns = hash(this.hash, options.ns); - this.ttl = options.ttl ?? 0; - - if (isString(options.extension)) { - this.extension = options.extension; - } - - if (isFileSync(this.basePath)) { - throw new Error(`The basePath '${this.basePath}' is a file. It should be a folder.`); - } - - if (!hashExists(this.hash)) { - throw new Error(`Hash does not exist: ${this.hash}`); - } + private parseSetData(key: string, data: T, opts: CacheSetOptions = {}): string { + const ttl = opts.ttl ?? this.ttl; + return JSON.stringify({ key, content: data, ...(ttl && { ttl: Date.now() + ttl * 1000 }) }); } - /** - * Generates the path to the cached files. - * - * @param {string} key: The key of the cache item. - */ - public path(key: string): string { - if (isNothing(key)) { - throw new Error(`Path requires a cache key.`); - } - let name = hash(this.hash, key); - - if (this.ns) { - name = `${this.ns}-${name}`; - } - - if (this.extension) { - name = `${name}.${this.extension.replace(/^\./, '')}`; + public async get( + name: string, + fallback: T | null = null, + opts?: CacheSetOptions + ): Promise { + try { + const data = await fsPromises.readFile(this.generateHash(name), 'utf8'); + return this.parseCacheData(data, fallback, opts); + } catch { + return fallback; } - return `${this.basePath}/${name}`; } - /** - * Determines whether the file exists. - * - * @param {string} key: The key of the cache item. - */ - public fileExists(key: string) { - return pathExists(this.path(key)); - } - - /** Ensure that the base path exists. */ - public async ensureBasePath() { - if (!this.basePathExists) { - await ensureDir(this.basePath); + public getSync(name: string, fallback: T | null = null, opts?: CacheSetOptions): T | null { + try { + const data = readFileSync(this.generateHash(name), 'utf8'); + return this.parseCacheData(data, fallback, opts); + } catch { + return fallback; } - this.basePathExists = true; } - /** - * Gets the contents of the file with the given key. - * - * @param {string} key: The key of the cache item. - * @param defaultValue: Optional. A default value to return if the value does not exist in cache. - * @returns File contents, or undefined if the file does not exis - */ - public get(key: string, defaultValue?: any) { - return getValueP(this.path(key), defaultValue); + public async set( + name: string, + data: T, + orgOpts: CacheSetOptions | number = {} + ): Promise { + const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts; + await fsPromises.writeFile(this.generateHash(name), this.parseSetData(name, data, opts), { + encoding: opts.encoding || 'utf8', + }); } - /** - * Gets the contents of the file with the given key. - * - * @param {string} key: The key of the cache item. - * @param defaultValue: Optional. A default value to return if the value does not exist in cache. - * @returns The cached value, or undefined. - */ - public getSync(key: string, defaultValue?: any) { - const path = this.path(key); - const content = readFileSync(path) || ''; - return fs.existsSync(path) ? toGetValue(JSON.parse(content)) : defaultValue; + public setSync(name: string, data: T, orgOpts: CacheSetOptions | number = {}): void { + const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts; + writeFileSync(this.generateHash(name), this.parseSetData(name, data, opts), { + encoding: opts.encoding || 'utf8', + }); } - /** - * Writes the given value to the file-system. - * - * @param {string} key: The key of the cache item. - * @param value: The value to write (Primitive or Object). - */ - public async set(key: string, value: any, ttl?: number) { - const path = this.path(key); - ttl = typeof ttl === 'number' ? ttl : this.ttl; - await this.ensureBasePath(); - await fsp.writeFile(path, toJson(value, ttl)); - return { path }; + public async setMany(items: CacheItem[], options?: CacheSetOptions): Promise { + await Promise.all(items.map((item) => this.set(item.key, item.content ?? item.value, options))); } - /** - * Writes the given value to the file-system and memory cache. - * - * @param {string} key: The key of the cache item. - * @param value: The value to write (Primitive or Object). - * @returns The cache. - */ - public setSync(key: string, value: any, ttl?: number) { - ttl = typeof ttl === 'number' ? ttl : this.ttl; - fs.writeFileSync(this.path(key), toJson(value, ttl)); - return this; + public setManySync(items: CacheItem[], options?: CacheSetOptions): void { + items.forEach((item) => this.setSync(item.key, item.content ?? item.value, options)); } - /** - * Removes the item from the file-system. - * - * @param {string} key: The key of the cache item. - */ - public remove(key: string) { - return remove(this.path(key)); + public async remove(name: string): Promise { + await fsPromises.rm(this.generateHash(name), { force: true }); } - /** Removes all items from the cache. */ - public async clear() { - const paths = await filePathsP(this.basePath, this.ns); - await Promise.all(paths.map((path) => remove(path))); - console.groupEnd(); + public removeSync(name: string): void { + rmSync(this.generateHash(name), { force: true }); } - /** - * Saves several items to the cache in one operation. - * - * @param {array} items: An array of objects of the form { key, value }. - */ - public async save( - input: ({ key: string; value: any } | null | undefined)[] - ): Promise<{ paths: string[] }> { - type Item = { key: string; value: any }; - let items = (Array.isArray(input) ? input : [input]) as Item[]; - - const isValid = (item: any) => { - if (!R.is(Object, item)) { - return false; - } - return item.key && item.value; - }; - - items = items.filter((item) => Boolean(item)); - items - .filter((item) => !isValid(item)) - .forEach(() => { - const err = `Save items not valid, must be an array of {key, value} objects.`; - throw new Error(err); - }); - - if (items.length === 0) { - return { paths: [] }; - } - - const paths = await Promise.all( - items.map(async (item) => (await this.set(item.key, item.value)).path) + public async clear(): Promise { + const files = await fsPromises.readdir(this.cache_dir); + await Promise.all( + files + .filter((f) => f.startsWith(this.prefix)) + .map((f) => fsPromises.rm(join(this.cache_dir, f), { force: true })) ); - - return { paths }; } - /** Loads all files within the cache's namespace. */ - public async load(): Promise<{ files: { path: string; value: any }[] }> { - const paths = await filePathsP(this.basePath, this.ns); + public clearSync(): void { + readdirSync(this.cache_dir) + .filter((f) => f.startsWith(this.prefix)) + .forEach((f) => rmSync(join(this.cache_dir, f), { force: true })); + } - if (paths.length === 0) { - return { files: [] }; - } - const files = await Promise.all( - paths.map(async (path) => ({ path, value: await getValueP(path) })) + public async getAll(): Promise { + const now = Date.now(); + const files = await fsPromises.readdir(this.cache_dir); + const items = await Promise.all( + files + .filter((f) => f.startsWith(this.prefix)) + .map((f) => fsPromises.readFile(join(this.cache_dir, f), 'utf8')) ); - return { files }; + return items + .map((data) => JSON.parse(data)) + .filter((entry) => entry.content && !this.isExpired(entry, now)); + } + + public async load(): Promise<{ files: CacheItem[] }> { + const res = await this.getAll(); + return { + files: res.map((entry) => ({ + path: this.generateHash(entry.key), + value: entry.content, + key: entry.key, + })), + }; } } -/** Helpers */ - -function formatPath(path?: string) { - path = ensureString('./.cache', path); - path = toAbsolutePath(path); - return path; -} - export function createFileSystemCache(options: FileSystemCacheOptions): FileSystemCache { return new FileSystemCache(options); } diff --git a/code/yarn.lock b/code/yarn.lock index 495364337ab2..f258f17c2b2b 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6039,7 +6039,6 @@ __metadata: "@types/prettier": "npm:^3.0.0" "@types/pretty-hrtime": "npm:^1.0.0" "@types/prompts": "npm:^2.0.9" - "@types/ramda": "npm:^0.30.2" "@types/react-syntax-highlighter": "npm:11.0.5" "@types/react-transition-group": "npm:^4" "@types/semver": "npm:^7.5.8" @@ -6105,7 +6104,6 @@ __metadata: pretty-hrtime: "npm:^1.0.3" process: "npm:^0.11.10" prompts: "npm:^2.4.0" - ramda: "npm:^0.30.1" react: "npm:^18.2.0" react-dom: "npm:^18.2.0" react-draggable: "npm:^4.4.5" @@ -8146,15 +8144,6 @@ __metadata: languageName: node linkType: hard -"@types/ramda@npm:^0.30.2": - version: 0.30.2 - resolution: "@types/ramda@npm:0.30.2" - dependencies: - types-ramda: "npm:^0.30.1" - checksum: 10c0/dda95008860f594eb7b4fd9819adeb2dcd4d4e2baca6cb33f692f6f8ea76d04a7fd81f9a057c5c67555612769e5592cb15f91de6c9f8b619b8b1d806d19dc9ea - languageName: node - linkType: hard - "@types/range-parser@npm:*": version: 1.2.5 resolution: "@types/range-parser@npm:1.2.5" @@ -23573,13 +23562,6 @@ __metadata: languageName: node linkType: hard -"ramda@npm:^0.30.1": - version: 0.30.1 - resolution: "ramda@npm:0.30.1" - checksum: 10c0/3ea3e35c80e1a1b78c23de0c72d3382c3446f42052b113b851f1b7fc421e33a45ce92e7aef3c705cc6de3812a209d03417af5c264f67126cda539fd66c8bea71 - languageName: node - linkType: hard - "randombytes@npm:^2.0.0, randombytes@npm:^2.0.1, randombytes@npm:^2.0.5, randombytes@npm:^2.1.0": version: 2.1.0 resolution: "randombytes@npm:2.1.0" @@ -27336,13 +27318,6 @@ __metadata: languageName: node linkType: hard -"ts-toolbelt@npm:^9.6.0": - version: 9.6.0 - resolution: "ts-toolbelt@npm:9.6.0" - checksum: 10c0/838f9a2f0fe881d5065257a23b402c41315b33ff987b73db3e2b39fcb70640c4c7220e1ef118ed5676763543724fdbf4eda7b0e2c17acb667ed1401336af9f8c - languageName: node - linkType: hard - "tsconfig-paths-webpack-plugin@npm:^4.0.1": version: 4.1.0 resolution: "tsconfig-paths-webpack-plugin@npm:4.1.0" @@ -27526,15 +27501,6 @@ __metadata: languageName: node linkType: hard -"types-ramda@npm:^0.30.1": - version: 0.30.1 - resolution: "types-ramda@npm:0.30.1" - dependencies: - ts-toolbelt: "npm:^9.6.0" - checksum: 10c0/4a8b230ae9772e6534f65b1a154dd5604bcd1d74e27b49686337a215e83aa8fc93e49f8c49af395418d2950cb9fb9b900662077c1d4b73ff6fe4f4bcb83ab2d6 - languageName: node - linkType: hard - "typescript@npm:^3.8.3": version: 3.9.10 resolution: "typescript@npm:3.9.10" From a4e35ec921a948026e6cc63d2db2f9e1db2c05f5 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 13:33:39 +0200 Subject: [PATCH 18/41] fix --- code/core/src/common/utils/file-cache.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index 6e2a9d545bf9..c44e4dc66038 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -65,7 +65,7 @@ export class FileSystemCache { return JSON.stringify({ key, content: data, ...(ttl && { ttl: Date.now() + ttl * 1000 }) }); } - public async get( + public async get( name: string, fallback: T | null = null, opts?: CacheSetOptions From 9e050395f156dffdb8ee4f75207755d80a0f1b1e Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 13:42:44 +0200 Subject: [PATCH 19/41] fix --- code/__mocks__/fs.ts | 2 ++ code/core/src/cli/detect.test.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/code/__mocks__/fs.ts b/code/__mocks__/fs.ts index 50e34e8e4ca1..f617d31141f6 100644 --- a/code/__mocks__/fs.ts +++ b/code/__mocks__/fs.ts @@ -19,6 +19,7 @@ export const realpathSync = vi.fn(); export const readdir = vi.fn(); export const readdirSync = vi.fn(); export const readlinkSync = vi.fn(); +export const mkdirSync = vi.fn(); export default { __setMockFiles, @@ -29,4 +30,5 @@ export default { readdir, readdirSync, readlinkSync, + mkdirSync, }; diff --git a/code/core/src/cli/detect.test.ts b/code/core/src/cli/detect.test.ts index 95c1b126dca3..ea7f8139fda3 100644 --- a/code/core/src/cli/detect.test.ts +++ b/code/core/src/cli/detect.test.ts @@ -24,6 +24,7 @@ vi.mock('fs', () => ({ readdirSync: vi.fn(), readlinkSync: vi.fn(), default: vi.fn(), + mkdirSync: vi.fn(), })); vi.mock('@storybook/core/node-logger'); From c36ee50b67be7917b46c7acc5e63e1915abbf671 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 15:17:40 +0200 Subject: [PATCH 20/41] simplifications, fixes, and make webpack progress actually represent the modules, instead of entrypoints... --- code/builders/builder-webpack5/src/index.ts | 4 +- .../src/preview/iframe-webpack.config.ts | 4 +- code/core/src/common/utils/file-cache.ts | 38 ++++++++----------- 3 files changed, 19 insertions(+), 27 deletions(-) diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index ffc11812562b..e35ced7be073 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -137,7 +137,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ } yield; - const modulesCount = (await options.cache?.get('modulesCount').catch(() => {})) || 1000; + const modulesCount = await options.cache?.get('modulesCount', 1000); let totalModules: number; let value = 0; @@ -147,7 +147,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ const progress = { value, message: message.charAt(0).toUpperCase() + message.slice(1) }; if (message === 'building') { // arg3 undefined in webpack5 - const counts = (arg3 && arg3.match(/(\d+)\/(\d+)/)) || []; + const counts = (arg3 && arg3.match(/entries (\d+)\/(\d+)/)) || []; const complete = parseInt(counts[1], 10); const total = parseInt(counts[2], 10); if (!Number.isNaN(complete) && !Number.isNaN(total)) { diff --git a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts index ea8b55d4973c..763f2bf15646 100644 --- a/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts +++ b/code/builders/builder-webpack5/src/preview/iframe-webpack.config.ts @@ -72,7 +72,7 @@ export default async ( docsOptions, entries, nonNormalizedStories, - modulesCount = 1000, + modulesCount, build, tagsOptions, ] = await Promise.all([ @@ -86,7 +86,7 @@ export default async ( presets.apply('docs'), presets.apply('entries', []), presets.apply('stories', []), - options.cache?.get('modulesCount').catch(() => {}), + options.cache?.get('modulesCount', 1000), options.presets.apply('build'), presets.apply('tags', {}), ]); diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index c44e4dc66038..3dd7849abd66 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -1,6 +1,6 @@ import { createHash, randomBytes } from 'node:crypto'; import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; -import { promises as fsPromises } from 'node:fs'; +import { readFile, readdir, rm, writeFile } from 'node:fs/promises'; import { tmpdir } from 'node:os'; import { join } from 'node:path'; @@ -51,11 +51,7 @@ export class FileSystemCache { return parsed.ttl != null && now > parsed.ttl; } - private parseCacheData( - data: string, - fallback: T | null, - opts: CacheSetOptions = {} - ): T | null { + private parseCacheData(data: string, fallback: T | null): T | null { const parsed = JSON.parse(data); return this.isExpired(parsed, Date.now()) ? fallback : (parsed.content as T); } @@ -65,25 +61,21 @@ export class FileSystemCache { return JSON.stringify({ key, content: data, ...(ttl && { ttl: Date.now() + ttl * 1000 }) }); } - public async get( - name: string, - fallback: T | null = null, - opts?: CacheSetOptions - ): Promise { + public async get(name: string, fallback?: T): Promise { try { - const data = await fsPromises.readFile(this.generateHash(name), 'utf8'); - return this.parseCacheData(data, fallback, opts); + const data = await readFile(this.generateHash(name), 'utf8'); + return this.parseCacheData(data, fallback) as T; } catch { - return fallback; + return fallback as T; } } - public getSync(name: string, fallback: T | null = null, opts?: CacheSetOptions): T | null { + public getSync(name: string, fallback?: T): T { try { const data = readFileSync(this.generateHash(name), 'utf8'); - return this.parseCacheData(data, fallback, opts); + return this.parseCacheData(data, fallback) as T; } catch { - return fallback; + return fallback as T; } } @@ -93,7 +85,7 @@ export class FileSystemCache { orgOpts: CacheSetOptions | number = {} ): Promise { const opts: CacheSetOptions = typeof orgOpts === 'number' ? { ttl: orgOpts } : orgOpts; - await fsPromises.writeFile(this.generateHash(name), this.parseSetData(name, data, opts), { + await writeFile(this.generateHash(name), this.parseSetData(name, data, opts), { encoding: opts.encoding || 'utf8', }); } @@ -114,7 +106,7 @@ export class FileSystemCache { } public async remove(name: string): Promise { - await fsPromises.rm(this.generateHash(name), { force: true }); + await rm(this.generateHash(name), { force: true }); } public removeSync(name: string): void { @@ -122,11 +114,11 @@ export class FileSystemCache { } public async clear(): Promise { - const files = await fsPromises.readdir(this.cache_dir); + const files = await readdir(this.cache_dir); await Promise.all( files .filter((f) => f.startsWith(this.prefix)) - .map((f) => fsPromises.rm(join(this.cache_dir, f), { force: true })) + .map((f) => rm(join(this.cache_dir, f), { force: true })) ); } @@ -138,11 +130,11 @@ export class FileSystemCache { public async getAll(): Promise { const now = Date.now(); - const files = await fsPromises.readdir(this.cache_dir); + const files = await readdir(this.cache_dir); const items = await Promise.all( files .filter((f) => f.startsWith(this.prefix)) - .map((f) => fsPromises.readFile(join(this.cache_dir, f), 'utf8')) + .map((f) => readFile(join(this.cache_dir, f), 'utf8')) ); return items .map((data) => JSON.parse(data)) From 0080cf2b450a30ca07fdd4999dee92be235263e1 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 15:58:19 +0200 Subject: [PATCH 21/41] fix typing issue --- code/core/src/common/utils/file-cache.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index 3dd7849abd66..3c9fd7d10789 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -24,8 +24,6 @@ interface CacheSetOptions { } export class FileSystemCache { - private id = randomBytes(15).toString('base64').replace(/\//g, '-'); - private prefix: string; private hash_alg: string; @@ -37,7 +35,8 @@ export class FileSystemCache { constructor(options: FileSystemCacheOptions = {}) { this.prefix = (options.ns || options.prefix || '') + '-'; this.hash_alg = options.hash_alg || 'md5'; - this.cache_dir = options.basePath || join(tmpdir(), this.id); + this.cache_dir = + options.basePath || join(tmpdir(), randomBytes(15).toString('base64').replace(/\//g, '-')); this.ttl = options.ttl || 0; createHash(this.hash_alg); // Verifies hash algorithm is available mkdirSync(this.cache_dir, { recursive: true }); From 219b7d7cb1662799b9a7af0c25e86830c3e192c2 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 16:10:10 +0200 Subject: [PATCH 22/41] fix typing issues proper --- code/core/src/cli/dev.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/code/core/src/cli/dev.ts b/code/core/src/cli/dev.ts index 6d05f140fa38..26ff6250f3a8 100644 --- a/code/core/src/cli/dev.ts +++ b/code/core/src/cli/dev.ts @@ -44,14 +44,16 @@ export const dev = async (cliOptions: CLIOptions) => { const packageJson = await findPackage(__dirname); invariant(packageJson, 'Failed to find the closest package.json file.'); + type Options = Parameters[0]; + const options = { ...cliOptions, configDir: cliOptions.configDir || './.storybook', configType: 'DEVELOPMENT', ignorePreview: !!cliOptions.previewUrl && !cliOptions.forceBuildPreview, - cache, + cache: cache as any, packageJson, - } as Parameters[0]; + } as Options; await withTelemetry( 'dev', From 3116f88a6459b8a6e7385f7160b5bf974c31ae99 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 16:26:43 +0200 Subject: [PATCH 23/41] set up the linting plugin --- code/package.json | 1 + code/yarn.lock | 19 +++++++++++++++++++ scripts/.eslintrc.cjs | 10 +++++++++- scripts/package.json | 1 + scripts/yarn.lock | 37 +++++++++++++++++++++++++++++++++++++ 5 files changed, 67 insertions(+), 1 deletion(-) diff --git a/code/package.json b/code/package.json index 6619f4e0b187..a62be2693a17 100644 --- a/code/package.json +++ b/code/package.json @@ -191,6 +191,7 @@ "esbuild-plugin-alias": "^0.2.1", "eslint": "^8.56.0", "eslint-import-resolver-typescript": "^3.6.1", + "eslint-plugin-depend": "^0.11.0", "eslint-plugin-local-rules": "portal:../scripts/eslint-plugin-local-rules", "eslint-plugin-playwright": "^1.6.2", "eslint-plugin-storybook": "^0.8.0", diff --git a/code/yarn.lock b/code/yarn.lock index 1b04c78853dc..f71bd7d4d3b6 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6891,6 +6891,7 @@ __metadata: esbuild-plugin-alias: "npm:^0.2.1" eslint: "npm:^8.56.0" eslint-import-resolver-typescript: "npm:^3.6.1" + eslint-plugin-depend: "npm:^0.11.0" eslint-plugin-local-rules: "portal:../scripts/eslint-plugin-local-rules" eslint-plugin-playwright: "npm:^1.6.2" eslint-plugin-storybook: "npm:^0.8.0" @@ -14336,6 +14337,17 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-depend@npm:^0.11.0": + version: 0.11.0 + resolution: "eslint-plugin-depend@npm:0.11.0" + dependencies: + fd-package-json: "npm:^1.2.0" + module-replacements: "npm:^2.1.0" + semver: "npm:^7.6.3" + checksum: 10c0/64baf4d4f5d406efa1f13bda723ff0eb5fe4cee0ae8c3679fcdfccb4d7ba3a9472416fa3c54d75f1bde3e0123e55a85774662484a5b0355812f21a8968ee784a + languageName: node + linkType: hard + "eslint-plugin-eslint-comments@npm:^3.2.0": version: 3.2.0 resolution: "eslint-plugin-eslint-comments@npm:3.2.0" @@ -21040,6 +21052,13 @@ __metadata: languageName: node linkType: hard +"module-replacements@npm:^2.1.0": + version: 2.5.0 + resolution: "module-replacements@npm:2.5.0" + checksum: 10c0/7fcbcb19151778a2f2fa70b7bffb134bb8922b2306e2a0d7b4a863467a9d6d9d5fed537763c43272e22b69dbddaf1610746b42a68b4663aa225e85f9ae9b03c8 + languageName: node + linkType: hard + "mri@npm:^1.1.0, mri@npm:^1.2.0": version: 1.2.0 resolution: "mri@npm:1.2.0" diff --git a/scripts/.eslintrc.cjs b/scripts/.eslintrc.cjs index 2af8b19b61c1..b49fe70944d0 100644 --- a/scripts/.eslintrc.cjs +++ b/scripts/.eslintrc.cjs @@ -1,6 +1,11 @@ module.exports = { root: true, - extends: ['@storybook/eslint-config-storybook', 'plugin:storybook/recommended'], + extends: [ + // + '@storybook/eslint-config-storybook', + 'plugin:storybook/recommended', + 'plugin:depend/recommended' + ], parserOptions: { tsconfigRootDir: __dirname, project: ['./tsconfig.json'], @@ -11,6 +16,9 @@ module.exports = { '@typescript-eslint/consistent-type-imports': ['error', { disallowTypeAnnotations: false }], 'no-use-before-define': 'off', 'eslint-comments/disable-enable-pair': ['error', { allowWholeFile: true }], + "depend/ban-dependencies": ["error", { + "modules": ["lodash", "chalk", "qs", "handlebars", "fs-extra"] + }] }, overrides: [ { diff --git a/scripts/package.json b/scripts/package.json index d38128434b76..fa651f004959 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -112,6 +112,7 @@ "eslint": "^8.57.0", "eslint-config-airbnb-typescript": "^18.0.0", "eslint-config-prettier": "^9.1.0", + "eslint-plugin-depend": "^0.11.0", "eslint-plugin-eslint-comments": "^3.2.0", "eslint-plugin-file-progress": "^1.4.0", "eslint-plugin-html": "^8.1.1", diff --git a/scripts/yarn.lock b/scripts/yarn.lock index a17539cb16d5..72976374f403 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -1576,6 +1576,7 @@ __metadata: eslint: "npm:^8.57.0" eslint-config-airbnb-typescript: "npm:^18.0.0" eslint-config-prettier: "npm:^9.1.0" + eslint-plugin-depend: "npm:^0.11.0" eslint-plugin-eslint-comments: "npm:^3.2.0" eslint-plugin-file-progress: "npm:^1.4.0" eslint-plugin-html: "npm:^8.1.1" @@ -5517,6 +5518,17 @@ __metadata: languageName: node linkType: hard +"eslint-plugin-depend@npm:^0.11.0": + version: 0.11.0 + resolution: "eslint-plugin-depend@npm:0.11.0" + dependencies: + fd-package-json: "npm:^1.2.0" + module-replacements: "npm:^2.1.0" + semver: "npm:^7.6.3" + checksum: 10c0/64baf4d4f5d406efa1f13bda723ff0eb5fe4cee0ae8c3679fcdfccb4d7ba3a9472416fa3c54d75f1bde3e0123e55a85774662484a5b0355812f21a8968ee784a + languageName: node + linkType: hard + "eslint-plugin-eslint-comments@npm:^3.2.0": version: 3.2.0 resolution: "eslint-plugin-eslint-comments@npm:3.2.0" @@ -6182,6 +6194,15 @@ __metadata: languageName: node linkType: hard +"fd-package-json@npm:^1.2.0": + version: 1.2.0 + resolution: "fd-package-json@npm:1.2.0" + dependencies: + walk-up-path: "npm:^3.0.1" + checksum: 10c0/712a78a12bd8ec8482867b26bbcb2ff1dca9b096a416150c138e1512f1879c6d23dfb41b03b8e9226afc1e58a35df4738e9f9ae57032ff1dbbae75acfb70343b + languageName: node + linkType: hard + "fd-slicer@npm:~1.1.0": version: 1.1.0 resolution: "fd-slicer@npm:1.1.0" @@ -9820,6 +9841,13 @@ __metadata: languageName: node linkType: hard +"module-replacements@npm:^2.1.0": + version: 2.5.0 + resolution: "module-replacements@npm:2.5.0" + checksum: 10c0/7fcbcb19151778a2f2fa70b7bffb134bb8922b2306e2a0d7b4a863467a9d6d9d5fed537763c43272e22b69dbddaf1610746b42a68b4663aa225e85f9ae9b03c8 + languageName: node + linkType: hard + "mount-point@npm:^3.0.0": version: 3.0.0 resolution: "mount-point@npm:3.0.0" @@ -12381,6 +12409,15 @@ __metadata: languageName: node linkType: hard +"semver@npm:^7.6.3": + version: 7.6.3 + resolution: "semver@npm:7.6.3" + bin: + semver: bin/semver.js + checksum: 10c0/88f33e148b210c153873cb08cfe1e281d518aaa9a666d4d148add6560db5cd3c582f3a08ccb91f38d5f379ead256da9931234ed122057f40bb5766e65e58adaf + languageName: node + linkType: hard + "send@npm:0.18.0": version: 0.18.0 resolution: "send@npm:0.18.0" From c2233ad230363d04c9f8ce5bde9026997f598854 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Wed, 2 Oct 2024 17:07:43 +0200 Subject: [PATCH 24/41] add ignores for disallowed packages --- code/builders/builder-vite/src/list-stories.ts | 1 + code/core/src/common/js-package-manager/JsPackageManager.ts | 4 ++-- code/core/src/common/utils/validate-configuration-files.ts | 1 + code/core/src/core-server/utils/StoryIndexGenerator.ts | 1 + .../core-server/utils/__tests__/remove-mdx-stories.test.ts | 1 + code/core/src/core-server/utils/remove-mdx-entries.ts | 1 + code/core/src/core-server/utils/search-files.ts | 1 + code/core/src/core-server/utils/watch-story-specifiers.ts | 1 + code/core/src/telemetry/get-portable-stories-usage.ts | 1 + code/lib/cli-storybook/src/automigrate/fixes/mdx-1-to-3.ts | 1 + code/lib/cli-storybook/src/automigrate/fixes/mdx-gfm.ts | 1 + code/lib/cli-storybook/src/automigrate/fixes/mdx-to-csf.ts | 1 + .../src/automigrate/fixes/missing-storybook-dependencies.ts | 1 + .../src/automigrate/fixes/prompt-remove-react.test.ts | 1 + code/lib/cli-storybook/src/warn.ts | 1 + code/lib/codemod/src/index.ts | 1 + code/lib/create-storybook/src/generators/baseGenerator.ts | 1 + code/lib/create-storybook/src/scaffold-new-project.ts | 1 + scripts/bench/utils.ts | 1 + scripts/build-package.ts | 2 ++ scripts/check-package.ts | 2 ++ scripts/combine-compodoc.ts | 3 +++ scripts/dangerfile.ts | 3 +++ scripts/get-report-message.ts | 2 ++ scripts/get-template.ts | 1 + scripts/knip.config.ts | 1 + scripts/prepare/addon-bundle.ts | 2 ++ scripts/prepare/bundle.ts | 2 ++ scripts/prepare/check.ts | 1 + scripts/prepare/tools.ts | 2 ++ scripts/prepare/tsc.ts | 2 ++ scripts/release/__tests__/is-pr-frozen.test.ts | 1 + scripts/release/__tests__/version.test.ts | 2 ++ scripts/release/__tests__/write-changelog.test.ts | 1 + scripts/release/get-changelog-from-file.ts | 1 + scripts/release/get-current-version.ts | 1 + scripts/release/is-pr-frozen.ts | 1 + scripts/release/label-patches.ts | 1 + scripts/release/pick-patches.ts | 1 + scripts/release/publish.ts | 2 ++ scripts/release/version.ts | 2 ++ scripts/release/write-changelog.ts | 1 + scripts/reset.js | 1 + scripts/run-registry.ts | 2 ++ scripts/sandbox/generate.ts | 3 +++ scripts/sandbox/publish.ts | 3 +++ scripts/sandbox/utils/git.ts | 1 + scripts/sandbox/utils/template.ts | 1 + scripts/sandbox/utils/yarn.ts | 1 + scripts/strict-ts.ts | 1 + scripts/task.ts | 1 + scripts/tasks/build.ts | 1 + scripts/tasks/compile.ts | 1 + scripts/tasks/generate.ts | 1 + scripts/tasks/install.ts | 1 + scripts/tasks/publish.ts | 1 + scripts/tasks/sandbox-parts.ts | 1 + scripts/tasks/sandbox.ts | 1 + scripts/upload-bench.ts | 1 + scripts/utils/exec.ts | 4 ++-- scripts/utils/filterExistsInCodeDir.ts | 1 + scripts/utils/package-json.ts | 1 + scripts/utils/paths.ts | 1 + scripts/utils/workspace.ts | 1 + scripts/utils/yarn.ts | 1 + scripts/vite-ecosystem-ci/before-test.js | 3 ++- 66 files changed, 88 insertions(+), 5 deletions(-) diff --git a/code/builders/builder-vite/src/list-stories.ts b/code/builders/builder-vite/src/list-stories.ts index 5eefb9b8fb74..d5b417f2553c 100644 --- a/code/builders/builder-vite/src/list-stories.ts +++ b/code/builders/builder-vite/src/list-stories.ts @@ -3,6 +3,7 @@ import { isAbsolute, join } from 'node:path'; import { commonGlobOptions, normalizeStories } from 'storybook/internal/common'; import type { Options } from 'storybook/internal/types'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import slash from 'slash'; diff --git a/code/core/src/common/js-package-manager/JsPackageManager.ts b/code/core/src/common/js-package-manager/JsPackageManager.ts index 5b0bdde0fdb6..21f870852d4d 100644 --- a/code/core/src/common/js-package-manager/JsPackageManager.ts +++ b/code/core/src/common/js-package-manager/JsPackageManager.ts @@ -2,8 +2,8 @@ import { existsSync, readFileSync } from 'node:fs'; import { readFile, writeFile } from 'node:fs/promises'; import { dirname, resolve } from 'node:path'; -import type { CommonOptions } from 'execa'; -import { execaCommand, execaCommandSync } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies +import { type CommonOptions, execaCommand, execaCommandSync } from 'execa'; import picocolors from 'picocolors'; import { gt, satisfies } from 'semver'; import invariant from 'tiny-invariant'; diff --git a/code/core/src/common/utils/validate-configuration-files.ts b/code/core/src/common/utils/validate-configuration-files.ts index 3e35a6f2bafb..ccd0dba864ea 100644 --- a/code/core/src/common/utils/validate-configuration-files.ts +++ b/code/core/src/common/utils/validate-configuration-files.ts @@ -3,6 +3,7 @@ import { resolve } from 'node:path'; import { once } from '@storybook/core/node-logger'; import { MainFileMissingError } from '@storybook/core/server-errors'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import slash from 'slash'; import { dedent } from 'ts-dedent'; diff --git a/code/core/src/core-server/utils/StoryIndexGenerator.ts b/code/core/src/core-server/utils/StoryIndexGenerator.ts index aed65a46bf6b..164613d7e4c2 100644 --- a/code/core/src/core-server/utils/StoryIndexGenerator.ts +++ b/code/core/src/core-server/utils/StoryIndexGenerator.ts @@ -130,6 +130,7 @@ export class StoryIndexGenerator { const fullGlob = slash(join(specifier.directory, specifier.files)); // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); const files = await globby(fullGlob, { diff --git a/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts b/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts index f1342ad48a9a..87fe8317ea35 100644 --- a/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts +++ b/code/core/src/core-server/utils/__tests__/remove-mdx-stories.test.ts @@ -5,6 +5,7 @@ import { describe, expect, it, vi } from 'vitest'; import { normalizeStoriesEntry } from '@storybook/core/common'; import { type StoriesEntry } from '@storybook/core/types'; +// eslint-disable-next-line depend/ban-dependencies import { glob as globOriginal } from 'glob'; import slash from 'slash'; diff --git a/code/core/src/core-server/utils/remove-mdx-entries.ts b/code/core/src/core-server/utils/remove-mdx-entries.ts index f71488712a49..da431155016a 100644 --- a/code/core/src/core-server/utils/remove-mdx-entries.ts +++ b/code/core/src/core-server/utils/remove-mdx-entries.ts @@ -3,6 +3,7 @@ import { isAbsolute, join, relative } from 'node:path'; import { commonGlobOptions, normalizeStories } from '@storybook/core/common'; import type { Options, StoriesEntry } from '@storybook/core/types'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import slash from 'slash'; diff --git a/code/core/src/core-server/utils/search-files.ts b/code/core/src/core-server/utils/search-files.ts index b0e743895aa9..723f74341b34 100644 --- a/code/core/src/core-server/utils/search-files.ts +++ b/code/core/src/core-server/utils/search-files.ts @@ -31,6 +31,7 @@ export async function searchFiles({ fileExtensions?: string[]; }): Promise { // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby, isDynamicPattern } = await import('globby'); const hasSearchSpecialGlobChars = isDynamicPattern(searchQuery, { cwd }); diff --git a/code/core/src/core-server/utils/watch-story-specifiers.ts b/code/core/src/core-server/utils/watch-story-specifiers.ts index b320520dc9a4..6fa8d3e83a6f 100644 --- a/code/core/src/core-server/utils/watch-story-specifiers.ts +++ b/code/core/src/core-server/utils/watch-story-specifiers.ts @@ -97,6 +97,7 @@ export function watchStorySpecifiers( ); // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); // glob only supports forward slashes diff --git a/code/core/src/telemetry/get-portable-stories-usage.ts b/code/core/src/telemetry/get-portable-stories-usage.ts index e328a3283c57..cd9da7f4f589 100644 --- a/code/core/src/telemetry/get-portable-stories-usage.ts +++ b/code/core/src/telemetry/get-portable-stories-usage.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import { createFileSystemCache, resolvePathInStorybookCache } from '../common'; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/mdx-1-to-3.ts b/code/lib/cli-storybook/src/automigrate/fixes/mdx-1-to-3.ts index e53ee7cde234..155ee08246f6 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/mdx-1-to-3.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/mdx-1-to-3.ts @@ -51,6 +51,7 @@ export const mdx1to3: Fix = { async check() { // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); const storiesMdxFiles = await globby('./!(node_modules)**/*.(story|stories).mdx'); diff --git a/code/lib/cli-storybook/src/automigrate/fixes/mdx-gfm.ts b/code/lib/cli-storybook/src/automigrate/fixes/mdx-gfm.ts index 8369f8896ef3..41fc1b4a3a0b 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/mdx-gfm.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/mdx-gfm.ts @@ -47,6 +47,7 @@ export const mdxgfm: Fix = { } // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); const files = await globby(pattern, commonGlobOptions(pattern)); diff --git a/code/lib/cli-storybook/src/automigrate/fixes/mdx-to-csf.ts b/code/lib/cli-storybook/src/automigrate/fixes/mdx-to-csf.ts index 55e36258c9cd..217b3dcacb93 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/mdx-to-csf.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/mdx-to-csf.ts @@ -2,6 +2,7 @@ import type { StoriesEntry } from 'storybook/internal/types'; import { runCodemod } from '@storybook/codemod'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import picocolors from 'picocolors'; import { prompt } from 'prompts'; diff --git a/code/lib/cli-storybook/src/automigrate/fixes/missing-storybook-dependencies.ts b/code/lib/cli-storybook/src/automigrate/fixes/missing-storybook-dependencies.ts index 9b5892b51a32..8eda42d9b9ba 100644 --- a/code/lib/cli-storybook/src/automigrate/fixes/missing-storybook-dependencies.ts +++ b/code/lib/cli-storybook/src/automigrate/fixes/missing-storybook-dependencies.ts @@ -70,6 +70,7 @@ export const missingStorybookDependencies: Fix { if (!hasTSDependency) { // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); const files = await globby(['**/*.@(ts|tsx)', '!**/node_modules', '!**/*.d.ts']); diff --git a/code/lib/codemod/src/index.ts b/code/lib/codemod/src/index.ts index ec80bd250d3f..80bc90932918 100644 --- a/code/lib/codemod/src/index.ts +++ b/code/lib/codemod/src/index.ts @@ -65,6 +65,7 @@ export async function runCodemod( } // Dynamically import globby because it is a pure ESM module + // eslint-disable-next-line depend/ban-dependencies const { globby } = await import('globby'); const files = await globby([glob, '!**/node_modules', '!**/dist']); diff --git a/code/lib/create-storybook/src/generators/baseGenerator.ts b/code/lib/create-storybook/src/generators/baseGenerator.ts index b1aea02b11e1..1a44e3ba272b 100644 --- a/code/lib/create-storybook/src/generators/baseGenerator.ts +++ b/code/lib/create-storybook/src/generators/baseGenerator.ts @@ -11,6 +11,7 @@ import type { JsPackageManager } from 'storybook/internal/common'; import { getPackageDetails, versions as packageVersions } from 'storybook/internal/common'; import type { SupportedFrameworks } from 'storybook/internal/types'; +// eslint-disable-next-line depend/ban-dependencies import ora from 'ora'; import invariant from 'tiny-invariant'; import { dedent } from 'ts-dedent'; diff --git a/code/lib/create-storybook/src/scaffold-new-project.ts b/code/lib/create-storybook/src/scaffold-new-project.ts index f41d9c876010..c07ff8c9fba4 100644 --- a/code/lib/create-storybook/src/scaffold-new-project.ts +++ b/code/lib/create-storybook/src/scaffold-new-project.ts @@ -7,6 +7,7 @@ import { GenerateNewProjectOnInitError } from 'storybook/internal/server-errors' import { telemetry } from 'storybook/internal/telemetry'; import boxen from 'boxen'; +// eslint-disable-next-line depend/ban-dependencies import execa from 'execa'; import picocolors from 'picocolors'; import prompts from 'prompts'; diff --git a/scripts/bench/utils.ts b/scripts/bench/utils.ts index 1bd3a3f849ae..673fb56c4360 100644 --- a/scripts/bench/utils.ts +++ b/scripts/bench/utils.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { ensureDir, readJSON, readdir, writeJSON } from 'fs-extra'; import { join } from 'path'; import type { Page } from 'playwright-core'; diff --git a/scripts/build-package.ts b/scripts/build-package.ts index 96ddb84c2fbc..d1d1f147e69c 100644 --- a/scripts/build-package.ts +++ b/scripts/build-package.ts @@ -1,5 +1,7 @@ import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { readJSON } from 'fs-extra'; import { posix, resolve, sep } from 'path'; import picocolors from 'picocolors'; diff --git a/scripts/check-package.ts b/scripts/check-package.ts index 8b9c49985fb5..035ae8a74ec6 100644 --- a/scripts/check-package.ts +++ b/scripts/check-package.ts @@ -2,7 +2,9 @@ // without having to build dts files for all packages in the monorepo. // It is not implemented yet for angular, svelte and vue. import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { readJSON } from 'fs-extra'; import { resolve } from 'path'; import picocolors from 'picocolors'; diff --git a/scripts/combine-compodoc.ts b/scripts/combine-compodoc.ts index eefc905fc132..7b934854d015 100755 --- a/scripts/combine-compodoc.ts +++ b/scripts/combine-compodoc.ts @@ -1,8 +1,11 @@ // Compodoc does not follow symlinks (it ignores them and their contents entirely) // So, we need to run a separate compodoc process on every symlink inside the project, // then combine the results into one large documentation.json +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { lstat, readFile, realpath, writeFile } from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { globSync } from 'glob'; import { join, resolve } from 'path'; diff --git a/scripts/dangerfile.ts b/scripts/dangerfile.ts index 93382ae441cf..961d77cbd2f8 100644 --- a/scripts/dangerfile.ts +++ b/scripts/dangerfile.ts @@ -4,8 +4,11 @@ import { danger, fail } from 'danger'; execSync('npm install lodash'); +// eslint-disable-next-line depend/ban-dependencies const flatten = require('lodash/flatten.js'); +// eslint-disable-next-line depend/ban-dependencies const intersection = require('lodash/intersection.js'); +// eslint-disable-next-line depend/ban-dependencies const isEmpty = require('lodash/isEmpty.js'); const pkg = require('../code/package.json'); diff --git a/scripts/get-report-message.ts b/scripts/get-report-message.ts index 4774bc0f8ca2..60f556b91014 100644 --- a/scripts/get-report-message.ts +++ b/scripts/get-report-message.ts @@ -1,4 +1,6 @@ +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { readJson } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/get-template.ts b/scripts/get-template.ts index 728632392489..cb351eab0410 100644 --- a/scripts/get-template.ts +++ b/scripts/get-template.ts @@ -1,4 +1,5 @@ import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists, readFile } from 'fs-extra'; import { readdir } from 'fs/promises'; import picocolors from 'picocolors'; diff --git a/scripts/knip.config.ts b/scripts/knip.config.ts index ef23f8c556bd..c57b570a8ac0 100644 --- a/scripts/knip.config.ts +++ b/scripts/knip.config.ts @@ -1,5 +1,6 @@ import { join, relative } from 'node:path'; +// eslint-disable-next-line depend/ban-dependencies import fg from 'fast-glob'; import type { KnipConfig } from 'knip'; import { match } from 'minimatch'; diff --git a/scripts/prepare/addon-bundle.ts b/scripts/prepare/addon-bundle.ts index fa5e14a0e4c4..16683ea38ff2 100755 --- a/scripts/prepare/addon-bundle.ts +++ b/scripts/prepare/addon-bundle.ts @@ -3,7 +3,9 @@ import { builtinModules } from 'node:module'; import type { Metafile } from 'esbuild'; import aliasPlugin from 'esbuild-plugin-alias'; +// eslint-disable-next-line depend/ban-dependencies import * as fs from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import { dirname, join, parse, posix, relative, sep } from 'path'; import slash from 'slash'; diff --git a/scripts/prepare/bundle.ts b/scripts/prepare/bundle.ts index 4651774257c8..d3a671034d17 100755 --- a/scripts/prepare/bundle.ts +++ b/scripts/prepare/bundle.ts @@ -3,7 +3,9 @@ import { dirname, join, parse, posix, relative, resolve, sep } from 'node:path'; import type { Metafile } from 'esbuild'; import aliasPlugin from 'esbuild-plugin-alias'; +// eslint-disable-next-line depend/ban-dependencies import * as fs from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import slash from 'slash'; import { dedent } from 'ts-dedent'; diff --git a/scripts/prepare/check.ts b/scripts/prepare/check.ts index dbf09429492b..0462b6094464 100755 --- a/scripts/prepare/check.ts +++ b/scripts/prepare/check.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import fs from 'fs-extra'; import { join } from 'path'; import ts from 'typescript'; diff --git a/scripts/prepare/tools.ts b/scripts/prepare/tools.ts index eb4214a945ba..d2c58b420833 100644 --- a/scripts/prepare/tools.ts +++ b/scripts/prepare/tools.ts @@ -5,7 +5,9 @@ import * as process from 'node:process'; import { globalExternals } from '@fal-works/esbuild-plugin-global-externals'; import { spawn } from 'cross-spawn'; import * as esbuild from 'esbuild'; +// eslint-disable-next-line depend/ban-dependencies import { readJson } from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import limit from 'p-limit'; import picocolors from 'picocolors'; diff --git a/scripts/prepare/tsc.ts b/scripts/prepare/tsc.ts index 6a6aba2643bd..af6b39e15050 100755 --- a/scripts/prepare/tsc.ts +++ b/scripts/prepare/tsc.ts @@ -1,4 +1,6 @@ +// eslint-disable-next-line depend/ban-dependencies import { emptyDir, move, readJson } from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { globSync } from 'glob'; import { join } from 'path'; import * as ts from 'typescript'; diff --git a/scripts/release/__tests__/is-pr-frozen.test.ts b/scripts/release/__tests__/is-pr-frozen.test.ts index 681069af7256..27baeaa4a723 100644 --- a/scripts/release/__tests__/is-pr-frozen.test.ts +++ b/scripts/release/__tests__/is-pr-frozen.test.ts @@ -3,6 +3,7 @@ import { join } from 'node:path'; import { describe, expect, it, vi } from 'vitest'; +// eslint-disable-next-line depend/ban-dependencies import * as fsExtraImp from 'fs-extra'; import * as simpleGitImp from 'simple-git'; diff --git a/scripts/release/__tests__/version.test.ts b/scripts/release/__tests__/version.test.ts index 3572e4cb76ee..58dd785c0284 100644 --- a/scripts/release/__tests__/version.test.ts +++ b/scripts/release/__tests__/version.test.ts @@ -3,7 +3,9 @@ import { join } from 'node:path'; import { describe, expect, it, vi } from 'vitest'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import * as fsExtraImp from 'fs-extra'; import type * as MockedFSToExtra from '../../../code/__mocks__/fs-extra'; diff --git a/scripts/release/__tests__/write-changelog.test.ts b/scripts/release/__tests__/write-changelog.test.ts index f0346066b26c..59e1ccb6fd60 100644 --- a/scripts/release/__tests__/write-changelog.test.ts +++ b/scripts/release/__tests__/write-changelog.test.ts @@ -3,6 +3,7 @@ import { join } from 'node:path'; import { beforeEach, describe, expect, it, vi } from 'vitest'; +// eslint-disable-next-line depend/ban-dependencies import * as fsExtraImp from 'fs-extra'; import { dedent } from 'ts-dedent'; diff --git a/scripts/release/get-changelog-from-file.ts b/scripts/release/get-changelog-from-file.ts index 354605e04644..de8bc4e386e9 100644 --- a/scripts/release/get-changelog-from-file.ts +++ b/scripts/release/get-changelog-from-file.ts @@ -2,6 +2,7 @@ import { join } from 'node:path'; import { setOutput } from '@actions/core'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { readFile } from 'fs-extra'; import picocolors from 'picocolors'; import semver from 'semver'; diff --git a/scripts/release/get-current-version.ts b/scripts/release/get-current-version.ts index 8530f6cf9646..b0133cf03f7f 100644 --- a/scripts/release/get-current-version.ts +++ b/scripts/release/get-current-version.ts @@ -1,6 +1,7 @@ import { join } from 'node:path'; import { setOutput } from '@actions/core'; +// eslint-disable-next-line depend/ban-dependencies import { readJson } from 'fs-extra'; import picocolors from 'picocolors'; diff --git a/scripts/release/is-pr-frozen.ts b/scripts/release/is-pr-frozen.ts index d8c80708fc71..e198e89d8202 100644 --- a/scripts/release/is-pr-frozen.ts +++ b/scripts/release/is-pr-frozen.ts @@ -2,6 +2,7 @@ import { join } from 'node:path'; import { setOutput } from '@actions/core'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { readJson } from 'fs-extra'; import picocolors from 'picocolors'; diff --git a/scripts/release/label-patches.ts b/scripts/release/label-patches.ts index c1d8fa945e11..0ddbd60af981 100644 --- a/scripts/release/label-patches.ts +++ b/scripts/release/label-patches.ts @@ -1,4 +1,5 @@ import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import ora from 'ora'; import { v4 as uuidv4 } from 'uuid'; diff --git a/scripts/release/pick-patches.ts b/scripts/release/pick-patches.ts index d25667cc4974..54dc6a21b2bb 100644 --- a/scripts/release/pick-patches.ts +++ b/scripts/release/pick-patches.ts @@ -1,5 +1,6 @@ import { setOutput } from '@actions/core'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import ora from 'ora'; import picocolors from 'picocolors'; import invariant from 'tiny-invariant'; diff --git a/scripts/release/publish.ts b/scripts/release/publish.ts index 83839dd4a003..f2054d93398e 100644 --- a/scripts/release/publish.ts +++ b/scripts/release/publish.ts @@ -1,7 +1,9 @@ import { join } from 'node:path'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { readJson } from 'fs-extra'; import pRetry from 'p-retry'; import picocolors from 'picocolors'; diff --git a/scripts/release/version.ts b/scripts/release/version.ts index bdaef52fa18e..7d18b99aeca5 100644 --- a/scripts/release/version.ts +++ b/scripts/release/version.ts @@ -2,7 +2,9 @@ import { join } from 'node:path'; import { setOutput } from '@actions/core'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { readFile, readJson, writeFile, writeJson } from 'fs-extra'; import picocolors from 'picocolors'; import semver from 'semver'; diff --git a/scripts/release/write-changelog.ts b/scripts/release/write-changelog.ts index 59e0d3273958..9e8b1e342cb2 100644 --- a/scripts/release/write-changelog.ts +++ b/scripts/release/write-changelog.ts @@ -1,6 +1,7 @@ import { join } from 'node:path'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { readFile, writeFile, writeJson } from 'fs-extra'; import picocolors from 'picocolors'; import semver from 'semver'; diff --git a/scripts/reset.js b/scripts/reset.js index ed93cbce800b..d9049633d2bc 100644 --- a/scripts/reset.js +++ b/scripts/reset.js @@ -1,6 +1,7 @@ import { spawn } from 'node:child_process'; import { appendFile, writeFileSync } from 'node:fs'; +// eslint-disable-next-line depend/ban-dependencies import { remove } from 'fs-extra'; import trash from 'trash'; diff --git a/scripts/run-registry.ts b/scripts/run-registry.ts index 825788b24f51..5f179501583d 100755 --- a/scripts/run-registry.ts +++ b/scripts/run-registry.ts @@ -5,7 +5,9 @@ import type { Server } from 'node:http'; import { join, resolve as resolvePath } from 'node:path'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execa, execaSync } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists, readJSON, remove } from 'fs-extra'; import pLimit from 'p-limit'; import picocolors from 'picocolors'; diff --git a/scripts/sandbox/generate.ts b/scripts/sandbox/generate.ts index d92696383699..495d142c0196 100755 --- a/scripts/sandbox/generate.ts +++ b/scripts/sandbox/generate.ts @@ -1,7 +1,10 @@ import * as ghActions from '@actions/core'; import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import type { Options as ExecaOptions } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies import { copy, emptyDir, ensureDir, move, remove, rename, writeFile } from 'fs-extra'; import pLimit from 'p-limit'; import { join, relative } from 'path'; diff --git a/scripts/sandbox/publish.ts b/scripts/sandbox/publish.ts index 7ddb549c3900..f83048dff5cd 100755 --- a/scripts/sandbox/publish.ts +++ b/scripts/sandbox/publish.ts @@ -1,7 +1,10 @@ import { program } from 'commander'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import { existsSync } from 'fs'; +// eslint-disable-next-line depend/ban-dependencies import { copy, emptyDir, remove, writeFile } from 'fs-extra'; +// eslint-disable-next-line depend/ban-dependencies import { glob } from 'glob'; import { dirname, join, relative } from 'path'; diff --git a/scripts/sandbox/utils/git.ts b/scripts/sandbox/utils/git.ts index 17022db63fca..2ea8b89f29b4 100644 --- a/scripts/sandbox/utils/git.ts +++ b/scripts/sandbox/utils/git.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import invariant from 'tiny-invariant'; diff --git a/scripts/sandbox/utils/template.ts b/scripts/sandbox/utils/template.ts index 11b6c1e86d5a..825cd6e58641 100644 --- a/scripts/sandbox/utils/template.ts +++ b/scripts/sandbox/utils/template.ts @@ -1,4 +1,5 @@ import { render } from 'ejs'; +// eslint-disable-next-line depend/ban-dependencies import { readFile } from 'fs-extra'; import prettier from 'prettier'; diff --git a/scripts/sandbox/utils/yarn.ts b/scripts/sandbox/utils/yarn.ts index a2d579b2cde0..8f4163256a08 100644 --- a/scripts/sandbox/utils/yarn.ts +++ b/scripts/sandbox/utils/yarn.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { move, remove } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/strict-ts.ts b/scripts/strict-ts.ts index 990cbe866ccf..bf0710f5a583 100644 --- a/scripts/strict-ts.ts +++ b/scripts/strict-ts.ts @@ -1,6 +1,7 @@ import { existsSync, readFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; +// eslint-disable-next-line depend/ban-dependencies import glob from 'fast-glob'; import JSON5 from 'json5'; diff --git a/scripts/task.ts b/scripts/task.ts index 905b53b82cae..9a28f8e79546 100644 --- a/scripts/task.ts +++ b/scripts/task.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { outputFile, pathExists, readFile } from 'fs-extra'; import type { TestCase } from 'junit-xml'; import { getJunitXml } from 'junit-xml'; diff --git a/scripts/tasks/build.ts b/scripts/tasks/build.ts index 4a74dcba1f55..796532e2bc0c 100644 --- a/scripts/tasks/build.ts +++ b/scripts/tasks/build.ts @@ -1,4 +1,5 @@ import dirSize from 'fast-folder-size'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists } from 'fs-extra'; import { join } from 'path'; import { promisify } from 'util'; diff --git a/scripts/tasks/compile.ts b/scripts/tasks/compile.ts index 2fe631c5f615..bb0bf918812a 100644 --- a/scripts/tasks/compile.ts +++ b/scripts/tasks/compile.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { readFile } from 'fs-extra'; import { resolve } from 'path'; diff --git a/scripts/tasks/generate.ts b/scripts/tasks/generate.ts index 3e1b0ddc5bc3..5736803a551d 100644 --- a/scripts/tasks/generate.ts +++ b/scripts/tasks/generate.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { pathExists, remove } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/tasks/install.ts b/scripts/tasks/install.ts index 90342845687e..0299c18d2fe4 100644 --- a/scripts/tasks/install.ts +++ b/scripts/tasks/install.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { pathExists, remove } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/tasks/publish.ts b/scripts/tasks/publish.ts index d83ffb9272b2..987286207dd1 100644 --- a/scripts/tasks/publish.ts +++ b/scripts/tasks/publish.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { pathExists } from 'fs-extra'; import { resolve } from 'path'; diff --git a/scripts/tasks/sandbox-parts.ts b/scripts/tasks/sandbox-parts.ts index a2df1e8e1691..78f8dad696cc 100644 --- a/scripts/tasks/sandbox-parts.ts +++ b/scripts/tasks/sandbox-parts.ts @@ -1,6 +1,7 @@ // This file requires many imports from `../code`, which requires both an install and bootstrap of // the repo to work properly. So we load it async in the task runner *after* those steps. import { isFunction } from 'es-toolkit'; +// eslint-disable-next-line depend/ban-dependencies import { copy, ensureDir, diff --git a/scripts/tasks/sandbox.ts b/scripts/tasks/sandbox.ts index 93d5cf823c93..5b3494d9955f 100644 --- a/scripts/tasks/sandbox.ts +++ b/scripts/tasks/sandbox.ts @@ -1,4 +1,5 @@ import dirSize from 'fast-folder-size'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists, remove } from 'fs-extra'; import { join } from 'path'; import { promisify } from 'util'; diff --git a/scripts/upload-bench.ts b/scripts/upload-bench.ts index 9766079b9dc8..48e5fa618896 100644 --- a/scripts/upload-bench.ts +++ b/scripts/upload-bench.ts @@ -1,4 +1,5 @@ import { BigQuery } from '@google-cloud/bigquery'; +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import { join } from 'path'; diff --git a/scripts/utils/exec.ts b/scripts/utils/exec.ts index c12c9eea2f9f..a4a77ebd2244 100644 --- a/scripts/utils/exec.ts +++ b/scripts/utils/exec.ts @@ -1,5 +1,5 @@ -import type { ExecaChildProcess, Options } from 'execa'; -import { execa } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies +import { type ExecaChildProcess, type Options, execa } from 'execa'; import picocolors from 'picocolors'; const logger = console; diff --git a/scripts/utils/filterExistsInCodeDir.ts b/scripts/utils/filterExistsInCodeDir.ts index 7a22fdf8d2f2..673148f916eb 100644 --- a/scripts/utils/filterExistsInCodeDir.ts +++ b/scripts/utils/filterExistsInCodeDir.ts @@ -1,5 +1,6 @@ import { join, resolve } from 'node:path'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists } from 'fs-extra'; import { CODE_DIRECTORY } from './constants'; diff --git a/scripts/utils/package-json.ts b/scripts/utils/package-json.ts index cc88350ddfaa..16bdb67f7078 100644 --- a/scripts/utils/package-json.ts +++ b/scripts/utils/package-json.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { readJSON, writeJSON } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/utils/paths.ts b/scripts/utils/paths.ts index 36db99f4e093..7253fdff740c 100644 --- a/scripts/utils/paths.ts +++ b/scripts/utils/paths.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { pathExists } from 'fs-extra'; import { join } from 'path'; diff --git a/scripts/utils/workspace.ts b/scripts/utils/workspace.ts index 98a0164ec5ac..fcba0311b09d 100644 --- a/scripts/utils/workspace.ts +++ b/scripts/utils/workspace.ts @@ -1,3 +1,4 @@ +// eslint-disable-next-line depend/ban-dependencies import { execaCommand } from 'execa'; import memoize from 'memoizerific'; diff --git a/scripts/utils/yarn.ts b/scripts/utils/yarn.ts index 0b8147dfa983..1f78e58162c5 100644 --- a/scripts/utils/yarn.ts +++ b/scripts/utils/yarn.ts @@ -1,5 +1,6 @@ import { join } from 'node:path'; +// eslint-disable-next-line depend/ban-dependencies import { pathExists, readJSON, writeJSON } from 'fs-extra'; // TODO -- should we generate this file a second time outside of CLI? diff --git a/scripts/vite-ecosystem-ci/before-test.js b/scripts/vite-ecosystem-ci/before-test.js index 93da3f28519b..35ba21734d06 100644 --- a/scripts/vite-ecosystem-ci/before-test.js +++ b/scripts/vite-ecosystem-ci/before-test.js @@ -8,7 +8,8 @@ import { readFile, writeFile } from 'node:fs/promises'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; -import { execa, execaCommand } from 'execa'; +// eslint-disable-next-line depend/ban-dependencies +import { execaCommand } from 'execa'; const filename = fileURLToPath(import.meta.url); // eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention From d85dc51b86688c207527d830fb5f5627c5df9b01 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 3 Oct 2024 11:15:59 +0200 Subject: [PATCH 25/41] revert to existing static serving logic --- .../src/core-server/utils/server-statics.ts | 116 +++++++----------- 1 file changed, 46 insertions(+), 70 deletions(-) diff --git a/code/core/src/core-server/utils/server-statics.ts b/code/core/src/core-server/utils/server-statics.ts index 04f985901ce3..b49130ad1755 100644 --- a/code/core/src/core-server/utils/server-statics.ts +++ b/code/core/src/core-server/utils/server-statics.ts @@ -1,5 +1,5 @@ import { existsSync } from 'node:fs'; -import { basename, isAbsolute, normalize, posix, relative, resolve, sep, win32 } from 'node:path'; +import { basename, isAbsolute, posix, resolve, sep, win32 } from 'node:path'; import { getDirectoryFromWorkingDir } from '@storybook/core/common'; import type { Options } from '@storybook/core/types'; @@ -15,76 +15,52 @@ export async function useStatics(app: Polka.Polka, options: Options): Promise('favicon'); - const statics: Array<{ targetEndpoint: string; staticPath: string }> = []; - const userStatics = [ - `${faviconPath}:/${basename(faviconPath)}`, - ...staticDirs.map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)), - ]; - - for (const dir of userStatics) { - try { - const normalizedDir = - staticDirs && !isAbsolute(dir) - ? getDirectoryFromWorkingDir({ - configDir: options.configDir, - workingDir: process.cwd(), - directory: dir, + await Promise.all( + staticDirs + .map((dir) => (typeof dir === 'string' ? dir : `${dir.from}:${dir.to}`)) + .map(async (dir) => { + try { + const normalizedDir = + staticDirs && !isAbsolute(dir) + ? getDirectoryFromWorkingDir({ + configDir: options.configDir, + workingDir: process.cwd(), + directory: dir, + }) + : dir; + const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(normalizedDir); + + // Don't log for the internal static dir + if (!targetEndpoint.startsWith('/sb-')) { + logger.info( + `=> Serving static files from ${chalk.cyan(staticDir)} at ${chalk.cyan(targetEndpoint)}` + ); + } + + app.use( + targetEndpoint, + sirv(staticPath, { + dev: true, + etag: true, + extensions: [], }) - : dir; - const { staticDir, staticPath, targetEndpoint } = await parseStaticDir(normalizedDir); - - // Don't log for the internal static dir - if (!targetEndpoint.startsWith('/sb-') && staticPath !== faviconPath) { - logger.info( - `=> Serving static files from ${chalk.cyan(staticDir)} at ${chalk.cyan(targetEndpoint)}` - ); - } - - statics.push({ targetEndpoint, staticPath }); - } catch (e) { - if (e instanceof Error) { - logger.warn(e.message); - } - } - } - - const serve = sirv(process.cwd(), { - dev: true, - etag: true, - }); - - app.use((req, res, next) => { - if (!req.url) { - return next(); - } - - // the base isn't used for anything, but it's required by the URL constructor - const url = new URL(req.url, 'http://localhost:6006'); - const pathname = normalize(url.pathname); - - // TODO (43081j): this is 'security' so you can't break out of cwd - // Probably need to do something better here - if (pathname.startsWith('..') || pathname.endsWith('/')) { - return next(); - } - - for (const { targetEndpoint, staticPath } of statics) { - if (!pathname.startsWith(targetEndpoint)) { - continue; - } - // TODO (43081j): similar as above, this might be doable in a cleaner way - const newPath = relative( - process.cwd(), - resolve(staticPath, './' + pathname.slice(targetEndpoint.length)) - ); - url.pathname = newPath; - req.url = url.href.slice(url.origin.length); - serve(req, res, next); - return; - } - - next(); - }); + ); + } catch (e) { + if (e instanceof Error) { + logger.warn(e.message); + } + } + }) + ); + + app.get( + `/${basename(faviconPath)}`, + sirv(faviconPath, { + dev: true, + etag: true, + extensions: [], + }) + ); } export const parseStaticDir = async (arg: string) => { From 8f7f8812f5913eaa39fe5fc09da484aa5897baae Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 3 Oct 2024 13:25:10 +0200 Subject: [PATCH 26/41] cleanup express dependencies --- code/builders/builder-vite/package.json | 1 - code/yarn.lock | 3 +- scripts/package.json | 2 - scripts/utils/serve.ts | 14 ------- scripts/yarn.lock | 54 +------------------------ 5 files changed, 3 insertions(+), 71 deletions(-) delete mode 100644 scripts/utils/serve.ts diff --git a/code/builders/builder-vite/package.json b/code/builders/builder-vite/package.json index da62b3d90d69..a9c982f98d45 100644 --- a/code/builders/builder-vite/package.json +++ b/code/builders/builder-vite/package.json @@ -52,7 +52,6 @@ "ts-dedent": "^2.0.0" }, "devDependencies": { - "@types/express": "^4.17.21", "@types/node": "^22.0.0", "glob": "^10.0.0", "polka": "^1.0.0-next.28", diff --git a/code/yarn.lock b/code/yarn.lock index e3ca8b48ce61..d5ec15207ec3 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -6089,7 +6089,6 @@ __metadata: resolution: "@storybook/builder-vite@workspace:builders/builder-vite" dependencies: "@storybook/csf-plugin": "workspace:*" - "@types/express": "npm:^4.17.21" "@types/find-cache-dir": "npm:^3.2.1" "@types/node": "npm:^22.0.0" browser-assert: "npm:^1.2.1" @@ -8104,7 +8103,7 @@ __metadata: languageName: node linkType: hard -"@types/express@npm:*, @types/express@npm:^4.17.13, @types/express@npm:^4.17.21": +"@types/express@npm:*, @types/express@npm:^4.17.13": version: 4.17.21 resolution: "@types/express@npm:4.17.21" dependencies: diff --git a/scripts/package.json b/scripts/package.json index 456ba6c06038..51c33d4b0004 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -75,7 +75,6 @@ "@types/detect-port": "^1.3.5", "@types/ejs": "^3.1.5", "@types/escodegen": "^0.0.6", - "@types/express": "^4.17.21", "@types/fs-extra": "^11.0.4", "@types/http-server": "^0.12.4", "@types/jest": "^29.5.12", @@ -124,7 +123,6 @@ "eslint-plugin-react-hooks": "^4.6.2", "eslint-plugin-storybook": "^0.8.0", "execa": "^6.1.0", - "express": "^4.19.2", "fast-folder-size": "^2.2.0", "fast-glob": "^3.3.2", "find-up": "^5.0.0", diff --git a/scripts/utils/serve.ts b/scripts/utils/serve.ts deleted file mode 100644 index 98ba1da21c63..000000000000 --- a/scripts/utils/serve.ts +++ /dev/null @@ -1,14 +0,0 @@ -import express from 'express'; -import type { Server } from 'http'; -import serveStatic from 'serve-static'; - -export const serve = async (location: string, port: string): Promise => { - return new Promise((resolve) => { - const app = express(); - - app.use(serveStatic(location)); - const server = app.listen(port, () => { - resolve(server); - }); - }); -}; diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 68267cf11fe1..18fd280b33a4 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -1538,7 +1538,6 @@ __metadata: "@types/detect-port": "npm:^1.3.5" "@types/ejs": "npm:^3.1.5" "@types/escodegen": "npm:^0.0.6" - "@types/express": "npm:^4.17.21" "@types/fs-extra": "npm:^11.0.4" "@types/http-server": "npm:^0.12.4" "@types/jest": "npm:^29.5.12" @@ -1588,7 +1587,6 @@ __metadata: eslint-plugin-react-hooks: "npm:^4.6.2" eslint-plugin-storybook: "npm:^0.8.0" execa: "npm:^6.1.0" - express: "npm:^4.19.2" fast-folder-size: "npm:^2.2.0" fast-glob: "npm:^3.3.2" find-up: "npm:^5.0.0" @@ -1769,16 +1767,6 @@ __metadata: languageName: node linkType: hard -"@types/body-parser@npm:*": - version: 1.19.4 - resolution: "@types/body-parser@npm:1.19.4" - dependencies: - "@types/connect": "npm:*" - "@types/node": "npm:*" - checksum: 10c0/bec2b8a97861a960ee415f7ab3c2aeb7f4d779fd364d27ddee46057897ea571735f1f854f5ee41682964315d4e3699f62427998b9c21851d773398ef535f0612 - languageName: node - linkType: hard - "@types/concat-stream@npm:^2.0.0": version: 2.0.1 resolution: "@types/concat-stream@npm:2.0.1" @@ -1852,30 +1840,6 @@ __metadata: languageName: node linkType: hard -"@types/express-serve-static-core@npm:^4.17.33": - version: 4.17.39 - resolution: "@types/express-serve-static-core@npm:4.17.39" - dependencies: - "@types/node": "npm:*" - "@types/qs": "npm:*" - "@types/range-parser": "npm:*" - "@types/send": "npm:*" - checksum: 10c0/b23b005fddd2ba3f7142ec9713f06b5582c7712cdf99c3419d3972364903b348a103c3264d9a761d6497140e3b89bd416454684c4bdeff206b4c59b86e96428a - languageName: node - linkType: hard - -"@types/express@npm:^4.17.21": - version: 4.17.21 - resolution: "@types/express@npm:4.17.21" - dependencies: - "@types/body-parser": "npm:*" - "@types/express-serve-static-core": "npm:^4.17.33" - "@types/qs": "npm:*" - "@types/serve-static": "npm:*" - checksum: 10c0/12e562c4571da50c7d239e117e688dc434db1bac8be55613294762f84fd77fbd0658ccd553c7d3ab02408f385bc93980992369dd30e2ecd2c68c358e6af8fabf - languageName: node - linkType: hard - "@types/fs-extra@npm:^11.0.4": version: 11.0.4 resolution: "@types/fs-extra@npm:11.0.4" @@ -2097,20 +2061,6 @@ __metadata: languageName: node linkType: hard -"@types/qs@npm:*": - version: 6.9.9 - resolution: "@types/qs@npm:6.9.9" - checksum: 10c0/aede2a4181a49ae8548a1354bac3f8235cb0c5aab066b10875a3e68e88a199e220f4284e7e2bb75a3c18e5d4ff6abe1a6ce0389ef31b63952cc45e0f4d885ba0 - languageName: node - linkType: hard - -"@types/range-parser@npm:*": - version: 1.2.6 - resolution: "@types/range-parser@npm:1.2.6" - checksum: 10c0/46e7fffc54cdacc8fb0cd576f8f9a6436453f0176205d6ec55434a460c7677e78e688673426d5db5e480501b2943ba08a16ececa3a354c222093551c7217fb8f - languageName: node - linkType: hard - "@types/react-dom@npm:^18.3.0": version: 18.3.0 resolution: "@types/react-dom@npm:18.3.0" @@ -2154,7 +2104,7 @@ __metadata: languageName: node linkType: hard -"@types/serve-static@npm:*, @types/serve-static@npm:^1.15.7": +"@types/serve-static@npm:^1.15.7": version: 1.15.7 resolution: "@types/serve-static@npm:1.15.7" dependencies: @@ -6015,7 +5965,7 @@ __metadata: languageName: node linkType: hard -"express@npm:4.19.2, express@npm:^4.19.2": +"express@npm:4.19.2": version: 4.19.2 resolution: "express@npm:4.19.2" dependencies: From 2b4803efdab25e8ed0f1aaf677cd6bd0b31283ce Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Thu, 3 Oct 2024 13:52:04 +0200 Subject: [PATCH 27/41] Don't expose Polka typings --- code/core/src/types/modules/core-common.ts | 32 +++++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index ddecfea2d89d..290f632f7995 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -1,8 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core -import type { Server as HttpServer } from 'http'; -import type Polka from 'polka'; +import type { Server as HttpServer, IncomingMessage } from 'http'; import type { Options as TelejsonOptions } from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; @@ -211,13 +210,38 @@ export type Options = LoadOptions & CLIOptions & BuilderOptions & { build?: TestBuildConfig }; +// A minimal version of Polka's interface to avoid exposing internal implementation details +type Pattern = RegExp | string; +type Middleware = ( + req: T & IncomingMessage, + res: Response, + next: (err?: string | Error) => Promise | void +) => Promise; + +interface ServerApp { + server: HttpServer; + + use(pattern: Pattern, ...handlers: Middleware[]): this; + use(...handlers: Middleware[]): this; + + get(...handlers: Middleware[]): this; + post(...handlers: Middleware[]): this; + put(...handlers: Middleware[]): this; + patch(...handlers: Middleware[]): this; + delete(...handlers: Middleware[]): this; + head(...handlers: Middleware[]): this; + options(...handlers: Middleware[]): this; + connect(...handlers: Middleware[]): this; + trace(...handlers: Middleware[]): this; +} + export interface Builder { getConfig: (options: Options) => Promise; start: (args: { options: Options; startTime: ReturnType; - app: Polka.Polka; - router: Polka.Polka; // back-compatability with express-based API + app: ServerApp; + router: ServerApp; // back-compatability with express-based API server: HttpServer; channel: ServerChannel; }) => Promise Date: Thu, 3 Oct 2024 14:29:48 +0200 Subject: [PATCH 28/41] fix middleware types --- code/builders/builder-vite/src/index.ts | 5 ++--- .../src/core-server/utils/get-caching-middleware.ts | 4 ++-- .../core-server/utils/getAccessControlMiddleware.ts | 4 ++-- code/core/src/types/modules/core-common.ts | 11 +++++------ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index 9307c07dfed6..fab1d8c81bf9 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -3,9 +3,8 @@ import { cp, readFile } from 'node:fs/promises'; import { join, parse } from 'node:path'; import { NoStatsForViteDevError } from 'storybook/internal/server-errors'; -import type { Options } from 'storybook/internal/types'; +import type { Middleware, Options } from 'storybook/internal/types'; -import type Polka from 'polka'; import sirv from 'sirv'; import { corePath } from 'storybook/core-path'; import type { ViteDevServer } from 'vite'; @@ -20,7 +19,7 @@ export { hasVitePlugins } from './utils/has-vite-plugins'; export * from './types'; -function iframeMiddleware(options: Options, server: ViteDevServer): Polka.Middleware { +function iframeMiddleware(options: Options, server: ViteDevServer): Middleware { return async (req, res, next) => { if (!req.url || !req.url.match(/^\/iframe\.html($|\?)/)) { next(); diff --git a/code/core/src/core-server/utils/get-caching-middleware.ts b/code/core/src/core-server/utils/get-caching-middleware.ts index dd4d5c747156..88cc96c2ae70 100644 --- a/code/core/src/core-server/utils/get-caching-middleware.ts +++ b/code/core/src/core-server/utils/get-caching-middleware.ts @@ -1,6 +1,6 @@ -import type Polka from 'polka'; +import type { Middleware } from '../../types'; -export function getCachingMiddleware(): Polka.Middleware { +export function getCachingMiddleware(): Middleware { return (req, res, next) => { res.setHeader('Cache-Control', 'no-store'); next(); diff --git a/code/core/src/core-server/utils/getAccessControlMiddleware.ts b/code/core/src/core-server/utils/getAccessControlMiddleware.ts index b44046d290bf..0b5c3428b842 100644 --- a/code/core/src/core-server/utils/getAccessControlMiddleware.ts +++ b/code/core/src/core-server/utils/getAccessControlMiddleware.ts @@ -1,6 +1,6 @@ -import type Polka from 'polka'; +import type { Middleware } from '../../types'; -export function getAccessControlMiddleware(crossOriginIsolated: boolean): Polka.Middleware { +export function getAccessControlMiddleware(crossOriginIsolated: boolean): Middleware { return (req, res, next) => { res.setHeader('Access-Control-Allow-Origin', '*'); res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept'); diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index 290f632f7995..968b588054f9 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -1,7 +1,7 @@ /* eslint-disable @typescript-eslint/naming-convention */ import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core -import type { Server as HttpServer, IncomingMessage } from 'http'; +import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'http'; import type { Options as TelejsonOptions } from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; @@ -211,17 +211,16 @@ export type Options = LoadOptions & BuilderOptions & { build?: TestBuildConfig }; // A minimal version of Polka's interface to avoid exposing internal implementation details -type Pattern = RegExp | string; -type Middleware = ( +export type Middleware = ( req: T & IncomingMessage, - res: Response, + res: ServerResponse, next: (err?: string | Error) => Promise | void -) => Promise; +) => Promise | void; interface ServerApp { server: HttpServer; - use(pattern: Pattern, ...handlers: Middleware[]): this; + use(pattern: RegExp | string, ...handlers: Middleware[]): this; use(...handlers: Middleware[]): this; get(...handlers: Middleware[]): this; From e33f6714c6f746bb40aeafb05688de8b1a723efd Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Fri, 4 Oct 2024 07:17:10 +0000 Subject: [PATCH 29/41] Update CHANGELOG.md for v8.3.5 [skip ci] --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dd75af133731..f3e13bedee71 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 8.3.5 + +- CLI: Update the React Native init to include v8 dependencies - [#29273](https://github.com/storybookjs/storybook/pull/29273), thanks @dannyhw! +- Vitest plugin: Fix renamed export stories - [#29250](https://github.com/storybookjs/storybook/pull/29250), thanks @shilman! + ## 8.3.4 - Addon Test: Support story name as test description - [#29147](https://github.com/storybookjs/storybook/pull/29147), thanks @InfiniteXyy! From b563eee59979388a354e79c18d42d3eff6593fb1 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Fri, 4 Oct 2024 11:46:21 +0200 Subject: [PATCH 30/41] only expose router to builders --- code/builders/builder-vite/src/index.ts | 8 ++++---- code/builders/builder-webpack5/src/index.ts | 8 ++++---- code/core/src/builder-manager/index.ts | 14 +++++++++----- code/core/src/core-server/dev-server.ts | 3 +-- code/core/src/types/modules/core-common.ts | 3 +-- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/code/builders/builder-vite/src/index.ts b/code/builders/builder-vite/src/index.ts index fab1d8c81bf9..9ab66f2771d0 100644 --- a/code/builders/builder-vite/src/index.ts +++ b/code/builders/builder-vite/src/index.ts @@ -56,13 +56,13 @@ export async function bail(): Promise { export const start: ViteBuilder['start'] = async ({ startTime, options, - app, + router, server: devServer, }) => { server = await createViteServer(options as Options, devServer); const previewResolvedDir = join(corePath, 'dist/preview'); - app.use( + router.use( '/sb-preview', sirv(previewResolvedDir, { maxAge: 300000, @@ -70,8 +70,8 @@ export const start: ViteBuilder['start'] = async ({ immutable: true, }) ); - app.use(iframeMiddleware(options as Options, server)); - app.use(server.middlewares); + router.use(iframeMiddleware(options as Options, server)); + router.use(server.middlewares); return { bail, diff --git a/code/builders/builder-webpack5/src/index.ts b/code/builders/builder-webpack5/src/index.ts index 9e2245fec19c..f5d973547a66 100644 --- a/code/builders/builder-webpack5/src/index.ts +++ b/code/builders/builder-webpack5/src/index.ts @@ -114,7 +114,7 @@ export const bail: WebpackBuilder['bail'] = async () => { const starter: StarterFunction = async function* starterGeneratorFn({ startTime, options, - app, + router, channel, }) { const webpackInstance = await executor.get(options); @@ -180,7 +180,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ compilation = webpackDevMiddleware(compiler, middlewareOptions); const previewResolvedDir = join(corePath, 'dist/preview'); - app.use( + router.use( '/sb-preview', sirv(previewResolvedDir, { maxAge: 300000, @@ -188,8 +188,8 @@ const starter: StarterFunction = async function* starterGeneratorFn({ immutable: true, }) ); - app.use(compilation); - app.use(webpackHotMiddleware(compiler, { log: false })); + router.use(compilation); + router.use(webpackHotMiddleware(compiler, { log: false })); const stats = await new Promise((res, rej) => { compilation?.waitUntilValid(res as any); diff --git a/code/core/src/builder-manager/index.ts b/code/core/src/builder-manager/index.ts index 93241012b068..faad0a288acf 100644 --- a/code/core/src/builder-manager/index.ts +++ b/code/core/src/builder-manager/index.ts @@ -122,7 +122,11 @@ export const executor = { * * I am sorry for making you read about generators today :') */ -const starter: StarterFunction = async function* starterGeneratorFn({ startTime, options, app }) { +const starter: StarterFunction = async function* starterGeneratorFn({ + startTime, + options, + router, +}) { if (!options.quiet) { logger.info('=> Starting manager..'); } @@ -162,7 +166,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, 'manager' ); - app.use( + router.use( '/sb-addons', sirv(addonsDir, { maxAge: 300000, @@ -170,7 +174,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, immutable: true, }) ); - app.use( + router.use( '/sb-manager', sirv(coreDirOrigin, { maxAge: 300000, @@ -204,7 +208,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, yield; - app.use('/', ({ url }, res, next) => { + router.use('/', ({ url }, res, next) => { if (url && isRootPath.test(url)) { res.statusCode = 200; res.write(html); @@ -213,7 +217,7 @@ const starter: StarterFunction = async function* starterGeneratorFn({ startTime, next(); } }); - app.use(`/index.html`, (req, res) => { + router.use(`/index.html`, (req, res) => { res.statusCode = 200; res.write(html); res.end(); diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 9cf13d96f959..5164ee319926 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -78,8 +78,7 @@ export async function storybookDevServer(options: Options) { const managerResult = await managerBuilder.start({ startTime: process.hrtime(), options, - app, - router: app, // back-compatability with express-based API + router: app, server, channel: serverChannel, }); diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index 968b588054f9..d8a5e1b5bca2 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -239,8 +239,7 @@ export interface Builder { start: (args: { options: Options; startTime: ReturnType; - app: ServerApp; - router: ServerApp; // back-compatability with express-based API + router: ServerApp; server: HttpServer; channel: ServerChannel; }) => Promise Date: Sun, 6 Oct 2024 13:31:26 +0200 Subject: [PATCH 31/41] chore: Filter out @storybook/core from buildable packages --- scripts/build-package.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/build-package.ts b/scripts/build-package.ts index 96ddb84c2fbc..5eba9690602f 100644 --- a/scripts/build-package.ts +++ b/scripts/build-package.ts @@ -9,7 +9,7 @@ import windowSize from 'window-size'; import { getWorkspaces } from './utils/workspace'; async function run() { - const packages = await getWorkspaces(); + const packages = (await getWorkspaces()).filter(({ name }) => name !== '@storybook/root'); const packageTasks = packages .map((pkg) => { let suffix = pkg.name.replace('@storybook/', ''); From 9fa3ee2993063f2b046773bcce700d55de61afc0 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 13:15:46 +0200 Subject: [PATCH 32/41] fix ServerApp types to match Polka/Trouter --- code/core/src/core-server/dev-server.ts | 3 +- .../core-server/utils/stories-json.test.ts | 2 +- code/core/src/types/modules/core-common.ts | 21 ++++++------ scripts/package.json | 1 + scripts/yarn.lock | 34 +++++++++++++++++++ 5 files changed, 48 insertions(+), 13 deletions(-) diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 5164ee319926..f0af2ec8e1b3 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -93,8 +93,7 @@ export async function storybookDevServer(options: Options) { .start({ startTime: process.hrtime(), options, - app, - router: app, // back-compatability with express-based API + router: app, server, channel: serverChannel, }) diff --git a/code/core/src/core-server/utils/stories-json.test.ts b/code/core/src/core-server/utils/stories-json.test.ts index b1cbbf169f64..4868c149b724 100644 --- a/code/core/src/core-server/utils/stories-json.test.ts +++ b/code/core/src/core-server/utils/stories-json.test.ts @@ -385,7 +385,7 @@ describe('useStoriesJson', () => { await Promise.all([firstPromise, secondPromise]); expect(end).toHaveBeenCalledTimes(1); - expect(response.status).not.toEqual(500); + expect(response.statusCode).not.toEqual(500); expect(secondResponse.end).toHaveBeenCalledTimes(1); expect(secondResponse.status).not.toEqual(500); }); diff --git a/code/core/src/types/modules/core-common.ts b/code/core/src/types/modules/core-common.ts index d8a5e1b5bca2..3dd6668ef112 100644 --- a/code/core/src/types/modules/core-common.ts +++ b/code/core/src/types/modules/core-common.ts @@ -2,6 +2,7 @@ import type { FileSystemCache } from 'file-system-cache'; // should be node:http, but that caused the ui/manager to fail to build, might be able to switch this back once ui/manager is in the core import type { Server as HttpServer, IncomingMessage, ServerResponse } from 'http'; +import type { Server as NetServer } from 'net'; import type { Options as TelejsonOptions } from 'telejson'; import type { PackageJson as PackageJsonFromTypeFest } from 'type-fest'; @@ -218,20 +219,20 @@ export type Middleware = ( ) => Promise | void; interface ServerApp { - server: HttpServer; + server: NetServer; use(pattern: RegExp | string, ...handlers: Middleware[]): this; use(...handlers: Middleware[]): this; - get(...handlers: Middleware[]): this; - post(...handlers: Middleware[]): this; - put(...handlers: Middleware[]): this; - patch(...handlers: Middleware[]): this; - delete(...handlers: Middleware[]): this; - head(...handlers: Middleware[]): this; - options(...handlers: Middleware[]): this; - connect(...handlers: Middleware[]): this; - trace(...handlers: Middleware[]): this; + get(pattern: RegExp | string, ...handlers: Middleware[]): this; + post(pattern: RegExp | string, ...handlers: Middleware[]): this; + put(pattern: RegExp | string, ...handlers: Middleware[]): this; + patch(pattern: RegExp | string, ...handlers: Middleware[]): this; + delete(pattern: RegExp | string, ...handlers: Middleware[]): this; + head(pattern: RegExp | string, ...handlers: Middleware[]): this; + options(pattern: RegExp | string, ...handlers: Middleware[]): this; + connect(pattern: RegExp | string, ...handlers: Middleware[]): this; + trace(pattern: RegExp | string, ...handlers: Middleware[]): this; } export interface Builder { diff --git a/scripts/package.json b/scripts/package.json index 4ac174e81448..3424ae1c34bc 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -144,6 +144,7 @@ "picocolors": "^1.1.0", "playwright": "1.46.0", "playwright-core": "1.46.0", + "polka": "^1.0.0-next.28", "prettier": "^3.3.2", "prettier-plugin-brace-style": "^0.6.2", "prettier-plugin-css-order": "^2.1.2", diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 2a07e09852d9..3edd98c91256 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -1301,6 +1301,13 @@ __metadata: languageName: node linkType: hard +"@polka/url@npm:^1.0.0-next.21": + version: 1.0.0-next.28 + resolution: "@polka/url@npm:1.0.0-next.28" + checksum: 10c0/acc5ea62597e4da2fb42dbee02749d07f102ae7d6d2c966bf7e423c79cd65d1621da305af567e6e7c232f3b565e242d1ec932cbb3dcc0db1508d02e9a2cafa2e + languageName: node + linkType: hard + "@rollup/rollup-android-arm-eabi@npm:4.21.0": version: 4.21.0 resolution: "@rollup/rollup-android-arm-eabi@npm:4.21.0" @@ -1609,6 +1616,7 @@ __metadata: picocolors: "npm:^1.1.0" playwright: "npm:1.46.0" playwright-core: "npm:1.46.0" + polka: "npm:^1.0.0-next.28" prettier: "npm:^3.3.2" prettier-plugin-brace-style: "npm:^0.6.2" prettier-plugin-css-order: "npm:^2.1.2" @@ -10918,6 +10926,16 @@ __metadata: languageName: node linkType: hard +"polka@npm:^1.0.0-next.28": + version: 1.0.0-next.28 + resolution: "polka@npm:1.0.0-next.28" + dependencies: + "@polka/url": "npm:^1.0.0-next.21" + trouter: "npm:^4.0.0" + checksum: 10c0/206bab3eb1c3c44c2fba9704d998b144ec36c4852b0b97192a1fd3953f215b739e2286852492c13dcc9faecea0f7825a76356d6eef7e02afd6a800d1dbb84ead + languageName: node + linkType: hard + "portfinder@npm:^1.0.28": version: 1.0.32 resolution: "portfinder@npm:1.0.32" @@ -11577,6 +11595,13 @@ __metadata: languageName: node linkType: hard +"regexparam@npm:^3.0.0": + version: 3.0.0 + resolution: "regexparam@npm:3.0.0" + checksum: 10c0/a6430d7b97d5a7d5518f37a850b6b73aab479029d02f46af4fa0e8e4a1d7aad05b7a0d2d10c86ded21a14d5f0fa4c68525f873a5fca2efeefcccd93c36627459 + languageName: node + linkType: hard + "remark-cli@npm:^12.0.0, remark-cli@npm:^12.0.1": version: 12.0.1 resolution: "remark-cli@npm:12.0.1" @@ -13450,6 +13475,15 @@ __metadata: languageName: node linkType: hard +"trouter@npm:^4.0.0": + version: 4.0.0 + resolution: "trouter@npm:4.0.0" + dependencies: + regexparam: "npm:^3.0.0" + checksum: 10c0/e27326a831187c6a47a72b62212364e3f88247fa2a8723e5030e14a0002b69756fb51f97efbda2466deb05f4a78ecb83c2a1a7b343e9659cbfb3f370156f1e12 + languageName: node + linkType: hard + "try-catch@npm:^3.0.0": version: 3.0.1 resolution: "try-catch@npm:3.0.1" From 0f86686cffcebcd40d955510febf5e2cfe080a71 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 13:34:36 +0200 Subject: [PATCH 33/41] migrate event log server to polka --- scripts/event-log-collector.ts | 9 +++++---- scripts/package.json | 1 + scripts/yarn.lock | 8 ++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/event-log-collector.ts b/scripts/event-log-collector.ts index f3ad10700887..1e4a656960b1 100644 --- a/scripts/event-log-collector.ts +++ b/scripts/event-log-collector.ts @@ -1,9 +1,10 @@ -import express from 'express'; +import { json } from '@polka/parse'; +import polka from 'polka'; const PORT = process.env.PORT || 6007; -const server = express(); -server.use(express.json()); +const server = polka(); +server.use(json()); const events: Record[] = []; server.post('/event-log', (req, res) => { @@ -14,7 +15,7 @@ server.post('/event-log', (req, res) => { server.get('/event-log', (_req, res) => { console.log(`Sending ${events.length} events`); - res.json(events); + res.end(JSON.stringify(events)); }); server.listen(PORT, () => { diff --git a/scripts/package.json b/scripts/package.json index 3424ae1c34bc..522fa52ffc85 100644 --- a/scripts/package.json +++ b/scripts/package.json @@ -64,6 +64,7 @@ "@nx/workspace": "18.0.6", "@octokit/graphql": "^5.0.5", "@octokit/request": "^8.1.2", + "@polka/parse": "^1.0.0-next.28", "@storybook/eslint-config-storybook": "^4.0.0", "@storybook/linter-config": "^4.0.0", "@testing-library/dom": "^10.4.0", diff --git a/scripts/yarn.lock b/scripts/yarn.lock index 3edd98c91256..07e2cd5656a5 100644 --- a/scripts/yarn.lock +++ b/scripts/yarn.lock @@ -1301,6 +1301,13 @@ __metadata: languageName: node linkType: hard +"@polka/parse@npm:^1.0.0-next.28": + version: 1.0.0-next.28 + resolution: "@polka/parse@npm:1.0.0-next.28" + checksum: 10c0/42c53dfdc4b39a3b516fbd4358b2472b22f36e6038e25d463afb3f133fb1d5af84d7eb4d245ab66bc5793d6414299fdd9093803e5214e560f0693f2176fc58b6 + languageName: node + linkType: hard + "@polka/url@npm:^1.0.0-next.21": version: 1.0.0-next.28 resolution: "@polka/url@npm:1.0.0-next.28" @@ -1534,6 +1541,7 @@ __metadata: "@nx/workspace": "npm:18.0.6" "@octokit/graphql": "npm:^5.0.5" "@octokit/request": "npm:^8.1.2" + "@polka/parse": "npm:^1.0.0-next.28" "@storybook/eslint-config-storybook": "npm:^4.0.0" "@storybook/linter-config": "npm:^4.0.0" "@testing-library/dom": "npm:^10.4.0" From ca2a0698e5ba92155c8df1dffc0e28e9ae470aa8 Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 7 Oct 2024 13:46:04 +0200 Subject: [PATCH 34/41] add comment --- code/core/src/common/utils/file-cache.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index 3c9fd7d10789..74bc27d87b25 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -1,3 +1,7 @@ +/** + * This file is a modified copy from https://git.nfp.is/TheThing/fs-cache-fast + */ + import { createHash, randomBytes } from 'node:crypto'; import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; import { readFile, readdir, rm, writeFile } from 'node:fs/promises'; From fbf7a926cdef8fc77acae6a44b854f8e78e1e37c Mon Sep 17 00:00:00 2001 From: Norbert de Langen Date: Mon, 7 Oct 2024 14:00:51 +0200 Subject: [PATCH 35/41] fix linting --- code/core/src/common/utils/file-cache.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/code/core/src/common/utils/file-cache.ts b/code/core/src/common/utils/file-cache.ts index 74bc27d87b25..590ddf60d608 100644 --- a/code/core/src/common/utils/file-cache.ts +++ b/code/core/src/common/utils/file-cache.ts @@ -1,7 +1,4 @@ -/** - * This file is a modified copy from https://git.nfp.is/TheThing/fs-cache-fast - */ - +/** This file is a modified copy from https://git.nfp.is/TheThing/fs-cache-fast */ import { createHash, randomBytes } from 'node:crypto'; import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from 'node:fs'; import { readFile, readdir, rm, writeFile } from 'node:fs/promises'; From e6e745b506ad546d66c3bb747e5c58c0085ecba4 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 16:12:52 +0200 Subject: [PATCH 36/41] cleanup --- code/core/src/core-server/dev-server.ts | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index f0af2ec8e1b3..9cca751704ba 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -23,13 +23,8 @@ import { useStatics } from './utils/server-statics'; export async function storybookDevServer(options: Options) { const [server, core] = await Promise.all([getServer(options), options.presets.apply('core')]); - console.log('LOG: starting dev server'); const app = polka({ server }); - // app.use((req, res, next) => { - // console.log('LOG: ', { url: req.url, method: req.method }); - // next(); - // }); - + const serverChannel = await options.presets.apply( 'experimental_serverChannel', getServerChannel(server) From 49483aa7be4fd1af04049e882ad297ec274e1ace Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 20:30:49 +0200 Subject: [PATCH 37/41] wait for server to listen --- code/core/src/core-server/dev-server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 9cca751704ba..2ee47ca89886 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -116,9 +116,12 @@ export async function storybookDevServer(options: Options) { previewStarted.catch(() => {}).then(() => next()); }); - app.listen(port, host); + const listening = new Promise((resolve, reject) => { + server.once('error', reject); + app.listen({ port, host }, resolve); + }); - await Promise.all([initializedStoryIndexGenerator]).then(async ([indexGenerator]) => { + await Promise.all([initializedStoryIndexGenerator, listening]).then(async ([indexGenerator]) => { if (indexGenerator && !options.ci && !options.smokeTest && options.open) { openInBrowser(host ? networkAddress : address); } From 9fcba90bf0ddde25586b1172f369db985f64ff05 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 21:19:21 +0200 Subject: [PATCH 38/41] fix format --- code/core/src/core-server/dev-server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/core/src/core-server/dev-server.ts b/code/core/src/core-server/dev-server.ts index 2ee47ca89886..325d33366514 100644 --- a/code/core/src/core-server/dev-server.ts +++ b/code/core/src/core-server/dev-server.ts @@ -24,7 +24,7 @@ import { useStatics } from './utils/server-statics'; export async function storybookDevServer(options: Options) { const [server, core] = await Promise.all([getServer(options), options.presets.apply('core')]); const app = polka({ server }); - + const serverChannel = await options.presets.apply( 'experimental_serverChannel', getServerChannel(server) From 68f57245b1d19b4f5bf876ebd4caa8d866849043 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 21:19:31 +0200 Subject: [PATCH 39/41] regenerate lock-file --- code/yarn.lock | 911 +++++++++++++++---------------------------------- 1 file changed, 281 insertions(+), 630 deletions(-) diff --git a/code/yarn.lock b/code/yarn.lock index 5d09c24f0be6..2c6f7244e415 100644 --- a/code/yarn.lock +++ b/code/yarn.lock @@ -367,7 +367,7 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.16.0, @babel/code-frame@npm:^7.16.7, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.24.2, @babel/code-frame@npm:^7.24.7": +"@babel/code-frame@npm:^7.0.0, @babel/code-frame@npm:^7.10.4, @babel/code-frame@npm:^7.16.0, @babel/code-frame@npm:^7.16.7, @babel/code-frame@npm:^7.21.4, @babel/code-frame@npm:^7.22.13, @babel/code-frame@npm:^7.23.5, @babel/code-frame@npm:^7.24.7": version: 7.24.7 resolution: "@babel/code-frame@npm:7.24.7" dependencies: @@ -377,16 +377,6 @@ __metadata: languageName: node linkType: hard -"@babel/code-frame@npm:^7.24.1": - version: 7.24.2 - resolution: "@babel/code-frame@npm:7.24.2" - dependencies: - "@babel/highlight": "npm:^7.24.2" - picocolors: "npm:^1.0.0" - checksum: 10c0/d1d4cba89475ab6aab7a88242e1fd73b15ecb9f30c109b69752956434d10a26a52cbd37727c4eca104b6d45227bd1dfce39a6a6f4a14c9b2f07f871e968cf406 - languageName: node - linkType: hard - "@babel/compat-data@npm:^7.22.6, @babel/compat-data@npm:^7.23.5, @babel/compat-data@npm:^7.24.4, @babel/compat-data@npm:^7.25.2": version: 7.25.2 resolution: "@babel/compat-data@npm:7.25.2" @@ -440,30 +430,7 @@ __metadata: languageName: node linkType: hard -"@babel/core@npm:^7.12.0, @babel/core@npm:^7.12.3, @babel/core@npm:^7.13.16, @babel/core@npm:^7.18.9, @babel/core@npm:^7.20.12, @babel/core@npm:^7.23.0, @babel/core@npm:^7.23.2, @babel/core@npm:^7.24.4, @babel/core@npm:^7.3.4, @babel/core@npm:^7.7.5": - version: 7.24.4 - resolution: "@babel/core@npm:7.24.4" - dependencies: - "@ampproject/remapping": "npm:^2.2.0" - "@babel/code-frame": "npm:^7.24.2" - "@babel/generator": "npm:^7.24.4" - "@babel/helper-compilation-targets": "npm:^7.23.6" - "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helpers": "npm:^7.24.4" - "@babel/parser": "npm:^7.24.4" - "@babel/template": "npm:^7.24.0" - "@babel/traverse": "npm:^7.24.1" - "@babel/types": "npm:^7.24.0" - convert-source-map: "npm:^2.0.0" - debug: "npm:^4.1.0" - gensync: "npm:^1.0.0-beta.2" - json5: "npm:^2.2.3" - semver: "npm:^6.3.1" - checksum: 10c0/fc136966583e64d6f84f4a676368de6ab4583aa87f867186068655b30ef67f21f8e65a88c6d446a7efd219ad7ffb9185c82e8a90183ee033f6f47b5026641e16 - languageName: node - linkType: hard - -"@babel/core@npm:^7.23.9": +"@babel/core@npm:^7.12.0, @babel/core@npm:^7.12.3, @babel/core@npm:^7.13.16, @babel/core@npm:^7.18.9, @babel/core@npm:^7.20.12, @babel/core@npm:^7.23.0, @babel/core@npm:^7.23.2, @babel/core@npm:^7.23.9, @babel/core@npm:^7.24.4, @babel/core@npm:^7.3.4, @babel/core@npm:^7.7.5": version: 7.25.2 resolution: "@babel/core@npm:7.25.2" dependencies: @@ -509,19 +476,7 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.23.6, @babel/generator@npm:^7.24.4, @babel/generator@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/generator@npm:7.24.7" - dependencies: - "@babel/types": "npm:^7.24.7" - "@jridgewell/gen-mapping": "npm:^0.3.5" - "@jridgewell/trace-mapping": "npm:^0.3.25" - jsesc: "npm:^2.5.1" - checksum: 10c0/06b1f3350baf527a3309e50ffd7065f7aee04dd06e1e7db794ddfde7fe9d81f28df64edd587173f8f9295496a7ddb74b9a185d4bf4de7bb619e6d4ec45c8fd35 - languageName: node - linkType: hard - -"@babel/generator@npm:^7.23.0, @babel/generator@npm:^7.25.0": +"@babel/generator@npm:^7.12.11, @babel/generator@npm:^7.23.0, @babel/generator@npm:^7.23.6, @babel/generator@npm:^7.24.4, @babel/generator@npm:^7.25.0": version: 7.25.0 resolution: "@babel/generator@npm:7.25.0" dependencies: @@ -533,18 +488,6 @@ __metadata: languageName: node linkType: hard -"@babel/generator@npm:^7.24.1": - version: 7.24.4 - resolution: "@babel/generator@npm:7.24.4" - dependencies: - "@babel/types": "npm:^7.24.0" - "@jridgewell/gen-mapping": "npm:^0.3.5" - "@jridgewell/trace-mapping": "npm:^0.3.25" - jsesc: "npm:^2.5.1" - checksum: 10c0/67a1b2f7cc985aaaa11b01e8ddd4fffa4f285837bc7a209738eb8203aa34bdafeb8507ed75fd883ddbabd641a036ca0a8d984e760f28ad4a9d60bff29d0a60bb - languageName: node - linkType: hard - "@babel/helper-annotate-as-pure@npm:7.22.5": version: 7.22.5 resolution: "@babel/helper-annotate-as-pure@npm:7.22.5" @@ -563,16 +506,17 @@ __metadata: languageName: node linkType: hard -"@babel/helper-builder-binary-assignment-operator-visitor@npm:^7.22.15": - version: 7.22.15 - resolution: "@babel/helper-builder-binary-assignment-operator-visitor@npm:7.22.15" +"@babel/helper-builder-binary-assignment-operator-visitor@npm:^7.24.7": + version: 7.24.7 + resolution: "@babel/helper-builder-binary-assignment-operator-visitor@npm:7.24.7" dependencies: - "@babel/types": "npm:^7.22.15" - checksum: 10c0/2535e3824ca6337f65786bbac98e562f71699f25532cecd196f027d7698b4967a96953d64e36567956658ad1a05ccbdc62d1ba79ee751c79f4f1d2d3ecc2e01c + "@babel/traverse": "npm:^7.24.7" + "@babel/types": "npm:^7.24.7" + checksum: 10c0/0ed84abf848c79fb1cd4c1ddac12c771d32c1904d87fc3087f33cfdeb0c2e0db4e7892b74b407d9d8d0c000044f3645a7391a781f788da8410c290bb123a1f13 languageName: node linkType: hard -"@babel/helper-compilation-targets@npm:^7.12.0, @babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.23.6, @babel/helper-compilation-targets@npm:^7.25.2": +"@babel/helper-compilation-targets@npm:^7.12.0, @babel/helper-compilation-targets@npm:^7.22.6, @babel/helper-compilation-targets@npm:^7.23.6, @babel/helper-compilation-targets@npm:^7.24.7, @babel/helper-compilation-targets@npm:^7.25.2": version: 7.25.2 resolution: "@babel/helper-compilation-targets@npm:7.25.2" dependencies: @@ -585,7 +529,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.21.0, @babel/helper-create-class-features-plugin@npm:^7.24.0": +"@babel/helper-create-class-features-plugin@npm:^7.18.6, @babel/helper-create-class-features-plugin@npm:^7.21.0, @babel/helper-create-class-features-plugin@npm:^7.24.0, @babel/helper-create-class-features-plugin@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-create-class-features-plugin@npm:7.24.7" dependencies: @@ -604,26 +548,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-create-class-features-plugin@npm:^7.24.1, @babel/helper-create-class-features-plugin@npm:^7.24.4": - version: 7.24.4 - resolution: "@babel/helper-create-class-features-plugin@npm:7.24.4" - dependencies: - "@babel/helper-annotate-as-pure": "npm:^7.22.5" - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-function-name": "npm:^7.23.0" - "@babel/helper-member-expression-to-functions": "npm:^7.23.0" - "@babel/helper-optimise-call-expression": "npm:^7.22.5" - "@babel/helper-replace-supers": "npm:^7.24.1" - "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.22.5" - "@babel/helper-split-export-declaration": "npm:^7.22.6" - semver: "npm:^6.3.1" - peerDependencies: - "@babel/core": ^7.0.0 - checksum: 10c0/6ebb38375dcd44c79f40008c2de4d023376cf436c135439f15c9c54603c2d6a8ada39b2e07be545da684d9e40b602a0cb0d1670f3877d056deb5f0d786c4bf86 - languageName: node - linkType: hard - -"@babel/helper-create-regexp-features-plugin@npm:^7.18.6": +"@babel/helper-create-regexp-features-plugin@npm:^7.18.6, @babel/helper-create-regexp-features-plugin@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-create-regexp-features-plugin@npm:7.24.7" dependencies: @@ -636,19 +561,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-create-regexp-features-plugin@npm:^7.22.15, @babel/helper-create-regexp-features-plugin@npm:^7.22.5": - version: 7.22.15 - resolution: "@babel/helper-create-regexp-features-plugin@npm:7.22.15" - dependencies: - "@babel/helper-annotate-as-pure": "npm:^7.22.5" - regexpu-core: "npm:^5.3.1" - semver: "npm:^6.3.1" - peerDependencies: - "@babel/core": ^7.0.0 - checksum: 10c0/8eba4c1b7b94a83e7a82df5c3e504584ff0ba6ab8710a67ecc2c434a7fb841a29c2f5c94d2de51f25446119a1df538fa90b37bd570db22ddd5e7147fe98277c6 - languageName: node - linkType: hard - "@babel/helper-define-polyfill-provider@npm:^0.5.0": version: 0.5.0 resolution: "@babel/helper-define-polyfill-provider@npm:0.5.0" @@ -707,15 +619,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-member-expression-to-functions@npm:^7.23.0": - version: 7.23.0 - resolution: "@babel/helper-member-expression-to-functions@npm:7.23.0" - dependencies: - "@babel/types": "npm:^7.23.0" - checksum: 10c0/b810daddf093ffd0802f1429052349ed9ea08ef7d0c56da34ffbcdecbdafac86f95bdea2fe30e0e0e629febc7dd41b56cb5eacc10d1a44336d37b755dac31fa4 - languageName: node - linkType: hard - "@babel/helper-member-expression-to-functions@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-member-expression-to-functions@npm:7.24.7" @@ -736,16 +639,7 @@ __metadata: languageName: node linkType: hard -"@babel/helper-module-imports@npm:^7.24.1": - version: 7.24.3 - resolution: "@babel/helper-module-imports@npm:7.24.3" - dependencies: - "@babel/types": "npm:^7.24.0" - checksum: 10c0/052c188adcd100f5e8b6ff0c9643ddaabc58b6700d3bbbc26804141ad68375a9f97d9d173658d373d31853019e65f62610239e3295cdd58e573bdcb2fded188d - languageName: node - linkType: hard - -"@babel/helper-module-transforms@npm:^7.23.3, @babel/helper-module-transforms@npm:^7.25.2": +"@babel/helper-module-transforms@npm:^7.23.3, @babel/helper-module-transforms@npm:^7.24.7, @babel/helper-module-transforms@npm:^7.25.2": version: 7.25.2 resolution: "@babel/helper-module-transforms@npm:7.25.2" dependencies: @@ -759,15 +653,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-optimise-call-expression@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-optimise-call-expression@npm:7.22.5" - dependencies: - "@babel/types": "npm:^7.22.5" - checksum: 10c0/31b41a764fc3c585196cf5b776b70cf4705c132e4ce9723f39871f215f2ddbfb2e28a62f9917610f67c8216c1080482b9b05f65dd195dae2a52cef461f2ac7b8 - languageName: node - linkType: hard - "@babel/helper-optimise-call-expression@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-optimise-call-expression@npm:7.24.7" @@ -777,21 +662,14 @@ __metadata: languageName: node linkType: hard -"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.20.2, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3": - version: 7.24.0 - resolution: "@babel/helper-plugin-utils@npm:7.24.0" - checksum: 10c0/90f41bd1b4dfe7226b1d33a4bb745844c5c63e400f9e4e8bf9103a7ceddd7d425d65333b564d9daba3cebd105985764d51b4bd4c95822b97c2e3ac1201a8a5da - languageName: node - linkType: hard - -"@babel/helper-plugin-utils@npm:^7.24.7": +"@babel/helper-plugin-utils@npm:^7.0.0, @babel/helper-plugin-utils@npm:^7.10.4, @babel/helper-plugin-utils@npm:^7.12.13, @babel/helper-plugin-utils@npm:^7.14.5, @babel/helper-plugin-utils@npm:^7.18.6, @babel/helper-plugin-utils@npm:^7.20.2, @babel/helper-plugin-utils@npm:^7.22.5, @babel/helper-plugin-utils@npm:^7.24.0, @babel/helper-plugin-utils@npm:^7.24.7, @babel/helper-plugin-utils@npm:^7.8.0, @babel/helper-plugin-utils@npm:^7.8.3": version: 7.24.7 resolution: "@babel/helper-plugin-utils@npm:7.24.7" checksum: 10c0/c3d38cd9b3520757bb4a279255cc3f956fc0ac1c193964bd0816ebd5c86e30710be8e35252227e0c9d9e0f4f56d9b5f916537f2bc588084b0988b4787a967d31 languageName: node linkType: hard -"@babel/helper-remap-async-to-generator@npm:^7.22.20": +"@babel/helper-remap-async-to-generator@npm:^7.22.20, @babel/helper-remap-async-to-generator@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-remap-async-to-generator@npm:7.24.7" dependencies: @@ -804,19 +682,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-replace-supers@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/helper-replace-supers@npm:7.24.1" - dependencies: - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-member-expression-to-functions": "npm:^7.23.0" - "@babel/helper-optimise-call-expression": "npm:^7.22.5" - peerDependencies: - "@babel/core": ^7.0.0 - checksum: 10c0/d39a3df7892b7c3c0e307fb229646168a9bd35e26a72080c2530729322600e8cff5f738f44a14860a2358faffa741b6a6a0d6749f113387b03ddbfa0ec10e1a0 - languageName: node - linkType: hard - "@babel/helper-replace-supers@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-replace-supers@npm:7.24.7" @@ -830,15 +695,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-simple-access@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-simple-access@npm:7.22.5" - dependencies: - "@babel/types": "npm:^7.22.5" - checksum: 10c0/f0cf81a30ba3d09a625fd50e5a9069e575c5b6719234e04ee74247057f8104beca89ed03e9217b6e9b0493434cedc18c5ecca4cea6244990836f1f893e140369 - languageName: node - linkType: hard - "@babel/helper-simple-access@npm:^7.24.7": version: 7.24.7 resolution: "@babel/helper-simple-access@npm:7.24.7" @@ -859,15 +715,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-skip-transparent-expression-wrappers@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/helper-skip-transparent-expression-wrappers@npm:7.22.5" - dependencies: - "@babel/types": "npm:^7.22.5" - checksum: 10c0/ab7fa2aa709ab49bb8cd86515a1e715a3108c4bb9a616965ba76b43dc346dee66d1004ccf4d222b596b6224e43e04cbc5c3a34459501b388451f8c589fbc3691 - languageName: node - linkType: hard - "@babel/helper-split-export-declaration@npm:7.22.6": version: 7.22.6 resolution: "@babel/helper-split-export-declaration@npm:7.22.6" @@ -886,20 +733,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-string-parser@npm:^7.23.4": - version: 7.23.4 - resolution: "@babel/helper-string-parser@npm:7.23.4" - checksum: 10c0/f348d5637ad70b6b54b026d6544bd9040f78d24e7ec245a0fc42293968181f6ae9879c22d89744730d246ce8ec53588f716f102addd4df8bbc79b73ea10004ac - languageName: node - linkType: hard - -"@babel/helper-string-parser@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/helper-string-parser@npm:7.24.7" - checksum: 10c0/47840c7004e735f3dc93939c77b099bb41a64bf3dda0cae62f60e6f74a5ff80b63e9b7cf77b5ec25a324516381fc994e1f62f922533236a8e3a6af57decb5e1e - languageName: node - linkType: hard - "@babel/helper-string-parser@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-string-parser@npm:7.24.8" @@ -914,13 +747,6 @@ __metadata: languageName: node linkType: hard -"@babel/helper-validator-identifier@npm:^7.22.20": - version: 7.22.20 - resolution: "@babel/helper-validator-identifier@npm:7.22.20" - checksum: 10c0/dcad63db345fb110e032de46c3688384b0008a42a4845180ce7cd62b1a9c0507a1bed727c4d1060ed1a03ae57b4d918570259f81724aaac1a5b776056f37504e - languageName: node - linkType: hard - "@babel/helper-validator-option@npm:^7.22.15, @babel/helper-validator-option@npm:^7.23.5, @babel/helper-validator-option@npm:^7.24.8": version: 7.24.8 resolution: "@babel/helper-validator-option@npm:7.24.8" @@ -950,29 +776,6 @@ __metadata: languageName: node linkType: hard -"@babel/helpers@npm:^7.24.4": - version: 7.24.4 - resolution: "@babel/helpers@npm:7.24.4" - dependencies: - "@babel/template": "npm:^7.24.0" - "@babel/traverse": "npm:^7.24.1" - "@babel/types": "npm:^7.24.0" - checksum: 10c0/747ef62b7fe87de31a2f3c19ff337a86cbb79be2f6c18af63133b614ab5a8f6da5b06ae4b06fb0e71271cb6a27efec6f8b6c9f44c60b8a18777832dc7929e6c5 - languageName: node - linkType: hard - -"@babel/highlight@npm:^7.24.2": - version: 7.24.2 - resolution: "@babel/highlight@npm:7.24.2" - dependencies: - "@babel/helper-validator-identifier": "npm:^7.22.20" - chalk: "npm:^2.4.2" - js-tokens: "npm:^4.0.0" - picocolors: "npm:^1.0.0" - checksum: 10c0/98ce00321daedeed33a4ed9362dc089a70375ff1b3b91228b9f05e6591d387a81a8cba68886e207861b8871efa0bc997ceabdd9c90f6cce3ee1b2f7f941b42db - languageName: node - linkType: hard - "@babel/highlight@npm:^7.24.7": version: 7.24.7 resolution: "@babel/highlight@npm:7.24.7" @@ -985,16 +788,7 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.11.5, @babel/parser@npm:^7.13.16, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.23.5, @babel/parser@npm:^7.23.6, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.0, @babel/parser@npm:^7.24.4, @babel/parser@npm:^7.24.7, @babel/parser@npm:^7.4.5, @babel/parser@npm:^7.6.0, @babel/parser@npm:^7.9.6": - version: 7.24.7 - resolution: "@babel/parser@npm:7.24.7" - bin: - parser: ./bin/babel-parser.js - checksum: 10c0/8b244756872185a1c6f14b979b3535e682ff08cb5a2a5fd97cc36c017c7ef431ba76439e95e419d43000c5b07720495b00cf29a7f0d9a483643d08802b58819b - languageName: node - linkType: hard - -"@babel/parser@npm:^7.20.5, @babel/parser@npm:^7.22.5, @babel/parser@npm:^7.25.0, @babel/parser@npm:^7.25.3": +"@babel/parser@npm:^7.1.0, @babel/parser@npm:^7.11.5, @babel/parser@npm:^7.13.16, @babel/parser@npm:^7.14.7, @babel/parser@npm:^7.20.5, @babel/parser@npm:^7.20.7, @babel/parser@npm:^7.22.5, @babel/parser@npm:^7.23.0, @babel/parser@npm:^7.23.5, @babel/parser@npm:^7.23.6, @babel/parser@npm:^7.23.9, @babel/parser@npm:^7.24.0, @babel/parser@npm:^7.24.4, @babel/parser@npm:^7.24.7, @babel/parser@npm:^7.25.0, @babel/parser@npm:^7.25.3, @babel/parser@npm:^7.4.5, @babel/parser@npm:^7.6.0, @babel/parser@npm:^7.9.6": version: 7.25.3 resolution: "@babel/parser@npm:7.25.3" dependencies: @@ -1005,15 +799,6 @@ __metadata: languageName: node linkType: hard -"@babel/parser@npm:^7.24.1": - version: 7.24.4 - resolution: "@babel/parser@npm:7.24.4" - bin: - parser: ./bin/babel-parser.js - checksum: 10c0/8381e1efead5069cb7ed2abc3a583f4a86289b2f376c75cecc69f59a8eb36df18274b1886cecf2f97a6a0dff5334b27330f58535be9b3e4e26102cc50e12eac8 - languageName: node - linkType: hard - "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:^7.24.4": version: 7.24.4 resolution: "@babel/plugin-bugfix-firefox-class-in-computed-class-key@npm:7.24.4" @@ -1027,38 +812,38 @@ __metadata: linkType: hard "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.23.3, @babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0 - checksum: 10c0/d4e592e6fc4878654243d2e7b51ea86471b868a8cb09de29e73b65d2b64159990c6c198fd7c9c2af2e38b1cddf70206243792853c47384a84f829dada152f605 + checksum: 10c0/a36307428ecc1a01b00cf90812335eed1575d13f211ab24fe4d0c55c28a2fcbd4135f142efabc3b277b2a8e09ee05df594a1272353f061b63829495b5dcfdb96 languageName: node linkType: hard "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:^7.23.3, @babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.22.5" - "@babel/plugin-transform-optional-chaining": "npm:^7.24.1" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.24.7" + "@babel/plugin-transform-optional-chaining": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.13.0 - checksum: 10c0/351c36e45795a7890d610ab9041a52f4078a59429f6e74c281984aa44149a10d43e82b3a8172c703c0d5679471e165d1c02b6d2e45a677958ee301b89403f202 + checksum: 10c0/aeb6e7aa363a47f815cf956ea1053c5dd8b786a17799f065c9688ba4b0051fe7565d258bbe9400bfcbfb3114cb9fda66983e10afe4d750bc70ff75403e15dd36 languageName: node linkType: hard "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@npm:^7.23.7, @babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@npm:7.24.7" dependencies: - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-environment-visitor": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0 - checksum: 10c0/d7dd5a59a54635a3152895dcaa68f3370bb09d1f9906c1e72232ff759159e6be48de4a598a993c986997280a2dc29922a48aaa98020f16439f3f57ad72788354 + checksum: 10c0/2b52a73e444f6adc73f927b623e53a4cf64397170dd1071268536df1b3db1e02131418c8dc91351af48837a6298212118f4a72d5407f8005cf9a732370a315b0 languageName: node linkType: hard @@ -1236,24 +1021,24 @@ __metadata: linkType: hard "@babel/plugin-syntax-import-assertions@npm:^7.23.3, @babel/plugin-syntax-import-assertions@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-syntax-import-assertions@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-syntax-import-assertions@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/72f0340d73e037f0702c61670054e0af66ece7282c5c2f4ba8de059390fee502de282defdf15959cd9f71aa18dc5c5e4e7a0fde317799a0600c6c4e0a656d82b + checksum: 10c0/b82c53e095274ee71c248551352d73441cf65b3b3fc0107258ba4e9aef7090772a425442b3ed1c396fa207d0efafde8929c87a17d3c885b3ca2021316e87e246 languageName: node linkType: hard "@babel/plugin-syntax-import-attributes@npm:^7.23.3, @babel/plugin-syntax-import-attributes@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-syntax-import-attributes@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-syntax-import-attributes@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/309634e3335777aee902552b2cf244c4a8050213cc878b3fb9d70ad8cbbff325dc46ac5e5791836ff477ea373b27832238205f6ceaff81f7ea7c4c7e8fbb13bb + checksum: 10c0/eccc54d0f03c96d0eec7a6e2fa124dadbc7298345b62ffc4238f173308c4325b5598f139695ff05a95cf78412ef6903599e4b814496612bf39aad4715a16375b languageName: node linkType: hard @@ -1378,18 +1163,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-syntax-typescript@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-syntax-typescript@npm:7.24.1" - dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - peerDependencies: - "@babel/core": ^7.0.0-0 - checksum: 10c0/7a81e277dcfe3138847e8e5944e02a42ff3c2e864aea6f33fd9b70d1556d12b0e70f0d56cc1985d353c91bcbf8fe163e6cc17418da21129b7f7f1d8b9ac00c93 - languageName: node - linkType: hard - -"@babel/plugin-syntax-typescript@npm:^7.3.3": +"@babel/plugin-syntax-typescript@npm:^7.24.7, @babel/plugin-syntax-typescript@npm:^7.3.3": version: 7.24.7 resolution: "@babel/plugin-syntax-typescript@npm:7.24.7" dependencies: @@ -1413,13 +1187,13 @@ __metadata: linkType: hard "@babel/plugin-transform-arrow-functions@npm:^7.23.3, @babel/plugin-transform-arrow-functions@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-arrow-functions@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-arrow-functions@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/f44bfacf087dc21b422bab99f4e9344ee7b695b05c947dacae66de05c723ab9d91800be7edc1fa016185e8c819f3aca2b4a5f66d8a4d1e47d9bad80b8fa55b8e + checksum: 10c0/6ac05a54e5582f34ac6d5dc26499e227227ec1c7fa6fc8de1f3d40c275f140d3907f79bbbd49304da2d7008a5ecafb219d0b71d78ee3290ca22020d878041245 languageName: node linkType: hard @@ -1438,16 +1212,16 @@ __metadata: linkType: hard "@babel/plugin-transform-async-generator-functions@npm:^7.23.9, @babel/plugin-transform-async-generator-functions@npm:^7.24.3": - version: 7.24.3 - resolution: "@babel/plugin-transform-async-generator-functions@npm:7.24.3" + version: 7.24.7 + resolution: "@babel/plugin-transform-async-generator-functions@npm:7.24.7" dependencies: - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-remap-async-to-generator": "npm:^7.22.20" + "@babel/helper-environment-visitor": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-remap-async-to-generator": "npm:^7.24.7" "@babel/plugin-syntax-async-generators": "npm:^7.8.4" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/55ceed059f819dcccbfe69600bfa1c055ada466bd54eda117cfdd2cf773dd85799e2f6556e4a559b076e93b9704abcca2aef9d72aad7dc8a5d3d17886052f1d3 + checksum: 10c0/6b5e33ae66dce0afce9b06d8dace6fa052528e60f7622aa6cfd3e71bd372ca5079d426e78336ca564bc0d5f37acbcda1b21f4fe656fcb642f1a93a697ab39742 languageName: node linkType: hard @@ -1465,162 +1239,162 @@ __metadata: linkType: hard "@babel/plugin-transform-async-to-generator@npm:^7.23.3, @babel/plugin-transform-async-to-generator@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-async-to-generator@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-async-to-generator@npm:7.24.7" dependencies: - "@babel/helper-module-imports": "npm:^7.24.1" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-remap-async-to-generator": "npm:^7.22.20" + "@babel/helper-module-imports": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-remap-async-to-generator": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/3731ba8e83cbea1ab22905031f25b3aeb0b97c6467360a2cc685352f16e7c786417d8883bc747f5a0beff32266bdb12a05b6292e7b8b75967087200a7bc012c4 + checksum: 10c0/83c82e243898875af8457972a26ab29baf8a2078768ee9f35141eb3edff0f84b165582a2ff73e90a9e08f5922bf813dbf15a85c1213654385198f4591c0dc45d languageName: node linkType: hard "@babel/plugin-transform-block-scoped-functions@npm:^7.23.3, @babel/plugin-transform-block-scoped-functions@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-block-scoped-functions@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-block-scoped-functions@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/6fbaa85f5204f34845dfc0bebf62fdd3ac5a286241c85651e59d426001e7a1785ac501f154e093e0b8ee49e1f51e3f8b06575a5ae8d4a9406d43e4816bf18c37 + checksum: 10c0/113e86de4612ae91773ff5cb6b980f01e1da7e26ae6f6012127415d7ae144e74987bc23feb97f63ba4bc699331490ddea36eac004d76a20d5369e4cc6a7f61cd languageName: node linkType: hard "@babel/plugin-transform-block-scoping@npm:^7.23.4, @babel/plugin-transform-block-scoping@npm:^7.24.4, @babel/plugin-transform-block-scoping@npm:^7.8.3": - version: 7.24.4 - resolution: "@babel/plugin-transform-block-scoping@npm:7.24.4" + version: 7.24.7 + resolution: "@babel/plugin-transform-block-scoping@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/62f55fd1b60a115506e9553c3bf925179b1ab8a42dc31471c4e3ada20573a488b5c5e3317145da352493ef07f1d9750ce1f8a49cb3f39489ac1ab42e5ddc883d + checksum: 10c0/dcbc5e385c0ca5fb5736b1c720c90755cffe9f91d8c854f82e61e59217dd3f6c91b3633eeee4b55a89d3f59e5275d0f5b0b1b1363d4fa70c49c468b55aa87700 languageName: node linkType: hard "@babel/plugin-transform-class-properties@npm:^7.22.5, @babel/plugin-transform-class-properties@npm:^7.23.3, @babel/plugin-transform-class-properties@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-class-properties@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-class-properties@npm:7.24.7" dependencies: - "@babel/helper-create-class-features-plugin": "npm:^7.24.1" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-class-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/00dff042ac9df4ae67b5ef98b1137cc72e0a24e6d911dc200540a8cb1f00b4cff367a922aeb22da17da662079f0abcd46ee1c5f4cdf37ceebf6ff1639bb9af27 + checksum: 10c0/75018a466c7ede3d2397e158891c224ba7fca72864506ce067ddbc02fc65191d44da4d6379c996d0c7f09019e26b5c3f5f1d3a639cd98366519723886f0689d0 languageName: node linkType: hard "@babel/plugin-transform-class-static-block@npm:^7.23.4, @babel/plugin-transform-class-static-block@npm:^7.24.4": - version: 7.24.4 - resolution: "@babel/plugin-transform-class-static-block@npm:7.24.4" + version: 7.24.7 + resolution: "@babel/plugin-transform-class-static-block@npm:7.24.7" dependencies: - "@babel/helper-create-class-features-plugin": "npm:^7.24.4" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-class-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-class-static-block": "npm:^7.14.5" peerDependencies: "@babel/core": ^7.12.0 - checksum: 10c0/19dfeaf4a2ac03695034f7211a8b5ad89103b224608ac3e91791055107c5fe4d7ebe5d9fbb31b4a91265694af78762260642eb270f4b239c175984ee4b253f80 + checksum: 10c0/b0ade39a3d09dce886f79dbd5907c3d99b48167eddb6b9bbde24a0598129654d7017e611c20494cdbea48b07ac14397cd97ea34e3754bbb2abae4e698128eccb languageName: node linkType: hard "@babel/plugin-transform-classes@npm:^7.23.8, @babel/plugin-transform-classes@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-classes@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-classes@npm:7.24.7" dependencies: - "@babel/helper-annotate-as-pure": "npm:^7.22.5" - "@babel/helper-compilation-targets": "npm:^7.23.6" - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-function-name": "npm:^7.23.0" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-replace-supers": "npm:^7.24.1" - "@babel/helper-split-export-declaration": "npm:^7.22.6" + "@babel/helper-annotate-as-pure": "npm:^7.24.7" + "@babel/helper-compilation-targets": "npm:^7.24.7" + "@babel/helper-environment-visitor": "npm:^7.24.7" + "@babel/helper-function-name": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-replace-supers": "npm:^7.24.7" + "@babel/helper-split-export-declaration": "npm:^7.24.7" globals: "npm:^11.1.0" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/586a95826be4d68056fa23d8e6c34353ce2ea59bf3ca8cf62bc784e60964d492d76e1b48760c43fd486ffb65a79d3fed9a4f91289e4f526f88c3b6acc0dfb00e + checksum: 10c0/e51dba7ce8b770d1eee929e098d5a3be3efc3e8b941e22dda7d0097dc4e7be5feabd2da7b707ac06fcac5661b31223c541941dec08ce76c1faa55544d87d06ec languageName: node linkType: hard "@babel/plugin-transform-computed-properties@npm:^7.23.3, @babel/plugin-transform-computed-properties@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-computed-properties@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-computed-properties@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/template": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/template": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/8292c508b656b7722e2c2ca0f6f31339852e3ed2b9b80f6e068a4010e961b431ca109ecd467fc906283f4b1574c1e7b1cb68d35a4dea12079d386c15ff7e0eac + checksum: 10c0/25636dbc1f605c0b8bc60aa58628a916b689473d11551c9864a855142e36742fe62d4a70400ba3b74902338e77fb3d940376c0a0ba154b6b7ec5367175233b49 languageName: node linkType: hard "@babel/plugin-transform-destructuring@npm:^7.23.3, @babel/plugin-transform-destructuring@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-destructuring@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-destructuring@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/a08e706a9274a699abc3093f38c72d4a5354eac11c44572cc9ea049915b6e03255744297069fd94fcce82380725c5d6b1b11b9a84c0081aa3aa6fc2fdab98ef6 + checksum: 10c0/929f07a807fb62230bfbf881cfcedf187ac5daf2f1b01da94a75c7a0f6f72400268cf4bcfee534479e43260af8193e42c31ee03c8b0278ba77d0036ed6709c27 languageName: node linkType: hard "@babel/plugin-transform-dotall-regex@npm:^7.23.3, @babel/plugin-transform-dotall-regex@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-dotall-regex@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-dotall-regex@npm:7.24.7" dependencies: - "@babel/helper-create-regexp-features-plugin": "npm:^7.22.15" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-regexp-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/758def705ec5a87ef910280dc2df5d2fda59dc5d4771c1725c7aed0988ae5b79e29aeb48109120301a3e1c6c03dfac84700469de06f38ca92c96834e09eadf5d + checksum: 10c0/793f14c9494972d294b7e7b97b747f47874b6d57d7804d3443c701becf5db192c9311be6a1835c07664486df1f5c60d33196c36fb7e11a53015e476b4c145b33 languageName: node linkType: hard "@babel/plugin-transform-duplicate-keys@npm:^7.23.3, @babel/plugin-transform-duplicate-keys@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-duplicate-keys@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-duplicate-keys@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/41072f57f83a6c2b15f3ee0b6779cdca105ff3d98061efe92ac02d6c7b90fdb6e7e293b8a4d5b9c690d9ae5d3ae73e6bde4596dc4d8c66526a0e5e1abc73c88c + checksum: 10c0/75ff7ec1117ac500e77bf20a144411d39c0fdd038f108eec061724123ce6d1bb8d5bd27968e466573ee70014f8be0043361cdb0ef388f8a182d1d97ad67e51b9 languageName: node linkType: hard "@babel/plugin-transform-dynamic-import@npm:^7.23.4, @babel/plugin-transform-dynamic-import@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-dynamic-import@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-dynamic-import@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-dynamic-import": "npm:^7.8.3" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/7e2834780e9b5251ef341854043a89c91473b83c335358620ca721554877e64e416aeb3288a35f03e825c4958e07d5d00ead08c4490fadc276a21fe151d812f1 + checksum: 10c0/eeda48372efd0a5103cb22dadb13563c975bce18ae85daafbb47d57bb9665d187da9d4fe8d07ac0a6e1288afcfcb73e4e5618bf75ff63fddf9736bfbf225203b languageName: node linkType: hard "@babel/plugin-transform-exponentiation-operator@npm:^7.23.3, @babel/plugin-transform-exponentiation-operator@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-exponentiation-operator@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-exponentiation-operator@npm:7.24.7" dependencies: - "@babel/helper-builder-binary-assignment-operator-visitor": "npm:^7.22.15" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-builder-binary-assignment-operator-visitor": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/f0fc4c5a9add25fd6bf23dabe6752e9b7c0a2b2554933dddfd16601245a2ba332b647951079c782bf3b94c6330e3638b9b4e0227f469a7c1c707446ba0eba6c7 + checksum: 10c0/ace3e11c94041b88848552ba8feb39ae4d6cad3696d439ff51445bd2882d8b8775d85a26c2c0edb9b5e38c9e6013cc11b0dea89ec8f93c7d9d7ee95e3645078c languageName: node linkType: hard "@babel/plugin-transform-export-namespace-from@npm:^7.23.4, @babel/plugin-transform-export-namespace-from@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-export-namespace-from@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-export-namespace-from@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-export-namespace-from": "npm:^7.8.3" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/510bb23b2423d5fbffef69b356e4050929c21a7627e8194b1506dd935c7d9cbbd696c9ae9d7c3bcd7e6e7b69561b0b290c2d72d446327b40fc20ce40bbca6712 + checksum: 10c0/4e144d7f1c57bc63b4899dbbbdfed0880f2daa75ea9c7251c7997f106e4b390dc362175ab7830f11358cb21f6b972ca10a43a2e56cd789065f7606b082674c0c languageName: node linkType: hard @@ -1637,171 +1411,171 @@ __metadata: linkType: hard "@babel/plugin-transform-for-of@npm:^7.23.6, @babel/plugin-transform-for-of@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-for-of@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-for-of@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.22.5" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/e4bc92b1f334246e62d4bde079938df940794db564742034f6597f2e38bd426e11ae8c5670448e15dd6e45c462f2a9ab3fa87259bddf7c08553ffd9457fc2b2c + checksum: 10c0/77629b1173e55d07416f05ba7353caa09d2c2149da2ca26721ab812209b63689d1be45116b68eadc011c49ced59daf5320835b15245eb7ae93ae0c5e8277cfc0 languageName: node linkType: hard "@babel/plugin-transform-function-name@npm:^7.23.3, @babel/plugin-transform-function-name@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-function-name@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-function-name@npm:7.24.7" dependencies: - "@babel/helper-compilation-targets": "npm:^7.23.6" - "@babel/helper-function-name": "npm:^7.23.0" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-compilation-targets": "npm:^7.24.7" + "@babel/helper-function-name": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/65c1735ec3b5e43db9b5aebf3c16171c04b3050c92396b9e22dda0d2aaf51f43fdcf147f70a40678fd9a4ee2272a5acec4826e9c21bcf968762f4c184897ad75 + checksum: 10c0/3e9642428d6952851850d89ea9307d55946528d18973784d0e2f04a651b23bd9924dd8a2641c824b483bd4ab1223bab1d2f6a1106a939998f7ced512cb60ac5b languageName: node linkType: hard "@babel/plugin-transform-json-strings@npm:^7.23.4, @babel/plugin-transform-json-strings@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-json-strings@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-json-strings@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-json-strings": "npm:^7.8.3" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/13d9b6a3c31ab4be853b3d49d8d1171f9bd8198562fd75da8f31e7de31398e1cfa6eb1d073bed93c9746e4f9c47a53b20f8f4c255ece3f88c90852ad3181dc2d + checksum: 10c0/17c72cd5bf3e90e722aabd333559275f3309e3fa0b9cea8c2944ab83ae01502c71a2be05da5101edc02b3fc8df15a8dbb9b861cbfcc8a52bf5e797cf01d3a40a languageName: node linkType: hard "@babel/plugin-transform-literals@npm:^7.23.3, @babel/plugin-transform-literals@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-literals@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-literals@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/a27cc7d565ee57b5a2bf136fa889c5c2f5988545ae7b3b2c83a7afe5dd37dfac80dca88b1c633c65851ce6af7d2095c04c01228657ce0198f918e64b5ccd01fa + checksum: 10c0/9f3f6f3831929cd2a977748c07addf9944d5cccb50bd3a24a58beb54f91f00d6cacd3d7831d13ffe1ad6f8aba0aefd7bca5aec65d63b77f39c62ad1f2d484a3e languageName: node linkType: hard "@babel/plugin-transform-logical-assignment-operators@npm:^7.23.4, @babel/plugin-transform-logical-assignment-operators@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-logical-assignment-operators@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-logical-assignment-operators": "npm:^7.10.4" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/98a2e0843ddfe51443c1bfcf08ba40ad8856fd4f8e397b392a5390a54f257c8c1b9a99d8ffc0fc7e8c55cce45e2cd9c2795a4450303f48f501bcbd662de44554 + checksum: 10c0/dbe882eb9053931f2ab332c50fc7c2a10ef507d6421bd9831adbb4cb7c9f8e1e5fbac4fbd2e007f6a1bf1df1843547559434012f118084dc0bf42cda3b106272 languageName: node linkType: hard "@babel/plugin-transform-member-expression-literals@npm:^7.23.3, @babel/plugin-transform-member-expression-literals@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-member-expression-literals@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-member-expression-literals@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/2af731d02aa4c757ef80c46df42264128cbe45bfd15e1812d1a595265b690a44ad036041c406a73411733540e1c4256d8174705ae6b8cfaf757fc175613993fd + checksum: 10c0/e789ae359bdf2d20e90bedef18dfdbd965c9ebae1cee398474a0c349590fda7c8b874e1a2ceee62e47e5e6ec1730e76b0f24e502164357571854271fc12cc684 languageName: node linkType: hard "@babel/plugin-transform-modules-amd@npm:^7.13.0, @babel/plugin-transform-modules-amd@npm:^7.23.3, @babel/plugin-transform-modules-amd@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-modules-amd@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-modules-amd@npm:7.24.7" dependencies: - "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-module-transforms": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/71fd04e5e7026e6e52701214b1e9f7508ba371b757e5075fbb938a79235ed66a54ce65f89bb92b59159e9f03f01b392e6c4de6d255b948bec975a90cfd6809ef + checksum: 10c0/6df7de7fce34117ca4b2fa07949b12274c03668cbfe21481c4037b6300796d50ae40f4f170527b61b70a67f26db906747797e30dbd0d9809a441b6e220b5728f languageName: node linkType: hard "@babel/plugin-transform-modules-commonjs@npm:^7.13.8, @babel/plugin-transform-modules-commonjs@npm:^7.23.0, @babel/plugin-transform-modules-commonjs@npm:^7.23.3, @babel/plugin-transform-modules-commonjs@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-modules-commonjs@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-modules-commonjs@npm:7.24.7" dependencies: - "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-simple-access": "npm:^7.22.5" + "@babel/helper-module-transforms": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-simple-access": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/efb3ea2047604a7eb44a9289311ebb29842fe6510ff8b66a77a60440448c65e1312a60dc48191ed98246bdbd163b5b6f3348a0669bcc0e3809e69c7c776b20fa + checksum: 10c0/9442292b3daf6a5076cdc3c4c32bf423bda824ccaeb0dd0dc8b3effaa1fecfcb0130ae6e647fef12a5d5ff25bcc99a0d6bfc6d24a7525345e1bcf46fcdf81752 languageName: node linkType: hard "@babel/plugin-transform-modules-systemjs@npm:^7.23.9, @babel/plugin-transform-modules-systemjs@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-modules-systemjs@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-modules-systemjs@npm:7.24.7" dependencies: - "@babel/helper-hoist-variables": "npm:^7.22.5" - "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-validator-identifier": "npm:^7.22.20" + "@babel/helper-hoist-variables": "npm:^7.24.7" + "@babel/helper-module-transforms": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-validator-identifier": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/38145f8abe8a4ce2b41adabe5d65eb7bd54a139dc58e2885fec975eb5cf247bd938c1dd9f09145c46dbe57d25dd0ef7f00a020e5eb0cbe8195b2065d51e2d93d + checksum: 10c0/e2a795e0a6baafe26f4a74010622212ddd873170742d673f450e0097f8d984f6e6a95eb8ce41b05071ee9790c4be088b33801aaab3f78ee202c567634e52a331 languageName: node linkType: hard "@babel/plugin-transform-modules-umd@npm:^7.23.3, @babel/plugin-transform-modules-umd@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-modules-umd@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-modules-umd@npm:7.24.7" dependencies: - "@babel/helper-module-transforms": "npm:^7.23.3" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-module-transforms": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/14c90c58562b54e17fe4a8ded3f627f9a993648f8378ef00cb2f6c34532032b83290d2ad54c7fff4f0c2cd49091bda780f8cc28926ec4b77a6c2141105a2e699 + checksum: 10c0/7791d290121db210e4338b94b4a069a1a79e4c7a8d7638d8159a97b281851bbed3048dac87a4ae718ad963005e6c14a5d28e6db2eeb2b04e031cee92fb312f85 languageName: node linkType: hard "@babel/plugin-transform-named-capturing-groups-regex@npm:^7.22.5": - version: 7.22.5 - resolution: "@babel/plugin-transform-named-capturing-groups-regex@npm:7.22.5" + version: 7.24.7 + resolution: "@babel/plugin-transform-named-capturing-groups-regex@npm:7.24.7" dependencies: - "@babel/helper-create-regexp-features-plugin": "npm:^7.22.5" - "@babel/helper-plugin-utils": "npm:^7.22.5" + "@babel/helper-create-regexp-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0 - checksum: 10c0/b0b072bef303670b5a98307bc37d1ac326cb7ad40ea162b89a03c2ffc465451be7ef05be95cb81ed28bfeb29670dc98fe911f793a67bceab18b4cb4c81ef48f3 + checksum: 10c0/41a0b0f2d0886318237440aa3b489f6d0305361d8671121777d9ff89f9f6de9d0c02ce93625049061426c8994064ef64deae8b819d1b14c00374a6a2336fb5d9 languageName: node linkType: hard "@babel/plugin-transform-new-target@npm:^7.23.3, @babel/plugin-transform-new-target@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-new-target@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-new-target@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/c4cabe628163855f175a8799eb73d692b6f1dc347aae5022af0c253f80c92edb962e48ddccc98b691eff3d5d8e53c9a8f10894c33ba4cebc2e2f8f8fe554fb7a + checksum: 10c0/2540808a35e1a978e537334c43dab439cf24c93e7beb213a2e71902f6710e60e0184316643790c0a6644e7a8021e52f7ab8165e6b3e2d6651be07bdf517b67df languageName: node linkType: hard "@babel/plugin-transform-nullish-coalescing-operator@npm:^7.22.11, @babel/plugin-transform-nullish-coalescing-operator@npm:^7.23.4, @babel/plugin-transform-nullish-coalescing-operator@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-nullish-coalescing-operator@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-nullish-coalescing-operator": "npm:^7.8.3" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/c8532951506fb031287280cebeef10aa714f8a7cea2b62a13c805f0e0af945ba77a7c87e4bbbe4c37fe973e0e5d5e649cfac7f0374f57efc54cdf9656362a392 + checksum: 10c0/7243c8ff734ed5ef759dd8768773c4b443c12e792727e759a1aec2c7fa2bfdd24f1ecb42e292a7b3d8bd3d7f7b861cf256a8eb4ba144fc9cc463892c303083d9 languageName: node linkType: hard "@babel/plugin-transform-numeric-separator@npm:^7.23.4, @babel/plugin-transform-numeric-separator@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-numeric-separator@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-numeric-separator@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-numeric-separator": "npm:^7.10.4" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/15e2b83292e586fb4f5b4b4021d4821a806ca6de2b77d5ad6c4e07aa7afa23704e31b4d683dac041afc69ac51b2461b96e8c98e46311cc1faba54c73f235044f + checksum: 10c0/e18e09ca5a6342645d00ede477731aa6e8714ff357efc9d7cda5934f1703b3b6fb7d3298dce3ce3ba53e9ff1158eab8f1aadc68874cc21a6099d33a1ca457789 languageName: node linkType: hard @@ -1817,44 +1591,44 @@ __metadata: linkType: hard "@babel/plugin-transform-object-rest-spread@npm:^7.24.0, @babel/plugin-transform-object-rest-spread@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-object-rest-spread@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-object-rest-spread@npm:7.24.7" dependencies: - "@babel/helper-compilation-targets": "npm:^7.23.6" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-compilation-targets": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-object-rest-spread": "npm:^7.8.3" - "@babel/plugin-transform-parameters": "npm:^7.24.1" + "@babel/plugin-transform-parameters": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/e301f1a66b63bafc2bce885305cc88ab30ec875b5e2c7933fb7f9cbf0d954685aa10334ffcecf147ba19d6a1d7ffab37baf4ce871849d395941c56fdb3060f73 + checksum: 10c0/9ad64bc003f583030f9da50614b485852f8edac93f8faf5d1cd855201a4852f37c5255ae4daf70dd4375bdd4874e16e39b91f680d4668ec219ba05441ce286eb languageName: node linkType: hard "@babel/plugin-transform-object-super@npm:^7.23.3, @babel/plugin-transform-object-super@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-object-super@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-object-super@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-replace-supers": "npm:^7.24.1" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-replace-supers": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/d30e6b9e59a707efd7ed524fc0a8deeea046011a6990250f2e9280516683138e2d13d9c52daf41d78407bdab0378aef7478326f2a15305b773d851cb6e106157 + checksum: 10c0/770cebb4b4e1872c216b17069db9a13b87dfee747d359dc56d9fcdd66e7544f92dc6ab1861a4e7e0528196aaff2444e4f17dc84efd8eaf162d542b4ba0943869 languageName: node linkType: hard "@babel/plugin-transform-optional-catch-binding@npm:^7.23.4, @babel/plugin-transform-optional-catch-binding@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-optional-catch-binding@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-optional-catch-binding@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-optional-catch-binding": "npm:^7.8.3" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/68408b9ef772d9aa5dccf166c86dc4d2505990ce93e03dcfc65c73fb95c2511248e009ba9ccf5b96405fb85de1c16ad8291016b1cc5689ee4becb1e3050e0ae7 + checksum: 10c0/1e2f10a018f7d03b3bde6c0b70d063df8d5dd5209861d4467726cf834f5e3d354e2276079dc226aa8e6ece35f5c9b264d64b8229a8bb232829c01e561bcfb07a languageName: node linkType: hard -"@babel/plugin-transform-optional-chaining@npm:^7.23.0, @babel/plugin-transform-optional-chaining@npm:^7.23.4, @babel/plugin-transform-optional-chaining@npm:^7.24.1": +"@babel/plugin-transform-optional-chaining@npm:^7.23.0, @babel/plugin-transform-optional-chaining@npm:^7.23.4, @babel/plugin-transform-optional-chaining@npm:^7.24.1, @babel/plugin-transform-optional-chaining@npm:^7.24.7": version: 7.24.7 resolution: "@babel/plugin-transform-optional-chaining@npm:7.24.7" dependencies: @@ -1867,7 +1641,7 @@ __metadata: languageName: node linkType: hard -"@babel/plugin-transform-parameters@npm:^7.23.3, @babel/plugin-transform-parameters@npm:^7.24.1": +"@babel/plugin-transform-parameters@npm:^7.23.3, @babel/plugin-transform-parameters@npm:^7.24.1, @babel/plugin-transform-parameters@npm:^7.24.7": version: 7.24.7 resolution: "@babel/plugin-transform-parameters@npm:7.24.7" dependencies: @@ -1879,39 +1653,39 @@ __metadata: linkType: hard "@babel/plugin-transform-private-methods@npm:^7.22.5, @babel/plugin-transform-private-methods@npm:^7.23.3, @babel/plugin-transform-private-methods@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-private-methods@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-private-methods@npm:7.24.7" dependencies: - "@babel/helper-create-class-features-plugin": "npm:^7.24.1" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-class-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/d8e18587d2a8b71a795da5e8841b0e64f1525a99ad73ea8b9caa331bc271d69646e2e1e749fd634321f3df9d126070208ddac22a27ccf070566b2efb74fecd99 + checksum: 10c0/5b7bf923b738fbe3ad6c33b260e0a7451be288edfe4ef516303fa787a1870cd87533bfbf61abb779c22ed003c2fc484dec2436fe75a48756f686c0241173d364 languageName: node linkType: hard "@babel/plugin-transform-private-property-in-object@npm:^7.23.4, @babel/plugin-transform-private-property-in-object@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-private-property-in-object@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-private-property-in-object@npm:7.24.7" dependencies: - "@babel/helper-annotate-as-pure": "npm:^7.22.5" - "@babel/helper-create-class-features-plugin": "npm:^7.24.1" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-annotate-as-pure": "npm:^7.24.7" + "@babel/helper-create-class-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" "@babel/plugin-syntax-private-property-in-object": "npm:^7.14.5" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/33d2b9737de7667d7a1b704eef99bfecc6736157d9ea28c2e09010d5f25e33ff841c41d89a4430c5d47f4eb3384e24770fa0ec79600e1e38d6d16e2f9333b4b5 + checksum: 10c0/c6fa7defb90b1b0ed46f24ff94ff2e77f44c1f478d1090e81712f33cf992dda5ba347016f030082a2f770138bac6f4a9c2c1565e9f767a125901c77dd9c239ba languageName: node linkType: hard "@babel/plugin-transform-property-literals@npm:^7.23.3, @babel/plugin-transform-property-literals@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-property-literals@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-property-literals@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/3bf3e01f7bb8215a8b6d0081b6f86fea23e3a4543b619e059a264ede028bc58cdfb0acb2c43271271915a74917effa547bc280ac636a9901fa9f2fb45623f87e + checksum: 10c0/52564b58f3d111dc02d241d5892a4b01512e98dfdf6ef11b0ed62f8b11b0acacccef0fc229b44114fe8d1a57a8b70780b11bdd18b807d3754a781a07d8f57433 languageName: node linkType: hard @@ -1987,25 +1761,25 @@ __metadata: linkType: hard "@babel/plugin-transform-regenerator@npm:^7.23.3, @babel/plugin-transform-regenerator@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-regenerator@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-regenerator@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" regenerator-transform: "npm:^0.15.2" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/0a333585d7c0b38d31cc549d0f3cf7c396d1d50b6588a307dc58325505ddd4f5446188bc536c4779431b396251801b3f32d6d8e87db8274bc84e8c41950737f7 + checksum: 10c0/d2dc2c788fdae9d97217e70d46ba8ca9db0035c398dc3e161552b0c437113719a75c04f201f9c91ddc8d28a1da60d0b0853f616dead98a396abb9c845c44892b languageName: node linkType: hard "@babel/plugin-transform-reserved-words@npm:^7.23.3, @babel/plugin-transform-reserved-words@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-reserved-words@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-reserved-words@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/936d6e73cafb2cbb495f6817c6f8463288dbc9ab3c44684b931ebc1ece24f0d55dfabc1a75ba1de5b48843d0fef448dcfdbecb8485e4014f8f41d0d1440c536f + checksum: 10c0/2229de2768615e7f5dc0bbc55bc121b5678fd6d2febd46c74a58e42bb894d74cd5955c805880f4e02d0e1cf94f6886270eda7fafc1be9305a1ec3b9fd1d063f5 languageName: node linkType: hard @@ -2042,119 +1816,119 @@ __metadata: linkType: hard "@babel/plugin-transform-shorthand-properties@npm:^7.23.3, @babel/plugin-transform-shorthand-properties@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-shorthand-properties@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-shorthand-properties@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/8273347621183aada3cf1f3019d8d5f29467ba13a75b72cb405bc7f23b7e05fd85f4edb1e4d9f0103153dddb61826a42dc24d466480d707f8932c1923a4c25fa + checksum: 10c0/41b155bdbb3be66618358488bf7731b3b2e8fff2de3dbfd541847720a9debfcec14db06a117abedd03c9cd786db20a79e2a86509a4f19513f6e1b610520905cf languageName: node linkType: hard "@babel/plugin-transform-spread@npm:^7.23.3, @babel/plugin-transform-spread@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-spread@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-spread@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.22.5" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/helper-skip-transparent-expression-wrappers": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/50a0302e344546d57e5c9f4dea575f88e084352eeac4e9a3e238c41739eef2df1daf4a7ebbb3ccb7acd3447f6a5ce9938405f98bf5f5583deceb8257f5a673c9 + checksum: 10c0/facba1553035f76b0d2930d4ada89a8cd0f45b79579afd35baefbfaf12e3b86096995f4b0c402cf9ee23b3f2ea0a4460c3b1ec0c192d340962c948bb223d4e66 languageName: node linkType: hard "@babel/plugin-transform-sticky-regex@npm:^7.23.3, @babel/plugin-transform-sticky-regex@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-sticky-regex@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-sticky-regex@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/786fe2ae11ef9046b9fa95677935abe495031eebf1274ad03f2054a20adea7b9dbd00336ac0b143f7924bc562e5e09793f6e8613607674b97e067d4838ccc4a0 + checksum: 10c0/5a74ed2ed0a3ab51c3d15fcaf09d9e2fe915823535c7a4d7b019813177d559b69677090e189ec3d5d08b619483eb5ad371fbcfbbff5ace2a76ba33ee566a1109 languageName: node linkType: hard "@babel/plugin-transform-template-literals@npm:^7.23.3, @babel/plugin-transform-template-literals@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-template-literals@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-template-literals@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/f73bcda5488eb81c6e7a876498d9e6b72be32fca5a4d9db9053491a2d1300cd27b889b463fd2558f3cd5826a85ed00f61d81b234aa55cb5a0abf1b6fa1bd5026 + checksum: 10c0/3630f966257bcace122f04d3157416a09d40768c44c3a800855da81146b009187daa21859d1c3b7d13f4e19e8888e60613964b175b2275d451200fb6d8d6cfe6 languageName: node linkType: hard "@babel/plugin-transform-typeof-symbol@npm:^7.23.3, @babel/plugin-transform-typeof-symbol@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-typeof-symbol@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-typeof-symbol@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/d392f549bfd13414f59feecdf3fb286f266a3eb9107a9de818e57907bda56eed08d1f6f8e314d09bf99252df026a7fd4d5df839acd45078a777abcebaa9a8593 + checksum: 10c0/5649e7260a138681e68b296ab5931e2b1f132f287d6b4131d49b24f9dc20d62902b7e9d63c4d2decd5683b41df35ef4b9b03f58c7f9f65e4c25a6d8bbf04e9e9 languageName: node linkType: hard "@babel/plugin-transform-typescript@npm:^7.13.0, @babel/plugin-transform-typescript@npm:^7.24.1": - version: 7.24.4 - resolution: "@babel/plugin-transform-typescript@npm:7.24.4" + version: 7.24.7 + resolution: "@babel/plugin-transform-typescript@npm:7.24.7" dependencies: - "@babel/helper-annotate-as-pure": "npm:^7.22.5" - "@babel/helper-create-class-features-plugin": "npm:^7.24.4" - "@babel/helper-plugin-utils": "npm:^7.24.0" - "@babel/plugin-syntax-typescript": "npm:^7.24.1" + "@babel/helper-annotate-as-pure": "npm:^7.24.7" + "@babel/helper-create-class-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" + "@babel/plugin-syntax-typescript": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/fa6625046f219cdc75061025c8031ada75ef631b137f1442e3d0054ba4e63548eb12cf55e2e1f442c889aa5fdd76d0d0b7904fdf812ce4c38748446227acc798 + checksum: 10c0/e8dacdc153a4c4599014b66eb01b94e3dc933d58d4f0cc3039c1a8f432e77b9df14f34a61964e014b975bf466f3fefd8c4768b3e887d3da1be9dc942799bdfdf languageName: node linkType: hard "@babel/plugin-transform-unicode-escapes@npm:^7.23.3, @babel/plugin-transform-unicode-escapes@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-unicode-escapes@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-unicode-escapes@npm:7.24.7" dependencies: - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/67a72a1ed99639de6a93aead35b1993cb3f0eb178a8991fcef48732c38c9f0279c85bbe1e2e2477b85afea873e738ff0955a35057635ce67bc149038e2d8a28e + checksum: 10c0/8b18e2e66af33471a6971289492beff5c240e56727331db1d34c4338a6a368a82a7ed6d57ec911001b6d65643aed76531e1e7cac93265fb3fb2717f54d845e69 languageName: node linkType: hard "@babel/plugin-transform-unicode-property-regex@npm:^7.23.3, @babel/plugin-transform-unicode-property-regex@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-unicode-property-regex@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-unicode-property-regex@npm:7.24.7" dependencies: - "@babel/helper-create-regexp-features-plugin": "npm:^7.22.15" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-regexp-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/d9d9752df7d51bf9357c0bf3762fe16b8c841fca9ecf4409a16f15ccc34be06e8e71abfaee1251b7d451227e70e6b873b36f86b090efdb20f6f7de5fdb6c7a05 + checksum: 10c0/bc57656eb94584d1b74a385d378818ac2b3fca642e3f649fead8da5fb3f9de22f8461185936915dfb33d5a9104e62e7a47828331248b09d28bb2d59e9276de3e languageName: node linkType: hard "@babel/plugin-transform-unicode-regex@npm:^7.23.3, @babel/plugin-transform-unicode-regex@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-unicode-regex@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-unicode-regex@npm:7.24.7" dependencies: - "@babel/helper-create-regexp-features-plugin": "npm:^7.22.15" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-regexp-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0-0 - checksum: 10c0/6046ab38e5d14ed97dbb921bd79ac1d7ad9d3286da44a48930e980b16896db2df21e093563ec3c916a630dc346639bf47c5924a33902a06fe3bbb5cdc7ef5f2f + checksum: 10c0/83f72a345b751566b601dc4d07e9f2c8f1bc0e0c6f7abb56ceb3095b3c9d304de73f85f2f477a09f8cc7edd5e65afd0ff9e376cdbcbea33bc0c28f3705b38fd9 languageName: node linkType: hard "@babel/plugin-transform-unicode-sets-regex@npm:^7.23.3, @babel/plugin-transform-unicode-sets-regex@npm:^7.24.1": - version: 7.24.1 - resolution: "@babel/plugin-transform-unicode-sets-regex@npm:7.24.1" + version: 7.24.7 + resolution: "@babel/plugin-transform-unicode-sets-regex@npm:7.24.7" dependencies: - "@babel/helper-create-regexp-features-plugin": "npm:^7.22.15" - "@babel/helper-plugin-utils": "npm:^7.24.0" + "@babel/helper-create-regexp-features-plugin": "npm:^7.24.7" + "@babel/helper-plugin-utils": "npm:^7.24.7" peerDependencies: "@babel/core": ^7.0.0 - checksum: 10c0/b6c1f6b90afeeddf97e5713f72575787fcb7179be7b4c961869bfbc66915f66540dc49da93e4369da15596bd44b896d1eb8a50f5e1fd907abd7a1a625901006b + checksum: 10c0/7457c0ee8e80a80cb6fdc1fe54ab115b52815627616ce9151be8ef292fc99d04a910ec24f11382b4f124b89374264396892b086886bd2a9c2317904d87c9b21b languageName: node linkType: hard @@ -2502,25 +2276,7 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.16.0, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.23.9, @babel/traverse@npm:^7.24.0, @babel/traverse@npm:^7.24.1, @babel/traverse@npm:^7.4.5": - version: 7.24.1 - resolution: "@babel/traverse@npm:7.24.1" - dependencies: - "@babel/code-frame": "npm:^7.24.1" - "@babel/generator": "npm:^7.24.1" - "@babel/helper-environment-visitor": "npm:^7.22.20" - "@babel/helper-function-name": "npm:^7.23.0" - "@babel/helper-hoist-variables": "npm:^7.22.5" - "@babel/helper-split-export-declaration": "npm:^7.22.6" - "@babel/parser": "npm:^7.24.1" - "@babel/types": "npm:^7.24.0" - debug: "npm:^4.3.1" - globals: "npm:^11.1.0" - checksum: 10c0/c087b918f6823776537ba246136c70e7ce0719fc05361ebcbfd16f4e6f2f6f1f8f4f9167f1d9b675f27d12074839605189cc9d689de20b89a85e7c140f23daab - languageName: node - linkType: hard - -"@babel/traverse@npm:^7.22.5, @babel/traverse@npm:^7.25.2": +"@babel/traverse@npm:^7.1.6, @babel/traverse@npm:^7.16.0, @babel/traverse@npm:^7.18.9, @babel/traverse@npm:^7.22.5, @babel/traverse@npm:^7.23.9, @babel/traverse@npm:^7.24.0, @babel/traverse@npm:^7.24.1, @babel/traverse@npm:^7.24.7, @babel/traverse@npm:^7.25.2, @babel/traverse@npm:^7.4.5": version: 7.25.3 resolution: "@babel/traverse@npm:7.25.3" dependencies: @@ -2535,24 +2291,6 @@ __metadata: languageName: node linkType: hard -"@babel/traverse@npm:^7.24.7": - version: 7.24.7 - resolution: "@babel/traverse@npm:7.24.7" - dependencies: - "@babel/code-frame": "npm:^7.24.7" - "@babel/generator": "npm:^7.24.7" - "@babel/helper-environment-visitor": "npm:^7.24.7" - "@babel/helper-function-name": "npm:^7.24.7" - "@babel/helper-hoist-variables": "npm:^7.24.7" - "@babel/helper-split-export-declaration": "npm:^7.24.7" - "@babel/parser": "npm:^7.24.7" - "@babel/types": "npm:^7.24.7" - debug: "npm:^4.3.1" - globals: "npm:^11.1.0" - checksum: 10c0/a5135e589c3f1972b8877805f50a084a04865ccb1d68e5e1f3b94a8841b3485da4142e33413d8fd76bc0e6444531d3adf1f59f359c11ffac452b743d835068ab - languageName: node - linkType: hard - "@babel/types@npm:7.17.0": version: 7.17.0 resolution: "@babel/types@npm:7.17.0" @@ -2563,18 +2301,7 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.18.9, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.6, @babel/types@npm:^7.23.9, @babel/types@npm:^7.24.0, @babel/types@npm:^7.24.7, @babel/types@npm:^7.4.4, @babel/types@npm:^7.6.1, @babel/types@npm:^7.7.2, @babel/types@npm:^7.8.3, @babel/types@npm:^7.9.6": - version: 7.24.7 - resolution: "@babel/types@npm:7.24.7" - dependencies: - "@babel/helper-string-parser": "npm:^7.24.7" - "@babel/helper-validator-identifier": "npm:^7.24.7" - to-fast-properties: "npm:^2.0.0" - checksum: 10c0/d9ecbfc3eb2b05fb1e6eeea546836ac30d990f395ef3fe3f75ced777a222c3cfc4489492f72e0ce3d9a5a28860a1ce5f81e66b88cf5088909068b3ff4fab72c1 - languageName: node - linkType: hard - -"@babel/types@npm:^7.17.0, @babel/types@npm:^7.25.0, @babel/types@npm:^7.25.2": +"@babel/types@npm:^7.0.0, @babel/types@npm:^7.11.5, @babel/types@npm:^7.17.0, @babel/types@npm:^7.18.9, @babel/types@npm:^7.2.0, @babel/types@npm:^7.20.7, @babel/types@npm:^7.22.5, @babel/types@npm:^7.23.0, @babel/types@npm:^7.23.4, @babel/types@npm:^7.23.6, @babel/types@npm:^7.23.9, @babel/types@npm:^7.24.0, @babel/types@npm:^7.24.7, @babel/types@npm:^7.25.0, @babel/types@npm:^7.25.2, @babel/types@npm:^7.4.4, @babel/types@npm:^7.6.1, @babel/types@npm:^7.7.2, @babel/types@npm:^7.9.6": version: 7.25.2 resolution: "@babel/types@npm:7.25.2" dependencies: @@ -2585,17 +2312,6 @@ __metadata: languageName: node linkType: hard -"@babel/types@npm:^7.22.15, @babel/types@npm:^7.23.0": - version: 7.24.0 - resolution: "@babel/types@npm:7.24.0" - dependencies: - "@babel/helper-string-parser": "npm:^7.23.4" - "@babel/helper-validator-identifier": "npm:^7.22.20" - to-fast-properties: "npm:^2.0.0" - checksum: 10c0/777a0bb5dbe038ca4c905fdafb1cdb6bdd10fe9d63ce13eca0bd91909363cbad554a53dc1f902004b78c1dcbc742056f877f2c99eeedff647333b1fadf51235d - languageName: node - linkType: hard - "@base2/pretty-print-object@npm:1.0.1": version: 1.0.1 resolution: "@base2/pretty-print-object@npm:1.0.1" @@ -6627,7 +6343,7 @@ __metadata: languageName: unknown linkType: soft -"@storybook/icons@npm:^1.2.10": +"@storybook/icons@npm:^1.2.10, @storybook/icons@npm:^1.2.5": version: 1.2.10 resolution: "@storybook/icons@npm:1.2.10" peerDependencies: @@ -6637,16 +6353,6 @@ __metadata: languageName: node linkType: hard -"@storybook/icons@npm:^1.2.5": - version: 1.2.5 - resolution: "@storybook/icons@npm:1.2.5" - peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 - react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 - checksum: 10c0/089622af6de4ab82624d894fbe43688a0eb72f15e6bb8fc19c54fb9f9d7312ce7caf34acebcbd63319dbaef129d8547bc23a5600955d04f6034355e7d82dcfa1 - languageName: node - linkType: hard - "@storybook/instrumenter@workspace:*, @storybook/instrumenter@workspace:lib/instrumenter": version: 0.0.0-use.local resolution: "@storybook/instrumenter@workspace:lib/instrumenter" @@ -9893,16 +9599,7 @@ __metadata: languageName: node linkType: hard -"acorn@npm:^8.0.0, acorn@npm:^8.10.0, acorn@npm:^8.11.2, acorn@npm:^8.11.3, acorn@npm:^8.4.1, acorn@npm:^8.6.0, acorn@npm:^8.7.1, acorn@npm:^8.8.2, acorn@npm:^8.9.0": - version: 8.11.3 - resolution: "acorn@npm:8.11.3" - bin: - acorn: bin/acorn - checksum: 10c0/3ff155f8812e4a746fee8ecff1f227d527c4c45655bb1fad6347c3cb58e46190598217551b1500f18542d2bbe5c87120cb6927f5a074a59166fbdd9468f0a299 - languageName: node - linkType: hard - -"acorn@npm:^8.12.1": +"acorn@npm:^8.0.0, acorn@npm:^8.10.0, acorn@npm:^8.11.2, acorn@npm:^8.11.3, acorn@npm:^8.12.1, acorn@npm:^8.4.1, acorn@npm:^8.6.0, acorn@npm:^8.7.1, acorn@npm:^8.8.2, acorn@npm:^8.9.0": version: 8.12.1 resolution: "acorn@npm:8.12.1" bin: @@ -10590,7 +10287,7 @@ __metadata: languageName: node linkType: hard -"available-typed-arrays@npm:^1.0.6, available-typed-arrays@npm:^1.0.7": +"available-typed-arrays@npm:^1.0.7": version: 1.0.7 resolution: "available-typed-arrays@npm:1.0.7" dependencies: @@ -11140,16 +10837,7 @@ __metadata: languageName: node linkType: hard -"braces@npm:^3.0.2, braces@npm:~3.0.2": - version: 3.0.2 - resolution: "braces@npm:3.0.2" - dependencies: - fill-range: "npm:^7.0.1" - checksum: 10c0/321b4d675791479293264019156ca322163f02dc06e3c4cab33bb15cd43d80b51efef69b0930cfde3acd63d126ebca24cd0544fa6f261e093a0fb41ab9dda381 - languageName: node - linkType: hard - -"braces@npm:^3.0.3": +"braces@npm:^3.0.2, braces@npm:^3.0.3, braces@npm:~3.0.2": version: 3.0.3 resolution: "braces@npm:3.0.3" dependencies: @@ -15594,15 +15282,6 @@ __metadata: languageName: node linkType: hard -"fill-range@npm:^7.0.1": - version: 7.0.1 - resolution: "fill-range@npm:7.0.1" - dependencies: - to-regex-range: "npm:^5.0.1" - checksum: 10c0/7cdad7d426ffbaadf45aeb5d15ec675bbd77f7597ad5399e3d2766987ed20bda24d5fac64b3ee79d93276f5865608bb22344a26b9b1ae6c4d00bd94bf611623f - languageName: node - linkType: hard - "fill-range@npm:^7.1.1": version: 7.1.1 resolution: "fill-range@npm:7.1.1" @@ -16822,7 +16501,7 @@ __metadata: languageName: node linkType: hard -"has-tostringtag@npm:^1.0.0, has-tostringtag@npm:^1.0.1, has-tostringtag@npm:^1.0.2": +"has-tostringtag@npm:^1.0.0, has-tostringtag@npm:^1.0.2": version: 1.0.2 resolution: "has-tostringtag@npm:1.0.2" dependencies: @@ -23431,11 +23110,11 @@ __metadata: linkType: hard "prettier@npm:*, prettier@npm:^3.1.1, prettier@npm:^3.2.5": - version: 3.2.5 - resolution: "prettier@npm:3.2.5" + version: 3.3.3 + resolution: "prettier@npm:3.3.3" bin: prettier: bin/prettier.cjs - checksum: 10c0/ea327f37a7d46f2324a34ad35292af2ad4c4c3c3355da07313339d7e554320f66f65f91e856add8530157a733c6c4a897dc41b577056be5c24c40f739f5ee8c6 + checksum: 10c0/b85828b08e7505716324e4245549b9205c0cacb25342a030ba8885aba2039a115dbcf75a0b7ca3b37bc9d101ee61fab8113fc69ca3359f2a226f1ecc07ad2e26 languageName: node linkType: hard @@ -29580,20 +29259,7 @@ __metadata: languageName: node linkType: hard -"which-typed-array@npm:^1.1.14, which-typed-array@npm:^1.1.2, which-typed-array@npm:^1.1.9": - version: 1.1.14 - resolution: "which-typed-array@npm:1.1.14" - dependencies: - available-typed-arrays: "npm:^1.0.6" - call-bind: "npm:^1.0.5" - for-each: "npm:^0.3.3" - gopd: "npm:^1.0.1" - has-tostringtag: "npm:^1.0.1" - checksum: 10c0/0960f1e77807058819451b98c51d4cd72031593e8de990b24bd3fc22e176f5eee22921d68d852297c786aec117689f0423ed20aa4fde7ce2704d680677891f56 - languageName: node - linkType: hard - -"which-typed-array@npm:^1.1.15": +"which-typed-array@npm:^1.1.14, which-typed-array@npm:^1.1.15, which-typed-array@npm:^1.1.2, which-typed-array@npm:^1.1.9": version: 1.1.15 resolution: "which-typed-array@npm:1.1.15" dependencies: @@ -29779,22 +29445,7 @@ __metadata: languageName: node linkType: hard -"ws@npm:^8.13.0, ws@npm:^8.2.3": - version: 8.16.0 - resolution: "ws@npm:8.16.0" - peerDependencies: - bufferutil: ^4.0.1 - utf-8-validate: ">=5.0.2" - peerDependenciesMeta: - bufferutil: - optional: true - utf-8-validate: - optional: true - checksum: 10c0/a7783bb421c648b1e622b423409cb2a58ac5839521d2f689e84bc9dc41d59379c692dd405b15a997ea1d4c0c2e5314ad707332d0c558f15232d2bc07c0b4618a - languageName: node - linkType: hard - -"ws@npm:^8.18.0": +"ws@npm:^8.13.0, ws@npm:^8.18.0, ws@npm:^8.2.3": version: 8.18.0 resolution: "ws@npm:8.18.0" peerDependencies: From 6c3a0bb1eee028f7a5fccc86194ac333a36f0280 Mon Sep 17 00:00:00 2001 From: Jeppe Reinhold Date: Mon, 7 Oct 2024 21:58:32 +0200 Subject: [PATCH 40/41] fix formatting --- code/core/src/common/js-package-manager/JsPackageManager.ts | 2 +- .../src/preview-api/modules/store/csf/portable-stories.ts | 2 +- code/e2e-tests/util.ts | 2 +- code/frameworks/angular/src/server/angular-cli-webpack.js | 2 +- code/frameworks/vue3-vite/src/preset.ts | 2 +- .../cli-storybook/src/automigrate/helpers/mainConfigFile.ts | 4 +++- .../src/automigrate/helpers/new-frameworks-utils.ts | 4 ++-- code/lib/cli-storybook/src/automigrate/index.ts | 2 +- code/lib/codemod/src/transforms/__tests__/mdx-to-csf.test.ts | 2 +- code/renderers/vue3/src/docs/extractArgTypes.ts | 2 +- 10 files changed, 13 insertions(+), 11 deletions(-) diff --git a/code/core/src/common/js-package-manager/JsPackageManager.ts b/code/core/src/common/js-package-manager/JsPackageManager.ts index cf42d73d2a22..21f870852d4d 100644 --- a/code/core/src/common/js-package-manager/JsPackageManager.ts +++ b/code/core/src/common/js-package-manager/JsPackageManager.ts @@ -60,7 +60,7 @@ export abstract class JsPackageManager { /** Get the INSTALLED version of a package from the package.json file */ async getPackageVersion(packageName: string, basePath = this.cwd): Promise { const packageJSON = await this.getPackageJSON(packageName, basePath); - return packageJSON ? packageJSON.version ?? null : null; + return packageJSON ? (packageJSON.version ?? null) : null; } constructor(options?: JsPackageManagerOptions) { diff --git a/code/core/src/preview-api/modules/store/csf/portable-stories.ts b/code/core/src/preview-api/modules/store/csf/portable-stories.ts index fd50bd57c2dd..2ae9143a1a5d 100644 --- a/code/core/src/preview-api/modules/store/csf/portable-stories.ts +++ b/code/core/src/preview-api/modules/store/csf/portable-stories.ts @@ -126,7 +126,7 @@ export function composeStory 0 ? defaultConfig - : globalThis.defaultProjectAnnotations ?? {}, + : (globalThis.defaultProjectAnnotations ?? {}), globalThis.globalProjectAnnotations ?? {}, projectAnnotations ?? {}, ]) diff --git a/code/e2e-tests/util.ts b/code/e2e-tests/util.ts index 00122ef595d2..2137386c6675 100644 --- a/code/e2e-tests/util.ts +++ b/code/e2e-tests/util.ts @@ -49,7 +49,7 @@ export class SbPage { await this.page.waitForURL((url) => url.search.includes( - `path=/${viewMode ?? name === 'docs' ? 'docs' : 'story'}/${titleId}--${storyId}` + `path=/${(viewMode ?? name === 'docs') ? 'docs' : 'story'}/${titleId}--${storyId}` ) ); diff --git a/code/frameworks/angular/src/server/angular-cli-webpack.js b/code/frameworks/angular/src/server/angular-cli-webpack.js index 92ed6225d19f..6be86712e5bc 100644 --- a/code/frameworks/angular/src/server/angular-cli-webpack.js +++ b/code/frameworks/angular/src/server/angular-cli-webpack.js @@ -68,7 +68,7 @@ exports.getWebpackConfig = async (baseConfig, { builderOptions, builderContext } outputPath: typeof builderOptions.outputPath === 'string' ? builderOptions.outputPath - : builderOptions.outputPath?.base ?? 'noop-out', + : (builderOptions.outputPath?.base ?? 'noop-out'), // Fixed options optimization: false, diff --git a/code/frameworks/vue3-vite/src/preset.ts b/code/frameworks/vue3-vite/src/preset.ts index 574ab0a04ad3..8bbaf394d442 100644 --- a/code/frameworks/vue3-vite/src/preset.ts +++ b/code/frameworks/vue3-vite/src/preset.ts @@ -22,7 +22,7 @@ export const viteFinal: StorybookConfig['viteFinal'] = async (config, options) = const framework = await options.presets.apply('framework'); const frameworkOptions: FrameworkOptions = - typeof framework === 'string' ? {} : framework.options ?? {}; + typeof framework === 'string' ? {} : (framework.options ?? {}); const docgen = resolveDocgenOptions(frameworkOptions.docgen); diff --git a/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts b/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts index 492a91e5ff7d..57aa4bf7ce07 100644 --- a/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts +++ b/code/lib/cli-storybook/src/automigrate/helpers/mainConfigFile.ts @@ -94,7 +94,9 @@ export const getBuilderPackageName = (mainConfig?: StorybookConfigRaw) => { export const getFrameworkOptions = ( mainConfig?: StorybookConfigRaw ): Record | null => { - return typeof mainConfig?.framework === 'string' ? null : mainConfig?.framework?.options ?? null; + return typeof mainConfig?.framework === 'string' + ? null + : (mainConfig?.framework?.options ?? null); }; /** diff --git a/code/lib/cli-storybook/src/automigrate/helpers/new-frameworks-utils.ts b/code/lib/cli-storybook/src/automigrate/helpers/new-frameworks-utils.ts index a4ab6ee34a4f..280bb2cf5034 100644 --- a/code/lib/cli-storybook/src/automigrate/helpers/new-frameworks-utils.ts +++ b/code/lib/cli-storybook/src/automigrate/helpers/new-frameworks-utils.ts @@ -77,14 +77,14 @@ export const detectBuilderInfo = async ({ const builderPackageName = getBuilderPackageName(mainConfig); const frameworkPackageName = getFrameworkPackageName(mainConfig) as string; - let builderOptions = typeof builder !== 'string' ? builder?.options ?? {} : {}; + let builderOptions = typeof builder !== 'string' ? (builder?.options ?? {}) : {}; if (builderPackageName) { builderOrFrameworkName = builderPackageName; } else if (framework) { if (Object.keys(frameworkPackages).includes(frameworkPackageName)) { builderOrFrameworkName = frameworkPackageName; - builderOptions = typeof framework === 'object' ? framework.options?.builder ?? {} : {}; + builderOptions = typeof framework === 'object' ? (framework.options?.builder ?? {}) : {}; } } diff --git a/code/lib/cli-storybook/src/automigrate/index.ts b/code/lib/cli-storybook/src/automigrate/index.ts index 5b76b917b547..9d98d97d7013 100644 --- a/code/lib/cli-storybook/src/automigrate/index.ts +++ b/code/lib/cli-storybook/src/automigrate/index.ts @@ -275,7 +275,7 @@ export async function runFixes({ if (result) { const promptType: Prompt = - typeof f.promptType === 'function' ? await f.promptType(result) : f.promptType ?? 'auto'; + typeof f.promptType === 'function' ? await f.promptType(result) : (f.promptType ?? 'auto'); logger.info(`\nšŸ”Ž found a '${picocolors.cyan(f.id)}' migration:`); const message = f.prompt(result); diff --git a/code/lib/codemod/src/transforms/__tests__/mdx-to-csf.test.ts b/code/lib/codemod/src/transforms/__tests__/mdx-to-csf.test.ts index 304fb0c40b05..6d41995d3e82 100644 --- a/code/lib/codemod/src/transforms/__tests__/mdx-to-csf.test.ts +++ b/code/lib/codemod/src/transforms/__tests__/mdx-to-csf.test.ts @@ -7,7 +7,7 @@ import { dedent } from 'ts-dedent'; import jscodeshift, { nameToValidExport } from '../mdx-to-csf'; expect.addSnapshotSerializer({ - print: (val: any) => (typeof val === 'string' ? val : JSON.stringify(val, null, 2) ?? ''), + print: (val: any) => (typeof val === 'string' ? val : (JSON.stringify(val, null, 2) ?? '')), test: () => true, }); diff --git a/code/renderers/vue3/src/docs/extractArgTypes.ts b/code/renderers/vue3/src/docs/extractArgTypes.ts index 7e76c731177f..f52f21c15255 100644 --- a/code/renderers/vue3/src/docs/extractArgTypes.ts +++ b/code/renderers/vue3/src/docs/extractArgTypes.ts @@ -129,7 +129,7 @@ export const extractFromVueDocgenApi = ( } } - const required = 'required' in docgenInfo ? docgenInfo.required ?? false : false; + const required = 'required' in docgenInfo ? (docgenInfo.required ?? false) : false; return { name: docgenInfo.name, From 6e32f1c2c16dd2c4eff110ca50ebbc150d5d7cfc Mon Sep 17 00:00:00 2001 From: storybook-bot <32066757+storybook-bot@users.noreply.github.com> Date: Tue, 8 Oct 2024 13:16:53 +0000 Subject: [PATCH 41/41] Write changelog for 8.4.0-alpha.5 [skip ci] --- CHANGELOG.prerelease.md | 5 +++++ code/package.json | 3 ++- docs/versions/next.json | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.prerelease.md b/CHANGELOG.prerelease.md index 40c0aa95376f..8c9a74c850e4 100644 --- a/CHANGELOG.prerelease.md +++ b/CHANGELOG.prerelease.md @@ -1,3 +1,8 @@ +## 8.4.0-alpha.5 + +- Core: Migrate from `express` to `polka` - [#29230](https://github.com/storybookjs/storybook/pull/29230), thanks @43081j! +- Core: Remove dependence on `file-system-cache` - [#29256](https://github.com/storybookjs/storybook/pull/29256), thanks @ndelangen! + ## 8.4.0-alpha.4 - Blocks: Prebundle `es-toolkit` - [#29259](https://github.com/storybookjs/storybook/pull/29259), thanks @JReinhold! diff --git a/code/package.json b/code/package.json index a109bbb40d02..e441ef956340 100644 --- a/code/package.json +++ b/code/package.json @@ -293,5 +293,6 @@ "Dependency Upgrades" ] ] - } + }, + "deferredNextVersion": "8.4.0-alpha.5" } diff --git a/docs/versions/next.json b/docs/versions/next.json index ab225ca861a5..d74fdfbac9b2 100644 --- a/docs/versions/next.json +++ b/docs/versions/next.json @@ -1 +1 @@ -{"version":"8.4.0-alpha.4","info":{"plain":"- Blocks: Prebundle `es-toolkit` - [#29259](https://github.com/storybookjs/storybook/pull/29259), thanks @JReinhold!\n- CLI: Update the React Native init to include v8 dependencies - [#29273](https://github.com/storybookjs/storybook/pull/29273), thanks @dannyhw!\n- Core: Upgrade `esbuild`, broadening version range - [#29254](https://github.com/storybookjs/storybook/pull/29254), thanks @ndelangen!\n- Vitest plugin: Fix renamed export stories - [#29250](https://github.com/storybookjs/storybook/pull/29250), thanks @shilman!"}} +{"version":"8.4.0-alpha.5","info":{"plain":"- Core: Migrate from `express` to `polka` - [#29230](https://github.com/storybookjs/storybook/pull/29230), thanks @43081j!\n- Core: Remove dependence on `file-system-cache` - [#29256](https://github.com/storybookjs/storybook/pull/29256), thanks @ndelangen!"}}