nadesiko3 3.7.21 → 3.7.22

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 (155) hide show
  1. package/batch/command.txt +370 -334
  2. package/batch/jsplugin2text.nako3 +1 -1
  3. package/batch/pickup_command.nako3 +12 -0
  4. package/core/command/snako.mts +5 -1
  5. package/core/deno/snako.ts +5 -1
  6. package/core/package-lock.json +382 -21
  7. package/core/package.json +4 -4
  8. package/core/src/nako3.mts +178 -614
  9. package/core/src/nako_basic_plugins.mts +39 -0
  10. package/core/src/nako_core_version.mts +2 -2
  11. package/core/src/nako_csv.mts +0 -1
  12. package/core/src/nako_event.mts +49 -0
  13. package/core/src/nako_gen.mts +291 -202
  14. package/core/src/nako_indent_inline.mts +2 -2
  15. package/core/src/nako_lex_rules.mts +1 -1
  16. package/core/src/nako_parser3.mts +106 -165
  17. package/core/src/nako_parser_async.mts +97 -0
  18. package/core/src/nako_parser_base.mts +4 -55
  19. package/core/src/nako_parser_message.mts +105 -0
  20. package/core/src/nako_parser_operator.mts +93 -0
  21. package/core/src/nako_plugin_manager.mts +260 -0
  22. package/core/src/nako_require.mts +292 -0
  23. package/core/src/nako_runner.mts +191 -0
  24. package/core/src/nako_tokenizer.mts +221 -0
  25. package/core/src/plugin_csv.mts +1 -1
  26. package/core/src/plugin_system.mts +34 -3259
  27. package/core/src/plugin_system_array.mts +699 -0
  28. package/core/src/plugin_system_datetime.mts +368 -0
  29. package/core/src/plugin_system_debug.mts +403 -0
  30. package/core/src/plugin_system_dict.mts +85 -0
  31. package/core/src/plugin_system_json.mts +73 -0
  32. package/core/src/plugin_system_math.mts +383 -0
  33. package/core/src/plugin_system_regexp.mts +120 -0
  34. package/core/src/plugin_system_stdio.mts +86 -0
  35. package/core/src/plugin_system_string.mts +666 -0
  36. package/core/src/plugin_system_timer.mts +152 -0
  37. package/core/src/plugin_system_types.mts +151 -0
  38. package/core/src/plugin_system_url.mts +193 -0
  39. package/core/src/plugin_toml.mts +3 -3
  40. package/core/test/fixtures/README.md +39 -0
  41. package/core/test/fixtures/make_parser_ast_golden.mjs +31 -0
  42. package/core/test/fixtures/parser_ast_golden.json +8027 -0
  43. package/core/test/fixtures/parser_corpus.mjs +120 -0
  44. package/core/test/indent_test.mjs +6 -0
  45. package/core/test/nako_basic_plugins_test.mjs +44 -0
  46. package/core/test/nako_event_test.mjs +85 -0
  47. package/core/test/nako_gen_perf_test.mjs +178 -0
  48. package/core/test/nako_parser_async_test.mjs +112 -0
  49. package/core/test/nako_parser_test.mjs +160 -0
  50. package/core/test/nako_plugin_manager_test.mjs +185 -0
  51. package/core/test/nako_require_test.mjs +153 -0
  52. package/core/test/nako_runner_test.mjs +114 -0
  53. package/core/test/nako_tokenizer_test.mjs +115 -0
  54. package/core/test/plugin_system_debug_test.mjs +141 -0
  55. package/core/test/plugin_system_split_test.mjs +179 -0
  56. package/core/test/plugin_system_test.mjs +6 -0
  57. package/core/tsconfig.json +0 -1
  58. package/package.json +17 -21
  59. package/release/_hash.txt +36 -36
  60. package/release/_script-tags.txt +16 -16
  61. package/release/command.json +1 -1
  62. package/release/command.json.js +1 -1
  63. package/release/command_cnako3.json +1 -1
  64. package/release/command_list.json +1 -1
  65. package/release/edit_main.js +6 -6
  66. package/release/edit_main.js.map +3 -3
  67. package/release/editor.js +6 -6
  68. package/release/plugin_keigo.js.map +3 -3
  69. package/release/plugin_markup.js +46 -46
  70. package/release/plugin_markup.js.map +3 -3
  71. package/release/plugin_weykturtle3d.js +1 -1
  72. package/release/plugin_weykturtle3d.js.map +3 -3
  73. package/release/version.js +2 -2
  74. package/release/version_main.js +2 -2
  75. package/release/version_main.js.map +1 -1
  76. package/release/wnako3.js +186 -213
  77. package/release/wnako3.js.map +4 -4
  78. package/release/wnako3webworker.js +172 -199
  79. package/release/wnako3webworker.js.map +4 -4
  80. package/src/cnako3mod.mjs +7 -2
  81. package/src/cnako3mod.mts +7 -2
  82. package/src/nako_version.mjs +2 -2
  83. package/src/nako_version.mts +2 -2
  84. package/src/plugin_browser_ajax.mjs +4 -4
  85. package/src/plugin_browser_ajax.mts +4 -4
  86. package/src/plugin_browser_audio.mjs +10 -10
  87. package/src/plugin_browser_audio.mts +10 -10
  88. package/src/plugin_browser_camera.mjs +4 -4
  89. package/src/plugin_browser_camera.mts +4 -4
  90. package/src/plugin_browser_canvas.mjs +2 -2
  91. package/src/plugin_browser_canvas.mts +2 -2
  92. package/src/plugin_browser_crypto.mjs +3 -3
  93. package/src/plugin_browser_crypto.mts +3 -3
  94. package/src/plugin_browser_dom_event.mjs +1 -1
  95. package/src/plugin_browser_dom_event.mts +1 -1
  96. package/src/plugin_browser_geolocation.mjs +1 -1
  97. package/src/plugin_browser_geolocation.mts +1 -1
  98. package/src/plugin_browser_hotkey.mjs +1 -1
  99. package/src/plugin_browser_hotkey.mts +1 -1
  100. package/src/plugin_browser_html.mjs +1 -1
  101. package/src/plugin_browser_html.mts +1 -1
  102. package/src/plugin_browser_location.mjs +1 -1
  103. package/src/plugin_browser_location.mts +1 -1
  104. package/src/plugin_browser_speech.mjs +1 -1
  105. package/src/plugin_browser_speech.mts +1 -1
  106. package/src/plugin_browser_storage.mjs +2 -2
  107. package/src/plugin_browser_storage.mts +2 -2
  108. package/src/plugin_httpserver.mjs +3 -3
  109. package/src/plugin_httpserver.mts +3 -3
  110. package/src/plugin_keigo.mjs +2 -2
  111. package/src/plugin_keigo.mts +2 -2
  112. package/src/plugin_node.mjs +48 -48
  113. package/src/plugin_node.mts +53 -53
  114. package/src/plugin_weykturtle3d.mjs +56 -56
  115. package/src/plugin_weykturtle3d.mts +56 -56
  116. package/src/wnako3.mjs +1 -1
  117. package/src/wnako3.mts +1 -1
  118. package/src/wnako3_editor.mjs +5 -5
  119. package/src/wnako3_editor.mts +5 -5
  120. package/src/wnako3mod.mjs +2 -2
  121. package/src/wnako3mod.mts +2 -2
  122. package/core/src/nako3.mjs +0 -1021
  123. package/core/src/nako_ast.mjs +0 -4
  124. package/core/src/nako_colors.mjs +0 -77
  125. package/core/src/nako_core_version.mjs +0 -8
  126. package/core/src/nako_csv.mjs +0 -193
  127. package/core/src/nako_errors.mjs +0 -166
  128. package/core/src/nako_from_dncl.mjs +0 -285
  129. package/core/src/nako_from_dncl2.mjs +0 -347
  130. package/core/src/nako_gen.mjs +0 -2500
  131. package/core/src/nako_global.mjs +0 -138
  132. package/core/src/nako_indent.mjs +0 -442
  133. package/core/src/nako_indent_chars.mjs +0 -29
  134. package/core/src/nako_indent_inline.mjs +0 -361
  135. package/core/src/nako_josi_list.mjs +0 -47
  136. package/core/src/nako_lex_rules.mjs +0 -319
  137. package/core/src/nako_lexer.mjs +0 -794
  138. package/core/src/nako_logger.mjs +0 -221
  139. package/core/src/nako_parser3.mjs +0 -3250
  140. package/core/src/nako_parser_base.mjs +0 -403
  141. package/core/src/nako_parser_const.mjs +0 -37
  142. package/core/src/nako_prepare.mjs +0 -329
  143. package/core/src/nako_reserved_words.mjs +0 -42
  144. package/core/src/nako_source_mapping.mjs +0 -207
  145. package/core/src/nako_test.mjs +0 -37
  146. package/core/src/nako_token.mjs +0 -1
  147. package/core/src/nako_tools.mjs +0 -53
  148. package/core/src/nako_types.mjs +0 -14
  149. package/core/src/plugin_api.mjs +0 -4
  150. package/core/src/plugin_csv.mjs +0 -97
  151. package/core/src/plugin_math.mjs +0 -352
  152. package/core/src/plugin_promise.mjs +0 -102
  153. package/core/src/plugin_system.mjs +0 -3810
  154. package/core/src/plugin_test.mjs +0 -52
  155. package/core/src/plugin_toml.mjs +0 -39
