@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,92 +1,99 @@
1
- import { MaybeRefOrGetter } from "vue";
2
- import { type DeepSignal } from "@ng-org/alien-deepsignals";
3
- import { DiscreteArray, DiscreteObject } from "../../types.ts";
1
+ import { MaybeRefOrGetter, ToRefs } from "vue";
2
+ import { DiscreteRootObject } from "../../types.ts";
4
3
  /**
5
- * Hook to subscribe to discrete (JSON) CRDT documents.
4
+ * Hook to subscribe to an existing discrete (JSON) CRDT document.
6
5
  * You can modify the returned object like any other JSON object. Changes are immediately
7
- * reflected in the CRDT.
6
+ * reflected in the CRDT document.
8
7
  *
9
8
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
10
- * 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.
11
10
  *
12
11
  * In comparison to `useShape`, discrete CRDTs are untyped.
13
12
  * You can put any JSON data inside and need to validate the schema yourself.
14
13
  *
15
- * @param documentId The IRI of the crdt document.
16
- * @returns An object that contains as `data` the reactive DeepSignal object.
14
+ * @param documentId The IRI of the CRDT document or `undefined` as MaybeRefOrGetter.
15
+ * @returns An object that contains as `data` the reactive DeepSignal object or undefined if not loaded yet or `documentId` is undefined.
17
16
  *
18
17
  *@example
19
- ```html
20
- <script lang="ts">
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(documentId);
30
-
31
- // If document is new, we need to set up the basic structure.
32
- if (data && !data.expenses) {
33
- data.expenses = [];
34
- }
35
-
36
- // Note that we use expense["@id"] as a key in the expense list.
37
- // Every object added to a CRDT array gets a stable `@id` property assigned
38
- // which you can use for referencing objects in arrays even as
39
- // objects are removed from the array. The ID is an IRI with the schema `<documentId>:d:<object-specific id>`.
40
- // Since the `@id` is generated in the backend, the object is preliminarily
41
- // given a mock id which will be replaced immediately
42
- </script>
43
-
44
- <template>
45
- <div v-if="!data">
46
- Loading...
47
- </div>
48
- <div v-else>
49
- <p v-if="expensesSorted.length === 0">
50
- No expenses yet.
51
- </p>
52
- <template v-else>
53
- <ExpenseCard
54
- v-for="expense in expenses"
55
- :key="expense['@id']"
56
- :expense="expense"
57
- />
58
- </template>
59
- </div>
60
- </template>
61
- ```
62
-
63
- In the `ExpenseCard` component:
64
- ```html
65
- <script lang="ts">
66
- const props = defineProps<{
67
- expense: DeepSignal<Expense>;
68
- }>();
69
-
70
- // Important!
71
- // In vue, you need to wrap children into useDeepSignal hooks,
72
- // to ensure the component re-renders on changes coming from
73
- // other components or the backend.
74
- const expense = useDeepSignal(props.expense);
75
-
76
- // If you modify expense in the component,
77
- // the changes are immediately propagated to the other components
78
- // And persisted in the database.
79
- </script>
80
-
81
- <template>
82
- <input
83
- v-model="expense.title"
84
- placeholder="Expense title"
85
- />
86
- </template>
87
- ```
18
+ * ```html
19
+ * <script lang="ts">
20
+ * // We assume you have created a CRDT document already, as below.
21
+ * // const documentId = await ng.doc_create(
22
+ * // session_id,
23
+ * // crdt, // "Automerge" | "YMap" | "YArray"
24
+ * // crdt === "Automerge" ? "data:json" : crdt === "YMap ? "data:map" : "data:array",
25
+ * // "store",
26
+ * // undefined
27
+ * // );
28
+ * const { doc } = useDiscrete(documentId);
29
+ *
30
+ * // If document is new, we need to set up the basic structure.
31
+ * effect(() => {
32
+ * if (doc.value && !doc.value.expenses) {
33
+ * doc.value.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
+ * doc.value.expenses.push({
46
+ * title: "New expense",
47
+ * date: new Date().toISOString(),
48
+ * });
49
+ * };
50
+ * </script>
51
+ *
52
+ * <template>
53
+ * <div v-if="!doc">
54
+ * Loading...
55
+ * </div>
56
+ * <div v-else>
57
+ * <p v-if="expenses.length === 0">
58
+ * No expenses yet.
59
+ * </p>
60
+ * <template v-else>
61
+ * <button
62
+ * @click={() => createExpense()}
63
+ * >
64
+ * + Add expense
65
+ * </button>
66
+ * <ExpenseCard
67
+ * v-for="expense in expenses"
68
+ * :key="expense['@id']"
69
+ * :expense="expense"
70
+ * />
71
+ * </template>
72
+ * </div>
73
+ * </template>
74
+ * ```
75
+ *
76
+ * In the `ExpenseCard` component:
77
+ * ```html
78
+ * <script lang="ts">
79
+ * const { expense } = defineProps<{
80
+ * expense: DeepSignal<Expense>;
81
+ * }>();
82
+ *
83
+ * // If you modify expense in the component,
84
+ * // the changes are immediately propagated to the other components
85
+ * // And persisted in the database.
86
+ * </script>
87
+ *
88
+ * <template>
89
+ * <input
90
+ * v-model="expense.title"
91
+ * placeholder="Expense title"
92
+ * />
93
+ * </template>
94
+ * ```
88
95
  */
