Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add notebook #3945

Merged
merged 42 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a19e917
feat: add notebook module
zhanba Aug 16, 2024
364822e
chore: merge from main
ensorrow Oct 14, 2024
34c851e
chore: temp support startup
ensorrow Oct 15, 2024
e493780
fix: issues related to the libro export way
ensorrow Oct 17, 2024
164e4b8
feat: upgrade typescript to 5, build notebook to esnext
ensorrow Oct 17, 2024
6f5d7a0
chore: sync libro official change
ensorrow Oct 18, 2024
f0d3eb4
fix: change build setting
ensorrow Oct 18, 2024
c543e04
chore: sync libro official change
ensorrow Oct 18, 2024
5ceabff
fix: devtool support esModule
ensorrow Oct 19, 2024
e125799
chore: reset test
ensorrow Oct 19, 2024
6d66e9e
fix: outline
ensorrow Oct 19, 2024
a542eb1
feat: add notebookServerHost to appConfig
ensorrow Oct 19, 2024
0f2b505
chore: only init libro server manager when notebook file opened for t…
ensorrow Oct 28, 2024
4946581
chore: add readme
ensorrow Oct 28, 2024
a6f086c
Merge branch 'main' of https://github.com/opensumi/core into feat-not…
ensorrow Oct 28, 2024
1caa861
chore: remove useless code
ensorrow Oct 28, 2024
404f87a
fix: missing extension
ensorrow Oct 28, 2024
952f347
fix: dep conflict
ensorrow Oct 28, 2024
7b326b4
chore: update lock
ensorrow Oct 28, 2024
10901e4
chore: add fixme to existed error
ensorrow Oct 28, 2024
99eed7f
fix: ts error
ensorrow Oct 28, 2024
1545923
fix: lint error
ensorrow Oct 28, 2024
5135840
fix: add missing deps
ensorrow Oct 28, 2024
1a26793
chore: remove outdated tsconfig
ensorrow Oct 28, 2024
d068651
fix: update server connection settings based on protocol
ensorrow Nov 4, 2024
5764978
chore: add tsconfig for notebook package
ensorrow Nov 12, 2024
d635397
chore: remove useless code
ensorrow Nov 12, 2024
30ecdc7
feat: add authentication token option for notebook server connections
ensorrow Nov 12, 2024
2dec1f0
refactor: extend LibroContribution with Disposable and update theme l…
ensorrow Nov 12, 2024
3f83b46
Merge branch 'main' of https://github.com/opensumi/core into feat-not…
ensorrow Nov 12, 2024
edde5b7
refactor: correct method name typo in multiple files
ensorrow Nov 12, 2024
efde88d
fix: remove useless observer
ensorrow Nov 12, 2024
4d1c804
fix: optimize code
zhanba Nov 13, 2024
922024b
fix: optimize code
ensorrow Nov 13, 2024
8c5e6ac
build: add @opensumi/ide-components dependency
ensorrow Nov 13, 2024
7ffaf6e
chore: update lock
ensorrow Nov 13, 2024
b3d62ff
chore: simplify notebook command register
ensorrow Nov 13, 2024
d18b4ad
fix: lint error
ensorrow Nov 13, 2024
6417ff0
docs: update Jupyter notebook server README with token info
ensorrow Nov 13, 2024
20a4615
feat: add i18n support for notebook kernel panel
ensorrow Nov 13, 2024
7387749
chore: remove useless code
ensorrow Nov 13, 2024
b9e9381
refactor: add cleanup for theme service event listener
ensorrow Nov 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,8 @@ iteration-plan.md
tools/electron/app
tools/electron/extensions
tools/workspace

# jupyter
.ipynb_checkpoints

