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.
Files changed (127) hide show
  1. package/batch/command.txt +473 -473
  2. package/batch/jsplugin2text.nako3 +2 -0
  3. package/core/package.json +1 -1
  4. package/core/src/nako3.mjs +0 -4
  5. package/core/src/nako3.mts +55 -55
  6. package/core/src/nako_ast.mjs +0 -1
  7. package/core/src/nako_ast.mts +1 -1
  8. package/core/src/nako_colors.mjs +0 -1
  9. package/core/src/nako_colors.mts +1 -1
  10. package/core/src/nako_core_version.mjs +2 -2
  11. package/core/src/nako_core_version.mts +2 -2
  12. package/core/src/nako_csv.mjs +0 -1
  13. package/core/src/nako_csv.mts +9 -9
  14. package/core/src/nako_errors.mts +8 -8
  15. package/core/src/nako_from_dncl.mts +5 -5
  16. package/core/src/nako_from_dncl2.mjs +0 -1
  17. package/core/src/nako_from_dncl2.mts +5 -5
  18. package/core/src/nako_gen.mjs +13 -15
  19. package/core/src/nako_gen.mts +224 -220
  20. package/core/src/nako_global.mts +11 -11
  21. package/core/src/nako_indent.mts +92 -92
  22. package/core/src/nako_indent_chars.mts +1 -1
  23. package/core/src/nako_indent_inline.mjs +11 -11
  24. package/core/src/nako_indent_inline.mts +20 -20
  25. package/core/src/nako_lex_rules.mjs +0 -1
  26. package/core/src/nako_lex_rules.mts +8 -8
  27. package/core/src/nako_lexer.mjs +0 -1
  28. package/core/src/nako_lexer.mts +23 -23
  29. package/core/src/nako_logger.mjs +1 -1
  30. package/core/src/nako_logger.mts +38 -38
  31. package/core/src/nako_parser3.mjs +4 -5
  32. package/core/src/nako_parser3.mts +79 -79
  33. package/core/src/nako_parser_base.mjs +1 -1
  34. package/core/src/nako_parser_base.mts +68 -68
  35. package/core/src/nako_parser_const.mjs +0 -1
  36. package/core/src/nako_parser_const.mts +1 -1
  37. package/core/src/nako_prepare.mts +12 -12
  38. package/core/src/nako_source_mapping.mts +9 -9
  39. package/core/src/nako_token.mjs +0 -1
  40. package/core/src/nako_token.mts +2 -2
  41. package/core/src/nako_tools.mjs +0 -1
  42. package/core/src/nako_tools.mts +4 -4
  43. package/core/src/nako_types.mjs +0 -1
  44. package/core/src/nako_types.mts +3 -3
  45. package/core/src/plugin_api.mjs +0 -1
  46. package/core/src/plugin_api.mts +1 -1
  47. package/core/src/plugin_csv.mjs +0 -1
  48. package/core/src/plugin_csv.mts +7 -7
  49. package/core/src/plugin_math.mjs +0 -1
  50. package/core/src/plugin_math.mts +39 -40
  51. package/core/src/plugin_promise.mjs +1 -1
  52. package/core/src/plugin_promise.mts +9 -9
  53. package/core/src/plugin_system.mjs +1 -10
  54. package/core/src/plugin_system.mts +319 -321
  55. package/core/src/plugin_test.mjs +0 -2
  56. package/core/src/plugin_test.mts +6 -6
  57. package/core/src/plugin_toml.mjs +1 -1
  58. package/core/src/plugin_toml.mts +4 -4
  59. package/core/test/flow_test.mjs +22 -0
  60. package/package.json +31 -34
  61. package/release/_hash.txt +24 -24
  62. package/release/_script-tags.txt +16 -16
  63. package/release/command_cnako3.json +1 -1
  64. package/release/edit_main.js +33 -21
  65. package/release/edit_main.js.map +4 -4
  66. package/release/editor.js +33 -21
  67. package/release/plugin_keigo.js.map +2 -2
  68. package/release/plugin_turtle.js.map +2 -2
  69. package/release/plugin_weykturtle3d.js.map +2 -2
  70. package/release/version.js +29 -17
  71. package/release/version_main.js +29 -17
  72. package/release/version_main.js.map +4 -4
  73. package/release/wnako3.js +51 -44
  74. package/release/wnako3.js.map +3 -3
  75. package/release/wnako3webworker.js +45 -38
  76. package/release/wnako3webworker.js.map +2 -2
  77. package/src/cnako3.mts +1 -1
  78. package/src/cnako3mod.mjs +4 -7
  79. package/src/cnako3mod.mts +24 -24
  80. package/src/commander_ja.mts +8 -8
  81. package/src/deno_wrapper.mjs +0 -1
  82. package/src/deno_wrapper.mts +5 -5
  83. package/src/nako_version.mjs +2 -2
  84. package/src/nako_version.mts +2 -2
  85. package/src/plugin_browser.mjs +21 -29
  86. package/src/plugin_browser.mts +30 -35
  87. package/src/plugin_browser_ajax.mts +27 -27
  88. package/src/plugin_browser_audio.mjs +0 -1
  89. package/src/plugin_browser_audio.mts +11 -11
  90. package/src/plugin_browser_camera.mts +8 -8
  91. package/src/plugin_browser_canvas.mjs +0 -2
  92. package/src/plugin_browser_canvas.mts +34 -34
  93. package/src/plugin_browser_chart.mjs +0 -1
  94. package/src/plugin_browser_chart.mts +13 -13
  95. package/src/plugin_browser_color.mts +2 -2
  96. package/src/plugin_browser_crypto.mts +5 -5
  97. package/src/plugin_browser_dialog.mts +4 -4
  98. package/src/plugin_browser_dom_basic.mts +42 -42
  99. package/src/plugin_browser_dom_event.mjs +0 -1
  100. package/src/plugin_browser_dom_event.mts +27 -28
  101. package/src/plugin_browser_dom_parts.mjs +0 -2
  102. package/src/plugin_browser_dom_parts.mts +31 -31
  103. package/src/plugin_browser_geolocation.mts +3 -3
  104. package/src/plugin_browser_hotkey.mts +3 -3
  105. package/src/plugin_browser_html.mts +4 -4
  106. package/src/plugin_browser_in_worker.mts +1 -1
  107. package/src/plugin_browser_location.mts +2 -2
  108. package/src/plugin_browser_speech.mts +7 -7
  109. package/src/plugin_browser_storage.mts +11 -11
  110. package/src/plugin_browser_system.mts +2 -2
  111. package/src/plugin_browser_websocket.mts +6 -6
  112. package/src/plugin_httpserver.mts +17 -17
  113. package/src/plugin_keigo.mts +5 -5
  114. package/src/plugin_node.mjs +7 -48
  115. package/src/plugin_node.mts +114 -145
  116. package/src/plugin_turtle.mts +143 -143
  117. package/src/plugin_weykturtle3d.mjs +0 -3
  118. package/src/plugin_weykturtle3d.mts +135 -135
  119. package/src/plugin_weykturtle3d_three.mjs +0 -1
  120. package/src/plugin_weykturtle3d_three.mts +1 -1
  121. package/src/plugin_weykturtle3d_threeutil.mts +3 -3
  122. package/src/wnako3.mjs +0 -1
  123. package/src/wnako3.mts +1 -1
  124. package/src/wnako3_editor.mjs +0 -2
  125. package/src/wnako3_editor.mts +132 -132
  126. package/src/wnako3mod.mjs +0 -5
  127. package/src/wnako3mod.mts +19 -19
