@ldo/svelte 1.0.0-alpha.46 → 1.0.0-alpha.50
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 +16 -9
- package/dist/createLdoSvelteMethods.d.cts.map +1 -1
- package/dist/createLdoSvelteMethods.d.mts +16 -9
- package/dist/createLdoSvelteMethods.d.mts.map +1 -1
- package/dist/methods/useLdo.cjs +28 -0
- package/dist/methods/useLdo.mjs +28 -0
- package/dist/methods/useLdo.mjs.map +1 -1
- package/dist/methods/useResource.mjs.map +1 -1
- package/dist/util/useTrackingProxy.mjs.map +1 -1
- package/package.json +9 -8
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { UseLdoMethods } from "./methods/useLdo.cjs";
|
|
2
|
+
import { useResourceType } from "./methods/useResource.cjs";
|
|
3
|
+
import { useSubjectType } from "./methods/useSubject.cjs";
|
|
4
|
+
import * as _$_ldo_connected0 from "@ldo/connected";
|
|
2
5
|
import { ConnectedPlugin } from "@ldo/connected";
|
|
6
|
+
import * as _$_ldo_ldo0 from "@ldo/ldo";
|
|
7
|
+
import * as _$_ldo_rdf_utils0 from "@ldo/rdf-utils";
|
|
8
|
+
import * as _$_ldo_jsonld_dataset_proxy0 from "@ldo/jsonld-dataset-proxy";
|
|
9
|
+
import * as _$svelte_store0 from "svelte/store";
|
|
3
10
|
|
|
4
11
|
//#region src/createLdoSvelteMethods.d.ts
|
|
5
12
|
/**
|
|
@@ -50,14 +57,14 @@ import { ConnectedPlugin } from "@ldo/connected";
|
|
|
50
57
|
* ```
|
|
51
58
|
*/
|
|
52
59
|
declare function createLdoSvelteMethods<Plugins extends ConnectedPlugin<any, any, any, any>[]>(plugins: Plugins): {
|
|
53
|
-
dataset: _ldo_connected0.ConnectedLdoDataset<Plugins>;
|
|
54
|
-
useLdo:
|
|
55
|
-
useMatchObject:
|
|
56
|
-
useMatchSubject:
|
|
57
|
-
useResource:
|
|
58
|
-
useSubject:
|
|
59
|
-
useSubscribeToResource:
|
|
60
|
-
useLinkQuery:
|
|
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>;
|
|
61
68
|
};
|
|
62
69
|
//#endregion
|
|
63
70
|
export { createLdoSvelteMethods };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLdoSvelteMethods.d.cts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createLdoSvelteMethods.d.cts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sBAAA,iBACE,eAAA,uBAAA,CAChB,OAAA,EAAS,OAAA"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
import
|
|
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";
|
|
2
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";
|
|
3
10
|
|
|
4
11
|
//#region src/createLdoSvelteMethods.d.ts
|
|
5
12
|
/**
|
|
@@ -50,14 +57,14 @@ import { ConnectedPlugin } from "@ldo/connected";
|
|
|
50
57
|
* ```
|
|
51
58
|
*/
|
|
52
59
|
declare function createLdoSvelteMethods<Plugins extends ConnectedPlugin<any, any, any, any>[]>(plugins: Plugins): {
|
|
53
|
-
dataset: _ldo_connected0.ConnectedLdoDataset<Plugins>;
|
|
54
|
-
useLdo:
|
|
55
|
-
useMatchObject:
|
|
56
|
-
useMatchSubject:
|
|
57
|
-
useResource:
|
|
58
|
-
useSubject:
|
|
59
|
-
useSubscribeToResource:
|
|
60
|
-
useLinkQuery:
|
|
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>;
|
|
61
68
|
};
|
|
62
69
|
//#endregion
|
|
63
70
|
export { createLdoSvelteMethods };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createLdoSvelteMethods.d.mts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"createLdoSvelteMethods.d.mts","names":[],"sources":["../src/createLdoSvelteMethods.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA4DA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAgB,sBAAA,iBACE,eAAA,uBAAA,CAChB,OAAA,EAAS,OAAA"}
|
package/dist/methods/useLdo.cjs
CHANGED
|
@@ -8,15 +8,43 @@ let _ldo_ldo = require("@ldo/ldo");
|
|
|
8
8
|
function createUseLdo(dataset) {
|
|
9
9
|
const toReturn = {
|
|
10
10
|
dataset,
|
|
11
|
+
/**
|
|
12
|
+
* Gets a resource
|
|
13
|
+
*/
|
|
11
14
|
getResource: dataset.getResource.bind(dataset),
|
|
15
|
+
/**
|
|
16
|
+
* Set the context
|
|
17
|
+
*/
|
|
12
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
|
+
*/
|
|
13
25
|
getSubject(shapeType, subject) {
|
|
14
26
|
return dataset.usingType(shapeType).fromSubject(subject);
|
|
15
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
|
+
*/
|
|
16
35
|
createData(shapeType, subject, resource, ...additionalResources) {
|
|
17
36
|
return dataset.createData(shapeType, subject, resource, ...additionalResources);
|
|
18
37
|
},
|
|
38
|
+
/**
|
|
39
|
+
* Begins tracking changes to eventually commit
|
|
40
|
+
* @param input A linked data object to track changes on
|
|
41
|
+
* @param resources
|
|
42
|
+
*/
|
|
19
43
|
changeData: _ldo_connected.changeData,
|
|
44
|
+
/**
|
|
45
|
+
* Commits the transaction to the global dataset, syncing all subscribing
|
|
46
|
+
* components and Solid Pods
|
|
47
|
+
*/
|
|
20
48
|
commitData(input) {
|
|
21
49
|
return (0, _ldo_ldo.getDataset)(input).commitToRemote();
|
|
22
50
|
}
|
package/dist/methods/useLdo.mjs
CHANGED
|
@@ -8,15 +8,43 @@ import { getDataset } from "@ldo/ldo";
|
|
|
8
8
|
function createUseLdo(dataset) {
|
|
9
9
|
const toReturn = {
|
|
10
10
|
dataset,
|
|
11
|
+
/**
|
|
12
|
+
* Gets a resource
|
|
13
|
+
*/
|
|
11
14
|
getResource: dataset.getResource.bind(dataset),
|
|
15
|
+
/**
|
|
16
|
+
* Set the context
|
|
17
|
+
*/
|
|
12
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
|
+
*/
|
|
13
25
|
getSubject(shapeType, subject) {
|
|
14
26
|
return dataset.usingType(shapeType).fromSubject(subject);
|
|
15
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
|
+
*/
|
|
16
35
|
createData(shapeType, subject, resource, ...additionalResources) {
|
|
17
36
|
return dataset.createData(shapeType, subject, resource, ...additionalResources);
|
|
18
37
|
},
|
|
38
|
+
/**
|
|
39
|
+
* Begins tracking changes to eventually commit
|
|
40
|
+
* @param input A linked data object to track changes on
|
|
41
|
+
* @param resources
|
|
42
|
+
*/
|
|
19
43
|
changeData,
|
|
44
|
+
/**
|
|
45
|
+
* Commits the transaction to the global dataset, syncing all subscribing
|
|
46
|
+
* components and Solid Pods
|
|
47
|
+
*/
|
|
20
48
|
commitData(input) {
|
|
21
49
|
return getDataset(input).commitToRemote();
|
|
22
50
|
}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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 +1 @@
|
|
|
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;;;
|
|
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useTrackingProxy.mjs","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,
|
|
1
|
+
{"version":3,"file":"useTrackingProxy.mjs","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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ldo/svelte",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.50",
|
|
4
4
|
"description": "A Svelte library for LDO.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.cjs",
|
|
@@ -43,12 +43,13 @@
|
|
|
43
43
|
},
|
|
44
44
|
"homepage": "https://github.com/o-development/ldo/tree/main/packages/svelte#readme",
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@ldo/test-solid-server": "^1.0.0-alpha.
|
|
46
|
+
"@ldo/test-solid-server": "^1.0.0-alpha.50",
|
|
47
47
|
"@sveltejs/vite-plugin-svelte": "^2.5.3",
|
|
48
48
|
"@testing-library/jest-dom": "^6.6.3",
|
|
49
49
|
"@testing-library/svelte": "^5.2.7",
|
|
50
50
|
"@tsconfig/svelte": "^5.0.4",
|
|
51
51
|
"concurrently": "^9.1.2",
|
|
52
|
+
"deepmerge": "^4.3.1",
|
|
52
53
|
"eslint-plugin-svelte3": "^4.0.0",
|
|
53
54
|
"identity-obj-proxy": "^3.0.0",
|
|
54
55
|
"rimraf": "^5.0.10",
|
|
@@ -64,11 +65,11 @@
|
|
|
64
65
|
"svelte": "^3.50.0"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"@ldo/connected": "^1.0.0-alpha.
|
|
68
|
-
"@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.
|
|
69
|
-
"@ldo/ldo": "^1.0.0-alpha.
|
|
70
|
-
"@ldo/rdf-utils": "^1.0.0-alpha.
|
|
71
|
-
"@ldo/subscribable-dataset": "^1.0.0-alpha.
|
|
68
|
+
"@ldo/connected": "^1.0.0-alpha.50",
|
|
69
|
+
"@ldo/jsonld-dataset-proxy": "^1.0.0-alpha.50",
|
|
70
|
+
"@ldo/ldo": "^1.0.0-alpha.50",
|
|
71
|
+
"@ldo/rdf-utils": "^1.0.0-alpha.50",
|
|
72
|
+
"@ldo/subscribable-dataset": "^1.0.0-alpha.50",
|
|
72
73
|
"tsx": "^4.19.4"
|
|
73
74
|
},
|
|
74
75
|
"files": [
|
|
@@ -78,5 +79,5 @@
|
|
|
78
79
|
"publishConfig": {
|
|
79
80
|
"access": "public"
|
|
80
81
|
},
|
|
81
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "7277a6694f01cdb776495a3028a625d8386c4887"
|
|
82
83
|
}
|