@xyo-network/react-schema 2.64.0-rc.7 → 2.64.1

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.
Files changed (290) hide show
  1. package/dist/browser/components/Property/SchemaProperty.cjs +76 -0
  2. package/dist/{node/components/Property/SchemaProperty.mjs.map → browser/components/Property/SchemaProperty.cjs.map} +1 -1
  3. package/dist/browser/components/Property/SchemaProperty.d.cts +40 -0
  4. package/dist/browser/components/Property/SchemaProperty.d.cts.map +1 -0
  5. package/dist/browser/components/Property/SchemaProperty.js +4 -3
  6. package/dist/browser/components/Property/SchemaProperty.js.map +1 -1
  7. package/dist/browser/components/Property/index.cjs +78 -0
  8. package/dist/browser/components/Property/index.cjs.map +1 -0
  9. package/dist/browser/components/Property/index.d.cts +2 -0
  10. package/dist/browser/components/Property/index.d.cts.map +1 -0
  11. package/dist/browser/components/Property/index.js +54 -1
  12. package/dist/browser/components/Property/index.js.map +1 -1
  13. package/dist/browser/components/SelectEx/SchemaSelectEx.cjs +68 -0
  14. package/dist/browser/components/SelectEx/SchemaSelectEx.cjs.map +1 -0
  15. package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts +5 -0
  16. package/dist/browser/components/SelectEx/SchemaSelectEx.d.cts.map +1 -0
  17. package/dist/browser/components/SelectEx/SchemaSelectEx.js +15 -3
  18. package/dist/browser/components/SelectEx/SchemaSelectEx.js.map +1 -1
  19. package/dist/browser/components/SelectEx/index.cjs +70 -0
  20. package/dist/browser/components/SelectEx/index.cjs.map +1 -0
  21. package/dist/browser/components/SelectEx/index.d.cts +2 -0
  22. package/dist/browser/components/SelectEx/index.d.cts.map +1 -0
  23. package/dist/browser/components/SelectEx/index.js +46 -1
  24. package/dist/browser/components/SelectEx/index.js.map +1 -1
  25. package/dist/browser/components/index.cjs +123 -0
  26. package/dist/browser/components/index.cjs.map +1 -0
  27. package/dist/browser/components/index.d.cts +3 -0
  28. package/dist/browser/components/index.d.cts.map +1 -0
  29. package/dist/browser/components/index.js +99 -2
  30. package/dist/browser/components/index.js.map +1 -1
  31. package/dist/browser/contexts/Schema/Context.cjs +28 -0
  32. package/dist/{node/contexts/Schema/Context.mjs.map → browser/contexts/Schema/Context.cjs.map} +1 -1
  33. package/dist/browser/contexts/Schema/Context.d.cts +4 -0
  34. package/dist/browser/contexts/Schema/Context.d.cts.map +1 -0
  35. package/dist/browser/contexts/Schema/Context.js +2 -1
  36. package/dist/browser/contexts/Schema/Context.js.map +1 -1
  37. package/dist/browser/contexts/Schema/Provider/Memory.cjs +94 -0
  38. package/dist/browser/contexts/Schema/Provider/Memory.cjs.map +1 -0
  39. package/dist/browser/contexts/Schema/Provider/Memory.d.cts +5 -0
  40. package/dist/browser/contexts/Schema/Provider/Memory.d.cts.map +1 -0
  41. package/dist/browser/contexts/Schema/Provider/Memory.js +59 -7
  42. package/dist/browser/contexts/Schema/Provider/Memory.js.map +1 -1
  43. package/dist/browser/contexts/Schema/Provider/Props.cjs +19 -0
  44. package/dist/browser/contexts/Schema/Provider/Props.cjs.map +1 -0
  45. package/dist/browser/contexts/Schema/Provider/Props.d.cts +5 -0
  46. package/dist/browser/contexts/Schema/Provider/Props.d.cts.map +1 -0
  47. package/dist/browser/contexts/Schema/Provider/Route.cjs +144 -0
  48. package/dist/browser/contexts/Schema/Provider/Route.cjs.map +1 -0
  49. package/dist/browser/contexts/Schema/Provider/Route.d.cts +5 -0
  50. package/dist/browser/contexts/Schema/Provider/Route.d.cts.map +1 -0
  51. package/dist/browser/contexts/Schema/Provider/Route.js +86 -10
  52. package/dist/browser/contexts/Schema/Provider/Route.js.map +1 -1
  53. package/dist/browser/contexts/Schema/Provider/index.cjs +147 -0
  54. package/dist/browser/contexts/Schema/Provider/index.cjs.map +1 -0
  55. package/dist/browser/contexts/Schema/Provider/index.d.cts +4 -0
  56. package/dist/browser/contexts/Schema/Provider/index.d.cts.map +1 -0
  57. package/dist/browser/contexts/Schema/Provider/index.js +123 -3
  58. package/dist/browser/contexts/Schema/Provider/index.js.map +1 -1
  59. package/dist/browser/contexts/Schema/State.cjs +19 -0
  60. package/dist/browser/contexts/Schema/State.cjs.map +1 -0
  61. package/dist/browser/contexts/Schema/State.d.cts +13 -0
  62. package/dist/browser/contexts/Schema/State.d.cts.map +1 -0
  63. package/dist/browser/contexts/Schema/index.cjs +149 -0
  64. package/dist/browser/contexts/Schema/index.cjs.map +1 -0
  65. package/dist/browser/contexts/Schema/index.d.cts +5 -0
  66. package/dist/browser/contexts/Schema/index.d.cts.map +1 -0
  67. package/dist/browser/contexts/Schema/index.js +125 -4
  68. package/dist/browser/contexts/Schema/index.js.map +1 -1
  69. package/dist/browser/contexts/Schema/use.cjs +36 -0
  70. package/dist/browser/contexts/Schema/use.cjs.map +1 -0
  71. package/dist/browser/contexts/Schema/use.d.cts +3 -0
  72. package/dist/browser/contexts/Schema/use.d.cts.map +1 -0
  73. package/dist/browser/contexts/Schema/use.js +8 -2
  74. package/dist/browser/contexts/Schema/use.js.map +1 -1
  75. package/dist/browser/contexts/index.cjs +149 -0
  76. package/dist/browser/contexts/index.cjs.map +1 -0
  77. package/dist/browser/contexts/index.d.cts +2 -0
  78. package/dist/browser/contexts/index.d.cts.map +1 -0
  79. package/dist/browser/contexts/index.js +125 -1
  80. package/dist/browser/contexts/index.js.map +1 -1
  81. package/dist/browser/hooks/index.cjs +189 -0
  82. package/dist/browser/hooks/index.cjs.map +1 -0
  83. package/dist/browser/hooks/index.d.cts +5 -0
  84. package/dist/browser/hooks/index.d.cts.map +1 -0
  85. package/dist/browser/hooks/index.js +165 -4
  86. package/dist/browser/hooks/index.js.map +1 -1
  87. package/dist/browser/hooks/useGetSchema.cjs +69 -0
  88. package/dist/{node/hooks/useGetSchema.mjs.map → browser/hooks/useGetSchema.cjs.map} +1 -1
  89. package/dist/browser/hooks/useGetSchema.d.cts +27 -0
  90. package/dist/browser/hooks/useGetSchema.d.cts.map +1 -0
  91. package/dist/browser/hooks/useGetSchema.js +2 -1
  92. package/dist/browser/hooks/useGetSchema.js.map +1 -1
  93. package/dist/browser/hooks/useSchemaDefinitions.cjs +47 -0
  94. package/dist/{node/hooks/useSchemaDefinitions.mjs.map → browser/hooks/useSchemaDefinitions.cjs.map} +1 -1
  95. package/dist/browser/hooks/useSchemaDefinitions.d.cts +6 -0
  96. package/dist/browser/hooks/useSchemaDefinitions.d.cts.map +1 -0
  97. package/dist/browser/hooks/useSchemaDefinitions.js +2 -1
  98. package/dist/browser/hooks/useSchemaDefinitions.js.map +1 -1
  99. package/dist/browser/hooks/useSchemaList.cjs +69 -0
  100. package/dist/browser/hooks/useSchemaList.cjs.map +1 -0
  101. package/dist/browser/hooks/useSchemaList.d.cts +3 -0
  102. package/dist/browser/hooks/useSchemaList.d.cts.map +1 -0
  103. package/dist/browser/hooks/useSchemaList.js +2 -1
  104. package/dist/browser/hooks/useSchemaList.js.map +1 -1
  105. package/dist/browser/hooks/useSchemaStats.cjs +71 -0
  106. package/dist/{node/hooks/useSchemaStats.mjs.map → browser/hooks/useSchemaStats.cjs.map} +1 -1
  107. package/dist/browser/hooks/useSchemaStats.d.cts +4 -0
  108. package/dist/browser/hooks/useSchemaStats.d.cts.map +1 -0
  109. package/dist/browser/hooks/useSchemaStats.js +2 -1
  110. package/dist/browser/hooks/useSchemaStats.js.map +1 -1
  111. package/dist/browser/index.cjs +354 -0
  112. package/dist/browser/index.cjs.map +1 -0
  113. package/dist/browser/index.d.cts +4 -0
  114. package/dist/browser/index.d.cts.map +1 -0
  115. package/dist/browser/index.js +330 -3
  116. package/dist/browser/index.js.map +1 -1
  117. package/dist/docs.json +2071 -0
  118. package/dist/node/components/Property/SchemaProperty.cjs +81 -0
  119. package/dist/node/components/Property/SchemaProperty.cjs.map +1 -0
  120. package/dist/node/components/Property/SchemaProperty.d.cts +40 -0
  121. package/dist/node/components/Property/SchemaProperty.d.cts.map +1 -0
  122. package/dist/node/components/Property/SchemaProperty.js +26 -48
  123. package/dist/node/components/Property/SchemaProperty.js.map +1 -1
  124. package/dist/node/components/Property/index.cjs +83 -0
  125. package/dist/node/components/Property/index.cjs.map +1 -0
  126. package/dist/node/components/Property/index.d.cts +2 -0
  127. package/dist/node/components/Property/index.d.cts.map +1 -0
  128. package/dist/node/components/Property/index.js +53 -20
  129. package/dist/node/components/Property/index.js.map +1 -1
  130. package/dist/node/components/SelectEx/SchemaSelectEx.cjs +72 -0
  131. package/dist/node/components/SelectEx/SchemaSelectEx.cjs.map +1 -0
  132. package/dist/node/components/SelectEx/SchemaSelectEx.d.cts +5 -0
  133. package/dist/node/components/SelectEx/SchemaSelectEx.d.cts.map +1 -0
  134. package/dist/node/components/SelectEx/SchemaSelectEx.js +27 -39
  135. package/dist/node/components/SelectEx/SchemaSelectEx.js.map +1 -1
  136. package/dist/node/components/SelectEx/index.cjs +74 -0
  137. package/dist/node/components/SelectEx/index.cjs.map +1 -0
  138. package/dist/node/components/SelectEx/index.d.cts +2 -0
  139. package/dist/node/components/SelectEx/index.d.cts.map +1 -0
  140. package/dist/node/components/SelectEx/index.js +45 -21
  141. package/dist/node/components/SelectEx/index.js.map +1 -1
  142. package/dist/node/components/index.cjs +129 -0
  143. package/dist/node/components/index.cjs.map +1 -0
  144. package/dist/node/components/index.d.cts +3 -0
  145. package/dist/node/components/index.d.cts.map +1 -0
  146. package/dist/node/components/index.js +98 -22
  147. package/dist/node/components/index.js.map +1 -1
  148. package/dist/node/contexts/Schema/Context.cjs +32 -0
  149. package/dist/node/contexts/Schema/Context.cjs.map +1 -0
  150. package/dist/node/contexts/Schema/Context.d.cts +4 -0
  151. package/dist/node/contexts/Schema/Context.d.cts.map +1 -0
  152. package/dist/node/contexts/Schema/Context.js +5 -28
  153. package/dist/node/contexts/Schema/Context.js.map +1 -1
  154. package/dist/node/contexts/Schema/Provider/Memory.cjs +98 -0
  155. package/dist/node/contexts/Schema/Provider/Memory.cjs.map +1 -0
  156. package/dist/node/contexts/Schema/Provider/Memory.d.cts +5 -0
  157. package/dist/node/contexts/Schema/Provider/Memory.d.cts.map +1 -0
  158. package/dist/node/contexts/Schema/Provider/Memory.js +65 -37
  159. package/dist/node/contexts/Schema/Provider/Memory.js.map +1 -1
  160. package/dist/node/contexts/Schema/Provider/Props.cjs +19 -0
  161. package/dist/node/contexts/Schema/Provider/Props.cjs.map +1 -0
  162. package/dist/node/contexts/Schema/Provider/Props.d.cts +5 -0
  163. package/dist/node/contexts/Schema/Provider/Props.d.cts.map +1 -0
  164. package/dist/node/contexts/Schema/Provider/Props.js +0 -16
  165. package/dist/node/contexts/Schema/Provider/Props.js.map +1 -1
  166. package/dist/node/contexts/Schema/Provider/Route.cjs +148 -0
  167. package/dist/node/contexts/Schema/Provider/Route.cjs.map +1 -0
  168. package/dist/node/contexts/Schema/Provider/Route.d.cts +5 -0
  169. package/dist/node/contexts/Schema/Provider/Route.d.cts.map +1 -0
  170. package/dist/node/contexts/Schema/Provider/Route.js +94 -42
  171. package/dist/node/contexts/Schema/Provider/Route.js.map +1 -1
  172. package/dist/node/contexts/Schema/Provider/index.cjs +152 -0
  173. package/dist/node/contexts/Schema/Provider/index.cjs.map +1 -0
  174. package/dist/node/contexts/Schema/Provider/index.d.cts +4 -0
  175. package/dist/node/contexts/Schema/Provider/index.d.cts.map +1 -0
  176. package/dist/node/contexts/Schema/Provider/index.js +122 -25
  177. package/dist/node/contexts/Schema/Provider/index.js.map +1 -1
  178. package/dist/node/contexts/Schema/State.cjs +19 -0
  179. package/dist/node/contexts/Schema/State.cjs.map +1 -0
  180. package/dist/node/contexts/Schema/State.d.cts +13 -0
  181. package/dist/node/contexts/Schema/State.d.cts.map +1 -0
  182. package/dist/node/contexts/Schema/State.js +0 -16
  183. package/dist/node/contexts/Schema/State.js.map +1 -1
  184. package/dist/node/contexts/Schema/index.cjs +156 -0
  185. package/dist/node/contexts/Schema/index.cjs.map +1 -0
  186. package/dist/node/contexts/Schema/index.d.cts +5 -0
  187. package/dist/node/contexts/Schema/index.d.cts.map +1 -0
  188. package/dist/node/contexts/Schema/index.js +124 -27
  189. package/dist/node/contexts/Schema/index.js.map +1 -1
  190. package/dist/node/contexts/Schema/use.cjs +40 -0
  191. package/dist/node/contexts/Schema/use.cjs.map +1 -0
  192. package/dist/node/contexts/Schema/use.d.cts +3 -0
  193. package/dist/node/contexts/Schema/use.d.cts.map +1 -0
  194. package/dist/node/contexts/Schema/use.js +12 -30
  195. package/dist/node/contexts/Schema/use.js.map +1 -1
  196. package/dist/node/contexts/index.cjs +156 -0
  197. package/dist/node/contexts/index.cjs.map +1 -0
  198. package/dist/node/contexts/index.d.cts +2 -0
  199. package/dist/node/contexts/index.d.cts.map +1 -0
  200. package/dist/node/contexts/index.js +124 -21
  201. package/dist/node/contexts/index.js.map +1 -1
  202. package/dist/node/hooks/index.cjs +199 -0
  203. package/dist/node/hooks/index.cjs.map +1 -0
  204. package/dist/node/hooks/index.d.cts +5 -0
  205. package/dist/node/hooks/index.d.cts.map +1 -0
  206. package/dist/node/hooks/index.js +167 -27
  207. package/dist/node/hooks/index.js.map +1 -1
  208. package/dist/node/hooks/useGetSchema.cjs +73 -0
  209. package/dist/node/hooks/useGetSchema.cjs.map +1 -0
  210. package/dist/node/hooks/useGetSchema.d.cts +27 -0
  211. package/dist/node/hooks/useGetSchema.d.cts.map +1 -0
  212. package/dist/node/hooks/useGetSchema.js +18 -41
  213. package/dist/node/hooks/useGetSchema.js.map +1 -1
  214. package/dist/node/hooks/useSchemaDefinitions.cjs +54 -0
  215. package/dist/node/hooks/useSchemaDefinitions.cjs.map +1 -0
  216. package/dist/node/hooks/useSchemaDefinitions.d.cts +6 -0
  217. package/dist/node/hooks/useSchemaDefinitions.d.cts.map +1 -0
  218. package/dist/node/hooks/useSchemaDefinitions.js +14 -34
  219. package/dist/node/hooks/useSchemaDefinitions.js.map +1 -1
  220. package/dist/node/hooks/useSchemaList.cjs +73 -0
  221. package/dist/node/hooks/{useSchemaList.mjs.map → useSchemaList.cjs.map} +1 -1
  222. package/dist/node/hooks/useSchemaList.d.cts +3 -0
  223. package/dist/node/hooks/useSchemaList.d.cts.map +1 -0
  224. package/dist/node/hooks/useSchemaList.js +16 -39
  225. package/dist/node/hooks/useSchemaList.js.map +1 -1
  226. package/dist/node/hooks/useSchemaStats.cjs +75 -0
  227. package/dist/node/hooks/useSchemaStats.cjs.map +1 -0
  228. package/dist/node/hooks/useSchemaStats.d.cts +4 -0
  229. package/dist/node/hooks/useSchemaStats.d.cts.map +1 -0
  230. package/dist/node/hooks/useSchemaStats.js +17 -40
  231. package/dist/node/hooks/useSchemaStats.js.map +1 -1
  232. package/dist/node/index.cjs +371 -0
  233. package/dist/node/index.cjs.map +1 -0
  234. package/dist/node/index.d.cts +4 -0
  235. package/dist/node/index.d.cts.map +1 -0
  236. package/dist/node/index.js +333 -25
  237. package/dist/node/index.js.map +1 -1
  238. package/package.json +36 -36
  239. package/dist/browser/components/Property/SchemaProperty.stories.js +0 -37
  240. package/dist/browser/components/Property/SchemaProperty.stories.js.map +0 -1
  241. package/dist/browser/hooks/stories/TestSchemaHooks.stories.js +0 -65
  242. package/dist/browser/hooks/stories/TestSchemaHooks.stories.js.map +0 -1
  243. package/dist/browser/hooks/useGetSchema.stories.js +0 -63
  244. package/dist/browser/hooks/useGetSchema.stories.js.map +0 -1
  245. package/dist/node/components/Property/SchemaProperty.mjs +0 -54
  246. package/dist/node/components/Property/SchemaProperty.stories.js +0 -64
  247. package/dist/node/components/Property/SchemaProperty.stories.js.map +0 -1
  248. package/dist/node/components/Property/SchemaProperty.stories.mjs +0 -37
  249. package/dist/node/components/Property/SchemaProperty.stories.mjs.map +0 -1
  250. package/dist/node/components/Property/index.mjs +0 -2
  251. package/dist/node/components/Property/index.mjs.map +0 -1
  252. package/dist/node/components/SelectEx/SchemaSelectEx.mjs +0 -35
  253. package/dist/node/components/SelectEx/SchemaSelectEx.mjs.map +0 -1
  254. package/dist/node/components/SelectEx/index.mjs +0 -2
  255. package/dist/node/components/SelectEx/index.mjs.map +0 -1
  256. package/dist/node/components/index.mjs +0 -3
  257. package/dist/node/components/index.mjs.map +0 -1
  258. package/dist/node/contexts/Schema/Context.mjs +0 -6
  259. package/dist/node/contexts/Schema/Provider/Memory.mjs +0 -21
  260. package/dist/node/contexts/Schema/Provider/Memory.mjs.map +0 -1
  261. package/dist/node/contexts/Schema/Provider/Props.mjs +0 -1
  262. package/dist/node/contexts/Schema/Provider/Props.mjs.map +0 -1
  263. package/dist/node/contexts/Schema/Provider/Route.mjs +0 -47
  264. package/dist/node/contexts/Schema/Provider/Route.mjs.map +0 -1
  265. package/dist/node/contexts/Schema/Provider/index.mjs +0 -4
  266. package/dist/node/contexts/Schema/Provider/index.mjs.map +0 -1
  267. package/dist/node/contexts/Schema/State.mjs +0 -1
  268. package/dist/node/contexts/Schema/State.mjs.map +0 -1
  269. package/dist/node/contexts/Schema/index.mjs +0 -5
  270. package/dist/node/contexts/Schema/index.mjs.map +0 -1
  271. package/dist/node/contexts/Schema/use.mjs +0 -9
  272. package/dist/node/contexts/Schema/use.mjs.map +0 -1
  273. package/dist/node/contexts/index.mjs +0 -2
  274. package/dist/node/contexts/index.mjs.map +0 -1
  275. package/dist/node/hooks/index.mjs +0 -5
  276. package/dist/node/hooks/index.mjs.map +0 -1
  277. package/dist/node/hooks/stories/TestSchemaHooks.stories.js +0 -89
  278. package/dist/node/hooks/stories/TestSchemaHooks.stories.js.map +0 -1
  279. package/dist/node/hooks/stories/TestSchemaHooks.stories.mjs +0 -65
  280. package/dist/node/hooks/stories/TestSchemaHooks.stories.mjs.map +0 -1
  281. package/dist/node/hooks/useGetSchema.mjs +0 -47
  282. package/dist/node/hooks/useGetSchema.stories.js +0 -98
  283. package/dist/node/hooks/useGetSchema.stories.js.map +0 -1
  284. package/dist/node/hooks/useGetSchema.stories.mjs +0 -63
  285. package/dist/node/hooks/useGetSchema.stories.mjs.map +0 -1
  286. package/dist/node/hooks/useSchemaDefinitions.mjs +0 -25
  287. package/dist/node/hooks/useSchemaList.mjs +0 -47
  288. package/dist/node/hooks/useSchemaStats.mjs +0 -49
  289. package/dist/node/index.mjs +0 -4
  290. package/dist/node/index.mjs.map +0 -1
