@replohq/sandbox-runtime 0.1.0 → 0.2.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.
- package/_vendor/schemas/generated/selectModeIframeRpc.d.ts +1 -1
- package/next/component-preview.d.ts +6 -0
- package/next/component-preview.js +38 -0
- package/next/component-preview.js.map +7 -0
- package/next/config.d.ts +2 -0
- package/next/config.js +18 -0
- package/next/config.js.map +7 -0
- package/package.json +9 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DisplayMode, SelectModeSelectionType, SelectModeOptimisticUpdatePayload, SelectModeFormatCommand, SelectableData, SelectModeBoundingRect, SelectModeClickPosition, SelectModeSelectionRect, SelectModeTiptapActiveMarks } from "./selectMode
|
|
1
|
+
import type { DisplayMode, SelectModeSelectionType, SelectModeOptimisticUpdatePayload, SelectModeFormatCommand, SelectableData, SelectModeBoundingRect, SelectModeClickPosition, SelectModeSelectionRect, SelectModeTiptapActiveMarks } from "./selectMode";
|
|
2
2
|
export type SelectModeParentMessage = {
|
|
3
3
|
method: "setDisplayMode";
|
|
4
4
|
data: {
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
export declare function createComponentPreviewPage(Component: ComponentType<Record<string, unknown>>): ({ searchParams, }: {
|
|
3
|
+
searchParams: Promise<{
|
|
4
|
+
props?: string | string[];
|
|
5
|
+
}>;
|
|
6
|
+
}) => Promise<import("react/jsx-runtime").JSX.Element>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
const MAX_PREVIEW_PROPS_BYTES = 16 * 1024;
|
|
3
|
+
const BLOCKED_PROP_NAMES = /* @__PURE__ */ new Set([
|
|
4
|
+
"__proto__",
|
|
5
|
+
"constructor",
|
|
6
|
+
"dangerouslySetInnerHTML"
|
|
7
|
+
]);
|
|
8
|
+
function getPreviewProps(value) {
|
|
9
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
return Object.fromEntries(
|
|
13
|
+
Object.entries(value).filter(([name]) => !BLOCKED_PROP_NAMES.has(name))
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
function parseProps(value) {
|
|
17
|
+
if (typeof value !== "string" || new TextEncoder().encode(value).byteLength > MAX_PREVIEW_PROPS_BYTES) {
|
|
18
|
+
return {};
|
|
19
|
+
}
|
|
20
|
+
try {
|
|
21
|
+
const parsed = JSON.parse(value);
|
|
22
|
+
return getPreviewProps(parsed);
|
|
23
|
+
} catch {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function createComponentPreviewPage(Component) {
|
|
28
|
+
return async function ComponentPreviewPage({
|
|
29
|
+
searchParams
|
|
30
|
+
}) {
|
|
31
|
+
const props = parseProps((await searchParams).props);
|
|
32
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
export {
|
|
36
|
+
createComponentPreviewPage
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=component-preview.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../next/component-preview.tsx"],
|
|
4
|
+
"sourcesContent": ["import type { ComponentType } from \"react\";\n\nconst MAX_PREVIEW_PROPS_BYTES = 16 * 1024;\nconst BLOCKED_PROP_NAMES = new Set([\n \"__proto__\",\n \"constructor\",\n \"dangerouslySetInnerHTML\",\n]);\n\nfunction getPreviewProps(value: unknown): Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n return {};\n }\n\n return Object.fromEntries(\n Object.entries(value).filter(([name]) => !BLOCKED_PROP_NAMES.has(name)),\n );\n}\n\nfunction parseProps(value: string | string[] | undefined) {\n if (\n typeof value !== \"string\" ||\n new TextEncoder().encode(value).byteLength > MAX_PREVIEW_PROPS_BYTES\n ) {\n return {};\n }\n try {\n const parsed: unknown = JSON.parse(value);\n return getPreviewProps(parsed);\n } catch {\n return {};\n }\n}\n\nexport function createComponentPreviewPage(\n Component: ComponentType<Record<string, unknown>>,\n) {\n return async function ComponentPreviewPage({\n searchParams,\n }: {\n searchParams: Promise<{ props?: string | string[] }>;\n }) {\n const props = parseProps((await searchParams).props);\n return <Component {...props} />;\n };\n}\n"],
|
|
5
|
+
"mappings": "AA2CW;AAzCX,MAAM,0BAA0B,KAAK;AACrC,MAAM,qBAAqB,oBAAI,IAAI;AAAA,EACjC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAED,SAAS,gBAAgB,OAAyC;AAChE,MAAI,UAAU,QAAQ,OAAO,UAAU,YAAY,MAAM,QAAQ,KAAK,GAAG;AACvE,WAAO,CAAC;AAAA,EACV;AAEA,SAAO,OAAO;AAAA,IACZ,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,IAAI,MAAM,CAAC,mBAAmB,IAAI,IAAI,CAAC;AAAA,EACxE;AACF;AAEA,SAAS,WAAW,OAAsC;AACxD,MACE,OAAO,UAAU,YACjB,IAAI,YAAY,EAAE,OAAO,KAAK,EAAE,aAAa,yBAC7C;AACA,WAAO,CAAC;AAAA,EACV;AACA,MAAI;AACF,UAAM,SAAkB,KAAK,MAAM,KAAK;AACxC,WAAO,gBAAgB,MAAM;AAAA,EAC/B,QAAQ;AACN,WAAO,CAAC;AAAA,EACV;AACF;AAEO,SAAS,2BACd,WACA;AACA,SAAO,eAAe,qBAAqB;AAAA,IACzC;AAAA,EACF,GAEG;AACD,UAAM,QAAQ,YAAY,MAAM,cAAc,KAAK;AACnD,WAAO,oBAAC,aAAW,GAAG,OAAO;AAAA,EAC/B;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/next/config.d.ts
ADDED
package/next/config.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const DEFAULT_PAGE_EXTENSIONS = ["tsx", "ts", "jsx", "js"];
|
|
2
|
+
function getPageExtensions(configuredExtensions) {
|
|
3
|
+
const pageExtensions = (configuredExtensions ?? DEFAULT_PAGE_EXTENSIONS).filter((extension) => extension !== "dev.jsx");
|
|
4
|
+
if (process.env.BUILD_ENV !== "build") {
|
|
5
|
+
return ["dev.jsx", ...pageExtensions];
|
|
6
|
+
}
|
|
7
|
+
return configuredExtensions && pageExtensions.length > 0 ? pageExtensions : void 0;
|
|
8
|
+
}
|
|
9
|
+
function withComponentPreviewPageExtension(config) {
|
|
10
|
+
return {
|
|
11
|
+
...config,
|
|
12
|
+
pageExtensions: getPageExtensions(config.pageExtensions)
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export {
|
|
16
|
+
withComponentPreviewPageExtension
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../next/config.ts"],
|
|
4
|
+
"sourcesContent": ["import type { NextConfig } from \"next\";\n\nconst DEFAULT_PAGE_EXTENSIONS = [\"tsx\", \"ts\", \"jsx\", \"js\"];\n\nfunction getPageExtensions(configuredExtensions: string[] | undefined) {\n const pageExtensions = (\n configuredExtensions ?? DEFAULT_PAGE_EXTENSIONS\n ).filter((extension) => extension !== \"dev.jsx\");\n\n if (process.env.BUILD_ENV !== \"build\") {\n return [\"dev.jsx\", ...pageExtensions];\n }\n return configuredExtensions && pageExtensions.length > 0\n ? pageExtensions\n : undefined;\n}\n\nexport function withComponentPreviewPageExtension(\n config: NextConfig,\n): NextConfig {\n return {\n ...config,\n pageExtensions: getPageExtensions(config.pageExtensions),\n };\n}\n"],
|
|
5
|
+
"mappings": "AAEA,MAAM,0BAA0B,CAAC,OAAO,MAAM,OAAO,IAAI;AAEzD,SAAS,kBAAkB,sBAA4C;AACrE,QAAM,kBACJ,wBAAwB,yBACxB,OAAO,CAAC,cAAc,cAAc,SAAS;AAE/C,MAAI,QAAQ,IAAI,cAAc,SAAS;AACrC,WAAO,CAAC,WAAW,GAAG,cAAc;AAAA,EACtC;AACA,SAAO,wBAAwB,eAAe,SAAS,IACnD,iBACA;AACN;AAEO,SAAS,kCACd,QACY;AACZ,SAAO;AAAA,IACL,GAAG;AAAA,IACH,gBAAgB,kBAAkB,OAAO,cAAc;AAAA,EACzD;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@replohq/sandbox-runtime",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Replo sandbox runtime — editor integration for agent-built Next.js sites.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|
|
@@ -10,6 +10,14 @@
|
|
|
10
10
|
"types": "./sandbox-runtime.d.ts",
|
|
11
11
|
"default": "./sandbox-runtime.js"
|
|
12
12
|
},
|
|
13
|
+
"./next/component-preview": {
|
|
14
|
+
"types": "./next/component-preview.d.ts",
|
|
15
|
+
"default": "./next/component-preview.js"
|
|
16
|
+
},
|
|
17
|
+
"./next/config": {
|
|
18
|
+
"types": "./next/config.d.ts",
|
|
19
|
+
"default": "./next/config.js"
|
|
20
|
+
},
|
|
13
21
|
"./package.json": "./package.json"
|
|
14
22
|
},
|
|
15
23
|
"dependencies": {
|