@seedgrid/fe-components 2026.3.2-6 → 2026.3.2-8
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.
|
@@ -16,11 +16,21 @@ export type SgPlaygroundProps = {
|
|
|
16
16
|
defaultImports?: string;
|
|
17
17
|
previewWrapperClassName?: string;
|
|
18
18
|
seedgridDependency?: string;
|
|
19
|
+
bundlerURL?: string;
|
|
20
|
+
bundlerTimeoutMs?: number;
|
|
21
|
+
npmRegistries?: SgPlaygroundNpmRegistry[];
|
|
19
22
|
withCard?: boolean;
|
|
20
23
|
collapsible?: boolean;
|
|
21
24
|
defaultOpen?: boolean;
|
|
22
25
|
cardId?: string;
|
|
23
26
|
};
|
|
24
27
|
export type SgPlaygroundPreset = "auto" | "basic" | "seedgrid" | "editor" | "full";
|
|
28
|
+
export type SgPlaygroundNpmRegistry = {
|
|
29
|
+
enabledScopes: string[];
|
|
30
|
+
limitToScopes: boolean;
|
|
31
|
+
registryUrl: string;
|
|
32
|
+
proxyEnabled: boolean;
|
|
33
|
+
registryAuthToken?: string;
|
|
34
|
+
};
|
|
25
35
|
export default function SgPlayground(props: Readonly<SgPlaygroundProps>): import("react/jsx-runtime").JSX.Element;
|
|
26
36
|
//# sourceMappingURL=SgPlayground.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"AAsBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,UAAU,GAAG,YAAY,GAAG,MAAM,CAAC;IAChD,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE,uBAAuB,EAAE,CAAC;IAC1C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;AACnF,MAAM,MAAM,uBAAuB,GAAG;IACpC,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,OAAO,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,OAAO,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAmuBF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CA8XtE"}
|
|
@@ -4,10 +4,17 @@ import * as React from "react";
|
|
|
4
4
|
import { SandpackCodeEditor, SandpackPreview, SandpackProvider, useSandpack } from "@codesandbox/sandpack-react";
|
|
5
5
|
import { SgButton } from "../buttons/SgButton";
|
|
6
6
|
import { SgCard } from "../layout/SgCard";
|
|
7
|
+
import blockedEmailDomainsConfig from "../blocked-email-domains.json";
|
|
8
|
+
import componentsMessagesEnUsJson from "../i18n/en-US.json";
|
|
9
|
+
import componentsMessagesEsJson from "../i18n/es.json";
|
|
10
|
+
import componentsMessagesPtBrJson from "../i18n/pt-BR.json";
|
|
11
|
+
import componentsMessagesPtPtJson from "../i18n/pt-PT.json";
|
|
7
12
|
function cn(...parts) {
|
|
8
13
|
return parts.filter(Boolean).join(" ");
|
|
9
14
|
}
|
|
10
15
|
const DEFAULT_SEEDGRID_DEPENDENCY = "latest";
|
|
16
|
+
const DEFAULT_SANDPACK_BUNDLER_URL = "https://sandpack.seedgrid.com.br";
|
|
17
|
+
const DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS = 60000;
|
|
11
18
|
const DEFAULT_SANDBOX_BASE_DEPENDENCIES = {
|
|
12
19
|
react: "18.2.0",
|
|
13
20
|
"react-dom": "18.2.0"
|
|
@@ -59,16 +66,6 @@ const SANDPACK_EXTERNAL_RESOURCES = [
|
|
|
59
66
|
// Prebuilt utility CSS so classes from @seedgrid/fe-components can render inside Sandpack
|
|
60
67
|
"https://unpkg.com/tailwindcss@2.2.19/dist/tailwind.min.css"
|
|
61
68
|
];
|
|
62
|
-
const SANDPACK_QRCODE_SHIM_PACKAGE_JSON = `{
|
|
63
|
-
"name": "qrcode",
|
|
64
|
-
"version": "0.0.0-sandpack-shim",
|
|
65
|
-
"type": "module",
|
|
66
|
-
"main": "./index.js",
|
|
67
|
-
"module": "./index.js",
|
|
68
|
-
"exports": {
|
|
69
|
-
".": "./index.js"
|
|
70
|
-
}
|
|
71
|
-
}`;
|
|
72
69
|
const SANDPACK_QRCODE_SHIM_INDEX_JS = `const makeError = () =>
|
|
73
70
|
new Error(
|
|
74
71
|
"qrcode (node build) is not supported in Sandpack browser runtime. Update @seedgrid/fe-components to a browser-safe QR implementation."
|
|
@@ -90,18 +87,6 @@ const SANDPACK_MARKDOWN_IT_BIN_SHIM = `import markdownit from "../index.mjs";
|
|
|
90
87
|
export default markdownit;
|
|
91
88
|
export { markdownit };
|
|
92
89
|
`;
|
|
93
|
-
function createEsmShimPackageJson(name) {
|
|
94
|
-
return `{
|
|
95
|
-
"name": "${name}",
|
|
96
|
-
"version": "0.0.0-sandpack-shim",
|
|
97
|
-
"type": "module",
|
|
98
|
-
"main": "./index.js",
|
|
99
|
-
"module": "./index.js",
|
|
100
|
-
"exports": {
|
|
101
|
-
".": "./index.js"
|
|
102
|
-
}
|
|
103
|
-
}`;
|
|
104
|
-
}
|
|
105
90
|
const SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS = `export const SandpackProvider = ({ children }) => children ?? null;
|
|
106
91
|
export const SandpackCodeEditor = () => null;
|
|
107
92
|
export const SandpackPreview = () => null;
|
|
@@ -134,11 +119,27 @@ const SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS = `const extension = {
|
|
|
134
119
|
};
|
|
135
120
|
export default extension;
|
|
136
121
|
`;
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
122
|
+
const SANDPACK_SEEDGRID_TEXT_EDITOR_SHIM_INDEX_JS = `import * as React from "react";
|
|
123
|
+
|
|
124
|
+
export function SgTextEditor() {
|
|
125
|
+
return React.createElement(
|
|
126
|
+
"div",
|
|
127
|
+
{
|
|
128
|
+
style: {
|
|
129
|
+
padding: "0.75rem",
|
|
130
|
+
border: "1px solid #e4e4e7",
|
|
131
|
+
borderRadius: "0.5rem",
|
|
132
|
+
fontSize: "0.875rem",
|
|
133
|
+
color: "#6b7280",
|
|
134
|
+
background: "#f9fafb"
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
"SgTextEditor is disabled in this sandbox preset."
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default SgTextEditor;
|
|
142
|
+
`;
|
|
142
143
|
const SANDPACK_ASSERT_SHIM_INDEX_JS = `function fail(message) {
|
|
143
144
|
throw new Error(message || "Assertion failed");
|
|
144
145
|
}
|
|
@@ -179,11 +180,6 @@ assert.fail = fail;
|
|
|
179
180
|
module.exports = assert;
|
|
180
181
|
module.exports.default = assert;
|
|
181
182
|
`;
|
|
182
|
-
const SANDPACK_UTIL_SHIM_PACKAGE_JSON = `{
|
|
183
|
-
"name": "util",
|
|
184
|
-
"version": "0.0.0-sandpack-shim",
|
|
185
|
-
"main": "./index.js"
|
|
186
|
-
}`;
|
|
187
183
|
const SANDPACK_UTIL_SHIM_INDEX_JS = `const inspect = function inspect(value) {
|
|
188
184
|
try {
|
|
189
185
|
return JSON.stringify(value);
|
|
@@ -217,11 +213,6 @@ const utilShim = { inspect, deprecate, format };
|
|
|
217
213
|
module.exports = utilShim;
|
|
218
214
|
module.exports.default = utilShim;
|
|
219
215
|
`;
|
|
220
|
-
const SANDPACK_PATH_SHIM_PACKAGE_JSON = `{
|
|
221
|
-
"name": "path",
|
|
222
|
-
"version": "0.0.0-sandpack-shim",
|
|
223
|
-
"main": "./index.js"
|
|
224
|
-
}`;
|
|
225
216
|
const SANDPACK_PATH_SHIM_INDEX_JS = `function normalize(input) {
|
|
226
217
|
return String(input || "").replace(/\\\\/g, "/");
|
|
227
218
|
}
|
|
@@ -264,11 +255,6 @@ const pathShim = {
|
|
|
264
255
|
module.exports = pathShim;
|
|
265
256
|
module.exports.default = pathShim;
|
|
266
257
|
`;
|
|
267
|
-
const SANDPACK_FS_SHIM_PACKAGE_JSON = `{
|
|
268
|
-
"name": "fs",
|
|
269
|
-
"version": "0.0.0-sandpack-shim",
|
|
270
|
-
"main": "./index.js"
|
|
271
|
-
}`;
|
|
272
258
|
const SANDPACK_FS_SHIM_INDEX_JS = `function notSupported(name) {
|
|
273
259
|
throw new Error("fs." + name + " is not supported in Sandpack browser runtime.");
|
|
274
260
|
}
|
|
@@ -283,11 +269,6 @@ const fsShim = {
|
|
|
283
269
|
module.exports = fsShim;
|
|
284
270
|
module.exports.default = fsShim;
|
|
285
271
|
`;
|
|
286
|
-
const SANDPACK_PROCESS_SHIM_PACKAGE_JSON = `{
|
|
287
|
-
"name": "process",
|
|
288
|
-
"version": "0.0.0-sandpack-shim",
|
|
289
|
-
"main": "./index.js"
|
|
290
|
-
}`;
|
|
291
272
|
const SANDPACK_PROCESS_SHIM_INDEX_JS = `const processShim = {
|
|
292
273
|
env: {},
|
|
293
274
|
argv: ["browser"],
|
|
@@ -389,6 +370,70 @@ const SANDPACK_HOST_STYLES_CSS = `
|
|
|
389
370
|
left: auto !important;
|
|
390
371
|
}
|
|
391
372
|
`;
|
|
373
|
+
function normalizeUrl(raw, fallback) {
|
|
374
|
+
const value = raw?.trim();
|
|
375
|
+
if (!value)
|
|
376
|
+
return fallback;
|
|
377
|
+
try {
|
|
378
|
+
const parsed = new URL(value);
|
|
379
|
+
return parsed.toString().replace(/\/+$/, "");
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
return fallback;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
function normalizeTimeoutMs(value, fallback) {
|
|
386
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
387
|
+
return fallback;
|
|
388
|
+
}
|
|
389
|
+
return Math.round(value);
|
|
390
|
+
}
|
|
391
|
+
function parseBooleanFlag(value, fallback) {
|
|
392
|
+
const normalized = value?.trim().toLowerCase();
|
|
393
|
+
if (!normalized)
|
|
394
|
+
return fallback;
|
|
395
|
+
if (normalized === "1" || normalized === "true" || normalized === "yes" || normalized === "on") {
|
|
396
|
+
return true;
|
|
397
|
+
}
|
|
398
|
+
if (normalized === "0" || normalized === "false" || normalized === "no" || normalized === "off") {
|
|
399
|
+
return false;
|
|
400
|
+
}
|
|
401
|
+
return fallback;
|
|
402
|
+
}
|
|
403
|
+
function resolveDefaultNpmRegistriesFromEnv() {
|
|
404
|
+
const registryUrlRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_URL?.trim();
|
|
405
|
+
if (!registryUrlRaw)
|
|
406
|
+
return undefined;
|
|
407
|
+
const scopesRaw = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_SCOPES;
|
|
408
|
+
const enabledScopes = (scopesRaw ?? "@seedgrid")
|
|
409
|
+
.split(",")
|
|
410
|
+
.map((scope) => scope.trim())
|
|
411
|
+
.filter(Boolean);
|
|
412
|
+
const limitToScopes = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_LIMIT_TO_SCOPES, true);
|
|
413
|
+
const proxyEnabled = parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_PROXY_ENABLED, false);
|
|
414
|
+
const registryAuthToken = process.env.NEXT_PUBLIC_SANDPACK_NPM_REGISTRY_AUTH_TOKEN?.trim();
|
|
415
|
+
return [
|
|
416
|
+
{
|
|
417
|
+
enabledScopes,
|
|
418
|
+
limitToScopes,
|
|
419
|
+
registryUrl: registryUrlRaw.replace(/\/+$/, ""),
|
|
420
|
+
proxyEnabled,
|
|
421
|
+
...(registryAuthToken ? { registryAuthToken } : {})
|
|
422
|
+
}
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
function buildCjsJsonModule(value) {
|
|
426
|
+
const serialized = JSON.stringify(value);
|
|
427
|
+
return `const data = ${serialized};
|
|
428
|
+
module.exports = data;
|
|
429
|
+
module.exports.default = data;
|
|
430
|
+
`;
|
|
431
|
+
}
|
|
432
|
+
const SANDPACK_SEEDGRID_PT_BR_JSON_SHIM = buildCjsJsonModule(componentsMessagesPtBrJson);
|
|
433
|
+
const SANDPACK_SEEDGRID_PT_PT_JSON_SHIM = buildCjsJsonModule(componentsMessagesPtPtJson);
|
|
434
|
+
const SANDPACK_SEEDGRID_EN_US_JSON_SHIM = buildCjsJsonModule(componentsMessagesEnUsJson);
|
|
435
|
+
const SANDPACK_SEEDGRID_ES_JSON_SHIM = buildCjsJsonModule(componentsMessagesEsJson);
|
|
436
|
+
const SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM = buildCjsJsonModule(blockedEmailDomainsConfig);
|
|
392
437
|
function parseRgbParts(raw) {
|
|
393
438
|
const value = raw.trim();
|
|
394
439
|
if (!value)
|
|
@@ -627,7 +672,7 @@ function RunButton({ onRun }) {
|
|
|
627
672
|
return (_jsx(SgButton, { severity: "primary", size: "sm", loading: running, onClick: handleRun, children: running ? "Running" : "Run" }));
|
|
628
673
|
}
|
|
629
674
|
export default function SgPlayground(props) {
|
|
630
|
-
const { code, interactive = false, codeContract = "renderBody", preset = "auto", title, description, height = 360, expandedHeight = "70vh", expandable = true, resizable = true, resizeAxis = "vertical", previewPadding, className, dependencies, defaultImports, previewWrapperClassName = "h-[420px] rounded-xl border border-border bg-muted/30 p-3", seedgridDependency, withCard = true, collapsible = true, defaultOpen = true, cardId } = props;
|
|
675
|
+
const { code, interactive = false, codeContract = "renderBody", preset = "auto", title, description, height = 360, expandedHeight = "70vh", expandable = true, resizable = true, resizeAxis = "vertical", previewPadding, className, dependencies, defaultImports, previewWrapperClassName = "h-[420px] rounded-xl border border-border bg-muted/30 p-3", seedgridDependency, bundlerURL, bundlerTimeoutMs, npmRegistries, withCard = true, collapsible = true, defaultOpen = true, cardId } = props;
|
|
631
676
|
const effectivePreviewPadding = normalizeCssSize(previewPadding ?? (codeContract === "appFile" ? 12 : 0));
|
|
632
677
|
const [sandpackStylesCss, setSandpackStylesCss] = React.useState(() => buildSandpackStylesCss({}, effectivePreviewPadding));
|
|
633
678
|
const [isExpanded, setIsExpanded] = React.useState(false);
|
|
@@ -679,6 +724,26 @@ export default function SgPlayground(props) {
|
|
|
679
724
|
DEFAULT_SEEDGRID_DEPENDENCY;
|
|
680
725
|
const requestedDeps = dependencies ?? {};
|
|
681
726
|
const requestedDepKeys = Object.keys(requestedDeps);
|
|
727
|
+
const resolvedBundlerURL = normalizeUrl(bundlerURL ?? process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_URL, DEFAULT_SANDPACK_BUNDLER_URL);
|
|
728
|
+
const resolvedBundlerTimeoutMs = normalizeTimeoutMs(bundlerTimeoutMs ??
|
|
729
|
+
Number(process.env.NEXT_PUBLIC_SANDPACK_BUNDLER_TIMEOUT_MS ?? Number.NaN), DEFAULT_SANDPACK_BUNDLER_TIMEOUT_MS);
|
|
730
|
+
const resolvedNpmRegistries = React.useMemo(() => npmRegistries ?? resolveDefaultNpmRegistriesFromEnv(), [npmRegistries]);
|
|
731
|
+
React.useEffect(() => {
|
|
732
|
+
if (!interactive)
|
|
733
|
+
return;
|
|
734
|
+
if (!parseBooleanFlag(process.env.NEXT_PUBLIC_SANDPACK_DEBUG, false))
|
|
735
|
+
return;
|
|
736
|
+
console.info("[SgPlayground] Sandpack runtime config", {
|
|
737
|
+
bundlerURL: resolvedBundlerURL,
|
|
738
|
+
bundlerTimeoutMs: resolvedBundlerTimeoutMs,
|
|
739
|
+
npmRegistries: (resolvedNpmRegistries ?? []).map((registry) => ({
|
|
740
|
+
enabledScopes: registry.enabledScopes,
|
|
741
|
+
limitToScopes: registry.limitToScopes,
|
|
742
|
+
registryUrl: registry.registryUrl,
|
|
743
|
+
proxyEnabled: registry.proxyEnabled
|
|
744
|
+
}))
|
|
745
|
+
});
|
|
746
|
+
}, [interactive, resolvedBundlerTimeoutMs, resolvedBundlerURL, resolvedNpmRegistries]);
|
|
682
747
|
const codeUsesSeedgrid = /from\s+["']@seedgrid\/fe-components["']/.test(appTsx);
|
|
683
748
|
const codeUsesTextEditor = /\bSgTextEditor\b/.test(appTsx);
|
|
684
749
|
const codeUsesPlaygroundComponent = /\bSgPlayground\b/.test(appTsx);
|
|
@@ -709,8 +774,29 @@ export default function SgPlayground(props) {
|
|
|
709
774
|
};
|
|
710
775
|
if (includeSeedgridDependency) {
|
|
711
776
|
// Compatibility shim for legacy @seedgrid/fe-components builds that still import "qrcode" (node-only path).
|
|
712
|
-
files["/node_modules/qrcode/package.json"] = { code: SANDPACK_QRCODE_SHIM_PACKAGE_JSON, hidden: true };
|
|
713
777
|
files["/node_modules/qrcode/index.js"] = { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true };
|
|
778
|
+
// Sandpack runtime can evaluate JSON files as plain JS modules.
|
|
779
|
+
// Provide CJS-compatible shims to keep @seedgrid/fe-components i18n/validators working.
|
|
780
|
+
files["/node_modules/@seedgrid/fe-components/dist/i18n/pt-BR.json"] = {
|
|
781
|
+
code: SANDPACK_SEEDGRID_PT_BR_JSON_SHIM,
|
|
782
|
+
hidden: true
|
|
783
|
+
};
|
|
784
|
+
files["/node_modules/@seedgrid/fe-components/dist/i18n/pt-PT.json"] = {
|
|
785
|
+
code: SANDPACK_SEEDGRID_PT_PT_JSON_SHIM,
|
|
786
|
+
hidden: true
|
|
787
|
+
};
|
|
788
|
+
files["/node_modules/@seedgrid/fe-components/dist/i18n/en-US.json"] = {
|
|
789
|
+
code: SANDPACK_SEEDGRID_EN_US_JSON_SHIM,
|
|
790
|
+
hidden: true
|
|
791
|
+
};
|
|
792
|
+
files["/node_modules/@seedgrid/fe-components/dist/i18n/es.json"] = {
|
|
793
|
+
code: SANDPACK_SEEDGRID_ES_JSON_SHIM,
|
|
794
|
+
hidden: true
|
|
795
|
+
};
|
|
796
|
+
files["/node_modules/@seedgrid/fe-components/dist/blocked-email-domains.json"] = {
|
|
797
|
+
code: SANDPACK_SEEDGRID_BLOCKED_EMAIL_DOMAINS_JSON_SHIM,
|
|
798
|
+
hidden: true
|
|
799
|
+
};
|
|
714
800
|
}
|
|
715
801
|
if (shouldIncludeNodePolyfills) {
|
|
716
802
|
// markdown-it CLI entry uses node:fs and breaks in browser runtime.
|
|
@@ -719,30 +805,21 @@ export default function SgPlayground(props) {
|
|
|
719
805
|
hidden: true
|
|
720
806
|
};
|
|
721
807
|
// Node builtin compatibility shims used by transitive dependencies (e.g. argparse from markdown-it/tiptap).
|
|
722
|
-
files["/node_modules/assert/package.json"] = { code: SANDPACK_ASSERT_SHIM_PACKAGE_JSON, hidden: true };
|
|
723
808
|
files["/node_modules/assert/index.js"] = { code: SANDPACK_ASSERT_SHIM_INDEX_JS, hidden: true };
|
|
724
|
-
files["/node_modules/util/package.json"] = { code: SANDPACK_UTIL_SHIM_PACKAGE_JSON, hidden: true };
|
|
725
809
|
files["/node_modules/util/index.js"] = { code: SANDPACK_UTIL_SHIM_INDEX_JS, hidden: true };
|
|
726
|
-
files["/node_modules/path/package.json"] = { code: SANDPACK_PATH_SHIM_PACKAGE_JSON, hidden: true };
|
|
727
810
|
files["/node_modules/path/index.js"] = { code: SANDPACK_PATH_SHIM_INDEX_JS, hidden: true };
|
|
728
|
-
files["/node_modules/fs/package.json"] = { code: SANDPACK_FS_SHIM_PACKAGE_JSON, hidden: true };
|
|
729
811
|
files["/node_modules/fs/index.js"] = { code: SANDPACK_FS_SHIM_INDEX_JS, hidden: true };
|
|
730
|
-
files["/node_modules/process/package.json"] = { code: SANDPACK_PROCESS_SHIM_PACKAGE_JSON, hidden: true };
|
|
731
812
|
files["/node_modules/process/index.js"] = { code: SANDPACK_PROCESS_SHIM_INDEX_JS, hidden: true };
|
|
732
813
|
}
|
|
733
814
|
if (shouldShimSandpackReact) {
|
|
734
|
-
files["/node_modules/@codesandbox/sandpack-react/package.json"] = {
|
|
735
|
-
code: createEsmShimPackageJson("@codesandbox/sandpack-react"),
|
|
736
|
-
hidden: true
|
|
737
|
-
};
|
|
738
815
|
files["/node_modules/@codesandbox/sandpack-react/index.js"] = {
|
|
739
816
|
code: SANDPACK_SANDBOX_SANDPACK_REACT_SHIM_INDEX_JS,
|
|
740
817
|
hidden: true
|
|
741
818
|
};
|
|
742
819
|
}
|
|
743
820
|
if (shouldShimTiptap) {
|
|
744
|
-
files["/node_modules/@
|
|
745
|
-
code:
|
|
821
|
+
files["/node_modules/@seedgrid/fe-components/dist/inputs/SgTextEditor.js"] = {
|
|
822
|
+
code: SANDPACK_SEEDGRID_TEXT_EDITOR_SHIM_INDEX_JS,
|
|
746
823
|
hidden: true
|
|
747
824
|
};
|
|
748
825
|
files["/node_modules/@tiptap/react/index.js"] = {
|
|
@@ -750,10 +827,6 @@ export default function SgPlayground(props) {
|
|
|
750
827
|
hidden: true
|
|
751
828
|
};
|
|
752
829
|
for (const packageName of TIPTAP_SHIM_PACKAGES) {
|
|
753
|
-
files[`/node_modules/${packageName}/package.json`] = {
|
|
754
|
-
code: createEsmShimPackageJson(packageName),
|
|
755
|
-
hidden: true
|
|
756
|
-
};
|
|
757
830
|
files[`/node_modules/${packageName}/index.js`] = {
|
|
758
831
|
code: SANDPACK_TIPTAP_EXTENSION_SHIM_INDEX_JS,
|
|
759
832
|
hidden: true
|
|
@@ -777,17 +850,23 @@ export default function SgPlayground(props) {
|
|
|
777
850
|
: resizeAxis === "horizontal"
|
|
778
851
|
? "resize-x"
|
|
779
852
|
: "resize";
|
|
780
|
-
const
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
853
|
+
const sandpackCustomSetup = React.useMemo(() => ({
|
|
854
|
+
dependencies: deps,
|
|
855
|
+
entry: "/index.tsx",
|
|
856
|
+
...(resolvedNpmRegistries ? { npmRegistries: resolvedNpmRegistries } : {})
|
|
857
|
+
}), [deps, resolvedNpmRegistries]);
|
|
858
|
+
const sandpackOptions = React.useMemo(() => ({
|
|
859
|
+
autorun: false,
|
|
860
|
+
initMode: "lazy",
|
|
861
|
+
bundlerURL: resolvedBundlerURL,
|
|
862
|
+
// Keep both keys while sandpack typings/runtime differ across versions.
|
|
863
|
+
bundlerTimeOut: resolvedBundlerTimeoutMs,
|
|
864
|
+
bundlerTimeout: resolvedBundlerTimeoutMs,
|
|
865
|
+
activeFile: "/App.tsx",
|
|
866
|
+
visibleFiles: ["/App.tsx"],
|
|
867
|
+
externalResources: SANDPACK_EXTERNAL_RESOURCES
|
|
868
|
+
}), [resolvedBundlerTimeoutMs, resolvedBundlerURL]);
|
|
869
|
+
const content = interactive ? (_jsx("div", { className: cn(withCard ? "" : "rounded-lg border border-border", withCard ? undefined : className), children: _jsxs(SandpackProvider, { template: "react-ts", files: files, customSetup: sandpackCustomSetup, options: sandpackOptions, children: [_jsx("style", { children: SANDPACK_HOST_STYLES_CSS }), _jsxs("div", { className: "flex items-center justify-between border-b border-border px-3 py-2", children: [_jsxs("div", { className: "flex items-center gap-2", children: [withCard ? null : _jsx("span", { className: "text-sm font-medium", children: title ?? "Example" }), _jsx("span", { className: "text-xs text-muted-foreground", children: codeContract === "renderBody" ? "editable snippet" : "editable App.tsx" })] }), _jsxs("div", { className: "flex items-center gap-2", children: [expandable ? (_jsx(SgButton, { appearance: "outline", size: "sm", onClick: () => setIsExpanded((prev) => !prev), children: isExpanded ? "Reduzir" : "Expandir" })) : null, _jsx(RunButton, { onRun: () => setActivePanel("preview") })] })] }), _jsxs("div", { className: "flex md:hidden border-b border-border", children: [_jsx("button", { type: "button", className: cn("flex-1 py-2 text-sm font-medium border-b-2 -mb-px transition-colors", activePanel === "code"
|
|
791
870
|
? "border-primary text-foreground"
|
|
792
871
|
: "border-transparent text-muted-foreground hover:text-foreground"), onClick: () => setActivePanel("code"), children: "C\u00F3digo" }), _jsx("button", { type: "button", className: cn("flex-1 py-2 text-sm font-medium border-b-2 -mb-px transition-colors", activePanel === "preview"
|
|
793
872
|
? "border-primary text-foreground"
|