@seedgrid/fe-components 2026.3.2-3 → 2026.3.2-5

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 +1 @@
1
- {"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"AAiBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,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,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;AAwXF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAoOtE"}
1
+ {"version":3,"file":"SgPlayground.d.ts","sourceRoot":"","sources":["../../src/others/SgPlayground.tsx"],"names":[],"mappings":"AAiBA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,YAAY,CAAC,EAAE,YAAY,GAAG,SAAS,CAAC;IACxC,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,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;AAimBF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,KAAK,EAAE,QAAQ,CAAC,iBAAiB,CAAC,2CAyPtE"}
@@ -27,6 +27,11 @@ const DEFAULT_SEEDGRID_PEER_DEPENDENCIES = {
27
27
  "@tiptap/extension-superscript": "^2.9.1",
28
28
  "@tiptap/extension-font-family": "^2.9.1"
29
29
  };
30
+ const DEFAULT_SANDPACK_POLYFILLS = {
31
+ assert: "^2.1.0",
32
+ process: "^0.11.10",
33
+ util: "^0.12.5"
34
+ };
30
35
  const SANDPACK_EXTERNAL_RESOURCES = [
31
36
  // Prebuilt utility CSS so classes from @seedgrid/fe-components can render inside Sandpack
32
37
  "https://unpkg.com/tailwindcss@2.2.19/dist/tailwind.min.css"
@@ -55,6 +60,186 @@ const qrcodeShim = {
55
60
  export const toDataURL = (...args) => qrcodeShim.toDataURL(...args);
56
61
  export default qrcodeShim;
57
62
  `;
63
+ const SANDPACK_MARKDOWN_IT_BIN_SHIM = `import markdownit from "../index.mjs";
64
+
65
+ // Browser-safe shim: Sandpack must not execute markdown-it CLI entrypoint.
66
+ // Re-export parser factory so accidental imports of the bin path remain harmless.
67
+ export default markdownit;
68
+ export { markdownit };
69
+ `;
70
+ const SANDPACK_ASSERT_SHIM_PACKAGE_JSON = `{
71
+ "name": "assert",
72
+ "version": "0.0.0-sandpack-shim",
73
+ "main": "./index.js"
74
+ }`;
75
+ const SANDPACK_ASSERT_SHIM_INDEX_JS = `function fail(message) {
76
+ throw new Error(message || "Assertion failed");
77
+ }
78
+
79
+ function assert(value, message) {
80
+ if (!value) fail(message);
81
+ }
82
+
83
+ assert.ok = assert;
84
+ assert.equal = function equal(actual, expected, message) {
85
+ if (actual != expected) fail(message || "Expected values to be loosely equal");
86
+ };
87
+ assert.strictEqual = function strictEqual(actual, expected, message) {
88
+ if (actual !== expected) fail(message || "Expected values to be strictly equal");
89
+ };
90
+ assert.notEqual = function notEqual(actual, expected, message) {
91
+ if (actual == expected) fail(message || "Expected values to be different");
92
+ };
93
+ assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
94
+ if (actual === expected) fail(message || "Expected values to be different");
95
+ };
96
+ assert.deepEqual = function deepEqual(actual, expected, message) {
97
+ try {
98
+ if (JSON.stringify(actual) !== JSON.stringify(expected)) {
99
+ fail(message || "Expected values to be deeply equal");
100
+ }
101
+ } catch (_) {
102
+ if (actual !== expected) fail(message || "Expected values to be deeply equal");
103
+ }
104
+ };
105
+ assert.throws = function throwsAssertion(fn, message) {
106
+ var didThrow = false;
107
+ try { fn(); } catch (_) { didThrow = true; }
108
+ if (!didThrow) fail(message || "Expected function to throw");
109
+ };
110
+ assert.fail = fail;
111
+
112
+ module.exports = assert;
113
+ module.exports.default = assert;
114
+ `;
115
+ const SANDPACK_UTIL_SHIM_PACKAGE_JSON = `{
116
+ "name": "util",
117
+ "version": "0.0.0-sandpack-shim",
118
+ "main": "./index.js"
119
+ }`;
120
+ const SANDPACK_UTIL_SHIM_INDEX_JS = `const inspect = function inspect(value) {
121
+ try {
122
+ return JSON.stringify(value);
123
+ } catch (_) {
124
+ return String(value);
125
+ }
126
+ };
127
+
128
+ inspect.custom = typeof Symbol !== "undefined" && Symbol.for
129
+ ? Symbol.for("nodejs.util.inspect.custom")
130
+ : "@@nodejs.util.inspect.custom";
131
+
132
+ function deprecate(fn, message) {
133
+ var warned = false;
134
+ return function deprecatedWrapper() {
135
+ if (!warned && typeof console !== "undefined" && typeof console.warn === "function") {
136
+ console.warn(message);
137
+ warned = true;
138
+ }
139
+ return fn.apply(this, arguments);
140
+ };
141
+ }
142
+
143
+ function format() {
144
+ return Array.prototype.map.call(arguments, function (item) {
145
+ return String(item);
146
+ }).join(" ");
147
+ }
148
+
149
+ const utilShim = { inspect, deprecate, format };
150
+ module.exports = utilShim;
151
+ module.exports.default = utilShim;
152
+ `;
153
+ const SANDPACK_PATH_SHIM_PACKAGE_JSON = `{
154
+ "name": "path",
155
+ "version": "0.0.0-sandpack-shim",
156
+ "main": "./index.js"
157
+ }`;
158
+ const SANDPACK_PATH_SHIM_INDEX_JS = `function normalize(input) {
159
+ return String(input || "").replace(/\\\\/g, "/");
160
+ }
161
+
162
+ function basename(input) {
163
+ var text = normalize(input);
164
+ var pieces = text.split("/").filter(Boolean);
165
+ return pieces.length ? pieces[pieces.length - 1] : "";
166
+ }
167
+
168
+ function dirname(input) {
169
+ var text = normalize(input);
170
+ var index = text.lastIndexOf("/");
171
+ if (index <= 0) return ".";
172
+ return text.slice(0, index);
173
+ }
174
+
175
+ function join() {
176
+ return Array.prototype
177
+ .map.call(arguments, normalize)
178
+ .filter(Boolean)
179
+ .join("/")
180
+ .replace(/\\/{2,}/g, "/");
181
+ }
182
+
183
+ function resolve() {
184
+ return join.apply(null, arguments);
185
+ }
186
+
187
+ const pathShim = {
188
+ sep: "/",
189
+ delimiter: ":",
190
+ basename,
191
+ dirname,
192
+ join,
193
+ resolve,
194
+ normalize
195
+ };
196
+
197
+ module.exports = pathShim;
198
+ module.exports.default = pathShim;
199
+ `;
200
+ const SANDPACK_FS_SHIM_PACKAGE_JSON = `{
201
+ "name": "fs",
202
+ "version": "0.0.0-sandpack-shim",
203
+ "main": "./index.js"
204
+ }`;
205
+ const SANDPACK_FS_SHIM_INDEX_JS = `function notSupported(name) {
206
+ throw new Error("fs." + name + " is not supported in Sandpack browser runtime.");
207
+ }
208
+
209
+ const fsShim = {
210
+ openSync: function openSync() { return notSupported("openSync"); },
211
+ createReadStream: function createReadStream() { return notSupported("createReadStream"); },
212
+ createWriteStream: function createWriteStream() { return notSupported("createWriteStream"); },
213
+ readFileSync: function readFileSync() { return notSupported("readFileSync"); }
214
+ };
215
+
216
+ module.exports = fsShim;
217
+ module.exports.default = fsShim;
218
+ `;
219
+ const SANDPACK_PROCESS_SHIM_PACKAGE_JSON = `{
220
+ "name": "process",
221
+ "version": "0.0.0-sandpack-shim",
222
+ "main": "./index.js"
223
+ }`;
224
+ const SANDPACK_PROCESS_SHIM_INDEX_JS = `const processShim = {
225
+ env: {},
226
+ argv: ["browser"],
227
+ stdout: { columns: 80 },
228
+ stderr: { columns: 80 },
229
+ cwd: function cwd() { return "/"; },
230
+ nextTick: function nextTick(fn) {
231
+ var args = Array.prototype.slice.call(arguments, 1);
232
+ return Promise.resolve().then(function () { return fn.apply(null, args); });
233
+ }
234
+ };
235
+
236
+ if (typeof globalThis !== "undefined" && !globalThis.process) {
237
+ globalThis.process = processShim;
238
+ }
239
+
240
+ module.exports = processShim;
241
+ module.exports.default = processShim;
242
+ `;
58
243
  const SANDPACK_FALLBACK_THEME_VARS = {
59
244
  "--background": "0 0% 100%",
60
245
  "--foreground": "222.2 84% 4.9%",
@@ -329,10 +514,42 @@ function CopyButton() {
329
514
  }
330
515
  function RunButton({ onRun }) {
331
516
  const { sandpack } = useSandpack();
332
- return (_jsx(SgButton, { severity: "primary", size: "sm", onClick: () => {
333
- sandpack.runSandpack();
334
- onRun?.();
335
- }, children: "Run" }));
517
+ const [running, setRunning] = React.useState(false);
518
+ const handleRun = React.useCallback(async () => {
519
+ if (running)
520
+ return;
521
+ setRunning(true);
522
+ onRun?.();
523
+ try {
524
+ if (typeof window !== "undefined") {
525
+ await new Promise((resolve) => {
526
+ window.requestAnimationFrame(() => window.requestAnimationFrame(() => resolve()));
527
+ });
528
+ }
529
+ // On lazy init + hidden preview scenarios, iframe/client registration can lag by a tick.
530
+ for (let attempt = 0; attempt < 3; attempt += 1) {
531
+ await sandpack.runSandpack();
532
+ if (sandpack.status === "running" ||
533
+ sandpack.status === "done" ||
534
+ Object.keys(sandpack.clients ?? {}).length > 0) {
535
+ break;
536
+ }
537
+ await new Promise((resolve) => setTimeout(resolve, 120));
538
+ }
539
+ }
540
+ catch (error) {
541
+ console.error("[SgPlayground] Failed to run Sandpack", error);
542
+ }
543
+ finally {
544
+ if (typeof window !== "undefined") {
545
+ window.setTimeout(() => setRunning(false), 150);
546
+ }
547
+ else {
548
+ setRunning(false);
549
+ }
550
+ }
551
+ }, [onRun, running, sandpack]);
552
+ return (_jsx(SgButton, { severity: "primary", size: "sm", loading: running, onClick: handleRun, children: running ? "Running" : "Run" }));
336
553
  }
337
554
  export default function SgPlayground(props) {
338
555
  const { code, interactive = false, codeContract = "renderBody", 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;
@@ -390,11 +607,28 @@ export default function SgPlayground(props) {
390
607
  "/styles.css": { code: sandpackStylesCss || buildSandpackStylesCss({}, effectivePreviewPadding) },
391
608
  // Compatibility shim for legacy @seedgrid/fe-components builds that still import "qrcode" (node-only path).
392
609
  "/node_modules/qrcode/package.json": { code: SANDPACK_QRCODE_SHIM_PACKAGE_JSON, hidden: true },
393
- "/node_modules/qrcode/index.js": { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true }
610
+ "/node_modules/qrcode/index.js": { code: SANDPACK_QRCODE_SHIM_INDEX_JS, hidden: true },
611
+ // markdown-it CLI entry uses node:fs and breaks in browser runtime.
612
+ "/node_modules/markdown-it/bin/markdown-it.mjs": {
613
+ code: SANDPACK_MARKDOWN_IT_BIN_SHIM,
614
+ hidden: true
615
+ },
616
+ // Node builtin compatibility shims used by transitive dependencies (e.g. argparse from markdown-it/tiptap).
617
+ "/node_modules/assert/package.json": { code: SANDPACK_ASSERT_SHIM_PACKAGE_JSON, hidden: true },
618
+ "/node_modules/assert/index.js": { code: SANDPACK_ASSERT_SHIM_INDEX_JS, hidden: true },
619
+ "/node_modules/util/package.json": { code: SANDPACK_UTIL_SHIM_PACKAGE_JSON, hidden: true },
620
+ "/node_modules/util/index.js": { code: SANDPACK_UTIL_SHIM_INDEX_JS, hidden: true },
621
+ "/node_modules/path/package.json": { code: SANDPACK_PATH_SHIM_PACKAGE_JSON, hidden: true },
622
+ "/node_modules/path/index.js": { code: SANDPACK_PATH_SHIM_INDEX_JS, hidden: true },
623
+ "/node_modules/fs/package.json": { code: SANDPACK_FS_SHIM_PACKAGE_JSON, hidden: true },
624
+ "/node_modules/fs/index.js": { code: SANDPACK_FS_SHIM_INDEX_JS, hidden: true },
625
+ "/node_modules/process/package.json": { code: SANDPACK_PROCESS_SHIM_PACKAGE_JSON, hidden: true },
626
+ "/node_modules/process/index.js": { code: SANDPACK_PROCESS_SHIM_INDEX_JS, hidden: true }
394
627
  };
395
628
  const deps = {
396
629
  react: "^19.0.0",
397
630
  "react-dom": "^19.0.0",
631
+ ...DEFAULT_SANDPACK_POLYFILLS,
398
632
  ...DEFAULT_SEEDGRID_PEER_DEPENDENCIES,
399
633
  "@seedgrid/fe-components": resolvedSeedgridDependency,
400
634
  ...(dependencies ?? {})
@@ -411,7 +645,9 @@ export default function SgPlayground(props) {
411
645
  autorun: false,
412
646
  initMode: "lazy",
413
647
  bundlerURL: "https://sandpack.seedgrid.com.br",
648
+ // Keep both keys while sandpack typings/runtime differ across versions.
414
649
  bundlerTimeOut: 60000,
650
+ bundlerTimeout: 60000,
415
651
  activeFile: "/App.tsx",
416
652
  visibleFiles: ["/App.tsx"],
417
653
  externalResources: SANDPACK_EXTERNAL_RESOURCES
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedgrid/fe-components",
3
- "version": "2026.3.2-3",
3
+ "version": "2026.3.2-5",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",