diff --git a/CHANGELOG.md b/CHANGELOG.md index a7aee6131..eb83c4be6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.14.2](https://github.com/codesandbox/sandpack/compare/v2.14.1...v2.14.2) (2024-06-06) + +### Bug Fixes + +- **export:** normalize files and pass template ([#1145](https://github.com/codesandbox/sandpack/issues/1145)) ([c3bc09d](https://github.com/codesandbox/sandpack/commit/c3bc09d11a0cf492c5211bf25d5916685aeae170)) + ## [2.14.1](https://github.com/codesandbox/sandpack/compare/v2.14.0...v2.14.1) (2024-06-05) ### Bug Fixes diff --git a/lerna.json b/lerna.json index a961ccce7..b971e76cb 100644 --- a/lerna.json +++ b/lerna.json @@ -17,5 +17,5 @@ "message": "chore: [skip ci] bump packages" } }, - "version": "2.14.1" + "version": "2.14.2" } diff --git a/sandpack-react/CHANGELOG.md b/sandpack-react/CHANGELOG.md index bdc559fa0..1086319fd 100644 --- a/sandpack-react/CHANGELOG.md +++ b/sandpack-react/CHANGELOG.md @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +## [2.14.2](https://github.com/codesandbox/sandpack/compare/v2.14.1...v2.14.2) (2024-06-06) + +### Bug Fixes + +- **export:** normalize files and pass template ([#1145](https://github.com/codesandbox/sandpack/issues/1145)) ([c3bc09d](https://github.com/codesandbox/sandpack/commit/c3bc09d11a0cf492c5211bf25d5916685aeae170)) + ## [2.14.1](https://github.com/codesandbox/sandpack/compare/v2.14.0...v2.14.1) (2024-06-05) ### Bug Fixes diff --git a/sandpack-react/package.json b/sandpack-react/package.json index 47d255ace..d84dd717f 100644 --- a/sandpack-react/package.json +++ b/sandpack-react/package.json @@ -1,6 +1,6 @@ { "name": "@codesandbox/sandpack-react", - "version": "2.14.1", + "version": "2.14.2", "description": "", "keywords": [], "repository": { diff --git a/sandpack-react/src/PrivatePackage.stories.tsx b/sandpack-react/src/PrivatePackage.stories.tsx index dc490c046..588b4b124 100644 --- a/sandpack-react/src/PrivatePackage.stories.tsx +++ b/sandpack-react/src/PrivatePackage.stories.tsx @@ -20,8 +20,6 @@ export default function App() { return }`, }} - // options={{ bundlerURL: `http://localhost:3000` }} - // options={{ bundlerURL: `https://2-1-0-sandpack.codesandbox.stream/` }} teamId="642af90c-4717-4730-bad3-e4c1e37ca5e2" template="react" /> diff --git a/sandpack-react/src/components/common/OpenInCodeSandboxButton/UnstyledOpenInCodeSandboxButton.tsx b/sandpack-react/src/components/common/OpenInCodeSandboxButton/UnstyledOpenInCodeSandboxButton.tsx index 79e62d8e7..966c6a79c 100644 --- a/sandpack-react/src/components/common/OpenInCodeSandboxButton/UnstyledOpenInCodeSandboxButton.tsx +++ b/sandpack-react/src/components/common/OpenInCodeSandboxButton/UnstyledOpenInCodeSandboxButton.tsx @@ -63,10 +63,16 @@ export const ExportToWorkspaceButton: React.FC< throw new Error("Missing `apiToken` property"); } + const normalizedFiles = Object.keys(state.files).reduce((prev, next) => { + const fileName = next.replace("/", ""); + return { ...prev, [fileName]: state.files[next] }; + }, {}); + const response = await fetch("https://api.codesandbox.io/sandbox", { method: "POST", body: JSON.stringify({ - files: state.files, + template: state.environment, + files: normalizedFiles, privacy: state.exportOptions.privacy === "public" ? 0 : 2, }), headers: { @@ -79,7 +85,7 @@ export const ExportToWorkspaceButton: React.FC< const data: { data: { alias: string } } = await response.json(); window.open( - `https://codesandbox.io/p/sandbox/${data.data.alias}?file=/src/App.js&utm-source=storybook-addon`, + `https://codesandbox.io/p/sandbox/${data.data.alias}?file=/${state.activeFile}&utm-source=storybook-addon`, "_blank" ); };