@ng-org/orm 0.1.2-alpha.7 → 0.1.2-alpha.9

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.
Files changed (53) hide show
  1. package/README.md +74 -92
  2. package/dist/connector/applyPatches.d.ts +13 -4
  3. package/dist/connector/applyPatches.d.ts.map +1 -1
  4. package/dist/connector/applyPatches.js +9 -5
  5. package/dist/connector/discrete/discreteOrmSubscriptionHandler.d.ts +156 -0
  6. package/dist/connector/discrete/discreteOrmSubscriptionHandler.d.ts.map +1 -0
  7. package/dist/connector/discrete/{discreteOrmConnectionHandler.js → discreteOrmSubscriptionHandler.js} +130 -19
  8. package/dist/connector/getObjects.js +2 -2
  9. package/dist/connector/initNg.d.ts +35 -0
  10. package/dist/connector/initNg.d.ts.map +1 -1
  11. package/dist/connector/initNg.js +35 -0
  12. package/dist/connector/insertObject.js +2 -2
  13. package/dist/connector/ormSubscriptionHandler.d.ts +166 -0
  14. package/dist/connector/ormSubscriptionHandler.d.ts.map +1 -0
  15. package/dist/connector/{ormConnectionHandler.js → ormSubscriptionHandler.js} +157 -32
  16. package/dist/frontendAdapters/react/useDiscrete.d.ts +89 -69
  17. package/dist/frontendAdapters/react/useDiscrete.d.ts.map +1 -1
  18. package/dist/frontendAdapters/react/useDiscrete.js +103 -81
  19. package/dist/frontendAdapters/react/useShape.d.ts +55 -55
  20. package/dist/frontendAdapters/react/useShape.d.ts.map +1 -1
  21. package/dist/frontendAdapters/react/useShape.js +71 -73
  22. package/dist/frontendAdapters/svelte/useDiscrete.svelte.d.ts +80 -71
  23. package/dist/frontendAdapters/svelte/useDiscrete.svelte.d.ts.map +1 -1
  24. package/dist/frontendAdapters/svelte/useDiscrete.svelte.js +102 -91
  25. package/dist/frontendAdapters/svelte/useShape.svelte.d.ts +70 -64
  26. package/dist/frontendAdapters/svelte/useShape.svelte.d.ts.map +1 -1
  27. package/dist/frontendAdapters/svelte/useShape.svelte.js +73 -62
  28. package/dist/frontendAdapters/svelte4/index.d.ts +5 -0
  29. package/dist/frontendAdapters/svelte4/index.d.ts.map +1 -0
  30. package/dist/frontendAdapters/svelte4/index.js +12 -0
  31. package/dist/frontendAdapters/svelte4/useDiscrete.svelte.d.ts +85 -0
  32. package/dist/frontendAdapters/svelte4/useDiscrete.svelte.d.ts.map +1 -0
  33. package/dist/frontendAdapters/svelte4/useDiscrete.svelte.js +124 -0
  34. package/dist/frontendAdapters/svelte4/useShape.svelte.d.ts +76 -0
  35. package/dist/frontendAdapters/svelte4/useShape.svelte.d.ts.map +1 -0
  36. package/dist/frontendAdapters/svelte4/useShape.svelte.js +84 -0
  37. package/dist/frontendAdapters/vue/useDiscrete.d.ts +87 -80
  38. package/dist/frontendAdapters/vue/useDiscrete.d.ts.map +1 -1
  39. package/dist/frontendAdapters/vue/useDiscrete.js +96 -84
  40. package/dist/frontendAdapters/vue/useShape.d.ts +57 -63
  41. package/dist/frontendAdapters/vue/useShape.d.ts.map +1 -1
  42. package/dist/frontendAdapters/vue/useShape.js +59 -64
  43. package/dist/index.d.ts +6 -3
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +14 -3
  46. package/dist/types.d.ts +17 -7
  47. package/dist/types.d.ts.map +1 -1
  48. package/dist/types.js +11 -2
  49. package/package.json +7 -3
  50. package/dist/connector/discrete/discreteOrmConnectionHandler.d.ts +0 -45
  51. package/dist/connector/discrete/discreteOrmConnectionHandler.d.ts.map +0 -1
  52. package/dist/connector/ormConnectionHandler.d.ts +0 -48
  53. package/dist/connector/ormConnectionHandler.d.ts.map +0 -1
