@galaxyproject/jupyterlite 0.0.28 → 0.0.30

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@galaxyproject/jupyterlite",
3
- "version": "0.0.28",
3
+ "version": "0.0.30",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "static"
@@ -18,7 +18,6 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@playwright/test": "^1.52.0",
21
- "axios": "^1.9.0",
22
21
  "cpx": "^1.5.0",
23
22
  "node-fetch": "^3.3.2",
24
23
  "playwright": "^1.52.0",
@@ -248,28 +248,71 @@ function addFavicon(config) {
248
248
  async function main() {
249
249
  const config = await jupyterConfigData();
250
250
  //__GXY__INJECTION__
251
+ const AI_SETTINGS = "@jupyterlite/ai:settings-model";
252
+ const PYODIDE_KERNEL = "@jupyterlite/pyodide-kernel-extension:kernel";
253
+ const searchParams = Object.fromEntries(new URL(window.location.href).searchParams.entries());
254
+ const galaxyRoot = searchParams.root || "/";
255
+ const galaxyApiBase = galaxyRoot + "api/plugins/jupyterlite";
256
+
257
+ // Intercept fetch to strip Authorization header for Galaxy API requests
258
+ const originalFetch = window.fetch;
259
+ const galaxyApiPath = galaxyApiBase.startsWith("http") ? new URL(galaxyApiBase).pathname : galaxyApiBase;
260
+ window.fetch = async function (url, init) {
261
+ // Normalize URL to pathname for comparison
262
+ let pathname;
263
+ if (typeof url === "string") {
264
+ pathname = url.startsWith("http") ? new URL(url).pathname : url;
265
+ } else if (url instanceof URL) {
266
+ pathname = url.pathname;
267
+ } else if (url instanceof Request) {
268
+ pathname = new URL(url.url).pathname;
269
+ } else {
270
+ pathname = String(url);
271
+ }
251
272
 
252
- const AI_SETTINGS = "@jupyterlite/ai:settings-model";
253
- const PYODIDE_KERNEL = "@jupyterlite/pyodide-kernel-extension:kernel";
254
- const searchParams = Object.fromEntries(new URL(window.location.href).searchParams.entries());
255
- config.litePluginSettings[PYODIDE_KERNEL].loadPyodideOptions.env = {
256
- __gxy__: JSON.stringify(searchParams)
257
- };
258
- config.settingsOverrides = {};
259
- config.settingsOverrides[AI_SETTINGS] = {
260
- defaultProvider: "jnaut",
261
- useSameProviderForChatAndCompleter: false,
262
- providers: [
263
- {
264
- id: "jnaut",
265
- name: "jnaut",
266
- provider: "generic",
267
- model: "jnaut",
268
- apiKey: "jnaut",
269
- baseURL: searchParams.root + "api/plugins/jupyterlite"
270
- }
271
- ]
272
- };
273
+ // Check if this is a Galaxy API request
274
+ if (pathname.startsWith(galaxyApiPath)) {
275
+ // Handle Request objects with built-in headers
276
+ if (url instanceof Request) {
277
+ const headers = new Headers(url.headers);
278
+ headers.delete("Authorization");
279
+ url = new Request(url, { headers });
280
+ }
281
+ // Handle headers in init options
282
+ if (init?.headers) {
283
+ const headers = new Headers(init.headers);
284
+ headers.delete("Authorization");
285
+ init = { ...init, headers };
286
+ }
287
+ }
288
+ return originalFetch.call(this, url, init);
289
+ };
290
+
291
+ // Ensure nested config structure exists
292
+ config.litePluginSettings = config.litePluginSettings || {};
293
+ config.litePluginSettings[PYODIDE_KERNEL] = config.litePluginSettings[PYODIDE_KERNEL] || {};
294
+ config.litePluginSettings[PYODIDE_KERNEL].loadPyodideOptions =
295
+ config.litePluginSettings[PYODIDE_KERNEL].loadPyodideOptions || {};
296
+ config.litePluginSettings[PYODIDE_KERNEL].loadPyodideOptions.env = {
297
+ __gxy__: JSON.stringify(searchParams),
298
+ };
299
+ config.settingsOverrides = {};
300
+ config.settingsOverrides[AI_SETTINGS] = {
301
+ defaultProvider: "jnaut",
302
+ useSameProviderForChatAndCompleter: false,
303
+ providers: [
304
+ {
305
+ id: "jnaut",
306
+ name: "jnaut",
307
+ provider: "generic",
308
+ model: "jnaut",
309
+ baseURL: galaxyApiBase,
310
+ parameters: {
311
+ maxTokens: 4096,
312
+ },
313
+ },
314
+ ],
315
+ };
273
316
 
274
317
  //__GXY__INJECTION__
275
318
  if (config.baseUrl === new URL(here()).pathname) {