piral-core 1.0.0-pre.2296 → 1.0.1-beta.5640

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 (672) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +12 -4
  3. package/app.codegen +36 -0
  4. package/app.codegen.d.ts +29 -0
  5. package/dist/codegen.js +5308 -0
  6. package/esm/Piral.d.ts +4 -4
  7. package/esm/Piral.js +8 -11
  8. package/esm/Piral.js.map +1 -1
  9. package/esm/PiralContext.d.ts +21 -0
  10. package/esm/PiralContext.js +34 -0
  11. package/esm/PiralContext.js.map +1 -0
  12. package/esm/RootListener.d.ts +2 -0
  13. package/esm/RootListener.js +23 -0
  14. package/esm/RootListener.js.map +1 -0
  15. package/esm/actions/app.d.ts +7 -4
  16. package/esm/actions/app.js +24 -14
  17. package/esm/actions/app.js.map +1 -1
  18. package/esm/actions/components.js +5 -6
  19. package/esm/actions/components.js.map +1 -1
  20. package/esm/actions/data.js +16 -17
  21. package/esm/actions/data.js.map +1 -1
  22. package/esm/actions/define.js +2 -3
  23. package/esm/actions/define.js.map +1 -1
  24. package/esm/actions/portal.d.ts +2 -0
  25. package/esm/actions/portal.js +9 -4
  26. package/esm/actions/portal.js.map +1 -1
  27. package/esm/actions/state.js +7 -4
  28. package/esm/actions/state.js.map +1 -1
  29. package/esm/components/ErrorBoundary.d.ts +14 -31
  30. package/esm/components/ErrorBoundary.js +22 -28
  31. package/esm/components/ErrorBoundary.js.map +1 -1
  32. package/esm/components/ExtensionSlot.d.ts +1 -0
  33. package/esm/components/ExtensionSlot.js +34 -11
  34. package/esm/components/ExtensionSlot.js.map +1 -1
  35. package/esm/components/ForeignComponentContainer.d.ts +19 -0
  36. package/esm/components/ForeignComponentContainer.js +46 -0
  37. package/esm/components/ForeignComponentContainer.js.map +1 -0
  38. package/esm/components/Mediator.js +15 -12
  39. package/esm/components/Mediator.js.map +1 -1
  40. package/esm/components/PiralGlobals.d.ts +6 -0
  41. package/esm/components/PiralGlobals.js +13 -0
  42. package/esm/components/PiralGlobals.js.map +1 -0
  43. package/esm/components/PiralRoutes.d.ts +5 -0
  44. package/esm/components/PiralRoutes.js +6 -11
  45. package/esm/components/PiralRoutes.js.map +1 -1
  46. package/esm/components/PiralSuspense.d.ts +5 -0
  47. package/esm/components/PiralSuspense.js +8 -0
  48. package/esm/components/PiralSuspense.js.map +1 -0
  49. package/esm/components/PiralView.d.ts +10 -1
  50. package/esm/components/PiralView.js +12 -25
  51. package/esm/components/PiralView.js.map +1 -1
  52. package/esm/components/PortalRenderer.d.ts +5 -0
  53. package/esm/components/PortalRenderer.js +7 -0
  54. package/esm/components/PortalRenderer.js.map +1 -0
  55. package/esm/components/ResponsiveLayout.d.ts +9 -1
  56. package/esm/components/ResponsiveLayout.js +5 -13
  57. package/esm/components/ResponsiveLayout.js.map +1 -1
  58. package/esm/components/SwitchErrorInfo.js +12 -10
  59. package/esm/components/SwitchErrorInfo.js.map +1 -1
  60. package/esm/components/components.d.ts +18 -6
  61. package/esm/components/components.js +21 -9
  62. package/esm/components/components.js.map +1 -1
  63. package/esm/components/index.d.ts +4 -10
  64. package/esm/components/index.js +4 -10
  65. package/esm/components/index.js.map +1 -1
  66. package/esm/components/wrapComponent.d.ts +7 -0
  67. package/esm/components/wrapComponent.js +42 -0
  68. package/esm/components/wrapComponent.js.map +1 -0
  69. package/esm/createInstance.d.ts +2 -2
  70. package/esm/createInstance.js +34 -30
  71. package/esm/createInstance.js.map +1 -1
  72. package/esm/defaults/DefaultErrorInfo.js +10 -0
  73. package/esm/defaults/DefaultErrorInfo.js.map +1 -0
  74. package/esm/{components → defaults}/DefaultLayout.js +1 -4
  75. package/esm/defaults/DefaultLayout.js.map +1 -0
  76. package/esm/{components/DefaultLoader.js → defaults/DefaultLoadingIndicator.js} +2 -2
  77. package/esm/defaults/DefaultLoadingIndicator.js.map +1 -0
  78. package/esm/defaults/DefaultRouteSwitch_v5.d.ts +3 -0
  79. package/esm/defaults/DefaultRouteSwitch_v5.js +11 -0
  80. package/esm/defaults/DefaultRouteSwitch_v5.js.map +1 -0
  81. package/esm/defaults/DefaultRouteSwitch_v6.d.ts +3 -0
  82. package/esm/defaults/DefaultRouteSwitch_v6.js +15 -0
  83. package/esm/defaults/DefaultRouteSwitch_v6.js.map +1 -0
  84. package/esm/defaults/DefaultRouter_v5.d.ts +3 -0
  85. package/esm/defaults/DefaultRouter_v5.js +7 -0
  86. package/esm/defaults/DefaultRouter_v5.js.map +1 -0
  87. package/esm/defaults/DefaultRouter_v6.d.ts +3 -0
  88. package/esm/defaults/DefaultRouter_v6.js +7 -0
  89. package/esm/defaults/DefaultRouter_v6.js.map +1 -0
  90. package/esm/defaults/navigator_none.d.ts +5 -0
  91. package/esm/defaults/navigator_none.js +30 -0
  92. package/esm/defaults/navigator_none.js.map +1 -0
  93. package/esm/defaults/navigator_v5.d.ts +6 -0
  94. package/esm/defaults/navigator_v5.js +81 -0
  95. package/esm/defaults/navigator_v5.js.map +1 -0
  96. package/esm/defaults/navigator_v6.d.ts +6 -0
  97. package/esm/defaults/navigator_v6.js +77 -0
  98. package/esm/defaults/navigator_v6.js.map +1 -0
  99. package/esm/helpers.d.ts +12 -26
  100. package/esm/helpers.js +14 -72
  101. package/esm/helpers.js.map +1 -1
  102. package/esm/hooks/action.js +2 -3
  103. package/esm/hooks/action.js.map +1 -1
  104. package/esm/hooks/actions.js +1 -1
  105. package/esm/hooks/actions.js.map +1 -1
  106. package/esm/hooks/globalState.d.ts +7 -0
  107. package/esm/hooks/globalState.js +10 -8
  108. package/esm/hooks/globalState.js.map +1 -1
  109. package/esm/hooks/index.d.ts +2 -5
  110. package/esm/hooks/index.js +2 -5
  111. package/esm/hooks/index.js.map +1 -1
  112. package/esm/hooks/media.js +8 -7
  113. package/esm/hooks/media.js.map +1 -1
  114. package/esm/hooks/piletApi.d.ts +7 -0
  115. package/esm/hooks/piletApi.js +14 -0
  116. package/esm/hooks/piletApi.js.map +1 -0
  117. package/esm/hooks/routes.d.ts +2 -0
  118. package/esm/hooks/routes.js +11 -0
  119. package/esm/hooks/routes.js.map +1 -0
  120. package/esm/hooks/setter.js +3 -2
  121. package/esm/hooks/setter.js.map +1 -1
  122. package/esm/hooks/sharedData.js +2 -2
  123. package/esm/hooks/sharedData.js.map +1 -1
  124. package/esm/index.d.ts +3 -1
  125. package/esm/index.js +3 -1
  126. package/esm/index.js.map +1 -1
  127. package/esm/modules/api.d.ts +2 -5
  128. package/esm/modules/api.js +9 -69
  129. package/esm/modules/api.js.map +1 -1
  130. package/esm/modules/core.d.ts +3 -0
  131. package/esm/modules/core.js +50 -0
  132. package/esm/modules/core.js.map +1 -0
  133. package/esm/modules/dependencies.d.ts +5 -6
  134. package/esm/modules/dependencies.js +9 -24
  135. package/esm/modules/dependencies.js.map +1 -1
  136. package/esm/modules/element.d.ts +5 -0
  137. package/esm/modules/element.js +169 -0
  138. package/esm/modules/element.js.map +1 -0
  139. package/esm/modules/index.d.ts +1 -0
  140. package/esm/modules/index.js +1 -0
  141. package/esm/modules/index.js.map +1 -1
  142. package/esm/setters/SetComponent.js +11 -0
  143. package/esm/setters/SetComponent.js.map +1 -0
  144. package/esm/setters/SetError.js +11 -0
  145. package/esm/setters/SetError.js.map +1 -0
  146. package/esm/setters/SetErrors.js +9 -0
  147. package/esm/setters/SetErrors.js.map +1 -0
  148. package/esm/setters/SetLayout.js +9 -0
  149. package/esm/setters/SetLayout.js.map +1 -0
  150. package/esm/setters/SetProvider.js +11 -0
  151. package/esm/setters/SetProvider.js.map +1 -0
  152. package/esm/setters/SetRedirect.js +12 -0
  153. package/esm/setters/SetRedirect.js.map +1 -0
  154. package/{lib/components → esm/setters}/SetRoute.d.ts +6 -2
  155. package/esm/setters/SetRoute.js +11 -0
  156. package/esm/setters/SetRoute.js.map +1 -0
  157. package/esm/setters/index.d.ts +7 -0
  158. package/esm/setters/index.js +8 -0
  159. package/esm/setters/index.js.map +1 -0
  160. package/esm/state/createActions.d.ts +2 -2
  161. package/esm/state/createActions.js +8 -12
  162. package/esm/state/createActions.js.map +1 -1
  163. package/esm/state/createGlobalState.d.ts +1 -2
  164. package/esm/state/createGlobalState.js +9 -34
  165. package/esm/state/createGlobalState.js.map +1 -1
  166. package/esm/state/stateContext.js +1 -1
  167. package/esm/state/stateContext.js.map +1 -1
  168. package/esm/state/withApi.d.ts +1 -1
  169. package/esm/state/withApi.js +19 -104
  170. package/esm/state/withApi.js.map +1 -1
  171. package/esm/tools/codegen.d.ts +21 -0
  172. package/esm/tools/codegen.js +145 -0
  173. package/esm/tools/codegen.js.map +1 -0
  174. package/esm/tools/debugger.d.ts +4 -0
  175. package/esm/tools/debugger.js +54 -0
  176. package/esm/tools/debugger.js.map +1 -0
  177. package/esm/tools/emulator.d.ts +3 -0
  178. package/esm/tools/emulator.js +11 -0
  179. package/esm/tools/emulator.js.map +1 -0
  180. package/esm/types/api.d.ts +34 -9
  181. package/esm/types/common.d.ts +11 -11
  182. package/esm/types/components.d.ts +74 -8
  183. package/esm/types/config.d.ts +24 -17
  184. package/esm/types/data.d.ts +2 -2
  185. package/esm/types/extension.d.ts +31 -4
  186. package/esm/types/index.d.ts +1 -0
  187. package/esm/types/index.js +1 -0
  188. package/esm/types/index.js.map +1 -1
  189. package/esm/types/instance.d.ts +26 -4
  190. package/esm/types/layout.d.ts +3 -3
  191. package/esm/types/navigation.d.ts +94 -0
  192. package/esm/types/navigation.js +2 -0
  193. package/esm/types/navigation.js.map +1 -0
  194. package/esm/types/plugin.d.ts +1 -14
  195. package/esm/types/state.d.ts +66 -27
  196. package/esm/types/utils.d.ts +1 -1
  197. package/esm/utils/compare.d.ts +1 -1
  198. package/esm/utils/compare.js +24 -7
  199. package/esm/utils/compare.js.map +1 -1
  200. package/esm/utils/data.js +6 -7
  201. package/esm/utils/data.js.map +1 -1
  202. package/esm/utils/extension.d.ts +16 -0
  203. package/esm/utils/extension.js +37 -0
  204. package/esm/utils/extension.js.map +1 -0
  205. package/esm/utils/foreign.d.ts +7 -2
  206. package/esm/utils/foreign.js +20 -9
  207. package/esm/utils/foreign.js.map +1 -1
  208. package/esm/utils/guid.js +3 -3
  209. package/esm/utils/guid.js.map +1 -1
  210. package/esm/utils/helpers.d.ts +11 -8
  211. package/esm/utils/helpers.js +29 -18
  212. package/esm/utils/helpers.js.map +1 -1
  213. package/esm/utils/index.d.ts +3 -1
  214. package/esm/utils/index.js +3 -1
  215. package/esm/utils/index.js.map +1 -1
  216. package/esm/utils/media.js +8 -8
  217. package/esm/utils/media.js.map +1 -1
  218. package/esm/utils/state.d.ts +57 -0
  219. package/esm/utils/state.js +83 -0
  220. package/esm/utils/state.js.map +1 -0
  221. package/esm/utils/storage.js +13 -14
  222. package/esm/utils/storage.js.map +1 -1
  223. package/lib/Piral.d.ts +4 -4
  224. package/lib/Piral.js +11 -13
  225. package/lib/Piral.js.map +1 -1
  226. package/lib/PiralContext.d.ts +21 -0
  227. package/lib/PiralContext.js +38 -0
  228. package/lib/PiralContext.js.map +1 -0
  229. package/lib/RootListener.d.ts +2 -0
  230. package/lib/RootListener.js +27 -0
  231. package/lib/RootListener.js.map +1 -0
  232. package/lib/actions/app.d.ts +7 -4
  233. package/lib/actions/app.js +27 -16
  234. package/lib/actions/app.js.map +1 -1
  235. package/lib/actions/components.js +5 -6
  236. package/lib/actions/components.js.map +1 -1
  237. package/lib/actions/data.js +17 -18
  238. package/lib/actions/data.js.map +1 -1
  239. package/lib/actions/define.js +2 -3
  240. package/lib/actions/define.js.map +1 -1
  241. package/lib/actions/index.js +1 -1
  242. package/lib/actions/portal.d.ts +2 -0
  243. package/lib/actions/portal.js +12 -5
  244. package/lib/actions/portal.js.map +1 -1
  245. package/lib/actions/state.js +7 -4
  246. package/lib/actions/state.js.map +1 -1
  247. package/lib/components/ErrorBoundary.d.ts +14 -31
  248. package/lib/components/ErrorBoundary.js +23 -28
  249. package/lib/components/ErrorBoundary.js.map +1 -1
  250. package/lib/components/ExtensionSlot.d.ts +1 -0
  251. package/lib/components/ExtensionSlot.js +37 -14
  252. package/lib/components/ExtensionSlot.js.map +1 -1
  253. package/lib/components/ForeignComponentContainer.d.ts +19 -0
  254. package/lib/components/ForeignComponentContainer.js +50 -0
  255. package/lib/components/ForeignComponentContainer.js.map +1 -0
  256. package/lib/components/Mediator.js +18 -14
  257. package/lib/components/Mediator.js.map +1 -1
  258. package/lib/components/PiralGlobals.d.ts +6 -0
  259. package/lib/components/PiralGlobals.js +17 -0
  260. package/lib/components/PiralGlobals.js.map +1 -0
  261. package/lib/components/PiralRoutes.d.ts +5 -0
  262. package/lib/components/PiralRoutes.js +8 -12
  263. package/lib/components/PiralRoutes.js.map +1 -1
  264. package/lib/components/PiralSuspense.d.ts +5 -0
  265. package/lib/components/PiralSuspense.js +12 -0
  266. package/lib/components/PiralSuspense.js.map +1 -0
  267. package/lib/components/PiralView.d.ts +10 -1
  268. package/lib/components/PiralView.js +15 -27
  269. package/lib/components/PiralView.js.map +1 -1
  270. package/lib/components/PortalRenderer.d.ts +5 -0
  271. package/lib/components/PortalRenderer.js +11 -0
  272. package/lib/components/PortalRenderer.js.map +1 -0
  273. package/lib/components/ResponsiveLayout.d.ts +9 -1
  274. package/lib/components/ResponsiveLayout.js +7 -14
  275. package/lib/components/ResponsiveLayout.js.map +1 -1
  276. package/lib/components/SwitchErrorInfo.js +15 -12
  277. package/lib/components/SwitchErrorInfo.js.map +1 -1
  278. package/lib/components/components.d.ts +18 -6
  279. package/lib/components/components.js +24 -12
  280. package/lib/components/components.js.map +1 -1
  281. package/lib/components/index.d.ts +4 -10
  282. package/lib/components/index.js +5 -11
  283. package/lib/components/index.js.map +1 -1
  284. package/lib/components/wrapComponent.d.ts +7 -0
  285. package/lib/components/wrapComponent.js +46 -0
  286. package/lib/components/wrapComponent.js.map +1 -0
  287. package/lib/createInstance.d.ts +2 -2
  288. package/lib/createInstance.js +40 -36
  289. package/lib/createInstance.js.map +1 -1
  290. package/lib/defaults/DefaultErrorInfo.js +14 -0
  291. package/lib/defaults/DefaultErrorInfo.js.map +1 -0
  292. package/lib/{components → defaults}/DefaultLayout.js +3 -5
  293. package/lib/defaults/DefaultLayout.js.map +1 -0
  294. package/lib/{components/DefaultLoader.js → defaults/DefaultLoadingIndicator.js} +4 -3
  295. package/lib/defaults/DefaultLoadingIndicator.js.map +1 -0
  296. package/lib/defaults/DefaultRouteSwitch_v5.d.ts +3 -0
  297. package/lib/defaults/DefaultRouteSwitch_v5.js +15 -0
  298. package/lib/defaults/DefaultRouteSwitch_v5.js.map +1 -0
  299. package/lib/defaults/DefaultRouteSwitch_v6.d.ts +3 -0
  300. package/lib/defaults/DefaultRouteSwitch_v6.js +19 -0
  301. package/lib/defaults/DefaultRouteSwitch_v6.js.map +1 -0
  302. package/lib/defaults/DefaultRouter_v5.d.ts +3 -0
  303. package/lib/defaults/DefaultRouter_v5.js +11 -0
  304. package/lib/defaults/DefaultRouter_v5.js.map +1 -0
  305. package/lib/defaults/DefaultRouter_v6.d.ts +3 -0
  306. package/lib/defaults/DefaultRouter_v6.js +11 -0
  307. package/lib/defaults/DefaultRouter_v6.js.map +1 -0
  308. package/lib/defaults/navigator_none.d.ts +5 -0
  309. package/lib/defaults/navigator_none.js +37 -0
  310. package/lib/defaults/navigator_none.js.map +1 -0
  311. package/lib/defaults/navigator_v5.d.ts +6 -0
  312. package/lib/defaults/navigator_v5.js +88 -0
  313. package/lib/defaults/navigator_v5.js.map +1 -0
  314. package/lib/defaults/navigator_v6.d.ts +6 -0
  315. package/lib/defaults/navigator_v6.js +84 -0
  316. package/lib/defaults/navigator_v6.js.map +1 -0
  317. package/lib/helpers.d.ts +12 -26
  318. package/lib/helpers.js +15 -75
  319. package/lib/helpers.js.map +1 -1
  320. package/lib/hooks/action.js +2 -3
  321. package/lib/hooks/action.js.map +1 -1
  322. package/lib/hooks/actions.js +4 -4
  323. package/lib/hooks/actions.js.map +1 -1
  324. package/lib/hooks/globalState.d.ts +7 -0
  325. package/lib/hooks/globalState.js +14 -11
  326. package/lib/hooks/globalState.js.map +1 -1
  327. package/lib/hooks/index.d.ts +2 -5
  328. package/lib/hooks/index.js +3 -6
  329. package/lib/hooks/index.js.map +1 -1
  330. package/lib/hooks/media.js +10 -9
  331. package/lib/hooks/media.js.map +1 -1
  332. package/lib/hooks/piletApi.d.ts +7 -0
  333. package/lib/hooks/piletApi.js +18 -0
  334. package/lib/hooks/piletApi.js.map +1 -0
  335. package/lib/hooks/routes.d.ts +2 -0
  336. package/lib/hooks/routes.js +15 -0
  337. package/lib/hooks/routes.js.map +1 -0
  338. package/lib/hooks/setter.js +4 -3
  339. package/lib/hooks/setter.js.map +1 -1
  340. package/lib/hooks/sharedData.js +3 -3
  341. package/lib/hooks/sharedData.js.map +1 -1
  342. package/lib/index.d.ts +3 -1
  343. package/lib/index.js +4 -2
  344. package/lib/index.js.map +1 -1
  345. package/lib/modules/api.d.ts +2 -5
  346. package/lib/modules/api.js +12 -75
  347. package/lib/modules/api.js.map +1 -1
  348. package/lib/modules/core.d.ts +3 -0
  349. package/lib/modules/core.js +54 -0
  350. package/lib/modules/core.js.map +1 -0
  351. package/lib/modules/dependencies.d.ts +5 -6
  352. package/lib/modules/dependencies.js +12 -27
  353. package/lib/modules/dependencies.js.map +1 -1
  354. package/lib/modules/element.d.ts +5 -0
  355. package/lib/modules/element.js +173 -0
  356. package/lib/modules/element.js.map +1 -0
  357. package/lib/modules/index.d.ts +1 -0
  358. package/lib/modules/index.js +2 -1
  359. package/lib/modules/index.js.map +1 -1
  360. package/lib/setters/SetComponent.js +15 -0
  361. package/lib/setters/SetComponent.js.map +1 -0
  362. package/lib/setters/SetError.js +15 -0
  363. package/lib/setters/SetError.js.map +1 -0
  364. package/lib/setters/SetErrors.js +13 -0
  365. package/lib/setters/SetErrors.js.map +1 -0
  366. package/lib/setters/SetLayout.js +13 -0
  367. package/lib/setters/SetLayout.js.map +1 -0
  368. package/lib/{components → setters}/SetProvider.js +4 -5
  369. package/lib/setters/SetProvider.js.map +1 -0
  370. package/lib/setters/SetRedirect.js +16 -0
  371. package/lib/setters/SetRedirect.js.map +1 -0
  372. package/{esm/components → lib/setters}/SetRoute.d.ts +6 -2
  373. package/lib/setters/SetRoute.js +15 -0
  374. package/lib/setters/SetRoute.js.map +1 -0
  375. package/lib/setters/index.d.ts +7 -0
  376. package/lib/setters/index.js +11 -0
  377. package/lib/setters/index.js.map +1 -0
  378. package/lib/state/createActions.d.ts +2 -2
  379. package/lib/state/createActions.js +9 -13
  380. package/lib/state/createActions.js.map +1 -1
  381. package/lib/state/createGlobalState.d.ts +1 -2
  382. package/lib/state/createGlobalState.js +9 -34
  383. package/lib/state/createGlobalState.js.map +1 -1
  384. package/lib/state/index.js +1 -1
  385. package/lib/state/stateContext.js +1 -1
  386. package/lib/state/stateContext.js.map +1 -1
  387. package/lib/state/withApi.d.ts +1 -1
  388. package/lib/state/withApi.js +20 -105
  389. package/lib/state/withApi.js.map +1 -1
  390. package/lib/tools/codegen.d.ts +21 -0
  391. package/lib/tools/codegen.js +152 -0
  392. package/lib/tools/codegen.js.map +1 -0
  393. package/lib/tools/debugger.d.ts +4 -0
  394. package/lib/tools/debugger.js +58 -0
  395. package/lib/tools/debugger.js.map +1 -0
  396. package/lib/tools/emulator.d.ts +3 -0
  397. package/lib/tools/emulator.js +15 -0
  398. package/lib/tools/emulator.js.map +1 -0
  399. package/lib/types/api.d.ts +34 -9
  400. package/lib/types/common.d.ts +11 -11
  401. package/lib/types/components.d.ts +74 -8
  402. package/lib/types/config.d.ts +24 -17
  403. package/lib/types/data.d.ts +2 -2
  404. package/lib/types/extension.d.ts +31 -4
  405. package/lib/types/index.d.ts +1 -0
  406. package/lib/types/index.js +2 -1
  407. package/lib/types/index.js.map +1 -1
  408. package/lib/types/instance.d.ts +26 -4
  409. package/lib/types/layout.d.ts +3 -3
  410. package/lib/types/navigation.d.ts +94 -0
  411. package/lib/types/navigation.js +3 -0
  412. package/lib/types/navigation.js.map +1 -0
  413. package/lib/types/plugin.d.ts +1 -14
  414. package/lib/types/state.d.ts +66 -27
  415. package/lib/types/utils.d.ts +1 -1
  416. package/lib/utils/compare.d.ts +1 -1
  417. package/lib/utils/compare.js +26 -9
  418. package/lib/utils/compare.js.map +1 -1
  419. package/lib/utils/data.js +6 -7
  420. package/lib/utils/data.js.map +1 -1
  421. package/lib/utils/extension.d.ts +16 -0
  422. package/lib/utils/extension.js +42 -0
  423. package/lib/utils/extension.js.map +1 -0
  424. package/lib/utils/foreign.d.ts +7 -2
  425. package/lib/utils/foreign.js +25 -12
  426. package/lib/utils/foreign.js.map +1 -1
  427. package/lib/utils/guid.js +3 -3
  428. package/lib/utils/guid.js.map +1 -1
  429. package/lib/utils/helpers.d.ts +11 -8
  430. package/lib/utils/helpers.js +31 -18
  431. package/lib/utils/helpers.js.map +1 -1
  432. package/lib/utils/index.d.ts +3 -1
  433. package/lib/utils/index.js +7 -2
  434. package/lib/utils/index.js.map +1 -1
  435. package/lib/utils/media.js +7 -7
  436. package/lib/utils/media.js.map +1 -1
  437. package/lib/utils/react.js +1 -1
  438. package/lib/utils/react.js.map +1 -1
  439. package/lib/utils/state.d.ts +57 -0
  440. package/lib/utils/state.js +94 -0
  441. package/lib/utils/state.js.map +1 -0
  442. package/lib/utils/storage.js +11 -12
  443. package/lib/utils/storage.js.map +1 -1
  444. package/package.json +51 -20
  445. package/src/Piral.test.tsx +7 -16
  446. package/src/Piral.tsx +12 -11
  447. package/src/PiralContext.tsx +43 -0
  448. package/src/RootListener.test.tsx +46 -0
  449. package/src/RootListener.tsx +26 -0
  450. package/src/actions/app.test.ts +114 -44
  451. package/src/actions/app.ts +33 -23
  452. package/src/actions/components.test.ts +11 -11
  453. package/src/actions/components.ts +5 -33
  454. package/src/actions/data.test.ts +50 -50
  455. package/src/actions/define.test.ts +2 -2
  456. package/src/actions/portal.test.ts +62 -17
  457. package/src/actions/portal.ts +19 -1
  458. package/src/actions/state.test.ts +3 -3
  459. package/src/actions/state.ts +8 -4
  460. package/src/components/ErrorBoundary.tsx +22 -49
  461. package/src/components/ExtensionSlot.test.tsx +115 -30
  462. package/src/components/ExtensionSlot.tsx +57 -18
  463. package/src/components/ForeignComponentContainer.test.tsx +100 -0
  464. package/src/components/ForeignComponentContainer.tsx +63 -0
  465. package/src/components/Mediator.test.tsx +16 -14
  466. package/src/components/Mediator.tsx +17 -9
  467. package/src/components/PiralGlobals.tsx +16 -0
  468. package/src/components/PiralRoutes.test.tsx +65 -57
  469. package/src/components/PiralRoutes.tsx +10 -17
  470. package/src/components/PiralSuspense.tsx +19 -0
  471. package/src/components/PiralView-server.test.tsx +61 -0
  472. package/src/components/PiralView.test.tsx +27 -26
  473. package/src/components/PiralView.tsx +28 -35
  474. package/src/components/PortalRenderer.tsx +12 -0
  475. package/src/components/ResponsiveLayout.test.tsx +18 -37
  476. package/src/components/ResponsiveLayout.tsx +18 -15
  477. package/src/components/SwitchErrorInfo.test.tsx +36 -0
  478. package/src/components/SwitchErrorInfo.tsx +5 -1
  479. package/src/components/components.tsx +20 -6
  480. package/src/components/index.ts +4 -10
  481. package/src/components/wrapComponent.tsx +74 -0
  482. package/src/createInstance.test.tsx +10 -0
  483. package/src/createInstance.tsx +19 -14
  484. package/src/{components → defaults}/DefaultErrorInfo.test.tsx +15 -18
  485. package/src/{components → defaults}/DefaultErrorInfo.tsx +2 -3
  486. package/src/defaults/DefaultLayout.test.tsx +23 -0
  487. package/src/defaults/DefaultLoadingIndicator.test.tsx +10 -0
  488. package/src/defaults/DefaultRouteSwitch_v5.tsx +15 -0
  489. package/src/defaults/DefaultRouteSwitch_v6.tsx +20 -0
  490. package/src/defaults/DefaultRouter_v5.tsx +8 -0
  491. package/src/defaults/DefaultRouter_v6.tsx +8 -0
  492. package/src/defaults/navigator_none.tsx +35 -0
  493. package/src/defaults/navigator_v5.tsx +99 -0
  494. package/src/defaults/navigator_v6.tsx +96 -0
  495. package/src/helpers.test.tsx +30 -49
  496. package/src/helpers.tsx +31 -108
  497. package/src/hooks/action.ts +2 -3
  498. package/src/hooks/globalState.ts +10 -9
  499. package/src/hooks/index.ts +2 -5
  500. package/src/hooks/media.ts +2 -1
  501. package/src/hooks/piletApi.ts +14 -0
  502. package/src/hooks/routes.ts +14 -0
  503. package/src/hooks/setter-server.test.ts +22 -0
  504. package/src/hooks/setter.test.ts +18 -0
  505. package/src/hooks/setter.ts +2 -1
  506. package/src/index.tsx +3 -1
  507. package/src/modules/api.test.ts +15 -26
  508. package/src/modules/api.ts +3 -66
  509. package/src/modules/core.test.ts +148 -0
  510. package/src/modules/core.ts +52 -0
  511. package/src/modules/dependencies.test.ts +16 -5
  512. package/src/modules/dependencies.ts +13 -31
  513. package/src/modules/element-server.test.ts +29 -0
  514. package/src/modules/element.test.ts +67 -0
  515. package/src/modules/element.ts +212 -0
  516. package/src/modules/index.ts +1 -0
  517. package/src/{components → setters}/SetComponent.test.tsx +9 -8
  518. package/src/{components → setters}/SetComponent.tsx +2 -2
  519. package/src/{components → setters}/SetError.test.tsx +9 -8
  520. package/src/{components → setters}/SetError.tsx +2 -2
  521. package/src/{components → setters}/SetErrors.test.tsx +9 -8
  522. package/src/{components → setters}/SetLayout.test.tsx +9 -8
  523. package/src/{components → setters}/SetProvider.test.tsx +9 -8
  524. package/src/{components → setters}/SetProvider.tsx +2 -2
  525. package/src/{components → setters}/SetRedirect.test.tsx +9 -8
  526. package/src/{components → setters}/SetRedirect.tsx +4 -4
  527. package/src/{components → setters}/SetRoute.test.tsx +9 -8
  528. package/src/{components → setters}/SetRoute.tsx +7 -4
  529. package/src/setters/index.ts +7 -0
  530. package/src/state/createActions.test.ts +2 -2
  531. package/src/state/createActions.ts +5 -3
  532. package/src/state/createGlobalState.test.ts +55 -54
  533. package/src/state/createGlobalState.ts +4 -28
  534. package/src/state/withApi.test.tsx +87 -40
  535. package/src/state/withApi.tsx +31 -165
  536. package/src/tools/codegen.ts +193 -0
  537. package/src/tools/debugger.ts +84 -0
  538. package/src/tools/emulator.ts +13 -0
  539. package/src/types/api.ts +47 -10
  540. package/src/types/components.ts +76 -7
  541. package/src/types/config.ts +23 -17
  542. package/src/types/extension.ts +38 -5
  543. package/src/types/index.ts +1 -0
  544. package/src/types/instance.ts +28 -4
  545. package/src/types/navigation.ts +101 -0
  546. package/src/types/plugin.ts +1 -15
  547. package/src/types/state.ts +65 -25
  548. package/src/types/utils.ts +1 -1
  549. package/src/utils/compare.test.ts +15 -15
  550. package/src/utils/compare.ts +23 -3
  551. package/src/utils/extension.test.tsx +21 -0
  552. package/src/utils/extension.tsx +48 -0
  553. package/src/utils/foreign.test.ts +29 -11
  554. package/src/utils/foreign.ts +34 -7
  555. package/src/utils/guid.test.ts +6 -1
  556. package/src/utils/helpers.test.ts +52 -0
  557. package/src/utils/helpers.ts +22 -8
  558. package/src/utils/index.ts +4 -1
  559. package/src/utils/media-server.test.ts +13 -0
  560. package/src/utils/media.ts +2 -2
  561. package/src/utils/state.test.ts +37 -0
  562. package/src/utils/state.ts +131 -0
  563. package/dependencies.codegen +0 -9
  564. package/dependencies.codegen.native.js +0 -2
  565. package/esm/components/DefaultErrorInfo.js +0 -12
  566. package/esm/components/DefaultErrorInfo.js.map +0 -1
  567. package/esm/components/DefaultLayout.js.map +0 -1
  568. package/esm/components/DefaultLoader.js.map +0 -1
  569. package/esm/components/SetComponent.js +0 -12
  570. package/esm/components/SetComponent.js.map +0 -1
  571. package/esm/components/SetError.js +0 -12
  572. package/esm/components/SetError.js.map +0 -1
  573. package/esm/components/SetErrors.js +0 -10
  574. package/esm/components/SetErrors.js.map +0 -1
  575. package/esm/components/SetLayout.js +0 -10
  576. package/esm/components/SetLayout.js.map +0 -1
  577. package/esm/components/SetProvider.js +0 -12
  578. package/esm/components/SetProvider.js.map +0 -1
  579. package/esm/components/SetRedirect.js +0 -14
  580. package/esm/components/SetRedirect.js.map +0 -1
  581. package/esm/components/SetRoute.js +0 -12
  582. package/esm/components/SetRoute.js.map +0 -1
  583. package/esm/hooks/debounce.d.ts +0 -8
  584. package/esm/hooks/debounce.js +0 -18
  585. package/esm/hooks/debounce.js.map +0 -1
  586. package/esm/hooks/lockBodyScroll.d.ts +0 -6
  587. package/esm/hooks/lockBodyScroll.js +0 -13
  588. package/esm/hooks/lockBodyScroll.js.map +0 -1
  589. package/esm/hooks/onClickOutside.d.ts +0 -8
  590. package/esm/hooks/onClickOutside.js +0 -23
  591. package/esm/hooks/onClickOutside.js.map +0 -1
  592. package/esm/hooks/onScreenVisible.d.ts +0 -11
  593. package/esm/hooks/onScreenVisible.js +0 -28
  594. package/esm/hooks/onScreenVisible.js.map +0 -1
  595. package/esm/hooks/promise.d.ts +0 -13
  596. package/esm/hooks/promise.js +0 -21
  597. package/esm/hooks/promise.js.map +0 -1
  598. package/esm/utils/events.d.ts +0 -3
  599. package/esm/utils/events.js +0 -35
  600. package/esm/utils/events.js.map +0 -1
  601. package/lib/components/DefaultErrorInfo.js +0 -15
  602. package/lib/components/DefaultErrorInfo.js.map +0 -1
  603. package/lib/components/DefaultLayout.js.map +0 -1
  604. package/lib/components/DefaultLoader.js.map +0 -1
  605. package/lib/components/SetComponent.js +0 -16
  606. package/lib/components/SetComponent.js.map +0 -1
  607. package/lib/components/SetError.js +0 -16
  608. package/lib/components/SetError.js.map +0 -1
  609. package/lib/components/SetErrors.js +0 -14
  610. package/lib/components/SetErrors.js.map +0 -1
  611. package/lib/components/SetLayout.js +0 -14
  612. package/lib/components/SetLayout.js.map +0 -1
  613. package/lib/components/SetProvider.js.map +0 -1
  614. package/lib/components/SetRedirect.js +0 -18
  615. package/lib/components/SetRedirect.js.map +0 -1
  616. package/lib/components/SetRoute.js +0 -16
  617. package/lib/components/SetRoute.js.map +0 -1
  618. package/lib/hooks/debounce.d.ts +0 -8
  619. package/lib/hooks/debounce.js +0 -22
  620. package/lib/hooks/debounce.js.map +0 -1
  621. package/lib/hooks/lockBodyScroll.d.ts +0 -6
  622. package/lib/hooks/lockBodyScroll.js +0 -17
  623. package/lib/hooks/lockBodyScroll.js.map +0 -1
  624. package/lib/hooks/onClickOutside.d.ts +0 -8
  625. package/lib/hooks/onClickOutside.js +0 -27
  626. package/lib/hooks/onClickOutside.js.map +0 -1
  627. package/lib/hooks/onScreenVisible.d.ts +0 -11
  628. package/lib/hooks/onScreenVisible.js +0 -32
  629. package/lib/hooks/onScreenVisible.js.map +0 -1
  630. package/lib/hooks/promise.d.ts +0 -13
  631. package/lib/hooks/promise.js +0 -25
  632. package/lib/hooks/promise.js.map +0 -1
  633. package/lib/utils/events.d.ts +0 -3
  634. package/lib/utils/events.js +0 -39
  635. package/lib/utils/events.js.map +0 -1
  636. package/src/components/DefaultLayout.test.tsx +0 -23
  637. package/src/components/DefaultLoader.test.tsx +0 -10
  638. package/src/hooks/debounce.test.ts +0 -67
  639. package/src/hooks/debounce.ts +0 -19
  640. package/src/hooks/globalState.test.ts +0 -47
  641. package/src/hooks/lockBodyScroll.test.ts +0 -24
  642. package/src/hooks/lockBodyScroll.ts +0 -13
  643. package/src/hooks/onClickOutside.test.ts +0 -113
  644. package/src/hooks/onClickOutside.ts +0 -25
  645. package/src/hooks/onScreenVisible.test.ts +0 -68
  646. package/src/hooks/onScreenVisible.ts +0 -28
  647. package/src/hooks/promise.test.ts +0 -76
  648. package/src/hooks/promise.ts +0 -35
  649. package/src/utils/events.test.ts +0 -65
  650. package/src/utils/events.ts +0 -39
  651. package/esm/{components → defaults}/DefaultErrorInfo.d.ts +0 -0
  652. package/esm/{components → defaults}/DefaultLayout.d.ts +0 -0
  653. package/esm/{components/DefaultLoader.d.ts → defaults/DefaultLoadingIndicator.d.ts} +0 -0
  654. package/esm/{components → setters}/SetComponent.d.ts +0 -0
  655. package/esm/{components → setters}/SetError.d.ts +0 -0
  656. package/esm/{components → setters}/SetErrors.d.ts +0 -0
  657. package/esm/{components → setters}/SetLayout.d.ts +0 -0
  658. package/esm/{components → setters}/SetProvider.d.ts +0 -0
  659. package/esm/{components → setters}/SetRedirect.d.ts +0 -0
  660. package/lib/{components → defaults}/DefaultErrorInfo.d.ts +0 -0
  661. package/lib/{components → defaults}/DefaultLayout.d.ts +0 -0
  662. package/lib/{components/DefaultLoader.d.ts → defaults/DefaultLoadingIndicator.d.ts} +0 -0
  663. package/lib/{components → setters}/SetComponent.d.ts +0 -0
  664. package/lib/{components → setters}/SetError.d.ts +0 -0
  665. package/lib/{components → setters}/SetErrors.d.ts +0 -0
  666. package/lib/{components → setters}/SetLayout.d.ts +0 -0
  667. package/lib/{components → setters}/SetProvider.d.ts +0 -0
  668. package/lib/{components → setters}/SetRedirect.d.ts +0 -0
  669. package/src/{components → defaults}/DefaultLayout.tsx +1 -1
  670. /package/src/{components/DefaultLoader.tsx → defaults/DefaultLoadingIndicator.tsx} +0 -0
  671. /package/src/{components → setters}/SetErrors.tsx +0 -0
  672. /package/src/{components → setters}/SetLayout.tsx +0 -0