@@ -1,85 +1,94 @@
1
- import { UseDeepSignalResult } from "@ng-org/alien-deepsignals/svelte";
2
1
  import { DiscreteRootArray, DiscreteRootObject } from "../../types.ts";
3
2
  /**
4
- * Svelte version 3/4 hook to subscribe to discrete (JSON) CRDT documents.
3
+ * Svelte 5 hook to subscribe to existing discrete (JSON) CRDT documents.
5
4
  * You can modify the returned object like any other JSON object. Changes are immediately
6
5
  * reflected in the CRDT.
7
6
  *
8
7
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
9
- * changes coming from the backend (or other components) cause an immediate rerender.
8
+ * changes coming from the engine (or other components) cause an immediate rerender.
10
9
  *
11
- * In comparison to `useShape`, discrete CRDTs are untyped.
10
+ * In comparison to {@link svelteUseShape}, discrete CRDTs are untyped.
12
11
  * You can put any JSON data inside and need to validate the schema yourself.
13
12
  *
14
- * @param documentId The IRI of the CRDT document.
13
+ * @param documentIdOrPromise The IRI of the CRDT document or a promise to that.
15
14
  * @returns The reactive JSON object of the CRDT document.
16
15
  *
17
16
  *@example
18
- ```svelte
19
- <script lang="ts">
20
-
21
- // We assume you have created a CRDT document already, as below.
22
- // const documentId = await ng.doc_create(
23
- // session_id,
24
- // crdt, // "Automerge" | "YMap" | "YArray"
25
- // crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
26
- // "store",
27
- // undefined
28
-
29
- const data = useDiscrete(documentIdPromise);
30
-
31
- // If the CRDT document is still empty, we need to initialize it.
32
- if (data && !data.expenses) {
33
- data.expenses = [];
34
- }
35
-
36
- // Call data.expenses.push({title: "Example title"}), to add new elements.
37
-
38
-
39
- // Note that we use expense["@id"] as a key in the expense list.
40
- // Every object added to a CRDT array gets a stable `@id` property assigned
41
- // which you can use for referencing objects in arrays even as
42
- // objects are removed from the array. The ID is an IRI with the schema `<documentId>:d:<object-specific id>`.
43
- // Since the `@id` is generated in the backend, the object is preliminarily
44
- // given a mock id which will be replaced immediately
45
- </script>
46
-
47
- <section>
48
- <div>
49
- {#if !data}
50
- Loading...
51
- {:else if data.expenses.length === 0}
52
- <p>
53
- Nothing tracked yet - log your first purchase to kick things off.
54
- </p>
55
- {:else}
56
- {#each data.expenses as expense, index (expense['@id']) }
57
- <ExpenseCard
58
- expense={expense}
59
- />
60
- {/each}
61
- {/if}
62
- </div>
63
- </section>
64
- ```
65
-
66
- ---
67
- In the ExpenseCard component:
68
- ```svelte
69
- let {
70
- expense = $bindable(),
71
- }: { expense: Expense; } = $props();
72
- </script>
73
-
74
- <div>
75
- <input
76
- value={expense.title ?? ""}
77
- oninput={(event) => {expense.title = event.currentTarget?.value ?? ""}}
78
- placeholder="Expense title"
79
- />
80
- </div>
81
- ```
82
-
17
+ * ```svelte
18
+ * <script lang="ts">
19
+ * // We assume you have created a CRDT document already, as below.
20
+ * // const documentId = await ng.doc_create(
21
+ * // session_id,
22
+ * // crdt, // "Automerge" | "YMap" | "YArray"
23
+ * // crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
24
+ * // "store",
25
+ * // undefined,
26
+ * // );
27
+ *
28
+ * const { doc } = useDiscrete(documentIdPromise);
29
+ *
30
+ * $effect(() => {
31
+ * // If the CRDT document is still empty, we need to initialize it.
32
+ * if (doc && !doc.expenses) {
33
+ * doc.expenses = [];
34
+ * }
35
+ * });
36
+ *
37
+ * const createExpense = () => {
38
+ * // Note that we use *expense["@id"]* as a key in the expense list.
39
+ * // Every object added to a CRDT array gets a stable `@id` property assigned
40
+ * // which you can use for referencing objects in arrays even as
41
+ * // objects are removed or added from the array.
42
+ * // The `@id` is an IRI with the schema `<documentId>:d:<object-specific id>`.
43
+ * // Since the `@id` is generated in the engine, the object is
44
+ * // *preliminarily given a mock id* which will be replaced immediately.
45
+ * expenses.push({
46
+ * title: "New expense",
47
+ * date: new Date().toISOString(),
48
+ * });
49
+ * };
50
+ *
51
+ *
52
+ * </script>
53
+ *
54
+ * <section>
55
+ * <div>
56
+ * <button on:click={() => createExpense({})}/>
57
+ *
58
+ * {#if !doc}
59
+ * Loading...
60
+ * {:else if doc.expenses.length === 0}
61
+ * <p>
62
+ * Nothing tracked yet - log your first purchase to kick things off.
63
+ * </p>
64
+ * {:else}
65
+ * {#each doc.expenses as expense, index (expense['@id']) }
66
+ * <ExpenseCard
67
+ * expense={expense}
68
+ * />
69
+ * {/each}
70
+ * {/if}
71
+ * </div>
72
+ * </section>
73
+ * ```
74
+ *
75
+ * ---
76
+ * In the ExpenseCard component:
77
+ * ```svelte
78
+ * let {
79
+ * expense = $bindable(),
80
+ * }: { expense: Expense; } = $props();
81
+ * </script>
82
+ *
83
+ * <div>
84
+ * <input
85
+ * value={expense.title ?? ""}
86
+ * oninput={(event) => {expense.title = event.currentTarget?.value ?? ""}}
87
+ * />
88
+ * </div>
89
+ * ```
83
90
  */
