Skip to content

Commit

Permalink
feat: add sandbox-id prop to compile (#1015)
Browse files Browse the repository at this point in the history
  • Loading branch information
DeMoorJasper committed Oct 6, 2023
1 parent 013a8df commit 600b984
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions sandpack-client/src/clients/runtime/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
}

Expand Down
1 change: 1 addition & 0 deletions sandpack-client/src/clients/runtime/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export type SandpackRuntimeMessage = BaseSandpackMessage &
logLevel?: SandpackLogLevel;
customNpmRegistries?: NpmRegistry[];
teamId?: string;
sandboxId?: string;
}
| {
type: "refresh";
Expand Down
5 changes: 5 additions & 0 deletions sandpack-client/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions sandpack-react/src/contexts/utils/useClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type UseClient = (
) => [SandpackConfigState, UseClientOperations];

export const useClient: UseClient = (
{ options, customSetup, teamId },
{ options, customSetup, teamId, sandboxId },
filesState
) => {
options ??= {};
Expand Down Expand Up @@ -165,7 +165,8 @@ export const useClient: UseClient = (
showLoadingScreen: false,
reactDevTools: state.reactDevTools,
customNpmRegistries: customSetup?.npmRegistries,
teamId: teamId,
teamId,
sandboxId,
}
);

Expand Down
1 change: 1 addition & 0 deletions sandpack-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ interface SandpackRootProps<
customSetup?: SandpackSetup;
theme?: SandpackThemeProp;
teamId?: string;
sandboxId?: string;
}

export interface SandpackInternalOptions<
Expand Down

1 comment on commit 600b984

@vercel
Copy link

@vercel vercel bot commented on 600b984 Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.