@arcote.tech/arc-react 0.0.26 → 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 CHANGED
@@ -157,31 +157,37 @@ var reactModel = (arcContext, databaseName) => {
157
157
  return [
158
158
  function LiveModelProvider(props) {
159
159
  const dataStorage = useMemo(() => {
160
+ if (typeof window === "undefined")
161
+ return null;
160
162
  const dbAdapterPromise = idbAdapterFactory(databaseName, arcContext.version)(arcContext);
161
- const dataStorage2 = new MasterDataStorage(dbAdapterPromise, rtcClientFactory, arcContext);
163
+ const dataStorage2 = new MasterDataStorage(dbAdapterPromise, rtcClientFactory(props.token), arcContext);
162
164
  modelMasterDataStorage = dataStorage2;
163
165
  return dataStorage2;
164
166
  }, [arcContext, databaseName, arcContext.version]);
165
167
  const [syncProgress, setSyncProgress] = useState([]);
166
168
  const [syncDone, setSyncDone] = useState(false);
167
169
  useEffect(() => {
170
+ if (typeof window === "undefined" || !dataStorage)
171
+ return;
168
172
  const sync = async () => {
169
- await dataStorage?.sync(({ store, size }) => {
173
+ await dataStorage.sync(({ store, size }) => {
170
174
  setSyncProgress((prev) => [...prev, { store, size }]);
171
175
  });
172
176
  setSyncDone(true);
173
177
  };
174
178
  sync();
175
- }, []);
179
+ }, [dataStorage]);
180
+ if (!dataStorage || !syncDone)
181
+ return /* @__PURE__ */ jsx(props.syncView, {
182
+ progress: syncProgress
183
+ }, undefined, false, undefined, this);
176
184
  return /* @__PURE__ */ jsx(LiveModelContext.Provider, {
177
185
  value: {
178
186
  dataStorage,
179
187
  client: props.client,
180
188
  catchErrorCallback: props.catchErrorCallback
181
189
  },
182
- children: syncDone ? props.children : /* @__PURE__ */ jsx(props.syncView, {
183
- progress: syncProgress
184
- }, undefined, false, undefined, this)
190
+ children: props.children
185
191
  }, undefined, false, undefined, this);
186
192
  },
187
193
  function LocalModelProvider({ children }) {
@@ -261,4 +267,4 @@ export {
261
267
  formResolver
262
268
  };
263
269
 
264
- //# debugId=BD5635FAE340904564756E2164756E21
270
+ //# debugId=A52AEF20E5EEA1DC64756E2164756E21
@@ -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.26",
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.",