89
- export declare function useDiscrete(documentId: MaybeRefOrGetter<string | undefined>): {
90
- data: import("vue").ComputedRef<DeepSignal<DiscreteArray | DiscreteObject> | undefined>;
91
- };
96
+ export declare function useDiscrete(documentId: MaybeRefOrGetter<string | undefined>): ToRefs<{
97
+ doc: DiscreteRootObject;
98
+ }>;
92
99
  //# sourceMappingURL=useDiscrete.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDiscrete.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useDiscrete.ts"],"names":[],"mappings":"AAUA,OAAO,EAAY,gBAAgB,EAA4B,MAAM,KAAK,CAAC;AAC3E,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAG5D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC;;EAuB3E"}
1
+ {"version":3,"file":"useDiscrete.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useDiscrete.ts"],"names":[],"mappings":"AAUA,OAAO,EAEH,gBAAgB,EAGhB,MAAM,EAIT,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FG;AACH,wBAAgB,WAAW,CAAC,UAAU,EAAE,gBAAgB,CAAC,MAAM,GAAG,SAAS,CAAC,GAmBlD,MAAM,CAAC;IAAE,GAAG,EAAE,kBAAkB,CAAA;CAAE,CAAC,CAC5D"}
@@ -7,105 +7,117 @@
7
7
  // notice may not be copied, modified, or distributed except
8
8
  // according to those terms.
9
9
  // SPDX-License-Identifier: Apache-2.0 OR MIT
10
- import { computed, onBeforeUnmount, toValue } from "vue";
10
+ import { computed, onBeforeUnmount, shallowReactive, toRefs, toValue, watchEffect, } from "vue";
11
11
  import { useDeepSignal } from "@ng-org/alien-deepsignals/vue";
