next-live 0.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/CHANGELOG.md +33 -0
- package/LICENSE +21 -0
- package/README.md +142 -0
- package/dist/editor.cjs +247 -0
- package/dist/editor.cjs.map +1 -0
- package/dist/editor.d.cts +80 -0
- package/dist/editor.d.ts +80 -0
- package/dist/editor.js +225 -0
- package/dist/editor.js.map +1 -0
- package/dist/index.cjs +1265 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +580 -0
- package/dist/index.d.ts +580 -0
- package/dist/index.js +1192 -0
- package/dist/index.js.map +1 -0
- package/dist/server.cjs +287 -0
- package/dist/server.cjs.map +1 -0
- package/dist/server.d.cts +142 -0
- package/dist/server.d.ts +142 -0
- package/dist/server.js +282 -0
- package/dist/server.js.map +1 -0
- package/dist/shared.js +30 -0
- package/dist/shared.js.map +1 -0
- package/docs/01-getting-started.md +244 -0
- package/docs/02-module-registry.md +487 -0
- package/docs/03-sharing-your-app-libraries.md +206 -0
- package/docs/04-scaling.md +234 -0
- package/docs/05-security.md +204 -0
- package/docs/06-api-reference.md +337 -0
- package/docs/07-troubleshooting.md +289 -0
- package/docs/08-integration-guide.md +340 -0
- package/docs/09-non-ui-snippets.md +124 -0
- package/docs/10-validating-in-ci.md +192 -0
- package/docs/README.md +76 -0
- package/package.json +105 -0
package/docs/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
# next-live documentation
|
|
2
|
+
|
|
3
|
+
Live TSX/JSX evaluation for React, SSR-safe and tuned for the Next.js App Router.
|
|
4
|
+
|
|
5
|
+
## Guides
|
|
6
|
+
|
|
7
|
+
| | |
|
|
8
|
+
|---|---|
|
|
9
|
+
| **[1. Getting started](./01-getting-started.md)** | Install, and a working live preview in four steps. |
|
|
10
|
+
| **[2. The module registry](./02-module-registry.md)** | How `import` resolves. The core concept, read this second. |
|
|
11
|
+
| **[3. Sharing libraries with your app](./03-sharing-your-app-libraries.md)** | Your app and your snippets both use the same library. Is that two copies? (No.) |
|
|
12
|
+
| **[4. Scaling to many apps](./04-scaling.md)** | Keeping the bundle small with hundreds of snippets and a large SDK. |
|
|
13
|
+
| **[5. Security](./05-security.md)** | The trust model, and the CSP you need. **Read before deploying.** |
|
|
14
|
+
| **[6. API reference](./06-api-reference.md)** | Every export, prop, and type. |
|
|
15
|
+
| **[7. Troubleshooting](./07-troubleshooting.md)** | Real error messages and their fixes. |
|
|
16
|
+
| **[8. Integration guide](./08-integration-guide.md)** | End-to-end: apps stored in a database, authored in a control panel. |
|
|
17
|
+
| **[9. Snippets that are not components](./09-non-ui-snippets.md)** | Validators, transformers, config, code with no UI. |
|
|
18
|
+
| **[10. Validating stored snippets in CI](./10-validating-in-ci.md)** | Catch an SDK rename breaking stored apps before your users do. |
|
|
19
|
+
|
|
20
|
+
## Where to start
|
|
21
|
+
|
|
22
|
+
- **New here?** [Getting started](./01-getting-started.md), then
|
|
23
|
+
[the module registry](./02-module-registry.md).
|
|
24
|
+
- **Adding this to a real application?** Jump to the
|
|
25
|
+
[integration guide](./08-integration-guide.md), then try the live
|
|
26
|
+
**`/apps` shell demo** in the playground repository.
|
|
27
|
+
- **Something is broken?** [Troubleshooting](./07-troubleshooting.md).
|
|
28
|
+
- **About to deploy?** [Security](./05-security.md), it takes ten minutes and
|
|
29
|
+
covers the one rule that actually protects you.
|
|
30
|
+
|
|
31
|
+
## Frequently asked
|
|
32
|
+
|
|
33
|
+
**Does `import` work for any package?**
|
|
34
|
+
Only what you register. There is no npm in the browser, see
|
|
35
|
+
[the module registry](./02-module-registry.md).
|
|
36
|
+
|
|
37
|
+
**My app already uses the same library. Two copies?**
|
|
38
|
+
No, one instance, which is why a shared store really is shared.
|
|
39
|
+
[Details and the cases that break it](./03-sharing-your-app-libraries.md).
|
|
40
|
+
|
|
41
|
+
**Do I need `'unsafe-eval'` in production?**
|
|
42
|
+
Yes, but scoped to the routes that run snippets, not your whole app.
|
|
43
|
+
[Security](./05-security.md).
|
|
44
|
+
|
|
45
|
+
**Will this bloat my bundle?**
|
|
46
|
+
No. A page that only runs snippets pays **16.1 KB** - the editor and its syntax
|
|
47
|
+
highlighter live on a separate entry (`next-live/editor`), and the transpiler is
|
|
48
|
+
a lazily-fetched chunk. Registering modules as loaders keeps your own
|
|
49
|
+
dependencies out of the page too: measured 827 KB → 666 KB.
|
|
50
|
+
[Scaling](./04-scaling.md).
|
|
51
|
+
|
|
52
|
+
**Are TypeScript types checked?**
|
|
53
|
+
No. They are stripped, not verified -
|
|
54
|
+
[why](./07-troubleshooting.md#my-typescript-errors-are-not-reported).
|
|
55
|
+
|
|
56
|
+
**Do I need `next/dynamic` with `ssr: false`?**
|
|
57
|
+
No. It is already SSR-safe.
|
|
58
|
+
[How](./01-getting-started.md#ssr-and-hydration).
|
|
59
|
+
|
|
60
|
+
**Does this require Next.js?**
|
|
61
|
+
No. The library imports only React, it works in Vite, CRA, Remix, or anywhere
|
|
62
|
+
React runs. The name reflects where it was designed, not what it needs.
|
|
63
|
+
|
|
64
|
+
**Can a snippet export something other than a component?**
|
|
65
|
+
Yes, `useLiveModule` returns raw exports.
|
|
66
|
+
[Non-UI snippets](./09-non-ui-snippets.md).
|
|
67
|
+
|
|
68
|
+
**How do I know when I break my stored apps?**
|
|
69
|
+
Validate them in CI.
|
|
70
|
+
[Validating in CI](./10-validating-in-ci.md).
|
|
71
|
+
|
|
72
|
+
**Do React hooks and Tailwind work in snippets?**
|
|
73
|
+
Hooks yes, snippets share your React instance.
|
|
74
|
+
[Troubleshooting: hooks](./07-troubleshooting.md#do-react-hooks-work-in-snippets).
|
|
75
|
+
Tailwind only through registered UI components or an explicit safelist -
|
|
76
|
+
[Module registry: styling](./02-module-registry.md#styling-and-tailwind).
|
package/package.json
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "next-live",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Live TSX/JSX evaluation for React \u2014 real ESM imports, a module registry instead of a global scope, and zero hydration mismatches. Works anywhere React runs, SSR-safe and tuned for the Next.js App Router.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"next",
|
|
8
|
+
"nextjs",
|
|
9
|
+
"app-router",
|
|
10
|
+
"live",
|
|
11
|
+
"react-live",
|
|
12
|
+
"playground",
|
|
13
|
+
"sucrase",
|
|
14
|
+
"jsx",
|
|
15
|
+
"tsx",
|
|
16
|
+
"editor",
|
|
17
|
+
"eval",
|
|
18
|
+
"ssr",
|
|
19
|
+
"vite",
|
|
20
|
+
"live-code",
|
|
21
|
+
"code-editor",
|
|
22
|
+
"react-19"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"author": "Khaled Oghli",
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/khaledOghli/next-live.git",
|
|
29
|
+
"directory": "packages/next-live"
|
|
30
|
+
},
|
|
31
|
+
"homepage": "https://github.com/khaledOghli/next-live#readme",
|
|
32
|
+
"bugs": {
|
|
33
|
+
"url": "https://github.com/khaledOghli/next-live/issues"
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"provenance": true
|
|
38
|
+
},
|
|
39
|
+
"sideEffects": false,
|
|
40
|
+
"type": "module",
|
|
41
|
+
"main": "./dist/index.cjs",
|
|
42
|
+
"module": "./dist/index.js",
|
|
43
|
+
"types": "./dist/index.d.ts",
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"types": "./dist/index.d.ts",
|
|
47
|
+
"import": "./dist/index.js",
|
|
48
|
+
"require": "./dist/index.cjs"
|
|
49
|
+
},
|
|
50
|
+
"./editor": {
|
|
51
|
+
"types": "./dist/editor.d.ts",
|
|
52
|
+
"import": "./dist/editor.js",
|
|
53
|
+
"require": "./dist/editor.cjs"
|
|
54
|
+
},
|
|
55
|
+
"./server": {
|
|
56
|
+
"types": "./dist/server.d.ts",
|
|
57
|
+
"import": "./dist/server.js",
|
|
58
|
+
"require": "./dist/server.cjs"
|
|
59
|
+
},
|
|
60
|
+
"./package.json": "./package.json"
|
|
61
|
+
},
|
|
62
|
+
"files": [
|
|
63
|
+
"dist",
|
|
64
|
+
"docs",
|
|
65
|
+
"CHANGELOG.md"
|
|
66
|
+
],
|
|
67
|
+
"scripts": {
|
|
68
|
+
"prepublishOnly": "npm run build && npm test",
|
|
69
|
+
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsup && node scripts/add-use-client.mjs",
|
|
70
|
+
"dev": "tsup --watch --onSuccess \"node scripts/add-use-client.mjs\"",
|
|
71
|
+
"typecheck": "tsc --noEmit",
|
|
72
|
+
"test": "vitest run",
|
|
73
|
+
"test:node": "vitest run --exclude '**/*.test.tsx'",
|
|
74
|
+
"test:watch": "vitest"
|
|
75
|
+
},
|
|
76
|
+
"dependencies": {
|
|
77
|
+
"sucrase": "^3.35.1"
|
|
78
|
+
},
|
|
79
|
+
"peerDependencies": {
|
|
80
|
+
"react": ">=19",
|
|
81
|
+
"react-dom": ">=19",
|
|
82
|
+
"prism-react-renderer": ">=2"
|
|
83
|
+
},
|
|
84
|
+
"devDependencies": {
|
|
85
|
+
"@testing-library/dom": "^10.4.1",
|
|
86
|
+
"@testing-library/react": "^16.3.3",
|
|
87
|
+
"@types/react": "^19",
|
|
88
|
+
"@types/react-dom": "^19",
|
|
89
|
+
"jsdom": "^30.0.1",
|
|
90
|
+
"react": "^19.2.8",
|
|
91
|
+
"react-dom": "^19.2.8",
|
|
92
|
+
"tsup": "^8.5.1",
|
|
93
|
+
"typescript": "^5.9.3",
|
|
94
|
+
"vitest": "^5.0.0",
|
|
95
|
+
"prism-react-renderer": "^2.4.1"
|
|
96
|
+
},
|
|
97
|
+
"engines": {
|
|
98
|
+
"node": ">=20.9"
|
|
99
|
+
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"prism-react-renderer": {
|
|
102
|
+
"optional": true
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|