statebus 7.0.0 → 7.0.3
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/clients.js +3 -8
- package/package.json +1 -1
- package/servers.js +11 -9
- package/statebus.js +1 -1
package/clients.js
CHANGED
|
@@ -224,13 +224,6 @@
|
|
|
224
224
|
function localstorage_client (prefix) {
|
|
225
225
|
try { localStorage } catch (e) { return }
|
|
226
226
|
|
|
227
|
-
// This doesn't yet trigger updates across multiple browser windows.
|
|
228
|
-
// We can do that by adding a list of dirty keys and
|
|
229
|
-
|
|
230
|
-
var bus = this
|
|
231
|
-
bus.log(this)
|
|
232
|
-
|
|
233
|
-
// Get returns the value immediately in a set
|
|
234
227
|
// Sets are queued up, to store values with a delay, in batch
|
|
235
228
|
var sets_are_pending = false
|
|
236
229
|
var pending_sets = {}
|
|
@@ -522,7 +515,7 @@
|
|
|
522
515
|
var react_render
|
|
523
516
|
function scripts_ready () {
|
|
524
517
|
react_render = ReactDOM.render
|
|
525
|
-
make_client_statebus_maker()
|
|
518
|
+
// make_client_statebus_maker()
|
|
526
519
|
window.bus = window.statebus()
|
|
527
520
|
bus.label = 'bus'
|
|
528
521
|
|
|
@@ -535,6 +528,8 @@
|
|
|
535
528
|
bus.libs.http_out = http_mount
|
|
536
529
|
bus.libs.react_class = create_react_class
|
|
537
530
|
bus.libs.input = make_better_input_17()
|
|
531
|
+
bus.libs.localstorage = localstorage_client
|
|
532
|
+
|
|
538
533
|
// if (statebus_server !== 'none') {
|
|
539
534
|
// if (clientjs_option('braid_mode')) {
|
|
540
535
|
// console.log('Using Braid-HTTP!')
|
package/package.json
CHANGED
package/servers.js
CHANGED
|
@@ -103,7 +103,7 @@ function import_server (bus, options)
|
|
|
103
103
|
bus.express.use(bus.http)
|
|
104
104
|
|
|
105
105
|
// Connect bus to the HTTP server
|
|
106
|
-
bus.express.use(bus.
|
|
106
|
+
bus.express.use(bus.http_in)
|
|
107
107
|
|
|
108
108
|
// Serve Client Coffee
|
|
109
109
|
bus.serve_client_coffee()
|
|
@@ -154,7 +154,7 @@ function import_server (bus, options)
|
|
|
154
154
|
},
|
|
155
155
|
|
|
156
156
|
// Connect HTTP GET and PUT to our Get and Set
|
|
157
|
-
|
|
157
|
+
http_in: function (req, res, next) {
|
|
158
158
|
if (bus.honk)
|
|
159
159
|
console.log(req.method, req.url, req.headers.subscribe
|
|
160
160
|
? 'Subscribe: ' + req.headers.subscribe : '')
|
|
@@ -182,6 +182,9 @@ function import_server (bus, options)
|
|
|
182
182
|
else
|
|
183
183
|
res.statusCode = 200
|
|
184
184
|
|
|
185
|
+
// We only return JSON
|
|
186
|
+
res.setHeader('Content-Type', 'application/json')
|
|
187
|
+
|
|
185
188
|
// Do the get
|
|
186
189
|
// cbus.honk = 'statelog'
|
|
187
190
|
var key = req.path.substr(1)
|
|
@@ -594,7 +597,7 @@ function import_server (bus, options)
|
|
|
594
597
|
function save_db() {
|
|
595
598
|
if (!db_is_ok) return
|
|
596
599
|
|
|
597
|
-
console.time('saved db')
|
|
600
|
+
// console.time('saved db')
|
|
598
601
|
|
|
599
602
|
fs.writeFile(filename+'.tmp', JSON.stringify(db, null, 1), function(err) {
|
|
600
603
|
if (err) {
|
|
@@ -606,7 +609,7 @@ function import_server (bus, options)
|
|
|
606
609
|
console.error('Crap !! DB IS DYING !!!!', err)
|
|
607
610
|
db_is_ok = false
|
|
608
611
|
} else {
|
|
609
|
-
console.timeEnd('saved db')
|
|
612
|
+
// console.timeEnd('saved db')
|
|
610
613
|
pending_save = null
|
|
611
614
|
}
|
|
612
615
|
})
|
|
@@ -1131,7 +1134,7 @@ function import_server (bus, options)
|
|
|
1131
1134
|
JSON.stringify(details)])
|
|
1132
1135
|
},
|
|
1133
1136
|
|
|
1134
|
-
|
|
1137
|
+
time () {
|
|
1135
1138
|
if (bus('time*').to_get.length > 0)
|
|
1136
1139
|
// Then it's already installed
|
|
1137
1140
|
return
|
|
@@ -2417,11 +2420,10 @@ function import_server (bus, options)
|
|
|
2417
2420
|
}
|
|
2418
2421
|
}
|
|
2419
2422
|
// Add methods to bus object
|
|
2420
|
-
for (var m in extra_methods)
|
|
2423
|
+
for (var m in extra_methods) {
|
|
2421
2424
|
bus[m] = extra_methods[m]
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
bus.libs.http_in = extra_methods.handle_http
|
|
2425
|
+
bus.libs[m] = extra_methods[m]
|
|
2426
|
+
}
|
|
2425
2427
|
|
|
2426
2428
|
bus.options = default_options(bus)
|
|
2427
2429
|
set_options(bus, options)
|
package/statebus.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
else if (typeof define == 'function' && typeof define.amd == 'object') define(definition)
|
|
5
5
|
else this[name] = definition()
|
|
6
6
|
}('statebus', function() {statelog_indent = 0; var busses = {}, bus_count = 0, executing_funk, global_funk, funks = {}, clean_timer, symbols, nodejs = typeof window === 'undefined'; function make_bus (options) {
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
|
|
9
9
|
// ****************
|
|
10
10
|
// Get, Set, Forget, Delete
|