@@ -0,0 +1,156 @@
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/contexts/Schema/index.ts
21
+ var Schema_exports = {};
22
+ __export(Schema_exports, {
23
+ SchemaContext: () => SchemaContext,
24
+ SchemaMemoryProvider: () => SchemaMemoryProvider,
25
+ SchemaRouteProvider: () => SchemaRouteProvider,
26
+ useSchema: () => useSchema
27
+ });
28
+ module.exports = __toCommonJS(Schema_exports);
29
+
30
+ // src/contexts/Schema/Context.ts
31
+ var import_react_shared = require("@xyo-network/react-shared");
32
+ var SchemaContext = (0, import_react_shared.createContextEx)();
33
+
34
+ // src/contexts/Schema/Provider/Memory.tsx
35
+ var import_lodash = require("@xylabs/lodash");
36
+ var import_react2 = require("react");
37
+
38
+ // src/hooks/useSchemaStats.tsx
39
+ var import_react_async_effect = require("@xylabs/react-async-effect");
40
+ var import_diviner_schema_stats_model = require("@xyo-network/diviner-schema-stats-model");
41
+ var import_node_core_types = require("@xyo-network/node-core-types");
42
+ var import_react_diviner = require("@xyo-network/react-diviner");
43
+ var import_react = require("react");
44
+ var useSchemaStats = (statsAddress, nameOrAddress = import_node_core_types.TYPES.SchemaStatsDiviner.description) => {
45
+ const [refresh, setRefresh] = (0, import_react.useState)(1);
46
+ const [diviner, divinerError] = (0, import_react_diviner.useDivinerFromNode)(nameOrAddress);
47
+ const [error, setError] = (0, import_react.useState)();
48
+ const refreshHistory = () => setRefresh((previous) => previous + 1);
49
+ const [schemaList, setSchemaList] = (0, import_react.useState)();
50
+ const query = (0, import_react.useMemo)(
51
+ () => ({
52
+ address: statsAddress,
53
+ schema: import_diviner_schema_stats_model.SchemaStatsQuerySchema
54
+ }),
55
+ [statsAddress]
56
+ );
57
+ (0, import_react_async_effect.useAsyncEffect)(
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ async (mounted) => {
60
+ if (diviner) {
61
+ if (divinerError) {
62
+ if (mounted()) {
63
+ setError(divinerError);
64
+ setSchemaList(void 0);
65
+ }
66
+ } else {
67
+ try {
68
+ const schemas = (await diviner.divine([query])).filter(import_diviner_schema_stats_model.isSchemaStatsPayload);
69
+ if (mounted()) {
70
+ setSchemaList(schemas);
71
+ setError(void 0);
72
+ }
73
+ } catch (ex) {
74
+ setError(ex);
75
+ setSchemaList(void 0);
76
+ }
77
+ }
78
+ }
79
+ },
80
+ [diviner, refresh, divinerError, query]
81
+ );
82
+ return [schemaList, error, refreshHistory];
83
+ };
84
+
85
+ // src/contexts/Schema/Provider/Memory.tsx
86
+ var import_jsx_runtime = require("react/jsx-runtime");
87
+ var SchemaMemoryProvider = ({ defaultSchema, knownSchemaList = [], ...props }) => {
88
+ const [schema, setSchema] = (0, import_react2.useState)(defaultSchema);
89
+ const [schemaList, setSchemaList] = (0, import_react2.useState)(knownSchemaList);
90
+ const [fetchedSchemaStats] = useSchemaStats();
91
+ (0, import_react2.useEffect)(() => {
92
+ if (fetchedSchemaStats) {
93
+ const schemaList2 = (0, import_lodash.compact)(fetchedSchemaStats.map(({ name }) => name));
94
+ setSchemaList(schemaList2);
95
+ }
96
+ }, [fetchedSchemaStats]);
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaContext.Provider, { value: { provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }, ...props });
98
+ };
99
+
100
+ // src/contexts/Schema/Provider/Route.tsx
101
+ var import_react3 = require("react");
102
+ var import_react_router_dom = require("react-router-dom");
103
+
104
+ // src/contexts/Schema/use.ts
105
+ var import_react_shared2 = require("@xyo-network/react-shared");
106
+ var useSchema = (required = false) => {
107
+ return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
108
+ };
109
+
110
+ // src/contexts/Schema/Provider/Route.tsx
111
+ var import_jsx_runtime2 = require("react/jsx-runtime");
112
+ var SchemaRouteProviderInner = ({ children }) => {
113
+ const { schema, setSchema, schemaList } = useSchema();
114
+ const [params, setParams] = (0, import_react_router_dom.useSearchParams)();
115
+ const routeSchema = params.get("schema");
116
+ const setSchemaParam = (0, import_react3.useCallback)(
117
+ (schema2) => {
118
+ if (schema2) {
119
+ params.set("schema", schema2);
120
+ setParams(params, { replace: true });
121
+ setSchema == null ? void 0 : setSchema(schema2);
122
+ } else {
123
+ params.delete("network");
124
+ }
125
+ },
126
+ [params, setParams, setSchema]
127
+ );
128
+ const setSchemaLocal = (0, import_react3.useCallback)(
129
+ (schema2) => {
130
+ setSchemaParam(schema2);
131
+ setSchema == null ? void 0 : setSchema(schema2);
132
+ },
133
+ [setSchemaParam, setSchema]
134
+ );
135
+ (0, import_react3.useEffect)(() => {
136
+ if (routeSchema !== schema) {
137
+ if (routeSchema === void 0 && schema !== void 0) {
138
+ setSchemaLocal(schema);
139
+ } else if (routeSchema) {
140
+ setSchema == null ? void 0 : setSchema(routeSchema);
141
+ }
142
+ }
143
+ }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal]);
144
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaContext.Provider, { value: { provided: true, schema, schemaList, setSchema: setSchemaLocal }, children });
145
+ };
146
+ var SchemaRouteProvider = ({ knownSchemaList, defaultSchema, ...props }) => {
147
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaMemoryProvider, { knownSchemaList, defaultSchema, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaRouteProviderInner, { ...props }) });
148
+ };
149
+ // Annotate the CommonJS export names for ESM import in node:
150
+ 0 && (module.exports = {
151
+ SchemaContext,
152
+ SchemaMemoryProvider,
153
+ SchemaRouteProvider,
154
+ useSchema
155
+ });
156
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/contexts/Schema/index.ts","../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/Provider/Memory.tsx","../../../../src/hooks/useSchemaStats.tsx","../../../../src/contexts/Schema/Provider/Route.tsx","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["export * from './Context'\nexport * from './Provider'\nexport * from './State'\nexport * from './use'\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks'\nimport { SchemaContext } from '../Context'\nimport { SchemaProviderProps } from './Props'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList = [], ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { useCallback, useEffect } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context'\nimport { useSchema } from '../use'\nimport { SchemaMemoryProvider } from './Memory'\nimport { SchemaProviderProps } from './Props'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n //update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n //if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n //sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n //if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n //if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList, setSchema: setSchemaLocal }}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,0BAAgC;AAIzB,IAAM,oBAAgB,qCAAoC;;;ACJjE,oBAAwB;AAExB,IAAAA,gBAAoC;;;ACFpC,gCAA+B;AAC/B,wCAA0G;AAC1G,6BAAsB;AACtB,2BAAmC;AACnC,mBAA4D;AAErD,IAAM,iBAAiB,CAC5B,cACA,gBAAgB,6BAAM,mBAAmB,gBACmD;AAC5F,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,CAAC;AACxC,QAAM,CAAC,SAAS,YAAY,QAAI,yCAAmB,aAAa;AAChE,QAAM,CAA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GAAG,MAAM,MAAM;AAChI,SACE,6CAAC,wBAAqB,iBAAkC,eACtD,uDAAC,4BAA0B,GAAG,OAAO,GACvC;AAEJ;","names":["import_react","schemaList","import_react","import_react_shared","import_jsx_runtime","schema"]}
@@ -0,0 +1,5 @@
1
+ export * from './Context';
2
+ export * from './Provider';
3
+ export * from './State';
4
+ export * from './use';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,OAAO,CAAA"}
@@ -1,29 +1,126 @@
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 __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
1
+ // src/contexts/Schema/Context.ts
2
+ import { createContextEx } from "@xyo-network/react-shared";
3
+ var SchemaContext = createContextEx();
4
+
5
+ // src/contexts/Schema/Provider/Memory.tsx
6
+ import { compact } from "@xylabs/lodash";
7
+ import { useEffect, useState as useState2 } from "react";
8
+
9
+ // src/hooks/useSchemaStats.tsx
10
+ import { useAsyncEffect } from "@xylabs/react-async-effect";
11
+ import { isSchemaStatsPayload, SchemaStatsQuerySchema } from "@xyo-network/diviner-schema-stats-model";
12
+ import { TYPES } from "@xyo-network/node-core-types";
13
+ import { useDivinerFromNode } from "@xyo-network/react-diviner";
14
+ import { useMemo, useState } from "react";
15
+ var useSchemaStats = (statsAddress, nameOrAddress = TYPES.SchemaStatsDiviner.description) => {
16
+ const [refresh, setRefresh] = useState(1);
17
+ const [diviner, divinerError] = useDivinerFromNode(nameOrAddress);
18
+ const [error, setError] = useState();
19
+ const refreshHistory = () => setRefresh((previous) => previous + 1);
20
+ const [schemaList, setSchemaList] = useState();
21
+ const query = useMemo(
22
+ () => ({
23
+ address: statsAddress,
24
+ schema: SchemaStatsQuerySchema
25
+ }),
26
+ [statsAddress]
27
+ );
28
+ useAsyncEffect(
29
+ // eslint-disable-next-line react-hooks/exhaustive-deps
30
+ async (mounted) => {
31
+ if (diviner) {
32
+ if (divinerError) {
33
+ if (mounted()) {
34
+ setError(divinerError);
35
+ setSchemaList(void 0);
36
+ }
37
+ } else {
38
+ try {
39
+ const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload);
40
+ if (mounted()) {
41
+ setSchemaList(schemas);
42
+ setError(void 0);
43
+ }
44
+ } catch (ex) {
45
+ setError(ex);
46
+ setSchemaList(void 0);
47
+ }
48
+ }
49
+ }
50
+ },
51
+ [diviner, refresh, divinerError, query]
52
+ );
53
+ return [schemaList, error, refreshHistory];
54
+ };
55
+
56
+ // src/contexts/Schema/Provider/Memory.tsx
57
+ import { jsx } from "react/jsx-runtime";
58
+ var SchemaMemoryProvider = ({ defaultSchema, knownSchemaList = [], ...props }) => {
59
+ const [schema, setSchema] = useState2(defaultSchema);
60
+ const [schemaList, setSchemaList] = useState2(knownSchemaList);
61
+ const [fetchedSchemaStats] = useSchemaStats();
62
+ useEffect(() => {
63
+ if (fetchedSchemaStats) {
64
+ const schemaList2 = compact(fetchedSchemaStats.map(({ name }) => name));
65
+ setSchemaList(schemaList2);
66
+ }
67
+ }, [fetchedSchemaStats]);
68
+ return /* @__PURE__ */ jsx(SchemaContext.Provider, { value: { provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }, ...props });
69
+ };
70
+
71
+ // src/contexts/Schema/Provider/Route.tsx
72
+ import { useCallback, useEffect as useEffect2 } from "react";
73
+ import { useSearchParams } from "react-router-dom";
74
+
75
+ // src/contexts/Schema/use.ts
76
+ import { useContextEx } from "@xyo-network/react-shared";
77
+ var useSchema = (required = false) => {
78
+ return useContextEx(SchemaContext, "Schema", required);
79
+ };
80
+
81
+ // src/contexts/Schema/Provider/Route.tsx
82
+ import { jsx as jsx2 } from "react/jsx-runtime";
83
+ var SchemaRouteProviderInner = ({ children }) => {
84
+ const { schema, setSchema, schemaList } = useSchema();
85
+ const [params, setParams] = useSearchParams();
86
+ const routeSchema = params.get("schema");
87
+ const setSchemaParam = useCallback(
88
+ (schema2) => {
89
+ if (schema2) {
90
+ params.set("schema", schema2);
91
+ setParams(params, { replace: true });
92
+ setSchema == null ? void 0 : setSchema(schema2);
93
+ } else {
94
+ params.delete("network");
95
+ }
96
+ },
97
+ [params, setParams, setSchema]
98
+ );
99
+ const setSchemaLocal = useCallback(
100
+ (schema2) => {
101
+ setSchemaParam(schema2);
102
+ setSchema == null ? void 0 : setSchema(schema2);
103
+ },
104
+ [setSchemaParam, setSchema]
105
+ );
106
+ useEffect2(() => {
107
+ if (routeSchema !== schema) {
108
+ if (routeSchema === void 0 && schema !== void 0) {
109
+ setSchemaLocal(schema);
110
+ } else if (routeSchema) {
111
+ setSchema == null ? void 0 : setSchema(routeSchema);
112
+ }
113
+ }
114
+ }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal]);
115
+ return /* @__PURE__ */ jsx2(SchemaContext.Provider, { value: { provided: true, schema, schemaList, setSchema: setSchemaLocal }, children });
116
+ };
117
+ var SchemaRouteProvider = ({ knownSchemaList, defaultSchema, ...props }) => {
118
+ return /* @__PURE__ */ jsx2(SchemaMemoryProvider, { knownSchemaList, defaultSchema, children: /* @__PURE__ */ jsx2(SchemaRouteProviderInner, { ...props }) });
119
+ };
120
+ export {
121
+ SchemaContext,
122
+ SchemaMemoryProvider,
123
+ SchemaRouteProvider,
124
+ useSchema
13
125
  };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var Schema_exports = {};