84
- export declare function useDiscrete(documentIdOrPromise: string | Promise<string>): UseDeepSignalResult<DiscreteRootArray | DiscreteRootObject | undefined>;
91
+ export declare function useDiscrete(documentIdOrPromise: string | Promise<string>): {
92
+ doc: DiscreteRootArray | DiscreteRootObject | undefined;
93
+ };
85
94
  //# sourceMappingURL=useDiscrete.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDiscrete.svelte.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/svelte/useDiscrete.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,EAEH,mBAAmB,EACtB,MAAM,kCAAkC,CAAC;AAE1C,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgFG;AACH,wBAAgB,WAAW,CACvB,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAC9C,mBAAmB,CAAC,iBAAiB,GAAG,kBAAkB,GAAG,SAAS,CAAC,CAgCzE"}
1
+ {"version":3,"file":"useDiscrete.svelte.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/svelte/useDiscrete.svelte.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEvE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwFG;AACH,wBAAgB,WAAW,CAAC,mBAAmB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG;IACxE,GAAG,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,SAAS,CAAC;CAC3D,CAwCA"}
@@ -8,117 +8,128 @@
8
8
  // according to those terms.
9
9
  // SPDX-License-Identifier: Apache-2.0 OR MIT
10
10
  import { onDestroy } from "svelte";
