@multiplatform.one/core 6.0.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 +25 -0
- package/LICENSE +201 -0
- package/package.json +126 -0
- package/src/app/CreateApp.tsx +325 -0
- package/src/app/CreateRootLayout.native.tsx +74 -0
- package/src/app/CreateRootLayout.tsx +66 -0
- package/src/app/CreateRootLayout.web.tsx +181 -0
- package/src/app/TanstackDevtools.tsx +138 -0
- package/src/app/TanstackProvider.tsx +41 -0
- package/src/app/index.ts +27 -0
- package/src/app/loadWalletProvider.d.ts +7 -0
- package/src/app/loadWalletProvider.native.ts +14 -0
- package/src/app/loadWalletProvider.web.ts +10 -0
- package/src/app/rootLayoutShared.ts +60 -0
- package/src/app/tanstackProvider.native.tsx +13 -0
- package/src/healthz.ts +4 -0
- package/src/index.ts +2 -0
- package/src/layouts/CreateDefaultLayout.tsx +127 -0
- package/src/layouts/index.ts +6 -0
- package/tsconfig.json +11 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# @multiplatform.one/core
|
|
2
|
+
|
|
3
|
+
## 6.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Unified 6.0.0 release: realign all public `@multiplatform.one/*` packages onto a single, matching version line (changesets `fixed` group). Highlights:
|
|
8
|
+
- **web3 split** into standalone `@multiplatform.one/connectkit` and `@multiplatform.one/gpg` packages; `web3` now depends on them instead of bundling ConnectKit.
|
|
9
|
+
- **Sign-In With GPG** screen added to the ConnectKit modal.
|
|
10
|
+
- **Native workspace web-resolution fix** + platform-split wrappers (rich-text / `TextEditor`, forms `Barcode`) so web-only libraries stay out of the native Hermes bundle.
|
|
11
|
+
|
|
12
|
+
From this release on, these packages are versioned together.
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- Updated dependencies
|
|
17
|
+
- @multiplatform.one/frappe@6.0.0
|
|
18
|
+
- @multiplatform.one/frappe-ui@6.0.0
|
|
19
|
+
- @multiplatform.one/i18n@6.0.0
|
|
20
|
+
- @multiplatform.one/keycloak@6.0.0
|
|
21
|
+
- @multiplatform.one/logger@6.0.0
|
|
22
|
+
- @multiplatform.one/platform@6.0.0
|
|
23
|
+
- @multiplatform.one/store@6.0.0
|
|
24
|
+
- @multiplatform.one/theme@6.0.0
|
|
25
|
+
- @multiplatform.one/web3@6.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2021 [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/package.json
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@multiplatform.one/core",
|
|
3
|
+
"version": "6.0.0",
|
|
4
|
+
"description": "Core framework shell, provider composition, and layout factories for multiplatform.one",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"app",
|
|
7
|
+
"multiplatform",
|
|
8
|
+
"multiplatform.one"
|
|
9
|
+
],
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"author": "BitSpur",
|
|
12
|
+
"source": "src/index.ts",
|
|
13
|
+
"sideEffects": true,
|
|
14
|
+
"main": "src/index.ts",
|
|
15
|
+
"module": "src/index.ts",
|
|
16
|
+
"types": "src/index.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"./package.json": "./package.json",
|
|
19
|
+
"./healthz": {
|
|
20
|
+
"types": "./src/healthz.ts",
|
|
21
|
+
"source": "./src/healthz.ts",
|
|
22
|
+
"default": "./src/healthz.ts"
|
|
23
|
+
},
|
|
24
|
+
".": {
|
|
25
|
+
"source": "./src/index.ts",
|
|
26
|
+
"types": "./src/index.ts",
|
|
27
|
+
"default": "./src/index.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
33
|
+
"dependencies": {
|
|
34
|
+
"@tanstack/devtools-event-client": "^0.4.3",
|
|
35
|
+
"@tanstack/react-devtools": "^0.10.2",
|
|
36
|
+
"@tanstack/react-form-devtools": "0.2.22",
|
|
37
|
+
"@tanstack/react-pacer-devtools": "^0.7.0",
|
|
38
|
+
"react-cookie": "^8.1.2",
|
|
39
|
+
"@multiplatform.one/i18n": "6.0.0",
|
|
40
|
+
"@multiplatform.one/platform": "6.0.0",
|
|
41
|
+
"@multiplatform.one/store": "6.0.0",
|
|
42
|
+
"@multiplatform.one/theme": "6.0.0",
|
|
43
|
+
"@multiplatform.one/logger": "6.0.0",
|
|
44
|
+
"@multiplatform.one/web3": "6.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@sentry/react": "^10.51.0",
|
|
48
|
+
"@tanstack/react-query": "^5.100.7",
|
|
49
|
+
"@tanstack/react-query-devtools": "^5.100.7",
|
|
50
|
+
"@types/react": "~19.2.14",
|
|
51
|
+
"i18next": "^25.10.10",
|
|
52
|
+
"one": "^1.16.5",
|
|
53
|
+
"react": "19.2.5",
|
|
54
|
+
"react-i18next": "^16.6.6",
|
|
55
|
+
"react-native": "0.83.2",
|
|
56
|
+
"react-native-gesture-handler": "~2.31.1",
|
|
57
|
+
"react-native-safe-area-context": "~5.7.0",
|
|
58
|
+
"tamagui": "2.0.0-rc.41",
|
|
59
|
+
"typescript": "~5.9.3",
|
|
60
|
+
"@multiplatform.one/frappe": "6.0.0",
|
|
61
|
+
"@multiplatform.one/web3": "6.0.0"
|
|
62
|
+
},
|
|
63
|
+
"peerDependencies": {
|
|
64
|
+
"@sentry/react": "^9.0.0",
|
|
65
|
+
"@tanstack/react-query": "^5.0.0",
|
|
66
|
+
"@tanstack/react-query-devtools": "^5.0.0",
|
|
67
|
+
"@vxrn/color-scheme": "^1.0.0",
|
|
68
|
+
"expo-font": ">=11.0.0",
|
|
69
|
+
"i18next": "^25.0.0",
|
|
70
|
+
"one": "^1.0.0",
|
|
71
|
+
"react": "^19.1.0",
|
|
72
|
+
"react-i18next": "^16.0.0",
|
|
73
|
+
"react-native": ">=0.83.0",
|
|
74
|
+
"react-native-gesture-handler": ">=2.0.0",
|
|
75
|
+
"react-native-safe-area-context": ">=4.0.0",
|
|
76
|
+
"tamagui": "^2.0.0-rc",
|
|
77
|
+
"@multiplatform.one/frappe": "6.0.0",
|
|
78
|
+
"@multiplatform.one/keycloak": "6.0.0",
|
|
79
|
+
"@multiplatform.one/frappe-ui": "6.0.0",
|
|
80
|
+
"@multiplatform.one/web3": "6.0.0"
|
|
81
|
+
},
|
|
82
|
+
"peerDependenciesMeta": {
|
|
83
|
+
"@multiplatform.one/frappe": {
|
|
84
|
+
"optional": true
|
|
85
|
+
},
|
|
86
|
+
"@multiplatform.one/frappe-ui": {
|
|
87
|
+
"optional": true
|
|
88
|
+
},
|
|
89
|
+
"@multiplatform.one/keycloak": {
|
|
90
|
+
"optional": true
|
|
91
|
+
},
|
|
92
|
+
"@multiplatform.one/web3": {
|
|
93
|
+
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"@sentry/react": {
|
|
96
|
+
"optional": true
|
|
97
|
+
},
|
|
98
|
+
"@tanstack/react-query": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"@tanstack/react-query-devtools": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
104
|
+
"@vxrn/color-scheme": {
|
|
105
|
+
"optional": true
|
|
106
|
+
},
|
|
107
|
+
"i18next": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"react-i18next": {
|
|
111
|
+
"optional": true
|
|
112
|
+
},
|
|
113
|
+
"expo-font": {
|
|
114
|
+
"optional": true
|
|
115
|
+
},
|
|
116
|
+
"react-native-gesture-handler": {
|
|
117
|
+
"optional": true
|
|
118
|
+
},
|
|
119
|
+
"react-native-safe-area-context": {
|
|
120
|
+
"optional": true
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"scripts": {
|
|
124
|
+
"typecheck": "tsc --noEmit"
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
Suspense,
|
|
3
|
+
createContext,
|
|
4
|
+
lazy,
|
|
5
|
+
useContext,
|
|
6
|
+
type ComponentType,
|
|
7
|
+
type PropsWithChildren,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
} from "react";
|
|
10
|
+
import { config, isWeb } from "@multiplatform.one/platform";
|
|
11
|
+
import type { ThemeConfig } from "@multiplatform.one/theme";
|
|
12
|
+
import { ThemeProvider } from "@multiplatform.one/theme";
|
|
13
|
+
import { FrappeProvider } from "@multiplatform.one/frappe-ui";
|
|
14
|
+
import { createTanstackProvider } from "./TanstackProvider";
|
|
15
|
+
// Platform-split: native -> bridge-only web3 via the `/native` subpath (no connectkit
|
|
16
|
+
// in Hermes); web -> passthrough (web mounts the provider at screen scope). Importing a
|
|
17
|
+
// single symbol here avoids a bare dynamic import("@multiplatform.one/web3") on native,
|
|
18
|
+
// which would resolve the WEB dist and dead-bundle the EVM-modal stack into Hermes.
|
|
19
|
+
import LazyWalletProvider from "./loadWalletProvider";
|
|
20
|
+
|
|
21
|
+
export type ProviderComponent = ComponentType<PropsWithChildren>;
|
|
22
|
+
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
// Provider config types
|
|
25
|
+
// ---------------------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
export interface TanstackConfig {
|
|
28
|
+
/** Show React Query devtools (web only, ignored on native and in Storybook). */
|
|
29
|
+
debug?: boolean;
|
|
30
|
+
/** Options forwarded to the QueryClient constructor. */
|
|
31
|
+
queryClientOptions?: Record<string, unknown>;
|
|
32
|
+
/**
|
|
33
|
+
* Pass `useUserScheme` from `one` / `@vxrn/color-scheme` so the theme
|
|
34
|
+
* devtools panel can control the color scheme (light / dark / system).
|
|
35
|
+
*/
|
|
36
|
+
useUserScheme?: () => {
|
|
37
|
+
setting: "system" | "light" | "dark";
|
|
38
|
+
value: "light" | "dark";
|
|
39
|
+
set: (s: "system" | "light" | "dark") => void;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Tamagui config object (from `createTamagui()`). When provided, the
|
|
43
|
+
* TanStack Devtools theme panel extracts `$color1`–`$color12` directly
|
|
44
|
+
* from the config's themes for the color line visualizer.
|
|
45
|
+
* Passed automatically by `createApp()` from the theme config.
|
|
46
|
+
*/
|
|
47
|
+
tamaguiConfig?: unknown;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface KeycloakConfig {
|
|
51
|
+
/** Force-enable or disable. When omitted, reads KEYCLOAK_ENABLED from env config. */
|
|
52
|
+
enabled?: boolean;
|
|
53
|
+
baseUrl?: string;
|
|
54
|
+
clientId?: string;
|
|
55
|
+
publicClientId?: string;
|
|
56
|
+
realm?: string;
|
|
57
|
+
debug?: boolean;
|
|
58
|
+
iframeSso?: boolean;
|
|
59
|
+
loginRedirectUri?: string;
|
|
60
|
+
messageHandlerKeys?: string[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface FrappeConfig {
|
|
64
|
+
/** Force-enable or disable. When omitted, reads FRAPPE_ENABLED from env config. */
|
|
65
|
+
enabled?: boolean;
|
|
66
|
+
baseURL?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Override port for Socket.IO realtime connection (e.g. 9000 in dev).
|
|
69
|
+
* Omit in production behind a reverse proxy.
|
|
70
|
+
*/
|
|
71
|
+
socketPort?: number;
|
|
72
|
+
auth?: {
|
|
73
|
+
useToken?: boolean;
|
|
74
|
+
token?: string;
|
|
75
|
+
type?: string;
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface Web3AppConfig {
|
|
80
|
+
/** Force-enable or disable. When omitted, reads WEB3_ENABLED from env config. */
|
|
81
|
+
enabled?: boolean;
|
|
82
|
+
walletConnectProjectId?: string;
|
|
83
|
+
appName?: string;
|
|
84
|
+
appDescription?: string;
|
|
85
|
+
appUrl?: string;
|
|
86
|
+
appIcon?: string;
|
|
87
|
+
enableTestnets?: boolean;
|
|
88
|
+
/** Native: URL serving the wallet WebView HTML (preferred over the inline string). */
|
|
89
|
+
webViewUrl?: string;
|
|
90
|
+
/** E2E only (native): route connect through the in-WebView mock wallet. */
|
|
91
|
+
mockWallet?: boolean;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// ---------------------------------------------------------------------------
|
|
95
|
+
// createApp config & props
|
|
96
|
+
// ---------------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
export interface CreateAppConfig {
|
|
99
|
+
/** ThemeConfig to pass to the built-in ThemeProvider. */
|
|
100
|
+
theme?: ThemeConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Additional providers composed outermost-to-innermost order.
|
|
103
|
+
* Each component receives `{ children }` and must render them.
|
|
104
|
+
* The first provider in the array becomes the outermost wrapper.
|
|
105
|
+
*/
|
|
106
|
+
providers?: ProviderComponent[];
|
|
107
|
+
/** TanStack Query provider with optional devtools. Pass `true` for defaults. */
|
|
108
|
+
tanstack?: TanstackConfig | boolean;
|
|
109
|
+
/** Keycloak auth provider (lazy-loaded). Pass `true` to read all settings from env config. */
|
|
110
|
+
keycloak?: KeycloakConfig | boolean;
|
|
111
|
+
/** Frappe provider (lazy-loaded). Pass `true` to read all settings from env config. */
|
|
112
|
+
frappe?: FrappeConfig | boolean;
|
|
113
|
+
/** Web3 wallet provider (lazy-loaded). Pass `true` to read all settings from env config. */
|
|
114
|
+
web3?: Web3AppConfig | boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface AppProviderProps extends PropsWithChildren {
|
|
118
|
+
/** System color scheme for theme resolution. */
|
|
119
|
+
systemTheme?: "light" | "dark";
|
|
120
|
+
/** Override the theme config set at createApp() time (useful for Storybook). */
|
|
121
|
+
themeConfig?: ThemeConfig;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const AppConfigContext = createContext<CreateAppConfig>({});
|
|
125
|
+
|
|
126
|
+
// ---------------------------------------------------------------------------
|
|
127
|
+
// createApp
|
|
128
|
+
// ---------------------------------------------------------------------------
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Creates a pre-configured app shell with composable providers.
|
|
132
|
+
*
|
|
133
|
+
* Returns `{ AppProvider, withApp, useAppConfig }`.
|
|
134
|
+
*
|
|
135
|
+
* Provider composition order (outermost → innermost):
|
|
136
|
+
* config context → TanStack → Web3 → Keycloak → Frappe → custom providers → ThemeProvider → children
|
|
137
|
+
*/
|
|
138
|
+
export function createApp(appConfig: CreateAppConfig) {
|
|
139
|
+
const builtinProviders: ProviderComponent[] = [];
|
|
140
|
+
|
|
141
|
+
// -- TanStack (outermost built-in, eagerly loaded) -------------------------
|
|
142
|
+
if (appConfig.tanstack) {
|
|
143
|
+
const cfg: TanstackConfig = appConfig.tanstack === true ? {} : { ...appConfig.tanstack };
|
|
144
|
+
// Inject the Tamagui config so the devtools panel can read theme colors
|
|
145
|
+
if (appConfig.theme?.tamagui && !cfg.tamaguiConfig) {
|
|
146
|
+
cfg.tamaguiConfig = appConfig.theme.tamagui;
|
|
147
|
+
}
|
|
148
|
+
builtinProviders.push(createTanstackProvider(cfg));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// -- Web3 (lazy-loaded) ----------------------------------------------------
|
|
152
|
+
if (appConfig.web3) {
|
|
153
|
+
const cfg: Web3AppConfig = appConfig.web3 === true ? {} : appConfig.web3;
|
|
154
|
+
|
|
155
|
+
function Web3Provider({ children }: PropsWithChildren) {
|
|
156
|
+
const enabled = cfg.enabled ?? config.get("WEB3_ENABLED") === "1";
|
|
157
|
+
if (!enabled) return children;
|
|
158
|
+
|
|
159
|
+
// On web the WagmiProvider must NOT sit above the router: it can't be
|
|
160
|
+
// server-rendered (wagmi/connectkit throw under the SSR ESM evaluator), so
|
|
161
|
+
// mounting it only on the client changes the element type above the
|
|
162
|
+
// navigator on hydration and remounts it → "Another navigator is already
|
|
163
|
+
// registered". Instead, web mounts the provider at screen scope (below the
|
|
164
|
+
// navigator) — see features/wallet/screen.tsx. Native has no SSR/navigator
|
|
165
|
+
// conflict, so it keeps the global provider here. Config is still available
|
|
166
|
+
// to the screen via useAppConfig().web3.
|
|
167
|
+
if (isWeb) return children;
|
|
168
|
+
|
|
169
|
+
const projectId = cfg.walletConnectProjectId || config.get("WALLETCONNECT_PROJECT_ID") || "";
|
|
170
|
+
const testnetsEnabled = cfg.enableTestnets ?? config.get("WEB3_TESTNETS_ENABLED") === "1";
|
|
171
|
+
|
|
172
|
+
const WalletWithChildren = LazyWalletProvider as unknown as ComponentType<
|
|
173
|
+
PropsWithChildren<{ config: Record<string, unknown> }>
|
|
174
|
+
>;
|
|
175
|
+
return (
|
|
176
|
+
// fallback must NOT be `children`: rendering web3-consuming screens before
|
|
177
|
+
// the lazy WagmiProvider loads throws "useConfig must be used within WagmiProvider".
|
|
178
|
+
<Suspense fallback={null}>
|
|
179
|
+
<WalletWithChildren
|
|
180
|
+
config={{
|
|
181
|
+
walletConnectProjectId: projectId,
|
|
182
|
+
appName: cfg.appName || "Multiplatform.one",
|
|
183
|
+
appDescription: cfg.appDescription || "Connect your wallet",
|
|
184
|
+
appUrl:
|
|
185
|
+
cfg.appUrl ||
|
|
186
|
+
(isWeb && typeof window !== "undefined" ? window.location.origin : ""),
|
|
187
|
+
appIcon: cfg.appIcon,
|
|
188
|
+
enableTestnets: testnetsEnabled,
|
|
189
|
+
webViewUrl: cfg.webViewUrl,
|
|
190
|
+
mockWallet: cfg.mockWallet,
|
|
191
|
+
}}
|
|
192
|
+
>
|
|
193
|
+
{children}
|
|
194
|
+
</WalletWithChildren>
|
|
195
|
+
</Suspense>
|
|
196
|
+
);
|
|
197
|
+
}
|
|
198
|
+
Web3Provider.displayName = "Web3Provider";
|
|
199
|
+
builtinProviders.push(Web3Provider);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// -- Keycloak (lazy-loaded) ------------------------------------------------
|
|
203
|
+
if (appConfig.keycloak) {
|
|
204
|
+
const cfg: KeycloakConfig = appConfig.keycloak === true ? {} : appConfig.keycloak;
|
|
205
|
+
const LazyKeycloakProvider = lazy(async () => {
|
|
206
|
+
const mod = await import("@multiplatform.one/keycloak");
|
|
207
|
+
return {
|
|
208
|
+
default: mod.KeycloakProvider as ComponentType<
|
|
209
|
+
PropsWithChildren<{
|
|
210
|
+
disabled?: boolean;
|
|
211
|
+
debug?: boolean;
|
|
212
|
+
baseUrl?: string;
|
|
213
|
+
clientId?: string;
|
|
214
|
+
publicClientId?: string;
|
|
215
|
+
realm?: string;
|
|
216
|
+
iframeSso?: boolean;
|
|
217
|
+
loginRedirectUri?: string;
|
|
218
|
+
messageHandlerKeys?: string[];
|
|
219
|
+
}>
|
|
220
|
+
>,
|
|
221
|
+
};
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
function KeycloakProviderWrapper({ children }: PropsWithChildren) {
|
|
225
|
+
const enabled = cfg.enabled ?? config.get("KEYCLOAK_ENABLED") === "1";
|
|
226
|
+
if (!enabled) return children;
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<Suspense fallback={children}>
|
|
230
|
+
<LazyKeycloakProvider
|
|
231
|
+
disabled={false}
|
|
232
|
+
debug={cfg.debug ?? config.get("DEBUG") === "1"}
|
|
233
|
+
baseUrl={cfg.baseUrl || `${config.get("BASE_URL") || ""}/auth`}
|
|
234
|
+
clientId={cfg.clientId || config.get("KEYCLOAK_CLIENT_ID")}
|
|
235
|
+
publicClientId={cfg.publicClientId || config.get("KEYCLOAK_PUBLIC_CLIENT_ID")}
|
|
236
|
+
realm={cfg.realm || config.get("KEYCLOAK_REALM") || ""}
|
|
237
|
+
iframeSso={cfg.iframeSso}
|
|
238
|
+
loginRedirectUri={cfg.loginRedirectUri}
|
|
239
|
+
messageHandlerKeys={cfg.messageHandlerKeys || []}
|
|
240
|
+
>
|
|
241
|
+
{children}
|
|
242
|
+
</LazyKeycloakProvider>
|
|
243
|
+
</Suspense>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
KeycloakProviderWrapper.displayName = "KeycloakProvider";
|
|
247
|
+
builtinProviders.push(KeycloakProviderWrapper);
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// -- Frappe (eagerly imported) ---------------------------------------------
|
|
251
|
+
// NOT lazy: a lazy()+Suspense boundary here remounts the router subtree when
|
|
252
|
+
// the (large) frappe-ui chunk resolves, which resets one's navigation to the
|
|
253
|
+
// index route — so deep-loading e.g. /wallet snapped back to /. (fallback=null
|
|
254
|
+
// doesn't help; the remount is from the lazy boundary resolving, not the
|
|
255
|
+
// fallback content.) frappe-ui is on the critical path for this app anyway.
|
|
256
|
+
if (appConfig.frappe) {
|
|
257
|
+
const cfg: FrappeConfig = appConfig.frappe === true ? {} : appConfig.frappe;
|
|
258
|
+
|
|
259
|
+
function FrappeProviderWrapper({ children }: PropsWithChildren) {
|
|
260
|
+
const enabled = cfg.enabled ?? config.get("FRAPPE_ENABLED") === "1";
|
|
261
|
+
if (!enabled) return children;
|
|
262
|
+
|
|
263
|
+
const baseURL = cfg.baseURL || config.get("BASE_URL") || "http://localhost:8000";
|
|
264
|
+
const socketPort =
|
|
265
|
+
cfg.socketPort ?? (Number(config.get("FRAPPE_SOCKETIO_PORT")) || undefined);
|
|
266
|
+
|
|
267
|
+
return (
|
|
268
|
+
<FrappeProvider baseURL={baseURL} socketPort={socketPort} auth={cfg.auth}>
|
|
269
|
+
{children}
|
|
270
|
+
</FrappeProvider>
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
FrappeProviderWrapper.displayName = "FrappeProvider";
|
|
274
|
+
builtinProviders.push(FrappeProviderWrapper);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// -- Combine: builtin → custom providers (theme is innermost) --------------
|
|
278
|
+
const allProviders = [...builtinProviders, ...(appConfig.providers || [])];
|
|
279
|
+
|
|
280
|
+
function AppProvider({ children, systemTheme, themeConfig }: AppProviderProps) {
|
|
281
|
+
const theme = themeConfig || appConfig.theme;
|
|
282
|
+
|
|
283
|
+
// Theme wraps children directly (innermost layer)
|
|
284
|
+
let content: ReactNode = theme ? (
|
|
285
|
+
<ThemeProvider config={theme} systemTheme={systemTheme}>
|
|
286
|
+
{children}
|
|
287
|
+
</ThemeProvider>
|
|
288
|
+
) : (
|
|
289
|
+
children
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
// Compose providers outermost-to-innermost (reduceRight so first element is outermost)
|
|
293
|
+
for (let i = allProviders.length - 1; i >= 0; i--) {
|
|
294
|
+
const Provider = allProviders[i];
|
|
295
|
+
content = <Provider>{content}</Provider>;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// AppConfig context is the outermost layer
|
|
299
|
+
return <AppConfigContext.Provider value={appConfig}>{content}</AppConfigContext.Provider>;
|
|
300
|
+
}
|
|
301
|
+
AppProvider.displayName = "AppProvider";
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* HOC that wraps a screen component in the AppProvider.
|
|
305
|
+
* Useful for wrapping individual route screens.
|
|
306
|
+
*/
|
|
307
|
+
function withApp<P extends Record<string, unknown>>(Screen: ComponentType<P>): ComponentType<P> {
|
|
308
|
+
function WrappedScreen(props: P) {
|
|
309
|
+
return (
|
|
310
|
+
<AppProvider>
|
|
311
|
+
<Screen {...props} />
|
|
312
|
+
</AppProvider>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
WrappedScreen.displayName = `withApp(${Screen.displayName || Screen.name || "Component"})`;
|
|
316
|
+
return WrappedScreen;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/** Read the app config from the nearest AppProvider context. */
|
|
320
|
+
function useAppConfig(): CreateAppConfig {
|
|
321
|
+
return useContext(AppConfigContext);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return { AppProvider, withApp, useAppConfig };
|
|
325
|
+
}
|