nadesiko3 3.2.52 → 3.3.3
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/README.md +1 -1
- package/bin/cnako3 +1 -1
- package/bin/cnako3.bat +1 -1
- package/demo/browsers.html +9 -10
- package/demo/flow.html +1 -0
- package/demo/runscript3.html +35 -0
- package/demo/turtle3.html +18 -17
- package/demo/turtle3d.html +1 -1
- package/demo/turtle3d2.html +1 -1
- package/doc/browsers.md +9 -10
- package/package.json +58 -57
- package/release/_hash.txt +57 -52
- package/release/_script-tags.txt +14 -13
- 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/editor.js +1 -1
- package/release/editor.js.LICENSE.txt +9 -12
- package/release/nako_gen_async.js +1 -1
- package/release/nako_gen_async.js.LICENSE.txt +10 -666
- package/release/plugin_caniuse.js +1 -1
- package/release/plugin_caniuse.js.LICENSE.txt +9 -425
- package/release/plugin_csv.js +1 -1
- package/release/plugin_csv.js.LICENSE.txt +3 -419
- package/release/plugin_datetime.js +1 -1
- package/release/plugin_datetime.js.LICENSE.txt +6 -530
- package/release/plugin_kansuji.js +1 -1
- package/release/plugin_kansuji.js.LICENSE.txt +3 -559
- package/release/plugin_markup.js +1 -1
- package/release/plugin_markup.js.LICENSE.txt +4 -420
- package/release/plugin_turtle.js +1 -1
- package/release/plugin_turtle.js.LICENSE.txt +12 -500
- package/release/plugin_webworker.js +1 -1
- package/release/plugin_webworker.js.LICENSE.txt +3 -563
- package/release/plugin_weykturtle3d.js +1 -0
- package/release/plugin_weykturtle3d.js.LICENSE.txt +3 -0
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/version.js.LICENSE.txt +9 -12
- package/release/wnako3.js +1 -1
- package/release/wnako3.js.LICENSE.txt +1 -1
- package/release/wnako3webworker.js +1 -1
- package/release/wnako3webworker.js.LICENSE.txt +1 -1117
- package/src/browsers.mjs +1 -0
- package/src/browsers.txt +15 -15
- package/src/browsers_agents.mjs +1 -0
- package/src/cnako3.mjs +13 -0
- package/src/{cnako3.js → cnako3mod.mjs} +119 -101
- package/src/{commander_ja.js → commander_ja.mjs} +16 -11
- package/src/{enako3.js → enako3.mjs} +0 -0
- package/src/{era.json → era.mjs} +1 -1
- package/src/image_turtle-elephant.mjs +5 -0
- package/src/image_turtle-panda.mjs +5 -0
- package/src/image_turtle64.mjs +5 -0
- package/src/index.mjs +9 -0
- package/src/{nako3.js → nako3.mjs} +69 -57
- package/src/{nako3_assert.js → nako3_assert.mjs} +7 -6
- package/src/{nako3server.js → nako3server.mjs} +12 -5
- package/src/{nako_colors.js → nako_colors.mjs} +1 -1
- package/src/{nako_errors.js → nako_errors.mjs} +10 -20
- package/src/{nako_from_dncl.js → nako_from_dncl.mjs} +11 -8
- package/src/{nako_gen.js → nako_gen.mjs} +93 -87
- package/src/{nako_gen_async.js → nako_gen_async.mjs} +5 -8
- package/src/{nako_global.js → nako_global.mjs} +4 -5
- package/src/{nako_indent.js → nako_indent.mjs} +29 -25
- package/src/{nako_josi_list.js → nako_josi_list.mjs} +16 -14
- package/src/nako_lex_rules.mjs +244 -0
- package/src/{nako_lexer.js → nako_lexer.mjs} +7 -10
- package/src/{nako_logger.js → nako_logger.mjs} +3 -4
- package/src/{nako_parser3.js → nako_parser3.mjs} +5 -5
- package/src/{nako_parser_base.js → nako_parser_base.mjs} +1 -9
- package/src/{nako_parser_const.js → nako_parser_const.mjs} +2 -6
- package/src/{nako_prepare.js → nako_prepare.mjs} +46 -8
- package/src/{nako_reserved_words.js → nako_reserved_words.mjs} +1 -1
- package/src/{nako_source_mapping.js → nako_source_mapping.mjs} +4 -11
- package/src/{nako_test.js → nako_test.mjs} +0 -0
- package/src/nako_version.mjs +7 -0
- package/src/{plugin_browser.js → plugin_browser.mjs} +30 -30
- package/src/{plugin_browser_ajax.js → plugin_browser_ajax.mjs} +7 -7
- package/src/{plugin_browser_audio.js → plugin_browser_audio.mjs} +1 -1
- package/src/{plugin_browser_canvas.js → plugin_browser_canvas.mjs} +1 -1
- package/src/{plugin_browser_chart.js → plugin_browser_chart.mjs} +1 -1
- package/src/{plugin_browser_color.js → plugin_browser_color.mjs} +1 -1
- package/src/{plugin_browser_crypto.js → plugin_browser_crypto.mjs} +1 -1
- package/src/{plugin_browser_dialog.js → plugin_browser_dialog.mjs} +1 -1
- package/src/{plugin_browser_dom_basic.js → plugin_browser_dom_basic.mjs} +1 -1
- package/src/{plugin_browser_dom_event.js → plugin_browser_dom_event.mjs} +1 -1
- package/src/{plugin_browser_dom_parts.js → plugin_browser_dom_parts.mjs} +1 -1
- package/src/{plugin_browser_geolocation.js → plugin_browser_geolocation.mjs} +1 -1
- package/src/{plugin_browser_hotkey.js → plugin_browser_hotkey.mjs} +2 -2
- package/src/{plugin_browser_html.js → plugin_browser_html.mjs} +1 -1
- package/src/{plugin_browser_in_worker.js → plugin_browser_in_worker.mjs} +4 -4
- package/src/{plugin_browser_location.js → plugin_browser_location.mjs} +1 -1
- package/src/{plugin_browser_speech.js → plugin_browser_speech.mjs} +1 -1
- package/src/{plugin_browser_storage.js → plugin_browser_storage.mjs} +1 -1
- package/src/{plugin_browser_system.js → plugin_browser_system.mjs} +1 -1
- package/src/{plugin_browser_websocket.js → plugin_browser_websocket.mjs} +1 -1
- package/src/{plugin_caniuse.js → plugin_caniuse.mjs} +8 -3
- package/src/{plugin_csv.js → plugin_csv.mjs} +4 -5
- package/src/{plugin_datetime.js → plugin_datetime.mjs} +19 -26
- package/src/{plugin_express.js → plugin_express.mjs} +4 -3
- package/src/{plugin_kansuji.js → plugin_kansuji.mjs} +1 -1
- package/src/{plugin_keigo.js → plugin_keigo.mjs} +1 -1
- package/src/{plugin_markup.js → plugin_markup.mjs} +6 -6
- package/src/{plugin_math.js → plugin_math.mjs} +1 -4
- package/src/{plugin_node.js → plugin_node.mjs} +25 -57
- package/src/{plugin_promise.js → plugin_promise.mjs} +1 -3
- package/src/{plugin_system.js → plugin_system.mjs} +32 -15
- package/src/{plugin_test.js → plugin_test.mjs} +1 -3
- package/src/{plugin_turtle.js → plugin_turtle.mjs} +5 -4
- package/src/{plugin_webworker.js → plugin_webworker.mjs} +3 -3
- package/src/{plugin_weykturtle3d.js → plugin_weykturtle3d.mjs} +1 -3
- package/src/{plugin_worker.js → plugin_worker.mjs} +4 -1
- package/src/{wnako3.js → wnako3.mjs} +24 -14
- package/src/{wnako3_editor.js → wnako3_editor.mjs} +28 -22
- package/src/{wnako3webworker.js → wnako3webworker.mjs} +0 -0
- package/test/async/{async_basic_test.js → async_basic_test.mjs} +3 -4
- package/test/browser/karma.config.js +9 -0
- package/test/browser/test/plugin_browser_test.js +2 -2
- package/test/browser/test/plugin_turtle_test.js +2 -2
- package/test/browser/test/plugin_webworker_test.js +3 -3
- package/test/browser/test/require_test.js +2 -2
- package/test/common/{array_test.js → array_test.mjs} +3 -3
- package/test/common/{basic_test.js → basic_test.mjs} +3 -13
- package/test/common/{calc_test.js → calc_test.mjs} +2 -2
- package/test/common/{debug_test.js → debug_test.mjs} +2 -2
- package/test/common/{dncl_test.js → dncl_test.mjs} +3 -3
- package/test/common/{error_test.js → error_test.mjs} +2 -2
- package/test/common/{flow_test.js → flow_test.mjs} +2 -2
- package/test/common/{func_call.js → func_call.mjs} +3 -3
- package/test/common/{func_test.js → func_test.mjs} +2 -2
- package/test/common/{indent_test.js → indent_test.mjs} +3 -2
- package/test/common/{lex_test.js → lex_test.mjs} +2 -2
- package/test/common/{literal_test.js → literal_test.mjs} +3 -2
- package/test/common/{nako_logger_test.js → nako_logger_test.mjs} +3 -3
- package/test/common/{plugin_browser_test.js → plugin_browser_test.mjs} +4 -4
- package/test/common/{plugin_browser_ut_audio_test.js → plugin_browser_ut_audio_test.mjs} +4 -4
- package/test/common/{plugin_browser_ut_color_test.js → plugin_browser_ut_color_test.mjs} +2 -2
- package/test/common/{plugin_browser_ut_dialog_test.js → plugin_browser_ut_dialog_test.mjs} +3 -3
- package/test/common/{plugin_browser_ut_html_test.js → plugin_browser_ut_html_test.mjs} +2 -2
- package/test/common/{plugin_browser_ut_system_test.js → plugin_browser_ut_system_test.mjs} +2 -2
- package/test/common/{plugin_csv_test.js → plugin_csv_test.mjs} +3 -3
- package/test/common/{plugin_datetime_test.js → plugin_datetime_test.mjs} +4 -4
- package/test/common/{plugin_kansuji_test.js → plugin_kansuji_test.mjs} +3 -3
- package/test/common/{plugin_markup_test.js → plugin_markup_test.mjs} +3 -3
- package/test/common/{plugin_promise_test.js → plugin_promise_test.mjs} +2 -2
- package/test/common/{plugin_system_test.js → plugin_system_test.mjs} +2 -2
- package/test/common/{prepare_test.js → prepare_test.mjs} +2 -2
- package/test/common/{re_test.js → re_test.mjs} +2 -2
- package/test/common/{variable_scope_test.js → variable_scope_test.mjs} +2 -2
- package/test/karma.config.js +3 -3
- package/test/node/{async_test.js → async_test.mjs} +4 -2
- package/test/node/{commander_ja_test.js → commander_ja_test.mjs} +17 -12
- package/test/node/{error_message_test.js → error_message_test.mjs} +13 -10
- package/test/node/node_test.mjs +57 -0
- package/test/node/{plugin_browser_ut_ajax_test.js → plugin_browser_ut_ajax_test.mjs} +7 -5
- package/test/node/{plugin_browser_ut_location_test.js → plugin_browser_ut_location_test.mjs} +3 -3
- package/test/node/{plugin_markup_test.js → plugin_markup_test.mjs} +6 -7
- package/test/node/{plugin_math_test.js → plugin_math_test.mjs} +5 -5
- package/test/node/{plugin_node_test.js → plugin_node_test.mjs} +11 -7
- package/test/node/{plugin_test.js → plugin_test.mjs} +11 -5
- package/test/node/{require_nako3_test.js → require_nako3_test.mjs} +19 -12
- package/test/node/{side_effects_test.js → side_effects_test.mjs} +24 -13
- package/test/node/{wnako3_editor_test.js → wnako3_editor_test.mjs} +16 -9
- package/tools/nako3edit/html/daisyui/LICENSE +22 -0
- package/tools/nako3edit/html/daisyui/full.css +1 -0
- package/tools/nako3edit/html/daisyui/tailwind.min.css +1 -0
- package/tools/nako3edit/html/daisyui/version_2.14.1 +1 -0
- package/tools/nako3edit/html/edit.html +104 -19
- package/tools/nako3edit/html/files.html +84 -8
- package/tools/nako3edit/html/nako3edit.css +6 -7
- package/tools/nako3edit/index.nako3 +45 -6
- package/tools/nako3edit/{run.js → run.mjs} +8 -2
- package/src/index.js +0 -5
- package/src/nako_lex_rules.js +0 -260
- package/src/nako_version.js +0 -8
- package/test/node/node_test.js +0 -43
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
// nadesiko for web browser
|
|
3
3
|
// wnako3.js
|
|
4
|
-
require('whatwg-fetch') // IE11サポートが不要になったら外す
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import { NakoCompiler } from './nako3.mjs'
|
|
6
|
+
import { NakoImportError } from './nako_errors.mjs'
|
|
7
|
+
import { setupEditor } from './wnako3_editor.mjs'
|
|
8
|
+
import PluginBrowser from './plugin_browser.mjs'
|
|
9
|
+
|
|
8
10
|
const NAKO_SCRIPT_RE = /^(なでしこ|nako|nadesiko)3?$/
|
|
9
|
-
const { setupEditor } = require('./wnako3_editor')
|
|
10
|
-
const PluginBrowser = require('./plugin_browser')
|
|
11
11
|
|
|
12
12
|
class WebNakoCompiler extends NakoCompiler {
|
|
13
13
|
constructor () {
|
|
@@ -18,7 +18,7 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
18
18
|
/**
|
|
19
19
|
* ブラウザでtype="なでしこ"というスクリプトを得て実行する
|
|
20
20
|
*/
|
|
21
|
-
runNakoScript () {
|
|
21
|
+
async runNakoScript () {
|
|
22
22
|
// スクリプトタグの中身を得る
|
|
23
23
|
let nakoScriptCount = 0
|
|
24
24
|
const scripts = document.querySelectorAll('script')
|
|
@@ -26,7 +26,14 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
26
26
|
const script = scripts[i]
|
|
27
27
|
if (script.type.match(NAKO_SCRIPT_RE)) {
|
|
28
28
|
nakoScriptCount++
|
|
29
|
-
|
|
29
|
+
// URLからスクリプト名を見つける
|
|
30
|
+
const url = (typeof(window.location) == 'object') ? window.location.href : 'url_unknown'
|
|
31
|
+
const fname = `${url}#script${nakoScriptCount}.nako3`
|
|
32
|
+
const code = script.text
|
|
33
|
+
// 依存するライブラリをロード
|
|
34
|
+
await this.loadDependencies(code, fname)
|
|
35
|
+
// プログラムを実行
|
|
36
|
+
this.run(script.text, fname)
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
39
|
console.log('実行したなでしこの個数=', nakoScriptCount)
|
|
@@ -59,11 +66,11 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
59
66
|
value: (async () => {
|
|
60
67
|
const res = await fetch(filePath)
|
|
61
68
|
if (!res.ok) {
|
|
62
|
-
throw new NakoImportError(
|
|
69
|
+
throw new NakoImportError(`ファイル『${filePath}』のダウンロードに失敗しました: ${res.status} ${res.statusText}`, token.file, token.line)
|
|
63
70
|
}
|
|
64
71
|
const text = await res.text()
|
|
65
72
|
if (!text.includes('navigator.nako3.addPluginObject')) {
|
|
66
|
-
throw new NakoImportError(`ファイル ${filePath} の中に文字列 "navigator.nako3.addPluginObject" が存在しません。現在、ブラウザ版のなでしこ言語v3は自動登録するプラグインのみをサポートしています。`, token.
|
|
73
|
+
throw new NakoImportError(`ファイル ${filePath} の中に文字列 "navigator.nako3.addPluginObject" が存在しません。現在、ブラウザ版のなでしこ言語v3は自動登録するプラグインのみをサポートしています。`, token.file, token.line)
|
|
67
74
|
}
|
|
68
75
|
// textの例: `navigator.nako3.addPluginObject('PluginRequireTest', { requiretest: { type: 'var', value: 100 } })`
|
|
69
76
|
return () => {
|
|
@@ -74,7 +81,7 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
74
81
|
// eslint-disable-next-line no-new-func
|
|
75
82
|
Function(text)()
|
|
76
83
|
} catch (err) {
|
|
77
|
-
throw new NakoImportError(`プラグイン ${filePath} の取り込みに失敗: ${err instanceof Error ? err.message : err + ''}`, token.
|
|
84
|
+
throw new NakoImportError(`プラグイン ${filePath} の取り込みに失敗: ${err instanceof Error ? err.message : err + ''}`, token.file, token.line)
|
|
78
85
|
} finally {
|
|
79
86
|
navigator.nako3 = globalNako3
|
|
80
87
|
}
|
|
@@ -93,7 +100,7 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
93
100
|
value: (async () => {
|
|
94
101
|
const res = await fetch(filePath)
|
|
95
102
|
if (!res.ok) {
|
|
96
|
-
throw new NakoImportError(`ファイル ${filePath} のダウンロードに失敗しました: ${res.status} ${res.statusText}`, token.
|
|
103
|
+
throw new NakoImportError(`ファイル ${filePath} のダウンロードに失敗しました: ${res.status} ${res.statusText}`, token.file, token.line)
|
|
97
104
|
}
|
|
98
105
|
return await res.text()
|
|
99
106
|
})()
|
|
@@ -114,17 +121,20 @@ class WebNakoCompiler extends NakoCompiler {
|
|
|
114
121
|
const href = href_dir + '/' + name
|
|
115
122
|
pathname = new URL(href).pathname
|
|
116
123
|
} catch (e) {
|
|
117
|
-
throw new NakoImportError(`取り込み文の引数でパスが解決できません。https:// か http:// で始まるアドレスを指定してください。\n${e}`, token.
|
|
124
|
+
throw new NakoImportError(`取り込み文の引数でパスが解決できません。https:// か http:// で始まるアドレスを指定してください。\n${e}`, token.file, token.line)
|
|
118
125
|
}
|
|
119
126
|
}
|
|
120
127
|
}
|
|
121
|
-
|
|
128
|
+
// .js および .mjs なら JSプラグイン
|
|
129
|
+
if (pathname.endsWith('.js') || pathname.endsWith('.js.txt') || pathname.endsWith('.mjs') || pathname.endsWith('.mjs.txt')) {
|
|
122
130
|
return { filePath: name, type: 'js' }
|
|
123
131
|
}
|
|
132
|
+
// .nako3 なら なでしこ3プラグイン
|
|
124
133
|
if (pathname.endsWith('.nako3') || pathname.endsWith('.nako3.txt')) {
|
|
125
134
|
return { filePath: name, type: 'nako3' }
|
|
126
135
|
}
|
|
127
|
-
|
|
136
|
+
// ファイル拡張子が未指定の場合
|
|
137
|
+
throw new NakoImportError(`ファイル『${name}』は拡張子が(.nako3|.js|.js.txt|.mjs|.mjs.txt)以外なので取り込めません。`, token.file, token.line)
|
|
128
138
|
}
|
|
129
139
|
})
|
|
130
140
|
}
|
|
@@ -2,11 +2,17 @@
|
|
|
2
2
|
/* eslint-disable no-template-curly-in-string */
|
|
3
3
|
/** なでしこのtokenのtypeをscope(CSSのクラス名)に変換する。 */
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
import { OffsetToLineColumn } from './nako_source_mapping.mjs'
|
|
6
|
+
import { NakoError } from './nako_errors.mjs'
|
|
7
|
+
import NakoIndent from './nako_indent.mjs'
|
|
8
|
+
import { NakoPrepare } from './nako_prepare.mjs'
|
|
9
|
+
import { NakoLogger } from './nako_logger.mjs'
|
|
10
|
+
|
|
11
|
+
// alias
|
|
12
|
+
const getBlockStructure = NakoIndent.getBlockStructure
|
|
13
|
+
const getIndent = NakoIndent.getIndent
|
|
14
|
+
const countIndent = NakoIndent.countIndent
|
|
15
|
+
const isIndentSyntaxEnabled = NakoIndent.isIndentSyntaxEnabled
|
|
10
16
|
|
|
11
17
|
/**
|
|
12
18
|
* @typedef {import('./nako3')} NakoCompiler
|
|
@@ -69,7 +75,7 @@ const NakoLogger = require('./nako_logger')
|
|
|
69
75
|
* @param {TokenWithSourceMap} token
|
|
70
76
|
* @returns {TokenType}
|
|
71
77
|
*/
|
|
72
|
-
function getScope (token) {
|
|
78
|
+
export function getScope (token) {
|
|
73
79
|
switch (token.type) {
|
|
74
80
|
case 'line_comment': return 'comment.line'
|
|
75
81
|
case 'range_comment': return 'comment.block'
|
|
@@ -154,7 +160,7 @@ function getScope (token) {
|
|
|
154
160
|
* @param {boolean} includesLastCharacter
|
|
155
161
|
* @param {boolean} underlineJosi
|
|
156
162
|
*/
|
|
157
|
-
function getEditorTokens (compilerToken, nako3, value, includesLastCharacter, underlineJosi) {
|
|
163
|
+
export function getEditorTokens (compilerToken, nako3, value, includesLastCharacter, underlineJosi) {
|
|
158
164
|
const type = getScope(compilerToken)
|
|
159
165
|
const docHTML = getDocumentationHTML(compilerToken, nako3)
|
|
160
166
|
|
|
@@ -177,7 +183,7 @@ function getEditorTokens (compilerToken, nako3, value, includesLastCharacter, un
|
|
|
177
183
|
* @param {NakoCompiler} nako3
|
|
178
184
|
* @returns {string | null}
|
|
179
185
|
*/
|
|
180
|
-
function findPluginName (name, nako3) {
|
|
186
|
+
export function findPluginName (name, nako3) {
|
|
181
187
|
for (const pluginName of Object.keys(nako3.__module)) {
|
|
182
188
|
if (Object.keys(nako3.__module[pluginName]).includes(name)) {
|
|
183
189
|
return pluginName
|
|
@@ -191,7 +197,7 @@ function findPluginName (name, nako3) {
|
|
|
191
197
|
* @param {number} i
|
|
192
198
|
* @returns {string}
|
|
193
199
|
*/
|
|
194
|
-
function createParameterName (i) {
|
|
200
|
+
export function createParameterName (i) {
|
|
195
201
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
|
|
196
202
|
return i.toString(26).split('').map((v) => alphabet[parseInt(v, 26)]).join('')
|
|
197
203
|
}
|
|
@@ -201,7 +207,7 @@ function createParameterName (i) {
|
|
|
201
207
|
* @param {string[][]} josi
|
|
202
208
|
* @retunrs {string}
|
|
203
209
|
*/
|
|
204
|
-
function createParameterDeclaration (josi) {
|
|
210
|
+
export function createParameterDeclaration (josi) {
|
|
205
211
|
const args = josi.map((union, i) => union.map((v) => `${createParameterName(i)}${v}`).join('|')).join('、')
|
|
206
212
|
if (args !== '') {
|
|
207
213
|
return `(${args})`
|
|
@@ -212,7 +218,7 @@ function createParameterDeclaration (josi) {
|
|
|
212
218
|
|
|
213
219
|
// https://stackoverflow.com/a/6234804
|
|
214
220
|
/** @param {string} t */
|
|
215
|
-
function escapeHTML (t) {
|
|
221
|
+
export function escapeHTML (t) {
|
|
216
222
|
return t
|
|
217
223
|
.replace(/&/g, '&')
|
|
218
224
|
.replace(/</g, '<')
|
|
@@ -227,7 +233,7 @@ function escapeHTML (t) {
|
|
|
227
233
|
* @param {NakoCompiler} nako3
|
|
228
234
|
* @returns {string | null}
|
|
229
235
|
*/
|
|
230
|
-
function getDocumentationHTML (token, nako3) {
|
|
236
|
+
export function getDocumentationHTML (token, nako3) {
|
|
231
237
|
/** @param {string} text */
|
|
232
238
|
const meta = (text) => `<span class="tooltip-plugin-name">${escapeHTML(text)}</span>`
|
|
233
239
|
if (token.type === 'func') {
|
|
@@ -277,7 +283,7 @@ const withoutLogger = (nako3, f) => {
|
|
|
277
283
|
* @param {NakoCompiler} nako3
|
|
278
284
|
* @param {boolean} underlineJosi
|
|
279
285
|
*/
|
|
280
|
-
function tokenize (lines, nako3, underlineJosi) {
|
|
286
|
+
export function tokenize (lines, nako3, underlineJosi) {
|
|
281
287
|
const code = lines.join('\n')
|
|
282
288
|
|
|
283
289
|
// 取り込み文を含めてしまうと依存ファイルが大きい時に時間がかかってしまうため、
|
|
@@ -399,7 +405,7 @@ function tokenize (lines, nako3, underlineJosi) {
|
|
|
399
405
|
/**
|
|
400
406
|
* エディタ上にエラーメッセージの波線とgutterの赤いマークとエラーメッセージのポップアップを設定するためのクラス。
|
|
401
407
|
*/
|
|
402
|
-
class EditorMarkers {
|
|
408
|
+
export class EditorMarkers {
|
|
403
409
|
/**
|
|
404
410
|
* @param {any} session
|
|
405
411
|
* @param {AceDocument} doc
|
|
@@ -521,7 +527,7 @@ class EditorMarkers {
|
|
|
521
527
|
* ace editor ではシンタックスハイライトのために正規表現ベースのBackgroundTokenizerクラスを用意し定期的にトークン化を
|
|
522
528
|
* 行っているが、正規表現ではなくなでしこのコンパイラの出力を使うためにはそれを上書きする必要がある。
|
|
523
529
|
*/
|
|
524
|
-
class BackgroundTokenizer {
|
|
530
|
+
export class BackgroundTokenizer {
|
|
525
531
|
/**
|
|
526
532
|
* @param {AceDocument} doc
|
|
527
533
|
* @param {NakoCompiler} nako3
|
|
@@ -699,7 +705,7 @@ class BackgroundTokenizer {
|
|
|
699
705
|
/**
|
|
700
706
|
* シンタックスハイライト以外のエディタの挙動の定義。
|
|
701
707
|
*/
|
|
702
|
-
class LanguageFeatures {
|
|
708
|
+
export class LanguageFeatures {
|
|
703
709
|
/**
|
|
704
710
|
* @param {TypeofAceRange} AceRange
|
|
705
711
|
* @param {NakoCompiler} nako3
|
|
@@ -717,7 +723,7 @@ class LanguageFeatures {
|
|
|
717
723
|
* @param {number} endRow
|
|
718
724
|
*/
|
|
719
725
|
static toggleCommentLines (state, { doc }, startRow, endRow) {
|
|
720
|
-
const prepare =
|
|
726
|
+
const prepare = NakoPrepare.getInstance(new NakoLogger())
|
|
721
727
|
/**
|
|
722
728
|
* @param {string} line
|
|
723
729
|
* @returns {{ type: 'blank' | 'code' } | { type: 'comment', start: number, len: number }}
|
|
@@ -728,11 +734,11 @@ class LanguageFeatures {
|
|
|
728
734
|
if (indent === line) {
|
|
729
735
|
return { type: 'blank' }
|
|
730
736
|
}
|
|
731
|
-
line = line.
|
|
737
|
+
line = line.substring(indent.length)
|
|
732
738
|
|
|
733
739
|
// 先頭がコメントの開始文字かどうか確認する
|
|
734
|
-
const ch2 = line.
|
|
735
|
-
if (ch2.
|
|
740
|
+
const ch2 = line.substring(0, 2).split('').map((c) => prepare.convert1ch(c)).join('')
|
|
741
|
+
if (ch2.substring(0, 1) === '#') {
|
|
736
742
|
return { type: 'comment', start: indent.length, len: 1 + (line.charAt(1) === ' ' ? 1 : 0) }
|
|
737
743
|
}
|
|
738
744
|
if (ch2 === '//') {
|
|
@@ -1287,7 +1293,7 @@ let editorIdCounter = 0
|
|
|
1287
1293
|
* @param {import('./wnako3')} nako3
|
|
1288
1294
|
* @param {any} ace
|
|
1289
1295
|
*/
|
|
1290
|
-
function setupEditor (idOrElement, nako3, ace) {
|
|
1296
|
+
export function setupEditor (idOrElement, nako3, ace) {
|
|
1291
1297
|
/** @type {AceEditor} */
|
|
1292
1298
|
const editor = ace.edit(idOrElement)
|
|
1293
1299
|
const element = typeof idOrElement === 'string' ? document.getElementById(idOrElement) : idOrElement
|
|
@@ -1636,7 +1642,7 @@ function setupEditor (idOrElement, nako3, ace) {
|
|
|
1636
1642
|
return { editor, editorMarkers, editorTabs, retokenize, run, codeLensListeners }
|
|
1637
1643
|
}
|
|
1638
1644
|
|
|
1639
|
-
|
|
1645
|
+
export default {
|
|
1640
1646
|
tokenize,
|
|
1641
1647
|
setupEditor,
|
|
1642
1648
|
LanguageFeatures,
|
|
File without changes
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import { NakoGenASync } from '../../src/nako_gen_async.mjs'
|
|
4
4
|
|
|
5
5
|
describe('aysnc_basic_test', () => {
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
const nako = new NakoCompiler()
|
|
8
|
-
nako.addCodeGenerator('非同期モード', NakoGenAsync)
|
|
9
8
|
const cmp = (/** @type {string} */code, /** @type {string} */res) => {
|
|
10
9
|
code = '!非同期モード\n' + code
|
|
11
10
|
nako.logger.debug('code=' + code)
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
import express from 'express'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import multer from 'multer'
|
|
5
|
+
import bodyParserRaw from 'body-parser/lib/types/raw.js'
|
|
6
|
+
import bodyParserText from 'body-parser/lib/types/text.js'
|
|
7
|
+
import bodyParserUrlencoded =from 'body-parser/lib/types/urlencoded.js'
|
|
8
|
+
*/
|
|
9
|
+
|
|
1
10
|
const multer = require('multer')
|
|
2
11
|
const bodyParserRaw = require('body-parser/lib/types/raw')
|
|
3
12
|
const bodyParserText = require('body-parser/lib/types/text')
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'whatwg-fetch'
|
|
2
|
-
import NakoCompiler from 'nako3/nako3.
|
|
3
|
-
import PluginBrowser from 'nako3/plugin_browser.
|
|
2
|
+
import { NakoCompiler } from 'nako3/nako3.mjs'
|
|
3
|
+
import PluginBrowser from 'nako3/plugin_browser.mjs'
|
|
4
4
|
|
|
5
5
|
import browserTestColor from './plugin_browser_test_color.js'
|
|
6
6
|
import browserTestSystem from './plugin_browser_test_system.js'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/* global __html__ */
|
|
2
2
|
import { assert } from 'chai'
|
|
3
|
-
import NakoCompiler from 'nako3/nako3.
|
|
3
|
+
import { NakoCompiler } from 'nako3/nako3.mjs'
|
|
4
4
|
import { importStatus } from './import_plugin_checker.js'
|
|
5
|
-
import PluginTurtle from 'nako3/plugin_turtle'
|
|
5
|
+
import PluginTurtle from 'nako3/plugin_turtle.mjs'
|
|
6
6
|
|
|
7
7
|
const htmlPath = 'test/html/'
|
|
8
8
|
const imagePath = '/test/image/'
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import 'whatwg-fetch'
|
|
2
2
|
import { assert } from 'chai'
|
|
3
|
-
import NakoCompiler from 'nako3/nako3.
|
|
4
|
-
import PluginBrowser from 'nako3/plugin_browser'
|
|
3
|
+
import { NakoCompiler } from 'nako3/nako3.mjs'
|
|
4
|
+
import PluginBrowser from 'nako3/plugin_browser.mjs'
|
|
5
5
|
import { importStatus } from './import_plugin_checker.js'
|
|
6
|
-
import PluginWebWorker from 'nako3/plugin_webworker'
|
|
6
|
+
import PluginWebWorker from 'nako3/plugin_webworker.mjs'
|
|
7
7
|
import { retry } from './compare_util'
|
|
8
8
|
|
|
9
9
|
describe('plugin_webworker_test', () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { assert } from 'chai'
|
|
2
|
-
import { NakoImportError } from 'nako3/nako_errors'
|
|
2
|
+
import { NakoImportError } from 'nako3/nako_errors.mjs'
|
|
3
3
|
|
|
4
4
|
navigator.exportWNako3 = true
|
|
5
|
-
const WebNakoCompiler = require('nako3/wnako3')
|
|
5
|
+
const WebNakoCompiler = require('nako3/wnako3.mjs')
|
|
6
6
|
navigator.exportWNako3 = false
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import { expect } from 'chai'
|
|
4
4
|
|
|
5
5
|
describe('array_test', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import { expect } from 'chai'
|
|
4
4
|
|
|
5
5
|
describe('basic', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|
|
@@ -255,16 +255,6 @@ describe('basic', () => {
|
|
|
255
255
|
, 'main.nako3')
|
|
256
256
|
assert.strictEqual(log, '')
|
|
257
257
|
})
|
|
258
|
-
it('単独で実行できるプログラムの出力', function (done) {
|
|
259
|
-
if (typeof process === 'undefined' || process.env.NODE_ENV === 'test') {return this.skip()}
|
|
260
|
-
const code = nako.compileStandalone('1+2を表示', 'main.nako3', false)
|
|
261
|
-
Function('const console = { log: this.callback };\n' + code).apply({
|
|
262
|
-
callback: (/** @type {any} */text) => {
|
|
263
|
-
assert.strictEqual(text, '3')
|
|
264
|
-
done()
|
|
265
|
-
},
|
|
266
|
-
})
|
|
267
|
-
})
|
|
268
258
|
it('resetされた後に関数名を取得できない問題の修正 #849', (done) => {
|
|
269
259
|
const nako = new NakoCompiler()
|
|
270
260
|
nako.logger.addListener('stdout', ({ noColor }) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import { NakoDncl } from '../../src/nako_from_dncl.mjs'
|
|
4
4
|
|
|
5
5
|
describe('dncl (#1140)', () => {
|
|
6
6
|
const cmp = (src, expected) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import { NakoSyntaxError } from '../../src/nako_errors.mjs'
|
|
4
4
|
|
|
5
5
|
describe('関数呼び出しテスト', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import NakoIndent from '../../src/nako_indent.mjs'
|
|
3
4
|
|
|
4
5
|
describe('indent', () => {
|
|
5
6
|
const cmp = (src, expected) => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
|
|
3
4
|
describe('literal_test', () => {
|
|
4
5
|
const nako = new NakoCompiler()
|
|
5
6
|
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoColors } from '../../src/nako_colors.mjs'
|
|
3
|
+
import { NakoLogger } from '../../src/nako_logger.mjs'
|
|
4
4
|
|
|
5
5
|
describe('nako_logger_test', () => {
|
|
6
6
|
it('色付けのテスト', () => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
4
4
|
|
|
5
5
|
describe('plugin_browser_test', () => {
|
|
6
|
-
const nako = new NakoCompiler()
|
|
6
|
+
const nako = new NakoCompiler({useBasicPlugin: true})
|
|
7
7
|
// nako.logger.addListener('trace', ({ browserConsole }) => { console.log(...browserConsole) })
|
|
8
8
|
nako.addPluginFile('PluginBrowser', 'plugin_browser.js', PluginBrowser)
|
|
9
9
|
const cmp = (code, res) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import * as td from 'testdouble'
|
|
2
|
+
import assert from 'assert'
|
|
3
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
4
|
+
import { PluginUtHelper } from '../../utils/plugin_ut_helper.js'
|
|
5
5
|
|
|
6
6
|
class StubAudio {
|
|
7
7
|
contructor () {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
2
|
+
import { PluginUtHelper } from '../../utils/plugin_ut_helper.js'
|
|
3
3
|
|
|
4
4
|
describe('plugin_browser_color', () => {
|
|
5
5
|
const cu = new PluginUtHelper(PluginBrowser)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import * as td from 'testdouble'
|
|
2
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
3
|
+
import assert from 'assert'
|
|
4
4
|
|
|
5
5
|
describe('plugin_browser_dialog', () => {
|
|
6
6
|
describe('言う', () => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
2
|
+
import { PluginUtHelper } from '../../utils/plugin_ut_helper.js'
|
|
3
3
|
|
|
4
4
|
describe('plugin_browser_html', () => {
|
|
5
5
|
const cu = new PluginUtHelper(PluginBrowser)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import PluginBrowser from '../../src/plugin_browser.mjs'
|
|
2
|
+
import { PluginUtHelper } from '../../utils/plugin_ut_helper.js'
|
|
3
3
|
|
|
4
4
|
describe('plugin_browser_system', () => {
|
|
5
5
|
const cu = new PluginUtHelper(PluginBrowser)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import PluginCSV from '../../src/plugin_csv.mjs'
|
|
4
4
|
|
|
5
5
|
describe('plugin_csv_test', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import {NakoRuntimeError} from '../../src/nako_errors.mjs'
|
|
4
|
+
import PluginDateTime from '../../src/plugin_datetime.mjs'
|
|
5
5
|
|
|
6
6
|
describe('plugin_datetime_test', () => {
|
|
7
7
|
const nako = new NakoCompiler()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import PluginKansuji from '../../src/plugin_kansuji.mjs'
|
|
4
4
|
|
|
5
5
|
describe('plugin_kansuji_test', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { NakoCompiler } from '../../src/nako3.mjs'
|
|
3
|
+
import PluginMarkup from '../../src/plugin_markup.mjs'
|
|
4
4
|
|
|
5
5
|
describe('plugin_markup_test', () => {
|
|
6
6
|
const nako = new NakoCompiler()
|