Skip to content

Commit db8eba7

Browse files
authored
feat: sandpack template type (#1075)
* fix(type): sandpack template * chore(deps): remove codesandbox-import-util-types * docs(type): update sandpack template usage --------- Co-authored-by: Jimmy Jouanne <jimmy.jouanne@jobteaser.com>
1 parent 3bfd4ac commit db8eba7

File tree

6 files changed

+6
-13
lines changed

6 files changed

+6
-13
lines changed

sandpack-client/src/clients/runtime/types.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import type { ITemplate } from "codesandbox-import-util-types";
2-
31
import type {
42
BaseSandpackMessage,
53
BundlerState,
@@ -11,6 +9,7 @@ import type {
119
SandpackErrorMessage,
1210
SandpackLogLevel,
1311
SandpackMessageConsoleMethods,
12+
SandpackTemplate,
1413
} from "../..";
1514

1615
export type SandpackRuntimeMessage = BaseSandpackMessage &
@@ -69,7 +68,7 @@ export type SandpackRuntimeMessage = BaseSandpackMessage &
6968
externalResources: string[];
7069
hasFileResolver: boolean;
7170
disableDependencyPreprocessing?: boolean;
72-
template?: string | ITemplate;
71+
template?: string | SandpackTemplate;
7372
showOpenInCodeSandbox: boolean;
7473
showErrorScreen: boolean;
7574
showLoadingScreen: boolean;

sandpack-client/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export interface SandboxSetup {
8181
* What template we use, if not defined we infer the template from the dependencies or files.
8282
*
8383
*/
84-
template?: Template;
84+
template?: SandpackTemplate;
8585

8686
/**
8787
* Only use unpkg for fetching the dependencies, no preprocessing. It's slower, but doesn't talk
@@ -381,7 +381,7 @@ interface RunTests {
381381
path: string;
382382
}
383383

384-
export type Template =
384+
export type SandpackTemplate =
385385
| "angular-cli"
386386
| "create-react-app"
387387
| "create-react-app-typescript"

sandpack-react/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
"@stitches/core": "^1.2.6",
6666
"anser": "^2.1.1",
6767
"clean-set": "^1.1.2",
68-
"codesandbox-import-util-types": "^2.2.3",
6968
"dequal": "^2.0.2",
7069
"escape-carriage": "^1.3.1",
7170
"lz-string": "^1.4.4",

website/docs/src/pages/advanced-usage/client.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ The `getCodeSandboxURL` method creates a sandbox from the current files and retu
278278
/**
279279
* The sandbox template to use; this is inferred from the files and package.json if not specified
280280
**/
281-
template?: Template
281+
template?: SandpackTemplate
282282
}
283283
```
284284

website/docs/src/pages/getting-started/usage.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ By default your `<Sandpack />` instance starts with a predefined `template`. Eac
1515

1616
<Templates />
1717

18-
The `template` prop accepts a `string`, and has a variety of presets. If the template prop is not passed or has an invalid value, it defaults to `vanilla`.
18+
The `template` property accepts a [defined preset list](https://github.com/codesandbox/sandpack/blob/main/sandpack-client/src/types.ts#L384). If the property is not passed, `vanilla` will be set by default.
1919

2020
## Files
2121

yarn.lock

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6252,11 +6252,6 @@ code-point-at@^1.0.0:
62526252
resolved "https://registry.yarnpkg.com/code-point-at/-/code-point-at-1.1.0.tgz#0d070b4d043a5bea33a2f1a40e2edb3d9a4ccf77"
62536253
integrity sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=
62546254

6255-
codesandbox-import-util-types@^2.2.3:
6256-
version "2.2.3"
6257-
resolved "https://registry.yarnpkg.com/codesandbox-import-util-types/-/codesandbox-import-util-types-2.2.3.tgz#b354b2f732ad130e119ebd9ead3bda3be5981a54"
6258-
integrity sha512-Qj00p60oNExthP2oR3vvXmUGjukij+rxJGuiaKM6tyUmSyimdZsqHI/TUvFFClAffk9s7hxGnQgWQ8KCce27qQ==
6259-
62606255
collect-v8-coverage@^1.0.0:
62616256
version "1.0.1"
62626257
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.1.tgz#cc2c8e94fc18bbdffe64d6534570c8a673b27f59"

0 commit comments

Comments
 (0)