@arcote.tech/arc-react 0.0.13 → 0.0.15

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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -128,24 +128,27 @@ model
128
128
  } from "@arcote.tech/arc";
129
129
  import {createContext, useContext, useEffect, useRef, useState} from "react";
130
130
  import {
131
- jsxDEV
132
- } from "react/jsx-dev-runtime";
131
+ jsx
132
+ } from "react/jsx-runtime";
133
133
  var reactModel = (context, dependecies) => {
134
134
  const LiveModelContext = createContext(null);
135
+ let localClient;
135
136
  return [
136
137
  function LiveModelProvider(props) {
137
138
  const [client, setClient] = useState(null);
138
139
  const clientRef = useRef(null);
139
140
  useEffect(() => {
141
+ console.log("test");
140
142
  if (clientRef.current)
141
143
  return;
142
144
  const client2 = model(context, dependecies);
143
145
  clientRef.current = client2;
144
146
  setClient(client2);
147
+ localClient = client2;
145
148
  }, []);
146
149
  if (!client)
147
150
  return "Ekran \u0142adowania";
148
- return /* @__PURE__ */ jsxDEV(LiveModelContext.Provider, {
151
+ return /* @__PURE__ */ jsx(LiveModelContext.Provider, {
149
152
  value: {
150
153
  client
151
154
  },
@@ -177,6 +180,24 @@ var reactModel = (context, dependecies) => {
177
180
  if (!context2)
178
181
  throw new Error("useCommands must be used within a LiveModelProvider");
179
182
  return context2.client.commands();
183
+ },
184
+ function query(queryBuilder) {
185
+ return new Promise((resolve, reject) => {
186
+ if (!localClient) {
187
+ reject(new Error("Client is not initialized"));
188
+ return;
189
+ }
190
+ const query = localClient.query(queryBuilder);
191
+ const subscription = query.result$.subscribe({
192
+ next: (result) => {
193
+ subscription.unsubscribe();
194
+ resolve(result);
195
+ },
196
+ error: (error) => {
197
+ reject(error);
198
+ }
199
+ });
200
+ });
180
201
  }
181
202
  ];
182
203
  };
@@ -185,3 +206,5 @@ export {
185
206
  idbAdapterFactory,
186
207
  formResolver
187
208
  };
209
+
210
+ //# debugId=7BFBB6B196E11E8364756E2164756E21
package/package.json CHANGED
@@ -4,12 +4,12 @@
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
7
- "version": "0.0.13",
7
+ "version": "0.0.15",
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.",
11
11
  "scripts": {
12
- "build": "bun build --target=node ./index.ts --outfile=dist/index.js --external react --external rxjs --external @arcote.tech/arc && bun run build:declaration",
12
+ "build": "bun run ./build.ts && bun run build:declaration",
13
13
  "build:declaration": "tsc --emitDeclarationOnly --project tsconfig.types.json",
14
14
  "postbuild": "rimraf tsconfig.types.tsbuildinfo",
15
15
  "type-check": "tsc",
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from "./form.ts";
2
- export * from "./idb.ts";
3
- export * from "./reactModel.tsx";
@@ -1,4 +0,0 @@
1
- import { type ArcContextWithCommandsAny, type ArcModelDependencies, type GetAnyCollectionQueryResult, type QueryFactoryFunction } from "@arcote.tech/arc";
2
- export declare const reactModel: <C extends ArcContextWithCommandsAny>(context: C, dependecies: ArcModelDependencies<C>) => readonly [(props: {
3
- children: React.ReactNode;
4
- }) => "Ekran ładowania" | import("react/jsx-runtime").JSX.Element, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilder: QueryBuilderFn, dependencies?: any[]) => [GetAnyCollectionQueryResult<QueryBuilderFn>, false] | [null, true], () => import("@arcote.tech/arc/dist/context/commands").CommandsClient<C["commands"]>];