@myst-theme/jupyter 0.3.6 → 0.3.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.
- package/dist/cjs/BinderBadge.js +1 -1
- package/dist/cjs/embed.d.ts.map +1 -1
- package/dist/cjs/embed.js +7 -3
- package/dist/cjs/execute/hooks.d.ts +3 -0
- package/dist/cjs/execute/hooks.d.ts.map +1 -1
- package/dist/cjs/execute/hooks.js +23 -28
- package/dist/cjs/execute/leaf.d.ts.map +1 -1
- package/dist/cjs/execute/leaf.js +2 -4
- package/dist/cjs/execute/provider.d.ts +5 -0
- package/dist/cjs/execute/provider.d.ts.map +1 -1
- package/dist/cjs/execute/provider.js +3 -1
- package/dist/cjs/execute/reducer.js +4 -3
- package/dist/cjs/execute/selectors.d.ts +4 -1
- package/dist/cjs/execute/selectors.d.ts.map +1 -1
- package/dist/cjs/execute/selectors.js +11 -6
- package/dist/cjs/execute/utils.js +1 -1
- package/dist/cjs/providers.d.ts +6 -1
- package/dist/cjs/providers.d.ts.map +1 -1
- package/dist/cjs/providers.js +8 -3
- package/dist/esm/BinderBadge.js +1 -1
- package/dist/esm/embed.d.ts.map +1 -1
- package/dist/esm/embed.js +7 -3
- package/dist/esm/execute/hooks.d.ts +3 -0
- package/dist/esm/execute/hooks.d.ts.map +1 -1
- package/dist/esm/execute/hooks.js +23 -28
- package/dist/esm/execute/leaf.d.ts.map +1 -1
- package/dist/esm/execute/leaf.js +3 -5
- package/dist/esm/execute/provider.d.ts +5 -0
- package/dist/esm/execute/provider.d.ts.map +1 -1
- package/dist/esm/execute/provider.js +3 -1
- package/dist/esm/execute/reducer.js +4 -3
- package/dist/esm/execute/selectors.d.ts +4 -1
- package/dist/esm/execute/selectors.d.ts.map +1 -1
- package/dist/esm/execute/selectors.js +8 -4
- package/dist/esm/execute/utils.js +1 -1
- package/dist/esm/providers.d.ts +6 -1
- package/dist/esm/providers.d.ts.map +1 -1
- package/dist/esm/providers.js +6 -2
- package/dist/types/embed.d.ts.map +1 -1
- package/dist/types/execute/hooks.d.ts +3 -0
- package/dist/types/execute/hooks.d.ts.map +1 -1
- package/dist/types/execute/leaf.d.ts.map +1 -1
- package/dist/types/execute/provider.d.ts +5 -0
- package/dist/types/execute/provider.d.ts.map +1 -1
- package/dist/types/execute/selectors.d.ts +4 -1
- package/dist/types/execute/selectors.d.ts.map +1 -1
- package/dist/types/providers.d.ts +6 -1
- package/dist/types/providers.d.ts.map +1 -1
- package/package.json +6 -6
package/dist/cjs/BinderBadge.js
CHANGED
|
@@ -8,6 +8,6 @@ function BinderBadgeLogo() {
|
|
|
8
8
|
function BinderBadge({ binder }) {
|
|
9
9
|
if (!binder)
|
|
10
10
|
return null;
|
|
11
|
-
return ((0, jsx_runtime_1.jsx)("div", { className: "inline-block
|
|
11
|
+
return ((0, jsx_runtime_1.jsx)("div", { className: "inline-block m-1 opacity-80 hover:opacity-100", children: (0, jsx_runtime_1.jsx)("a", { href: binder, title: `Launch Binder Session: ${binder}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit", children: (0, jsx_runtime_1.jsx)(BinderBadgeLogo, {}) }) }));
|
|
12
12
|
}
|
|
13
13
|
exports.BinderBadge = BinderBadge;
|
package/dist/cjs/embed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AA2E/D,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,2CAajE"}
|
package/dist/cjs/embed.js
CHANGED
|
@@ -9,11 +9,15 @@ const solid_1 = require("@scienceicons/react/24/solid");
|
|
|
9
9
|
const unist_util_select_1 = require("unist-util-select");
|
|
10
10
|
const providers_1 = require("@myst-theme/providers");
|
|
11
11
|
function EmbedWithControls({ outputKey, children, title = 'Jupyter Notebook', url, }) {
|
|
12
|
-
const { kind } = (0, execute_1.useCellExecution)(outputKey);
|
|
12
|
+
const { canCompute, kind } = (0, execute_1.useCellExecution)(outputKey);
|
|
13
13
|
const Link = (0, providers_1.useLinkProvider)();
|
|
14
14
|
const baseurl = (0, providers_1.useBaseurl)();
|
|
15
|
-
const
|
|
16
|
-
|
|
15
|
+
const showComputeControls = canCompute && kind === myst_common_1.SourceFileKind.Article;
|
|
16
|
+
if (showComputeControls) {
|
|
17
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "shadow", children: [(0, jsx_runtime_1.jsx)("div", { className: "sticky top-[60px] z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", children: (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsxs)("div", { className: "flex items-center", children: [(0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "inline-block w-5 h-5" }), (0, jsx_runtime_1.jsx)("span", { className: "ml-2", children: "Source:" }), url && ((0, jsx_runtime_1.jsx)(Link, { to: (0, providers_1.withBaseurl)(url, baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), (0, jsx_runtime_1.jsx)("div", { className: "flex-grow" }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleStatusBadge, { id: outputKey }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleRunNotebook, { id: outputKey }), (0, jsx_runtime_1.jsx)(ArticleCellControls_1.ArticleResetNotebook, { id: outputKey })] }) }), (0, jsx_runtime_1.jsx)("div", { className: "mt-2", children: children })] }));
|
|
18
|
+
}
|
|
19
|
+
// light
|
|
20
|
+
return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [children, (0, jsx_runtime_1.jsxs)("div", { className: "flex items-center justify-end text-xs", children: [(0, jsx_runtime_1.jsx)(solid_1.JupyterIcon, { className: "inline-block w-3 h-3" }), (0, jsx_runtime_1.jsx)("div", { className: "ml-1", children: "Source:" }), url && ((0, jsx_runtime_1.jsx)(Link, { to: (0, providers_1.withBaseurl)(url, baseurl), className: "ml-1 no-underline text-normal hover:underline", children: title }))] })] }));
|
|
17
21
|
}
|
|
18
22
|
function Embed(node, children) {
|
|
19
23
|
var _a, _b;
|
|
@@ -10,6 +10,7 @@ export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
|
|
|
10
10
|
clearAll: (pageSlug: string) => void;
|
|
11
11
|
resetAll: (pageSlug: string) => void;
|
|
12
12
|
execute: (slug: string) => void;
|
|
13
|
+
canCompute: boolean;
|
|
13
14
|
slug: string;
|
|
14
15
|
state: import("./types").ExecuteScopeState;
|
|
15
16
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -31,6 +32,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
31
32
|
notebookIsResetting: boolean;
|
|
32
33
|
notebookIsBusy: boolean;
|
|
33
34
|
executionCount: number | null | undefined;
|
|
35
|
+
canCompute: boolean;
|
|
34
36
|
slug: string;
|
|
35
37
|
state: import("./types").ExecuteScopeState;
|
|
36
38
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -43,6 +45,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
43
45
|
* @returns
|
|
44
46
|
*/
|
|
45
47
|
export declare function useCellExecution(id: IdOrKey): {
|
|
48
|
+
canCompute: boolean;
|
|
46
49
|
kind: SourceFileKind;
|
|
47
50
|
ready: boolean;
|
|
48
51
|
execute: () => void;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,aAAa,CAAC;AAG7C,wBAAgB,iBAAiB,CAAC,EAChC,qBAA6B,GAC9B,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO;;kBAUR,MAAM;yBAsD1B,MAAM;yBAYN,MAAM;oBAxDI,MAAM;;;;;;EAgF9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;;;;;;EA2G9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO;;;;;;;;;;;EAgE3C;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
|
|
@@ -38,6 +38,7 @@ const provider_1 = require("./provider");
|
|
|
38
38
|
const busy_1 = require("./busy");
|
|
39
39
|
const thebe_react_1 = require("thebe-react");
|
|
40
40
|
const myst_common_1 = require("myst-common");
|
|
41
|
+
const selectors_1 = require("./selectors");
|
|
41
42
|
function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
42
43
|
var _a;
|
|
43
44
|
const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
|
|
@@ -59,7 +60,7 @@ function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
59
60
|
const execute = (slug) => {
|
|
60
61
|
// set busy
|
|
61
62
|
Object.entries(state.pages[slug].scopes).forEach(([notebookSlug, { notebook }]) => {
|
|
62
|
-
busy.setNotebook(slug, notebookSlug, notebook.
|
|
63
|
+
busy.setNotebook(slug, notebookSlug, notebook.code.map((c) => c.id), 'execute');
|
|
63
64
|
});
|
|
64
65
|
if (clearOutputsOnExecute) {
|
|
65
66
|
// clear all notebook cell outputs
|
|
@@ -92,7 +93,8 @@ function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
92
93
|
*
|
|
93
94
|
*/
|
|
94
95
|
const clearAll = (0, react_1.useCallback)((pageSlug) => {
|
|
95
|
-
|
|
96
|
+
var _a;
|
|
97
|
+
Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([, { notebook }]) => {
|
|
96
98
|
notebook.clear();
|
|
97
99
|
});
|
|
98
100
|
}, [state]);
|
|
@@ -100,8 +102,9 @@ function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
100
102
|
* resetAll resets all cells in all notebooks for a given rendering
|
|
101
103
|
*/
|
|
102
104
|
const resetAll = (0, react_1.useCallback)((pageSlug) => {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
+
var _a;
|
|
106
|
+
Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([notebookSlug, { notebook, session }]) => {
|
|
107
|
+
busy.setNotebook(pageSlug, notebookSlug, notebook.code.map((c) => c.id), 'reset');
|
|
105
108
|
setTimeout(() => {
|
|
106
109
|
var _a;
|
|
107
110
|
notebook.reset();
|
|
@@ -126,7 +129,7 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
126
129
|
const { config } = (0, thebe_react_1.useThebeConfig)();
|
|
127
130
|
const busy = (0, busy_1.useBusyScope)();
|
|
128
131
|
if (context === undefined) {
|
|
129
|
-
throw new Error('
|
|
132
|
+
throw new Error('useNotebookExecution must be used within a ExecuteScopeProvider');
|
|
130
133
|
}
|
|
131
134
|
const { state, dispatch, idkmap } = context;
|
|
132
135
|
const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -144,18 +147,14 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
144
147
|
let cell;
|
|
145
148
|
let notebook;
|
|
146
149
|
if (target && state.pages[pageSlug]) {
|
|
147
|
-
notebook = state
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
151
|
-
if (!cell)
|
|
152
|
-
console.error('no cell found', { pageSlug, notebookSlug, cellId });
|
|
150
|
+
notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
151
|
+
if (notebook)
|
|
152
|
+
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
153
153
|
}
|
|
154
154
|
const execute = () => {
|
|
155
|
-
|
|
156
|
-
const nb = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
155
|
+
const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
157
156
|
// set busy
|
|
158
|
-
busy.setNotebook(pageSlug, notebookSlug, nb.
|
|
157
|
+
busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'execute');
|
|
159
158
|
if (clearOutputsOnExecute)
|
|
160
159
|
nb.clear();
|
|
161
160
|
// let busy state update prior to launching execute
|
|
@@ -180,21 +179,19 @@ function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
180
179
|
*
|
|
181
180
|
*/
|
|
182
181
|
const clear = (0, react_1.useCallback)(() => {
|
|
183
|
-
|
|
184
|
-
const nb = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
182
|
+
const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
185
183
|
nb.clear();
|
|
186
184
|
}, [state]);
|
|
187
185
|
/**
|
|
188
186
|
* resetAll resets all cells in all notebooks for a given rendering
|
|
189
187
|
*/
|
|
190
188
|
const reset = (0, react_1.useCallback)(() => {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
busy.setNotebook(pageSlug, notebookSlug, nb.cells.map((c) => c.id), 'reset');
|
|
189
|
+
const nb = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
190
|
+
busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'reset');
|
|
194
191
|
setTimeout(() => {
|
|
195
|
-
var _a;
|
|
192
|
+
var _a, _b;
|
|
196
193
|
nb.reset();
|
|
197
|
-
(_a = session === null ||
|
|
194
|
+
(_b = (_a = nb.session) === null || _a === void 0 ? void 0 : _a.kernel) === null || _b === void 0 ? void 0 : _b.restart().finally(() => {
|
|
198
195
|
busy.clearNotebook(pageSlug, notebookSlug, 'reset');
|
|
199
196
|
});
|
|
200
197
|
}, 300);
|
|
@@ -223,7 +220,7 @@ function useCellExecution(id) {
|
|
|
223
220
|
const busy = (0, busy_1.useBusyScope)();
|
|
224
221
|
const context = react_1.default.useContext(provider_1.ExecuteScopeContext);
|
|
225
222
|
if (context === undefined) {
|
|
226
|
-
throw new Error('
|
|
223
|
+
throw new Error('useCellExecution must be used within a ExecuteScopeProvider');
|
|
227
224
|
}
|
|
228
225
|
const { state, idkmap } = context;
|
|
229
226
|
const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -231,12 +228,9 @@ function useCellExecution(id) {
|
|
|
231
228
|
let cell;
|
|
232
229
|
let notebook;
|
|
233
230
|
if (target && state.pages[pageSlug]) {
|
|
234
|
-
notebook = state
|
|
235
|
-
if (
|
|
236
|
-
|
|
237
|
-
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
238
|
-
if (!cell)
|
|
239
|
-
console.error('no cell found', { pageSlug, notebookSlug, cellId });
|
|
231
|
+
notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
232
|
+
if (notebook)
|
|
233
|
+
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
240
234
|
}
|
|
241
235
|
const ready = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready;
|
|
242
236
|
const kind = (_d = (_c = context.state.pages[context.slug]) === null || _c === void 0 ? void 0 : _c.kind) !== null && _d !== void 0 ? _d : myst_common_1.SourceFileKind.Article;
|
|
@@ -270,6 +264,7 @@ function useCellExecution(id) {
|
|
|
270
264
|
const notebookIsResetting = busy.notebook(pageSlug, notebookSlug, 'reset');
|
|
271
265
|
const notebookIsBusy = notebookIsExecuting || notebookIsResetting;
|
|
272
266
|
return {
|
|
267
|
+
canCompute: context.canCompute,
|
|
273
268
|
kind,
|
|
274
269
|
ready,
|
|
275
270
|
execute,
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QAoEA;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"}
|
package/dist/cjs/execute/leaf.js
CHANGED
|
@@ -84,8 +84,7 @@ function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
84
84
|
console.debug(`reconnected to session for ${pageSlug}/${notebookSlug}`, sesh);
|
|
85
85
|
console.debug('restarting session', sesh);
|
|
86
86
|
(_a = sesh.kernel) === null || _a === void 0 ? void 0 : _a.restart().then(() => {
|
|
87
|
-
|
|
88
|
-
const notebook = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug].notebook;
|
|
87
|
+
const notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
89
88
|
notebook.attachSession(sesh);
|
|
90
89
|
dispatch({ type: 'ADD_SESSION', payload: { pageSlug, notebookSlug, session: sesh } });
|
|
91
90
|
});
|
|
@@ -95,7 +94,6 @@ function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
95
94
|
server
|
|
96
95
|
.startNewSession(scope.rendermime, Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.kernels), { name: `${pageSlug}-${notebookSlug}.ipynb`, path }))
|
|
97
96
|
.then((sesh) => {
|
|
98
|
-
var _a;
|
|
99
97
|
if (sesh == null) {
|
|
100
98
|
server === null || server === void 0 ? void 0 : server.getKernelSpecs().then((specs) => {
|
|
101
99
|
console.error(`Could not start session for ${pageSlug} ${notebookSlug}`);
|
|
@@ -104,7 +102,7 @@ function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
104
102
|
return;
|
|
105
103
|
}
|
|
106
104
|
console.debug(`session started for ${pageSlug}/${notebookSlug}`, sesh);
|
|
107
|
-
const notebook = (
|
|
105
|
+
const notebook = (0, selectors_1.selectNotebookForPage)(state, pageSlug, notebookSlug);
|
|
108
106
|
notebook.attachSession(sesh);
|
|
109
107
|
dispatch({ type: 'ADD_SESSION', payload: { pageSlug, notebookSlug, session: sesh } });
|
|
110
108
|
});
|
|
@@ -4,7 +4,9 @@ import type { Root } from 'mdast';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import type { ExecuteScopeAction } from './actions';
|
|
6
6
|
import type { ExecuteScopeState, IdKeyMap } from './types';
|
|
7
|
+
import type { Thebe } from 'myst-frontmatter';
|
|
7
8
|
export interface ExecuteScopeType {
|
|
9
|
+
canCompute: boolean;
|
|
8
10
|
slug: string;
|
|
9
11
|
state: ExecuteScopeState;
|
|
10
12
|
dispatch: React.Dispatch<ExecuteScopeAction>;
|
|
@@ -16,6 +18,9 @@ type ArticleContents = {
|
|
|
16
18
|
kind: SourceFileKind;
|
|
17
19
|
mdast: Root;
|
|
18
20
|
dependencies?: Dependency[];
|
|
21
|
+
frontmatter: {
|
|
22
|
+
thebe?: boolean | Thebe;
|
|
23
|
+
};
|
|
19
24
|
};
|
|
20
25
|
/**
|
|
21
26
|
* The ExecuteScopeProvider is responsible for maintaining the state of the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE,CAAC;CAC1C,CAAC;AA8DF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAiGxD"}
|
|
@@ -31,6 +31,7 @@ const unist_util_select_1 = require("unist-util-select");
|
|
|
31
31
|
const reducer_1 = require("./reducer");
|
|
32
32
|
const selectors_1 = require("./selectors");
|
|
33
33
|
const leaf_1 = require("./leaf");
|
|
34
|
+
const __1 = require("..");
|
|
34
35
|
exports.ExecuteScopeContext = react_1.default.createContext(undefined);
|
|
35
36
|
function useScopeNavigate({ contents: { slug, kind, mdast, dependencies }, state, dispatch, }) {
|
|
36
37
|
(0, react_1.useEffect)(() => {
|
|
@@ -82,6 +83,7 @@ function useExecutionScopeFetcher({ slug, state, dispatch, }) {
|
|
|
82
83
|
*/
|
|
83
84
|
function ExecuteScopeProvider({ children, contents, }) {
|
|
84
85
|
var _a;
|
|
86
|
+
const canCompute = (0, __1.useCanCompute)(contents);
|
|
85
87
|
// compute incoming for first render
|
|
86
88
|
const computables = (0, unist_util_select_1.selectAll)('container > embed', contents.mdast).map((node) => {
|
|
87
89
|
const { key, label, source } = node;
|
|
@@ -117,7 +119,7 @@ function ExecuteScopeProvider({ children, contents, }) {
|
|
|
117
119
|
const fetchTargets = (0, selectors_1.selectDependenciesToFetch)(state);
|
|
118
120
|
const notebookBuildTargets = (0, selectors_1.selectScopeNotebooksToBuild)(state);
|
|
119
121
|
const sessionStartTargets = (0, selectors_1.selectSessionsToStart)(state);
|
|
120
|
-
const memo = react_1.default.useMemo(() => ({ slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
|
|
122
|
+
const memo = react_1.default.useMemo(() => ({ canCompute, slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
|
|
121
123
|
if (typeof window !== 'undefined') {
|
|
122
124
|
window.executeScope = memo;
|
|
123
125
|
}
|
|
@@ -15,6 +15,7 @@ exports.reducer = void 0;
|
|
|
15
15
|
const myst_common_1 = require("myst-common");
|
|
16
16
|
const actions_1 = require("./actions");
|
|
17
17
|
function reducer(state, action) {
|
|
18
|
+
var _a;
|
|
18
19
|
switch (action.type) {
|
|
19
20
|
case 'NAVIGATE': {
|
|
20
21
|
if (!(0, actions_1.isNavigatePayload)(action.payload)) {
|
|
@@ -79,7 +80,7 @@ function reducer(state, action) {
|
|
|
79
80
|
if (!state.builds[slug])
|
|
80
81
|
return state;
|
|
81
82
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
82
|
-
const
|
|
83
|
+
const _b = state.builds, _c = slug, _ = _b[_c], builds = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
83
84
|
return Object.assign(Object.assign({}, state), { builds });
|
|
84
85
|
}
|
|
85
86
|
case 'SET_RENDERING_READY': {
|
|
@@ -91,7 +92,7 @@ function reducer(state, action) {
|
|
|
91
92
|
if (state.pages[slug].ready)
|
|
92
93
|
return state;
|
|
93
94
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
94
|
-
const
|
|
95
|
+
const _d = state.builds, _e = slug, _ = _d[_e], builds = __rest(_d, [typeof _e === "symbol" ? _e : _e + ""]);
|
|
95
96
|
const newState = Object.assign(Object.assign({}, state), { builds, pages: Object.assign(Object.assign({}, state.pages), { [slug]: Object.assign(Object.assign({}, state.pages[slug]), { ready: true }) }) });
|
|
96
97
|
return newState;
|
|
97
98
|
}
|
|
@@ -124,7 +125,7 @@ function reducer(state, action) {
|
|
|
124
125
|
console.error(state, action.payload);
|
|
125
126
|
throw new Error('Trying to add session when there is no rendering state');
|
|
126
127
|
}
|
|
127
|
-
if (state.pages[pageSlug].scopes[notebookSlug].session) {
|
|
128
|
+
if ((_a = state.pages[pageSlug].scopes[notebookSlug]) === null || _a === void 0 ? void 0 : _a.session) {
|
|
128
129
|
console.warn('Trying to add session scope when rendering already has one', action.payload);
|
|
129
130
|
return state;
|
|
130
131
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BuildStatus, ExecuteScopeState } from './types';
|
|
2
|
+
export declare function selectScopeForPage(state: ExecuteScopeState, pageSlug: string): {
|
|
3
|
+
[notebookSlug: string]: import("./types").ExecutionScope;
|
|
4
|
+
};
|
|
5
|
+
export declare function selectNotebookForPage(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): import("thebe-core/dist/types/notebook").default;
|
|
2
6
|
export declare function selectIsComputable(state: ExecuteScopeState, slug: string): boolean;
|
|
3
7
|
export declare function selectAreExecutionScopesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
4
8
|
export declare function selectAreExecutionScopesBuilding(state: ExecuteScopeState, slug: string): boolean;
|
|
@@ -18,5 +22,4 @@ export declare const selectSessionsToStart: (state: ExecuteScopeState) => {
|
|
|
18
22
|
export declare function selectAreAllDependenciesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
19
23
|
export declare function selectAreAllNotebookScopesBuilt(state: ExecuteScopeState, slug: string): boolean;
|
|
20
24
|
export declare function selectAreAllSessionsStarted(state: ExecuteScopeState, slug: string): boolean;
|
|
21
|
-
export declare function selectNotebookCellIds(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): string[];
|
|
22
25
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM;;EAE5E;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,oDAGrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF"}
|
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.selectAreAllSessionsStarted = exports.selectAreAllNotebookScopesBuilt = exports.selectAreAllDependenciesReady = exports.selectSessionsToStart = exports.selectScopeNotebooksToBuild = exports.selectDependenciesToFetch = exports.selectExecutionScopeStatus = exports.selectAreExecutionScopesBuilding = exports.selectAreExecutionScopesReady = exports.selectIsComputable = exports.selectNotebookForPage = exports.selectScopeForPage = void 0;
|
|
4
4
|
const myst_common_1 = require("myst-common");
|
|
5
|
+
function selectScopeForPage(state, pageSlug) {
|
|
6
|
+
var _a, _b;
|
|
7
|
+
return (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes) !== null && _b !== void 0 ? _b : {};
|
|
8
|
+
}
|
|
9
|
+
exports.selectScopeForPage = selectScopeForPage;
|
|
10
|
+
function selectNotebookForPage(state, pageSlug, notebookSlug) {
|
|
11
|
+
var _a, _b;
|
|
12
|
+
return (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
13
|
+
}
|
|
14
|
+
exports.selectNotebookForPage = selectNotebookForPage;
|
|
5
15
|
function selectIsComputable(state, slug) {
|
|
6
16
|
var _a, _b;
|
|
7
17
|
return (_b = (_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.computable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -82,8 +92,3 @@ function selectAreAllSessionsStarted(state, slug) {
|
|
|
82
92
|
return rendering === null || rendering === void 0 ? void 0 : rendering.dependencies.every((dep) => { var _a, _b; return !!((_b = rendering.scopes[(_a = dep.slug) !== null && _a !== void 0 ? _a : dep.url]) === null || _b === void 0 ? void 0 : _b.session); });
|
|
83
93
|
}
|
|
84
94
|
exports.selectAreAllSessionsStarted = selectAreAllSessionsStarted;
|
|
85
|
-
function selectNotebookCellIds(state, pageSlug, notebookSlug) {
|
|
86
|
-
var _a, _b, _c, _d;
|
|
87
|
-
return (_d = (_c = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook) === null || _c === void 0 ? void 0 : _c.cells.map(({ id }) => id)) !== null && _d !== void 0 ? _d : [];
|
|
88
|
-
}
|
|
89
|
-
exports.selectNotebookCellIds = selectNotebookCellIds;
|
|
@@ -48,7 +48,7 @@ function notebookFromMdast(core, config, pageSlug, notebookSlug, mdast, idkmap,
|
|
|
48
48
|
idkmap[block.label] = target;
|
|
49
49
|
if (block.identifier)
|
|
50
50
|
idkmap[block.identifier] = target;
|
|
51
|
-
return new core.
|
|
51
|
+
return new core.ThebeCodeCell(target.cellId, notebook.id, (_a = codeCell.value) !== null && _a !== void 0 ? _a : '', config, (_b = block.data) !== null && _b !== void 0 ? _b : {}, notebook.rendermime);
|
|
52
52
|
}
|
|
53
53
|
else {
|
|
54
54
|
// assume content - concatenate it
|
package/dist/cjs/providers.d.ts
CHANGED
|
@@ -7,11 +7,16 @@ export declare function useComputeOptions(): {
|
|
|
7
7
|
githubBadgeUrl?: undefined;
|
|
8
8
|
binderBadgeUrl?: undefined;
|
|
9
9
|
} | {
|
|
10
|
-
canCompute: boolean;
|
|
11
10
|
thebe: import("./utils").ExtendedCoreOptions | undefined;
|
|
12
11
|
githubBadgeUrl: string | undefined;
|
|
13
12
|
binderBadgeUrl: string | undefined;
|
|
13
|
+
canCompute?: undefined;
|
|
14
14
|
};
|
|
15
|
+
export declare function useCanCompute(article: {
|
|
16
|
+
frontmatter: {
|
|
17
|
+
thebe?: boolean | Record<string, any>;
|
|
18
|
+
};
|
|
19
|
+
}): boolean;
|
|
15
20
|
export declare function ConfiguredThebeServerProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
16
21
|
export type PartialPage = {
|
|
17
22
|
kind: SourceFileKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;EAuBhC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,WAGhG;AAED,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,2CAalF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,CAAC"}
|
package/dist/cjs/providers.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ConfiguredThebeServerProvider = exports.useComputeOptions = void 0;
|
|
6
|
+
exports.ConfiguredThebeServerProvider = exports.useCanCompute = exports.useComputeOptions = void 0;
|
|
7
7
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
8
|
const react_1 = __importDefault(require("react"));
|
|
9
9
|
const thebe_react_1 = require("thebe-react");
|
|
@@ -23,8 +23,7 @@ function useComputeOptions() {
|
|
|
23
23
|
const binderBadgeUrl = mainProject === null || mainProject === void 0 ? void 0 : mainProject.binder;
|
|
24
24
|
const thebeOptions = (0, utils_1.thebeFrontmatterToOptions)(thebeFrontmatter, githubBadgeUrl, binderBadgeUrl);
|
|
25
25
|
return {
|
|
26
|
-
|
|
27
|
-
thebe: thebeOptions,
|
|
26
|
+
thebe: thebeFrontmatter ? thebeOptions : undefined,
|
|
28
27
|
githubBadgeUrl,
|
|
29
28
|
binderBadgeUrl,
|
|
30
29
|
};
|
|
@@ -32,6 +31,12 @@ function useComputeOptions() {
|
|
|
32
31
|
return react_1.default.useMemo(makeOptions, [config]);
|
|
33
32
|
}
|
|
34
33
|
exports.useComputeOptions = useComputeOptions;
|
|
34
|
+
function useCanCompute(article) {
|
|
35
|
+
var _a;
|
|
36
|
+
const { thebe } = useComputeOptions();
|
|
37
|
+
return !!thebe && ((_a = article.frontmatter) === null || _a === void 0 ? void 0 : _a.thebe) !== false;
|
|
38
|
+
}
|
|
39
|
+
exports.useCanCompute = useCanCompute;
|
|
35
40
|
function ConfiguredThebeServerProvider({ children }) {
|
|
36
41
|
const { thebe } = useComputeOptions();
|
|
37
42
|
return ((0, jsx_runtime_1.jsx)(thebe_react_1.ThebeServerProvider, { connect: false, options: thebe, useBinder: thebe === null || thebe === void 0 ? void 0 : thebe.useBinder, useJupyterLite: thebe === null || thebe === void 0 ? void 0 : thebe.useJupyterLite, children: children }));
|
package/dist/esm/BinderBadge.js
CHANGED
|
@@ -5,5 +5,5 @@ function BinderBadgeLogo() {
|
|
|
5
5
|
export function BinderBadge({ binder }) {
|
|
6
6
|
if (!binder)
|
|
7
7
|
return null;
|
|
8
|
-
return (_jsx("div", { className: "inline-block
|
|
8
|
+
return (_jsx("div", { className: "inline-block m-1 opacity-80 hover:opacity-100", children: _jsx("a", { href: binder, title: `Launch Binder Session: ${binder}`, target: "_blank", rel: "noopener noreferrer", className: "text-inherit hover:text-inherit", children: _jsx(BinderBadgeLogo, {}) }) }));
|
|
9
9
|
}
|
package/dist/esm/embed.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AA2E/D,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,2CAajE"}
|
package/dist/esm/embed.js
CHANGED
|
@@ -6,11 +6,15 @@ import { JupyterIcon } from '@scienceicons/react/24/solid';
|
|
|
6
6
|
import { select } from 'unist-util-select';
|
|
7
7
|
import { useLinkProvider, useBaseurl, withBaseurl } from '@myst-theme/providers';
|
|
8
8
|
function EmbedWithControls({ outputKey, children, title = 'Jupyter Notebook', url, }) {
|
|
9
|
-
const { kind } = useCellExecution(outputKey);
|
|
9
|
+
const { canCompute, kind } = useCellExecution(outputKey);
|
|
10
10
|
const Link = useLinkProvider();
|
|
11
11
|
const baseurl = useBaseurl();
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const showComputeControls = canCompute && kind === SourceFileKind.Article;
|
|
13
|
+
if (showComputeControls) {
|
|
14
|
+
return (_jsxs("div", { className: "shadow", children: [_jsx("div", { className: "sticky top-[60px] z-[2] w-full bg-gray-100/80 backdrop-blur dark:bg-neutral-800/80 py-1 px-2", children: _jsxs("div", { className: "flex items-center", children: [_jsxs("div", { className: "flex items-center", children: [_jsx(JupyterIcon, { className: "inline-block w-5 h-5" }), _jsx("span", { className: "ml-2", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, baseurl), className: "ml-2 no-underline text-normal hover:underline", children: title }))] }), _jsx("div", { className: "flex-grow" }), _jsx(ArticleStatusBadge, { id: outputKey }), _jsx(ArticleRunNotebook, { id: outputKey }), _jsx(ArticleResetNotebook, { id: outputKey })] }) }), _jsx("div", { className: "mt-2", children: children })] }));
|
|
15
|
+
}
|
|
16
|
+
// light
|
|
17
|
+
return (_jsxs(_Fragment, { children: [children, _jsxs("div", { className: "flex items-center justify-end text-xs", children: [_jsx(JupyterIcon, { className: "inline-block w-3 h-3" }), _jsx("div", { className: "ml-1", children: "Source:" }), url && (_jsx(Link, { to: withBaseurl(url, baseurl), className: "ml-1 no-underline text-normal hover:underline", children: title }))] })] }));
|
|
14
18
|
}
|
|
15
19
|
export function Embed(node, children) {
|
|
16
20
|
var _a, _b;
|
|
@@ -10,6 +10,7 @@ export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
|
|
|
10
10
|
clearAll: (pageSlug: string) => void;
|
|
11
11
|
resetAll: (pageSlug: string) => void;
|
|
12
12
|
execute: (slug: string) => void;
|
|
13
|
+
canCompute: boolean;
|
|
13
14
|
slug: string;
|
|
14
15
|
state: import("./types").ExecuteScopeState;
|
|
15
16
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -31,6 +32,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
31
32
|
notebookIsResetting: boolean;
|
|
32
33
|
notebookIsBusy: boolean;
|
|
33
34
|
executionCount: number | null | undefined;
|
|
35
|
+
canCompute: boolean;
|
|
34
36
|
slug: string;
|
|
35
37
|
state: import("./types").ExecuteScopeState;
|
|
36
38
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -43,6 +45,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
43
45
|
* @returns
|
|
44
46
|
*/
|
|
45
47
|
export declare function useCellExecution(id: IdOrKey): {
|
|
48
|
+
canCompute: boolean;
|
|
46
49
|
kind: SourceFileKind;
|
|
47
50
|
ready: boolean;
|
|
48
51
|
execute: () => void;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,aAAa,CAAC;AAG7C,wBAAgB,iBAAiB,CAAC,EAChC,qBAA6B,GAC9B,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO;;kBAUR,MAAM;yBAsD1B,MAAM;yBAYN,MAAM;oBAxDI,MAAM;;;;;;EAgF9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;;;;;;EA2G9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO;;;;;;;;;;;EAgE3C;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
|
|
@@ -12,6 +12,7 @@ import { ExecuteScopeContext } from './provider';
|
|
|
12
12
|
import { useBusyScope } from './busy';
|
|
13
13
|
import { findErrors, useThebeConfig } from 'thebe-react';
|
|
14
14
|
import { SourceFileKind } from 'myst-common';
|
|
15
|
+
import { selectNotebookForPage } from './selectors';
|
|
15
16
|
export function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
16
17
|
var _a;
|
|
17
18
|
const context = React.useContext(ExecuteScopeContext);
|
|
@@ -33,7 +34,7 @@ export function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
33
34
|
const execute = (slug) => {
|
|
34
35
|
// set busy
|
|
35
36
|
Object.entries(state.pages[slug].scopes).forEach(([notebookSlug, { notebook }]) => {
|
|
36
|
-
busy.setNotebook(slug, notebookSlug, notebook.
|
|
37
|
+
busy.setNotebook(slug, notebookSlug, notebook.code.map((c) => c.id), 'execute');
|
|
37
38
|
});
|
|
38
39
|
if (clearOutputsOnExecute) {
|
|
39
40
|
// clear all notebook cell outputs
|
|
@@ -66,7 +67,8 @@ export function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
66
67
|
*
|
|
67
68
|
*/
|
|
68
69
|
const clearAll = useCallback((pageSlug) => {
|
|
69
|
-
|
|
70
|
+
var _a;
|
|
71
|
+
Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([, { notebook }]) => {
|
|
70
72
|
notebook.clear();
|
|
71
73
|
});
|
|
72
74
|
}, [state]);
|
|
@@ -74,8 +76,9 @@ export function useExecutionScope({ clearOutputsOnExecute = false, } = {}) {
|
|
|
74
76
|
* resetAll resets all cells in all notebooks for a given rendering
|
|
75
77
|
*/
|
|
76
78
|
const resetAll = useCallback((pageSlug) => {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
+
var _a;
|
|
80
|
+
Object.entries((_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes).forEach(([notebookSlug, { notebook, session }]) => {
|
|
81
|
+
busy.setNotebook(pageSlug, notebookSlug, notebook.code.map((c) => c.id), 'reset');
|
|
79
82
|
setTimeout(() => {
|
|
80
83
|
var _a;
|
|
81
84
|
notebook.reset();
|
|
@@ -99,7 +102,7 @@ export function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
99
102
|
const { config } = useThebeConfig();
|
|
100
103
|
const busy = useBusyScope();
|
|
101
104
|
if (context === undefined) {
|
|
102
|
-
throw new Error('
|
|
105
|
+
throw new Error('useNotebookExecution must be used within a ExecuteScopeProvider');
|
|
103
106
|
}
|
|
104
107
|
const { state, dispatch, idkmap } = context;
|
|
105
108
|
const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -117,18 +120,14 @@ export function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
117
120
|
let cell;
|
|
118
121
|
let notebook;
|
|
119
122
|
if (target && state.pages[pageSlug]) {
|
|
120
|
-
notebook = state
|
|
121
|
-
if (
|
|
122
|
-
|
|
123
|
-
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
124
|
-
if (!cell)
|
|
125
|
-
console.error('no cell found', { pageSlug, notebookSlug, cellId });
|
|
123
|
+
notebook = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
124
|
+
if (notebook)
|
|
125
|
+
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
126
126
|
}
|
|
127
127
|
const execute = () => {
|
|
128
|
-
|
|
129
|
-
const nb = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
128
|
+
const nb = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
130
129
|
// set busy
|
|
131
|
-
busy.setNotebook(pageSlug, notebookSlug, nb.
|
|
130
|
+
busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'execute');
|
|
132
131
|
if (clearOutputsOnExecute)
|
|
133
132
|
nb.clear();
|
|
134
133
|
// let busy state update prior to launching execute
|
|
@@ -153,21 +152,19 @@ export function useNotebookExecution(id, clearOutputsOnExecute = false) {
|
|
|
153
152
|
*
|
|
154
153
|
*/
|
|
155
154
|
const clear = useCallback(() => {
|
|
156
|
-
|
|
157
|
-
const nb = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
155
|
+
const nb = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
158
156
|
nb.clear();
|
|
159
157
|
}, [state]);
|
|
160
158
|
/**
|
|
161
159
|
* resetAll resets all cells in all notebooks for a given rendering
|
|
162
160
|
*/
|
|
163
161
|
const reset = useCallback(() => {
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
busy.setNotebook(pageSlug, notebookSlug, nb.cells.map((c) => c.id), 'reset');
|
|
162
|
+
const nb = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
163
|
+
busy.setNotebook(pageSlug, notebookSlug, nb.code.map((c) => c.id), 'reset');
|
|
167
164
|
setTimeout(() => {
|
|
168
|
-
var _a;
|
|
165
|
+
var _a, _b;
|
|
169
166
|
nb.reset();
|
|
170
|
-
(_a = session === null ||
|
|
167
|
+
(_b = (_a = nb.session) === null || _a === void 0 ? void 0 : _a.kernel) === null || _b === void 0 ? void 0 : _b.restart().finally(() => {
|
|
171
168
|
busy.clearNotebook(pageSlug, notebookSlug, 'reset');
|
|
172
169
|
});
|
|
173
170
|
}, 300);
|
|
@@ -195,7 +192,7 @@ export function useCellExecution(id) {
|
|
|
195
192
|
const busy = useBusyScope();
|
|
196
193
|
const context = React.useContext(ExecuteScopeContext);
|
|
197
194
|
if (context === undefined) {
|
|
198
|
-
throw new Error('
|
|
195
|
+
throw new Error('useCellExecution must be used within a ExecuteScopeProvider');
|
|
199
196
|
}
|
|
200
197
|
const { state, idkmap } = context;
|
|
201
198
|
const target = (_a = idkmap[id]) !== null && _a !== void 0 ? _a : {};
|
|
@@ -203,12 +200,9 @@ export function useCellExecution(id) {
|
|
|
203
200
|
let cell;
|
|
204
201
|
let notebook;
|
|
205
202
|
if (target && state.pages[pageSlug]) {
|
|
206
|
-
notebook = state
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
210
|
-
if (!cell)
|
|
211
|
-
console.error('no cell found', { pageSlug, notebookSlug, cellId });
|
|
203
|
+
notebook = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
204
|
+
if (notebook)
|
|
205
|
+
cell = notebook === null || notebook === void 0 ? void 0 : notebook.getCellById(cellId);
|
|
212
206
|
}
|
|
213
207
|
const ready = (_b = context.state.pages[context.slug]) === null || _b === void 0 ? void 0 : _b.ready;
|
|
214
208
|
const kind = (_d = (_c = context.state.pages[context.slug]) === null || _c === void 0 ? void 0 : _c.kind) !== null && _d !== void 0 ? _d : SourceFileKind.Article;
|
|
@@ -242,6 +236,7 @@ export function useCellExecution(id) {
|
|
|
242
236
|
const notebookIsResetting = busy.notebook(pageSlug, notebookSlug, 'reset');
|
|
243
237
|
const notebookIsBusy = notebookIsExecuting || notebookIsResetting;
|
|
244
238
|
return {
|
|
239
|
+
canCompute: context.canCompute,
|
|
245
240
|
kind,
|
|
246
241
|
ready,
|
|
247
242
|
execute,
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QAoEA;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"}
|
package/dist/esm/execute/leaf.js
CHANGED
|
@@ -2,7 +2,7 @@ import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useRef } from 'react';
|
|
3
3
|
import { useThebeLoader, useThebeConfig, useThebeServer } from 'thebe-react';
|
|
4
4
|
import { notebookFromMdast } from './utils';
|
|
5
|
-
import { selectAreAllNotebookScopesBuilt, selectAreAllSessionsStarted } from './selectors';
|
|
5
|
+
import { selectAreAllNotebookScopesBuilt, selectAreAllSessionsStarted, selectNotebookForPage, } from './selectors';
|
|
6
6
|
import { useFetchMdast } from 'myst-to-react';
|
|
7
7
|
export function MdastFetcher({ slug, url, dispatch, }) {
|
|
8
8
|
const { data, error } = useFetchMdast({ remote: true, dataUrl: `${url}.json` });
|
|
@@ -79,8 +79,7 @@ export function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
79
79
|
console.debug(`reconnected to session for ${pageSlug}/${notebookSlug}`, sesh);
|
|
80
80
|
console.debug('restarting session', sesh);
|
|
81
81
|
(_a = sesh.kernel) === null || _a === void 0 ? void 0 : _a.restart().then(() => {
|
|
82
|
-
|
|
83
|
-
const notebook = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug].notebook;
|
|
82
|
+
const notebook = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
84
83
|
notebook.attachSession(sesh);
|
|
85
84
|
dispatch({ type: 'ADD_SESSION', payload: { pageSlug, notebookSlug, session: sesh } });
|
|
86
85
|
});
|
|
@@ -90,7 +89,6 @@ export function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
90
89
|
server
|
|
91
90
|
.startNewSession(scope.rendermime, Object.assign(Object.assign({}, config === null || config === void 0 ? void 0 : config.kernels), { name: `${pageSlug}-${notebookSlug}.ipynb`, path }))
|
|
92
91
|
.then((sesh) => {
|
|
93
|
-
var _a;
|
|
94
92
|
if (sesh == null) {
|
|
95
93
|
server === null || server === void 0 ? void 0 : server.getKernelSpecs().then((specs) => {
|
|
96
94
|
console.error(`Could not start session for ${pageSlug} ${notebookSlug}`);
|
|
@@ -99,7 +97,7 @@ export function SessionStarter({ pageSlug, notebookSlug, state, dispatch, }) {
|
|
|
99
97
|
return;
|
|
100
98
|
}
|
|
101
99
|
console.debug(`session started for ${pageSlug}/${notebookSlug}`, sesh);
|
|
102
|
-
const notebook = (
|
|
100
|
+
const notebook = selectNotebookForPage(state, pageSlug, notebookSlug);
|
|
103
101
|
notebook.attachSession(sesh);
|
|
104
102
|
dispatch({ type: 'ADD_SESSION', payload: { pageSlug, notebookSlug, session: sesh } });
|
|
105
103
|
});
|
|
@@ -4,7 +4,9 @@ import type { Root } from 'mdast';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import type { ExecuteScopeAction } from './actions';
|
|
6
6
|
import type { ExecuteScopeState, IdKeyMap } from './types';
|
|
7
|
+
import type { Thebe } from 'myst-frontmatter';
|
|
7
8
|
export interface ExecuteScopeType {
|
|
9
|
+
canCompute: boolean;
|
|
8
10
|
slug: string;
|
|
9
11
|
state: ExecuteScopeState;
|
|
10
12
|
dispatch: React.Dispatch<ExecuteScopeAction>;
|
|
@@ -16,6 +18,9 @@ type ArticleContents = {
|
|
|
16
18
|
kind: SourceFileKind;
|
|
17
19
|
mdast: Root;
|
|
18
20
|
dependencies?: Dependency[];
|
|
21
|
+
frontmatter: {
|
|
22
|
+
thebe?: boolean | Thebe;
|
|
23
|
+
};
|
|
19
24
|
};
|
|
20
25
|
/**
|
|
21
26
|
* The ExecuteScopeProvider is responsible for maintaining the state of the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE,CAAC;CAC1C,CAAC;AA8DF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAiGxD"}
|
|
@@ -5,6 +5,7 @@ import { selectAll } from 'unist-util-select';
|
|
|
5
5
|
import { reducer } from './reducer';
|
|
6
6
|
import { selectAreAllDependenciesReady, selectDependenciesToFetch, selectScopeNotebooksToBuild, selectSessionsToStart, } from './selectors';
|
|
7
7
|
import { MdastFetcher, NotebookBuilder, ServerMonitor, SessionStarter } from './leaf';
|
|
8
|
+
import { useCanCompute } from '..';
|
|
8
9
|
export const ExecuteScopeContext = React.createContext(undefined);
|
|
9
10
|
function useScopeNavigate({ contents: { slug, kind, mdast, dependencies }, state, dispatch, }) {
|
|
10
11
|
useEffect(() => {
|
|
@@ -56,6 +57,7 @@ function useExecutionScopeFetcher({ slug, state, dispatch, }) {
|
|
|
56
57
|
*/
|
|
57
58
|
export function ExecuteScopeProvider({ children, contents, }) {
|
|
58
59
|
var _a;
|
|
60
|
+
const canCompute = useCanCompute(contents);
|
|
59
61
|
// compute incoming for first render
|
|
60
62
|
const computables = selectAll('container > embed', contents.mdast).map((node) => {
|
|
61
63
|
const { key, label, source } = node;
|
|
@@ -91,7 +93,7 @@ export function ExecuteScopeProvider({ children, contents, }) {
|
|
|
91
93
|
const fetchTargets = selectDependenciesToFetch(state);
|
|
92
94
|
const notebookBuildTargets = selectScopeNotebooksToBuild(state);
|
|
93
95
|
const sessionStartTargets = selectSessionsToStart(state);
|
|
94
|
-
const memo = React.useMemo(() => ({ slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
|
|
96
|
+
const memo = React.useMemo(() => ({ canCompute, slug: contents.slug, state, dispatch, idkmap: idkmap.current }), [state, contents.slug]);
|
|
95
97
|
if (typeof window !== 'undefined') {
|
|
96
98
|
window.executeScope = memo;
|
|
97
99
|
}
|
|
@@ -12,6 +12,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
12
12
|
import { SourceFileKind } from 'myst-common';
|
|
13
13
|
import { isAddMdastPayload, isAddNotebookPayload, isAddSessionPayload, isBuildStatusPayload, isNavigatePayload, isSlugPayload, } from './actions';
|
|
14
14
|
export function reducer(state, action) {
|
|
15
|
+
var _a;
|
|
15
16
|
switch (action.type) {
|
|
16
17
|
case 'NAVIGATE': {
|
|
17
18
|
if (!isNavigatePayload(action.payload)) {
|
|
@@ -76,7 +77,7 @@ export function reducer(state, action) {
|
|
|
76
77
|
if (!state.builds[slug])
|
|
77
78
|
return state;
|
|
78
79
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
-
const
|
|
80
|
+
const _b = state.builds, _c = slug, _ = _b[_c], builds = __rest(_b, [typeof _c === "symbol" ? _c : _c + ""]);
|
|
80
81
|
return Object.assign(Object.assign({}, state), { builds });
|
|
81
82
|
}
|
|
82
83
|
case 'SET_RENDERING_READY': {
|
|
@@ -88,7 +89,7 @@ export function reducer(state, action) {
|
|
|
88
89
|
if (state.pages[slug].ready)
|
|
89
90
|
return state;
|
|
90
91
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
-
const
|
|
92
|
+
const _d = state.builds, _e = slug, _ = _d[_e], builds = __rest(_d, [typeof _e === "symbol" ? _e : _e + ""]);
|
|
92
93
|
const newState = Object.assign(Object.assign({}, state), { builds, pages: Object.assign(Object.assign({}, state.pages), { [slug]: Object.assign(Object.assign({}, state.pages[slug]), { ready: true }) }) });
|
|
93
94
|
return newState;
|
|
94
95
|
}
|
|
@@ -121,7 +122,7 @@ export function reducer(state, action) {
|
|
|
121
122
|
console.error(state, action.payload);
|
|
122
123
|
throw new Error('Trying to add session when there is no rendering state');
|
|
123
124
|
}
|
|
124
|
-
if (state.pages[pageSlug].scopes[notebookSlug].session) {
|
|
125
|
+
if ((_a = state.pages[pageSlug].scopes[notebookSlug]) === null || _a === void 0 ? void 0 : _a.session) {
|
|
125
126
|
console.warn('Trying to add session scope when rendering already has one', action.payload);
|
|
126
127
|
return state;
|
|
127
128
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BuildStatus, ExecuteScopeState } from './types';
|
|
2
|
+
export declare function selectScopeForPage(state: ExecuteScopeState, pageSlug: string): {
|
|
3
|
+
[notebookSlug: string]: import("./types").ExecutionScope;
|
|
4
|
+
};
|
|
5
|
+
export declare function selectNotebookForPage(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): import("thebe-core/dist/types/notebook").default;
|
|
2
6
|
export declare function selectIsComputable(state: ExecuteScopeState, slug: string): boolean;
|
|
3
7
|
export declare function selectAreExecutionScopesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
4
8
|
export declare function selectAreExecutionScopesBuilding(state: ExecuteScopeState, slug: string): boolean;
|
|
@@ -18,5 +22,4 @@ export declare const selectSessionsToStart: (state: ExecuteScopeState) => {
|
|
|
18
22
|
export declare function selectAreAllDependenciesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
19
23
|
export declare function selectAreAllNotebookScopesBuilt(state: ExecuteScopeState, slug: string): boolean;
|
|
20
24
|
export declare function selectAreAllSessionsStarted(state: ExecuteScopeState, slug: string): boolean;
|
|
21
|
-
export declare function selectNotebookCellIds(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): string[];
|
|
22
25
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM;;EAE5E;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,oDAGrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF"}
|
|
@@ -1,4 +1,12 @@
|
|
|
1
1
|
import { SourceFileKind } from 'myst-common';
|
|
2
|
+
export function selectScopeForPage(state, pageSlug) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
return (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes) !== null && _b !== void 0 ? _b : {};
|
|
5
|
+
}
|
|
6
|
+
export function selectNotebookForPage(state, pageSlug, notebookSlug) {
|
|
7
|
+
var _a, _b;
|
|
8
|
+
return (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook;
|
|
9
|
+
}
|
|
2
10
|
export function selectIsComputable(state, slug) {
|
|
3
11
|
var _a, _b;
|
|
4
12
|
return (_b = (_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.computable) !== null && _b !== void 0 ? _b : false;
|
|
@@ -71,7 +79,3 @@ export function selectAreAllSessionsStarted(state, slug) {
|
|
|
71
79
|
// TODO is this working??
|
|
72
80
|
return rendering === null || rendering === void 0 ? void 0 : rendering.dependencies.every((dep) => { var _a, _b; return !!((_b = rendering.scopes[(_a = dep.slug) !== null && _a !== void 0 ? _a : dep.url]) === null || _b === void 0 ? void 0 : _b.session); });
|
|
73
81
|
}
|
|
74
|
-
export function selectNotebookCellIds(state, pageSlug, notebookSlug) {
|
|
75
|
-
var _a, _b, _c, _d;
|
|
76
|
-
return (_d = (_c = (_b = (_a = state.pages[pageSlug]) === null || _a === void 0 ? void 0 : _a.scopes[notebookSlug]) === null || _b === void 0 ? void 0 : _b.notebook) === null || _c === void 0 ? void 0 : _c.cells.map(({ id }) => id)) !== null && _d !== void 0 ? _d : [];
|
|
77
|
-
}
|
|
@@ -45,7 +45,7 @@ export function notebookFromMdast(core, config, pageSlug, notebookSlug, mdast, i
|
|
|
45
45
|
idkmap[block.label] = target;
|
|
46
46
|
if (block.identifier)
|
|
47
47
|
idkmap[block.identifier] = target;
|
|
48
|
-
return new core.
|
|
48
|
+
return new core.ThebeCodeCell(target.cellId, notebook.id, (_a = codeCell.value) !== null && _a !== void 0 ? _a : '', config, (_b = block.data) !== null && _b !== void 0 ? _b : {}, notebook.rendermime);
|
|
49
49
|
}
|
|
50
50
|
else {
|
|
51
51
|
// assume content - concatenate it
|
package/dist/esm/providers.d.ts
CHANGED
|
@@ -7,11 +7,16 @@ export declare function useComputeOptions(): {
|
|
|
7
7
|
githubBadgeUrl?: undefined;
|
|
8
8
|
binderBadgeUrl?: undefined;
|
|
9
9
|
} | {
|
|
10
|
-
canCompute: boolean;
|
|
11
10
|
thebe: import("./utils").ExtendedCoreOptions | undefined;
|
|
12
11
|
githubBadgeUrl: string | undefined;
|
|
13
12
|
binderBadgeUrl: string | undefined;
|
|
13
|
+
canCompute?: undefined;
|
|
14
14
|
};
|
|
15
|
+
export declare function useCanCompute(article: {
|
|
16
|
+
frontmatter: {
|
|
17
|
+
thebe?: boolean | Record<string, any>;
|
|
18
|
+
};
|
|
19
|
+
}): boolean;
|
|
15
20
|
export declare function ConfiguredThebeServerProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
16
21
|
export type PartialPage = {
|
|
17
22
|
kind: SourceFileKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;EAuBhC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,WAGhG;AAED,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,2CAalF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,CAAC"}
|
package/dist/esm/providers.js
CHANGED
|
@@ -17,14 +17,18 @@ export function useComputeOptions() {
|
|
|
17
17
|
const binderBadgeUrl = mainProject === null || mainProject === void 0 ? void 0 : mainProject.binder;
|
|
18
18
|
const thebeOptions = thebeFrontmatterToOptions(thebeFrontmatter, githubBadgeUrl, binderBadgeUrl);
|
|
19
19
|
return {
|
|
20
|
-
|
|
21
|
-
thebe: thebeOptions,
|
|
20
|
+
thebe: thebeFrontmatter ? thebeOptions : undefined,
|
|
22
21
|
githubBadgeUrl,
|
|
23
22
|
binderBadgeUrl,
|
|
24
23
|
};
|
|
25
24
|
};
|
|
26
25
|
return React.useMemo(makeOptions, [config]);
|
|
27
26
|
}
|
|
27
|
+
export function useCanCompute(article) {
|
|
28
|
+
var _a;
|
|
29
|
+
const { thebe } = useComputeOptions();
|
|
30
|
+
return !!thebe && ((_a = article.frontmatter) === null || _a === void 0 ? void 0 : _a.thebe) !== false;
|
|
31
|
+
}
|
|
28
32
|
export function ConfiguredThebeServerProvider({ children }) {
|
|
29
33
|
const { thebe } = useComputeOptions();
|
|
30
34
|
return (_jsx(ThebeServerProvider, { connect: false, options: thebe, useBinder: thebe === null || thebe === void 0 ? void 0 : thebe.useBinder, useJupyterLite: thebe === null || thebe === void 0 ? void 0 : thebe.useJupyterLite, children: children }));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"embed.d.ts","sourceRoot":"","sources":["../../src/embed.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AA2E/D,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,EAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,2CAajE"}
|
|
@@ -10,6 +10,7 @@ export declare function useExecutionScope({ clearOutputsOnExecute, }?: {
|
|
|
10
10
|
clearAll: (pageSlug: string) => void;
|
|
11
11
|
resetAll: (pageSlug: string) => void;
|
|
12
12
|
execute: (slug: string) => void;
|
|
13
|
+
canCompute: boolean;
|
|
13
14
|
slug: string;
|
|
14
15
|
state: import("./types").ExecuteScopeState;
|
|
15
16
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -31,6 +32,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
31
32
|
notebookIsResetting: boolean;
|
|
32
33
|
notebookIsBusy: boolean;
|
|
33
34
|
executionCount: number | null | undefined;
|
|
35
|
+
canCompute: boolean;
|
|
34
36
|
slug: string;
|
|
35
37
|
state: import("./types").ExecuteScopeState;
|
|
36
38
|
dispatch: React.Dispatch<import("./actions").ExecuteScopeAction>;
|
|
@@ -43,6 +45,7 @@ export declare function useNotebookExecution(id: IdOrKey, clearOutputsOnExecute?
|
|
|
43
45
|
* @returns
|
|
44
46
|
*/
|
|
45
47
|
export declare function useCellExecution(id: IdOrKey): {
|
|
48
|
+
canCompute: boolean;
|
|
46
49
|
kind: SourceFileKind;
|
|
47
50
|
ready: boolean;
|
|
48
51
|
execute: () => void;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
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,aAAa,CAAC;AAG7C,wBAAgB,iBAAiB,CAAC,EAChC,qBAA6B,GAC9B,GAAE;IAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;CAAO;;kBAUR,MAAM;yBAsD1B,MAAM;yBAYN,MAAM;oBAxDI,MAAM;;;;;;EAgF9B;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO,EAAE,qBAAqB,UAAQ;;;;;;;;;;;;;;;;EA2G9E;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,EAAE,EAAE,OAAO;;;;;;;;;;;EAgE3C;AAED,wBAAgB,oBAAoB,CAAC,EAAE,EAAE,OAAO;;;;EAc/C;AAED,wBAAgB,iBAAiB,YAOhC"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,KAAK,EACL,QAAQ,GACT,EAAE;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;CAC9C,QAoEA;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"}
|
|
@@ -4,7 +4,9 @@ import type { Root } from 'mdast';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import type { ExecuteScopeAction } from './actions';
|
|
6
6
|
import type { ExecuteScopeState, IdKeyMap } from './types';
|
|
7
|
+
import type { Thebe } from 'myst-frontmatter';
|
|
7
8
|
export interface ExecuteScopeType {
|
|
9
|
+
canCompute: boolean;
|
|
8
10
|
slug: string;
|
|
9
11
|
state: ExecuteScopeState;
|
|
10
12
|
dispatch: React.Dispatch<ExecuteScopeAction>;
|
|
@@ -16,6 +18,9 @@ type ArticleContents = {
|
|
|
16
18
|
kind: SourceFileKind;
|
|
17
19
|
mdast: Root;
|
|
18
20
|
dependencies?: Dependency[];
|
|
21
|
+
frontmatter: {
|
|
22
|
+
thebe?: boolean | Thebe;
|
|
23
|
+
};
|
|
19
24
|
};
|
|
20
25
|
/**
|
|
21
26
|
* The ExecuteScopeProvider is responsible for maintaining the state of the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../../src/execute/provider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAwC,MAAM,OAAO,CAAC;AAE7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAc,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAUvE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAE9C,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,iBAAiB,CAAC;IACzB,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC7C,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,eAAO,MAAM,mBAAmB,6CAA+D,CAAC;AAEhG,KAAK,eAAe,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,cAAc,CAAC;IACrB,KAAK,EAAE,IAAI,CAAC;IACZ,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC;IAC5B,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAA;KAAE,CAAC;CAC1C,CAAC;AA8DF;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,QAAQ,EACR,QAAQ,GACT,EAAE,KAAK,CAAC,iBAAiB,CAAC;IAAE,QAAQ,EAAE,eAAe,CAAA;CAAE,CAAC,2CAiGxD"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { BuildStatus, ExecuteScopeState } from './types';
|
|
2
|
+
export declare function selectScopeForPage(state: ExecuteScopeState, pageSlug: string): {
|
|
3
|
+
[notebookSlug: string]: import("./types").ExecutionScope;
|
|
4
|
+
};
|
|
5
|
+
export declare function selectNotebookForPage(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): import("thebe-core/dist/types/notebook").default;
|
|
2
6
|
export declare function selectIsComputable(state: ExecuteScopeState, slug: string): boolean;
|
|
3
7
|
export declare function selectAreExecutionScopesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
4
8
|
export declare function selectAreExecutionScopesBuilding(state: ExecuteScopeState, slug: string): boolean;
|
|
@@ -18,5 +22,4 @@ export declare const selectSessionsToStart: (state: ExecuteScopeState) => {
|
|
|
18
22
|
export declare function selectAreAllDependenciesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
19
23
|
export declare function selectAreAllNotebookScopesBuilt(state: ExecuteScopeState, slug: string): boolean;
|
|
20
24
|
export declare function selectAreAllSessionsStarted(state: ExecuteScopeState, slug: string): boolean;
|
|
21
|
-
export declare function selectNotebookCellIds(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): string[];
|
|
22
25
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../../src/execute/selectors.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAE9D,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM;;EAE5E;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,oDAGrB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAExE;AAED,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,gCAAgC,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEtF;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,yBAEhF;AAQD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,iBAAiB;UAKpD,MAAM;SACP,MAAM;IAclB;AAsBD,eAAO,MAAM,2BAA2B,UAlBvB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAkBS,CAAC;AACzF,eAAO,MAAM,qBAAqB,UAnBjB,iBAAiB,KAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,EAmBC,CAAC;AAEjF,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAEnF;AAED,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAGrF;AAED,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,iBAAiB,EAAE,IAAI,EAAE,MAAM,WAIjF"}
|
|
@@ -7,11 +7,16 @@ export declare function useComputeOptions(): {
|
|
|
7
7
|
githubBadgeUrl?: undefined;
|
|
8
8
|
binderBadgeUrl?: undefined;
|
|
9
9
|
} | {
|
|
10
|
-
canCompute: boolean;
|
|
11
10
|
thebe: import("./utils").ExtendedCoreOptions | undefined;
|
|
12
11
|
githubBadgeUrl: string | undefined;
|
|
13
12
|
binderBadgeUrl: string | undefined;
|
|
13
|
+
canCompute?: undefined;
|
|
14
14
|
};
|
|
15
|
+
export declare function useCanCompute(article: {
|
|
16
|
+
frontmatter: {
|
|
17
|
+
thebe?: boolean | Record<string, any>;
|
|
18
|
+
};
|
|
19
|
+
}): boolean;
|
|
15
20
|
export declare function ConfiguredThebeServerProvider({ children }: React.PropsWithChildren): import("react/jsx-runtime").JSX.Element;
|
|
16
21
|
export type PartialPage = {
|
|
17
22
|
kind: SourceFileKind;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAIlC,wBAAgB,iBAAiB;;;;;;;;;;EAuBhC;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE;IAAE,WAAW,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,CAAA;CAAE,WAGhG;AAED,wBAAgB,6BAA6B,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,CAAC,iBAAiB,2CAalF;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,cAAc,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,IAAI,CAAC;CACb,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myst-theme/jupyter",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.8",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@headlessui/react": "^1.7.15",
|
|
25
25
|
"@heroicons/react": "^2.0.18",
|
|
26
|
-
"@myst-theme/providers": "^0.3.
|
|
26
|
+
"@myst-theme/providers": "^0.3.8",
|
|
27
27
|
"ansi-to-react": "^6.1.6",
|
|
28
28
|
"buffer": "^6.0.3",
|
|
29
29
|
"classnames": "^2.3.2",
|
|
@@ -31,14 +31,14 @@
|
|
|
31
31
|
"myst-config": "^1.0.0",
|
|
32
32
|
"myst-frontmatter": "^1.0.0",
|
|
33
33
|
"myst-spec": "^0.0.4",
|
|
34
|
-
"myst-to-react": "^0.3.
|
|
34
|
+
"myst-to-react": "^0.3.8",
|
|
35
35
|
"nanoid": "^4.0.2",
|
|
36
36
|
"nbtx": "^0.2.3",
|
|
37
37
|
"react-syntax-highlighter": "^15.5.0",
|
|
38
38
|
"swr": "^2.1.5",
|
|
39
|
-
"thebe-core": "^0.
|
|
40
|
-
"thebe-lite": "^0.
|
|
41
|
-
"thebe-react": "^0.
|
|
39
|
+
"thebe-core": "^0.3.0",
|
|
40
|
+
"thebe-lite": "^0.3.0",
|
|
41
|
+
"thebe-react": "^0.3.0",
|
|
42
42
|
"unist-util-select": "^4.0.3"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|