@@ -11,7 +11,7 @@ export class NakoError extends Error {
11
11
  public line: number | undefined
12
12
  public positionJa: string
13
13
 
14
- constructor (tag: string, msg: string, file: string | undefined = undefined, line: number | undefined = undefined) {
14
+ constructor(tag: string, msg: string, file: string | undefined = undefined, line: number | undefined = undefined) {
15
15
  // エラー位置を分かりやすく日本語に変換
16
16
  const positionJa = `${file || ''}${line === undefined ? '' : `(${line + 1}行目): `}`
17
17
  // #1223 エラーメッセージに「main__関数名」と表示されるので、main__は省略して表示
@@ -33,7 +33,7 @@ export class NakoIndentError extends NakoError {
33
33
  * @param {number} line
34
34
  * @param {string} file
35
35
  */
36
- constructor (msg: string, line: number, file: string) {
36
+ constructor(msg: string, line: number, file: string) {
37
37
  super('インデントエラー', msg, file, line)
38
38
  this.type = 'NakoIndentError'
39
39
  this.line = line
@@ -52,7 +52,7 @@ export class InternalLexerError extends NakoError {
52
52
  * @param {number | undefined} [line]
53
53
  * @param {string | undefined} [file]
54
54
  */
55
- constructor (msg: string, preprocessedCodeStartOffset: number, preprocessedCodeEndOffset: number, line: number | undefined, file: string | undefined) {
55
+ constructor(msg: string, preprocessedCodeStartOffset: number, preprocessedCodeEndOffset: number, line: number | undefined, file: string | undefined) {
56
56
  super('字句解析エラー(内部エラー)', msg, file, line)
57
57
  this.type = 'InternalLexerError'
58
58
  this.preprocessedCodeStartOffset = preprocessedCodeStartOffset
@@ -72,7 +72,7 @@ export class NakoLexerError extends NakoError {
72
72
  * @param {number | undefined} line
73
73
  * @param {string | undefined} file
74
74
  */
75
- constructor (
75
+ constructor(
76
76
  msg: string,
77
77
  startOffset: number,
78
78
  endOffset: number,
@@ -96,7 +96,7 @@ export class NakoSyntaxError extends NakoError {
96
96
  * @param {Ast} first
97
97
  * @param {Ast} [last]
98
98
  */
99
- public static fromNode (msg: string, first: Ast | Token | SourceMap, last: Ast|undefined = undefined) {
99
+ public static fromNode(msg: string, first: Ast | Token | SourceMap, last: Ast|undefined = undefined) {
100
100
  if (!first) {
101
101
  return new NakoSyntaxError(msg, undefined, undefined, undefined, undefined)
102
102
  }
@@ -115,7 +115,7 @@ export class NakoSyntaxError extends NakoError {
115
115
  * @param {number | undefined} endOffset
116
116
  * @param {string | undefined} file
117
117
  */
118
- constructor (msg: string, line: number | undefined, startOffset: number | undefined, endOffset: number | undefined, file: string | undefined) {
118
+ constructor(msg: string, line: number | undefined, startOffset: number | undefined, endOffset: number | undefined, file: string | undefined) {
119
119
  super('文法エラー', msg, file, line)
120
120
  this.type = 'NakoSyntaxError'
121
121
  this.file = file
@@ -131,7 +131,7 @@ export class NakoRuntimeError extends NakoError {
131
131
  * @param error エラー
132
132
  * @param lineNo 発生行
133
133
  */
134
- constructor (error: Error | string, lineNo: string | undefined) {
134
+ constructor(error: Error | string, lineNo: string | undefined) {
135
135
  let msg = 'unknown'
136
136
  if (typeof error === 'string') {
137
137
  msg = error
@@ -183,7 +183,7 @@ export class NakoImportError extends NakoError {
183
183
  * @param {string} file
184
184
  * @param {number} line
185
185
  */
186
- constructor (msg: string, file: string, line: number) {
186
+ constructor(msg: string, file: string, line: number) {
187
187
  super('取り込みエラー', msg, file, line)
188
188
  this.file = file
189
189
  this.line = line
@@ -23,7 +23,7 @@ const DNCL_SIMPLES: { [key: string]: string[] } = {
23
23
  /**
24
24
  * DNCLのソースコードをなでしこに変換する
25
25
  */
26
- export function convertDNCL (tokens: Token[]): Token[] {
26
+ export function convertDNCL(tokens: Token[]): Token[] {
27
27
  if (!useDNCLmode(tokens)) { return tokens }
28
28
 
29
29
  // 一行ずつに分ける
@@ -192,7 +192,7 @@ export function convertDNCL (tokens: Token[]): Token[] {
192
192
  return tokens
193
193
  }
194
194
 
195
- function replaceAllElementV (line: Token[], ni: number): void {
195
+ function replaceAllElementV(line: Token[], ni: number): void {
196
196
  //
197
197
  // const ni = findTokens(line, ['word:すべて', 'word:要素'])
198
198
  //
@@ -210,7 +210,7 @@ function replaceAllElementV (line: Token[], ni: number): void {
210
210
  line.splice(ni, 4, eq, begin, val, end, times, mul)
211
211
  }
212
212
 
213
- function replaceAtohantei (tokens: Token[], fi: number): void {
213
+ function replaceAtohantei(tokens: Token[], fi: number): void {
214
214
  // `ここまで、(${r[1]})になるまでの間`
215
215
  const wo = findTokens(tokens, ['word:を'])
216
216
  if (wo >= 0) {
@@ -226,7 +226,7 @@ function replaceAtohantei (tokens: Token[], fi: number): void {
226
226
  tokens[fi + 1].value = '間'
227
227
  }
228
228
 
229
- function findTokens (tokens: Token[], findTypeValue: string[]): number {
229
+ function findTokens(tokens: Token[], findTypeValue: string[]): number {
230
230
  const findA = findTypeValue.map(s => s.split(':'))
231
231
  for (let i = 0; i < tokens.length; i++) {
232
232
  let flag = true
@@ -246,7 +246,7 @@ function findTokens (tokens: Token[], findTypeValue: string[]): number {
246
246
  return -1
247
247
  }
248
248
 
249
- function useDNCLmode (tokens: Token[]): boolean {
249
+ function useDNCLmode(tokens: Token[]): boolean {
250
250
  // 先頭の100語調べる
251
251
  for (let i = 0; i < tokens.length; i++) {
252
252
  if (i > 100) { break }
@@ -1,4 +1,3 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
2
1
  /**
3
2
  * DNCL ver2 に対応する構文
4
3
  */
@@ -1,4 +1,4 @@
1
- /* eslint-disable @typescript-eslint/no-explicit-any */
1
+
2
2
  /**
3
3
  * DNCL ver2 に対応する構文
4
4
  */
@@ -31,7 +31,7 @@ const DNCL_SIMPLES: { [key: string]: string[] } = {
31
31
  /**
32
32
  * DNCLのソースコードをなでしこに変換する
33
33
  */
34
- export function convertDNCL2 (tokens: Token[]): Token[] {
34
+ export function convertDNCL2(tokens: Token[]): Token[] {
35
35
  if (!useDNCL2mode(tokens)) { return tokens }
36
36
 
37
37
  // 一行ずつに分ける
@@ -272,7 +272,7 @@ export function convertDNCL2 (tokens: Token[]): Token[] {
272
272
  * @param fromIndex 検索場所
273
273
  * @returns 合致したかどうか
274
274
  */
275
- function tokenEq (typeValues: any[], lines: Token[], fromIndex: number): boolean {
275
+ function tokenEq(typeValues: any[], lines: Token[], fromIndex: number): boolean {
276
276
  const check = (pattern: string|Array<string>, t: { type: string, value: string }): boolean => {
277
277
  if (pattern instanceof Array) {
278
278
  for (let i = 0; i < pattern.length; i++) {
@@ -298,7 +298,7 @@ function tokenEq (typeValues: any[], lines: Token[], fromIndex: number): boolean
298
298
  return true
299
299
  }
300
300
 
301
- function findTokens (tokens: Token[], findTypeValue: string[]): number {
301
+ function findTokens(tokens: Token[], findTypeValue: string[]): number {
302
302
  const findA = findTypeValue.map(s => s.split(':'))
303
303
  for (let i = 0; i < tokens.length; i++) {
304
304
  let flag = true
@@ -318,7 +318,7 @@ function findTokens (tokens: Token[], findTypeValue: string[]): number {
318
318
  return -1
319
319
  }
320
320
 
321
- function useDNCL2mode (tokens: Token[]): boolean {
321
+ function useDNCL2mode(tokens: Token[]): boolean {
322
322
  // 先頭の100語調べる
323
323
  for (let i = 0; i < tokens.length; i++) {
324
324
  if (i > 100) { break }
@@ -1,5 +1,3 @@
1
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
2
- /* eslint-disable @typescript-eslint/no-explicit-any */
3
1
  /**
4
2
  * パーサーが生成した中間オブジェクトを実際のJavaScriptのコードに変換する。
5
3
  * なお速度優先で忠実にJavaScriptのコードを生成する。
@@ -225,7 +223,6 @@ export class NakoGen {
225
223
  }
226
224
  /** @param {Ast} node */
227
225
  static convPrint(node) {
228
- // eslint-disable-next-line @typescript-eslint/restrict-template-expressions
229
226
  return `__print(${node});`;
230
227
  }
231
228
  /** @param {AstStrValue} node */
@@ -347,7 +344,6 @@ export class NakoGen {
347
344
  }
348
345
  const name = t.name;
349
346
  this.usedFuncSet.add(name);
350
- // eslint-disable-next-line @typescript-eslint/no-empty-function
351
347
  this.__self.__varslist[1].set(name, () => { }); // 事前に適当な値を設定
352
348
  this.varslistSet[1].names.add(name); // global
353
349
  const meta = t.meta;
@@ -356,7 +352,6 @@ export class NakoGen {
356
352
  }
357
353
  this.nakoFuncList.set(name, {
358
354
  josi: meta.josi,
359
- // eslint-disable-next-line @typescript-eslint/no-empty-function
360
355
  fn: () => { },
361
356
  type: 'func',
362
357
  asyncFn: !!t.asyncFn,
@@ -661,10 +656,7 @@ export class NakoGen {
661
656
  commentSrc = commentSrc.replace(/\*\//g, '*/');
662
657
  commentSrc = commentSrc.replace(/(^\s+|\s+$)/g, '');
663
658
  // コメントの行番号を得る
664
- let lineNo = this.convLineno(node, false);
665
- if (node.line === 0) {
666
- lineNo = ''; // 0行目なら行番号は更新なし
667
- }
659
+ const lineNo = this.convLineno(node, false);
668
660
  if (commentSrc === '' && lineNo === '') {
669
661
  return ';';
670
662
  }
@@ -857,7 +849,6 @@ export class NakoGen {
857
849
  // 既に generate で作成済みのはず(念のため)
858
850
  this.nakoFuncList.set(name, {
859
851
  josi: node.meta.josi,
860
- // eslint-disable-next-line @typescript-eslint/no-empty-function
861
852
  fn: () => { },
862
853
  type: 'func',
863
854
  asyncFn: false,
@@ -1062,7 +1053,7 @@ export class NakoGen {
1062
1053
  if (valueNode.type !== 'nop') {
1063
1054
  value = this._convGen(valueNode, true);
1064
1055
  }
1065
- if (value == null) {
1056
+ if (value === null) {
1066
1057
  throw NakoSyntaxError.fromNode('代入する先の変数名がありません。', node);
1067
1058
  }
1068
1059
  code += ' = ' + value + ';\n';
@@ -1129,7 +1120,7 @@ export class NakoGen {
1129
1120
  `const ${varTemp} = ${temp};\n` +
1130
1121
  `const ${varFrom} = ${kara};\n` +
1131
1122
  `const ${varTo} = ${made};\n` +
1132
- `if (${varFrom} <= ${varTo}) { // up\n` +
1123
+ `if (${varFrom} < ${varTo}) { // up\n` +
1133
1124
  ` if (${String(flagUp)}) {` +
1134
1125
  ` for (let ${varI} = ${varFrom}; ${varI} <= ${varTo}; ${varI}+= ${inc}) {\n` +
1135
1126
  ` ${sorePrefex};${loopVarSetter}\n` +
@@ -1138,7 +1129,7 @@ export class NakoGen {
1138
1129
  ' // for block end\n' +
1139
1130
  ' };\n' +
1140
1131
  ' };\n' +
1141
- '} else { // down\n' +
1132
+ `} else if (${varFrom} > ${varTo}) { // down\n` +
1142
1133
  ` if (${String(flagDown)}) {` +
1143
1134
  ` for (let ${varI} = ${varFrom}; ${varI} >= ${varTo}; ${varI}-= ${inc}) {\n` +
1144
1135
  ` ${sorePrefex};${loopVarSetter}\n` +
@@ -1147,6 +1138,13 @@ export class NakoGen {
1147
1138
  ' // for block end\n' +
1148
1139
  ' }\n' +
1149
1140
  ' };\n' +
1141
+ '} else { // from == to\n' +
1142
+ ` for (let ${varI} = ${varFrom}; ${varI} <= ${varTo}; ${varI}+= 1) {\n` +
1143
+ ` ${sorePrefex};${loopVarSetter}\n` +
1144
+ ' // for block begin\n' +
1145
+ ` ${block}\n` +
1146
+ ' // for block end\n' +
1147
+ ' };\n' +
1150
1148
  '};\n' +
1151
1149
  `//[/convFor id=${idLoop}]\n`;
1152
1150
  return code;
@@ -1776,7 +1774,7 @@ export class NakoGen {
1776
1774
  value = this._convGen(astValue, true);
1777
1775
  }
1778
1776
  // 戻り値の検証
1779
- if (value == null) {
1777
+ if (value === null) {
1780
1778
  throw NakoSyntaxError.fromNode('代入する先の変数名がありません。', node);
1781
1779
  }
1782
1780
  // 変数名
@@ -2355,7 +2353,7 @@ function removeDuplicateChars(code) {
2355
2353
  continue;
2356
2354
  }
2357
2355
  // 文字列・正規表現・テンプレートリテラルの開始チェック
2358
- if (ch === '"' || ch === "'") {
2356
+ if (ch === '"' || ch === '\'') {
2359
2357
  inString = true;
2360
2358
  stringDelimiter = ch;
2361
2359
  result.push(ch);