12
- import { DiscreteOrmConnection } from "../../connector/discrete/discreteOrmConnectionHandler.js";
13
- const EMPTY_OBJECT = {};
12
+ import { DiscreteOrmSubscription } from "../../connector/discrete/discreteOrmSubscriptionHandler.js";
14
13
  /**
15
- * Hook to subscribe to discrete (JSON) CRDT documents.
14
+ * Hook to subscribe to an existing discrete (JSON) CRDT document.
16
15
  * You can modify the returned object like any other JSON object. Changes are immediately
17
- * reflected in the CRDT.
16
+ * reflected in the CRDT document.
18
17
  *
19
18
  * Establishes a 2-way binding: Modifications to the object are immediately committed,
20
- * 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.
21
20
  *
22
21
  * In comparison to `useShape`, discrete CRDTs are untyped.
23
22
  * You can put any JSON data inside and need to validate the schema yourself.
24
23
  *
25
- * @param documentId The IRI of the crdt document.
26
- * @returns An object that contains as `data` the reactive DeepSignal object.
24
+ * @param documentId The IRI of the CRDT document or `undefined` as MaybeRefOrGetter.
25
+ * @returns An object that contains as `data` the reactive DeepSignal object or undefined if not loaded yet or `documentId` is undefined.
27
26
  *
28
27
  *@example
29
- ```html
30
- <script lang="ts">
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(documentId);
40
-
41
- // If document is new, we need to set up the basic structure.
42
- if (data && !data.expenses) {
43
- data.expenses = [];
44
- }
45
-
46
- // Note that we use expense["@id"] as a key in the expense list.
47
- // Every object added to a CRDT array gets a stable `@id` property assigned
48
- // which you can use for referencing objects in arrays even as
49
- // objects are removed from the array. The ID is an IRI with the schema `<documentId>:d:<object-specific id>`.
50
- // Since the `@id` is generated in the backend, the object is preliminarily
51
- // given a mock id which will be replaced immediately
52
- </script>
53
-
54
- <template>
55
- <div v-if="!data">
56
- Loading...
57
- </div>
58
- <div v-else>
59
- <p v-if="expensesSorted.length === 0">
60
- No expenses yet.
61
- </p>
62
- <template v-else>
63
- <ExpenseCard
64
- v-for="expense in expenses"
65
- :key="expense['@id']"
66
- :expense="expense"
67
- />
68
- </template>
69
- </div>
70
- </template>
71
- ```
72
-
73
- In the `ExpenseCard` component:
74
- ```html
75
- <script lang="ts">
76
- const props = defineProps<{
77
- expense: DeepSignal<Expense>;
78
- }>();
79
-
80
- // Important!
81
- // In vue, you need to wrap children into useDeepSignal hooks,
82
- // to ensure the component re-renders on changes coming from
83
- // other components or the backend.
84
- const expense = useDeepSignal(props.expense);
85
-
86
- // If you modify expense in the component,
87
- // the changes are immediately propagated to the other components
88
- // And persisted in the database.
89
- </script>
90
-
91
- <template>
92
- <input
93
- v-model="expense.title"
94
- placeholder="Expense title"
95
- />
96
- </template>
97
- ```
28
+ * ```html
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
+ * const { doc } = useDiscrete(documentId);
39
+ *
40
+ * // If document is new, we need to set up the basic structure.
41
+ * effect(() => {
42
+ * if (doc.value && !doc.value.expenses) {
43
+ * doc.value.expenses = [];
44
+ * }
45
+ * })
46
+ *
47
+ * const createExpense = () => {
48
+ * // Note that we use *expense["@id"]* as a key in the expense list.
49
+ * // Every object added to a CRDT array gets a stable `@id` property assigned
50
+ * // which you can use for referencing objects in arrays even as
51
+ * // objects are removed or added from the array.
52
+ * // The `@id` is an IRI with the schema `<documentId>:d:<object-specific id>`.
53
+ * // Since the `@id` is generated in the engine, the object is
54
+ * // *preliminarily given a mock id* which will be replaced immediately.
55
+ * doc.value.expenses.push({
56
+ * title: "New expense",
57
+ * date: new Date().toISOString(),
58
+ * });
59
+ * };
60
+ * </script>
61
+ *
62
+ * <template>
63
+ * <div v-if="!doc">
64
+ * Loading...
65
+ * </div>
66
+ * <div v-else>
67
+ * <p v-if="expenses.length === 0">
68
+ * No expenses yet.
69
+ * </p>
70
+ * <template v-else>
71
+ * <button
72
+ * @click={() => createExpense()}
73
+ * >
74
+ * + Add expense
75
+ * </button>
76
+ * <ExpenseCard
77
+ * v-for="expense in expenses"
78
+ * :key="expense['@id']"
79
+ * :expense="expense"
80
+ * />
81
+ * </template>
82
+ * </div>
83
+ * </template>
84
+ * ```
85
+ *
86
+ * In the `ExpenseCard` component:
87
+ * ```html
88
+ * <script lang="ts">
89
+ * const { expense } = defineProps<{
90
+ * expense: DeepSignal<Expense>;
91
+ * }>();
92
+ *
93
+ * // If you modify expense in the component,
94
+ * // the changes are immediately propagated to the other components
95
+ * // And persisted in the database.
96
+ * </script>
97
+ *
98
+ * <template>
99
+ * <input
100
+ * v-model="expense.title"
101
+ * placeholder="Expense title"
102
+ * />
103
+ * </template>
104
+ * ```
98
105
  */
