nadesiko3 3.2.43 → 3.2.44

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.
@@ -250,6 +250,10 @@
250
250
  !*** ./node_modules/core-js/internals/to-string.js ***!
251
251
  \*****************************************************/
252
252
 
253
+ /*!*****************************************************!*\
254
+ !*** ./node_modules/regenerator-runtime/runtime.js ***!
255
+ \*****************************************************/
256
+
253
257
  /*!*****************************************************!*\
254
258
  !*** ./node_modules/whatwg-fetch/dist/fetch.umd.js ***!
255
259
  \*****************************************************/
package/src/nako3.js CHANGED
@@ -666,7 +666,7 @@ class NakoCompiler {
666
666
  }
667
667
  try {
668
668
  // eslint-disable-next-line no-new-func
669
- new Function(out.runtimeEnv).apply(nakoGlobal)
669
+ new Function(out.runtimeEnv).apply(nakoGlobal);
670
670
  return nakoGlobal
671
671
  } catch (e) {
672
672
  let err = e
package/src/nako_gen.js CHANGED
@@ -37,6 +37,19 @@ class NakoGen {
37
37
  if (js && isTest) {
38
38
  js += '\n__self._runTests(__tests);\n'
39
39
  }
40
+ // async method
41
+ if (gen.numAsyncFn > 0) {
42
+ let canAsync = true
43
+ if (window && window.navigator && window.navigator.userAgent) {
44
+ const ua = window.navigator.userAgent
45
+ canAsync = (ua.indexOf('MSIE') === -1)
46
+ }
47
+ if (canAsync) {
48
+ js = '// <nadesiko3::gen::async>\n' +
49
+ `(async () => {\n${js}\n})();\n` +
50
+ '// </nadesiko3::gen::async>\n'
51
+ }
52
+ }
40
53
 
41
54
  // デバッグメッセージ
42
55
  com.logger.trace('--- generate ---\n' + js)
@@ -61,7 +74,7 @@ this.__locals = {};
61
74
  this.__genMode = 'sync';
62
75
  try {
63
76
  ${gen.getVarsCode()}
64
- ${js}
77
+ ${js}
65
78
  } catch (err) {
66
79
  if (!(err instanceof NakoRuntimeError)) {
67
80
  err = new NakoRuntimeError(err, __varslist[0].line);
@@ -103,6 +116,12 @@ try {
103
116
  */
104
117
  this.loop_id = 1
105
118
 
119
+ /**
120
+ * 非同関数を何回使ったか
121
+ * @type {number}
122
+ */
123
+ this.numAsyncFn = 0
124
+
106
125
  /**
107
126
  * 変換中の処理が、ループの中かどうかを判定する
108
127
  * @type {boolean}
@@ -1272,7 +1291,10 @@ try {
1272
1291
  }
1273
1292
 
1274
1293
  let funcCall = `${res.js}(${argsCode})`
1275
- if (func.asyncFn) { funcCall = `await ${funcCall}` }
1294
+ if (func.asyncFn) {
1295
+ funcCall = `await ${funcCall}`
1296
+ this.numAsyncFn++
1297
+ }
1276
1298
  if (res.i === 0 && this.performanceMonitor.systemFunctionBody !== 0) {
1277
1299
  let key = funcName
1278
1300
  if (!key) {
@@ -1,8 +1,8 @@
1
1
  // なでしこバージョン
2
2
  const nakoVersion = {
3
- version: '3.2.43',
3
+ version: '3.2.44',
4
4
  major: 3,
5
5
  minor: 2,
6
- patch: 43
6
+ patch: 44
7
7
  }
8
8
  module.exports = nakoVersion
@@ -68,7 +68,7 @@ module.exports = {
68
68
  },
69
69
  return_none: true
70
70
  },
71
- 'POSTデータ生成': { // @連想配列をkey=value&key=value...の形式に変換する // @POSTでーたせいせい
71
+ 'POSTデータ生成': { // @辞書形式のデータPARAMSをkey=value&key=value...の形式に変換する // @POSTでーたせいせい
72
72
  type: 'func',
73
73
  josi: [['の', 'を']],
74
74
  pure: true,
@@ -136,7 +136,7 @@ module.exports = {
136
136
  }
137
137
  },
138
138
  'AJAXオプション': { type: 'const', value: '' }, // @AJAXおぷしょん
139
- 'AJAXオプション設定': { // @Ajax命令でオプションを設定 // @AJAXおぷしょんせってい
139
+ 'AJAXオプション設定': { // @AJAX命令でオプションを設定 // @AJAXおぷしょんせってい
140
140
  type: 'func',
141
141
  josi: [['に', 'へ', 'と']],
142
142
  pure: true,
@@ -145,6 +145,23 @@ module.exports = {
145
145
  },
146
146
  return_none: true
147
147
  },
148
+ 'AJAXオプションPOST設定': { // @AJAXオプションにPOSTメソッドとパラメータPARAMSを設定 // @AJAXおぷしょんPOSTせってい
149
+ type: 'func',
150
+ josi: [['を', 'で']],
151
+ pure: true,
152
+ fn: function (params, sys) {
153
+ const bodyData = sys.__exec('POSTデータ生成', [params, sys])
154
+ const options = {
155
+ method: 'POST',
156
+ headers: {
157
+ 'Content-Type': 'application/x-www-form-urlencoded'
158
+ },
159
+ body: bodyData
160
+ }
161
+ sys.__v0['AJAXオプション'] = options
162
+ },
163
+ return_none: true
164
+ },
148
165
  'AJAX送信': { // @逐次実行構文にて、非同期通信(Ajax)でURLにデータを送信する。成功すると『対象』にデータが代入される。 // @AJAXそうしん
149
166
  type: 'func',
150
167
  josi: [['まで', 'へ', 'に']],
@@ -349,5 +366,34 @@ module.exports = {
349
366
  return res.body()
350
367
  },
351
368
  return_none: false
352
- }
369
+ },
370
+ // @新AJAX
371
+ 'AJAXテキスト取得': { // @AJAXでURLにアクセスしテキスト形式で結果を得る。送信時AJAXオプションの値を参照。 // @AJAXてきすとしゅとく
372
+ type: 'func',
373
+ josi: [['から']],
374
+ pure: true,
375
+ asyncFn: true,
376
+ fn: async function (url, sys) {
377
+ let options = sys.__v0['AJAXオプション']
378
+ if (options === '') { options = { method: 'GET' } }
379
+ const res = await fetch(url, options)
380
+ const txt = await res.text()
381
+ return txt
382
+ },
383
+ return_none: true
384
+ },
385
+ 'AJAX_JSON取得': { // @AJAXでURLにアクセスしJSONの結果を得て、送信時AJAXオプションの値を参照。 // @AJAX_JSONしゅとく
386
+ type: 'func',
387
+ josi: [['から']],
388
+ pure: true,
389
+ asyncFn: true,
390
+ fn: async function (url, sys) {
391
+ let options = sys.__v0['AJAXオプション']
392
+ if (options === '') { options = { method: 'GET' } }
393
+ const res = await fetch(url, options)
394
+ const txt = await res.json()
395
+ return txt
396
+ },
397
+ return_none: true
398
+ },
353
399
  }