nadesiko3 3.7.13 → 3.7.14
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 +473 -473
- package/batch/jsplugin2text.nako3 +2 -0
- package/core/package.json +1 -1
- package/core/src/nako3.mjs +0 -4
- package/core/src/nako3.mts +55 -55
- package/core/src/nako_ast.mjs +0 -1
- package/core/src/nako_ast.mts +1 -1
- package/core/src/nako_colors.mjs +0 -1
- package/core/src/nako_colors.mts +1 -1
- package/core/src/nako_core_version.mjs +2 -2
- package/core/src/nako_core_version.mts +2 -2
- package/core/src/nako_csv.mjs +0 -1
- package/core/src/nako_csv.mts +9 -9
- package/core/src/nako_errors.mts +8 -8
- package/core/src/nako_from_dncl.mts +5 -5
- package/core/src/nako_from_dncl2.mjs +0 -1
- package/core/src/nako_from_dncl2.mts +5 -5
- package/core/src/nako_gen.mjs +13 -15
- package/core/src/nako_gen.mts +224 -220
- package/core/src/nako_global.mts +11 -11
- package/core/src/nako_indent.mts +92 -92
- package/core/src/nako_indent_chars.mts +1 -1
- package/core/src/nako_indent_inline.mjs +11 -11
- package/core/src/nako_indent_inline.mts +20 -20
- package/core/src/nako_lex_rules.mjs +0 -1
- package/core/src/nako_lex_rules.mts +8 -8
- package/core/src/nako_lexer.mjs +0 -1
- package/core/src/nako_lexer.mts +23 -23
- package/core/src/nako_logger.mjs +1 -1
- package/core/src/nako_logger.mts +38 -38
- package/core/src/nako_parser3.mjs +4 -5
- package/core/src/nako_parser3.mts +79 -79
- package/core/src/nako_parser_base.mjs +1 -1
- package/core/src/nako_parser_base.mts +68 -68
- package/core/src/nako_parser_const.mjs +0 -1
- package/core/src/nako_parser_const.mts +1 -1
- package/core/src/nako_prepare.mts +12 -12
- package/core/src/nako_source_mapping.mts +9 -9
- package/core/src/nako_token.mjs +0 -1
- package/core/src/nako_token.mts +2 -2
- package/core/src/nako_tools.mjs +0 -1
- package/core/src/nako_tools.mts +4 -4
- package/core/src/nako_types.mjs +0 -1
- package/core/src/nako_types.mts +3 -3
- package/core/src/plugin_api.mjs +0 -1
- package/core/src/plugin_api.mts +1 -1
- package/core/src/plugin_csv.mjs +0 -1
- package/core/src/plugin_csv.mts +7 -7
- package/core/src/plugin_math.mjs +0 -1
- package/core/src/plugin_math.mts +39 -40
- package/core/src/plugin_promise.mjs +1 -1
- package/core/src/plugin_promise.mts +9 -9
- package/core/src/plugin_system.mjs +1 -10
- package/core/src/plugin_system.mts +319 -321
- package/core/src/plugin_test.mjs +0 -2
- package/core/src/plugin_test.mts +6 -6
- package/core/src/plugin_toml.mjs +1 -1
- package/core/src/plugin_toml.mts +4 -4
- package/core/test/flow_test.mjs +22 -0
- package/package.json +31 -34
- package/release/_hash.txt +24 -24
- package/release/_script-tags.txt +16 -16
- package/release/command_cnako3.json +1 -1
- package/release/edit_main.js +33 -21
- package/release/edit_main.js.map +4 -4
- package/release/editor.js +33 -21
- package/release/plugin_keigo.js.map +2 -2
- package/release/plugin_turtle.js.map +2 -2
- package/release/plugin_weykturtle3d.js.map +2 -2
- package/release/version.js +29 -17
- package/release/version_main.js +29 -17
- package/release/version_main.js.map +4 -4
- package/release/wnako3.js +51 -44
- package/release/wnako3.js.map +3 -3
- package/release/wnako3webworker.js +45 -38
- package/release/wnako3webworker.js.map +2 -2
- package/src/cnako3.mts +1 -1
- package/src/cnako3mod.mjs +4 -7
- package/src/cnako3mod.mts +24 -24
- package/src/commander_ja.mts +8 -8
- package/src/deno_wrapper.mjs +0 -1
- package/src/deno_wrapper.mts +5 -5
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +21 -29
- package/src/plugin_browser.mts +30 -35
- package/src/plugin_browser_ajax.mts +27 -27
- package/src/plugin_browser_audio.mjs +0 -1
- package/src/plugin_browser_audio.mts +11 -11
- package/src/plugin_browser_camera.mts +8 -8
- package/src/plugin_browser_canvas.mjs +0 -2
- package/src/plugin_browser_canvas.mts +34 -34
- package/src/plugin_browser_chart.mjs +0 -1
- package/src/plugin_browser_chart.mts +13 -13
- package/src/plugin_browser_color.mts +2 -2
- package/src/plugin_browser_crypto.mts +5 -5
- package/src/plugin_browser_dialog.mts +4 -4
- package/src/plugin_browser_dom_basic.mts +42 -42
- package/src/plugin_browser_dom_event.mjs +0 -1
- package/src/plugin_browser_dom_event.mts +27 -28
- package/src/plugin_browser_dom_parts.mjs +0 -2
- package/src/plugin_browser_dom_parts.mts +31 -31
- package/src/plugin_browser_geolocation.mts +3 -3
- package/src/plugin_browser_hotkey.mts +3 -3
- package/src/plugin_browser_html.mts +4 -4
- package/src/plugin_browser_in_worker.mts +1 -1
- package/src/plugin_browser_location.mts +2 -2
- package/src/plugin_browser_speech.mts +7 -7
- package/src/plugin_browser_storage.mts +11 -11
- package/src/plugin_browser_system.mts +2 -2
- package/src/plugin_browser_websocket.mts +6 -6
- package/src/plugin_httpserver.mts +17 -17
- package/src/plugin_keigo.mts +5 -5
- package/src/plugin_node.mjs +7 -48
- package/src/plugin_node.mts +114 -145
- package/src/plugin_turtle.mts +143 -143
- package/src/plugin_weykturtle3d.mjs +0 -3
- package/src/plugin_weykturtle3d.mts +135 -135
- package/src/plugin_weykturtle3d_three.mjs +0 -1
- package/src/plugin_weykturtle3d_three.mts +1 -1
- package/src/plugin_weykturtle3d_threeutil.mts +3 -3
- package/src/wnako3.mjs +0 -1
- package/src/wnako3.mts +1 -1
- package/src/wnako3_editor.mjs +0 -2
- package/src/wnako3_editor.mts +132 -132
- package/src/wnako3mod.mjs +0 -5
- package/src/wnako3mod.mts +19 -19
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type * as THREENS from './plugin_weykturtle3d_three.mjs'
|
|
2
2
|
|
|
3
3
|
export class ThreeUtil {
|
|
4
|
-
private static isDisporsal
|
|
4
|
+
private static isDisporsal(obj: any): obj is THREENS.Disporsal {
|
|
5
5
|
return 'dispose' in obj && typeof obj.dispose === 'function'
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
private static isMesh
|
|
8
|
+
private static isMesh(obj: THREENS.Object3D): obj is THREENS.Mesh {
|
|
9
9
|
return 'isMesh' in obj && obj.isMesh === true
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
static disposeChildObject
|
|
12
|
+
static disposeChildObject(obj: THREENS.Object3D) {
|
|
13
13
|
while (obj.children.length > 0) {
|
|
14
14
|
this.disposeChildObject(obj.children[0])
|
|
15
15
|
obj.remove(obj.children[0])
|
package/src/wnako3.mjs
CHANGED
|
@@ -5,7 +5,6 @@ if ((typeof navigator) === 'object' && !navigator.exportWNako3) {
|
|
|
5
5
|
const wnako3 = navigator.nako3 = new WebNakoCompiler();
|
|
6
6
|
window.addEventListener('DOMContentLoaded', (e) => {
|
|
7
7
|
const isAutoRun = wnako3.checkScriptTagParam();
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
9
8
|
if (isAutoRun) {
|
|
10
9
|
wnako3.runNakoScript();
|
|
11
10
|
}
|
package/src/wnako3.mts
CHANGED
|
@@ -6,7 +6,7 @@ if ((typeof navigator) === 'object' && !(navigator as any).exportWNako3) {
|
|
|
6
6
|
const wnako3 = (navigator as any).nako3 = new WebNakoCompiler()
|
|
7
7
|
window.addEventListener('DOMContentLoaded', (e) => {
|
|
8
8
|
const isAutoRun = wnako3.checkScriptTagParam()
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
if (isAutoRun) { wnako3.runNakoScript() }
|
|
11
11
|
}, false)
|
|
12
12
|
}
|
package/src/wnako3_editor.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
/* eslint-disable no-template-curly-in-string */
|
|
3
2
|
/** なでしこのtokenのtypeをscope(CSSのクラス名)に変換する。 */
|
|
4
3
|
import { OffsetToLineColumn } from '../core/src/nako_source_mapping.mjs';
|
|
5
4
|
import { NakoError } from '../core/src/nako_errors.mjs';
|
|
@@ -215,7 +214,6 @@ export function tokenize(lines, nako3, underlineJosi) {
|
|
|
215
214
|
lexerOutput.tokens = lexerOutput.tokens.filter((t) => t.file === 'main.nako3');
|
|
216
215
|
// 外部ファイルで定義された関数名に一致するトークンのtypeをfuncに変更する。
|
|
217
216
|
// 取り込んでいないファイルも参照される問題や、関数名の重複がある場合に正しくない情報を表示する問題がある。
|
|
218
|
-
// eslint-disable-next-line no-lone-blocks
|
|
219
217
|
{
|
|
220
218
|
/** @type {Record<string, object>} */
|
|
221
219
|
for (const [file, { funclist }] of Object.entries(nako3.dependencies)) {
|
package/src/wnako3_editor.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
|
-
|
|
2
|
+
|
|
3
3
|
/** なでしこのtokenのtypeをscope(CSSのクラス名)に変換する。 */
|
|
4
4
|
|
|
5
5
|
import { OffsetToLineColumn } from '../core/src/nako_source_mapping.mjs'
|
|
@@ -65,83 +65,83 @@ type AceEditor = {
|
|
|
65
65
|
* ace editor では例えば 'comment.line' が付いた部分はクラス .ace_comment.ace_line が付いたHTMLタグで囲まれ、各テーマはそれに対応するCSSを実装する。
|
|
66
66
|
* @returns TokenType
|
|
67
67
|
*/
|
|
68
|
-
export function getScope
|
|
68
|
+
export function getScope(token: Token): string {
|
|
69
69
|
switch (token.type) {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
70
|
+
case 'line_comment': return 'comment.line'
|
|
71
|
+
case 'range_comment': return 'comment.block'
|
|
72
|
+
case 'def_test': return 'keyword.control'
|
|
73
|
+
case 'def_func': return 'keyword.control'
|
|
74
|
+
case 'func': return 'entity.name.function'
|
|
75
|
+
case 'number': return 'constant.numeric'
|
|
76
|
+
// 独立した助詞
|
|
77
|
+
case 'とは':
|
|
78
|
+
case 'ならば':
|
|
79
|
+
case 'でなければ':
|
|
80
|
+
return 'keyword.control'
|
|
81
|
+
// 制御構文
|
|
82
|
+
case 'ここから':
|
|
83
|
+
case 'ここまで':
|
|
84
|
+
case 'もし':
|
|
85
|
+
case '違えば':
|
|
86
|
+
case 'require':
|
|
87
|
+
return 'keyword.control'
|
|
88
|
+
// 予約語
|
|
89
|
+
case '回':
|
|
90
|
+
case '間':
|
|
91
|
+
case '繰り返す':
|
|
92
|
+
case '反復':
|
|
93
|
+
case '抜ける':
|
|
94
|
+
case '続ける':
|
|
95
|
+
case '戻る':
|
|
96
|
+
case '先に':
|
|
97
|
+
case '次に':
|
|
98
|
+
case '代入':
|
|
99
|
+
case '逐次実行':
|
|
100
|
+
case '条件分岐':
|
|
101
|
+
case '取込':
|
|
102
|
+
case 'エラー監視':
|
|
103
|
+
case 'エラー':
|
|
104
|
+
case '変数':
|
|
105
|
+
case '実行速度優先':
|
|
106
|
+
return 'keyword.control'
|
|
107
|
+
case '定める':
|
|
108
|
+
case '定数':
|
|
109
|
+
return 'support.constant'
|
|
110
|
+
// 演算子
|
|
111
|
+
case 'shift_r0':
|
|
112
|
+
case 'shift_r':
|
|
113
|
+
case 'shift_l':
|
|
114
|
+
case 'gteq':
|
|
115
|
+
case 'lteq':
|
|
116
|
+
case 'noteq':
|
|
117
|
+
case 'eq':
|
|
118
|
+
case 'not':
|
|
119
|
+
case 'gt':
|
|
120
|
+
case 'lt':
|
|
121
|
+
case 'and':
|
|
122
|
+
case 'or':
|
|
123
|
+
case '@':
|
|
124
|
+
case '+':
|
|
125
|
+
case '-':
|
|
126
|
+
case '**':
|
|
127
|
+
case '*':
|
|
128
|
+
case '÷÷':
|
|
129
|
+
case '/':
|
|
130
|
+
case '%':
|
|
131
|
+
case '^':
|
|
132
|
+
case '&':
|
|
133
|
+
return 'keyword.operator'
|
|
134
|
+
case 'string':
|
|
135
|
+
case 'string_ex':
|
|
136
|
+
return 'string.other'
|
|
137
|
+
case 'word':
|
|
138
|
+
if (['そう', 'それ', '回数', '対象キー', '対象'].includes(token.value)) {
|
|
139
|
+
return 'variable.language'
|
|
140
|
+
} else {
|
|
141
|
+
return 'variable.other'
|
|
142
|
+
}
|
|
143
|
+
default:
|
|
144
|
+
return 'markup.other'
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -152,7 +152,7 @@ export function getScope (token: Token): string {
|
|
|
152
152
|
* @param {boolean} includesLastCharacter
|
|
153
153
|
* @param {boolean} underlineJosi
|
|
154
154
|
*/
|
|
155
|
-
export function getEditorTokens
|
|
155
|
+
export function getEditorTokens(compilerToken, nako3, value, includesLastCharacter, underlineJosi) {
|
|
156
156
|
const type = getScope(compilerToken)
|
|
157
157
|
const docHTML = getDocumentationHTML(compilerToken, nako3)
|
|
158
158
|
|
|
@@ -172,7 +172,7 @@ export function getEditorTokens (compilerToken, nako3, value, includesLastCharac
|
|
|
172
172
|
/**
|
|
173
173
|
* `name` が定義されたプラグインの名前を返す。
|
|
174
174
|
*/
|
|
175
|
-
export function findPluginName
|
|
175
|
+
export function findPluginName(name: string, nako3: NakoCompiler): string|null {
|
|
176
176
|
for (const pluginName of Object.keys(nako3.__module)) {
|
|
177
177
|
if (Object.keys(nako3.__module[pluginName]).includes(name)) {
|
|
178
178
|
return pluginName
|
|
@@ -184,7 +184,7 @@ export function findPluginName (name: string, nako3: NakoCompiler): string|null
|
|
|
184
184
|
/**
|
|
185
185
|
* i = 0, 1, 2, ... に対して 'A', 'B', 'C', ... 'Z', 'AA', 'AB', ... を返す。
|
|
186
186
|
*/
|
|
187
|
-
export function createParameterName
|
|
187
|
+
export function createParameterName(i: number): string {
|
|
188
188
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
|
|
189
189
|
return i.toString(26).split('').map((v) => alphabet[parseInt(v, 26)]).join('')
|
|
190
190
|
}
|
|
@@ -192,7 +192,7 @@ export function createParameterName (i: number): string {
|
|
|
192
192
|
/**
|
|
193
193
|
* パラメータの定義を表す文字列を生成する。例えば `[['と', 'の'], ['を']]` に対して `'(Aと|Aの、Bを)'` を返す、パラメータが無い場合、空文字列を返す。
|
|
194
194
|
*/
|
|
195
|
-
export function createParameterDeclaration
|
|
195
|
+
export function createParameterDeclaration(josi: string[][]): string {
|
|
196
196
|
const args = josi.map((union, i) => union.map((v) => `${createParameterName(i)}${v}`).join('|')).join('、')
|
|
197
197
|
if (args !== '') {
|
|
198
198
|
return `(${args})`
|
|
@@ -202,7 +202,7 @@ export function createParameterDeclaration (josi: string[][]): string {
|
|
|
202
202
|
}
|
|
203
203
|
|
|
204
204
|
// https://stackoverflow.com/a/6234804
|
|
205
|
-
export function escapeHTML
|
|
205
|
+
export function escapeHTML(t: string) {
|
|
206
206
|
return t
|
|
207
207
|
.replace(/&/g, '&')
|
|
208
208
|
.replace(/</g, '<')
|
|
@@ -214,7 +214,7 @@ export function escapeHTML (t: string) {
|
|
|
214
214
|
/**
|
|
215
215
|
* 関数のドキュメントを返す。
|
|
216
216
|
*/
|
|
217
|
-
export function getDocumentationHTML
|
|
217
|
+
export function getDocumentationHTML(token: Token, nako3: NakoCompiler): string|null {
|
|
218
218
|
const meta = (text: string) => `<span class="tooltip-plugin-name">${escapeHTML(text)}</span>`
|
|
219
219
|
if (token.type === 'func') {
|
|
220
220
|
const pluginName: string|null = findPluginName(token.value + '', nako3) || (token.meta && token.meta.file ? token.meta.file : null)
|
|
@@ -260,7 +260,7 @@ const withoutLogger = (nako3, f) => {
|
|
|
260
260
|
* @param nako3
|
|
261
261
|
* @param underlineJosi
|
|
262
262
|
*/
|
|
263
|
-
export function tokenize
|
|
263
|
+
export function tokenize(lines: string[], nako3: NakoCompiler, underlineJosi: boolean) {
|
|
264
264
|
const code = lines.join('\n')
|
|
265
265
|
|
|
266
266
|
// 取り込み文を含めてしまうと依存ファイルが大きい時に時間がかかってしまうため、
|
|
@@ -273,7 +273,7 @@ export function tokenize (lines: string[], nako3: NakoCompiler, underlineJosi: b
|
|
|
273
273
|
|
|
274
274
|
// 外部ファイルで定義された関数名に一致するトークンのtypeをfuncに変更する。
|
|
275
275
|
// 取り込んでいないファイルも参照される問題や、関数名の重複がある場合に正しくない情報を表示する問題がある。
|
|
276
|
-
|
|
276
|
+
|
|
277
277
|
{
|
|
278
278
|
/** @type {Record<string, object>} */
|
|
279
279
|
for (const [file, { funclist }] of Object.entries(nako3.dependencies)) {
|
|
@@ -389,7 +389,7 @@ export class EditorMarkers {
|
|
|
389
389
|
* @param {TypeofAceRange} AceRange
|
|
390
390
|
* @param {boolean} disable
|
|
391
391
|
*/
|
|
392
|
-
constructor
|
|
392
|
+
constructor(session, doc, AceRange, disable) {
|
|
393
393
|
this.session = session
|
|
394
394
|
this.doc = doc
|
|
395
395
|
this.AceRange = AceRange
|
|
@@ -407,7 +407,7 @@ export class EditorMarkers {
|
|
|
407
407
|
* @param {(row: number) => string} getLine
|
|
408
408
|
* @returns {[number, number, number, number]}
|
|
409
409
|
*/
|
|
410
|
-
static fromNullable
|
|
410
|
+
static fromNullable(startLine, startColumn, endLine, endColumn, getLine) {
|
|
411
411
|
if (startColumn === null) {
|
|
412
412
|
startColumn = 0
|
|
413
413
|
}
|
|
@@ -430,7 +430,7 @@ export class EditorMarkers {
|
|
|
430
430
|
* @param {string} code @param {number} startOffset @param {number} endOffset
|
|
431
431
|
* @returns {[number, number, number, number]}
|
|
432
432
|
*/
|
|
433
|
-
static fromOffset
|
|
433
|
+
static fromOffset(code, startOffset, endOffset) {
|
|
434
434
|
const offsetToLineColumn = new OffsetToLineColumn(code)
|
|
435
435
|
const start = offsetToLineColumn.map(startOffset, false)
|
|
436
436
|
const end = offsetToLineColumn.map(endOffset, false)
|
|
@@ -443,7 +443,7 @@ export class EditorMarkers {
|
|
|
443
443
|
* @param {(row: number) => string} getLine
|
|
444
444
|
* @returns {[number, number, number, number]}
|
|
445
445
|
*/
|
|
446
|
-
static fromError
|
|
446
|
+
static fromError(code, error, getLine) {
|
|
447
447
|
if (typeof error.startOffset === 'number' && typeof error.endOffset === 'number') {
|
|
448
448
|
// 完全な位置を取得できる場合
|
|
449
449
|
return this.fromOffset(code, error.startOffset, error.endOffset)
|
|
@@ -464,7 +464,7 @@ export class EditorMarkers {
|
|
|
464
464
|
* @param {string} message
|
|
465
465
|
* @param {'warn' | 'error'} type
|
|
466
466
|
*/
|
|
467
|
-
add
|
|
467
|
+
add(startLine, startColumn, endLine, endColumn, message, type) {
|
|
468
468
|
if (this.disable) {
|
|
469
469
|
return
|
|
470
470
|
}
|
|
@@ -480,14 +480,14 @@ export class EditorMarkers {
|
|
|
480
480
|
* @param {{ line?: number, startOffset?: number | null, endOffset?: number | null, message: string }} error
|
|
481
481
|
* @param {'warn' | 'error'} type
|
|
482
482
|
*/
|
|
483
|
-
addByError
|
|
483
|
+
addByError(code, error, type) {
|
|
484
484
|
this.add(...EditorMarkers.fromError(code, error, (row) => this.doc.getLine(row)), error.message, type)
|
|
485
485
|
}
|
|
486
486
|
|
|
487
487
|
/**
|
|
488
488
|
* 全てのエラーメッセージを削除する。
|
|
489
489
|
*/
|
|
490
|
-
clear
|
|
490
|
+
clear() {
|
|
491
491
|
for (const marker of this.markers) {
|
|
492
492
|
this.session.removeMarker(marker)
|
|
493
493
|
}
|
|
@@ -512,7 +512,7 @@ export class BackgroundTokenizer {
|
|
|
512
512
|
* @param {(code: string, err: Error) => void} onCompileError
|
|
513
513
|
* @param {boolean} underlineJosi
|
|
514
514
|
*/
|
|
515
|
-
constructor
|
|
515
|
+
constructor(doc, nako3, onTokenUpdate, onCompileError, underlineJosi) {
|
|
516
516
|
this.onUpdate = onTokenUpdate
|
|
517
517
|
this.doc = doc
|
|
518
518
|
this.dirty = true
|
|
@@ -570,7 +570,7 @@ export class BackgroundTokenizer {
|
|
|
570
570
|
setTimeout(() => { update() }, 0)
|
|
571
571
|
}
|
|
572
572
|
|
|
573
|
-
dispose
|
|
573
|
+
dispose() {
|
|
574
574
|
this.deleted = true
|
|
575
575
|
}
|
|
576
576
|
|
|
@@ -578,7 +578,7 @@ export class BackgroundTokenizer {
|
|
|
578
578
|
* テキストに変更があったときに呼ばれる。IME入力中には呼ばれない。
|
|
579
579
|
* @param {{ action: string, start: { row: number, column: number }, end: { row: number, column: number }, lines: string[] }} delta
|
|
580
580
|
*/
|
|
581
|
-
$updateOnChange
|
|
581
|
+
$updateOnChange(delta) {
|
|
582
582
|
this.dirty = true
|
|
583
583
|
const startRow = delta.start.row
|
|
584
584
|
const endRow = delta.end.row
|
|
@@ -631,7 +631,7 @@ export class BackgroundTokenizer {
|
|
|
631
631
|
* tokenizerの出力を返す。文字入力したときに呼ばれる。
|
|
632
632
|
* @param {number} row
|
|
633
633
|
*/
|
|
634
|
-
getTokens
|
|
634
|
+
getTokens(row) {
|
|
635
635
|
// IME入力中はthis.lines[row]に自動的にnullが設定される。その場合新しく行のトークン列を生成して返さなければならない。
|
|
636
636
|
// 返した配列には自動的にIMEの入力用のテキストボックスであるcomposition_placeholderが挿入される。
|
|
637
637
|
if (!this.lines[row]) {
|
|
@@ -666,17 +666,17 @@ export class BackgroundTokenizer {
|
|
|
666
666
|
|
|
667
667
|
// ace側から呼ばれるが無視するメソッド
|
|
668
668
|
// @ts-ignore
|
|
669
|
-
start
|
|
669
|
+
start(startRow) { /* pass */ }
|
|
670
670
|
// @ts-ignore
|
|
671
|
-
fireUpdateEvent
|
|
671
|
+
fireUpdateEvent(firstRow, lastRow) { /* pass */ }
|
|
672
672
|
// @ts-ignore
|
|
673
|
-
setDocument
|
|
674
|
-
scheduleStart
|
|
673
|
+
setDocument(doc) { /* pass */ }
|
|
674
|
+
scheduleStart() { /* pass */ }
|
|
675
675
|
// @ts-ignore
|
|
676
|
-
setTokenizer
|
|
677
|
-
stop
|
|
676
|
+
setTokenizer(tokenizer) { /* pass */ }
|
|
677
|
+
stop() { /* pass */ }
|
|
678
678
|
// @ts-ignore
|
|
679
|
-
getState
|
|
679
|
+
getState(row) { return 'start' }
|
|
680
680
|
}
|
|
681
681
|
|
|
682
682
|
/**
|
|
@@ -687,7 +687,7 @@ export class LanguageFeatures {
|
|
|
687
687
|
* @param {TypeofAceRange} AceRange
|
|
688
688
|
* @param {NakoCompiler} nako3
|
|
689
689
|
*/
|
|
690
|
-
constructor
|
|
690
|
+
constructor(AceRange, nako3) {
|
|
691
691
|
this.AceRange = AceRange
|
|
692
692
|
this.nako3 = nako3
|
|
693
693
|
}
|
|
@@ -699,7 +699,7 @@ export class LanguageFeatures {
|
|
|
699
699
|
* @param {number} startRow
|
|
700
700
|
* @param {number} endRow
|
|
701
701
|
*/
|
|
702
|
-
static toggleCommentLines
|
|
702
|
+
static toggleCommentLines(state, { doc }, startRow, endRow) {
|
|
703
703
|
const prepare = NakoPrepare.getInstance()
|
|
704
704
|
/**
|
|
705
705
|
* @param {string} line
|
|
@@ -769,7 +769,7 @@ export class LanguageFeatures {
|
|
|
769
769
|
* @param {string} input
|
|
770
770
|
* @returns {boolean}
|
|
771
771
|
*/
|
|
772
|
-
static checkOutdent
|
|
772
|
+
static checkOutdent(state, line, input) {
|
|
773
773
|
// 特定のキーワードの入力が終わったタイミングでインデントを自動修正する。
|
|
774
774
|
// '違えば'のautoOutdentは「もし」と「条件分岐」のどちらのものか見分けが付かないため諦める。
|
|
775
775
|
// 「ここ|ま」(縦線がカーソル)の状態で「で」を打つとtrueになってしまう問題があるが、修正するには引数が足りない。
|
|
@@ -784,7 +784,7 @@ export class LanguageFeatures {
|
|
|
784
784
|
* @param {number} row
|
|
785
785
|
* @returns {void}
|
|
786
786
|
*/
|
|
787
|
-
autoOutdent
|
|
787
|
+
autoOutdent(state, { doc }, row) {
|
|
788
788
|
// 1行目なら何もしない
|
|
789
789
|
if (row === 0) {
|
|
790
790
|
return
|
|
@@ -812,7 +812,7 @@ export class LanguageFeatures {
|
|
|
812
812
|
* @param {string} line 改行前にカーソルがあった行の文字列
|
|
813
813
|
* @param {string} tab タブ文字(デフォルトでは " ")
|
|
814
814
|
*/
|
|
815
|
-
static getNextLineIndent
|
|
815
|
+
static getNextLineIndent(state, line, tab) {
|
|
816
816
|
// ●で始まるか、特定のキーワードで終わる場合にマッチする。
|
|
817
817
|
if (this.isBlockStart(line)) {
|
|
818
818
|
return getIndent(line) + tab
|
|
@@ -821,7 +821,7 @@ export class LanguageFeatures {
|
|
|
821
821
|
}
|
|
822
822
|
|
|
823
823
|
/** @param {string} line */
|
|
824
|
-
static isBlockStart
|
|
824
|
+
static isBlockStart(line) {
|
|
825
825
|
// eslint-disable-next-line no-irregular-whitespace
|
|
826
826
|
return /^[ ・\t]*●|(ならば|なければ|ここから|条件分岐|違えば|回|繰り返(す|し)|の間|反復|とは|には|エラー監視|エラーならば|実行速度優先)、?\s*$/.test(line)
|
|
827
827
|
}
|
|
@@ -833,7 +833,7 @@ export class LanguageFeatures {
|
|
|
833
833
|
* @param {NakoCompiler} nako3
|
|
834
834
|
* @param {BackgroundTokenizer} backgroundTokenizer
|
|
835
835
|
*/
|
|
836
|
-
static getCompletionItems
|
|
836
|
+
static getCompletionItems(row, prefix, nako3, backgroundTokenizer) {
|
|
837
837
|
/**
|
|
838
838
|
* keyはcaption。metaは候補の横に薄く表示されるテキスト。
|
|
839
839
|
* @type {Map<string, { value: string, meta: Set<string>, score: number }>}
|
|
@@ -910,7 +910,7 @@ export class LanguageFeatures {
|
|
|
910
910
|
* スニペット
|
|
911
911
|
*/
|
|
912
912
|
/** @param {string} text */
|
|
913
|
-
static getSnippets
|
|
913
|
+
static getSnippets(text) {
|
|
914
914
|
// インデント構文が有効化されているなら「ここまで」を消す
|
|
915
915
|
const indentSyntax = isIndentSyntaxEnabled(text)
|
|
916
916
|
|
|
@@ -936,7 +936,7 @@ export class LanguageFeatures {
|
|
|
936
936
|
* @param {string} line
|
|
937
937
|
* @param {NakoCompiler} nako3
|
|
938
938
|
*/
|
|
939
|
-
static getCompletionPrefix
|
|
939
|
+
static getCompletionPrefix(line, nako3) {
|
|
940
940
|
/** @type {ReturnType<NakoCompiler['lex']>["tokens"] | null} */
|
|
941
941
|
let tokens = null
|
|
942
942
|
|
|
@@ -976,7 +976,7 @@ export class LanguageFeatures {
|
|
|
976
976
|
* @param {number} row
|
|
977
977
|
* @returns {'start' | ''}
|
|
978
978
|
*/
|
|
979
|
-
getFoldWidget
|
|
979
|
+
getFoldWidget({ doc }, foldStyle, row) {
|
|
980
980
|
// 速度が重要なため正規表現でマッチする。
|
|
981
981
|
return LanguageFeatures.isBlockStart(doc.getLine(row)) ? 'start' : ''
|
|
982
982
|
}
|
|
@@ -988,7 +988,7 @@ export class LanguageFeatures {
|
|
|
988
988
|
* @param {number} row
|
|
989
989
|
* @returns {AceRange | null} foldする範囲
|
|
990
990
|
*/
|
|
991
|
-
getFoldWidgetRange
|
|
991
|
+
getFoldWidgetRange({ doc }, foldStyle, row) {
|
|
992
992
|
const pair = this.getBlockStructure(doc.getAllLines().join('\n')).pairs.find((v) => v[0] === row)
|
|
993
993
|
if (pair !== undefined) {
|
|
994
994
|
return new this.AceRange(pair[0], doc.getLine(pair[0]).length, pair[1] - 1, doc.getLine(pair[1] - 1).length)
|
|
@@ -1000,7 +1000,7 @@ export class LanguageFeatures {
|
|
|
1000
1000
|
* @param {AceDocument} doc
|
|
1001
1001
|
* @returns {CodeLens[]}
|
|
1002
1002
|
*/
|
|
1003
|
-
static getCodeLens
|
|
1003
|
+
static getCodeLens(doc) {
|
|
1004
1004
|
const results = []
|
|
1005
1005
|
for (const [row, line] of Array.from(doc.getAllLines().entries())) {
|
|
1006
1006
|
// eslint-disable-next-line no-irregular-whitespace
|
|
@@ -1020,7 +1020,7 @@ export class LanguageFeatures {
|
|
|
1020
1020
|
* @returns {ReturnType<getBlockStructure>}
|
|
1021
1021
|
* @private
|
|
1022
1022
|
*/
|
|
1023
|
-
getBlockStructure
|
|
1023
|
+
getBlockStructure(code) {
|
|
1024
1024
|
// キャッシュ
|
|
1025
1025
|
if (!this.blockStructure || this.blockStructure.code !== code) {
|
|
1026
1026
|
// @ts-ignore
|
|
@@ -1040,14 +1040,14 @@ class EditorTabs {
|
|
|
1040
1040
|
* @param {TypeofAceRange} AceRange
|
|
1041
1041
|
* @param {any} UndoManager
|
|
1042
1042
|
*/
|
|
1043
|
-
constructor
|
|
1043
|
+
constructor(editor, AceRange, UndoManager) {
|
|
1044
1044
|
this.editor = editor
|
|
1045
1045
|
this.AceRange = AceRange
|
|
1046
1046
|
this.UndoManager = UndoManager
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
1049
|
/** @param {string} content @returns {EditorTabState} */
|
|
1050
|
-
newTab
|
|
1050
|
+
newTab(content) {
|
|
1051
1051
|
return {
|
|
1052
1052
|
content,
|
|
1053
1053
|
cursor: { range: new this.AceRange(0, 0, 0, 0), reversed: false },
|
|
@@ -1057,7 +1057,7 @@ class EditorTabs {
|
|
|
1057
1057
|
}
|
|
1058
1058
|
|
|
1059
1059
|
/** @returns {EditorTabState} */
|
|
1060
|
-
getTab
|
|
1060
|
+
getTab() {
|
|
1061
1061
|
return {
|
|
1062
1062
|
content: this.editor.getValue(),
|
|
1063
1063
|
cursor: { range: this.editor.session.selection.getRange(), reversed: this.editor.session.selection.isBackwards() },
|
|
@@ -1067,7 +1067,7 @@ class EditorTabs {
|
|
|
1067
1067
|
}
|
|
1068
1068
|
|
|
1069
1069
|
/** @param {EditorTabState} state */
|
|
1070
|
-
setTab
|
|
1070
|
+
setTab(state) {
|
|
1071
1071
|
this.editor.setValue(state.content)
|
|
1072
1072
|
this.editor.session.selection.setRange(state.cursor.range, state.cursor.reversed)
|
|
1073
1073
|
this.editor.session.setScrollLeft(state.scroll.left)
|
|
@@ -1078,7 +1078,7 @@ class EditorTabs {
|
|
|
1078
1078
|
|
|
1079
1079
|
class Options {
|
|
1080
1080
|
/** Save Options */
|
|
1081
|
-
static save
|
|
1081
|
+
static save(editor: AceEditor) {
|
|
1082
1082
|
try {
|
|
1083
1083
|
/** @type {any} */
|
|
1084
1084
|
const obj = {}
|
|
@@ -1094,7 +1094,7 @@ class Options {
|
|
|
1094
1094
|
}
|
|
1095
1095
|
|
|
1096
1096
|
/** @param {AceEditor} editor */
|
|
1097
|
-
static load
|
|
1097
|
+
static load(editor) {
|
|
1098
1098
|
try {
|
|
1099
1099
|
if (!window.localStorage) {
|
|
1100
1100
|
return null
|
|
@@ -1129,7 +1129,7 @@ class Options {
|
|
|
1129
1129
|
}
|
|
1130
1130
|
|
|
1131
1131
|
/** OptionPanelクラスをなでしこ用に書き換える。 */
|
|
1132
|
-
static initPanel
|
|
1132
|
+
static initPanel(OptionPanel: any, editor: AceEditor) {
|
|
1133
1133
|
const panel = new OptionPanel(editor) // editorはエラーが飛ばなければ何でも良い
|
|
1134
1134
|
|
|
1135
1135
|
// ページ内で一度だけ呼ぶ
|
|
@@ -1214,7 +1214,7 @@ class Options {
|
|
|
1214
1214
|
// showSettingsMenu 関数は new OptionPanel(editor).render() で新しい設定パネルのインスタンスを生成するため、
|
|
1215
1215
|
// renderメソッドを上書きすることで、生成されたインスタンスにアクセスできる。
|
|
1216
1216
|
const render = OptionPanel.prototype.render
|
|
1217
|
-
OptionPanel.prototype.render = function
|
|
1217
|
+
OptionPanel.prototype.render = function(...args) {
|
|
1218
1218
|
render.apply(this, ...args) // 元の処理
|
|
1219
1219
|
// OptionPanel.setOption() で発火される setOption イベントをキャッチする
|
|
1220
1220
|
this.on('setOption', () => {
|
|
@@ -1264,7 +1264,7 @@ let editorIdCounter = 0
|
|
|
1264
1264
|
* @param {import('./wnako3')} nako3
|
|
1265
1265
|
* @param {any} ace
|
|
1266
1266
|
*/
|
|
1267
|
-
export function setupEditor
|
|
1267
|
+
export function setupEditor(idOrElement, nako3, ace) {
|
|
1268
1268
|
/** @type {AceEditor} */
|
|
1269
1269
|
const editor = ace.edit(idOrElement)
|
|
1270
1270
|
const element = typeof idOrElement === 'string' ? document.getElementById(idOrElement) : idOrElement
|
|
@@ -1315,7 +1315,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1315
1315
|
ace.require('ace/config').defineOptions(editor.constructor.prototype, 'editor', {
|
|
1316
1316
|
syntaxHighlighting: {
|
|
1317
1317
|
/** @type {(this: AceEditor, value: boolean) => void} */
|
|
1318
|
-
set: function
|
|
1318
|
+
set: function(value) {
|
|
1319
1319
|
this.session.bgTokenizer.enabled = value
|
|
1320
1320
|
resetEditorTokens(this.session)
|
|
1321
1321
|
},
|
|
@@ -1323,7 +1323,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1323
1323
|
},
|
|
1324
1324
|
underlineJosi: {
|
|
1325
1325
|
/** @type {(this: AceEditor, value: boolean) => void} */
|
|
1326
|
-
set: function
|
|
1326
|
+
set: function(value) {
|
|
1327
1327
|
this.session.bgTokenizer.underlineJosi = value
|
|
1328
1328
|
resetEditorTokens(this.session)
|
|
1329
1329
|
},
|
|
@@ -1428,7 +1428,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1428
1428
|
// オートコンプリートのcompleterを設定する
|
|
1429
1429
|
completers.push(
|
|
1430
1430
|
{
|
|
1431
|
-
getCompletions
|
|
1431
|
+
getCompletions(editor, session, pos, prefix, callback) {
|
|
1432
1432
|
if (editor.wnako3EditorId !== editorId) {
|
|
1433
1433
|
callback(null, [])
|
|
1434
1434
|
} else {
|
|
@@ -1442,7 +1442,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1442
1442
|
}
|
|
1443
1443
|
}
|
|
1444
1444
|
},
|
|
1445
|
-
{ getCompletions
|
|
1445
|
+
{ getCompletions(editor, session, pos, prefix, callback) { callback(null, (editor.wnako3EditorId !== editorId) ? [] : LanguageFeatures.getSnippets(editor.session.doc.getAllLines().join('\n'))) } }
|
|
1446
1446
|
)
|
|
1447
1447
|
ace.require('ace/ext/language_tools').setCompleters(completers)
|
|
1448
1448
|
|
|
@@ -1457,7 +1457,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1457
1457
|
const languageFeatures = new LanguageFeatures(AceRange, nako3)
|
|
1458
1458
|
const oop = ace.require('ace/lib/oop')
|
|
1459
1459
|
const TextMode = ace.require('ace/mode/text').Mode
|
|
1460
|
-
const Mode = function
|
|
1460
|
+
const Mode = function() {
|
|
1461
1461
|
this.HighlightRules = new TextMode().HighlightRules
|
|
1462
1462
|
this.foldingRules = {
|
|
1463
1463
|
getFoldWidget: languageFeatures.getFoldWidget.bind(languageFeatures),
|
|
@@ -1599,7 +1599,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1599
1599
|
|
|
1600
1600
|
// 依存ファイルを読み込む。
|
|
1601
1601
|
const promise = nako3.loadDependencies(preCode + code, filename, preCode, opts.localFiles || {})
|
|
1602
|
-
.then(async
|
|
1602
|
+
.then(async() => {
|
|
1603
1603
|
// プログラムを実行する。
|
|
1604
1604
|
if (!filename) { filename = 'main.nako3' }
|
|
1605
1605
|
if (opts.method === 'test') {
|
|
@@ -1616,7 +1616,7 @@ export function setupEditor (idOrElement, nako3, ace) {
|
|
|
1616
1616
|
// しかし念のため console.error で出力
|
|
1617
1617
|
console.error('[wnako3_editor]', err, nako3.__globalObj)
|
|
1618
1618
|
})
|
|
1619
|
-
.then(async
|
|
1619
|
+
.then(async(res) => {
|
|
1620
1620
|
// 読み込んだ依存ファイルの情報を使って再度シンタックスハイライトする。
|
|
1621
1621
|
retokenize()
|
|
1622
1622
|
// シンタックスハイライトが終わるのを待つ
|