Skip to content

Commit 76fe431

Browse files
authored
Merge pull request #20 from hbcarlos/blockly_file_type
FileType, Manager and Register
2 parents d56ccaf + acd288d commit 76fe431

22 files changed

+1456
-1036
lines changed

.eslintignore

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
1-
node_modules
1+
**/node_modules
2+
**/lib
3+
**/package.json
4+
**/patches
25
dist
36
coverage
47
**/*.d.ts
58
tests
9+
10+
.github
11+
binder
12+
jupyterlab_blockly/labextension
13+
.eslintignore
14+
.eslintrc.js
15+
.gitignore
16+
.pre-commit-config.yaml
17+
.prettierignore
18+
.prettierrc
19+
CHANGELOG.md
20+
install.json
21+
LICENSE
22+
MANIFEST.in
23+
pyproject.toml
24+
README.md
25+
RELEASE.md
26+
tsconfig.json
27+
yarn.lock

.eslintrc.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ module.exports = {
33
'eslint:recommended',
44
'plugin:@typescript-eslint/eslint-recommended',
55
'plugin:@typescript-eslint/recommended',
6-
'plugin:prettier/recommended'
6+
'plugin:prettier/recommended',
7+
'plugin:react/recommended'
78
],
89
parser: '@typescript-eslint/parser',
910
parserOptions: {
@@ -15,11 +16,11 @@ module.exports = {
1516
'@typescript-eslint/naming-convention': [
1617
'error',
1718
{
18-
'selector': 'interface',
19-
'format': ['PascalCase'],
20-
'custom': {
21-
'regex': '^I[A-Z]',
22-
'match': true
19+
selector: 'interface',
20+
format: ['PascalCase'],
21+
custom: {
22+
regex: '^I[A-Z]',
23+
match: true
2324
}
2425
}
2526
],

.github/workflows/binder-on-pr.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Reference https://mybinder.readthedocs.io/en/latest/howto/gh-actions-badges.html
2+
name: Binder Badge
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
7+
permissions:
8+
pull-requests: write
9+
jobs:
10+
binder:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: comment on PR with Binder link
14+
uses: actions/github-script@v3
15+
with:
16+
github-token: ${{secrets.GITHUB_TOKEN}}
17+
script: |
18+
var PR_HEAD_USERREPO = process.env.PR_HEAD_USERREPO;
19+
var PR_HEAD_REF = process.env.PR_HEAD_REF;
20+
github.issues.createComment({
21+
issue_number: context.issue.number,
22+
owner: context.repo.owner,
23+
repo: context.repo.repo,
24+
body: `[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/${PR_HEAD_USERREPO}/${PR_HEAD_REF}?urlpath=lab) :point_left: Launch a Binder on branch _${PR_HEAD_USERREPO}/${PR_HEAD_REF}_`
25+
})
26+
env:
27+
PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}
28+
PR_HEAD_USERREPO: ${{ github.event.pull_request.head.repo.full_name }}

.pre-commit-config.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: prettier
5+
name: prettier
6+
entry: 'npm run prettier'
7+
language: node
8+
- id: eslint
9+
name: eslint
10+
entry: 'npm run eslint'
11+
language: node

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"singleQuote": true,
33
"trailingComma": "none",
4-
"arrowParens": "avoid"
5-
}
4+
"arrowParens": "avoid",
5+
"endOfLine": "auto"
6+
}

README.md

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,34 @@
55
Blockly extension for JupyterLab.
66

77
## Blockly
8+
89
Blockly is a library from Google for building beginner-friendly block-based programming languages.
910

1011
Docs: https://developers.google.com/blockly/guides/overview
1112
Repo: https://github.com/google/blockly
1213

13-
1414
## Requirements
1515

16-
* JupyterLab == 3.4
16+
- JupyterLab == 3.4
1717

1818
## Install
1919

2020
To install the extension, execute:
2121

2222
```bash
23-
micromamba create -n blockly -c conda-forge python
23+
micromamba create -n blockly -c conda-forge python jupyterlab==3.4 ipykernel xeus-python xeus-lua jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR
2424
micromamba activate blockly
2525
pip install jupyterlab_blockly
2626
```
2727

28+
#### Kernels
29+
30+
- ipykernel
31+
- xeus-python
32+
- xeus-lua
33+
- [JavaScript](https://github.com/n-riesco/ijavascript#installation)
34+
- [JavaScript](https://github.com/yunabe/tslab)
35+
2836
## Uninstall
2937

3038
To remove the extension, execute:
@@ -33,7 +41,6 @@ To remove the extension, execute:
3341
pip uninstall jupyterlab_blockly
3442
```
3543

36-
3744
## Contributing
3845

3946
### Development install
@@ -45,12 +52,14 @@ The `jlpm` command is JupyterLab's pinned version of
4552
`yarn` or `npm` in lieu of `jlpm` below.
4653

4754
```bash
48-
micromamba create -n blockly -c conda-forge python nodejs yarn jupyterlab==3.4 jupyter-packaging
55+
micromamba create -n blockly -c conda-forge python nodejs pre-commit yarn jupyterlab==3.4 jupyter-packaging jupyterlab-language-pack-es-ES jupyterlab-language-pack-fr-FR ipykernel xeus-python xeus-lua
4956
micromamba activate blockly
5057
# Clone the repo to your local environment
5158
# Change directory to the jupyterlab_blockly directory
5259
# Install package in development mode
5360
pip install -e .
61+
# Installing pre-commit to run command when adding commits
62+
pre-commit install
5463
# Link your development version of the extension with JupyterLab
5564
jupyter labextension develop . --overwrite
5665
# Rebuild extension Typescript source after making changes

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Python package. Before generating a package, we first need to install `build`.
1515
pip install build twine
1616
```
1717

18-
To create a Python source package (``.tar.gz``) and the binary package (`.whl`) in the `dist/` directory, do:
18+
To create a Python source package (`.tar.gz`) and the binary package (`.whl`) in the `dist/` directory, do:
1919

2020
```bash
2121
python -m build

package.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@
3737
"clean:lib": "rimraf lib tsconfig.tsbuildinfo",
3838
"clean:labextension": "rimraf jupyterlab_blockly/labextension",
3939
"clean:all": "jlpm run clean:lib && jlpm run clean:labextension",
40-
"eslint": "eslint . --ext .ts,.tsx --fix",
40+
"eslint": "jlpm eslint:check --fix",
4141
"eslint:check": "eslint . --ext .ts,.tsx",
4242
"install:extension": "jlpm run build",
43+
"lint": "jlpm stylelint && jlpm prettier && jlpm eslint",
44+
"lint:check": "jlpm stylelint:check && jlpm prettier:check && jlpm eslint:check",
45+
"prettier": "jlpm prettier:base --write --list-different",
46+
"prettier:base": "prettier \"**/*{.ts,.tsx,.js,.jsx,.css}\"",
47+
"prettier:check": "jlpm prettier:base --check",
4348
"watch": "run-p watch:src watch:labextension",
4449
"watch:src": "tsc -w",
4550
"watch:labextension": "jupyter labextension watch .",
@@ -48,11 +53,16 @@
4853
"dependencies": {
4954
"@jupyterlab/application": "^3.4",
5055
"@jupyterlab/apputils": "^3.4",
56+
"@jupyterlab/cells": "^3.4",
57+
"@jupyterlab/codeeditor": "^3.4",
58+
"@jupyterlab/coreutils": "^5.4",
5159
"@jupyterlab/docregistry": "^3.4",
5260
"@jupyterlab/filebrowser": "^3.4",
5361
"@jupyterlab/launcher": "^3.4",
5462
"@jupyterlab/outputarea": "^3.4",
5563
"@jupyterlab/rendermime": "^3.4",
64+
"@jupyterlab/services": "^6.4",
65+
"@jupyterlab/ui-components": "^3.4",
5666
"@lumino/algorithm": "^1.9.0",
5767
"@lumino/coreutils": "^1.11.0",
5868
"@lumino/messaging": "^1.10.0",
@@ -69,6 +79,7 @@
6979
"eslint": "^8.9.0",
7080
"eslint-config-prettier": "^8.4.0",
7181
"eslint-plugin-prettier": "^4.0.0",
82+
"eslint-plugin-react": "^7.30.0",
7283
"npm-run-all": "^4.1.5",
7384
"prettier": "^2.5.1",
7485
"rimraf": "^3.0.2",

src/factory.ts

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import {
44
DocumentModel
55
} from '@jupyterlab/docregistry';
66
import { IRenderMimeRegistry } from '@jupyterlab/rendermime';
7-
// import { ITranslator } from '@jupyterlab/translation';
7+
import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
88

99
import { BlocklyEditor, BlocklyPanel } from './widget';
10+
import { BlocklyRegistry } from './registry';
1011
import { BlocklyManager } from './manager';
1112

1213
/**
@@ -16,10 +17,9 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
1617
BlocklyEditor,
1718
DocumentModel
1819
> {
19-
private _manager: BlocklyManager;
20+
private _registry: BlocklyRegistry;
2021
private _rendermime: IRenderMimeRegistry;
21-
private _language: string;
22-
// private _translator: ITranslator;
22+
private _mimetypeService: IEditorMimeTypeService;
2323

2424
/**
2525
* Constructor of BlocklyEditorFactory.
@@ -28,14 +28,13 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
2828
*/
2929
constructor(options: BlocklyEditorFactory.IOptions) {
3030
super(options);
31-
this._manager = new BlocklyManager();
31+
this._registry = new BlocklyRegistry();
3232
this._rendermime = options.rendermime;
33-
this._language = this._manager.language;
34-
// this._translator = options.translator;
33+
this._mimetypeService = options.mimetypeService;
3534
}
3635

37-
get manager(): BlocklyManager {
38-
return this._manager;
36+
get registry(): BlocklyRegistry {
37+
return this._registry;
3938
}
4039

4140
/**
@@ -47,15 +46,13 @@ export class BlocklyEditorFactory extends ABCWidgetFactory<
4746
protected createNewWidget(
4847
context: DocumentRegistry.IContext<DocumentModel>
4948
): BlocklyEditor {
50-
return new BlocklyEditor({
51-
context,
52-
content: new BlocklyPanel(
53-
context,
54-
this._manager,
55-
this._rendermime,
56-
this._language
57-
)
58-
});
49+
const manager = new BlocklyManager(
50+
this._registry,
51+
context.sessionContext,
52+
this._mimetypeService
53+
);
54+
const content = new BlocklyPanel(context, manager, this._rendermime);
55+
return new BlocklyEditor({ context, content, manager });
5956
}
6057
}
6158

@@ -65,5 +62,9 @@ export namespace BlocklyEditorFactory {
6562
* A rendermime instance.
6663
*/
6764
rendermime: IRenderMimeRegistry;
65+
/*
66+
* A mimeType service instance.
67+
*/
68+
mimetypeService: IEditorMimeTypeService;
6869
}
6970
}

0 commit comments

Comments
 (0)