@arcote.tech/arc-react 0.1.10 → 0.3.0

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
@@ -1,8 +1,8 @@
1
1
  'use client';
2
- // form/field.tsx
2
+ // src/form/field.tsx
3
3
  import { createContext as createContext3, useCallback as useCallback3, useContext as useContext2, useMemo as useMemo2 } from "react";
4
4
 
5
- // form/form.tsx
5
+ // src/form/form.tsx
6
6
  import {
7
7
  deepMerge
8
8
  } from "@arcote.tech/arc";
@@ -165,7 +165,7 @@ var Form = forwardRef(function Form2(props, ref) {
165
165
  }, undefined, false, undefined, this);
166
166
  });
167
167
 
168
- // form/form-part.tsx
168
+ // src/form/form-part.tsx
169
169
  import React2, { createContext as createContext2, useCallback as useCallback2, useContext, useState as useState2 } from "react";
170
170
  import { jsx as jsx2 } from "react/jsx-runtime";
171
171
  var FormPartContext = createContext2(null);
@@ -219,7 +219,7 @@ function useFormPartField(fieldName) {
219
219
  return context;
220
220
  }
221
221
 
222
- // form/field.tsx
222
+ // src/form/field.tsx
223
223
  import { jsx as jsx3 } from "react/jsx-runtime";
224
224
  function getNestedValue2(obj, path) {
225
225
  return path.split(".").reduce((current, key) => current?.[key], obj);
@@ -282,16 +282,7 @@ function FormField(name, defaultValue, subFields) {
282
282
  }, undefined, false, undefined, this);
283
283
  };
284
284
  }
285
- // form/legacy_form_resolver.ts
286
- function formResolver(schema) {
287
- return async (data) => {
288
- return {
289
- values: data,
290
- errors: {}
291
- };
292
- };
293
- }
294
- // form/message.tsx
285
+ // src/form/message.tsx
295
286
  import { jsx as jsx4 } from "react/jsx-runtime";
296
287
  function FormMessage({ ...props }) {
297
288
  const { messages } = useFormField();
@@ -303,213 +294,253 @@ function FormMessage({ ...props }) {
303
294
  }, undefined, false, undefined, this);
304
295
  }
305
296
  FormMessage.displayName = "FormMessage";
306
- // reactModel.tsx
297
+ // src/factories/model-provider-factory.tsx
307
298
  import {
299
+ AuthAdapter,
300
+ CommandWire,
301
+ EventWire,
302
+ LocalEventPublisher,
308
303
  MasterDataStorage,
309
- Model,
310
- RemoteModelClient,
311
- rtcClientFactory
312
- } from "@arcote.tech/arc";
313
- import {
314
- createContext as createContext4,
315
- useCallback as useCallback4,
316
- useContext as useContext3,
317
- useEffect as useEffect2,
318
- useMemo as useMemo3,
319
- useRef,
320
- useState as useState3
321
- } from "react";
322
-
323
- // sqliteWasmAdapter.ts
324
- import {
325
- createSQLiteAdapterFactory
304
+ Model
326
305
  } from "@arcote.tech/arc";
327
- var sqliteWasmAdapterFactory = (db) => {
328
- return async (context) => {
329
- return createSQLiteAdapterFactory(db)(context);
330
- };
331
- };
332
-
333
- // reactModel.tsx
306
+ import { createContext as createContext4, useContext as useContext3, useEffect as useEffect2, useState as useState3 } from "react";
334
307
  import { jsx as jsx5 } from "react/jsx-runtime";
