@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
package/README.md
CHANGED
|
@@ -8,6 +8,26 @@ Reusable toolkit for project-specific Sixb apps. It owns custom app route scanni
|
|
|
8
8
|
bun add @sixb/app
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
+
## Public environment variables
|
|
12
|
+
|
|
13
|
+
Set browser-safe values with the `SIXB_PUBLIC_` prefix:
|
|
14
|
+
|
|
15
|
+
```dotenv
|
|
16
|
+
SIXB_PUBLIC_GOOGLE_MAPS_API_KEY=your-browser-key
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
import { publicEnv } from "@sixb/app"
|
|
21
|
+
|
|
22
|
+
const key = publicEnv.SIXB_PUBLIC_GOOGLE_MAPS_API_KEY // string | undefined
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Values are strings; missing keys return `undefined`. Only prefixed variables are available.
|
|
26
|
+
Outside the browser, `publicEnv` is empty. With `sixb dev` and `sixb app`, restart the app server
|
|
27
|
+
after changing values; no rebuild is required.
|
|
28
|
+
|
|
29
|
+
Public values are visible to every user. Never use `SIXB_PUBLIC_` for backend secrets.
|
|
30
|
+
|
|
11
31
|
## How It Works
|
|
12
32
|
|
|
13
33
|
The build pipeline has three stages: **scan**, **codegen**, and **build**.
|
|
@@ -79,31 +99,13 @@ These routes are generated only when the project has at least one `app/` page, s
|
|
|
79
99
|
|
|
80
100
|
The default agent UI is imported through `@sixb/app/agents`, so app projects do not need to import `@sixb/agent-ui` directly. A framework-owned `agent-ui.css` bundle is generated before the app stylesheet and imports normal `@sixb/ui` styles, which means app-level token overrides in `app/globals.css` still apply in the usual way.
|
|
81
101
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
import { AgentWorkspaceProvider } from "@sixb/app/agents"
|
|
87
|
-
import type { PropsWithChildren } from "react"
|
|
88
|
-
|
|
89
|
-
export default function AgentsLayout({ children }: PropsWithChildren) {
|
|
90
|
-
return (
|
|
91
|
-
<AgentWorkspaceProvider
|
|
92
|
-
sidebarHeader={<AppSidebarHeader />}
|
|
93
|
-
sidebarFooter={<AppSidebarFooter />}
|
|
94
|
-
sidebarWidth="12.5rem"
|
|
95
|
-
>
|
|
96
|
-
{children}
|
|
97
|
-
</AgentWorkspaceProvider>
|
|
98
|
-
)
|
|
99
|
-
}
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
Explicit props passed to a project-owned `AgentsPage` override provider defaults. The custom width
|
|
103
|
-
applies to the persistent desktop rail; the mobile sheet keeps its responsive width.
|
|
102
|
+
The routed page uses the same conversation header, history dialog, and new-thread flow as an
|
|
103
|
+
embedded agent panel. Applications that want a conversation to move between a full page and an
|
|
104
|
+
in-app dock should mount one `AgentSurface` in their shell and derive its `fullPage` presentation
|
|
105
|
+
from the route instead of mounting a second chat.
|
|
104
106
|
|
|
105
|
-
|
|
106
|
-
without coupling `@sixb/app` or `@sixb/agent-ui` to their implementation.
|
|
107
|
+
Add `AgentWorkspaceProvider` to `app/agents/layout.tsx` to register `documentPreviewRenderers`
|
|
108
|
+
for the generated routes without coupling `@sixb/app` or `@sixb/agent-ui` to their implementation.
|
|
107
109
|
|
|
108
110
|
```tsx
|
|
109
111
|
<AgentWorkspaceProvider documentPreviewRenderers={[workbookPreviewRenderer]}>
|
|
@@ -157,6 +159,33 @@ Context is visible and removable before send, then stored on that user message.
|
|
|
157
159
|
object references explicitly. V1 accepts 12 entries, 16 KB per app-state entry, and 64 KB of app
|
|
158
160
|
state per message. Object references identify live data; they do not grant access.
|
|
159
161
|
|
|
162
|
+
For an assistant that lives beside the app, keep one `AgentSurface` mounted next to the route
|
|
163
|
+
outlet:
|
|
164
|
+
|
|
165
|
+
```tsx
|
|
166
|
+
import { AgentSurface } from "@sixb/app/agents"
|
|
167
|
+
|
|
168
|
+
function AppAssistant() {
|
|
169
|
+
return (
|
|
170
|
+
<AgentSurface
|
|
171
|
+
title="Invoice Assistant"
|
|
172
|
+
launcherLabel="Ask about invoices"
|
|
173
|
+
/>
|
|
174
|
+
)
|
|
175
|
+
}
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
`AgentSurface` opens as a resizable dock by default and owns its open/closed state, width, and
|
|
179
|
+
selected thread. It persists those values in `sessionStorage`: refreshes restore them, while each
|
|
180
|
+
browser tab can diverge without changing the app URL. Pass controlled `mode`, `threadId`, or
|
|
181
|
+
`dockWidth` props when the host needs to own a value, or `persistenceKey={false}` to disable per-tab
|
|
182
|
+
persistence. Documents open in a modeless tabbed canvas over the app area while the dock stays
|
|
183
|
+
visible and interactive; hiding the canvas preserves its tabs. Mobile uses a full-screen dock and
|
|
184
|
+
modal document overlay. Set `fullPage` from the host's conversation route when that same session
|
|
185
|
+
should occupy the main application canvas. Connect `onRequestFullPage` and `onRequestDock` to host
|
|
186
|
+
navigation; leaving that route returns the session to its dock without changing the selected
|
|
187
|
+
thread.
|
|
188
|
+
|
|
160
189
|
### Styling and Tailwind
|
|
161
190
|
|
|
162
191
|
`app/globals.css` is treated as source:
|
package/dist/agents.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type AgentChatPageProps } from "@sixb/agent-ui/react-router";
|
|
2
2
|
import { type PropsWithChildren } from "react";
|
|
3
|
-
export { AgentContextProvider, type AgentDocumentPreviewRenderer, type AgentDocumentPreviewRendererProps, type AgentFileRef, AgentPanel, type AgentPanelProps, useAgentContext, } from "@sixb/agent-ui";
|
|
3
|
+
export { AgentContextProvider, type AgentDocumentPreviewRenderer, type AgentDocumentPreviewRendererProps, type AgentFileRef, AgentPanel, type AgentPanelProps, AgentSurface, type AgentSurfaceMode, type AgentSurfaceProps, handoffAgentSurfaceThread, setAgentSurfaceMode, useAgentContext, } from "@sixb/agent-ui";
|
|
4
4
|
export { agentContext } from "@sixb/core/agents/context";
|
|
5
5
|
export type AgentsPageProps = Omit<AgentChatPageProps, "routeBase">;
|
|
6
|
-
type AgentWorkspaceConfiguration = Pick<AgentsPageProps, "
|
|
6
|
+
type AgentWorkspaceConfiguration = Pick<AgentsPageProps, "documentPreviewRenderers">;
|
|
7
7
|
export type AgentWorkspaceProviderProps = PropsWithChildren<AgentWorkspaceConfiguration>;
|
|
8
8
|
/** Configure the framework-owned Agents routes, typically from `app/agents/layout.tsx`. */
|
|
9
|
-
export declare function AgentWorkspaceProvider({
|
|
9
|
+
export declare function AgentWorkspaceProvider({ documentPreviewRenderers, children, }: AgentWorkspaceProviderProps): import("react").FunctionComponentElement<import("react").ProviderProps<AgentWorkspaceConfiguration>>;
|
|
10
10
|
export default function AgentsPage(props: AgentsPageProps): import("react").FunctionComponentElement<AgentChatPageProps>;
|
|
11
11
|
//# sourceMappingURL=agents.d.ts.map
|
package/dist/agents.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,EAAgC,KAAK,iBAAiB,EAAc,MAAM,OAAO,CAAA;AAExF,OAAO,EACL,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EACtC,KAAK,YAAY,EACjB,UAAU,EACV,KAAK,eAAe,EACpB,eAAe,GAChB,MAAM,gBAAgB,CAAA;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../src/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,kBAAkB,EAAE,MAAM,6BAA6B,CAAA;AACpF,OAAO,EAAgC,KAAK,iBAAiB,EAAc,MAAM,OAAO,CAAA;AAExF,OAAO,EACL,oBAAoB,EACpB,KAAK,4BAA4B,EACjC,KAAK,iCAAiC,EACtC,KAAK,YAAY,EACjB,UAAU,EACV,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,yBAAyB,EACzB,mBAAmB,EACnB,eAAe,GAChB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAExD,MAAM,MAAM,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAA;AAEnE,KAAK,2BAA2B,GAAG,IAAI,CAAC,eAAe,EAAE,0BAA0B,CAAC,CAAA;AAEpF,MAAM,MAAM,2BAA2B,GAAG,iBAAiB,CAAC,2BAA2B,CAAC,CAAA;AAIxF,2FAA2F;AAC3F,wBAAgB,sBAAsB,CAAC,EACrC,wBAAwB,EACxB,QAAQ,GACT,EAAE,2BAA2B,wGAM7B;AAED,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,KAAK,EAAE,eAAe,gEAQxD"}
|
package/dist/agents.js
CHANGED
|
@@ -5,18 +5,18 @@ import { createContext, createElement, useContext } from "react";
|
|
|
5
5
|
import {
|
|
6
6
|
AgentContextProvider,
|
|
7
7
|
AgentPanel,
|
|
8
|
+
AgentSurface,
|
|
9
|
+
handoffAgentSurfaceThread,
|
|
10
|
+
setAgentSurfaceMode,
|
|
8
11
|
useAgentContext
|
|
9
12
|
} from "@sixb/agent-ui";
|
|
10
13
|
import { agentContext } from "@sixb/core/agents/context";
|
|
11
14
|
var AgentWorkspaceContext = createContext({});
|
|
12
15
|
function AgentWorkspaceProvider({
|
|
13
|
-
sidebarHeader,
|
|
14
|
-
sidebarFooter,
|
|
15
|
-
sidebarWidth,
|
|
16
16
|
documentPreviewRenderers,
|
|
17
17
|
children
|
|
18
18
|
}) {
|
|
19
|
-
return createElement(AgentWorkspaceContext.Provider, { value: {
|
|
19
|
+
return createElement(AgentWorkspaceContext.Provider, { value: { documentPreviewRenderers } }, children);
|
|
20
20
|
}
|
|
21
21
|
function AgentsPage(props) {
|
|
22
22
|
const workspaceConfiguration = useContext(AgentWorkspaceContext);
|
|
@@ -29,10 +29,13 @@ function AgentsPage(props) {
|
|
|
29
29
|
export {
|
|
30
30
|
AgentContextProvider,
|
|
31
31
|
AgentPanel,
|
|
32
|
+
AgentSurface,
|
|
32
33
|
AgentWorkspaceProvider,
|
|
33
34
|
agentContext,
|
|
34
35
|
AgentsPage as default,
|
|
36
|
+
handoffAgentSurfaceThread,
|
|
37
|
+
setAgentSurfaceMode,
|
|
35
38
|
useAgentContext
|
|
36
39
|
};
|
|
37
40
|
|
|
38
|
-
//# debugId=
|
|
41
|
+
//# debugId=F6514E745A4EB36964756E2164756E21
|
package/dist/agents.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/agents.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import { AgentChatPage, type AgentChatPageProps } from \"@sixb/agent-ui/react-router\"\nimport { createContext, createElement, type PropsWithChildren, useContext } from \"react\"\n\nexport {\n AgentContextProvider,\n type AgentDocumentPreviewRenderer,\n type AgentDocumentPreviewRendererProps,\n type AgentFileRef,\n AgentPanel,\n type AgentPanelProps,\n useAgentContext,\n} from \"@sixb/agent-ui\"\
|
|
5
|
+
"import { AgentChatPage, type AgentChatPageProps } from \"@sixb/agent-ui/react-router\"\nimport { createContext, createElement, type PropsWithChildren, useContext } from \"react\"\n\nexport {\n AgentContextProvider,\n type AgentDocumentPreviewRenderer,\n type AgentDocumentPreviewRendererProps,\n type AgentFileRef,\n AgentPanel,\n type AgentPanelProps,\n AgentSurface,\n type AgentSurfaceMode,\n type AgentSurfaceProps,\n handoffAgentSurfaceThread,\n setAgentSurfaceMode,\n useAgentContext,\n} from \"@sixb/agent-ui\"\nexport { agentContext } from \"@sixb/core/agents/context\"\n\nexport type AgentsPageProps = Omit<AgentChatPageProps, \"routeBase\">\n\ntype AgentWorkspaceConfiguration = Pick<AgentsPageProps, \"documentPreviewRenderers\">\n\nexport type AgentWorkspaceProviderProps = PropsWithChildren<AgentWorkspaceConfiguration>\n\nconst AgentWorkspaceContext = createContext<AgentWorkspaceConfiguration>({})\n\n/** Configure the framework-owned Agents routes, typically from `app/agents/layout.tsx`. */\nexport function AgentWorkspaceProvider({\n documentPreviewRenderers,\n children,\n}: AgentWorkspaceProviderProps) {\n return createElement(\n AgentWorkspaceContext.Provider,\n { value: { documentPreviewRenderers } },\n children\n )\n}\n\nexport default function AgentsPage(props: AgentsPageProps) {\n const workspaceConfiguration = useContext(AgentWorkspaceContext)\n\n return createElement(AgentChatPage, {\n ...workspaceConfiguration,\n ...props,\n routeBase: \"/agents\",\n })\n}\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAAA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;
|
|
8
|
-
"debugId": "
|
|
7
|
+
"mappings": ";;AAAA;AACA;AAEA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAcA;AAQA,IAAM,wBAAwB,cAA2C,CAAC,CAAC;AAGpE,SAAS,sBAAsB;AAAA,EACpC;AAAA,EACA;AAAA,GAC8B;AAAA,EAC9B,OAAO,cACL,sBAAsB,UACtB,EAAE,OAAO,EAAE,yBAAyB,EAAE,GACtC,QACF;AAAA;AAGF,SAAwB,UAAU,CAAC,OAAwB;AAAA,EACzD,MAAM,yBAAyB,WAAW,qBAAqB;AAAA,EAE/D,OAAO,cAAc,eAAe;AAAA,OAC/B;AAAA,OACA;AAAA,IACH,WAAW;AAAA,EACb,CAAC;AAAA;",
|
|
8
|
+
"debugId": "F6514E745A4EB36964756E2164756E21",
|
|
9
9
|
"names": []
|
|
10
10
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
// src/public-env.ts
|
|
3
|
+
var runtime = typeof window === "undefined" ? undefined : window.__SIXB_RUNTIME__;
|
|
4
|
+
var publicEnv2 = Object.freeze(Object.assign(Object.create(null), runtime?.publicEnv));
|
|
5
|
+
|
|
6
|
+
export { publicEnv2 };
|
|
7
|
+
|
|
8
|
+
//# debugId=62C3FDDD48F648C464756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/public-env.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"const runtime =\n typeof window === \"undefined\"\n ? undefined\n : (window as Window & { __SIXB_RUNTIME__?: { publicEnv?: Record<string, string> } })\n .__SIXB_RUNTIME__\n\n/** Public environment captured at app-server startup. Missing values are undefined. */\nexport const publicEnv: Readonly<Record<string, string | undefined>> = Object.freeze(\n Object.assign(Object.create(null), runtime?.publicEnv)\n)\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": ";;AAAA,IAAM,UACJ,OAAO,WAAW,cACd,YACC,OACE;AAGF,IAAM,aAA0D,OAAO,OAC5E,OAAO,OAAO,OAAO,OAAO,IAAI,GAAG,SAAS,SAAS,CACvD;",
|
|
8
|
+
"debugId": "62C3FDDD48F648C464756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createCustomApp.d.ts","sourceRoot":"","sources":["../src/createCustomApp.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,OAAO,EACL,KAAK,cAAc,EAQpB,MAAM,SAAS,CAAA;AAShB,OAAO,EAAE,KAAK,SAAS,EAAkC,MAAM,WAAW,CAAA;AAI1E,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,mBAAmB,CAAA;IAC9B,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,WAAW,CAAC,EAAE,OAAO,CAAA;CACtB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,gCAAgC;IAC/C,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,MAAM,CAAC,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AAC,CAAA;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAC/D,KAAK,CAAC,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAAA;CACpE;AAYD,wBAAsB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAkjBjG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { type CreateCustomAppOptions, type CustomAppBuildOptions, type CustomAppDevOptions, type CustomAppDevServer, type CustomAppInstance, type CustomAppStartOptions, type CustomAuthExperienceBuildOptions, type CustomAuthExperienceBuildResult, createCustomApp, } from "./createCustomApp";
|
|
2
2
|
export { devReloadResponse } from "./dev-reload";
|
|
3
3
|
export type { AppMetadata } from "./metadata";
|
|
4
|
+
export { publicEnv } from "./public-env";
|
|
4
5
|
export { createTailwindCssCompiler, type TailwindCssCompiler, type TailwindCssCompilerOptions, } from "./tailwind";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,GAChC,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,gCAAgC,EACrC,KAAK,+BAA+B,EACpC,eAAe,GAChB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EACL,yBAAyB,EACzB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,GAChC,MAAM,YAAY,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
import {
|
|
3
|
+
publicEnv2
|
|
4
|
+
} from "./chunk-e1gj8c1a.js";
|
|
5
|
+
|
|
2
6
|
// src/createCustomApp.ts
|
|
3
7
|
import { randomBytes } from "crypto";
|
|
4
8
|
import { watch } from "fs";
|
|
@@ -427,6 +431,9 @@ async function fileExists(path) {
|
|
|
427
431
|
}
|
|
428
432
|
|
|
429
433
|
// src/runtime.ts
|
|
434
|
+
function collectPublicEnv() {
|
|
435
|
+
return Object.fromEntries(Object.entries(process.env).filter((entry) => entry[0].startsWith("SIXB_PUBLIC_") && entry[1] !== undefined));
|
|
436
|
+
}
|
|
430
437
|
function renderCustomAppRuntimeScript(config) {
|
|
431
438
|
const safeConfig = JSON.stringify(config).replaceAll("<", "\\u003c");
|
|
432
439
|
return `<script>window.__SIXB_RUNTIME__ = ${safeConfig};</script>`;
|
|
@@ -2135,6 +2142,8 @@ async function createCustomApp(options) {
|
|
|
2135
2142
|
return await prepareAuthExperience(options);
|
|
2136
2143
|
},
|
|
2137
2144
|
async dev(devOptions = {}) {
|
|
2145
|
+
const publicEnv = collectPublicEnv();
|
|
2146
|
+
const withRuntime = (html) => injectRuntimeConfig(html, { apiBaseUrl, audience, authEnabled, publicEnv });
|
|
2138
2147
|
const host = devOptions.host ?? "0.0.0.0";
|
|
2139
2148
|
const port = devOptions.port ?? 3001;
|
|
2140
2149
|
const { htmlPath, manifestPath, sharedHtmlPath, sharedMainPath } = await prepareGeneratedApp();
|
|
@@ -2165,9 +2174,20 @@ async function createCustomApp(options) {
|
|
|
2165
2174
|
"/__sixb/dev-reload.js": getHeadRoute(devReloadResponse),
|
|
2166
2175
|
[customAppManifestRoute]: manifestRoute(manifestPath),
|
|
2167
2176
|
[privateAppShellRoute]: htmlBundleRoute(bundle),
|
|
2168
|
-
...sharedAppDevRoutes(async () => (await ensureSharedBuild()).html,
|
|
2169
|
-
|
|
2170
|
-
|
|
2177
|
+
...sharedAppDevRoutes(async () => injectRuntimeConfig((await ensureSharedBuild()).html, {
|
|
2178
|
+
apiBaseUrl,
|
|
2179
|
+
audience: "app",
|
|
2180
|
+
authEnabled: false,
|
|
2181
|
+
publicEnv
|
|
2182
|
+
}), apiBaseUrl),
|
|
2183
|
+
"/": spaHtmlRoute(() => internalOrigin, {
|
|
2184
|
+
shellRoute: privateAppShellRoute,
|
|
2185
|
+
transformHtml: withRuntime
|
|
2186
|
+
}),
|
|
2187
|
+
"/*": spaHtmlRoute(() => internalOrigin, {
|
|
2188
|
+
shellRoute: privateAppShellRoute,
|
|
2189
|
+
transformHtml: withRuntime
|
|
2190
|
+
})
|
|
2171
2191
|
}
|
|
2172
2192
|
});
|
|
2173
2193
|
async function ensureSharedBuild() {
|
|
@@ -2291,6 +2311,7 @@ async function createCustomApp(options) {
|
|
|
2291
2311
|
return result;
|
|
2292
2312
|
},
|
|
2293
2313
|
async start(startOptions = {}) {
|
|
2314
|
+
const publicEnv = collectPublicEnv();
|
|
2294
2315
|
const host = startOptions.host ?? "0.0.0.0";
|
|
2295
2316
|
const port = startOptions.port ?? 3001;
|
|
2296
2317
|
const outdir = resolve3(rootDir, startOptions.outdir ?? join7(".sixb", "dist", "app"));
|
|
@@ -2305,12 +2326,14 @@ async function createCustomApp(options) {
|
|
|
2305
2326
|
const indexHtml = injectRuntimeConfig(await Bun.file(indexPath).text(), {
|
|
2306
2327
|
apiBaseUrl: startOptions.apiBaseUrl ?? apiBaseUrl,
|
|
2307
2328
|
audience: startOptions.audience ?? audience,
|
|
2308
|
-
authEnabled: startOptions.authEnabled ?? authEnabled
|
|
2329
|
+
authEnabled: startOptions.authEnabled ?? authEnabled,
|
|
2330
|
+
publicEnv
|
|
2309
2331
|
});
|
|
2310
2332
|
const sharedIndexHtml = injectRuntimeConfig(await Bun.file(sharedIndexPath).text(), {
|
|
2311
2333
|
apiBaseUrl: startOptions.apiBaseUrl ?? apiBaseUrl,
|
|
2312
2334
|
audience: "app",
|
|
2313
|
-
authEnabled: false
|
|
2335
|
+
authEnabled: false,
|
|
2336
|
+
publicEnv
|
|
2314
2337
|
});
|
|
2315
2338
|
const runtimeApiBaseUrl = startOptions.apiBaseUrl ?? apiBaseUrl;
|
|
2316
2339
|
const server = Bun.serve({
|
|
@@ -2346,6 +2369,9 @@ async function createCustomApp(options) {
|
|
|
2346
2369
|
}
|
|
2347
2370
|
const directFile = Bun.file(resolvedPath);
|
|
2348
2371
|
if (await directFile.exists()) {
|
|
2372
|
+
if (resolvedPath === indexPath) {
|
|
2373
|
+
return htmlResponse(req, indexHtml);
|
|
2374
|
+
}
|
|
2349
2375
|
return staticFileResponse(req, resolvedPath, staticAssetHeaders(url.pathname));
|
|
2350
2376
|
}
|
|
2351
2377
|
if (isAssetRequest(url.pathname)) {
|
|
@@ -2353,6 +2379,9 @@ async function createCustomApp(options) {
|
|
|
2353
2379
|
}
|
|
2354
2380
|
const htmlFile = Bun.file(`${resolvedPath}.html`);
|
|
2355
2381
|
if (await htmlFile.exists()) {
|
|
2382
|
+
if (`${resolvedPath}.html` === indexPath) {
|
|
2383
|
+
return htmlResponse(req, indexHtml);
|
|
2384
|
+
}
|
|
2356
2385
|
return fileResponse(req, htmlFile);
|
|
2357
2386
|
}
|
|
2358
2387
|
const nestedIndexFile = Bun.file(join7(resolvedPath, "index.html"));
|
|
@@ -2563,20 +2592,23 @@ function resolveStaticPath(appRoot, pathname) {
|
|
|
2563
2592
|
return resolvedPath;
|
|
2564
2593
|
}
|
|
2565
2594
|
function injectRuntimeConfig(html, config) {
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
}
|
|
2595
|
+
const existingRuntimeScript = /<script>window\.__SIXB_RUNTIME__ = (.*?);<\/script>/;
|
|
2596
|
+
const existingConfig = html.match(existingRuntimeScript)?.[1];
|
|
2569
2597
|
const script = renderCustomAppRuntimeScript({
|
|
2570
|
-
|
|
2571
|
-
|
|
2598
|
+
auth: { audience: config.audience, enabled: config.authEnabled },
|
|
2599
|
+
...existingConfig ? JSON.parse(existingConfig) : {},
|
|
2600
|
+
...config.apiBaseUrl ? {
|
|
2601
|
+
api: { baseUrl: config.apiBaseUrl },
|
|
2602
|
+
auth: { audience: config.audience, enabled: config.authEnabled }
|
|
2603
|
+
} : {},
|
|
2604
|
+
publicEnv: config.publicEnv
|
|
2572
2605
|
});
|
|
2573
|
-
const existingRuntimeScript = /<script>window\.__SIXB_RUNTIME__ = .*?;<\/script>/;
|
|
2574
2606
|
if (existingRuntimeScript.test(html)) {
|
|
2575
|
-
return html.replace(existingRuntimeScript, script);
|
|
2607
|
+
return html.replace(existingRuntimeScript, () => script);
|
|
2576
2608
|
}
|
|
2577
|
-
if (
|
|
2578
|
-
return html.replace(
|
|
2579
|
-
|
|
2609
|
+
if (/<head\b[^>]*>/i.test(html)) {
|
|
2610
|
+
return html.replace(/<head\b[^>]*>/i, (head) => `${head}
|
|
2611
|
+
${script}`);
|
|
2580
2612
|
}
|
|
2581
2613
|
return `${script}
|
|
2582
2614
|
${html}`;
|
|
@@ -2785,7 +2817,7 @@ function spaHtmlRoute(internalOrigin, options = {}) {
|
|
|
2785
2817
|
});
|
|
2786
2818
|
}
|
|
2787
2819
|
const html = restoreAppStaticUrls(await bundleResponse.text()).replace("</head>", '<script src="/__sixb/dev-reload.js"></script></head>');
|
|
2788
|
-
return new Response(html, {
|
|
2820
|
+
return new Response(options.transformHtml?.(html) ?? html, {
|
|
2789
2821
|
status: bundleResponse.status,
|
|
2790
2822
|
statusText: bundleResponse.statusText,
|
|
2791
2823
|
headers: responseHeaders
|
|
@@ -2795,7 +2827,8 @@ function spaHtmlRoute(internalOrigin, options = {}) {
|
|
|
2795
2827
|
export {
|
|
2796
2828
|
createCustomApp,
|
|
2797
2829
|
createTailwindCssCompiler,
|
|
2798
|
-
devReloadResponse
|
|
2830
|
+
devReloadResponse,
|
|
2831
|
+
publicEnv2 as publicEnv
|
|
2799
2832
|
};
|
|
2800
2833
|
|
|
2801
|
-
//# debugId=
|
|
2834
|
+
//# debugId=6856E0633EA3EB7F64756E2164756E21
|