@sixb/app 0.1.2 → 0.1.4
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 +36 -12
- package/dist/agents.d.ts +1 -1
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js.map +1 -1
- package/dist/auth.d.ts +22 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +3 -0
- package/dist/auth.js.map +9 -0
- package/dist/build.d.ts +10 -0
- package/dist/build.d.ts.map +1 -1
- package/dist/codegen.d.ts +14 -3
- package/dist/codegen.d.ts.map +1 -1
- package/dist/createCustomApp.d.ts +7 -0
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +546 -97
- package/dist/index.js.map +6 -6
- package/dist/scanner.d.ts +24 -6
- package/dist/scanner.d.ts.map +1 -1
- package/package.json +13 -3
- package/src/agents.ts +1 -1
- package/src/auth.ts +17 -0
- package/src/build.ts +83 -4
- package/src/codegen.ts +386 -25
- package/src/createCustomApp.ts +100 -13
- package/src/index.ts +2 -0
- package/src/scanner.ts +191 -46
package/dist/scanner.d.ts
CHANGED
|
@@ -6,14 +6,32 @@ export interface PageRoute {
|
|
|
6
6
|
/** Relative path from the app directory, e.g. "remote/[id]/page.tsx" */
|
|
7
7
|
relativePath: string;
|
|
8
8
|
}
|
|
9
|
+
export interface AppRouteLayout {
|
|
10
|
+
/** React Router prefix owned by this layout, e.g. "/remote/:id". */
|
|
11
|
+
path: string;
|
|
12
|
+
/** Absolute file path. */
|
|
13
|
+
filePath: string;
|
|
14
|
+
/** Relative path from the app directory, e.g. "remote/[id]/layout.tsx". */
|
|
15
|
+
relativePath: string;
|
|
16
|
+
}
|
|
17
|
+
export interface AppRouteDiscovery {
|
|
18
|
+
readonly pages: readonly PageRoute[];
|
|
19
|
+
/** Descendant layouts only. The root layout remains the global app wrapper. */
|
|
20
|
+
readonly layouts: readonly AppRouteLayout[];
|
|
21
|
+
}
|
|
9
22
|
/**
|
|
10
|
-
* Recursively scans an `app/` directory for
|
|
11
|
-
* converts them to React Router route paths.
|
|
23
|
+
* Recursively scans an `app/` directory for page modules and descendant layouts.
|
|
12
24
|
*
|
|
13
|
-
* - `app/page.tsx`
|
|
14
|
-
* - `app/about/page.tsx`
|
|
15
|
-
* - `app/remote/[id]/page.tsx`
|
|
16
|
-
* -
|
|
25
|
+
* - `app/page.tsx` -> page `/`
|
|
26
|
+
* - `app/about/page.tsx` -> page `/about`
|
|
27
|
+
* - `app/remote/[id]/page.tsx` -> page `/remote/:id`
|
|
28
|
+
* - `app/remote/[id]/layout.tsx` -> layout `/remote/:id/**`
|
|
29
|
+
* - `app/layout.tsx` remains the global wrapper and is not returned as a route layout.
|
|
30
|
+
* - Files and folders starting with `_` are skipped.
|
|
17
31
|
*/
|
|
32
|
+
export declare function scanAppRoutes(appDir: string): Promise<AppRouteDiscovery>;
|
|
33
|
+
/** Preserve the existing flat inspection contract while route generation uses the richer scan. */
|
|
18
34
|
export declare function scanPages(appDir: string): Promise<PageRoute[]>;
|
|
35
|
+
/** Treat parameter names as labels when comparing route ownership and overrides. */
|
|
36
|
+
export declare function routePatternKey(path: string): string;
|
|
19
37
|
//# sourceMappingURL=scanner.d.ts.map
|
package/dist/scanner.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"scanner.d.ts","sourceRoot":"","sources":["../src/scanner.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,SAAS;IACxB,mDAAmD;IACnD,IAAI,EAAE,MAAM,CAAA;IACZ,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAA;IAChB,wEAAwE;IACxE,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,oEAAoE;IACpE,IAAI,EAAE,MAAM,CAAA;IACZ,0BAA0B;IAC1B,QAAQ,EAAE,MAAM,CAAA;IAChB,2EAA2E;IAC3E,YAAY,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,KAAK,EAAE,SAAS,SAAS,EAAE,CAAA;IACpC,+EAA+E;IAC/E,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAA;CAC5C;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAO9E;AAED,kGAAkG;AAClG,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAEpE;AAED,oFAAoF;AACpF,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMpD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -33,16 +33,23 @@
|
|
|
33
33
|
"bun": "./src/agents.ts",
|
|
34
34
|
"import": "./dist/agents.js",
|
|
35
35
|
"default": "./dist/agents.js"
|
|
36
|
+
},
|
|
37
|
+
"./auth": {
|
|
38
|
+
"types": "./dist/auth.d.ts",
|
|
39
|
+
"bun": "./src/auth.ts",
|
|
40
|
+
"import": "./dist/auth.js",
|
|
41
|
+
"default": "./dist/auth.js"
|
|
36
42
|
}
|
|
37
43
|
},
|
|
38
44
|
"scripts": {
|
|
39
45
|
"build": "bun ../../scripts/build-package.ts",
|
|
46
|
+
"test:e2e": "bun test ./tests/build-browser.e2e.ts",
|
|
40
47
|
"typecheck": "tsc --noEmit",
|
|
41
48
|
"prepack": "bun run build"
|
|
42
49
|
},
|
|
43
50
|
"dependencies": {
|
|
44
|
-
"@sixb/agent-ui": "^0.1.
|
|
45
|
-
"@sixb/core": "^0.1.
|
|
51
|
+
"@sixb/agent-ui": "^0.1.4",
|
|
52
|
+
"@sixb/core": "^0.1.4",
|
|
46
53
|
"@sixb/ui": "^0.1.1",
|
|
47
54
|
"@tailwindcss/cli": "^4.2.2",
|
|
48
55
|
"tailwindcss": "^4.1.18"
|
|
@@ -54,8 +61,11 @@
|
|
|
54
61
|
"react-router-dom": "^7.0.0"
|
|
55
62
|
},
|
|
56
63
|
"devDependencies": {
|
|
64
|
+
"@testing-library/react": "^16.3.2",
|
|
57
65
|
"@types/bun": "latest",
|
|
58
66
|
"@types/react": "^19.0.0",
|
|
67
|
+
"happy-dom": "^20.11.6",
|
|
68
|
+
"libphonenumber-js": "1.13.9",
|
|
59
69
|
"typescript": "^5.7.0"
|
|
60
70
|
},
|
|
61
71
|
"license": "MIT",
|
package/src/agents.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type AgentWorkspaceProviderProps = PropsWithChildren<AgentWorkspaceChrome
|
|
|
21
21
|
|
|
22
22
|
const AgentWorkspaceContext = createContext<AgentWorkspaceChrome>({})
|
|
23
23
|
|
|
24
|
-
/** Configure the framework-owned Agents routes from
|
|
24
|
+
/** Configure the framework-owned Agents routes, typically from `app/agents/layout.tsx`. */
|
|
25
25
|
export function AgentWorkspaceProvider({
|
|
26
26
|
sidebarHeader,
|
|
27
27
|
sidebarFooter,
|
package/src/auth.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type AuthExperienceState =
|
|
2
|
+
| { readonly kind: "signIn" }
|
|
3
|
+
| { readonly kind: "checkEmail" }
|
|
4
|
+
| { readonly kind: "confirm"; readonly email?: string }
|
|
5
|
+
| { readonly kind: "invalidLink" }
|
|
6
|
+
| { readonly kind: "error" }
|
|
7
|
+
|
|
8
|
+
export interface AuthExperienceActions {
|
|
9
|
+
requestMagicLink(email: string): void
|
|
10
|
+
confirmSignIn(): void
|
|
11
|
+
restartSignIn(): void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface AuthExperienceProps {
|
|
15
|
+
readonly state: AuthExperienceState
|
|
16
|
+
readonly actions: AuthExperienceActions
|
|
17
|
+
}
|
package/src/build.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { existsSync } from "node:fs"
|
|
2
2
|
import { copyFile, mkdir, readFile, rm, writeFile } from "node:fs/promises"
|
|
3
|
-
import { basename, dirname,
|
|
3
|
+
import { basename, dirname, join, resolve } from "node:path"
|
|
4
4
|
import { promisify } from "node:util"
|
|
5
5
|
import {
|
|
6
6
|
brotliCompress as brotliCompressCallback,
|
|
@@ -30,6 +30,15 @@ export interface BuildAppResult {
|
|
|
30
30
|
logs?: string[]
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
export interface BuildAuthExperienceOptions {
|
|
34
|
+
/** Generated HTML shell containing the auth bootstrap placeholder. */
|
|
35
|
+
entryPath: string
|
|
36
|
+
/** Browser TypeScript entry generated alongside `entryPath`. */
|
|
37
|
+
scriptEntryPath: string
|
|
38
|
+
/** Directory written for the API server to mount under `/auth`. */
|
|
39
|
+
outdir: string
|
|
40
|
+
}
|
|
41
|
+
|
|
33
42
|
/**
|
|
34
43
|
* Builds the generated browser entry and writes a production-ready static shell and bundle.
|
|
35
44
|
*/
|
|
@@ -110,6 +119,74 @@ export async function buildApp(options: BuildAppOptions): Promise<BuildAppResult
|
|
|
110
119
|
return { success: true, outdir }
|
|
111
120
|
}
|
|
112
121
|
|
|
122
|
+
/** Builds the optional custom auth entry as API-served static assets. */
|
|
123
|
+
export async function buildAuthExperience(
|
|
124
|
+
options: BuildAuthExperienceOptions
|
|
125
|
+
): Promise<BuildAppResult> {
|
|
126
|
+
const outdir = resolve(options.outdir)
|
|
127
|
+
const assetsDir = join(outdir, "assets")
|
|
128
|
+
await rm(outdir, { recursive: true, force: true })
|
|
129
|
+
await mkdir(assetsDir, { recursive: true })
|
|
130
|
+
|
|
131
|
+
const result = await Bun.build({
|
|
132
|
+
entrypoints: [options.scriptEntryPath],
|
|
133
|
+
outdir: assetsDir,
|
|
134
|
+
target: "browser",
|
|
135
|
+
conditions: ["bun"],
|
|
136
|
+
publicPath: "/auth/assets/",
|
|
137
|
+
minify: true,
|
|
138
|
+
splitting: true,
|
|
139
|
+
naming: {
|
|
140
|
+
entry: "auth-[hash].[ext]",
|
|
141
|
+
chunk: "chunk-[name]-[hash].[ext]",
|
|
142
|
+
asset: "asset-[name]-[hash].[ext]",
|
|
143
|
+
},
|
|
144
|
+
plugins: [extensionlessSourceImportPlugin],
|
|
145
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
146
|
+
sourcemap: "external",
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
if (!result.success) {
|
|
150
|
+
return {
|
|
151
|
+
success: false,
|
|
152
|
+
outdir,
|
|
153
|
+
logs: result.logs.map(String),
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const script = result.outputs.find(
|
|
158
|
+
(output) => output.kind === "entry-point" && output.type.startsWith("text/javascript")
|
|
159
|
+
)
|
|
160
|
+
const stylesheets = result.outputs.filter((output) => output.type.startsWith("text/css"))
|
|
161
|
+
if (!script || stylesheets.length > 1) {
|
|
162
|
+
throw new Error(
|
|
163
|
+
`[SixbCustomApp] Expected one auth entry and at most one stylesheet, found ${script ? 1 : 0} entries and ${stylesheets.length} stylesheets.`
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const sourceHtml = await readFile(options.entryPath, "utf-8")
|
|
168
|
+
const sourceEntryPattern =
|
|
169
|
+
/\s*<script\s+type=["']module["']\s+src=["']\.\/auth-main\.tsx["']><\/script>/
|
|
170
|
+
if (!sourceEntryPattern.test(sourceHtml)) {
|
|
171
|
+
throw new Error("[SixbCustomApp] Generated auth shell is missing its ./auth-main.tsx entry.")
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const assetTags = [
|
|
175
|
+
...stylesheets.map(
|
|
176
|
+
(stylesheet) =>
|
|
177
|
+
`<link rel="stylesheet" crossorigin href="/auth/assets/${basename(stylesheet.path)}">`
|
|
178
|
+
),
|
|
179
|
+
`<script type="module" crossorigin src="/auth/assets/${basename(script.path)}"></script>`,
|
|
180
|
+
].join("")
|
|
181
|
+
const html = sourceHtml
|
|
182
|
+
.replace(sourceEntryPattern, "")
|
|
183
|
+
.replace("</head>", ` ${assetTags}</head>`)
|
|
184
|
+
await writeFile(join(outdir, "index.html"), html, "utf-8")
|
|
185
|
+
await precompressBuildAssets(result.outputs)
|
|
186
|
+
|
|
187
|
+
return { success: true, outdir }
|
|
188
|
+
}
|
|
189
|
+
|
|
113
190
|
// Bun's HTML bundler currently tries to resolve root-relative link assets from
|
|
114
191
|
// the filesystem root. A temporary external origin keeps these stable URLs out
|
|
115
192
|
// of the asset graph; dev responses and production output restore the originals.
|
|
@@ -152,9 +229,11 @@ const extensionlessSourceImportPlugin: Bun.BunPlugin = {
|
|
|
152
229
|
// A direct TypeScript entry with splitting exposes a Bun 1.3 resolver edge in linked workspace
|
|
153
230
|
// packages: extensionless relative imports such as `../json` can fail even though `json.ts`
|
|
154
231
|
// exists. HTML entries masked it, but HTML splitting can point at the wrong dynamic chunk.
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
232
|
+
// Let Bun resolve already-explicit imports without entering this hook. On affected Bun
|
|
233
|
+
// releases (including 1.3.14 and 1.4.0), merely intercepting a package's explicit `.js`
|
|
234
|
+
// imports and returning `undefined` can corrupt DCE: subclass wrappers remain in the bundle
|
|
235
|
+
// while their imported superclass is removed.
|
|
236
|
+
build.onResolve({ filter: /^\.\.?\/(?:.*\/)?[^/.]+$/ }, (args) => {
|
|
158
237
|
const base = resolve(dirname(args.importer), args.path)
|
|
159
238
|
for (const candidate of [
|
|
160
239
|
`${base}.ts`,
|