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
package/src/cnako3.mts
CHANGED
package/src/cnako3mod.mjs
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-redundant-type-constituents */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
3
1
|
// deno-lint-ignore-file no-explicit-any
|
|
4
2
|
/**
|
|
5
3
|
* コマンドライン版のなでしこ3をモジュールとして定義
|
|
6
4
|
* 実際には cnako3.mjs から読み込まれる
|
|
7
5
|
*/
|
|
8
6
|
import fs from 'node:fs';
|
|
9
|
-
import fse from 'fs-extra';
|
|
10
7
|
import { exec } from 'node:child_process';
|
|
11
8
|
import path from 'node:path';
|
|
9
|
+
import url from 'node:url';
|
|
10
|
+
import fse from 'fs-extra';
|
|
11
|
+
import fetch from 'node-fetch';
|
|
12
12
|
import { NakoCompiler, newCompilerOptions } from '../core/src/nako3.mjs';
|
|
13
13
|
import { NakoImportError } from '../core/src/nako_errors.mjs';
|
|
14
|
+
import { NakoGenOptions } from '../core/src/nako_gen.mjs';
|
|
14
15
|
import nakoVersion from './nako_version.mjs';
|
|
15
16
|
import PluginNode from './plugin_node.mjs';
|
|
16
17
|
import app from './commander_ja.mjs';
|
|
17
|
-
import fetch from 'node-fetch';
|
|
18
|
-
import { NakoGenOptions } from '../core/src/nako_gen.mjs';
|
|
19
18
|
import { getEnv, isWindows, getCommandLineArgs, exit } from './deno_wrapper.mjs';
|
|
20
19
|
// __dirname のために
|
|
21
|
-
import url from 'node:url';
|
|
22
20
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
23
21
|
const __dirname = path.dirname(__filename);
|
|
24
22
|
/** CNako3 */
|
|
@@ -569,7 +567,6 @@ export class CNako3 extends NakoCompiler {
|
|
|
569
567
|
const b = !!(stat && stat.isFile());
|
|
570
568
|
cachePath[f] = b;
|
|
571
569
|
return b;
|
|
572
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
573
570
|
}
|
|
574
571
|
catch (_) {
|
|
575
572
|
return false;
|
package/src/cnako3mod.mts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
|
|
2
|
+
|
|
3
3
|
// deno-lint-ignore-file no-explicit-any
|
|
4
4
|
/**
|
|
5
5
|
* コマンドライン版のなでしこ3をモジュールとして定義
|
|
6
6
|
* 実際には cnako3.mjs から読み込まれる
|
|
7
7
|
*/
|
|
8
8
|
import fs from 'node:fs'
|
|
9
|
-
import fse from 'fs-extra'
|
|
10
9
|
import { exec } from 'node:child_process'
|
|
11
10
|
import path from 'node:path'
|
|
11
|
+
import url from 'node:url'
|
|
12
|
+
import fse from 'fs-extra'
|
|
12
13
|
|
|
14
|
+
import fetch from 'node-fetch'
|
|
13
15
|
import { NakoCompiler, LoaderTool, newCompilerOptions } from '../core/src/nako3.mjs'
|
|
14
16
|
import { NakoImportError } from '../core/src/nako_errors.mjs'
|
|
15
17
|
|
|
16
18
|
import { Ast, CompilerOptions } from '../core/src/nako_types.mjs'
|
|
17
19
|
import { NakoGlobal } from '../core/src/nako_global.mjs'
|
|
20
|
+
import { NakoGenOptions } from '../core/src/nako_gen.mjs'
|
|
18
21
|
import nakoVersion from './nako_version.mjs'
|
|
19
22
|
|
|
20
23
|
import PluginNode from './plugin_node.mjs'
|
|
21
24
|
import app from './commander_ja.mjs'
|
|
22
|
-
import fetch from 'node-fetch'
|
|
23
25
|
|
|
24
|
-
import { NakoGenOptions } from '../core/src/nako_gen.mjs'
|
|
25
26
|
|
|
26
27
|
import { getEnv, isWindows, getCommandLineArgs, exit } from './deno_wrapper.mjs'
|
|
27
28
|
|
|
28
29
|
// __dirname のために
|
|
29
|
-
import url from 'node:url'
|
|
30
30
|
const __filename = url.fileURLToPath(import.meta.url)
|
|
31
31
|
const __dirname = path.dirname(__filename)
|
|
32
32
|
|
|
@@ -57,7 +57,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
57
57
|
debug: boolean
|
|
58
58
|
version: string
|
|
59
59
|
|
|
60
|
-
constructor
|
|
60
|
+
constructor(opts:CNako3Options = { nostd: false }) {
|
|
61
61
|
super({ useBasicPlugin: !opts.nostd })
|
|
62
62
|
this.debug = false
|
|
63
63
|
this.filename = 'main.nako3'
|
|
@@ -73,7 +73,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
// CNAKO3で使えるコマンドを登録する
|
|
76
|
-
registerCommands
|
|
76
|
+
registerCommands() {
|
|
77
77
|
// コマンドライン引数を得る
|
|
78
78
|
const args: string[] = getCommandLineArgs()
|
|
79
79
|
// コマンド引数がないならば、ヘルプを表示(-hはcommandarにデフォルト用意されている)
|
|
@@ -108,7 +108,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
108
108
|
}
|
|
109
109
|
|
|
110
110
|
/** コマンドライン引数を解析 */
|
|
111
|
-
checkArguments
|
|
111
|
+
checkArguments(): CNako3ArgOptions {
|
|
112
112
|
const app: any = this.registerCommands()
|
|
113
113
|
|
|
114
114
|
let logLevel = 'error'
|
|
@@ -166,7 +166,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
// 実行する
|
|
169
|
-
async execCommand
|
|
169
|
+
async execCommand() {
|
|
170
170
|
// コマンドを解析
|
|
171
171
|
const opt: CNako3ArgOptions = this.checkArguments()
|
|
172
172
|
// 使い方の表示か?
|
|
@@ -247,7 +247,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
247
247
|
/**
|
|
248
248
|
* コンパイルモードの場合
|
|
249
249
|
*/
|
|
250
|
-
async nakoCompile
|
|
250
|
+
async nakoCompile(opt: any, src: string, isTest: boolean) {
|
|
251
251
|
// 依存ライブラリなどを読み込む
|
|
252
252
|
await this.loadDependencies(src, this.filename, '')
|
|
253
253
|
// JSにコンパイル
|
|
@@ -300,7 +300,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
300
300
|
}
|
|
301
301
|
|
|
302
302
|
if (opt.run) {
|
|
303
|
-
exec(`node ${opt.output}`, function
|
|
303
|
+
exec(`node ${opt.output}`, function(err, stdout, stderr) {
|
|
304
304
|
if (err) { console.log('[ERROR]', stderr) }
|
|
305
305
|
console.log(stdout)
|
|
306
306
|
})
|
|
@@ -308,7 +308,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
// ワンライナーの場合
|
|
311
|
-
async cnakoOneLiner
|
|
311
|
+
async cnakoOneLiner(opt: any) {
|
|
312
312
|
const org = opt.source
|
|
313
313
|
try {
|
|
314
314
|
if (opt.source.indexOf('表示') < 0) {
|
|
@@ -336,7 +336,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
336
336
|
/**
|
|
337
337
|
* JSONを出力
|
|
338
338
|
*/
|
|
339
|
-
outputJSON
|
|
339
|
+
outputJSON(ast: any, level: number): string {
|
|
340
340
|
const makeIndent = (level: number) => {
|
|
341
341
|
let s = ''
|
|
342
342
|
for (let i = 0; i < level; i++) { s += ' ' }
|
|
@@ -374,20 +374,20 @@ export class CNako3 extends NakoCompiler {
|
|
|
374
374
|
/**
|
|
375
375
|
* ASTを出力
|
|
376
376
|
*/
|
|
377
|
-
outputAST
|
|
377
|
+
outputAST(opt: any, src: string) {
|
|
378
378
|
const ast = this.parse(src, opt.mainfile)
|
|
379
379
|
console.log(this.outputJSON(ast, 0))
|
|
380
380
|
}
|
|
381
381
|
|
|
382
382
|
// REPL(対話実行環境)の場合
|
|
383
|
-
async cnakoRepl
|
|
383
|
+
async cnakoRepl() {
|
|
384
384
|
const fname = path.join(__dirname, 'repl.nako3')
|
|
385
385
|
const src = fs.readFileSync(fname, 'utf-8')
|
|
386
386
|
await this.runAsync(src, 'main.nako3')
|
|
387
387
|
}
|
|
388
388
|
|
|
389
389
|
// マニュアルを表示する
|
|
390
|
-
cnakoMan
|
|
390
|
+
cnakoMan(command: string) {
|
|
391
391
|
try {
|
|
392
392
|
const pathCommands = path.join(__dirname, '../release/command_cnako3.json')
|
|
393
393
|
const commands = JSON.parse(fs.readFileSync(pathCommands, 'utf-8'))
|
|
@@ -405,13 +405,13 @@ export class CNako3 extends NakoCompiler {
|
|
|
405
405
|
}
|
|
406
406
|
|
|
407
407
|
// 対応機器/Webブラウザを表示する
|
|
408
|
-
cnakoBrowsers
|
|
408
|
+
cnakoBrowsers() {
|
|
409
409
|
const fileMD = path.resolve(__dirname, '../doc', 'browsers.md')
|
|
410
410
|
console.log(fs.readFileSync(fileMD, 'utf-8'))
|
|
411
411
|
}
|
|
412
412
|
|
|
413
413
|
// (js|nako3) loader
|
|
414
|
-
getLoaderTools
|
|
414
|
+
getLoaderTools() {
|
|
415
415
|
/** @type {string[]} */
|
|
416
416
|
const log: string[] = []
|
|
417
417
|
const tools: LoaderTool = {
|
|
@@ -452,7 +452,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
452
452
|
// ファイルかHTTPか
|
|
453
453
|
if (name.startsWith('http://') || name.startsWith('https://')) {
|
|
454
454
|
// Webのファイルを非同期で読み込む
|
|
455
|
-
loader.task = (async
|
|
455
|
+
loader.task = (async() => {
|
|
456
456
|
const res = await fetch(name)
|
|
457
457
|
if (!res.ok) {
|
|
458
458
|
throw new NakoImportError(`『${name}』からのダウンロードに失敗しました: ${res.status} ${res.statusText}`, token.file, token.line)
|
|
@@ -561,7 +561,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
561
561
|
}
|
|
562
562
|
|
|
563
563
|
/** 『!「xxx」を取込』の処理 */
|
|
564
|
-
async loadDependencies
|
|
564
|
+
async loadDependencies(code: string, filename: string, preCode: string) {
|
|
565
565
|
const tools = this.getLoaderTools()
|
|
566
566
|
await super._loadDependencies(code, filename, preCode, tools)
|
|
567
567
|
}
|
|
@@ -569,7 +569,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
569
569
|
/**
|
|
570
570
|
* 非同期でなでしこのコードを実行する
|
|
571
571
|
*/
|
|
572
|
-
async runAsync
|
|
572
|
+
async runAsync(code: string, fname: string, options: CompilerOptions|undefined = undefined): Promise<NakoGlobal> {
|
|
573
573
|
// オプション
|
|
574
574
|
const opt = newCompilerOptions(options)
|
|
575
575
|
// 取り込む文
|
|
@@ -586,7 +586,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
586
586
|
* @param log
|
|
587
587
|
* @return フルパス、失敗した時は、''を返す
|
|
588
588
|
*/
|
|
589
|
-
static findJSPluginFile
|
|
589
|
+
static findJSPluginFile(pname: string, filename: string, srcDir: string, log: string[] = []): string {
|
|
590
590
|
log.length = 0
|
|
591
591
|
const cachePath: {[key: string]: boolean} = {}
|
|
592
592
|
/** キャッシュ付きでファイルがあるか検索 */
|
|
@@ -599,7 +599,7 @@ export class CNako3 extends NakoCompiler {
|
|
|
599
599
|
const b = !!(stat && stat.isFile())
|
|
600
600
|
cachePath[f] = b
|
|
601
601
|
return b
|
|
602
|
-
|
|
602
|
+
|
|
603
603
|
} catch (_: any) {
|
|
604
604
|
return false
|
|
605
605
|
}
|
package/src/commander_ja.mts
CHANGED
|
@@ -7,7 +7,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
7
7
|
_usage: '',
|
|
8
8
|
_version: '1.0.0',
|
|
9
9
|
_title: '',
|
|
10
|
-
reset: function
|
|
10
|
+
reset: function() {
|
|
11
11
|
this.args = []
|
|
12
12
|
this._alias = {}
|
|
13
13
|
this._hasarg = {}
|
|
@@ -22,7 +22,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
22
22
|
* @param {*} ver version info
|
|
23
23
|
* @param {*} cmd -v, --version
|
|
24
24
|
*/
|
|
25
|
-
version
|
|
25
|
+
version(ver: string, cmd: string) {
|
|
26
26
|
this.option(cmd, 'バージョン情報を表示')
|
|
27
27
|
this._version = ver
|
|
28
28
|
return this
|
|
@@ -30,14 +30,14 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
30
30
|
/**
|
|
31
31
|
* @param {string} title
|
|
32
32
|
*/
|
|
33
|
-
title
|
|
33
|
+
title(title: string) {
|
|
34
34
|
this._title = title
|
|
35
35
|
return this
|
|
36
36
|
},
|
|
37
37
|
/**
|
|
38
38
|
* @param {string} usage
|
|
39
39
|
*/
|
|
40
|
-
usage
|
|
40
|
+
usage(usage: string) {
|
|
41
41
|
this._usage = usage
|
|
42
42
|
return this
|
|
43
43
|
},
|
|
@@ -45,7 +45,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
45
45
|
* @param {string} cmd
|
|
46
46
|
* @param {string} desc
|
|
47
47
|
*/
|
|
48
|
-
option
|
|
48
|
+
option(cmd: string, desc: string) {
|
|
49
49
|
this._help.push([cmd, desc])
|
|
50
50
|
let name1 = ''
|
|
51
51
|
const name2: any = /** @type {string[]} */([])
|
|
@@ -80,7 +80,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
80
80
|
* @param {string[]} argv
|
|
81
81
|
* @return {string}
|
|
82
82
|
*/
|
|
83
|
-
parseStr
|
|
83
|
+
parseStr(argv: string[]): string {
|
|
84
84
|
this.args = []
|
|
85
85
|
const paramStack: string[] = []
|
|
86
86
|
let lastOpt = ''
|
|
@@ -133,7 +133,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
133
133
|
* parse
|
|
134
134
|
* @param {*} argv
|
|
135
135
|
*/
|
|
136
|
-
parse
|
|
136
|
+
parse(argv: any) {
|
|
137
137
|
const s = this.parseStr(argv)
|
|
138
138
|
if (s === '') {
|
|
139
139
|
return this
|
|
@@ -147,7 +147,7 @@ const CommanderJa: {[key: string]: any} = {
|
|
|
147
147
|
}
|
|
148
148
|
},
|
|
149
149
|
|
|
150
|
-
getHelp
|
|
150
|
+
getHelp() {
|
|
151
151
|
let ss = ''
|
|
152
152
|
if (this._title) {
|
|
153
153
|
ss += this._title + '\n'
|
package/src/deno_wrapper.mjs
CHANGED
package/src/deno_wrapper.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
2
|
|
|
3
3
|
/** get environment name */
|
|
4
|
-
export function getEnv
|
|
4
|
+
export function getEnv(name: string): string | undefined {
|
|
5
5
|
if (typeof (globalThis as any).process !== 'undefined' && (globalThis as any).process.env !== undefined) {
|
|
6
6
|
return (globalThis as any).process.env[name]
|
|
7
7
|
}
|
|
@@ -12,7 +12,7 @@ export function getEnv (name: string): string | undefined {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
/** check is windows */
|
|
15
|
-
export function isWindows
|
|
15
|
+
export function isWindows(): boolean {
|
|
16
16
|
if (typeof (globalThis as any).process !== 'undefined' && (globalThis as any).process.platform) {
|
|
17
17
|
return (globalThis as any).process.platform === 'win32'
|
|
18
18
|
}
|
|
@@ -23,7 +23,7 @@ export function isWindows (): boolean {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/** get command line arguments */
|
|
26
|
-
export function getCommandLineArgs
|
|
26
|
+
export function getCommandLineArgs(): string[] {
|
|
27
27
|
// Node.js
|
|
28
28
|
if (typeof (globalThis as any).process !== 'undefined' && (globalThis as any).process.argv) {
|
|
29
29
|
return (globalThis as any).process.argv
|
|
@@ -40,7 +40,7 @@ export function getCommandLineArgs (): string[] {
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
/** Exit */
|
|
43
|
-
export function exit
|
|
43
|
+
export function exit(code: number): void {
|
|
44
44
|
if (typeof (globalThis as any).process !== 'undefined') {
|
|
45
45
|
(globalThis as any).process.exit(code)
|
|
46
46
|
}
|
package/src/nako_version.mjs
CHANGED
package/src/nako_version.mts
CHANGED
package/src/plugin_browser.mjs
CHANGED
|
@@ -226,7 +226,6 @@ const PluginBrowser = {
|
|
|
226
226
|
}
|
|
227
227
|
};
|
|
228
228
|
// DOMに動的プロパティの取得と設定を追加する
|
|
229
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
230
229
|
sys.__addPropMethod = (obj) => {
|
|
231
230
|
if (!obj) {
|
|
232
231
|
return;
|
|
@@ -238,38 +237,32 @@ const PluginBrowser = {
|
|
|
238
237
|
configurable: false,
|
|
239
238
|
value: true
|
|
240
239
|
});
|
|
241
|
-
//
|
|
240
|
+
// DOM和スタイル・DOM和属性・DOMプロパティ情報の適用
|
|
242
241
|
const waStyle = sys.__getSysVar('DOM和スタイル');
|
|
243
242
|
const waAttr = sys.__getSysVar('DOM和属性');
|
|
243
|
+
const waPriority = sys.__getSysVar('DOMプロパティ情報');
|
|
244
|
+
const propsToDefine = [];
|
|
245
|
+
if (waPriority) {
|
|
246
|
+
propsToDefine.push(...Object.keys(waPriority));
|
|
247
|
+
}
|
|
244
248
|
if (waStyle) {
|
|
245
|
-
|
|
246
|
-
for (const key of Object.keys(waStyle)) {
|
|
247
|
-
Object.defineProperty(obj, key, {
|
|
248
|
-
enumerable: false,
|
|
249
|
-
configurable: true,
|
|
250
|
-
get: function () {
|
|
251
|
-
return sys.__exec('DOM設定取得', [obj, key, sys]);
|
|
252
|
-
},
|
|
253
|
-
set: function (value) {
|
|
254
|
-
sys.__exec('DOM設定変更', [obj, key, value, sys]);
|
|
255
|
-
}
|
|
256
|
-
});
|
|
257
|
-
}
|
|
249
|
+
propsToDefine.push(...Object.keys(waStyle));
|
|
258
250
|
}
|
|
259
251
|
if (waAttr) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
252
|
+
propsToDefine.push(...Object.keys(waAttr));
|
|
253
|
+
}
|
|
254
|
+
// プロパティを適用する
|
|
255
|
+
for (const key of propsToDefine) {
|
|
256
|
+
Object.defineProperty(obj, key, {
|
|
257
|
+
enumerable: false,
|
|
258
|
+
configurable: true,
|
|
259
|
+
get: function () {
|
|
260
|
+
return sys.__exec('DOM設定取得', [obj, key, sys]);
|
|
261
|
+
},
|
|
262
|
+
set: function (value) {
|
|
263
|
+
sys.__exec('DOM設定変更', [obj, key, value, sys]);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
273
266
|
}
|
|
274
267
|
}
|
|
275
268
|
};
|
|
@@ -348,7 +341,6 @@ const PluginBrowser = {
|
|
|
348
341
|
}
|
|
349
342
|
};
|
|
350
343
|
BrowserParts.forEach((a) => {
|
|
351
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
352
344
|
const b = {};
|
|
353
345
|
Object.assign(b, a);
|
|
354
346
|
// 各モジュールでの初期化処理は認めない
|
package/src/plugin_browser.mts
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* @fileOverview ブラウザプラグイン
|
|
3
3
|
*/
|
|
4
4
|
import { NakoValue, NakoCallback, NakoCallbackEvent, NakoSystem } from '../core/src/plugin_api.mjs'
|
|
5
|
-
import { NakoBrowsesrSystem, IBrowserDocument, IBrowserWindow, IBrowserLocation } from './plugin_browser_api.mjs'
|
|
6
5
|
import { parsePosition } from '../core/src/nako_logger.mjs'
|
|
6
|
+
import { NakoBrowsesrSystem, IBrowserDocument, IBrowserWindow, IBrowserLocation } from './plugin_browser_api.mjs'
|
|
7
7
|
|
|
8
8
|
import PartBrowserColor from './plugin_browser_color.mjs'
|
|
9
9
|
import PartBrowserSystem from './plugin_browser_system.mjs'
|
|
@@ -24,7 +24,6 @@ import PartBrowserHotkey from './plugin_browser_hotkey.mjs'
|
|
|
24
24
|
import PartBrowserChart from './plugin_browser_chart.mjs'
|
|
25
25
|
import PartBrowserCrypto from './plugin_browser_crypto.mjs'
|
|
26
26
|
import PartBrowserCamera from './plugin_browser_camera.mjs'
|
|
27
|
-
import { NakoRuntimeError } from '../core/src/nako_errors.mjs'
|
|
28
27
|
|
|
29
28
|
const BrowserParts = [
|
|
30
29
|
PartBrowserColor,
|
|
@@ -63,7 +62,7 @@ const PluginBrowser = {
|
|
|
63
62
|
type: 'func',
|
|
64
63
|
josi: [],
|
|
65
64
|
pure: true,
|
|
66
|
-
fn: function
|
|
65
|
+
fn: function(sys: NakoBrowsesrSystem) {
|
|
67
66
|
sys.engine = 'wnako'
|
|
68
67
|
/* eslint no-global-assign: 0 */
|
|
69
68
|
const doc: IBrowserDocument = (typeof document === 'undefined') ? { 'body': {}, 'querySelector': () => null } : document
|
|
@@ -222,7 +221,7 @@ const PluginBrowser = {
|
|
|
222
221
|
}
|
|
223
222
|
}
|
|
224
223
|
// DOMに動的プロパティの取得と設定を追加する
|
|
225
|
-
|
|
224
|
+
|
|
226
225
|
sys.__addPropMethod = (obj: any) => {
|
|
227
226
|
if (!obj) { return }
|
|
228
227
|
if (!obj.__nako3) {
|
|
@@ -232,38 +231,34 @@ const PluginBrowser = {
|
|
|
232
231
|
configurable: false,
|
|
233
232
|
value: true
|
|
234
233
|
})
|
|
235
|
-
//
|
|
234
|
+
// DOM和スタイル・DOM和属性・DOMプロパティ情報の適用
|
|
236
235
|
const waStyle = sys.__getSysVar('DOM和スタイル')
|
|
237
236
|
const waAttr = sys.__getSysVar('DOM和属性')
|
|
237
|
+
const waPriority = sys.__getSysVar('DOMプロパティ情報')
|
|
238
|
+
|
|
239
|
+
const propsToDefine: string[] = []
|
|
240
|
+
if (waPriority) {
|
|
241
|
+
propsToDefine.push(...Object.keys(waPriority))
|
|
242
|
+
}
|
|
238
243
|
if (waStyle) {
|
|
239
|
-
|
|
240
|
-
for (const key of Object.keys(waStyle)) {
|
|
241
|
-
Object.defineProperty(obj, key, {
|
|
242
|
-
enumerable: false,
|
|
243
|
-
configurable: true,
|
|
244
|
-
get: function () {
|
|
245
|
-
return sys.__exec('DOM設定取得', [obj, key, sys])
|
|
246
|
-
},
|
|
247
|
-
set: function (value: object) {
|
|
248
|
-
sys.__exec('DOM設定変更', [obj, key, value, sys])
|
|
249
|
-
}
|
|
250
|
-
})
|
|
251
|
-
}
|
|
244
|
+
propsToDefine.push(...Object.keys(waStyle))
|
|
252
245
|
}
|
|
253
246
|
if (waAttr) {
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
247
|
+
propsToDefine.push(...Object.keys(waAttr))
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// プロパティを適用する
|
|
251
|
+
for (const key of propsToDefine) {
|
|
252
|
+
Object.defineProperty(obj, key, {
|
|
253
|
+
enumerable: false,
|
|
254
|
+
configurable: true,
|
|
255
|
+
get: function() {
|
|
256
|
+
return sys.__exec('DOM設定取得', [obj, key, sys])
|
|
257
|
+
},
|
|
258
|
+
set: function(value: object) {
|
|
259
|
+
sys.__exec('DOM設定変更', [obj, key, value, sys])
|
|
260
|
+
}
|
|
261
|
+
})
|
|
267
262
|
}
|
|
268
263
|
}
|
|
269
264
|
}
|
|
@@ -271,11 +266,11 @@ const PluginBrowser = {
|
|
|
271
266
|
if (sys.__registPropAccessor && globalThis.Element) {
|
|
272
267
|
sys.__registPropAccessor(
|
|
273
268
|
Element,
|
|
274
|
-
function
|
|
269
|
+
function(prop: string|string[], sys: NakoSystem): unknown {
|
|
275
270
|
// @ts-expect-error: use this
|
|
276
271
|
return sys.__exec('DOM設定取得', [(this as Element), prop, sys as NakoBrowsesrSystem])
|
|
277
272
|
},
|
|
278
|
-
function
|
|
273
|
+
function(prop: string|string[], value: object, sys: NakoSystem): void {
|
|
279
274
|
// @ts-expect-error: use this
|
|
280
275
|
sys.__exec('DOM設定変更', [(this as Element), prop, value, sys as NakoBrowsesrSystem])
|
|
281
276
|
}
|
|
@@ -326,7 +321,7 @@ const PluginBrowser = {
|
|
|
326
321
|
type: 'func',
|
|
327
322
|
josi: [],
|
|
328
323
|
pure: true,
|
|
329
|
-
fn: function
|
|
324
|
+
fn: function(sys: NakoBrowsesrSystem) {
|
|
330
325
|
// chart.jsを破棄
|
|
331
326
|
if (sys.__chartjs) {
|
|
332
327
|
const chartjs = sys.__chartjs as { destroy: () => void }
|
|
@@ -345,7 +340,7 @@ const PluginBrowser = {
|
|
|
345
340
|
}
|
|
346
341
|
|
|
347
342
|
BrowserParts.forEach((a) => {
|
|
348
|
-
|
|
343
|
+
|
|
349
344
|
const b: any = {}
|
|
350
345
|
Object.assign(b, a)
|
|
351
346
|
// 各モジュールでの初期化処理は認めない
|