@lukso/core 1.1.0-dev.c21633f → 1.1.0
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/README.md +0 -55
- package/dist/chains/index.cjs +0 -1
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.js +0 -1
- package/dist/chunk-AMRGSLR5.cjs +1 -0
- package/dist/chunk-AMRGSLR5.cjs.map +1 -0
- package/dist/chunk-DKEXQFNE.js +1 -0
- package/dist/chunk-DKXHVRHM.js +84 -0
- package/dist/chunk-DKXHVRHM.js.map +1 -0
- package/dist/chunk-MBIRTPNM.cjs +84 -0
- package/dist/chunk-MBIRTPNM.cjs.map +1 -0
- package/dist/config.cjs +0 -1
- package/dist/config.cjs.map +1 -1
- package/dist/config.js +0 -1
- package/dist/index.cjs +5 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.ts +1 -2
- package/dist/index.js +4 -13
- package/dist/mixins/device.cjs +0 -1
- package/dist/mixins/device.cjs.map +1 -1
- package/dist/mixins/device.js +0 -1
- package/dist/mixins/index.cjs +2 -7
- package/dist/mixins/index.cjs.map +1 -1
- package/dist/mixins/index.d.cts +0 -1
- package/dist/mixins/index.d.ts +0 -1
- package/dist/mixins/index.js +2 -7
- package/dist/mixins/intl.cjs +0 -1
- package/dist/mixins/intl.cjs.map +1 -1
- package/dist/mixins/intl.js +0 -1
- package/dist/services/device.cjs +0 -1
- package/dist/services/device.cjs.map +1 -1
- package/dist/services/device.js +0 -1
- package/dist/services/index.cjs +0 -1
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.js +0 -1
- package/dist/services/intl.cjs +0 -1
- package/dist/services/intl.cjs.map +1 -1
- package/dist/services/intl.js +0 -1
- package/dist/utils/index.cjs +2 -7
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +1 -34
- package/dist/utils/index.d.ts +1 -34
- package/dist/utils/index.js +1 -6
- package/package.json +2 -8
- package/src/mixins/index.ts +0 -1
- package/src/utils/index.ts +0 -1
- package/dist/chunk-CUDG6NPH.cjs +0 -111
- package/dist/chunk-CUDG6NPH.cjs.map +0 -1
- package/dist/chunk-DWXFDFMM.cjs +0 -1
- package/dist/chunk-DWXFDFMM.cjs.map +0 -1
- package/dist/chunk-EUXUH3YW.js +0 -15
- package/dist/chunk-GFLV5EJV.js +0 -159
- package/dist/chunk-GFLV5EJV.js.map +0 -1
- package/dist/chunk-JEE6C34P.js +0 -1
- package/dist/chunk-JEE6C34P.js.map +0 -1
- package/dist/chunk-LQIOVPBE.js +0 -111
- package/dist/chunk-LQIOVPBE.js.map +0 -1
- package/dist/chunk-QU6NUTY6.cjs +0 -159
- package/dist/chunk-QU6NUTY6.cjs.map +0 -1
- package/dist/chunk-ZBDE64SD.cjs +0 -15
- package/dist/chunk-ZBDE64SD.cjs.map +0 -1
- package/dist/mixins/theme.cjs +0 -8
- package/dist/mixins/theme.cjs.map +0 -1
- package/dist/mixins/theme.d.cts +0 -45
- package/dist/mixins/theme.d.ts +0 -45
- package/dist/mixins/theme.js +0 -8
- package/dist/mixins/theme.js.map +0 -1
- package/src/mixins/__tests__/theme.spec.ts +0 -478
- package/src/mixins/theme.ts +0 -172
- package/src/utils/url-resolver.ts +0 -93
- /package/dist/{chunk-EUXUH3YW.js.map → chunk-DKEXQFNE.js.map} +0 -0
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
export class UrlConverter {
|
|
2
|
-
private destination: URL
|
|
3
|
-
/**
|
|
4
|
-
* It will relatively append pathname or hostname to the destination URL
|
|
5
|
-
*
|
|
6
|
-
* For example:
|
|
7
|
-
* destination=https://some.api.gateway/something/ipfs
|
|
8
|
-
* url=ipfs://QmSomeHash
|
|
9
|
-
* output=https://some.api.gateway/something/ipfs/QmSomeHash
|
|
10
|
-
*
|
|
11
|
-
* destination=https://some.api.gateway/something/ipfs
|
|
12
|
-
* url=https://something.com/somewhere
|
|
13
|
-
* output=https://some.api.gateway/something/ipfs/somewhere
|
|
14
|
-
*
|
|
15
|
-
* @param destination destination string | URL
|
|
16
|
-
*/
|
|
17
|
-
constructor(destination: string | URL) {
|
|
18
|
-
this.destination = new URL(destination)
|
|
19
|
-
if (this.destination.pathname.at(-1) !== '/') {
|
|
20
|
-
this.destination.pathname += '/'
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
resolveUrl(url: string): string {
|
|
25
|
-
// Parse and convert to javascript URL objects
|
|
26
|
-
// this will manage / and relative paths for us.
|
|
27
|
-
const source = new URL(url)
|
|
28
|
-
// extract the relative path. For URLs with a pathname prepend "." to make it ./ (i.e. relative)
|
|
29
|
-
// for anything that only has a hostname we prepend ./ to make it relative
|
|
30
|
-
// the pathname is at least slash for https urls, but '' for ipfs for example
|
|
31
|
-
const relativePath = source.pathname
|
|
32
|
-
? `./${source.hostname}${source.pathname}` // pathname always starts with at least a slash
|
|
33
|
-
: `./${source.hostname}`
|
|
34
|
-
// Construct relative URL on destination using the relative pathname.
|
|
35
|
-
const out = new URL(relativePath, this.destination)
|
|
36
|
-
out.pathname = out.pathname.replaceAll(/\/\/+/g, '/')
|
|
37
|
-
return out.toString()
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export class UrlResolver {
|
|
42
|
-
private converters: Array<{
|
|
43
|
-
match: string | RegExp
|
|
44
|
-
converter: UrlConverter
|
|
45
|
-
}> = []
|
|
46
|
-
constructor(converters: Array<[string | RegExp, UrlConverter | string]>) {
|
|
47
|
-
for (const item of converters) {
|
|
48
|
-
const [match, _converter] = item
|
|
49
|
-
if (match == null) {
|
|
50
|
-
throw new TypeError('Match criteria not defined')
|
|
51
|
-
}
|
|
52
|
-
const converter =
|
|
53
|
-
typeof _converter === 'string'
|
|
54
|
-
? new UrlConverter(_converter)
|
|
55
|
-
: _converter
|
|
56
|
-
if (!(converter instanceof UrlConverter)) {
|
|
57
|
-
throw new TypeError('Invalid converter')
|
|
58
|
-
}
|
|
59
|
-
this.converters.push({ match, converter })
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Resolves a URL to a gateway URL.
|
|
65
|
-
* Supports possible multiple converters transforming the URL
|
|
66
|
-
* in sequence until no converter matches.
|
|
67
|
-
*
|
|
68
|
-
* @param {string} url to resolve
|
|
69
|
-
* @returns {string} resolved url (if resolver is found, otherwise the parameter url is returned)
|
|
70
|
-
*/
|
|
71
|
-
resolveUrl(url_: string): string {
|
|
72
|
-
let url = url_
|
|
73
|
-
const current = new Set<{
|
|
74
|
-
match: string | RegExp
|
|
75
|
-
converter: UrlConverter
|
|
76
|
-
}>(this.converters)
|
|
77
|
-
let found = true
|
|
78
|
-
while (found) {
|
|
79
|
-
found = false
|
|
80
|
-
for (const entry of current) {
|
|
81
|
-
const { match, converter } = entry
|
|
82
|
-
if (match instanceof RegExp ? match.test(url) : url.startsWith(match)) {
|
|
83
|
-
url = converter.resolveUrl(url)
|
|
84
|
-
// This converter matches, so don't use it again.
|
|
85
|
-
current.delete(entry)
|
|
86
|
-
found = true
|
|
87
|
-
break
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return url
|
|
92
|
-
}
|
|
93
|
-
}
|
|
File without changes
|