17
- module.exports = __toCommonJS(Schema_exports);
18
- __reExport(Schema_exports, require("./Context"), module.exports);
19
- __reExport(Schema_exports, require("./Provider"), module.exports);
20
- __reExport(Schema_exports, require("./State"), module.exports);
21
- __reExport(Schema_exports, require("./use"), module.exports);
22
- // Annotate the CommonJS export names for ESM import in node:
23
- 0 && (module.exports = {
24
- ...require("./Context"),
25
- ...require("./Provider"),
26
- ...require("./State"),
27
- ...require("./use")
28
- });
29
126
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/contexts/Schema/index.ts"],"sourcesContent":["export * from './Context'\nexport * from './Provider'\nexport * from './State'\nexport * from './use'\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,2BAAc,sBAAd;AACA,2BAAc,uBADd;AAEA,2BAAc,oBAFd;AAGA,2BAAc,kBAHd;","names":[]}
1
+ {"version":3,"sources":["../../../../src/contexts/Schema/Context.ts","../../../../src/contexts/Schema/Provider/Memory.tsx","../../../../src/hooks/useSchemaStats.tsx","../../../../src/contexts/Schema/Provider/Route.tsx","../../../../src/contexts/Schema/use.ts"],"sourcesContent":["import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks'\nimport { SchemaContext } from '../Context'\nimport { SchemaProviderProps } from './Props'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList = [], ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { useCallback, useEffect } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context'\nimport { useSchema } from '../use'\nimport { SchemaMemoryProvider } from './Memory'\nimport { SchemaProviderProps } from './Props'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n //update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n //if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n //sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n //if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n //if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList, setSchema: setSchemaLocal }}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";AAAA,SAAS,uBAAuB;AAIzB,IAAM,gBAAgB,gBAAoC;;;ACJjE,SAAS,eAAe;AAExB,SAAS,WAAW,YAAAA,iBAAgB;;;ACFpC,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AW,QAAW;AAErD,uBAAe,MAAM;AAAA,MACvB,WAAW,aAAa;AAEtB,+CAAY;AAAA,MACd;AAAA,IACF;AAAA,EACF,GAAG,CAAC,aAAa,QAAQ,gBAAgB,WAAW,cAAc,CAAC;AAEnE,SAAO,gBAAAF,KAAC,cAAc,UAAd,EAAuB,OAAO,EAAE,UAAU,MAAM,QAAQ,YAAY,WAAW,eAAe,GAAI,UAAS;AACrH;AAEO,IAAM,sBAAmE,CAAC,EAAE,iBAAiB,eAAe,GAAG,MAAM,MAAM;AAChI,SACE,gBAAAA,KAAC,wBAAqB,iBAAkC,eACtD,0BAAAA,KAAC,4BAA0B,GAAG,OAAO,GACvC;AAEJ;","names":["useState","useState","schemaList","useEffect","jsx","schema","useEffect"]}
@@ -0,0 +1,40 @@
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/contexts/Schema/use.ts
21
+ var use_exports = {};
22
+ __export(use_exports, {
23
+ useSchema: () => useSchema
24
+ });
25
+ module.exports = __toCommonJS(use_exports);
26
+ var import_react_shared2 = require("@xyo-network/react-shared");
27
+
28
+ // src/contexts/Schema/Context.ts
29
+ var import_react_shared = require("@xyo-network/react-shared");
30
+ var SchemaContext = (0, import_react_shared.createContextEx)();
31
+
32
+ // src/contexts/Schema/use.ts
33
+ var useSchema = (required = false) => {
34
+ return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
35
+ };
36
+ // Annotate the CommonJS export names for ESM import in node:
37
+ 0 && (module.exports = {
38
+ useSchema
39
+ });
40
+ //# sourceMappingURL=use.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../src/contexts/Schema/use.ts","../../../../src/contexts/Schema/Context.ts"],"sourcesContent":["import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAAAA,uBAA6B;;;ACA7B,0BAAgC;AAIzB,IAAM,oBAAgB,qCAAoC;;;ADC1D,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,aAAO,mCAAiC,eAAe,UAAU,QAAQ;AAC3E;","names":["import_react_shared"]}
@@ -0,0 +1,3 @@
1
+ import { SchemaContextState } from './State';
2
+ export declare const useSchema: (required?: boolean) => Omit<SchemaContextState, "provided">;
3
+ //# sourceMappingURL=use.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../../../src/contexts/Schema/use.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,SAAS,8DAErB,CAAA"}
@@ -1,33 +1,15 @@
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 });
1
+ // src/contexts/Schema/use.ts
2
+ import { useContextEx } from "@xyo-network/react-shared";
3
+
4
+ // src/contexts/Schema/Context.ts
5
+ import { createContextEx } from "@xyo-network/react-shared";
6
+ var SchemaContext = createContextEx();
7
+
8
+ // src/contexts/Schema/use.ts
9
+ var useSchema = (required = false) => {
10
+ return useContextEx(SchemaContext, "Schema", required);
9
11
  };
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
- var use_exports = {};
20
- __export(use_exports, {
21
- useSchema: () => useSchema
22
- });
23
- module.exports = __toCommonJS(use_exports);
24
- var import_react_shared = require("@xyo-network/react-shared");
25
- var import_Context = require("./Context");
26
- const useSchema = (required = false) => {
27
- return (0, import_react_shared.useContextEx)(import_Context.SchemaContext, "Schema", required);
28
- };
29
- // Annotate the CommonJS export names for ESM import in node:
30
- 0 && (module.exports = {
12
+ export {
31
13
  useSchema
32
- });
14
+ };
33
15
  //# sourceMappingURL=use.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/contexts/Schema/use.ts"],"sourcesContent":["import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,0BAA6B;AAE7B,qBAA8B;AAGvB,MAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,aAAO,kCAAiC,8BAAe,UAAU,QAAQ;AAC3E;","names":[]}
