@myst-theme/jupyter 0.5.6 → 0.5.8

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 (317) hide show
  1. package/dist/BinderBadge.d.ts.map +1 -0
  2. package/dist/ClientOnly.d.ts.map +1 -0
  3. package/dist/ConnectionStatusTray.d.ts +4 -0
  4. package/dist/ConnectionStatusTray.d.ts.map +1 -0
  5. package/dist/ConnectionStatusTray.js +54 -0
  6. package/dist/ErrorTray.d.ts.map +1 -0
  7. package/dist/{esm/ErrorTray.js → ErrorTray.js} +1 -1
  8. package/dist/components.d.ts.map +1 -0
  9. package/dist/{esm/components.js → components.js} +1 -1
  10. package/dist/controls/ArticleCellControls.d.ts.map +1 -0
  11. package/dist/{esm/controls → controls}/ArticleCellControls.js +7 -3
  12. package/dist/{cjs/controls → controls}/Buttons.d.ts +4 -0
  13. package/dist/{cjs/controls → controls}/Buttons.d.ts.map +1 -1
  14. package/dist/{esm/controls → controls}/Buttons.js +67 -11
  15. package/dist/controls/NotebookCellControls.d.ts.map +1 -0
  16. package/dist/{esm/controls → controls}/NotebookCellControls.js +2 -2
  17. package/dist/controls/NotebookToolbar.d.ts.map +1 -0
  18. package/dist/{esm/controls → controls}/NotebookToolbar.js +9 -5
  19. package/dist/controls/Spinner.d.ts.map +1 -0
  20. package/dist/controls/index.d.ts +5 -0
  21. package/dist/controls/index.d.ts.map +1 -0
  22. package/dist/controls/index.js +4 -0
  23. package/dist/convertImages.d.ts.map +1 -0
  24. package/dist/decoration.d.ts.map +1 -0
  25. package/dist/{esm/decoration.js → decoration.js} +2 -2
  26. package/dist/embed.d.ts.map +1 -0
  27. package/dist/{esm/embed.js → embed.js} +1 -1
  28. package/dist/error.d.ts.map +1 -0
  29. package/dist/{esm/error.js → error.js} +2 -2
  30. package/dist/{types/execute → execute}/actions.d.ts +1 -1
  31. package/dist/execute/actions.d.ts.map +1 -0
  32. package/dist/execute/busy.d.ts.map +1 -0
  33. package/dist/{cjs/execute → execute}/hooks.d.ts +7 -7
  34. package/dist/execute/hooks.d.ts.map +1 -0
  35. package/dist/{esm/execute → execute}/hooks.js +3 -3
  36. package/dist/execute/index.d.ts +7 -0
  37. package/dist/execute/index.d.ts.map +1 -0
  38. package/dist/execute/index.js +6 -0
  39. package/dist/{types/execute → execute}/leaf.d.ts +3 -3
  40. package/dist/execute/leaf.d.ts.map +1 -0
  41. package/dist/{esm/execute → execute}/leaf.js +2 -2
  42. package/dist/{types/execute → execute}/provider.d.ts +2 -2
  43. package/dist/execute/provider.d.ts.map +1 -0
  44. package/dist/{esm/execute → execute}/provider.js +4 -4
  45. package/dist/execute/reducer.d.ts +4 -0
  46. package/dist/execute/reducer.d.ts.map +1 -0
  47. package/dist/{esm/execute → execute}/reducer.js +1 -1
  48. package/dist/{cjs/execute → execute}/selectors.d.ts +3 -3
  49. package/dist/execute/selectors.d.ts.map +1 -0
  50. package/dist/execute/types.d.ts.map +1 -0
  51. package/dist/{esm/execute → execute}/utils.d.ts +2 -2
  52. package/dist/execute/utils.d.ts.map +1 -0
  53. package/dist/figure.d.ts.map +1 -0
  54. package/dist/{esm/figure.js → figure.js} +1 -1
  55. package/dist/hooks.d.ts.map +1 -0
  56. package/dist/{esm/hooks.js → hooks.js} +1 -1
  57. package/dist/index.d.ts +16 -0
  58. package/dist/index.d.ts.map +1 -0
  59. package/dist/index.js +15 -0
  60. package/dist/jupyter.d.ts.map +1 -0
  61. package/dist/{esm/jupyter.js → jupyter.js} +4 -4
  62. package/dist/output.d.ts.map +1 -0
  63. package/dist/{esm/output.js → output.js} +4 -4
  64. package/dist/providers.d.ts +32 -0
  65. package/dist/providers.d.ts.map +1 -0
  66. package/dist/providers.js +38 -0
  67. package/dist/safe.d.ts.map +1 -0
  68. package/dist/{esm/safe.js → safe.js} +3 -3
  69. package/dist/stream.d.ts.map +1 -0
  70. package/dist/{esm/stream.js → stream.js} +2 -2
  71. package/dist/utils.d.ts.map +1 -0
  72. package/dist/{esm/utils.js → utils.js} +1 -1
  73. package/package.json +21 -20
  74. package/dist/cjs/BinderBadge.d.ts.map +0 -1
  75. package/dist/cjs/BinderBadge.js +0 -13
  76. package/dist/cjs/ClientOnly.d.ts.map +0 -1
  77. package/dist/cjs/ClientOnly.js +0 -13
  78. package/dist/cjs/ConnectionStatusTray.d.ts +0 -2
  79. package/dist/cjs/ConnectionStatusTray.d.ts.map +0 -1
  80. package/dist/cjs/ConnectionStatusTray.js +0 -56
  81. package/dist/cjs/ErrorTray.d.ts.map +0 -1
  82. package/dist/cjs/ErrorTray.js +0 -42
  83. package/dist/cjs/components.d.ts.map +0 -1
  84. package/dist/cjs/components.js +0 -41
  85. package/dist/cjs/controls/ArticleCellControls.d.ts.map +0 -1
  86. package/dist/cjs/controls/ArticleCellControls.js +0 -33
  87. package/dist/cjs/controls/Buttons.js +0 -70
  88. package/dist/cjs/controls/NotebookCellControls.d.ts.map +0 -1
  89. package/dist/cjs/controls/NotebookCellControls.js +0 -27
  90. package/dist/cjs/controls/NotebookToolbar.d.ts.map +0 -1
  91. package/dist/cjs/controls/NotebookToolbar.js +0 -47
  92. package/dist/cjs/controls/Spinner.d.ts.map +0 -1
  93. package/dist/cjs/controls/Spinner.js +0 -8
  94. package/dist/cjs/controls/index.d.ts +0 -5
  95. package/dist/cjs/controls/index.d.ts.map +0 -1
  96. package/dist/cjs/controls/index.js +0 -20
  97. package/dist/cjs/convertImages.d.ts.map +0 -1
  98. package/dist/cjs/convertImages.js +0 -70
  99. package/dist/cjs/decoration.d.ts.map +0 -1
  100. package/dist/cjs/decoration.js +0 -40
  101. package/dist/cjs/embed.d.ts.map +0 -1
  102. package/dist/cjs/embed.js +0 -14
  103. package/dist/cjs/error.d.ts.map +0 -1
  104. package/dist/cjs/error.js +0 -15
  105. package/dist/cjs/execute/actions.d.ts +0 -56
  106. package/dist/cjs/execute/actions.d.ts.map +0 -1
  107. package/dist/cjs/execute/actions.js +0 -50
  108. package/dist/cjs/execute/busy.d.ts.map +0 -1
  109. package/dist/cjs/execute/busy.js +0 -259
  110. package/dist/cjs/execute/hooks.d.ts.map +0 -1
  111. package/dist/cjs/execute/hooks.js +0 -311
  112. package/dist/cjs/execute/index.d.ts +0 -7
  113. package/dist/cjs/execute/index.d.ts.map +0 -1
  114. package/dist/cjs/execute/index.js +0 -22
  115. package/dist/cjs/execute/leaf.d.ts +0 -27
  116. package/dist/cjs/execute/leaf.d.ts.map +0 -1
  117. package/dist/cjs/execute/leaf.js +0 -160
  118. package/dist/cjs/execute/provider.d.ts +0 -35
  119. package/dist/cjs/execute/provider.d.ts.map +0 -1
  120. package/dist/cjs/execute/provider.js +0 -129
  121. package/dist/cjs/execute/reducer.d.ts +0 -4
  122. package/dist/cjs/execute/reducer.d.ts.map +0 -1
  123. package/dist/cjs/execute/reducer.js +0 -138
  124. package/dist/cjs/execute/selectors.d.ts.map +0 -1
  125. package/dist/cjs/execute/selectors.js +0 -99
  126. package/dist/cjs/execute/types.d.ts.map +0 -1
  127. package/dist/cjs/execute/types.js +0 -2
  128. package/dist/cjs/execute/utils.d.ts +0 -23
  129. package/dist/cjs/execute/utils.d.ts.map +0 -1
  130. package/dist/cjs/execute/utils.js +0 -63
  131. package/dist/cjs/figure.d.ts.map +0 -1
  132. package/dist/cjs/figure.js +0 -20
  133. package/dist/cjs/hooks.d.ts.map +0 -1
  134. package/dist/cjs/hooks.js +0 -122
  135. package/dist/cjs/index.d.ts +0 -16
  136. package/dist/cjs/index.d.ts.map +0 -1
  137. package/dist/cjs/index.js +0 -31
  138. package/dist/cjs/jupyter.d.ts.map +0 -1
  139. package/dist/cjs/jupyter.js +0 -111
  140. package/dist/cjs/output.d.ts.map +0 -1
  141. package/dist/cjs/output.js +0 -67
  142. package/dist/cjs/providers.d.ts +0 -28
  143. package/dist/cjs/providers.d.ts.map +0 -1
  144. package/dist/cjs/providers.js +0 -44
  145. package/dist/cjs/safe.d.ts.map +0 -1
  146. package/dist/cjs/safe.js +0 -79
  147. package/dist/cjs/stream.d.ts.map +0 -1
  148. package/dist/cjs/stream.js +0 -13
  149. package/dist/cjs/utils.d.ts.map +0 -1
  150. package/dist/cjs/utils.js +0 -179
  151. package/dist/esm/BinderBadge.d.ts +0 -4
  152. package/dist/esm/BinderBadge.d.ts.map +0 -1
  153. package/dist/esm/ClientOnly.d.ts +0 -5
  154. package/dist/esm/ClientOnly.d.ts.map +0 -1
  155. package/dist/esm/ConnectionStatusTray.d.ts +0 -2
  156. package/dist/esm/ConnectionStatusTray.d.ts.map +0 -1
  157. package/dist/esm/ConnectionStatusTray.js +0 -52
  158. package/dist/esm/ErrorTray.d.ts +0 -5
  159. package/dist/esm/ErrorTray.d.ts.map +0 -1
  160. package/dist/esm/components.d.ts +0 -9
  161. package/dist/esm/components.d.ts.map +0 -1
  162. package/dist/esm/controls/ArticleCellControls.d.ts +0 -10
  163. package/dist/esm/controls/ArticleCellControls.d.ts.map +0 -1
  164. package/dist/esm/controls/Buttons.d.ts +0 -47
  165. package/dist/esm/controls/Buttons.d.ts.map +0 -1
  166. package/dist/esm/controls/NotebookCellControls.d.ts +0 -10
  167. package/dist/esm/controls/NotebookCellControls.d.ts.map +0 -1
  168. package/dist/esm/controls/NotebookToolbar.d.ts +0 -4
  169. package/dist/esm/controls/NotebookToolbar.d.ts.map +0 -1
  170. package/dist/esm/controls/Spinner.d.ts +0 -4
  171. package/dist/esm/controls/Spinner.d.ts.map +0 -1
  172. package/dist/esm/controls/index.d.ts +0 -5
  173. package/dist/esm/controls/index.d.ts.map +0 -1
  174. package/dist/esm/controls/index.js +0 -4
  175. package/dist/esm/convertImages.d.ts +0 -3
  176. package/dist/esm/convertImages.d.ts.map +0 -1
  177. package/dist/esm/decoration.d.ts +0 -11
  178. package/dist/esm/decoration.d.ts.map +0 -1
  179. package/dist/esm/embed.d.ts +0 -5
  180. package/dist/esm/embed.d.ts.map +0 -1
  181. package/dist/esm/error.d.ts +0 -5
  182. package/dist/esm/error.d.ts.map +0 -1
  183. package/dist/esm/execute/actions.d.ts +0 -56
  184. package/dist/esm/execute/actions.d.ts.map +0 -1
  185. package/dist/esm/execute/busy.d.ts +0 -96
  186. package/dist/esm/execute/busy.d.ts.map +0 -1
  187. package/dist/esm/execute/hooks.d.ts +0 -65
  188. package/dist/esm/execute/hooks.d.ts.map +0 -1
  189. package/dist/esm/execute/index.d.ts +0 -7
  190. package/dist/esm/execute/index.d.ts.map +0 -1
  191. package/dist/esm/execute/index.js +0 -6
  192. package/dist/esm/execute/leaf.d.ts +0 -27
  193. package/dist/esm/execute/leaf.d.ts.map +0 -1
  194. package/dist/esm/execute/provider.d.ts +0 -35
  195. package/dist/esm/execute/provider.d.ts.map +0 -1
  196. package/dist/esm/execute/reducer.d.ts +0 -4
  197. package/dist/esm/execute/reducer.d.ts.map +0 -1
  198. package/dist/esm/execute/selectors.d.ts +0 -27
  199. package/dist/esm/execute/selectors.d.ts.map +0 -1
  200. package/dist/esm/execute/types.d.ts +0 -50
  201. package/dist/esm/execute/types.d.ts.map +0 -1
  202. package/dist/esm/execute/utils.d.ts.map +0 -1
  203. package/dist/esm/figure.d.ts +0 -5
  204. package/dist/esm/figure.d.ts.map +0 -1
  205. package/dist/esm/hooks.d.ts +0 -19
  206. package/dist/esm/hooks.d.ts.map +0 -1
  207. package/dist/esm/index.d.ts +0 -16
  208. package/dist/esm/index.d.ts.map +0 -1
  209. package/dist/esm/index.js +0 -15
  210. package/dist/esm/jupyter.d.ts +0 -7
  211. package/dist/esm/jupyter.d.ts.map +0 -1
  212. package/dist/esm/output.d.ts +0 -15
  213. package/dist/esm/output.d.ts.map +0 -1
  214. package/dist/esm/providers.d.ts +0 -28
  215. package/dist/esm/providers.d.ts.map +0 -1
  216. package/dist/esm/providers.js +0 -35
  217. package/dist/esm/safe.d.ts +0 -6
  218. package/dist/esm/safe.d.ts.map +0 -1
  219. package/dist/esm/stream.d.ts +0 -5
  220. package/dist/esm/stream.d.ts.map +0 -1
  221. package/dist/esm/utils.d.ts +0 -8
  222. package/dist/esm/utils.d.ts.map +0 -1
  223. package/dist/types/BinderBadge.d.ts +0 -4
  224. package/dist/types/BinderBadge.d.ts.map +0 -1
  225. package/dist/types/ClientOnly.d.ts +0 -5
  226. package/dist/types/ClientOnly.d.ts.map +0 -1
  227. package/dist/types/ConnectionStatusTray.d.ts +0 -2
  228. package/dist/types/ConnectionStatusTray.d.ts.map +0 -1
  229. package/dist/types/ErrorTray.d.ts +0 -5
  230. package/dist/types/ErrorTray.d.ts.map +0 -1
  231. package/dist/types/components.d.ts +0 -9
  232. package/dist/types/components.d.ts.map +0 -1
  233. package/dist/types/controls/ArticleCellControls.d.ts +0 -10
  234. package/dist/types/controls/ArticleCellControls.d.ts.map +0 -1
  235. package/dist/types/controls/Buttons.d.ts +0 -47
  236. package/dist/types/controls/Buttons.d.ts.map +0 -1
  237. package/dist/types/controls/NotebookCellControls.d.ts +0 -10
  238. package/dist/types/controls/NotebookCellControls.d.ts.map +0 -1
  239. package/dist/types/controls/NotebookToolbar.d.ts +0 -4
  240. package/dist/types/controls/NotebookToolbar.d.ts.map +0 -1
  241. package/dist/types/controls/Spinner.d.ts +0 -4
  242. package/dist/types/controls/Spinner.d.ts.map +0 -1
  243. package/dist/types/controls/index.d.ts +0 -5
  244. package/dist/types/controls/index.d.ts.map +0 -1
  245. package/dist/types/convertImages.d.ts +0 -3
  246. package/dist/types/convertImages.d.ts.map +0 -1
  247. package/dist/types/decoration.d.ts +0 -11
  248. package/dist/types/decoration.d.ts.map +0 -1
  249. package/dist/types/embed.d.ts +0 -5
  250. package/dist/types/embed.d.ts.map +0 -1
  251. package/dist/types/error.d.ts +0 -5
  252. package/dist/types/error.d.ts.map +0 -1
  253. package/dist/types/execute/actions.d.ts.map +0 -1
  254. package/dist/types/execute/busy.d.ts +0 -96
  255. package/dist/types/execute/busy.d.ts.map +0 -1
  256. package/dist/types/execute/hooks.d.ts +0 -65
  257. package/dist/types/execute/hooks.d.ts.map +0 -1
  258. package/dist/types/execute/index.d.ts +0 -7
  259. package/dist/types/execute/index.d.ts.map +0 -1
  260. package/dist/types/execute/leaf.d.ts.map +0 -1
  261. package/dist/types/execute/provider.d.ts.map +0 -1
  262. package/dist/types/execute/reducer.d.ts +0 -4
  263. package/dist/types/execute/reducer.d.ts.map +0 -1
  264. package/dist/types/execute/selectors.d.ts +0 -27
  265. package/dist/types/execute/selectors.d.ts.map +0 -1
  266. package/dist/types/execute/types.d.ts +0 -50
  267. package/dist/types/execute/types.d.ts.map +0 -1
  268. package/dist/types/execute/utils.d.ts +0 -23
  269. package/dist/types/execute/utils.d.ts.map +0 -1
  270. package/dist/types/figure.d.ts +0 -5
  271. package/dist/types/figure.d.ts.map +0 -1
  272. package/dist/types/hooks.d.ts +0 -19
  273. package/dist/types/hooks.d.ts.map +0 -1
  274. package/dist/types/index.d.ts +0 -16
  275. package/dist/types/index.d.ts.map +0 -1
  276. package/dist/types/jupyter.d.ts +0 -7
  277. package/dist/types/jupyter.d.ts.map +0 -1
  278. package/dist/types/output.d.ts +0 -15
  279. package/dist/types/output.d.ts.map +0 -1
  280. package/dist/types/providers.d.ts +0 -28
  281. package/dist/types/providers.d.ts.map +0 -1
  282. package/dist/types/safe.d.ts +0 -6
  283. package/dist/types/safe.d.ts.map +0 -1
  284. package/dist/types/stream.d.ts +0 -5
  285. package/dist/types/stream.d.ts.map +0 -1
  286. package/dist/types/utils.d.ts +0 -8
  287. package/dist/types/utils.d.ts.map +0 -1
  288. /package/dist/{cjs/BinderBadge.d.ts → BinderBadge.d.ts} +0 -0
  289. /package/dist/{esm/BinderBadge.js → BinderBadge.js} +0 -0
  290. /package/dist/{cjs/ClientOnly.d.ts → ClientOnly.d.ts} +0 -0
  291. /package/dist/{esm/ClientOnly.js → ClientOnly.js} +0 -0
  292. /package/dist/{cjs/ErrorTray.d.ts → ErrorTray.d.ts} +0 -0
  293. /package/dist/{cjs/components.d.ts → components.d.ts} +0 -0
  294. /package/dist/{cjs/controls → controls}/ArticleCellControls.d.ts +0 -0
  295. /package/dist/{cjs/controls → controls}/NotebookCellControls.d.ts +0 -0
  296. /package/dist/{cjs/controls → controls}/NotebookToolbar.d.ts +0 -0
  297. /package/dist/{cjs/controls → controls}/Spinner.d.ts +0 -0
  298. /package/dist/{esm/controls → controls}/Spinner.js +0 -0
  299. /package/dist/{cjs/convertImages.d.ts → convertImages.d.ts} +0 -0
  300. /package/dist/{esm/convertImages.js → convertImages.js} +0 -0
  301. /package/dist/{cjs/decoration.d.ts → decoration.d.ts} +0 -0
  302. /package/dist/{cjs/embed.d.ts → embed.d.ts} +0 -0
  303. /package/dist/{cjs/error.d.ts → error.d.ts} +0 -0
  304. /package/dist/{esm/execute → execute}/actions.js +0 -0
  305. /package/dist/{cjs/execute → execute}/busy.d.ts +0 -0
  306. /package/dist/{esm/execute → execute}/busy.js +0 -0
  307. /package/dist/{esm/execute → execute}/selectors.js +0 -0
  308. /package/dist/{cjs/execute → execute}/types.d.ts +0 -0
  309. /package/dist/{esm/execute → execute}/types.js +0 -0
  310. /package/dist/{esm/execute → execute}/utils.js +0 -0
  311. /package/dist/{cjs/figure.d.ts → figure.d.ts} +0 -0
  312. /package/dist/{cjs/hooks.d.ts → hooks.d.ts} +0 -0
  313. /package/dist/{cjs/jupyter.d.ts → jupyter.d.ts} +0 -0
  314. /package/dist/{cjs/output.d.ts → output.d.ts} +0 -0
  315. /package/dist/{cjs/safe.d.ts → safe.d.ts} +0 -0
  316. /package/dist/{cjs/stream.d.ts → stream.d.ts} +0 -0
  317. /package/dist/{cjs/utils.d.ts → utils.d.ts} +0 -0
