Skip to content

Commit 6573b90

Browse files
authored
handle nbl (#36)
1 parent 891f08e commit 6573b90

2 files changed

Lines changed: 62 additions & 1 deletion

File tree

‎app/bootstrap.js‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,27 @@ async function loadComponent(url, scope) {
122122
}
123123

124124
void (async function bootstrap() {
125+
let labExtensionUrl = getOption('fullLabextensionsUrl');
126+
127+
const notebookLinkExtensions = getOption('notebookLinkExtensions');
128+
if (notebookLinkExtensions && notebookLinkExtensions.length > 0) {
129+
const nblinkExtensions = await Promise.allSettled(
130+
notebookLinkExtensions.map(async data => {
131+
await loadComponent(
132+
`${labExtensionUrl}/${data.name}/${data.load}`,
133+
data.name
134+
);
135+
})
136+
);
137+
138+
nblinkExtensions.forEach(p => {
139+
if (p.status === 'rejected') {
140+
// There was an error loading the component
141+
console.error(p.reason);
142+
}
143+
});
144+
}
145+
125146
await applyThemeToAppLoadingIndicator();
126147

127148
// This is all the data needed to load and activate plugins. This should be
@@ -133,7 +154,7 @@ void (async function bootstrap() {
133154
// components should be actually used. We have to do this before importing
134155
// and using the module that actually uses these components so that all
135156
// dependencies are initialized.
136-
let labExtensionUrl = getOption('fullLabextensionsUrl');
157+
137158
const extensions = await Promise.allSettled(
138159
extension_data.map(async data => {
139160
await loadComponent(

‎app/index.template.js‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,46 @@ export async function main() {
4545
const federatedMimeExtensionPromises = [];
4646
const federatedStylePromises = [];
4747

48+
const notebookLinkExtensionsString = PageConfig.getOption(
49+
"notebookLinkExtensions"
50+
);
51+
if (notebookLinkExtensionsString && notebookLinkExtensionsString.length > 0) {
52+
const notebookLinkExtensions = JSON.parse(notebookLinkExtensionsString);
53+
const notebookLinkExtensionPromises = []
54+
const notebookLinkStylePromises = [];
55+
notebookLinkExtensions.forEach((data) => {
56+
if (data.extension) {
57+
notebookLinkExtensionPromises.push(
58+
createModule(data.name, data.extension)
59+
);
60+
}
61+
if (data.style) {
62+
notebookLinkStylePromises.push(createModule(data.name, data.style));
63+
}
64+
});
65+
66+
// Add the notebook.link extensions.
67+
const notebookLinkExtensionsResult = await Promise.allSettled(
68+
notebookLinkExtensionPromises
69+
);
70+
notebookLinkExtensionsResult.forEach((p) => {
71+
if (p.status === "fulfilled") {
72+
for (let plugin of activePlugins(p.value)) {
73+
pluginsToRegister.push(plugin);
74+
}
75+
} else {
76+
console.error(p.reason);
77+
}
78+
});
79+
80+
// Load all notebook.link styles and log errors for any that do not
81+
(await Promise.allSettled(notebookLinkStylePromises))
82+
.filter(({ status }) => status === "rejected")
83+
.forEach(({ reason }) => {
84+
console.error(reason);
85+
});
86+
}
87+
4888
// This is all the data needed to load and activate plugins. This should be
4989
// gathered by the server and put onto the initial page template.
5090
const extensions = JSON.parse(

0 commit comments

Comments
 (0)