[update] skyway api キーの保存場所とロード方法を変更

This commit is contained in:
ocogeclub 2022-01-16 17:30:21 +09:00
parent 36683b31ba
commit 496ee02f12
5 changed files with 33 additions and 29 deletions

View File

@ -367,7 +367,7 @@
<field name="level">1</field> <field name="level">1</field>
</block> </block>
<block type="ugj_gpio_set_input"> <block type="ugj_gpio_set_input">
<field name="lflag">pi.PULL_DOWN</field> <field name="lflag">_pi.PULL_DOWN</field>
<value name="gpio"> <value name="gpio">
<shadow type="math_number"> <shadow type="math_number">
<field name="NUM">6</field> <field name="NUM">6</field>
@ -793,9 +793,14 @@
<block type="ugj_skyway_newpeer"> <block type="ugj_skyway_newpeer">
<value name="my_id"> <value name="my_id">
<block type="variables_get"> <block type="variables_get">
<field name="VAR" id="*;kYz5q$=N`hBZ$%/Gyb">自分のID</field> <field name="VAR" id="P$},PvZ}j#)8lw++|u7h">自分のID</field>
</block> </block>
</value> </value>
<value name="apikey">
<shadow type="text">
<field name="TEXT"></field>
</shadow>
</value>
</block> </block>
<block type="ugj_skyway_called"></block> <block type="ugj_skyway_called"></block>
<!-- <block type="ugj_skyway_events"> <!-- <block type="ugj_skyway_events">
@ -1133,7 +1138,7 @@
<script src="./index.js"></script> <script src="./index.js"></script>
<script src="./lib/beautify.min.js"></script> <script src="./lib/beautify.min.js"></script>
<script src="./lib/prettify.js"></script> <script src="./lib/prettify.js"></script>
<script src="./.shared/skyway_key.js"></script> <!-- <script src="./.shared/skyway_key.js"></script> -->
</body> </body>
</html> </html>

View File

@ -31,6 +31,7 @@ class elUtil {
this.children = []; this.children = [];
this.gpio_backend = ugj_const.pig; this.gpio_backend = ugj_const.pig;
this.i2c_bus = ugj_const.i2c_defbus; this.i2c_bus = ugj_const.i2c_defbus;
this.doc_root = process.env["HOME"] + '/Documents/';
this.doc_current = process.env["HOME"] + '/Documents'; this.doc_current = process.env["HOME"] + '/Documents';
this.executable_path = process.env["HOME"] + '/.local/lib/ocogeclub/' this.executable_path = process.env["HOME"] + '/.local/lib/ocogeclub/'
} }

32
package-lock.json generated
View File

