@sixb/app 0.1.9 → 0.1.11

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.
@@ -0,0 +1,37 @@
1
+ import type { Translation } from "@sixb/ui/lib/i18n";
2
+ /** Source catalog of the screens Sixb generates around a custom app. */
3
+ export declare const en: {
4
+ goHome: string;
5
+ reload: string;
6
+ retry: string;
7
+ notFound: {
8
+ title: string;
9
+ detail: string;
10
+ };
11
+ accessDenied: {
12
+ title: string;
13
+ detail: string;
14
+ signOut: string;
15
+ signingOut: string;
16
+ };
17
+ error: {
18
+ title: string;
19
+ sharedDetail: string;
20
+ };
21
+ apiUnavailable: {
22
+ title: string;
23
+ detail: (apiBaseUrl: string) => string;
24
+ };
25
+ shared: {
26
+ opening: string;
27
+ verifying: string;
28
+ retryableTitle: string;
29
+ retryableDetail: string;
30
+ unavailableTitle: string;
31
+ unavailableDetail: string;
32
+ tryAgain: string;
33
+ };
34
+ };
35
+ export type AppMessages = typeof en;
36
+ export declare const fr: Translation<AppMessages>;
37
+ //# sourceMappingURL=locale-messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale-messages.d.ts","sourceRoot":"","sources":["../src/locale-messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEjE,wEAAwE;AACxE,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;6BAoBU,MAAM;;;;;;;;;;;CAYR,CAAA;AAEvB,MAAM,MAAM,WAAW,GAAG,OAAO,EAAE,CAAA;AAEnC,eAAO,MAAM,EAAE,EAAE,WAAW,CAAC,WAAW,CAgCvC,CAAA"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Language of the screens the generated runtime draws around a custom app. Imported through
3
+ * `@sixb/app` so a project builds whether or not it depends on `@sixb/ui` itself, the same way the
4
+ * built-in agent routes resolve `@sixb/agent-ui`.
5
+ */
6
+ import { LocaleProvider } from "@sixb/ui/lib/i18n";
7
+ import { type AppMessages } from "./locale-messages";
8
+ export { LocaleProvider };
9
+ /** Messages of the generated screens in the current locale. */
10
+ export declare const useAppMessages: () => {
11
+ goHome: string;
12
+ reload: string;
13
+ retry: string;
14
+ notFound: {
15
+ title: string;
16
+ detail: string;
17
+ };
18
+ accessDenied: {
19
+ title: string;
20
+ detail: string;
21
+ signOut: string;
22
+ signingOut: string;
23
+ };
24
+ error: {
25
+ title: string;
26
+ sharedDetail: string;
27
+ };
28
+ apiUnavailable: {
29
+ title: string;
30
+ detail: (apiBaseUrl: string) => string;
31
+ };
32
+ shared: {
33
+ opening: string;
34
+ verifying: string;
35
+ retryableTitle: string;
36
+ retryableDetail: string;
37
+ unavailableTitle: string;
38
+ unavailableDetail: string;
39
+ tryAgain: string;
40
+ };
41
+ };
42
+ /** The browser's first language with a translation, for pages without project settings. */
43
+ export declare function browserAppLocale(): string;
44
+ /** Messages for screens drawn before React starts, in the browser's language. */
45
+ export declare function browserAppMessages(): AppMessages;
46
+ //# sourceMappingURL=locale.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locale.d.ts","sourceRoot":"","sources":["../src/locale.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAkB,cAAc,EAAmB,MAAM,mBAAmB,CAAA;AACnF,OAAO,EAAE,KAAK,WAAW,EAAU,MAAM,mBAAmB,CAAA;AAI5D,OAAO,EAAE,cAAc,EAAE,CAAA;AAEzB,+DAA+D;AAC/D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0B,CAAA;AAErD,2FAA2F;AAC3F,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,iFAAiF;AACjF,wBAAgB,kBAAkB,IAAI,WAAW,CAEhD"}
package/dist/locale.js ADDED
@@ -0,0 +1,24 @@
1
+ // @bun
2
+ import {
3
+ en,
4
+ fr
5
+ } from "./chunk-cftmy40z.js";
6
+
7
+ // src/locale.ts
8
+ import { defineMessages, LocaleProvider, negotiateLocale } from "@sixb/ui/lib/i18n";
9
+ var appMessages = defineMessages({ en, fr });
10
+ var useAppMessages = appMessages.useMessages;
11
+ function browserAppLocale() {
12
+ return negotiateLocale({ preferred: typeof navigator === "undefined" ? [] : navigator.languages });
13
+ }
14
+ function browserAppMessages() {
15
+ return appMessages.messagesFor(browserAppLocale());
16
+ }
17
+ export {
18
+ LocaleProvider,
19
+ browserAppLocale,
20
+ browserAppMessages,
21
+ useAppMessages
22
+ };
23
+
24
+ //# debugId=F4D9310BE0385F1164756E2164756E21
@@ -0,0 +1,10 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/locale.ts"],
4
+ "sourcesContent": [
5
+ "/**\n * Language of the screens the generated runtime draws around a custom app. Imported through\n * `@sixb/app` so a project builds whether or not it depends on `@sixb/ui` itself, the same way the\n * built-in agent routes resolve `@sixb/agent-ui`.\n */\nimport { defineMessages, LocaleProvider, negotiateLocale } from \"@sixb/ui/lib/i18n\"\nimport { type AppMessages, en, fr } from \"./locale-messages\"\n\nconst appMessages = defineMessages<AppMessages>({ en, fr })\n\nexport { LocaleProvider }\n\n/** Messages of the generated screens in the current locale. */\nexport const useAppMessages = appMessages.useMessages\n\n/** The browser's first language with a translation, for pages without project settings. */\nexport function browserAppLocale(): string {\n return negotiateLocale({ preferred: typeof navigator === \"undefined\" ? [] : navigator.languages })\n}\n\n/** Messages for screens drawn before React starts, in the browser's language. */\nexport function browserAppMessages(): AppMessages {\n return appMessages.messagesFor(browserAppLocale())\n}\n"
6
+ ],
7
+ "mappings": ";;;;;;;AAKA;AAGA,IAAM,cAAc,eAA4B,EAAE,IAAI,GAAG,CAAC;AAKnD,IAAM,iBAAiB,YAAY;AAGnC,SAAS,gBAAgB,GAAW;AAAA,EACzC,OAAO,gBAAgB,EAAE,WAAW,OAAO,cAAc,cAAc,CAAC,IAAI,UAAU,UAAU,CAAC;AAAA;AAI5F,SAAS,kBAAkB,GAAgB;AAAA,EAChD,OAAO,YAAY,YAAY,iBAAiB,CAAC;AAAA;",
8
+ "debugId": "F4D9310BE0385F1164756E2164756E21",
9
+ "names": []
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/app",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Custom app toolkit for Sixb projects — route scanning, dev serving, and production builds",
5
5
  "keywords": [
6
6
  "sixb",
@@ -39,6 +39,12 @@
39
39
  "import": "./dist/agents.js",
40
40
  "default": "./dist/agents.js"
41
41
  },
