@ldo/svelte 1.0.0-alpha.50 → 1.0.0-alpha.53
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/{createLdoSvelteMethods.d.cts → createLdoSvelteMethods.d.ts} +6 -6
- package/dist/createLdoSvelteMethods.d.ts.map +1 -0
- package/dist/{createLdoSvelteMethods.mjs → createLdoSvelteMethods.js} +9 -9
- package/dist/createLdoSvelteMethods.js.map +1 -0
- package/dist/{index.d.cts → index.d.ts} +8 -8
- package/dist/{index.mjs → index.js} +8 -8
- package/dist/methods/{useLdo.d.mts → useLdo.d.ts} +4 -4
- package/dist/methods/useLdo.d.ts.map +1 -0
- package/dist/methods/{useLdo.mjs → useLdo.js} +1 -1
- package/dist/methods/useLdo.js.map +1 -0
- package/dist/methods/{useLinkQuery.d.cts → useLinkQuery.d.ts} +2 -2
- package/dist/methods/useLinkQuery.d.ts.map +1 -0
- package/dist/methods/{useLinkQuery.mjs → useLinkQuery.js} +2 -2
- package/dist/methods/useLinkQuery.js.map +1 -0
- package/dist/methods/{useMatchObject.d.cts → useMatchObject.d.ts} +2 -2
- package/dist/methods/useMatchObject.d.ts.map +1 -0
- package/dist/methods/{useMatchObject.mjs → useMatchObject.js} +2 -2
- package/dist/methods/useMatchObject.js.map +1 -0
- package/dist/methods/{useMatchSubject.d.cts → useMatchSubject.d.ts} +2 -2
- package/dist/methods/useMatchSubject.d.ts.map +1 -0
- package/dist/methods/{useMatchSubject.mjs → useMatchSubject.js} +2 -2
- package/dist/methods/useMatchSubject.js.map +1 -0
- package/dist/methods/{useResource.d.cts → useResource.d.ts} +1 -1
- package/dist/methods/useResource.d.ts.map +1 -0
- package/dist/methods/{useResource.mjs → useResource.js} +1 -1
- package/dist/methods/useResource.js.map +1 -0
- package/dist/methods/{useSubject.d.cts → useSubject.d.ts} +2 -2
- package/dist/methods/useSubject.d.ts.map +1 -0
- package/dist/methods/{useSubject.mjs → useSubject.js} +2 -2
- package/dist/methods/useSubject.js.map +1 -0
- package/dist/methods/{useSubscribeToResource.d.cts → useSubscribeToResource.d.ts} +1 -1
- package/dist/methods/useSubscribeToResource.d.ts.map +1 -0
- package/dist/methods/{useSubscribeToResource.mjs → useSubscribeToResource.js} +1 -1
- package/dist/methods/useSubscribeToResource.js.map +1 -0
- package/dist/util/{useTrackingProxy.mjs → useTrackingProxy.js} +1 -1
- package/dist/util/useTrackingProxy.js.map +1 -0
- package/package.json +15 -19
- package/src/createLdoSvelteMethods.tsx +1 -1
- package/src/methods/useLdo.ts +3 -3
- package/src/methods/useResource.ts +1 -1
- package/dist/createLdoSvelteMethods.cjs +0 -72
- package/dist/createLdoSvelteMethods.d.cts.map +0 -1
- package/dist/createLdoSvelteMethods.d.mts +0 -71
- package/dist/createLdoSvelteMethods.d.mts.map +0 -1
- package/dist/createLdoSvelteMethods.mjs.map +0 -1
- package/dist/index.cjs +0 -17
- package/dist/index.d.mts +0 -9
- package/dist/methods/useLdo.cjs +0 -57
- package/dist/methods/useLdo.d.cts +0 -63
- package/dist/methods/useLdo.d.cts.map +0 -1
- package/dist/methods/useLdo.d.mts.map +0 -1
- package/dist/methods/useLdo.mjs.map +0 -1
- package/dist/methods/useLinkQuery.cjs +0 -32
- package/dist/methods/useLinkQuery.d.cts.map +0 -1
- package/dist/methods/useLinkQuery.d.mts +0 -15
- package/dist/methods/useLinkQuery.d.mts.map +0 -1
- package/dist/methods/useLinkQuery.mjs.map +0 -1
- package/dist/methods/useMatchObject.cjs +0 -21
- package/dist/methods/useMatchObject.d.cts.map +0 -1
- package/dist/methods/useMatchObject.d.mts +0 -15
- package/dist/methods/useMatchObject.d.mts.map +0 -1
- package/dist/methods/useMatchObject.mjs.map +0 -1
- package/dist/methods/useMatchSubject.cjs +0 -21
- package/dist/methods/useMatchSubject.d.cts.map +0 -1
- package/dist/methods/useMatchSubject.d.mts +0 -15
- package/dist/methods/useMatchSubject.d.mts.map +0 -1
- package/dist/methods/useMatchSubject.mjs.map +0 -1
- package/dist/methods/useResource.cjs +0 -33
- package/dist/methods/useResource.d.cts.map +0 -1
- package/dist/methods/useResource.d.mts +0 -27
- package/dist/methods/useResource.d.mts.map +0 -1
- package/dist/methods/useResource.mjs.map +0 -1
- package/dist/methods/useSubject.cjs +0 -22
- package/dist/methods/useSubject.d.cts.map +0 -1
- package/dist/methods/useSubject.d.mts +0 -20
- package/dist/methods/useSubject.d.mts.map +0 -1
- package/dist/methods/useSubject.mjs.map +0 -1
- package/dist/methods/useSubscribeToResource.cjs +0 -16
- package/dist/methods/useSubscribeToResource.d.cts.map +0 -1
- package/dist/methods/useSubscribeToResource.d.mts +0 -12
- package/dist/methods/useSubscribeToResource.d.mts.map +0 -1
- package/dist/methods/useSubscribeToResource.mjs.map +0 -1
- package/dist/util/useTrackingProxy.cjs +0 -35
- package/dist/util/useTrackingProxy.mjs.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { UseLdoMethods } from "./methods/useLdo.
|
|
2
|
-
import { useResourceType } from "./methods/useResource.
|
|
3
|
-
import { useSubjectType } from "./methods/useSubject.
|
|
1
|
+
import { UseLdoMethods } from "./methods/useLdo.js";
|
|
2
|
+
import { useResourceType } from "./methods/useResource.js";
|
|
3
|
+
import { useSubjectType } from "./methods/useSubject.js";
|
|
4
4
|
import * as _$_ldo_connected0 from "@ldo/connected";
|
|
5
5
|
import { ConnectedPlugin } from "@ldo/connected";
|
|
6
6
|
import * as _$_ldo_ldo0 from "@ldo/ldo";
|
|
7
|
+
import * as _$svelte_store0 from "svelte/store";
|
|
7
8
|
import * as _$_ldo_rdf_utils0 from "@ldo/rdf-utils";
|
|
8
9
|
import * as _$_ldo_jsonld_dataset_proxy0 from "@ldo/jsonld-dataset-proxy";
|
|
9
|
-
import * as _$svelte_store0 from "svelte/store";
|
|
10
10
|
|
|
11
11
|
//#region src/createLdoSvelteMethods.d.ts
|
|
12
12
|
/**
|
|
@@ -14,7 +14,7 @@ import * as _$svelte_store0 from "svelte/store";
|
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* `methods.ts`
|
|
17
|
-
* ```
|
|
17
|
+
* ```typescript
|
|
18
18
|
* import { solidConnectedPlugin } from "@ldo/connected-solid";
|
|
19
19
|
* import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
|
|
20
20
|
* import { createLdoReactMethods } from "@ldo/react";
|
|
@@ -68,4 +68,4 @@ declare function createLdoSvelteMethods<Plugins extends ConnectedPlugin<any, any
|
|
|
68
68
|
};
|
|
69
69
|
//#endregion
|
|
70
70
|
export { createLdoSvelteMethods };
|
|
71
|
-
//# sourceMappingURL=createLdoSvelteMethods.d.
|
|
71
|
+
//# sourceMappingURL=createLdoSvelteMethods.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLdoSvelteMethods.d.ts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sBAAA,iBACE,eAAA,uBAAA,CAChB,OAAA,EAAS,OAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { createUseLdo } from "./methods/useLdo.
|
|
2
|
-
import { createUseMatchObject } from "./methods/useMatchObject.
|
|
3
|
-
import { createUseMatchSubject } from "./methods/useMatchSubject.
|
|
4
|
-
import { createUseResource } from "./methods/useResource.
|
|
5
|
-
import { createUseSubject } from "./methods/useSubject.
|
|
6
|
-
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.
|
|
7
|
-
import { createUseLinkQuery } from "./methods/useLinkQuery.
|
|
1
|
+
import { createUseLdo } from "./methods/useLdo.js";
|
|
2
|
+
import { createUseMatchObject } from "./methods/useMatchObject.js";
|
|
3
|
+
import { createUseMatchSubject } from "./methods/useMatchSubject.js";
|
|
4
|
+
import { createUseResource } from "./methods/useResource.js";
|
|
5
|
+
import { createUseSubject } from "./methods/useSubject.js";
|
|
6
|
+
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.js";
|
|
7
|
+
import { createUseLinkQuery } from "./methods/useLinkQuery.js";
|
|
8
8
|
import { createConnectedLdoDataset } from "@ldo/connected";
|
|
9
9
|
//#region src/createLdoSvelteMethods.tsx
|
|
10
10
|
/**
|
|
@@ -12,7 +12,7 @@ import { createConnectedLdoDataset } from "@ldo/connected";
|
|
|
12
12
|
*
|
|
13
13
|
* @example
|
|
14
14
|
* `methods.ts`
|
|
15
|
-
* ```
|
|
15
|
+
* ```typescript
|
|
16
16
|
* import { solidConnectedPlugin } from "@ldo/connected-solid";
|
|
17
17
|
* import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
|
|
18
18
|
* import { createLdoReactMethods } from "@ldo/react";
|
|
@@ -71,4 +71,4 @@ function createLdoSvelteMethods(plugins) {
|
|
|
71
71
|
//#endregion
|
|
72
72
|
export { createLdoSvelteMethods };
|
|
73
73
|
|
|
74
|
-
//# sourceMappingURL=createLdoSvelteMethods.
|
|
74
|
+
//# sourceMappingURL=createLdoSvelteMethods.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createLdoSvelteMethods.js","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { createUseLdo } from \"./methods/useLdo\";\nimport {\n createConnectedLdoDataset,\n type ConnectedPlugin,\n} from \"@ldo/connected\";\nimport { createUseMatchObject } from \"./methods/useMatchObject\";\nimport { createUseMatchSubject } from \"./methods/useMatchSubject\";\nimport { createUseResource } from \"./methods/useResource\";\nimport { createUseSubject } from \"./methods/useSubject\";\nimport { createUseSubscribeToResource } from \"./methods/useSubscribeToResource\";\nimport { createUseLinkQuery } from \"./methods/useLinkQuery\";\n\n/**\n * A function that creates all common react functions given specific plugin.\n *\n * @example\n * `methods.ts`\n * ```typescript\n * import { solidConnectedPlugin } from \"@ldo/connected-solid\";\n * import { nextGraphConnectedPlugin } from \"@ldo/connected-nextgraph\";\n * import { createLdoReactMethods } from \"@ldo/react\";\n *\n * // Export the results to be used in the reset of the application\n * export const {\n * dataset,\n * useLdo,\n * useMatchObject,\n * useMatchSubject,\n * useResource,\n * useSubject,\n * useSubscribeToResource,\n * useLinkQuery,\n * } = createLdoReactMethods([\n * solidConnectedPlugin,\n * nextGraphConnectedPlugin\n * ]);\n * ```\n *\n * `App.tsx`\n * ```typescript\n * import react, { FunctionComponent } from \"react\";\n * import { PostShShapeType } from \"./_ldo/posts.shapeType.ts\";\n * import { useResource, useSubject } from \"./methods.ts\";\n *\n * const UseSubjectTest: FunctionComponent = () => {\n * const resource = useResource(SAMPLE_DATA_URI);\n * const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`);\n * if (resource.isLoading() || !post) return <p>loading</p>;\n *\n * return (\n * <ul>\n * {post.publisher.map((publisher) => {\n * return <li key={publisher[\"@id\"]}>{publisher[\"@id\"]}</li>;\n * })}\n * </ul>\n * );\n * };\n * ```\n */\nexport function createLdoSvelteMethods<\n Plugins extends ConnectedPlugin<any, any, any, any>[],\n>(plugins: Plugins) {\n const dataset = createConnectedLdoDataset(plugins);\n dataset.setMaxListeners(1000);\n\n return {\n dataset,\n useLdo: createUseLdo<Plugins>(dataset),\n useMatchObject: createUseMatchObject<Plugins>(dataset),\n useMatchSubject: createUseMatchSubject<Plugins>(dataset),\n useResource: createUseResource<Plugins>(dataset),\n useSubject: createUseSubject<Plugins>(dataset),\n useSubscribeToResource: createUseSubscribeToResource<Plugins>(dataset),\n useLinkQuery: createUseLinkQuery<Plugins>(dataset),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4DA,SAAgB,uBAEd,SAAkB;CAClB,MAAM,UAAU,0BAA0B,QAAQ;AAClD,SAAQ,gBAAgB,IAAK;AAE7B,QAAO;EACL;EACA,QAAQ,aAAsB,QAAQ;EACtC,gBAAgB,qBAA8B,QAAQ;EACtD,iBAAiB,sBAA+B,QAAQ;EACxD,aAAa,kBAA2B,QAAQ;EAChD,YAAY,iBAA0B,QAAQ;EAC9C,wBAAwB,6BAAsC,QAAQ;EACtE,cAAc,mBAA4B,QAAQ;EACnD"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createLdoSvelteMethods } from "./createLdoSvelteMethods.
|
|
2
|
-
import { UseLdoMethods, createUseLdo } from "./methods/useLdo.
|
|
3
|
-
import { createUseMatchObject } from "./methods/useMatchObject.
|
|
4
|
-
import { createUseMatchSubject } from "./methods/useMatchSubject.
|
|
5
|
-
import { UseResourceOptions, createUseResource, useResourceType } from "./methods/useResource.
|
|
6
|
-
import { createUseSubject, useSubjectType } from "./methods/useSubject.
|
|
7
|
-
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.
|
|
8
|
-
import { createUseLinkQuery } from "./methods/useLinkQuery.
|
|
1
|
+
import { createLdoSvelteMethods } from "./createLdoSvelteMethods.js";
|
|
2
|
+
import { UseLdoMethods, createUseLdo } from "./methods/useLdo.js";
|
|
3
|
+
import { createUseMatchObject } from "./methods/useMatchObject.js";
|
|
4
|
+
import { createUseMatchSubject } from "./methods/useMatchSubject.js";
|
|
5
|
+
import { UseResourceOptions, createUseResource, useResourceType } from "./methods/useResource.js";
|
|
6
|
+
import { createUseSubject, useSubjectType } from "./methods/useSubject.js";
|
|
7
|
+
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.js";
|
|
8
|
+
import { createUseLinkQuery } from "./methods/useLinkQuery.js";
|
|
9
9
|
export { UseLdoMethods, UseResourceOptions, createLdoSvelteMethods, createUseLdo, createUseLinkQuery, createUseMatchObject, createUseMatchSubject, createUseResource, createUseSubject, createUseSubscribeToResource, useResourceType, useSubjectType };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { createUseLdo } from "./methods/useLdo.
|
|
2
|
-
import { createUseMatchObject } from "./methods/useMatchObject.
|
|
3
|
-
import { createUseMatchSubject } from "./methods/useMatchSubject.
|
|
4
|
-
import { createUseResource } from "./methods/useResource.
|
|
5
|
-
import { createUseSubject } from "./methods/useSubject.
|
|
6
|
-
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.
|
|
7
|
-
import { createUseLinkQuery } from "./methods/useLinkQuery.
|
|
8
|
-
import { createLdoSvelteMethods } from "./createLdoSvelteMethods.
|
|
1
|
+
import { createUseLdo } from "./methods/useLdo.js";
|
|
2
|
+
import { createUseMatchObject } from "./methods/useMatchObject.js";
|
|
3
|
+
import { createUseMatchSubject } from "./methods/useMatchSubject.js";
|
|
4
|
+
import { createUseResource } from "./methods/useResource.js";
|
|
5
|
+
import { createUseSubject } from "./methods/useSubject.js";
|
|
6
|
+
import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.js";
|
|
7
|
+
import { createUseLinkQuery } from "./methods/useLinkQuery.js";
|
|
8
|
+
import { createLdoSvelteMethods } from "./createLdoSvelteMethods.js";
|
|
9
9
|
export { createLdoSvelteMethods, createUseLdo, createUseLinkQuery, createUseMatchObject, createUseMatchSubject, createUseResource, createUseSubject, createUseSubscribeToResource };
|
|
@@ -12,7 +12,7 @@ interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
12
12
|
*/
|
|
13
13
|
dataset: ConnectedLdoDataset<Plugins>;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* Retrieves a representation of a Resource at the given URI. This resource
|
|
16
16
|
* represents the current state of the resource: whether it is currently
|
|
17
17
|
* fetched or in the process of fetching as well as some information about it.
|
|
18
18
|
*
|
|
@@ -24,7 +24,7 @@ interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
24
24
|
*/
|
|
25
25
|
getResource: ConnectedLdoDataset<Plugins>["getResource"];
|
|
26
26
|
/**
|
|
27
|
-
* Sets
|
|
27
|
+
* Sets context for a specific plugin
|
|
28
28
|
*
|
|
29
29
|
* @param pluginName - the name of the plugin
|
|
30
30
|
* @param context - the context for this specific plugin
|
|
@@ -49,7 +49,7 @@ interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
49
49
|
*/
|
|
50
50
|
changeData<Type extends LdoBase>(input: Type, resource: Plugins[number]["types"]["resource"], ...additionalResources: Plugins[number]["types"]["resource"][]): Type;
|
|
51
51
|
/**
|
|
52
|
-
* Commits the data of a writable
|
|
52
|
+
* Commits the data of a writable Linked Data Object back to the remote.
|
|
53
53
|
*/
|
|
54
54
|
commitData(input: LdoBase): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]>;
|
|
55
55
|
}
|
|
@@ -60,4 +60,4 @@ interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
60
60
|
declare function createUseLdo<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): () => UseLdoMethods<Plugins>;
|
|
61
61
|
//#endregion
|
|
62
62
|
export { UseLdoMethods, createUseLdo };
|
|
63
|
-
//# sourceMappingURL=useLdo.d.
|
|
63
|
+
//# sourceMappingURL=useLdo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLdo.d.ts","names":[],"sources":["../../src/methods/useLdo.ts"],"mappings":";;;;;;;AAaA;UAAiB,aAAA,iBAA8B,eAAA;EAAjB;;;EAI5B,OAAA,EAAS,mBAAA,CAAoB,OAAA;EAYI;;;;;;;;;;;EAAjC,WAAA,EAAa,mBAAA,CAAoB,OAAA;EA0Bb;;;;;;EAnBpB,UAAA,EAAY,mBAAA,CAAoB,OAAA;EA6BN;;;EAzB1B,UAAA,cAAwB,OAAA,EACtB,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,WAAkB,WAAA,GACjB,IAAA;EA6BW;;;;;;;;;EAnBd,UAAA,cAAwB,OAAA,EACtB,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,WAAkB,WAAA,EAClB,QAAA,EAAU,OAAA,kCACP,mBAAA,EAAqB,OAAA,kCACvB,IAAA;EA7BU;;;EAiCb,UAAA,cAAwB,OAAA,EACtB,KAAA,EAAO,IAAA,EACP,QAAA,EAAU,OAAA,kCACP,mBAAA,EAAqB,OAAA,kCACvB,IAAA;EA9B6B;;;EAkChC,UAAA,CACE,KAAA,EAAO,OAAA,GACN,UAAA,CAAW,8BAAA,CAA+B,OAAA;AAAA;;;;;iBAO/B,YAAA,iBAA6B,eAAA,GAAA,CAC3C,OAAA,EAAS,mBAAA,CAAoB,OAAA,UA+DH,aAAA,CAAc,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLdo.js","names":[],"sources":["../../src/methods/useLdo.ts"],"sourcesContent":["import {\n changeData,\n // changeData,\n type ConnectedLdoDataset,\n type ConnectedLdoTransactionDataset,\n type ConnectedPlugin,\n} from \"@ldo/connected\";\nimport { getDataset, type LdoBase, type ShapeType } from \"@ldo/ldo\";\nimport type { SubjectNode } from \"@ldo/rdf-utils\";\n\n/**\n * The methods returned by useLdo\n */\nexport interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {\n /**\n * A ConnectedLdoDataset\n */\n dataset: ConnectedLdoDataset<Plugins>;\n /**\n * Retrieves a representation of a Resource at the given URI. This resource\n * represents the current state of the resource: whether it is currently\n * fetched or in the process of fetching as well as some information about it.\n *\n * @param uri - the URI of the resource\n * @param pluginName - optionally, force this function to choose a specific\n * plugin to use rather than perform content negotiation.\n *\n * @returns a Resource\n */\n getResource: ConnectedLdoDataset<Plugins>[\"getResource\"];\n /**\n * Sets context for a specific plugin\n *\n * @param pluginName - the name of the plugin\n * @param context - the context for this specific plugin\n */\n setContext: ConnectedLdoDataset<Plugins>[\"setContext\"];\n /**\n * Gets a linked data object based on the subject\n */\n getSubject<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject: string | SubjectNode,\n ): Type;\n /**\n * Shorthand for connectedLdoDataset\n * .usingType(shapeType)\n * .write(...resources.map((r) => r.uri))\n * .fromSubject(subject);\n * @param shapeType - The shapetype to represent the data\n * @param subject - A subject URI\n * @param resources - The resources changes to should written to\n */\n createData<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject: string | SubjectNode,\n resource: Plugins[number][\"types\"][\"resource\"],\n ...additionalResources: Plugins[number][\"types\"][\"resource\"][]\n ): Type;\n /**\n * Returns a writable LinkedDataObject given a linked data object\n */\n changeData<Type extends LdoBase>(\n input: Type,\n resource: Plugins[number][\"types\"][\"resource\"],\n ...additionalResources: Plugins[number][\"types\"][\"resource\"][]\n ): Type;\n /**\n * Commits the data of a writable Linked Data Object back to the remote.\n */\n commitData(\n input: LdoBase,\n ): ReturnType<ConnectedLdoTransactionDataset<Plugins>[\"commitToRemote\"]>;\n}\n\n/**\n * @internal\n * Creates the useLdoHook\n */\nexport function createUseLdo<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n) {\n const toReturn = {\n dataset,\n /**\n * Gets a resource\n */\n getResource: dataset.getResource.bind(dataset),\n /**\n * Set the context\n */\n setContext: dataset.setContext.bind(dataset),\n /**\n * Returns a Linked Data Object for a subject\n * @param shapeType The shape type for the data\n * @param subject Subject Node\n * @returns A Linked Data Object\n */\n getSubject<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject: string | SubjectNode,\n ): Type {\n return dataset.usingType(shapeType).fromSubject(subject);\n },\n /**\n * Begins tracking changes to eventually commit for a new subject\n * @param shapeType The shape type that defines the created data\n * @param subject The RDF subject for a Linked Data Object\n * @param resources Any number of resources to which this data should be written\n * @returns A Linked Data Object to modify and commit\n */\n createData<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject: string | SubjectNode,\n resource: Plugins[number][\"types\"][\"resource\"],\n ...additionalResources: Plugins[number][\"types\"][\"resource\"][]\n ): Type {\n return dataset.createData(\n shapeType,\n subject,\n resource,\n ...additionalResources,\n );\n },\n /**\n * Begins tracking changes to eventually commit\n * @param input A linked data object to track changes on\n * @param resources\n */\n changeData: changeData,\n /**\n * Commits the transaction to the global dataset, syncing all subscribing\n * components and Solid Pods\n */\n commitData(\n input: LdoBase,\n ): ReturnType<ConnectedLdoTransactionDataset<Plugins>[\"commitToRemote\"]> {\n const inputDataset = getDataset(\n input,\n ) as ConnectedLdoTransactionDataset<Plugins>;\n return inputDataset.commitToRemote();\n },\n };\n return function useLdo(): UseLdoMethods<Plugins> {\n return toReturn;\n };\n}\n"],"mappings":";;;;;;;AA+EA,SAAgB,aACd,SACA;CACA,MAAM,WAAW;EACf;;;;EAIA,aAAa,QAAQ,YAAY,KAAK,QAAQ;;;;EAI9C,YAAY,QAAQ,WAAW,KAAK,QAAQ;;;;;;;EAO5C,WACE,WACA,SACM;AACN,UAAO,QAAQ,UAAU,UAAU,CAAC,YAAY,QAAQ;;;;;;;;;EAS1D,WACE,WACA,SACA,UACA,GAAG,qBACG;AACN,UAAO,QAAQ,WACb,WACA,SACA,UACA,GAAG,oBACJ;;;;;;;EAOS;;;;;EAKZ,WACE,OACuE;AAIvE,UAHqB,WACnB,MAEiB,CAAC,gBAAgB;;EAEvC;AACD,QAAO,SAAS,SAAiC;AAC/C,SAAO"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectedLdoDataset, ConnectedPlugin, ExpandDeep, LQInput, LQReturn } from "@ldo/connected";
|
|
2
2
|
import { LdoBase, ShapeType } from "@ldo/ldo";
|
|
3
|
-
import { SubjectNode } from "@ldo/rdf-utils";
|
|
4
3
|
import { Readable } from "svelte/store";
|
|
4
|
+
import { SubjectNode } from "@ldo/rdf-utils";
|
|
5
5
|
|
|
6
6
|
//#region src/methods/useLinkQuery.d.ts
|
|
7
7
|
/**
|
|
@@ -12,4 +12,4 @@ import { Readable } from "svelte/store";
|
|
|
12
12
|
declare function createUseLinkQuery<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): <Type extends LdoBase, QueryInput extends LQInput<Type>>(shapeType: ShapeType<Type>, startingResource: string, startingSubject: SubjectNode | string, linkQuery: QueryInput) => Readable<ExpandDeep<LQReturn<Type, QueryInput>> | undefined>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { createUseLinkQuery };
|
|
15
|
-
//# sourceMappingURL=useLinkQuery.d.
|
|
15
|
+
//# sourceMappingURL=useLinkQuery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkQuery.d.ts","names":[],"sources":["../../src/methods/useLinkQuery.ts"],"mappings":";;;;;;;;AAkBA;;;iBAAgB,kBAAA,iBAAmC,eAAA,GAAA,CACjD,OAAA,EAAS,mBAAA,CAAoB,OAAA,kBAOd,OAAA,qBACM,OAAA,CAAQ,IAAA,GAE3B,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,gBAAA,UACA,eAAA,EAAiB,WAAA,WACjB,SAAA,EAAW,UAAA,KACV,QAAA,CAAS,UAAA,CAAW,QAAA,CAAS,IAAA,EAAM,UAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTrackingProxy } from "../util/useTrackingProxy.
|
|
1
|
+
import { useTrackingProxy } from "../util/useTrackingProxy.js";
|
|
2
2
|
import { onDestroy } from "svelte";
|
|
3
3
|
//#region src/methods/useLinkQuery.ts
|
|
4
4
|
/**
|
|
@@ -31,4 +31,4 @@ function createUseLinkQuery(dataset) {
|
|
|
31
31
|
//#endregion
|
|
32
32
|
export { createUseLinkQuery };
|
|
33
33
|
|
|
34
|
-
//# sourceMappingURL=useLinkQuery.
|
|
34
|
+
//# sourceMappingURL=useLinkQuery.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLinkQuery.js","names":[],"sources":["../../src/methods/useLinkQuery.ts"],"sourcesContent":["import {\n type ConnectedLdoDataset,\n type ConnectedPlugin,\n type ExpandDeep,\n type LQInput,\n type LQReturn,\n} from \"@ldo/connected\";\nimport { type LdoBase, type LdoBuilder, type ShapeType } from \"@ldo/ldo\";\nimport type { SubjectNode } from \"@ldo/rdf-utils\";\nimport { type Readable } from \"svelte/store\";\nimport { useTrackingProxy } from \"../util/useTrackingProxy\";\nimport { onDestroy } from \"svelte\";\n\n/**\n * @internal\n *\n * Creates a useMatchSubject function.\n */\nexport function createUseLinkQuery<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n) {\n /**\n * Returns an array of matching linked data objects. Triggers a rerender if\n * the data is updated.\n */\n return function useQueryLink<\n Type extends LdoBase,\n QueryInput extends LQInput<Type>,\n >(\n shapeType: ShapeType<Type>,\n startingResource: string,\n startingSubject: SubjectNode | string,\n linkQuery: QueryInput,\n ): Readable<ExpandDeep<LQReturn<Type, QueryInput>> | undefined> {\n const resource = dataset.getResource(startingResource);\n console.log(resource);\n const lq = dataset\n .usingType(shapeType)\n .startLinkQuery(resource, startingSubject, linkQuery);\n console.log(\"Calling subscribe\");\n lq.subscribe();\n console.log(\"After call subscribe\");\n\n onDestroy(() => {\n lq.unsubscribeAll();\n });\n\n const fromSubject = (builder: LdoBuilder<Type>) => {\n if (!startingSubject) return;\n return builder.fromSubject(startingSubject);\n };\n\n return useTrackingProxy(\n shapeType,\n fromSubject,\n dataset,\n ) as unknown as Readable<ExpandDeep<LQReturn<Type, QueryInput>>>;\n };\n}\n"],"mappings":";;;;;;;;AAkBA,SAAgB,mBACd,SACA;;;;;AAKA,QAAO,SAAS,aAId,WACA,kBACA,iBACA,WAC8D;EAC9D,MAAM,WAAW,QAAQ,YAAY,iBAAiB;AACtD,UAAQ,IAAI,SAAS;EACrB,MAAM,KAAK,QACR,UAAU,UAAU,CACpB,eAAe,UAAU,iBAAiB,UAAU;AACvD,UAAQ,IAAI,oBAAoB;AAChC,KAAG,WAAW;AACd,UAAQ,IAAI,uBAAuB;AAEnC,kBAAgB;AACd,MAAG,gBAAgB;IACnB;EAEF,MAAM,eAAe,YAA8B;AACjD,OAAI,CAAC,gBAAiB;AACtB,UAAO,QAAQ,YAAY,gBAAgB;;AAG7C,SAAO,iBACL,WACA,aACA,QACD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
2
2
|
import { LdSet, LdoBase, ShapeType } from "@ldo/ldo";
|
|
3
|
-
import { QuadMatch } from "@ldo/rdf-utils";
|
|
4
3
|
import { Readable } from "svelte/store";
|
|
4
|
+
import { QuadMatch } from "@ldo/rdf-utils";
|
|
5
5
|
|
|
6
6
|
//#region src/methods/useMatchObject.d.ts
|
|
7
7
|
/**
|
|
@@ -12,4 +12,4 @@ import { Readable } from "svelte/store";
|
|
|
12
12
|
declare function createUseMatchObject<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): <Type extends LdoBase>(shapeType: ShapeType<Type>, subject?: QuadMatch[0] | string, predicate?: QuadMatch[1] | string, graph?: QuadMatch[3] | string) => Readable<LdSet<Type>>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { createUseMatchObject };
|
|
15
|
-
//# sourceMappingURL=useMatchObject.d.
|
|
15
|
+
//# sourceMappingURL=useMatchObject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMatchObject.d.ts","names":[],"sources":["../../src/methods/useMatchObject.ts"],"mappings":";;;;;;;;AAWA;;;iBAAgB,oBAAA,iBAAqC,eAAA,GAAA,CACnD,OAAA,EAAS,mBAAA,CAAoB,OAAA,kBAMe,OAAA,EAC1C,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,GAAU,SAAA,cACV,SAAA,GAAY,SAAA,cACZ,KAAA,GAAQ,SAAA,iBACP,QAAA,CAAS,KAAA,CAAM,IAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTrackingProxy } from "../util/useTrackingProxy.
|
|
1
|
+
import { useTrackingProxy } from "../util/useTrackingProxy.js";
|
|
2
2
|
//#region src/methods/useMatchObject.ts
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -20,4 +20,4 @@ function createUseMatchObject(dataset) {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { createUseMatchObject };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=useMatchObject.
|
|
23
|
+
//# sourceMappingURL=useMatchObject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMatchObject.js","names":[],"sources":["../../src/methods/useMatchObject.ts"],"sourcesContent":["import type { LdoBase, LdoBuilder, LdSet, ShapeType } from \"@ldo/ldo\";\nimport type { QuadMatch } from \"@ldo/rdf-utils\";\nimport type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\nimport type { Readable } from \"svelte/store\";\nimport { useTrackingProxy } from \"../util/useTrackingProxy\";\n\n/**\n * @internal\n *\n * Creates a useMatchObject function\n */\nexport function createUseMatchObject<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n) {\n /**\n * Returns an array of matching items and triggers a rerender when that data\n * is updated.\n */\n return function useMatchObject<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject?: QuadMatch[0] | string,\n predicate?: QuadMatch[1] | string,\n graph?: QuadMatch[3] | string,\n ): Readable<LdSet<Type>> {\n const matchObject = (builder: LdoBuilder<Type>) => {\n return builder.matchObject(subject, predicate, graph);\n };\n\n return useTrackingProxy(shapeType, matchObject, dataset);\n };\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,qBACd,SACA;;;;;AAKA,QAAO,SAAS,eACd,WACA,SACA,WACA,OACuB;EACvB,MAAM,eAAe,YAA8B;AACjD,UAAO,QAAQ,YAAY,SAAS,WAAW,MAAM;;AAGvD,SAAO,iBAAiB,WAAW,aAAa,QAAQ"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
2
2
|
import { LdSet, LdoBase, ShapeType } from "@ldo/ldo";
|
|
3
|
-
import { QuadMatch } from "@ldo/rdf-utils";
|
|
4
3
|
import { Readable } from "svelte/store";
|
|
4
|
+
import { QuadMatch } from "@ldo/rdf-utils";
|
|
5
5
|
|
|
6
6
|
//#region src/methods/useMatchSubject.d.ts
|
|
7
7
|
/**
|
|
@@ -12,4 +12,4 @@ import { Readable } from "svelte/store";
|
|
|
12
12
|
declare function createUseMatchSubject<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): <Type extends LdoBase>(shapeType: ShapeType<Type>, predicate?: QuadMatch[1] | string, object?: QuadMatch[2] | string, graph?: QuadMatch[3] | string) => Readable<LdSet<Type>>;
|
|
13
13
|
//#endregion
|
|
14
14
|
export { createUseMatchSubject };
|
|
15
|
-
//# sourceMappingURL=useMatchSubject.d.
|
|
15
|
+
//# sourceMappingURL=useMatchSubject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMatchSubject.d.ts","names":[],"sources":["../../src/methods/useMatchSubject.ts"],"mappings":";;;;;;;;AAWA;;;iBAAgB,qBAAA,iBAAsC,eAAA,GAAA,CACpD,OAAA,EAAS,mBAAA,CAAoB,OAAA,kBAMgB,OAAA,EAC3C,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,SAAA,GAAY,SAAA,cACZ,MAAA,GAAS,SAAA,cACT,KAAA,GAAQ,SAAA,iBACP,QAAA,CAAS,KAAA,CAAM,IAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTrackingProxy } from "../util/useTrackingProxy.
|
|
1
|
+
import { useTrackingProxy } from "../util/useTrackingProxy.js";
|
|
2
2
|
//#region src/methods/useMatchSubject.ts
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -20,4 +20,4 @@ function createUseMatchSubject(dataset) {
|
|
|
20
20
|
//#endregion
|
|
21
21
|
export { createUseMatchSubject };
|
|
22
22
|
|
|
23
|
-
//# sourceMappingURL=useMatchSubject.
|
|
23
|
+
//# sourceMappingURL=useMatchSubject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useMatchSubject.js","names":[],"sources":["../../src/methods/useMatchSubject.ts"],"sourcesContent":["import type { LdoBase, LdoBuilder, LdSet, ShapeType } from \"@ldo/ldo\";\nimport type { QuadMatch } from \"@ldo/rdf-utils\";\nimport type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\nimport { useTrackingProxy } from \"../util/useTrackingProxy\";\nimport type { Readable } from \"svelte/store\";\n\n/**\n * @internal\n *\n * Creates a useMatchSubject function.\n */\nexport function createUseMatchSubject<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n) {\n /**\n * Returns an array of matching linked data objects. Triggers a rerender if\n * the data is updated.\n */\n return function useMatchSubject<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n predicate?: QuadMatch[1] | string,\n object?: QuadMatch[2] | string,\n graph?: QuadMatch[3] | string,\n ): Readable<LdSet<Type>> {\n const matchSubject = (builder: LdoBuilder<Type>) => {\n return builder.matchSubject(predicate, object, graph);\n };\n\n return useTrackingProxy(shapeType, matchSubject, dataset);\n };\n}\n"],"mappings":";;;;;;;AAWA,SAAgB,sBACd,SACA;;;;;AAKA,QAAO,SAAS,gBACd,WACA,WACA,QACA,OACuB;EACvB,MAAM,gBAAgB,YAA8B;AAClD,UAAO,QAAQ,aAAa,WAAW,QAAQ,MAAM;;AAGvD,SAAO,iBAAiB,WAAW,cAAc,QAAQ"}
|
|
@@ -24,4 +24,4 @@ type useResourceType<Plugins extends ConnectedPlugin[]> = {
|
|
|
24
24
|
declare function createUseResource<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): useResourceType<Plugins>;
|
|
25
25
|
//#endregion
|
|
26
26
|
export { UseResourceOptions, createUseResource, useResourceType };
|
|
27
|
-
//# sourceMappingURL=useResource.d.
|
|
27
|
+
//# sourceMappingURL=useResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResource.d.ts","names":[],"sources":["../../src/methods/useResource.ts"],"mappings":";;;;UAOiB,kBAAA;EACf,UAAA,GAAa,IAAA;EACb,mBAAA;EACA,aAAA;EACA,SAAA;AAAA;AAAA,KAGU,eAAA,iBAAgC,eAAA;EAAA,cAE3B,OAAA,iCACE,OAAA,CAAQ,OAAA;IAAmB,IAAA,EAAM,IAAA;EAAA,4BAGhD,GAAA,EAAK,OAAA,EACL,OAAA,GAAU,kBAAA,CAAmB,IAAA,IAC5B,QAAA,CAAS,qBAAA,CAAsB,MAAA,EAAQ,OAAA;EAAA,cAE3B,OAAA,iCACE,OAAA,CAAQ,OAAA;IAAmB,IAAA,EAAM,IAAA;EAAA,4BAGhD,GAAA,GAAM,OAAA,EACN,OAAA,GAAU,kBAAA,CAAmB,IAAA,IAC5B,QAAA,CAAS,qBAAA,CAAsB,MAAA,EAAQ,OAAA;AAAA;AAhB5C;;;;;AAAA,iBAwBgB,iBAAA,iBAAkC,eAAA,GAAA,CAChD,OAAA,EAAS,mBAAA,CAAoB,OAAA,IAC5B,eAAA,CAAgB,OAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useResource.js","names":[],"sources":["../../src/methods/useResource.ts"],"sourcesContent":["import type {\n ConnectedLdoDataset,\n ConnectedPlugin,\n GetResourceReturnType,\n} from \"@ldo/connected\";\nimport { writable, type Readable } from \"svelte/store\";\n\nexport interface UseResourceOptions<Name> {\n pluginName?: Name;\n suppressInitialRead?: boolean;\n reloadOnMount?: boolean;\n subscribe?: boolean;\n}\n\nexport type useResourceType<Plugins extends ConnectedPlugin[]> = {\n <\n Name extends Plugins[number][\"name\"],\n Plugin extends Extract<Plugins[number], { name: Name }>,\n UriType extends string,\n >(\n uri: UriType,\n options?: UseResourceOptions<Name>,\n ): Readable<GetResourceReturnType<Plugin, UriType>>;\n <\n Name extends Plugins[number][\"name\"],\n Plugin extends Extract<Plugins[number], { name: Name }>,\n UriType extends string,\n >(\n uri?: UriType,\n options?: UseResourceOptions<Name>,\n ): Readable<GetResourceReturnType<Plugin, UriType> | undefined>;\n};\n\n/**\n * @internal\n *\n * Creates a useResource function.\n */\nexport function createUseResource<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n): useResourceType<Plugins> {\n /**\n * Returns a resource and triggers a rerender if that resource is updated.\n */\n return function useResource<\n Name extends Plugins[number][\"name\"],\n Plugin extends Extract<Plugins[number], { name: Name }>,\n UriType extends string,\n >(\n uri?: UriType,\n options?: UseResourceOptions<Name>,\n ): Readable<GetResourceReturnType<Plugin, UriType> | undefined> {\n let resource: GetResourceReturnType<Plugin, UriType> | undefined;\n // Get the resource based on incoming data\n if (uri) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n resource = dataset.getResource(uri) as any;\n // Run read operations if necessary\n if (!options?.suppressInitialRead) {\n if (options?.reloadOnMount) {\n resource!.read();\n } else {\n resource!.readIfUnfetched();\n }\n }\n } else {\n resource = undefined;\n }\n\n // The Svelte store\n const store = writable<GetResourceReturnType<Plugin, UriType> | undefined>(\n resource,\n (set) => {\n const onResourceUpdate = () => {\n set(resource);\n };\n\n if (resource) {\n resource.on(\"update\", onResourceUpdate);\n\n // TODO: handle subscriptions\n\n return () => {\n resource.off(\"update\", onResourceUpdate);\n };\n }\n },\n );\n\n return {\n subscribe: store.subscribe,\n };\n };\n}\n"],"mappings":";;;;;;;AAsCA,SAAgB,kBACd,SAC0B;;;;AAI1B,QAAO,SAAS,YAKd,KACA,SAC8D;EAC9D,IAAI;AAEJ,MAAI,KAAK;AAEP,cAAW,QAAQ,YAAY,IAAI;AAEnC,OAAI,CAAC,SAAS,oBACZ,KAAI,SAAS,cACX,UAAU,MAAM;OAEhB,UAAU,iBAAiB;QAI/B,YAAW,KAAA;AAuBb,SAAO,EACL,WApBY,SACZ,WACC,QAAQ;GACP,MAAM,yBAAyB;AAC7B,QAAI,SAAS;;AAGf,OAAI,UAAU;AACZ,aAAS,GAAG,UAAU,iBAAiB;AAIvC,iBAAa;AACX,cAAS,IAAI,UAAU,iBAAiB;;;IAO9B,CAAC,WAClB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
2
2
|
import { LdoBase, ShapeType } from "@ldo/ldo";
|
|
3
|
-
import { SubjectNode } from "@ldo/rdf-utils";
|
|
4
3
|
import { Readable } from "svelte/store";
|
|
4
|
+
import { SubjectNode } from "@ldo/rdf-utils";
|
|
5
5
|
|
|
6
6
|
//#region src/methods/useSubject.d.ts
|
|
7
7
|
type useSubjectType = {
|
|
@@ -17,4 +17,4 @@ type useSubjectType = {
|
|
|
17
17
|
declare function createUseSubject<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): useSubjectType;
|
|
18
18
|
//#endregion
|
|
19
19
|
export { createUseSubject, useSubjectType };
|
|
20
|
-
//# sourceMappingURL=useSubject.d.
|
|
20
|
+
//# sourceMappingURL=useSubject.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubject.d.ts","names":[],"sources":["../../src/methods/useSubject.ts"],"mappings":";;;;;;KASY,cAAA;EAAA,cACI,OAAA,EACZ,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,WAAkB,WAAA,GACjB,QAAA,CAAS,IAAA;EAAA,cACE,OAAA,EACZ,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,YAAmB,WAAA,GAClB,QAAA,CAAS,IAAA;EAAA,cACE,OAAA,EACZ,SAAA,EAAW,SAAA,CAAU,IAAA,GACrB,OAAA,YAAmB,WAAA,GAClB,QAAA,CAAS,IAAA;AAAA;;;;;;iBAQE,gBAAA,iBAAiC,eAAA,GAAA,CAC/C,OAAA,EAAS,mBAAA,CAAoB,OAAA,IAC5B,cAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useTrackingProxy } from "../util/useTrackingProxy.
|
|
1
|
+
import { useTrackingProxy } from "../util/useTrackingProxy.js";
|
|
2
2
|
//#region src/methods/useSubject.ts
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
@@ -21,4 +21,4 @@ function createUseSubject(dataset) {
|
|
|
21
21
|
//#endregion
|
|
22
22
|
export { createUseSubject };
|
|
23
23
|
|
|
24
|
-
//# sourceMappingURL=useSubject.
|
|
24
|
+
//# sourceMappingURL=useSubject.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubject.js","names":[],"sources":["../../src/methods/useSubject.ts"],"sourcesContent":["import type { SubjectNode } from \"@ldo/rdf-utils\";\nimport type { ShapeType } from \"@ldo/ldo\";\nimport type { LdoBuilder } from \"@ldo/ldo\";\nimport type { LdoBase } from \"@ldo/ldo\";\n\nimport { useTrackingProxy } from \"../util/useTrackingProxy\";\nimport type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\nimport type { Readable } from \"svelte/store\";\n\nexport type useSubjectType = {\n <Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject: string | SubjectNode,\n ): Readable<Type>;\n <Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject?: string | SubjectNode,\n ): Readable<Type | undefined>;\n <Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject?: string | SubjectNode,\n ): Readable<Type | undefined>;\n};\n\n/**\n * @internal\n *\n * Creates a useSubject function.\n */\nexport function createUseSubject<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n): useSubjectType {\n /**\n * Returns a Linked Data Object based on the provided subject. Triggers a\n * rerender if the data is udpated.\n */\n return function useSubject<Type extends LdoBase>(\n shapeType: ShapeType<Type>,\n subject?: string | SubjectNode,\n ): Readable<Type | undefined> {\n const fromSubject = (builder: LdoBuilder<Type>) => {\n if (!subject) return;\n return builder.fromSubject(subject);\n };\n\n return useTrackingProxy(shapeType, fromSubject, dataset);\n };\n}\n"],"mappings":";;;;;;;AA6BA,SAAgB,iBACd,SACgB;;;;;AAKhB,QAAO,SAAS,WACd,WACA,SAC4B;EAC5B,MAAM,eAAe,YAA8B;AACjD,OAAI,CAAC,QAAS;AACd,UAAO,QAAQ,YAAY,QAAQ;;AAGrC,SAAO,iBAAiB,WAAW,aAAa,QAAQ"}
|
|
@@ -9,4 +9,4 @@ import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
|
|
|
9
9
|
declare function createUseSubscribeToResource<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): (...uris: string[]) => void;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { createUseSubscribeToResource };
|
|
12
|
-
//# sourceMappingURL=useSubscribeToResource.d.
|
|
12
|
+
//# sourceMappingURL=useSubscribeToResource.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubscribeToResource.d.ts","names":[],"sources":["../../src/methods/useSubscribeToResource.ts"],"mappings":";;;;;AAOA;;;iBAAgB,4BAAA,iBAA6C,eAAA,GAAA,CAC3D,OAAA,EAAS,mBAAA,CAAoB,OAAA,QAKa,IAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSubscribeToResource.js","names":[],"sources":["../../src/methods/useSubscribeToResource.ts"],"sourcesContent":["import type { ConnectedLdoDataset, ConnectedPlugin } from \"@ldo/connected\";\n\n/**\n * @internal\n *\n * Creates a useSubscribeToResource function.\n */\nexport function createUseSubscribeToResource<Plugins extends ConnectedPlugin[]>(\n dataset: ConnectedLdoDataset<Plugins>,\n) {\n /**\n * Starts a subscription to a resource.\n */\n return function useSubscribeToResource(...uris: string[]): void {\n throw new Error(\"Subscribe to Resource is Not Implemented for Svelte\");\n };\n}\n"],"mappings":";;;;;;AAOA,SAAgB,6BACd,SACA;;;;AAIA,QAAO,SAAS,uBAAuB,GAAG,MAAsB;AAC9D,QAAM,IAAI,MAAM,sDAAsD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTrackingProxy.js","names":[],"sources":["../../src/util/useTrackingProxy.ts"],"sourcesContent":["import type { LdoBuilder } from \"@ldo/ldo\";\nimport type { LdoBase, LdoDataset, ShapeType } from \"@ldo/ldo\";\nimport { createTrackingProxyBuilder } from \"@ldo/connected\";\nimport { writable, type Readable } from \"svelte/store\";\nimport type { nodeEventListener } from \"@ldo/subscribable-dataset\";\nimport { onDestroy } from \"svelte\";\n\n/**\n * @internal\n *\n * A hook for tracking proxies\n */\nexport function useTrackingProxy<Type extends LdoBase, ReturnType>(\n shapeType: ShapeType<Type>,\n createLdo: (builder: LdoBuilder<Type>) => ReturnType,\n dataset: LdoDataset,\n): Readable<ReturnType> {\n const forceUpdateInfo: {\n set?: (item: ReturnType) => void;\n ldo?: ReturnType;\n } = {};\n\n const forceUpdate: nodeEventListener = () => {\n dataset.removeListenerFromAllEvents(forceUpdate);\n const builder = createTrackingProxyBuilder(dataset, shapeType, forceUpdate);\n const linkedDataObject = createLdo(builder);\n forceUpdateInfo.ldo = linkedDataObject;\n if (forceUpdateInfo.set && forceUpdateInfo.ldo)\n forceUpdateInfo.set(forceUpdateInfo.ldo);\n };\n forceUpdate({}, \"\", [undefined, undefined, undefined, undefined]);\n\n // The Svelte store\n const store = writable<ReturnType>(forceUpdateInfo.ldo, (set) => {\n forceUpdateInfo.set = set;\n\n return () => {\n dataset.removeListenerFromAllEvents(forceUpdate);\n };\n });\n\n onDestroy(() => {\n dataset.removeListenerFromAllEvents(forceUpdate);\n });\n\n return {\n subscribe: store.subscribe,\n };\n}\n"],"mappings":";;;;;;;;;AAYA,SAAgB,iBACd,WACA,WACA,SACsB;CACtB,MAAM,kBAGF,EAAE;CAEN,MAAM,oBAAuC;AAC3C,UAAQ,4BAA4B,YAAY;AAGhD,kBAAgB,MADS,UADT,2BAA2B,SAAS,WAAW,YACrB,CACJ;AACtC,MAAI,gBAAgB,OAAO,gBAAgB,IACzC,iBAAgB,IAAI,gBAAgB,IAAI;;AAE5C,aAAY,EAAE,EAAE,IAAI;EAAC,KAAA;EAAW,KAAA;EAAW,KAAA;EAAW,KAAA;EAAU,CAAC;CAGjE,MAAM,QAAQ,SAAqB,gBAAgB,MAAM,QAAQ;AAC/D,kBAAgB,MAAM;AAEtB,eAAa;AACX,WAAQ,4BAA4B,YAAY;;GAElD;AAEF,iBAAgB;AACd,UAAQ,4BAA4B,YAAY;GAChD;AAEF,QAAO,EACL,WAAW,MAAM,WAClB"}
|
package/package.json
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/svelte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.53",
|
|
4
4
|
"description": "A Svelte library for LDO.",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "./dist/index.
|
|
7
|
-
"module": "./dist/index.mjs",
|
|
6
|
+
"main": "./dist/index.js",
|
|
8
7
|
"svelte": "src/index.ts",
|
|
9
|
-
"types": "./dist/index.d.
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
"default": "./dist/index.mjs"
|
|
15
|
-
},
|
|
16
|
-
"require": {
|
|
17
|
-
"types": "./dist/index.d.cts",
|
|
18
|
-
"default": "./dist/index.cjs"
|
|
19
|
-
}
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"default": "./dist/index.js"
|
|
20
13
|
},
|
|
21
14
|
"./package.json": "./package.json"
|
|
22
15
|
},
|
|
@@ -43,7 +36,7 @@
|
|
|
43
36
|
},
|
|
44
37
|
"homepage": "https://github.com/o-development/ldo/tree/main/packages/svelte#readme",
|
|
45
38
|
"devDependencies": {
|
|
46
|
-
"@ldo/test-solid-server": "^1.0.0-alpha.
|
|
39
|
+
"@ldo/test-solid-server": "^1.0.0-alpha.53",
|
|
47
40
|
"@sveltejs/vite-plugin-svelte": "^2.5.3",
|
|
48
41
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
42
|
"@testing-library/svelte": "^5.2.7",
|
|
@@ -65,19 +58,22 @@
|
|
|
65
58
|
"svelte": "^3.50.0"
|
|
66
59
|
},
|
|
67
60
|
"dependencies": {
|
|
68
|
-
"@ldo/connected": "^1.0.0-alpha.
|
|
69
|
-
"@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.
|
|
70
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
71
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
72
|
-
"@ldo/subscribable-dataset": "^1.0.0-alpha.
|
|
61
|
+
"@ldo/connected": "^1.0.0-alpha.53",
|
|
62
|
+
"@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.53",
|
|
63
|
+
"@ldo/ldo": "^1.0.0-alpha.53",
|
|
64
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.53",
|
|
65
|
+
"@ldo/subscribable-dataset": "^1.0.0-alpha.53",
|
|
73
66
|
"tsx": "^4.19.4"
|
|
74
67
|
},
|
|
75
68
|
"files": [
|
|
76
69
|
"dist",
|
|
77
70
|
"src"
|
|
78
71
|
],
|
|
72
|
+
"engines": {
|
|
73
|
+
"node": ">=20.19.0"
|
|
74
|
+
},
|
|
79
75
|
"publishConfig": {
|
|
80
76
|
"access": "public"
|
|
81
77
|
},
|
|
82
|
-
"gitHead": "
|
|
78
|
+
"gitHead": "4064165d9f3fbeadcb6b06b5e978771535bd3c56"
|
|
83
79
|
}
|
|
@@ -16,7 +16,7 @@ import { createUseLinkQuery } from "./methods/useLinkQuery";
|
|
|
16
16
|
*
|
|
17
17
|
* @example
|
|
18
18
|
* `methods.ts`
|
|
19
|
-
* ```
|
|
19
|
+
* ```typescript
|
|
20
20
|
* import { solidConnectedPlugin } from "@ldo/connected-solid";
|
|
21
21
|
* import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
|
|
22
22
|
* import { createLdoReactMethods } from "@ldo/react";
|
package/src/methods/useLdo.ts
CHANGED
|
@@ -17,7 +17,7 @@ export interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
17
17
|
*/
|
|
18
18
|
dataset: ConnectedLdoDataset<Plugins>;
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Retrieves a representation of a Resource at the given URI. This resource
|
|
21
21
|
* represents the current state of the resource: whether it is currently
|
|
22
22
|
* fetched or in the process of fetching as well as some information about it.
|
|
23
23
|
*
|
|
@@ -29,7 +29,7 @@ export interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
29
29
|
*/
|
|
30
30
|
getResource: ConnectedLdoDataset<Plugins>["getResource"];
|
|
31
31
|
/**
|
|
32
|
-
* Sets
|
|
32
|
+
* Sets context for a specific plugin
|
|
33
33
|
*
|
|
34
34
|
* @param pluginName - the name of the plugin
|
|
35
35
|
* @param context - the context for this specific plugin
|
|
@@ -66,7 +66,7 @@ export interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
|
|
|
66
66
|
...additionalResources: Plugins[number]["types"]["resource"][]
|
|
67
67
|
): Type;
|
|
68
68
|
/**
|
|
69
|
-
* Commits the data of a writable
|
|
69
|
+
* Commits the data of a writable Linked Data Object back to the remote.
|
|
70
70
|
*/
|
|
71
71
|
commitData(
|
|
72
72
|
input: LdoBase,
|
|
@@ -55,7 +55,7 @@ export function createUseResource<Plugins extends ConnectedPlugin[]>(
|
|
|
55
55
|
if (uri) {
|
|
56
56
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
57
57
|
resource = dataset.getResource(uri) as any;
|
|
58
|
-
// Run read operations if
|
|
58
|
+
// Run read operations if necessary
|
|
59
59
|
if (!options?.suppressInitialRead) {
|
|
60
60
|
if (options?.reloadOnMount) {
|
|
61
61
|
resource!.read();
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
const require_useLdo = require("./methods/useLdo.cjs");
|
|
2
|
-
const require_useMatchObject = require("./methods/useMatchObject.cjs");
|
|
3
|
-
const require_useMatchSubject = require("./methods/useMatchSubject.cjs");
|
|
4
|
-
const require_useResource = require("./methods/useResource.cjs");
|
|
5
|
-
const require_useSubject = require("./methods/useSubject.cjs");
|
|
6
|
-
const require_useSubscribeToResource = require("./methods/useSubscribeToResource.cjs");
|
|
7
|
-
const require_useLinkQuery = require("./methods/useLinkQuery.cjs");
|
|
8
|
-
let _ldo_connected = require("@ldo/connected");
|
|
9
|
-
//#region src/createLdoSvelteMethods.tsx
|
|
10
|
-
/**
|
|
11
|
-
* A function that creates all common react functions given specific plugin.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* `methods.ts`
|
|
15
|
-
* ```tyepscript
|
|
16
|
-
* import { solidConnectedPlugin } from "@ldo/connected-solid";
|
|
17
|
-
* import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
|
|
18
|
-
* import { createLdoReactMethods } from "@ldo/react";
|
|
19
|
-
*
|
|
20
|
-
* // Export the results to be used in the reset of the application
|
|
21
|
-
* export const {
|
|
22
|
-
* dataset,
|
|
23
|
-
* useLdo,
|
|
24
|
-
* useMatchObject,
|
|
25
|
-
* useMatchSubject,
|
|
26
|
-
* useResource,
|
|
27
|
-
* useSubject,
|
|
28
|
-
* useSubscribeToResource,
|
|
29
|
-
* useLinkQuery,
|
|
30
|
-
* } = createLdoReactMethods([
|
|
31
|
-
* solidConnectedPlugin,
|
|
32
|
-
* nextGraphConnectedPlugin
|
|
33
|
-
* ]);
|
|
34
|
-
* ```
|
|
35
|
-
*
|
|
36
|
-
* `App.tsx`
|
|
37
|
-
* ```typescript
|
|
38
|
-
* import react, { FunctionComponent } from "react";
|
|
39
|
-
* import { PostShShapeType } from "./_ldo/posts.shapeType.ts";
|
|
40
|
-
* import { useResource, useSubject } from "./methods.ts";
|
|
41
|
-
*
|
|
42
|
-
* const UseSubjectTest: FunctionComponent = () => {
|
|
43
|
-
* const resource = useResource(SAMPLE_DATA_URI);
|
|
44
|
-
* const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`);
|
|
45
|
-
* if (resource.isLoading() || !post) return <p>loading</p>;
|
|
46
|
-
*
|
|
47
|
-
* return (
|
|
48
|
-
* <ul>
|
|
49
|
-
* {post.publisher.map((publisher) => {
|
|
50
|
-
* return <li key={publisher["@id"]}>{publisher["@id"]}</li>;
|
|
51
|
-
* })}
|
|
52
|
-
* </ul>
|
|
53
|
-
* );
|
|
54
|
-
* };
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
function createLdoSvelteMethods(plugins) {
|
|
58
|
-
const dataset = (0, _ldo_connected.createConnectedLdoDataset)(plugins);
|
|
59
|
-
dataset.setMaxListeners(1e3);
|
|
60
|
-
return {
|
|
61
|
-
dataset,
|
|
62
|
-
useLdo: require_useLdo.createUseLdo(dataset),
|
|
63
|
-
useMatchObject: require_useMatchObject.createUseMatchObject(dataset),
|
|
64
|
-
useMatchSubject: require_useMatchSubject.createUseMatchSubject(dataset),
|
|
65
|
-
useResource: require_useResource.createUseResource(dataset),
|
|
66
|
-
useSubject: require_useSubject.createUseSubject(dataset),
|
|
67
|
-
useSubscribeToResource: require_useSubscribeToResource.createUseSubscribeToResource(dataset),
|
|
68
|
-
useLinkQuery: require_useLinkQuery.createUseLinkQuery(dataset)
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
//#endregion
|
|
72
|
-
exports.createLdoSvelteMethods = createLdoSvelteMethods;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createLdoSvelteMethods.d.cts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sBAAA,iBACE,eAAA,uBAAA,CAChB,OAAA,EAAS,OAAA"}
|