Skip to content

Commit 2f422c4

Browse files
committed
version 1.1.0
1 parent 59e691c commit 2f422c4

17 files changed

+5762
-359
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
dist.zip

.vscode/getNet.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { networkInterfaces } = require('os');
2+
3+
module.exports = async (mode = 'dev') => {
4+
const { WiFi, Ethernet } = getIp();
5+
const [ip] = WiFi || Ethernet;
6+
const port = '5500';
7+
const src = `https://${ip || '10.0.0'}:${port}`;
8+
console.log('Server starting at: ', src);
9+
return { ip, port };
10+
};
11+
12+
function getIp() {
13+
const nets = networkInterfaces();
14+
const results = {}; // Or just '{}', an empty object
15+
16+
Object.keys(nets).forEach((name) => {
17+
nets[name].forEach((net) => {
18+
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
19+
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
20+
const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4;
21+
if (net.family === familyV4Value && !net.internal) {
22+
if (!results[name]) {
23+
results[name] = [];
24+
}
25+
results[name].push(net.address);
26+
}
27+
});
28+
});
29+
return results;
30+
}

.vscode/run-webpack.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable no-console */
2+
const { spawn } = require('child_process');
3+
const path = require('path');
4+
5+
const webpack = spawn('npx.cmd', ['webpack', '--mode=development', '--watch'], { cwd: path.resolve(__dirname, '../') });
6+
7+
webpack.on('error', (webpackError) => {
8+
if (webpackError) {
9+
console.error(webpackError);
10+
process.exit(1);
11+
}
12+
});
13+
14+
webpack.stdout.on('data', (chunk) => {
15+
const stdout = chunk.toString();
16+
console.log(stdout);
17+
process.send(stdout);
18+
});
19+
20+
webpack.stdout.on('error', (error) => {
21+
console.log(error);
22+
});
23+
24+
webpack.stderr.on('data', (chunk) => {
25+
const stderr = chunk.toString();
26+
console.log(stderr);
27+
});

.vscode/server.crt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIICfjCCAecCFGoKwe9jqvLXZUsAKK8R9rBoxQBVMA0GCSqGSIb3DQEBCwUAMH4x
3+
CzAJBgNVBAYTAklOMRMwEQYDVQQIDApBaml0IEt1bWFyMQwwCgYDVQQHDANCU1Ax
4+
DjAMBgNVBAoMBUZYREJHMQwwCgYDVQQLDANERVYxDTALBgNVBAMMBEFqaXQxHzAd
5+
BgkqhkiG9w0BCQEWEG1lQGFqaXRrdW1hci5kZXYwHhcNMjIwODIxMDc0NjI1WhcN
6+
MjMwODIxMDc0NjI1WjB+MQswCQYDVQQGEwJJTjETMBEGA1UECAwKQWppdCBLdW1h
7+
cjEMMAoGA1UEBwwDQlNQMQ4wDAYDVQQKDAVGWERCRzEMMAoGA1UECwwDREVWMQ0w
8+
CwYDVQQDDARBaml0MR8wHQYJKoZIhvcNAQkBFhBtZUBhaml0a3VtYXIuZGV2MIGf
9+
MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClD9GyID1GNGCdsq8vshf2h/tMUzxW
10+
mWqOoBi8ZSUrQGoZJ4vxSk5+kPkSvaZzj4zs+LnUMqIXPu1KSIXflVRXzAvh5VIE
11+
7M0ithYYbGPSyviUWpatdLCvLCOPXZPTXc+66mY7RnCVzlBqGKOR2H4goeGWq0zG
12+
Q+V3pAM7gLUJsQIDAQABMA0GCSqGSIb3DQEBCwUAA4GBAHpMjw8nYPtJ20jO2i6M
13+
kJg09Hk91g63HEx4noV8WallM80exNYWJgzNI69UIRdh78QAEknJh43TSF61bVpo
14+
i+mtBHzZLyPv4LHKNN+6eBoMxi58tbWVZXQB4awW6d1AstHY10aSygOmOUKLtGxr
15+
lYt6v4QwWrm3j7oNCDRDwxlj
16+
-----END CERTIFICATE-----

