nadesiko3 3.6.21 → 3.6.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/batch/command.txt +60 -52
  2. package/batch/copy_core.nako3 +5 -1
  3. package/core/README.md +4 -10
  4. package/core/__report.txt +617 -0
  5. package/core/batch/clean.nako3 +23 -0
  6. package/core/bin/snako +18 -0
  7. package/core/bin/snako.bat +15 -0
  8. package/core/package-lock.json +5 -5
  9. package/core/package.json +2 -1
  10. package/core/src/nako_ast.mts +1 -0
  11. package/core/src/nako_core_version.mjs +2 -2
  12. package/core/src/nako_core_version.mts +2 -2
  13. package/core/src/nako_gen.mjs +8 -5
  14. package/core/src/nako_gen.mts +8 -5
  15. package/core/src/nako_parser3.mjs +8 -0
  16. package/core/src/nako_parser3.mts +4 -2
  17. package/core/test/dncl2_test.mjs +2 -2
  18. package/core/test/flow_test.mjs +18 -0
  19. package/core/tsconfig.json +2 -2
  20. package/package.json +4 -3
  21. package/release/_hash.txt +28 -28
  22. package/release/_script-tags.txt +33 -33
  23. package/release/command.json +1 -1
  24. package/release/command.json.js +1 -1
  25. package/release/command_cnako3.json +1 -1
  26. package/release/command_list.json +1 -1
  27. package/release/edit_main.js +5 -5
  28. package/release/edit_main.js.map +2 -2
  29. package/release/editor.js +5 -5
  30. package/release/version.js +1 -1
  31. package/release/version_main.js +1 -1
  32. package/release/version_main.js.map +1 -1
  33. package/release/wnako3.js +36 -35
  34. package/release/wnako3.js.map +3 -3
  35. package/release/wnako3webworker.js +50 -49
  36. package/release/wnako3webworker.js.map +3 -3
  37. package/src/nako_version.mjs +2 -2
  38. package/src/nako_version.mts +2 -2
  39. package/src/plugin_browser.mjs +4 -0
  40. package/src/plugin_browser.mts +4 -0
  41. package/src/plugin_browser_dom_event.mjs +50 -1
  42. package/src/plugin_browser_dom_event.mts +54 -5
  43. package/src/plugin_browser_dom_parts.mjs +20 -5
  44. package/src/plugin_browser_dom_parts.mts +16 -5
  45. package/tools/nako3edit/html/files.html +5 -1
  46. package/tools/nako3edit/html/plugins.html +134 -0
  47. package/tools/nako3edit/index.mjs +55 -7
  48. package/core/command/plugin_snako.mjs +0 -112
  49. package/core/command/snako.mjs +0 -114
  50. package/core/sample/hoge.mjs +0 -7
