From 95a7f50824b3cf21a6d2f0cc8c8297ae211d22c2 Mon Sep 17 00:00:00 2001 From: Tim Daniel Metzler Date: Wed, 23 Oct 2024 15:00:51 +0200 Subject: [PATCH] Add new hello world lab-extension --- packages/lab-extension/package.json | 197 ++++++++++++++++++++++ packages/lab-extension/schema/plugin.json | 8 + packages/lab-extension/src/index.ts | 41 +++++ packages/lab-extension/style/base.css | 5 + packages/lab-extension/style/index.css | 1 + packages/lab-extension/style/index.js | 1 + packages/lab-extension/tsconfig.json | 8 + 7 files changed, 261 insertions(+) create mode 100644 packages/lab-extension/package.json create mode 100644 packages/lab-extension/schema/plugin.json create mode 100644 packages/lab-extension/src/index.ts create mode 100644 packages/lab-extension/style/base.css create mode 100644 packages/lab-extension/style/index.css create mode 100644 packages/lab-extension/style/index.js create mode 100644 packages/lab-extension/tsconfig.json diff --git a/packages/lab-extension/package.json b/packages/lab-extension/package.json new file mode 100644 index 00000000..8ed1319c --- /dev/null +++ b/packages/lab-extension/package.json @@ -0,0 +1,197 @@ +{ + "name": "@e2xgrader/labextension", + "version": "0.1.0", + "description": "A JupyterLab extension which bundles e2xgrader extensions", + "keywords": [ + "jupyter", + "jupyterlab", + "jupyterlab-extension" + ], + "homepage": "https://github.com/DigiKlausur/e2xgrader", + "bugs": { + "url": "https://github.com/DigiKlausur/e2xgrader/issues" + }, + "license": "BSD-3-Clause", + "author": { + "name": "Tim Metzler", + "email": "tim.metzler@h-brs.de" + }, + "files": [ + "lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}", + "style/**/*.{css,js,eot,gif,html,jpg,json,png,svg,woff2,ttf}", + "src/**/*.{ts,tsx}", + "schema/*.json" + ], + "main": "lib/index.js", + "types": "lib/index.d.ts", + "style": "style/index.css", + "repository": { + "type": "git", + "url": "https://github.com/DigiKlausur/e2xgrader.git" + }, + "scripts": { + "build": "jlpm build:lib && jlpm build:labextension:dev", + "build:prod": "jlpm clean && jlpm build:lib:prod && jlpm build:labextension", + "build:labextension": "jupyter labextension build .", + "build:labextension:dev": "jupyter labextension build --development True .", + "build:lib": "tsc --sourceMap", + "build:lib:prod": "tsc", + "clean": "jlpm clean:lib", + "clean:lib": "rimraf lib tsconfig.tsbuildinfo", + "clean:lintcache": "rimraf .eslintcache .stylelintcache", + "clean:labextension": "rimraf e2xgrader_extensions/labextension e2xgrader_extensions/_version.py", + "clean:all": "jlpm clean:lib && jlpm clean:labextension && jlpm clean:lintcache", + "eslint": "jlpm eslint:check --fix", + "eslint:check": "eslint . --cache --ext .ts,.tsx", + "install:extension": "jlpm build", + "lint": "jlpm stylelint && jlpm prettier && jlpm eslint", + "lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check", + "prettier": "jlpm prettier:base --write --list-different", + "prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css,.json,.md}\"", + "prettier:check": "jlpm prettier:base --check", + "stylelint": "jlpm stylelint:check --fix", + "stylelint:check": "stylelint --cache \"style/**/*.css\"", + "test": "jest --coverage", + "watch": "run-p watch:src watch:labextension", + "watch:src": "tsc -w --sourceMap", + "watch:labextension": "jupyter labextension watch ." + }, + "dependencies": { + "@jupyterlab/application": "^4.0.0", + "@jupyterlab/settingregistry": "^4.0.0" + }, + "devDependencies": { + "@jupyterlab/builder": "^4.0.0", + "@jupyterlab/testutils": "^4.0.0", + "@types/jest": "^29.2.0", + "@types/json-schema": "^7.0.11", + "@types/react": "^18.0.26", + "@types/react-addons-linked-state-mixin": "^0.14.22", + "@typescript-eslint/eslint-plugin": "^6.1.0", + "@typescript-eslint/parser": "^6.1.0", + "css-loader": "^6.7.1", + "eslint": "^8.36.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.2.0", + "npm-run-all": "^4.1.5", + "prettier": "^3.0.0", + "rimraf": "^5.0.1", + "source-map-loader": "^1.0.2", + "style-loader": "^3.3.1", + "stylelint": "^15.10.1", + "stylelint-config-recommended": "^13.0.0", + "stylelint-config-standard": "^34.0.0", + "stylelint-csstree-validator": "^3.0.0", + "stylelint-prettier": "^4.0.0", + "typescript": "~5.0.2", + "yjs": "^13.5.0" + }, + "sideEffects": [ + "style/*.css", + "style/index.js" + ], + "styleModule": "style/index.js", + "publishConfig": { + "access": "public" + }, + "jupyterlab": { + "extension": true, + "outputDir": "../../e2xgrader/static/labextensions/@e2xgrader/labextension", + "schemaDir": "schema" + }, + "eslintIgnore": [ + "node_modules", + "dist", + "coverage", + "**/*.d.ts", + "tests", + "**/__tests__", + "ui-tests" + ], + "eslintConfig": { + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "plugin:prettier/recommended" + ], + "parser": "@typescript-eslint/parser", + "parserOptions": { + "project": "tsconfig.json", + "sourceType": "module" + }, + "plugins": [ + "@typescript-eslint" + ], + "rules": { + "@typescript-eslint/naming-convention": [ + "error", + { + "selector": "interface", + "format": [ + "PascalCase" + ], + "custom": { + "regex": "^I[A-Z]", + "match": true + } + } + ], + "@typescript-eslint/no-unused-vars": [ + "warn", + { + "args": "none" + } + ], + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-namespace": "off", + "@typescript-eslint/no-use-before-define": "off", + "@typescript-eslint/quotes": [ + "error", + "single", + { + "avoidEscape": true, + "allowTemplateLiterals": false + } + ], + "curly": [ + "error", + "all" + ], + "eqeqeq": "error", + "prefer-arrow-callback": "error" + } + }, + "prettier": { + "singleQuote": true, + "trailingComma": "none", + "arrowParens": "avoid", + "endOfLine": "auto", + "overrides": [ + { + "files": "package.json", + "options": { + "tabWidth": 4 + } + } + ] + }, + "stylelint": { + "extends": [ + "stylelint-config-recommended", + "stylelint-config-standard", + "stylelint-prettier/recommended" + ], + "plugins": [ + "stylelint-csstree-validator" + ], + "rules": { + "csstree/validator": true, + "property-no-vendor-prefix": null, + "selector-class-pattern": "^([a-z][A-z\\d]*)(-[A-z\\d]+)*$", + "selector-no-vendor-prefix": null, + "value-no-vendor-prefix": null + } + } +} diff --git a/packages/lab-extension/schema/plugin.json b/packages/lab-extension/schema/plugin.json new file mode 100644 index 00000000..c4f7311a --- /dev/null +++ b/packages/lab-extension/schema/plugin.json @@ -0,0 +1,8 @@ +{ + "jupyter.lab.shortcuts": [], + "title": "@e2xgrader/labextension", + "description": "@e2xgrader/labextension settings.", + "type": "object", + "properties": {}, + "additionalProperties": false +} diff --git a/packages/lab-extension/src/index.ts b/packages/lab-extension/src/index.ts new file mode 100644 index 00000000..5d93948e --- /dev/null +++ b/packages/lab-extension/src/index.ts @@ -0,0 +1,41 @@ +import { + JupyterFrontEnd, + JupyterFrontEndPlugin +} from '@jupyterlab/application'; + +import { ISettingRegistry } from '@jupyterlab/settingregistry'; + +/** + * Initialization data for the @e2xgrader/labextension extension. + */ +const plugin: JupyterFrontEndPlugin = { + id: '@e2xgrader/labextension:plugin', + description: 'A JupyterLab extension which bundles e2xgrader extensions', + autoStart: true, + optional: [ISettingRegistry], + activate: ( + app: JupyterFrontEnd, + settingRegistry: ISettingRegistry | null + ) => { + console.log('JupyterLab extension @e2xgrader/labextension is activated!'); + + if (settingRegistry) { + settingRegistry + .load(plugin.id) + .then(settings => { + console.log( + '@e2xgrader/labextension settings loaded:', + settings.composite + ); + }) + .catch(reason => { + console.error( + 'Failed to load settings for @e2xgrader/labextension.', + reason + ); + }); + } + } +}; + +export default [plugin]; diff --git a/packages/lab-extension/style/base.css b/packages/lab-extension/style/base.css new file mode 100644 index 00000000..e11f4577 --- /dev/null +++ b/packages/lab-extension/style/base.css @@ -0,0 +1,5 @@ +/* + See the JupyterLab Developer Guide for useful CSS Patterns: + + https://jupyterlab.readthedocs.io/en/stable/developer/css.html +*/ diff --git a/packages/lab-extension/style/index.css b/packages/lab-extension/style/index.css new file mode 100644 index 00000000..8a7ea29e --- /dev/null +++ b/packages/lab-extension/style/index.css @@ -0,0 +1 @@ +@import url('base.css'); diff --git a/packages/lab-extension/style/index.js b/packages/lab-extension/style/index.js new file mode 100644 index 00000000..a028a764 --- /dev/null +++ b/packages/lab-extension/style/index.js @@ -0,0 +1 @@ +import './base.css'; diff --git a/packages/lab-extension/tsconfig.json b/packages/lab-extension/tsconfig.json new file mode 100644 index 00000000..102b45fd --- /dev/null +++ b/packages/lab-extension/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "../../tsconfig", + "compilerOptions": { + "outDir": "lib", + "rootDir": "src" + }, + "include": ["src/**/*"] +}