@arcote.tech/arc-react 0.0.14 → 0.0.16
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 +23 -0
- package/dist/reactModel.d.ts +1 -1
- package/package.json +2 -2
- package/dist/build.d.ts +0 -1
package/dist/index.js
CHANGED
|
@@ -132,16 +132,19 @@ jsx
|
|
|
132
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";
|
|
@@ -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=98FDF01FC816B22E64756E2164756E21
|
package/dist/reactModel.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ArcContextWithCommandsAny, type ArcModelDependencies, type GetAnyCollectionQueryResult, type QueryFactoryFunction } from "@arcote.tech/arc";
|
|
2
2
|
export declare const reactModel: <C extends ArcContextWithCommandsAny>(context: C, dependecies: ArcModelDependencies<C>) => readonly [(props: {
|
|
3
3
|
children: React.ReactNode;
|
|
4
|
-
}) => "Ekran ładowania" | import("react/jsx-dev-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"]>];
|
|
4
|
+
}) => "Ekran ładowania" | import("react/jsx-dev-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"]>, <QueryBuilderFn extends QueryFactoryFunction<C>>(queryBuilder: QueryBuilderFn) => Promise<GetAnyCollectionQueryResult<QueryBuilderFn> | null>];
|
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.
|
|
7
|
+
"version": "0.0.16",
|
|
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 run ./build.ts && bun run build:declaration",
|
|
12
|
+
"build": "rm -R dist && 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/build.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|