@xyo-network/react-panel 2.26.34 → 2.26.35
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/docs.json +1 -1
- package/package.json +5 -5
- package/babel.config.json +0 -5
- package/src/contexts/Context.ts +0 -5
- package/src/contexts/Provider.tsx +0 -150
- package/src/contexts/State.ts +0 -35
- package/src/contexts/index.ts +0 -4
- package/src/contexts/use.ts +0 -8
- package/src/index.ts +0 -1
package/dist/docs.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"fileName": "index.ts",
|
|
11
11
|
"line": 1,
|
|
12
12
|
"character": 0,
|
|
13
|
-
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/
|
|
13
|
+
"url": "https://github.com/XYOracleNetwork/sdk-xyo-react-js/blob/7efa6fa/packages/panel/src/index.ts#L1"
|
|
14
14
|
}
|
|
15
15
|
]
|
|
16
16
|
}
|
package/package.json
CHANGED
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"@xyo-network/boundwitness": "^2.22.15",
|
|
17
17
|
"@xyo-network/panel": "^2.22.15",
|
|
18
18
|
"@xyo-network/payload": "^2.22.15",
|
|
19
|
-
"@xyo-network/react-archive": "^2.26.
|
|
20
|
-
"@xyo-network/react-shared": "^2.26.
|
|
21
|
-
"@xyo-network/react-wallet": "^2.26.
|
|
19
|
+
"@xyo-network/react-archive": "^2.26.35",
|
|
20
|
+
"@xyo-network/react-shared": "^2.26.35",
|
|
21
|
+
"@xyo-network/react-wallet": "^2.26.35",
|
|
22
22
|
"@xyo-network/systeminfo-witness": "^2.22.15",
|
|
23
23
|
"@xyo-network/witnesses": "^2.22.15",
|
|
24
24
|
"react": "^18.2.0",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@babel/core": "^7.18.9",
|
|
30
30
|
"@babel/preset-env": "^7.18.9",
|
|
31
31
|
"@xylabs/sdk-js": "^2.6.2",
|
|
32
|
-
"@xylabs/tsconfig-dom": "^2.5.
|
|
32
|
+
"@xylabs/tsconfig-dom": "^2.5.3"
|
|
33
33
|
},
|
|
34
34
|
"browser": "dist/esm/index.js",
|
|
35
35
|
"docs": "dist/docs.json",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
},
|
|
81
81
|
"sideEffects": false,
|
|
82
82
|
"types": "dist/esm/index.d.ts",
|
|
83
|
-
"version": "2.26.
|
|
83
|
+
"version": "2.26.35"
|
|
84
84
|
}
|
package/babel.config.json
DELETED
package/src/contexts/Context.ts
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { useAsyncEffect, WithChildren } from '@xylabs/react-shared'
|
|
2
|
-
import { assertEx, delay } from '@xylabs/sdk-js'
|
|
3
|
-
import { XyoApiConfig, XyoArchivistApi } from '@xyo-network/api'
|
|
4
|
-
import { XyoBoundWitness } from '@xyo-network/boundwitness'
|
|
5
|
-
import { XyoPanel } from '@xyo-network/panel'
|
|
6
|
-
import { XyoPayload } from '@xyo-network/payload'
|
|
7
|
-
import { useArchive } from '@xyo-network/react-archive'
|
|
8
|
-
import { useAccount } from '@xyo-network/react-wallet'
|
|
9
|
-
import { XyoSystemInfoWitness } from '@xyo-network/systeminfo-witness'
|
|
10
|
-
import { XyoWitness } from '@xyo-network/witnesses'
|
|
11
|
-
import { useEffect, useState } from 'react'
|
|
12
|
-
|
|
13
|
-
import { XyoPanelContext } from './Context'
|
|
14
|
-
import { XyoPanelReportProgress, XyoReportStatus } from './State'
|
|
15
|
-
|
|
16
|
-
export interface XyoPanelProviderProps {
|
|
17
|
-
archivists?: XyoArchivistApi[]
|
|
18
|
-
inlinePayloads?: boolean
|
|
19
|
-
witnesses?: XyoWitness<XyoPayload>[]
|
|
20
|
-
required?: boolean
|
|
21
|
-
archive?: string
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const getDefaultArchivists = () => {
|
|
25
|
-
const archivistConfigs: XyoApiConfig[] = [
|
|
26
|
-
{
|
|
27
|
-
apiDomain: process.env.API_DOMAIN || 'https://api.archivist.xyo.network',
|
|
28
|
-
},
|
|
29
|
-
]
|
|
30
|
-
|
|
31
|
-
return archivistConfigs.map((config) => {
|
|
32
|
-
return new XyoArchivistApi(config)
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const XyoPanelProvider: React.FC<WithChildren<XyoPanelProviderProps>> = ({
|
|
37
|
-
inlinePayloads = false,
|
|
38
|
-
required = false,
|
|
39
|
-
archivists = getDefaultArchivists(),
|
|
40
|
-
witnesses = [new XyoSystemInfoWitness()],
|
|
41
|
-
children,
|
|
42
|
-
}) => {
|
|
43
|
-
const { archive } = useArchive()
|
|
44
|
-
const [panel, setPanel] = useState<XyoPanel>()
|
|
45
|
-
const [history, setHistory] = useState<XyoBoundWitness[]>()
|
|
46
|
-
const [progress, setProgress] = useState<XyoPanelReportProgress>({})
|
|
47
|
-
const [status, setStatus] = useState(XyoReportStatus.Idle)
|
|
48
|
-
const [reportingErrors, setReportingErrors] = useState<Error[]>()
|
|
49
|
-
|
|
50
|
-
const { account } = useAccount()
|
|
51
|
-
|
|
52
|
-
useAsyncEffect(
|
|
53
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
54
|
-
async (mounted) => {
|
|
55
|
-
const panel = new XyoPanel({
|
|
56
|
-
account,
|
|
57
|
-
archive,
|
|
58
|
-
archivists,
|
|
59
|
-
inlinePayloads,
|
|
60
|
-
onArchivistSendEnd: (archivist: XyoArchivistApi, error?: Error) => {
|
|
61
|
-
const archivists = progress.archivists ?? {}
|
|
62
|
-
archivists[archivist.config.apiDomain] = {
|
|
63
|
-
archivist,
|
|
64
|
-
status: error ? XyoReportStatus.Failed : XyoReportStatus.Succeeded,
|
|
65
|
-
}
|
|
66
|
-
if (mounted()) {
|
|
67
|
-
setProgress({ archivists, witnesses: progress.witnesses })
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
onArchivistSendStart: (archivist: XyoArchivistApi) => {
|
|
71
|
-
const archivists = progress.archivists ?? {}
|
|
72
|
-
archivists[archivist.config.apiDomain] = {
|
|
73
|
-
archivist,
|
|
74
|
-
status: XyoReportStatus.Started,
|
|
75
|
-
}
|
|
76
|
-
if (mounted()) {
|
|
77
|
-
setProgress({ archivists, witnesses: progress.witnesses })
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
onHistoryAdd: () => {
|
|
81
|
-
if (mounted()) {
|
|
82
|
-
setHistory(assertEx(panel).history.map((item) => item))
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
onHistoryRemove: () => {
|
|
86
|
-
if (mounted()) {
|
|
87
|
-
setHistory(assertEx(panel).history.map((item) => item))
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
onReportEnd: (_, errors?: Error[]) => {
|
|
91
|
-
if (mounted()) {
|
|
92
|
-
setProgress({
|
|
93
|
-
archivists: progress.archivists,
|
|
94
|
-
witnesses: progress.witnesses,
|
|
95
|
-
})
|
|
96
|
-
setStatus(errors ? XyoReportStatus.Failed : XyoReportStatus.Succeeded)
|
|
97
|
-
setReportingErrors(errors)
|
|
98
|
-
}
|
|
99
|
-
},
|
|
100
|
-
onReportStart: () => {
|
|
101
|
-
if (mounted()) {
|
|
102
|
-
setProgress({ archivists: {}, witnesses: {} })
|
|
103
|
-
setStatus(XyoReportStatus.Started)
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
onWitnessReportEnd: (witness: XyoWitness, error?: Error) => {
|
|
107
|
-
const witnesses = progress.witnesses ?? {}
|
|
108
|
-
witnesses[witness.targetSchema] = {
|
|
109
|
-
status: error ? XyoReportStatus.Failed : XyoReportStatus.Succeeded,
|
|
110
|
-
witness,
|
|
111
|
-
}
|
|
112
|
-
if (mounted()) {
|
|
113
|
-
setProgress({
|
|
114
|
-
archivists: progress.archivists,
|
|
115
|
-
witnesses,
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
onWitnessReportStart: (witness: XyoWitness) => {
|
|
120
|
-
const witnesses = progress.witnesses ?? {}
|
|
121
|
-
witnesses[witness.targetSchema] = {
|
|
122
|
-
status: XyoReportStatus.Started,
|
|
123
|
-
witness,
|
|
124
|
-
}
|
|
125
|
-
if (mounted()) {
|
|
126
|
-
setProgress({
|
|
127
|
-
archivists: progress.archivists,
|
|
128
|
-
witnesses,
|
|
129
|
-
})
|
|
130
|
-
}
|
|
131
|
-
},
|
|
132
|
-
witnesses: witnesses.filter((witness) => !!witness),
|
|
133
|
-
})
|
|
134
|
-
setPanel(panel)
|
|
135
|
-
await delay(0)
|
|
136
|
-
},
|
|
137
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
138
|
-
[account, archive, archivists, witnesses]
|
|
139
|
-
)
|
|
140
|
-
|
|
141
|
-
useEffect(() => {
|
|
142
|
-
setHistory(panel?.history)
|
|
143
|
-
}, [panel])
|
|
144
|
-
|
|
145
|
-
return (
|
|
146
|
-
<XyoPanelContext.Provider value={{ history, panel, progress, provided: true, reportingErrors, status }}>
|
|
147
|
-
{panel ? children : required ? null : children}
|
|
148
|
-
</XyoPanelContext.Provider>
|
|
149
|
-
)
|
|
150
|
-
}
|
package/src/contexts/State.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { XyoArchivistApi } from '@xyo-network/api'
|
|
2
|
-
import { XyoBoundWitness } from '@xyo-network/boundwitness'
|
|
3
|
-
import { XyoPanel } from '@xyo-network/panel'
|
|
4
|
-
import { XyoWitness } from '@xyo-network/witnesses'
|
|
5
|
-
|
|
6
|
-
export enum XyoReportStatus {
|
|
7
|
-
Idle = 'idle',
|
|
8
|
-
Queued = 'queued',
|
|
9
|
-
Started = 'started',
|
|
10
|
-
Succeeded = 'succeeded',
|
|
11
|
-
Failed = 'failed',
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface XyoWitnessReportProgress {
|
|
15
|
-
witness: XyoWitness
|
|
16
|
-
status: XyoReportStatus
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export interface XyoArchivistApiReportProgress {
|
|
20
|
-
archivist: XyoArchivistApi
|
|
21
|
-
status: XyoReportStatus
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface XyoPanelReportProgress {
|
|
25
|
-
witnesses?: Record<string, XyoWitnessReportProgress>
|
|
26
|
-
archivists?: Record<string, XyoArchivistApiReportProgress>
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface XyoPanelContextState {
|
|
30
|
-
panel?: XyoPanel
|
|
31
|
-
history?: XyoBoundWitness[]
|
|
32
|
-
progress?: XyoPanelReportProgress
|
|
33
|
-
status?: XyoReportStatus
|
|
34
|
-
reportingErrors?: Error[]
|
|
35
|
-
}
|
package/src/contexts/index.ts
DELETED
package/src/contexts/use.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useContextEx } from '@xyo-network/react-shared'
|
|
2
|
-
|
|
3
|
-
import { XyoPanelContext } from './Context'
|
|
4
|
-
|
|
5
|
-
export const useXyoPanel = () => {
|
|
6
|
-
const { panel, history, progress, reportingErrors, status } = useContextEx(XyoPanelContext, 'XyoPanel')
|
|
7
|
-
return { history, panel, progress, reportingErrors, status }
|
|
8
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './contexts'
|