@@ -1,259 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __rest = (this && this.__rest) || function (s, e) {
26
- var t = {};
27
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
28
- t[p] = s[p];
29
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
30
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
31
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
32
- t[p[i]] = s[p[i]];
33
- }
34
- return t;
35
- };
36
- Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.selectPageIsBusy = exports.selectNotebookIsBusy = exports.selectCellIsBusy = exports.useBusyErrors = exports.useBusyScope = exports.BusyScopeProvider = exports.reducer = void 0;
38
- const jsx_runtime_1 = require("react/jsx-runtime");
39
- const react_1 = __importStar(require("react"));
40
- const BusyScopeContext = react_1.default.createContext(undefined);
41
- function isSlugPayload(payload) {
42
- return (typeof payload.pageSlug === 'string' &&
43
- typeof payload.notebookSlug === 'string' &&
44
- typeof payload.kind === 'string');
45
- }
46
- function isCellPayload(payload) {
47
- return (isSlugPayload(payload) &&
48
- typeof payload.cellId === 'string' &&
49
- typeof payload.kind === 'string');
50
- }
51
- function isNotebookPayload(payload) {
52
- return (isSlugPayload(payload) &&
53
- Array.isArray(payload.cellIds) &&
54
- payload.cellIds.every((id) => typeof id === 'string') &&
55
- typeof payload.kind === 'string');
56
- }
57
- function isErrorPayload(payload) {
58
- var _a, _b;
59
- return ((typeof payload.pageSlug === 'string' &&
60
- typeof payload.notebookSlug === 'string' &&
61
- payload.errors === undefined) ||
62
- ((_b = (Array.isArray(payload.errors) &&
63
- ((_a = payload.errors) === null || _a === void 0 ? void 0 : _a.every((error) => typeof error === 'object')))) !== null && _b !== void 0 ? _b : false));
64
- }
65
- function reducer(state, action) {
66
- var _a, _b, _c, _d, _e, _f, _g;
67
- switch (action.type) {
68
- case 'SET_CELL_BUSY': {
69
- if (!isCellPayload(action.payload)) {
70
- console.error('SET_CELL_BUSY payload must be a cell payload', action.payload);
71
- return state;
72
- }
73
- const { pageSlug, notebookSlug, cellId, kind } = action.payload;
74
- if ((_b = (_a = state[kind][pageSlug]) === null || _a === void 0 ? void 0 : _a[notebookSlug]) === null || _b === void 0 ? void 0 : _b[cellId])
75
- return state;
76
- return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [pageSlug]: Object.assign(Object.assign({}, state[kind][pageSlug]), { [notebookSlug]: Object.assign(Object.assign({}, (_c = state[kind][pageSlug]) === null || _c === void 0 ? void 0 : _c[notebookSlug]), { [cellId]: true }) }) }) });
77
- }
78
- case 'CLEAR_CELL_BUSY': {
79
- if (!isCellPayload(action.payload)) {
80
- console.error('CLEAR_CELL_BUSY payload must be a cell payload', action.payload);
81
- return state;
82
- }
83
- const { pageSlug, notebookSlug, cellId, kind } = action.payload;
84
- const _h = state[kind], _j = pageSlug, renderBusy = _h[_j], otherRenders = __rest(_h, [typeof _j === "symbol" ? _j : _j + ""]);
85
- if (!renderBusy)
86
- return state;
87
- const _k = renderBusy, _l = notebookSlug, notebookBusy = _k[_l], otherNotebooks = __rest(_k, [typeof _l === "symbol" ? _l : _l + ""]);
88
- if (!notebookBusy)
89
- return state;
90
- if (!notebookBusy[cellId])
91
- return state;
92
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
93
- const _m = notebookBusy, _o = cellId, cellBusy = _m[_o], otherCells = __rest(_m, [typeof _o === "symbol" ? _o : _o + ""]);
94
- // remove the render if it's empty
95
- if (Object.keys(otherCells).length === 0 && Object.keys(otherNotebooks).length === 0) {
96
- return Object.assign(Object.assign({}, state), { [kind]: otherRenders });
97
- }
98
- // remove the notebook if it's empty
99
- if (Object.keys(otherCells).length === 0) {
100
- return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [pageSlug]: Object.assign({}, otherNotebooks) }) });
101
- }
102
- return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [action.payload.pageSlug]: Object.assign(Object.assign({}, otherNotebooks), { [notebookSlug]: Object.assign({}, otherCells) }) }) });
103
- }
104
- case 'SET_NOTEBOOK_BUSY': {
105
- if (!isNotebookPayload(action.payload)) {
106
- console.error('SET_NOTEBOOK_BUSY payload must be a notebook payload', action.payload);
107
- return state;
108
- }
109
- const { pageSlug, notebookSlug, cellIds, kind } = action.payload;
110
- return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [pageSlug]: Object.assign(Object.assign({}, state[kind][pageSlug]), { [notebookSlug]: Object.assign(Object.assign({}, (_d = state[kind][pageSlug]) === null || _d === void 0 ? void 0 : _d[notebookSlug]), cellIds.reduce((acc, cellId) => (Object.assign(Object.assign({}, acc), { [cellId]: true })), {})) }) }) });
111
- }
112
- case 'CLEAR_NOTEBOOK_BUSY': {
113
- if (!isSlugPayload(action.payload)) {
114
- console.error('CLEAR_NOTEBOOK_BUSY payload must be a notebook payload', action.payload);
115
- return state;
116
- }
117
- const { pageSlug, notebookSlug, kind } = action.payload;
118
- if (!state[kind][pageSlug])
119
- return state;
120
- if (!((_e = state[kind][pageSlug]) === null || _e === void 0 ? void 0 : _e[notebookSlug]))
121
- return state;
122
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
123
- const _p = state[kind][pageSlug], _q = notebookSlug, notebookBusy = _p[_q], otherNotebooks = __rest(_p, [typeof _q === "symbol" ? _q : _q + ""]);
124
- if (Object.keys(otherNotebooks).length === 0) {
125
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
126
- const _r = state[kind], _s = pageSlug, renderBusy = _r[_s], otherRenders = __rest(_r, [typeof _s === "symbol" ? _s : _s + ""]);
127
- return Object.assign(Object.assign({}, state), { [kind]: otherRenders });
128
- }
129
- return Object.assign(Object.assign({}, state), { [kind]: Object.assign(Object.assign({}, state[kind]), { [pageSlug]: Object.assign({}, otherNotebooks) }) });
130
- }
131
- case 'SET_ERROR': {
132
- if (!isErrorPayload(action.payload)) {
133
- console.error('SET_ERROR payload must be an error payload', action.payload);
134
- return state;
135
- }
136
- const { pageSlug, notebookSlug, errors } = action.payload;
137
- if (!errors) {
138
- console.error('SET_ERROR payload must have errors', action.payload);
139
- return state;
140
- }
141
- if (state.error[pageSlug])
142
- return state;
143
- if ((_f = state.error[pageSlug]) === null || _f === void 0 ? void 0 : _f[notebookSlug])
144
- return state;
145
- return Object.assign(Object.assign({}, state), { error: Object.assign(Object.assign({}, state.error), { [pageSlug]: Object.assign(Object.assign({}, state.error[pageSlug]), { [notebookSlug]: errors }) }) });
146
- }
147
- case 'CLEAR_ERROR': {
148
- if (!isErrorPayload(action.payload)) {
149
- console.error('CLEAR_ERROR payload must be a error payload', action.payload);
150
- return state;
151
- }
152
- const { pageSlug, notebookSlug } = action.payload;
153
- if (!state.error[pageSlug])
154
- return state;
155
- if (!((_g = state.error[pageSlug]) === null || _g === void 0 ? void 0 : _g[notebookSlug]))
156
- return state;
157
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
158
- const _t = state.error[pageSlug], _u = notebookSlug, notebookErrors = _t[_u], otherNotebooks = __rest(_t, [typeof _u === "symbol" ? _u : _u + ""]);
159
- if (Object.keys(otherNotebooks).length > 0) {
160
- return Object.assign(Object.assign({}, state), { error: Object.assign(Object.assign({}, state.error), { [pageSlug]: Object.assign({}, otherNotebooks) }) });
161
- }
162
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
163
- const _v = state.error, _w = pageSlug, renderErrors = _v[_w], otherRenders = __rest(_v, [typeof _w === "symbol" ? _w : _w + ""]);
164
- return Object.assign(Object.assign({}, state), { error: otherRenders });
165
- }
166
- }
167
- return state;
168
- }
169
- exports.reducer = reducer;
170
- function BusyScopeProvider({ children }) {
171
- const [state, dispatch] = (0, react_1.useReducer)(reducer, { execute: {}, reset: {}, error: {} });
172
- const memo = react_1.default.useMemo(() => ({ state, dispatch }), [state]);
173
- if (typeof window !== 'undefined') {
174
- window.busyScopeState = memo.state;
175
- }
176
- return (0, jsx_runtime_1.jsx)(BusyScopeContext.Provider, { value: memo, children: children });
177
- }
178
- exports.BusyScopeProvider = BusyScopeProvider;
179
- function useBusyScope() {
180
- const context = react_1.default.useContext(BusyScopeContext);
181
- if (context === undefined) {
182
- throw new Error('useBusyScope must be used within a BusyScopeProvider');
183
- }
184
- const { dispatch, state } = context;
185
- const cell = (0, react_1.useCallback)((pageSlug, notebookSlug, cellId, kind) => selectCellIsBusy(state, pageSlug, notebookSlug, cellId, kind), [state]);
186
- const notebook = (0, react_1.useCallback)((pageSlug, notebookSlug, kind) => selectNotebookIsBusy(state, pageSlug, notebookSlug, kind), [state]);
187
- const page = (0, react_1.useCallback)((pageSlug, kind) => selectPageIsBusy(state, pageSlug, kind), [state]);
188
- const setCell = (0, react_1.useCallback)((pageSlug, notebookSlug, cellId, kind) => {
189
- dispatch({ type: 'SET_CELL_BUSY', payload: { pageSlug, notebookSlug, cellId, kind } });
190
- }, [dispatch]);
191
- const clearCell = (0, react_1.useCallback)((pageSlug, notebookSlug, cellId, kind) => dispatch({ type: 'CLEAR_CELL_BUSY', payload: { pageSlug, notebookSlug, cellId, kind } }), [dispatch]);
192
- const setNotebook = (0, react_1.useCallback)((pageSlug, notebookSlug, cellIds, kind) => dispatch({ type: 'SET_NOTEBOOK_BUSY', payload: { pageSlug, notebookSlug, cellIds, kind } }), [dispatch]);
193
- const clearNotebook = (0, react_1.useCallback)((pageSlug, notebookSlug, kind) => dispatch({ type: 'CLEAR_NOTEBOOK_BUSY', payload: { pageSlug, notebookSlug, kind } }), [dispatch]);
194
- const setError = (0, react_1.useCallback)((pageSlug, notebookSlug, errors) => dispatch({ type: 'SET_ERROR', payload: { pageSlug, notebookSlug, errors } }), [dispatch]);
195
- const clearError = (0, react_1.useCallback)((pageSlug, notebookSlug) => dispatch({ type: 'CLEAR_ERROR', payload: { pageSlug, notebookSlug } }), [dispatch]);
196
- return {
197
- cell,
198
- notebook,
199
- page,
200
- setCell,
201
- clearCell,
202
- setNotebook,
203
- clearNotebook,
204
- setError,
205
- clearError,
206
- };
207
- }
208
- exports.useBusyScope = useBusyScope;
209
- function useBusyErrors(pageSlug) {
210
- const context = react_1.default.useContext(BusyScopeContext);
211
- if (context === undefined) {
212
- throw new Error('useBusyScope must be used within a BusyScopeProvider');
213
- }
214
- const { state, dispatch } = context;
215
- const clearErrors = () => {
216
- Object.keys(state.error[pageSlug]).forEach((notebookSlug) => {
217
- dispatch({ type: 'CLEAR_ERROR', payload: { pageSlug, notebookSlug } });
218
- });
219
- };
220
- let items;
221
- if (Object.keys(state.error).length > 0 && state.error[pageSlug]) {
222
- items = Object.entries(state.error[pageSlug]).map(([notebookSlug, errors]) => ({
223
- pageSlug,
224
- notebookSlug,
225
- errors,
226
- }));
227
- }
228
- return { items, clearErrors };
229
- }
230
- exports.useBusyErrors = useBusyErrors;
231
- function selectCellIsBusy(state, pageSlug, notebookSlug, cellId, kind) {
232
- var _a, _b;
233
- return !!((_b = (_a = state[kind][pageSlug]) === null || _a === void 0 ? void 0 : _a[notebookSlug]) === null || _b === void 0 ? void 0 : _b[cellId]);
234
- }
235
- exports.selectCellIsBusy = selectCellIsBusy;
236
- /**
237
- * a fast selector relying on the fact that if at least one cell is present, the notebook is busy
238
- *
239
- * @param state
240
- * @param pageSlug
241
- * @param notebookSlug
242
- * @returns
243
- */
244
- function selectNotebookIsBusy(state, pageSlug, notebookSlug, kind) {
245
- var _a;
246
- return !!((_a = state[kind][pageSlug]) === null || _a === void 0 ? void 0 : _a[notebookSlug]);
247
- }
248
- exports.selectNotebookIsBusy = selectNotebookIsBusy;
249
- /**
250
- * a fast selector relying on the fact that if at least one notebook is present, the render is busy
251
- *
252
- * @param state
253
- * @param pageSlug
254
- * @returns
255
- */
256
- function selectPageIsBusy(state, pageSlug, kind) {
257
- return !!state[kind][pageSlug];
258
- }
259
- exports.selectPageIsBusy = selectPageIsBusy;
@@ -1 +0,0 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../../src/execute/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAsB,MAAM,OAAO,CAAC;AAC3C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,KAAK,EAAE,UAAU,EAA8C,MAAM,YAAY,CAAC;AAGzF,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C,wBAAgB,iBAAiB,CAAC,EAChC,qBAA6B,GAC9B,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO;;kBAUR,MAAM;yBAuD1B,MAAM;yBAYN,MAAM;oBAzDI,MAAM;;;;;;EAkF9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;;;;;;EAgH9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;EAgE1E;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
@@ -1,311 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || function (mod) {
19
- if (mod && mod.__esModule) return mod;
20
- var result = {};
21
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
- __setModuleDefault(result, mod);
23
- return result;
24
- };
25
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
26
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
27
- return new (P || (P = Promise))(function (resolve, reject) {
28
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
29
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
30
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
31
- step((generator = generator.apply(thisArg, _arguments || [])).next());
32
- });
33
- };
34
- Object.defineProperty(exports, "__esModule", { value: true });
35
- exports.useReadyToExecute = exports.useIsAComputableCell = exports.useCellExecution = exports.useNotebookExecution = exports.useExecutionScope = void 0;
36
- const react_1 = __importStar(require("react"));
37
- const provider_1 = require("./provider");
38
- const busy_1 = require("./busy");
39
- const thebe_react_1 = require("thebe-react");
40
- const myst_spec_ext_1 = require("myst-spec-ext");
41
- const selectors_1 = require("./selectors");
42
- function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
43
- var _a;
44
- const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
45
- const { config } = (0, thebe_react_1.useThebeConfig)();
46
- const busy = (0, busy_1.useBusyScope)();
47
- if (context === undefined) {
48
- throw new Error('useExecuteScope must be used within a ExecuteScopeProvider');
49
- }
50
- const { state, dispatch } = context;
51
- const start = (0, react_1.useCallback)((slug) => {
52
- console.debug(`Jupyter: Starting ${slug}`);
53
- dispatch({
54
- type: 'REQUEST_BUILD',
55
- payload: {
56
- slug,
57
- },
58
- });
59
- }, []);
60
- const execute = (slug) => {
61
- // set busy
62
- Object.entries(state.pages[slug].scopes).forEach(([notebookSlug, { notebook }]) => {
63
- busy.clearError(slug, notebookSlug);
64
- busy.setNotebook(slug, notebookSlug, notebook.code.map((c) => c.id), 'execute');
65
- });
66
- if (clearOutputsOnExecute) {
67
- // clear all notebook cell outputs
68
- Object.values(state.pages[slug].scopes).forEach(({ notebook }) => {
69
- notebook.clear();
70
- });
71
- }
72
- // let busy state update prior to launching execute
73
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
74
- const handler = (_, data) => {
75
- var _a, _b;
76
- if (data.subject === 'cell' && data.status === 'idle') {
77
- const notebookSlug = (_a = data.object.notebookId) !== null && _a !== void 0 ? _a : 'unknown';
78
- busy.clearCell(slug, notebookSlug, (_b = data.id) !== null && _b !== void 0 ? _b : 'unknown', 'execute');
79
- }
80
- };
81
- config === null || config === void 0 ? void 0 : config.events.on('status', handler);
82
- // execute all cells on all notebooks
83
- yield Promise.all(Object.entries(state.pages[slug].scopes).map(([, { notebook }]) => __awaiter(this, void 0, void 0, function* () {
84
- const execReturns = yield notebook.executeAll(true);
85
- const errs = (0, thebe_react_1.findErrors)(execReturns);
86
- if (errs != null)
87
- console.error('errors', errs);
88
- })));
89
- config === null || config === void 0 ? void 0 : config.events.off('status', handler);
90
- }), 100);
91
- };
92
- /**
93
- * clearAll clears all cells in all notebooks for a given rendering
94
- *
95
- */
96
- const clearAll = (0, react_1.useCallback)((pageSlug) => {
97
- var _a;
98
- Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([, { notebook }]) => {
99
- notebook.clear();
100
- });
101
- }, [state]);
102
- /**
103
- * resetAll resets all cells in all notebooks for a given rendering
104
- */
105
- const resetAll = (0, react_1.useCallback)((pageSlug) => {
106
- var _a;
107
- Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([notebookSlug, { notebook, session }]) => {
108
- busy.clearError(pageSlug, notebookSlug);
109
- busy.setNotebook(pageSlug, notebookSlug, notebook.code.map((c) => c.id), 'reset');
110
- setTimeout(() => {
111
- var _a;
112
- notebook.reset();
113
- (_a = session === null || session === void 0 ? void 0 : session.kernel) === null || _a === void 0 ? void 0 : _a.restart().finally(() => {
114
- busy.clearNotebook(pageSlug, notebookSlug, 'reset');
115
- });
116
- }, 300);
117
- });
118
- }, [state]);
119
- const ready = (_a = context.state.pages[context.slug]) === null || _a === void 0 ? void 0 : _a.ready;
120
- return Object.assign(Object.assign({}, context), { ready, start, clearAll, resetAll, execute });
121
- }
122
- exports.useExecutionScope = useExecutionScope;
123
- /**
124
- * useNotebookExecution a hook to govern notebook execution in the context of a single
125
- * cell embedded in an article
126
- *
127
- */
128
- function useNotebookExecution(id, clearOutputsOnExecute = false) {
129
- var _a, _b;
130
- const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
131
- const { config } = (0, thebe_react_1.useThebeConfig)();
132
- const busy = (0, busy_1.useBusyScope)();
133
- if (context === undefined) {
134
- throw new Error('useNotebookExecution must be used within a ExecuteScopeProvider');
135
- }
136
- const { state, dispatch, idkmap } = context;
137
- const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
138
- const { pageSlug, notebookSlug, cellId } = target;
139
- // TODO consider extending this to start only the notebook requested, currently this will
140
- // execute all connected notebooks
141
- const start = (0, react_1.useCallback)(() => {
142
- dispatch({
143
- type: 'REQUEST_BUILD',
144
- payload: {
145
- slug: context.slug,
146
- },
147
- });
148
- }, [target]);
149
- let cell;
150
- let notebook;
151
- if (target && state.pages[pageSlug]) {
152
- notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
153
- if (notebook)
154
- cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
155
- }
156
- const execute = () => {
157
- const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
158
- busy.clearError(pageSlug, notebookSlug);
159
- // set busy
160
- busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'execute');
161
- if (clearOutputsOnExecute)
162
- nb.clear();
163
- // let busy state update prior to launching execute
164
- setTimeout(() => __awaiter(this, void 0, void 0, function* () {
165
- const handler = (_, data) => {
166
- var _a;
167
- if (data.subject === 'cell' && data.status === 'idle') {
168
- busy.clearCell(pageSlug, notebookSlug, (_a = data.id) !== null && _a !== void 0 ? _a : 'unknown', 'execute');
169
- }
170
- };
171
- config === null || config === void 0 ? void 0 : config.events.on('status', handler);
172
- // execute all cells on the notebooks
173
- const execReturns = yield nb.executeAll(true);
174
- const errs = (0, thebe_react_1.findErrors)(execReturns);
175
- if (errs != null) {
176
- console.error('an error occurred during notebook execution');
177
- busy.setError(pageSlug, notebookSlug, errs);
178
- busy.clearNotebook(pageSlug, notebookSlug, 'execute');
179
- }
180
- config === null || config === void 0 ? void 0 : config.events.off('status', handler);
181
- }), 100);
182
- };
183
- /**
184
- * clearAll clears all cells in all notebooks for a given rendering
185
- *
186
- */
187
- const clear = (0, react_1.useCallback)(() => {
188
- const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
189
- nb.clear();
190
- }, [state]);
191
- /**
192
- * resetAll resets all cells in all notebooks for a given rendering
193
- */
194
- const reset = (0, react_1.useCallback)(() => {
195
- const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
196
- busy.clearError(pageSlug, notebookSlug);
197
- busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'reset');
198
- setTimeout(() => {
199
- var _a, _b;
200
- nb.reset();
201
- (_b = (_a = nb.session) === null || _a === void 0 ? void 0 : _a.kernel) === null || _b === void 0 ? void 0 : _b.restart().finally(() => {
202
- busy.clearNotebook(pageSlug, notebookSlug, 'reset');
203
- });
204
- }, 300);
205
- }, [state]);
206
- const ready = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready;
207
- const notebookIsExecuting = busy.notebook(pageSlug, notebookSlug, 'execute');
208
- const notebookIsResetting = busy.notebook(pageSlug, notebookSlug, 'reset');
209
- const notebookIsBusy = notebookIsExecuting || notebookIsResetting;
210
- return Object.assign(Object.assign({}, context), { ready,
211
- start,
212
- clear,
213
- reset,
214
- execute, cellIsExecuting: cell ? busy.cell(pageSlug, notebookSlug, cell === null || cell === void 0 ? void 0 : cell.id, 'execute') : false, notebookIsExecuting,
215
- notebookIsResetting,
216
- notebookIsBusy, executionCount: cell === null || cell === void 0 ? void 0 : cell.executionCount });
217
- }
218
- exports.useNotebookExecution = useNotebookExecution;
219
- /**
220
- * useCellExecution a hook to govern the execute status and actions for a single cell
221
- *
222
- * @param id
223
- * @returns
224
- */
225
- function useCellExecution(id, clearOutputsOnExecute = false) {
226
- var _a, _b, _c, _d;
227
- const busy = (0, busy_1.useBusyScope)();
228
- const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
229
- if (context === undefined) {
230
- throw new Error('useCellExecution must be used within a ExecuteScopeProvider');
231
- }
232
- const { state, idkmap } = context;
233
- const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
234
- const { pageSlug, notebookSlug, cellId } = target;
235
- let cell;
236
- let notebook;
237
- if (target && state.pages[pageSlug]) {
238
- notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
239
- if (notebook)
240
- cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
241
- }
242
- const ready = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready;
243
- const kind = (_d = (_c = context.state.pages[context.slug]) === null || _c === void 0 ? void 0 : _c.kind) !== null && _d !== void 0 ? _d : myst_spec_ext_1.SourceFileKind.Article;
244
- const execute = (0, react_1.useCallback)(() => {
245
- if (!cell) {
246
- console.error('no cell found on execute', { pageSlug, notebookSlug, cellId });
247
- return;
248
- }
249
- // set busy
250
- busy.setCell(pageSlug, notebookSlug, cell.id, 'execute');
251
- if (clearOutputsOnExecute)
252
- cell.clear();
253
- // let busy state update prior to launching execute
254
- setTimeout(() => {
255
- if (!cell)
256
- throw new Error('no cell found on execute');
257
- cell.execute().then(() => {
258
- if (!cell)
259
- throw new Error('no cell found after execute');
260
- busy.clearCell(pageSlug, notebookSlug, cell === null || cell === void 0 ? void 0 : cell.id, 'execute');
261
- });
262
- }, 100);
263
- }, [state, cell]);
264
- const clear = (0, react_1.useCallback)(() => {
265
- if (!cell) {
266
- console.error('no cell found on clear', { pageSlug, notebookSlug, cellId });
267
- return;
268
- }
269
- cell.clear();
270
- }, [state, cell]);
271
- const notebookIsExecuting = busy.notebook(pageSlug, notebookSlug, 'execute');
272
- const notebookIsResetting = busy.notebook(pageSlug, notebookSlug, 'reset');
273
- const notebookIsBusy = notebookIsExecuting || notebookIsResetting;
274
- return {
275
- canCompute: context.canCompute,
276
- kind,
277
- ready,
278
- execute,
279
- clear,
280
- cellIsExecuting: cell ? busy.cell(pageSlug, notebookSlug, cell === null || cell === void 0 ? void 0 : cell.id, 'execute') : false,
281
- notebookIsExecuting,
282
- notebookIsResetting,
283
- notebookIsBusy,
284
- cell,
285
- };
286
- }
287
- exports.useCellExecution = useCellExecution;
288
- function useIsAComputableCell(id) {
289
- var _a, _b, _c;
290
- const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
291
- if (context === undefined) {
292
- throw new Error('useExecuteScope must be used within a ExecuteScopeProvider');
293
- }
294
- const { idkmap } = context;
295
- const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
296
- return {
297
- slug: context.slug,
298
- computable: !!target,
299
- ready: (_c = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready) !== null && _c !== void 0 ? _c : false,
300
- };
301
- }
302
- exports.useIsAComputableCell = useIsAComputableCell;
303
- function useReadyToExecute() {
304
- var _a, _b;
305
- const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
306
- if (context === undefined) {
307
- throw new Error('useExecuteScope must be used within a ExecuteScopeProvider');
308
- }
309
- return (_b = (_a = context.state.pages[context.slug]) === null || _a === void 0 ? void 0 : _a.ready) !== null && _b !== void 0 ? _b : false;
310
- }
311
- exports.useReadyToExecute = useReadyToExecute;
@@ -1,7 +0,0 @@
1
- export * from './hooks';
2
- export * from './actions';
3
- export * from './provider';
4
- export * from './selectors';
5
- export * from './types';
6
- export * from './busy';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/execute/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./hooks"), exports);
18
- __exportStar(require("./actions"), exports);
19
- __exportStar(require("./provider"), exports);
20
- __exportStar(require("./selectors"), exports);
21
- __exportStar(require("./types"), exports);
22
- __exportStar(require("./busy"), exports);
@@ -1,27 +0,0 @@
1
- /// <reference types="react" />
2
- import type { ExecuteScopeAction } from './actions';
3
- import type { IdKeyMap, ExecuteScopeState } from './types';
4
- export declare function MdastFetcher({ slug, url, dispatch, }: {
5
- slug: string;
6
- url: string;
7
- dispatch: React.Dispatch<ExecuteScopeAction>;
8
- }): import("react/jsx-runtime").JSX.Element | null;
9
- export declare function NotebookBuilder({ pageSlug, notebookSlug, idkmap, state, dispatch, }: {
10
- pageSlug: string;
11
- notebookSlug: string;
12
- idkmap: IdKeyMap;
13
- state: ExecuteScopeState;
14
- dispatch: React.Dispatch<ExecuteScopeAction>;
15
- }): null;
16
- export declare function SessionStarter({ pageSlug, notebookSlug, location, state, dispatch, }: {
17
- pageSlug: string;
18
- notebookSlug: string;
19
- location: string | undefined;
20
- state: ExecuteScopeState;
21
- dispatch: React.Dispatch<ExecuteScopeAction>;
22
- }): null;
23
- export declare function ServerMonitor({ state, dispatch, }: {
24
- state: ExecuteScopeState;
25
- dispatch: React.Dispatch<ExecuteScopeAction>;
26
- }): null;
27
- //# sourceMappingURL=leaf.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"leaf.d.ts","sourceRoot":"","sources":["../../../src/execute/leaf.tsx"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAW3D,wBAAgB,YAAY,CAAC,EAC3B,IAAI,EACJ,GAAG,EACH,QAAQ,GACT,EAAE;IACD,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,kDAkBA;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,YAAY,EACZ,MAAM,EACN,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,QAAQ,CAAC;IACjB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QA8CA;AAED,wBAAgB,cAAc,CAAC,EAC7B,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QA2EA;AAED,wBAAgB,aAAa,CAAC,EAC5B,KAAK,EACL,QAAQ,GACT,EAAE;IACD,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QA4BA"}