11
- import { useDeepSignal, } from "@ng-org/alien-deepsignals/svelte";
12
- import { DiscreteOrmConnection } from "../../connector/discrete/discreteOrmConnectionHandler.js";
11
+ import { useDeepSignal } from "@ng-org/alien-deepsignals/svelte";
12
+ import { DiscreteOrmSubscription } from "../../connector/discrete/discreteOrmSubscriptionHandler.js";
13
13
  /**
14
- * Svelte version 3/4 hook to subscribe to discrete (JSON) CRDT documents.
14
+ * Svelte 5 hook to subscribe to existing discrete (JSON) CRDT documents.
15
15
  * You can modify the returned object like any other JSON object. Changes are immediately
16
16
  * reflected in the CRDT.
17
17
  *
18
18
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
19
- * changes coming from the backend (or other components) cause an immediate rerender.
19
+ * changes coming from the engine (or other components) cause an immediate rerender.
20
20
  *
21
- * In comparison to `useShape`, discrete CRDTs are untyped.
21
+ * In comparison to {@link svelteUseShape}, discrete CRDTs are untyped.
22
22
  * You can put any JSON data inside and need to validate the schema yourself.
23
23
  *
24
- * @param documentId The IRI of the CRDT document.
24
+ * @param documentIdOrPromise The IRI of the CRDT document or a promise to that.
25
25
  * @returns The reactive JSON object of the CRDT document.
26
26
  *
27
27
  *@example
28
- ```svelte
29
- <script lang="ts">
30
-
31
- // We assume you have created a CRDT document already, as below.
32
- // const documentId = await ng.doc_create(
33
- // session_id,
34
- // crdt, // "Automerge" | "YMap" | "YArray"
35
- // crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
36
- // "store",
37
- // undefined
38
-
39
- const data = useDiscrete(documentIdPromise);
40
-
41
- // If the CRDT document is still empty, we need to initialize it.
42
- if (data && !data.expenses) {
43
- data.expenses = [];
44
- }
45
-
46
- // Call data.expenses.push({title: "Example title"}), to add new elements.
47
-
48
-
49
- // Note that we use expense["@id"] as a key in the expense list.
50
- // Every object added to a CRDT array gets a stable `@id` property assigned
51
- // which you can use for referencing objects in arrays even as
52
- // objects are removed from the array. The ID is an IRI with the schema `<documentId>:d:<object-specific id>`.
53
- // Since the `@id` is generated in the backend, the object is preliminarily
54
- // given a mock id which will be replaced immediately
55
- </script>
56
-
57
- <section>
58
- <div>
59
- {#if !data}
60
- Loading...
61
- {:else if data.expenses.length === 0}
62
- <p>
63
- Nothing tracked yet - log your first purchase to kick things off.
64
- </p>
65
- {:else}
66
- {#each data.expenses as expense, index (expense['@id']) }
67
- <ExpenseCard
68
- expense={expense}
69
- />
70
- {/each}
71
- {/if}
72
- </div>
73
- </section>
74
- ```
75
-
76
- ---
77
- In the ExpenseCard component:
78
- ```svelte
79
- let {
80
- expense = $bindable(),
81
- }: { expense: Expense; } = $props();
82
- </script>
83
-
84
- <div>
85
- <input
86
- value={expense.title ?? ""}
87
- oninput={(event) => {expense.title = event.currentTarget?.value ?? ""}}
88
- placeholder="Expense title"
89
- />
90
- </div>
91
- ```
92
-
28
+ * ```svelte
29
+ * <script lang="ts">
30
+ * // We assume you have created a CRDT document already, as below.
31
+ * // const documentId = await ng.doc_create(
32
+ * // session_id,
33
+ * // crdt, // "Automerge" | "YMap" | "YArray"
34
+ * // crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
35
+ * // "store",
36
+ * // undefined,
37
+ * // );
38
+ *
39
+ * const { doc } = useDiscrete(documentIdPromise);
40
+ *
41
+ * $effect(() => {
42
+ * // If the CRDT document is still empty, we need to initialize it.
43
+ * if (doc && !doc.expenses) {
44
+ * doc.expenses = [];
45
+ * }
46
+ * });
47
+ *
48
+ * const createExpense = () => {
49
+ * // Note that we use *expense["@id"]* as a key in the expense list.
50
+ * // Every object added to a CRDT array gets a stable `@id` property assigned
51
+ * // which you can use for referencing objects in arrays even as
52
+ * // objects are removed or added from the array.
53
+ * // The `@id` is an IRI with the schema `<documentId>:d:<object-specific id>`.
54
+ * // Since the `@id` is generated in the engine, the object is
55
+ * // *preliminarily given a mock id* which will be replaced immediately.
56
+ * expenses.push({
57
+ * title: "New expense",
58
+ * date: new Date().toISOString(),
59
+ * });
60
+ * };
61
+ *
62
+ *
63
+ * </script>
64
+ *
65
+ * <section>
66
+ * <div>
67
+ * <button on:click={() => createExpense({})}/>
68
+ *
69
+ * {#if !doc}
70
+ * Loading...
71
+ * {:else if doc.expenses.length === 0}
72
+ * <p>
73
+ * Nothing tracked yet - log your first purchase to kick things off.
74
+ * </p>
75
+ * {:else}
76
+ * {#each doc.expenses as expense, index (expense['@id']) }
77
+ * <ExpenseCard
78
+ * expense={expense}
79
+ * />
80
+ * {/each}
81
+ * {/if}
82
+ * </div>
83
+ * </section>
84
+ * ```
85
+ *
86
+ * ---
87
+ * In the ExpenseCard component:
88
+ * ```svelte
89
+ * let {
90
+ * expense = $bindable(),
91
+ * }: { expense: Expense; } = $props();
92
+ * </script>
93
+ *
94
+ * <div>
95
+ * <input
96
+ * value={expense.title ?? ""}
97
+ * oninput={(event) => {expense.title = event.currentTarget?.value ?? ""}}
98
+ * />
99
+ * </div>
100
+ * ```
93
101
  */
