Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FC, PropsWithChildren, createContext, useContext } from 'react';
import { createElement, FC, PropsWithChildren, createContext, useContext } from 'react';

import { layers } from './layers.css';
import { vars } from './theme.css';
Expand All @@ -10,9 +10,9 @@ const uiTheme = {

const Context = createContext(uiTheme);

export const UiTheme: FC<PropsWithChildren> = ({ children }) => (
<Context.Provider value={uiTheme}>{children}</Context.Provider>
);
export const UiTheme: FC<PropsWithChildren> = ({ children }) => {
return createElement(Context.Provider, { value: uiTheme }, children);
};

if (import.meta.env.DEV) {
UiTheme.displayName = 'ui-theme(UiTheme)';
Expand Down
5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
"eslint": "^10.0.0",
"typescript": "^6.0.0"
}
},
"patchedDependencies": {
"@tabula/forge": "patches/@tabula__forge.patch"
}
},
"engines": {
Expand Down Expand Up @@ -74,8 +77,8 @@
"@vanilla-extract/dynamic": "catalog:",
"@vanilla-extract/vite-plugin": "^5.2.2",
"change-case": "^5.4.4",
"eslint": "^10.2.1",
"esbuild": "^0.28.0",
"eslint": "^10.2.1",
"execa": "^9.6.1",
"handlebars": "^4.7.9",
"happy-dom": "catalog:",
Expand Down
28 changes: 28 additions & 0 deletions patches/@tabula__forge.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/lib/index.js b/lib/index.js
index ebed270fae36eddde3d18d4960935659ce21d0de..200fe40c5c462ec34d20dea706109562bd165b83 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -174,8 +174,21 @@ function renderDocs(docs) {
return docs.map((doc) => {
const { expression, ...storybook2 } = doc;
const instance = expression?.getName() ?? doc.displayName;
- return `${instance}.__docgenInfo = ${JSON.stringify(storybook2, null, 2)};`;
- }).join("\n");
+ const cache = new Set();
+ const safeStringify = JSON.stringify(storybook2, (key, value) => {
+ if (typeof value === "object" && value !== null) {
+ if (cache.has(value)) {
+ return "[Circular]";
+ }
+ if (value.constructor && (value.constructor.name === "SourceFileObject" || value.constructor.name === "NodeObject")) {
+ return "[TSNode]";
+ }
+ cache.add(value);
+ }
+ return value;
+ }, 2);
+ return `${instance}.__docgenInfo = ${safeStringify};`;
+ }).join("\\n");
}

// src/plugins/reactDocgenPlugin/reactDocgenPlugin.ts
9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions test-json.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const stringify = (obj) => {
const cache = new Set();
return JSON.stringify(obj, (key, value) => {
if (typeof value === 'object' && value !== null) {
if (cache.has(value)) {
return '[Circular]';
}
cache.add(value);
}
return value;
}, 2);
};
Loading