@@ -1,112 +0,0 @@
1
- /**
2
- * file: plugin_snako.js
3
- * 簡単なファイル読み書きのプラグイン
4
- */
5
- import fs from 'node:fs';
6
- import { execSync } from 'node:child_process';
7
- import path from 'node:path';
8
- export default {
9
- 'meta': {
10
- type: 'const',
11
- value: {
12
- pluginName: 'plugin_snako', // プラグインの名前
13
- description: '最小の機能を提供するプラグイン', // プラグインの説明
14
- pluginVersion: '3.6.3', // プラグインのバージョン
15
- nakoRuntime: ['cnako'], // 対象ランタイム
16
- nakoVersion: '3.6.3' // 要求なでしこバージョン
17
- }
18
- },
19
- '初期化': {
20
- type: 'func',
21
- josi: [],
22
- pure: true,
23
- fn: function (sys) {
24
- sys.__getBokanPath = () => {
25
- let nakofile;
26
- const cmd = path.basename(process.argv[1]);
27
- if (cmd.indexOf('snako') < 0) {
28
- nakofile = process.argv[1];
29
- }
30
- else {
31
- nakofile = process.argv[2];
32
- }
33
- return path.dirname(path.resolve(nakofile));
34
- };
35
- sys.__setSysVar('コマンドライン', process.argv);
36
- sys.__setSysVar('ナデシコランタイムパス', process.argv[0]);
37
- sys.__setSysVar('ナデシコランタイム', path.basename(process.argv[0]));
38
- sys.__setSysVar('母艦パス', sys.__getBokanPath());
39
- }
40
- },
41
- // @SNAKO
42
- 'コマンドライン': { type: 'const', value: '' },
43
- 'ナデシコランタイムパス': { type: 'const', value: '' },
44
- 'ナデシコランタイム': { type: 'const', value: '' },
45
- '母艦パス': { type: 'const', value: '' },
46
- '読': {
47
- type: 'func',
48
- josi: [['を', 'から']],
49
- pure: true,
50
- fn: function (f) {
51
- return '' + fs.readFileSync(f);
52
- }
53
- },
54
- '開': {
55
- type: 'func',
56
- josi: [['を', 'から']],
57
- pure: true,
58
- fn: function (f) {
59
- return '' + fs.readFileSync(f);
60
- }
61
- },
62
- '保存': {
63
- type: 'func',
64
- josi: [['を'], ['に', 'へ']],
65
- pure: true,
66
- fn: function (s, f) {
67
- fs.writeFileSync(f, s, 'utf-8');
68
- },
69
- return_none: true
70
- },
71
- '起動待機': {
72
- type: 'func',
73
- josi: [['を']],
74
- pure: true,
75
- fn: function (s) {
76
- const r = execSync(s);
77
- return r.toString();
78
- }
79
- },
80
- 'ファイル名抽出': {
81
- type: 'func',
82
- josi: [['から', 'の']],
83
- pure: true,
84
- fn: function (s) {
85
- return path.basename(s);
86
- }
87
- },
88
- 'パス抽出': {
89
- type: 'func',
90
- josi: [['から', 'の']],
91
- pure: true,
92
- fn: function (s) {
93
- return path.dirname(s);
94
- }
95
- },
96
- '絶対パス変換': {
97
- type: 'func',
98
- josi: [['を', 'の']],
99
- pure: true,
100
- fn: function (a) {
101
- return path.resolve(a);
102
- }
103
- },
104
- '相対パス展開': {
105
- type: 'func',
106
- josi: [['を'], ['で']],
107
- pure: true,
108
- fn: function (a, b) {
109
- return path.resolve(path.join(a, b));
110
- }
111
- }
112
- };
@@ -1,114 +0,0 @@
1
- #!/usr/bin/env node --no-warnings=ExperimentalWarning --loader ts-node/esm
2
- import fs from 'node:fs';
3
- import path from 'node:path';
4
- import com from '../index.mjs';
5
- import { argv as nodejs_argv } from 'node:process';
6
- import * as url from 'node:url';
7
- import { NakoGenOptions } from '../src/nako_gen.mjs';
8
- import PluginSnako from './plugin_snako.mjs';
9
- const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
10
- /** コマンドラインオプション */
11
- class CommandOptions {
12
- isDebug;
13
- filename;
14
- nodePath;
15
- scriptPath;
16
- evalStr;
17
- flagConvert;
18
- constructor() {
19
- this.nodePath = '';
20
- this.scriptPath = '';
21
- this.filename = '';
22
- this.evalStr = '';
23
- this.isDebug = false;
24
- this.flagConvert = false;
25
- }
26
- }
27
- /** メイン処理 */
28
- async function main(argvOrg) {
29
- // コマンドラインオプションを確認
30
- const argv = [...argvOrg];
31
- const opt = new CommandOptions();
32
- opt.nodePath = argv.shift() || '';
33
- opt.scriptPath = argv.shift() || '';
34
- while (argv.length > 0) {
35
- const arg = argv.shift() || '';
36
- if (arg === '-d' || arg === '--debug') {
37
- opt.isDebug = true;
38
- continue;
39
- }
40
- if (arg === '-e' || arg === '--eval') {
41
- opt.evalStr = argv.shift() || '';
42
- continue;
43
- }
44
- if (arg === '-c' || arg === '--convert') {
45
- opt.flagConvert = true;
46
- continue;
47
- }
48
- if (opt.filename === '') {
49
- opt.filename = arg;
50
- }
51
- }
52
- // なでしこのコンパイラを生成
53
- const nako = new com.NakoCompiler();
54
- nako.addPluginObject('PluginSnako', PluginSnako);
55
- // 実行前にイベントを挟みたいとき
56
- nako.addListener('beforeRun', (g) => {
57
- g.__varslist[0].set('ナデシコ種類', 'snako');
58
- });
59
- // logger を設定 --- リスナーを登録することでデバッグレベルを指定
60
- const logger = nako.getLogger();
61
- if (opt.isDebug) {
62
- logger.addListener('trace', (data) => {
63
- console.log(data.nodeConsole);
64
- });
65
- }
66
- logger.addListener('stdout', (data) => {
67
- console.log(data.noColor);
68
- });
69
- // -e オプションを実行したとき
70
- if (opt.evalStr) {
71
- await nako.runAsync(opt.evalStr, 'main.nako3');
72
- return;
73
- }
74
- // パラメータが空だったとき
75
- if (opt.filename === '') {
76
- showHelp();
77
- return;
78
- }
79
- // ソースコードをファイルから読み込む
80
- const code = fs.readFileSync(opt.filename, 'utf-8');
81
- // -c オプションが指定されたとき
82
- if (opt.flagConvert) {
83
- convert(nako, code, opt);
84
- }
85
- // 実行
86
- await nako.runAsync(code, opt.filename);
87
- }
88
- // -c オプションを指定したとき
89
- function convert(nako, code, opt) {
90
- // オプションを指定
91
- const genOpt = new NakoGenOptions(false, ['nako_errors.mjs', 'nako_core_version.mjs', 'plugin_system.mjs'], '__self.__varslist[0].set(\'ナデシコ種類\', \'snako\')');
92
- // スタンドアロンコードを生成
93
- const js = nako.compileStandalone(code, opt.filename, genOpt);
94
- const jsFilename = opt.filename + '.js';
95
- fs.writeFileSync(jsFilename, js, { encoding: 'utf-8' });
96
- // 必要なライブラリをコピー
97
- const runtimeDir = path.join(path.dirname(jsFilename), 'nako3runtime');
98
- const srcDir = path.join(__dirname, '..', 'src');
99
- if (!fs.existsSync(runtimeDir)) {
100
- fs.mkdirSync(runtimeDir);
101
- }
102
- for (const f of genOpt.importFiles) {
103
- fs.copyFileSync(path.join(srcDir, f), path.join(runtimeDir, f));
104
- }
105
- }
106
- /** 使い方を表示 */
107
- function showHelp() {
108
- console.log('●なでしこ(簡易版) # v.' + com.version.version);
109
- console.log('[使い方] node snako.mjs [--debug|-d] (filename)');
110
- console.log('[使い方] node snako.mjs [--eval|-e] (source)');
111
- console.log('[使い方] node snako.mjs [-c] (source) ... convert');
112
- }
113
- /** メイン処理を実行 */
114
- main(nodejs_argv);
@@ -1,7 +0,0 @@
1
- import core from '../index.mjs';
2
- const main = async () => {
3
- const com = new core.NakoCompiler();
4
- const g = await com.runAsync('1 + 2 * 3を表示', 'main.nako3');
5
- console.log(g.log);
6
- };
7
- await main();