@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.
Files changed (84) hide show
  1. package/dist/{createLdoSvelteMethods.d.cts → createLdoSvelteMethods.d.ts} +6 -6
  2. package/dist/createLdoSvelteMethods.d.ts.map +1 -0
  3. package/dist/{createLdoSvelteMethods.mjs → createLdoSvelteMethods.js} +9 -9
  4. package/dist/createLdoSvelteMethods.js.map +1 -0
  5. package/dist/{index.d.cts → index.d.ts} +8 -8
  6. package/dist/{index.mjs → index.js} +8 -8
  7. package/dist/methods/{useLdo.d.mts → useLdo.d.ts} +4 -4
  8. package/dist/methods/useLdo.d.ts.map +1 -0
  9. package/dist/methods/{useLdo.mjs → useLdo.js} +1 -1
  10. package/dist/methods/useLdo.js.map +1 -0
  11. package/dist/methods/{useLinkQuery.d.cts → useLinkQuery.d.ts} +2 -2
  12. package/dist/methods/useLinkQuery.d.ts.map +1 -0
  13. package/dist/methods/{useLinkQuery.mjs → useLinkQuery.js} +2 -2
  14. package/dist/methods/useLinkQuery.js.map +1 -0
  15. package/dist/methods/{useMatchObject.d.cts → useMatchObject.d.ts} +2 -2
  16. package/dist/methods/useMatchObject.d.ts.map +1 -0
  17. package/dist/methods/{useMatchObject.mjs → useMatchObject.js} +2 -2
  18. package/dist/methods/useMatchObject.js.map +1 -0
  19. package/dist/methods/{useMatchSubject.d.cts → useMatchSubject.d.ts} +2 -2
  20. package/dist/methods/useMatchSubject.d.ts.map +1 -0
  21. package/dist/methods/{useMatchSubject.mjs → useMatchSubject.js} +2 -2
  22. package/dist/methods/useMatchSubject.js.map +1 -0
  23. package/dist/methods/{useResource.d.cts → useResource.d.ts} +1 -1
  24. package/dist/methods/useResource.d.ts.map +1 -0
  25. package/dist/methods/{useResource.mjs → useResource.js} +1 -1
  26. package/dist/methods/useResource.js.map +1 -0
  27. package/dist/methods/{useSubject.d.cts → useSubject.d.ts} +2 -2
  28. package/dist/methods/useSubject.d.ts.map +1 -0
  29. package/dist/methods/{useSubject.mjs → useSubject.js} +2 -2
  30. package/dist/methods/useSubject.js.map +1 -0
  31. package/dist/methods/{useSubscribeToResource.d.cts → useSubscribeToResource.d.ts} +1 -1
  32. package/dist/methods/useSubscribeToResource.d.ts.map +1 -0
  33. package/dist/methods/{useSubscribeToResource.mjs → useSubscribeToResource.js} +1 -1
  34. package/dist/methods/useSubscribeToResource.js.map +1 -0
  35. package/dist/util/{useTrackingProxy.mjs → useTrackingProxy.js} +1 -1
  36. package/dist/util/useTrackingProxy.js.map +1 -0
  37. package/package.json +15 -19
  38. package/src/createLdoSvelteMethods.tsx +1 -1
  39. package/src/methods/useLdo.ts +3 -3
  40. package/src/methods/useResource.ts +1 -1
  41. package/dist/createLdoSvelteMethods.cjs +0 -72
  42. package/dist/createLdoSvelteMethods.d.cts.map +0 -1
  43. package/dist/createLdoSvelteMethods.d.mts +0 -71
  44. package/dist/createLdoSvelteMethods.d.mts.map +0 -1
  45. package/dist/createLdoSvelteMethods.mjs.map +0 -1
  46. package/dist/index.cjs +0 -17
  47. package/dist/index.d.mts +0 -9
  48. package/dist/methods/useLdo.cjs +0 -57
  49. package/dist/methods/useLdo.d.cts +0 -63
  50. package/dist/methods/useLdo.d.cts.map +0 -1
  51. package/dist/methods/useLdo.d.mts.map +0 -1
  52. package/dist/methods/useLdo.mjs.map +0 -1
  53. package/dist/methods/useLinkQuery.cjs +0 -32
  54. package/dist/methods/useLinkQuery.d.cts.map +0 -1
  55. package/dist/methods/useLinkQuery.d.mts +0 -15
  56. package/dist/methods/useLinkQuery.d.mts.map +0 -1
  57. package/dist/methods/useLinkQuery.mjs.map +0 -1
  58. package/dist/methods/useMatchObject.cjs +0 -21
  59. package/dist/methods/useMatchObject.d.cts.map +0 -1
  60. package/dist/methods/useMatchObject.d.mts +0 -15
  61. package/dist/methods/useMatchObject.d.mts.map +0 -1
  62. package/dist/methods/useMatchObject.mjs.map +0 -1
  63. package/dist/methods/useMatchSubject.cjs +0 -21
  64. package/dist/methods/useMatchSubject.d.cts.map +0 -1
  65. package/dist/methods/useMatchSubject.d.mts +0 -15
  66. package/dist/methods/useMatchSubject.d.mts.map +0 -1
  67. package/dist/methods/useMatchSubject.mjs.map +0 -1
  68. package/dist/methods/useResource.cjs +0 -33
  69. package/dist/methods/useResource.d.cts.map +0 -1
  70. package/dist/methods/useResource.d.mts +0 -27
  71. package/dist/methods/useResource.d.mts.map +0 -1
  72. package/dist/methods/useResource.mjs.map +0 -1
  73. package/dist/methods/useSubject.cjs +0 -22
  74. package/dist/methods/useSubject.d.cts.map +0 -1
  75. package/dist/methods/useSubject.d.mts +0 -20
  76. package/dist/methods/useSubject.d.mts.map +0 -1
  77. package/dist/methods/useSubject.mjs.map +0 -1
  78. package/dist/methods/useSubscribeToResource.cjs +0 -16
  79. package/dist/methods/useSubscribeToResource.d.cts.map +0 -1
  80. package/dist/methods/useSubscribeToResource.d.mts +0 -12
  81. package/dist/methods/useSubscribeToResource.d.mts.map +0 -1
  82. package/dist/methods/useSubscribeToResource.mjs.map +0 -1
  83. package/dist/util/useTrackingProxy.cjs +0 -35
  84. package/dist/util/useTrackingProxy.mjs.map +0 -1
