@olonjs/react 0.1.1 → 0.1.3

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/dist/index.d.ts CHANGED
@@ -12,14 +12,57 @@ import { MenuItem } from '@olonjs/core';
12
12
  import { PageConfig } from '@olonjs/core';
13
13
  import { PageMeta } from '@olonjs/core';
14
14
  import { PageRendererProps } from '@olonjs/core';
15
+ import { ProjectState } from '@olonjs/core';
15
16
  import { ReactNode } from 'react';
16
17
  import { Section } from '@olonjs/core';
17
18
  import { SiteConfig } from '@olonjs/core';
18
19
  import { StudioRouteBodyProps } from '@olonjs/studio';
19
20
  import { ThemeConfig } from '@olonjs/core';
20
21
 
22
+ /**
23
+ * Prefer …/api/v1, keep raw base as fallback candidate.
24
+ */
25
+ export declare function buildApiCandidates(raw: string): string[];
26
+
21
27
  export { buildThemeVariableMap }
22
28
 
29
+ /**
30
+ * Cloud policy — single explicit contract for boot vs save.
31
+ *
32
+ * Boot and save are different:
33
+ * - bootSource: where content loads at startup (only Save2Repo yes/no among cloud modes)
34
+ * - hotSave / coldSave: what Studio may persist (Hot stays on whenever credentials exist)
35
+ */
36
+ export declare type CloudBootSource = 'local' | 'live' | 'static';
37
+
38
+ export declare type CloudEnvInput = {
39
+ /** Cloud API base URL (trimmed). Empty ⇒ no cloud credentials. */
40
+ apiUrl: string;
41
+ /** Bearer API key (trimmed). Empty ⇒ no cloud credentials. */
42
+ apiKey: string;
43
+ /** True when VITE_SAVE2REPO === 'true'. */
44
+ save2RepoFlag: boolean;
45
+ };
46
+
47
+ export declare type CloudPolicy = {
48
+ /** Has both URL and API key. */
49
+ isCloudMode: boolean;
50
+ /**
51
+ * Startup content source — decided only by credentials + Save2Repo:
52
+ * local (no cloud) | live (cloud, no Save2Repo) | static (Save2Repo on).
53
+ */
54
+ bootSource: CloudBootSource;
55
+ /** Hot save allowed whenever cloud credentials exist (also with Save2Repo). */
56
+ hotSaveEnabled: boolean;
57
+ /** Cold / Save2Repo save when cloud credentials exist AND save2RepoFlag. */
58
+ save2RepoEnabled: boolean;
59
+ showLocalSave: boolean;
60
+ showHotSave: boolean;
61
+ showColdSave: boolean;
62
+ apiUrl: string;
63
+ apiKey: string;
64
+ };
65
+
23
66
  export declare interface ConfigContextValue {
24
67
  registry: Registry;
25
68
  schemas: Schemas;
@@ -34,6 +77,31 @@ export declare const ConfigProvider: default_2.FC<{
34
77
  children: default_2.ReactNode;
35
78
  }>;
36
79
 
80
+ /**
81
+ * Studio HotSave — POST `{apiUrl}/hotSave` with Bearer key.
82
+ *
83
+ * Explicit: this only performs the live write. UI visibility is
84
+ * `CloudPolicy.showHotSave` / `hotSaveEnabled` (credentials ⇒ on, including dual Save2Repo).
85
+ */
86
+ export declare function createHotSaveHandler(options: CreateHotSaveHandlerOptions): HotSaveHandler;
87
+
88
+ export declare type CreateHotSaveHandlerOptions = {
89
+ apiUrl: string;
90
+ apiKey: string;
91
+ /** Injected for tests; defaults to global fetch. */
92
+ fetchImpl?: typeof fetch;
93
+ /**
94
+ * DNA hook after a successful hot save (e.g. local cloud cache).
95
+ * Not required for the HTTP contract itself.
96
+ */
97
+ onSuccess?: (ctx: {
98
+ state: ProjectState;
99
+ slug: string;
100
+ apiUrl: string;
101
+ apiKey: string;
102
+ }) => void | Promise<void>;
103
+ };
104
+
37
105
  export declare const DefaultNotFound: default_2.FC;
38
106
 
39
107
  /**
@@ -64,6 +132,8 @@ export declare interface FormState {
64
132
 
65
133
  export declare type FormStatus = 'idle' | 'submitting' | 'success' | 'error';
66
134
 
135
+ export declare type HotSaveHandler = (state: ProjectState, slug: string) => Promise<void>;
136
+
67
137
  export declare type IconRegistry = Record<string, LucideIcon>;
68
138
 
69
139
  export declare const IconRegistryContext: Context<IconRegistry>;
@@ -104,8 +174,19 @@ declare type Props = PageRendererProps & {
104
174
  onActiveSectionChange?: (sectionId: string | null) => void;
105
175
  };
106
176
 
177
+ /**
178
+ * Map Vite env bag → CloudEnvInput.
179
+ * Caller passes `import.meta.env` from the app (keeps this package free of ImportMeta coupling).
180
+ */
181
+ export declare function readCloudEnvFromVite(env: ViteCloudEnvBag): CloudEnvInput;
182
+
107
183
  declare type Registry = JsonPagesConfig['registry'];
108
184
 
185
+ /**
186
+ * Pure policy. Pass env in — do not read import.meta.env here.
187
+ */
188
+ export declare function resolveCloudPolicy(input: CloudEnvInput): CloudPolicy;
189
+
109
190
  declare type Schemas = JsonPagesConfig['schemas'];
110
191
 
111
192
  export declare const SectionRenderer: default_2.FC<SectionRendererProps>;
@@ -191,4 +272,7 @@ export declare interface VisitorRouteProps {
191
272
  NotFoundComponent: default_2.ComponentType;
192
273
  }
193
274
 
275
+ /** Vite `import.meta.env` bag (caller-supplied; no ImportMeta in this package). */
276
+ export declare type ViteCloudEnvBag = Record<string, unknown>;
277
+
194
278
  export { }