@ng-org/orm 0.1.2-alpha.13 → 0.1.2-alpha.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.
package/README.md CHANGED
@@ -22,19 +22,17 @@ Note that we support discrete (**JSON**) CRDT and graph (**RDF**) CRDT ORMs.
22
22
 
23
23
  ## Table of Contents
24
24
 
25
- - [Reference documentation](#reference-documentation)
26
- - [Why?](#why)
27
25
  - [Installation](#installation)
28
26
  - [Start](#start)
29
27
  - [RDF (graph) ORM: Defining Schemas](#rdf-graph-orm-defining-schemas)
30
28
  - [Frontend Framework Usage](#frontend-framework-usage)
31
29
  - [Working with Data](#working-with-data)
32
- - [Creating a Document](#creating-a-document)
33
- - [Using and Modifying ORM Objects](#using-and-modifying-orm-objects)
34
- - [The (Discrete)OrmSubscription Class](#the-discreteormsubscription-class)
35
- - [Transactions](#transactions)
36
- - [The DeepSignal\<\> type](#the-deepsignal-type)
37
- - [Graph ORM: Relationships](#graph-orm-relationships)
30
+ - [Creating a Document](#creating-a-document)
31
+ - [Using and Modifying ORM Objects](#using-and-modifying-orm-objects)
32
+ - [The (Discrete)OrmSubscription Class](#the-discreteormsubscription-class)
33
+ - [Transactions](#transactions)
34
+ - [The DeepSignal\<\> type](#the-deepsignal-type)
35
+ - [Graph ORM: Relationships](#graph-orm-relationships)
38
36
 
39
37
  ---
40
38
 
@@ -56,12 +54,14 @@ pnpm add -D @ng-org/shex-orm
56
54
 
57
55
  Before writing your own app, you are strongly advised to look at the example apps below, where you can find framework and crdt-specific walkthroughs.
58
56
 
59
- - Discrete CRDTs [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-discrete)
57
+ - Discrete CRDTs
58
+ - [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-discrete)
60
59
  - [Svelte 5](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte)
61
60
  - [Svelte 4](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-svelte4) (no support for Svelte 3)
62
61
  - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-vue)
63
62
  - [React](https://git.nextgraph.org/NextGraph/expense-tracker-discrete-react)
64
- - RDF CRDTs for [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-graph)
63
+ - RDF CRDT
64
+ - [all frameworks running in the same window with Astro](https://git.nextgraph.org/NextGraph/expense-tracker-graph)
65
65
  - [Svelte 5](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte)
66
66
  - [Svelte 4](https://git.nextgraph.org/NextGraph/expense-tracker-graph-svelte4) (no support for Svelte 3)
67
67
  - [Vue](https://git.nextgraph.org/NextGraph/expense-tracker-graph-vue)
@@ -129,7 +129,7 @@ The SDK offers hooks for discrete and graph-based CRDTs for Svelte, Vue and Reac
129
129
  - Svelte 4: [useDiscrete](#svelte4usediscrete)
130
130
  - Vue: [useDiscrete](#vueusediscrete)
131
131
  - React: [useDiscrete](#reactusediscrete)
132
- - graph CRDTs for:
132
+ - graph CRDT for:
133
133
  - Svelte 5: [useShape](#svelteuseshape)
134
134
  - Svelte 4: [useShape](#svelte4useshape)
135
135
  - Vue: [useShape](#vueuseshape)
@@ -216,7 +216,7 @@ There are multiple ways to get and modify data:
216
216
  You can establish subscriptions outside of frontend components using the (Discrete)OrmSubscription class. DiscreteOrmSubscriptions are scoped to one document, (RDF-based) OrmSubscriptions can have a `Scope` of more than one document and require a shape type. Once a subscription is established, its `.readyPromise` resolves and the `.signalObject` contains the 2-way bound data.
217
217
 
218
218
  You can create a new subscription using `(Discrete)OrmSubscription.getOrCreate()`. If a subscription with the same document or scope exists already, a reference to that object is returned. Otherwise, a new one is created.
219
- The pooling is especially useful when more than one frontend component subscribes to the same data and scope by calling `useShape()` or `useDiscrete()`. This reduces load and the data is available instantly.
219
+ This pooling is especially useful when more than one frontend component subscribes to the same data and scope by calling `useShape()` or `useDiscrete()`. This reduces load and the data is available instantly.
220
220
 
221
221
  Subscriptions are open until `.close()` is called on all references of this object. The `useShape` and `useDiscrete` hooks call `.close()` on their reference when their component unmounts.
222
222
 
@@ -242,7 +242,7 @@ const dogSet: DeepSignal<Set<Dog>> = dogSubscription.signalObject;
242
242
  dogs.add({
243
243
  // Required: The document NURI. May be set to `""` for nested objects (will be inherited from parent object then).
244
244
  "@graph": docNuri,
245
- "@type": "did:ng:x:Dog", // Required: RDF type
245
+ "@type": "did:ng:z:Dog", // Required: RDF type
246
246
  "@id": "", // Empty string = auto-generate subject IRI
247
247
  name: "Mr Puppy",
248
248
  age: 2,
@@ -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;AAElD,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,OAAO,KAAK,GAAG,MAAM,GAAG,SAAS,KAgCjB,aAAa,CAAC,CAAC,CAClC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
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;AAElD,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAG1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,QAAA,MAAM,QAAQ,GAAI,CAAC,SAAS,QAAQ,EAChC,OAAO,SAAS,CAAC,CAAC,CAAC,EACnB,OAAO,KAAK,GAAG,MAAM,GAAG,SAAS,KAmCjB,aAAa,CAAC,CAAC,CAClC,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -79,7 +79,7 @@ import { readOnlySet } from "../utils.js";
79
79
  * ```
80
80
  */
81
81
  const useShape = (shape, scope) => {
82
- const parsedScope = !scope ? undefined : normalizeScope(scope);
82
+ const parsedScope = useMemo(() => (!scope ? undefined : normalizeScope(scope)), [scope, scope?.graphs, scope?.subjects]);
83
83
  const prevOrmSubscription = useRef(undefined);
84
84
  const ormSubscription = useMemo(() => {
85
85
  if (parsedScope === undefined)
@@ -89,7 +89,7 @@ const useShape = (shape, scope) => {
89
89
  const newOrmSubscription = OrmSubscription.getOrCreate(shape, parsedScope);
90
90
  prevOrmSubscription.current = newOrmSubscription;
91
91
  return newOrmSubscription;
92
- }, [shape, scope, parsedScope?.graphs, parsedScope?.subjects]);
92
+ }, [shape, parsedScope, parsedScope?.graphs, parsedScope?.subjects]);
93
93
  useEffect(() => {
94
94
  if (!ormSubscription)
95
95
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ng-org/orm",
3
- "version": "0.1.2-alpha.13",
3
+ "version": "0.1.2-alpha.15",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "authors": [
@@ -54,7 +54,7 @@
54
54
  }
55
55
  },
56
56
  "dependencies": {
57
- "@ng-org/alien-deepsignals": "0.1.2-alpha.10"
57
+ "@ng-org/alien-deepsignals": "0.1.2-alpha.11"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@types/react": "^19.1.10",
@@ -67,7 +67,7 @@
67
67
  "svelte": "^5.39.12",
68
68
  "vue": "^3.5.19",
69
69
  "@ng-org/shex-orm": "0.1.2-alpha.7",
70
- "@ng-org/web": "0.1.2-alpha.10"
70
+ "@ng-org/web": "0.1.2-alpha.11"
71
71
  },
72
72
  "files": [
73
73
  "dist"