total5 0.0.1-13 → 0.0.1-14
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/builders.js +27 -15
- package/controller.js +10 -0
- package/flow-flowstream.js +9 -9
- package/flow.js +1 -1
- package/global.js +70 -0
- package/index.js +7 -4
- package/minificators.js +1 -1
- package/package.json +1 -1
- package/routing.js +4 -0
- package/uibuilder.js +7 -2
- package/utils.js +10 -1
package/builders.js
CHANGED
|
@@ -24,7 +24,11 @@ Options.prototype = {
|
|
|
24
24
|
},
|
|
25
25
|
|
|
26
26
|
get websocket() {
|
|
27
|
-
return this.controller.parent;
|
|
27
|
+
return this.controller ? this.controller.parent : null;
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
get sessionid() {
|
|
31
|
+
return this.controller ? this.controller.sessionid : null;
|
|
28
32
|
},
|
|
29
33
|
|
|
30
34
|
get value() {
|
|
@@ -52,15 +56,15 @@ Options.prototype = {
|
|
|
52
56
|
},
|
|
53
57
|
|
|
54
58
|
get path() {
|
|
55
|
-
return
|
|
59
|
+
return this.controller ? this.controller.pathname : EMPTYARRAY;
|
|
56
60
|
},
|
|
57
61
|
|
|
58
62
|
get split() {
|
|
59
|
-
return
|
|
63
|
+
return this.controller ? this.controller.split : EMPTYARRAY;
|
|
60
64
|
},
|
|
61
65
|
|
|
62
66
|
get split2() {
|
|
63
|
-
return
|
|
67
|
+
return this.controller ? this.controller.split2 : EMPTYARRAY;
|
|
64
68
|
},
|
|
65
69
|
|
|
66
70
|
get language() {
|
|
@@ -149,8 +153,14 @@ Options.prototype.cancel = function() {
|
|
|
149
153
|
};
|
|
150
154
|
|
|
151
155
|
Options.prototype.redirect = function(url) {
|
|
152
|
-
this
|
|
153
|
-
|
|
156
|
+
var self = this;
|
|
157
|
+
self.$callback = null;
|
|
158
|
+
if (self.controller) {
|
|
159
|
+
self.controller.redirect(url);
|
|
160
|
+
self.controller.destroyed = true;
|
|
161
|
+
}
|
|
162
|
+
self.cancel();
|
|
163
|
+
return self;
|
|
154
164
|
};
|
|
155
165
|
|
|
156
166
|
Options.prototype.audit = function(message, type) {
|
|
@@ -184,7 +194,7 @@ Options.prototype.done = function(arg) {
|
|
|
184
194
|
return function(err, response) {
|
|
185
195
|
if (err) {
|
|
186
196
|
err && self.error.push(err);
|
|
187
|
-
self.callback();
|
|
197
|
+
self.callback(null);
|
|
188
198
|
} else {
|
|
189
199
|
if (self.TYPE === 'auth')
|
|
190
200
|
self.callback(arg === true ? response : arg);
|
|
@@ -1559,10 +1569,12 @@ exports.builtinauth = function(opt) {
|
|
|
1559
1569
|
if (!sessionid && opt.header)
|
|
1560
1570
|
sessionid = $.controller.headers[opt.header];
|
|
1561
1571
|
|
|
1572
|
+
var localize = opt.locale || opt.localize;
|
|
1573
|
+
|
|
1562
1574
|
if (!sessionid) {
|
|
1563
1575
|
|
|
1564
|
-
if (
|
|
1565
|
-
$.controller.language =
|
|
1576
|
+
if (localize)
|
|
1577
|
+
$.controller.language = localize(null, $.controller);
|
|
1566
1578
|
|
|
1567
1579
|
$.invalid();
|
|
1568
1580
|
return;
|
|
@@ -1583,14 +1595,14 @@ exports.builtinauth = function(opt) {
|
|
|
1583
1595
|
$.controller.session = session;
|
|
1584
1596
|
$.controller.sessionid = session.sessionid;
|
|
1585
1597
|
if (!opt.onsession || !opt.onsession(session, $)) {
|
|
1586
|
-
if (
|
|
1587
|
-
$.controller.language =
|
|
1598
|
+
if (localize)
|
|
1599
|
+
$.controller.language = localize(session.data, $.controller);
|
|
1588
1600
|
$.success(session.data);
|
|
1589
1601
|
}
|
|
1590
1602
|
} else {
|
|
1591
1603
|
|
|
1592
|
-
if (
|
|
1593
|
-
$.controller.language =
|
|
1604
|
+
if (localize)
|
|
1605
|
+
$.controller.language = localize(null, $.controller);
|
|
1594
1606
|
|
|
1595
1607
|
$.invalid();
|
|
1596
1608
|
sessionid = null;
|
|
@@ -1638,8 +1650,8 @@ exports.builtinauth = function(opt) {
|
|
|
1638
1650
|
$.controller.session = opt.sessions[meta.sessionid] = { sessionid: meta.sessionid, userid: meta.userid, data: data, ua: $.controller.ua, expire: NOW.add(opt.expire) };
|
|
1639
1651
|
$.controller.sessionid = meta.sessionid;
|
|
1640
1652
|
|
|
1641
|
-
if (
|
|
1642
|
-
$.controller.language =
|
|
1653
|
+
if (localize)
|
|
1654
|
+
$.controller.language = localize(data, $.controller);
|
|
1643
1655
|
|
|
1644
1656
|
if (!opt.onsession || !opt.onsession($.controller.session, $, true))
|
|
1645
1657
|
$.success(data);
|
package/controller.js
CHANGED
|
@@ -598,6 +598,16 @@ Controller.prototype.proxy = function(opt) {
|
|
|
598
598
|
|
|
599
599
|
};
|
|
600
600
|
|
|
601
|
+
Controller.prototype.done = function(arg) {
|
|
602
|
+
var ctrl = this;
|
|
603
|
+
return function(err, response) {
|
|
604
|
+
if (err)
|
|
605
|
+
ctrl.invalid(err);
|
|
606
|
+
else
|
|
607
|
+
ctrl.json(DEF.onSuccess(arg === true ? response : arg));
|
|
608
|
+
};
|
|
609
|
+
};
|
|
610
|
+
|
|
601
611
|
Controller.prototype.success = function(value) {
|
|
602
612
|
F.TUtils.success.value = value;
|
|
603
613
|
this.json(F.TUtils.success);
|
package/flow-flowstream.js
CHANGED
|
@@ -406,13 +406,8 @@ Instance.prototype.kill = Instance.prototype.destroy = function() {
|
|
|
406
406
|
|
|
407
407
|
if (self.flow.isworkerthread) {
|
|
408
408
|
|
|
409
|
-
self.
|
|
410
|
-
self.flow
|
|
411
|
-
|
|
412
|
-
if (self.flow.terminate)
|
|
413
|
-
self.flow.terminate();
|
|
414
|
-
else
|
|
415
|
-
self.flow.kill(9);
|
|
409
|
+
self.postMessage({ TYPE: 'stream/destroy' });
|
|
410
|
+
setTimeout(self => self.flow.terminate ? self.flow.terminate() : self.flow.kill(9), 1000, self);
|
|
416
411
|
|
|
417
412
|
if (PROXIES[self.id]) {
|
|
418
413
|
PROXIES[self.id].remove();
|
|
@@ -424,11 +419,12 @@ Instance.prototype.kill = Instance.prototype.destroy = function() {
|
|
|
424
419
|
for (var key in self.flow.sockets)
|
|
425
420
|
self.flow.sockets[key].destroy();
|
|
426
421
|
}
|
|
427
|
-
self.flow.$socket && self.flow.$socket.destroy();
|
|
428
|
-
self.flow.$client && self.flow.$client.destroy();
|
|
429
422
|
self.flow.destroy();
|
|
430
423
|
}
|
|
431
424
|
|
|
425
|
+
self.flow.$socket && self.flow.$socket.destroy();
|
|
426
|
+
self.flow.$client && self.flow.$client.destroy();
|
|
427
|
+
|
|
432
428
|
for (var key in CALLBACKS) {
|
|
433
429
|
if (CALLBACKS[key].id === self.id)
|
|
434
430
|
delete CALLBACKS[key];
|
|
@@ -1043,6 +1039,10 @@ function init_current(meta, callback, nested) {
|
|
|
1043
1039
|
flow.proxy.ping = setTimeout(killprocess, 10000);
|
|
1044
1040
|
break;
|
|
1045
1041
|
|
|
1042
|
+
case 'stream/destroy':
|
|
1043
|
+
flow.destroy();
|
|
1044
|
+
break;
|
|
1045
|
+
|
|
1046
1046
|
case 'stream/export':
|
|
1047
1047
|
msg.data = flow.export2();
|
|
1048
1048
|
Parent.postMessage(msg);
|
package/flow.js
CHANGED
package/global.js
CHANGED
|
@@ -103,6 +103,76 @@ global.CORS = function(origin) {
|
|
|
103
103
|
CONF.$cors = origin || '*';
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
+
global.AJAX = function(url, data, callback) {
|
|
107
|
+
|
|
108
|
+
if (typeof(data) === 'function') {
|
|
109
|
+
callback = data;
|
|
110
|
+
data = null;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (!callback)
|
|
114
|
+
return new Promise((resolve, reject) => global.AJAX(url, data, (err, response) => err ? reject(err) : resolve(response)));
|
|
115
|
+
|
|
116
|
+
var index = url.indexOf(' ');
|
|
117
|
+
var opt = {};
|
|
118
|
+
|
|
119
|
+
if (index !== -1) {
|
|
120
|
+
opt.method = url.substring(0, index);
|
|
121
|
+
opt.url = url.substring(index + 1);
|
|
122
|
+
} else {
|
|
123
|
+
opt.method = 'GET';
|
|
124
|
+
opt.url = url;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
if (data) {
|
|
128
|
+
opt.type = 'json';
|
|
129
|
+
opt.body = JSON.stringify(data);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
opt.callback = function(err, response) {
|
|
133
|
+
|
|
134
|
+
if (err) {
|
|
135
|
+
callback && callback(err, null, response);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
var type = err ? '' : response.headers['content-type'] || '';
|
|
140
|
+
if (type) {
|
|
141
|
+
var index = type.lastIndexOf(';');
|
|
142
|
+
if (index !== -1)
|
|
143
|
+
type = type.substring(0, index).trim();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
var value = null;
|
|
147
|
+
|
|
148
|
+
switch (type.toLowerCase()) {
|
|
149
|
+
case 'text/xml':
|
|
150
|
+
case 'application/xml':
|
|
151
|
+
value = response.body ? response.body.parseXML(self.$replace ? true : false) : {};
|
|
152
|
+
break;
|
|
153
|
+
case 'application/x-www-form-urlencoded':
|
|
154
|
+
value = response.body ? DEF.parsers.urlencoded(response.body) : {};
|
|
155
|
+
break;
|
|
156
|
+
case 'application/json':
|
|
157
|
+
case 'text/json':
|
|
158
|
+
value = response.body ? response.body.parseJSON(true) : null;
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
value = response.body;
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
if (response.status >= 400) {
|
|
166
|
+
err = value;
|
|
167
|
+
value = null;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
delete response.body;
|
|
171
|
+
callback && callback(err, value, response);
|
|
172
|
+
};
|
|
173
|
+
F.TUtils.request(opt);
|
|
174
|
+
};
|
|
175
|
+
|
|
106
176
|
// Utils
|
|
107
177
|
global.U = F.TUtils;
|
|
108
178
|
global.GUID = F.TUtils.guid;
|
package/index.js
CHANGED
|
@@ -483,7 +483,10 @@ function unlink(arr, callback) {
|
|
|
483
483
|
|
|
484
484
|
NOW = new Date();
|
|
485
485
|
|
|
486
|
-
if (
|
|
486
|
+
if (err instanceof F.TBuilders.ErrorBuilder) {
|
|
487
|
+
if (!name)
|
|
488
|
+
name = err[0].name;
|
|
489
|
+
} else if (!name && err.name)
|
|
487
490
|
name = err.name;
|
|
488
491
|
|
|
489
492
|
err = err.toString();
|
|
@@ -1347,13 +1350,13 @@ F.componentator = function(name, components, removeprev = true) {
|
|
|
1347
1350
|
|
|
1348
1351
|
};
|
|
1349
1352
|
|
|
1350
|
-
F.error = function(err, name,
|
|
1353
|
+
F.error = function(err, name, url) {
|
|
1351
1354
|
|
|
1352
1355
|
if (!arguments.length)
|
|
1353
1356
|
return F.errorcallback;
|
|
1354
1357
|
|
|
1355
1358
|
if (err)
|
|
1356
|
-
F.def.onError(err, name,
|
|
1359
|
+
F.def.onError(err, name, url);
|
|
1357
1360
|
};
|
|
1358
1361
|
|
|
1359
1362
|
F.errorcallback = function(err) {
|
|
@@ -2413,7 +2416,7 @@ F.dir = function(val) {
|
|
|
2413
2416
|
if (val)
|
|
2414
2417
|
F.directory = val;
|
|
2415
2418
|
|
|
2416
|
-
var dirs = ['public', 'tmp', 'logs', 'databases', 'controllers', 'resources', 'plugins', 'views', 'definitions', 'schemas', 'models', 'flowstreams', 'bundles', 'actions', 'extensions', 'source', 'services', 'updates', 'templates'];
|
|
2419
|
+
var dirs = ['public', 'tmp', 'logs', 'databases', 'controllers', 'resources', 'plugins', 'views', 'definitions', 'schemas', 'models', 'flowstreams', 'bundles', 'actions', 'extensions', 'source', 'services', 'updates', 'templates', 'private'];
|
|
2417
2420
|
|
|
2418
2421
|
for (let dir of dirs) {
|
|
2419
2422
|
var cfg = F.config['$dir' + dir];
|
package/minificators.js
CHANGED
|
@@ -167,7 +167,7 @@ exports.js = function(value) {
|
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
if ((c === '}' && last === ';') || ((c === '}' || c === ']') && output[output.length - 1] === ' ' && alpha.test(output[output.length - 2])))
|
|
170
|
+
if (!scope && (c === '}' && last === ';') || ((c === '}' || c === ']') && output[output.length - 1] === ' ' && alpha.test(output[output.length - 2])))
|
|
171
171
|
output.pop();
|
|
172
172
|
|
|
173
173
|
output.push(c);
|
package/package.json
CHANGED
package/routing.js
CHANGED
|
@@ -250,8 +250,12 @@ function Route(url, action, size) {
|
|
|
250
250
|
t.action = null;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
if (!t.view && !t.action && t.method !== 'FILE' && t.method !== 'SOCKET')
|
|
254
|
+
t.view = t.url[0] && t.url[0] !== '/' ? t.url[0] : 'index';
|
|
255
|
+
|
|
253
256
|
if (t.wildcard)
|
|
254
257
|
t.priority -= 50;
|
|
258
|
+
|
|
255
259
|
}
|
|
256
260
|
|
|
257
261
|
Route.prototype.compare = function(ctrl) {
|
package/uibuilder.js
CHANGED
|
@@ -7,6 +7,11 @@ const REG_STRING = /'|"/g;
|
|
|
7
7
|
|
|
8
8
|
exports.compile = async function(opt, callback) {
|
|
9
9
|
|
|
10
|
+
// opt.schema {String/Object}
|
|
11
|
+
// |--- opt.schema.origin {String}
|
|
12
|
+
// opt.local {Boolean}
|
|
13
|
+
// opt.download {Boolean}
|
|
14
|
+
|
|
10
15
|
if (!callback)
|
|
11
16
|
return new Promise((resolve, reject) => exports.compile(opt, (err, response) => err ? reject(err) : resolve(response)));
|
|
12
17
|
|
|
@@ -105,7 +110,7 @@ async function getComponents(schema, used, download) {
|
|
|
105
110
|
|
|
106
111
|
for (let com of arr) {
|
|
107
112
|
|
|
108
|
-
if (com.value.indexOf('.json') === -1
|
|
113
|
+
if (com.value.indexOf('.json') === -1 && !used[com.id])
|
|
109
114
|
continue;
|
|
110
115
|
|
|
111
116
|
let url = com.value;
|
|
@@ -137,7 +142,7 @@ async function getComponents(schema, used, download) {
|
|
|
137
142
|
components[com.id] = render;
|
|
138
143
|
} else {
|
|
139
144
|
if (render[0] === '/')
|
|
140
|
-
render = schema.origin + render;
|
|
145
|
+
render = (schema.origin || '') + render;
|
|
141
146
|
let html = await Download(render);
|
|
142
147
|
if (html)
|
|
143
148
|
components[com.id] = 'base64 ' + Buffer.from(encodeURIComponent(html), 'utf8').toString('base64');
|
package/utils.js
CHANGED
|
@@ -2207,7 +2207,16 @@ SP.hash = function(type, salt) {
|
|
|
2207
2207
|
}
|
|
2208
2208
|
};
|
|
2209
2209
|
|
|
2210
|
-
SP.sign = function(key) {
|
|
2210
|
+
SP.sign = function(key, check) {
|
|
2211
|
+
|
|
2212
|
+
if (check) {
|
|
2213
|
+
let index = this.lastIndexOf('-');
|
|
2214
|
+
if (index === -1)
|
|
2215
|
+
return null;
|
|
2216
|
+
var id = this.substring(0, index);
|
|
2217
|
+
return id.sign(key) === this ? id : null;
|
|
2218
|
+
}
|
|
2219
|
+
|
|
2211
2220
|
return this + '-' + (string_hash(this + (key || '')) >>> 0).toString(36);
|
|
2212
2221
|
};
|
|
2213
2222
|
|