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.
Files changed (178) hide show
  1. package/README.md +1 -1
  2. package/bin/cnako3 +1 -1
  3. package/bin/cnako3.bat +1 -1
  4. package/demo/browsers.html +9 -10
  5. package/demo/flow.html +1 -0
  6. package/demo/runscript3.html +35 -0
  7. package/demo/turtle3.html +18 -17
  8. package/demo/turtle3d.html +1 -1
  9. package/demo/turtle3d2.html +1 -1
  10. package/doc/browsers.md +9 -10
  11. package/package.json +58 -57
  12. package/release/_hash.txt +57 -52
  13. package/release/_script-tags.txt +14 -13
  14. package/release/command.json +1 -1
  15. package/release/command.json.js +1 -1
  16. package/release/command_cnako3.json +1 -1
  17. package/release/command_list.json +1 -1
  18. package/release/editor.js +1 -1
  19. package/release/editor.js.LICENSE.txt +9 -12
  20. package/release/nako_gen_async.js +1 -1
  21. package/release/nako_gen_async.js.LICENSE.txt +10 -666
  22. package/release/plugin_caniuse.js +1 -1
  23. package/release/plugin_caniuse.js.LICENSE.txt +9 -425
  24. package/release/plugin_csv.js +1 -1
  25. package/release/plugin_csv.js.LICENSE.txt +3 -419
  26. package/release/plugin_datetime.js +1 -1
  27. package/release/plugin_datetime.js.LICENSE.txt +6 -530
  28. package/release/plugin_kansuji.js +1 -1
  29. package/release/plugin_kansuji.js.LICENSE.txt +3 -559
  30. package/release/plugin_markup.js +1 -1
  31. package/release/plugin_markup.js.LICENSE.txt +4 -420
  32. package/release/plugin_turtle.js +1 -1
  33. package/release/plugin_turtle.js.LICENSE.txt +12 -500
  34. package/release/plugin_webworker.js +1 -1
  35. package/release/plugin_webworker.js.LICENSE.txt +3 -563
  36. package/release/plugin_weykturtle3d.js +1 -0
  37. package/release/plugin_weykturtle3d.js.LICENSE.txt +3 -0
  38. package/release/stats.json +1 -1
  39. package/release/version.js +1 -1
  40. package/release/version.js.LICENSE.txt +9 -12
  41. package/release/wnako3.js +1 -1
  42. package/release/wnako3.js.LICENSE.txt +1 -1
  43. package/release/wnako3webworker.js +1 -1
  44. package/release/wnako3webworker.js.LICENSE.txt +1 -1117
  45. package/src/browsers.mjs +1 -0
  46. package/src/browsers.txt +15 -15
  47. package/src/browsers_agents.mjs +1 -0
  48. package/src/cnako3.mjs +13 -0
  49. package/src/{cnako3.js → cnako3mod.mjs} +119 -101
  50. package/src/{commander_ja.js → commander_ja.mjs} +16 -11
  51. package/src/{enako3.js → enako3.mjs} +0 -0
  52. package/src/{era.json → era.mjs} +1 -1
  53. package/src/image_turtle-elephant.mjs +5 -0
  54. package/src/image_turtle-panda.mjs +5 -0
  55. package/src/image_turtle64.mjs +5 -0
  56. package/src/index.mjs +9 -0
  57. package/src/{nako3.js → nako3.mjs} +69 -57
  58. package/src/{nako3_assert.js → nako3_assert.mjs} +7 -6
  59. package/src/{nako3server.js → nako3server.mjs} +12 -5
  60. package/src/{nako_colors.js → nako_colors.mjs} +1 -1
  61. package/src/{nako_errors.js → nako_errors.mjs} +10 -20
  62. package/src/{nako_from_dncl.js → nako_from_dncl.mjs} +11 -8
  63. package/src/{nako_gen.js → nako_gen.mjs} +93 -87
  64. package/src/{nako_gen_async.js → nako_gen_async.mjs} +5 -8
  65. package/src/{nako_global.js → nako_global.mjs} +4 -5
  66. package/src/{nako_indent.js → nako_indent.mjs} +29 -25
  67. package/src/{nako_josi_list.js → nako_josi_list.mjs} +16 -14
  68. package/src/nako_lex_rules.mjs +244 -0
  69. package/src/{nako_lexer.js → nako_lexer.mjs} +7 -10
  70. package/src/{nako_logger.js → nako_logger.mjs} +3 -4
  71. package/src/{nako_parser3.js → nako_parser3.mjs} +5 -5
  72. package/src/{nako_parser_base.js → nako_parser_base.mjs} +1 -9
  73. package/src/{nako_parser_const.js → nako_parser_const.mjs} +2 -6
  74. package/src/{nako_prepare.js → nako_prepare.mjs} +46 -8
  75. package/src/{nako_reserved_words.js → nako_reserved_words.mjs} +1 -1
  76. package/src/{nako_source_mapping.js → nako_source_mapping.mjs} +4 -11
  77. package/src/{nako_test.js → nako_test.mjs} +0 -0
  78. package/src/nako_version.mjs +7 -0
  79. package/src/{plugin_browser.js → plugin_browser.mjs} +30 -30
  80. package/src/{plugin_browser_ajax.js → plugin_browser_ajax.mjs} +7 -7
  81. package/src/{plugin_browser_audio.js → plugin_browser_audio.mjs} +1 -1
  82. package/src/{plugin_browser_canvas.js → plugin_browser_canvas.mjs} +1 -1
  83. package/src/{plugin_browser_chart.js → plugin_browser_chart.mjs} +1 -1
  84. package/src/{plugin_browser_color.js → plugin_browser_color.mjs} +1 -1
  85. package/src/{plugin_browser_crypto.js → plugin_browser_crypto.mjs} +1 -1
  86. package/src/{plugin_browser_dialog.js → plugin_browser_dialog.mjs} +1 -1
  87. package/src/{plugin_browser_dom_basic.js → plugin_browser_dom_basic.mjs} +1 -1
  88. package/src/{plugin_browser_dom_event.js → plugin_browser_dom_event.mjs} +1 -1
  89. package/src/{plugin_browser_dom_parts.js → plugin_browser_dom_parts.mjs} +1 -1
  90. package/src/{plugin_browser_geolocation.js → plugin_browser_geolocation.mjs} +1 -1
  91. package/src/{plugin_browser_hotkey.js → plugin_browser_hotkey.mjs} +2 -2
  92. package/src/{plugin_browser_html.js → plugin_browser_html.mjs} +1 -1
  93. package/src/{plugin_browser_in_worker.js → plugin_browser_in_worker.mjs} +4 -4
  94. package/src/{plugin_browser_location.js → plugin_browser_location.mjs} +1 -1
  95. package/src/{plugin_browser_speech.js → plugin_browser_speech.mjs} +1 -1
  96. package/src/{plugin_browser_storage.js → plugin_browser_storage.mjs} +1 -1
  97. package/src/{plugin_browser_system.js → plugin_browser_system.mjs} +1 -1
  98. package/src/{plugin_browser_websocket.js → plugin_browser_websocket.mjs} +1 -1
  99. package/src/{plugin_caniuse.js → plugin_caniuse.mjs} +8 -3
  100. package/src/{plugin_csv.js → plugin_csv.mjs} +4 -5
  101. package/src/{plugin_datetime.js → plugin_datetime.mjs} +19 -26
  102. package/src/{plugin_express.js → plugin_express.mjs} +4 -3
  103. package/src/{plugin_kansuji.js → plugin_kansuji.mjs} +1 -1
  104. package/src/{plugin_keigo.js → plugin_keigo.mjs} +1 -1
  105. package/src/{plugin_markup.js → plugin_markup.mjs} +6 -6
  106. package/src/{plugin_math.js → plugin_math.mjs} +1 -4
  107. package/src/{plugin_node.js → plugin_node.mjs} +25 -57
  108. package/src/{plugin_promise.js → plugin_promise.mjs} +1 -3
  109. package/src/{plugin_system.js → plugin_system.mjs} +32 -15
  110. package/src/{plugin_test.js → plugin_test.mjs} +1 -3
  111. package/src/{plugin_turtle.js → plugin_turtle.mjs} +5 -4
  112. package/src/{plugin_webworker.js → plugin_webworker.mjs} +3 -3
  113. package/src/{plugin_weykturtle3d.js → plugin_weykturtle3d.mjs} +1 -3
  114. package/src/{plugin_worker.js → plugin_worker.mjs} +4 -1
  115. package/src/{wnako3.js → wnako3.mjs} +24 -14
  116. package/src/{wnako3_editor.js → wnako3_editor.mjs} +28 -22
  117. package/src/{wnako3webworker.js → wnako3webworker.mjs} +0 -0
  118. package/test/async/{async_basic_test.js → async_basic_test.mjs} +3 -4
  119. package/test/browser/karma.config.js +9 -0
  120. package/test/browser/test/plugin_browser_test.js +2 -2
  121. package/test/browser/test/plugin_turtle_test.js +2 -2
  122. package/test/browser/test/plugin_webworker_test.js +3 -3
  123. package/test/browser/test/require_test.js +2 -2
  124. package/test/common/{array_test.js → array_test.mjs} +3 -3
  125. package/test/common/{basic_test.js → basic_test.mjs} +3 -13
  126. package/test/common/{calc_test.js → calc_test.mjs} +2 -2
  127. package/test/common/{debug_test.js → debug_test.mjs} +2 -2
  128. package/test/common/{dncl_test.js → dncl_test.mjs} +3 -3
  129. package/test/common/{error_test.js → error_test.mjs} +2 -2
  130. package/test/common/{flow_test.js → flow_test.mjs} +2 -2
  131. package/test/common/{func_call.js → func_call.mjs} +3 -3
  132. package/test/common/{func_test.js → func_test.mjs} +2 -2
  133. package/test/common/{indent_test.js → indent_test.mjs} +3 -2
  134. package/test/common/{lex_test.js → lex_test.mjs} +2 -2
  135. package/test/common/{literal_test.js → literal_test.mjs} +3 -2
  136. package/test/common/{nako_logger_test.js → nako_logger_test.mjs} +3 -3
  137. package/test/common/{plugin_browser_test.js → plugin_browser_test.mjs} +4 -4
  138. package/test/common/{plugin_browser_ut_audio_test.js → plugin_browser_ut_audio_test.mjs} +4 -4
  139. package/test/common/{plugin_browser_ut_color_test.js → plugin_browser_ut_color_test.mjs} +2 -2
  140. package/test/common/{plugin_browser_ut_dialog_test.js → plugin_browser_ut_dialog_test.mjs} +3 -3
  141. package/test/common/{plugin_browser_ut_html_test.js → plugin_browser_ut_html_test.mjs} +2 -2
  142. package/test/common/{plugin_browser_ut_system_test.js → plugin_browser_ut_system_test.mjs} +2 -2
  143. package/test/common/{plugin_csv_test.js → plugin_csv_test.mjs} +3 -3
  144. package/test/common/{plugin_datetime_test.js → plugin_datetime_test.mjs} +4 -4
  145. package/test/common/{plugin_kansuji_test.js → plugin_kansuji_test.mjs} +3 -3
  146. package/test/common/{plugin_markup_test.js → plugin_markup_test.mjs} +3 -3
  147. package/test/common/{plugin_promise_test.js → plugin_promise_test.mjs} +2 -2
  148. package/test/common/{plugin_system_test.js → plugin_system_test.mjs} +2 -2
  149. package/test/common/{prepare_test.js → prepare_test.mjs} +2 -2
  150. package/test/common/{re_test.js → re_test.mjs} +2 -2
  151. package/test/common/{variable_scope_test.js → variable_scope_test.mjs} +2 -2
  152. package/test/karma.config.js +3 -3
  153. package/test/node/{async_test.js → async_test.mjs} +4 -2
  154. package/test/node/{commander_ja_test.js → commander_ja_test.mjs} +17 -12
  155. package/test/node/{error_message_test.js → error_message_test.mjs} +13 -10
  156. package/test/node/node_test.mjs +57 -0
  157. package/test/node/{plugin_browser_ut_ajax_test.js → plugin_browser_ut_ajax_test.mjs} +7 -5
  158. package/test/node/{plugin_browser_ut_location_test.js → plugin_browser_ut_location_test.mjs} +3 -3
  159. package/test/node/{plugin_markup_test.js → plugin_markup_test.mjs} +6 -7
  160. package/test/node/{plugin_math_test.js → plugin_math_test.mjs} +5 -5
  161. package/test/node/{plugin_node_test.js → plugin_node_test.mjs} +11 -7
  162. package/test/node/{plugin_test.js → plugin_test.mjs} +11 -5
  163. package/test/node/{require_nako3_test.js → require_nako3_test.mjs} +19 -12
  164. package/test/node/{side_effects_test.js → side_effects_test.mjs} +24 -13
  165. package/test/node/{wnako3_editor_test.js → wnako3_editor_test.mjs} +16 -9
  166. package/tools/nako3edit/html/daisyui/LICENSE +22 -0
  167. package/tools/nako3edit/html/daisyui/full.css +1 -0
  168. package/tools/nako3edit/html/daisyui/tailwind.min.css +1 -0
  169. package/tools/nako3edit/html/daisyui/version_2.14.1 +1 -0
  170. package/tools/nako3edit/html/edit.html +104 -19
  171. package/tools/nako3edit/html/files.html +84 -8
  172. package/tools/nako3edit/html/nako3edit.css +6 -7
  173. package/tools/nako3edit/index.nako3 +45 -6
  174. package/tools/nako3edit/{run.js → run.mjs} +8 -2
  175. package/src/index.js +0 -5
  176. package/src/nako_lex_rules.js +0 -260
  177. package/src/nako_version.js +0 -8
  178. package/test/node/node_test.js +0 -43