94
102
  export function useDiscrete(documentIdOrPromise) {
95
103
  let connection;
96
104
  let isDestroyed = false;
97
- const objectPromise = new Promise((resolve) => {
98
- const init = (docId) => {
99
- if (isDestroyed)
105
+ let doc = $state.raw(undefined);
106
+ const init = (docId) => {
107
+ if (isDestroyed)
108
+ return;
109
+ connection = DiscreteOrmSubscription.getOrCreate(docId);
110
+ connection.readyPromise.then(() => {
111
+ if (isDestroyed) {
112
+ connection?.close();
100
113
  return;
101
- connection = DiscreteOrmConnection.getOrCreate(docId);
102
- connection.readyPromise.then(() => {
103
- if (isDestroyed) {
104
- connection?.close();
105
- return;
106
- }
107
- resolve(connection.signalObject);
108
- });
109
- };
110
- if (typeof documentIdOrPromise === "string") {
111
- init(documentIdOrPromise);
112
- }
113
- else {
114
- documentIdOrPromise.then(init);
115
- }
116
- });
114
+ }
115
+ doc = useDeepSignal(connection.signalObject);
116
+ });
117
+ };
118
+ if (typeof documentIdOrPromise === "string") {
119
+ init(documentIdOrPromise);
120
+ }
121
+ else {
122
+ documentIdOrPromise.then(init);
123
+ }
117
124
  onDestroy(() => {
118
125
  isDestroyed = true;
119
126
  if (connection) {
120
127
  connection.close();
121
128
  }
122
129
  });
123
- return useDeepSignal(objectPromise);
130
+ return {
131
+ get doc() {
132
+ return doc;
133
+ },
134
+ };
124
135
  }
@@ -1,76 +1,82 @@
1
- import type { Scope } from "../../types.ts";
1
+ import { type Scope } from "../../types.ts";
2
2
  import type { BaseType, ShapeType } from "@ng-org/shex-orm";
