@structuralists/scaffolding 0.1.0 → 0.1.2

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,13 +1,44 @@
1
1
  import type { Preview } from '@storybook/react-vite';
2
2
  import { MemoryRouter } from 'react-router';
3
+ import * as prettier from 'prettier/standalone';
4
+ import * as babel from 'prettier/plugins/babel';
5
+ import * as estree from 'prettier/plugins/estree';
3
6
  import '../tokens.css';
4
7
 
8
+ // Storybook's useTransformCode re-invokes transform on every render with no
9
+ // dep array; memoizing by input lets cache hits return a string synchronously
10
+ // and skip the "Transforming..." placeholder that causes the flicker.
11
+ const formatCache = new Map<string, string>();
12
+
5
13
  const preview: Preview = {
6
14
  parameters: {
7
15
  layout: 'padded',
8
16
 
9
17
  docs: {
10
- codePanel: true
18
+ codePanel: true,
19
+ source: {
20
+ type: 'dynamic',
21
+ transform: (code: string) => {
22
+ const cached = formatCache.get(code);
23
+ if (cached !== undefined) return cached;
24
+
25
+ return prettier
26
+ .format(code, {
27
+ parser: 'babel',
28
+ plugins: [babel, estree],
29
+ printWidth: 80,
30
+ singleQuote: true,
31
+ })
32
+ .then((formatted) => {
33
+ formatCache.set(code, formatted);
34
+ return formatted;
35
+ })
36
+ .catch(() => {
37
+ formatCache.set(code, code);
38
+ return code;
39
+ });
40
+ },
41
+ },
11
42
  }
12
43
  },
13
44
  decorators: [
package/bun.lock CHANGED
@@ -23,6 +23,7 @@
23
23
  "eslint": "^10.3.0",
24
24
  "eslint-plugin-boundaries": "^6.0.2",
25
25
  "eslint-plugin-storybook": "10.3.6",
26
+ "prettier": "^3.8.3",
26
27
  "react-router": "^7.14.2",
27
28
  "storybook": "^10.3.6",
28
29
  "typescript": "^6.0.3",
@@ -755,6 +756,8 @@
755
756
 
756
757
  "prelude-ls": ["prelude-ls@1.2.1", "", {}, "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g=="],
757
758
 
759
+ "prettier": ["prettier@3.8.3", "", { "bin": { "prettier": "bin/prettier.cjs" } }, "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw=="],
760
+
758
761
  "pretty-format": ["pretty-format@27.5.1", "", { "dependencies": { "ansi-regex": "^5.0.1", "ansi-styles": "^5.0.0", "react-is": "^17.0.1" } }, "sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ=="],
759
762
 
760
763
  "property-information": ["property-information@7.1.0", "", {}, "sha512-TwEZ+X+yCJmYfL7TPUOcvBZ4QfoT5YenQiJuX//0th53DE6w0xxLEtfK3iyryQFddXuvkIk51EEgrJQ0WJkOmQ=="],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@structuralists/scaffolding",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "./index.ts",
5
5
  "types": "./index.ts",
6
6
  "exports": {
@@ -42,6 +42,7 @@
42
42
  "eslint": "^10.3.0",
43
43
  "eslint-plugin-boundaries": "^6.0.2",
44
44
  "eslint-plugin-storybook": "10.3.6",
45
+ "prettier": "^3.8.3",
45
46
  "react-router": "^7.14.2",
46
47
  "storybook": "^10.3.6",
47
48
  "typescript": "^6.0.3",