@ng-org/orm 0.1.2-alpha.3 → 0.1.2-alpha.5
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.
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type { BaseType } from "@ng-org/shex-orm";
|
|
2
2
|
import type { ShapeType } from "@ng-org/shex-orm";
|
|
3
3
|
import type { Scope } from "../../types.ts";
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param shape The shape type
|
|
7
|
+
* @param scope The document scope (IRI of named graph)
|
|
8
|
+
* @returns A deep signal set with the orm objects, an empty set if still loading,
|
|
9
|
+
* or an empty set which errors on modifications if scope is undefined.
|
|
10
|
+
*/
|
|
11
|
+
declare const useShape: <T extends BaseType>(shape: ShapeType<T>, scope?: Scope | undefined) => import("@ng-org/alien-deepsignals").DeepSignalSet<unknown> | import("@ng-org/alien-deepsignals").DeepSignalSet<T>;
|
|
5
12
|
export default useShape;
|
|
6
13
|
//# sourceMappingURL=useShape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/react/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,QAAO,
|
|
1
|
+
{"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/react/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,QAAO,KAAK,GAAG,SAAc,sHAqBhC,CAAC;AAiBF,eAAe,QAAQ,CAAC"}
|
|
@@ -8,17 +8,41 @@
|
|
|
8
8
|
// according to those terms.
|
|
9
9
|
// SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
10
10
|
import { useDeepSignal } from "@ng-org/alien-deepsignals/react";
|
|
11
|
-
import { useEffect,
|
|
11
|
+
import { useEffect, useMemo } from "react";
|
|
12
12
|
import { createSignalObjectForShape } from "../../connector/createSignalObjectForShape.js";
|
|
13
|
+
/**
|
|
14
|
+
*
|
|
15
|
+
* @param shape The shape type
|
|
16
|
+
* @param scope The document scope (IRI of named graph)
|
|
17
|
+
* @returns A deep signal set with the orm objects, an empty set if still loading,
|
|
18
|
+
* or an empty set which errors on modifications if scope is undefined.
|
|
19
|
+
*/
|
|
13
20
|
const useShape = (shape, scope = "") => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
21
|
+
const signalHandler = useMemo(() => scope === undefined
|
|
22
|
+
? undefined
|
|
23
|
+
: createSignalObjectForShape(shape, scope), [shape, scope]);
|
|
17
24
|
useEffect(() => {
|
|
25
|
+
if (!signalHandler)
|
|
26
|
+
return;
|
|
18
27
|
return () => {
|
|
19
|
-
|
|
28
|
+
signalHandler.stop();
|
|
20
29
|
};
|
|
21
|
-
}, [
|
|
30
|
+
}, [signalHandler]);
|
|
31
|
+
const state = useDeepSignal(signalHandler?.signalObject ?? readOnlySet);
|
|
22
32
|
return state;
|
|
23
33
|
};
|
|
34
|
+
const readOnlySet = new Proxy(new Set(), {
|
|
35
|
+
get(target, key, receiver) {
|
|
36
|
+
if (key === "add" || key === "delete" || key === "clear") {
|
|
37
|
+
return () => {
|
|
38
|
+
throw new Error("Set is readonly because scope is empty.");
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const value = target[key];
|
|
42
|
+
if (typeof value === "function") {
|
|
43
|
+
return value.bind(target);
|
|
44
|
+
}
|
|
45
|
+
return value;
|
|
46
|
+
},
|
|
47
|
+
});
|
|
24
48
|
export default useShape;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ng-org/orm",
|
|
3
|
-
"version": "0.1.2-alpha.
|
|
3
|
+
"version": "0.1.2-alpha.5",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"authors": [
|
|
@@ -29,10 +29,12 @@
|
|
|
29
29
|
"publishConfig": {
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
|
+
"optionalDependencies": {
|
|
33
|
+
"react": "^19.0.0 || ^18.0.0",
|
|
34
|
+
"svelte": "^5.0.0",
|
|
35
|
+
"vue": "^3.0.0"
|
|
36
|
+
},
|
|
32
37
|
"dependencies": {
|
|
33
|
-
"@astrojs/react": "4.3.0",
|
|
34
|
-
"@astrojs/svelte": "7.1.0",
|
|
35
|
-
"@astrojs/vue": "^5.1.0",
|
|
36
38
|
"@gn8/alien-signals-react": "^0.1.1",
|
|
37
39
|
"@gn8/alien-signals-solid": "^0.1.1",
|
|
38
40
|
"@gn8/alien-signals-svelte": "^0.1.1",
|
|
@@ -41,16 +43,11 @@
|
|
|
41
43
|
"@types/react-dom": "19.1.7",
|
|
42
44
|
"@types/shexj": "^2.1.7",
|
|
43
45
|
"alien-signals": "^2.0.7",
|
|
44
|
-
"astro": "5.13.2",
|
|
45
46
|
"install": "^0.13.0",
|
|
46
47
|
"npm": "^11.5.2",
|
|
47
48
|
"prettier-eslint": "^16.4.2",
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"svelte": "5.39.12",
|
|
51
|
-
"vue": "3.5.19",
|
|
52
|
-
"@ng-org/shex-orm": "0.1.2-alpha.1",
|
|
53
|
-
"@ng-org/alien-deepsignals": "0.1.2-alpha.2"
|
|
49
|
+
"@ng-org/shex-orm": "0.1.2-alpha.2",
|
|
50
|
+
"@ng-org/alien-deepsignals": "0.1.2-alpha.3"
|
|
54
51
|
},
|
|
55
52
|
"devDependencies": {
|
|
56
53
|
"@playwright/test": "^1.55.0",
|
|
@@ -60,7 +57,11 @@
|
|
|
60
57
|
"vite": "7.1.3",
|
|
61
58
|
"vitest": "^3.2.4",
|
|
62
59
|
"typescript": "^5.3.0",
|
|
63
|
-
"
|
|
60
|
+
"react": "19.1.1",
|
|
61
|
+
"react-dom": "19.1.1",
|
|
62
|
+
"svelte": "5.39.12",
|
|
63
|
+
"vue": "3.5.19",
|
|
64
|
+
"@ng-org/lib-wasm": "0.1.2-alpha.1"
|
|
64
65
|
},
|
|
65
66
|
"files": [
|
|
66
67
|
"dist"
|