*.tsbuildinfo
10 changes: 10 additions & 0 deletions configs/ts/references/tsconfig.notebook.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"extends": "../tsconfig.base.json",
"compilerOptions": {
"module": "esnext",
"moduleResolution": "bundler",
"rootDir": "../../../packages/notebook/src",
"outDir": "../../../packages/notebook/lib"
},
"include": ["../../../packages/notebook/src"]
}
4 changes: 2 additions & 2 deletions configs/ts/tsconfig.base.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"baseUrl": "./",
"compilerOptions": {
"module": "commonjs",
"target": "es2017",
"module": "nodenext",
"target": "es2018",
"moduleResolution": "nodenext",
"strict": true,
"strictPropertyInitialization": false,
Expand Down
3 changes: 3 additions & 0 deletions configs/ts/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@
},
{
"path": "./references/tsconfig.playwright.json"
},
{
"path": "./references/tsconfig.notebook.json"
}
]
}
4 changes: 3 additions & 1 deletion configs/ts/tsconfig.resolve.json
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@
"@opensumi/ide-design": ["../packages/design/src/index.ts"],
"@opensumi/ide-design/lib/*": ["../packages/design/src/*"],
"@opensumi/ide-ai-native": ["../packages/ai-native/src/index.ts"],
"@opensumi/ide-ai-native/lib/*": ["../packages/ai-native/src/*"]
"@opensumi/ide-ai-native/lib/*": ["../packages/ai-native/src/*"],
"@opensumi/ide-notebook": ["../packages/notebook/src/index.ts"],
"@opensumi/ide-notebook/lib/*": ["../packages/notebook/src/*"]
}
}
}
106 changes: 53 additions & 53 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,72 +1,75 @@
{
"name": "@opensumi/core",
"private": true,
"repository": {
"type": "git",
"url": "git@github.com:opensumi/core.git"
},
"license": "MIT",
"workspaces": [
"packages/*",
"tools/dev-tool",
"tools/playwright",
"tools/cli-engine"
],
"scripts": {
"preinstall": "node scripts/preinstall.js && husky install",
"clean": "rimraf \"./packages/*/lib\" && lerna run clean",
"check:dep": "tsx ./scripts/depcheck",
"init": "yarn run clean && yarn run build:all",
"start": "yarn run rebuild:node && cross-env HOST=127.0.0.1 WS_PATH=ws://127.0.0.1:8000 NODE_ENV=development tsx ./scripts/start",
"start:remote": "yarn run rebuild:node && cross-env NODE_ENV=development tsx ./scripts/start",
"start:electron": "cross-env NODE_ENV=development tsx ./scripts/start-electron",
"build:components": "cd packages/components && yarn run build:dist",
"start:lite": "cross-env NODE_ENV=development tsx ./scripts/start --script=start:lite",
"bundle:lite": "tsx ./scripts/start --script=bundle:lite",
"bundle:preview": "tsx ./scripts/start --script=bundle:preview",
"start:pty-service": "KTLOG_SHOW_DEBUG=1 npx tsx packages/terminal-next/src/node/pty.proxy.remote.exec.ts",
"create": "tsx ./scripts/create",
"add:node": "tsx ./scripts/add-node",
"add:browser": "tsx ./scripts/add-browser",
"add:node": "tsx ./scripts/add-node",
"build": "yarn run compile",
"build:all": "yarn build:webview-prebuilt && yarn run build && yarn run build:worker-host && yarn run build:ext-host && yarn run build:components && yarn build:monaco-worker",
"compile": "cross-env NODE_ENV=production tsx ./scripts/build",
"build:worker-host": "cd packages/extension && yarn run compile:worker",
"build:ext-host": "cd packages/extension && yarn run build:ext-host",
"build:cli-engine": "cd tools/cli-engine && yarn run build",
"build:components": "cd packages/components && yarn run build:dist",
"build:ext-host": "cd packages/extension && yarn run build:ext-host",
"build:monaco-worker": "cd packages/monaco && yarn run build:worker",
"build:webview-prebuilt": "yarn workspace @opensumi/ide-webview bundle-webview",
"watch:ext-host": "cd packages/extension && yarn run watch:ext-host",
"watch:worker-host": "cd packages/extension && yarn run watch:worker",
"watch": "yarn run rebuild:node && cross-env NODE_ENV=production tsx ./scripts/watch",
"publish": "yarn run build:all && tsx ./scripts/publish",
"publish:snapshot": "yarn run publish --rollback --type=snapshot",
"publish:next": "yarn run publish --rollback --type=next",
"update-version": "tsx ./scripts/publish --versionOnly",
"update-disttag": "tsx ./scripts/dist-tag",
"build:worker-host": "cd packages/extension && yarn run compile:worker",
"bundle:lite": "tsx ./scripts/start --script=bundle:lite",
"bundle:preview": "tsx ./scripts/start --script=bundle:preview",
"changelog": "tsx -P scripts/tsconfig.scripts.json scripts/changelog/index.ts",
"changelog-old": "node scripts/changelog/index.js",
"check:dep": "tsx ./scripts/depcheck",
"ci": "yarn run init && yarn run test:cov",
"clean": "rimraf \"./packages/*/lib\" && lerna run clean",
"compile": "cross-env NODE_ENV=production tsx ./scripts/build",
"create": "tsx ./scripts/create",
"download-extension": "cross-env DEBUG=InstallExtension MARKETPLACE=ALI node scripts/download.js",
"format": "yarn run lint:fix && prettier \"**/*.{js,jsx,ts,tsx,html,css,less}\" --write",
"init": "yarn run clean && yarn run build:all",
"preinstall": "node scripts/preinstall.js && husky install",
"iteration": "tsx -P scripts/tsconfig.scripts.json scripts/iteration-plan.ts",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "yarn run lint --fix",
"format": "yarn run lint:fix && prettier \"**/*.{js,jsx,ts,tsx,html,css,less}\" --write",
"manifest": "tsx ./scripts/generate-manifest-json",
"prepare:test": "yarn && yarn run compile && yarn run build:worker-host",
"publish": "yarn run build:all && tsx ./scripts/publish",
"publish:next": "yarn run publish --rollback --type=next",
"publish:snapshot": "yarn run publish --rollback --type=snapshot",
"rebuild:node": "sumi rebuild",
"test:module": "cross-env NODE_OPTIONS=--max-old-space-size=5120 tsx ./scripts/module-jest",
"start": "yarn run rebuild:node && cross-env HOST=127.0.0.1 WS_PATH=ws://127.0.0.1:8000 NODE_ENV=development tsx ./scripts/start",
"start:e2e": "yarn start --script=start:e2e",
"start:electron": "cross-env NODE_ENV=development tsx ./scripts/start-electron",
"start:lite": "cross-env NODE_ENV=development tsx ./scripts/start --script=start:lite",
"start:pty-service": "KTLOG_SHOW_DEBUG=1 npx tsx packages/terminal-next/src/node/pty.proxy.remote.exec.ts",
"start:remote": "yarn run rebuild:node && cross-env NODE_ENV=development tsx ./scripts/start",
"test": "node --expose-gc ./node_modules/.bin/jest --forceExit --detectOpenHandles",
"test:cov": "cross-env NODE_OPTIONS=--max-old-space-size=32768 yarn run test:heap --coverage",
"test:heap": "yarn test --logHeapUsage",
"test:module": "cross-env NODE_OPTIONS=--max-old-space-size=5120 tsx ./scripts/module-jest",
"test:ui": "tsx ./scripts/run-ui-tests",
"test:ui-ci": "tsx ./scripts/run-ui-tests --ci=true",
"test:ui-headful": "tsx ./scripts/run-ui-tests --headful=true",
"test:ui-report": "tsx ./scripts/run-ui-tests --report=true",
"test": "node --expose-gc ./node_modules/.bin/jest --forceExit --detectOpenHandles",
"test:heap": "yarn test --logHeapUsage",
"prepare:test": "yarn && yarn run compile && yarn run build:worker-host",
"test:cov": "cross-env NODE_OPTIONS=--max-old-space-size=32768 yarn run test:heap --coverage",
"ci": "yarn run init && yarn run test:cov",
"download-extension": "cross-env DEBUG=InstallExtension node scripts/download.js",
"update-disttag": "tsx ./scripts/dist-tag",
"update-version": "tsx ./scripts/publish --versionOnly",
"update:iconfont": "tsx ./scripts/download-iconfont.ts",
"changelog-old": "node scripts/changelog/index.js",
"changelog": "tsx -P scripts/tsconfig.scripts.json scripts/changelog/index.ts",
"iteration": "tsx -P scripts/tsconfig.scripts.json scripts/iteration-plan.ts",
"manifest": "tsx ./scripts/generate-manifest-json"
},
"engines": {
"node": ">=18.12.0"
"watch": "yarn run rebuild:node && cross-env NODE_ENV=production tsx ./scripts/watch",
"watch:ext-host": "cd packages/extension && yarn run watch:ext-host",
"watch:worker-host": "cd packages/extension && yarn run watch:worker"
},
"lint-staged": {
"*.{js,jsx,ts,tsx,md,html,css,less,json,yml}": "prettier --write",
"*.{js,jsx,ts,tsx}": "eslint --fix --quiet"
},
"repository": {
"type": "git",
"url": "git@github.com:opensumi/core.git"
},
"devDependencies": {
"@ast-grep/napi": "^0.17.1",
"@commitlint/cli": "^19.2.1",
Expand All @@ -79,7 +82,7 @@
"@types/jest": "^29.5.6",
"@types/jsdom": "^16.2.14",
"@types/lodash": "^4.14.202",
"@types/node": "^20.11.30",
"@types/node": "^22.7.6",
"@types/node-fetch": "^2.6.1",
"@types/react": "^18.2.0",
"@types/react-dom": "^18.2.0",
Expand Down Expand Up @@ -137,15 +140,12 @@
"ts-node": "^10.9.1",
"tslib": "^2.6.2",
"tsx": "^4.7.1",
"typescript": "4.9.3",
"typescript": "^5.6.3",
"webpack": "^5.90.0",
"webpack-manifest-plugin": "^5.0.0"
},
"workspaces": [
"packages/*",
"tools/dev-tool",
"tools/playwright",
"tools/cli-engine"
],
"packageManager": "yarn@4.4.1"
"packageManager": "yarn@4.4.1",
"engines": {
"node": ">=18.12.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export async function getPrefixPrompt(

const { maxPromptTokenSize } = promptConfig;

const prefixPercent = 1 - promptConfig.wishList.afterCursor.extOption.suffixPercent ?? 0.25;
const prefixPercent = 1 - (promptConfig.wishList.afterCursor.extOption.suffixPercent ?? 0.25);
const beforeCursorMaxTokenSize = Math.ceil(prefixPercent * maxPromptTokenSize);
const leftTokenSize = beforeCursorMaxTokenSize;

Expand Down
2 changes: 1 addition & 1 deletion packages/comments/src/browser/comments.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1106,7 +1106,7 @@ export class CommentsService extends Disposable implements ICommentsService {
public getProviderIdsByLine(line: number): string[] {
const result: string[] = [];
if (this.rangeOwner.size === 1) {
return [this.rangeOwner.keys().next().value];
return [this.rangeOwner.keys().next().value!];
}
for (const rangeOwner of this.rangeOwner) {
const [id, ranges] = rangeOwner;
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/menu/MenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface MenuItemProps
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
onMouseEnter?: (e: { key: string; domEvent: React.MouseEvent<HTMLElement> }) => void;
onMouseLeave?: (e: { key: string; domEvent: React.MouseEvent<HTMLElement> }) => void;
ref?: React.Ref<HTMLElement> | undefined;
}

export default class MenuItem extends React.Component<MenuItemProps> {
Expand Down
1 change: 1 addition & 0 deletions packages/components/src/menu/SubMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface SubMenuProps extends RCSubMenuProps {
onKeyDown?: (e: React.KeyboardEvent<HTMLElement>) => void;
popupOffset?: [number, number];
popupClassName?: string;
ref?: React.Ref<HTMLLIElement> | undefined;
}

class SubMenu extends React.Component<SubMenuProps, any> {
Expand Down
12 changes: 10 additions & 2 deletions packages/core-browser/src/bootstrap/app.view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import ReactDom from 'react-dom/client';

import { ComponentContextProvider, IIconResourceOptions } from '@opensumi/ide-components';
import { IEventBus, URI, getDebugLogger, localize } from '@opensumi/ide-core-common';
import { ContributionProvider, IEventBus, URI, getDebugLogger, localize } from '@opensumi/ide-core-common';

import { IClientApp } from '../browser-module';
import { DefaultLayout } from '../components/layout/default-layout';
Expand All @@ -12,6 +12,8 @@ import { allSlot } from '../react-providers/slot';
import { LabelService } from '../services';
import { getIcon } from '../style/icon/icon';

import { ClientAppContextContribution } from './context-contribution';

export interface AppProps {
app: IClientApp;
main: React.ComponentType<{ callback?: () => void }>;
Expand Down Expand Up @@ -70,7 +72,7 @@ const defaultAppRender =
const debugLogger = getDebugLogger();

export function renderClientApp(app: IClientApp, container: HTMLElement | IAppRenderer) {
const Layout = app.config.layoutComponent || DefaultLayout;
let Layout = app.config.layoutComponent || DefaultLayout;
const overlayComponents = app.browserModules
.filter((mod) => mod.isOverlay)
.map((mod) => {
Expand All @@ -82,6 +84,12 @@ export function renderClientApp(app: IClientApp, container: HTMLElement | IAppRe
})
.filter(Boolean) as React.ComponentType[];

const injector = app.injector;
const clientAppContextContribution: ContributionProvider<ClientAppContextContribution> =
injector.get(ClientAppContextContribution);
const contextContrib = clientAppContextContribution.getContributions();
contextContrib.forEach((contextProvider) => (Layout = contextProvider.registerClientAppContext(Layout, injector)));

const IdeApp = (props) => <App {...props} app={app} main={Layout} overlays={overlayComponents} />;

const render = typeof container === 'function' ? container : defaultAppRender(container);
Expand Down
7 changes: 7 additions & 0 deletions packages/core-browser/src/bootstrap/context-contribution.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { Injector } from '@opensumi/di';

export const ClientAppContextContribution = Symbol('ClientAppContextContribution');

export interface ClientAppContextContribution {
registerClientAppContext: (layout: React.FC, injector: Injector) => React.FC;
}
1 change: 1 addition & 0 deletions packages/core-browser/src/bootstrap/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './app.interface';
export * from './app.view';
export * from './connection';
export * from './context-contribution';
2 changes: 2 additions & 0 deletions packages/core-browser/src/bootstrap/inner-providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ import { VariableContribution, VariableRegistry, VariableRegistryImpl } from '..
import { IWindowService } from '../window';
import { WindowService } from '../window/window.service';

import { ClientAppContextContribution } from './context-contribution';
import { AppLifeCycleService } from './lifecycle.service';

export function injectInnerProviders(injector: Injector) {
Expand All @@ -96,6 +97,7 @@ export function injectInnerProviders(injector: Injector) {
createContributionProvider(injector, TabBarToolbarContribution);
createContributionProvider(injector, ToolBarActionContribution);
createContributionProvider(injector, StaticResourceContribution);
createContributionProvider(injector, ClientAppContextContribution);

// 一些内置抽象实现
const providers: Provider[] = [
Expand Down
9 changes: 9 additions & 0 deletions packages/core-browser/src/react-providers/config-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,15 @@ export interface AppConfig {
* This is useful when your scenario is one-time use, and you can control the opening of the editor tab yourself.
*/
disableRestoreEditorGroupState?: boolean;
/**
* Notebook Server Host
* Provide when you want to connect to a notebook server
*/
notebookServerHost?: string;
/**
* The authentication token for requests. Use an empty string to disable.
*/
notebookServerToken?: string;
}

export interface ICollaborationClientOpts {
Expand Down
2 changes: 1 addition & 1 deletion packages/core-browser/src/services/label-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ const getIconClass = (
};

export function cssEscape(str: string): string {
return str.replace(/[\11\12\14\15\40]/g, '/'); // HTML class names can not contain certain whitespace characters, use / instead, which doesn't exist in file names.
return str.replace(/[\x09\x0a\x0c\x0d\x20]/g, '/'); // HTML class names can not contain certain whitespace characters, use / instead, which doesn't exist in file names.
}

export function basenameOrAuthority(resource: URI) {
Expand Down
2 changes: 1 addition & 1 deletion packages/core-common/src/const/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ export namespace DEFAULT_ALIPAY_CLOUD_REGISTRY {
export const MASTER_KEY = 'i6rkupqyvC6Bc6CiO0yVLNqq';
}

export const DEFAULT_VSCODE_ENGINE_VERSION = '1.68.0';
export const DEFAULT_VSCODE_ENGINE_VERSION = '1.90.0';
5 changes: 2 additions & 3 deletions packages/core-common/src/problem-pattern.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,13 @@
********************************************************************************/
// Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/core/src/common/severity.ts

// eslint-disable-next-line import/no-unresolved
import { Diagnostic } from 'vscode';

import { Injectable } from '@opensumi/di';
import { Disposable, DisposableCollection, IDisposable, URI, isArray, isString } from '@opensumi/ide-utils';

import { ProblemMatcher } from './problem-matcher';

import type { Diagnostic } from 'vscode';

export enum ApplyToKind {
allDocuments,
openDocuments,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ class FloatController {
private origin: number = 0;

state = derived(this, (reader) => ({
enable: this._enable.read(reader),
x: this._x.read(reader),
line: this._line.read(reader),
}));
enable: this._enable.read(reader),
x: this._x.read(reader),
line: this._line.read(reader),
}));

setEnable(value: boolean) {
transaction((tx) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export class SymbolInformationQuickOpenItem extends QuickOpenItem {
}

getIconClass() {
return getSymbolIcon(this.symbol.kind);
return getSymbolIcon(this.symbol.kind as SymbolKindEnum);
}

getDescription() {
Expand Down
Loading
Loading