From a8cf74417b99d405278fa535cba9fe13507d78ed Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 12:55:47 +0100 Subject: [PATCH 1/7] =?UTF-8?q?=F0=9F=A7=B9=20removes=20extra=20thebe-lite?= =?UTF-8?q?=20load?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/demo-react/public/index.html | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/demo-react/public/index.html b/apps/demo-react/public/index.html index 9a3aedd7..60b8a294 100644 --- a/apps/demo-react/public/index.html +++ b/apps/demo-react/public/index.html @@ -3,7 +3,6 @@ - Date: Mon, 19 Jun 2023 12:57:59 +0100 Subject: [PATCH 2/7] =?UTF-8?q?=F0=9F=93=92=20made=20`demo-react`=20more?= =?UTF-8?q?=20binder=20friendly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/demo-react/src/App.tsx | 13 ++++++---- apps/demo-react/src/ThebeStatusTray.tsx | 33 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 apps/demo-react/src/ThebeStatusTray.tsx diff --git a/apps/demo-react/src/App.tsx b/apps/demo-react/src/App.tsx index aae0964f..e163e040 100644 --- a/apps/demo-react/src/App.tsx +++ b/apps/demo-react/src/App.tsx @@ -1,21 +1,23 @@ -import { useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { ThebeBundleLoaderProvider, ThebeServerProvider } from 'thebe-react'; import { NavLink, Outlet } from 'react-router-dom'; import './App.css'; import { Connect } from './Connect'; import { ServerMode, ServerModeType } from './ServerMode'; +import { ThebeStatusTray } from './ThebeStatusTray'; function App() { const [mode, setMode] = useState('local'); + const useBinder = false; + const options = useMemo( () => ({ - useBinder: false, kernelOptions: { name: 'Python 3', }, - savedSessionOptions: { - enabled: false, + binderOptions: { + repo: 'curvenote/binder-base', }, }), [], @@ -45,11 +47,12 @@ function App() { + diff --git a/apps/demo-react/src/ThebeStatusTray.tsx b/apps/demo-react/src/ThebeStatusTray.tsx new file mode 100644 index 00000000..f08c11a6 --- /dev/null +++ b/apps/demo-react/src/ThebeStatusTray.tsx @@ -0,0 +1,33 @@ +import { useState, useEffect } from 'react'; +import { ThebeEventData, ThebeEventType } from 'thebe-core'; +import { useThebeLoader, useThebeServer } from 'thebe-react'; + +export function ThebeStatusTray() { + const { core } = useThebeLoader(); + const { connecting, ready, error, events } = useThebeServer(); + const [subscribed, setSubscribed] = useState(false); + const [status, setStatus] = useState(null); + + useEffect(() => { + if (!events || subscribed) return; + setSubscribed(true); + events?.on('status' as ThebeEventType, (event: any, data: ThebeEventData) => { + console.log('EVENTS', 'status' as ThebeEventType, event, data); + setStatus(data); + }); + }, [events, subscribed]); + + return ( +
+ {connecting &&
connecting to server...
} + {error &&
connection error: {error}
} + {status && ( +
+ last status: {`[${status.subject}] ${status.status}`} +
{status.message}
+
+ )} +
+
+ ); +} From e1fb134a18a1645af69c53f4513077b967d96f98 Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 13:10:09 +0100 Subject: [PATCH 3/7] =?UTF-8?q?=F0=9F=A6=BE=20easier=20binder=20testing=20?= =?UTF-8?q?in=20react?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/demo-react/src/App.tsx | 4 +- apps/demo-react/src/ServerMode.tsx | 83 +++++++++++++++++++++--------- 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/apps/demo-react/src/App.tsx b/apps/demo-react/src/App.tsx index e163e040..b2b99338 100644 --- a/apps/demo-react/src/App.tsx +++ b/apps/demo-react/src/App.tsx @@ -9,8 +9,6 @@ import { ThebeStatusTray } from './ThebeStatusTray'; function App() { const [mode, setMode] = useState('local'); - const useBinder = false; - const options = useMemo( () => ({ kernelOptions: { @@ -47,7 +45,7 @@ function App() { diff --git a/apps/demo-react/src/ServerMode.tsx b/apps/demo-react/src/ServerMode.tsx index 42b47ad7..8a25db7c 100644 --- a/apps/demo-react/src/ServerMode.tsx +++ b/apps/demo-react/src/ServerMode.tsx @@ -1,7 +1,7 @@ import liteIcon from './lite.png'; import serverIcon from './server.svg'; -export type ServerModeType = 'local' | 'lite'; +export type ServerModeType = 'local' | 'lite' | 'binder'; export function ServerMode({ mode, @@ -12,33 +12,68 @@ export function ServerMode({ }) { return (
-
-
- Local Server -
-
-
+
); } From 225b2cb4848ec332f0683d1684bce64cec42fc5f Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 13:10:33 +0100 Subject: [PATCH 4/7] =?UTF-8?q?=E2=98=81=EF=B8=8Fchange=20up=20default=20b?= =?UTF-8?q?inder=20repo=20to=20match=20other=20demos?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/src/options.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/core/src/options.ts b/packages/core/src/options.ts index 8a6eb490..6ef5a2c5 100644 --- a/packages/core/src/options.ts +++ b/packages/core/src/options.ts @@ -12,8 +12,8 @@ import { RepoProvider } from './types'; export function makeBinderOptions(opts: BinderOptions) { return { - repo: 'binder-examples/requirements', - ref: 'master', + repo: 'executablebooks/thebe-binder-base', + ref: 'HEAD', binderUrl: 'https://mybinder.org', repoProvider: RepoProvider.github, ...opts, From 1b4dcf4b2a7febbcd6c14dfd8a76a3a1d47575dd Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 14:07:59 +0100 Subject: [PATCH 5/7] =?UTF-8?q?=E2=9C=85=20updated=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/tests/connect.binder.spec.ts | 12 ++++++------ packages/core/tests/options.spec.ts | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/core/tests/connect.binder.spec.ts b/packages/core/tests/connect.binder.spec.ts index 56e1a947..d79042f7 100644 --- a/packages/core/tests/connect.binder.spec.ts +++ b/packages/core/tests/connect.binder.spec.ts @@ -8,11 +8,11 @@ describe('connect.binder', () => { describe('urls', () => { test('git', () => { expect(makeGitUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.git }))).toEqual( - 'https://binder.curvenote.dev/build/git/binder-examples%2Frequirements/master', + 'https://binder.curvenote.dev/build/git/executablebooks%2Fthebe-binder-base/HEAD', ); expect( makeGitUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.git, ref: 'main' })), - ).toEqual('https://binder.curvenote.dev/build/git/binder-examples%2Frequirements/main'); + ).toEqual('https://binder.curvenote.dev/build/git/executablebooks%2Fthebe-binder-base/main'); expect(() => makeGitUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.github })), ).toThrow(); @@ -20,12 +20,12 @@ describe('connect.binder', () => { test('github', () => { expect( makeGitHubUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.github })), - ).toEqual('https://binder.curvenote.dev/build/gh/binder-examples/requirements/master'); + ).toEqual('https://binder.curvenote.dev/build/gh/executablebooks/thebe-binder-base/HEAD'); expect( makeGitHubUrl( makeBinderOptions({ binderUrl, repoProvider: RepoProvider.github, ref: 'main' }), ), - ).toEqual('https://binder.curvenote.dev/build/gh/binder-examples/requirements/main'); + ).toEqual('https://binder.curvenote.dev/build/gh/executablebooks/thebe-binder-base/main'); expect(() => makeGitHubUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.git })), ).toThrow(); @@ -33,12 +33,12 @@ describe('connect.binder', () => { test('gitlab', () => { expect( makeGitLabUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.gitlab })), - ).toEqual('https://binder.curvenote.dev/build/gl/binder-examples%2Frequirements/master'); + ).toEqual('https://binder.curvenote.dev/build/gl/executablebooks%2Fthebe-binder-base/HEAD'); expect( makeGitLabUrl( makeBinderOptions({ binderUrl, repoProvider: RepoProvider.gitlab, ref: 'main' }), ), - ).toEqual('https://binder.curvenote.dev/build/gl/binder-examples%2Frequirements/main'); + ).toEqual('https://binder.curvenote.dev/build/gl/executablebooks%2Fthebe-binder-base/main'); expect(() => makeGitLabUrl(makeBinderOptions({ binderUrl, repoProvider: RepoProvider.git })), ).toThrow(); diff --git a/packages/core/tests/options.spec.ts b/packages/core/tests/options.spec.ts index c1e9eef1..c297f72f 100644 --- a/packages/core/tests/options.spec.ts +++ b/packages/core/tests/options.spec.ts @@ -11,7 +11,7 @@ describe('options', () => { test('defaults', () => { expect(makeBinderOptions({})).toEqual({ repo: 'binder-examples/requirements', - ref: 'master', + ref: 'HEAD', binderUrl: 'https://mybinder.org', repoProvider: RepoProvider.github, }); From acd79b7b78eb3dcbcefeaea8f889f9bbafaf1396 Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 14:26:32 +0100 Subject: [PATCH 6/7] =?UTF-8?q?=F0=9F=A7=B9=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/demo-react/src/App.tsx | 2 +- apps/demo-react/src/ThebeStatusTray.tsx | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/demo-react/src/App.tsx b/apps/demo-react/src/App.tsx index b2b99338..be6c32ed 100644 --- a/apps/demo-react/src/App.tsx +++ b/apps/demo-react/src/App.tsx @@ -1,4 +1,4 @@ -import { useEffect, useMemo, useState } from 'react'; +import { useMemo, useState } from 'react'; import { ThebeBundleLoaderProvider, ThebeServerProvider } from 'thebe-react'; import { NavLink, Outlet } from 'react-router-dom'; import './App.css'; diff --git a/apps/demo-react/src/ThebeStatusTray.tsx b/apps/demo-react/src/ThebeStatusTray.tsx index f08c11a6..81e9361c 100644 --- a/apps/demo-react/src/ThebeStatusTray.tsx +++ b/apps/demo-react/src/ThebeStatusTray.tsx @@ -1,10 +1,9 @@ import { useState, useEffect } from 'react'; import { ThebeEventData, ThebeEventType } from 'thebe-core'; -import { useThebeLoader, useThebeServer } from 'thebe-react'; +import { useThebeServer } from 'thebe-react'; export function ThebeStatusTray() { - const { core } = useThebeLoader(); - const { connecting, ready, error, events } = useThebeServer(); + const { connecting, error, events } = useThebeServer(); const [subscribed, setSubscribed] = useState(false); const [status, setStatus] = useState(null); From 7ef1a6122d1cc14093f4043df572bedfd5b8e9c7 Mon Sep 17 00:00:00 2001 From: stevejpurves Date: Mon, 19 Jun 2023 14:53:14 +0100 Subject: [PATCH 7/7] =?UTF-8?q?=E2=9C=85fixed=20core=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/core/tests/config.spec.ts | 4 ++-- packages/core/tests/options.spec.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/core/tests/config.spec.ts b/packages/core/tests/config.spec.ts index 77482931..d150ca09 100644 --- a/packages/core/tests/config.spec.ts +++ b/packages/core/tests/config.spec.ts @@ -15,8 +15,8 @@ describe('config', () => { }); test('binder', () => { expect(config.binder).toEqual({ - repo: 'binder-examples/requirements', - ref: 'master', + repo: 'executablebooks/thebe-binder-base', + ref: 'HEAD', binderUrl: 'https://mybinder.org', repoProvider: RepoProvider.github, }); diff --git a/packages/core/tests/options.spec.ts b/packages/core/tests/options.spec.ts index c297f72f..f1259f88 100644 --- a/packages/core/tests/options.spec.ts +++ b/packages/core/tests/options.spec.ts @@ -10,7 +10,7 @@ describe('options', () => { describe('binder', () => { test('defaults', () => { expect(makeBinderOptions({})).toEqual({ - repo: 'binder-examples/requirements', + repo: 'executablebooks/thebe-binder-base', ref: 'HEAD', binderUrl: 'https://mybinder.org', repoProvider: RepoProvider.github,