.vscode/server.key

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
Proc-Type: 4,ENCRYPTED
3+
DEK-Info: DES-EDE3-CBC,F6E1E7807FC07585
4+
5+
1RxeEBdxtQ0+Erd+wmDLuaHy07d81+5uqCBZ1FVkzFOReCwDHFvqT9pyo00soIBJ
6+
ECcUOQyVoV7XyQKZVna+XwQJ8WoiF7R0dVeP7q1E8whFhVD+ybnwvCHSe9Zv1DTo
7+
8R74rrAqRRKOf0aFEt2DR3sO9vdljOQY0JSTOefFisJs++FSDGSMPzyoUjyGzix+
8+
jOcbA9BjPoossVRNSNta9q7IMZRvYnF+mqbeKrlQ7dDV6BBCICJ15syzp0FFZcry
9+
7Upmstp+HtFphDr1ABaXlbSzPIzj+lYBro4vV4v/FuyGigwzYhiftTzypz0sVV2u
10+
yOSIGkQkNrg+0iaD35BuLzuZnKvlmjwBeFL0xlN0oh2yUSqveTUwiyGXhJxqjuKe
11+
lK9LEkKFtkj+BB0gwKy0aHNYM7Z3F2FfNGd/FlxxEbZMfORm03W/I3ploJLKk6kO
12+
H69Rkh+5lPsO0q89YBuqptiJH4cgKSup+yWH8LASbz+nuxLEKJTasJZJFEFxO62v
13+
gVHARgwv/V5HYqE4FF860mQs/ZiRVJfTN1HWZ4OpEHjJMuDhWLCyqxHeLMvL8nxd
14+
5qm9cGoguHWmv7JLe/R238AZhYg6eBybg+WAqOJZ2LdMQjAKFa5+oWezCAk1uLI9
15+
v12C5EBYZFI7znx2C4A+YAN7a3HAf+p6o467c1aL/8CQdb37soSpdnAKApx1uFBp
16+
TBxPrNXBOkND/bdU/w4E1lqMPg5KPFNn3gYe7YTB0fG4YqrBfpA0uswBdNHf4u4E
17+
u2Q99Fw9dIsj/BMkwFxTWM0Mb119VPyZm5nd5L4Y0GZmhND4UyVV0A==
18+
-----END RSA PRIVATE KEY-----

.vscode/settings.json

+2-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
{
2-
"liveServer.settings.https": {
3-
"enable": true, //set it true to enable the feature.
4-
"cert": "D:\\Dev\\server.crt", //full path of the certificate
5-
"key": "D:\\Dev\\server.key", //full path of the private key
6-
"passphrase": "1234"
7-
}
2+
"dart.lineLength": 50,
3+
"prettier.printWidth": 50,
84
}

.vscode/start-dev.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable no-console */
2+
const { fork, spawn } = require('child_process');
3+
const path = require('path');
4+
5+
main();
6+
7+
async function main() {
8+
let serverStarted = false;
9+
console.log('+--------------+');
10+
console.log('| Starting dev |');
11+
console.log('+--------------+');
12+
const webpack = fork(path.resolve(__dirname, './run-webpack.js'));
13+
webpack.on('message', (chunk) => {
14+
if (!serverStarted && chunk.search(/compiled\ssuccessfully/)) {
15+
startServer();
16+
serverStarted = true;
17+
}
18+
});
19+
20+
webpack.on('error', (err) => {
21+
console.log('WEBPACK ERROR', err);
22+
webpack.kill(1);
23+
process.exit(1);
24+
});
25+
}
26+
27+
async function startServer() {
28+
const server = fork(path.resolve(__dirname, './start-server.js'));
29+
server.on('error', (err) => {
30+
console.log('SERVER ERROR', err);
31+
server.kill(1);
32+
process.exit(1);
33+
});
34+
}