335
- var reactModel = (arcContext, options) => {
336
- const LiveModelContext = createContext4(null);
337
- const LocalModelContext = createContext4(null);
338
- let masterModel = null;
339
- return [
340
- function LiveModelProvider(props) {
341
- const [context, setContext] = useState3(null);
342
- useEffect2(() => {
343
- setContext(arcContext);
344
- }, [arcContext]);
345
- useEffect2(() => {
346
- model?.setAuthToken(props.token);
347
- }, [props.token]);
348
- const model = useMemo3(() => {
349
- if (typeof window === "undefined")
350
- return null;
351
- if (masterModel)
352
- return masterModel;
353
- if (!context)
354
- return null;
355
- if ("remoteUrl" in options) {
356
- const model2 = new RemoteModelClient(context, options.remoteUrl, props.client, props.catchErrorCallback);
357
- masterModel = model2;
358
- return model2;
359
- } else {
360
- const dbAdapterPromise = sqliteWasmAdapterFactory(options.sqliteAdapter)(context);
361
- const dataStorage = new MasterDataStorage(dbAdapterPromise, rtcClientFactory(props.token), context);
362
- const model2 = new Model(context, dataStorage, props.catchErrorCallback);
363
- masterModel = model2;
364
- return model2;
365
- }
366
- }, [context, options, props.client]);
367
- const [syncProgress, setSyncProgress] = useState3([]);
368
- const [syncDone, setSyncDone] = useState3(false);
369
- useEffect2(() => {
370
- if (typeof window === "undefined" || !model)
371
- return;
372
- const sync = async () => {
373
- if (!("dataStorage" in model))
374
- return setSyncDone(true);
375
- await model.dataStorage.sync(({ store, size }) => {
376
- setSyncProgress((prev) => [...prev, { store, size }]);
377
- });
378
- setSyncDone(true);
379
- };
380
- sync();
381
- }, [model]);
382
- if (!model || !syncDone)
383
- return props.syncView ? /* @__PURE__ */ jsx5(props.syncView, {
384
- progress: syncProgress
385
- }, undefined, false, undefined, this) : null;
386
- return /* @__PURE__ */ jsx5(LiveModelContext.Provider, {
387
- value: model,
388
- children: props.children
389
- }, undefined, false, undefined, this);
390
- },
391
- function LocalModelProvider({ children }) {
392
- const parentModel = useContext3(LiveModelContext);
393
- if (!parentModel || !(parentModel instanceof Model)) {
394
- throw new Error("LocalModelProvider must be used within a LiveModelProvider");
395
- }
396
- const [localModel] = useState3(() => parentModel);
397
- return /* @__PURE__ */ jsx5(LocalModelContext.Provider, {
398
- value: localModel,
399
- children
400
- }, undefined, false, undefined, this);
401
- },
402
- function useQuery(queryBuilderFn, dependencies = [], cacheKey) {
403
- const model = useContext3(LocalModelContext) || useContext3(LiveModelContext);
404
- if (!model) {
405
- throw new Error("useQuery must be used within a ModelProvider");
308
+ var modelProviderFactory = (context, options) => {
309
+ const ModelContext = createContext4(null);
310
+ const commandWire = options.remoteUrl ? new CommandWire(options.remoteUrl) : undefined;
311
+ const eventWire = options.remoteUrl ? new EventWire(options.remoteUrl) : undefined;
312
+ const authAdapter = new AuthAdapter;
313
+ let initialized = false;
314
+ let cachedModel = null;
315
+ let cachedDataStorage = null;
316
+ let onResetCallback = null;
317
+ function ModelProvider(props) {
318
+ const [model, setModel] = useState3(cachedModel);
319
+ const [resetTrigger, setResetTrigger] = useState3(0);
320
+ useEffect2(() => {
321
+ onResetCallback = () => {
322
+ setModel(null);
323
+ setResetTrigger((prev) => prev + 1);
324
+ };
325
+ return () => {
326
+ onResetCallback = null;
327
+ };
328
+ }, []);
329
+ useEffect2(() => {
330
+ if (initialized && cachedModel) {
331
+ setModel(cachedModel);
332
+ return;
406
333
  }
407
- const [loading, setLoading] = useState3(true);
408
- const [result, setResult] = useState3(null);
409
- const [revalidationTrigger, setRevalidationTrigger] = useState3(0);
410
- const unsubscribeRef = useRef(null);
411
- const queryPromiseRef = useRef(null);
412
- const resolvePromiseRef = useRef(null);
413
- useEffect2(() => {
414
- if (cacheKey) {
415
- if (!model.__cacheRegistry) {
416
- model.__cacheRegistry = new Map;
417
- }
418
- if (!model.__cacheRegistry.has(cacheKey)) {
419
- model.__cacheRegistry.set(cacheKey, new Set);
420
- }
421
- const revalidateFn = async () => {
422
- const promise = new Promise((resolve) => {
423
- resolvePromiseRef.current = resolve;
424
- });
425
- queryPromiseRef.current = promise;
426
- setRevalidationTrigger((prev) => prev + 1);
427
- return promise;
428
- };
429
- model.__cacheRegistry.get(cacheKey).add(revalidateFn);
430
- return () => {
431
- const registry = model.__cacheRegistry?.get(cacheKey);
432
- if (registry) {
433
- registry.delete(revalidateFn);
434
- if (registry.size === 0) {
435
- model.__cacheRegistry.delete(cacheKey);
334
+ initialized = true;
335
+ let cancelled = false;
336
+ async function initializeModel() {
337
+ let dataStorage;
338
+ let eventPublisher;
339
+ if (options.dbAdapterFactory) {
340
+ const databaseAdapter = await options.dbAdapterFactory(context);
341
+ if (cancelled)
342
+ return;
343
+ if (databaseAdapter) {
344
+ dataStorage = new MasterDataStorage(databaseAdapter);
345
+ cachedDataStorage = dataStorage;
346
+ eventPublisher = new LocalEventPublisher(dataStorage);
347
+ const views = context.elements.filter((element) => ("getHandlers" in element) && ("databaseStoreSchema" in element) && ("schema" in element));
348
+ eventPublisher.registerViews(views);
349
+ if (eventWire && eventPublisher) {
350
+ const publisher = eventPublisher;
351
+ const eventsStore = dataStorage.getStore("events");
352
+ const allEvents = await eventsStore.find({});
353
+ const hostEvents = allEvents.filter((e) => typeof e._id === "string" && e._id.startsWith("host_"));
354
+ if (hostEvents.length > 0) {
355
+ hostEvents.sort((a, b) => {
356
+ const aTimestamp = parseInt(a._id.split("_")[2] || "0", 10);
357
+ const bTimestamp = parseInt(b._id.split("_")[2] || "0", 10);
358
+ return bTimestamp - aTimestamp;
359
+ });
360
+ const lastHostEventId = hostEvents[0]._id;
361
+ eventWire.setLastHostEventId(lastHostEventId);
362
+ }
363
+ const eventsFromHost = new Set;
364
+ publisher.onPublish((event) => {
365
+ if (eventsFromHost.has(event.id)) {
366
+ eventsFromHost.delete(event.id);
367
+ return;
368
+ }
369
+ eventWire.syncEvents([
370
+ {
371
+ localId: event.id,
372
+ type: event.type,
373
+ payload: event.payload,
374
+ createdAt: event.createdAt.toISOString()
375
+ }
376
+ ]);
377
+ });
378
+ const processedEvents = new Set;
379
+ let eventQueue = Promise.resolve();
380
+ eventWire.onEvent((event) => {
381
+ eventQueue = eventQueue.then(async () => {
382
+ try {
383
+ if (processedEvents.has(event.hostId)) {
384
+ return;
385
+ }
386
+ processedEvents.add(event.hostId);
387
+ eventsFromHost.add(event.hostId);
388
+ const eventsStore2 = dataStorage?.getStore("events");
389
+ if (eventsStore2) {
390
+ const existing = await eventsStore2.find({
391
+ where: { _id: event.hostId }
392
+ });
393
+ if (existing.length > 0) {
394
+ return;
395
+ }
396
+ }
397
+ await publisher.publish({
398
+ id: event.hostId,
399
+ type: event.type,
400
+ payload: event.payload,
401
+ createdAt: new Date(event.createdAt)
402
+ });
403
+ } catch (error) {
404
+ console.error(`[Arc] Failed to process event ${event.hostId} (${event.type}):`, error, `
405
+ Event payload:`, event.payload);
406
+ processedEvents.delete(event.hostId);
407
+ eventsFromHost.delete(event.hostId);
408
+ }
409
+ });
410
+ });
411
+ if (authAdapter.isAuthenticated()) {
412
+ eventWire.connect();
436
413
  }
437
414
  }
438
- };
439
- }
440
- }, [model, cacheKey]);
441
- useEffect2(() => {
442
- if (unsubscribeRef.current) {
443
- unsubscribeRef.current();
444
- }
445
- const defaultAuthContext = { userId: "react-user" };
446
- const { unsubscribe, result: result2 } = model.subscribe(queryBuilderFn, (newResult) => {
447
- setResult(newResult);
448
- setLoading(false);
449
- if (resolvePromiseRef.current) {
450
- resolvePromiseRef.current();
451
- resolvePromiseRef.current = null;
452
- }
453
- }, defaultAuthContext);
454
- unsubscribeRef.current = unsubscribe;
455
- return () => {
456
- if (unsubscribeRef.current) {
457
- unsubscribeRef.current();
458
- unsubscribeRef.current = null;
459
- }
460
- };
461
- }, [model, revalidationTrigger, ...dependencies]);
462
- return [result, loading];
463
- },
464
- function useRevalidate() {
465
- const model = useContext3(LocalModelContext) || useContext3(LiveModelContext);
466
- if (!model) {
467
- throw new Error("useRevalidate must be used within a ModelProvider");
468
- }
469
- return useCallback4(async (cacheKey) => {
470
- const registry = model.__cacheRegistry;
471
- if (registry && registry.has(cacheKey)) {
472
- const revalidators = registry.get(cacheKey);
473
- if (revalidators) {
474
- const promises = [];
475
- revalidators.forEach((revalidateFn) => {
476
- promises.push(revalidateFn());
477
- });
478
- await Promise.all(promises);
479
415
  }
480
416
  }
481
- }, [model]);
482
- },
483
- function useCommands() {
484
- const model = useContext3(LocalModelContext) || useContext3(LiveModelContext);
485
- if (!model) {
486
- throw new Error("useCommands must be used within a ModelProvider");
417
+ if (cancelled)
418
+ return;
419
+ const newModel = new Model(context, {
420
+ adapters: {
421
+ dataStorage,
422
+ commandWire,
423
+ eventPublisher,
424
+ eventWire,
425
+ authAdapter
426
+ },
427
+ environment: "client"
428
+ });
429
+ await newModel.init();
430
+ if (cancelled)
431
+ return;
432
+ cachedModel = newModel;
433
+ setModel(newModel);
434
+ if (typeof window !== "undefined") {
435
+ window.arcModel = newModel;
436
+ window.arcDataStorage = dataStorage;
437
+ }
487
438
  }
488
- const defaultAuthContext = { userId: "react-user" };
489
- return model.commands(defaultAuthContext);
490
- },
491
- async function query(queryBuilderFn, model) {
492
- if (!model)
493
- model = masterModel;
494
- if (!model)
495
- throw new Error("Model not found");
496
- const defaultAuthContext = { userId: "react-user" };
497
- return model.query(queryBuilderFn, defaultAuthContext);
498
- },
499
- function useLocalModel() {
500
- const model = useContext3(LocalModelContext);
501
- if (!model) {
502
- return null;
439
+ initializeModel();
440
+ return () => {
441
+ cancelled = true;
442
+ eventWire?.disconnect();
443
+ };
444
+ }, [resetTrigger]);
445
+ if (!model)
446
+ return;
447
+ return /* @__PURE__ */ jsx5(ModelContext.Provider, {
448
+ value: model,
449
+ children: props.children
450
+ }, undefined, false, undefined, this);
451
+ }
452
+ function useModel() {
453
+ const model = useContext3(ModelContext);
454
+ if (!model) {
455
+ throw new Error("useModel must be used within a ModelProvider");
456
+ }
457
+ return model;
458
+ }
459
+ function setAuthToken(token) {
460
+ authAdapter.setToken(token);
461
+ commandWire?.setAuthToken(token);
462
+ if (eventWire) {
463
+ eventWire.setAuthToken(token);
464
+ if (token && eventWire.getState() === "disconnected") {
465
+ eventWire.connect();
503
466
  }
504
- return model;
505
- },
506
- function useModel(token) {
507
- const parentModel = useContext3(LiveModelContext);
508
- if (!parentModel)
509
- throw new Error("useModel have to be used in Provider");
510
- return parentModel;
511
467
  }
512
- ];
468
+ }
469
+ async function resetModel() {
470
+ eventWire?.disconnect();
471
+ if (cachedDataStorage) {
472
+ await cachedDataStorage.destroy();
473
+ cachedDataStorage = null;
474
+ }
475
+ cachedModel = null;
476
+ initialized = false;
477
+ authAdapter.setToken(null);
478
+ commandWire?.setAuthToken(null);
479
+ eventWire?.setAuthToken(null);
480
+ if (onResetCallback) {
481
+ onResetCallback();
482
+ }
483
+ }
484
+ function onReset(callback) {
485
+ onResetCallback = callback;
486
+ }
487
+ return {
488
+ ModelProvider,
489
+ useModel,
490
+ commandWire,
491
+ eventWire,
492
+ setAuthToken,
493
+ resetModel,
494
+ onReset
495
+ };
496
+ };
497
+ // src/factories/use-commands-factory.tsx
498
+ import {
499
+ mutationExecutor
500
+ } from "@arcote.tech/arc";
501
+ import { useMemo as useMemo3 } from "react";
502
+ var useCommandsFactory = (useModel) => {
503
+ return function useCommands() {
504
+ const model = useModel();
505
+ return useMemo3(() => mutationExecutor(model), [model]);
506
+ };
507
+ };
508
+ // src/factories/use-query-factory.tsx
509
+ import {
510
+ liveQuery
511
+ } from "@arcote.tech/arc";
512
+ import { useEffect as useEffect3, useState as useState4 } from "react";
513
+ var useQueryFactory = (useModel) => {
514
+ return function useQuery(queryFn, dependencies = []) {
515
+ const model = useModel();
516
+ const [loading, setLoading] = useState4(true);
517
+ const [result, setResult] = useState4(undefined);
518
+ useEffect3(() => {
519
+ const { unsubscribe } = liveQuery(model, queryFn, (newResult) => {
520
+ setResult(newResult);
521
+ setLoading(false);
522
+ });
523
+ return () => {
524
+ unsubscribe();
525
+ };
526
+ }, [model, ...dependencies]);
527
+ return [result, loading];
528
+ };
529
+ };
530
+ // src/react-model.tsx
531
+ var reactModel = (context, options = {}) => {
532
+ const { ModelProvider, useModel, commandWire, setAuthToken, resetModel } = modelProviderFactory(context, options);
533
+ const useQuery = useQueryFactory(useModel);
534
+ const useCommands = useCommandsFactory(useModel);
535
+ return {
536
+ ModelProvider,
537
+ useModel,
538
+ useQuery,
539
+ useCommands,
540
+ commandWire,
541
+ setAuthToken,
542
+ resetModel
543
+ };
513
544
  };
514
545
  export {
515
546
  useFormPartField,
@@ -517,7 +548,6 @@ export {
517
548
  useFormField,
518
549
  useForm,
519
550
  reactModel,
520
- formResolver,
521
551
  FormPartContext,
522
552
  FormPart,
523
553
  FormMessage,
@@ -527,4 +557,4 @@ export {
527
557
  Form
528
558
  };
529
559
 
530
- //# debugId=93653667973401D564756E2164756E21
560
+ //# debugId=7543AFFDBE5BB66264756E2164756E21
@@ -0,0 +1,4 @@
1
+ export * from "./model-provider-factory";
2
+ export * from "./use-commands-factory";
3
+ export * from "./use-query-factory";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import { CommandWire, EventWire, Model, type ArcContextAny } from "@arcote.tech/arc";
2
+ import type { ReactModelOptions } from "../options";
3
+ export declare const modelProviderFactory: <C extends ArcContextAny>(context: C, options: ReactModelOptions) => {
4
+ ModelProvider: (props: {
5
+ children: React.ReactNode;
6
+ }) => import("react/jsx-dev-runtime").JSX.Element | undefined;
7
+ useModel: () => Model<C>;
8
+ commandWire: CommandWire | undefined;
9
+ eventWire: EventWire | undefined;
10
+ setAuthToken: (token: string | null) => void;
11
+ resetModel: () => Promise<void>;
12
+ onReset: (callback: () => void) => void;
13
+ };
14
+ //# sourceMappingURL=model-provider-factory.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { type ArcContextAny, type Model } from "@arcote.tech/arc";
2
+ export declare const useCommandsFactory: <C extends ArcContextAny>(useModel: () => Model<C>) => () => { [Element in C["elements"][number] as Element["mutateContext"] extends (...args: any[]) => infer Return ? Element["name"] : never]: Element["mutateContext"] extends (...args: any[]) => infer Return ? Return : never; } extends infer T ? { [K in keyof T]: T[K]; } : never;
3
+ //# sourceMappingURL=use-commands-factory.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { type ArcContextAny, type Model, type QueryContext } from "@arcote.tech/arc";
2
+ export declare const useQueryFactory: <C extends ArcContextAny>(useModel: () => Model<C>) => <TResult>(queryFn: (q: QueryContext<C>) => Promise<TResult>, dependencies?: any[]) => [TResult | undefined, boolean];
3
+ //# sourceMappingURL=use-query-factory.d.ts.map
@@ -1,6 +1,5 @@
1
1
  export * from "./field";
2
2
  export * from "./form";
3
3
  export * from "./form-part";
4
- export * from "./legacy_form_resolver";
5
4
  export * from "./message";
6
5
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
1
+ export * from "./form/";
2
+ export * from "./options";
3
+ export * from "./react-model";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ import type { DBAdapterFactory } from "@arcote.tech/arc";
2
+ export type ReactModelOptions = {
3
+ dbAdapterFactory?: DBAdapterFactory;
4
+ remoteUrl?: string;
5
+ };
6
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1,17 @@
1
+ import type { ArcContextAny } from "@arcote.tech/arc";
2
+ import type { ReactModelOptions } from "./options";
3
+ export declare const reactModel: <C extends ArcContextAny>(context: C, options?: ReactModelOptions) => {
4
+ readonly ModelProvider: (props: {
5
+ children: React.ReactNode;
6
+ }) => import("react/jsx-dev-runtime").JSX.Element | undefined;
7
+ readonly useModel: () => import("@arcote.tech/arc").Model<C>;
8
+ readonly useQuery: <TResult>(queryFn: (q: { [Element in C["elements"][number] as Element["queryContext"] extends (...args: any[]) => infer Return ? Element["name"] : never]: Element["queryContext"] extends (...args: any[]) => infer Return ? Return : never; } extends infer T ? { [K in keyof T]: T[K]; } : never) => Promise<TResult>, dependencies?: any[]) => [TResult | undefined, boolean];
9
+ readonly useCommands: () => { [Element in C["elements"][number] as Element["mutateContext"] extends (...args: any[]) => infer Return ? Element["name"] : never]: Element["mutateContext"] extends (...args: any[]) => infer Return ? Return : never; } extends infer T ? { [K in keyof T]: T[K]; } : never;
10
+ /** CommandWire instance for remote execution (if remoteUrl provided) */
11
+ readonly commandWire: import("@arcote.tech/arc").CommandWire | undefined;
12
+ /** Set auth token for remote command execution */
13
+ readonly setAuthToken: (token: string | null) => void;
14
+ /** Reset model - destroys local database and disconnects from host */
15
+ readonly resetModel: () => Promise<void>;
16
+ };
17
+ //# sourceMappingURL=react-model.d.ts.map
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-react",
3
3
  "type": "module",
4
- "version": "0.1.10",
4
+ "version": "0.3.0",
5
5
  "private": false,
6
6
  "author": "Przemysław Krasiński [arcote.tech]",
7
7
  "description": "React client for the Arc framework, providing utilities for querying data and executing commands, enhancing the development of reactive and efficient user interfaces.",
8
8
  "main": "./dist/index.js",
9
9
  "module": "./dist/index.js",
10
- "types": "./dist/index.d.ts",
10
+ "types": "./dist/src/index.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/index.d.ts",
13
+ "types": "./dist/src/index.d.ts",
14
14
  "import": "./dist/index.js",
15
15
  "default": "./dist/index.js"
16
16
  }
@@ -22,10 +22,6 @@
22
22
  "type-check": "tsc",
23
23
  "dev": "nodemon --ignore dist -e ts,tsx --exec 'bun run build'"
24
24
  },
25
- "dependencies": {
26
- "react": "^18.3.1",
27
- "react-dom": "^18.3.1"
28
- },
29
25
  "devDependencies": {
30
26
  "@types/bun": "latest",
31
27
  "@types/react": "^18.3.5",
@@ -37,6 +33,8 @@
37
33
  },
38
34
  "peerDependencies": {
39
35
  "@arcote.tech/arc": "latest",
36
+ "react": "^18.0.0",
37
+ "react-dom": "^18.0.0",
40
38
  "typescript": "^5.0.0"
41
39
  },
42
40
  "files": [
@@ -1,6 +0,0 @@
1
- import type { ArcObjectAny } from "@arcote.tech/arc";
2
- export declare function formResolver(schema: ArcObjectAny): (data: any) => Promise<{
3
- values: any;
4
- errors: {};
5
- }>;
6
- //# sourceMappingURL=legacy_form_resolver.d.ts.map
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./form/";
2
- export * from "./reactModel.tsx";
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,21 +0,0 @@
1
- import { Model, type ArcContextAny, type IArcQueryBuilder, type ModelBase, type QueryBuilderFunctionResult, type QueryFactoryFunction, type UnaryFunction } from "@arcote.tech/arc";
2
- import type { ArcContextElementMethodReturnType, objectUtil, SQLiteDatabase } from "@arcote.tech/arc";
3
- export declare const reactModel: <C extends ArcContextAny>(arcContext: C, options: {
4
- sqliteAdapter: SQLiteDatabase;
5
- } | {
6
- remoteUrl: string;
7
- }) => readonly [(props: {
8
- children: React.ReactNode;
9
- client: string;
10
- token: string;
11
- syncView?: React.ComponentType<{
12
- progress: {
13
- store: string;
14
- size: number;
15
- }[];
16
- }>;
17
- catchErrorCallback: (error: any) => void;
18
- }) => import("react/jsx-dev-runtime").JSX.Element | null, ({ children }: {
19
- children: React.ReactNode;
20
- }) => import("react/jsx-dev-runtime").JSX.Element, <Q extends IArcQueryBuilder>(queryBuilderFn: UnaryFunction<ReturnType<C["queryBuilder"]>, Q>, dependencies?: any[], cacheKey?: string) => [objectUtil.simplify<ReturnType<Q["toQuery"]>["lastResult"]>, false] | [undefined, true], () => (cacheKey: string) => Promise<void>, () => ArcContextElementMethodReturnType<C["elements"], "commandClient">, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilderFn: QueryBuilderFn, model?: ModelBase<C> | null) => Promise<QueryBuilderFunctionResult<QueryBuilderFn>>, () => Model<C> | null, (token: string) => ModelBase<C>];
21
- //# sourceMappingURL=reactModel.d.ts.map
@@ -1,4 +0,0 @@
1
- import type { SQLiteDatabase } from "@arcote.tech/arc";
2
- import { type DBAdapterFactory } from "@arcote.tech/arc";
3
- export declare const sqliteWasmAdapterFactory: (db: SQLiteDatabase) => DBAdapterFactory;
4
- //# sourceMappingURL=sqliteWasmAdapter.d.ts.map
File without changes
File without changes
File without changes
File without changes