3
- import { type UseDeepSignalResult } from "@ng-org/alien-deepsignals/svelte";
4
- export type { UseDeepSignalResult } from "@ng-org/alien-deepsignals/svelte";
5
- /** Extended result including the originating root signal wrapper from shape logic. */
6
- export interface UseShapeRuneResult<T extends object> extends UseDeepSignalResult<T> {
7
- root: any;
8
- }
3
+ import { DeepSignalSet } from "@ng-org/alien-deepsignals";
9
4
  /**
10
- * Hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
5
+ * Svelte 5 hook to subscribe to RDF data in the graph database using a shape, see {@link ShapeType}.
11
6
  *
12
- * Returns a {@link DeepSignalSet} of objects matching the shape and that are within the scope.
7
+ * Returns a {@link DeepSignalSet} that contain the objects matching the shape and that are within the scope.
13
8
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
14
- * changes coming from the backend (or other components) cause an immediate rerender.
9
+ * changes coming from the engine (or other components) cause an immediate rerender.
15
10
  *
16
- * @param shape The {@link ShapeType} the objects should have (generated by the shex-orm tool).
11
+ * @param shape The {@link ShapeType} the objects should have (generated by the `@ng-org/shex-orm` tool).
17
12
  * @param scope The {@link Scope} in which the objects should be.
18
13
  * @returns A {@link DeepSignalSet} containing the objects matching the shape type and scope.
19
14
  *
20
15
  * @example
21
- ```svelte
22
- <script lang="ts">
23
- // Gets all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
24
- const expenses: DeepSignalSet<Expense> = useShape(ExpenseShape,
25
- {graphs: ["<g1 IRI>", "<g2 IRI>"],
26
- subjects: ["<s1 IRI>", "<s2 IRI>"]});
27
-
28
- const expensesSorted = computed(() => expenses.sort((a, b) =>
29
- a.dateOfPurchase.localeCompare(b.dateOfPurchase)
30
- ));
31
-
32
- // Call expenses.add({"@graph": "<g1 or g2 IRI>", "@id": "", title: "Example title"}), to add new elements.
33
- // Leave `@id` an empty string to auto-generate a subject IRI (adjust your scope accordingly).
34
-
35
- // Not that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
36
- // If it is not, use the combination of `@graph` and `@id`.
37
- </script>
38
-
39
- <section>
40
- <div>
41
- {# if expensesSorted.length === 0}
42
- <p>
43
- No expense yet.
44
- </p>
45
- {:else}
46
- {#each expensesSorted as expense, index (expense['@id']) }
47
- <ExpenseCard
48
- expense={expense}
49
- />
50
- {/each}
51
- {/if}
52
- </div>
53
- </section>
54
- ```
55
-
56
- ---
57
- In the ExpenseCard component:
58
- ```svelte
59
-
60
- let {
61
- expense = $bindable(),
62
- }: { expense: Expense; } = $props();
63
- </script>
64
-
65
- <div>
66
- <input
67
- value={expense.title ?? ""}
68
- oninput={(event) => {expense.title = event.currentTarget!.value}}
69
- placeholder="Expense title"
70
- />
71
- </div>
72
- ```
16
+ * ```svelte
17
+ * <script lang="ts">
18
+ * // Gets all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
19
+ * const expenses: DeepSignalSet<Expense> = useShape(ExpenseShapeType,
20
+ * {graphs: ["<g1 IRI>", "<g2 IRI>"],
21
+ * subjects: ["<s1 IRI>", "<s2 IRI>"]});
22
+ *
23
+ * const expensesSorted = computed(() => expenses.sort((a, b) =>
24
+ * a.dateOfPurchase.localeCompare(b.dateOfPurchase)
25
+ * ));
26
+ *
27
+ * const createExpense = () => {
28
+ * expenses.add({
29
+ * "@graph": `<graph IRI>`,
30
+ * "@type": "http://example.org/Expense",
31
+ * "@id": "", // Assigns id automatically, if set to "".
32
+ * title: "New expense",
33
+ * dateOfPurchase: obj.dateOfPurchase ?? new Date().toISOString(),
34
+ * });
35
+ * };
36
+ *
37
+ *
38
+ * // Note that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
39
+ * // If it is not, use the combination of `@graph` and `@id`.
40
+ * </script>
41
+ *
42
+ * <section>
43
+ * <div>
44
+ * <button on:click={() => createExpense()}>
45
+ * + Add expense
46
+ * </button>
47
+ *
48
+ * {# if expensesSorted.length === 0}
49
+ * <p>
50
+ * No expense yet.
51
+ * </p>
52
+ * {:else}
53
+ * {#each expensesSorted as expense, index (expense['@id']) }
54
+ * <ExpenseCard
55
+ * expense={expense}
56
+ * />
57
+ * {/each}
58
+ * {/if}
59
+ * </div>
60
+ * </section>
61
+ * ```
62
+ *
63
+ * ---
64
+ * In the ExpenseCard component:
65
+ * ```svelte
66
+ * <script lang="ts">
67
+ * let {
68
+ * expense,
69
+ * }: { expense: DeepSignal<Expense>; } = $props();
70
+ * </script>
71
+ *
72
+ * <div>
73
+ * <input
74
+ * value={expense.title ?? ""}
75
+ * oninput={(event) => {expense.title = event.currentTarget.value}}
76
+ * />
77
+ * </div>
78
+ * ```
73
79
  */
74
- export declare function useShape<T extends BaseType>(shape: ShapeType<T>, scope?: Scope): UseShapeRuneResult<Set<T>>;
80
+ export declare function useShape<T extends BaseType>(shape: ShapeType<T>, scope: Scope): DeepSignalSet<T>;
75
81
  export default useShape;
76
82
  //# sourceMappingURL=useShape.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useShape.svelte.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/svelte/useShape.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAEH,KAAK,mBAAmB,EAC3B,MAAM,kCAAkC,CAAC;AAG1C,YAAY,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAE5E,sFAAsF;AACtF,MAAM,WAAW,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAChD,SAAQ,mBAAmB,CAAC,CAAC,CAAC;IAC9B,IAAI,EAAE,GAAG,CAAC;CACb;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACvC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,GAAE,KAAU,GAClB,kBAAkB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAU5B;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"useShape.svelte.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/svelte/useShape.svelte.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAI1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2EG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACvC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,KAAK,GACb,aAAa,CAAC,CAAC,CAAC,CAUlB;AAED,eAAe,QAAQ,CAAC"}