@arcote.tech/arc-react 0.1.0 → 0.1.1
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 +15 -7
- package/dist/reactModel.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -175,29 +175,37 @@ var sqliteWasmAdapterFactory = (db) => {
|
|
|
175
175
|
|
|
176
176
|
// reactModel.tsx
|
|
177
177
|
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
178
|
-
var reactModel = (
|
|
178
|
+
var reactModel = (arcContextPromise, options) => {
|
|
179
179
|
const LiveModelContext = createContext3(null);
|
|
180
180
|
const LocalModelContext = createContext3(null);
|
|
181
181
|
let masterModel = null;
|
|
182
182
|
return [
|
|
183
183
|
function LiveModelProvider(props) {
|
|
184
|
+
const [context, setContext] = useState2(null);
|
|
185
|
+
useEffect2(() => {
|
|
186
|
+
arcContextPromise.then((arcContext) => {
|
|
187
|
+
setContext(arcContext);
|
|
188
|
+
});
|
|
189
|
+
}, [arcContextPromise]);
|
|
184
190
|
const model = useMemo3(() => {
|
|
185
191
|
if (typeof window === "undefined")
|
|
186
192
|
return null;
|
|
187
193
|
if (masterModel)
|
|
188
194
|
return masterModel;
|
|
195
|
+
if (!context)
|
|
196
|
+
return null;
|
|
189
197
|
if ("remoteUrl" in options) {
|
|
190
|
-
const model2 = new RemoteModelClient(
|
|
198
|
+
const model2 = new RemoteModelClient(context, options.remoteUrl, props.client, props.catchErrorCallback);
|
|
191
199
|
masterModel = model2;
|
|
192
200
|
return model2;
|
|
193
201
|
} else {
|
|
194
|
-
const dbAdapterPromise = sqliteWasmAdapterFactory(options.sqliteAdapter)(
|
|
195
|
-
const dataStorage = new MasterDataStorage(dbAdapterPromise, rtcClientFactory(props.token),
|
|
196
|
-
const model2 = new Model(
|
|
202
|
+
const dbAdapterPromise = sqliteWasmAdapterFactory(options.sqliteAdapter)(context);
|
|
203
|
+
const dataStorage = new MasterDataStorage(dbAdapterPromise, rtcClientFactory(props.token), context);
|
|
204
|
+
const model2 = new Model(context, dataStorage, props.client, props.catchErrorCallback);
|
|
197
205
|
masterModel = model2;
|
|
198
206
|
return model2;
|
|
199
207
|
}
|
|
200
|
-
}, [
|
|
208
|
+
}, [context, options, props.client]);
|
|
201
209
|
const [syncProgress, setSyncProgress] = useState2([]);
|
|
202
210
|
const [syncDone, setSyncDone] = useState2(false);
|
|
203
211
|
useEffect2(() => {
|
|
@@ -296,4 +304,4 @@ export {
|
|
|
296
304
|
Form
|
|
297
305
|
};
|
|
298
306
|
|
|
299
|
-
//# debugId=
|
|
307
|
+
//# debugId=1DFCDB435242322064756E2164756E21
|
package/dist/reactModel.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ForkedModel, type ArcContextAny, type IArcQueryBuilder, type ModelBase, type QueryBuilderFunctionResult, type QueryFactoryFunction, type UnaryFunction } from "@arcote.tech/arc";
|
|
2
2
|
import type { SQLiteDatabase } from "@arcote.tech/arc";
|
|
3
|
-
export declare const reactModel: <C extends ArcContextAny>(
|
|
3
|
+
export declare const reactModel: <C extends ArcContextAny>(arcContextPromise: Promise<C>, options: {
|
|
4
4
|
sqliteAdapter: SQLiteDatabase;
|
|
5
5
|
} | {
|
|
6
6
|
remoteUrl: 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.1.
|
|
7
|
+
"version": "0.1.1",
|
|
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.",
|