hsync 0.11.0 → 0.13.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/config.js +2 -0
- package/dist/hsync.js +15 -3
- package/dist/hsync.min.js +1 -1
- package/hsync-web.js +2 -0
- package/package.json +1 -1
- package/webpack.config.js +3 -0
package/config.js
CHANGED
package/dist/hsync.js
CHANGED
|
@@ -13,9 +13,9 @@
|
|
|
13
13
|
/*!*******************!*\
|
|
14
14
|
!*** ./config.js ***!
|
|
15
15
|
\*******************/
|
|
16
|
-
/***/ ((module) => {
|
|
16
|
+
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
17
17
|
|
|
18
|
-
eval("
|
|
18
|
+
eval("let process = __webpack_require__.g.process || {env: {}};\n\nconst baseConfig = {\n hsyncServer: process.env.HSYNC_SERVER, // something like 'wss://mydevice.mydomain.com'\n hsyncSecret: process.env.HSYNC_SECRET, // keep it secret, keep it safe!\n localHost: process.env.LOCAL_HOST || 'localhost', // host of local server\n port: process.env.PORT || 3000, // port of local server\n hsyncBase: process.env.HSYNC_BASE || '_hs',\n keepalive: parseInt(process.env.HSYNC_KEEP_ALIVE) || 300,\n dynamicHost: process.env.HSYNC_DYNAMIC_HOST,\n defaultDynamicHost: 'https://demo.hsync.tech',\n};\n\n\nconst connections = [baseConfig];\nconst keys = Object.keys(process.env);\nkeys.forEach((k) => {\n if(k.startsWith('HSYNC_SERVER_')) {\n const name = k.substring(13);\n const value = process.env[k];\n if (name && value) {\n connections.push({\n name,\n hsyncServer: value,\n hsyncSecret: process.env['HSYNC_SECRET_' + name] || baseConfig.hsyncSecret,\n localHost: process.env['LOCAL_HOST_' + name] || baseConfig.localHost,\n port: process.env['PORT_' + name] || baseConfig.port,\n hsyncBase: process.env['HSYNC_BASE_' + name] || baseConfig.hsyncBase,\n keepalive: parseInt(process.env['HSYNC_KEEP_ALIVE_' + name]) || baseConfig.keepalive,\n dynamicHost: process.env['HSYNC_DYNAMIC_HOST_' + name],\n });\n }\n }\n})\n\nconst config = Object.assign({}, baseConfig, {connections});\n\nmodule.exports = config;\n\n//# sourceURL=webpack://hsync/./config.js?");
|
|
19
19
|
|
|
20
20
|
/***/ }),
|
|
21
21
|
|
|
@@ -35,7 +35,7 @@ eval("const fetch = __webpack_require__(/*! isomorphic-fetch */ \"./node_modules
|
|
|
35
35
|
\**********************/
|
|
36
36
|
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
|
|
37
37
|
|
|
38
|
-
eval("const mqtt = __webpack_require__(/*! precompiled-mqtt */ \"./node_modules/precompiled-mqtt/dist/mqtt.browser.js\");\nconst buffer = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\nconst net = __webpack_require__(/*! net-web */ \"./node_modules/net-web/net-web.js\");\nconst { createHsync, setNet, setMqtt } = __webpack_require__(/*! ./connection */ \"./connection.js\");\nconst config = __webpack_require__(/*! ./config */ \"./config.js\");\n\n// TODO need to make this work with web/service workers\nwindow.Buffer = buffer.Buffer;\n\nsetNet(net);\nsetMqtt(mqtt);\n\nasync function dynamicConnect(dynamicHost, useLocalStorage) {\n let con;\n if (useLocalStorage) {\n const localConfigStr = localStorage.getItem('hsyncConfig');\n if (localConfigStr) {\n const localConfig = JSON.parse(localConfigStr);\n if ((Date.now() - localConfig.created) < (localConfig.timeout * 0.66)) {\n config.hsyncSecret = localConfig.hsyncSecret;\n config.hsyncServer = localConfig.hsyncServer;\n }\n }\n \n if (!config.hsyncSecret) {\n config.dynamicHost = dynamicHost || config.defaultDynamicHost;\n }\n \n con = await createHsync(config);\n \n if (config.dynamicHost) {\n const storeConfig = {\n hsyncSecret: con.hsyncSecret,\n hsyncServer: con.hsyncServer,\n timeout: con.dynamicTimeout,\n created: Date.now(),\n };\n localStorage.setItem('hsyncConfig', JSON.stringify(storeConfig));\n }\n\n return con;\n }\n\n config.dynamicHost = dynamicHost || config.defaultDynamicHost;\n con = await createHsync(config);\n\n return con;\n \n}\n\n\nconst hsync = globalThis.hsync || {\n createConnection: createHsync,\n dynamicConnect,\n net,\n config,\n};\nglobalThis.hsync = hsync;\n\nmodule.exports = hsync;\n\n\n//# sourceURL=webpack://hsync/./hsync-web.js?");
|
|
38
|
+
eval("const mqtt = __webpack_require__(/*! precompiled-mqtt */ \"./node_modules/precompiled-mqtt/dist/mqtt.browser.js\");\nconst buffer = __webpack_require__(/*! buffer */ \"./node_modules/buffer/index.js\");\nconst net = __webpack_require__(/*! net-web */ \"./node_modules/net-web/net-web.js\");\nconst { createHsync, setNet, setMqtt } = __webpack_require__(/*! ./connection */ \"./connection.js\");\nconst config = __webpack_require__(/*! ./config */ \"./config.js\");\n\n// TODO need to make this work with web/service workers\nwindow.Buffer = buffer.Buffer;\n\nsetNet(net);\nsetMqtt(mqtt);\n\nasync function dynamicConnect(dynamicHost, useLocalStorage) {\n let con;\n if (useLocalStorage) {\n const localConfigStr = localStorage.getItem('hsyncConfig');\n if (localConfigStr) {\n const localConfig = JSON.parse(localConfigStr);\n if ((Date.now() - localConfig.created) < (localConfig.timeout * 0.66)) {\n config.hsyncSecret = localConfig.hsyncSecret;\n config.hsyncServer = localConfig.hsyncServer;\n } else {\n localStorage.removeItem('hsyncConfig');\n }\n }\n \n if (!config.hsyncSecret) {\n config.dynamicHost = dynamicHost || config.defaultDynamicHost;\n }\n \n con = await createHsync(config);\n \n if (config.dynamicHost) {\n const storeConfig = {\n hsyncSecret: con.hsyncSecret,\n hsyncServer: con.hsyncServer,\n timeout: con.dynamicTimeout,\n created: Date.now(),\n };\n localStorage.setItem('hsyncConfig', JSON.stringify(storeConfig));\n }\n\n return con;\n }\n\n config.dynamicHost = dynamicHost || config.defaultDynamicHost;\n con = await createHsync(config);\n\n return con;\n \n}\n\n\nconst hsync = globalThis.hsync || {\n createConnection: createHsync,\n dynamicConnect,\n net,\n config,\n};\nglobalThis.hsync = hsync;\n\nmodule.exports = hsync;\n\n\n//# sourceURL=webpack://hsync/./hsync-web.js?");
|
|
39
39
|
|
|
40
40
|
/***/ }),
|
|
41
41
|
|
|
@@ -344,6 +344,18 @@ eval("module.exports = JSON.parse('{\"_from\":\"net-web\",\"_id\":\"net-web@0.2.
|
|
|
344
344
|
/******/ };
|
|
345
345
|
/******/ })();
|
|
346
346
|
/******/
|
|
347
|
+
/******/ /* webpack/runtime/global */
|
|
348
|
+
/******/ (() => {
|
|
349
|
+
/******/ __webpack_require__.g = (function() {
|
|
350
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
351
|
+
/******/ try {
|
|
352
|
+
/******/ return this || new Function('return this')();
|
|
353
|
+
/******/ } catch (e) {
|
|
354
|
+
/******/ if (typeof window === 'object') return window;
|
|
355
|
+
/******/ }
|
|
356
|
+
/******/ })();
|
|
357
|
+
/******/ })();
|
|
358
|
+
/******/
|
|
347
359
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
348
360
|
/******/ (() => {
|
|
349
361
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|