@briancray/belte 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/LICENSE +21 -0
- package/README.md +49 -0
- package/bin/belte.ts +136 -0
- package/package.json +80 -0
- package/src/App.svelte +31 -0
- package/src/assets/app.html +14 -0
- package/src/belteResolverPlugin.ts +832 -0
- package/src/build.ts +144 -0
- package/src/buildCli.ts +160 -0
- package/src/cliEntry.ts +31 -0
- package/src/clientEntry.ts +7 -0
- package/src/compile.ts +64 -0
- package/src/devEntry.ts +33 -0
- package/src/discoveryEntry.ts +33 -0
- package/src/lib/browser/cache.ts +191 -0
- package/src/lib/browser/page.svelte.ts +215 -0
- package/src/lib/browser/remoteProxy.ts +44 -0
- package/src/lib/browser/socketChannel.ts +182 -0
- package/src/lib/browser/socketProxy.ts +64 -0
- package/src/lib/browser/startClient.ts +132 -0
- package/src/lib/browser/subscribe.ts +131 -0
- package/src/lib/browser/types/Layouts.ts +7 -0
- package/src/lib/browser/types/Pages.ts +7 -0
- package/src/lib/cli/createClient.ts +126 -0
- package/src/lib/cli/loadEnvFromBinaryDir.ts +44 -0
- package/src/lib/cli/parseArgvForRpc.ts +97 -0
- package/src/lib/cli/printHelp.ts +70 -0
- package/src/lib/cli/runCli.ts +88 -0
- package/src/lib/cli/types/CliManifest.ts +9 -0
- package/src/lib/cli/types/CliManifestEntry.ts +12 -0
- package/src/lib/mcp/createMcpResourceServer.ts +101 -0
- package/src/lib/mcp/createMcpServer.ts +40 -0
- package/src/lib/mcp/dispatchMcpRequest.ts +294 -0
- package/src/lib/mcp/mcpResourceServerSlot.ts +18 -0
- package/src/lib/mcp/types/JsonRpcRequest.ts +12 -0
- package/src/lib/mcp/types/JsonRpcResponse.ts +20 -0
- package/src/lib/mcp/types/McpResourceContents.ts +10 -0
- package/src/lib/mcp/types/McpResourceDescriptor.ts +6 -0
- package/src/lib/mcp/types/McpResourceServer.ts +12 -0
- package/src/lib/mcp/types/McpServer.ts +9 -0
- package/src/lib/mcp/types/McpServerOptions.ts +16 -0
- package/src/lib/server/AppModule.ts +25 -0
- package/src/lib/server/DELETE.ts +9 -0
- package/src/lib/server/GET.ts +9 -0
- package/src/lib/server/HEAD.ts +9 -0
- package/src/lib/server/HttpError.ts +19 -0
- package/src/lib/server/PATCH.ts +9 -0
- package/src/lib/server/POST.ts +9 -0
- package/src/lib/server/PUT.ts +9 -0
- package/src/lib/server/cli/buildEnvContent.ts +18 -0
- package/src/lib/server/cli/createTarGz.ts +76 -0
- package/src/lib/server/cli/handleCliDownload.ts +124 -0
- package/src/lib/server/cli/handleCliInstall.ts +20 -0
- package/src/lib/server/cli/installScript.ts +29 -0
- package/src/lib/server/cli/maxSourceMtime.ts +27 -0
- package/src/lib/server/error.ts +56 -0
- package/src/lib/server/json.ts +28 -0
- package/src/lib/server/jsonl.ts +40 -0
- package/src/lib/server/prompt.ts +30 -0
- package/src/lib/server/prompts/definePrompt.ts +20 -0
- package/src/lib/server/prompts/promptRegistry.ts +9 -0
- package/src/lib/server/prompts/registerPrompt.ts +6 -0
- package/src/lib/server/prompts/types/Prompt.ts +14 -0
- package/src/lib/server/prompts/types/PromptMessage.ts +10 -0
- package/src/lib/server/prompts/types/PromptOptions.ts +17 -0
- package/src/lib/server/prompts/types/PromptRegistryEntry.ts +15 -0
- package/src/lib/server/prompts/types/PromptRoutes.ts +10 -0
- package/src/lib/server/redirect.ts +37 -0
- package/src/lib/server/request.ts +18 -0
- package/src/lib/server/rpc/defineVerb.ts +103 -0
- package/src/lib/server/rpc/parseArgs.ts +60 -0
- package/src/lib/server/rpc/registerVerb.ts +6 -0
- package/src/lib/server/rpc/types/HttpVerb.ts +1 -0
- package/src/lib/server/rpc/types/RawRemoteFunction.ts +13 -0
- package/src/lib/server/rpc/types/RemoteFunction.ts +35 -0
- package/src/lib/server/rpc/types/RemoteHandler.ts +22 -0
- package/src/lib/server/rpc/types/RemoteRoutes.ts +13 -0
- package/src/lib/server/rpc/types/StandardSchemaV1.ts +57 -0
- package/src/lib/server/rpc/types/TypedResponse.ts +18 -0
- package/src/lib/server/rpc/types/VerbHelper.ts +39 -0
- package/src/lib/server/rpc/types/VerbRegistryEntry.ts +17 -0
- package/src/lib/server/rpc/unprocessed.ts +14 -0
- package/src/lib/server/rpc/verbRegistry.ts +11 -0
- package/src/lib/server/runtime/buildOpenApiSpec.ts +66 -0
- package/src/lib/server/runtime/cacheControlForAsset.ts +17 -0
- package/src/lib/server/runtime/containsTraversal.ts +37 -0
- package/src/lib/server/runtime/createPublicAssetServer.ts +66 -0
- package/src/lib/server/runtime/createServer.ts +555 -0
- package/src/lib/server/runtime/getActiveServer.ts +6 -0
- package/src/lib/server/runtime/mimeForExtension.ts +20 -0
- package/src/lib/server/runtime/registryManifests.ts +48 -0
- package/src/lib/server/runtime/requestContext.ts +5 -0
- package/src/lib/server/runtime/safeJsonForScript.ts +17 -0
- package/src/lib/server/runtime/serializeCacheSnapshot.ts +84 -0
- package/src/lib/server/runtime/serverSlot.ts +13 -0
- package/src/lib/server/runtime/setActiveServer.ts +6 -0
- package/src/lib/server/runtime/streamFromIterator.ts +76 -0
- package/src/lib/server/runtime/types/Assets.ts +1 -0
- package/src/lib/server/runtime/types/CompileTarget.ts +6 -0
- package/src/lib/server/runtime/types/RequestStore.ts +15 -0
- package/src/lib/server/runtime/types/SvelteConfig.ts +5 -0
- package/src/lib/server/server.ts +19 -0
- package/src/lib/server/socket.ts +31 -0
- package/src/lib/server/sockets/createSocketDispatcher.ts +267 -0
- package/src/lib/server/sockets/defineSocket.ts +160 -0
- package/src/lib/server/sockets/lookupSocket.ts +6 -0
- package/src/lib/server/sockets/registerSocket.ts +6 -0
- package/src/lib/server/sockets/socketRegistry.ts +9 -0
- package/src/lib/server/sockets/types/Socket.ts +21 -0
- package/src/lib/server/sockets/types/SocketClientFrame.ts +18 -0
- package/src/lib/server/sockets/types/SocketOptions.ts +22 -0
- package/src/lib/server/sockets/types/SocketRegistryEntry.ts +18 -0
- package/src/lib/server/sockets/types/SocketRoutes.ts +10 -0
- package/src/lib/server/sockets/types/SocketServerFrame.ts +15 -0
- package/src/lib/server/sse.ts +47 -0
- package/src/lib/shared/activeCacheStore.ts +20 -0
- package/src/lib/shared/buildRpcRequest.ts +61 -0
- package/src/lib/shared/cacheControlValues.ts +8 -0
- package/src/lib/shared/cacheStoreSlot.ts +16 -0
- package/src/lib/shared/canonicalJson.ts +24 -0
- package/src/lib/shared/commandNameForUrl.ts +17 -0
- package/src/lib/shared/createCacheStore.ts +42 -0
- package/src/lib/shared/createPushIterator.ts +77 -0
- package/src/lib/shared/createRemoteFunction.ts +89 -0
- package/src/lib/shared/decodeResponse.ts +47 -0
- package/src/lib/shared/detectTarget.ts +27 -0
- package/src/lib/shared/findExportCallSite.ts +479 -0
- package/src/lib/shared/forwardHeaders.ts +28 -0
- package/src/lib/shared/getRemoteMeta.ts +5 -0
- package/src/lib/shared/isDebugEnabled.ts +23 -0
- package/src/lib/shared/jsonSchemaForSchema.ts +38 -0
- package/src/lib/shared/keyForRemoteCall.ts +38 -0
- package/src/lib/shared/loadSvelteConfig.ts +18 -0
- package/src/lib/shared/log.ts +104 -0
- package/src/lib/shared/nearestLayoutPrefix.ts +36 -0
- package/src/lib/shared/normalizeTarget.ts +10 -0
- package/src/lib/shared/pageUrlForFile.ts +14 -0
- package/src/lib/shared/parseRouteSegments.ts +22 -0
- package/src/lib/shared/preparePromptModule.ts +36 -0
- package/src/lib/shared/prepareRpcModule.ts +51 -0
- package/src/lib/shared/prepareSocketModule.ts +37 -0
- package/src/lib/shared/programNameForPackage.ts +14 -0
- package/src/lib/shared/promptNameForFile.ts +10 -0
- package/src/lib/shared/recordRemoteMeta.ts +5 -0
- package/src/lib/shared/remoteMetaStore.ts +16 -0
- package/src/lib/shared/resolveClientFlags.ts +18 -0
- package/src/lib/shared/rpcUrlForFile.ts +19 -0
- package/src/lib/shared/setCacheStoreResolver.ts +6 -0
- package/src/lib/shared/socketNameForFile.ts +11 -0
- package/src/lib/shared/streamingContentTypes.ts +11 -0
- package/src/lib/shared/stripImport.ts +27 -0
- package/src/lib/shared/subscribableFromResponse.ts +333 -0
- package/src/lib/shared/toBunRoutePattern.ts +28 -0
- package/src/lib/shared/types/CacheEntry.ts +16 -0
- package/src/lib/shared/types/CacheOptions.ts +10 -0
- package/src/lib/shared/types/CacheSnapshotEntry.ts +15 -0
- package/src/lib/shared/types/CacheStore.ts +15 -0
- package/src/lib/shared/types/ClientFlags.ts +11 -0
- package/src/lib/shared/types/Subscribable.ts +15 -0
- package/src/lib/shared/writeRoutesDts.ts +64 -0
- package/src/preload.ts +20 -0
- package/src/scaffold.ts +92 -0
- package/src/serverEntry.ts +47 -0
- package/src/sveltePlugin.ts +58 -0
- package/src/tailwindStylePreprocessor.ts +62 -0
- package/template/package.json +16 -0
- package/template/src/app.ts +23 -0
- package/template/src/browser/app.css +21 -0
- package/template/src/browser/app.html +24 -0
- package/template/src/browser/pages/about/page.svelte +5 -0
- package/template/src/browser/pages/layout.svelte +26 -0
- package/template/src/browser/pages/page.svelte +20 -0
- package/template/src/cli/banner.txt +3 -0
- package/template/src/cli/footer.txt +1 -0
- package/template/src/server/rpc/getHello.ts +33 -0
- package/template/svelte.config.js +12 -0
- package/template/tsconfig.json +18 -0
- package/tsconfig.app.json +16 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Brian Cray
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# @briancray/belte
|
|
2
|
+
|
|
3
|
+
Isomorphic multimodal HTTP framework built for humans and machines in a single [Bun](https://bun.sh) runtime.
|
|
4
|
+
|
|
5
|
+
Declare a backend once and it answers on every surface. Humans reach it through the web
|
|
6
|
+
(server-rendered Svelte) and the command line; machines reach it through MCP and the command line.
|
|
7
|
+
The bundler swaps the runtime per target — the call site, name, and behaviour stay identical.
|
|
8
|
+
|
|
9
|
+
> **Requires Bun ≥ 1.3.** Modules are shipped as TypeScript and consumed directly by Bun.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
bun add @briancray/belte
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`svelte` is a peer dependency; `tailwindcss` and `bun-plugin-tailwind` are optional peers.
|
|
18
|
+
|
|
19
|
+
## At a glance
|
|
20
|
+
|
|
21
|
+
Declare a remote function once:
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// src/server/rpc/getOrder.ts
|
|
25
|
+
import { GET } from '@briancray/belte/server/GET'
|
|
26
|
+
import { json } from '@briancray/belte/server/json'
|
|
27
|
+
|
|
28
|
+
export const getOrder = GET<{ id: string }>(async ({ id }) => json(await db.getOrder(id)))
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Consume the same `getOrder` from each client:
|
|
32
|
+
|
|
33
|
+
| Surface | How it is exposed | Call |
|
|
34
|
+
| --- | --- | --- |
|
|
35
|
+
| Browser / HTTP | function + `GET /rpc/getOrder?id=…` | `await getOrder({ id })` |
|
|
36
|
+
| MCP | tool `getOrder` (with a schema) | `tools/call { name: "getOrder", arguments: { id } }` |
|
|
37
|
+
| CLI | subcommand `getOrder` (with a schema) | `app getOrder --id 7` |
|
|
38
|
+
|
|
39
|
+
Browser exposure is always on; MCP and CLI flip on automatically when a declaration carries a
|
|
40
|
+
validation schema.
|
|
41
|
+
|
|
42
|
+
## Documentation
|
|
43
|
+
|
|
44
|
+
Full docs, the API reference, and runnable examples live in the
|
|
45
|
+
[repository README](https://github.com/briancray/belte#readme).
|
|
46
|
+
|
|
47
|
+
## License
|
|
48
|
+
|
|
49
|
+
[MIT](./LICENSE) © Brian Cray
|
package/bin/belte.ts
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { build } from '../src/build.ts'
|
|
3
|
+
import { buildCli } from '../src/buildCli.ts'
|
|
4
|
+
import { compile } from '../src/compile.ts'
|
|
5
|
+
import { normalizeTarget } from '../src/lib/shared/normalizeTarget.ts'
|
|
6
|
+
import { scaffold } from '../src/scaffold.ts'
|
|
7
|
+
|
|
8
|
+
const PRELOAD = new URL('../src/preload.ts', import.meta.url).pathname
|
|
9
|
+
const SERVER_ENTRY = new URL('../src/serverEntry.ts', import.meta.url).pathname
|
|
10
|
+
const DEV_ENTRY = new URL('../src/devEntry.ts', import.meta.url).pathname
|
|
11
|
+
const cwd = process.cwd()
|
|
12
|
+
const [, , command, ...rest] = process.argv
|
|
13
|
+
|
|
14
|
+
// Reads `--name=value` or `--name value` from the trailing argv tail.
|
|
15
|
+
function parseFlag(name: string): string | undefined {
|
|
16
|
+
const prefix = `--${name}=`
|
|
17
|
+
const match = rest.find((arg) => arg.startsWith(prefix))
|
|
18
|
+
if (match) {
|
|
19
|
+
return match.slice(prefix.length)
|
|
20
|
+
}
|
|
21
|
+
const index = rest.indexOf(`--${name}`)
|
|
22
|
+
if (index !== -1 && index + 1 < rest.length) {
|
|
23
|
+
return rest[index + 1]
|
|
24
|
+
}
|
|
25
|
+
return undefined
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/*
|
|
29
|
+
Spawns the server under `bun --watch` against the dev entry. The dev entry
|
|
30
|
+
re-runs the client build and eagerly imports every page/layout/rpc/socket
|
|
31
|
+
module on each boot, so Bun's watcher sees them from the start and
|
|
32
|
+
restarts the whole process whenever any file in the graph changes. The
|
|
33
|
+
browser is not auto-reloaded — refresh manually after the server is back.
|
|
34
|
+
*/
|
|
35
|
+
async function dev(): Promise<void> {
|
|
36
|
+
const child = Bun.spawn({
|
|
37
|
+
cmd: ['bun', '--watch', '--preload', PRELOAD, DEV_ENTRY],
|
|
38
|
+
cwd,
|
|
39
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
40
|
+
})
|
|
41
|
+
process.exit(await child.exited)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Performs a single client build with no server attached (for CI / static deploys).
|
|
45
|
+
async function buildOnce(): Promise<void> {
|
|
46
|
+
await build({ cwd })
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Starts the production server against an already-built dist directory.
|
|
50
|
+
// Awaits the child process so the parent's exit code mirrors the server's.
|
|
51
|
+
async function start(): Promise<void> {
|
|
52
|
+
const child = Bun.spawn({
|
|
53
|
+
cmd: ['bun', '--preload', PRELOAD, SERVER_ENTRY],
|
|
54
|
+
cwd,
|
|
55
|
+
stdio: ['inherit', 'inherit', 'inherit'],
|
|
56
|
+
})
|
|
57
|
+
process.exit(await child.exited)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Parses the --target and --out flags and produces a standalone executable.
|
|
61
|
+
async function compileCmd(): Promise<void> {
|
|
62
|
+
const targetFlag = parseFlag('target')
|
|
63
|
+
const outFlag = parseFlag('out')
|
|
64
|
+
await compile({
|
|
65
|
+
cwd,
|
|
66
|
+
target: targetFlag ? normalizeTarget(targetFlag) : undefined,
|
|
67
|
+
outfile: outFlag,
|
|
68
|
+
})
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Builds the standalone CLI binary. Defaults to full (backend embedded, runs
|
|
72
|
+
// locally); `--thin` builds the remote client (manifest only, needs APP_URL
|
|
73
|
+
// at runtime). Discovery walks the rpc registry to bake the manifest in.
|
|
74
|
+
// `--platforms a,b,c` cross-compiles per target — thin binaries land in
|
|
75
|
+
// dist/cli-thin/<platform>/ (the layout the /__belte/cli download endpoint
|
|
76
|
+
// streams), full binaries in dist/cli/<platform>/.
|
|
77
|
+
async function cliCmd(): Promise<void> {
|
|
78
|
+
const targetFlag = parseFlag('target')
|
|
79
|
+
const outFlag = parseFlag('out')
|
|
80
|
+
const platformsFlag = parseFlag('platforms')
|
|
81
|
+
const thin = rest.includes('--thin')
|
|
82
|
+
const platforms = platformsFlag
|
|
83
|
+
? platformsFlag.split(',').map((value) => normalizeTarget(value.trim()))
|
|
84
|
+
: undefined
|
|
85
|
+
await buildCli({
|
|
86
|
+
cwd,
|
|
87
|
+
target: targetFlag ? normalizeTarget(targetFlag) : undefined,
|
|
88
|
+
outfile: outFlag,
|
|
89
|
+
platforms,
|
|
90
|
+
thin,
|
|
91
|
+
})
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Scaffolds the bundled template into a new project directory.
|
|
95
|
+
async function scaffoldCmd(): Promise<void> {
|
|
96
|
+
const name = rest.find((arg) => !arg.startsWith('--'))
|
|
97
|
+
if (!name) {
|
|
98
|
+
console.error('usage: bunx belte scaffold <project-name>')
|
|
99
|
+
process.exit(1)
|
|
100
|
+
}
|
|
101
|
+
await scaffold({ cwd, name })
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Prints the CLI synopsis to stderr and exits non-zero. Marked `never` because the process is gone.
|
|
105
|
+
function usage(): never {
|
|
106
|
+
console.error(
|
|
107
|
+
'usage:\n' +
|
|
108
|
+
' bunx belte scaffold <project-name> scaffold a new belte project\n' +
|
|
109
|
+
' belte dev build + run with hot reload\n' +
|
|
110
|
+
' belte build build the client into dist/_app/\n' +
|
|
111
|
+
' belte start run the production server against dist/\n' +
|
|
112
|
+
' belte compile [--target=<bun-...>] [--out=<path>]\n' +
|
|
113
|
+
' build a standalone server executable\n' +
|
|
114
|
+
' belte cli [--thin] [--target=<bun-...>] [--out=<path>] [--platforms=<a,b,c>]\n' +
|
|
115
|
+
' build the cli binary (full by default — runs\n' +
|
|
116
|
+
' locally; --thin builds the remote client;\n' +
|
|
117
|
+
' --platforms cross-compiles per platform)',
|
|
118
|
+
)
|
|
119
|
+
process.exit(1)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (command === 'scaffold') {
|
|
123
|
+
await scaffoldCmd()
|
|
124
|
+
} else if (command === 'dev') {
|
|
125
|
+
await dev()
|
|
126
|
+
} else if (command === 'build') {
|
|
127
|
+
await buildOnce()
|
|
128
|
+
} else if (command === 'start') {
|
|
129
|
+
await start()
|
|
130
|
+
} else if (command === 'compile') {
|
|
131
|
+
await compileCmd()
|
|
132
|
+
} else if (command === 'cli') {
|
|
133
|
+
await cliCmd()
|
|
134
|
+
} else {
|
|
135
|
+
usage()
|
|
136
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@briancray/belte",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Isomorphic multimodal HTTP framework built for humans and machines in a single Bun runtime",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "Brian Cray",
|
|
8
|
+
"homepage": "https://github.com/briancray/belte#readme",
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "git+https://github.com/briancray/belte.git",
|
|
12
|
+
"directory": "packages/belte"
|
|
13
|
+
},
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/briancray/belte/issues"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"bun",
|
|
19
|
+
"svelte",
|
|
20
|
+
"ssr",
|
|
21
|
+
"spa",
|
|
22
|
+
"framework",
|
|
23
|
+
"isomorphic",
|
|
24
|
+
"rpc",
|
|
25
|
+
"mcp",
|
|
26
|
+
"cli"
|
|
27
|
+
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"bun": ">=1.3.0"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"access": "public",
|
|
33
|
+
"provenance": true
|
|
34
|
+
},
|
|
35
|
+
"exports": {
|
|
36
|
+
"./server/*": "./src/lib/server/*.ts",
|
|
37
|
+
"./server/rpc/*": "./src/lib/server/rpc/*.ts",
|
|
38
|
+
"./server/sockets/*": "./src/lib/server/sockets/*.ts",
|
|
39
|
+
"./server/prompts/*": "./src/lib/server/prompts/*.ts",
|
|
40
|
+
"./browser/*": "./src/lib/browser/*.ts",
|
|
41
|
+
"./browser/page": "./src/lib/browser/page.svelte.ts",
|
|
42
|
+
"./browser/navigate": "./src/lib/browser/page.svelte.ts",
|
|
43
|
+
"./browser/HttpError": "./src/lib/server/HttpError.ts",
|
|
44
|
+
"./mcp/*": "./src/lib/mcp/*.ts",
|
|
45
|
+
"./cli/*": "./src/lib/cli/*.ts",
|
|
46
|
+
"./shared/*": "./src/lib/shared/*.ts",
|
|
47
|
+
"./build": "./src/build.ts",
|
|
48
|
+
"./compile": "./src/compile.ts",
|
|
49
|
+
"./preload": "./src/preload.ts",
|
|
50
|
+
"./svelte-plugin": "./src/sveltePlugin.ts",
|
|
51
|
+
"./resolver-plugin": "./src/belteResolverPlugin.ts",
|
|
52
|
+
"./tsconfig": "./tsconfig.app.json"
|
|
53
|
+
},
|
|
54
|
+
"bin": {
|
|
55
|
+
"belte": "./bin/belte.ts"
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"src",
|
|
59
|
+
"bin",
|
|
60
|
+
"template",
|
|
61
|
+
"tsconfig.app.json"
|
|
62
|
+
],
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"svelte": "^5.0.0",
|
|
65
|
+
"bun-plugin-tailwind": "*",
|
|
66
|
+
"tailwindcss": "^4.0.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"bun-plugin-tailwind": {
|
|
70
|
+
"optional": true
|
|
71
|
+
},
|
|
72
|
+
"tailwindcss": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
"devDependencies": {
|
|
77
|
+
"bun-plugin-tailwind": "latest",
|
|
78
|
+
"tailwindcss": "^4.0.0"
|
|
79
|
+
}
|
|
80
|
+
}
|
package/src/App.svelte
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Component } from 'svelte'
|
|
3
|
+
import type { Page as PageState } from './lib/browser/page.svelte.ts'
|
|
4
|
+
|
|
5
|
+
let {
|
|
6
|
+
state,
|
|
7
|
+
}: {
|
|
8
|
+
state: {
|
|
9
|
+
page: PageState
|
|
10
|
+
render: { Layout: Component | undefined; Page: Component | undefined }
|
|
11
|
+
}
|
|
12
|
+
} = $props()
|
|
13
|
+
|
|
14
|
+
let Layout = $derived(state.render.Layout)
|
|
15
|
+
let PageView = $derived(state.render.Page)
|
|
16
|
+
let params = $derived(state.page.params)
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
{#if Layout}
|
|
20
|
+
<Layout>
|
|
21
|
+
{#if PageView}
|
|
22
|
+
{#key PageView}
|
|
23
|
+
<PageView {...params} />
|
|
24
|
+
{/key}
|
|
25
|
+
{/if}
|
|
26
|
+
</Layout>
|
|
27
|
+
{:else if PageView}
|
|
28
|
+
{#key PageView}
|
|
29
|
+
<PageView {...params} />
|
|
30
|
+
{/key}
|
|
31
|
+
{/if}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<link rel="stylesheet" href="/_app/client.css" />
|
|
7
|
+
<!--ssr:head-->
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
<div id="app"><!--ssr:body--></div>
|
|
11
|
+
<!--ssr:state-->
|
|
12
|
+
<script type="module" src="/_app/client.js"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|