@arcote.tech/platform 0.5.6 → 0.5.7
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/package.json +4 -4
- package/src/index.ts +3 -0
- package/src/platform-app.tsx +13 -5
- package/src/registry.ts +28 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcote.tech/platform",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.7",
|
|
5
5
|
"private": false,
|
|
6
6
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
7
7
|
"description": "Arc Platform — module system, router, layout, theme, i18n, platform app shell",
|
|
@@ -18,11 +18,11 @@
|
|
|
18
18
|
"type-check": "tsc --noEmit"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@arcote.tech/arc-ds": "^0.5.
|
|
22
|
-
"@arcote.tech/arc-react": "^0.5.
|
|
21
|
+
"@arcote.tech/arc-ds": "^0.5.7",
|
|
22
|
+
"@arcote.tech/arc-react": "^0.5.7"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@arcote.tech/arc": "^0.5.
|
|
25
|
+
"@arcote.tech/arc": "^0.5.7",
|
|
26
26
|
"@lingui/core": "^5.0.0",
|
|
27
27
|
"@lingui/react": "^5.0.0",
|
|
28
28
|
"framer-motion": "^12.0.0",
|
package/src/index.ts
CHANGED
|
@@ -18,6 +18,7 @@ export {
|
|
|
18
18
|
getDefaultLayout,
|
|
19
19
|
getModule,
|
|
20
20
|
getPageByPath,
|
|
21
|
+
getPlatformConfig,
|
|
21
22
|
getPageFragments,
|
|
22
23
|
getSlotFragments,
|
|
23
24
|
getVariantOverrides,
|
|
@@ -25,6 +26,7 @@ export {
|
|
|
25
26
|
registerModule,
|
|
26
27
|
setContext,
|
|
27
28
|
setDefaultLayout,
|
|
29
|
+
setPlatformConfig,
|
|
28
30
|
setVariantOverrides,
|
|
29
31
|
subscribe,
|
|
30
32
|
subscribeContext,
|
|
@@ -95,6 +97,7 @@ export { loadModules, reloadModules, syncModules, useModuleLoader } from "./modu
|
|
|
95
97
|
export type { ModuleLoaderState, ModuleManifest } from "./module-loader";
|
|
96
98
|
export { PlatformApp } from "./platform-app";
|
|
97
99
|
export type { PlatformAppProps } from "./platform-app";
|
|
100
|
+
export type { PlatformConfig, PlatformStorageConfig } from "./registry";
|
|
98
101
|
export {
|
|
99
102
|
PlatformModelProvider,
|
|
100
103
|
usePlatformResetModel,
|
package/src/platform-app.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArcContextAny } from "@arcote.tech/arc";
|
|
1
|
+
import type { ArcContextAny, DBAdapterFactory } from "@arcote.tech/arc";
|
|
2
2
|
import type { DSVariantOverrides } from "@arcote.tech/arc-ds";
|
|
3
3
|
import { DesignSystemProvider, TooltipProvider } from "@arcote.tech/arc-ds";
|
|
4
4
|
import { reactModel } from "@arcote.tech/arc-react";
|
|
@@ -8,6 +8,7 @@ import { PageRouter } from "./layout/page-router";
|
|
|
8
8
|
import { I18nProvider } from "./i18n";
|
|
9
9
|
import {
|
|
10
10
|
getContext,
|
|
11
|
+
getPlatformConfig,
|
|
11
12
|
getVariantOverrides,
|
|
12
13
|
getWrapperFragments,
|
|
13
14
|
setDefaultLayout,
|
|
@@ -104,10 +105,17 @@ function PlatformAppInner({
|
|
|
104
105
|
|
|
105
106
|
const i18nConfig = useI18nConfig(apiUrl);
|
|
106
107
|
|
|
107
|
-
const model = useMemo(
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
const model = useMemo(() => {
|
|
109
|
+
const cfg = getPlatformConfig();
|
|
110
|
+
if (cfg.storage?.mode === "local") {
|
|
111
|
+
// Local-only: SQLite WASM (lub inny lokalny adapter) w przeglądarce,
|
|
112
|
+
// bez WS sync. Apka musi dostarczyć dbAdapterFactory przez setPlatformConfig.
|
|
113
|
+
return reactModel(context, {
|
|
114
|
+
dbAdapterFactory: cfg.storage.dbAdapterFactory as DBAdapterFactory,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
return reactModel(context, { remoteUrl: wsUrl });
|
|
118
|
+
}, [context, wsUrl]);
|
|
111
119
|
|
|
112
120
|
const {
|
|
113
121
|
ModelProvider,
|
package/src/registry.ts
CHANGED
|
@@ -156,6 +156,34 @@ export function getDefaultLayout(): ArcLayoutComponent | null {
|
|
|
156
156
|
return defaultLayout;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
// Platform config — opt-in dla local-only mode + custom dbAdapter
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
|
|
163
|
+
export interface PlatformStorageConfig {
|
|
164
|
+
/** "remote" = klient łączy się z hostem przez WS (default).
|
|
165
|
+
* "local" = SQLite WASM w przeglądarce, bez sync. */
|
|
166
|
+
mode: "remote" | "local";
|
|
167
|
+
/** Wymagane gdy mode="local" — async factory zwracająca DatabaseAdapter. */
|
|
168
|
+
dbAdapterFactory?: unknown;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface PlatformConfig {
|
|
172
|
+
storage?: PlatformStorageConfig;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let platformConfig: PlatformConfig = {};
|
|
176
|
+
|
|
177
|
+
/** Set platform config (storage mode etc.). Wywołaj ZANIM PlatformApp się
|
|
178
|
+
* zamontuje — najlepiej w side-effect importu modułu. */
|
|
179
|
+
export function setPlatformConfig(config: PlatformConfig): void {
|
|
180
|
+
platformConfig = { ...platformConfig, ...config };
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export function getPlatformConfig(): PlatformConfig {
|
|
184
|
+
return platformConfig;
|
|
185
|
+
}
|
|
186
|
+
|
|
159
187
|
// ---------------------------------------------------------------------------
|
|
160
188
|
// Variant overrides — moduły rejestrują nadpisania wariantów DS
|
|
161
189
|
// ---------------------------------------------------------------------------
|