@rebasepro/app 0.16.0 → 0.16.1-canary.g0d7af95

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.
Files changed (50) hide show
  1. package/dist/auth/api.d.ts +8 -21
  2. package/dist/auth/index.d.ts +4 -4
  3. package/dist/auth/types.d.ts +1 -1
  4. package/dist/auth/useRebaseAuthController.d.ts +1 -1
  5. package/dist/collections/index.d.ts +13 -13
  6. package/dist/collections/title-property.d.ts +1 -1
  7. package/dist/components/Debug/collection-views/index.d.ts +3 -3
  8. package/dist/components/LoginView/LoginView.d.ts +2 -2
  9. package/dist/components/LoginView/index.d.ts +2 -2
  10. package/dist/components/common/index.d.ts +6 -6
  11. package/dist/components/common/useDataTableController.d.ts +1 -1
  12. package/dist/components/index.d.ts +18 -18
  13. package/dist/contexts/AdminModeController.d.ts +1 -1
  14. package/dist/contexts/ModeController.d.ts +1 -1
  15. package/dist/contexts/index.d.ts +18 -18
  16. package/dist/core/Rebase.d.ts +1 -1
  17. package/dist/core/index.d.ts +4 -4
  18. package/dist/hooks/index.d.ts +36 -36
  19. package/dist/hooks/useBridgeRegistration.d.ts +1 -1
  20. package/dist/hooks/useBuildAdminModeController.d.ts +1 -1
  21. package/dist/hooks/useBuildModeController.d.ts +1 -1
  22. package/dist/hooks/useUnsavedChangesDialog.d.ts +1 -1
  23. package/dist/index.d.ts +19 -19
  24. package/dist/index.es.js +129 -79
  25. package/dist/index.es.js.map +1 -1
  26. package/dist/util/index.d.ts +9 -8
  27. package/dist/util/local_storage.d.ts +31 -0
  28. package/package.json +9 -9
  29. package/src/auth/api.ts +8 -21
  30. package/src/auth/useRebaseAuthController.ts +6 -3
  31. package/src/collections/entity-display.ts +6 -34
  32. package/src/collections/form-layout.ts +2 -1
  33. package/src/collections/title-property.ts +1 -1
  34. package/src/components/Debug/UIReferenceView.tsx +53 -16
  35. package/src/components/LoginView/LoginView.tsx +3 -3
  36. package/src/components/common/useDataTableController.tsx +20 -1
  37. package/src/core/Rebase.tsx +3 -24
  38. package/src/hooks/useBuildAdminModeController.tsx +3 -4
  39. package/src/hooks/useBuildEffectiveRoleController.tsx +6 -7
  40. package/src/hooks/useBuildModeController.tsx +8 -6
  41. package/src/i18n/RebaseI18nProvider.tsx +5 -6
  42. package/src/locales/de.ts +0 -1
  43. package/src/locales/en.ts +0 -1
  44. package/src/locales/es.ts +0 -1
  45. package/src/locales/fr.ts +0 -1
  46. package/src/locales/hi.ts +0 -1
  47. package/src/locales/it.ts +0 -1
  48. package/src/locales/pt.ts +0 -1
  49. package/src/util/index.ts +1 -0
  50. package/src/util/local_storage.ts +66 -0
@@ -9,6 +9,7 @@ import { it } from "../locales/it";
9
9
  import { hi } from "../locales/hi";
10
10
  import { pt } from "../locales/pt";
11
11
  import { RebaseTranslations } from "@rebasepro/admin-types";
12
+ import { readStoredString, writeStoredString } from "../util/local_storage";
12
13
 
13
14
  const REBASE_NS = "rebase_core";
14
15
 
