nadesiko3 3.2.27
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/LICENSE +21 -0
- package/README.md +107 -0
- package/bin/cnako3 +10 -0
- package/bin/cnako3.bat +11 -0
- package/bin/nako3server.bat +6 -0
- package/demo/ace_editor.html +90 -0
- package/demo/ace_editor_tabs.html +162 -0
- package/demo/basic.html +71 -0
- package/demo/browsers.html +128 -0
- package/demo/css/basic.css +3 -0
- package/demo/css/common.css +157 -0
- package/demo/css/editor.css +8 -0
- package/demo/css/flow.css +3 -0
- package/demo/css/index.css +3 -0
- package/demo/extlib/ace@1.4.12/ace.js +17 -0
- package/demo/extlib/ace@1.4.12/ext-code_lens.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-language_tools.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-options.min.js +1 -0
- package/demo/extlib/ace@1.4.12/ext-settings_menu.js +8 -0
- package/demo/extlib/ace@1.4.12/keybinding-vscode.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-monokai.js +8 -0
- package/demo/extlib/ace@1.4.12/theme-xcode.js +8 -0
- package/demo/extlib/chart.js@3.2.1/chart.min.js +13 -0
- package/demo/extlib/pure-min.css +11 -0
- package/demo/flow.html +97 -0
- package/demo/graph.html +53 -0
- package/demo/image/nako.png +0 -0
- package/demo/image/nakopad-icon256.png +0 -0
- package/demo/image/turtle.fla +0 -0
- package/demo/image/turtle.png +0 -0
- package/demo/index.html +134 -0
- package/demo/js/common.js +17 -0
- package/demo/js/turtle3d_test.js +44 -0
- package/demo/js/turtle_test.js +44 -0
- package/demo/runscript.html +47 -0
- package/demo/runscript2.html +33 -0
- package/demo/turtle.html +58 -0
- package/demo/turtle2.html +141 -0
- package/demo/turtle3.html +278 -0
- package/demo/turtle3d.html +58 -0
- package/demo/turtle3d2.html +107 -0
- package/demo/version.html +24 -0
- package/doc/SETUP.md +172 -0
- package/doc/about.md +34 -0
- package/doc/browsers.md +60 -0
- package/doc/docgen.md +21 -0
- package/doc/editor.md +44 -0
- package/doc/files.md +37 -0
- package/doc/plugins.md +195 -0
- package/doc/release.md +78 -0
- package/doc/win32.md +57 -0
- package/package.json +196 -0
- package/release/_hash.txt +65 -0
- package/release/_script-tags.txt +13 -0
- package/release/command.json +1 -0
- package/release/command.json.js +1 -0
- package/release/command_cnako3.json +1 -0
- package/release/command_list.json +1 -0
- package/release/editor.js +2 -0
- package/release/editor.js.LICENSE.txt +32 -0
- package/release/josi.json +48 -0
- package/release/nako_gen_async.js +1 -0
- package/release/nako_gen_async.js.LICENSE.txt +595 -0
- package/release/plugin_caniuse.js +1 -0
- package/release/plugin_caniuse.js.LICENSE.txt +411 -0
- package/release/plugin_csv.js +1 -0
- package/release/plugin_csv.js.LICENSE.txt +367 -0
- package/release/plugin_datetime.js +1 -0
- package/release/plugin_datetime.js.LICENSE.txt +471 -0
- package/release/plugin_kansuji.js +1 -0
- package/release/plugin_kansuji.js.LICENSE.txt +491 -0
- package/release/plugin_markup.js +1 -0
- package/release/plugin_markup.js.LICENSE.txt +363 -0
- package/release/plugin_turtle.js +1 -0
- package/release/plugin_turtle.js.LICENSE.txt +435 -0
- package/release/plugin_webworker.js +1 -0
- package/release/plugin_webworker.js.LICENSE.txt +491 -0
- package/release/version.js +2 -0
- package/release/version.js.LICENSE.txt +32 -0
- package/release/wnako3.js +2 -0
- package/release/wnako3.js.LICENSE.txt +1 -0
- package/release/wnako3webworker.js +1 -0
- package/release/wnako3webworker.js.LICENSE.txt +847 -0
- package/release/yoyakugo.json +30 -0
- package/src/browsers.md +60 -0
- package/src/cnako3.js +466 -0
- package/src/commander_ja.js +154 -0
- package/src/enako3.js +69 -0
- package/src/era.json +22 -0
- package/src/index.js +5 -0
- package/src/nako3.js +836 -0
- package/src/nako3_assert.js +37 -0
- package/src/nako3editorfix.sfd +106 -0
- package/src/nako3editorfix.woff +0 -0
- package/src/nako3server.js +51 -0
- package/src/nako_colors.js +86 -0
- package/src/nako_errors.js +176 -0
- package/src/nako_gen.js +1459 -0
- package/src/nako_gen_async.js +1622 -0
- package/src/nako_global.js +113 -0
- package/src/nako_indent.js +480 -0
- package/src/nako_josi_list.js +46 -0
- package/src/nako_lex_rules.js +259 -0
- package/src/nako_lexer.js +576 -0
- package/src/nako_logger.js +138 -0
- package/src/nako_parser3.js +1768 -0
- package/src/nako_parser_base.js +265 -0
- package/src/nako_parser_const.js +37 -0
- package/src/nako_prepare.js +293 -0
- package/src/nako_reserved_words.js +35 -0
- package/src/nako_source_mapping.js +251 -0
- package/src/nako_test.js +37 -0
- package/src/nako_version.js +8 -0
- package/src/plugin_browser.js +191 -0
- package/src/plugin_browser_ajax.js +352 -0
- package/src/plugin_browser_audio.js +109 -0
- package/src/plugin_browser_canvas.js +462 -0
- package/src/plugin_browser_chart.js +296 -0
- package/src/plugin_browser_color.js +49 -0
- package/src/plugin_browser_crypto.js +26 -0
- package/src/plugin_browser_dialog.js +53 -0
- package/src/plugin_browser_dom_basic.js +322 -0
- package/src/plugin_browser_dom_event.js +193 -0
- package/src/plugin_browser_dom_parts.js +163 -0
- package/src/plugin_browser_geolocation.js +51 -0
- package/src/plugin_browser_hotkey.js +25 -0
- package/src/plugin_browser_html.js +59 -0
- package/src/plugin_browser_in_worker.js +44 -0
- package/src/plugin_browser_location.js +21 -0
- package/src/plugin_browser_speech.js +111 -0
- package/src/plugin_browser_storage.js +121 -0
- package/src/plugin_browser_system.js +12 -0
- package/src/plugin_browser_websocket.js +73 -0
- package/src/plugin_caniuse.js +24 -0
- package/src/plugin_csv.js +57 -0
- package/src/plugin_datetime.js +414 -0
- package/src/plugin_express.js +212 -0
- package/src/plugin_kansuji.js +224 -0
- package/src/plugin_keigo.js +55 -0
- package/src/plugin_markup.js +32 -0
- package/src/plugin_math.js +319 -0
- package/src/plugin_node.js +1018 -0
- package/src/plugin_promise.js +94 -0
- package/src/plugin_system.js +2109 -0
- package/src/plugin_test.js +38 -0
- package/src/plugin_turtle.js +646 -0
- package/src/plugin_webworker.js +334 -0
- package/src/plugin_weykturtle3d.js +1216 -0
- package/src/plugin_worker.js +92 -0
- package/src/repl.nako3 +63 -0
- package/src/turtle-elephant.png +0 -0
- package/src/turtle-panda.png +0 -0
- package/src/turtle64.png +0 -0
- package/src/wnako3.js +162 -0
- package/src/wnako3_editor.css +215 -0
- package/src/wnako3_editor.js +1645 -0
- package/src/wnako3_editor_marker_red.png +0 -0
- package/src/wnako3_editor_marker_red.xcf +0 -0
- package/src/wnako3_editor_marker_yellow.png +0 -0
- package/src/wnako3_editor_marker_yellow.xcf +0 -0
- package/src/wnako3webworker.js +70 -0
- package/test/ace_editor/karma.config.js +94 -0
- package/test/ace_editor/test/.babelrc.json +3 -0
- package/test/ace_editor/test/ace_editor_test.js +178 -0
- package/test/ace_editor/test/html/custom_context.html +140 -0
- package/test/async/async_basic_test.js +124 -0
- package/test/browser/karma.config.js +212 -0
- package/test/browser/test/.babelrc.json +3 -0
- package/test/browser/test/compare_util.js +50 -0
- package/test/browser/test/html/canvas_basic.html +1 -0
- package/test/browser/test/html/div_basic.html +2 -0
- package/test/browser/test/html/event_dom_form.html +4 -0
- package/test/browser/test/html/event_dom_scrolldiv.html +5 -0
- package/test/browser/test/image/canvas_test1.png +0 -0
- package/test/browser/test/image/canvas_test2.png +0 -0
- package/test/browser/test/image/canvas_test3.png +0 -0
- package/test/browser/test/image/canvas_test4.png +0 -0
- package/test/browser/test/image/canvas_test7.png +0 -0
- package/test/browser/test/image/canvas_test8.png +0 -0
- package/test/browser/test/image/canvas_test_blank.png +0 -0
- package/test/browser/test/image/elephant_kana.png +0 -0
- package/test/browser/test/image/panda_kana.png +0 -0
- package/test/browser/test/image/turtle_kana.png +0 -0
- package/test/browser/test/import_plugin_checker.js +24 -0
- package/test/browser/test/plugin_browser_test.js +52 -0
- package/test/browser/test/plugin_browser_test_ajax.js +123 -0
- package/test/browser/test/plugin_browser_test_color.js +18 -0
- package/test/browser/test/plugin_browser_test_dialog.js +72 -0
- package/test/browser/test/plugin_browser_test_dom_event.js +598 -0
- package/test/browser/test/plugin_browser_test_dom_parts.js +125 -0
- package/test/browser/test/plugin_browser_test_system.js +9 -0
- package/test/browser/test/plugin_turtle_test.js +817 -0
- package/test/browser/test/plugin_webworker_test.js +87 -0
- package/test/browser/test/require_test.js +71 -0
- package/test/bundled/karma.config.base.js +117 -0
- package/test/bundled/karma.config.js +86 -0
- package/test/bundled/test/.babelrc.json +3 -0
- package/test/bundled/test/bundled_test.js +69 -0
- package/test/bundled/test/html/custom_context.html +65 -0
- package/test/bundled/test/html/custom_debug.html +66 -0
- package/test/bundled/test4b.cmd +52 -0
- package/test/bundled/test_base/.babelrc.json +3 -0
- package/test/bundled/test_base/_checktool_test.js +25 -0
- package/test/bundled/test_base/basic_ajax_test.js +56 -0
- package/test/bundled/test_base/basic_async_test.js +18 -0
- package/test/bundled/test_base/basic_test.js +153 -0
- package/test/bundled/test_base/calc_test.js +132 -0
- package/test/bundled/test_base/css/browsers_box.css +114 -0
- package/test/bundled/test_base/html/custom_context.html +69 -0
- package/test/bundled/test_base/html/custom_debug.html +71 -0
- package/test/bundled/test_base/js/browsers_box.js +72 -0
- package/test/bundled/test_base/plugin_csv_test.js +37 -0
- package/test/bundled/test_base/plugin_datetime_test.js +115 -0
- package/test/bundled/test_base/plugin_kansuji_test.js +49 -0
- package/test/bundled/test_base/plugin_system_test.js +410 -0
- package/test/bundled/test_base/plugin_webworker_test.js +53 -0
- package/test/bundled/test_base/resources/ok.txt +1 -0
- package/test/bundled/test_base/test_utils.js +191 -0
- package/test/common/array_test.js +40 -0
- package/test/common/basic_test.js +317 -0
- package/test/common/calc_test.js +139 -0
- package/test/common/debug_test.js +16 -0
- package/test/common/error_test.js +16 -0
- package/test/common/flow_test.js +360 -0
- package/test/common/func_call.js +136 -0
- package/test/common/func_test.js +149 -0
- package/test/common/indent_test.js +362 -0
- package/test/common/lex_test.js +146 -0
- package/test/common/literal_test.js +72 -0
- package/test/common/nako_logger_test.js +26 -0
- package/test/common/plugin_browser_test.js +24 -0
- package/test/common/plugin_browser_ut_audio_test.js +88 -0
- package/test/common/plugin_browser_ut_color_test.js +21 -0
- package/test/common/plugin_browser_ut_dialog_test.js +100 -0
- package/test/common/plugin_browser_ut_html_test.js +13 -0
- package/test/common/plugin_browser_ut_system_test.js +10 -0
- package/test/common/plugin_csv_test.js +39 -0
- package/test/common/plugin_datetime_test.js +120 -0
- package/test/common/plugin_kansuji_test.js +59 -0
- package/test/common/plugin_promise_test.js +18 -0
- package/test/common/plugin_system_test.js +451 -0
- package/test/common/prepare_test.js +93 -0
- package/test/common/re_test.js +20 -0
- package/test/common/variable_scope_test.js +105 -0
- package/test/jsconfig.json +19 -0
- package/test/karma.config.js +91 -0
- package/test/node/add_test.nako3 +1 -0
- package/test/node/async_test.js +80 -0
- package/test/node/commander_ja_test.js +82 -0
- package/test/node/error_message_test.js +244 -0
- package/test/node/kai_test.nako3 +6 -0
- package/test/node/node_test.js +43 -0
- package/test/node/plugin_broken.js.txt +3 -0
- package/test/node/plugin_browser_ut_ajax_test.js +355 -0
- package/test/node/plugin_browser_ut_location_test.js +32 -0
- package/test/node/plugin_markup_test.js +44 -0
- package/test/node/plugin_math_test.js +42 -0
- package/test/node/plugin_node_test.js +93 -0
- package/test/node/plugin_test.js +16 -0
- package/test/node/relative_import_test_1.nako3 +1 -0
- package/test/node/relative_import_test_2.nako3 +2 -0
- package/test/node/require_nako3_test.js +59 -0
- package/test/node/requiretest.nako3 +4 -0
- package/test/node/requiretest_indirect.nako3 +1 -0
- package/test/node/requiretest_name.nako3 +5 -0
- package/test/node/runtime_error.nako3 +2 -0
- package/test/node/side_effects_test.js +106 -0
- package/test/node/sjis.txt +5 -0
- package/test/node/syntax_error.nako3 +2 -0
- package/test/node/wnako3_editor_test.js +360 -0
- package/tools/README.md +7 -0
- package/tools/nako3edit/html/edit.html +83 -0
- package/tools/nako3edit/html/edit_plugin.js +6 -0
- package/tools/nako3edit/html/files.html +49 -0
- package/tools/nako3edit/html/nako3edit.css +66 -0
- package/tools/nako3edit/index.nako3 +145 -0
- package/tools/nako3edit/run.js +12 -0
- package/tools/nako3server/html/edit.html +104 -0
- package/tools/nako3server/html/edit_plugin.js +6 -0
- package/tools/nako3server/html/files.html +53 -0
- package/tools/nako3server/html/nako3edit.css +66 -0
- package/tools/nako3server/index.nako3 +129 -0
- package/tools/nako3server/run.js +12 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
const multer = require('multer')
|
|
2
|
+
const bodyParserRaw = require('body-parser/lib/types/raw')
|
|
3
|
+
const bodyParserText = require('body-parser/lib/types/text')
|
|
4
|
+
const bodyParserUrlencoded = require('body-parser/lib/types/urlencoded')
|
|
5
|
+
const express = require('express')
|
|
6
|
+
const path = require('path')
|
|
7
|
+
|
|
8
|
+
const storage = multer.diskStorage({
|
|
9
|
+
// ファイルの保存先を指定
|
|
10
|
+
destination: function (req, file, cb) {
|
|
11
|
+
cb(null, 'tmp')
|
|
12
|
+
},
|
|
13
|
+
// ファイル名を指定(オリジナルのファイル名を指定)
|
|
14
|
+
filename: function (req, file, cb) {
|
|
15
|
+
cb(null, file.originalname)
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
const parserUpload = multer({ storage: storage })
|
|
20
|
+
const parserMultipart = multer().none()
|
|
21
|
+
const parserText = bodyParserText({type: ['application/x-www-form-urlencoded','multipart/form-data']})
|
|
22
|
+
const parserRaw = bodyParserRaw({})
|
|
23
|
+
|
|
24
|
+
var CustomMiddlewareFactory = function (config) {
|
|
25
|
+
// /custom/*
|
|
26
|
+
const custom = express.Router()
|
|
27
|
+
|
|
28
|
+
custom.get('/echo.nako3', (req, res) => {
|
|
29
|
+
// 例: http://localhost:9876/custom/echo.nako3?delay_ms=30&content=A%3D20
|
|
30
|
+
setTimeout(() => { res.send(req.query['content']) }, +req.query['delay_ms'])
|
|
31
|
+
})
|
|
32
|
+
custom.get('/cyclic_import_1.nako3', (req, res) => {
|
|
33
|
+
res.send('!「http://localhost:9876/custom/cyclic_import_2.nako3」を取り込む。\nA=100')
|
|
34
|
+
})
|
|
35
|
+
custom.get('/cyclic_import_2.nako3', (req, res) => {
|
|
36
|
+
res.send('!「http://localhost:9876/custom/cyclic_import_1.nako3」を取り込む。\nB=200')
|
|
37
|
+
})
|
|
38
|
+
custom.get('/echo.js', (req, res) => {
|
|
39
|
+
setTimeout(() => { res.send(req.query['content']) }, +req.query['delay_ms'])
|
|
40
|
+
})
|
|
41
|
+
custom.all('/delayedimage/:name', (req, res) => {
|
|
42
|
+
const filename = '/' + req.params.name
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
res.setHeader('Location', filename);
|
|
45
|
+
res.status(307).end()
|
|
46
|
+
}, 500)
|
|
47
|
+
})
|
|
48
|
+
custom.all('/ok', (req, res) => {
|
|
49
|
+
console.log('test')
|
|
50
|
+
res.send('OK')
|
|
51
|
+
})
|
|
52
|
+
custom.all('/ok/json', (req, res) => {
|
|
53
|
+
res.json('OK')
|
|
54
|
+
})
|
|
55
|
+
custom.all('/uploadimage', (req, res) => {
|
|
56
|
+
const type = req.headers['content-type'].split(';')[0]
|
|
57
|
+
if (type === 'multipart/form-data') {
|
|
58
|
+
parserUpload.single('file')(req, res, (err) => {
|
|
59
|
+
if (err) {
|
|
60
|
+
console.log('parse error'+(!!err?' and has error':''))
|
|
61
|
+
console.log(err)
|
|
62
|
+
return res.end(err)
|
|
63
|
+
}
|
|
64
|
+
return res.end('OK')
|
|
65
|
+
})
|
|
66
|
+
} else {
|
|
67
|
+
console.log(type)
|
|
68
|
+
return res.status(501).end('content-type must multipart/form-data')
|
|
69
|
+
}
|
|
70
|
+
})
|
|
71
|
+
custom.all(['/echo', '/echo/json'], (req, res) => {
|
|
72
|
+
const type = req.headers['content-type'].split(';')[0]
|
|
73
|
+
const echos = (err) => {
|
|
74
|
+
if (err) {
|
|
75
|
+
console.log('parse error'+(!!err?' and has error':''))
|
|
76
|
+
console.log(err)
|
|
77
|
+
return res.end(err)
|
|
78
|
+
}
|
|
79
|
+
let data = req.body
|
|
80
|
+
if (req.url.endsWith('/json') || typeof data !== 'string') {
|
|
81
|
+
data = JSON.stringify(data)
|
|
82
|
+
}
|
|
83
|
+
res.writeHead(200)
|
|
84
|
+
return res.end(data)
|
|
85
|
+
}
|
|
86
|
+
switch (type) {
|
|
87
|
+
case 'application/x-www-form-urlencoded':
|
|
88
|
+
case 'text/plain':
|
|
89
|
+
parserText(req, res, echos)
|
|
90
|
+
break
|
|
91
|
+
case 'application/octet-stream':
|
|
92
|
+
parserRaw(req, res, echos)
|
|
93
|
+
break
|
|
94
|
+
case 'multipart/form-data':
|
|
95
|
+
parserMultipart(req, res, echos)
|
|
96
|
+
break
|
|
97
|
+
default:
|
|
98
|
+
res.status(501).send('unsupport content-type')
|
|
99
|
+
}
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
const app = express()
|
|
103
|
+
app.use('/custom', custom)
|
|
104
|
+
return app
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
module.exports = function(config) {
|
|
108
|
+
config.set({
|
|
109
|
+
basePath: '',
|
|
110
|
+
frameworks: ['mocha','webpack'],
|
|
111
|
+
files: [
|
|
112
|
+
{pattern: '../../release/wnako3webworker.js', served: true, included: false},
|
|
113
|
+
'test/*_test.js',
|
|
114
|
+
'test/html/*.html',
|
|
115
|
+
{pattern: 'test/image/*.png', included: false, served: true, watched: false, nocache: false}
|
|
116
|
+
],
|
|
117
|
+
proxies: {
|
|
118
|
+
'/wnako3webworker.js': '/absolute' + path.resolve('./release/wnako3webworker.js'),
|
|
119
|
+
'/turtle.png': '/base/test/image/turtle_kana.png',
|
|
120
|
+
'/turtle-elephant.png': '/base/test/image/elephant_kana.png',
|
|
121
|
+
'/turtle-panda.png': '/base/test/image/panda_kana.png',
|
|
122
|
+
'/test/image/': '/base/test/image/'
|
|
123
|
+
},
|
|
124
|
+
middleware: ['custom'],
|
|
125
|
+
plugins: [
|
|
126
|
+
'karma-firefox-launcher',
|
|
127
|
+
'karma-mocha',
|
|
128
|
+
'karma-mocha-reporter',
|
|
129
|
+
'karma-webpack',
|
|
130
|
+
'karma-html2js-preprocessor',
|
|
131
|
+
{'middleware:custom': ['factory', CustomMiddlewareFactory]}
|
|
132
|
+
],
|
|
133
|
+
customLaunchers: {
|
|
134
|
+
FirefoxCustom: {
|
|
135
|
+
base: 'Firefox',
|
|
136
|
+
prefs: {
|
|
137
|
+
'dom.w3c_touch_events.enabled': 1,
|
|
138
|
+
'dom.w3c_touch_events.legacy_apis.enabled': true
|
|
139
|
+
},
|
|
140
|
+
flags: [ '-width', 400, '-height', 400 ]
|
|
141
|
+
},
|
|
142
|
+
FirefoxCustomHeadless: {
|
|
143
|
+
base: 'FirefoxHeadless',
|
|
144
|
+
prefs: {
|
|
145
|
+
'dom.w3c_touch_events.enabled': 1,
|
|
146
|
+
'dom.w3c_touch_events.legacy_apis.enabled': true
|
|
147
|
+
},
|
|
148
|
+
flags: [ '-width', 400, '-height', 400 ]
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
preprocessors: {
|
|
152
|
+
'test/*_test.js': ['webpack'],
|
|
153
|
+
'test/html/*.html': ['html2js']
|
|
154
|
+
},
|
|
155
|
+
// webpackの設定
|
|
156
|
+
webpack: {
|
|
157
|
+
mode: "development",
|
|
158
|
+
target: ["web", "es5"],
|
|
159
|
+
resolve: {
|
|
160
|
+
mainFields: ["browser", "main", "module"],
|
|
161
|
+
alias: {
|
|
162
|
+
"root": path.join(__dirname, "../.."),
|
|
163
|
+
"nako3": path.join(__dirname, '../../src'),
|
|
164
|
+
"utils" : path.join(__dirname, '../../utils')
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
module: {
|
|
168
|
+
rules: [
|
|
169
|
+
{
|
|
170
|
+
test: /\.js$/,
|
|
171
|
+
exclude: /(node_modules|bower_components)/,
|
|
172
|
+
use: { loader: 'babel-loader' }
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
test: /\.(jpg|png)$/,
|
|
176
|
+
use: { loader: 'url-loader' }
|
|
177
|
+
}
|
|
178
|
+
]
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
reporters: ['mocha'],
|
|
182
|
+
// reporter options
|
|
183
|
+
mochaReporter: {
|
|
184
|
+
showDiff: true,
|
|
185
|
+
},
|
|
186
|
+
coverageReporter: {
|
|
187
|
+
dir: '../../coverage/browser',
|
|
188
|
+
subdir: function(browser) {
|
|
189
|
+
return browser.toLowerCase().split(/[ /-]/)[0];
|
|
190
|
+
},
|
|
191
|
+
reporters: [
|
|
192
|
+
{ type: 'text' },
|
|
193
|
+
{ type: 'text-summary' },
|
|
194
|
+
{ type: 'lcov' },
|
|
195
|
+
{ type: 'text', file: 'text.txt' },
|
|
196
|
+
{ type: 'json', file: 'text.json' },
|
|
197
|
+
{ type: 'text-summary', file: 'text-summary.txt' },
|
|
198
|
+
{ type: 'lcovonly', file: 'report-lcovonly.txt' },
|
|
199
|
+
],
|
|
200
|
+
instrumenterOptions: {
|
|
201
|
+
istanbul: { noCompact: true }
|
|
202
|
+
}
|
|
203
|
+
},
|
|
204
|
+
port: 9876, // karma web server port
|
|
205
|
+
colors: true,
|
|
206
|
+
logLevel: config.LOG_INFO,
|
|
207
|
+
browsers: ['Firefox', 'FirefoxHeadless', 'FirefoxCustom', 'FirefoxCustomHeadless' ],
|
|
208
|
+
autoWatch: false,
|
|
209
|
+
// singleRun: false, // Karma captures browsers, runs the tests and exits
|
|
210
|
+
concurrency: Infinity
|
|
211
|
+
})
|
|
212
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const assert = require('chai').assert
|
|
2
|
+
|
|
3
|
+
class CompareUtil {
|
|
4
|
+
constructor (nako) {
|
|
5
|
+
this._nako = nako
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
cmp (code, res) {
|
|
9
|
+
this.nako.logger.debug('code=' + code)
|
|
10
|
+
assert.strictEqual(this.nako.run(code).log, res)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
cmpex (code, err, res) {
|
|
14
|
+
this.nako.logger.debug('code=' + code)
|
|
15
|
+
assert.throws(() => { this.nako.run(code) }, err, res)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get nako () {
|
|
19
|
+
return this._nako
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const waitTimer = (second) => {
|
|
24
|
+
return new Promise((resolve, reject) => {
|
|
25
|
+
setTimeout(() => {
|
|
26
|
+
resolve()
|
|
27
|
+
}, second * 1000)
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* 5秒たつかfがエラーを投げなくなるまで繰り返す。呼び出すときは必ずawaitすること。
|
|
33
|
+
* @type {<T>(f: () => Promise<T>) => Promise<T>}
|
|
34
|
+
*/
|
|
35
|
+
const retry = async (f) => {
|
|
36
|
+
const startTime = Date.now()
|
|
37
|
+
while (true) {
|
|
38
|
+
try {
|
|
39
|
+
return await f()
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (Date.now() - startTime < 5000) {
|
|
42
|
+
await waitTimer(0.1)
|
|
43
|
+
continue
|
|
44
|
+
}
|
|
45
|
+
throw err
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export { CompareUtil, waitTimer, assert, retry }
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<canvas id="turtle_cv" width="100" height="100"></canvas>
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
if (typeof (navigator) === 'object' && typeof (navigator.nako3) === 'undefined') {
|
|
2
|
+
navigator.nako3 = {
|
|
3
|
+
autoImport: {},
|
|
4
|
+
addPluginObject: function (pluginName, pluginObject) {
|
|
5
|
+
this.autoImport[pluginName] = {
|
|
6
|
+
name: pluginName,
|
|
7
|
+
obj: pluginObject,
|
|
8
|
+
imported: true
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
getAutoImport: function (pluginName) {
|
|
12
|
+
return this.autoImport[pluginName]
|
|
13
|
+
},
|
|
14
|
+
hasImport: function (pluginName) {
|
|
15
|
+
return this.autoImport.hasOwnProperty(pluginName)
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const importStatus = {
|
|
21
|
+
getAutoImport: navigator.nako3.getAutoImport.bind(navigator.nako3),
|
|
22
|
+
hasImport: navigator.nako3.hasImport.bind(navigator.nako3)
|
|
23
|
+
}
|
|
24
|
+
export { importStatus }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import 'whatwg-fetch'
|
|
2
|
+
import NakoCompiler from 'nako3/nako3.js'
|
|
3
|
+
import PluginBrowser from 'nako3/plugin_browser.js'
|
|
4
|
+
|
|
5
|
+
import browserTestColor from './plugin_browser_test_color.js'
|
|
6
|
+
import browserTestSystem from './plugin_browser_test_system.js'
|
|
7
|
+
import browserTestDialog from './plugin_browser_test_dialog.js'
|
|
8
|
+
import browserTestAjax from './plugin_browser_test_ajax.js'
|
|
9
|
+
import browserTestDomEvent from './plugin_browser_test_dom_event.js'
|
|
10
|
+
import browserTestDomParts from './plugin_browser_test_dom_parts.js'
|
|
11
|
+
|
|
12
|
+
class CallReport {
|
|
13
|
+
constructor (nako) {
|
|
14
|
+
this.funcCalled = false
|
|
15
|
+
this.rslt = []
|
|
16
|
+
nako.addFunc('報告', [['を']], (msg) => {
|
|
17
|
+
this.funcCalled = true
|
|
18
|
+
this.rslt.push(msg)
|
|
19
|
+
})
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
reset () {
|
|
23
|
+
this.funcCalled = false
|
|
24
|
+
this.rslt = []
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get isCalled () {
|
|
28
|
+
return this.funcCalled
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
get messages () {
|
|
32
|
+
return this.rslt
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getMessageAsJson () {
|
|
36
|
+
return JSON.stringify(this.rslt)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
describe('plugin_browser_test', () => {
|
|
42
|
+
const nako = new NakoCompiler()
|
|
43
|
+
nako.addPluginFile('PluginBrowser', 'plugin_browser.js', PluginBrowser)
|
|
44
|
+
window.cr = new CallReport(nako)
|
|
45
|
+
|
|
46
|
+
browserTestColor(nako)
|
|
47
|
+
browserTestSystem(nako)
|
|
48
|
+
browserTestDialog(nako)
|
|
49
|
+
browserTestAjax(nako)
|
|
50
|
+
browserTestDomEvent(nako)
|
|
51
|
+
browserTestDomParts(nako)
|
|
52
|
+
})
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import * as td from 'testdouble'
|
|
2
|
+
import { CompareUtil, waitTimer, retry } from './compare_util'
|
|
3
|
+
|
|
4
|
+
export default (nako) => {
|
|
5
|
+
const cu = new CompareUtil(nako)
|
|
6
|
+
|
|
7
|
+
describe('ajax通信', () => {
|
|
8
|
+
it('POSTデータ生成', () => {
|
|
9
|
+
const code = `
|
|
10
|
+
パラメータは空オブジェクト。
|
|
11
|
+
パラメータ["KEY"]は、「VALUE」。
|
|
12
|
+
パラメータ["_X"]は、「XE^ZA」。
|
|
13
|
+
パラメータ["SPACE"]は、「 」。
|
|
14
|
+
パラメータをPOSTデータ生成してJSONエンコードして表示する。
|
|
15
|
+
`
|
|
16
|
+
cu.cmp(code, '"KEY=VALUE&_X=XE%5EZA&SPACE=%20"')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('AJAXオプション設定', () => {
|
|
20
|
+
const code = `
|
|
21
|
+
パラメータは空オブジェクト。
|
|
22
|
+
パラメータ["KEY"]は、「VALUE」。
|
|
23
|
+
パラメータにAJAXオプション設定する。
|
|
24
|
+
AJAXオプションをJSONエンコードして表示する。
|
|
25
|
+
`
|
|
26
|
+
cu.cmp(code, '{"KEY":"VALUE"}')
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
it('AJAX送信時', async () => {
|
|
30
|
+
const windowalert = td.replace(window, 'alert')
|
|
31
|
+
const code = '「/custom/ok」へAJAX送信時には;対象をJSONエンコードして言う;ここまで'
|
|
32
|
+
nako.logger.debug('code=' + code)
|
|
33
|
+
nako.run(code)
|
|
34
|
+
|
|
35
|
+
await retry(() => td.verify(windowalert('"OK"'), { times: 1 }))
|
|
36
|
+
td.reset()
|
|
37
|
+
}).timeout(10000)
|
|
38
|
+
|
|
39
|
+
it('POST送信時', async () => {
|
|
40
|
+
const windowalert = td.replace(window, 'alert')
|
|
41
|
+
const code = `
|
|
42
|
+
パラメータは空オブジェクト。
|
|
43
|
+
パラメータ["param1"]は、「data1^」。
|
|
44
|
+
パラメータ["param2"]は、「data2^^」。
|
|
45
|
+
パラメータを「/custom/echo/json」へPOST送信時には
|
|
46
|
+
対象を言う
|
|
47
|
+
ここまで
|
|
48
|
+
`
|
|
49
|
+
nako.logger.debug('code=' + code)
|
|
50
|
+
nako.run(code)
|
|
51
|
+
|
|
52
|
+
await retry(() => td.verify(windowalert('"param1=data1%5E¶m2=data2%5E%5E"'), { times: 1 }))
|
|
53
|
+
td.reset()
|
|
54
|
+
}).timeout(10000)
|
|
55
|
+
|
|
56
|
+
it('POSTフォーム送信時', async () => {
|
|
57
|
+
const windowalert = td.replace(window, 'alert')
|
|
58
|
+
const code = `
|
|
59
|
+
パラメータは空オブジェクト。
|
|
60
|
+
パラメータ["param1"]は、「data1^」。
|
|
61
|
+
パラメータ["param2"]は、「data2^^」。
|
|
62
|
+
パラメータを「/custom/echo/json」へPOSTフォーム送信時には
|
|
63
|
+
対象を言う
|
|
64
|
+
ここまで
|
|
65
|
+
`
|
|
66
|
+
nako.logger.debug('code=' + code)
|
|
67
|
+
nako.run(code)
|
|
68
|
+
|
|
69
|
+
await retry(() => td.verify(windowalert('{"param1":"data1^","param2":"data2^^"}'), { times: 1 }))
|
|
70
|
+
td.reset()
|
|
71
|
+
}).timeout(10000)
|
|
72
|
+
|
|
73
|
+
it('AJAX送信', async () => {
|
|
74
|
+
const windowalert = td.replace(window, 'alert')
|
|
75
|
+
const code = `
|
|
76
|
+
逐次実行
|
|
77
|
+
次に、「/custom/ok/json」へAJAX送信する。
|
|
78
|
+
次に、対象を言う。
|
|
79
|
+
ここまで
|
|
80
|
+
`
|
|
81
|
+
nako.logger.debug('code=' + code)
|
|
82
|
+
nako.run(code)
|
|
83
|
+
|
|
84
|
+
await retry(() => td.verify(windowalert('"OK"'), { times: 1 }))
|
|
85
|
+
td.reset()
|
|
86
|
+
}).timeout(10000)
|
|
87
|
+
|
|
88
|
+
it('POST送信', async () => {
|
|
89
|
+
const windowalert = td.replace(window, 'alert')
|
|
90
|
+
const code = `
|
|
91
|
+
パラメータは空オブジェクト。
|
|
92
|
+
パラメータ["param1"]は、「data1^」。
|
|
93
|
+
パラメータ["param2"]は、「data2^^」。
|
|
94
|
+
逐次実行
|
|
95
|
+
次に、パラメータを「/custom/echo/json」へPOST送信する。
|
|
96
|
+
次に、対象を言う。
|
|
97
|
+
ここまで
|
|
98
|
+
`
|
|
99
|
+
nako.logger.debug('code=' + code)
|
|
100
|
+
nako.run(code)
|
|
101
|
+
await retry(() => td.verify(windowalert('"param1=data1%5E¶m2=data2%5E%5E"'), { times: 1 }))
|
|
102
|
+
td.reset()
|
|
103
|
+
}).timeout(10000)
|
|
104
|
+
|
|
105
|
+
it('POSTフォーム送信', async () => {
|
|
106
|
+
const windowalert = td.replace(window, 'alert')
|
|
107
|
+
const code = `
|
|
108
|
+
パラメータは空オブジェクト。
|
|
109
|
+
パラメータ["param1"]は、「data1^」。
|
|
110
|
+
パラメータ["param2"]は、「data2^^」。
|
|
111
|
+
逐次実行
|
|
112
|
+
次に、パラメータを「/custom/echo」へPOSTフォーム送信する。
|
|
113
|
+
次に、対象を言う。
|
|
114
|
+
ここまで
|
|
115
|
+
`
|
|
116
|
+
nako.logger.debug('code=' + code)
|
|
117
|
+
nako.run(code)
|
|
118
|
+
|
|
119
|
+
await retry(() => td.verify(windowalert('{"param1":"data1^","param2":"data2^^"}'), { times: 1 }))
|
|
120
|
+
td.reset()
|
|
121
|
+
}).timeout(10000)
|
|
122
|
+
})
|
|
123
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CompareUtil } from './compare_util'
|
|
2
|
+
|
|
3
|
+
export default (nako) => {
|
|
4
|
+
const cu = new CompareUtil(nako)
|
|
5
|
+
|
|
6
|
+
describe('色', () => {
|
|
7
|
+
it('RGB', () => {
|
|
8
|
+
cu.cmp('CODE=RGB(255,255,255);CODEを大文字変換して表示', '#FFFFFF')
|
|
9
|
+
cu.cmp('CODE=RGB(0,255,255);CODEを大文字変換して表示', '#00FFFF')
|
|
10
|
+
cu.cmp('CODE=RGB(0,0,0);CODEを大文字変換して表示', '#000000')
|
|
11
|
+
cu.cmp('CODE=22と25と255のRGB;CODEを大文字変換して表示', '#1619FF')
|
|
12
|
+
cu.cmp('22と25と255のRGBを大文字変換して表示', '#1619FF')
|
|
13
|
+
})
|
|
14
|
+
it('色混ぜる', () => {
|
|
15
|
+
cu.cmp('[255,255,255]の色混ぜして大文字変換して表示', '#FFFFFF')
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import * as td from 'testdouble'
|
|
2
|
+
import { assert } from './compare_util'
|
|
3
|
+
|
|
4
|
+
export default (nako) => {
|
|
5
|
+
describe('言う', () => {
|
|
6
|
+
const cmpalert = (code, msg) => {
|
|
7
|
+
const windowalert = td.replace(window, 'alert')
|
|
8
|
+
td.when(windowalert(msg)).thenReturn(undefined)
|
|
9
|
+
nako.logger.debug('code=' + code)
|
|
10
|
+
nako.run(code)
|
|
11
|
+
td.verify(windowalert(td.matchers.anything()), { times: 1 })
|
|
12
|
+
td.reset()
|
|
13
|
+
}
|
|
14
|
+
it('言う', () => {
|
|
15
|
+
cmpalert('「あいうえおか」を言う', 'あいうえおか')
|
|
16
|
+
})
|
|
17
|
+
})
|
|
18
|
+
describe('尋ねる/文字尋ねる', () => {
|
|
19
|
+
const cmpprompt = (code, msg, rslt, res) => {
|
|
20
|
+
const windowprompt = td.replace(window, 'prompt')
|
|
21
|
+
td.when(windowprompt(msg)).thenReturn(rslt)
|
|
22
|
+
nako.logger.debug('code=' + code)
|
|
23
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
24
|
+
td.verify(windowprompt(td.matchers.anything()), { times: 1 })
|
|
25
|
+
td.reset()
|
|
26
|
+
}
|
|
27
|
+
it('尋ねる - string', () => {
|
|
28
|
+
cmpprompt('A=「から」を尋ねる;AをJSONエンコードして表示', 'から', null, '""')
|
|
29
|
+
cmpprompt('A=「かきくけこ」を尋ねる;AをJSONエンコードして表示', 'かきくけこ', 'abc', '"abc"')
|
|
30
|
+
cmpprompt('A=「あ」を尋ねる;AをJSONエンコードして表示', 'あ', '1..5', '"1..5"')
|
|
31
|
+
cmpprompt('A=「い」を尋ねる;AをJSONエンコードして表示', 'い', '1.2.3', '"1.2.3"')
|
|
32
|
+
cmpprompt('A=「う」を尋ねる;AをJSONエンコードして表示', 'う', '....', '"...."')
|
|
33
|
+
})
|
|
34
|
+
it('尋ねる - number', () => {
|
|
35
|
+
cmpprompt('A=「あいうえおか」を尋ねる;AをJSONエンコードして表示', 'あいうえおか', '1.24', '1.24')
|
|
36
|
+
cmpprompt('A=「かききけこけ」を尋ねる;AをJSONエンコードして表示', 'かききけこけ', '20', '20')
|
|
37
|
+
cmpprompt('A=「ままみみむむ」を尋ねる;AをJSONエンコードして表示', 'ままみみむむ', '+23', '23')
|
|
38
|
+
cmpprompt('A=「さしすせそ」を尋ねる;AをJSONエンコードして表示', 'さしすせそ', '9007199254740991', '9007199254740991')
|
|
39
|
+
})
|
|
40
|
+
it('尋ねる - negative number', () => {
|
|
41
|
+
cmpprompt('A=「さしすせ」を尋ねる;AをJSONエンコードして表示', 'さしすせ', '-10', '-10')
|
|
42
|
+
cmpprompt('A=「そ」を尋ねる;AをJSONエンコードして表示', 'そ', '-0.3', '-0.3')
|
|
43
|
+
})
|
|
44
|
+
it('尋ねる - zenkaku number', () => {
|
|
45
|
+
cmpprompt('A=「とてとてとて」を尋ねる;AをJSONエンコードして表示', 'とてとてとて', '20', '20')
|
|
46
|
+
cmpprompt('A=「りりりて」を尋ねる;AをJSONエンコードして表示', 'りりりて', '+5.55', '5.55')
|
|
47
|
+
cmpprompt('A=「てけり」を尋ねる;AをJSONエンコードして表示', 'てけり', '-0.3', '-0.3')
|
|
48
|
+
})
|
|
49
|
+
it('文字尋ねる - string', () => {
|
|
50
|
+
cmpprompt('A=「から」を文字尋ねる;AをJSONエンコードして表示', 'から', null, '""')
|
|
51
|
+
cmpprompt('A=「かきくけこ」を文字尋ねる;AをJSONエンコードして表示', 'かきくけこ', 'abc', '"abc"')
|
|
52
|
+
cmpprompt('A=「あ」を文字尋ねる;AをJSONエンコードして表示', 'あ', '1..5', '"1..5"')
|
|
53
|
+
cmpprompt('A=「かききけこけ」を文字尋ねる;AをJSONエンコードして表示', 'かききけこけ', '20', '"20"')
|
|
54
|
+
cmpprompt('A=「あいうえおか」を文字尋ねる;AをJSONエンコードして表示', 'あいうえおか', '1.24', '"1.24"')
|
|
55
|
+
cmpprompt('A=「そ」を文字尋ねる;AをJSONエンコードして表示', 'そ', '-0.3', '"-0.3"')
|
|
56
|
+
})
|
|
57
|
+
})
|
|
58
|
+
describe('二択', () => {
|
|
59
|
+
const cmpconfirm = (code, msg, rslt, res) => {
|
|
60
|
+
const windowconfirm = td.replace(window, 'confirm')
|
|
61
|
+
td.when(windowconfirm(msg)).thenReturn(rslt)
|
|
62
|
+
nako.logger.debug('code=' + code)
|
|
63
|
+
assert.strictEqual(nako.run(code).log, res)
|
|
64
|
+
td.verify(windowconfirm(td.matchers.anything()), { times: 1 })
|
|
65
|
+
td.reset()
|
|
66
|
+
}
|
|
67
|
+
it('二択', () => {
|
|
68
|
+
cmpconfirm('A=「これ」で二択;AをJSONエンコードして表示', 'これ', true, 'true')
|
|
69
|
+
cmpconfirm('A=「それ」で二択;AをJSONエンコードして表示', 'それ', false, 'false')
|
|
70
|
+
})
|
|
71
|
+
})
|
|
72
|
+
}
|