@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.
Files changed (178) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/bin/belte.ts +136 -0
  4. package/package.json +80 -0
  5. package/src/App.svelte +31 -0
  6. package/src/assets/app.html +14 -0
  7. package/src/belteResolverPlugin.ts +832 -0
  8. package/src/build.ts +144 -0
  9. package/src/buildCli.ts +160 -0
  10. package/src/cliEntry.ts +31 -0
  11. package/src/clientEntry.ts +7 -0
  12. package/src/compile.ts +64 -0
  13. package/src/devEntry.ts +33 -0
  14. package/src/discoveryEntry.ts +33 -0
  15. package/src/lib/browser/cache.ts +191 -0
  16. package/src/lib/browser/page.svelte.ts +215 -0
  17. package/src/lib/browser/remoteProxy.ts +44 -0
  18. package/src/lib/browser/socketChannel.ts +182 -0
  19. package/src/lib/browser/socketProxy.ts +64 -0
  20. package/src/lib/browser/startClient.ts +132 -0
  21. package/src/lib/browser/subscribe.ts +131 -0
  22. package/src/lib/browser/types/Layouts.ts +7 -0
  23. package/src/lib/browser/types/Pages.ts +7 -0
  24. package/src/lib/cli/createClient.ts +126 -0
  25. package/src/lib/cli/loadEnvFromBinaryDir.ts +44 -0
  26. package/src/lib/cli/parseArgvForRpc.ts +97 -0
  27. package/src/lib/cli/printHelp.ts +70 -0
  28. package/src/lib/cli/runCli.ts +88 -0
  29. package/src/lib/cli/types/CliManifest.ts +9 -0
  30. package/src/lib/cli/types/CliManifestEntry.ts +12 -0
  31. package/src/lib/mcp/createMcpResourceServer.ts +101 -0
  32. package/src/lib/mcp/createMcpServer.ts +40 -0
  33. package/src/lib/mcp/dispatchMcpRequest.ts +294 -0
  34. package/src/lib/mcp/mcpResourceServerSlot.ts +18 -0
  35. package/src/lib/mcp/types/JsonRpcRequest.ts +12 -0
  36. package/src/lib/mcp/types/JsonRpcResponse.ts +20 -0
  37. package/src/lib/mcp/types/McpResourceContents.ts +10 -0
  38. package/src/lib/mcp/types/McpResourceDescriptor.ts +6 -0
  39. package/src/lib/mcp/types/McpResourceServer.ts +12 -0
  40. package/src/lib/mcp/types/McpServer.ts +9 -0
  41. package/src/lib/mcp/types/McpServerOptions.ts +16 -0
  42. package/src/lib/server/AppModule.ts +25 -0
  43. package/src/lib/server/DELETE.ts +9 -0
  44. package/src/lib/server/GET.ts +9 -0
  45. package/src/lib/server/HEAD.ts +9 -0
  46. package/src/lib/server/HttpError.ts +19 -0
  47. package/src/lib/server/PATCH.ts +9 -0
  48. package/src/lib/server/POST.ts +9 -0
  49. package/src/lib/server/PUT.ts +9 -0
  50. package/src/lib/server/cli/buildEnvContent.ts +18 -0
  51. package/src/lib/server/cli/createTarGz.ts +76 -0
  52. package/src/lib/server/cli/handleCliDownload.ts +124 -0
  53. package/src/lib/server/cli/handleCliInstall.ts +20 -0
  54. package/src/lib/server/cli/installScript.ts +29 -0
  55. package/src/lib/server/cli/maxSourceMtime.ts +27 -0
  56. package/src/lib/server/error.ts +56 -0
  57. package/src/lib/server/json.ts +28 -0
  58. package/src/lib/server/jsonl.ts +40 -0
  59. package/src/lib/server/prompt.ts +30 -0
  60. package/src/lib/server/prompts/definePrompt.ts +20 -0
  61. package/src/lib/server/prompts/promptRegistry.ts +9 -0
  62. package/src/lib/server/prompts/registerPrompt.ts +6 -0
  63. package/src/lib/server/prompts/types/Prompt.ts +14 -0
  64. package/src/lib/server/prompts/types/PromptMessage.ts +10 -0
  65. package/src/lib/server/prompts/types/PromptOptions.ts +17 -0
  66. package/src/lib/server/prompts/types/PromptRegistryEntry.ts +15 -0
  67. package/src/lib/server/prompts/types/PromptRoutes.ts +10 -0
  68. package/src/lib/server/redirect.ts +37 -0
  69. package/src/lib/server/request.ts +18 -0
  70. package/src/lib/server/rpc/defineVerb.ts +103 -0
  71. package/src/lib/server/rpc/parseArgs.ts +60 -0
  72. package/src/lib/server/rpc/registerVerb.ts +6 -0
  73. package/src/lib/server/rpc/types/HttpVerb.ts +1 -0
  74. package/src/lib/server/rpc/types/RawRemoteFunction.ts +13 -0
  75. package/src/lib/server/rpc/types/RemoteFunction.ts +35 -0
  76. package/src/lib/server/rpc/types/RemoteHandler.ts +22 -0
  77. package/src/lib/server/rpc/types/RemoteRoutes.ts +13 -0
  78. package/src/lib/server/rpc/types/StandardSchemaV1.ts +57 -0
  79. package/src/lib/server/rpc/types/TypedResponse.ts +18 -0
  80. package/src/lib/server/rpc/types/VerbHelper.ts +39 -0
  81. package/src/lib/server/rpc/types/VerbRegistryEntry.ts +17 -0
  82. package/src/lib/server/rpc/unprocessed.ts +14 -0
  83. package/src/lib/server/rpc/verbRegistry.ts +11 -0
  84. package/src/lib/server/runtime/buildOpenApiSpec.ts +66 -0
  85. package/src/lib/server/runtime/cacheControlForAsset.ts +17 -0
  86. package/src/lib/server/runtime/containsTraversal.ts +37 -0
  87. package/src/lib/server/runtime/createPublicAssetServer.ts +66 -0
  88. package/src/lib/server/runtime/createServer.ts +555 -0
  89. package/src/lib/server/runtime/getActiveServer.ts +6 -0
  90. package/src/lib/server/runtime/mimeForExtension.ts +20 -0
  91. package/src/lib/server/runtime/registryManifests.ts +48 -0
  92. package/src/lib/server/runtime/requestContext.ts +5 -0
  93. package/src/lib/server/runtime/safeJsonForScript.ts +17 -0
  94. package/src/lib/server/runtime/serializeCacheSnapshot.ts +84 -0
  95. package/src/lib/server/runtime/serverSlot.ts +13 -0
  96. package/src/lib/server/runtime/setActiveServer.ts +6 -0
  97. package/src/lib/server/runtime/streamFromIterator.ts +76 -0
  98. package/src/lib/server/runtime/types/Assets.ts +1 -0
  99. package/src/lib/server/runtime/types/CompileTarget.ts +6 -0
  100. package/src/lib/server/runtime/types/RequestStore.ts +15 -0
  101. package/src/lib/server/runtime/types/SvelteConfig.ts +5 -0
  102. package/src/lib/server/server.ts +19 -0
  103. package/src/lib/server/socket.ts +31 -0
  104. package/src/lib/server/sockets/createSocketDispatcher.ts +267 -0
  105. package/src/lib/server/sockets/defineSocket.ts +160 -0
  106. package/src/lib/server/sockets/lookupSocket.ts +6 -0
  107. package/src/lib/server/sockets/registerSocket.ts +6 -0
  108. package/src/lib/server/sockets/socketRegistry.ts +9 -0
  109. package/src/lib/server/sockets/types/Socket.ts +21 -0
  110. package/src/lib/server/sockets/types/SocketClientFrame.ts +18 -0
  111. package/src/lib/server/sockets/types/SocketOptions.ts +22 -0
  112. package/src/lib/server/sockets/types/SocketRegistryEntry.ts +18 -0
  113. package/src/lib/server/sockets/types/SocketRoutes.ts +10 -0
  114. package/src/lib/server/sockets/types/SocketServerFrame.ts +15 -0
  115. package/src/lib/server/sse.ts +47 -0
  116. package/src/lib/shared/activeCacheStore.ts +20 -0
  117. package/src/lib/shared/buildRpcRequest.ts +61 -0
  118. package/src/lib/shared/cacheControlValues.ts +8 -0
  119. package/src/lib/shared/cacheStoreSlot.ts +16 -0
  120. package/src/lib/shared/canonicalJson.ts +24 -0
  121. package/src/lib/shared/commandNameForUrl.ts +17 -0
  122. package/src/lib/shared/createCacheStore.ts +42 -0
  123. package/src/lib/shared/createPushIterator.ts +77 -0
  124. package/src/lib/shared/createRemoteFunction.ts +89 -0
  125. package/src/lib/shared/decodeResponse.ts +47 -0
  126. package/src/lib/shared/detectTarget.ts +27 -0
  127. package/src/lib/shared/findExportCallSite.ts +479 -0
  128. package/src/lib/shared/forwardHeaders.ts +28 -0
  129. package/src/lib/shared/getRemoteMeta.ts +5 -0
  130. package/src/lib/shared/isDebugEnabled.ts +23 -0
  131. package/src/lib/shared/jsonSchemaForSchema.ts +38 -0
  132. package/src/lib/shared/keyForRemoteCall.ts +38 -0
  133. package/src/lib/shared/loadSvelteConfig.ts +18 -0
  134. package/src/lib/shared/log.ts +104 -0
  135. package/src/lib/shared/nearestLayoutPrefix.ts +36 -0
  136. package/src/lib/shared/normalizeTarget.ts +10 -0
  137. package/src/lib/shared/pageUrlForFile.ts +14 -0
  138. package/src/lib/shared/parseRouteSegments.ts +22 -0
  139. package/src/lib/shared/preparePromptModule.ts +36 -0
  140. package/src/lib/shared/prepareRpcModule.ts +51 -0
  141. package/src/lib/shared/prepareSocketModule.ts +37 -0
  142. package/src/lib/shared/programNameForPackage.ts +14 -0
  143. package/src/lib/shared/promptNameForFile.ts +10 -0
  144. package/src/lib/shared/recordRemoteMeta.ts +5 -0
  145. package/src/lib/shared/remoteMetaStore.ts +16 -0
  146. package/src/lib/shared/resolveClientFlags.ts +18 -0
  147. package/src/lib/shared/rpcUrlForFile.ts +19 -0
  148. package/src/lib/shared/setCacheStoreResolver.ts +6 -0
  149. package/src/lib/shared/socketNameForFile.ts +11 -0
  150. package/src/lib/shared/streamingContentTypes.ts +11 -0
  151. package/src/lib/shared/stripImport.ts +27 -0
  152. package/src/lib/shared/subscribableFromResponse.ts +333 -0
  153. package/src/lib/shared/toBunRoutePattern.ts +28 -0
  154. package/src/lib/shared/types/CacheEntry.ts +16 -0
  155. package/src/lib/shared/types/CacheOptions.ts +10 -0
  156. package/src/lib/shared/types/CacheSnapshotEntry.ts +15 -0
  157. package/src/lib/shared/types/CacheStore.ts +15 -0
  158. package/src/lib/shared/types/ClientFlags.ts +11 -0
  159. package/src/lib/shared/types/Subscribable.ts +15 -0
  160. package/src/lib/shared/writeRoutesDts.ts +64 -0
  161. package/src/preload.ts +20 -0
  162. package/src/scaffold.ts +92 -0
  163. package/src/serverEntry.ts +47 -0
  164. package/src/sveltePlugin.ts +58 -0
  165. package/src/tailwindStylePreprocessor.ts +62 -0
  166. package/template/package.json +16 -0
  167. package/template/src/app.ts +23 -0
  168. package/template/src/browser/app.css +21 -0
  169. package/template/src/browser/app.html +24 -0
  170. package/template/src/browser/pages/about/page.svelte +5 -0
  171. package/template/src/browser/pages/layout.svelte +26 -0
  172. package/template/src/browser/pages/page.svelte +20 -0
  173. package/template/src/cli/banner.txt +3 -0
  174. package/template/src/cli/footer.txt +1 -0
  175. package/template/src/server/rpc/getHello.ts +33 -0
  176. package/template/svelte.config.js +12 -0
  177. package/template/tsconfig.json +18 -0
  178. 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>