From 600b984d4dccaefc36e87d41a56bbd4cb9bb434f Mon Sep 17 00:00:00 2001 From: Jasper De Moor Date: Fri, 6 Oct 2023 10:40:29 +0200 Subject: [PATCH] feat: add sandbox-id prop to compile (#1015) --- sandpack-client/src/clients/runtime/index.ts | 1 + sandpack-client/src/clients/runtime/types.ts | 1 + sandpack-client/src/types.ts | 5 +++++ sandpack-react/src/contexts/utils/useClient.ts | 5 +++-- sandpack-react/src/types.ts | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/sandpack-client/src/clients/runtime/index.ts b/sandpack-client/src/clients/runtime/index.ts index 924166f63..627f5b7ea 100644 --- a/sandpack-client/src/clients/runtime/index.ts +++ b/sandpack-client/src/clients/runtime/index.ts @@ -250,6 +250,7 @@ export class SandpackRuntime extends SandpackClient { logLevel: this.options.logLevel ?? SandpackLogLevel.Info, customNpmRegistries: this.options.customNpmRegistries, teamId: this.options.teamId, + sandboxId: this.options.sandboxId, }); } diff --git a/sandpack-client/src/clients/runtime/types.ts b/sandpack-client/src/clients/runtime/types.ts index 670724ad7..ceb01998f 100644 --- a/sandpack-client/src/clients/runtime/types.ts +++ b/sandpack-client/src/clients/runtime/types.ts @@ -79,6 +79,7 @@ export type SandpackRuntimeMessage = BaseSandpackMessage & logLevel?: SandpackLogLevel; customNpmRegistries?: NpmRegistry[]; teamId?: string; + sandboxId?: string; } | { type: "refresh"; diff --git a/sandpack-client/src/types.ts b/sandpack-client/src/types.ts index 754628d07..4e6c0cc87 100644 --- a/sandpack-client/src/types.ts +++ b/sandpack-client/src/types.ts @@ -60,6 +60,11 @@ export interface ClientOptions { */ customNpmRegistries?: NpmRegistry[]; + /** + * CodeSandbox sandbox id: used internally by codesandbox + */ + sandboxId?: string; + /** * CodeSandbox team id: with this information, bundler can connect to CodeSandbox * and unlock a few capabilities diff --git a/sandpack-react/src/contexts/utils/useClient.ts b/sandpack-react/src/contexts/utils/useClient.ts index 3d0198a87..723b8f50f 100644 --- a/sandpack-react/src/contexts/utils/useClient.ts +++ b/sandpack-react/src/contexts/utils/useClient.ts @@ -69,7 +69,7 @@ type UseClient = ( ) => [SandpackConfigState, UseClientOperations]; export const useClient: UseClient = ( - { options, customSetup, teamId }, + { options, customSetup, teamId, sandboxId }, filesState ) => { options ??= {}; @@ -165,7 +165,8 @@ export const useClient: UseClient = ( showLoadingScreen: false, reactDevTools: state.reactDevTools, customNpmRegistries: customSetup?.npmRegistries, - teamId: teamId, + teamId, + sandboxId, } ); diff --git a/sandpack-react/src/types.ts b/sandpack-react/src/types.ts index 4ed1a4f18..d52f73cd5 100644 --- a/sandpack-react/src/types.ts +++ b/sandpack-react/src/types.ts @@ -431,6 +431,7 @@ interface SandpackRootProps< customSetup?: SandpackSetup; theme?: SandpackThemeProp; teamId?: string; + sandboxId?: string; } export interface SandpackInternalOptions<