@briancray/belte 0.2.1 → 0.2.2
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/package.json +1 -1
- package/src/belteResolverPlugin.ts +12 -8
- package/src/lib/shared/writeRoutesDts.ts +7 -2
- package/template/package.json +1 -1
- package/template/src/app.ts +1 -1
- package/template/src/browser/pages/page.svelte +1 -1
- package/template/src/server/rpc/getHello.ts +2 -2
- package/template/svelte.config.js +1 -1
- package/template/tsconfig.json +1 -1
package/package.json
CHANGED
|
@@ -112,6 +112,13 @@ export function belteResolverPlugin({
|
|
|
112
112
|
const promptsDir = `${mcpDir}/prompts`
|
|
113
113
|
const resourcesDir = `${mcpDir}/resources`
|
|
114
114
|
|
|
115
|
+
/*
|
|
116
|
+
The bare specifier the project imports belte under (canonical
|
|
117
|
+
`@briancray/belte` or a package alias). Resolved once from the project's
|
|
118
|
+
package.json and threaded into every generated module so the codegen's
|
|
119
|
+
imports resolve regardless of which install style the project uses.
|
|
120
|
+
*/
|
|
121
|
+
const belteImportNameOnce = once(() => belteImportName(cwd))
|
|
115
122
|
/*
|
|
116
123
|
The whole-tree validation + per-leaf classification only needs to run
|
|
117
124
|
once per build. Memoise the promise so the virtual manifests
|
|
@@ -121,7 +128,11 @@ export function belteResolverPlugin({
|
|
|
121
128
|
*/
|
|
122
129
|
const scanPagesOnce = once(() =>
|
|
123
130
|
scanPages(pagesDir).then(async (scan) => {
|
|
124
|
-
await writeRoutesDts({
|
|
131
|
+
await writeRoutesDts({
|
|
132
|
+
cwd,
|
|
133
|
+
pageFiles: scan.pageFiles,
|
|
134
|
+
importName: await belteImportNameOnce(),
|
|
135
|
+
})
|
|
125
136
|
return scan
|
|
126
137
|
}),
|
|
127
138
|
)
|
|
@@ -129,13 +140,6 @@ export function belteResolverPlugin({
|
|
|
129
140
|
const scanSocketsOnce = once(() => scanSockets(socketsDir))
|
|
130
141
|
const scanPromptsOnce = once(() => scanPrompts(promptsDir))
|
|
131
142
|
const loadShellOnce = once(() => loadShell(cwd))
|
|
132
|
-
/*
|
|
133
|
-
The bare specifier the project imports belte under (canonical
|
|
134
|
-
`@briancray/belte` or a package alias). Resolved once from the project's
|
|
135
|
-
package.json and threaded into every generated module so the codegen's
|
|
136
|
-
imports resolve regardless of which install style the project uses.
|
|
137
|
-
*/
|
|
138
|
-
const belteImportNameOnce = once(() => belteImportName(cwd))
|
|
139
143
|
|
|
140
144
|
const rpcFilter = new RegExp(`^${escapeRegex(rpcDir)}/.*\\.ts$`)
|
|
141
145
|
const socketsFilter = new RegExp(`^${escapeRegex(socketsDir)}/.*\\.ts$`)
|
|
@@ -30,14 +30,19 @@ page file in the project. Page picks this up as a discriminated union keyed
|
|
|
30
30
|
on `route`, so `if (page.route === '/media/[id]') page.params.id` is typed
|
|
31
31
|
automatically without consumers writing route types by hand.
|
|
32
32
|
The file is written to `src/.belte/routes.d.ts` so the consumer's existing
|
|
33
|
-
src tsconfig include picks it up with no extra configuration.
|
|
33
|
+
src tsconfig include picks it up with no extra configuration. The augmented
|
|
34
|
+
module is keyed on the name the project imports belte under (`importName`),
|
|
35
|
+
so the augmentation matches the consumer's `page` import whether belte is
|
|
36
|
+
installed directly (`@briancray/belte`) or behind an alias.
|
|
34
37
|
*/
|
|
35
38
|
export async function writeRoutesDts({
|
|
36
39
|
cwd,
|
|
37
40
|
pageFiles,
|
|
41
|
+
importName,
|
|
38
42
|
}: {
|
|
39
43
|
cwd: string
|
|
40
44
|
pageFiles: string[]
|
|
45
|
+
importName: string
|
|
41
46
|
}): Promise<void> {
|
|
42
47
|
const entries = pageFiles
|
|
43
48
|
.map((file) => ({
|
|
@@ -50,7 +55,7 @@ export async function writeRoutesDts({
|
|
|
50
55
|
)
|
|
51
56
|
.join('\n')
|
|
52
57
|
const contents = `// Generated by belte. Do not edit by hand.
|
|
53
|
-
declare module '
|
|
58
|
+
declare module '${importName}/browser/page' {
|
|
54
59
|
interface Routes {
|
|
55
60
|
${entries}
|
|
56
61
|
}
|
package/template/package.json
CHANGED
package/template/src/app.ts
CHANGED
|
@@ -7,7 +7,7 @@ module — no import is needed from your own code.
|
|
|
7
7
|
handle middleware wrapping the default request pipeline
|
|
8
8
|
handleError custom 500 fallback
|
|
9
9
|
*/
|
|
10
|
-
import type { AppModule } from 'belte/server/AppModule'
|
|
10
|
+
import type { AppModule } from '@briancray/belte/server/AppModule'
|
|
11
11
|
|
|
12
12
|
export const init: AppModule['init'] = ({ server }) => {
|
|
13
13
|
console.log(`server listening on http://localhost:${server.port}`)
|
|
@@ -3,7 +3,7 @@ Root page — served at GET /. Every folder under src/browser/pages/ that
|
|
|
3
3
|
contains a page.svelte mounts at that folder's URL.
|
|
4
4
|
-->
|
|
5
5
|
<script lang="ts">
|
|
6
|
-
import { cache } from 'belte/browser/cache'
|
|
6
|
+
import { cache } from '@briancray/belte/browser/cache'
|
|
7
7
|
import { getHello } from '$server/rpc/getHello.ts'
|
|
8
8
|
|
|
9
9
|
/*
|
|
@@ -27,7 +27,7 @@ Every rpc value also exposes `.raw(args?)` (returns the underlying
|
|
|
27
27
|
for callers that need headers/status or want to iterate SSE/JSONL frames.
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
|
-
import { GET } from 'belte/server/GET'
|
|
31
|
-
import { json } from 'belte/server/json'
|
|
30
|
+
import { GET } from '@briancray/belte/server/GET'
|
|
31
|
+
import { json } from '@briancray/belte/server/json'
|
|
32
32
|
|
|
33
33
|
export const getHello = GET(() => json({ message: 'Hello from belte' }))
|
|
@@ -3,7 +3,7 @@ Optional Svelte compiler configuration. Same shape as upstream Svelte.
|
|
|
3
3
|
Delete this file to use defaults.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
/** @type {import('belte').SvelteConfig} */
|
|
6
|
+
/** @type {import('@briancray/belte').SvelteConfig} */
|
|
7
7
|
export default {
|
|
8
8
|
compilerOptions: {
|
|
9
9
|
// Opt in to top-level await inside Svelte components.
|
package/template/tsconfig.json
CHANGED