@ -18,7 +18,7 @@
"@tensorflow/tfjs-converter": "^3.13.0", "@tensorflow/tfjs-converter": "^3.13.0",
"@tensorflow/tfjs-core": "^3.13.0", "@tensorflow/tfjs-core": "^3.13.0",
"@tensorflow/tfjs-node": "^3.13.0", "@tensorflow/tfjs-node": "^3.13.0",
"@vladmandic/face-api": "^1.6.3", "@vladmandic/face-api": "^1.6.4",
"axios": "^0.24.0", "axios": "^0.24.0",
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",
"nodemailer": "^6.7.2", "nodemailer": "^6.7.2",
@ -1882,9 +1882,9 @@
} }
}, },
"node_modules/@vladmandic/face-api": { "node_modules/@vladmandic/face-api": {
"version": "1.6.3", "version": "1.6.4",
"resolved": "https://registry.npmjs.org/@vladmandic/face-api/-/face-api-1.6.3.tgz", "resolved": "https://registry.npmjs.org/@vladmandic/face-api/-/face-api-1.6.4.tgz",
"integrity": "sha512-dB/oKHvst9Byw9umxJE4uFKpjUoVBj1AkJQUrTyHqjk2Q3AuG7mnmjVH3jJ/jKgmnAPRxwO1MBdqCptb6eyZiQ==", "integrity": "sha512-tVx8lCL1mKb44qeN5EEypJNXqxRYXh+7BcSzfY4iMaZIoF5Y+Jev20UiIn9JvxwGV2caWkdFIjpvw+OxsL/kdg==",
"engines": { "engines": {
"node": ">=14.0.0" "node": ">=14.0.0"
} }
@ -10139,14 +10139,12 @@
"@tensorflow-models/knn-classifier": { "@tensorflow-models/knn-classifier": {
"version": "1.2.2", "version": "1.2.2",
"resolved": "https://registry.npmjs.org/@tensorflow-models/knn-classifier/-/knn-classifier-1.2.2.tgz", "resolved": "https://registry.npmjs.org/@tensorflow-models/knn-classifier/-/knn-classifier-1.2.2.tgz",
"integrity": "sha512-QRnkCf7ErOxSRtvJ6yCwhlLREPcBJGaXRanF46f0iY6ii3Sybjb6Ux0qnNPTrHZChD0izPa3Z4GQEgSAykiHkQ==", "integrity": "sha512-QRnkCf7ErOxSRtvJ6yCwhlLREPcBJGaXRanF46f0iY6ii3Sybjb6Ux0qnNPTrHZChD0izPa3Z4GQEgSAykiHkQ=="
"requires": {}
}, },
"@tensorflow-models/mobilenet": { "@tensorflow-models/mobilenet": {
"version": "2.1.0", "version": "2.1.0",
"resolved": "https://registry.npmjs.org/@tensorflow-models/mobilenet/-/mobilenet-2.1.0.tgz", "resolved": "https://registry.npmjs.org/@tensorflow-models/mobilenet/-/mobilenet-2.1.0.tgz",
"integrity": "sha512-JjqT9ijHDFA2FEpUGWg7H2lQ0GrMuE2VmiCRBYmUew6b4JKht8LXDjG5HxZh95YH6c/25sZWTpGeHbquloH+hw==", "integrity": "sha512-JjqT9ijHDFA2FEpUGWg7H2lQ0GrMuE2VmiCRBYmUew6b4JKht8LXDjG5HxZh95YH6c/25sZWTpGeHbquloH+hw=="
"requires": {}
}, },
"@tensorflow/tfjs": { "@tensorflow/tfjs": {
"version": "3.13.0", "version": "3.13.0",
@ -10191,8 +10189,7 @@
"@tensorflow/tfjs-converter": { "@tensorflow/tfjs-converter": {
"version": "3.13.0", "version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.13.0.tgz", "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-3.13.0.tgz",
"integrity": "sha512-H2VpDTv9Ve0HBt7ttzz46DmnsPaiT0B+yJjVH3NebGZbgY9C8boBgJIsdyqfiqEWBS3WxF8h4rh58Hv5XXMgaQ==", "integrity": "sha512-H2VpDTv9Ve0HBt7ttzz46DmnsPaiT0B+yJjVH3NebGZbgY9C8boBgJIsdyqfiqEWBS3WxF8h4rh58Hv5XXMgaQ=="
"requires": {}
}, },
"@tensorflow/tfjs-core": { "@tensorflow/tfjs-core": {
"version": "3.13.0", "version": "3.13.0",
@ -10220,8 +10217,7 @@
"@tensorflow/tfjs-layers": { "@tensorflow/tfjs-layers": {
"version": "3.13.0", "version": "3.13.0",
"resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.13.0.tgz", "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-3.13.0.tgz",
"integrity": "sha512-kTWJ/+9fbNCMDA9iQjDMYHmWivsiWz8CKNSOZdeCW7tiBwF1EiREBVQXMk1JI11ngQa8f+rYSLs7rkhp3SYl5Q==", "integrity": "sha512-kTWJ/+9fbNCMDA9iQjDMYHmWivsiWz8CKNSOZdeCW7tiBwF1EiREBVQXMk1JI11ngQa8f+rYSLs7rkhp3SYl5Q=="
"requires": {}
}, },
"@tensorflow/tfjs-node": { "@tensorflow/tfjs-node": {
"version": "3.13.0", "version": "3.13.0",
@ -10367,9 +10363,9 @@
} }
}, },
"@vladmandic/face-api": { "@vladmandic/face-api": {
"version": "1.6.3", "version": "1.6.4",
"resolved": "https://registry.npmjs.org/@vladmandic/face-api/-/face-api-1.6.3.tgz", "resolved": "https://registry.npmjs.org/@vladmandic/face-api/-/face-api-1.6.4.tgz",
"integrity": "sha512-dB/oKHvst9Byw9umxJE4uFKpjUoVBj1AkJQUrTyHqjk2Q3AuG7mnmjVH3jJ/jKgmnAPRxwO1MBdqCptb6eyZiQ==" "integrity": "sha512-tVx8lCL1mKb44qeN5EEypJNXqxRYXh+7BcSzfY4iMaZIoF5Y+Jev20UiIn9JvxwGV2caWkdFIjpvw+OxsL/kdg=="
}, },
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
@ -15233,8 +15229,7 @@
"@tensorflow/tfjs-converter": { "@tensorflow/tfjs-converter": {
"version": "2.8.6", "version": "2.8.6",
"resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-2.8.6.tgz", "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-converter/-/tfjs-converter-2.8.6.tgz",
"integrity": "sha512-Uv4YC66qjVC9UwBxz0IeLZ8KS2CReh63WlGRtHcSwDEYiwsa7cvp9H6lFSSPT7kiJmrK6JtHeJGIVcTuNnSt9w==", "integrity": "sha512-Uv4YC66qjVC9UwBxz0IeLZ8KS2CReh63WlGRtHcSwDEYiwsa7cvp9H6lFSSPT7kiJmrK6JtHeJGIVcTuNnSt9w=="
"requires": {}
}, },
"@tensorflow/tfjs-core": { "@tensorflow/tfjs-core": {
"version": "2.8.6", "version": "2.8.6",
@ -15260,8 +15255,7 @@
"@tensorflow/tfjs-layers": { "@tensorflow/tfjs-layers": {
"version": "2.8.6", "version": "2.8.6",
"resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-2.8.6.tgz", "resolved": "https://registry.npmjs.org/@tensorflow/tfjs-layers/-/tfjs-layers-2.8.6.tgz",
"integrity": "sha512-fdZ0i/R2dIKmy8OB5tBAsm5IbAHfJpI6AlbjxpgoU3aWj1HCdDo+pMji928MkDJhP01ISgFTgw/7PseGNaUflw==", "integrity": "sha512-fdZ0i/R2dIKmy8OB5tBAsm5IbAHfJpI6AlbjxpgoU3aWj1HCdDo+pMji928MkDJhP01ISgFTgw/7PseGNaUflw=="
"requires": {}
}, },
"@types/webgl2": { "@types/webgl2": {
"version": "0.0.5", "version": "0.0.5",

View File

@ -4,7 +4,6 @@
"description": "ブロックベースビジュアルプログラム開発・実行環境", "description": "ブロックベースビジュアルプログラム開発・実行環境",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"build": "npm install --legacy-peer-deps",
"start": "electron-forge start", "start": "electron-forge start",
"rebuild": "electron-rebuild", "rebuild": "electron-rebuild",
"package": "electron-forge package", "package": "electron-forge package",
@ -41,7 +40,7 @@
"@tensorflow/tfjs-converter": "^3.13.0", "@tensorflow/tfjs-converter": "^3.13.0",
"@tensorflow/tfjs-core": "^3.13.0", "@tensorflow/tfjs-core": "^3.13.0",
"@tensorflow/tfjs-node": "^3.13.0", "@tensorflow/tfjs-node": "^3.13.0",
"@vladmandic/face-api": "^1.6.3", "@vladmandic/face-api": "^1.6.4",
"axios": "^0.24.0", "axios": "^0.24.0",
"electron-squirrel-startup": "^1.0.0", "electron-squirrel-startup": "^1.0.0",
"nodemailer": "^6.7.2", "nodemailer": "^6.7.2",

View File

@ -1778,7 +1778,7 @@ Blockly.JavaScript['ugj_canvas_loadimg'] = function (block) {
var value_imgfilename = Blockly.JavaScript.valueToCode(block, 'imgfilename', Blockly.JavaScript.ORDER_ATOMIC); var value_imgfilename = Blockly.JavaScript.valueToCode(block, 'imgfilename', Blockly.JavaScript.ORDER_ATOMIC);
var code = [ var code = [
`let _img = new Image();`, `let _img = new Image();`,
`_img.src = '${ugj_const.doc_root}' + ${value_imgfilename};`, `_img.src = '${elutil.doc_root}' + ${value_imgfilename};`,
`_img.onload = () => _ctx.drawImage(img,0,0);`, `_img.onload = () => _ctx.drawImage(img,0,0);`,
// `ugj_canvasImg('${ugj_const.doc_root}' + ${value_imgfilename});`, // `ugj_canvasImg('${ugj_const.doc_root}' + ${value_imgfilename});`,
'' ''
@ -2603,6 +2603,9 @@ Blockly.Blocks['ugj_skyway_newpeer'] = {
this.appendValueInput("my_id") this.appendValueInput("my_id")
.setCheck("Variable") .setCheck("Variable")
.appendField("SkyWayサーバーに ID:"); .appendField("SkyWayサーバーに ID:");
this.appendValueInput("apikey")
.setCheck("String")
.appendField("APIキー:");
this.appendDummyInput() this.appendDummyInput()
.appendField("で接続する"); .appendField("で接続する");
this.appendStatementInput("do") this.appendStatementInput("do")
@ -2620,10 +2623,12 @@ Blockly.JavaScript['ugj_skyway_newpeer'] = function (block) {
var value_my_id = Blockly.JavaScript.valueToCode(block, 'my_id', Blockly.JavaScript.ORDER_ATOMIC); var value_my_id = Blockly.JavaScript.valueToCode(block, 'my_id', Blockly.JavaScript.ORDER_ATOMIC);
// var variable_my_id = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('my_id'), Blockly.Variables.NAME_TYPE); // var variable_my_id = Blockly.JavaScript.nameDB_.getName(block.getFieldValue('my_id'), Blockly.Variables.NAME_TYPE);
// var text_name = block.getFieldValue('NAME'); // var text_name = block.getFieldValue('NAME');
var value_apikey = Blockly.JavaScript.valueToCode(block, 'apikey', Blockly.JavaScript.ORDER_ATOMIC);
var statements_do = Blockly.JavaScript.statementToCode(block, 'do'); var statements_do = Blockly.JavaScript.statementToCode(block, 'do');
var code = [ var code = [
`const _peer = new Peer(${value_my_id}, {`, `const _peer = new Peer(${value_my_id}, {`,
" key: window.__SKYWAY_KEY__,", ` key: ${value_apikey},`,
// " key: window.__SKYWAY_KEY__,",
" debug: 3", " debug: 3",
"});", "});",
"_peer.on('open', () => {", "_peer.on('open', () => {",
@ -2813,14 +2818,14 @@ Blockly.Blocks['ugj_file_readsync'] = {
this.setOutput(true, "String"); this.setOutput(true, "String");
this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND); this.setOutputShape(Blockly.OUTPUT_SHAPE_ROUND);
this.setStyle('special_blocks') this.setStyle('special_blocks')
this.setTooltip("あなたのホーム/ocogeディレクトリ内にあるファイルの内容を取得します。「符号化」は、テキストファイルでは通常「utf8」を選択します。"); this.setTooltip("あなたのホーム/Documentsディレクトリ内にあるファイルの内容を取得します。「符号化」は、テキストファイルでは通常「utf8」を選択します。");
this.setHelpUrl(""); this.setHelpUrl("");
} }
}; };
Blockly.JavaScript['ugj_file_readsync'] = function (block) { Blockly.JavaScript['ugj_file_readsync'] = function (block) {
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC); var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
var dropdown_encoding = block.getFieldValue('encoding'); var dropdown_encoding = block.getFieldValue('encoding');
let filepath = ugj_const.doc_root + value_filename.replace(/\'/g, ''); let filepath = elutil.doc_root + value_filename.replace(/\'/g, '');
Blockly.JavaScript.provideFunction_( Blockly.JavaScript.provideFunction_(
'require_fs', [`const _fs = require('fs');`] 'require_fs', [`const _fs = require('fs');`]
); );
@ -3065,7 +3070,7 @@ Blockly.Blocks['ugj_child_fswebcam'] = {
}; };
Blockly.JavaScript['ugj_child_fswebcam'] = function (block) { Blockly.JavaScript['ugj_child_fswebcam'] = function (block) {
var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC); var value_filename = Blockly.JavaScript.valueToCode(block, 'filename', Blockly.JavaScript.ORDER_ATOMIC);
var code = `'fswebcam', ['-r', '480x360', '${ugj_const.doc_root}' + ${value_filename}]`; var code = `'fswebcam', ['-r', '480x360', '${elutil.doc_root}' + ${value_filename}]`;
return [code, Blockly.JavaScript.ORDER_NONE]; return [code, Blockly.JavaScript.ORDER_NONE];
}; };