42
+ "./locale": {
43
+ "types": "./dist/locale.d.ts",
44
+ "bun": "./src/locale.ts",
45
+ "import": "./dist/locale.js",
46
+ "default": "./dist/locale.js"
47
+ },
42
48
  "./auth": {
43
49
  "types": "./dist/auth.d.ts",
44
50
  "bun": "./src/auth.ts",
@@ -53,9 +59,9 @@
53
59
  "prepack": "bun run build"
54
60
  },
55
61
  "dependencies": {
56
- "@sixb/agent-ui": "^0.1.9",
57
- "@sixb/core": "^0.1.12",
58
- "@sixb/ui": "^0.1.2",
62
+ "@sixb/agent-ui": "^0.1.11",
63
+ "@sixb/core": "^0.1.18",
64
+ "@sixb/ui": "^0.1.3",
59
65
  "@tailwindcss/cli": "^4.2.2",
60
66
  "tailwindcss": "^4.1.18"
61
67
  },
package/src/codegen.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { access, mkdir, readFile, writeFile } from "node:fs/promises"
2
2
  import { join, relative, resolve } from "node:path"
3
3
  import type { AuthSessionAudience } from "@sixb/core"
4
+ import { en, fr } from "./locale-messages"
4
5
  import { renderAppManifest } from "./manifest"