1
+ {"version":3,"sources":["../../../../src/contexts/Schema/use.ts","../../../../src/contexts/Schema/Context.ts"],"sourcesContent":["import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n"],"mappings":";AAAA,SAAS,oBAAoB;;;ACA7B,SAAS,uBAAuB;AAIzB,IAAM,gBAAgB,gBAAoC;;;ADC1D,IAAM,YAAY,CAAC,WAAW,UAAU;AAC7C,SAAO,aAAiC,eAAe,UAAU,QAAQ;AAC3E;","names":[]}
@@ -0,0 +1,156 @@
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/contexts/index.ts
21
+ var contexts_exports = {};
22
+ __export(contexts_exports, {
23
+ SchemaContext: () => SchemaContext,
24
+ SchemaMemoryProvider: () => SchemaMemoryProvider,
25
+ SchemaRouteProvider: () => SchemaRouteProvider,
26
+ useSchema: () => useSchema
27
+ });
28
+ module.exports = __toCommonJS(contexts_exports);
29
+
30
+ // src/contexts/Schema/Context.ts
31
+ var import_react_shared = require("@xyo-network/react-shared");
32
+ var SchemaContext = (0, import_react_shared.createContextEx)();
33
+
34
+ // src/contexts/Schema/Provider/Memory.tsx
35
+ var import_lodash = require("@xylabs/lodash");
36
+ var import_react2 = require("react");
37
+
38
+ // src/hooks/useSchemaStats.tsx
39
+ var import_react_async_effect = require("@xylabs/react-async-effect");
40
+ var import_diviner_schema_stats_model = require("@xyo-network/diviner-schema-stats-model");
41
+ var import_node_core_types = require("@xyo-network/node-core-types");
42
+ var import_react_diviner = require("@xyo-network/react-diviner");
43
+ var import_react = require("react");
44
+ var useSchemaStats = (statsAddress, nameOrAddress = import_node_core_types.TYPES.SchemaStatsDiviner.description) => {
45
+ const [refresh, setRefresh] = (0, import_react.useState)(1);
46
+ const [diviner, divinerError] = (0, import_react_diviner.useDivinerFromNode)(nameOrAddress);
47
+ const [error, setError] = (0, import_react.useState)();
48
+ const refreshHistory = () => setRefresh((previous) => previous + 1);
49
+ const [schemaList, setSchemaList] = (0, import_react.useState)();
50
+ const query = (0, import_react.useMemo)(
51
+ () => ({
52
+ address: statsAddress,
53
+ schema: import_diviner_schema_stats_model.SchemaStatsQuerySchema
54
+ }),
55
+ [statsAddress]
56
+ );
57
+ (0, import_react_async_effect.useAsyncEffect)(
58
+ // eslint-disable-next-line react-hooks/exhaustive-deps
59
+ async (mounted) => {
60
+ if (diviner) {
61
+ if (divinerError) {
62
+ if (mounted()) {
63
+ setError(divinerError);
64
+ setSchemaList(void 0);
65
+ }
66
+ } else {
67
+ try {
68
+ const schemas = (await diviner.divine([query])).filter(import_diviner_schema_stats_model.isSchemaStatsPayload);
69
+ if (mounted()) {
70
+ setSchemaList(schemas);
71
+ setError(void 0);
72
+ }
73
+ } catch (ex) {
74
+ setError(ex);
75
+ setSchemaList(void 0);
76
+ }
77
+ }
78
+ }
79
+ },
80
+ [diviner, refresh, divinerError, query]
81
+ );
82
+ return [schemaList, error, refreshHistory];
83
+ };
84
+
85
+ // src/contexts/Schema/Provider/Memory.tsx
86
+ var import_jsx_runtime = require("react/jsx-runtime");
87
+ var SchemaMemoryProvider = ({ defaultSchema, knownSchemaList = [], ...props }) => {
88
+ const [schema, setSchema] = (0, import_react2.useState)(defaultSchema);
89
+ const [schemaList, setSchemaList] = (0, import_react2.useState)(knownSchemaList);
90
+ const [fetchedSchemaStats] = useSchemaStats();
91
+ (0, import_react2.useEffect)(() => {
92
+ if (fetchedSchemaStats) {
93
+ const schemaList2 = (0, import_lodash.compact)(fetchedSchemaStats.map(({ name }) => name));
94
+ setSchemaList(schemaList2);
95
+ }
96
+ }, [fetchedSchemaStats]);
97
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SchemaContext.Provider, { value: { provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }, ...props });
98
+ };
99
+
100
+ // src/contexts/Schema/Provider/Route.tsx
101
+ var import_react3 = require("react");
102
+ var import_react_router_dom = require("react-router-dom");
103
+
104
+ // src/contexts/Schema/use.ts
105
+ var import_react_shared2 = require("@xyo-network/react-shared");
106
+ var useSchema = (required = false) => {
107
+ return (0, import_react_shared2.useContextEx)(SchemaContext, "Schema", required);
108
+ };
109
+
110
+ // src/contexts/Schema/Provider/Route.tsx
111
+ var import_jsx_runtime2 = require("react/jsx-runtime");
112
+ var SchemaRouteProviderInner = ({ children }) => {
113
+ const { schema, setSchema, schemaList } = useSchema();
114
+ const [params, setParams] = (0, import_react_router_dom.useSearchParams)();
115
+ const routeSchema = params.get("schema");
116
+ const setSchemaParam = (0, import_react3.useCallback)(
117
+ (schema2) => {
118
+ if (schema2) {
119
+ params.set("schema", schema2);
120
+ setParams(params, { replace: true });
121
+ setSchema == null ? void 0 : setSchema(schema2);
122
+ } else {
123
+ params.delete("network");
124
+ }
125
+ },
126
+ [params, setParams, setSchema]
127
+ );
128
+ const setSchemaLocal = (0, import_react3.useCallback)(
129
+ (schema2) => {
130
+ setSchemaParam(schema2);
131
+ setSchema == null ? void 0 : setSchema(schema2);
132
+ },
133
+ [setSchemaParam, setSchema]
134
+ );
135
+ (0, import_react3.useEffect)(() => {
136
+ if (routeSchema !== schema) {
137
+ if (routeSchema === void 0 && schema !== void 0) {
138
+ setSchemaLocal(schema);
139
+ } else if (routeSchema) {
140
+ setSchema == null ? void 0 : setSchema(routeSchema);
141
+ }
142
+ }
143
+ }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal]);
144
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaContext.Provider, { value: { provided: true, schema, schemaList, setSchema: setSchemaLocal }, children });
145
+ };
146
+ var SchemaRouteProvider = ({ knownSchemaList, defaultSchema, ...props }) => {
147
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaMemoryProvider, { knownSchemaList, defaultSchema, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(SchemaRouteProviderInner, { ...props }) });
148
+ };
149
+ // Annotate the CommonJS export names for ESM import in node:
150
+ 0 && (module.exports = {
151
+ SchemaContext,
152
+ SchemaMemoryProvider,
153
+ SchemaRouteProvider,
154
+ useSchema
155
+ });
156
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/contexts/index.ts","../../../src/contexts/Schema/Context.ts","../../../src/contexts/Schema/Provider/Memory.tsx","../../../src/hooks/useSchemaStats.tsx","../../../src/contexts/Schema/Provider/Route.tsx","../../../src/contexts/Schema/use.ts"],"sourcesContent":["export * from './Schema'\n","import { createContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContextState } from './State'\n\nexport const SchemaContext = createContextEx<SchemaContextState>()\n","import { compact } from '@xylabs/lodash'\nimport { WithChildren } from '@xylabs/react-shared'\nimport { useEffect, useState } from 'react'\n\nimport { useSchemaStats } from '../../../hooks'\nimport { SchemaContext } from '../Context'\nimport { SchemaProviderProps } from './Props'\n\nexport const SchemaMemoryProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ defaultSchema, knownSchemaList = [], ...props }) => {\n const [schema, setSchema] = useState(defaultSchema)\n const [schemaList, setSchemaList] = useState<string[] | undefined>(knownSchemaList)\n const [fetchedSchemaStats] = useSchemaStats()\n\n useEffect(() => {\n if (fetchedSchemaStats) {\n const schemaList = compact(fetchedSchemaStats.map(({ name }) => name))\n setSchemaList(schemaList)\n }\n }, [fetchedSchemaStats])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList: knownSchemaList ?? schemaList, setSchema, setSchemaList }} {...props} />\n}\n","import { useAsyncEffect } from '@xylabs/react-async-effect'\nimport { isSchemaStatsPayload, SchemaStatsPayload, SchemaStatsQueryPayload, SchemaStatsQuerySchema } from '@xyo-network/diviner-schema-stats-model'\nimport { TYPES } from '@xyo-network/node-core-types'\nimport { useDivinerFromNode } from '@xyo-network/react-diviner'\nimport { Dispatch, SetStateAction, useMemo, useState } from 'react'\n\nexport const useSchemaStats = (\n statsAddress?: string,\n nameOrAddress = TYPES.SchemaStatsDiviner.description,\n): [SchemaStatsPayload[] | undefined, Error | undefined, Dispatch<SetStateAction<number>>] => {\n const [refresh, setRefresh] = useState(1)\n const [diviner, divinerError] = useDivinerFromNode(nameOrAddress)\n const [error, setError] = useState<Error>()\n const refreshHistory = () => setRefresh((previous) => previous + 1)\n\n const [schemaList, setSchemaList] = useState<SchemaStatsPayload[]>()\n\n const query: SchemaStatsQueryPayload = useMemo(\n () => ({\n address: statsAddress,\n schema: SchemaStatsQuerySchema,\n }),\n [statsAddress],\n )\n\n useAsyncEffect(\n // eslint-disable-next-line react-hooks/exhaustive-deps\n async (mounted) => {\n if (diviner) {\n if (divinerError) {\n if (mounted()) {\n setError(divinerError)\n setSchemaList(undefined)\n }\n } else {\n try {\n const schemas = (await diviner.divine([query])).filter(isSchemaStatsPayload)\n if (mounted()) {\n setSchemaList(schemas)\n setError(undefined)\n }\n } catch (ex) {\n setError(ex as Error)\n setSchemaList(undefined)\n }\n }\n }\n },\n [diviner, refresh, divinerError, query],\n )\n\n return [schemaList, error, refreshHistory]\n}\n","import type { WithChildren } from '@xylabs/react-shared'\nimport { useCallback, useEffect } from 'react'\nimport { useSearchParams } from 'react-router-dom'\n\nimport { SchemaContext } from '../Context'\nimport { useSchema } from '../use'\nimport { SchemaMemoryProvider } from './Memory'\nimport { SchemaProviderProps } from './Props'\n\nconst SchemaRouteProviderInner: React.FC<WithChildren> = ({ children }) => {\n const { schema, setSchema, schemaList } = useSchema()\n\n const [params, setParams] = useSearchParams()\n\n const routeSchema = params.get('schema')\n\n //update the network stored in the route\n const setSchemaParam = useCallback(\n (schema?: string) => {\n if (schema) {\n params.set('schema', schema)\n setParams(params, { replace: true })\n setSchema?.(schema)\n } else {\n params.delete('network')\n }\n },\n [params, setParams, setSchema],\n )\n\n //if the network is actively changed, update both memory and route\n const setSchemaLocal = useCallback(\n (schema: string) => {\n setSchemaParam(schema)\n setSchema?.(schema)\n },\n [setSchemaParam, setSchema],\n )\n\n //sync memory and route storage of network\n useEffect(() => {\n if (routeSchema !== schema) {\n if (routeSchema === undefined && schema !== undefined) {\n //if the route does not have a network selected, use what is in the memory context\n setSchemaLocal(schema)\n } else if (routeSchema) {\n //if the route has a selection and it is different from memory, update memory\n setSchema?.(routeSchema)\n }\n }\n }, [routeSchema, schema, setSchemaParam, setSchema, setSchemaLocal])\n\n return <SchemaContext.Provider value={{ provided: true, schema, schemaList, setSchema: setSchemaLocal }}>{children}</SchemaContext.Provider>\n}\n\nexport const SchemaRouteProvider: React.FC<WithChildren<SchemaProviderProps>> = ({ knownSchemaList, defaultSchema, ...props }) => {\n return (\n <SchemaMemoryProvider knownSchemaList={knownSchemaList} defaultSchema={defaultSchema}>\n <SchemaRouteProviderInner {...props} />\n </SchemaMemoryProvider>\n )\n}\n","import { useContextEx } from '@xyo-network/react-shared'\n\nimport { SchemaContext } from './Context'\nimport { SchemaContextState } from './State'\n\nexport const useSchema = (required = false) => {\n return useContextEx<SchemaContextState>(SchemaContext, 'Schema', required)\n}\n"],"mappings":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