@@ -1,114 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.withApi = void 0;
4
- var tslib_1 = require("tslib");
5
- var React = require("react");
6
- var piral_base_1 = require("piral-base");
7
- var react_router_1 = require("react-router");
8
- var stateContext_1 = require("./stateContext");
9
- var components_1 = require("../components");
10
- var hooks_1 = require("../hooks");
11
- var utils_1 = require("../utils");
12
- var portalIdBase = 123456;
13
- var PortalRenderer = function (_a) {
14
- var id = _a.id;
15
- var children = hooks_1.useGlobalState(function (m) { return m.portals[id] || []; });
16
- return utils_1.defaultRender(children);
17
- };
18
- var DefaultWrapper = function (props) { return React.createElement(React.Fragment, null, props.children); };
19
- var ForeignComponentContainer = /** @class */ (function (_super) {
20
- tslib_1.__extends(ForeignComponentContainer, _super);
21
- function ForeignComponentContainer() {
22
- return _super !== null && _super.apply(this, arguments) || this;
4
+ const React = require("react");
5
+ const components_1 = require("../components");
6
+ const utils_1 = require("../utils");
7
+ const DefaultWrapper = (props) => (0, utils_1.defaultRender)(props.children);
8
+ function getWrapper(wrappers, wrapperType) {
9
+ const WrapAll = wrappers['*'];
10
+ const WrapType = wrappers[wrapperType];
11
+ if (WrapAll && WrapType) {
12
+ return (props) => (React.createElement(WrapAll, Object.assign({}, props),
13
+ React.createElement(WrapType, Object.assign({}, props))));
23
14
  }
24
- ForeignComponentContainer.prototype.componentDidMount = function () {
25
- var node = this.current;
26
- var _a = this.props, $component = _a.$component, $context = _a.$context, innerProps = _a.innerProps;
27
- var mount = $component.mount;
28
- if (node && piral_base_1.isfunc(mount)) {
29
- mount(node, innerProps, $context);
30
- }
31
- this.previous = node;
32
- };
33
- ForeignComponentContainer.prototype.componentDidUpdate = function () {
34
- var _a = this, current = _a.current, previous = _a.previous;
35
- var _b = this.props, $component = _b.$component, $context = _b.$context, innerProps = _b.innerProps;
36
- var update = $component.update;
37
- if (current !== previous) {
38
- previous && this.componentWillUnmount();
39
- current && this.componentDidMount();
40
- }
41
- else if (piral_base_1.isfunc(update)) {
42
- update(current, innerProps, $context);
43
- }
44
- };
45
- ForeignComponentContainer.prototype.componentWillUnmount = function () {
46
- var node = this.previous;
47
- var $component = this.props.$component;
48
- var unmount = $component.unmount;
49
- if (node && piral_base_1.isfunc(unmount)) {
50
- unmount(node);
51
- }
52
- this.previous = undefined;
53
- };
54
- ForeignComponentContainer.prototype.render = function () {
55
- var _this = this;
56
- var $portalId = this.props.$portalId;
57
- return (React.createElement("div", { "data-portal-id": $portalId, ref: function (node) {
58
- _this.current = node;
59
- } }));
60
- };
61
- return ForeignComponentContainer;
62
- }(React.Component));
63
- function wrapReactComponent(Component, stasisOptions, piral, Wrapper) {
64
- return function (props) { return (React.createElement(Wrapper, tslib_1.__assign({}, props, { piral: piral }),
65
- React.createElement(components_1.ErrorBoundary, tslib_1.__assign({}, stasisOptions, { renderProps: props }),
66
- React.createElement(Component, tslib_1.__assign({}, props, { piral: piral }))))); };
15
+ return WrapType || WrapAll || DefaultWrapper;
67
16
  }
68
- function wrapForeignComponent(component, stasisOptions, piral, Wrapper) {
69
- return function (props) {
70
- var destroyPortal = hooks_1.useActions().destroyPortal;
71
- var id = React.useState(function () { return (portalIdBase++).toString(26); })[0];
72
- var router = React.useContext(react_router_1.__RouterContext);
73
- var state = React.useContext(stateContext_1.StateContext).state;
74
- var innerProps = tslib_1.__assign(tslib_1.__assign({}, props), { piral: piral });
75
- React.useEffect(function () { return function () { return destroyPortal(id); }; }, []);
76
- return (React.createElement(Wrapper, tslib_1.__assign({}, innerProps),
77
- React.createElement(components_1.ErrorBoundary, tslib_1.__assign({}, stasisOptions, { renderProps: props }),
78
- React.createElement(PortalRenderer, { id: id }),
79
- React.createElement(ForeignComponentContainer, { innerProps: innerProps, "$portalId": id, "$component": component, "$context": { router: router, state: state } }))));
80
- };
17
+ function makeWrapper(context, outerProps, wrapperType, errorType) {
18
+ const OuterWrapper = context.readState((m) => getWrapper(m.registry.wrappers, wrapperType));
19
+ return (props) => (React.createElement(OuterWrapper, Object.assign({}, outerProps, props),
20
+ React.createElement(components_1.ErrorBoundary, Object.assign({}, outerProps, props, { errorType: errorType }), props.children)));
81
21
  }
82
- function isNotExotic(component) {
83
- return !component.$$typeof;
84
- }
85
- function wrapComponent(converters, component, piral, Wrapper, stasisOptions) {
86
- if (!component) {
87
- console.error('The given value is not a valid component.');
88
- // tslint:disable-next-line:no-null-keyword
89
- component = function () { return null; };
90
- }
91
- if (typeof component === 'object' && isNotExotic(component)) {
92
- var result = utils_1.convertComponent(converters[component.type], component);
93
- return wrapForeignComponent(result, stasisOptions, piral, Wrapper);
94
- }
95
- return wrapReactComponent(component, stasisOptions, piral, Wrapper);
96
- }
97
- function withApi(context, component, piral, errorType, wrapperType) {
98
- if (wrapperType === void 0) { wrapperType = errorType; }
99
- var converters = context.converters;
100
- var Wrapper = context.readState(function (m) { return m.registry.wrappers[wrapperType]; }) || DefaultWrapper;
101
- return wrapComponent(converters, component, piral, Wrapper, {
102
- onError: function (error) {
103
- console.error(piral, error);
104
- },
105
- renderChild: function (child) {
106
- return React.createElement(React.Suspense, { fallback: React.createElement(components_1.PiralLoadingIndicator, null) }, child);
107
- },
108
- renderError: function (error, props) {
109
- return React.createElement(components_1.PiralError, tslib_1.__assign({ type: errorType, error: error }, props));
110
- },
111
- });
22
+ function withApi(context, component, piral, errorType, wrapperType = errorType, captured = {}) {
23
+ const outerProps = Object.assign(Object.assign({}, captured), { piral });
24
+ const converters = context.converters;
25
+ const Wrapper = makeWrapper(context, outerProps, wrapperType, errorType);
26
+ return (0, components_1.wrapComponent)(converters, component, outerProps, Wrapper);
112
27
  }
113
28
  exports.withApi = withApi;
114
29
  //# sourceMappingURL=withApi.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"withApi.js","sourceRoot":"","sources":["../../src/state/withApi.tsx"],"names":[],"mappings":";;;;AAAA,6BAA+B;AAC/B,yCAAoC;AACpC,6CAA+C;AAC/C,+CAA8C;AAC9C,4CAAuG;AACvG,kCAAsD;AACtD,kCAA2D;AAY3D,IAAI,YAAY,GAAG,MAAM,CAAC;AAM1B,IAAM,cAAc,GAAkC,UAAC,EAAM;QAAJ,EAAE,QAAA;IACzD,IAAM,QAAQ,GAAG,sBAAc,CAAC,UAAC,CAAC,IAAK,OAAA,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,EAAnB,CAAmB,CAAC,CAAC;IAC5D,OAAO,qBAAa,CAAC,QAAQ,CAAC,CAAC;AACjC,CAAC,CAAC;AAEF,IAAM,cAAc,GAAa,UAAC,KAAK,IAAK,OAAA,0CAAG,KAAK,CAAC,QAAQ,CAAI,EAArB,CAAqB,CAAC;AASlE;IAA2C,qDAAkD;IAA7F;;IAqDA,CAAC;IAjDC,qDAAiB,GAAjB;QACE,IAAM,IAAI,GAAG,IAAI,CAAC,OAAO,CAAC;QACpB,IAAA,KAAuC,IAAI,CAAC,KAAK,EAA/C,UAAU,gBAAA,EAAE,QAAQ,cAAA,EAAE,UAAU,gBAAe,CAAC;QAChD,IAAA,KAAK,GAAK,UAAU,MAAf,CAAgB;QAE7B,IAAI,IAAI,IAAI,mBAAM,CAAC,KAAK,CAAC,EAAE;YACzB,KAAK,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,CAAC,CAAC;SACnC;Q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oBAAK,UAAU,EAAM,KAAK,IAAE,SAAS,EAAE,SAAS,KAC3D,KAAK,CAAC,QAAQ,CACD,CACH,CAChB,CAAC;AACJ,CAAC;AAED,SAAgB,OAAO,CACrB,OAA2B,EAC3B,SAAoD,EACpD,KAAe,EACf,SAAuB,EACvB,cAAsB,SAAS,EAC/B,QAAQ,GAAG,EAAE;IAEb,MAAM,UAAU,mCAAQ,QAAQ,KAAE,KAAK,GAAE,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IACtC,MAAM,OAAO,GAAG,WAAW,CAAS,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,CAAC,CAAC;IACjF,OAAO,IAAA,0BAAa,EAAC,UAAU,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAZD,0BAYC"}
@@ -0,0 +1,21 @@
1
+ interface CodegenOptions {
2
+ root: string;
3
+ cat: string;
4
+ appName: string;
5
+ externals: Array<string>;
6
+ publicPath: string;
7
+ debug?: {
8
+ viewState?: boolean;
9
+ loadPilets?: boolean;
10
+ hardRefresh?: boolean;
11
+ viewOrigins?: boolean;
12
+ extensionCatalogue?: boolean;
13
+ clearConsole?: boolean;
14
+ };
15
+ emulator: boolean;
16
+ }
17
+ export declare function createDependencies(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
18
+ export declare function createDefaultState(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
19
+ export declare function createDebugHandler(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
20
+ export declare function createRouteHandler(imports: Array<string>, exports: Array<string>, opts: CodegenOptions): void;
21
+ export {};
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createRouteHandler = exports.createDebugHandler = exports.createDefaultState = exports.createDependencies = void 0;
4
+ // this file is bundled, so the references here will not be at runtime (i.e., for a user)
5
+ const resolve_1 = require("piral-cli/src/external/resolve");
6
+ function getRouterVersion(root) {
7
+ const router = 'react-router';
8
+ try {
9
+ const modulePath = (0, resolve_1.getModulePath)(root, `${router}/package.json`);
10
+ const { version } = require(modulePath);
11
+ const [major] = version.split('.');
12
+ return parseInt(major, 10);
13
+ }
14
+ catch (_a) {
15
+ console.warn(`⚠ Could not determine version of ${router}. Falling back to v5.`);
16
+ return 5;
17
+ }
18
+ }
19
+ function getIdentifiers(root, packageName) {
20
+ const packageJson = `${packageName}/package.json`;
21
+ const identifiers = [packageName];
22
+ try {
23
+ const modulePath = (0, resolve_1.getModulePath)(root, packageJson);
24
+ const details = require(modulePath);
25
+ if (details.version) {
26
+ identifiers.push(`${packageName}@${details.version}`);
27
+ if (details.name !== packageName) {
28
+ identifiers.push(`${details.name}@${details.version}`);
29
+ }
30
+ }
31
+ }
32
+ catch (_a) { }
33
+ return identifiers;
34
+ }
35
+ function getModulePathOrDefault(root, name) {
36
+ try {
37
+ return (0, resolve_1.getModulePath)(root, name);
38
+ }
39
+ catch (_a) {
40
+ return name;
41
+ }
42
+ }
43
+ function createDependencies(imports, exports, opts) {
44
+ const { root, appName, externals } = opts;
45
+ const assignments = [];
46
+ if (appName) {
47
+ assignments.push(`deps['${appName}']={}`);
48
+ }
49
+ for (const name of externals) {
50
+ const identifiers = getIdentifiers(root, name);
51
+ const path = getModulePathOrDefault(root, name);
52
+ const ref = `_${imports.length}`;
53
+ imports.push(`import * as ${ref} from ${JSON.stringify(path)}`);
54
+ for (const id of identifiers) {
55
+ assignments.push(`deps[${JSON.stringify(id)}]=${ref}`);
56
+ }
57
+ }
58
+ exports.push(`
59
+ export function fillDependencies(deps) {
60
+ ${assignments.join(';')}
61
+ }
62
+ `);
63
+ }
64
+ exports.createDependencies = createDependencies;
65
+ function createDefaultState(imports, exports, opts) {
66
+ const { root, cat, publicPath } = opts;
67
+ const routerVersion = getRouterVersion(root);
68
+ imports.push(`import { DefaultErrorInfo } from 'piral-core/${cat}/defaults/DefaultErrorInfo';`, `import { DefaultLoadingIndicator } from 'piral-core/${cat}/defaults/DefaultLoadingIndicator';`, `import { DefaultLayout } from 'piral-core/${cat}/defaults/DefaultLayout';`);
69
+ if (routerVersion < 6) {
70
+ imports.push(`import { DefaultRouter } from 'piral-core/${cat}/defaults/DefaultRouter_v5';`, `import { DefaultRouteSwitch } from 'piral-core/${cat}/defaults/DefaultRouteSwitch_v5';`, `import { createRedirect, createNavigation, useCurrentNavigation, useRouterContext } from 'piral-core/${cat}/defaults/navigator_v5'`);
71
+ }
72
+ else {
73
+ imports.push(`import { DefaultRouter } from 'piral-core/${cat}/defaults/DefaultRouter_v6';`, `import { DefaultRouteSwitch } from 'piral-core/${cat}/defaults/DefaultRouteSwitch_v6';`, `import { createRedirect, createNavigation, useCurrentNavigation, useRouterContext } from 'piral-core/${cat}/defaults/navigator_v6'`);
74
+ }
75
+ exports.push(`
76
+ export { createRedirect, createNavigation, useRouterContext };
77
+ `);
78
+ exports.push(`
79
+ export const publicPath = ${JSON.stringify(publicPath)};
80
+ `);
81
+ exports.push(`
82
+ export function createDefaultState() {
83
+ return {
84
+ app: {
85
+ error: undefined,
86
+ loading: typeof window !== 'undefined',
87
+ },
88
+ components: {
89
+ ErrorInfo: DefaultErrorInfo,
90
+ LoadingIndicator: DefaultLoadingIndicator,
91
+ Router: DefaultRouter,
92
+ RouteSwitch: DefaultRouteSwitch,
93
+ Layout: DefaultLayout,
94
+ },
95
+ errorComponents: {},
96
+ registry: {
97
+ extensions: {},
98
+ pages: {},
99
+ wrappers: {},
100
+ },
101
+ routes: {},
102
+ data: {},
103
+ portals: {},
104
+ modules: [],
105
+ };
106
+ }
107
+ `);
108
+ }
109
+ exports.createDefaultState = createDefaultState;
110
+ function createDebugHandler(imports, exports, opts) {
111
+ const { cat, debug, emulator } = opts;
112
+ // if we build the debug version of piral (debug and emulator build)
113
+ if (debug) {
114
+ const originalCall = `originalDebugger(context, options, { defaultSettings: ${JSON.stringify(debug)}, ...debug })`;
115
+ imports.push(`import { integrateDebugger as originalDebugger } from "piral-core/${cat}/tools/debugger"`);
116
+ exports.push(`export function integrateDebugger(context, options, debug) { return ${originalCall}; }`);
117
+ }
118
+ else {
119
+ exports.push(`export function integrateDebugger() {}`);
120
+ }
121
+ // if we build the emulator version of piral (shipped to pilets)
122
+ if (emulator) {
123
+ imports.push(`import { integrateEmulator } from "piral-core/${cat}/tools/emulator"`);
124
+ exports.push(`export { integrateEmulator }`);
125
+ }
126
+ else {
127
+ exports.push(`export function integrateEmulator() {}`);
128
+ }
129
+ }
130
+ exports.createDebugHandler = createDebugHandler;
131
+ function createRouteHandler(imports, exports, opts) {
132
+ const { cat, emulator } = opts;
133
+ const assignments = [];
134
+ imports.push(`import { useGlobalStateContext } from 'piral-core/${cat}/hooks/globalState';`);
135
+ assignments.push(`
136
+ useCurrentNavigation();
137
+ `);
138
+ if (emulator) {
139
+ imports.push(`import { useDebugRouteFilter } from 'piral-debug-utils';`);
140
+ assignments.push('return useDebugRouteFilter(paths);');
141
+ }
142
+ else {
143
+ assignments.push('return paths;');
144
+ }
145
+ exports.push(`
146
+ export function useRouteFilter(paths) {
147
+ ${assignments.join('\n')}
148
+ }
149
+ `);
150
+ }
151
+ exports.createRouteHandler = createRouteHandler;
152
+ //# sourceMappingURL=codegen.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"codegen.js","sourceRoot":"","sources":["../../src/tools/codegen.ts"],"names":[],"mappings":";;;AAAA,yFAAyF;AACzF,4DAA+D;AAE/D,SAAS,gBAAgB,CAAC,IAAY;IACpC,MAAM,MAAM,GAAG,cAAc,CAAC;IAE9B,IAAI;QACF,MAAM,UAAU,GAAG,IAAA,uBAAa,EAAC,IAAI,EAAE,GAAG,MAAM,eAAe,CAAC,CAAC;QACjE,MAAM,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;QACxC,MAAM,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACnC,OAAO,QAAQ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O,CAAC,IAAI,CAAC,0DAA0D,CAAC,CAAC;QACzE,WAAW,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;KACxD;SAAM;QACL,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;KACnC;IAED,OAAO,CAAC,IAAI,CAAC;;QAEP,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC;;GAE3B,CAAC,CAAC;AACL,CAAC;AAtBD,gDAsBC"}
@@ -0,0 +1,4 @@
1
+ import { LoadPiletsOptions } from 'piral-base';
2
+ import { DebuggerExtensionOptions } from 'piral-debug-utils';
3
+ import { GlobalStateContext } from '../types';
4
+ export declare function integrateDebugger(context: GlobalStateContext, options: LoadPiletsOptions, debug?: DebuggerExtensionOptions): void;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.integrateDebugger = void 0;
4
+ const piral_debug_utils_1 = require("piral-debug-utils");
5
+ function integrateDebugger(context, options, debug = {}) {
6
+ (0, piral_debug_utils_1.installPiralDebug)(Object.assign(Object.assign({}, debug), { addPilet: context.addPilet, removePilet: context.removePilet, updatePilet(pilet) {
7
+ if (!pilet.disabled) {
8
+ const { createApi } = options;
9
+ const newApi = createApi(pilet);
10
+ try {
11
+ context.injectPilet(pilet);
12
+ pilet.setup(newApi);
13
+ }
14
+ catch (error) {
15
+ console.error(error);
16
+ }
17
+ }
18
+ else {
19
+ context.injectPilet(pilet);
20
+ }
21
+ }, fireEvent: context.emit, getDependencies() {
22
+ return Object.keys(options.dependencies);
23
+ },
24
+ getExtensions() {
25
+ return context.readState((s) => Object.keys(s.registry.extensions));
26
+ },
27
+ getRoutes() {
28
+ const registeredRoutes = context.readState((state) => Object.keys(state.registry.pages));
29
+ const componentRoutes = context.readState((state) => Object.keys(state.routes));
30
+ return [...componentRoutes, ...registeredRoutes];
31
+ },
32
+ getGlobalState() {
33
+ return context.readState((s) => s);
34
+ },
35
+ navigate(path, state) {
36
+ return context.navigation.push(path, state);
37
+ },
38
+ getPilets() {
39
+ return context.readState((s) => s.modules);
40
+ },
41
+ integrate(dbg) {
42
+ context.dispatch((s) => (Object.assign(Object.assign({}, s), { components: Object.assign(Object.assign({}, s.components), dbg.components), routes: Object.assign(Object.assign({}, s.routes), dbg.routes), registry: Object.assign(Object.assign({}, s.registry), { wrappers: Object.assign(Object.assign({}, s.registry.wrappers), dbg.wrappers) }) })));
43
+ context.state.subscribe((current, previous) => {
44
+ const pilets = current.modules !== previous.modules;
45
+ const pages = current.registry.pages !== previous.registry.pages || current.routes !== previous.routes;
46
+ const extensions = current.registry.extensions !== previous.registry.extensions;
47
+ const state = current !== previous;
48
+ dbg.onChange(previous, current, {
49
+ pilets,
50
+ pages,
51
+ extensions,
52
+ state,
53
+ });
54
+ });
55
+ } }));
56
+ }
57
+ exports.integrateDebugger = integrateDebugger;
58
+ //# sourceMappingURL=debugger.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../src/tools/debugger.ts"],"names":[],"mappings":";;;AACA,yDAAgF;AAGhF,SAAgB,iBAAiB,CAC/B,OAA2B,EAC3B,OAA0B,EAC1B,QAAkC,EAAE;IAEpC,IAAA,qCAAiB,kCACZ,KAAK,KACR,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAC1B,WAAW,EAAE,OAAO,CAAC,WAAW,EAChC,WAAW,CAAC,KAAK;YACf,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;gBACnB,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC;gBAC9B,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;gBAEhC,IAAI;oBACF,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;oBAC3B,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;iBACrB;gBAAC,OAAO,KAAK,EAAE;oBACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;iBACtB;aACF;iBAAM;gB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AAU,GAEnB,MAAM,kCACD,CAAC,CAAC,MAAM,GACR,GAAG,CAAC,MAAM,GAEf,QAAQ,kCACH,CAAC,CAAC,QAAQ,KACb,QAAQ,kCACH,CAAC,CAAC,QAAQ,CAAC,QAAQ,GACnB,GAAG,CAAC,QAAQ,QAGnB,CAAC,CAAC;YAEJ,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;gBAC5C,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,KAAK,QAAQ,CAAC,OAAO,CAAC;gBACpD,MAAM,KAAK,GAAG,OAAO,CAAC,QAAQ,CAAC,KAAK,KAAK,QAAQ,CAAC,QAAQ,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM,CAAC;gBACvG,MAAM,UAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,UAAU,KAAK,QAAQ,CAAC,QAAQ,CAAC,UAAU,CAAC;gBAChF,MAAM,KAAK,GAAG,OAAO,KAAK,QAAQ,CAAC;gBACnC,GAAG,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,EAAE;oBAC9B,MAAM;oBACN,KAAK;oBACL,UAAU;oBACV,KAAK;iBACN,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,IACD,CAAC;AACL,CAAC;AA/ED,8CA+EC"}
@@ -0,0 +1,3 @@
1
+ import { LoadPiletsOptions } from 'piral-base';
2
+ import { GlobalStateContext } from '../types';
3
+ export declare function integrateEmulator(context: GlobalStateContext, options: LoadPiletsOptions): void;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.integrateEmulator = void 0;
4
+ const piral_debug_utils_1 = require("piral-debug-utils");
5
+ function integrateEmulator(context, options) {
6
+ (0, piral_debug_utils_1.installPiletEmulator)(options.fetchPilets, {
7
+ addPilet: context.addPilet,
8
+ removePilet: context.removePilet,
9
+ integrate(requester) {
10
+ options.fetchPilets = requester;
11
+ },
12
+ });
13
+ }
14
+ exports.integrateEmulator = integrateEmulator;
15
+ //# sourceMappingURL=emulator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"emulator.js","sourceRoot":"","sources":["../../src/tools/emulator.ts"],"names":[],"mappings":";;;AACA,yDAAyD;AAGzD,SAAgB,iBAAiB,CAAC,OAA2B,EAAE,OAA0B;IACvF,IAAA,wCAAoB,EAAC,OAAO,CAAC,WAAW,EAAE;QACxC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,SAAS,CAAC,SAAS;YACjB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;QAClC,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AARD,8CAQC"}
@@ -1,12 +1,12 @@
1
- import type { ReactElement } from 'react';
1
+ import type { ReactElement, ReactNode } from 'react';
2
2
  import type { RouteComponentProps } from 'react-router';
3
- import type { PiletApi, Pilet, PiletMetadata, EventEmitter, SinglePilet, MultiPilet } from 'piral-base';
3
+ import type { PiletApi, Pilet, PiletEntry, PiletEntries, PiletMetadata, EventEmitter, PiletLoader, PiletLoadingStrategy } from 'piral-base';
4
4
  import type { PiletCustomApi, PiralCustomPageMeta } from './custom';
5
5
  import type { AnyComponent } from './components';
6
- import type { ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
6
+ import type { ExtensionParams, ExtensionSlotProps, PiralExtensionSlotMap } from './extension';
7
7
  import type { SharedData, DataStoreOptions } from './data';
8
8
  import type { Disposable } from './utils';
9
- export { PiletApi, Pilet, PiletMetadata, EventEmitter, SinglePilet, MultiPilet };
9
+ export { PiletApi, Pilet, PiletMetadata, EventEmitter, PiletEntry, PiletEntries, PiletLoader, PiletLoadingStrategy };
10
10
  /**
11
11
  * The props that every registered component obtains.
12
12
  */
@@ -33,22 +33,47 @@ export interface ExtensionComponentProps<T> extends BaseComponentProps {
33
33
  * The provided parameters for showing the extension.
34
34
  */
35
35
  params: T extends keyof PiralExtensionSlotMap ? PiralExtensionSlotMap[T] : T extends string ? any : T;
36
+ /**
37
+ * The optional children to receive, if any.
38
+ */
39
+ children?: ReactNode;
40
+ }
41
+ /**
42
+ * The meta data registered for a page.
43
+ */
44
+ export interface PiralPageMeta extends PiralCustomPageMeta {
36
45
  }
37
46
  /**
38
47
  * The props that every registered page component obtains.
39
48
  */
40
- export interface RouteBaseProps<UrlParams = any, UrlState = any> extends RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {
49
+ export interface RouteBaseProps<UrlParams extends {
50
+ [K in keyof UrlParams]?: string;
51
+ } = {}, UrlState = any> extends RouteComponentProps<UrlParams, {}, UrlState>, BaseComponentProps {
41
52
  }
42
53
  /**
43
54
  * The props used by a page component.
44
55
  */
45
- export interface PageComponentProps<T = any, S = any> extends RouteBaseProps<T, S> {
56
+ export interface PageComponentProps<T extends {
57
+ [K in keyof T]?: string;
58
+ } = {}, S = any> extends RouteBaseProps<T, S> {
59
+ /**
60
+ * The meta data registered with the page.
61
+ */
62
+ meta: PiralPageMeta;
63
+ /**
64
+ * The children of the page.
65
+ */
66
+ children: ReactNode;
46
67
  }
47
68
  /**
48
69
  * The meta data registered for a page.
49
70
  */
50
71
  export interface PiralPageMeta extends PiralCustomPageMeta {
51
72
  }
73
+ /**
74
+ * Shorthand for the definition of an extension component.
75
+ */
76
+ export type AnyExtensionComponent<TName> = TName extends keyof PiralExtensionSlotMap ? AnyComponent<ExtensionComponentProps<TName>> : TName extends string ? AnyComponent<ExtensionComponentProps<any>> : AnyComponent<ExtensionComponentProps<TName>>;
52
77
  /**
53
78
  * Defines the Pilet API from piral-core.
54
79
  * This interface will be consumed by pilet developers so that their pilet can interact with the piral instance.
@@ -89,14 +114,14 @@ export interface PiletCoreApi {
89
114
  * @param Component The component to be rendered.
90
115
  * @param defaults Optionally, sets the default values for the expected data.
91
116
  */
92
- registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>, defaults?: TName): RegistrationDisposer;
117
+ registerExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>, defaults?: Partial<ExtensionParams<TName>>): RegistrationDisposer;
93
118
  /**
94
119
  * Unregisters a global extension component.
95
120
  * Only previously registered extension components can be unregistered.
96
121
  * @param name The name of the extension slot to unregister from.
97
122
  * @param Component The registered extension component to unregister.
98
123
  */
99
- unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyComponent<ExtensionComponentProps<TName>>): void;
124
+ unregisterExtension<TName>(name: TName extends string ? TName : string, Component: AnyExtensionComponent<TName>): void;
100
125
  /**
101
126
  * React component for displaying extensions for a given name.
102
127
  * @param props The extension's rendering props.
@@ -111,7 +136,7 @@ export interface PiletCoreApi {
111
136
  */
112
137
  renderHtmlExtension<TName>(element: HTMLElement | ShadowRoot, props: ExtensionSlotProps<TName>): Disposable;
113
138
  }
114
- declare module 'piral-base/lib/types' {
139
+ declare module 'piral-base/lib/types/runtime' {
115
140
  interface PiletApi extends PiletCustomApi, PiletCoreApi {
116
141
  }
117
142
  }
@@ -1,21 +1,21 @@
1
- export declare type ValuesOf<T> = T extends {
1
+ export type ValuesOf<T> = T extends {
2
2
  [_ in keyof T]: infer U;
3
3
  } ? U : never;
4
- export declare type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5
- export declare type RemainingArgs<T> = T extends (_: any, ...args: infer U) => any ? U : never;
6
- export declare type DeepPartial<T> = {
4
+ export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
5
+ export type RemainingArgs<T> = T extends (_: any, ...args: infer U) => any ? U : never;
6
+ export type DeepPartial<T> = {
7
7
  [P in keyof T]?: T[P] extends Array<infer U> ? Array<DeepPartial<U>> : T[P] extends {} ? DeepPartial<T[P]> : T[P];
8
8
  };
9
- export declare type NestedPartial<T> = {
9
+ export type NestedPartial<T> = {
10
10
  [P in keyof T]?: T[P] extends Array<infer U> ? Array<Partial<U>> : T[P] extends {} ? Partial<T[P]> : T[P];
11
11
  };
12
- export declare type Dict<T> = Record<string, T>;
13
- export declare type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
14
- export declare type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
15
- export declare type FirstParametersOf<T> = {
12
+ export type Dict<T> = Record<string, T>;
13
+ export type Without<T, K> = Pick<T, Exclude<keyof T, K>>;
14
+ export type FirstParameter<T extends (arg: any) => any> = T extends (arg: infer P) => any ? P : never;
15
+ export type FirstParametersOf<T> = {
16
16
  [K in keyof T]: T[K] extends (arg: any) => any ? FirstParameter<T[K]> : never;
17
17
  }[keyof T];
18
- export declare type UnionOf<T> = {
18
+ export type UnionOf<T> = {
19
19
  [K in keyof T]: T[K];
20
20
  }[keyof T];
21
- export declare type MaybeAsync<T> = T | (() => Promise<T>);
21
+ export type MaybeAsync<T> = T | (() => Promise<T>);