nadesiko3 3.3.74 → 3.3.76
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 +6 -0
- package/batch/command_nakopad.txt +4 -0
- package/batch/pickup_command.nako3 +1 -0
- package/core/bun.lockb +0 -0
- package/core/package.json +1 -1
- package/core/src/nako_core_version.mjs +2 -2
- package/core/src/nako_core_version.mts +2 -2
- package/core/src/nako_lexer.mjs +2 -1
- package/core/src/nako_lexer.mts +2 -1
- package/core/test/inline_indent_test.mjs +7 -0
- package/package.json +1 -1
- package/release/_hash.txt +28 -28
- package/release/_script-tags.txt +14 -14
- 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/editor.js +1 -1
- package/release/nako_gen_async.js +1 -1
- package/release/plugin_markup.js +1 -1
- package/release/stats.json +1 -1
- package/release/version.js +1 -1
- package/release/wnako3.js +1 -1
- package/release/wnako3.js.LICENSE.txt +1 -1
- package/release/wnako3webworker.js +1 -1
- package/src/cnako3.mts +0 -1
- package/src/nako_version.mjs +2 -2
- package/src/nako_version.mts +2 -2
- package/tools/nako3edit/html/edit.html +1 -0
- package/tools/nako3edit/index.mjs +36 -14
package/src/cnako3.mts
CHANGED
package/src/nako_version.mjs
CHANGED
package/src/nako_version.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/** nako3edit用の超簡易サーバ(生のnodeだけで簡単HTTPサーバ) */
|
|
3
3
|
import path from 'path'
|
|
4
|
-
import fs
|
|
4
|
+
import fs from 'fs'
|
|
5
5
|
import { execSync } from 'child_process'
|
|
6
6
|
import opener from 'opener'
|
|
7
7
|
import http from 'http'
|
|
@@ -20,7 +20,11 @@ const homeDir = process.env[isWin ? 'USERPROFILE' : 'HOME']
|
|
|
20
20
|
const userDir = path.join(homeDir, 'nadesiko3_user')
|
|
21
21
|
const CNAKO3 = path.resolve(path.join(__dirname, '../../src/cnako3.mjs'))
|
|
22
22
|
const NODE = process.argv[0]
|
|
23
|
-
const appkey = '
|
|
23
|
+
const appkey = 'k' +
|
|
24
|
+
Math.floor(Math.random() * 0xFFFFFFFF).toString(16) +
|
|
25
|
+
Math.floor(Math.random() * 0xFFFFFFFF).toString(16) +
|
|
26
|
+
Math.floor(Math.random() * 0xFFFFFFFF).toString(16) +
|
|
27
|
+
Math.floor(Math.random() * 0xFFFFFFFF).toString(16)
|
|
24
28
|
|
|
25
29
|
// ユーザーフォルダを作成
|
|
26
30
|
if (!fs.existsSync(userDir)) { fs.mkdirSync(userDir) }
|
|
@@ -44,7 +48,11 @@ const server = http.createServer(function (req, res) {
|
|
|
44
48
|
const q = String(a[1]).split('&')
|
|
45
49
|
for (const kv of q) {
|
|
46
50
|
const qq = kv.split('=')
|
|
47
|
-
|
|
51
|
+
try {
|
|
52
|
+
params[qq[0]] = decodeURIComponent(qq[1])
|
|
53
|
+
} catch (e) {
|
|
54
|
+
console.error(e)
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
// サニタイズ
|
|
@@ -155,7 +163,7 @@ function apiFiles (res) {
|
|
|
155
163
|
res.end(JSON.stringify(files))
|
|
156
164
|
}
|
|
157
165
|
function apiLoad (res, params) {
|
|
158
|
-
const fname = params.file
|
|
166
|
+
const fname = removePathFlag(params.file)
|
|
159
167
|
const fullpath = path.join(userDir, fname)
|
|
160
168
|
console.log('load=', fullpath)
|
|
161
169
|
let text = '# 新規ファイル\n「こんにちは」と表示。'
|
|
@@ -172,7 +180,7 @@ function apiSave (res, params) {
|
|
|
172
180
|
res.end('[ERROR] キーが違います')
|
|
173
181
|
return
|
|
174
182
|
}
|
|
175
|
-
const fname = params.file
|
|
183
|
+
const fname = removePathFlag(params.file)
|
|
176
184
|
const body = params.body
|
|
177
185
|
const fullpath = path.join(userDir, fname)
|
|
178
186
|
try {
|
|
@@ -186,6 +194,13 @@ function apiSave (res, params) {
|
|
|
186
194
|
}
|
|
187
195
|
}
|
|
188
196
|
|
|
197
|
+
function removePathFlag (s) {
|
|
198
|
+
// ファイル名をサニタイズ
|
|
199
|
+
s = s.replace(/['"`\\?/<>*]/g, '_')
|
|
200
|
+
s = s.replace(/_{2,}/g, '') // '__'を削除
|
|
201
|
+
return s
|
|
202
|
+
}
|
|
203
|
+
|
|
189
204
|
function apiRun (res, params) {
|
|
190
205
|
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' })
|
|
191
206
|
const appkeyUser = params.appkey
|
|
@@ -193,7 +208,7 @@ function apiRun (res, params) {
|
|
|
193
208
|
res.end('[ERROR] キーが違います')
|
|
194
209
|
return
|
|
195
210
|
}
|
|
196
|
-
const fname = params.file
|
|
211
|
+
const fname = removePathFlag(params.file)
|
|
197
212
|
const body = params.body
|
|
198
213
|
const fullpath = path.join(userDir, fname)
|
|
199
214
|
try {
|
|
@@ -205,6 +220,8 @@ function apiRun (res, params) {
|
|
|
205
220
|
result = String(result)
|
|
206
221
|
} catch (err) {
|
|
207
222
|
console.error(err)
|
|
223
|
+
res.end('[ERROR]実行に失敗しました。' + err.toString())
|
|
224
|
+
return
|
|
208
225
|
}
|
|
209
226
|
console.log('[run] file=', fname)
|
|
210
227
|
console.log('--------------------------------')
|
|
@@ -212,6 +229,7 @@ function apiRun (res, params) {
|
|
|
212
229
|
console.log('--------------------------------')
|
|
213
230
|
res.end(result)
|
|
214
231
|
} catch (err) {
|
|
232
|
+
console.error(err)
|
|
215
233
|
res.end('[ERROR] 実行に失敗しました。')
|
|
216
234
|
}
|
|
217
235
|
}
|
|
@@ -220,27 +238,31 @@ function apiDelete (res, params) {
|
|
|
220
238
|
res.writeHead(200, { 'Content-Type': 'text/plain; charset=utf-8' })
|
|
221
239
|
const appkeyUser = params.appkey
|
|
222
240
|
if (appkey !== appkeyUser) {
|
|
223
|
-
res.end('[ERROR] キーが違います')
|
|
241
|
+
res.end('"[ERROR] キーが違います"')
|
|
224
242
|
return
|
|
225
243
|
}
|
|
226
|
-
const fname = params.file
|
|
227
|
-
const body = params.body
|
|
244
|
+
const fname = removePathFlag(params.file)
|
|
228
245
|
const fullpath = path.join(userDir, fname)
|
|
229
246
|
try {
|
|
230
|
-
fs.
|
|
231
|
-
|
|
247
|
+
if (fs.existsSync(fullpath)) {
|
|
248
|
+
fs.unlinkSync(fullpath)
|
|
249
|
+
res.end('"ok"')
|
|
250
|
+
} else {
|
|
251
|
+
res.end('"[ERROR] ファイルが見つかりません。"')
|
|
252
|
+
}
|
|
232
253
|
return
|
|
233
254
|
} catch (err) {
|
|
255
|
+
console.error(err)
|
|
234
256
|
res.end('error:' + err.message)
|
|
235
257
|
}
|
|
236
258
|
}
|
|
237
259
|
|
|
238
260
|
function apiGetNewFilename (res) {
|
|
239
261
|
let fname = 'newfile.nako3'
|
|
240
|
-
for (let i = 1; i <=
|
|
241
|
-
fname = `
|
|
262
|
+
for (let i = 1; i <= 9999; i++) {
|
|
263
|
+
fname = `file${i}.nako3`
|
|
242
264
|
const full = path.join(userDir, fname)
|
|
243
|
-
if (fs.existsSync(
|
|
265
|
+
if (fs.existsSync(full)) { continue }
|
|
244
266
|
break
|
|
245
267
|
}
|
|
246
268
|
res.writeHead(200, { 'Content-Type': 'text/plaing; charset=utf-8' })
|