@xyo-network/react-payload-huri 2.78.0 → 2.78.2
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/browser/index.cjs +72 -1
- package/dist/browser/index.cjs.map +1 -1
- package/dist/browser/index.js +49 -1
- package/dist/browser/index.js.map +1 -1
- package/dist/neutral/index.cjs +72 -1
- package/dist/neutral/index.cjs.map +1 -1
- package/dist/neutral/index.js +49 -1
- package/dist/neutral/index.js.map +1 -1
- package/dist/node/index.cjs +79 -1
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.js +50 -1
- package/dist/node/index.js.map +1 -1
- package/package.json +5 -5
package/dist/browser/index.cjs
CHANGED
|
@@ -1,2 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
useBuildHuri: () => useBuildHuri,
|
|
24
|
+
useFetchHuri: () => useFetchHuri,
|
|
25
|
+
useParseHuriFromRoute: () => useParseHuriFromRoute
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useBuildHuri.tsx
|
|
30
|
+
var import_react_network = require("@xyo-network/react-network");
|
|
31
|
+
var useBuildHuri = (hash) => {
|
|
32
|
+
const { network } = (0, import_react_network.useNetwork)();
|
|
33
|
+
const networkUri = network?.nodes?.find((node) => node.type === "archivist")?.uri;
|
|
34
|
+
if (!hash || hash.startsWith("http")) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return `${networkUri}/${hash}`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/hooks/useFetchHuri.tsx
|
|
41
|
+
var import_react_promise = require("@xylabs/react-promise");
|
|
42
|
+
var import_diviner_huri = require("@xyo-network/diviner-huri");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
45
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
46
|
+
const huriPayload = (0, import_react.useMemo)(
|
|
47
|
+
() => huri ? { huri: [huri], schema: import_diviner_huri.HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
48
|
+
[huri, token]
|
|
49
|
+
);
|
|
50
|
+
return (0, import_react_promise.usePromise)(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
54
|
+
var import_react_router_dom = require("react-router-dom");
|
|
55
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
56
|
+
const { hash: hashParam } = (0, import_react_router_dom.useParams)();
|
|
57
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
58
|
+
const [params] = (0, import_react_router_dom.useSearchParams)();
|
|
59
|
+
const huriSearchParameter = params.get("huri");
|
|
60
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
61
|
+
switch (routeOption) {
|
|
62
|
+
case "routeParam": {
|
|
63
|
+
return huriFromHashParam;
|
|
64
|
+
}
|
|
65
|
+
case "searchParam": {
|
|
66
|
+
return decodedHuriParam;
|
|
67
|
+
}
|
|
68
|
+
default: {
|
|
69
|
+
return huriFromHashParam || decodedHuriParam;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
2
73
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,2BAA2B;AAEpB,IAAM,eAAe,CAAC,SAAkB;AAC7C,QAAM,EAAE,QAAQ,QAAI,iCAAW;AAC/B,QAAM,aAAa,SAAS,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW,GAAG;AAE9E,MAAI,CAAC,QAAQ,KAAK,WAAW,MAAM,GAAG;AACpC;AAAA,EACF;AAEA,SAAO,GAAG,UAAU,IAAI,IAAI;AAC9B;;;ACXA,2BAA2B;AAC3B,0BAAwC;AAExC,mBAAwB;AAIjB,IAAM,eAAe,CAAC,YAAqB,SAA2B,UAAmB;AAC9F,QAAM,OAAO,aAAa,UAAU,KAAK;AACzC,QAAM,kBAAuC;AAAA,IAC3C,MAAO,OAAO,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,gCAAY,QAAQ,QAAQ,CAAC,KAAK,IAAI,OAAU,IAAI;AAAA,IAC1F,CAAC,MAAM,KAAK;AAAA,EACd;AAEA,aAAO,iCAAW,YAAa,WAAW,cAAc,MAAM,QAAQ,OAAO,CAAC,WAAW,CAAC,IAAI,QAAY,CAAC,SAAS,WAAW,CAAC;AAClI;;;ACfA,8BAA2C;AAMpC,IAAM,wBAAwB,CAAC,cAA4B,UAAU;AAC1E,QAAM,EAAE,MAAM,UAAU,QAAI,mCAAU;AAEtC,QAAM,oBAAoB,aAAa,SAAS;AAEhD,QAAM,CAAC,MAAM,QAAI,yCAAgB;AACjC,QAAM,sBAAsB,OAAO,IAAI,MAAM;AAC7C,QAAM,mBAAmB,mBAAmB,uBAAuB,EAAE;AAErE,UAAQ,aAAa;AAAA,IACnB,KAAK,cAAc;AACjB,aAAO;AAAA,IACT;AAAA,IACA,KAAK,eAAe;AAClB,aAAO;AAAA,IACT;AAAA,IACA,SAAS;AACP,aAAO,qBAAqB;AAAA,IAC9B;AAAA,EACF;AACF;","names":[]}
|
package/dist/browser/index.js
CHANGED
|
@@ -1,2 +1,50 @@
|
|
|
1
|
-
|
|
1
|
+
// src/hooks/useBuildHuri.tsx
|
|
2
|
+
import { useNetwork } from "@xyo-network/react-network";
|
|
3
|
+
var useBuildHuri = (hash) => {
|
|
4
|
+
const { network } = useNetwork();
|
|
5
|
+
const networkUri = network?.nodes?.find((node) => node.type === "archivist")?.uri;
|
|
6
|
+
if (!hash || hash.startsWith("http")) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return `${networkUri}/${hash}`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/hooks/useFetchHuri.tsx
|
|
13
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
14
|
+
import { HuriSchema } from "@xyo-network/diviner-huri";
|
|
15
|
+
import { useMemo } from "react";
|
|
16
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
17
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
18
|
+
const huriPayload = useMemo(
|
|
19
|
+
() => huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
20
|
+
[huri, token]
|
|
21
|
+
);
|
|
22
|
+
return usePromise(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
26
|
+
import { useParams, useSearchParams } from "react-router-dom";
|
|
27
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
28
|
+
const { hash: hashParam } = useParams();
|
|
29
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
30
|
+
const [params] = useSearchParams();
|
|
31
|
+
const huriSearchParameter = params.get("huri");
|
|
32
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
33
|
+
switch (routeOption) {
|
|
34
|
+
case "routeParam": {
|
|
35
|
+
return huriFromHashParam;
|
|
36
|
+
}
|
|
37
|
+
case "searchParam": {
|
|
38
|
+
return decodedHuriParam;
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
return huriFromHashParam || decodedHuriParam;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
useBuildHuri,
|
|
47
|
+
useFetchHuri,
|
|
48
|
+
useParseHuriFromRoute
|
|
49
|
+
};
|
|
2
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAEpB,IAAM,eAAe,CAAC,SAAkB;AAC7C,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,aAAa,SAAS,OAAO,KAAK,CAAC,SAAS,KAAK,SAAS,WAAW,GAAG;AAE9E,MAAI,CAAC,QAAQ,KAAK,WAAW,MAAM,GAAG;AACpC;AAAA,EACF;AAEA,SAAO,GAAG,UAAU,IAAI,IAAI;AAC9B;;;ACXA,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AAExC,SAAS,eAAe;AAIjB,IAAM,eAAe,CAAC,YAAqB,SAA2B,UAAmB;AAC9F,QAAM,OAAO,aAAa,UAAU,KAAK;AACzC,QAAM,cAAuC;AAAA,IAC3C,MAAO,OAAO,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,YAAY,QAAQ,QAAQ,CAAC,KAAK,IAAI,OAAU,IAAI;AAAA,IAC1F,CAAC,MAAM,KAAK;AAAA,EACd;AAEA,SAAO,WAAW,YAAa,WAAW,cAAc,MAAM,QAAQ,OAAO,CAAC,WAAW,CAAC,IAAI,QAAY,CAAC,SAAS,WAAW,CAAC;AAClI;;;ACfA,SAAS,WAAW,uBAAuB;AAMpC,IAAM,wBAAwB,CAAC,cAA4B,UAAU;AAC1E,QAAM,EAAE,MAAM,UAAU,IAAI,UAAU;AAEtC,QAAM,oBAAoB,aAAa,SAAS;AAEhD,QAAM,CAAC,MAAM,IAAI,gBAAgB;AACjC,QAAM,sBAAsB,OAAO,IAAI,MAAM;AAC7C,QAAM,mBAAmB,mBAAmB,uBAAuB,EAAE;AAErE,UAAQ,aAAa;AAAA,IACnB,KAAK,cAAc;AACjB,aAAO;AAAA,IACT;AAAA,IACA,KAAK,eAAe;AAClB,aAAO;AAAA,IACT;AAAA,IACA,SAAS;AACP,aAAO,qBAAqB;AAAA,IAC9B;AAAA,EACF;AACF;","names":[]}
|
package/dist/neutral/index.cjs
CHANGED
|
@@ -1,2 +1,73 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
useBuildHuri: () => useBuildHuri,
|
|
24
|
+
useFetchHuri: () => useFetchHuri,
|
|
25
|
+
useParseHuriFromRoute: () => useParseHuriFromRoute
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useBuildHuri.tsx
|
|
30
|
+
var import_react_network = require("@xyo-network/react-network");
|
|
31
|
+
var useBuildHuri = (hash) => {
|
|
32
|
+
const { network } = (0, import_react_network.useNetwork)();
|
|
33
|
+
const networkUri = network?.nodes?.find((node) => node.type === "archivist")?.uri;
|
|
34
|
+
if (!hash || hash.startsWith("http")) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
return `${networkUri}/${hash}`;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// src/hooks/useFetchHuri.tsx
|
|
41
|
+
var import_react_promise = require("@xylabs/react-promise");
|
|
42
|
+
var import_diviner_huri = require("@xyo-network/diviner-huri");
|
|
43
|
+
var import_react = require("react");
|
|
44
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
45
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
46
|
+
const huriPayload = (0, import_react.useMemo)(
|
|
47
|
+
() => huri ? { huri: [huri], schema: import_diviner_huri.HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
48
|
+
[huri, token]
|
|
49
|
+
);
|
|
50
|
+
return (0, import_react_promise.usePromise)(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
54
|
+
var import_react_router_dom = require("react-router-dom");
|
|
55
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
56
|
+
const { hash: hashParam } = (0, import_react_router_dom.useParams)();
|
|
57
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
58
|
+
const [params] = (0, import_react_router_dom.useSearchParams)();
|
|
59
|
+
const huriSearchParameter = params.get("huri");
|
|
60
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
61
|
+
switch (routeOption) {
|
|
62
|
+
case "routeParam": {
|
|
63
|
+
return huriFromHashParam;
|
|
64
|
+
}
|
|
65
|
+
case "searchParam": {
|
|
66
|
+
return decodedHuriParam;
|
|
67
|
+
}
|
|
68
|
+
default: {
|
|
69
|
+
return huriFromHashParam || decodedHuriParam;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
2
73
|
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;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uildHuri.tsx
|
|
2
|
+
import { useNetwork } from "@xyo-network/react-network";
|
|
3
|
+
var useBuildHuri = (hash) => {
|
|
4
|
+
const { network } = useNetwork();
|
|
5
|
+
const networkUri = network?.nodes?.find((node) => node.type === "archivist")?.uri;
|
|
6
|
+
if (!hash || hash.startsWith("http")) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return `${networkUri}/${hash}`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
// src/hooks/useFetchHuri.tsx
|
|
13
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
14
|
+
import { HuriSchema } from "@xyo-network/diviner-huri";
|
|
15
|
+
import { useMemo } from "react";
|
|
16
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
17
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
18
|
+
const huriPayload = useMemo(
|
|
19
|
+
() => huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
20
|
+
[huri, token]
|
|
21
|
+
);
|
|
22
|
+
return usePromise(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
26
|
+
import { useParams, useSearchParams } from "react-router-dom";
|
|
27
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
28
|
+
const { hash: hashParam } = useParams();
|
|
29
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
30
|
+
const [params] = useSearchParams();
|
|
31
|
+
const huriSearchParameter = params.get("huri");
|
|
32
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
33
|
+
switch (routeOption) {
|
|
34
|
+
case "routeParam": {
|
|
35
|
+
return huriFromHashParam;
|
|
36
|
+
}
|
|
37
|
+
case "searchParam": {
|
|
38
|
+
return decodedHuriParam;
|
|
39
|
+
}
|
|
40
|
+
default: {
|
|
41
|
+
return huriFromHashParam || decodedHuriParam;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
useBuildHuri,
|
|
47
|
+
useFetchHuri,
|
|
48
|
+
useParseHuriFromRoute
|
|
49
|
+
};
|
|
2
50
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mapp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
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
useBuildHuri: () => useBuildHuri,
|
|
24
|
+
useFetchHuri: () => useFetchHuri,
|
|
25
|
+
useParseHuriFromRoute: () => useParseHuriFromRoute
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(src_exports);
|
|
28
|
+
|
|
29
|
+
// src/hooks/useBuildHuri.tsx
|
|
30
|
+
var import_react_network = require("@xyo-network/react-network");
|
|
31
|
+
var useBuildHuri = (hash) => {
|
|
32
|
+
var _a, _b;
|
|
33
|
+
const { network } = (0, import_react_network.useNetwork)();
|
|
34
|
+
const networkUri = (_b = (_a = network == null ? void 0 : network.nodes) == null ? void 0 : _a.find((node) => node.type === "archivist")) == null ? void 0 : _b.uri;
|
|
35
|
+
if (!hash || hash.startsWith("http")) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
return `${networkUri}/${hash}`;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// src/hooks/useFetchHuri.tsx
|
|
42
|
+
var import_react_promise = require("@xylabs/react-promise");
|
|
43
|
+
var import_diviner_huri = require("@xyo-network/diviner-huri");
|
|
44
|
+
var import_react = require("react");
|
|
45
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
46
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
47
|
+
const huriPayload = (0, import_react.useMemo)(
|
|
48
|
+
() => huri ? { huri: [huri], schema: import_diviner_huri.HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
49
|
+
[huri, token]
|
|
50
|
+
);
|
|
51
|
+
return (0, import_react_promise.usePromise)(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
55
|
+
var import_react_router_dom = require("react-router-dom");
|
|
56
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
57
|
+
const { hash: hashParam } = (0, import_react_router_dom.useParams)();
|
|
58
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
59
|
+
const [params] = (0, import_react_router_dom.useSearchParams)();
|
|
60
|
+
const huriSearchParameter = params.get("huri");
|
|
61
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
62
|
+
switch (routeOption) {
|
|
63
|
+
case "routeParam": {
|
|
64
|
+
return huriFromHashParam;
|
|
65
|
+
}
|
|
66
|
+
case "searchParam": {
|
|
67
|
+
return decodedHuriParam;
|
|
68
|
+
}
|
|
69
|
+
default: {
|
|
70
|
+
return huriFromHashParam || decodedHuriParam;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
75
|
+
0 && (module.exports = {
|
|
76
|
+
useBuildHuri,
|
|
77
|
+
useFetchHuri,
|
|
78
|
+
useParseHuriFromRoute
|
|
79
|
+
});
|
|
2
80
|
//# sourceMappingURL=index.cjs.map
|
package/dist/node/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../src/index.ts","../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["export * from './hooks'\n","import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA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
|
1
|
+
// src/hooks/useBuildHuri.tsx
|
|
2
|
+
import { useNetwork } from "@xyo-network/react-network";
|
|
3
|
+
var useBuildHuri = (hash) => {
|
|
4
|
+
var _a, _b;
|
|
5
|
+
const { network } = useNetwork();
|
|
6
|
+
const networkUri = (_b = (_a = network == null ? void 0 : network.nodes) == null ? void 0 : _a.find((node) => node.type === "archivist")) == null ? void 0 : _b.uri;
|
|
7
|
+
if (!hash || hash.startsWith("http")) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
return `${networkUri}/${hash}`;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/hooks/useFetchHuri.tsx
|
|
14
|
+
import { usePromise } from "@xylabs/react-promise";
|
|
15
|
+
import { HuriSchema } from "@xyo-network/diviner-huri";
|
|
16
|
+
import { useMemo } from "react";
|
|
17
|
+
var useFetchHuri = (hashOrHuri, diviner, token) => {
|
|
18
|
+
const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri;
|
|
19
|
+
const huriPayload = useMemo(
|
|
20
|
+
() => huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : void 0 } : void 0,
|
|
21
|
+
[huri, token]
|
|
22
|
+
);
|
|
23
|
+
return usePromise(async () => diviner && huriPayload ? await diviner.divine([huriPayload]) : void 0, [diviner, huriPayload]);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/hooks/useParseHuriFromRoute.tsx
|
|
27
|
+
import { useParams, useSearchParams } from "react-router-dom";
|
|
28
|
+
var useParseHuriFromRoute = (routeOption = "any") => {
|
|
29
|
+
const { hash: hashParam } = useParams();
|
|
30
|
+
const huriFromHashParam = useBuildHuri(hashParam);
|
|
31
|
+
const [params] = useSearchParams();
|
|
32
|
+
const huriSearchParameter = params.get("huri");
|
|
33
|
+
const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? "");
|
|
34
|
+
switch (routeOption) {
|
|
35
|
+
case "routeParam": {
|
|
36
|
+
return huriFromHashParam;
|
|
37
|
+
}
|
|
38
|
+
case "searchParam": {
|
|
39
|
+
return decodedHuriParam;
|
|
40
|
+
}
|
|
41
|
+
default: {
|
|
42
|
+
return huriFromHashParam || decodedHuriParam;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
export {
|
|
47
|
+
useBuildHuri,
|
|
48
|
+
useFetchHuri,
|
|
49
|
+
useParseHuriFromRoute
|
|
50
|
+
};
|
|
2
51
|
//# sourceMappingURL=index.js.map
|
package/dist/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["../../src/hooks/useBuildHuri.tsx","../../src/hooks/useFetchHuri.tsx","../../src/hooks/useParseHuriFromRoute.tsx"],"sourcesContent":["import { useNetwork } from '@xyo-network/react-network'\n\nexport const useBuildHuri = (hash?: string) => {\n const { network } = useNetwork()\n const networkUri = network?.nodes?.find((node) => node.type === 'archivist')?.uri\n\n if (!hash || hash.startsWith('http')) {\n return\n }\n\n return `${networkUri}/${hash}`\n}\n","import { usePromise } from '@xylabs/react-promise'\nimport { HuriPayload, HuriSchema } from '@xyo-network/diviner-huri'\nimport { DivinerInstance } from '@xyo-network/diviner-model'\nimport { useMemo } from 'react'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport const useFetchHuri = (hashOrHuri?: string, diviner?: DivinerInstance, token?: string) => {\n const huri = useBuildHuri(hashOrHuri) ?? hashOrHuri\n const huriPayload: HuriPayload | undefined = useMemo(\n () => (huri ? { huri: [huri], schema: HuriSchema, tokens: token ? [token] : undefined } : undefined),\n [huri, token],\n )\n\n return usePromise(async () => (diviner && huriPayload ? await diviner.divine([huriPayload]) : undefined), [diviner, huriPayload])\n}\n","import { useParams, useSearchParams } from 'react-router-dom'\n\nimport { useBuildHuri } from './useBuildHuri'\n\nexport type RouteOptions = 'routeParam' | 'searchParam' | 'any'\n\nexport const useParseHuriFromRoute = (routeOption: RouteOptions = 'any') => {\n const { hash: hashParam } = useParams()\n\n const huriFromHashParam = useBuildHuri(hashParam)\n\n const [params] = useSearchParams()\n const huriSearchParameter = params.get('huri')\n const decodedHuriParam = decodeURIComponent(huriSearchParameter ?? '')\n\n switch (routeOption) {\n case 'routeParam': {\n return huriFromHashParam\n }\n case 'searchParam': {\n return decodedHuriParam\n }\n default: {\n return huriFromHashParam || decodedHuriParam\n }\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAEpB,IAAM,eAAe,CAAC,SAAkB;AAF/C;AAGE,QAAM,EAAE,QAAQ,IAAI,WAAW;AAC/B,QAAM,cAAa,8CAAS,UAAT,mBAAgB,KAAK,CAAC,SAAS,KAAK,SAAS,iBAA7C,mBAA2D;AAE9E,MAAI,CAAC,QAAQ,KAAK,WAAW,MAAM,GAAG;AACpC;AAAA,EACF;AAEA,SAAO,GAAG,UAAU,IAAI,IAAI;AAC9B;;;ACXA,SAAS,kBAAkB;AAC3B,SAAsB,kBAAkB;AAExC,SAAS,eAAe;AAIjB,IAAM,eAAe,CAAC,YAAqB,SAA2B,UAAmB;AAC9F,QAAM,OAAO,aAAa,UAAU,KAAK;AACzC,QAAM,cAAuC;AAAA,IAC3C,MAAO,OAAO,EAAE,MAAM,CAAC,IAAI,GAAG,QAAQ,YAAY,QAAQ,QAAQ,CAAC,KAAK,IAAI,OAAU,IAAI;AAAA,IAC1F,CAAC,MAAM,KAAK;AAAA,EACd;AAEA,SAAO,WAAW,YAAa,WAAW,cAAc,MAAM,QAAQ,OAAO,CAAC,WAAW,CAAC,IAAI,QAAY,CAAC,SAAS,WAAW,CAAC;AAClI;;;ACfA,SAAS,WAAW,uBAAuB;AAMpC,IAAM,wBAAwB,CAAC,cAA4B,UAAU;AAC1E,QAAM,EAAE,MAAM,UAAU,IAAI,UAAU;AAEtC,QAAM,oBAAoB,aAAa,SAAS;AAEhD,QAAM,CAAC,MAAM,IAAI,gBAAgB;AACjC,QAAM,sBAAsB,OAAO,IAAI,MAAM;AAC7C,QAAM,mBAAmB,mBAAmB,uBAAuB,EAAE;AAErE,UAAQ,aAAa;AAAA,IACnB,KAAK,cAAc;AACjB,aAAO;AAAA,IACT;AAAA,IACA,KAAK,eAAe;AAClB,aAAO;AAAA,IACT;AAAA,IACA,SAAS;AACP,aAAO,qBAAqB;AAAA,IAC9B;AAAA,EACF;AACF;","names":[]}
|
package/package.json
CHANGED
|
@@ -11,13 +11,13 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@xylabs/react-promise": "^3.1.7",
|
|
14
|
-
"@xyo-network/diviner-huri": "^2.107.
|
|
15
|
-
"@xyo-network/diviner-model": "^2.107.
|
|
16
|
-
"@xyo-network/react-network": "
|
|
14
|
+
"@xyo-network/diviner-huri": "^2.107.6",
|
|
15
|
+
"@xyo-network/diviner-model": "^2.107.6",
|
|
16
|
+
"@xyo-network/react-network": "^2.78.2",
|
|
17
17
|
"react-router-dom": "^6.24.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@xylabs/ts-scripts-yarn3": "^3.11.
|
|
20
|
+
"@xylabs/ts-scripts-yarn3": "^3.11.12",
|
|
21
21
|
"typescript": "^5.5.2"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
@@ -78,6 +78,6 @@
|
|
|
78
78
|
},
|
|
79
79
|
"sideEffects": false,
|
|
80
80
|
"types": "dist/browser/index.d.ts",
|
|
81
|
-
"version": "2.78.
|
|
81
|
+
"version": "2.78.2",
|
|
82
82
|
"type": "module"
|
|
83
83
|
}
|