@@ -1,71 +0,0 @@
1
- import { UseLdoMethods } from "./methods/useLdo.mjs";
2
- import { useResourceType } from "./methods/useResource.mjs";
3
- import { useSubjectType } from "./methods/useSubject.mjs";
4
- import * as _$_ldo_connected0 from "@ldo/connected";
5
- import { ConnectedPlugin } from "@ldo/connected";
6
- import * as _$_ldo_ldo0 from "@ldo/ldo";
7
- import * as _$svelte_store0 from "svelte/store";
8
- import * as _$_ldo_rdf_utils0 from "@ldo/rdf-utils";
9
- import * as _$_ldo_jsonld_dataset_proxy0 from "@ldo/jsonld-dataset-proxy";
10
-
11
- //#region src/createLdoSvelteMethods.d.ts
12
- /**
13
- * A function that creates all common react functions given specific plugin.
14
- *
15
- * @example
16
- * `methods.ts`
17
- * ```tyepscript
18
- * import { solidConnectedPlugin } from "@ldo/connected-solid";
19
- * import { nextGraphConnectedPlugin } from "@ldo/connected-nextgraph";
20
- * import { createLdoReactMethods } from "@ldo/react";
21
- *
22
- * // Export the results to be used in the reset of the application
23
- * export const {
24
- * dataset,
25
- * useLdo,
26
- * useMatchObject,
27
- * useMatchSubject,
28
- * useResource,
29
- * useSubject,
30
- * useSubscribeToResource,
31
- * useLinkQuery,
32
- * } = createLdoReactMethods([
33
- * solidConnectedPlugin,
34
- * nextGraphConnectedPlugin
35
- * ]);
36
- * ```
37
- *
38
- * `App.tsx`
39
- * ```typescript
40
- * import react, { FunctionComponent } from "react";
41
- * import { PostShShapeType } from "./_ldo/posts.shapeType.ts";
42
- * import { useResource, useSubject } from "./methods.ts";
43
- *
44
- * const UseSubjectTest: FunctionComponent = () => {
45
- * const resource = useResource(SAMPLE_DATA_URI);
46
- * const post = useSubject(PostShShapeType, `${SAMPLE_DATA_URI}#Post1`);
47
- * if (resource.isLoading() || !post) return <p>loading</p>;
48
- *
49
- * return (
50
- * <ul>
51
- * {post.publisher.map((publisher) => {
52
- * return <li key={publisher["@id"]}>{publisher["@id"]}</li>;
53
- * })}
54
- * </ul>
55
- * );
56
- * };
57
- * ```
58
- */
59
- declare function createLdoSvelteMethods<Plugins extends ConnectedPlugin<any, any, any, any>[]>(plugins: Plugins): {
60
- dataset: _$_ldo_connected0.ConnectedLdoDataset<Plugins>;
61
- useLdo: () => UseLdoMethods<Plugins>;
62
- useMatchObject: <Type extends _$_ldo_ldo0.LdoBase>(shapeType: _$_ldo_ldo0.ShapeType<Type>, subject?: _$_ldo_rdf_utils0.QuadMatch[0] | string, predicate?: _$_ldo_rdf_utils0.QuadMatch[1] | string, graph?: _$_ldo_rdf_utils0.QuadMatch[3] | string) => _$svelte_store0.Readable<_$_ldo_jsonld_dataset_proxy0.LdSet<Type>>;
63
- useMatchSubject: <Type extends _$_ldo_ldo0.LdoBase>(shapeType: _$_ldo_ldo0.ShapeType<Type>, predicate?: _$_ldo_rdf_utils0.QuadMatch[1] | string, object?: _$_ldo_rdf_utils0.QuadMatch[2] | string, graph?: _$_ldo_rdf_utils0.QuadMatch[3] | string) => _$svelte_store0.Readable<_$_ldo_jsonld_dataset_proxy0.LdSet<Type>>;
64
- useResource: useResourceType<Plugins>;
65
- useSubject: useSubjectType;
66
- useSubscribeToResource: (...uris: string[]) => void;
67
- useLinkQuery: <Type extends _$_ldo_ldo0.LdoBase, QueryInput extends Partial<{ [key in Exclude<keyof Type, "@context">]: _$_ldo_connected0.LQInputFlattenSet<Type[key]> }>>(shapeType: _$_ldo_ldo0.ShapeType<Type>, startingResource: string, startingSubject: _$_ldo_rdf_utils0.SubjectNode | string, linkQuery: QueryInput) => _$svelte_store0.Readable<_$_ldo_connected0.ExpandDeep<_$_ldo_connected0.LQReturn<Type, QueryInput>> | undefined>;
68
- };
69
- //#endregion
70
- export { createLdoSvelteMethods };
71
- //# sourceMappingURL=createLdoSvelteMethods.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createLdoSvelteMethods.d.mts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sBAAA,iBACE,eAAA,uBAAA,CAChB,OAAA,EAAS,OAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"createLdoSvelteMethods.mjs","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 * ```tyepscript\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"}
package/dist/index.cjs DELETED
@@ -1,17 +0,0 @@
1
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_useLdo = require("./methods/useLdo.cjs");
3
- const require_useMatchObject = require("./methods/useMatchObject.cjs");
4
- const require_useMatchSubject = require("./methods/useMatchSubject.cjs");
5
- const require_useResource = require("./methods/useResource.cjs");
6
- const require_useSubject = require("./methods/useSubject.cjs");
7
- const require_useSubscribeToResource = require("./methods/useSubscribeToResource.cjs");
8
- const require_useLinkQuery = require("./methods/useLinkQuery.cjs");
9
- const require_createLdoSvelteMethods = require("./createLdoSvelteMethods.cjs");
10
- exports.createLdoSvelteMethods = require_createLdoSvelteMethods.createLdoSvelteMethods;
11
- exports.createUseLdo = require_useLdo.createUseLdo;
12
- exports.createUseLinkQuery = require_useLinkQuery.createUseLinkQuery;
13
- exports.createUseMatchObject = require_useMatchObject.createUseMatchObject;
14
- exports.createUseMatchSubject = require_useMatchSubject.createUseMatchSubject;
15
- exports.createUseResource = require_useResource.createUseResource;
16
- exports.createUseSubject = require_useSubject.createUseSubject;
17
- exports.createUseSubscribeToResource = require_useSubscribeToResource.createUseSubscribeToResource;
package/dist/index.d.mts DELETED
@@ -1,9 +0,0 @@
1
- import { createLdoSvelteMethods } from "./createLdoSvelteMethods.mjs";
2
- import { UseLdoMethods, createUseLdo } from "./methods/useLdo.mjs";
3
- import { createUseMatchObject } from "./methods/useMatchObject.mjs";
4
- import { createUseMatchSubject } from "./methods/useMatchSubject.mjs";
5
- import { UseResourceOptions, createUseResource, useResourceType } from "./methods/useResource.mjs";
6
- import { createUseSubject, useSubjectType } from "./methods/useSubject.mjs";
7
- import { createUseSubscribeToResource } from "./methods/useSubscribeToResource.mjs";
8
- import { createUseLinkQuery } from "./methods/useLinkQuery.mjs";
9
- export { UseLdoMethods, UseResourceOptions, createLdoSvelteMethods, createUseLdo, createUseLinkQuery, createUseMatchObject, createUseMatchSubject, createUseResource, createUseSubject, createUseSubscribeToResource, useResourceType, useSubjectType };
@@ -1,57 +0,0 @@
1
- let _ldo_connected = require("@ldo/connected");
2
- let _ldo_ldo = require("@ldo/ldo");
3
- //#region src/methods/useLdo.ts
4
- /**
5
- * @internal
6
- * Creates the useLdoHook
7
- */
8
- function createUseLdo(dataset) {
9
- const toReturn = {
10
- dataset,
11
- /**
12
- * Gets a resource
13
- */
14
- getResource: dataset.getResource.bind(dataset),
15
- /**
16
- * Set the context
17
- */
18
- setContext: dataset.setContext.bind(dataset),
19
- /**
20
- * Returns a Linked Data Object for a subject
21
- * @param shapeType The shape type for the data
22
- * @param subject Subject Node
23
- * @returns A Linked Data Object
24
- */
25
- getSubject(shapeType, subject) {
26
- return dataset.usingType(shapeType).fromSubject(subject);
27
- },
28
- /**
29
- * Begins tracking changes to eventually commit for a new subject
30
- * @param shapeType The shape type that defines the created data
31
- * @param subject The RDF subject for a Linked Data Object
32
- * @param resources Any number of resources to which this data should be written
33
- * @returns A Linked Data Object to modify and commit
34
- */
35
- createData(shapeType, subject, resource, ...additionalResources) {
36
- return dataset.createData(shapeType, subject, resource, ...additionalResources);
37
- },
38
- /**
39
- * Begins tracking changes to eventually commit
40
- * @param input A linked data object to track changes on
41
- * @param resources
42
- */
43
- changeData: _ldo_connected.changeData,
44
- /**
45
- * Commits the transaction to the global dataset, syncing all subscribing
46
- * components and Solid Pods
47
- */
48
- commitData(input) {
49
- return (0, _ldo_ldo.getDataset)(input).commitToRemote();
50
- }
51
- };
52
- return function useLdo() {
53
- return toReturn;
54
- };
55
- }
56
- //#endregion
57
- exports.createUseLdo = createUseLdo;
@@ -1,63 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedLdoTransactionDataset, ConnectedPlugin } from "@ldo/connected";
2
- import { LdoBase, ShapeType } from "@ldo/ldo";
3
- import { SubjectNode } from "@ldo/rdf-utils";
4
-
5
- //#region src/methods/useLdo.d.ts
6
- /**
7
- * The methods returned by useLdo
8
- */
9
- interface UseLdoMethods<Plugins extends ConnectedPlugin[]> {
10
- /**
11
- * A ConnectedLdoDataset
12
- */
13
- dataset: ConnectedLdoDataset<Plugins>;
14
- /**
15
- * Retireves a representation of a Resource at the given URI. This resource
16
- * represents the current state of the resource: whether it is currently
17
- * fetched or in the process of fetching as well as some information about it.
18
- *
19
- * @param uri - the URI of the resource
20
- * @param pluginName - optionally, force this function to choose a specific
21
- * plugin to use rather than perform content negotiation.
22
- *
23
- * @returns a Resource
24
- */
25
- getResource: ConnectedLdoDataset<Plugins>["getResource"];
26
- /**
27
- * Sets conetext for a specific plugin
28
- *
29
- * @param pluginName - the name of the plugin
30
- * @param context - the context for this specific plugin
31
- */
32
- setContext: ConnectedLdoDataset<Plugins>["setContext"];
33
- /**
34
- * Gets a linked data object based on the subject
35
- */
36
- getSubject<Type extends LdoBase>(shapeType: ShapeType<Type>, subject: string | SubjectNode): Type;
37
- /**
38
- * Shorthand for connectedLdoDataset
39
- * .usingType(shapeType)
40
- * .write(...resources.map((r) => r.uri))
41
- * .fromSubject(subject);
42
- * @param shapeType - The shapetype to represent the data
43
- * @param subject - A subject URI
44
- * @param resources - The resources changes to should written to
45
- */
46
- createData<Type extends LdoBase>(shapeType: ShapeType<Type>, subject: string | SubjectNode, resource: Plugins[number]["types"]["resource"], ...additionalResources: Plugins[number]["types"]["resource"][]): Type;
47
- /**
48
- * Returns a writable LinkedDataObject given a linked data object
49
- */
50
- changeData<Type extends LdoBase>(input: Type, resource: Plugins[number]["types"]["resource"], ...additionalResources: Plugins[number]["types"]["resource"][]): Type;
51
- /**
52
- * Commits the data of a writable Linke Data Object back to the remote.
53
- */
54
- commitData(input: LdoBase): ReturnType<ConnectedLdoTransactionDataset<Plugins>["commitToRemote"]>;
55
- }
56
- /**
57
- * @internal
58
- * Creates the useLdoHook
59
- */
60
- declare function createUseLdo<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): () => UseLdoMethods<Plugins>;
61
- //#endregion
62
- export { UseLdoMethods, createUseLdo };
63
- //# sourceMappingURL=useLdo.d.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLdo.d.cts","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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLdo.d.mts","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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLdo.mjs","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 * Retireves 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 conetext 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 Linke 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,32 +0,0 @@
1
- const require_useTrackingProxy = require("../util/useTrackingProxy.cjs");
2
- let svelte = require("svelte");
3
- //#region src/methods/useLinkQuery.ts
4
- /**
5
- * @internal
6
- *
7
- * Creates a useMatchSubject function.
8
- */
9
- function createUseLinkQuery(dataset) {
10
- /**
11
- * Returns an array of matching linked data objects. Triggers a rerender if
12
- * the data is updated.
13
- */
14
- return function useQueryLink(shapeType, startingResource, startingSubject, linkQuery) {
15
- const resource = dataset.getResource(startingResource);
16
- console.log(resource);
17
- const lq = dataset.usingType(shapeType).startLinkQuery(resource, startingSubject, linkQuery);
18
- console.log("Calling subscribe");
19
- lq.subscribe();
20
- console.log("After call subscribe");
21
- (0, svelte.onDestroy)(() => {
22
- lq.unsubscribeAll();
23
- });
24
- const fromSubject = (builder) => {
25
- if (!startingSubject) return;
26
- return builder.fromSubject(startingSubject);
27
- };
28
- return require_useTrackingProxy.useTrackingProxy(shapeType, fromSubject, dataset);
29
- };
30
- }
31
- //#endregion
32
- exports.createUseLinkQuery = createUseLinkQuery;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLinkQuery.d.cts","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,15 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin, ExpandDeep, LQInput, LQReturn } from "@ldo/connected";
2
- import { LdoBase, ShapeType } from "@ldo/ldo";
3
- import { Readable } from "svelte/store";
4
- import { SubjectNode } from "@ldo/rdf-utils";
5
-
6
- //#region src/methods/useLinkQuery.d.ts
7
- /**
8
- * @internal
9
- *
10
- * Creates a useMatchSubject function.
11
- */
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
- //#endregion
14
- export { createUseLinkQuery };
15
- //# sourceMappingURL=useLinkQuery.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useLinkQuery.d.mts","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 +0,0 @@
1
- {"version":3,"file":"useLinkQuery.mjs","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,21 +0,0 @@
1
- const require_useTrackingProxy = require("../util/useTrackingProxy.cjs");
2
- //#region src/methods/useMatchObject.ts
3
- /**
4
- * @internal
5
- *
6
- * Creates a useMatchObject function
7
- */
8
- function createUseMatchObject(dataset) {
9
- /**
10
- * Returns an array of matching items and triggers a rerender when that data
11
- * is updated.
12
- */
13
- return function useMatchObject(shapeType, subject, predicate, graph) {
14
- const matchObject = (builder) => {
15
- return builder.matchObject(subject, predicate, graph);
16
- };
17
- return require_useTrackingProxy.useTrackingProxy(shapeType, matchObject, dataset);
18
- };
19
- }
20
- //#endregion
21
- exports.createUseMatchObject = createUseMatchObject;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchObject.d.cts","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,15 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
2
- import { LdSet, LdoBase, ShapeType } from "@ldo/ldo";
3
- import { Readable } from "svelte/store";
4
- import { QuadMatch } from "@ldo/rdf-utils";
5
-
6
- //#region src/methods/useMatchObject.d.ts
7
- /**
8
- * @internal
9
- *
10
- * Creates a useMatchObject function
11
- */
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
- //#endregion
14
- export { createUseMatchObject };
15
- //# sourceMappingURL=useMatchObject.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchObject.d.mts","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 +0,0 @@
1
- {"version":3,"file":"useMatchObject.mjs","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,21 +0,0 @@
1
- const require_useTrackingProxy = require("../util/useTrackingProxy.cjs");
2
- //#region src/methods/useMatchSubject.ts
3
- /**
4
- * @internal
5
- *
6
- * Creates a useMatchSubject function.
7
- */
8
- function createUseMatchSubject(dataset) {
9
- /**
10
- * Returns an array of matching linked data objects. Triggers a rerender if
11
- * the data is updated.
12
- */
13
- return function useMatchSubject(shapeType, predicate, object, graph) {
14
- const matchSubject = (builder) => {
15
- return builder.matchSubject(predicate, object, graph);
16
- };
17
- return require_useTrackingProxy.useTrackingProxy(shapeType, matchSubject, dataset);
18
- };
19
- }
20
- //#endregion
21
- exports.createUseMatchSubject = createUseMatchSubject;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchSubject.d.cts","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,15 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
2
- import { LdSet, LdoBase, ShapeType } from "@ldo/ldo";
3
- import { Readable } from "svelte/store";
4
- import { QuadMatch } from "@ldo/rdf-utils";
5
-
6
- //#region src/methods/useMatchSubject.d.ts
7
- /**
8
- * @internal
9
- *
10
- * Creates a useMatchSubject function.
11
- */
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
- //#endregion
14
- export { createUseMatchSubject };
15
- //# sourceMappingURL=useMatchSubject.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useMatchSubject.d.mts","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 +0,0 @@
1
- {"version":3,"file":"useMatchSubject.mjs","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"}
@@ -1,33 +0,0 @@
1
- let svelte_store = require("svelte/store");
2
- //#region src/methods/useResource.ts
3
- /**
4
- * @internal
5
- *
6
- * Creates a useResource function.
7
- */
8
- function createUseResource(dataset) {
9
- /**
10
- * Returns a resource and triggers a rerender if that resource is updated.
11
- */
12
- return function useResource(uri, options) {
13
- let resource;
14
- if (uri) {
15
- resource = dataset.getResource(uri);
16
- if (!options?.suppressInitialRead) if (options?.reloadOnMount) resource.read();
17
- else resource.readIfUnfetched();
18
- } else resource = void 0;
19
- return { subscribe: (0, svelte_store.writable)(resource, (set) => {
20
- const onResourceUpdate = () => {
21
- set(resource);
22
- };
23
- if (resource) {
24
- resource.on("update", onResourceUpdate);
25
- return () => {
26
- resource.off("update", onResourceUpdate);
27
- };
28
- }
29
- }).subscribe };
30
- };
31
- }
32
- //#endregion
33
- exports.createUseResource = createUseResource;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useResource.d.cts","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"}
@@ -1,27 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin, GetResourceReturnType } from "@ldo/connected";
2
- import { Readable } from "svelte/store";
3
-
4
- //#region src/methods/useResource.d.ts
5
- interface UseResourceOptions<Name> {
6
- pluginName?: Name;
7
- suppressInitialRead?: boolean;
8
- reloadOnMount?: boolean;
9
- subscribe?: boolean;
10
- }
11
- type useResourceType<Plugins extends ConnectedPlugin[]> = {
12
- <Name extends Plugins[number]["name"], Plugin extends Extract<Plugins[number], {
13
- name: Name;
14
- }>, UriType extends string>(uri: UriType, options?: UseResourceOptions<Name>): Readable<GetResourceReturnType<Plugin, UriType>>;
15
- <Name extends Plugins[number]["name"], Plugin extends Extract<Plugins[number], {
16
- name: Name;
17
- }>, UriType extends string>(uri?: UriType, options?: UseResourceOptions<Name>): Readable<GetResourceReturnType<Plugin, UriType> | undefined>;
18
- };
19
- /**
20
- * @internal
21
- *
22
- * Creates a useResource function.
23
- */
24
- declare function createUseResource<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): useResourceType<Plugins>;
25
- //#endregion
26
- export { UseResourceOptions, createUseResource, useResourceType };
27
- //# sourceMappingURL=useResource.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useResource.d.mts","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"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useResource.mjs","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 necissary\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,22 +0,0 @@
1
- const require_useTrackingProxy = require("../util/useTrackingProxy.cjs");
2
- //#region src/methods/useSubject.ts
3
- /**
4
- * @internal
5
- *
6
- * Creates a useSubject function.
7
- */
8
- function createUseSubject(dataset) {
9
- /**
10
- * Returns a Linked Data Object based on the provided subject. Triggers a
11
- * rerender if the data is udpated.
12
- */
13
- return function useSubject(shapeType, subject) {
14
- const fromSubject = (builder) => {
15
- if (!subject) return;
16
- return builder.fromSubject(subject);
17
- };
18
- return require_useTrackingProxy.useTrackingProxy(shapeType, fromSubject, dataset);
19
- };
20
- }
21
- //#endregion
22
- exports.createUseSubject = createUseSubject;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSubject.d.cts","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,20 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
2
- import { LdoBase, ShapeType } from "@ldo/ldo";
3
- import { Readable } from "svelte/store";
4
- import { SubjectNode } from "@ldo/rdf-utils";
5
-
6
- //#region src/methods/useSubject.d.ts
7
- type useSubjectType = {
8
- <Type extends LdoBase>(shapeType: ShapeType<Type>, subject: string | SubjectNode): Readable<Type>;
9
- <Type extends LdoBase>(shapeType: ShapeType<Type>, subject?: string | SubjectNode): Readable<Type | undefined>;
10
- <Type extends LdoBase>(shapeType: ShapeType<Type>, subject?: string | SubjectNode): Readable<Type | undefined>;
11
- };
12
- /**
13
- * @internal
14
- *
15
- * Creates a useSubject function.
16
- */
17
- declare function createUseSubject<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): useSubjectType;
18
- //#endregion
19
- export { createUseSubject, useSubjectType };
20
- //# sourceMappingURL=useSubject.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSubject.d.mts","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 +0,0 @@
1
- {"version":3,"file":"useSubject.mjs","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"}
@@ -1,16 +0,0 @@
1
- //#region src/methods/useSubscribeToResource.ts
2
- /**
3
- * @internal
4
- *
5
- * Creates a useSubscribeToResource function.
6
- */
7
- function createUseSubscribeToResource(dataset) {
8
- /**
9
- * Starts a subscription to a resource.
10
- */
11
- return function useSubscribeToResource(...uris) {
12
- throw new Error("Subscribe to Resource is Not Implemented for Svelte");
13
- };
14
- }
15
- //#endregion
16
- exports.createUseSubscribeToResource = createUseSubscribeToResource;
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSubscribeToResource.d.cts","names":[],"sources":["../../src/methods/useSubscribeToResource.ts"],"mappings":";;;;;AAOA;;;iBAAgB,4BAAA,iBAA6C,eAAA,GAAA,CAC3D,OAAA,EAAS,mBAAA,CAAoB,OAAA,QAKa,IAAA"}
@@ -1,12 +0,0 @@
1
- import { ConnectedLdoDataset, ConnectedPlugin } from "@ldo/connected";
2
-
3
- //#region src/methods/useSubscribeToResource.d.ts
4
- /**
5
- * @internal
6
- *
7
- * Creates a useSubscribeToResource function.
8
- */
9
- declare function createUseSubscribeToResource<Plugins extends ConnectedPlugin[]>(dataset: ConnectedLdoDataset<Plugins>): (...uris: string[]) => void;
10
- //#endregion
11
- export { createUseSubscribeToResource };
12
- //# sourceMappingURL=useSubscribeToResource.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSubscribeToResource.d.mts","names":[],"sources":["../../src/methods/useSubscribeToResource.ts"],"mappings":";;;;;AAOA;;;iBAAgB,4BAAA,iBAA6C,eAAA,GAAA,CAC3D,OAAA,EAAS,mBAAA,CAAoB,OAAA,QAKa,IAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"useSubscribeToResource.mjs","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"}