react-cosmos 7.2.0 → 7.2.1-canary.3822d76.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,3 @@
1
- import { sortBy } from 'lodash-es';
2
1
  import fs from 'node:fs/promises';
3
2
  import path from 'node:path';
4
3
  import { createRendererUrl, pickRendererUrl, removeFixtureNameExtension, removeFixtureNameSuffix, } from 'react-cosmos-core';
@@ -38,7 +37,11 @@ async function createFixtureItems(config, mode) {
38
37
  });
39
38
  return {
40
39
  rendererUrl,
41
- fixtures: sortBy(fixtures, f => f.cleanPath.join('-')),
40
+ fixtures: [...fixtures].sort((a, b) => {
41
+ const ak = a.cleanPath.join('-');
42
+ const bk = b.cleanPath.join('-');
43
+ return ak < bk ? -1 : ak > bk ? 1 : 0;
44
+ }),
42
45
  };
43
46
  }
44
47
  function cleanFixturePath(filePath, fixturesDir, fixtureSuffix) {
@@ -1,5 +1,5 @@
1
- import { fixtureWatcherPlugin } from './fixtureWatcherPlugin.js';
2
1
  import { fixturesJsonPlugin } from './fixturesJsonPlugin.js';
2
+ import { fixtureWatcherPlugin } from './fixtureWatcherPlugin.js';
3
3
  import { httpProxyPlugin } from './httpProxyPlugin.js';
4
4
  import { openFilePlugin } from './openFilePlugin.js';
5
5
  import { pluginEndpointPlugin } from './pluginEndpointPlugin.js';
@@ -1,7 +1,7 @@
1
- import launchEditor from '@skidding/launch-editor';
2
1
  import fs from 'fs';
3
- import open from 'open';
4
2
  import path from 'path';
3
+ import launchEditor from '@skidding/launch-editor';
4
+ import open from 'open';
5
5
  export const openFilePlugin = {
6
6
  name: 'openFile',
7
7
  devServer({ config, app }) {
@@ -25,7 +25,7 @@ export const openFilePlugin = {
25
25
  // Fall back to open in case launchEditor fails. launchEditor only works
26
26
  // when the editor app is already open, but is favorable because it can
27
27
  // open a code file on a specific line & column.
28
- .catch(err => open(absFilePath))
28
+ .catch(() => open(absFilePath))
29
29
  .catch(err => {
30
30
  console.log(err);
31
31
  res.status(500).send('Failed to open file');
@@ -1,5 +1,5 @@
1
- import { Express } from 'express';
2
1
  import http from 'http';
2
+ import { Express } from 'express';
3
3
  import { CosmosMode, MessageType } from 'react-cosmos-core';
4
4
  import { CosmosConfig } from '../cosmosConfig/types.js';
5
5
  export type CosmosPlatform = 'web' | 'native';
@@ -1,6 +1,5 @@
1
- import { mapValues } from 'lodash-es';
2
1
  import path from 'path';
3
- import { buildPlaygroundQueryString, createFixtureTree, createRendererUrl, flattenFixtureTree, getFixtureFromExport, getFixtureListFromExports, getSortedDecoratorsForFixturePath, } from 'react-cosmos-core';
2
+ import { buildPlaygroundQueryString, createFixtureTree, createRendererUrl, flattenFixtureTree, getFixtureFromExport, mapValues, getFixtureListFromExports, getSortedDecoratorsForFixturePath, } from 'react-cosmos-core';
4
3
  import { createFixtureNode, decorateFixture } from 'react-cosmos-renderer';
5
4
  import { getPlaygroundUrls } from '../shared/playgroundUrl.js';
6
5
  import { importUserModules } from './importUserModules.js';
@@ -1,5 +1,5 @@
1
- import express from 'express';
2
1
  import path from 'path';
2
+ import express from 'express';
3
3
  export function serveStaticDir(app, staticPath, publicUrl) {
4
4
  const relStaticPath = path.relative(process.cwd(), staticPath);
5
5
  console.log(`[Cosmos] Serving static files from ${relStaticPath}`);
@@ -1,4 +1,4 @@
1
- <!DOCTYPE html>
1
+ <!doctype html>
2
2
  <html>
3
3
  <head>
4
4
  <meta charset="utf-8" />
@@ -14,9 +14,6 @@ export async function mockConsole(cb) {
14
14
  expectedLogs.forEach(msg => expect(console.log).toBeCalledWith(msg));
15
15
  return cbReturn;
16
16
  }
17
- catch (err) {
18
- throw err;
19
- }
20
17
  finally {
21
18
  console.log = origConsoleLog;
22
19
  }
@@ -1 +1 @@
1
- {"root":["../src/client.ts","../src/index.ts","../src/vitest.ts","../src/@types/launch-editor.d.ts","../src/@types/mdx.d.ts","../src/@types/yargs.d.ts","../src/coreplugins/fixturewatcherplugin.ts","../src/coreplugins/fixturesjsonplugin.ts","../src/coreplugins/httpproxyplugin.ts","../src/coreplugins/index.ts","../src/coreplugins/openfileplugin.ts","../src/coreplugins/pluginendpointplugin.ts","../src/coreplugins/portretryplugin.ts","../src/coreplugins/remoterendererurlplugin.ts","../src/cosmosconfig/createcosmosconfig.ts","../src/cosmosconfig/detectcosmosconfig.ts","../src/cosmosconfig/getcosmosconfigatpath.ts","../src/cosmosconfig/shared.ts","../src/cosmosconfig/types.ts","../src/cosmosplugin/findcosmospluginconfigs.ts","../src/cosmosplugin/pluginconfigs.ts","../src/cosmosplugin/readcosmospluginconfig.ts","../src/cosmosplugin/types.ts","../src/devserver/expressapp.ts","../src/devserver/httpserver.ts","../src/devserver/httpscreds.ts","../src/devserver/messagehandler.ts","../src/devserver/startdevserver.ts","../src/export/generateexport.ts","../src/getfixtures/getfixtures.ts","../src/getfixtures/importusermodules.ts","../src/shared/applyserverconfigplugins.ts","../src/shared/findnextavailableport.ts","../src/shared/getserverplugins.ts","../src/shared/importserverplugins.ts","../src/shared/logplugininfo.ts","../src/shared/playgroundhtml.ts","../src/shared/playgroundurl.ts","../src/shared/remoterendererurl.ts","../src/shared/serveraddress.ts","../src/shared/serverfixturelist.ts","../src/shared/staticpath.ts","../src/shared/staticserver.ts","../src/shared/websocketurl.ts","../src/usermodules/findusermodulepaths.ts","../src/usermodules/fixturewatcher.ts","../src/usermodules/generateuserimports.ts","../src/usermodules/shared.ts","../src/usermodules/userimportslazytemplate.ts","../src/usermodules/userimportstemplate.ts","../src/utils/cli.ts","../src/utils/findup.ts","../src/utils/fs.ts","../src/utils/isnodeerror.ts","../src/utils/json.ts","../src/utils/requiremodule.ts","../src/utils/resolve.ts","../src/utils/resolveloose.ts","../src/utils/resolvesilent.ts","../src/utils/slash.ts"],"version":"5.9.3"}
1
+ {"root":["../src/client.ts","../src/index.ts","../src/vitest.ts","../src/@types/launch-editor.d.ts","../src/@types/mdx.d.ts","../src/@types/yargs.d.ts","../src/corePlugins/fixtureWatcherPlugin.ts","../src/corePlugins/fixturesJsonPlugin.ts","../src/corePlugins/httpProxyPlugin.ts","../src/corePlugins/index.ts","../src/corePlugins/openFilePlugin.ts","../src/corePlugins/pluginEndpointPlugin.ts","../src/corePlugins/portRetryPlugin.ts","../src/corePlugins/remoteRendererUrlPlugin.ts","../src/cosmosConfig/createCosmosConfig.ts","../src/cosmosConfig/detectCosmosConfig.ts","../src/cosmosConfig/getCosmosConfigAtPath.ts","../src/cosmosConfig/shared.ts","../src/cosmosConfig/types.ts","../src/cosmosPlugin/findCosmosPluginConfigs.ts","../src/cosmosPlugin/pluginConfigs.ts","../src/cosmosPlugin/readCosmosPluginConfig.ts","../src/cosmosPlugin/types.ts","../src/devServer/expressApp.ts","../src/devServer/httpServer.ts","../src/devServer/httpsCreds.ts","../src/devServer/messageHandler.ts","../src/devServer/startDevServer.ts","../src/export/generateExport.ts","../src/getFixtures/getFixtures.ts","../src/getFixtures/importUserModules.ts","../src/shared/applyServerConfigPlugins.ts","../src/shared/findNextAvailablePort.ts","../src/shared/getServerPlugins.ts","../src/shared/importServerPlugins.ts","../src/shared/logPluginInfo.ts","../src/shared/playgroundHtml.ts","../src/shared/playgroundUrl.ts","../src/shared/remoteRendererUrl.ts","../src/shared/serverAddress.ts","../src/shared/serverFixtureList.ts","../src/shared/staticPath.ts","../src/shared/staticServer.ts","../src/shared/webSocketUrl.ts","../src/userModules/findUserModulePaths.ts","../src/userModules/fixtureWatcher.ts","../src/userModules/generateUserImports.ts","../src/userModules/shared.ts","../src/userModules/userImportsLazyTemplate.ts","../src/userModules/userImportsTemplate.ts","../src/utils/cli.ts","../src/utils/findUp.ts","../src/utils/fs.ts","../src/utils/isNodeError.ts","../src/utils/json.ts","../src/utils/requireModule.ts","../src/utils/resolve.ts","../src/utils/resolveLoose.ts","../src/utils/resolveSilent.ts","../src/utils/slash.ts"],"version":"5.9.3"}
@@ -1,5 +1,4 @@
1
1
  import { watch } from 'chokidar';
2
- import { debounce } from 'lodash-es';
3
2
  import { getDecoratorPatterns, getFixturePatterns } from './shared.js';
4
3
  const DEBOUNCE_INTERVAL = 50;
5
4
  export async function startFixtureWatcher(config, event, callback) {
@@ -18,3 +17,10 @@ export async function startFixtureWatcher(config, event, callback) {
18
17
  .on(event, debounce(() => callback(), DEBOUNCE_INTERVAL));
19
18
  });
20
19
  }
20
+ function debounce(fn, delay) {
21
+ let timer;
22
+ return ((...args) => {
23
+ clearTimeout(timer);
24
+ timer = setTimeout(() => fn(...args), delay);
25
+ });
26
+ }
@@ -1,4 +1,3 @@
1
- import { flatten } from 'lodash-es';
2
1
  import { createImportMap, importPath, sortedImportKeys, } from './shared.js';
3
2
  export function userImportsLazyTemplate({ globalImports, modulePaths: { fixturePaths, decoratorPaths }, rendererConfig, rootDir, relativeToDir, typeScript, }) {
4
3
  function ext(filePath) {
@@ -41,7 +40,7 @@ export const moduleWrappers${ts(': UserModuleWrappers')} = {
41
40
  `.trimStart();
42
41
  }
43
42
  function importsStr(items) {
44
- if (flatten(items).length === 0) {
43
+ if (items.flat().length === 0) {
45
44
  return '';
46
45
  }
47
46
  const str = items
@@ -1,4 +1,3 @@
1
- import { flatten } from 'lodash-es';
2
1
  import { createImportMap, importPath, sortedImportKeys, } from './shared.js';
3
2
  export function userImportsTemplate({ globalImports, modulePaths: { fixturePaths, decoratorPaths }, rendererConfig, rootDir, relativeToDir, typeScript, }) {
4
3
  function ext(filePath) {
@@ -43,7 +42,7 @@ export const moduleWrappers${ts(': UserModuleWrappers')} = {
43
42
  `.trimStart();
44
43
  }
45
44
  function importsStr(items) {
46
- if (flatten(items).length === 0) {
45
+ if (items.flat().length === 0) {
47
46
  return '';
48
47
  }
49
48
  const str = items
package/dist/utils/fs.js CHANGED
@@ -16,7 +16,7 @@ export function moduleExists(moduleId) {
16
16
  resolve(moduleId);
17
17
  return true;
18
18
  }
19
- catch (err) {
19
+ catch {
20
20
  return false;
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,24 +1,23 @@
1
1
  {
2
2
  "name": "react-cosmos",
3
- "version": "7.2.0",
3
+ "version": "7.2.1-canary.3822d76.0+3822d76",
4
4
  "description": "Sandbox for developing and testing UI components in isolation",
5
5
  "repository": "https://github.com/react-cosmos/react-cosmos/tree/main/packages/react-cosmos",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "./index.js",
9
9
  "dependencies": {
10
- "@skidding/launch-editor": "2.2.3",
10
+ "@skidding/launch-editor": "2.13.2",
11
11
  "chokidar": "3.6.0",
12
12
  "express": "4.22.1",
13
13
  "glob": "10.5.0",
14
14
  "http-proxy-middleware": "3.0.5",
15
- "lodash-es": "4.17.23",
16
15
  "micromatch": "4.0.8",
17
16
  "open": "10.2.0",
18
17
  "pem": "1.15.1",
19
- "react-cosmos-core": "^7.2.0",
20
- "react-cosmos-renderer": "^7.2.0",
21
- "react-cosmos-ui": "^7.2.0",
18
+ "react-cosmos-core": "7.2.1-canary.3822d76.0+3822d76",
19
+ "react-cosmos-renderer": "7.2.1-canary.3822d76.0+3822d76",
20
+ "react-cosmos-ui": "7.2.1-canary.3822d76.0+3822d76",
22
21
  "ws": "8.19.0",
23
22
  "yargs": "17.7.2"
24
23
  },
@@ -31,5 +30,5 @@
31
30
  "cosmos-export": "./bin/cosmos-export.js",
32
31
  "cosmos-native": "./bin/cosmos-native.js"
33
32
  },
34
- "gitHead": "c1f63d79b3235011fb9f1a919378b95a59fff02e"
33
+ "gitHead": "3822d7614f71ce82c282b1516ad18552042ff71a"
35
34
  }