5
6
  import { resolveAppMetadata } from "./metadata"
6
7
  import { renderCustomAppRuntimeScript } from "./runtime"
@@ -17,6 +18,11 @@ export interface GenerateRouteManifestOptions {
17
18
  readonly layouts?: readonly AppRouteLayout[]
18
19
  }
19
20
 
21
+ /** The shared shell's unavailable message per language, inlined before any module loads. */
22
+ function sharedUnavailableTranslations(): Record<string, string> {
23
+ return { en: en.shared.unavailableDetail, fr: fr.shared.unavailableDetail }
24
+ }
25
+
20
26
  export const AUTH_EXPERIENCE_BOOTSTRAP_PLACEHOLDER = "__SIXB_AUTH_BOOTSTRAP__"
21
27
 
22
28
  function assertNoReservedSharedRoutes(routes: readonly PageRoute[]): void {
@@ -504,8 +510,10 @@ import {
504
510
  useNavigate,
505
511
  useRoutes,
506
512
  } from "react-router-dom"
507
- import { QueryClient, QueryClientProvider } from "@tanstack/react-query"
513
+ import { QueryClient, QueryClientProvider, useQuery } from "@tanstack/react-query"
508
514
  import { isSixbApiError } from "@sixb/client/browser"
515
+ import { getProjectInfoOptions } from "@sixb/client/hooks"
516
+ import { LocaleProvider, useAppMessages } from "@sixb/app/locale"
509
517
  import { routePaths, routes } from "./routes"
510
518
  ${globalsCssImport}
511
519
  ${layoutImport}
@@ -695,6 +703,7 @@ function AppFallback({
695
703
  showReload?: boolean
696
704
  action?: React.ReactNode
697
705
  }) {
706
+ const messages = useAppMessages()
698
707
  return (
699
708
  <div
700
709
  role="alert"
@@ -730,7 +739,7 @@ function AppFallback({
730
739
  textDecoration: "none",
731
740
  }}
732
741
  >
733
- Go home
742
+ {messages.goHome}
734
743
  </a>
735
744
  {showReload ? (
736
745
  <button
@@ -745,7 +754,7 @@ function AppFallback({
745
754
  cursor: "pointer",
746
755
  }}
747
756
  >
748
- Reload
757
+ {messages.reload}
749
758
  </button>
750
759
  ) : null}
751
760
  </>
@@ -756,6 +765,7 @@ function AppFallback({
756
765
  }
757
766
 
758
767
  function AccessDeniedView() {
768
+ const messages = useAppMessages().accessDenied
759
769
  const [isSigningOut, setIsSigningOut] = React.useState(false)
760
770
 
761
771
  async function handleSignOut() {
@@ -770,8 +780,8 @@ function AccessDeniedView() {
770
780
 
771
781
  return (
772
782
  <AppFallback
773
- title="Access required"
774
- detail="Your account is signed in, but it does not have permission to access this app."
783
+ title={messages.title}
784
+ detail={messages.detail}
775
785
  showReload={false}
776
786
  action={
777
787
  <button
@@ -787,7 +797,7 @@ function AccessDeniedView() {
787
797
  cursor: isSigningOut ? "default" : "pointer",
788
798
  }}
789
799
  >
790
- {isSigningOut ? "Signing out…" : "Sign out"}
800
+ {isSigningOut ? messages.signingOut : messages.signOut}
791
801
  </button>
792
802
  }
793
803
  />
@@ -798,10 +808,11 @@ function AccessDeniedView() {
798
808
  // route below) and for an expected 404 surfaced through a query. Apps will be
799
809
  // able to override this via app/not-found.tsx.
800
810
  function NotFoundView() {
811
+ const messages = useAppMessages().notFound
801
812
  return (
802
813
  <AppFallback
803
- title="Not found"
804
- detail="The page or resource you requested does not exist."
814
+ title={messages.title}
815
+ detail={messages.detail}
805
816
  showReload={false}
806
817
  />
807
818
  )
@@ -819,15 +830,16 @@ function AppErrorFallback({
819
830
  error: unknown
820
831
  hideErrorDetails: boolean
821
832
  }) {
833
+ const messages = useAppMessages().error
822
834
  if (isSixbApiError(error) && error.status === 404) {
823
835
  return <NotFoundView />
824
836
  }
825
837
  return (
826
838
  <AppFallback
827
- title="Something went wrong"
839
+ title={messages.title}
828
840
  detail={
829
841
  hideErrorDetails
830
- ? "This shared page could not be displayed."
842
+ ? messages.sharedDetail
831
843
  : error instanceof Error
832
844
  ? error.message
833
845
  : String(error)
@@ -909,30 +921,105 @@ function RoutedApp({ hideErrorDetails }: { readonly hideErrorDetails: boolean })
909
921
  )
910
922
  }
911
923
 
924
+ // Project settings do not change while the app runs: never refetch or collect them. Built on use:
925
+ // the query key captures the API base URL, which the bootstrap configures after this module loads.
926
+ function projectInfoQuery() {
927
+ return {
928
+ ...getProjectInfoOptions(),
929
+ staleTime: Number.POSITIVE_INFINITY,
930
+ gcTime: Number.POSITIVE_INFINITY,
931
+ retry: false,
932
+ }
933
+ }
934
+
935
+ // Framework text follows the reader's browser languages and falls back to the project's. A shared
936
+ // link's grant cannot read project settings, so it keeps the browser's languages alone.
937
+ function ProjectLocale({
938
+ shared,
939
+ children,
940
+ }: {
941
+ readonly shared: boolean
942
+ readonly children: React.ReactNode
943
+ }) {
944
+ const { data: project } = useQuery({ ...projectInfoQuery(), enabled: !shared })
945
+ return <LocaleProvider fallbackLocale={project?.locale}>{children}</LocaleProvider>
946
+ }
947
+
912
948
  function App({ basename }: StartAppOptions) {
913
949
  return (
914
950
  <QueryClientProvider client={queryClient}>
915
- <BrowserRouter basename={basename}>
916
- <SharedDocumentLinkInterceptor basename={basename} />
917
- <InternalLinkInterceptor basename={basename} />
918
- {basename ? (
919
- <RoutedApp hideErrorDetails />
920
- ) : (
921
- <SharedDocumentBoundary>
922
- <RoutedApp hideErrorDetails={false} />
923
- </SharedDocumentBoundary>
924
- )}
925
- </BrowserRouter>
951
+ <ProjectLocale shared={Boolean(basename)}>
952
+ <BrowserRouter basename={basename}>
953
+ <SharedDocumentLinkInterceptor basename={basename} />
954
+ <InternalLinkInterceptor basename={basename} />
955
+ {basename ? (
956
+ <RoutedApp hideErrorDetails />
957
+ ) : (
958
+ <SharedDocumentBoundary>
959
+ <RoutedApp hideErrorDetails={false} />
960
+ </SharedDocumentBoundary>
961
+ )}
962
+ </BrowserRouter>
963
+ </ProjectLocale>
926
964
  </QueryClientProvider>
927
965
  )
928
966
  }
929
967
 
930
968
  export function startApp(options: StartAppOptions = {}) {
969
+ // The HTML is built without loading the project: declare the project's language on the document
970
+ // as soon as the API answers, without waiting for the page tree to render.
971
+ if (!options.basename) {
972
+ void queryClient.fetchQuery(projectInfoQuery()).then(
973
+ (project) => {
974
+ document.documentElement.lang = project.locale
975
+ },
976
+ () => undefined
977
+ )
978
+ }
931
979
  getRoot().render(<App basename={options.basename} />)
932
980
  }
933
981
 
982
+ // Without a session the project's locale is unknown: these speak the browser's language.
934
983
  export function renderAccessDenied() {
935
- getRoot().render(<AccessDeniedView />)
984
+ getRoot().render(
985
+ <LocaleProvider>
986
+ <AccessDeniedView />
987
+ </LocaleProvider>
988
+ )
989
+ }
990
+
991
+ export function renderApiUnavailable(apiBaseUrl: string) {
992
+ getRoot().render(
993
+ <LocaleProvider>
994
+ <ApiUnavailableView apiBaseUrl={apiBaseUrl} />
995
+ </LocaleProvider>
996
+ )
997
+ }
998
+
999
+ function ApiUnavailableView({ apiBaseUrl }: { readonly apiBaseUrl: string }) {
1000
+ const messages = useAppMessages()
1001
+ return (
1002
+ <AppFallback
1003
+ title={messages.apiUnavailable.title}
1004
+ detail={messages.apiUnavailable.detail(apiBaseUrl)}
1005
+ action={
1006
+ <button
1007
+ type="button"
1008
+ onClick={() => window.location.reload()}
1009
+ style={{
1010
+ padding: "0.5rem 1rem",
1011
+ borderRadius: "var(--radius, 0.5rem)",
1012
+ border: "1px solid var(--border, #cbd2d9)",
1013
+ background: "transparent",
1014
+ color: "inherit",
1015
+ cursor: "pointer",
1016
+ }}
1017
+ >
1018
+ {messages.retry}
1019
+ </button>
1020
+ }
1021
+ />
1022
+ )
936
1023
  }
937
1024
  `
938
1025
 
@@ -946,7 +1033,7 @@ export function renderAccessDenied() {
946
1033
  readSixbBrowserRuntimeConfig,
947
1034
  requireSixbBrowserAuthSession,
948
1035
  } from "@sixb/client/browser"
949
- import { renderAccessDenied, startApp } from "./app-runtime"
1036
+ import { renderAccessDenied, renderApiUnavailable, startApp } from "./app-runtime"
950
1037
 
951
1038
  const runtimeConfig = readSixbBrowserRuntimeConfig({ audience: "app" })
952
1039
  const browserClient = configureSixbBrowserClient(runtimeConfig)
@@ -956,18 +1043,23 @@ if (import.meta.hot) {
956
1043
  import.meta.hot.dispose(() => browserClient.dispose())
957
1044
  }
958
1045
 
1046
+ // Without the API's answer the app can neither render nor send the user to sign in.
959
1047
  const authSession = runtimeConfig.auth.enabled
960
- ? await requireSixbBrowserAuthSession(runtimeConfig, browserClient)
1048
+ ? await requireSixbBrowserAuthSession(runtimeConfig, browserClient).catch((error: unknown) => {
1049
+ console.error("[SixbCustomApp] Could not load the session from the API:", error)
1050
+ return "unavailable" as const
1051
+ })
961
1052
  : null
962
- const applicationAccessDenied =
963
- authSession?.authenticated === true && !authSession.applicationAccess.allowed
964
- const canRenderApp =
1053
+
1054
+ if (authSession === "unavailable") {
1055
+ renderApiUnavailable(runtimeConfig.api.baseUrl)
1056
+ } else if (
965
1057
  !runtimeConfig.auth.enabled ||
1058
+ (authSession?.authenticated === false && authSession.authEnabled === false) ||
966
1059
  (authSession?.authenticated === true && authSession.applicationAccess.allowed)
967
-
968
- if (canRenderApp) {
1060
+ ) {
969
1061
  startApp()
970
- } else if (applicationAccessDenied) {
1062
+ } else if (authSession?.authenticated === true && !authSession.applicationAccess.allowed) {
971
1063
  renderAccessDenied()
972
1064
  }
973
1065
  `
@@ -977,7 +1069,8 @@ if (canRenderApp) {
977
1069
 
978
1070
  // This module contains framework bootstrap only. It must never statically import routes, the
979
1071
  // authored layout, or any page: that graph is imported after the session is accepted.
980
- const sharedMainContent = `import {
1072
+ const sharedMainContent = `import { browserAppLocale, browserAppMessages } from "@sixb/app/locale"
1073
+ import {
981
1074
  configureSixbSharedBrowserClient,
982
1075
  isSixbApiError,
983
1076
  readSixbBrowserRuntimeConfig,
@@ -1009,6 +1102,8 @@ export function startSharedApp(
1009
1102
  bootstrap: SharedAppBootstrap,
1010
1103
  options: SharedAppStartOptions = {}
1011
1104
  ): void {
1105
+ // A shared link speaks the reader's language: the grant cannot read the project's.
1106
+ document.documentElement.lang = browserAppLocale()
1012
1107
  if (!isValidBootstrap(bootstrap)) {
1013
1108
  renderSharedFallback("unavailable")
1014
1109
  return
@@ -1137,28 +1232,29 @@ function renderSharedFallback(
1137
1232
  "justify-content:center;gap:.75rem;padding:2rem;text-align:center;" +
1138
1233
  "font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"
1139
1234
 
1235
+ const messages = browserAppMessages().shared
1140
1236
  const title = document.createElement("h1")
1141
1237
  title.style.cssText = "margin:0;font-size:1.5rem"
1142
1238
  title.textContent =
1143
1239
  state === "loading"
1144
- ? "Opening shared access…"
1240
+ ? messages.opening
1145
1241
  : state === "retryable"
1146
- ? "Unable to open this link"
1147
- : "Link unavailable"
1242
+ ? messages.retryableTitle
1243
+ : messages.unavailableTitle
1148
1244
  const detail = document.createElement("p")
1149
1245
  detail.style.cssText = "margin:0;max-width:32rem"
1150
1246
  detail.textContent =
1151
1247
  state === "loading"
1152
- ? "Please wait while this link is verified."
1248
+ ? messages.verifying
1153
1249
  : state === "retryable"
1154
- ? "A temporary problem occurred. Please try again."
1155
- : "This shared link is invalid, expired, or no longer available."
1250
+ ? messages.retryableDetail
1251
+ : messages.unavailableDetail
1156
1252
  main.append(title, detail)
1157
1253
 
1158
1254
  if (retry) {
1159
1255
  const button = document.createElement("button")
1160
1256
  button.type = "button"
1161
- button.textContent = "Try again"
1257
+ button.textContent = messages.tryAgain
1162
1258
  button.style.cssText =
1163
1259
  "margin-top:.25rem;padding:.625rem 1rem;border:1px solid currentColor;" +
1164
1260
  "border-radius:.375rem;background:transparent;color:inherit;cursor:pointer;font:inherit"
@@ -1249,7 +1345,13 @@ ${renderSharedMetadataHead(metadata)}
1249
1345
  "min-height:100dvh;display:grid;place-items:center;padding:2rem;text-align:center;" +
1250
1346
  "font-family:system-ui,-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif"
1251
1347
  const message = document.createElement("p")
1252
- message.textContent = "This shared link is invalid, expired, or no longer available."
1348
+ // Inline and dependency-free: the translations travel with the page.
1349
+ const translations = ${JSON.stringify(sharedUnavailableTranslations())}
1350
+ const language = (navigator.languages || [navigator.language])
1351
+ .map((tag) => String(tag).split("-")[0].toLowerCase())
1352
+ .find((tag) => tag in translations)
1353
+ document.documentElement.lang = language || "en"
1354
+ message.textContent = translations[language || "en"]
1253
1355
  main.append(message)
1254
1356
  root.replaceChildren(main)
1255
1357
  }
@@ -978,7 +978,11 @@ function secureSharedHtml(
978
978
  // The browser client reports an invalid runtime URL. Keep the document policy fail-closed.
979
979
  }
980
980
 
981
- const connectSources = ["'self'", ...(apiOrigin === requestOrigin ? [] : [apiOrigin])]
981
+ const apiSources = apiOrigin === requestOrigin ? [] : [apiOrigin]
982
+ const connectSources = ["'self'", ...apiSources]
983
+ // Files are fetched or embedded from the API, which a split deployment serves from its own
984
+ // origin; `https:` alone misses it in plain-HTTP development.
985
+ const fileSources = ["'self'", ...apiSources, "data:", "blob:", "https:"]
982
986
  const scriptSources = [`'nonce-${nonce}'`, "'strict-dynamic'", "'self'"]
983
987
  const contentSecurityPolicy = [
984
988
  "default-src 'none'",
@@ -988,7 +992,8 @@ function secureSharedHtml(
988
992
  "form-action 'none'",
989
993
  `script-src ${scriptSources.join(" ")}`,
990
994
  "style-src 'self' 'unsafe-inline'",
991
- "img-src 'self' data: blob: https:",
995
+ `img-src ${fileSources.join(" ")}`,
996
+ `media-src ${fileSources.join(" ")}`,
992
997
  "font-src 'self' data: https:",
993
998
  `connect-src ${connectSources.join(" ")}`,
994
999
  "manifest-src 'none'",
@@ -0,0 +1,72 @@
1
+ import type { MessageTree, Translation } from "@sixb/ui/lib/i18n"
2
+
3
+ /** Source catalog of the screens Sixb generates around a custom app. */
4
+ export const en = {
5
+ goHome: "Go home",
6
+ reload: "Reload",
7
+ retry: "Retry",
8
+ notFound: {
9
+ title: "Not found",
10
+ detail: "The page or resource you requested does not exist.",
11
+ },
12
+ accessDenied: {
13
+ title: "Access required",
14
+ detail: "Your account is signed in, but it does not have permission to access this app.",
15
+ signOut: "Sign out",
16
+ signingOut: "Signing out…",
17
+ },
18
+ error: {
19
+ title: "Something went wrong",
20
+ sharedDetail: "This shared page could not be displayed.",
21
+ },
22
+ apiUnavailable: {
23
+ title: "Can't reach the Sixb API",
24
+ detail: (apiBaseUrl: string) =>
25
+ `This app could not load your session from ${apiBaseUrl}. Check that the API is running and allows this origin, then retry.`,
26
+ },
27
+ shared: {
28
+ opening: "Opening shared access…",
29
+ verifying: "Please wait while this link is verified.",
30
+ retryableTitle: "Unable to open this link",
31
+ retryableDetail: "A temporary problem occurred. Please try again.",
32
+ unavailableTitle: "Link unavailable",
33
+ unavailableDetail: "This shared link is invalid, expired, or no longer available.",
34
+ tryAgain: "Try again",
35
+ },
36
+ } satisfies MessageTree
37
+
38
+ export type AppMessages = typeof en
39
+
40
+ export const fr: Translation<AppMessages> = {
41
+ goHome: "Retour à l’accueil",
42
+ reload: "Recharger",
43
+ retry: "Réessayer",
44
+ notFound: {
45
+ title: "Page introuvable",
46
+ detail: "La page ou la ressource demandée n’existe pas.",
47
+ },
48
+ accessDenied: {
49
+ title: "Accès requis",
50
+ detail: "Ce compte est connecté, mais n’a pas l’autorisation d’accéder à cette application.",
51
+ signOut: "Se déconnecter",
52
+ signingOut: "Déconnexion…",
53
+ },
54
+ error: {
55
+ title: "Une erreur est survenue",
56
+ sharedDetail: "Cette page partagée n’a pas pu être affichée.",
57
+ },
58
+ apiUnavailable: {
59
+ title: "Impossible de joindre l’API Sixb",
60
+ detail: (apiBaseUrl) =>
61
+ `L’application n’a pas pu charger la session depuis ${apiBaseUrl}. Vérifiez que l’API est démarrée et autorise cette origine, puis réessayez.`,
62
+ },
63
+ shared: {
64
+ opening: "Ouverture de l’accès partagé…",
65
+ verifying: "Vérification du lien en cours.",
66
+ retryableTitle: "Impossible d’ouvrir ce lien",
67
+ retryableDetail: "Un problème temporaire est survenu. Réessayez.",
68
+ unavailableTitle: "Lien indisponible",
69
+ unavailableDetail: "Ce lien de partage est invalide, a expiré ou n’est plus disponible.",
70
+ tryAgain: "Réessayer",
71
+ },
72
+ }
package/src/locale.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Language of the screens the generated runtime draws around a custom app. Imported through
3
+ * `@sixb/app` so a project builds whether or not it depends on `@sixb/ui` itself, the same way the
4
+ * built-in agent routes resolve `@sixb/agent-ui`.
5
+ */
6
+ import { defineMessages, LocaleProvider, negotiateLocale } from "@sixb/ui/lib/i18n"
7
+ import { type AppMessages, en, fr } from "./locale-messages"
8
+
9
+ const appMessages = defineMessages<AppMessages>({ en, fr })
10
+
11
+ export { LocaleProvider }
12
+
13
+ /** Messages of the generated screens in the current locale. */
14
+ export const useAppMessages = appMessages.useMessages
15
+
16
+ /** The browser's first language with a translation, for pages without project settings. */
17
+ export function browserAppLocale(): string {
18
+ return negotiateLocale({ preferred: typeof navigator === "undefined" ? [] : navigator.languages })
19
+ }
20
+
21
+ /** Messages for screens drawn before React starts, in the browser's language. */
22
+ export function browserAppMessages(): AppMessages {
23
+ return appMessages.messagesFor(browserAppLocale())
24
+ }