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.
- package/batch/command.txt +370 -334
- package/batch/jsplugin2text.nako3 +1 -1
- package/batch/pickup_command.nako3 +12 -0
- package/core/command/snako.mts +5 -1
- package/core/deno/snako.ts +5 -1
- package/core/package-lock.json +382 -21
- package/core/package.json +4 -4
- package/core/src/nako3.mts +178 -614
- package/core/src/nako_basic_plugins.mts +39 -0
- package/core/src/nako_core_version.mts +2 -2
- package/core/src/nako_csv.mts +0 -1
- package/core/src/nako_event.mts +49 -0
- package/core/src/nako_gen.mts +291 -202
- package/core/src/nako_indent_inline.mts +2 -2
- package/core/src/nako_lex_rules.mts +1 -1
- package/core/src/nako_parser3.mts +106 -165
- package/core/src/nako_parser_async.mts +97 -0
- package/core/src/nako_parser_base.mts +4 -55
- package/core/src/nako_parser_message.mts +105 -0
- package/core/src/nako_parser_operator.mts +93 -0
- package/core/src/nako_plugin_manager.mts +260 -0
- package/core/src/nako_require.mts +292 -0
- package/core/src/nako_runner.mts +191 -0
- package/core/src/nako_tokenizer.mts +221 -0
- package/core/src/plugin_csv.mts +1 -1
- package/core/src/plugin_system.mts +34 -3259
- package/core/src/plugin_system_array.mts +699 -0
- package/core/src/plugin_system_datetime.mts +368 -0
- package/core/src/plugin_system_debug.mts +403 -0
- package/core/src/plugin_system_dict.mts +85 -0
- package/core/src/plugin_system_json.mts +73 -0
- package/core/src/plugin_system_math.mts +383 -0
- package/core/src/plugin_system_regexp.mts +120 -0
- package/core/src/plugin_system_stdio.mts +86 -0
- package/core/src/plugin_system_string.mts +666 -0
- package/core/src/plugin_system_timer.mts +152 -0
- package/core/src/plugin_system_types.mts +151 -0
- package/core/src/plugin_system_url.mts +193 -0
- package/core/src/plugin_toml.mts +3 -3
- package/core/test/fixtures/README.md +39 -0
- package/core/test/fixtures/make_parser_ast_golden.mjs +31 -0
- package/core/test/fixtures/parser_ast_golden.json +8027 -0
- package/core/test/fixtures/parser_corpus.mjs +120 -0
- package/core/test/indent_test.mjs +6 -0
- package/core/test/nako_basic_plugins_test.mjs +44 -0
- package/core/test/nako_event_test.mjs +85 -0
- package/core/test/nako_gen_perf_test.mjs +178 -0
- package/core/test/nako_parser_async_test.mjs +112 -0
- package/core/test/nako_parser_test.mjs +160 -0
- package/core/test/nako_plugin_manager_test.mjs +185 -0
- package/core/test/nako_require_test.mjs +153 -0
- package/core/test/nako_runner_test.mjs +114 -0
- package/core/test/nako_tokenizer_test.mjs +115 -0
- package/core/test/plugin_system_debug_test.mjs +141 -0
- package/core/test/plugin_system_split_test.mjs +179 -0
- package/core/test/plugin_system_test.mjs +6 -0
- package/core/tsconfig.json +0 -1
- package/package.json +17 -21
- package/release/_hash.txt +36 -36
- package/release/_script-tags.txt +16 -16
- package/release/command.json +1 -1
- package/release/command.json.js +1 -1
- package/release/command_cnako3.json +1 -1
- package/release/command_list.json +1 -1
- package/release/edit_main.js +6 -6
- package/release/edit_main.js.map +3 -3
- package/release/editor.js +6 -6
- package/release/plugin_keigo.js.map +3 -3
- package/release/plugin_markup.js +46 -46
- package/release/plugin_markup.js.map +3 -3
- package/release/plugin_weykturtle3d.js +1 -1
- package/release/plugin_weykturtle3d.js.map +3 -3
- package/release/version.js +2 -2
- package/release/version_main.js +2 -2
- package/release/version_main.js.map +1 -1
- package/release/wnako3.js +186 -213
- package/release/wnako3.js.map +4 -4
- package/release/wnako3webworker.js +172 -199
- package/release/wnako3webworker.js.map +4 -4
- package/src/cnako3mod.mjs +7 -2
- package/src/cnako3mod.mts +7 -2
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser_ajax.mjs +4 -4
- package/src/plugin_browser_ajax.mts +4 -4
- package/src/plugin_browser_audio.mjs +10 -10
- package/src/plugin_browser_audio.mts +10 -10
- package/src/plugin_browser_camera.mjs +4 -4
- package/src/plugin_browser_camera.mts +4 -4
- package/src/plugin_browser_canvas.mjs +2 -2
- package/src/plugin_browser_canvas.mts +2 -2
- package/src/plugin_browser_crypto.mjs +3 -3
- package/src/plugin_browser_crypto.mts +3 -3
- package/src/plugin_browser_dom_event.mjs +1 -1
- package/src/plugin_browser_dom_event.mts +1 -1
- package/src/plugin_browser_geolocation.mjs +1 -1
- package/src/plugin_browser_geolocation.mts +1 -1
- package/src/plugin_browser_hotkey.mjs +1 -1
- package/src/plugin_browser_hotkey.mts +1 -1
- package/src/plugin_browser_html.mjs +1 -1
- package/src/plugin_browser_html.mts +1 -1
- package/src/plugin_browser_location.mjs +1 -1
- package/src/plugin_browser_location.mts +1 -1
- package/src/plugin_browser_speech.mjs +1 -1
- package/src/plugin_browser_speech.mts +1 -1
- package/src/plugin_browser_storage.mjs +2 -2
- package/src/plugin_browser_storage.mts +2 -2
- package/src/plugin_httpserver.mjs +3 -3
- package/src/plugin_httpserver.mts +3 -3
- package/src/plugin_keigo.mjs +2 -2
- package/src/plugin_keigo.mts +2 -2
- package/src/plugin_node.mjs +48 -48
- package/src/plugin_node.mts +53 -53
- package/src/plugin_weykturtle3d.mjs +56 -56
- package/src/plugin_weykturtle3d.mts +56 -56
- package/src/wnako3.mjs +1 -1
- package/src/wnako3.mts +1 -1
- package/src/wnako3_editor.mjs +5 -5
- package/src/wnako3_editor.mts +5 -5
- package/src/wnako3mod.mjs +2 -2
- package/src/wnako3mod.mts +2 -2
- package/core/src/nako3.mjs +0 -1021
- package/core/src/nako_ast.mjs +0 -4
- package/core/src/nako_colors.mjs +0 -77
- package/core/src/nako_core_version.mjs +0 -8
- package/core/src/nako_csv.mjs +0 -193
- package/core/src/nako_errors.mjs +0 -166
- package/core/src/nako_from_dncl.mjs +0 -285
- package/core/src/nako_from_dncl2.mjs +0 -347
- package/core/src/nako_gen.mjs +0 -2500
- package/core/src/nako_global.mjs +0 -138
- package/core/src/nako_indent.mjs +0 -442
- package/core/src/nako_indent_chars.mjs +0 -29
- package/core/src/nako_indent_inline.mjs +0 -361
- package/core/src/nako_josi_list.mjs +0 -47
- package/core/src/nako_lex_rules.mjs +0 -319
- package/core/src/nako_lexer.mjs +0 -794
- package/core/src/nako_logger.mjs +0 -221
- package/core/src/nako_parser3.mjs +0 -3250
- package/core/src/nako_parser_base.mjs +0 -403
- package/core/src/nako_parser_const.mjs +0 -37
- package/core/src/nako_prepare.mjs +0 -329
- package/core/src/nako_reserved_words.mjs +0 -42
- package/core/src/nako_source_mapping.mjs +0 -207
- package/core/src/nako_test.mjs +0 -37
- package/core/src/nako_token.mjs +0 -1
- package/core/src/nako_tools.mjs +0 -53
- package/core/src/nako_types.mjs +0 -14
- package/core/src/plugin_api.mjs +0 -4
- package/core/src/plugin_csv.mjs +0 -97
- package/core/src/plugin_math.mjs +0 -352
- package/core/src/plugin_promise.mjs +0 -102
- package/core/src/plugin_system.mjs +0 -3810
- package/core/src/plugin_test.mjs +0 -52
- package/core/src/plugin_toml.mjs +0 -39
package/core/src/nako_logger.mjs
DELETED
|
@@ -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
|
-
}
|