.vscode/start-server.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
const fs = require('fs');
3+
const path = require('path');
4+
const liveServer = require('live-server');
5+
const getNet = require('./getNet');
6+
7+
const serverCrt = path.resolve(__dirname, 'server.crt');
8+
const serverKey = path.resolve(__dirname, 'server.key');
9+
10+
main();
11+
12+
async function main() {
13+
const { ip: host, port } = await getNet('dev');
14+
process.cwd = () => __dirname;
15+
liveServer.start({
16+
open: false,
17+
port,
18+
host,
19+
cors: true,
20+
root: '../',
21+
ignore: 'node_modules,platforms,plugins',
22+
file: 'index.html',
23+
https: {
24+
cert: fs.readFileSync(serverCrt),
25+
key: fs.readFileSync(serverKey),
26+
passphrase: '1234',
27+
},
28+
middleware: [(req, res, next) => {
29+
const url = req.originalUrl;
30+
const www = '../platforms/android/app/src/main/assets/www/';
31+
32+
if (url === '/cordova.js') {
33+
const file = path.resolve(__dirname, www, 'cordova.js');
34+
sendFile(res, file);
35+
return;
36+
}
37+
38+
if (url === '/cordova_plugins.js') {
39+
const file = path.resolve(__dirname, www, 'cordova_plugins.js');
40+
sendFile(res, file);
41+
return;
42+
}
43+
44+
next();
45+
}],
46+
});
47+
48+
process.send('OK');
49+
}
50+
51+
function sendFile(res, filePath) {
52+
if (fs.existsSync(filePath)) {
53+
const stat = fs.statSync(filePath);
54+
55+
res.writeHead(200, {
56+
'Content-Type': 'application/javascript',
57+
'Content-Length': stat.size,
58+
});
59+
60+
const readStream = fs.createReadStream(filePath);
61+
readStream.pipe(res);
62+
return;
63+
}
64+
65+
res.writeHead(404, { 'Content-Type': 'text/plain' });
66+
res.end(`ERROR cannot get ${filePath}`);
67+
}

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ Using this plugin you can run python codes but you cannot import other python fi
99
### Update 1.0.7
1010

1111
- Bugs fixes
12-
- Updated pyodide version
12+
- Updated pyodide
13+
14+
### Update 1.1.0
15+
16+
- Bugs fixes
17+
- Reduces waiting time
1318

1419
## WARNING
1520

dist.zip

1.06 KB
Binary file not shown.

dist/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/worker.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+15-13
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,37 @@
11
{
22
"name": "acode-plugin-python",
3-
"version": "1.0.7",
3+
"version": "1.1.0",
44
"description": "Acode plugin to run python code",
55
"main": "dist/main.js",
66
"repository": "https://github.com/deadlyjack/acode-plugin-python.git",
77
"author": "Ajit <[email protected]>",
88
"license": "MIT",
99
"dependencies": {
10-
"html-tag-js": "^1.1.36"
10+
"html-tag-js": "^1.1.37"
1111
},
1212
"devDependencies": {
13-
"@babel/cli": "^7.18.10",
14-
"@babel/core": "^7.18.10",
15-
"@babel/preset-env": "^7.18.10",
16-
"autoprefixer": "^10.4.13",
13+
"@babel/cli": "^7.21.0",
14+
"@babel/core": "^7.21.3",
15+
"@babel/preset-env": "^7.20.2",
16+
"autoprefixer": "^10.4.14",
1717
"babel-loader": "^9.1.2",
1818
"jszip": "^3.10.1",
19+
"live-server": "^1.2.2",
1920
"postcss": "^8.4.21",
20-
"postcss-loader": "^7.0.2",
21+
"postcss-loader": "^7.1.0",
2122
"raw-loader": "^4.0.2",
22-
"sass": "^1.58.0",
23-
"sass-loader": "^13.2.0",
24-
"style-loader": "^3.3.1",
25-
"webpack": "^5.76.0",
23+
"sass": "^1.59.3",
24+
"sass-loader": "^13.2.1",
25+
"style-loader": "^3.3.2",
26+
"webpack": "^5.76.3",
2627
"webpack-cli": "^5.0.1"
2728
},
2829
"scripts": {
2930
"build": "webpack",
30-
"build-release": "webpack --mode production"
31+
"build-release": "webpack --mode production",
32+
"start-dev": "node .vscode/start-dev"
3133
},
3234
"browserslist": [
3335
"> 0.25%, not dead"
3436
]
35-
}
37+
}

plugin.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "acode.plugin.python",
33
"name": "Python",
44
"main": "dist/main.js",
5-
"version": "1.0.7",
5+
"version": "1.1.0",
66
"readme": "README.md",
77
"icon": "icon.png",
88
"files": [

0 commit comments

Comments
 (0)