@@ -1,5 +1,10 @@
1
1
  // @ts-nocheck
2
2
  // file: plugin_datetime.js
3
+ import dayjs from 'dayjs'
4
+ import _ja from 'dayjs/locale/ja.js'
5
+
6
+ import era from './era.mjs'
7
+
3
8
  const PluginDateTime = {
4
9
  '初期化': {
5
10
  type: 'func',
@@ -9,13 +14,12 @@ const PluginDateTime = {
9
14
  }
10
15
  },
11
16
  // @日時処理
12
- '元号データ': { type: 'const', value: require('./era.json') }, // @げんごうでーた
17
+ '元号データ': { type: 'const', value: era }, // @げんごうでーた
13
18
  '今': { // @現在時刻を「HH:mm:ss」の形式で返す // @いま
14
19
  type: 'func',
15
20
  josi: [],
16
21
  pure: true,
17
22
  fn: function () {
18
- const dayjs = require('dayjs')
19
23
  return dayjs().format('HH:mm:ss')
20
24
  }
21
25
  },
@@ -24,7 +28,6 @@ const PluginDateTime = {
24
28
  josi: [],
25
29
  pure: true,
26
30
  fn: function () {
27
- const dayjs = require('dayjs')
28
31
  return dayjs().unix()
29
32
  }
30
33
  },
@@ -33,7 +36,6 @@ const PluginDateTime = {
33
36
  josi: [],
34
37
  pure: true,
35
38
  fn: function () {
36
- const dayjs = require('dayjs')
37
39
  return dayjs().format('YYYY/MM/DD')
38
40
  }
39
41
  },
@@ -42,7 +44,6 @@ const PluginDateTime = {
42
44
  josi: [],
43
45
  pure: true,
44
46
  fn: function () {
45
- const dayjs = require('dayjs')
46
47
  return dayjs().add(1, 'days').format('YYYY/MM/DD')
47
48
  }
48
49
  },
@@ -51,7 +52,6 @@ const PluginDateTime = {
51
52
  josi: [],
52
53
  pure: true,
53
54
  fn: function () {
54
- const dayjs = require('dayjs')
55
55
  return dayjs().subtract(1, 'days').format('YYYY/MM/DD')
56
56
  }
57
57
  },
@@ -60,7 +60,6 @@ const PluginDateTime = {
60
60
  josi: [],
61
61
  pure: true,
62
62
  fn: function () {
63
- const dayjs = require('dayjs')
64
63
  return dayjs().year()
65
64
  }
66
65
  },
@@ -69,7 +68,7 @@ const PluginDateTime = {
69
68
  josi: [],
70
69
  pure: true,
71
70
  fn: function () {
72
- const dayjs = require('dayjs')
71
+
73
72
  return dayjs().add(1, 'years').year()
74
73
  }
75
74
  },
@@ -78,7 +77,7 @@ const PluginDateTime = {
78
77
  josi: [],
79
78
  pure: true,
80
79
  fn: function () {
81
- const dayjs = require('dayjs')
80
+
82
81
  return dayjs().subtract(1, 'years').year()
83
82
  }
84
83
  },
@@ -87,7 +86,7 @@ const PluginDateTime = {
87
86
  josi: [],
88
87
  pure: true,
89
88
  fn: function () {
90
- const dayjs = require('dayjs')
89
+
91
90
  return dayjs().month() + 1
92
91
  }
93
92
  },
@@ -96,7 +95,7 @@ const PluginDateTime = {
96
95
  josi: [],
97
96
  pure: true,
98
97
  fn: function () {
99
- const dayjs = require('dayjs')
98
+
100
99
  return dayjs().add(1, 'months').month() + 1
101
100
  }
102
101
  },
@@ -105,7 +104,7 @@ const PluginDateTime = {
105
104
  josi: [],
106
105
  pure: true,
107
106
  fn: function () {
108
- const dayjs = require('dayjs')
107
+
109
108
  return dayjs().subtract(1, 'months').month() + 1
110
109
  }
111
110
  },
@@ -114,8 +113,6 @@ const PluginDateTime = {
114
113
  josi: [['の']],
115
114
  pure: true,
116
115
  fn: function (s) {
117
- const dayjs = require('dayjs')
118
- require('dayjs/locale/ja')
119
116
  return dayjs(s, 'YYYY/MM/DD').locale('ja').format('ddd')
120
117
  }
121
118
  },
@@ -124,11 +121,7 @@ const PluginDateTime = {
124
121
  josi: [['の']],
125
122
  pure: true,
126
123
  fn: function (s) {
127
- const dayjs = require('dayjs')
128
- require('dayjs/locale/ja')
129
-
130
124
  let t = dayjs(s, 'YYYY/MM/DD')
131
-
132
125
  if (!t.isValid()) {
133
126
  t = dayjs()
134
127
  }
@@ -149,7 +142,7 @@ const PluginDateTime = {
149
142
  josi: [['の', 'を', 'から']],
150
143
  pure: true,
151
144
  fn: function (s) {
152
- const dayjs = require('dayjs')
145
+
153
146
  return dayjs(s, 'YYYY/MM/DD HH:mm:ss').unix()
154
147
  }
155
148
  },
@@ -158,7 +151,7 @@ const PluginDateTime = {
158
151
  josi: [['を', 'から']],
159
152
  pure: true,
160
153
  fn: function (tm) {
161
- const dayjs = require('dayjs')
154
+
162
155
  return dayjs.unix(tm).format('YYYY/MM/DD HH:mm:ss')
163
156
  }
164
157
  },
@@ -167,7 +160,7 @@ const PluginDateTime = {
167
160
  josi: [['を']],
168
161
  pure: true,
169
162
  fn: function (s, sys) {
170
- const dayjs = require('dayjs')
163
+
171
164
  const date = dayjs(s, 'YYYY/MM/DD')
172
165
 
173
166
  for (const era of sys.__v0['元号データ']) {
@@ -215,7 +208,7 @@ const PluginDateTime = {
215
208
  josi: [['と', 'から'], ['の', 'までの'], ['による']],
216
209
  pure: true,
217
210
  fn: function (a, b, unit) {
218
- const dayjs = require('dayjs')
211
+
219
212
 
220
213
  switch (unit) {
221
214
  case '年':
@@ -339,10 +332,7 @@ const PluginDateTime = {
339
332
  josi: [['に'], ['を']],
340
333
  pure: true,
341
334
  fn: function (s, a) {
342
- const dayjs = require('dayjs')
343
-
344
335
  let unit
345
-
346
336
  switch (a.match(/(年|ヶ月|日|時間|分|秒)$/)[0]) {
347
337
  case '年':
348
338
  unit = 'years'
@@ -408,7 +398,10 @@ const PluginDateTime = {
408
398
  }
409
399
  }
410
400
 
411
- module.exports = PluginDateTime
401
+ export default PluginDateTime
402
+
412
403
  // scriptタグで取り込んだ時、自動で登録する
413
404
  /* istanbul ignore else */
414
405
  if (typeof (navigator) === 'object' && typeof (navigator.nako3) === 'object') { navigator.nako3.addPluginObject('PluginDateTime', PluginDateTime) }
406
+
407
+
@@ -3,8 +3,8 @@
3
3
  * file: plugin_express.js
4
4
  * Webサーバのためのプラグイン (expressをラップしたもの)
5
5
  */
6
- const express = require('express')
7
- const bodyParser = require('body-parser')
6
+ import express from 'express'
7
+ import bodyParser from 'body-parser'
8
8
 
9
9
  // 定数・変数
10
10
  let WEBSERVER_NAME = 'WEBサーバ(なでしこ+Express)'
@@ -209,4 +209,5 @@ function callbackServerFunc (callback, req, res, sys) {
209
209
  callback(req, res)
210
210
  }
211
211
 
212
- module.exports = PluginExpress
212
+ // module.exports = PluginExpress
213
+ export default PluginExpress
@@ -218,7 +218,7 @@ const 軸数字 = [
218
218
  const 基本算用数字 = '0123456789'.split('')
219
219
  const 基本漢数字 = '〇一二三四五六七八九'.split('')
220
220
 
221
- module.exports = PluginKansuji
221
+ export default PluginKansuji
222
222
 
223
223
  // scriptタグで取り込んだ時、自動で登録する
224
224
  if (typeof (navigator) === 'object' && typeof (navigator.nako3) === 'object') { navigator.nako3.addPluginObject('PluginKansuji', PluginKansuji) }
@@ -52,4 +52,4 @@ const PluginKeigo = {
52
52
 
53
53
  }
54
54
 
55
- module.exports = PluginKeigo
55
+ export default PluginKeigo
@@ -3,6 +3,10 @@
3
3
  * file: plugin_markup.js
4
4
  * マークアップ言語関連のプラグイン
5
5
  */
6
+
7
+ import { parse as parseMD } from 'marked'
8
+ import html from 'html'
9
+
6
10
  const PluginMarkup = {
7
11
  // @マークアップ
8
12
  'マークダウンHTML変換': { // @マークダウン形式で記述された文字列SをHTML形式に変換する // @まーくだうんHTMLへんかん
@@ -10,8 +14,7 @@ const PluginMarkup = {
10
14
  josi: [['を']],
11
15
  pure: true,
12
16
  fn: function (s) {
13
- const marked = require('marked')
14
- const html = marked.parse(s)
17
+ const html = parseMD(s)
15
18
  return html
16
19
  }
17
20
  },
@@ -20,13 +23,10 @@ const PluginMarkup = {
20
23
  josi: [['を']],
21
24
  pure: true,
22
25
  fn: function (s) {
23
- const html = require('html')
24
26
  return html.prettyPrint(s, { indent_size: 2 })
25
27
  }
26
28
  }
27
29
  }
28
-
29
- module.exports = PluginMarkup
30
-
30
+ export default PluginMarkup
31
31
  // scriptタグで取り込んだ時、自動で登録する
32
32
  if (typeof (navigator) === 'object') { navigator.nako3.addPluginObject('PluginMarkup', PluginMarkup) }
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- const PluginMath = {
2
+ export default {
3
3
  '初期化': {
4
4
  type: 'func',
5
5
  josi: [],
@@ -321,7 +321,4 @@ const PluginMath = {
321
321
  return Math.floor(v)
322
322
  }
323
323
  }
324
-
325
324
  }
326
-
327
- module.exports = PluginMath
@@ -1,46 +1,30 @@
1
- // @ts-nocheck
2
1
  /**
3
2
  * file: plugin_node.js
4
3
  * node.js のためのプラグイン
5
4
  */
6
- const fs = require('fs')
7
- const fse = require('fs-extra')
8
- const fetch = require('node-fetch')
9
- const childProcess = require('child_process')
10
- const execSync = childProcess.execSync
11
- const exec = childProcess.exec
12
- const path = require('path')
5
+ import fs from 'fs'
6
+ import fse from 'fs-extra'
7
+ import fetch from 'node-fetch'
8
+ import { exec, execSync } from 'child_process'
9
+ import path from 'path'
10
+ import iconv from 'iconv-lite'
11
+ import opener from 'opener'
12
+ import clipboardy from 'clipboardy'
13
+ import assert from 'assert'
14
+ // 「標準入力取得時」で利用
15
+ import * as readline from 'readline'
16
+ import { stdin as input, stdout as output } from 'process'
17
+ // ハッシュ関数で利用
18
+ import crypto from 'crypto'
19
+ import os from 'os'
20
+ import sendkeysJS from 'sendkeys-js'
13
21
 
14
- const PluginNode = {
22
+ export default {
15
23
  '初期化': {
16
24
  type: 'func',
17
25
  josi: [],
18
26
  pure: true,
19
27
  fn: function (sys) {
20
- // ランタイム環境無しで実行する場合
21
- if (typeof path === 'undefined') {
22
- /** @param {string} name @param {string} id */
23
- const tryRequire = (name, id) => {
24
- try {
25
- // @ts-ignore
26
- global[name] = require(id)
27
- } catch (e) {
28
- console.warn(e.message)
29
- }
30
- }
31
- tryRequire('fs', 'fs')
32
- tryRequire('fse', 'fs-extra')
33
- tryRequire('fetch', 'node-fetch')
34
- tryRequire('childProcess', 'child_process')
35
- tryRequire('path', 'path')
36
- if (typeof childProcess !== 'undefined') {
37
- // @ts-ignore
38
- global.execSync = childProcess.execSync
39
- // @ts-ignore
40
- global.exec = childProcess.exec
41
- }
42
- }
43
-
44
28
  sys.__getBinPath = (tool) => {
45
29
  let fpath = tool
46
30
  if (process.platform === 'win32') {
@@ -109,7 +93,6 @@ const PluginNode = {
109
93
  josi: [['を', 'から']],
110
94
  pure: true,
111
95
  fn: function (s, sys) {
112
- const iconv = require('iconv-lite')
113
96
  iconv.skipDecodeWarning = true
114
97
  const buf = fs.readFileSync(s)
115
98
  const text = iconv.decode(Buffer.from(buf), 'sjis')
@@ -121,7 +104,6 @@ const PluginNode = {
121
104
  josi: [['を'], ['へ', 'に']],
122
105
  pure: true,
123
106
  fn: function (s, f, sys) {
124
- const iconv = require('iconv-lite')
125
107
  iconv.skipDecodeWarning = true
126
108
  const buf = iconv.encode(s, 'Shift_JIS')
127
109
  fs.writeFileSync(f, buf)
@@ -163,7 +145,6 @@ const PluginNode = {
163
145
  josi: [['を']],
164
146
  pure: true,
165
147
  fn: function (url) {
166
- const opener = require('opener')
167
148
  opener(url)
168
149
  }
169
150
  },
@@ -575,7 +556,6 @@ const PluginNode = {
575
556
  josi: [['を']],
576
557
  pure: true,
577
558
  fn: function (v, sys) {
578
- const clipboardy = require('clipboardy')
579
559
  // copy
580
560
  if (sys && sys.isSetter) { return clipboardy.writeSync(v) }
581
561
  // paste
@@ -591,7 +571,7 @@ const PluginNode = {
591
571
  josi: [['を']],
592
572
  pure: true,
593
573
  fn: function (callback) {
594
- const reader = require('readline').createInterface({
574
+ const reader = readline.createInterface({
595
575
  input: process.stdin,
596
576
  output: process.stdout
597
577
  })
@@ -604,9 +584,10 @@ const PluginNode = {
604
584
  type: 'func',
605
585
  josi: [['と', 'を']],
606
586
  pure: true,
607
- fn: function (msg, sys) {
608
- const readlineSync = require('readline-sync')
609
- const res = readlineSync.question(msg)
587
+ asyncFn: true,
588
+ fn: async function (msg, sys) {
589
+ const rl = readline.createInterface({ input, output });
590
+ const res = await rl.question(msg)
610
591
  if (res.match(/^[0-9.]+$/)) { return parseFloat(res) }
611
592
  return res
612
593
  }
@@ -617,7 +598,7 @@ const PluginNode = {
617
598
  josi: [['と'], ['が']],
618
599
  pure: true,
619
600
  fn: function (a, b, sys) {
620
- const assert = require('assert')
601
+
621
602
  assert.strictEqual(a, b)
622
603
  }
623
604
  },
@@ -627,7 +608,6 @@ const PluginNode = {
627
608
  josi: [],
628
609
  pure: true,
629
610
  fn: function (sys) {
630
- const os = require('os')
631
611
  const nif = os.networkInterfaces()
632
612
  /**
633
613
  * @type {string[]}
@@ -647,7 +627,6 @@ const PluginNode = {
647
627
  josi: [],
648
628
  pure: true,
649
629
  fn: function (sys) {
650
- const os = require('os')
651
630
  const nif = os.networkInterfaces()
652
631
  const result = []
653
632
  for (const dev in nif) {
@@ -925,7 +904,6 @@ const PluginNode = {
925
904
  josi: [['の', 'を']],
926
905
  pure: true,
927
906
  fn: function (code, sys) {
928
- const iconv = require('iconv-lite')
929
907
  return iconv.encodingExists(code)
930
908
  }
931
909
  },
@@ -934,7 +912,6 @@ const PluginNode = {
934
912
  josi: [['に', 'へ', 'を']],
935
913
  pure: true,
936
914
  fn: function (str, sys) {
937
- const iconv = require('iconv-lite')
938
915
  iconv.skipDecodeWarning = true
939
916
  return iconv.encode(str, 'Shift_JIS')
940
917
  }
@@ -944,7 +921,6 @@ const PluginNode = {
944
921
  josi: [['から', 'を', 'で']],
945
922
  pure: true,
946
923
  fn: function (buf, sys) {
947
- const iconv = require('iconv-lite')
948
924
  iconv.skipDecodeWarning = true
949
925
  return iconv.decode(Buffer.from(buf), 'sjis')
950
926
  }
@@ -954,7 +930,6 @@ const PluginNode = {
954
930
  josi: [['を'], ['へ', 'で']],
955
931
  pure: true,
956
932
  fn: function (s, code, sys) {
957
- const iconv = require('iconv-lite')
958
933
  iconv.skipDecodeWarning = true
959
934
  return iconv.encode(s, code)
960
935
  }
@@ -964,7 +939,6 @@ const PluginNode = {
964
939
  josi: [['を'], ['から', 'で']],
965
940
  pure: true,
966
941
  fn: function (buf, code, sys) {
967
- const iconv = require('iconv-lite')
968
942
  iconv.skipDecodeWarning = true
969
943
  return iconv.decode(Buffer.from(buf), code)
970
944
  }
@@ -975,8 +949,7 @@ const PluginNode = {
975
949
  josi: [['を', 'の']],
976
950
  pure: true,
977
951
  fn: function (s, sys) {
978
- const keys = require('sendkeys-js')
979
- keys.sendKeys(s)
952
+ sendkeysJS.sendKeys(s)
980
953
  },
981
954
  return_none: true
982
955
  },
@@ -985,8 +958,7 @@ const PluginNode = {
985
958
  josi: [['を', 'の']],
986
959
  pure: true,
987
960
  fn: function (s, sys) {
988
- const keys = require('sendkeys-js')
989
- keys.activate(s)
961
+ sendkeysJS.activate(s)
990
962
  },
991
963
  return_none: true
992
964
  },
@@ -996,7 +968,6 @@ const PluginNode = {
996
968
  josi: [],
997
969
  pure: true,
998
970
  fn: function (sys) {
999
- const crypto = require('crypto')
1000
971
  return crypto.getHashes()
1001
972
  }
1002
973
  },
@@ -1005,7 +976,6 @@ const PluginNode = {
1005
976
  josi: [['を'], ['の'], ['で']],
1006
977
  pure: true,
1007
978
  fn: function (s, alg, enc, sys) {
1008
- const crypto = require('crypto')
1009
979
  const hashsum = crypto.createHash(alg)
1010
980
  hashsum.update(s)
1011
981
  return hashsum.digest(enc)
@@ -1031,5 +1001,3 @@ function isDir (f) {
1031
1001
  return false
1032
1002
  }
1033
1003
  }
1034
-
1035
- module.exports = PluginNode
@@ -1,5 +1,5 @@
1
1
  // @ts-nocheck
2
- const PluginPromise = {
2
+ export default {
3
3
  '初期化': {
4
4
  type: 'func',
5
5
  josi: [],
@@ -90,5 +90,3 @@ const PluginPromise = {
90
90
  return_none: false
91
91
  }
92
92
  }
93
-
94
- module.exports = PluginPromise
@@ -1,8 +1,8 @@
1
1
  // @ts-nocheck
2
- const { NakoRuntimeError } = require('./nako_errors')
3
- const NakoVersion = require('./nako_version')
2
+ import { NakoRuntimeError } from './nako_errors.mjs'
3
+ import NakoVersion from './nako_version.mjs'
4
4
 
5
- const PluginSystem = {
5
+ export default {
6
6
  'meta': {
7
7
  type: 'const',
8
8
  value: {
@@ -2526,22 +2526,41 @@ const PluginSystem = {
2526
2526
  type: 'func',
2527
2527
  josi: [],
2528
2528
  pure: true,
2529
+ asyncFn: true,
2529
2530
  fn: function () {
2530
- const josi = require('./nako_josi_list.js')
2531
- return josi.josiList
2531
+ return new Promise((resolve, reject) => {
2532
+ import('./nako_josi_list.mjs')
2533
+ .then((mod) => {
2534
+ const obj = Object.assign({}, mod)
2535
+ resolve(obj.josiList)
2536
+ })
2537
+ .catch((err) => {
2538
+ reject(err)
2539
+ })
2540
+ })
2532
2541
  }
2533
2542
  },
2534
2543
  '予約語一覧取得': { // @文法として定義されている予約語の一覧を取得する // @よやくごいちらんしゅとく
2535
2544
  type: 'func',
2536
2545
  josi: [],
2537
2546
  pure: true,
2547
+ asyncFn: true,
2538
2548
  fn: function () {
2539
- const words = require('./nako_reserved_words.js')
2540
- const w = []
2541
- for (const key in words) {
2542
- w.push(key)
2543
- }
2544
- return w
2549
+ // const words = require('./nako_reserved_words.mjs')
2550
+ return new Promise((resolve, reject) => {
2551
+ import('./nako_reserved_words.mjs')
2552
+ .then((mod) => {
2553
+ const obj = Object.assign({}, mod)
2554
+ const w = []
2555
+ for (const key in obj.default) {
2556
+ w.push(key)
2557
+ }
2558
+ resolve(w)
2559
+ })
2560
+ .catch((err) => {
2561
+ reject(err)
2562
+ })
2563
+ })
2545
2564
  }
2546
2565
  },
2547
2566
  // @プラグイン管理
@@ -2603,7 +2622,7 @@ const PluginSystem = {
2603
2622
  pure: true,
2604
2623
  fn: function (text) {
2605
2624
  // browser?
2606
- if (window.btoa) {
2625
+ if (typeof(window) !== 'undefined' && window.btoa) {
2607
2626
  const utf8str = String.fromCharCode.apply(null, new TextEncoder('UTF-8').encode(text))
2608
2627
  return btoa(utf8str)
2609
2628
  } else {
@@ -2616,7 +2635,7 @@ const PluginSystem = {
2616
2635
  josi: [['を', 'へ', 'に']],
2617
2636
  pure: true,
2618
2637
  fn: function (text) {
2619
- if (window.atob) {
2638
+ if (typeof(window) !== 'undefined' && window.atob) {
2620
2639
  const decodedUtf8str = atob(text)
2621
2640
  const decodedArray = new Uint8Array(Array.prototype.map.call(decodedUtf8str, c => c.charCodeAt()))
2622
2641
  return new TextDecoder('UTF-8').decode(decodedArray)
@@ -2626,5 +2645,3 @@ const PluginSystem = {
2626
2645
  }
2627
2646
  }
2628
2647
  }
2629
-
2630
- module.exports = PluginSystem
@@ -3,7 +3,7 @@
3
3
  * file: plugin_test.js
4
4
  * テスト実行用プラグイン
5
5
  */
6
- const PluginTest = {
6
+ export default {
7
7
  // @テスト
8
8
  'ASSERT等': { // @ テストで、ASSERTでAとBが正しいことを報告する // @ASSERTひとしい
9
9
  type: 'func',
@@ -34,5 +34,3 @@ const PluginTest = {
34
34
  }
35
35
 
36
36
  }
37
-
38
- module.exports = PluginTest
@@ -4,9 +4,9 @@
4
4
  * plugin_turtle.js
5
5
  */
6
6
 
7
- const turtleImage = require('./turtle64.png').default
8
- const elephantImage = require('./turtle-elephant.png').default
9
- const pandaImage = require('./turtle-panda.png').default
7
+ import turtleImage from './image_turtle64.mjs'
8
+ import elephantImage from './image_turtle-elephant.mjs'
9
+ import pandaImage from './image_turtle-panda.mjs'
10
10
 
11
11
  const PluginTurtle = {
12
12
  '初期化': {
@@ -639,7 +639,8 @@ const PluginTurtle = {
639
639
  }
640
640
  }
641
641
 
642
- module.exports = PluginTurtle
642
+ // module.exports = PluginTurtle
643
+ export default PluginTurtle
643
644
 
644
645
  // scriptタグで取り込んだ時、自動で登録する
645
646
  /* istanbul ignore else */
@@ -326,9 +326,9 @@ const PluginWebWorker = {
326
326
  }
327
327
  }
328
328
 
329
+ export default PluginWebWorker
330
+
329
331
  if (typeof (navigator) === 'object' && typeof (navigator.nako3) === 'object') {
330
332
  navigator.nako3.addPluginObject('PluginWebWorker', PluginWebWorker)
331
333
  }
332
- if (typeof (module) === 'object') {
333
- module.exports = PluginWebWorker
334
- }
334
+
@@ -1206,9 +1206,7 @@ const PluginWeykTurtle3D = {
1206
1206
  }
1207
1207
  }
1208
1208
 
1209
- if (typeof (global) === 'object' && typeof (global.process) === 'object') {
1210
- module.exports = PluginWeykTurtle3D
1211
- }
1209
+ export default PluginWeykTurtle3D
1212
1210
 
1213
1211
  // ブラウザからscriptタグで取り込んだ時、自動で登録する
1214
1212
  if (typeof (navigator) === 'object') {
@@ -89,4 +89,7 @@ const PluginWorker = {
89
89
  }
90
90
  }
91
91
 
92
- module.exports = PluginWorker
92
+ // module.exports = PluginWorker
93
+ export default PluginWorker
94
+
95
+