@naanlang/naan 1.0.16 → 1.1.0
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.md +2 -2
- package/README.md +2 -2
- package/bin/index.js +4 -4
- package/dist/naan.min.js +6 -6
- package/frameworks/browser/https_request.nlg +23 -9
- package/frameworks/browser/sworker.js +26 -25
- package/frameworks/browser/terminals.nlg +56 -15
- package/frameworks/browser/ws_client.nlg +124 -0
- package/frameworks/client/apiclient.nlg +3 -2
- package/frameworks/client/psm_client.nlg +1 -1
- package/frameworks/client/relaycon.nlg +308 -0
- package/frameworks/common/common.nlg +1 -1
- package/frameworks/common/utils.nlg +40 -2
- package/frameworks/node/apiserver.nlg +342 -103
- package/frameworks/node/https_request.nlg +30 -5
- package/frameworks/node/node.nlg +60 -2
- package/frameworks/node/psm_server.nlg +9 -5
- package/frameworks/node/worker.nlg +22 -9
- package/frameworks/node/ws_client.nlg +127 -0
- package/frameworks/project/build.nlg +2 -2
- package/frameworks/project/projects.nlg +8 -2
- package/frameworks/running/debugnub.nlg +2 -2
- package/frameworks/running/debugutil.nlg +1 -1
- package/frameworks/running/executors.nlg +59 -12
- package/frameworks/running/sourcecode.nlg +2 -2
- package/frameworks/running/taskexec.nlg +23 -24
- package/frameworks/storage/dbt_pouch.nlg +8 -6
- package/frameworks/storage/file_manager.nlg +6 -3
- package/frameworks/storage/psm.nlg +3 -2
- package/frameworks/storage/psm_dbtables.nlg +53 -41
- package/frameworks/storage/resources.nlg +4 -2
- package/lib/browser/env_web.js +6 -6
- package/lib/browser/env_webworker.js +1 -1
- package/lib/core/naanlib.js +6 -6
- package/lib/env_node.js +97 -8
- package/lib/env_nodeworker.js +22 -4
- package/package.json +1 -1
- package/plugins/serviceAws/aws/lambda_rest_index.js +5 -1
- package/plugins/serviceAws/dbt_aws.nlg +2 -2
- package/plugins/serviceAws/psm_aws.nlg +2 -2
- package/test/test_01_core.nlg +30 -4
|
@@ -5,13 +5,13 @@
|
|
|
5
5
|
*
|
|
6
6
|
* column positioning: // // !
|
|
7
7
|
*
|
|
8
|
-
* Copyright (c) 2021 by Richard C. Zulch
|
|
8
|
+
* Copyright (c) 2021-2023 by Richard C. Zulch
|
|
9
9
|
*
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
/*
|
|
14
|
-
*
|
|
14
|
+
* TaskDispatcher
|
|
15
15
|
*
|
|
16
16
|
* Create a dispatcher for remote evaluation. The replier argument is a function that accepts
|
|
17
17
|
* outgoing messages. The return value is a closure that processes incomming messages. This code is
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
closure
|
|
22
|
+
closure TaskDispatcher(replier, local contexts, gohome, util) {
|
|
23
23
|
contexts = { }
|
|
24
24
|
gohome = makeActivator()
|
|
25
25
|
util = modlist().Util.exports
|
|
@@ -68,24 +68,22 @@ closure taskDispatcher(replier, local contexts, gohome, util) {
|
|
|
68
68
|
})
|
|
69
69
|
expr = caar(expr)
|
|
70
70
|
reply.error = undefined
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
context.activator = makeActivator()
|
|
88
|
-
}
|
|
71
|
+
expr = evalactive(expr)
|
|
72
|
+
if data.get
|
|
73
|
+
roots = new(data.get).map(function(sym){ // new() to get symbol from compress
|
|
74
|
+
compress(sym)
|
|
75
|
+
})
|
|
76
|
+
if roots
|
|
77
|
+
roots = cons(`expr, totuple(roots))
|
|
78
|
+
else
|
|
79
|
+
roots = `(expr)
|
|
80
|
+
reply.result = util.pkgSave(`expr, roots, {
|
|
81
|
+
nsignore: true // don't report namespace errors
|
|
82
|
+
comments: true }) // include comments
|
|
83
|
+
if context.namespace !== nsactive().0
|
|
84
|
+
{ // evaluation changed namespace
|
|
85
|
+
context.namespace = nsactive().0
|
|
86
|
+
context.activator = makeActivator()
|
|
89
87
|
}
|
|
90
88
|
}
|
|
91
89
|
}
|
|
@@ -148,12 +146,12 @@ closure taskDispatcher(replier, local contexts, gohome, util) {
|
|
|
148
146
|
closure TaskExecutor() {
|
|
149
147
|
|
|
150
148
|
// taskInstall
|
|
151
|
-
// Install the
|
|
149
|
+
// Install the TaskDispatcher, and reload on state load.
|
|
152
150
|
//
|
|
153
151
|
function taskInstall() {
|
|
154
152
|
if !js.t.OnMessage
|
|
155
153
|
return (false) // false if not a worker
|
|
156
|
-
js.t.OnMessage(
|
|
154
|
+
js.t.OnMessage(TaskDispatcher(js.t.ReplyMessage))
|
|
157
155
|
}()
|
|
158
156
|
LoadNotify(taskInstall)
|
|
159
157
|
|
|
@@ -185,11 +183,12 @@ function TaskOnMessageHook(hook) {
|
|
|
185
183
|
|
|
186
184
|
function taxInit(local manifest) {
|
|
187
185
|
|
|
188
|
-
manifest = `(
|
|
186
|
+
manifest = `(TaskDispatcher, TaskExecutor, TaskOnMessageHook, taxInit)
|
|
189
187
|
|
|
190
188
|
Naan.module.build(module.id, "taskexec", function(modobj, compobj) {
|
|
191
189
|
require("./running.nlg").LiveImport()
|
|
192
190
|
compobj.manifest = manifest
|
|
191
|
+
modobj.exports.TaskDispatcher = TaskDispatcher
|
|
193
192
|
modobj.exports.TaskExecutor = TaskExecutor
|
|
194
193
|
modobj.exports.TaskOnMessageHook = TaskOnMessageHook
|
|
195
194
|
})
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* column positioning: // // !
|
|
9
9
|
*
|
|
10
|
-
* Copyright (c) 2017-
|
|
10
|
+
* Copyright (c) 2017-2024 by Richard C. Zulch
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
@@ -35,6 +35,7 @@
|
|
|
35
35
|
*/
|
|
36
36
|
|
|
37
37
|
closure dapoTable(database, path, local table, prefix) {
|
|
38
|
+
global()
|
|
38
39
|
table = new(object, this)
|
|
39
40
|
table.type = database.type
|
|
40
41
|
table.db = database
|
|
@@ -277,13 +278,11 @@ closure dapoTable(database, path, local table, prefix) {
|
|
|
277
278
|
// rows : [
|
|
278
279
|
// {
|
|
279
280
|
// key : "john",
|
|
280
|
-
// _modified : [Date Sat Apr 04 2020 17:05:38 GMT-0700 (Pacific Daylight Time)]
|
|
281
281
|
// _md5 : "55ff07fb005494c4bd42322d4845e858"
|
|
282
282
|
// _length : 156043
|
|
283
283
|
// [ doc | error: <document from "get" or "head"> | <error from get|head> ] },
|
|
284
284
|
// {
|
|
285
285
|
// key : "jill",
|
|
286
|
-
// _modified : [Date Sat Apr 22 2020 17:05:38 GMT-0700 (Pacific Daylight Time)]
|
|
287
286
|
// _md5 : "f53f07fb00d42322dc4bd42322d4845e"
|
|
288
287
|
// _length : 155
|
|
289
288
|
// [ doc : <document from "get" or "head"> ] } ] }
|
|
@@ -335,7 +334,7 @@ closure dapoTable(database, path, local table, prefix) {
|
|
|
335
334
|
_id: obj.id
|
|
336
335
|
_rev: obj.value.rev
|
|
337
336
|
}
|
|
338
|
-
if obj.doc {
|
|
337
|
+
if obj.doc { // docs were requested
|
|
339
338
|
if obj.doc.content {
|
|
340
339
|
item._md5 = HashMD5(obj.doc.content)
|
|
341
340
|
item._length = length(obj.doc.content) }
|
|
@@ -373,6 +372,7 @@ closure dapoTable(database, path, local table, prefix) {
|
|
|
373
372
|
*/
|
|
374
373
|
|
|
375
374
|
closure PouchDB(urlname, local database, options) {
|
|
375
|
+
global(jspath, pouchdb)
|
|
376
376
|
options = {
|
|
377
377
|
revs_limit: 1 // number of revs to maintain for replication
|
|
378
378
|
auto_compaction: false } // don't compcat on every change
|
|
@@ -480,7 +480,8 @@ closure PouchDB(urlname, local database, options) {
|
|
|
480
480
|
*
|
|
481
481
|
*/
|
|
482
482
|
|
|
483
|
-
closure ListBrowserDBs(local pending, output) {
|
|
483
|
+
closure ListBrowserDBs(local pending, output, item) {
|
|
484
|
+
global(indexedDB)
|
|
484
485
|
if !indexedDB
|
|
485
486
|
return (list(Error("browser database unavailable")))
|
|
486
487
|
if !indexedDB.databases
|
|
@@ -507,6 +508,7 @@ closure ListBrowserDBs(local pending, output) {
|
|
|
507
508
|
*/
|
|
508
509
|
|
|
509
510
|
closure DbConnector(psm, local connClassID, connector, watch) {
|
|
511
|
+
global()
|
|
510
512
|
connClassID = "PouchDB"
|
|
511
513
|
connector = new(object, this)
|
|
512
514
|
connector.psm = psm
|
|
@@ -572,7 +574,7 @@ closure DbConnector(psm, local connClassID, connector, watch) {
|
|
|
572
574
|
// The return value is an (error, resID) tuple. Error, if non-false, is a dictionary of field
|
|
573
575
|
// keys and error diagnostic strings.
|
|
574
576
|
connector.writeResource = function writeResource(resource, resID,
|
|
575
|
-
local errors, creds, original, error, data) {
|
|
577
|
+
local errors, creds, original, error, data, change) {
|
|
576
578
|
// badField - test for a bad string
|
|
577
579
|
function badField(str) { !string(str) || str.trim().length == 0 }
|
|
578
580
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
25
|
+
global(commonWatching)
|
|
25
26
|
files = new(object, this)
|
|
26
27
|
files.fs = fs
|
|
27
28
|
files.nodes = [] // array of nodes, one per file or folder
|
|
@@ -159,7 +160,7 @@ closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
|
159
160
|
//
|
|
160
161
|
// Return the parent path of the specified node, or "" for the root.
|
|
161
162
|
//
|
|
162
|
-
function parentPath(node) {
|
|
163
|
+
function parentPath(node, local path) {
|
|
163
164
|
path = node.path
|
|
164
165
|
if path.slice(-1) == files.pathsep
|
|
165
166
|
path = path.slice(0,-1)
|
|
@@ -415,7 +416,8 @@ closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
|
415
416
|
return // no git checking available
|
|
416
417
|
opBeginOrReschedule(closure(callback) {
|
|
417
418
|
willgit = true
|
|
418
|
-
files.fs.gitStatus(false, function (error, statlist,
|
|
419
|
+
files.fs.gitStatus(false, function (error, statlist,
|
|
420
|
+
local changed, delgit, unknownFiles, unknownFileStatus, changes, classID, item) {
|
|
419
421
|
if error {
|
|
420
422
|
files.gitvalid = false
|
|
421
423
|
return (callback(error))
|
|
@@ -649,6 +651,7 @@ closure FileManager(fs, options, local files, watch, opqueue, willgit, hadgit) {
|
|
|
649
651
|
*/
|
|
650
652
|
|
|
651
653
|
closure fimaStore(fm, node, local store) {
|
|
654
|
+
global()
|
|
652
655
|
store = new(object, this)
|
|
653
656
|
store.fm = fm
|
|
654
657
|
store.fs = fm.fs
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2019-
|
|
9
|
+
* Copyright (c) 2019-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -56,7 +56,8 @@ closure MakePSMutil(fs, local util) {
|
|
|
56
56
|
//
|
|
57
57
|
// Update a directory within an existing tree data structure. The result is a standard tuple with
|
|
58
58
|
// (error, changes) where the changes are added/deleted/changed. This assumes that children changed
|
|
59
|
-
// if their info is different
|
|
59
|
+
// if their info is different. If a child directory is found that does not yet have children, then
|
|
60
|
+
// the
|
|
60
61
|
|
|
61
62
|
util.treeDirUpdate = closure treeDirUpdate(treepath, dirpath, tree, callback, local error, inpath, treedir, files) {
|
|
62
63
|
if !callback
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* column positioning: // // !
|
|
8
8
|
*
|
|
9
|
-
* Copyright (c) 2020-
|
|
9
|
+
* Copyright (c) 2020-2024 by Richard C. Zulch
|
|
10
10
|
*
|
|
11
11
|
*/
|
|
12
12
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
* - directory names are non-empty strings with the sole "/" at the end
|
|
24
24
|
* - the names ".", "..", and anything containing ":" are forbidden
|
|
25
25
|
* - every directory has (or should have) an associated database record for itself
|
|
26
|
-
* -
|
|
26
|
+
* - when these records are missing, trivial parents are created during tree enumeration
|
|
27
27
|
* - pathnames are relative to the root of the view an d consist of a string with:
|
|
28
28
|
* - zero or more directory names joined by "/", then
|
|
29
29
|
* - either "", "/" for a directory, or "/" with a filename
|
|
@@ -37,6 +37,7 @@
|
|
|
37
37
|
*/
|
|
38
38
|
|
|
39
39
|
closure FSview(table, rootpath, local view) {
|
|
40
|
+
global(JSpath)
|
|
40
41
|
if !table
|
|
41
42
|
return (list(Error("invalid arguments")))
|
|
42
43
|
view = new(object, this)
|
|
@@ -83,7 +84,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
83
84
|
if isPath {
|
|
84
85
|
if name == ""
|
|
85
86
|
return (true)
|
|
86
|
-
else if name.substring(0, 1) == "/" ||
|
|
87
|
+
else if name.substring(0, 1) == "/" || name.indexOf("//") >= 0
|
|
87
88
|
return (false)
|
|
88
89
|
else
|
|
89
90
|
name = baseName(name) }
|
|
@@ -98,9 +99,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
98
99
|
if !string(path) {
|
|
99
100
|
if !msg
|
|
100
101
|
msg = "invalid path"
|
|
101
|
-
|
|
102
|
-
path = "<".concat(typeof(path), ">") // e.g. "<xobject>"
|
|
103
|
-
asyncResult(callback, Error(msg, typeof(content), {
|
|
102
|
+
asyncResult(callback, Error(msg, "invalid path ${typeof(path)}", {
|
|
104
103
|
status: 400
|
|
105
104
|
name: "invalid_arguments"
|
|
106
105
|
path: path
|
|
@@ -110,8 +109,10 @@ closure FSview(table, rootpath, local view) {
|
|
|
110
109
|
|
|
111
110
|
// checkPathName
|
|
112
111
|
//
|
|
113
|
-
// Return a `(path, name) tuple for a directory, or false if callback executed due to error.
|
|
114
|
-
|
|
112
|
+
// Return a `(path, name) tuple for a directory, or false if callback executed due to error. The
|
|
113
|
+
// name is the empty string if the path is empty. Path "/" has name "/". Otherwise the name is
|
|
114
|
+
// the last segment of the path, omitting the trailing slash.
|
|
115
|
+
//
|
|
115
116
|
function checkPathName(path, callback, local name, slashdex) {
|
|
116
117
|
if path == ""
|
|
117
118
|
name = ""
|
|
@@ -232,7 +233,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
232
233
|
else
|
|
233
234
|
metadata.finfo.encoding = "utf8" } // default string encoding
|
|
234
235
|
else if content && !xobject(content)
|
|
235
|
-
return (callback(Error("unsupported content type
|
|
236
|
+
return (callback(Error("unsupported content type ${typeof(content)}", {
|
|
236
237
|
status: 400
|
|
237
238
|
name: "invalid_arguments"
|
|
238
239
|
path: path
|
|
@@ -352,10 +353,17 @@ closure FSview(table, rootpath, local view) {
|
|
|
352
353
|
|
|
353
354
|
// copyDirectory
|
|
354
355
|
//
|
|
355
|
-
// Copy a directory by its source path, with optional move.
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
356
|
+
// Copy a directory by its source path, with optional move. The
|
|
357
|
+
// destination is:
|
|
358
|
+
// - a new name in same parent if it has no embedded slashes, or
|
|
359
|
+
// - the same name in a new location if it ends in a slash, otherwise
|
|
360
|
+
// - a new pathname for the source.
|
|
361
|
+
//
|
|
362
|
+
closure copyDirectory(srcpath, dest, options,
|
|
363
|
+
local error, nodes, data, destpath, errors, docpath, newpath, srcroot, item) {
|
|
364
|
+
if srcpath.slice(-1) != "/"
|
|
365
|
+
srcpath = srcpath.concat("/") // normalize source as directory
|
|
366
|
+
`(error, nodes) = view.table.records({ prefix: srcpath }) // each item has key/_id/_rev, not doc
|
|
359
367
|
if error
|
|
360
368
|
return (list(Error("copyDirectory: can't enumerate source directory", {
|
|
361
369
|
source: srcpath
|
|
@@ -434,7 +442,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
434
442
|
if !srcroot
|
|
435
443
|
srcroot = item // delete source root later
|
|
436
444
|
else {
|
|
437
|
-
`(error, data) = view.table.delete(item
|
|
445
|
+
`(error, data) = view.table.delete(item) // delete original
|
|
438
446
|
if error
|
|
439
447
|
errors.push(Error("copyDirectory: can't remove original", {
|
|
440
448
|
source: docpath
|
|
@@ -448,7 +456,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
448
456
|
}, errors))
|
|
449
457
|
else {
|
|
450
458
|
if srcroot {
|
|
451
|
-
`(error, data) = view.table.delete(srcroot
|
|
459
|
+
`(error, data) = view.table.delete(srcroot) // delete original root
|
|
452
460
|
if error
|
|
453
461
|
return (list(Error("copyDirectory: can't remove original root", {
|
|
454
462
|
source: srcpath
|
|
@@ -573,12 +581,11 @@ closure FSview(table, rootpath, local view) {
|
|
|
573
581
|
// Copy / move / rename a file or directory. The source is the full path of the item. The
|
|
574
582
|
// destination is:
|
|
575
583
|
// - a new name if it has no embedded slashes, or
|
|
576
|
-
// - a new location if it ends in a slash, otherwise
|
|
577
|
-
// - a new pathname for the source
|
|
584
|
+
// - the same name in a new location if it ends in a slash, otherwise
|
|
585
|
+
// - a new pathname for the source.
|
|
578
586
|
// This works by creating a new file or directory of files in the new location and then
|
|
579
|
-
//
|
|
580
|
-
//
|
|
581
|
-
|
|
587
|
+
// deleting the files in the existing location after the copy if options.move is true.
|
|
588
|
+
//
|
|
582
589
|
view.copy = closure copy(srcpath, dest, options, callback) {
|
|
583
590
|
if !callback
|
|
584
591
|
return (syncAdapter(copy, srcpath, dest, options))
|
|
@@ -594,7 +601,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
594
601
|
source: srcpath
|
|
595
602
|
destination: dest
|
|
596
603
|
}, error)))
|
|
597
|
-
else if
|
|
604
|
+
else if data.key.slice(-1) == "/"
|
|
598
605
|
result = copyDirectory(srcpath, dest, options) // hard case: directory with possibly many children
|
|
599
606
|
else
|
|
600
607
|
result = copyFile(data, dest, options) // easy case: single file
|
|
@@ -637,13 +644,13 @@ closure FSview(table, rootpath, local view) {
|
|
|
637
644
|
basedir = item // delete base directory at end
|
|
638
645
|
continue
|
|
639
646
|
}
|
|
640
|
-
`(error, data) = view.table.delete(item
|
|
647
|
+
`(error, data) = view.table.delete(item)
|
|
641
648
|
if error
|
|
642
649
|
errors.push(error) }
|
|
643
650
|
if errors.length != 0
|
|
644
651
|
error = Error("some directory children not deleted", errors)
|
|
645
652
|
else {
|
|
646
|
-
`(error, data) = view.table.delete(basedir
|
|
653
|
+
`(error, data) = view.table.delete(basedir)
|
|
647
654
|
if error
|
|
648
655
|
error = Error("delete directory failed", {
|
|
649
656
|
path: path
|
|
@@ -659,7 +666,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
659
666
|
//
|
|
660
667
|
// Read a directory at the specified path
|
|
661
668
|
// ### options currently ignored, for better or woise
|
|
662
|
-
|
|
669
|
+
//
|
|
663
670
|
view.dirList = closure dirList(path, options, callback, local name, dirdict) {
|
|
664
671
|
if !callback
|
|
665
672
|
return (syncAdapter(readir, path))
|
|
@@ -667,7 +674,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
667
674
|
if !path
|
|
668
675
|
return // already executed callback with error
|
|
669
676
|
dirdict = {
|
|
670
|
-
name: name
|
|
677
|
+
name: name
|
|
671
678
|
path: path
|
|
672
679
|
data: {
|
|
673
680
|
platform: table.type
|
|
@@ -700,10 +707,8 @@ closure FSview(table, rootpath, local view) {
|
|
|
700
707
|
finfo.type = "directory"
|
|
701
708
|
} else if !finfo.type
|
|
702
709
|
finfo.type = "file" // everything is a file in UNIX
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
if item.doc._length
|
|
706
|
-
finfo.length = item.doc._length
|
|
710
|
+
finfo.md5 = item.doc._md5 || undefined
|
|
711
|
+
finfo.length = item.doc._length || item.doc.length || undefined
|
|
707
712
|
if item.key.length > offset // not the directory itself
|
|
708
713
|
dirdict.children.push({
|
|
709
714
|
name: name
|
|
@@ -723,7 +728,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
723
728
|
// tree
|
|
724
729
|
//
|
|
725
730
|
// Return a tree for the specified path. The path is relative to the root of the view.
|
|
726
|
-
|
|
731
|
+
//
|
|
727
732
|
view.tree = closure tree(path, options, callback, local name, treedict, item, offset) {
|
|
728
733
|
if !callback
|
|
729
734
|
return (syncAdapter(tree, path, options))
|
|
@@ -735,7 +740,7 @@ closure FSview(table, rootpath, local view) {
|
|
|
735
740
|
deep: true
|
|
736
741
|
}
|
|
737
742
|
treedict = {
|
|
738
|
-
name: name
|
|
743
|
+
name: name
|
|
739
744
|
data: {
|
|
740
745
|
platform: table.type
|
|
741
746
|
semantics: "dbfs"
|
|
@@ -748,7 +753,8 @@ closure FSview(table, rootpath, local view) {
|
|
|
748
753
|
for item in path.split("/").slice(0,-1)
|
|
749
754
|
treedict.parents.push(item)
|
|
750
755
|
offset = path.length // offset to path's child names (after any slash)
|
|
751
|
-
view.table.records(options, function(error, data,
|
|
756
|
+
view.table.records(options, function(error, data,
|
|
757
|
+
local index, leaf, parent, child, slashdex, parents) {
|
|
752
758
|
if error
|
|
753
759
|
return (callback(error))
|
|
754
760
|
if data.rows.length == 0 && path != ""
|
|
@@ -775,22 +781,28 @@ closure FSview(table, rootpath, local view) {
|
|
|
775
781
|
else { // named or non-root directory
|
|
776
782
|
slashdex = name.lastIndexOf("/", name.length-2) // penultimate slash
|
|
777
783
|
parent = name.substring(0, slashdex+1) // includes parent's ending slash
|
|
778
|
-
|
|
779
|
-
|
|
784
|
+
leaf = name.slice(slashdex+1, -1) } // omits child's ending slash
|
|
785
|
+
child = index[name] = {
|
|
780
786
|
name: leaf
|
|
781
787
|
children: [] } }
|
|
782
788
|
else { // file child not in root
|
|
783
789
|
parent = name.substring(0, slashdex+1)
|
|
784
790
|
leaf = name.slice(slashdex+1)
|
|
785
791
|
child = { name: leaf } }
|
|
786
|
-
if index[parent]
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
792
|
+
if !index[parent] { // doesn't have immediate <parent>/ record
|
|
793
|
+
parents = parent.split("/").slice(0,-1)
|
|
794
|
+
parent = item = ""
|
|
795
|
+
for leaf in parents {
|
|
796
|
+
item = item.concat(leaf, "/")
|
|
797
|
+
if !index[item]
|
|
798
|
+
index[parent].children.push(
|
|
799
|
+
index[item] = {
|
|
800
|
+
name: leaf
|
|
801
|
+
children: [] })
|
|
802
|
+
parent = item
|
|
803
|
+
}
|
|
793
804
|
}
|
|
805
|
+
index[parent].children.push(child)
|
|
794
806
|
}
|
|
795
807
|
callback(false, treedict)
|
|
796
808
|
})
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
*
|
|
12
12
|
* column positioning: // // !
|
|
13
13
|
*
|
|
14
|
-
* Copyright (c) 2019-
|
|
14
|
+
* Copyright (c) 2019-2024 by Richard C. Zulch
|
|
15
15
|
*
|
|
16
16
|
*/
|
|
17
17
|
|
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
*/
|
|
29
29
|
|
|
30
30
|
closure rsrcVault(db, tablename, local vault) {
|
|
31
|
+
global()
|
|
31
32
|
vault = new(object, this)
|
|
32
33
|
|
|
33
34
|
// addResource
|
|
@@ -72,7 +73,7 @@ closure rsrcVault(db, tablename, local vault) {
|
|
|
72
73
|
//
|
|
73
74
|
// Return credentials for access to the resource.
|
|
74
75
|
|
|
75
|
-
vault.accessResource = function accessResource(resID) {
|
|
76
|
+
vault.accessResource = function accessResource(resID, local error, data) {
|
|
76
77
|
`(error, data) = vault.table.get(resID)
|
|
77
78
|
if error
|
|
78
79
|
list(error)
|
|
@@ -134,6 +135,7 @@ closure rsrcVault(db, tablename, local vault) {
|
|
|
134
135
|
*/
|
|
135
136
|
|
|
136
137
|
closure ResourceManager(dbname, prefix, local reman, watch, result) {
|
|
138
|
+
global(commonWatching)
|
|
137
139
|
reman = new(object, this)
|
|
138
140
|
watch = commonWatching.Watchable()
|
|
139
141
|
reman.watch = watch.watch
|
package/lib/browser/env_web.js
CHANGED
|
@@ -526,7 +526,7 @@ exports.NaanControllerWeb = function() {
|
|
|
526
526
|
statedoc.curversion = kStateCurrentVersion;
|
|
527
527
|
statedoc.firstver = kStateFirstVersion;
|
|
528
528
|
statedoc.licensee = "MIT-License";
|
|
529
|
-
statedoc.verstring = "1.0
|
|
529
|
+
statedoc.verstring = "1.1.0+1";
|
|
530
530
|
statedoc.date = new Date().toISOString();
|
|
531
531
|
statedoc.prefs = prefs;
|
|
532
532
|
statedoc.naan = naanlib.saveState(false); // true to optimize, which is a bit slower
|
|
@@ -544,7 +544,7 @@ exports.NaanControllerWeb = function() {
|
|
|
544
544
|
|| statedoc.firstver > kStateCurrentVersion
|
|
545
545
|
|| statedoc.curversion < kStateFirstVersion
|
|
546
546
|
|| statedoc.licensee != "MIT-License"
|
|
547
|
-
|| statedoc.verstring != "1.0
|
|
547
|
+
|| statedoc.verstring != "1.1.0+1")
|
|
548
548
|
{
|
|
549
549
|
localStorage.removeItem("NaanState_Hosted");
|
|
550
550
|
return (false);
|
|
@@ -603,7 +603,7 @@ exports.NaanControllerWeb = function() {
|
|
|
603
603
|
op: "VsiteOpen",
|
|
604
604
|
name: vsiteName,
|
|
605
605
|
naancont: contSelf,
|
|
606
|
-
title: vsiteName + " 1.0
|
|
606
|
+
title: vsiteName + " 1.1.0+1"
|
|
607
607
|
});
|
|
608
608
|
}
|
|
609
609
|
} catch (e) {
|
|
@@ -617,7 +617,7 @@ exports.NaanControllerWeb = function() {
|
|
|
617
617
|
op: "VsiteClose",
|
|
618
618
|
name: vsiteName,
|
|
619
619
|
naancont: contSelf,
|
|
620
|
-
title: vsiteName + " 1.0
|
|
620
|
+
title: vsiteName + " 1.1.0+1"
|
|
621
621
|
});
|
|
622
622
|
termTextOut("\x1b[90m\x1b[3m".concat("\nwindow closed", "\x1b[0m\n"));
|
|
623
623
|
}
|
|
@@ -632,8 +632,8 @@ exports.NaanControllerWeb = function() {
|
|
|
632
632
|
naanlib.banner();
|
|
633
633
|
var hostpath = naanlib.js.r("path").dirname(window.location.href);
|
|
634
634
|
naanlib.start({
|
|
635
|
-
cmd: 'App.version = "1.0
|
|
636
|
-
+ 'App.cache = "
|
|
635
|
+
cmd: 'App.version = "1.1.0+1";;\r\n'
|
|
636
|
+
+ 'App.cache = "241e1d15dfb0de008135e2de76886ccc";;\r\n'
|
|
637
637
|
+ 'Naan.module.requireQuery({ naanver: App.cache });;\r\n'
|
|
638
638
|
+ 'Naan.module.webparse("naan_init.nlg", "' + hostpath + '", { naanver: App.cache });;\r\n'
|
|
639
639
|
});
|