@arcote.tech/arc-react 0.0.25 → 0.0.27
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.js +13 -8
- package/dist/reactModel.d.ts +1 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -150,7 +150,6 @@ import {
|
|
|
150
150
|
useState
|
|
151
151
|
} from "react";
|
|
152
152
|
import { jsx } from "react/jsx-runtime";
|
|
153
|
-
"use client";
|
|
154
153
|
var reactModel = (arcContext, databaseName) => {
|
|
155
154
|
const LiveModelContext = createContext(null);
|
|
156
155
|
const LocalModelContext = createContext(null);
|
|
@@ -158,31 +157,37 @@ var reactModel = (arcContext, databaseName) => {
|
|
|
158
157
|
return [
|
|
159
158
|
function LiveModelProvider(props) {
|
|
160
159
|
const dataStorage = useMemo(() => {
|
|
160
|
+
if (typeof window === "undefined")
|
|
161
|
+
return null;
|
|
161
162
|
const dbAdapterPromise = idbAdapterFactory(databaseName, arcContext.version)(arcContext);
|
|
162
|
-
const dataStorage2 = new MasterDataStorage(dbAdapterPromise, rtcClientFactory, arcContext);
|
|
163
|
+
const dataStorage2 = new MasterDataStorage(dbAdapterPromise, rtcClientFactory(props.token), arcContext);
|
|
163
164
|
modelMasterDataStorage = dataStorage2;
|
|
164
165
|
return dataStorage2;
|
|
165
166
|
}, [arcContext, databaseName, arcContext.version]);
|
|
166
167
|
const [syncProgress, setSyncProgress] = useState([]);
|
|
167
168
|
const [syncDone, setSyncDone] = useState(false);
|
|
168
169
|
useEffect(() => {
|
|
170
|
+
if (typeof window === "undefined" || !dataStorage)
|
|
171
|
+
return;
|
|
169
172
|
const sync = async () => {
|
|
170
|
-
await dataStorage
|
|
173
|
+
await dataStorage.sync(({ store, size }) => {
|
|
171
174
|
setSyncProgress((prev) => [...prev, { store, size }]);
|
|
172
175
|
});
|
|
173
176
|
setSyncDone(true);
|
|
174
177
|
};
|
|
175
178
|
sync();
|
|
176
|
-
}, []);
|
|
179
|
+
}, [dataStorage]);
|
|
180
|
+
if (!dataStorage || !syncDone)
|
|
181
|
+
return /* @__PURE__ */ jsx(props.syncView, {
|
|
182
|
+
progress: syncProgress
|
|
183
|
+
}, undefined, false, undefined, this);
|
|
177
184
|
return /* @__PURE__ */ jsx(LiveModelContext.Provider, {
|
|
178
185
|
value: {
|
|
179
186
|
dataStorage,
|
|
180
187
|
client: props.client,
|
|
181
188
|
catchErrorCallback: props.catchErrorCallback
|
|
182
189
|
},
|
|
183
|
-
children:
|
|
184
|
-
progress: syncProgress
|
|
185
|
-
}, undefined, false, undefined, this)
|
|
190
|
+
children: props.children
|
|
186
191
|
}, undefined, false, undefined, this);
|
|
187
192
|
},
|
|
188
193
|
function LocalModelProvider({ children }) {
|
|
@@ -262,4 +267,4 @@ export {
|
|
|
262
267
|
formResolver
|
|
263
268
|
};
|
|
264
269
|
|
|
265
|
-
//# debugId=
|
|
270
|
+
//# debugId=A52AEF20E5EEA1DC64756E2164756E21
|
package/dist/reactModel.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ForkedDataStorage, type ArcContextAny, type CommandsClient, type QueryB
|
|
|
2
2
|
export declare const reactModel: <C extends ArcContextAny>(arcContext: C, databaseName: string) => readonly [(props: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
client: string;
|
|
5
|
+
token: string;
|
|
5
6
|
syncView: React.ComponentType<{
|
|
6
7
|
progress: {
|
|
7
8
|
store: string;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.0.
|
|
7
|
+
"version": "0.0.27",
|
|
8
8
|
"private": false,
|
|
9
9
|
"author": "Przemysław Krasiński [arcote.tech]",
|
|
10
10
|
"description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
|