nadesiko3 3.7.2 → 3.7.4
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 +472 -469
- package/batch/pickup_command.nako3 +1 -1
- package/core/.eslintrc.cjs +10 -3
- package/core/package-lock.json +1184 -645
- package/core/package.json +4 -5
- package/core/src/nako3.mjs +8 -6
- package/core/src/nako3.mts +19 -16
- package/core/src/nako_ast.mts +2 -3
- package/core/src/nako_core_version.mjs +2 -2
- package/core/src/nako_core_version.mts +2 -2
- package/core/src/nako_csv.mjs +1 -0
- package/core/src/nako_csv.mts +3 -2
- package/core/src/nako_from_dncl.mjs +1 -1
- package/core/src/nako_from_dncl.mts +1 -1
- package/core/src/nako_from_dncl2.mjs +1 -1
- package/core/src/nako_from_dncl2.mts +2 -2
- package/core/src/nako_gen.mjs +37 -35
- package/core/src/nako_gen.mts +70 -67
- package/core/src/nako_global.mjs +3 -2
- package/core/src/nako_global.mts +3 -2
- package/core/src/nako_lexer.mjs +3 -3
- package/core/src/nako_lexer.mts +3 -3
- package/core/src/nako_logger.mjs +1 -1
- package/core/src/nako_logger.mts +2 -2
- package/core/src/nako_parser3.mjs +67 -59
- package/core/src/nako_parser3.mts +96 -90
- package/core/src/nako_parser_base.mts +3 -3
- package/core/src/nako_prepare.mjs +1 -1
- package/core/src/nako_prepare.mts +1 -1
- package/core/src/nako_source_mapping.mts +0 -1
- package/core/src/nako_token.mts +8 -8
- package/core/src/nako_types.mts +1 -1
- package/core/src/plugin_api.mts +1 -1
- package/core/src/plugin_csv.mjs +1 -0
- package/core/src/plugin_csv.mts +2 -1
- package/core/src/plugin_math.mjs +2 -2
- package/core/src/plugin_math.mts +3 -3
- package/core/src/plugin_promise.mjs +1 -1
- package/core/src/plugin_promise.mts +1 -1
- package/core/src/plugin_system.mjs +117 -40
- package/core/src/plugin_system.mts +132 -58
- package/core/src/plugin_test.mjs +3 -1
- package/core/src/plugin_test.mts +3 -1
- package/core/test/basic_test.mjs +16 -0
- package/core/test/calc_test.mjs +7 -0
- package/core/test/plugin_system_test.mjs +33 -0
- package/doc/files.md +4 -4
- package/doc/plugins.md +1 -1
- package/package.json +9 -9
- package/release/_hash.txt +36 -121
- package/release/_script-tags.txt +16 -33
- 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 +3 -3
- package/release/edit_main.js.map +2 -2
- package/release/editor.js +3 -3
- package/release/plugin_markup.js +53 -53
- package/release/plugin_markup.js.map +3 -3
- package/release/plugin_weykturtle3d.js +1 -1
- package/release/plugin_weykturtle3d.js.map +4 -4
- package/release/version.js +3 -3
- package/release/version_main.js +3 -3
- package/release/version_main.js.map +2 -2
- package/release/wnako3.js +66 -66
- package/release/wnako3.js.map +3 -3
- package/release/wnako3webworker.js +58 -58
- package/release/wnako3webworker.js.map +3 -3
- package/src/browsers.txt +30 -20
- package/src/cnako3mod.mjs +19 -18
- package/src/cnako3mod.mts +17 -16
- package/src/deno_wrapper.mjs +6 -6
- package/src/deno_wrapper.mts +11 -11
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/src/plugin_browser.mjs +2 -2
- package/src/plugin_browser.mts +5 -5
- package/src/plugin_browser_ajax.mjs +2 -2
- package/src/plugin_browser_ajax.mts +2 -2
- package/src/plugin_browser_api.mts +0 -1
- package/src/plugin_browser_crypto.mjs +8 -8
- package/src/plugin_browser_crypto.mts +13 -13
- package/src/plugin_browser_dom_basic.mjs +3 -3
- package/src/plugin_browser_dom_basic.mts +5 -7
- package/src/plugin_browser_dom_event.mjs +1 -1
- package/src/plugin_browser_dom_event.mts +2 -1
- package/src/plugin_browser_dom_parts.mjs +33 -18
- package/src/plugin_browser_dom_parts.mts +60 -59
- package/src/plugin_browser_speech.mjs +1 -1
- package/src/plugin_browser_speech.mts +1 -1
- package/src/plugin_node.mjs +5 -3
- package/src/plugin_node.mts +6 -4
- package/src/plugin_weykturtle3d.mjs +38 -15
- package/src/plugin_weykturtle3d.mts +279 -240
- package/src/plugin_weykturtle3d_three.mjs +3 -0
- package/src/plugin_weykturtle3d_three.mts +214 -0
- package/src/plugin_weykturtle3d_threeutil.mjs +28 -0
- package/src/plugin_weykturtle3d_threeutil.mts +31 -0
- package/src/wnako3.mjs +1 -0
- package/src/wnako3.mts +1 -0
- package/src/wnako3mod.mjs +5 -2
- package/src/wnako3mod.mts +6 -3
- package/batch/command_nakopad.txt +0 -1177
- package/core/__report.txt +0 -617
- package/core/command/plugin_snako.mjs +0 -112
- package/core/command/snako.mjs +0 -108
- package/release/core_src_nako_josi_list_mjs.js +0 -3
- package/release/core_src_nako_josi_list_mjs.js.LICENSE.txt +0 -3
- package/release/core_src_nako_josi_list_mjs.js.map +0 -1
- package/release/core_src_nako_reserved_words_mjs.js +0 -3
- package/release/core_src_nako_reserved_words_mjs.js.LICENSE.txt +0 -3
- package/release/core_src_nako_reserved_words_mjs.js.map +0 -1
- package/release/editor/edit_main.js +0 -48
- package/release/editor/edit_main.js.map +0 -7
- package/release/editor/version_main.js +0 -44
- package/release/editor/version_main.js.map +0 -7
- package/release/editor.js.LICENSE.txt +0 -91
- package/release/editor.js.map +0 -1
- package/release/nako_gen_async.js +0 -2
- package/release/nako_gen_async.js.LICENSE.txt +0 -21
- package/release/nako_gen_async.js.map +0 -1
- package/release/plugin_caniuse.js.LICENSE.txt +0 -15
- package/release/plugin_datetime.js.LICENSE.txt +0 -21
- package/release/plugin_kansuji.js.LICENSE.txt +0 -3
- package/release/plugin_markup.js.LICENSE.txt +0 -15
- package/release/plugin_toml.js +0 -295
- package/release/plugin_toml.js.map +0 -7
- package/release/plugin_turtle.js.LICENSE.txt +0 -9
- package/release/plugin_webworker.js.LICENSE.txt +0 -3
- package/release/plugin_weykturtle3d.js.LICENSE.txt +0 -3
- package/release/src/plugin_caniuse.js +0 -2
- package/release/src/plugin_caniuse.js.map +0 -7
- package/release/src/plugin_datetime.js +0 -2
- package/release/src/plugin_datetime.js.map +0 -7
- package/release/src/plugin_kansuji.js +0 -2
- package/release/src/plugin_kansuji.js.map +0 -7
- package/release/src/plugin_keigo.js +0 -2
- package/release/src/plugin_keigo.js.map +0 -7
- package/release/src/plugin_markup.js +0 -64
- package/release/src/plugin_markup.js.map +0 -7
- package/release/src/plugin_three.js +0 -2
- package/release/src/plugin_three.js.map +0 -7
- package/release/src/plugin_turtle.js +0 -2
- package/release/src/plugin_turtle.js.map +0 -7
- package/release/src/plugin_webworker.js +0 -4
- package/release/src/plugin_webworker.js.map +0 -7
- package/release/src/plugin_weykturtle3d.js +0 -2
- package/release/src/plugin_weykturtle3d.js.map +0 -7
- package/release/src/wnako3.js +0 -482
- package/release/src/wnako3.js.map +0 -7
- package/release/src/wnako3webworker.js +0 -428
- package/release/src/wnako3webworker.js.map +0 -7
- package/release/stats.json +0 -1
- package/release/version.js.LICENSE.txt +0 -65
- package/release/version.js.map +0 -1
- package/release/wnako3.js.LICENSE.txt +0 -341
- package/release/wnako3webworker.js.LICENSE.txt +0 -209
- package/src/plugin_three.mts +0 -240
package/core/src/nako_token.mts
CHANGED
|
@@ -63,12 +63,12 @@ export type TokenType = '?'
|
|
|
63
63
|
| '…'
|
|
64
64
|
| 'もし'
|
|
65
65
|
| '回' // 回
|
|
66
|
-
|
|
66
|
+
// 回繰返 // (#924)
|
|
67
67
|
| '間' // 間
|
|
68
|
-
|
|
68
|
+
// 間繰返 // (#927)
|
|
69
69
|
| '繰返' // 繰返
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
// 増繰返 // (#1140)
|
|
71
|
+
// 減繰返
|
|
72
72
|
| '後判定' // 後判定 // (#1147)
|
|
73
73
|
| '反復' // 反復
|
|
74
74
|
| '抜ける' // 抜
|
|
@@ -85,12 +85,12 @@ export type TokenType = '?'
|
|
|
85
85
|
| '増' // 増
|
|
86
86
|
| '減' // 減
|
|
87
87
|
| '変数' // 変数
|
|
88
|
-
|
|
88
|
+
// 定数
|
|
89
89
|
| 'エラー監視' // エラー監視 // 例外処理:エラーならばと対
|
|
90
90
|
| 'エラー' // エラー
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
91
|
+
// それ
|
|
92
|
+
// そう // 「それ」のエイリアス
|
|
93
|
+
// 関数 // 無名関数の定義用
|
|
94
94
|
| 'インデント構文' // インデント構文 // https://nadesi.com/v3/doc/go.php?949
|
|
95
95
|
| '非同期モード' // 非同期モード // (#637)
|
|
96
96
|
| 'DNCLモード' // DNCLモード // (#1140)
|
package/core/src/nako_types.mts
CHANGED
|
@@ -46,7 +46,7 @@ export interface TokenMeta {
|
|
|
46
46
|
funcPointers: any[] | undefined;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
export function NewEmptyToken(type: TokenType = '?', value: any = '', indent = -1, line = 0, file = 'main.nako3'): Token {
|
|
49
|
+
export function NewEmptyToken (type: TokenType = '?', value: any = '', indent = -1, line = 0, file = 'main.nako3'): Token {
|
|
50
50
|
return {
|
|
51
51
|
type,
|
|
52
52
|
value,
|
package/core/src/plugin_api.mts
CHANGED
|
@@ -38,7 +38,7 @@ export interface NakoSystem {
|
|
|
38
38
|
__parseFloatOrBigint(v: NakoValue): number | bigint;
|
|
39
39
|
__evalJS(code: string, sys?: NakoSystem): NakoValue;
|
|
40
40
|
__evalSafe(code: string): NakoValue;
|
|
41
|
-
// eslint-disable-next-line
|
|
41
|
+
// eslint-disable-next-line
|
|
42
42
|
__registPropAccessor(f: Function, getProp: (prop: string|string[], sys: NakoSystem) => any, setProp: (prop: string|string[], value: object, sys: NakoSystem) => any):void;
|
|
43
43
|
__checkPropAccessor(mode: 'get'|'set', obj: any):void;
|
|
44
44
|
josiList: string[];
|
package/core/src/plugin_csv.mjs
CHANGED
package/core/src/plugin_csv.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1
2
|
import { CSVOptions, options, parse, stringify } from './nako_csv.mjs'
|
|
2
3
|
|
|
3
4
|
const PluginCSV = {
|
|
@@ -58,7 +59,7 @@ const PluginCSV = {
|
|
|
58
59
|
},
|
|
59
60
|
'CSVオプション設定': { // @「CSV取得」「表CSV変換」命令のオプションOBJ{delimiter,eol,auto_convert_number}をオブジェクトで指定 // @CSVおぷしょんせってい
|
|
60
61
|
type: 'func',
|
|
61
|
-
josi: [['を','で']],
|
|
62
|
+
josi: [['を', 'で']],
|
|
62
63
|
pure: true,
|
|
63
64
|
fn: function (obj: { [key: string]: unknown }): void {
|
|
64
65
|
for (const key in obj) {
|
package/core/src/plugin_math.mjs
CHANGED
|
@@ -239,13 +239,13 @@ export default {
|
|
|
239
239
|
if (typeof a === 'object' && a['先頭'] !== undefined) {
|
|
240
240
|
const min = a['先頭'];
|
|
241
241
|
const max = a['末尾'];
|
|
242
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
242
|
+
return Math.floor(Math.random() * (max - min + 1)) + Number(min);
|
|
243
243
|
}
|
|
244
244
|
// 配列の場合
|
|
245
245
|
if (Array.isArray(a)) {
|
|
246
246
|
const min = a[0];
|
|
247
247
|
const max = a[1];
|
|
248
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
248
|
+
return Math.floor(Math.random() * (max - min + 1)) + Number(min);
|
|
249
249
|
}
|
|
250
250
|
return undefined;
|
|
251
251
|
}
|
package/core/src/plugin_math.mts
CHANGED
|
@@ -233,19 +233,19 @@ export default {
|
|
|
233
233
|
fn: function (a: any): number | undefined {
|
|
234
234
|
// numberの場合
|
|
235
235
|
if (typeof a === 'number') {
|
|
236
|
-
|
|
236
|
+
return Math.floor(Math.random() * a)
|
|
237
237
|
}
|
|
238
238
|
// 範囲オブジェクトの場合
|
|
239
239
|
if (typeof a === 'object' && a['先頭'] !== undefined) {
|
|
240
240
|
const min = a['先頭']
|
|
241
241
|
const max = a['末尾']
|
|
242
|
-
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
242
|
+
return Math.floor(Math.random() * (max - min + 1)) + Number(min)
|
|
243
243
|
}
|
|
244
244
|
// 配列の場合
|
|
245
245
|
if (Array.isArray(a)) {
|
|
246
246
|
const min = a[0]
|
|
247
247
|
const max = a[1]
|
|
248
|
-
return Math.floor(Math.random() * (max - min + 1)) + min
|
|
248
|
+
return Math.floor(Math.random() * (max - min + 1)) + Number(min)
|
|
249
249
|
}
|
|
250
250
|
return undefined
|
|
251
251
|
}
|
|
@@ -97,7 +97,7 @@ export default {
|
|
|
97
97
|
pure: true,
|
|
98
98
|
fn: function (...args:any): any {
|
|
99
99
|
const sys = args.pop()
|
|
100
|
-
return (sys
|
|
100
|
+
return (sys).__promise.setLastPromise(Promise.all(args))
|
|
101
101
|
},
|
|
102
102
|
return_none: false
|
|
103
103
|
}
|
|
@@ -61,7 +61,7 @@ export default {
|
|
|
61
61
|
// 名前空間を参照して関数・変数名を解決する
|
|
62
62
|
const modList = system.__modList ? system.__modList : [system.__modName];
|
|
63
63
|
for (const modName of modList) {
|
|
64
|
-
const gname = modName
|
|
64
|
+
const gname = `${modName}__${nameStr}`;
|
|
65
65
|
for (let i = 2; i >= 0; i--) {
|
|
66
66
|
const scope = system.__varslist[i];
|
|
67
67
|
const scopeValue = scope.get(gname);
|
|
@@ -99,7 +99,7 @@ export default {
|
|
|
99
99
|
sys.__interval = [];
|
|
100
100
|
// 日付処理などに使う
|
|
101
101
|
const z2 = sys.__zero2 = (s) => {
|
|
102
|
-
s = '00' + s;
|
|
102
|
+
s = '00' + String(s);
|
|
103
103
|
return s.substring(s.length - 2);
|
|
104
104
|
};
|
|
105
105
|
sys.__zero = (s, keta) => {
|
|
@@ -111,13 +111,13 @@ export default {
|
|
|
111
111
|
return s.substring(s.length - keta);
|
|
112
112
|
};
|
|
113
113
|
sys.__formatDate = (t) => {
|
|
114
|
-
return t.getFullYear() + '/' + z2(t.getMonth() + 1) + '/' + z2(t.getDate());
|
|
114
|
+
return String(t.getFullYear()) + '/' + z2(t.getMonth() + 1) + '/' + z2(t.getDate());
|
|
115
115
|
};
|
|
116
116
|
sys.__formatTime = (t) => {
|
|
117
117
|
return z2(t.getHours()) + ':' + z2(t.getSeconds()) + ':' + z2(t.getMinutes());
|
|
118
118
|
};
|
|
119
119
|
sys.__formatDateTime = (t, fmt) => {
|
|
120
|
-
const dateStr = t.getFullYear() + '/' + z2(t.getMonth() + 1) + '/' + z2(t.getDate());
|
|
120
|
+
const dateStr = String(t.getFullYear()) + '/' + z2(t.getMonth() + 1) + '/' + z2(t.getDate());
|
|
121
121
|
const timeStr = z2(t.getHours()) + ':' + z2(t.getMinutes()) + ':' + z2(t.getSeconds());
|
|
122
122
|
if (fmt.match(/^\d+\/\d+\/\d+\s+\d+:\d+:\d+$/)) {
|
|
123
123
|
return dateStr + ' ' + timeStr;
|
|
@@ -174,6 +174,7 @@ export default {
|
|
|
174
174
|
sys.__evalSafe = (src) => {
|
|
175
175
|
// evalのスコープを変えるためのテクニック
|
|
176
176
|
// https://esbuild.github.io/content-types/#direct-eval
|
|
177
|
+
// eslint-disable-next-line no-eval
|
|
177
178
|
const _eval = eval;
|
|
178
179
|
try {
|
|
179
180
|
return _eval(src);
|
|
@@ -187,6 +188,7 @@ export default {
|
|
|
187
188
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
188
189
|
sys.__evalJS = (src, sys) => {
|
|
189
190
|
try {
|
|
191
|
+
// eslint-disable-next-line no-eval
|
|
190
192
|
return eval(src);
|
|
191
193
|
}
|
|
192
194
|
catch (e) {
|
|
@@ -195,7 +197,7 @@ export default {
|
|
|
195
197
|
}
|
|
196
198
|
};
|
|
197
199
|
// Propアクセス支援
|
|
198
|
-
// eslint-disable-next-line @typescript-eslint/
|
|
200
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
199
201
|
sys.__registPropAccessor = (f, getProp, setProp) => {
|
|
200
202
|
system.__propAccessor.push({
|
|
201
203
|
target: f,
|
|
@@ -327,10 +329,10 @@ export default {
|
|
|
327
329
|
pure: true,
|
|
328
330
|
fn: function (s, sys) {
|
|
329
331
|
// 継続表示の一時プールを出力
|
|
330
|
-
s = sys.__printPool + s;
|
|
332
|
+
s = String(sys.__printPool) + s;
|
|
331
333
|
sys.__printPool = '';
|
|
332
334
|
//
|
|
333
|
-
sys.__setSysVar('表示ログ', sys.__getSysVar('表示ログ') + s + '\n');
|
|
335
|
+
sys.__setSysVar('表示ログ', String(sys.__getSysVar('表示ログ')) + s + '\n');
|
|
334
336
|
sys.logger.send('stdout', s + '');
|
|
335
337
|
},
|
|
336
338
|
return_none: true
|
|
@@ -403,7 +405,39 @@ export default {
|
|
|
403
405
|
isVariableJosi: false,
|
|
404
406
|
pure: true,
|
|
405
407
|
fn: function (a, b) {
|
|
406
|
-
|
|
408
|
+
if (typeof (a) === 'bigint' || typeof (b) === 'bigint') {
|
|
409
|
+
return BigInt(a) + BigInt(b);
|
|
410
|
+
}
|
|
411
|
+
return parseFloat(a) + parseFloat(b);
|
|
412
|
+
}
|
|
413
|
+
},
|
|
414
|
+
'合計': {
|
|
415
|
+
type: 'func',
|
|
416
|
+
josi: [['と', 'を', 'の']],
|
|
417
|
+
isVariableJosi: true,
|
|
418
|
+
pure: true,
|
|
419
|
+
fn: function (...a) {
|
|
420
|
+
const sys = a.pop(); // remove NakoSystem
|
|
421
|
+
if (a.length >= 1 && a[0] instanceof Array) {
|
|
422
|
+
return sys.__exec('配列合計', [a[0], sys]);
|
|
423
|
+
}
|
|
424
|
+
let isBigInt = false;
|
|
425
|
+
let sum = 0;
|
|
426
|
+
for (const v of a) {
|
|
427
|
+
if (typeof (v) === 'bigint') {
|
|
428
|
+
isBigInt = true;
|
|
429
|
+
break;
|
|
430
|
+
}
|
|
431
|
+
sum += parseFloat(v);
|
|
432
|
+
}
|
|
433
|
+
if (isBigInt) {
|
|
434
|
+
let bigsum = 0n;
|
|
435
|
+
for (const v of a) {
|
|
436
|
+
bigsum += BigInt(v);
|
|
437
|
+
}
|
|
438
|
+
return bigsum;
|
|
439
|
+
}
|
|
440
|
+
return sum;
|
|
407
441
|
}
|
|
408
442
|
},
|
|
409
443
|
'引': {
|
|
@@ -601,6 +635,7 @@ export default {
|
|
|
601
635
|
fn: function (b, ...a) {
|
|
602
636
|
a.pop(); // 必ず末尾に sys があるので、末尾のシステム変数を除外
|
|
603
637
|
a.push(b);
|
|
638
|
+
// eslint-disable-next-line @typescript-eslint/restrict-plus-operands
|
|
604
639
|
return a.reduce((p, c) => p + c);
|
|
605
640
|
}
|
|
606
641
|
},
|
|
@@ -816,7 +851,7 @@ export default {
|
|
|
816
851
|
fn: function (code, sys) {
|
|
817
852
|
sys.__setSysVar('表示ログ', '');
|
|
818
853
|
sys.__self.runEx(code, sys.__modName, { resetEnv: false, resetLog: true });
|
|
819
|
-
const outLog = sys.__getSysVar('表示ログ')
|
|
854
|
+
const outLog = String(sys.__getSysVar('表示ログ'));
|
|
820
855
|
if (outLog) {
|
|
821
856
|
sys.logger.trace(outLog);
|
|
822
857
|
}
|
|
@@ -828,7 +863,7 @@ export default {
|
|
|
828
863
|
josi: [['を', 'で']],
|
|
829
864
|
fn: function (code, sys) {
|
|
830
865
|
sys.__self.runEx(code, sys.__modName, { resetEnv: false, resetAll: false });
|
|
831
|
-
const out = sys.__getSysVar('表示ログ')
|
|
866
|
+
const out = String(sys.__getSysVar('表示ログ'));
|
|
832
867
|
if (out) {
|
|
833
868
|
sys.logger.trace(out);
|
|
834
869
|
}
|
|
@@ -1028,7 +1063,7 @@ export default {
|
|
|
1028
1063
|
pure: true,
|
|
1029
1064
|
fn: function (r, g, b) {
|
|
1030
1065
|
const z2 = (v) => {
|
|
1031
|
-
const v2 = '00' + (parseInt(
|
|
1066
|
+
const v2 = '00' + (parseInt(String(v)).toString(16));
|
|
1032
1067
|
return v2.substring(v2.length - 2, v2.length);
|
|
1033
1068
|
};
|
|
1034
1069
|
return '#' + z2(r) + z2(g) + z2(b);
|
|
@@ -1056,7 +1091,7 @@ export default {
|
|
|
1056
1091
|
josi: [['の']],
|
|
1057
1092
|
pure: true,
|
|
1058
1093
|
fn: function (v) {
|
|
1059
|
-
return (!v)
|
|
1094
|
+
return (!v);
|
|
1060
1095
|
}
|
|
1061
1096
|
},
|
|
1062
1097
|
// @ビット演算
|
|
@@ -1257,7 +1292,17 @@ export default {
|
|
|
1257
1292
|
fn: function (...a) {
|
|
1258
1293
|
a.pop(); // NakoSystemを取り除く
|
|
1259
1294
|
return a.join('');
|
|
1260
|
-
}
|
|
1295
|
+
}
|
|
1296
|
+
},
|
|
1297
|
+
'文字列連結': {
|
|
1298
|
+
type: 'func',
|
|
1299
|
+
josi: [['と', 'を']],
|
|
1300
|
+
pure: true,
|
|
1301
|
+
isVariableJosi: true,
|
|
1302
|
+
fn: function (...a) {
|
|
1303
|
+
a.pop(); // NakoSystemを取り除く
|
|
1304
|
+
return a.join('');
|
|
1305
|
+
}
|
|
1261
1306
|
},
|
|
1262
1307
|
'文字列分解': {
|
|
1263
1308
|
type: 'func',
|
|
@@ -1347,7 +1392,11 @@ export default {
|
|
|
1347
1392
|
// return (s.substring(s.length - cnt, s.length))
|
|
1348
1393
|
// サロゲートペアを考慮
|
|
1349
1394
|
const strArray = Array.from(s);
|
|
1350
|
-
|
|
1395
|
+
let index = strArray.length - cnt;
|
|
1396
|
+
if (index < 0) {
|
|
1397
|
+
index = 0;
|
|
1398
|
+
}
|
|
1399
|
+
return strArray.slice(index, strArray.length).join('');
|
|
1351
1400
|
}
|
|
1352
1401
|
},
|
|
1353
1402
|
'区切': {
|
|
@@ -1552,7 +1601,10 @@ export default {
|
|
|
1552
1601
|
josi: [['の', 'を']],
|
|
1553
1602
|
pure: true,
|
|
1554
1603
|
fn: function (s) {
|
|
1555
|
-
return String(s).replace(/[\x20-\
|
|
1604
|
+
return String(s).replace(/[\x20-\x7E]/g, function (v) {
|
|
1605
|
+
if (v === ' ') {
|
|
1606
|
+
return ' ';
|
|
1607
|
+
} // 半角スペース(0x20)を全角スペース(U+3000)に
|
|
1556
1608
|
return String.fromCharCode(v.charCodeAt(0) + 0xFEE0);
|
|
1557
1609
|
});
|
|
1558
1610
|
}
|
|
@@ -1562,7 +1614,10 @@ export default {
|
|
|
1562
1614
|
josi: [['の', 'を']],
|
|
1563
1615
|
pure: true,
|
|
1564
1616
|
fn: function (s) {
|
|
1565
|
-
return String(s).replace(/[\uFF00-\uFF5F]/g, function (v) {
|
|
1617
|
+
return String(s).replace(/[\u3000\uFF00-\uFF5F]/g, function (v) {
|
|
1618
|
+
if (v === ' ') {
|
|
1619
|
+
return ' ';
|
|
1620
|
+
} // 全角スペース(U+3000)を半角スペース(U+0020)
|
|
1566
1621
|
return String.fromCharCode(v.charCodeAt(0) - 0xFEE0);
|
|
1567
1622
|
});
|
|
1568
1623
|
}
|
|
@@ -2134,7 +2189,7 @@ export default {
|
|
|
2134
2189
|
// 範囲オブジェクトのとき
|
|
2135
2190
|
if (typeof i === 'object' && typeof i['先頭'] === 'number') {
|
|
2136
2191
|
const start = i['先頭'];
|
|
2137
|
-
const last = i['末尾'] + 1;
|
|
2192
|
+
const last = Number(i['末尾']) + 1;
|
|
2138
2193
|
return JSON.parse(JSON.stringify(a.slice(start, last)));
|
|
2139
2194
|
}
|
|
2140
2195
|
return undefined;
|
|
@@ -2154,7 +2209,7 @@ export default {
|
|
|
2154
2209
|
// 範囲オブジェクトのとき
|
|
2155
2210
|
if (typeof i === 'object' && typeof i['先頭'] === 'number') {
|
|
2156
2211
|
const start = i['先頭'];
|
|
2157
|
-
const last = i['末尾'] + 1;
|
|
2212
|
+
const last = Number(i['末尾']) + 1;
|
|
2158
2213
|
return a.substring(start, last);
|
|
2159
2214
|
}
|
|
2160
2215
|
throw new Error(`『参照』で文字列型の範囲指定(${JSON.stringify(i)})が不正です。`);
|
|
@@ -2167,7 +2222,7 @@ export default {
|
|
|
2167
2222
|
// 範囲オブジェクトのとき
|
|
2168
2223
|
if (typeof i === 'object' && typeof i['先頭'] === 'number') {
|
|
2169
2224
|
const start = i['先頭'];
|
|
2170
|
-
const last = i['末尾'] + 1;
|
|
2225
|
+
const last = Number(i['末尾']) + 1;
|
|
2171
2226
|
return a.slice(start, last);
|
|
2172
2227
|
}
|
|
2173
2228
|
}
|
|
@@ -2260,14 +2315,37 @@ export default {
|
|
|
2260
2315
|
},
|
|
2261
2316
|
'配列要素作成': {
|
|
2262
2317
|
type: 'func',
|
|
2263
|
-
josi: [['を'], ['だけ']],
|
|
2318
|
+
josi: [['を'], ['だけ', 'で']],
|
|
2264
2319
|
pure: true,
|
|
2265
2320
|
fn: function (a, b) {
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2321
|
+
// value が配列やオブジェクトでも深くコピーするヘルパー
|
|
2322
|
+
const cloneValue = (v) => {
|
|
2323
|
+
if (Array.isArray(v)) {
|
|
2324
|
+
return (v).map(item => cloneValue(item));
|
|
2325
|
+
}
|
|
2326
|
+
if (v instanceof Date) {
|
|
2327
|
+
return new Date(v.getTime());
|
|
2328
|
+
}
|
|
2329
|
+
if (typeof v === 'object' && v !== null) {
|
|
2330
|
+
return JSON.parse(JSON.stringify(v));
|
|
2331
|
+
}
|
|
2332
|
+
return v;
|
|
2333
|
+
};
|
|
2334
|
+
// 再帰的に配列を生成する関数
|
|
2335
|
+
const full = function (value, shape) {
|
|
2336
|
+
// 1次元:shape が数値
|
|
2337
|
+
if (!Array.isArray(shape)) {
|
|
2338
|
+
return Array.from({ length: shape }, () => cloneValue(value));
|
|
2339
|
+
}
|
|
2340
|
+
// 1次元:shape が数値
|
|
2341
|
+
if (Array.isArray(shape) && shape.length === 1) {
|
|
2342
|
+
return Array.from({ length: shape[0] }, () => cloneValue(value));
|
|
2343
|
+
}
|
|
2344
|
+
// 多次元:shape が配列
|
|
2345
|
+
const [first, ...rest] = shape;
|
|
2346
|
+
return Array.from({ length: first }, () => full(cloneValue(value), rest));
|
|
2347
|
+
};
|
|
2348
|
+
return full(a, b);
|
|
2271
2349
|
}
|
|
2272
2350
|
},
|
|
2273
2351
|
'配列関数適用': {
|
|
@@ -2824,8 +2902,8 @@ export default {
|
|
|
2824
2902
|
pure: true,
|
|
2825
2903
|
fn: function () {
|
|
2826
2904
|
const z2 = (n) => {
|
|
2827
|
-
|
|
2828
|
-
return
|
|
2905
|
+
const ns = '00' + String(n);
|
|
2906
|
+
return ns.substring(ns.length - 2, ns.length);
|
|
2829
2907
|
};
|
|
2830
2908
|
const t = new Date();
|
|
2831
2909
|
return z2(t.getHours()) + ':' + z2(t.getMinutes()) + ':' + z2(t.getSeconds());
|
|
@@ -2978,8 +3056,8 @@ export default {
|
|
|
2978
3056
|
fmt = fmt.replace(/(YYYY|ccc|WWW|MMM|YY|MM|DD|HH|mm|ss|[MDHmsW])/g, (m) => {
|
|
2979
3057
|
switch (m) {
|
|
2980
3058
|
case 'YYYY': return t.getFullYear();
|
|
2981
|
-
case 'YY': return (
|
|
2982
|
-
case 'MM': return sys.__zero2(t.getMonth() + 1);
|
|
3059
|
+
case 'YY': return (String(t.getFullYear())).substring(2);
|
|
3060
|
+
case 'MM': return sys.__zero2(String(t.getMonth() + 1));
|
|
2983
3061
|
case 'DD': return sys.__zero2(t.getDate());
|
|
2984
3062
|
case 'M': return (t.getMonth() + 1);
|
|
2985
3063
|
case 'D': return (t.getDate());
|
|
@@ -3007,7 +3085,7 @@ export default {
|
|
|
3007
3085
|
const d = sys.__str2date(s);
|
|
3008
3086
|
const t = d.getTime();
|
|
3009
3087
|
for (const era of sys.__getSysVar('元号データ')) {
|
|
3010
|
-
const gengo = era['元号'];
|
|
3088
|
+
const gengo = String(era['元号']);
|
|
3011
3089
|
const d2 = sys.__str2date(era['改元日']);
|
|
3012
3090
|
const t2 = d2.getTime();
|
|
3013
3091
|
if (t2 <= t) {
|
|
@@ -3015,7 +3093,7 @@ export default {
|
|
|
3015
3093
|
if (y === 1) {
|
|
3016
3094
|
y = '元';
|
|
3017
3095
|
}
|
|
3018
|
-
return gengo + y + '年' + sys.__zero2(d.getMonth() + 1) + '月' + sys.__zero2(d.getDate()) + '日';
|
|
3096
|
+
return gengo + String(y) + '年' + sys.__zero2(d.getMonth() + 1) + '月' + sys.__zero2(d.getDate()) + '日';
|
|
3019
3097
|
}
|
|
3020
3098
|
}
|
|
3021
3099
|
throw new Error('『和暦変換』は明示以前の日付には対応していません。');
|
|
@@ -3038,8 +3116,8 @@ export default {
|
|
|
3038
3116
|
fn: function (a, b, sys) {
|
|
3039
3117
|
const t1 = sys.__str2date(a);
|
|
3040
3118
|
const t2 = sys.__str2date(b);
|
|
3041
|
-
return (
|
|
3042
|
-
(t1.getFullYear() * 12 + t1.getMonth()));
|
|
3119
|
+
return (t2.getFullYear() * 12 + Number(t2.getMonth())) -
|
|
3120
|
+
(t1.getFullYear() * 12 + Number(t1.getMonth()));
|
|
3043
3121
|
}
|
|
3044
3122
|
},
|
|
3045
3123
|
'日数差': {
|
|
@@ -3119,7 +3197,7 @@ export default {
|
|
|
3119
3197
|
if (op === '-') {
|
|
3120
3198
|
sec *= -1;
|
|
3121
3199
|
}
|
|
3122
|
-
const rd = new Date(d.getTime() + (sec * 1000));
|
|
3200
|
+
const rd = new Date(Number(d.getTime()) + (sec * 1000));
|
|
3123
3201
|
return sys.__formatDateTime(rd, s);
|
|
3124
3202
|
}
|
|
3125
3203
|
},
|
|
@@ -3141,9 +3219,9 @@ export default {
|
|
|
3141
3219
|
const addY = parseInt(aa[0]) * op;
|
|
3142
3220
|
const addM = parseInt(aa[1]) * op;
|
|
3143
3221
|
const addD = parseInt(aa[2]) * op;
|
|
3144
|
-
d.setFullYear(d.getFullYear() + addY);
|
|
3145
|
-
d.setMonth(d.getMonth() + addM);
|
|
3146
|
-
d.setDate(d.getDate() + addD);
|
|
3222
|
+
d.setFullYear(Number(d.getFullYear()) + addY);
|
|
3223
|
+
d.setMonth(Number(d.getMonth()) + addM);
|
|
3224
|
+
d.setDate(Number(d.getDate()) + addD);
|
|
3147
3225
|
return sys.__formatDateTime(d, s);
|
|
3148
3226
|
}
|
|
3149
3227
|
},
|
|
@@ -3191,12 +3269,12 @@ export default {
|
|
|
3191
3269
|
pure: true,
|
|
3192
3270
|
fn: function (s, sys) {
|
|
3193
3271
|
// 行番号の情報を得る
|
|
3194
|
-
const lineInfo = sys.__getSysVar('__line', 0) + '::';
|
|
3272
|
+
const lineInfo = String(sys.__getSysVar('__line', 0)) + '::';
|
|
3195
3273
|
const a = lineInfo.split(':', 2);
|
|
3196
3274
|
const no = parseInt(String(a[0]).replace('l', '')) + 1;
|
|
3197
3275
|
const fname = a[1];
|
|
3198
3276
|
// オブジェクトならJSON文字列に変換
|
|
3199
|
-
if (typeof s
|
|
3277
|
+
if (typeof s === 'object') {
|
|
3200
3278
|
s = JSON.stringify(s);
|
|
3201
3279
|
}
|
|
3202
3280
|
s = `${fname}(${no}): ${s}`;
|
|
@@ -3232,7 +3310,6 @@ export default {
|
|
|
3232
3310
|
for (const f of fa) {
|
|
3233
3311
|
param = f(param, sys);
|
|
3234
3312
|
}
|
|
3235
|
-
return;
|
|
3236
3313
|
};
|
|
3237
3314
|
return;
|
|
3238
3315
|
}
|