@@ -59,10 +60,8 @@ export function RebaseI18nProvider({
59
60
  const resources = buildResources(translations);
60
61
 
61
62
  let initialLocale = locale;
62
- if (typeof window !== "undefined") {
63
- const stored = localStorage.getItem(REBASE_LOCALE_STORAGE_KEY);
64
- if (stored) initialLocale = stored;
65
- }
63
+ const stored = readStoredString(REBASE_LOCALE_STORAGE_KEY);
64
+ if (stored) initialLocale = stored;
66
65
 
67
66
  instance
68
67
  .use(initReactI18next)
@@ -82,7 +81,7 @@ export function RebaseI18nProvider({
82
81
 
83
82
  instance.on("languageChanged", (lng) => {
84
83
  if (typeof window !== "undefined") {
85
- localStorage.setItem(REBASE_LOCALE_STORAGE_KEY, lng);
84
+ writeStoredString(REBASE_LOCALE_STORAGE_KEY, lng);
86
85
  }
87
86
  });
88
87
 
@@ -93,7 +92,7 @@ export function RebaseI18nProvider({
93
92
  // ONLY if the user hasn't explicitly set a preference
94
93
  useEffect(() => {
95
94
  if (i18nRef.current && i18nRef.current.language !== locale) {
96
- const hasUserPreference = typeof window !== "undefined" && Boolean(localStorage.getItem(REBASE_LOCALE_STORAGE_KEY));
95
+ const hasUserPreference = Boolean(readStoredString(REBASE_LOCALE_STORAGE_KEY));
97
96
  if (!hasUserPreference) {
98
97
  i18nRef.current.changeLanguage(locale);
99
98
  }
package/src/locales/de.ts CHANGED
@@ -523,7 +523,6 @@ export const de: RebaseTranslations = {
523
523
  add_your: "Fügen Sie Ihre",
524
524
  database_collections: "Datenbanksammlungen",
525
525
  no_unmapped_collections: "Keine nicht zugeordneten Sammlungen",
526
- query_and_update_with_datatalk: "Fragen Sie Ihre Daten in natürlicher Sprache ab und aktualisieren Sie sie mit DATATALK",
527
526
  welcome_to_rebase: "Willkommen bei Rebase",
528
527
  admin_panel_ready_bring_data: "Ihr Admin-Panel ist bereit. Bringen Sie Ihre Daten ein.",
529
528
  admin_panel_ready_get_started: "Ihr Admin-Panel ist bereit. So können Sie loslegen.",
package/src/locales/en.ts CHANGED
@@ -637,7 +637,6 @@ export const en: RebaseTranslations = {
637
637
  add_your: "Add your",
638
638
  database_collections: "database collections",
639
639
  no_unmapped_collections: "No unmapped collections in the database",
640
- query_and_update_with_datatalk: "Query and update your data in natural language with",
641
640
 
642
641
  welcome_to_rebase: "Welcome to Rebase Cloud",
643
642
  admin_panel_ready_bring_data: "Your admin panel is ready. Let's bring in your data.",
package/src/locales/es.ts CHANGED
@@ -533,7 +533,6 @@ export const es: RebaseTranslations = {
533
533
  add_your: "Añade tus",
534
534
  database_collections: "colecciones de base de datos",
535
535
  no_unmapped_collections: "No hay colecciones sin mapear en la base de datos",
536
- query_and_update_with_datatalk: "Consulta y actualiza tus datos en lenguaje natural con",
537
536
 
538
537
  welcome_to_rebase: "Bienvenido a Rebase Cloud",
539
538
  admin_panel_ready_bring_data: "Tu panel de administración está listo. Traigamos tus datos.",
package/src/locales/fr.ts CHANGED
@@ -523,7 +523,6 @@ export const fr: RebaseTranslations = {
523
523
  add_your: "Ajoutez vos",
524
524
  database_collections: "collections de base de données",
525
525
  no_unmapped_collections: "Aucune collection non mappée",
526
- query_and_update_with_datatalk: "Interrogez et mettez à jour vos données en langage naturel avec",
527
526
  welcome_to_rebase: "Bienvenue sur Rebase Cloud",
528
527
  admin_panel_ready_bring_data: "Votre panneau d'administration est prêt. Ajoutons vos données.",
529
528
  admin_panel_ready_get_started: "Votre panneau d'administration est prêt. Voici comment démarrer.",
package/src/locales/hi.ts CHANGED
@@ -523,7 +523,6 @@ export const hi: RebaseTranslations = {
523
523
  add_your: "अपने",
524
524
  database_collections: "डेटाबेस संग्रह",
525
525
  no_unmapped_collections: "कोई असंबद्ध संग्रह नहीं",
526
- query_and_update_with_datatalk: "DATATALK के साथ प्राकृतिक भाषा में अपना डेटा क्वेरी और अपडेट करें",
527
526
  welcome_to_rebase: "Rebase में आपका स्वागत है",
528
527
  admin_panel_ready_bring_data: "आपका पैनल तैयार है। अपना डेटा जोड़कर शुरू करें।",
529
528
  admin_panel_ready_get_started: "शुरू करें",
package/src/locales/it.ts CHANGED
@@ -523,7 +523,6 @@ export const it: RebaseTranslations = {
523
523
  add_your: "Aggiungi le tue",
524
524
  database_collections: "collezioni del database",
525
525
  no_unmapped_collections: "Nessuna collezione non mappata",
526
- query_and_update_with_datatalk: "Interroga e aggiorna i tuoi dati in linguaggio naturale con DATATALK",
527
526
  welcome_to_rebase: "Benvenuto in Rebase Cloud",
528
527
  admin_panel_ready_bring_data: "Il tuo pannello è pronto. Inizia aggiungendo i tuoi dati.",
529
528
  admin_panel_ready_get_started: "Il tuo pannello è pronto. Ecco come iniziare.",
package/src/locales/pt.ts CHANGED
@@ -530,7 +530,6 @@ export const pt: RebaseTranslations = {
530
530
  add_your: "Adicione as suas",
531
531
  database_collections: "coleções da base de dados",
532
532
  no_unmapped_collections: "Sem coleções não mapeadas na base de dados",
533
- query_and_update_with_datatalk: "Consulte e atualize os seus dados em linguagem natural com",
534
533
 
535
534
  welcome_to_rebase: "Bem-vindo ao Rebase Cloud",
536
535
  admin_panel_ready_bring_data: "O seu painel de administração está pronto. Vamos importar os seus dados.",
package/src/util/index.ts CHANGED
@@ -10,3 +10,4 @@ export * from "./useStorageUploadController";
10
10
  export * from "./previews";
11
11
  export * from "./enums";
12
12
  export * from "./constants";
13
+ export * from "./local_storage";
@@ -0,0 +1,66 @@
1
+ /**
2
+ * localStorage that tolerates not being there.
3
+ *
4
+ * `typeof window !== "undefined"` was the guard these call sites used, and it
5
+ * answers the wrong question: it says "am I in a browser", not "can I read
6
+ * storage". Three things make that distinction real rather than theoretical:
7
+ *
8
+ * - A browser can have storage **disabled**. Safari in private mode, a blocked
9
+ * third-party cookie policy, and a sandboxed iframe all give you a `window`
10
+ * whose `localStorage` property *throws on access* — a SecurityError raised
11
+ * before any method is called, which no amount of null-checking the result
12
+ * catches.
13
+ * - A test environment can be **half torn down**. jsdom is disposed at the end
14
+ * of a file while React is still finishing a concurrent render, so `window`
15
+ * survives as a husk and `localStorage.getItem` is no longer a function.
16
+ * That is how this was found: `TypeError: localStorage.getItem is not a
17
+ * function`, thrown out of a render, failing a suite in which every one of
18
+ * 709 tests passed.
19
+ * - Server rendering has no `window` at all, which is the only case the old
20
+ * guard actually covered.
21
+ *
22
+ * Reading a UI preference is never worth a crash. Every function here fails to
23
+ * `null` / no-op, so a user with storage switched off gets the default
24
+ * appearance instead of a blank page.
25
+ */
26
+
27
+ /** The Storage object, or null when it is absent, blocked, or not usable. */
28
+ function usableStorage(): Storage | null {
29
+ try {
30
+ if (typeof window === "undefined") return null;
31
+ const candidate = window.localStorage;
32
+ // Not `!= null`: a torn-down jsdom leaves an object behind whose
33
+ // methods are gone, which is exactly the shape that threw.
34
+ return typeof candidate?.getItem === "function" ? candidate : null;
35
+ } catch {
36
+ // Access itself throws when storage is blocked by policy.
37
+ return null;
38
+ }
39
+ }
40
+
41
+ /** The stored string for `key`, or null if it is unset or unreadable. */
42
+ export function readStoredString(key: string): string | null {
43
+ try {
44
+ return usableStorage()?.getItem(key) ?? null;
45
+ } catch {
46
+ return null;
47
+ }
48
+ }
49
+
50
+ /** Persist `value` under `key`. A no-op when storage is unavailable. */
51
+ export function writeStoredString(key: string, value: string): void {
52
+ try {
53
+ usableStorage()?.setItem(key, value);
54
+ } catch {
55
+ // Also the quota path: a full store throws on write but reads fine.
56
+ }
57
+ }
58
+
59
+ /** Remove `key`. A no-op when storage is unavailable. */
60
+ export function removeStoredString(key: string): void {
61
+ try {
62
+ usableStorage()?.removeItem(key);
63
+ } catch {
64
+ /* nothing to undo */
65
+ }
66
+ }