@myst-theme/jupyter 0.3.3 → 0.3.4
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/ConnectionStatusTray.d.ts.map +1 -1
- package/dist/cjs/ConnectionStatusTray.js +6 -4
- package/dist/cjs/ErrorTray.d.ts +5 -0
- package/dist/cjs/ErrorTray.d.ts.map +1 -0
- package/dist/cjs/ErrorTray.js +34 -0
- package/dist/cjs/controls/ArticleCellControls.d.ts +10 -0
- package/dist/cjs/controls/ArticleCellControls.d.ts.map +1 -0
- package/dist/cjs/controls/ArticleCellControls.js +33 -0
- package/dist/cjs/controls/Buttons.d.ts +47 -0
- package/dist/cjs/controls/Buttons.d.ts.map +1 -0
- package/dist/cjs/controls/Buttons.js +70 -0
- package/dist/cjs/controls/NotebookCellControls.d.ts +10 -0
- package/dist/cjs/controls/NotebookCellControls.d.ts.map +1 -0
- package/dist/cjs/controls/NotebookCellControls.js +27 -0
- package/dist/cjs/controls/NotebookToolbar.d.ts +4 -0
- package/dist/cjs/controls/NotebookToolbar.d.ts.map +1 -0
- package/dist/cjs/controls/NotebookToolbar.js +47 -0
- package/dist/cjs/controls/Spinner.d.ts +4 -0
- package/dist/cjs/controls/Spinner.d.ts.map +1 -0
- package/dist/cjs/controls/Spinner.js +8 -0
- package/dist/cjs/controls/index.d.ts +5 -0
- package/dist/cjs/controls/index.d.ts.map +1 -0
- package/dist/cjs/controls/index.js +20 -0
- package/dist/cjs/execute/actions.d.ts +55 -0
- package/dist/cjs/execute/actions.d.ts.map +1 -0
- package/dist/cjs/execute/actions.js +49 -0
- package/dist/cjs/execute/busy.d.ts +74 -0
- package/dist/cjs/execute/busy.d.ts.map +1 -0
- package/dist/cjs/execute/busy.js +182 -0
- package/dist/cjs/execute/hooks.d.ts +62 -0
- package/dist/cjs/execute/hooks.d.ts.map +1 -0
- package/dist/cjs/execute/hooks.js +308 -0
- package/dist/cjs/execute/index.d.ts +7 -0
- package/dist/cjs/execute/index.d.ts.map +1 -0
- package/dist/cjs/execute/index.js +22 -0
- package/dist/cjs/execute/leaf.d.ts +26 -0
- package/dist/cjs/execute/leaf.d.ts.map +1 -0
- package/dist/cjs/execute/leaf.js +154 -0
- package/dist/cjs/execute/provider.d.ts +29 -0
- package/dist/cjs/execute/provider.d.ts.map +1 -0
- package/dist/cjs/execute/provider.js +126 -0
- package/dist/cjs/execute/reducer.d.ts +4 -0
- package/dist/cjs/execute/reducer.d.ts.map +1 -0
- package/dist/cjs/execute/reducer.js +136 -0
- package/dist/cjs/execute/selectors.d.ts +22 -0
- package/dist/cjs/execute/selectors.d.ts.map +1 -0
- package/dist/cjs/execute/selectors.js +89 -0
- package/dist/cjs/execute/types.d.ts +49 -0
- package/dist/cjs/execute/types.d.ts.map +1 -0
- package/dist/cjs/execute/types.js +2 -0
- package/dist/cjs/execute/utils.d.ts +23 -0
- package/dist/cjs/execute/utils.d.ts.map +1 -0
- package/dist/cjs/execute/utils.js +62 -0
- package/dist/cjs/index.d.ts +4 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/jupyter.d.ts.map +1 -1
- package/dist/cjs/jupyter.js +19 -17
- package/dist/cjs/output.d.ts +1 -1
- package/dist/cjs/output.d.ts.map +1 -1
- package/dist/cjs/output.js +7 -4
- package/dist/cjs/providers.d.ts +1 -48
- package/dist/cjs/providers.d.ts.map +1 -1
- package/dist/cjs/providers.js +4 -155
- package/dist/esm/ConnectionStatusTray.d.ts.map +1 -1
- package/dist/esm/ConnectionStatusTray.js +7 -5
- package/dist/esm/ErrorTray.d.ts +5 -0
- package/dist/esm/ErrorTray.d.ts.map +1 -0
- package/dist/esm/ErrorTray.js +30 -0
- package/dist/esm/controls/ArticleCellControls.d.ts +10 -0
- package/dist/esm/controls/ArticleCellControls.d.ts.map +1 -0
- package/dist/esm/controls/ArticleCellControls.js +27 -0
- package/dist/esm/controls/Buttons.d.ts +47 -0
- package/dist/esm/controls/Buttons.d.ts.map +1 -0
- package/dist/esm/controls/Buttons.js +57 -0
- package/dist/esm/controls/NotebookCellControls.d.ts +10 -0
- package/dist/esm/controls/NotebookCellControls.d.ts.map +1 -0
- package/dist/esm/controls/NotebookCellControls.js +21 -0
- package/dist/esm/controls/NotebookToolbar.d.ts +4 -0
- package/dist/esm/controls/NotebookToolbar.d.ts.map +1 -0
- package/dist/esm/controls/NotebookToolbar.js +40 -0
- package/dist/esm/controls/Spinner.d.ts +4 -0
- package/dist/esm/controls/Spinner.d.ts.map +1 -0
- package/dist/esm/controls/Spinner.js +4 -0
- package/dist/esm/controls/index.d.ts +5 -0
- package/dist/esm/controls/index.d.ts.map +1 -0
- package/dist/esm/controls/index.js +4 -0
- package/dist/esm/execute/actions.d.ts +55 -0
- package/dist/esm/execute/actions.d.ts.map +1 -0
- package/dist/esm/execute/actions.js +38 -0
- package/dist/esm/execute/busy.d.ts +74 -0
- package/dist/esm/execute/busy.d.ts.map +1 -0
- package/dist/esm/execute/busy.js +150 -0
- package/dist/esm/execute/hooks.d.ts +62 -0
- package/dist/esm/execute/hooks.d.ts.map +1 -0
- package/dist/esm/execute/hooks.js +277 -0
- package/dist/esm/execute/index.d.ts +7 -0
- package/dist/esm/execute/index.d.ts.map +1 -0
- package/dist/esm/execute/index.js +6 -0
- package/dist/esm/execute/leaf.d.ts +26 -0
- package/dist/esm/execute/leaf.d.ts.map +1 -0
- package/dist/esm/execute/leaf.js +147 -0
- package/dist/esm/execute/provider.d.ts +29 -0
- package/dist/esm/execute/provider.d.ts.map +1 -0
- package/dist/esm/execute/provider.js +99 -0
- package/dist/esm/execute/reducer.d.ts +4 -0
- package/dist/esm/execute/reducer.d.ts.map +1 -0
- package/dist/esm/execute/reducer.js +132 -0
- package/dist/esm/execute/selectors.d.ts +22 -0
- package/dist/esm/execute/selectors.d.ts.map +1 -0
- package/dist/esm/execute/selectors.js +77 -0
- package/dist/esm/execute/types.d.ts +49 -0
- package/dist/esm/execute/types.d.ts.map +1 -0
- package/dist/esm/execute/types.js +1 -0
- package/dist/esm/execute/utils.d.ts +23 -0
- package/dist/esm/execute/utils.d.ts.map +1 -0
- package/dist/esm/execute/utils.js +58 -0
- package/dist/esm/index.d.ts +4 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -1
- package/dist/esm/jupyter.d.ts.map +1 -1
- package/dist/esm/jupyter.js +17 -15
- package/dist/esm/output.d.ts +1 -1
- package/dist/esm/output.d.ts.map +1 -1
- package/dist/esm/output.js +8 -5
- package/dist/esm/providers.d.ts +1 -48
- package/dist/esm/providers.d.ts.map +1 -1
- package/dist/esm/providers.js +2 -126
- package/dist/types/ConnectionStatusTray.d.ts.map +1 -1
- package/dist/types/ErrorTray.d.ts +5 -0
- package/dist/types/ErrorTray.d.ts.map +1 -0
- package/dist/types/controls/ArticleCellControls.d.ts +10 -0
- package/dist/types/controls/ArticleCellControls.d.ts.map +1 -0
- package/dist/types/controls/Buttons.d.ts +47 -0
- package/dist/types/controls/Buttons.d.ts.map +1 -0
- package/dist/types/controls/NotebookCellControls.d.ts +10 -0
- package/dist/types/controls/NotebookCellControls.d.ts.map +1 -0
- package/dist/types/controls/NotebookToolbar.d.ts +4 -0
- package/dist/types/controls/NotebookToolbar.d.ts.map +1 -0
- package/dist/types/controls/Spinner.d.ts +4 -0
- package/dist/types/controls/Spinner.d.ts.map +1 -0
- package/dist/types/controls/index.d.ts +5 -0
- package/dist/types/controls/index.d.ts.map +1 -0
- package/dist/types/execute/actions.d.ts +55 -0
- package/dist/types/execute/actions.d.ts.map +1 -0
- package/dist/types/execute/busy.d.ts +74 -0
- package/dist/types/execute/busy.d.ts.map +1 -0
- package/dist/types/execute/hooks.d.ts +62 -0
- package/dist/types/execute/hooks.d.ts.map +1 -0
- package/dist/types/execute/index.d.ts +7 -0
- package/dist/types/execute/index.d.ts.map +1 -0
- package/dist/types/execute/leaf.d.ts +26 -0
- package/dist/types/execute/leaf.d.ts.map +1 -0
- package/dist/types/execute/provider.d.ts +29 -0
- package/dist/types/execute/provider.d.ts.map +1 -0
- package/dist/types/execute/reducer.d.ts +4 -0
- package/dist/types/execute/reducer.d.ts.map +1 -0
- package/dist/types/execute/selectors.d.ts +22 -0
- package/dist/types/execute/selectors.d.ts.map +1 -0
- package/dist/types/execute/types.d.ts +49 -0
- package/dist/types/execute/types.d.ts.map +1 -0
- package/dist/types/execute/utils.d.ts +23 -0
- package/dist/types/execute/utils.d.ts.map +1 -0
- package/dist/types/index.d.ts +4 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/jupyter.d.ts.map +1 -1
- package/dist/types/output.d.ts +1 -1
- package/dist/types/output.d.ts.map +1 -1
- package/dist/types/providers.d.ts +1 -48
- package/dist/types/providers.d.ts.map +1 -1
- package/package.json +9 -8
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import { SourceFileKind } from 'myst-common';
|
|
13
|
+
import { isAddMdastPayload, isAddNotebookPayload, isAddSessionPayload, isBuildStatusPayload, isNavigatePayload, isSlugPayload, } from './actions';
|
|
14
|
+
export function reducer(state, action) {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
case 'NAVIGATE': {
|
|
17
|
+
if (!isNavigatePayload(action.payload)) {
|
|
18
|
+
console.error(action.payload);
|
|
19
|
+
throw new Error('invalid NAVIGATE payload');
|
|
20
|
+
}
|
|
21
|
+
const { kind, slug, mdast, dependencies, computables } = action.payload;
|
|
22
|
+
if (state.pages[slug])
|
|
23
|
+
return state;
|
|
24
|
+
return Object.assign(Object.assign({}, state), { mdast: Object.assign(Object.assign({}, state.mdast), { [slug]: { root: mdast } }), pages: Object.assign(Object.assign({}, state.pages), { [slug]: {
|
|
25
|
+
kind,
|
|
26
|
+
slug,
|
|
27
|
+
dependencies,
|
|
28
|
+
computables,
|
|
29
|
+
computable: computables.length > 0 || kind === SourceFileKind.Notebook,
|
|
30
|
+
ready: false,
|
|
31
|
+
scopes: {},
|
|
32
|
+
} }) });
|
|
33
|
+
}
|
|
34
|
+
case 'ADD_MDAST': {
|
|
35
|
+
if (!isAddMdastPayload(action.payload)) {
|
|
36
|
+
console.error(action.payload);
|
|
37
|
+
throw new Error('invalid ADD_MDAST payload');
|
|
38
|
+
}
|
|
39
|
+
const { slug, mdast } = action.payload;
|
|
40
|
+
if (state.mdast[slug])
|
|
41
|
+
return state;
|
|
42
|
+
return Object.assign(Object.assign({}, state), { mdast: Object.assign(Object.assign({}, state.mdast), { [slug]: { root: mdast } }) });
|
|
43
|
+
}
|
|
44
|
+
case 'REQUEST_BUILD': {
|
|
45
|
+
if (!isSlugPayload(action.payload)) {
|
|
46
|
+
console.error(action.payload);
|
|
47
|
+
throw new Error('invalid REQUEST_BUILD payload');
|
|
48
|
+
}
|
|
49
|
+
const { slug } = action.payload;
|
|
50
|
+
if (!!state.builds[slug] && state.builds[slug].status === 'pending')
|
|
51
|
+
return state;
|
|
52
|
+
return Object.assign(Object.assign({}, state), { builds: Object.assign(Object.assign({}, state.builds), { [slug]: {
|
|
53
|
+
status: 'pending',
|
|
54
|
+
} }) });
|
|
55
|
+
}
|
|
56
|
+
case 'BUILD_STATUS': {
|
|
57
|
+
if (!isBuildStatusPayload(action.payload)) {
|
|
58
|
+
console.error(action.payload);
|
|
59
|
+
throw new Error('invalid BUILD_STATUS payload');
|
|
60
|
+
}
|
|
61
|
+
const { slug } = action.payload;
|
|
62
|
+
if (!state.builds[slug]) {
|
|
63
|
+
console.error(state, action.payload);
|
|
64
|
+
throw new Error('Trying to set build status when there is no build state');
|
|
65
|
+
}
|
|
66
|
+
if (state.builds[slug].status === action.payload.status)
|
|
67
|
+
return state;
|
|
68
|
+
return Object.assign(Object.assign({}, state), { builds: Object.assign(Object.assign({}, state.builds), { [slug]: Object.assign(Object.assign({}, state.builds[slug]), { status: action.payload.status }) }) });
|
|
69
|
+
}
|
|
70
|
+
case 'CLEAR_BUILD': {
|
|
71
|
+
if (!isSlugPayload(action.payload)) {
|
|
72
|
+
console.error(action.payload);
|
|
73
|
+
throw new Error('invalid CLEAR_BUILD payload');
|
|
74
|
+
}
|
|
75
|
+
const { slug } = action.payload;
|
|
76
|
+
if (!state.builds[slug])
|
|
77
|
+
return state;
|
|
78
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
79
|
+
const _a = state.builds, _b = slug, _ = _a[_b], builds = __rest(_a, [typeof _b === "symbol" ? _b : _b + ""]);
|
|
80
|
+
return Object.assign(Object.assign({}, state), { builds });
|
|
81
|
+
}
|
|
82
|
+
case 'SET_RENDERING_READY': {
|
|
83
|
+
if (!isSlugPayload(action.payload)) {
|
|
84
|
+
console.error(action.payload);
|
|
85
|
+
throw new Error('invalid SET_READY payload');
|
|
86
|
+
}
|
|
87
|
+
const { slug } = action.payload;
|
|
88
|
+
if (state.pages[slug].ready)
|
|
89
|
+
return state;
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
91
|
+
const _c = state.builds, _d = slug, _ = _c[_d], builds = __rest(_c, [typeof _d === "symbol" ? _d : _d + ""]);
|
|
92
|
+
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
|
+
return newState;
|
|
94
|
+
}
|
|
95
|
+
case 'ADD_NOTEBOOK': {
|
|
96
|
+
if (!isAddNotebookPayload(action.payload)) {
|
|
97
|
+
console.error(action.payload);
|
|
98
|
+
throw new Error('invalid ADD_NOTEBOOK payload');
|
|
99
|
+
}
|
|
100
|
+
const { pageSlug, notebookSlug, notebook, rendermime } = action.payload;
|
|
101
|
+
if (!state.pages[pageSlug]) {
|
|
102
|
+
console.error(state, action.payload);
|
|
103
|
+
throw new Error('Trying to add notebook when there is no rendering state');
|
|
104
|
+
}
|
|
105
|
+
if (state.pages[pageSlug].scopes[notebookSlug]) {
|
|
106
|
+
console.warn('Trying to add notebook scope when rendering already has one', action.payload);
|
|
107
|
+
return state;
|
|
108
|
+
}
|
|
109
|
+
return Object.assign(Object.assign({}, state), { pages: Object.assign(Object.assign({}, state.pages), { [pageSlug]: Object.assign(Object.assign({}, state.pages[pageSlug]), { scopes: Object.assign(Object.assign({}, state.pages[pageSlug].scopes), { [notebookSlug]: {
|
|
110
|
+
notebook,
|
|
111
|
+
rendermime,
|
|
112
|
+
} }) }) }) });
|
|
113
|
+
}
|
|
114
|
+
case 'ADD_SESSION': {
|
|
115
|
+
if (!isAddSessionPayload(action.payload)) {
|
|
116
|
+
console.error(action.payload);
|
|
117
|
+
throw new Error('invalid ADD_SESSION payload');
|
|
118
|
+
}
|
|
119
|
+
const { pageSlug, notebookSlug, session } = action.payload;
|
|
120
|
+
if (!state.pages[pageSlug]) {
|
|
121
|
+
console.error(state, action.payload);
|
|
122
|
+
throw new Error('Trying to add session when there is no rendering state');
|
|
123
|
+
}
|
|
124
|
+
if (state.pages[pageSlug].scopes[notebookSlug].session) {
|
|
125
|
+
console.warn('Trying to add session scope when rendering already has one', action.payload);
|
|
126
|
+
return state;
|
|
127
|
+
}
|
|
128
|
+
return Object.assign(Object.assign({}, state), { pages: Object.assign(Object.assign({}, state.pages), { [pageSlug]: Object.assign(Object.assign({}, state.pages[pageSlug]), { scopes: Object.assign(Object.assign({}, state.pages[pageSlug].scopes), { [notebookSlug]: Object.assign(Object.assign({}, state.pages[pageSlug].scopes[notebookSlug]), { session }) }) }) }) });
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return state;
|
|
132
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { BuildStatus, ExecuteScopeState } from './types';
|
|
2
|
+
export declare function selectIsComputable(state: ExecuteScopeState, slug: string): boolean;
|
|
3
|
+
export declare function selectAreExecutionScopesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
4
|
+
export declare function selectAreExecutionScopesBuilding(state: ExecuteScopeState, slug: string): boolean;
|
|
5
|
+
export declare function selectExecutionScopeStatus(state: ExecuteScopeState, slug: string): BuildStatus | "ready";
|
|
6
|
+
export declare function selectDependenciesToFetch(state: ExecuteScopeState): {
|
|
7
|
+
slug: string;
|
|
8
|
+
url: string;
|
|
9
|
+
}[];
|
|
10
|
+
export declare const selectScopeNotebooksToBuild: (state: ExecuteScopeState) => {
|
|
11
|
+
pageSlug: string;
|
|
12
|
+
notebookSlug: string;
|
|
13
|
+
}[];
|
|
14
|
+
export declare const selectSessionsToStart: (state: ExecuteScopeState) => {
|
|
15
|
+
pageSlug: string;
|
|
16
|
+
notebookSlug: string;
|
|
17
|
+
}[];
|
|
18
|
+
export declare function selectAreAllDependenciesReady(state: ExecuteScopeState, slug: string): boolean;
|
|
19
|
+
export declare function selectAreAllNotebookScopesBuilt(state: ExecuteScopeState, slug: string): boolean;
|
|
20
|
+
export declare function selectAreAllSessionsStarted(state: ExecuteScopeState, slug: string): boolean;
|
|
21
|
+
export declare function selectNotebookCellIds(state: ExecuteScopeState, pageSlug: string, notebookSlug: string): string[];
|
|
22
|
+
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -0,0 +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;AAED,wBAAgB,qBAAqB,CACnC,KAAK,EAAE,iBAAiB,EACxB,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,YAGrB"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { SourceFileKind } from 'myst-common';
|
|
2
|
+
export function selectIsComputable(state, slug) {
|
|
3
|
+
var _a, _b;
|
|
4
|
+
return (_b = (_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.computable) !== null && _b !== void 0 ? _b : false;
|
|
5
|
+
}
|
|
6
|
+
export function selectAreExecutionScopesReady(state, slug) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.ready;
|
|
9
|
+
}
|
|
10
|
+
export function selectAreExecutionScopesBuilding(state, slug) {
|
|
11
|
+
var _a;
|
|
12
|
+
return !((_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.ready) && !!state.builds[slug];
|
|
13
|
+
}
|
|
14
|
+
export function selectExecutionScopeStatus(state, slug) {
|
|
15
|
+
var _a, _b, _c;
|
|
16
|
+
return ((_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.ready) ? 'ready' : (_c = (_b = state.builds[slug]) === null || _b === void 0 ? void 0 : _b.status) !== null && _c !== void 0 ? _c : 'unknown';
|
|
17
|
+
}
|
|
18
|
+
//
|
|
19
|
+
// The following teo functions are ripe for generaizing but also it would be good to
|
|
20
|
+
// see if we can memoize them, potentially with reselect.
|
|
21
|
+
//
|
|
22
|
+
// TODO Memoize?
|
|
23
|
+
export function selectDependenciesToFetch(state) {
|
|
24
|
+
return Object.entries(state.builds)
|
|
25
|
+
.filter(([, { status }]) => status === 'fetching')
|
|
26
|
+
.reduce((targets, [slug]) => [
|
|
27
|
+
...targets,
|
|
28
|
+
...state.pages[slug].dependencies
|
|
29
|
+
.filter((d) => { var _a; return !state.mdast[(_a = d.slug) !== null && _a !== void 0 ? _a : d.url]; })
|
|
30
|
+
.map((d) => {
|
|
31
|
+
var _a;
|
|
32
|
+
return ({
|
|
33
|
+
slug: (_a = d.slug) !== null && _a !== void 0 ? _a : d.url,
|
|
34
|
+
url: d.url,
|
|
35
|
+
});
|
|
36
|
+
}),
|
|
37
|
+
], []);
|
|
38
|
+
}
|
|
39
|
+
// // TODO Memoize?
|
|
40
|
+
function makeSelectScopeEventStatus(statusName) {
|
|
41
|
+
return (state) => {
|
|
42
|
+
return Object.entries(state.builds)
|
|
43
|
+
.filter(([, { status }]) => status === statusName)
|
|
44
|
+
.reduce((all, [slug]) => {
|
|
45
|
+
const targets = [];
|
|
46
|
+
if (state.pages[slug].kind === SourceFileKind.Notebook)
|
|
47
|
+
targets.push({ pageSlug: slug, notebookSlug: slug });
|
|
48
|
+
targets.push(...state.pages[slug].dependencies.map((d) => {
|
|
49
|
+
var _a;
|
|
50
|
+
return ({
|
|
51
|
+
pageSlug: slug,
|
|
52
|
+
notebookSlug: (_a = d.slug) !== null && _a !== void 0 ? _a : d.url,
|
|
53
|
+
});
|
|
54
|
+
}));
|
|
55
|
+
return [...all, ...targets];
|
|
56
|
+
}, []);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
export const selectScopeNotebooksToBuild = makeSelectScopeEventStatus('build-notebooks');
|
|
60
|
+
export const selectSessionsToStart = makeSelectScopeEventStatus('start-session');
|
|
61
|
+
export function selectAreAllDependenciesReady(state, slug) {
|
|
62
|
+
var _a;
|
|
63
|
+
return (_a = state.pages[slug]) === null || _a === void 0 ? void 0 : _a.dependencies.every((dep) => { var _a; return !!state.mdast[(_a = dep.slug) !== null && _a !== void 0 ? _a : dep.url]; });
|
|
64
|
+
}
|
|
65
|
+
export function selectAreAllNotebookScopesBuilt(state, slug) {
|
|
66
|
+
const rendering = state.pages[slug];
|
|
67
|
+
return rendering === null || rendering === void 0 ? void 0 : rendering.dependencies.every((dep) => { var _a; return !!rendering.scopes[(_a = dep.slug) !== null && _a !== void 0 ? _a : dep.url]; });
|
|
68
|
+
}
|
|
69
|
+
export function selectAreAllSessionsStarted(state, slug) {
|
|
70
|
+
const rendering = state.pages[slug];
|
|
71
|
+
// TODO is this working??
|
|
72
|
+
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
|
+
}
|
|
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
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { Root } from 'mdast';
|
|
2
|
+
import type { SourceFileKind, Dependency } from 'myst-common';
|
|
3
|
+
import type { IRenderMimeRegistry, ThebeNotebook, ThebeSession } from 'thebe-core';
|
|
4
|
+
export type BuildStatus = 'pending' | 'fetching' | 'build-notebooks' | 'wait-for-server' | 'start-session' | 'error';
|
|
5
|
+
export type IdOrKey = string;
|
|
6
|
+
export type CellId = string;
|
|
7
|
+
export type IdKeyMapTarget = {
|
|
8
|
+
pageSlug: string;
|
|
9
|
+
notebookSlug: string;
|
|
10
|
+
cellId: CellId;
|
|
11
|
+
};
|
|
12
|
+
export type IdKeyMap = Record<IdOrKey, IdKeyMapTarget>;
|
|
13
|
+
export interface ExecuteScopeState {
|
|
14
|
+
mdast: {
|
|
15
|
+
[slug: string]: {
|
|
16
|
+
root: Root;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
pages: {
|
|
20
|
+
[pageSlug: string]: {
|
|
21
|
+
slug: string;
|
|
22
|
+
kind: SourceFileKind;
|
|
23
|
+
computable: boolean;
|
|
24
|
+
dependencies: Dependency[];
|
|
25
|
+
computables: Computable[];
|
|
26
|
+
ready: boolean;
|
|
27
|
+
scopes: {
|
|
28
|
+
[notebookSlug: string]: ExecutionScope;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
builds: {
|
|
33
|
+
[pageSlug: string]: {
|
|
34
|
+
status: BuildStatus;
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export interface ExecutionScope {
|
|
39
|
+
rendermime: IRenderMimeRegistry;
|
|
40
|
+
notebook: ThebeNotebook;
|
|
41
|
+
session?: ThebeSession;
|
|
42
|
+
}
|
|
43
|
+
export interface Computable {
|
|
44
|
+
embedKey: string;
|
|
45
|
+
outputKey: string;
|
|
46
|
+
label: string;
|
|
47
|
+
source: Dependency;
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/execute/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAEnF,MAAM,MAAM,WAAW,GACnB,SAAS,GACT,UAAU,GACV,iBAAiB,GACjB,iBAAiB,GACjB,eAAe,GACf,OAAO,CAAC;AAEZ,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,cAAc,GAAG;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACxF,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,KAAK,EAAE;QACL,CAAC,IAAI,EAAE,MAAM,GAAG;YACd,IAAI,EAAE,IAAI,CAAC;SACZ,CAAC;KACH,CAAC;IACF,KAAK,EAAE;QACL,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,IAAI,EAAE,MAAM,CAAC;YACb,IAAI,EAAE,cAAc,CAAC;YACrB,UAAU,EAAE,OAAO,CAAC;YACpB,YAAY,EAAE,UAAU,EAAE,CAAC;YAC3B,WAAW,EAAE,UAAU,EAAE,CAAC;YAC1B,KAAK,EAAE,OAAO,CAAC;YACf,MAAM,EAAE;gBACN,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC;aACxC,CAAC;SACH,CAAC;KACH,CAAC;IACF,MAAM,EAAE;QACN,CAAC,QAAQ,EAAE,MAAM,GAAG;YAClB,MAAM,EAAE,WAAW,CAAC;SACrB,CAAC;KACH,CAAC;CACH;AAED,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,mBAAmB,CAAC;IAChC,QAAQ,EAAE,aAAa,CAAC;IACxB,OAAO,CAAC,EAAE,YAAY,CAAC;CACxB;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,UAAU,CAAC;CACpB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { GenericParent } from 'myst-common';
|
|
2
|
+
import type { Config, IRenderMimeRegistry, ThebeCore } from 'thebe-core';
|
|
3
|
+
import type { IdKeyMap } from './types';
|
|
4
|
+
/**
|
|
5
|
+
* Use the mdast to create a ThebeNotebook from the mdast tree of a notebook.
|
|
6
|
+
* This is intended to be used to create an independent ThebeNotebook instance
|
|
7
|
+
* for each notebook in a rendering context.
|
|
8
|
+
*
|
|
9
|
+
* NOTE: there is no need to scope the keys at this point, as the ThebeNotebook
|
|
10
|
+
* instance will be scoped to the render context. All underlying cells will be
|
|
11
|
+
* identified by keys from the mdast - so there may be duplicate ids between different
|
|
12
|
+
* notebook instances, but that is ok as they came from the same mdast which is readonly.
|
|
13
|
+
*
|
|
14
|
+
* @param core
|
|
15
|
+
* @param config
|
|
16
|
+
* @param pageSlug - slug identifying the render context used for key decoration
|
|
17
|
+
* @param mdast - the notebook mdast
|
|
18
|
+
* @param idkmap - map of scoped block keys to keys for code and output cells
|
|
19
|
+
* @param rendermime
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare function notebookFromMdast(core: ThebeCore, config: Config, pageSlug: string, notebookSlug: string, mdast: GenericParent, idkmap: IdKeyMap, rendermime: IRenderMimeRegistry): import("thebe-core/dist/types/notebook").default;
|
|
23
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/execute/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACzE,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,SAAS,CAAC;AAExD;;;;;;;;;;;;;;;;;GAiBG;AAEH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,MAAM,EACpB,KAAK,EAAE,aAAa,EACpB,MAAM,EAAE,QAAQ,EAChB,UAAU,EAAE,mBAAmB,oDAoDhC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Use the mdast to create a ThebeNotebook from the mdast tree of a notebook.
|
|
3
|
+
* This is intended to be used to create an independent ThebeNotebook instance
|
|
4
|
+
* for each notebook in a rendering context.
|
|
5
|
+
*
|
|
6
|
+
* NOTE: there is no need to scope the keys at this point, as the ThebeNotebook
|
|
7
|
+
* instance will be scoped to the render context. All underlying cells will be
|
|
8
|
+
* identified by keys from the mdast - so there may be duplicate ids between different
|
|
9
|
+
* notebook instances, but that is ok as they came from the same mdast which is readonly.
|
|
10
|
+
*
|
|
11
|
+
* @param core
|
|
12
|
+
* @param config
|
|
13
|
+
* @param pageSlug - slug identifying the render context used for key decoration
|
|
14
|
+
* @param mdast - the notebook mdast
|
|
15
|
+
* @param idkmap - map of scoped block keys to keys for code and output cells
|
|
16
|
+
* @param rendermime
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
export function notebookFromMdast(core, config, pageSlug, notebookSlug, mdast, idkmap, rendermime) {
|
|
20
|
+
// note the notebooks slug is used as the notebook id, this means accross pages
|
|
21
|
+
// mulitple notebooks with the same slug will be present but scoped to different pages
|
|
22
|
+
// the busyScope mecahnism relies on the notebookSlug as id
|
|
23
|
+
const notebook = new core.ThebeNotebook(notebookSlug, config, rendermime);
|
|
24
|
+
// no metadata included in mdast yet
|
|
25
|
+
//Object.assign(notebook.metadata, ipynb.metadata);
|
|
26
|
+
notebook.cells = mdast.children.map((block) => {
|
|
27
|
+
var _a, _b, _c;
|
|
28
|
+
if (block.type !== 'block')
|
|
29
|
+
console.warn(`Unexpected block type ${block.type}`);
|
|
30
|
+
if (block.children.length == 2 && block.children[0].type === 'code') {
|
|
31
|
+
const [codeCell, output] = block.children;
|
|
32
|
+
// use the block.key to identify the cell but maintain a mapping
|
|
33
|
+
// to allow code or output keys to look up cells and refs and idenifity
|
|
34
|
+
// the cell in the correct notebook
|
|
35
|
+
const target = {
|
|
36
|
+
pageSlug,
|
|
37
|
+
notebookSlug,
|
|
38
|
+
cellId: block.key,
|
|
39
|
+
};
|
|
40
|
+
idkmap[block.key] = target;
|
|
41
|
+
idkmap[codeCell.key] = target;
|
|
42
|
+
idkmap[output.key] = target;
|
|
43
|
+
// include block labels to enable lookup by from embedded blocks
|
|
44
|
+
if (block.label)
|
|
45
|
+
idkmap[block.label] = target;
|
|
46
|
+
if (block.identifier)
|
|
47
|
+
idkmap[block.identifier] = target;
|
|
48
|
+
return new core.ThebeCell(target.cellId, notebook.id, (_a = codeCell.value) !== null && _a !== void 0 ? _a : '', config, (_b = block.data) !== null && _b !== void 0 ? _b : {}, notebook.rendermime);
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
// assume content - concatenate it
|
|
52
|
+
// TODO inject cell metadata
|
|
53
|
+
const cell = new core.ThebeNonExecutableCell(block.key, notebook.id, block.children.reduce((acc, child) => { var _a; return acc + '\n' + ((_a = child.value) !== null && _a !== void 0 ? _a : ''); }, ''), (_c = block.data) !== null && _c !== void 0 ? _c : {}, notebook.rendermime);
|
|
54
|
+
return cell;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return notebook;
|
|
58
|
+
}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -3,7 +3,10 @@ declare const OUTPUT_RENDERERS: {
|
|
|
3
3
|
output: typeof Output;
|
|
4
4
|
};
|
|
5
5
|
export * from './BinderBadge';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './ErrorTray';
|
|
7
7
|
export * from './ConnectionStatusTray';
|
|
8
|
+
export * from './providers';
|
|
9
|
+
export * from './execute';
|
|
10
|
+
export * from './controls';
|
|
8
11
|
export default OUTPUT_RENDERERS;
|
|
9
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,QAAA,MAAM,gBAAgB;;CAErB,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,wBAAwB,CAAC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAE3B,eAAe,gBAAgB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -3,6 +3,9 @@ const OUTPUT_RENDERERS = {
|
|
|
3
3
|
output: Output,
|
|
4
4
|
};
|
|
5
5
|
export * from './BinderBadge';
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './ErrorTray';
|
|
7
7
|
export * from './ConnectionStatusTray';
|
|
8
|
+
export * from './providers';
|
|
9
|
+
export * from './execute';
|
|
10
|
+
export * from './controls';
|
|
8
11
|
export default OUTPUT_RENDERERS;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"jupyter.d.ts","sourceRoot":"","sources":["../../src/jupyter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAsC,MAAM,OAAO,CAAC;AAG3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AA6D3C,eAAO,MAAM,cAAc;QACD,MAAM;aAAW,cAAc,EAAE;8CAkD1D,CAAC"}
|
package/dist/esm/jupyter.js
CHANGED
|
@@ -3,30 +3,32 @@ import React, { useEffect, useRef, useState } from 'react';
|
|
|
3
3
|
import { useFetchAnyTruncatedContent } from './hooks';
|
|
4
4
|
import { convertToIOutputs } from 'nbtx';
|
|
5
5
|
import { fetchAndEncodeOutputImages } from './convertImages';
|
|
6
|
-
import { useNotebookCellExecution } from './providers';
|
|
7
6
|
import { SourceFileKind } from 'myst-common';
|
|
8
7
|
import { useXRefState } from '@myst-theme/providers';
|
|
9
8
|
import { useThebeLoader } from 'thebe-react';
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
import { useCellExecution } from './execute';
|
|
10
|
+
function ActiveOutputRenderer({ id, initialData }) {
|
|
11
|
+
const exec = useCellExecution(id);
|
|
12
12
|
const ref = useRef(null);
|
|
13
13
|
useEffect(() => {
|
|
14
14
|
var _a;
|
|
15
15
|
if (!ref.current || !(exec === null || exec === void 0 ? void 0 : exec.cell)) {
|
|
16
|
-
console.debug(`No cell ref available for cell ${(_a = exec === null || exec === void 0 ? void 0 : exec.cell) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
16
|
+
console.debug(`Jupyter: No cell ref available for cell ${(_a = exec === null || exec === void 0 ? void 0 : exec.cell) === null || _a === void 0 ? void 0 : _a.id}`);
|
|
17
17
|
return;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
console.debug(`Attaching cell ${exec.cell.id} to DOM at:`, {
|
|
19
|
+
const verb = exec.cell.isAttachedToDOM ? 'reattaching' : 'attaching';
|
|
20
|
+
console.debug(`${verb} cell ${exec.cell.id} to DOM at:`, {
|
|
24
21
|
el: ref.current,
|
|
25
22
|
connected: ref.current.isConnected,
|
|
26
|
-
data,
|
|
23
|
+
data: initialData,
|
|
27
24
|
});
|
|
28
25
|
exec.cell.attachToDOM(ref.current);
|
|
29
|
-
exec.cell.
|
|
26
|
+
if (exec.cell.executionCount == null) {
|
|
27
|
+
exec.cell.initOutputs(initialData);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
exec.cell.refresh();
|
|
31
|
+
}
|
|
30
32
|
}, [ref === null || ref === void 0 ? void 0 : ref.current, exec === null || exec === void 0 ? void 0 : exec.cell]);
|
|
31
33
|
return _jsx("div", { ref: ref, "data-thebe-active-ref": "true", className: "relative" });
|
|
32
34
|
}
|
|
@@ -42,12 +44,12 @@ function PassiveOutputRenderer({ id, data, core, kind, }) {
|
|
|
42
44
|
return _jsx("div", { ref: ref, "data-thebe-passive-ref": "true" });
|
|
43
45
|
}
|
|
44
46
|
export const JupyterOutputs = React.memo(({ id, outputs }) => {
|
|
45
|
-
var _a;
|
|
46
47
|
const { core, load } = useThebeLoader();
|
|
47
48
|
const { inCrossRef } = useXRefState();
|
|
48
49
|
const { data, error } = useFetchAnyTruncatedContent(outputs);
|
|
49
50
|
const [fullOutputs, setFullOutputs] = useState(null);
|
|
50
|
-
const exec = useNotebookCellExecution(id);
|
|
51
|
+
// const exec = useNotebookCellExecution(id);
|
|
52
|
+
const exec = useCellExecution(id);
|
|
51
53
|
useEffect(() => {
|
|
52
54
|
if (core)
|
|
53
55
|
return;
|
|
@@ -66,7 +68,7 @@ export const JupyterOutputs = React.memo(({ id, outputs }) => {
|
|
|
66
68
|
return _jsxs("div", { className: "text-red-500", children: ["Error rendering output: ", error.message] });
|
|
67
69
|
}
|
|
68
70
|
if (!inCrossRef && (exec === null || exec === void 0 ? void 0 : exec.ready)) {
|
|
69
|
-
return (_jsxs("div", { children: [!fullOutputs && _jsx("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && _jsx(ActiveOutputRenderer, { id: id,
|
|
71
|
+
return (_jsxs("div", { children: [!fullOutputs && _jsx("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && _jsx(ActiveOutputRenderer, { id: id, initialData: fullOutputs }, id)] }));
|
|
70
72
|
}
|
|
71
|
-
return (_jsxs("div", { children: [!fullOutputs && _jsx("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && core && (_jsx(PassiveOutputRenderer, { id: id, data: fullOutputs, core: core, kind:
|
|
73
|
+
return (_jsxs("div", { children: [!fullOutputs && _jsx("div", { className: "p-2.5", children: "Loading..." }), fullOutputs && core && (_jsx(PassiveOutputRenderer, { id: id, data: fullOutputs, core: core, kind: SourceFileKind.Notebook }))] }));
|
|
72
74
|
});
|
package/dist/esm/output.d.ts
CHANGED
package/dist/esm/output.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/output.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAkB,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAE/D,OAAO,KAAK,EAAsB,cAAc,EAAE,MAAM,MAAM,CAAC;AAY/D,eAAO,MAAM,mBAAmB,aAA+B,CAAC;AAEhE,eAAO,MAAM,iBAAiB,aAMb,CAAC;AAElB,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,cAAc,EAAE,EACzB,iBAAiB,EAAE,GAAG,CAAC,MAAM,CAAC,EAC9B,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,WAY7B;AAwDD,wBAAgB,MAAM,CAAC,IAAI,EAAE,WAAW,2CAYvC"}
|
package/dist/esm/output.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { SourceFileKind } from 'myst-common';
|
|
2
3
|
import { KnownCellOutputMimeTypes } from 'nbtx';
|
|
3
4
|
import classNames from 'classnames';
|
|
4
5
|
import { SafeOutputs } from './safe';
|
|
5
6
|
import { JupyterOutputs } from './jupyter';
|
|
6
|
-
import { useReadyToExecute } from './providers';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
|
+
import { useCellExecution } from './execute';
|
|
9
|
+
import { ArticleResetNotebook, ArticleRunNotebook, ArticleStatusBadge, } from './controls/ArticleCellControls';
|
|
8
10
|
export const DIRECT_OUTPUT_TYPES = new Set(['stream', 'error']);
|
|
9
11
|
export const DIRECT_MIME_TYPES = new Set([
|
|
10
12
|
KnownCellOutputMimeTypes.TextPlain,
|
|
@@ -26,7 +28,7 @@ export function allOutputsAreSafe(outputs, directOutputTypes, directMimeTypes) {
|
|
|
26
28
|
}, true);
|
|
27
29
|
}
|
|
28
30
|
function JupyterOutput({ nodeKey, nodeType, identifier, data, align, }) {
|
|
29
|
-
const ready =
|
|
31
|
+
const { kind, ready } = useCellExecution(nodeKey);
|
|
30
32
|
const outputs = data;
|
|
31
33
|
const allSafe = useMemo(() => allOutputsAreSafe(outputs, DIRECT_OUTPUT_TYPES, DIRECT_MIME_TYPES), [outputs]);
|
|
32
34
|
let component;
|
|
@@ -36,11 +38,12 @@ function JupyterOutput({ nodeKey, nodeType, identifier, data, align, }) {
|
|
|
36
38
|
else {
|
|
37
39
|
component = _jsx(JupyterOutputs, { id: nodeKey, outputs: outputs });
|
|
38
40
|
}
|
|
39
|
-
|
|
41
|
+
const showControls = kind === SourceFileKind.Article;
|
|
42
|
+
return (_jsxs("figure", { id: identifier || undefined, "data-mdast-node-type": nodeType, "data-mdast-node-id": nodeKey, className: classNames('max-w-full overflow-visible m-0 group not-prose relative', {
|
|
40
43
|
'text-left': !align || align === 'left',
|
|
41
44
|
'text-center': align === 'center',
|
|
42
45
|
'text-right': align === 'right',
|
|
43
|
-
}), children: component }));
|
|
46
|
+
}), children: [showControls && (_jsx("div", { className: "sticky top-[60px]", children: _jsxs("div", { className: "absolute -top-[28px] md:top-[30px] right-0 md:-right-[28px]", children: [_jsx(ArticleStatusBadge, { id: nodeKey }), _jsx(ArticleRunNotebook, { id: nodeKey }), _jsx(ArticleResetNotebook, { id: nodeKey })] }) })), component] }));
|
|
44
47
|
}
|
|
45
48
|
export function Output(node) {
|
|
46
49
|
// Note, NodeRenderer's can't have hooks in it directly!
|
package/dist/esm/providers.d.ts
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import { SourceFileKind } from 'myst-common';
|
|
1
|
+
import type { SourceFileKind } from 'myst-common';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import type { Config, IRenderMimeRegistry, IThebeCell, IThebeCellExecuteReturn, ThebeCore, ThebeNotebook } from 'thebe-core';
|
|
5
|
-
import type { IThebeNotebookError, NotebookExecuteOptions } from 'thebe-react';
|
|
6
3
|
import type { Root } from 'mdast';
|
|
7
4
|
export declare function useComputeOptions(): {
|
|
8
5
|
canCompute: boolean;
|
|
@@ -23,48 +20,4 @@ export type PartialPage = {
|
|
|
23
20
|
slug: string;
|
|
24
21
|
mdast: Root;
|
|
25
22
|
};
|
|
26
|
-
export declare function notebookFromMdast(core: ThebeCore, config: Config, mdast: GenericParent, idkMap: Record<string, string>, rendermime: IRenderMimeRegistry): ThebeNotebook;
|
|
27
|
-
type IdKeyMap = Record<string, string>;
|
|
28
|
-
interface NotebookContextType {
|
|
29
|
-
kind: SourceFileKind;
|
|
30
|
-
ready: boolean;
|
|
31
|
-
attached: boolean;
|
|
32
|
-
executing: boolean;
|
|
33
|
-
executed: boolean;
|
|
34
|
-
errors: IThebeNotebookError[] | null;
|
|
35
|
-
executeAll: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
36
|
-
executeSome: (predicate: (cell: IThebeCell) => boolean, options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
37
|
-
notebook: ThebeNotebook | undefined;
|
|
38
|
-
idkMap: IdKeyMap;
|
|
39
|
-
restart: () => Promise<void>;
|
|
40
|
-
clear: () => void;
|
|
41
|
-
}
|
|
42
|
-
export declare function NotebookProvider({ siteConfig, page, children, }: React.PropsWithChildren<{
|
|
43
|
-
siteConfig: boolean;
|
|
44
|
-
page: PartialPage;
|
|
45
|
-
}>): import("react/jsx-runtime").JSX.Element;
|
|
46
|
-
export declare function useHasNotebookProvider(): boolean;
|
|
47
|
-
export declare function useMDASTNotebook(): NotebookContextType | undefined;
|
|
48
|
-
export declare function useNotebookExecution(): {
|
|
49
|
-
ready: boolean;
|
|
50
|
-
attached: boolean;
|
|
51
|
-
executing: boolean;
|
|
52
|
-
executed: boolean;
|
|
53
|
-
errors: IThebeNotebookError[] | null;
|
|
54
|
-
execute: (options?: NotebookExecuteOptions | undefined) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
55
|
-
notebook: ThebeNotebook | undefined;
|
|
56
|
-
clear: () => void;
|
|
57
|
-
} | undefined;
|
|
58
|
-
export declare function useReadyToExecute(): boolean;
|
|
59
|
-
export declare function useNotebookCellExecution(id: string): {
|
|
60
|
-
kind: SourceFileKind;
|
|
61
|
-
ready: boolean;
|
|
62
|
-
cell: IThebeCell | undefined;
|
|
63
|
-
executing: boolean;
|
|
64
|
-
notebookIsExecuting: boolean;
|
|
65
|
-
execute: (options?: NotebookExecuteOptions) => Promise<(IThebeCellExecuteReturn | null)[]>;
|
|
66
|
-
clear: () => void | undefined;
|
|
67
|
-
notebook: ThebeNotebook;
|
|
68
|
-
} | undefined;
|
|
69
|
-
export {};
|
|
70
23
|
//# sourceMappingURL=providers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"providers.d.ts","sourceRoot":"","sources":["../../src/providers.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
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;;;;;;;;;;EAwBhC;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"}
|