@@ -1,221 +0,0 @@
1
- /** NakoLogger */
2
- import { NakoError, NakoRuntimeError } from './nako_errors.mjs';
3
- import { NakoColors } from './nako_colors.mjs';
4
- /**
5
- * ログレベル - 数字が高いほど優先度が高い。
6
- */
7
- export class LogLevel {
8
- // string to level no
9
- static fromS(levelStr) {
10
- let level = LogLevel.trace;
11
- switch (levelStr) {
12
- case 'all':
13
- level = LogLevel.all;
14
- break;
15
- case 'trace':
16
- level = LogLevel.trace;
17
- break;
18
- case 'debug':
19
- level = LogLevel.debug;
20
- break;
21
- case 'info':
22
- level = LogLevel.info;
23
- break;
24
- case 'warn':
25
- level = LogLevel.warn;
26
- break;
27
- case 'error':
28
- level = LogLevel.error;
29
- break;
30
- case 'stdout':
31
- level = LogLevel.stdout;
32
- break;
33
- default:
34
- throw new Error('[NakoLogger] unknown logger level:' + levelStr);
35
- }
36
- return level;
37
- }
38
- static toString(level) {
39
- const levels = ['all', 'trace', 'debug', 'info', 'warn', 'error', 'stdout'];
40
- return levels[level];
41
- }
42
- }
43
- // level no
44
- LogLevel.all = 0;
45
- LogLevel.trace = 1;
46
- LogLevel.debug = 2;
47
- LogLevel.info = 3;
48
- LogLevel.warn = 4;
49
- LogLevel.error = 5;
50
- LogLevel.stdout = 6;
51
- /**
52
- * エラー位置を日本語で表示する。
53
- * たとえば `stringifyPosition({ file: "foo.txt", line: 5 })` は `"foo.txt(6行目):"` を出力する。
54
- */
55
- function stringifyPosition(p) {
56
- if (!p) {
57
- return '';
58
- }
59
- return `${p.file || ''}${p.line === undefined ? '' : `(${p.line + 1}行目): `}`;
60
- }
61
- export function parsePosition(line) {
62
- const m = line.match(/^l(\d+):(.+)/);
63
- let lineNo = 0;
64
- let fileName = 'main.nako3';
65
- if (m) {
66
- lineNo = parseInt(m[1], 10);
67
- fileName = m[2];
68
- }
69
- return {
70
- startOffset: 0,
71
- endOffset: 0,
72
- line: lineNo,
73
- file: fileName
74
- };
75
- }
76
- /**
77
- * コンパイラのログ情報を出力するためのクラス。
78
- * trace(), debug(), info(), warn(), error() はそれぞれメッセージに `[警告]` などのタグとエラー位置の日本語表現を付けて表示する。
79
- * error() は引数にエラーオブジェクトを受け取ることもでき、その場合エラーオブジェクトからエラーメッセージとエラー位置が取り出される。
80
- */
81
- export class NakoLogger {
82
- constructor() {
83
- this.listeners = [];
84
- this.logs = '';
85
- this.position = '';
86
- }
87
- getErrorLogs() {
88
- return [this.logs.replace(/\s+$/, ''), this.position];
89
- }
90
- clear() {
91
- this.logs = '';
92
- this.position = '';
93
- }
94
- /**
95
- * sendメソッドで送られた情報を受け取るコールバックを設定する。
96
- * @param levelStr
97
- * @param callback
98
- */
99
- addListener(levelStr, callback) {
100
- const level = LogLevel.fromS(levelStr);
101
- this.listeners.push({ level, callback });
102
- }
103
- /**
104
- * addListenerメソッドで設定したコールバックを取り外す。
105
- * @param {LogListener} callback
106
- */
107
- removeListener(callback) {
108
- this.listeners = this.listeners.filter((l) => l.callback !== callback);
109
- }
110
- /** 本体開発時のデバッグ情報(debugより更に詳細な情報)
111
- * @param {string} message
112
- * @param {Position | null} position
113
- */
114
- trace(message, position = null) {
115
- this.sendI(LogLevel.trace, `${NakoColors.color.bold}[デバッグ情報(詳細)]${NakoColors.color.reset}${stringifyPosition(position)}${message}`, position);
116
- }
117
- /** 本体開発時のデバッグ情報
118
- * @param {string} message
119
- * @param {Position | null} position
120
- */
121
- debug(message, position = null) {
122
- this.sendI(LogLevel.debug, `${NakoColors.color.bold}[デバッグ情報]${NakoColors.color.reset}${stringifyPosition(position)}${message}`, position);
123
- }
124
- /** ユーザープログラムのデバッグ情報(あまり重要ではないもの)
125
- * @param {string} message
126
- * @param {Position | null} position
127
- */
128
- info(message, position = null) {
129
- this.sendI(LogLevel.info, `${NakoColors.color.bold}${NakoColors.color.blue}[情報]${NakoColors.color.reset}${stringifyPosition(position)}${message}`, position);
130
- }
131
- /** ユーザープログラムのデバッグ情報(重要なもの)
132
- * @param {string} message
133
- * @param {Position | null} position
134
- */
135
- warn(message, position = null) {
136
- this.sendI(LogLevel.warn, `${NakoColors.color.bold}${NakoColors.color.green}[警告]${NakoColors.color.reset}${stringifyPosition(position)}${message}`, position);
137
- }
138
- /** エラーメッセージ
139
- * @param {string | Error} message
140
- * @param {Position | null} position
141
- */
142
- error(message, position = null) {
143
- // NakoErrorか判定 (`message instanceof NakoError`では判定できない場合がある)
144
- if (message instanceof Error && typeof message.type === 'string') {
145
- // NakoErrorか
146
- const etype = message.type;
147
- switch (etype) {
148
- case 'NakoRuntimeError':
149
- case 'NakoError':
150
- if (message instanceof NakoError) {
151
- const e = message;
152
- let pos = position;
153
- if (pos === null || pos === undefined) {
154
- pos = { file: e.file, line: e.line || 0, startOffset: 0, endOffset: 0 };
155
- }
156
- this.sendI(LogLevel.error, e.message, pos);
157
- return;
158
- }
159
- }
160
- }
161
- if (message instanceof Error) {
162
- // 一般のエラーの場合は、messageのみ取得できる。
163
- message = message.message;
164
- }
165
- this.sendI(LogLevel.error, `${NakoColors.color.bold}${NakoColors.color.red}[エラー]${NakoColors.color.reset}${stringifyPosition(position)}${message}`, position);
166
- }
167
- /** RuntimeErrorを生成する */
168
- runtimeError(error, posStr) {
169
- const e = new NakoRuntimeError(error, posStr);
170
- return e;
171
- }
172
- /** ユーザープログラムのデバッグ情報(すべて)
173
- * @param {string} message
174
- * @param {Position | null} position
175
- */
176
- stdout(message, position = null) {
177
- this.sendI(LogLevel.stdout, `${message}`, position);
178
- }
179
- /** 指定したlevelのlistenerにメッセージを送る。htmlやbrowserConsoleは無ければnodeConsoleから生成する。 */
180
- send(levelStr, nodeConsole, position, html = null, browserConsole = null) {
181
- const i = LogLevel.fromS(levelStr);
182
- this.sendI(i, nodeConsole, position, html, browserConsole);
183
- }
184
- /** 指定したlevelのlistenerにメッセージを送る。htmlやbrowserConsoleは無ければnodeConsoleから生成する。 */
185
- sendI(level, nodeConsole, position, html = null, browserConsole = null) {
186
- const makeData = () => {
187
- // nodeConsoleからnoColor, nodeCondoleなどの形式を生成する。
188
- const formats = NakoColors.convertColorTextFormat(nodeConsole);
189
- // ログが複数行から構成される場合は、htmlでの表現にborderを設定する。
190
- let style = '';
191
- if (nodeConsole.includes('\n')) {
192
- style += 'border-top: 1px solid #8080806b; border-bottom: 1px solid #8080806b;';
193
- }
194
- // 各イベントリスナーが受け取るデータ
195
- const data = {
196
- noColor: formats.noColor,
197
- nodeConsole: formats.nodeConsole,
198
- browserConsole: browserConsole || formats.browserConsole,
199
- html: `<div style="${style}">` + (html || formats.html) + '</div>', // 各行を style: block で表示するために、<div>で囲む。
200
- level: LogLevel.toString(level),
201
- position
202
- };
203
- return data;
204
- };
205
- // エラーならログに追加
206
- if (level === LogLevel.error) {
207
- const data = makeData();
208
- this.logs += data.noColor + '\n';
209
- if (position && this.position !== null) {
210
- this.position = `l${position.line}:${position.file || 'unknown'}`;
211
- }
212
- }
213
- // 登録したリスナーに通知する
214
- for (const l of this.listeners) {
215
- if (l.level <= level) {
216
- const data = makeData();
217
- l.callback(data);
218
- }
219
- }
220
- }
221
- }