99
106
  export function useDiscrete(documentId) {
100
- const ormConnection = computed(() => {
107
+ const ormSubscription = computed(() => {
101
108
  const id = toValue(documentId);
102
- return id ? DiscreteOrmConnection.getOrCreate(id) : undefined;
109
+ return id ? DiscreteOrmSubscription.getOrCreate(id) : undefined;
110
+ });
111
+ const ret = shallowReactive({
112
+ doc: undefined,
113
+ });
114
+ watchEffect(() => {
115
+ ormSubscription.value?.readyPromise.then(() => {
116
+ ret.doc = useDeepSignal(ormSubscription.value.signalObject);
117
+ });
103
118
  });
104
119
  onBeforeUnmount(() => {
105
- ormConnection?.value?.close();
120
+ ormSubscription.value?.close();
106
121
  });
107
- const signalSource = computed(() => ormConnection.value?.signalObject ?? EMPTY_OBJECT);
108
- const state = useDeepSignal(signalSource);
109
- const data = computed(() => ormConnection.value?.signalObject ? state : undefined);
110
- return { data };
122
+ return toRefs(ret);
111
123
  }
@@ -1,4 +1,4 @@
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
3
  import { DeepSignalSet } from "@ng-org/alien-deepsignals";
4
4
  /**
@@ -10,71 +10,65 @@ import { DeepSignalSet } from "@ng-org/alien-deepsignals";
10
10
  * changes coming from the backend (or other components) cause an immediate rerender.
11
11
  *
12
12
  * @param shape The {@link ShapeType} the objects should have (generated by the shex-orm tool).
13
- * @param scope The scope in which the objects should be.
13
+ * @param scope The scope in which the objects should be. Leaving it `undefined` makes no subscription.
14
14
  * @returns A {@link DeepSignalSet} containing the objects matching the shape type and scope.
15
15
  *
16
16
  * @example
17
- ```html
18
- <script lang="ts">
19
- // Contains all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
20
- const expenses: DeepSignalSet<Expense> = useShape(ExpenseShape,
21
- {graphs: ["<g1 IRI>", "<g2 IRI>"],
22
- subjects: ["<s1 IRI>", "<s2 IRI>"]});
23
-
24
-
25
- const expensesSorted = computed(() => [...expenses].sort((a, b) =>
26
- a.dateOfPurchase.localeCompare(b.dateOfPurchase)
27
- ));
28
-
29
- // Call expenses.add({"@graph": "<g1 or g2 IRI>", "@id": "", title: "Example title"}), to add new elements.
30
- // Leave `@id` an empty string to auto-generate a subject IRI (adjust your scope accordingly).
31
-
32
- // Not that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
33
- // If it is not, use the combination of `@graph` and `@id`.
34
- </script>
35
-
36
- <template>
37
- <div>
38
- <p v-if="expensesSorted.length === 0">
39
- No expenses yet.
40
- </p>
41
- <template v-else>
42
- <ExpenseCard
43
- v-for="expense in expensesSorted"
44
- :key="expense['@id'])"
45
- :expense="expense"
46
- />
47
- </template>
48
- </div>
49
- </template>
50
- ```
51
-
52
- In the `ExpenseCard` component:
53
- ```html
54
- <script lang="ts">
55
- const props = defineProps<{
56
- expense: DeepSignal<Expense>;
57
- }>();
58
-
59
- // Important!
60
- // In vue, you need to wrap children into useDeepSignal hooks,
61
- // to ensure the component re-renders on changes coming from
62
- // other components or the backend.
63
- const expense = useDeepSignal(props.expense);
64
-
65
- // If you modify expense in the component,
66
- // the changes are immediately propagated to the other components
67
- // And persisted in the database.
68
- </script>
69
-
70
- <template>
71
- <input
72
- v-model="expense.title"
73
- placeholder="Expense title"
74
- />
75
- </template>
76
- ```
17
+ * ```html
18
+ * <script lang="ts">
19
+ * // Contains all expense objects with `@id` <s1 IRI> or <s2 IRI> and `@graph` <g1 IRI> or <g2 IRI>
20
+ * const expenses: DeepSignalSet<Expense> = useShape(ExpenseShapeType,
21
+ * {graphs: ["<g1 IRI>", "<g2 IRI>"],
22
+ * subjects: ["<s1 IRI>", "<s2 IRI>"]});
23
+ *
24
+ *
25
+ * const expensesSorted = computed(() => [...expenses].sort((a, b) =>
26
+ * a.dateOfPurchase.localeCompare(b.dateOfPurchase)
27
+ * ));
28
+ *
29
+ * // Simply call expenses.add({"@graph": "<g1 or g2 IRI>", "@id": "", title: "Example title"}), to add new elements.
30
+ * // Leave `@id` an empty string to auto-generate a subject IRI (adjust your scope accordingly).
31
+ *
32
+ * // Note that if you use `@id` (the subject IRI) as key, you need to ensure that it is unique within your scope.
33
+ * // If it is not, use the combination of `@graph` and `@id`.
34
+ * </script>
35
+ *
36
+ * <template>
37
+ * <div>
38
+ * <p v-if="expensesSorted.length === 0">
39
+ * No expenses yet.
40
+ * </p>
41
+ * <template v-else>
42
+ * <ExpenseCard
43
+ * v-for="expense in expensesSorted"
44
+ * :key="expense['@id'])"
45
+ * :expense="expense"
46
+ * />
47
+ * </template>
48
+ * </div>
49
+ * </template>
50
+ * ```
51
+ *
52
+ * In the `ExpenseCard` component:
53
+ * ```html
54
+ * <script lang="ts">
55
+ * const { expense } = defineProps<{
56
+ * expense: DeepSignal<Expense>;
57
+ * }>();
58
+ *
59
+ * // If you modify expense in the component,
60
+ * // the changes are immediately propagated to the other components
61
+ * // And persisted in the database.
62
+ * </script>
63
+ *
64
+ * <template>
65
+ * <input
66
+ * v-model="expense.title"
67
+ * placeholder="Expense title"
68
+ * />
69
+ * </template>
70
+ * ```
77
71
  */
78
- export declare function useShape<T extends BaseType>(shape: ShapeType<T>, scope?: Scope): DeepSignalSet<T>;
72
+ export declare function useShape<T extends BaseType>(shape: ShapeType<T>, scope: Scope): DeepSignalSet<T>;
79
73
  export default useShape;
80
74
  //# sourceMappingURL=useShape.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5C,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACvC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,GAAE,KAAU,oBAYpB;AAED,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"useShape.d.ts","sourceRoot":"","sources":["../../../src/frontendAdapters/vue/useShape.ts"],"names":[],"mappings":"AAUA,OAAO,EAAkB,KAAK,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAG5D,OAAO,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,QAAQ,EACvC,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,EACnB,KAAK,EAAE,KAAK,oBAef;AAED,eAAe,QAAQ,CAAC"}