@lekoarts/satteri-sandpack 1.0.0 → 1.1.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/README.md +12 -4
- package/dist/index.d.ts +0 -4
- package/dist/index.js +3 -6
- package/package.json +73 -74
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Author [Sandpack](https://sandpack.codesandbox.io/docs) files as fenced code blo
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
This package is ESM only and requires Node.js 22 or newer. It supports Sätteri
|
|
9
|
+
This package is ESM only and requires Node.js 22 or newer. It supports Sätteri `^0.10.5` and `^0.11.0`.
|
|
10
10
|
|
|
11
11
|
```shell
|
|
12
12
|
npm install @lekoarts/satteri-sandpack satteri
|
|
@@ -65,7 +65,9 @@ import satteriSandpack from '@lekoarts/satteri-sandpack'
|
|
|
65
65
|
import { mdxToJs } from 'satteri'
|
|
66
66
|
|
|
67
67
|
const result = mdxToJs(source, {
|
|
68
|
-
mdastPlugins: [
|
|
68
|
+
mdastPlugins: [
|
|
69
|
+
satteriSandpack()
|
|
70
|
+
],
|
|
69
71
|
})
|
|
70
72
|
|
|
71
73
|
console.log(result.code)
|
|
@@ -87,7 +89,11 @@ export default defineConfig({
|
|
|
87
89
|
plugins: [
|
|
88
90
|
react(),
|
|
89
91
|
satteri({
|
|
90
|
-
mdastPlugins: [
|
|
92
|
+
mdastPlugins: [
|
|
93
|
+
satteriSandpack({
|
|
94
|
+
componentName: ['Playground']
|
|
95
|
+
})
|
|
96
|
+
],
|
|
91
97
|
}),
|
|
92
98
|
],
|
|
93
99
|
})
|
|
@@ -131,7 +137,9 @@ satteriSandpack()
|
|
|
131
137
|
Use `componentName` for a custom component:
|
|
132
138
|
|
|
133
139
|
```js
|
|
134
|
-
satteriSandpack({
|
|
140
|
+
satteriSandpack({
|
|
141
|
+
componentName: ['Playground']
|
|
142
|
+
})
|
|
135
143
|
```
|
|
136
144
|
|
|
137
145
|
Pass multiple names when the same document uses more than one wrapper:
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import "satteri";
|
|
2
|
-
//#region src/types.d.ts
|
|
3
2
|
interface SatteriSandpackOptions {
|
|
4
3
|
/**
|
|
5
4
|
* Specify one or more component names to transform.
|
|
@@ -8,11 +7,8 @@ interface SatteriSandpackOptions {
|
|
|
8
7
|
*/
|
|
9
8
|
componentName?: Array<string>;
|
|
10
9
|
}
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/transform.d.ts
|
|
13
10
|
export default function satteriSandpack(options?: Readonly<SatteriSandpackOptions>): {
|
|
14
11
|
name: string;
|
|
15
12
|
mdxJsxFlowElement(node: Readonly<import("satteri").MdxJsxFlowElement>): import("satteri").MdxJsxFlowElement | null;
|
|
16
13
|
};
|
|
17
|
-
//#endregion
|
|
18
14
|
export type { SatteriSandpackOptions as Options };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineMdastPlugin } from "satteri";
|
|
2
|
-
|
|
2
|
+
// src/utils.ts
|
|
3
3
|
const CODE_META_OPTIONS = [
|
|
4
4
|
"active",
|
|
5
5
|
"hidden",
|
|
@@ -14,8 +14,7 @@ const ERRORS = {
|
|
|
14
14
|
INVALID_META: (attr) => `Invalid meta attribute "${attr}" found in a code block inside <Sandpack> component. Be sure to use one of these valid attributes: ${CODE_META_OPTIONS.join(", ")}.`,
|
|
15
15
|
MISSING_NAME: "Code blocks inside <Sandpack> components must have a \"name\" attribute in their metadata."
|
|
16
16
|
};
|
|
17
|
-
|
|
18
|
-
//#region src/node.ts
|
|
17
|
+
// src/node.ts
|
|
19
18
|
function resolveCodeMeta(codeNode) {
|
|
20
19
|
if (!codeNode.meta?.trim()) throw new Error(ERRORS.EMPTY_META);
|
|
21
20
|
const meta = {};
|
|
@@ -58,8 +57,7 @@ function collectCodeFiles(node, files) {
|
|
|
58
57
|
}
|
|
59
58
|
if ("children" in node) for (const child of node.children) collectCodeFiles(child, files);
|
|
60
59
|
}
|
|
61
|
-
|
|
62
|
-
//#region src/transform.ts
|
|
60
|
+
// src/transform.ts
|
|
63
61
|
function satteriSandpack(options) {
|
|
64
62
|
const componentName = options?.componentName ?? ["Sandpack"];
|
|
65
63
|
return defineMdastPlugin({
|
|
@@ -70,5 +68,4 @@ function satteriSandpack(options) {
|
|
|
70
68
|
}
|
|
71
69
|
});
|
|
72
70
|
}
|
|
73
|
-
//#endregion
|
|
74
71
|
export { satteriSandpack as default };
|
package/package.json
CHANGED
|
@@ -1,75 +1,74 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
2
|
+
"name": "@lekoarts/satteri-sandpack",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "1.1.0",
|
|
5
|
+
"description": "Author Sandpack examples in MDX with Sätteri",
|
|
6
|
+
"author": "LekoArts",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"homepage": "https://github.com/LekoArts/satteri-sandpack#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/LekoArts/satteri-sandpack.git"
|
|
12
|
+
},
|
|
13
|
+
"bugs": {
|
|
14
|
+
"url": "https://github.com/LekoArts/satteri-sandpack/issues"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"satteri",
|
|
18
|
+
"sandpack",
|
|
19
|
+
"MDX"
|
|
20
|
+
],
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public"
|
|
23
|
+
},
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
".": {
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"import": "./dist/index.js",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./package.json": "./package.json"
|
|
32
|
+
},
|
|
33
|
+
"main": "./dist/index.js",
|
|
34
|
+
"module": "./dist/index.js",
|
|
35
|
+
"types": "./dist/index.d.ts",
|
|
36
|
+
"files": [
|
|
37
|
+
"dist"
|
|
38
|
+
],
|
|
39
|
+
"engines": {
|
|
40
|
+
"node": ">=22"
|
|
41
|
+
},
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"satteri": "^0.10.5 || ^0.11.0"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@antfu/eslint-config": "^10.0.0",
|
|
47
|
+
"@arethetypeswrong/cli": "^0.18.5",
|
|
48
|
+
"@changesets/changelog-github": "^1.0.1",
|
|
49
|
+
"@changesets/cli": "^3.0.3",
|
|
50
|
+
"@types/node": "^26.6.6",
|
|
51
|
+
"eslint": "^10.15.0",
|
|
52
|
+
"eslint-plugin-format": "^2.0.1",
|
|
53
|
+
"publint": "^0.3.25",
|
|
54
|
+
"satteri": "^0.11.7",
|
|
55
|
+
"tsdown": "^0.23.7",
|
|
56
|
+
"typescript": "npm:@typescript/typescript6@^6.0.2",
|
|
57
|
+
"typescript-7": "npm:typescript@^7.0.2",
|
|
58
|
+
"vitest": "^5.1.1"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"lint": "eslint",
|
|
62
|
+
"lint:fix": "eslint --fix",
|
|
63
|
+
"build": "tsdown",
|
|
64
|
+
"dev": "tsdown --watch",
|
|
65
|
+
"test": "vitest run",
|
|
66
|
+
"test:watch": "vitest watch",
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
68
|
+
"changeset": "changeset",
|
|
69
|
+
"version": "changeset version",
|
|
70
|
+
"version:ci": "changeset version && pnpm install --lockfile-only",
|
|
71
|
+
"release": "pnpm build && changeset publish",
|
|
72
|
+
"check": "publint && attw --pack . --profile esm-only"
|
|
73
|
+
}
|
|
74
|
+
}
|