@sixb/app 0.1.7 → 0.1.9
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 +53 -24
- package/dist/agents.d.ts +3 -3
- package/dist/agents.d.ts.map +1 -1
- package/dist/agents.js +8 -5
- package/dist/agents.js.map +3 -3
- package/dist/browser.d.ts +3 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +9 -0
- package/dist/browser.js.map +9 -0
- package/dist/chunk-e1gj8c1a.js +8 -0
- package/dist/chunk-e1gj8c1a.js.map +10 -0
- package/dist/createCustomApp.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +51 -18
- package/dist/index.js.map +4 -4
- package/dist/public-env.d.ts +3 -0
- package/dist/public-env.d.ts.map +1 -0
- package/dist/runtime.d.ts +3 -1
- package/dist/runtime.d.ts.map +1 -1
- package/package.json +10 -4
- package/src/agents.ts +7 -9
- package/src/browser.ts +2 -0
- package/src/createCustomApp.ts +47 -15
- package/src/index.ts +1 -0
- package/src/public-env.ts +10 -0
- package/src/runtime.ts +11 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-env.d.ts","sourceRoot":"","sources":["../src/public-env.ts"],"names":[],"mappings":"AAMA,uFAAuF;AACvF,eAAO,MAAM,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAElE,CAAA"}
|
package/dist/runtime.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AuthSessionAudience } from "@sixb/core";
|
|
2
2
|
export interface CustomAppRuntimeConfig {
|
|
3
|
-
readonly
|
|
3
|
+
readonly publicEnv?: Readonly<Record<string, string | undefined>>;
|
|
4
|
+
readonly api?: {
|
|
4
5
|
readonly baseUrl: string;
|
|
5
6
|
};
|
|
6
7
|
readonly auth: {
|
|
@@ -8,5 +9,6 @@ export interface CustomAppRuntimeConfig {
|
|
|
8
9
|
readonly enabled: boolean;
|
|
9
10
|
};
|
|
10
11
|
}
|
|
12
|
+
export declare function collectPublicEnv(): Record<string, string>;
|
|
11
13
|
export declare function renderCustomAppRuntimeScript(config: CustomAppRuntimeConfig): string;
|
|
12
14
|
//# sourceMappingURL=runtime.d.ts.map
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,GAAG,EAAE;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AAErD,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAA;IACjE,QAAQ,CAAC,GAAG,CAAC,EAAE;QACb,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KACzB,CAAA;IACD,QAAQ,CAAC,IAAI,EAAE;QACb,QAAQ,CAAC,QAAQ,EAAE,mBAAmB,CAAA;QACtC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAC1B,CAAA;CACF;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAOzD;AAED,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,sBAAsB,GAAG,MAAM,CAGnF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sixb/app",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sixb",
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"types": "./dist/index.d.ts",
|
|
27
|
+
"browser": {
|
|
28
|
+
"types": "./dist/browser.d.ts",
|
|
29
|
+
"bun": "./src/browser.ts",
|
|
30
|
+
"default": "./dist/browser.js"
|
|
31
|
+
},
|
|
27
32
|
"bun": "./src/index.ts",
|
|
28
33
|
"import": "./dist/index.js",
|
|
29
34
|
"default": "./dist/index.js"
|
|
@@ -48,8 +53,8 @@
|
|
|
48
53
|
"prepack": "bun run build"
|
|
49
54
|
},
|
|
50
55
|
"dependencies": {
|
|
51
|
-
"@sixb/agent-ui": "^0.1.
|
|
52
|
-
"@sixb/core": "^0.1.
|
|
56
|
+
"@sixb/agent-ui": "^0.1.9",
|
|
57
|
+
"@sixb/core": "^0.1.12",
|
|
53
58
|
"@sixb/ui": "^0.1.2",
|
|
54
59
|
"@tailwindcss/cli": "^4.2.2",
|
|
55
60
|
"tailwindcss": "^4.1.18"
|
|
@@ -80,5 +85,6 @@
|
|
|
80
85
|
"src",
|
|
81
86
|
"README.md",
|
|
82
87
|
"LICENSE"
|
|
83
|
-
]
|
|
88
|
+
],
|
|
89
|
+
"sideEffects": false
|
|
84
90
|
}
|
package/src/agents.ts
CHANGED
|
@@ -8,17 +8,18 @@ export {
|
|
|
8
8
|
type AgentFileRef,
|
|
9
9
|
AgentPanel,
|
|
10
10
|
type AgentPanelProps,
|
|
11
|
+
AgentSurface,
|
|
12
|
+
type AgentSurfaceMode,
|
|
13
|
+
type AgentSurfaceProps,
|
|
14
|
+
handoffAgentSurfaceThread,
|
|
15
|
+
setAgentSurfaceMode,
|
|
11
16
|
useAgentContext,
|
|
12
17
|
} from "@sixb/agent-ui"
|
|
13
|
-
|
|
14
18
|
export { agentContext } from "@sixb/core/agents/context"
|
|
15
19
|
|
|
16
20
|
export type AgentsPageProps = Omit<AgentChatPageProps, "routeBase">
|
|
17
21
|
|
|
18
|
-
type AgentWorkspaceConfiguration = Pick<
|
|
19
|
-
AgentsPageProps,
|
|
20
|
-
"sidebarHeader" | "sidebarFooter" | "sidebarWidth" | "documentPreviewRenderers"
|
|
21
|
-
>
|
|
22
|
+
type AgentWorkspaceConfiguration = Pick<AgentsPageProps, "documentPreviewRenderers">
|
|
22
23
|
|
|
23
24
|
export type AgentWorkspaceProviderProps = PropsWithChildren<AgentWorkspaceConfiguration>
|
|
24
25
|
|
|
@@ -26,15 +27,12 @@ const AgentWorkspaceContext = createContext<AgentWorkspaceConfiguration>({})
|
|
|
26
27
|
|
|
27
28
|
/** Configure the framework-owned Agents routes, typically from `app/agents/layout.tsx`. */
|
|
28
29
|
export function AgentWorkspaceProvider({
|
|
29
|
-
sidebarHeader,
|
|
30
|
-
sidebarFooter,
|
|
31
|
-
sidebarWidth,
|
|
32
30
|
documentPreviewRenderers,
|
|
33
31
|
children,
|
|
34
32
|
}: AgentWorkspaceProviderProps) {
|
|
35
33
|
return createElement(
|
|
36
34
|
AgentWorkspaceContext.Provider,
|
|
37
|
-
{ value: {
|
|
35
|
+
{ value: { documentPreviewRenderers } },
|
|
38
36
|
children
|
|
39
37
|
)
|
|
40
38
|
}
|
package/src/browser.ts
ADDED
package/src/createCustomApp.ts
CHANGED
|
@@ -21,7 +21,7 @@ import {
|
|
|
21
21
|
generateRouteManifest,
|
|
22
22
|
} from "./codegen"
|
|
23
23
|
import { devReloadResponse } from "./dev-reload"
|
|
24
|
-
import { renderCustomAppRuntimeScript } from "./runtime"
|
|
24
|
+
import { collectPublicEnv, renderCustomAppRuntimeScript } from "./runtime"
|
|
25
25
|
import { type PageRoute, routePatternKey, scanAppRoutes } from "./scanner"
|
|
26
26
|
import { type CustomAppStylesheet, resolveCustomAppStylesheet } from "./styles"
|
|
27
27
|
import { createTailwindCssCompiler, type TailwindCssCompiler } from "./tailwind"
|
|
@@ -332,6 +332,9 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
332
332
|
},
|
|
333
333
|
|
|
334
334
|
async dev(devOptions: CustomAppDevOptions = {}) {
|
|
335
|
+
const publicEnv = collectPublicEnv()
|
|
336
|
+
const withRuntime = (html: string) =>
|
|
337
|
+
injectRuntimeConfig(html, { apiBaseUrl, audience, authEnabled, publicEnv })
|
|
335
338
|
const host = devOptions.host ?? "0.0.0.0"
|
|
336
339
|
const port = devOptions.port ?? 3001
|
|
337
340
|
const { htmlPath, manifestPath, sharedHtmlPath, sharedMainPath } = await prepareGeneratedApp()
|
|
@@ -363,9 +366,24 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
363
366
|
"/__sixb/dev-reload.js": getHeadRoute(devReloadResponse),
|
|
364
367
|
[customAppManifestRoute]: manifestRoute(manifestPath),
|
|
365
368
|
[privateAppShellRoute]: htmlBundleRoute(bundle),
|
|
366
|
-
...sharedAppDevRoutes(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
+
...sharedAppDevRoutes(
|
|
370
|
+
async () =>
|
|
371
|
+
injectRuntimeConfig((await ensureSharedBuild()).html, {
|
|
372
|
+
apiBaseUrl,
|
|
373
|
+
audience: "app",
|
|
374
|
+
authEnabled: false,
|
|
375
|
+
publicEnv,
|
|
376
|
+
}),
|
|
377
|
+
apiBaseUrl
|
|
378
|
+
),
|
|
379
|
+
"/": spaHtmlRoute(() => internalOrigin, {
|
|
380
|
+
shellRoute: privateAppShellRoute,
|
|
381
|
+
transformHtml: withRuntime,
|
|
382
|
+
}),
|
|
383
|
+
"/*": spaHtmlRoute(() => internalOrigin, {
|
|
384
|
+
shellRoute: privateAppShellRoute,
|
|
385
|
+
transformHtml: withRuntime,
|
|
386
|
+
}),
|
|
369
387
|
},
|
|
370
388
|
}) as Parameters<typeof Bun.serve>[0]
|
|
371
389
|
|
|
@@ -527,6 +545,7 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
527
545
|
},
|
|
528
546
|
|
|
529
547
|
async start(startOptions: CustomAppStartOptions = {}) {
|
|
548
|
+
const publicEnv = collectPublicEnv()
|
|
530
549
|
const host = startOptions.host ?? "0.0.0.0"
|
|
531
550
|
const port = startOptions.port ?? 3001
|
|
532
551
|
const outdir = resolve(rootDir, startOptions.outdir ?? join(".sixb", "dist", "app"))
|
|
@@ -546,11 +565,13 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
546
565
|
apiBaseUrl: startOptions.apiBaseUrl ?? apiBaseUrl,
|
|
547
566
|
audience: startOptions.audience ?? audience,
|
|
548
567
|
authEnabled: startOptions.authEnabled ?? authEnabled,
|
|
568
|
+
publicEnv,
|
|
549
569
|
})
|
|
550
570
|
const sharedIndexHtml = injectRuntimeConfig(await Bun.file(sharedIndexPath).text(), {
|
|
551
571
|
apiBaseUrl: startOptions.apiBaseUrl ?? apiBaseUrl,
|
|
552
572
|
audience: "app",
|
|
553
573
|
authEnabled: false,
|
|
574
|
+
publicEnv,
|
|
554
575
|
})
|
|
555
576
|
const runtimeApiBaseUrl = startOptions.apiBaseUrl ?? apiBaseUrl
|
|
556
577
|
const server = Bun.serve({
|
|
@@ -593,6 +614,9 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
593
614
|
|
|
594
615
|
const directFile = Bun.file(resolvedPath)
|
|
595
616
|
if (await directFile.exists()) {
|
|
617
|
+
if (resolvedPath === indexPath) {
|
|
618
|
+
return htmlResponse(req, indexHtml)
|
|
619
|
+
}
|
|
596
620
|
return staticFileResponse(req, resolvedPath, staticAssetHeaders(url.pathname))
|
|
597
621
|
}
|
|
598
622
|
|
|
@@ -602,6 +626,9 @@ export async function createCustomApp(options: CreateCustomAppOptions): Promise<
|
|
|
602
626
|
|
|
603
627
|
const htmlFile = Bun.file(`${resolvedPath}.html`)
|
|
604
628
|
if (await htmlFile.exists()) {
|
|
629
|
+
if (`${resolvedPath}.html` === indexPath) {
|
|
630
|
+
return htmlResponse(req, indexHtml)
|
|
631
|
+
}
|
|
605
632
|
return fileResponse(req, htmlFile)
|
|
606
633
|
}
|
|
607
634
|
|
|
@@ -887,23 +914,28 @@ function injectRuntimeConfig(
|
|
|
887
914
|
readonly apiBaseUrl?: string
|
|
888
915
|
readonly audience: AuthSessionAudience
|
|
889
916
|
readonly authEnabled: boolean
|
|
917
|
+
readonly publicEnv: Record<string, string>
|
|
890
918
|
}
|
|
891
919
|
): string {
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
920
|
+
const existingRuntimeScript = /<script>window\.__SIXB_RUNTIME__ = (.*?);<\/script>/
|
|
921
|
+
const existingConfig = html.match(existingRuntimeScript)?.[1]
|
|
896
922
|
const script = renderCustomAppRuntimeScript({
|
|
897
|
-
api: { baseUrl: config.apiBaseUrl },
|
|
898
923
|
auth: { audience: config.audience, enabled: config.authEnabled },
|
|
924
|
+
...(existingConfig ? JSON.parse(existingConfig) : {}),
|
|
925
|
+
...(config.apiBaseUrl
|
|
926
|
+
? {
|
|
927
|
+
api: { baseUrl: config.apiBaseUrl },
|
|
928
|
+
auth: { audience: config.audience, enabled: config.authEnabled },
|
|
929
|
+
}
|
|
930
|
+
: {}),
|
|
931
|
+
publicEnv: config.publicEnv,
|
|
899
932
|
})
|
|
900
|
-
const existingRuntimeScript = /<script>window\.__SIXB_RUNTIME__ = .*?;<\/script>/
|
|
901
933
|
if (existingRuntimeScript.test(html)) {
|
|
902
|
-
return html.replace(existingRuntimeScript, script)
|
|
934
|
+
return html.replace(existingRuntimeScript, () => script)
|
|
903
935
|
}
|
|
904
936
|
|
|
905
|
-
if (
|
|
906
|
-
return html.replace(
|
|
937
|
+
if (/<head\b[^>]*>/i.test(html)) {
|
|
938
|
+
return html.replace(/<head\b[^>]*>/i, (head) => `${head}\n ${script}`)
|
|
907
939
|
}
|
|
908
940
|
|
|
909
941
|
return `${script}\n${html}`
|
|
@@ -1135,7 +1167,7 @@ function devServerInternalOrigin(host: string, port: number): string {
|
|
|
1135
1167
|
|
|
1136
1168
|
function spaHtmlRoute(
|
|
1137
1169
|
internalOrigin: () => string,
|
|
1138
|
-
options: { readonly shellRoute?: string } = {}
|
|
1170
|
+
options: { readonly shellRoute?: string; readonly transformHtml?: (html: string) => string } = {}
|
|
1139
1171
|
): BunServeRoute {
|
|
1140
1172
|
return getHeadRoute(async (request) => {
|
|
1141
1173
|
const publicUrl = new URL(request.url)
|
|
@@ -1180,7 +1212,7 @@ function spaHtmlRoute(
|
|
|
1180
1212
|
"</head>",
|
|
1181
1213
|
'<script src="/__sixb/dev-reload.js"></script></head>'
|
|
1182
1214
|
)
|
|
1183
|
-
return new Response(html, {
|
|
1215
|
+
return new Response(options.transformHtml?.(html) ?? html, {
|
|
1184
1216
|
status: bundleResponse.status,
|
|
1185
1217
|
statusText: bundleResponse.statusText,
|
|
1186
1218
|
headers: responseHeaders,
|
package/src/index.ts
CHANGED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const runtime =
|
|
2
|
+
typeof window === "undefined"
|
|
3
|
+
? undefined
|
|
4
|
+
: (window as Window & { __SIXB_RUNTIME__?: { publicEnv?: Record<string, string> } })
|
|
5
|
+
.__SIXB_RUNTIME__
|
|
6
|
+
|
|
7
|
+
/** Public environment captured at app-server startup. Missing values are undefined. */
|
|
8
|
+
export const publicEnv: Readonly<Record<string, string | undefined>> = Object.freeze(
|
|
9
|
+
Object.assign(Object.create(null), runtime?.publicEnv)
|
|
10
|
+
)
|
package/src/runtime.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { AuthSessionAudience } from "@sixb/core"
|
|
2
2
|
|
|
3
3
|
export interface CustomAppRuntimeConfig {
|
|
4
|
-
readonly
|
|
4
|
+
readonly publicEnv?: Readonly<Record<string, string | undefined>>
|
|
5
|
+
readonly api?: {
|
|
5
6
|
readonly baseUrl: string
|
|
6
7
|
}
|
|
7
8
|
readonly auth: {
|
|
@@ -10,6 +11,15 @@ export interface CustomAppRuntimeConfig {
|
|
|
10
11
|
}
|
|
11
12
|
}
|
|
12
13
|
|
|
14
|
+
export function collectPublicEnv(): Record<string, string> {
|
|
15
|
+
return Object.fromEntries(
|
|
16
|
+
Object.entries(process.env).filter(
|
|
17
|
+
(entry): entry is [string, string] =>
|
|
18
|
+
entry[0].startsWith("SIXB_PUBLIC_") && entry[1] !== undefined
|
|
19
|
+
)
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
13
23
|
export function renderCustomAppRuntimeScript(config: CustomAppRuntimeConfig): string {
|
|
14
24
|
const safeConfig = JSON.stringify(config).replaceAll("<", "\\u003c")
|
|
15
25
|
return `<script>window.__SIXB_RUNTIME__ = ${safeConfig};</script>`
|