@rxap/config 19.3.0-dev.3 → 19.3.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/CHANGELOG.md +14 -0
- package/README.md +53 -0
- package/compodoc/changelog.html +11 -0
- package/compodoc/dependencies.html +2 -2
- package/compodoc/index.html +69 -1
- package/compodoc/injectables/ConfigService.html +210 -102
- package/compodoc/interfaces/ConfigLoadError.html +610 -0
- package/compodoc/interfaces/ConfigLoadOptions.html +213 -66
- package/compodoc/js/menu-wc.js +3 -0
- package/compodoc/js/menu-wc_es5.js +1 -1
- package/compodoc/js/search/search_index.js +2 -2
- package/compodoc/miscellaneous/functions.html +130 -1
- package/compodoc/miscellaneous/typealiases.html +78 -0
- package/compodoc/overview.html +1 -1
- package/compodoc/properties.html +1 -1
- package/docs/documentation.json +2441 -1293
- package/docs/html/assets/hierarchy.js +1 -1
- package/docs/html/assets/highlight.css +42 -0
- package/docs/html/assets/navigation.js +1 -1
- package/docs/html/assets/search.js +1 -1
- package/docs/html/classes/ConfigLoaderService.html +2 -2
- package/docs/html/classes/ConfigService.html +8 -6
- package/docs/html/classes/ConfigTestingService.html +2 -2
- package/docs/html/enums/ConfigLoadMethod.html +2 -2
- package/docs/html/enums/ConfigLoadingStrategy.html +2 -2
- package/docs/html/functions/ProvideConfig.html +1 -1
- package/docs/html/functions/defaultConfigLoadErrorHandler.html +4 -0
- package/docs/html/functions/dnsLookup.html +1 -1
- package/docs/html/functions/dnsResolver.html +1 -1
- package/docs/html/functions/fetchCidContent.html +1 -1
- package/docs/html/functions/fetchCidContentAsJson.html +1 -1
- package/docs/html/functions/fetchCidContentViaHttp.html +1 -1
- package/docs/html/functions/fetchContentViaHttp.html +1 -1
- package/docs/html/functions/localPathIpfsGateway.html +1 -1
- package/docs/html/functions/localSubDomainIpfsGateway.html +1 -1
- package/docs/html/functions/raceSuccess.html +2 -2
- package/docs/html/functions/showConfigLoadError.html +2 -0
- package/docs/html/functions/storachaIpfsGateway.html +1 -1
- package/docs/html/functions/w3sIpfsGateway.html +1 -1
- package/docs/html/hierarchy.html +1 -1
- package/docs/html/index.html +54 -2
- package/docs/html/interfaces/AppsNavigationConfig.html +2 -2
- package/docs/html/interfaces/Config.html +2 -2
- package/docs/html/interfaces/ConfigLoadError.html +11 -0
- package/docs/html/interfaces/ConfigLoadOptions.html +13 -6
- package/docs/html/interfaces/LogoConfig.html +2 -2
- package/docs/html/interfaces/NavigationConfig.html +2 -2
- package/docs/html/interfaces/Oauth2Config.html +2 -2
- package/docs/html/interfaces/i18nConfig.html +2 -2
- package/docs/html/modules.html +1 -1
- package/docs/html/types/AnySchema.html +1 -1
- package/docs/html/types/ConfigLoadErrorHandler.html +2 -0
- package/docs/html/types/ConfigLoadErrorKind.html +9 -0
- package/docs/html/types/ConfigRequestOptions.html +1 -0
- package/docs/html/types/IpfsGatewayFunction.html +1 -1
- package/docs/html/types/Join.html +1 -1
- package/docs/html/types/LanguagesConfig.html +1 -1
- package/docs/html/types/Leaves.html +1 -1
- package/docs/html/types/NoInferType.html +1 -1
- package/docs/html/types/Paths.html +1 -1
- package/docs/html/variables/RXAP_CONFIG.html +1 -1
- package/docs/html/variables/defaultDnsServers.html +1 -1
- package/docs/html/variables/defaultIpfsGatewayServers.html +1 -1
- package/docs/markdown/README.md +54 -1
- package/docs/markdown/classes/ConfigLoaderService.md +7 -7
- package/docs/markdown/classes/ConfigService.md +37 -23
- package/docs/markdown/classes/ConfigTestingService.md +8 -8
- package/docs/markdown/enumerations/ConfigLoadMethod.md +6 -6
- package/docs/markdown/enumerations/ConfigLoadingStrategy.md +4 -4
- package/docs/markdown/functions/ProvideConfig.md +2 -2
- package/docs/markdown/functions/defaultConfigLoadErrorHandler.md +26 -0
- package/docs/markdown/functions/dnsLookup.md +2 -2
- package/docs/markdown/functions/dnsResolver.md +2 -2
- package/docs/markdown/functions/fetchCidContent.md +2 -2
- package/docs/markdown/functions/fetchCidContentAsJson.md +2 -2
- package/docs/markdown/functions/fetchCidContentViaHttp.md +2 -2
- package/docs/markdown/functions/fetchContentViaHttp.md +2 -2
- package/docs/markdown/functions/localPathIpfsGateway.md +2 -2
- package/docs/markdown/functions/localSubDomainIpfsGateway.md +2 -2
- package/docs/markdown/functions/raceSuccess.md +2 -2
- package/docs/markdown/functions/showConfigLoadError.md +23 -0
- package/docs/markdown/functions/storachaIpfsGateway.md +2 -2
- package/docs/markdown/functions/w3sIpfsGateway.md +2 -2
- package/docs/markdown/globals.md +8 -2
- package/docs/markdown/interfaces/AppsNavigationConfig.md +12 -12
- package/docs/markdown/interfaces/Config.md +6 -6
- package/docs/markdown/interfaces/ConfigLoadError.md +70 -0
- package/docs/markdown/interfaces/ConfigLoadOptions.md +39 -15
- package/docs/markdown/interfaces/LogoConfig.md +5 -5
- package/docs/markdown/interfaces/NavigationConfig.md +9 -9
- package/docs/markdown/interfaces/Oauth2Config.md +3 -3
- package/docs/markdown/interfaces/i18nConfig.md +4 -4
- package/docs/markdown/type-aliases/AnySchema.md +2 -2
- package/docs/markdown/type-aliases/ConfigLoadErrorHandler.md +23 -0
- package/docs/markdown/type-aliases/ConfigLoadErrorKind.md +19 -0
- package/docs/markdown/type-aliases/ConfigRequestOptions.md +11 -0
- package/docs/markdown/type-aliases/IpfsGatewayFunction.md +2 -2
- package/docs/markdown/type-aliases/Join.md +2 -2
- package/docs/markdown/type-aliases/LanguagesConfig.md +2 -2
- package/docs/markdown/type-aliases/Leaves.md +2 -2
- package/docs/markdown/type-aliases/NoInferType.md +2 -2
- package/docs/markdown/type-aliases/Paths.md +2 -2
- package/docs/markdown/variables/RXAP_CONFIG.md +2 -2
- package/docs/markdown/variables/defaultDnsServers.md +2 -2
- package/docs/markdown/variables/defaultIpfsGatewayServers.md +2 -2
- package/docs/wiki/Class.ConfigLoaderService.md +6 -6
- package/docs/wiki/Class.ConfigService.md +36 -22
- package/docs/wiki/Class.ConfigTestingService.md +7 -7
- package/docs/wiki/Enumeration.ConfigLoadMethod.md +5 -5
- package/docs/wiki/Enumeration.ConfigLoadingStrategy.md +3 -3
- package/docs/wiki/Function.ProvideConfig.md +1 -1
- package/docs/wiki/Function.defaultConfigLoadErrorHandler.md +22 -0
- package/docs/wiki/Function.dnsLookup.md +1 -1
- package/docs/wiki/Function.dnsResolver.md +1 -1
- package/docs/wiki/Function.fetchCidContent.md +1 -1
- package/docs/wiki/Function.fetchCidContentAsJson.md +1 -1
- package/docs/wiki/Function.fetchCidContentViaHttp.md +1 -1
- package/docs/wiki/Function.fetchContentViaHttp.md +1 -1
- package/docs/wiki/Function.localPathIpfsGateway.md +1 -1
- package/docs/wiki/Function.localSubDomainIpfsGateway.md +1 -1
- package/docs/wiki/Function.raceSuccess.md +1 -1
- package/docs/wiki/Function.showConfigLoadError.md +19 -0
- package/docs/wiki/Function.storachaIpfsGateway.md +1 -1
- package/docs/wiki/Function.w3sIpfsGateway.md +1 -1
- package/docs/wiki/Home.md +53 -0
- package/docs/wiki/Interface.AppsNavigationConfig.md +11 -11
- package/docs/wiki/Interface.Config.md +5 -5
- package/docs/wiki/Interface.ConfigLoadError.md +66 -0
- package/docs/wiki/Interface.ConfigLoadOptions.md +38 -14
- package/docs/wiki/Interface.LogoConfig.md +4 -4
- package/docs/wiki/Interface.NavigationConfig.md +8 -8
- package/docs/wiki/Interface.Oauth2Config.md +2 -2
- package/docs/wiki/Interface.i18nConfig.md +3 -3
- package/docs/wiki/TypeAlias.AnySchema.md +1 -1
- package/docs/wiki/TypeAlias.ConfigLoadErrorHandler.md +19 -0
- package/docs/wiki/TypeAlias.ConfigLoadErrorKind.md +15 -0
- package/docs/wiki/TypeAlias.ConfigRequestOptions.md +7 -0
- package/docs/wiki/TypeAlias.IpfsGatewayFunction.md +1 -1
- package/docs/wiki/TypeAlias.Join.md +1 -1
- package/docs/wiki/TypeAlias.LanguagesConfig.md +1 -1
- package/docs/wiki/TypeAlias.Leaves.md +1 -1
- package/docs/wiki/TypeAlias.NoInferType.md +1 -1
- package/docs/wiki/TypeAlias.Paths.md +1 -1
- package/docs/wiki/Variable.RXAP_CONFIG.md +1 -1
- package/docs/wiki/Variable.defaultDnsServers.md +1 -1
- package/docs/wiki/Variable.defaultIpfsGatewayServers.md +1 -1
- package/docs/wiki/_Sidebar.md +6 -0
- package/docs/wiki/globals.md +7 -1
- package/fesm2022/rxap-config.mjs +125 -70
- package/fesm2022/rxap-config.mjs.map +1 -1
- package/index.d.ts +1 -0
- package/lib/config-load-error.d.ts +41 -0
- package/lib/config.service.d.ts +24 -2
- package/package.json +5 -5
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **AnySchema**: `object`
|
|
6
6
|
|
|
7
|
-
Defined in: [config.service.ts:
|
|
7
|
+
Defined in: [config.service.ts:27](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/config.service.ts#L27)
|
|
8
8
|
|
|
9
9
|
## Type declaration
|
|
10
10
|
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[@rxap/config](../wiki/globals) / ConfigLoadErrorHandler
|
|
2
|
+
|
|
3
|
+
# Type Alias: ConfigLoadErrorHandler()
|
|
4
|
+
|
|
5
|
+
> **ConfigLoadErrorHandler**: (`error`) => `void` \| `Promise`\<`void`\>
|
|
6
|
+
|
|
7
|
+
Defined in: [config-load-error.ts:37](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/config-load-error.ts#L37)
|
|
8
|
+
|
|
9
|
+
Called for every failed config url request. May never resolve, e.g. if it navigates away.
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
### error
|
|
14
|
+
|
|
15
|
+
[`ConfigLoadError`](../wiki/Interface.ConfigLoadError)
|
|
16
|
+
|
|
17
|
+
## Returns
|
|
18
|
+
|
|
19
|
+
`void` \| `Promise`\<`void`\>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
[@rxap/config](../wiki/globals) / ConfigLoadErrorKind
|
|
2
|
+
|
|
3
|
+
# Type Alias: ConfigLoadErrorKind
|
|
4
|
+
|
|
5
|
+
> **ConfigLoadErrorKind**: `"network"` \| `"redirect"` \| `"http"` \| `"parse"` \| `"schema"`
|
|
6
|
+
|
|
7
|
+
Defined in: [config-load-error.ts:10](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/config-load-error.ts#L10)
|
|
8
|
+
|
|
9
|
+
The kind of failure that happened while loading a config url.
|
|
10
|
+
|
|
11
|
+
- `network`: `fetch()` rejected (offline, DNS, CORS without a redirect)
|
|
12
|
+
- `redirect`: the response is an `opaqueredirect` (only with `requestInit.redirect === 'manual'`)
|
|
13
|
+
- `http`: the response is not ok - `status` and `response` are available
|
|
14
|
+
- `parse`: the response body is not valid JSON
|
|
15
|
+
- `schema`: the schema validation failed
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
[@rxap/config](../wiki/globals) / ConfigRequestOptions
|
|
2
|
+
|
|
3
|
+
# Type Alias: ConfigRequestOptions
|
|
4
|
+
|
|
5
|
+
> **ConfigRequestOptions**: `Pick`\<[`ConfigLoadOptions`](../wiki/Interface.ConfigLoadOptions), `"errorHandler"` \| `"requestInit"`\>
|
|
6
|
+
|
|
7
|
+
Defined in: [config.service.ts:87](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/config.service.ts#L87)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **IpfsGatewayFunction**: (`cid`) => `string`
|
|
6
6
|
|
|
7
|
-
Defined in: [utilities.ts:125](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [utilities.ts:125](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/utilities.ts#L125)
|
|
8
8
|
|
|
9
9
|
## Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **Join**\<`K`, `P`\>: `K` *extends* `string` \| `number` ? `P` *extends* `string` \| `number` ? `` `${K}${"" extends P ? "" : "."}${P}` `` : `never` : `never`
|
|
6
6
|
|
|
7
|
-
Defined in: [types.ts:8](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [types.ts:8](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/types.ts#L8)
|
|
8
8
|
|
|
9
9
|
## Type Parameters
|
|
10
10
|
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
> **LanguagesConfig**: `Record`\<`string`, `string`\>
|
|
6
6
|
|
|
7
|
-
Defined in: [config.ts:32](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [config.ts:32](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/config.ts#L32)
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **Leaves**\<`T`, `D`\>: \[`D`\] *extends* \[`never`\] ? `never` : `T` *extends* `object` ? `{ [K in keyof T]-?: Join<K, Leaves<T[K], Prev[D]>> }`\[keyof `T`\] : `""`
|
|
6
6
|
|
|
7
|
-
Defined in: [types.ts:20](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [types.ts:20](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/types.ts#L20)
|
|
8
8
|
|
|
9
9
|
## Type Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **NoInferType**\<`T`\>: \[`T`\]\[`T` *extends* `any` ? `0` : `never`\]
|
|
6
6
|
|
|
7
|
-
Defined in: [types.ts:1](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [types.ts:1](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/types.ts#L1)
|
|
8
8
|
|
|
9
9
|
## Type Parameters
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
> **Paths**\<`T`, `D`\>: \[`D`\] *extends* \[`never`\] ? `never` : `T` *extends* `object` ? \{ \[K in keyof T\]-?: K extends string \| number ? \`$\{K\}\` \| Join\<K, Paths\<T\[K\], Prev\[D\]\>\> : never \}\[keyof `T`\] : `""`
|
|
6
6
|
|
|
7
|
-
Defined in: [types.ts:13](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [types.ts:13](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/types.ts#L13)
|
|
8
8
|
|
|
9
9
|
## Type Parameters
|
|
10
10
|
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
> `const` **RXAP\_CONFIG**: `InjectionToken`\<`unknown`\>
|
|
6
6
|
|
|
7
|
-
Defined in: [tokens.ts:3](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [tokens.ts:3](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/tokens.ts#L3)
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
> `const` **defaultDnsServers**: `string`[]
|
|
6
6
|
|
|
7
|
-
Defined in: [utilities.ts:62](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [utilities.ts:62](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/utilities.ts#L62)
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
|
|
5
5
|
> `const` **defaultIpfsGatewayServers**: [`IpfsGatewayFunction`](../wiki/TypeAlias.IpfsGatewayFunction)[]
|
|
6
6
|
|
|
7
|
-
Defined in: [utilities.ts:132](https://gitlab.com/rxap/packages/-/blob/
|
|
7
|
+
Defined in: [utilities.ts:132](https://gitlab.com/rxap/packages/-/blob/3648307d22f6f77230de9b76f6335a68f0ed3849/packages/angular/config/src/lib/utilities.ts#L132)
|
package/docs/wiki/_Sidebar.md
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
- [AppsNavigationConfig](../wiki/Interface.AppsNavigationConfig)
|
|
17
17
|
- [Config](../wiki/Interface.Config)
|
|
18
|
+
- [ConfigLoadError](../wiki/Interface.ConfigLoadError)
|
|
18
19
|
- [ConfigLoadOptions](../wiki/Interface.ConfigLoadOptions)
|
|
19
20
|
- [i18nConfig](../wiki/Interface.i18nConfig)
|
|
20
21
|
- [LogoConfig](../wiki/Interface.LogoConfig)
|
|
@@ -24,6 +25,9 @@
|
|
|
24
25
|
### Type Aliases
|
|
25
26
|
|
|
26
27
|
- [AnySchema](../wiki/TypeAlias.AnySchema)
|
|
28
|
+
- [ConfigLoadErrorHandler](../wiki/TypeAlias.ConfigLoadErrorHandler)
|
|
29
|
+
- [ConfigLoadErrorKind](../wiki/TypeAlias.ConfigLoadErrorKind)
|
|
30
|
+
- [ConfigRequestOptions](../wiki/TypeAlias.ConfigRequestOptions)
|
|
27
31
|
- [IpfsGatewayFunction](../wiki/TypeAlias.IpfsGatewayFunction)
|
|
28
32
|
- [Join](../wiki/TypeAlias.Join)
|
|
29
33
|
- [LanguagesConfig](../wiki/TypeAlias.LanguagesConfig)
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
|
|
40
44
|
### Functions
|
|
41
45
|
|
|
46
|
+
- [defaultConfigLoadErrorHandler](../wiki/Function.defaultConfigLoadErrorHandler)
|
|
42
47
|
- [dnsLookup](../wiki/Function.dnsLookup)
|
|
43
48
|
- [dnsResolver](../wiki/Function.dnsResolver)
|
|
44
49
|
- [fetchCidContent](../wiki/Function.fetchCidContent)
|
|
@@ -49,5 +54,6 @@
|
|
|
49
54
|
- [localSubDomainIpfsGateway](../wiki/Function.localSubDomainIpfsGateway)
|
|
50
55
|
- [ProvideConfig](../wiki/Function.ProvideConfig)
|
|
51
56
|
- [raceSuccess](../wiki/Function.raceSuccess)
|
|
57
|
+
- [showConfigLoadError](../wiki/Function.showConfigLoadError)
|
|
52
58
|
- [storachaIpfsGateway](../wiki/Function.storachaIpfsGateway)
|
|
53
59
|
- [w3sIpfsGateway](../wiki/Function.w3sIpfsGateway)
|
package/docs/wiki/globals.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @rxap/config v19.3.0
|
|
1
|
+
# @rxap/config v19.3.0
|
|
2
2
|
|
|
3
3
|
## Enumerations
|
|
4
4
|
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
- [AppsNavigationConfig](../wiki/Interface.AppsNavigationConfig)
|
|
17
17
|
- [Config](../wiki/Interface.Config)
|
|
18
|
+
- [ConfigLoadError](../wiki/Interface.ConfigLoadError)
|
|
18
19
|
- [ConfigLoadOptions](../wiki/Interface.ConfigLoadOptions)
|
|
19
20
|
- [i18nConfig](../wiki/Interface.i18nConfig)
|
|
20
21
|
- [LogoConfig](../wiki/Interface.LogoConfig)
|
|
@@ -24,6 +25,9 @@
|
|
|
24
25
|
## Type Aliases
|
|
25
26
|
|
|
26
27
|
- [AnySchema](../wiki/TypeAlias.AnySchema)
|
|
28
|
+
- [ConfigLoadErrorHandler](../wiki/TypeAlias.ConfigLoadErrorHandler)
|
|
29
|
+
- [ConfigLoadErrorKind](../wiki/TypeAlias.ConfigLoadErrorKind)
|
|
30
|
+
- [ConfigRequestOptions](../wiki/TypeAlias.ConfigRequestOptions)
|
|
27
31
|
- [IpfsGatewayFunction](../wiki/TypeAlias.IpfsGatewayFunction)
|
|
28
32
|
- [Join](../wiki/TypeAlias.Join)
|
|
29
33
|
- [LanguagesConfig](../wiki/TypeAlias.LanguagesConfig)
|
|
@@ -39,6 +43,7 @@
|
|
|
39
43
|
|
|
40
44
|
## Functions
|
|
41
45
|
|
|
46
|
+
- [defaultConfigLoadErrorHandler](../wiki/Function.defaultConfigLoadErrorHandler)
|
|
42
47
|
- [dnsLookup](../wiki/Function.dnsLookup)
|
|
43
48
|
- [dnsResolver](../wiki/Function.dnsResolver)
|
|
44
49
|
- [fetchCidContent](../wiki/Function.fetchCidContent)
|
|
@@ -49,5 +54,6 @@
|
|
|
49
54
|
- [localSubDomainIpfsGateway](../wiki/Function.localSubDomainIpfsGateway)
|
|
50
55
|
- [ProvideConfig](../wiki/Function.ProvideConfig)
|
|
51
56
|
- [raceSuccess](../wiki/Function.raceSuccess)
|
|
57
|
+
- [showConfigLoadError](../wiki/Function.showConfigLoadError)
|
|
52
58
|
- [storachaIpfsGateway](../wiki/Function.storachaIpfsGateway)
|
|
53
59
|
- [w3sIpfsGateway](../wiki/Function.w3sIpfsGateway)
|
package/fesm2022/rxap-config.mjs
CHANGED
|
@@ -7,6 +7,49 @@ import { finalize, share } from 'rxjs/operators';
|
|
|
7
7
|
import { SetToObject, getFromObject, JoinPath, deepMerge, coerceArray, CoercePrefix, SetObjectValue } from '@rxap/utilities';
|
|
8
8
|
import { log } from '@rxap/rxjs';
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* The default config load error handler. Shows the error message in an overlay and reloads the
|
|
12
|
+
* page after 30 s for required config urls. Logs a warning for optional config urls.
|
|
13
|
+
*
|
|
14
|
+
* Can be used as fallback in a custom error handler for error kinds it does not handle.
|
|
15
|
+
*/
|
|
16
|
+
function defaultConfigLoadErrorHandler(error) {
|
|
17
|
+
if (error.required) {
|
|
18
|
+
showConfigLoadError(error.message);
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.warn(error.message);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Appends the message to the config error overlay and schedules a page reload in 30 s.
|
|
26
|
+
*/
|
|
27
|
+
function showConfigLoadError(message) {
|
|
28
|
+
const hasUl = document.getElementById('rxap-config-error') !== null;
|
|
29
|
+
const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');
|
|
30
|
+
ul.id = 'rxap-config-error';
|
|
31
|
+
ul.style.position = 'fixed';
|
|
32
|
+
ul.style.bottom = '16px';
|
|
33
|
+
ul.style.right = '16px';
|
|
34
|
+
ul.style.backgroundColor = 'white';
|
|
35
|
+
ul.style.padding = '32px';
|
|
36
|
+
ul.style.zIndex = '99999999';
|
|
37
|
+
ul.style.color = 'black';
|
|
38
|
+
const messageLi = document.createElement('li');
|
|
39
|
+
messageLi.innerText = message;
|
|
40
|
+
ul.appendChild(messageLi);
|
|
41
|
+
const refreshHintLi = document.createElement('li');
|
|
42
|
+
refreshHintLi.innerText = 'Please refresh the page to try again.';
|
|
43
|
+
ul.appendChild(refreshHintLi);
|
|
44
|
+
const autoRefreshHintLi = document.createElement('li');
|
|
45
|
+
autoRefreshHintLi.innerText = 'The page will refresh automatically in 30 seconds.';
|
|
46
|
+
ul.appendChild(autoRefreshHintLi);
|
|
47
|
+
if (!hasUl) {
|
|
48
|
+
document.body.appendChild(ul);
|
|
49
|
+
}
|
|
50
|
+
setTimeout(() => location.reload(), 30000);
|
|
51
|
+
}
|
|
52
|
+
|
|
10
53
|
class ConfigLoaderService {
|
|
11
54
|
constructor(http) {
|
|
12
55
|
this.http = http;
|
|
@@ -242,6 +285,10 @@ class ConfigService {
|
|
|
242
285
|
*/
|
|
243
286
|
static { this.Overwrites = {}; }
|
|
244
287
|
static { this.LocalStorageKey = 'rxap/config/local-config'; }
|
|
288
|
+
/**
|
|
289
|
+
* The errorHandler and requestInit of the last Load call. Used by SideLoad.
|
|
290
|
+
*/
|
|
291
|
+
static { this.RequestOptions = {}; }
|
|
245
292
|
/**
|
|
246
293
|
* @deprecated instead use the url property of the ConfigLoadOptions
|
|
247
294
|
*/
|
|
@@ -265,6 +312,10 @@ class ConfigService {
|
|
|
265
312
|
*/
|
|
266
313
|
static async Load(options, environment) {
|
|
267
314
|
options ??= {};
|
|
315
|
+
this.RequestOptions = {
|
|
316
|
+
errorHandler: options.errorHandler,
|
|
317
|
+
requestInit: options.requestInit,
|
|
318
|
+
};
|
|
268
319
|
let config = deepMerge(this.Defaults, {});
|
|
269
320
|
if (environment?.config) {
|
|
270
321
|
if (typeof environment.config === 'string') {
|
|
@@ -398,7 +449,7 @@ class ConfigService {
|
|
|
398
449
|
return coerceArray(url);
|
|
399
450
|
}).flat();
|
|
400
451
|
for (const url of urls) {
|
|
401
|
-
const loadedConfig = await this.loadConfig(url, true, options?.schema);
|
|
452
|
+
const loadedConfig = await this.loadConfig(url, true, options?.schema, options);
|
|
402
453
|
const match = url.match(/config\.([a-zA-Z0-9.\-_]+)\.json/);
|
|
403
454
|
if (match) {
|
|
404
455
|
SetToObject(config, match[1], loadedConfig);
|
|
@@ -490,23 +541,30 @@ class ConfigService {
|
|
|
490
541
|
}
|
|
491
542
|
}
|
|
492
543
|
}
|
|
493
|
-
static async loadConfig(url, required, schema) {
|
|
544
|
+
static async loadConfig(url, required = false, schema, options = this.RequestOptions) {
|
|
494
545
|
let config;
|
|
495
546
|
let response;
|
|
496
547
|
try {
|
|
497
|
-
response = await fetch(url);
|
|
548
|
+
response = await fetch(url, options.requestInit);
|
|
498
549
|
}
|
|
499
550
|
catch (error) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
551
|
+
return this.handleLoadError({
|
|
552
|
+
kind: 'network',
|
|
553
|
+
url,
|
|
554
|
+
required,
|
|
555
|
+
cause: error,
|
|
556
|
+
message: `Could not fetch config from '${url}': ${error.message}`,
|
|
557
|
+
}, options);
|
|
558
|
+
}
|
|
559
|
+
if (response.type === 'opaqueredirect') {
|
|
560
|
+
return this.handleLoadError({
|
|
561
|
+
kind: 'redirect',
|
|
562
|
+
url,
|
|
563
|
+
required,
|
|
564
|
+
status: response.status,
|
|
565
|
+
response,
|
|
566
|
+
message: `Config request for '${url}' was redirected`,
|
|
567
|
+
}, options);
|
|
510
568
|
}
|
|
511
569
|
if (!response.ok) {
|
|
512
570
|
let message = `Config request results in non ok response for '${url}': (${response.status}) ${response.statusText}`;
|
|
@@ -521,50 +579,72 @@ class ConfigService {
|
|
|
521
579
|
message = `Unauthorized to fetch config from '${url}'`;
|
|
522
580
|
break;
|
|
523
581
|
}
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
}
|
|
582
|
+
return this.handleLoadError({
|
|
583
|
+
kind: 'http',
|
|
584
|
+
url,
|
|
585
|
+
required,
|
|
586
|
+
status: response.status,
|
|
587
|
+
response,
|
|
588
|
+
message,
|
|
589
|
+
}, options);
|
|
533
590
|
}
|
|
534
591
|
try {
|
|
535
592
|
config = await response.json();
|
|
536
593
|
}
|
|
537
594
|
catch (error) {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
}
|
|
595
|
+
return this.handleLoadError({
|
|
596
|
+
kind: 'parse',
|
|
597
|
+
url,
|
|
598
|
+
required,
|
|
599
|
+
status: response.status,
|
|
600
|
+
response,
|
|
601
|
+
cause: error,
|
|
602
|
+
message: `Could not parse config from '${url}' to a json object: ${error.message}`,
|
|
603
|
+
}, options);
|
|
548
604
|
}
|
|
549
605
|
if (schema) {
|
|
550
606
|
try {
|
|
551
607
|
config = await schema.validateAsync(config);
|
|
552
608
|
}
|
|
553
609
|
catch (error) {
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
}
|
|
610
|
+
return this.handleLoadError({
|
|
611
|
+
kind: 'schema',
|
|
612
|
+
url,
|
|
613
|
+
required,
|
|
614
|
+
status: response.status,
|
|
615
|
+
response,
|
|
616
|
+
cause: error,
|
|
617
|
+
message: `Config from '${url}' is not valid: ${error.message}`,
|
|
618
|
+
}, options);
|
|
564
619
|
}
|
|
565
620
|
}
|
|
566
621
|
return config;
|
|
567
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* Notifies the onError/onRequestError hooks (required urls only), calls the error handler and
|
|
625
|
+
* throws for required urls. Resolves with null for optional urls.
|
|
626
|
+
*/
|
|
627
|
+
static async handleLoadError(error, options) {
|
|
628
|
+
if (error.required) {
|
|
629
|
+
if (error.response && (error.kind === 'http' || error.kind === 'redirect')) {
|
|
630
|
+
this.handleRequestError(error.response);
|
|
631
|
+
}
|
|
632
|
+
else {
|
|
633
|
+
this.handleError(error.cause);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
const errorHandler = options.errorHandler ?? defaultConfigLoadErrorHandler;
|
|
637
|
+
try {
|
|
638
|
+
await errorHandler(error);
|
|
639
|
+
}
|
|
640
|
+
catch (e) {
|
|
641
|
+
console.error('Error in config load error handler', e);
|
|
642
|
+
}
|
|
643
|
+
if (error.required) {
|
|
644
|
+
throw new Error(error.message);
|
|
645
|
+
}
|
|
646
|
+
return null;
|
|
647
|
+
}
|
|
568
648
|
static LoadConfigDefaultFromUrlParam(param = 'config') {
|
|
569
649
|
const queryString = window.location.search;
|
|
570
650
|
const urlParams = new URLSearchParams(queryString);
|
|
@@ -584,11 +664,11 @@ class ConfigService {
|
|
|
584
664
|
}
|
|
585
665
|
return configFromParams;
|
|
586
666
|
}
|
|
587
|
-
static async SideLoad(url, propertyPath, required, schema) {
|
|
667
|
+
static async SideLoad(url, propertyPath, required, schema, options = this.RequestOptions) {
|
|
588
668
|
if (!this.Config) {
|
|
589
669
|
throw new Error('Config side load is only possible after the initial config load.');
|
|
590
670
|
}
|
|
591
|
-
const config = await this.loadConfig(url, required, schema);
|
|
671
|
+
const config = await this.loadConfig(url, required, schema, options);
|
|
592
672
|
SetObjectValue(this.Config, propertyPath, config);
|
|
593
673
|
console.debug(`Side loaded config for '${propertyPath}' successful`, this.Config);
|
|
594
674
|
}
|
|
@@ -614,31 +694,6 @@ class ConfigService {
|
|
|
614
694
|
}
|
|
615
695
|
return configValue;
|
|
616
696
|
}
|
|
617
|
-
static showError(message) {
|
|
618
|
-
const hasUl = document.getElementById('rxap-config-error') !== null;
|
|
619
|
-
const ul = document.getElementById('rxap-config-error') ?? document.createElement('ul');
|
|
620
|
-
ul.id = 'rxap-config-error';
|
|
621
|
-
ul.style.position = 'fixed';
|
|
622
|
-
ul.style.bottom = '16px';
|
|
623
|
-
ul.style.right = '16px';
|
|
624
|
-
ul.style.backgroundColor = 'white';
|
|
625
|
-
ul.style.padding = '32px';
|
|
626
|
-
ul.style.zIndex = '99999999';
|
|
627
|
-
ul.style.color = 'black';
|
|
628
|
-
const messageLi = document.createElement('li');
|
|
629
|
-
messageLi.innerText = message;
|
|
630
|
-
ul.appendChild(messageLi);
|
|
631
|
-
const refreshHintLi = document.createElement('li');
|
|
632
|
-
refreshHintLi.innerText = 'Please refresh the page to try again.';
|
|
633
|
-
ul.appendChild(refreshHintLi);
|
|
634
|
-
const autoRefreshHintLi = document.createElement('li');
|
|
635
|
-
autoRefreshHintLi.innerText = 'The page will refresh automatically in 30 seconds.';
|
|
636
|
-
ul.appendChild(autoRefreshHintLi);
|
|
637
|
-
if (!hasUl) {
|
|
638
|
-
document.body.appendChild(ul);
|
|
639
|
-
}
|
|
640
|
-
setTimeout(() => location.reload(), 30000);
|
|
641
|
-
}
|
|
642
697
|
setLocalConfig(config) {
|
|
643
698
|
localStorage.setItem(ConfigService.LocalStorageKey, JSON.stringify(config));
|
|
644
699
|
}
|
|
@@ -684,5 +739,5 @@ function ProvideConfig(config = {}) {
|
|
|
684
739
|
* Generated bundle index. Do not edit.
|
|
685
740
|
*/
|
|
686
741
|
|
|
687
|
-
export { ConfigLoadMethod, ConfigLoaderService, ConfigLoadingStrategy, ConfigService, ConfigTestingService, ProvideConfig, RXAP_CONFIG, defaultDnsServers, defaultIpfsGatewayServers, dnsLookup, dnsResolver, fetchCidContent, fetchCidContentAsJson, fetchCidContentViaHttp, fetchContentViaHttp, localPathIpfsGateway, localSubDomainIpfsGateway, raceSuccess, storachaIpfsGateway, w3sIpfsGateway };
|
|
742
|
+
export { ConfigLoadMethod, ConfigLoaderService, ConfigLoadingStrategy, ConfigService, ConfigTestingService, ProvideConfig, RXAP_CONFIG, defaultConfigLoadErrorHandler, defaultDnsServers, defaultIpfsGatewayServers, dnsLookup, dnsResolver, fetchCidContent, fetchCidContentAsJson, fetchCidContentViaHttp, fetchContentViaHttp, localPathIpfsGateway, localSubDomainIpfsGateway, raceSuccess, showConfigLoadError, storachaIpfsGateway, w3sIpfsGateway };
|
|
688
743
|
//# sourceMappingURL=rxap-config.mjs.map
|