@things-factory/shell 4.0.25 → 4.0.30

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.
@@ -1,5 +1,6 @@
1
- import { LitElement, html } from 'lit-element'
2
- import { subscribe } from '../graphql-client'
1
+ import { html, LitElement } from 'lit-element'
2
+
3
+ import { subscribe } from '@operato/graphql'
3
4
 
4
5
  export class OopsProgress extends LitElement {
5
6
  static get properties() {
@@ -1,5 +1,6 @@
1
1
  import '@material/mwc-icon-button'
2
2
  import '@material/mwc-button'
3
+
3
4
  import { css, html, LitElement } from 'lit-element'
4
5
 
5
6
  export class HomePage extends LitElement {
@@ -66,7 +67,7 @@ export class HomePage extends LitElement {
66
67
  var { icon, title, description } = this.applicationMeta
67
68
 
68
69
  return html`
69
- <mwc-icon-button home icon="home" @click=${e => (window.location = '/')}></mwc-icon-button>
70
+ <mwc-icon-button home icon="home" @click=${e => (window.location.href = '/')}></mwc-icon-button>
70
71
 
71
72
  <div message>
72
73
  <strong>${title}</strong>
@@ -0,0 +1,140 @@
1
+ const log = require('./log');
2
+
3
+ const refresh = 'Please refresh the page.';
4
+ const hotOptions = {
5
+ ignoreUnaccepted: true,
6
+ ignoreDeclined: true,
7
+ ignoreErrored: true,
8
+ onUnaccepted(data) {
9
+ const chain = [].concat(data.chain);
10
+ const last = chain[chain.length - 1];
11
+
12
+ if (last === 0) {
13
+ chain.pop();
14
+ }
15
+
16
+ log.warn(`Ignored an update to unaccepted module ${chain.join(' ➭ ')}`);
17
+ },
18
+ onDeclined(data) {
19
+ log.warn(`Ignored an update to declined module ${data.chain.join(' ➭ ')}`);
20
+ },
21
+ onErrored(data) {
22
+ log.warn(`Ignored an error while updating module ${data.moduleId} <${data.type}>`);
23
+ log.warn(data.error);
24
+ }
25
+ };
26
+
27
+ let lastHash;
28
+
29
+ function upToDate() {
30
+ return lastHash.indexOf(__webpack_hash__) >= 0;
31
+ }
32
+
33
+ function result(modules, appliedModules) {
34
+ const unaccepted = modules.filter(
35
+ (moduleId) => appliedModules && appliedModules.indexOf(moduleId) < 0
36
+ );
37
+
38
+ if (unaccepted.length > 0) {
39
+ let message = 'The following modules could not be updated:';
40
+
41
+ for (const moduleId of unaccepted) {
42
+ message += `\n ⦻ ${moduleId}`;
43
+ }
44
+ log.warn(message);
45
+ }
46
+
47
+ if (!(appliedModules || []).length) {
48
+ log.info('No Modules Updated.');
49
+ } else {
50
+ const message = ['The following modules were updated:'];
51
+
52
+ for (const moduleId of appliedModules) {
53
+ message.push(` ↻ ${moduleId}`);
54
+ }
55
+
56
+ log.info(message.join('\n'));
57
+
58
+ const numberIds = appliedModules.every((moduleId) => typeof moduleId === 'number');
59
+ if (numberIds) {
60
+ log.info('Please consider using the NamedModulesPlugin for module names.');
61
+ }
62
+ }
63
+ }
64
+
65
+ function check(options) {
66
+ module.hot
67
+ .check()
68
+ .then((modules) => {
69
+ if (!modules) {
70
+ log.warn(`Cannot find update. The server may have been restarted. ${refresh}`);
71
+ if (options.reload) {
72
+ window.location.reload();
73
+ }
74
+ return null;
75
+ }
76
+
77
+ const hotOpts = options.reload ? {} : hotOptions;
78
+
79
+ return module.hot
80
+ .apply(hotOpts)
81
+ .then((appliedModules) => {
82
+ if (!upToDate()) {
83
+ check(options);
84
+ }
85
+
86
+ result(modules, appliedModules);
87
+
88
+ if (upToDate()) {
89
+ log.info('App is up to date.');
90
+ }
91
+ })
92
+ .catch((err) => {
93
+ const status = module.hot.status();
94
+ if (['abort', 'fail'].indexOf(status) >= 0) {
95
+ log.warn(`Cannot apply update. ${refresh}`);
96
+ log.warn(err.stack || err.message);
97
+ if (options.reload) {
98
+ window.location.reload();
99
+ }
100
+ } else {
101
+ log.warn(`Update failed: ${err.stack}` || err.message);
102
+ }
103
+ });
104
+ })
105
+ .catch((err) => {
106
+ const status = module.hot.status();
107
+ if (['abort', 'fail'].indexOf(status) >= 0) {
108
+ log.warn(`Cannot check for update. ${refresh}`);
109
+ log.warn(err.stack || err.message);
110
+ if (options.reload) {
111
+ window.location.reload();
112
+ }
113
+ } else {
114
+ log.warn(`Update check failed: ${err.stack}` || err.message);
115
+ }
116
+ });
117
+ }
118
+
119
+ if (module.hot) {
120
+ log.info('Hot Module Replacement Enabled. Waiting for signal.');
121
+ } else {
122
+ log.error('Hot Module Replacement is disabled.');
123
+ }
124
+
125
+ module.exports = function update(currentHash, options) {
126
+ lastHash = currentHash;
127
+ if (!upToDate()) {
128
+ const status = module.hot.status();
129
+
130
+ if (status === 'idle') {
131
+ log.info('Checking for updates to the bundle.');
132
+ check(options);
133
+ } else if (['abort', 'fail'].indexOf(status) >= 0) {
134
+ log.warn(`Cannot apply update. A previous update ${status}ed. ${refresh}`);
135
+ if (options.reload) {
136
+ window.location.reload();
137
+ }
138
+ }
139
+ }
140
+ };
@@ -0,0 +1,103 @@
1
+ /* eslint-disable global-require, consistent-return */
2
+
3
+ (function hotClientEntry() {
4
+ // eslint-disable-next-line no-underscore-dangle
5
+ if (window.__webpackHotClient__) {
6
+ return;
7
+ }
8
+
9
+ // eslint-disable-next-line no-underscore-dangle
10
+ window.__webpackHotClient__ = {};
11
+
12
+ // this is piped in at runtime build via DefinePlugin in /lib/plugins.js
13
+ // eslint-disable-next-line no-unused-vars, no-undef
14
+ const options = __hotClientOptions__;
15
+
16
+ const log = require('./log'); // eslint-disable-line import/order
17
+
18
+ log.level = options.logLevel;
19
+
20
+ const update = require('./hot');
21
+ const socket = require('./socket');
22
+
23
+ if (!options) {
24
+ throw new Error(
25
+ 'Something went awry and __hotClientOptions__ is undefined. Possible bad build. HMR cannot be enabled.'
26
+ );
27
+ }
28
+
29
+ let currentHash;
30
+ let initial = true;
31
+ let isUnloading;
32
+
33
+ window.addEventListener('beforeunload', () => {
34
+ isUnloading = true;
35
+ });
36
+
37
+ function reload() {
38
+ if (isUnloading) {
39
+ return;
40
+ }
41
+
42
+ if (options.hmr) {
43
+ log.info('App Updated, Reloading Modules');
44
+ update(currentHash, options);
45
+ } else if (options.reload) {
46
+ log.info('Refreshing Page');
47
+ window.location.reload();
48
+ } else {
49
+ log.warn('Please refresh the page manually.');
50
+ log.info('The `hot` and `reload` options are set to false.');
51
+ }
52
+ }
53
+
54
+ socket(options, {
55
+ compile({ compilerName }) {
56
+ log.info(`webpack: Compiling (${compilerName})`);
57
+ },
58
+
59
+ errors({ errors }) {
60
+ log.error('webpack: Encountered errors while compiling. Reload prevented.');
61
+
62
+ for (let i = 0; i < errors.length; i++) {
63
+ log.error(errors[i]);
64
+ }
65
+ },
66
+
67
+ hash({ hash }) {
68
+ currentHash = hash;
69
+ },
70
+
71
+ invalid({ fileName }) {
72
+ log.info(`App updated. Recompiling ${fileName}`);
73
+ },
74
+
75
+ ok() {
76
+ if (initial) {
77
+ initial = false;
78
+ return initial;
79
+ }
80
+
81
+ reload();
82
+ },
83
+
84
+ 'window-reload': () => {
85
+ window.location.reload();
86
+ },
87
+
88
+ warnings({ warnings }) {
89
+ log.warn('Warnings while compiling.');
90
+
91
+ for (let i = 0; i < warnings.length; i++) {
92
+ log.warn(warnings[i]);
93
+ }
94
+
95
+ if (initial) {
96
+ initial = false;
97
+ return initial;
98
+ }
99
+
100
+ reload();
101
+ }
102
+ });
103
+ })();
@@ -0,0 +1,44 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
2
+ const loglevel = require('loglevelnext/dist/loglevelnext');
3
+
4
+ const { MethodFactory } = loglevel.factories;
5
+ const css = {
6
+ prefix:
7
+ 'color: #999; padding: 0 0 0 20px; line-height: 16px; background: url(https://webpack.js.org/6bc5d8cf78d442a984e70195db059b69.svg) no-repeat; background-size: 16px 16px; background-position: 0 -2px;',
8
+ reset: 'color: #444'
9
+ };
10
+ const log = loglevel.getLogger({ name: 'hot', id: 'hot-middleware/client' });
11
+
12
+ function IconFactory(logger) {
13
+ MethodFactory.call(this, logger);
14
+ }
15
+
16
+ IconFactory.prototype = Object.create(MethodFactory.prototype);
17
+ IconFactory.prototype.constructor = IconFactory;
18
+
19
+ IconFactory.prototype.make = function make(methodName) {
20
+ const og = MethodFactory.prototype.make.call(this, methodName);
21
+
22
+ return function _(...params) {
23
+ const args = [].concat(params);
24
+ const prefix = '%c「hot」 %c';
25
+ const [first] = args;
26
+
27
+ if (typeof first === 'string') {
28
+ args[0] = prefix + first;
29
+ } else {
30
+ args.unshift(prefix);
31
+ }
32
+
33
+ args.splice(1, 0, css.prefix, css.reset);
34
+ og(...args);
35
+ };
36
+ };
37
+
38
+ log.factory = new IconFactory(log, {});
39
+
40
+ log.group = console.group; // eslint-disable-line no-console
41
+ log.groupCollapsed = console.groupCollapsed; // eslint-disable-line no-console
42
+ log.groupEnd = console.groupEnd; // eslint-disable-line no-console
43
+
44
+ module.exports = log;
@@ -0,0 +1,63 @@
1
+ const url = require('url');
2
+
3
+ const log = require('./log');
4
+
5
+ const maxRetries = 10;
6
+ let retry = maxRetries;
7
+
8
+ module.exports = function connect(options, handler) {
9
+ const { host } = options.webSocket;
10
+ const socketUrl = url.format({
11
+ protocol: options.https ? 'wss' : 'ws',
12
+ hostname: host === '*' ? window.location.hostname : host,
13
+ port: options.webSocket.port,
14
+ slashes: true
15
+ });
16
+
17
+ let open = false;
18
+ let socket = new WebSocket(socketUrl);
19
+
20
+ socket.addEventListener('open', () => {
21
+ open = true;
22
+ retry = maxRetries;
23
+ log.info('WebSocket connected');
24
+ });
25
+
26
+ socket.addEventListener('close', () => {
27
+ log.warn('WebSocket closed');
28
+
29
+ open = false;
30
+ socket = null;
31
+
32
+ // exponentation operator ** isn't supported by IE at all
33
+ const timeout =
34
+ // eslint-disable-next-line no-restricted-properties
35
+ 1000 * Math.pow(maxRetries - retry, 2) + Math.random() * 100;
36
+
37
+ if (open || retry <= 0) {
38
+ log.warn(`WebSocket: ending reconnect after ${maxRetries} attempts`);
39
+ return;
40
+ }
41
+
42
+ log.info(`WebSocket: attempting reconnect in ${parseInt(timeout / 1000, 10)}s`);
43
+
44
+ setTimeout(() => {
45
+ retry -= 1;
46
+
47
+ connect(
48
+ options,
49
+ handler
50
+ );
51
+ }, timeout);
52
+ });
53
+
54
+ socket.addEventListener('message', (event) => {
55
+ log.debug('WebSocket: message:', event.data);
56
+
57
+ const message = JSON.parse(event.data);
58
+
59
+ if (handler[message.type]) {
60
+ handler[message.type](message.data);
61
+ }
62
+ });
63
+ };
package/client/index.js CHANGED
@@ -19,19 +19,14 @@ export * from './actions'
19
19
  export * from './app/pages/page-view'
20
20
 
21
21
  // graphql-client
22
- export * from './graphql-client'
22
+ export * from '@operato/graphql'
23
23
 
24
24
  // indexdb-store
25
25
  export * from './indexdb'
26
26
 
27
- // mixins
28
- export * from './mixins'
29
-
30
27
  // elements
31
28
  export * from './elements'
32
29
 
33
30
  // Redux assumes `process.env.NODE_ENV` exists in the ES module build.
34
31
  // https://github.com/reactjs/redux/issues/2907
35
32
  window.process = { env: { NODE_ENV: 'production' } }
36
-
37
- export * from './gql-context'
@@ -3,8 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ // @prettier-ignore
6
7
  process.env.NODE_ENV = 'development';
7
8
  process.setMaxListeners(0);
9
+ /** Never move following lines */
8
10
  const subscriptions_transport_ws_1 = require("subscriptions-transport-ws");
9
11
  const env_1 = require("@things-factory/env");
10
12
  const routers_1 = require("./routers");
@@ -23,7 +25,7 @@ const koa2_connect_history_api_fallback_1 = require("koa2-connect-history-api-fa
23
25
  const koa_ip_1 = __importDefault(require("koa-ip"));
24
26
  const koa_bodyparser_1 = __importDefault(require("koa-bodyparser"));
25
27
  const koa_static_1 = __importDefault(require("koa-static"));
26
- const koa_webpack_1 = __importDefault(require("koa-webpack"));
28
+ const koa_webpack_1 = __importDefault(require("@hatiolab/koa-webpack"));
27
29
  const schema_1 = require("./schema");
28
30
  const debug = require('debug')('things-factory:shell:server-dev');
29
31
  const args = require('args');
@@ -152,7 +154,7 @@ const bootstrap = async () => {
152
154
  }
153
155
  });
154
156
  // only for development mode. triggered after webpack compilation is done.
155
- compiler.plugin('done', stats => {
157
+ compiler.hooks.done.tap({ name: 'server-dev' }, stats => {
156
158
  process.emit('client-rebuilt', app, compiler.outputFileSystem);
157
159
  });
158
160
  app.use((0, koa_bodyparser_1.default)(bodyParserOption));
@@ -1 +1 @@
1
- {"version":3,"file":"server-dev.js","sourceRoot":"","sources":["../server/server-dev.ts"],"names":[],"mappings":";;;;;AAAA,OAAO,CAAC,GAAG,CAAC,QAAQ,GAAG,aAAa,CAAA;AACpC,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAA;AAE1B,2EAAkF;AAClF,6CAAgF;AAChF,uCAA4G;AAC5G,qCAA4C;AAE5C,yDAAgD;AAChD,2DAAmF;AACnF,iEAA2D;AAC3D,8CAAqB;AACrB,4CAAmB;AACnB,8DAAiC;AACjC,qDAA4B;AAC5B,+BAAmC;AACnC,sDAA6D;AAC7D,mDAAiD;AACjD,yFAAsE;AACtE,oDAAuB;AACvB,oEAA0C;AAC1C,4DAAkC;AAClC,8DAAoC;AACpC,qCAAiC;AAEjC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,CAAA;AAEjE,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAE5B,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,2CAA2C,EAAE,YAAM,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAA;AAC1F,IAAI,CAAC,MAAM,CACT,SAAS,EACT;kGACgG,EAChG,YAAM,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,CAC/B,CAAA;AAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;AAEtC,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAC5B,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAClC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,6BAAmB,CAAC,MAAM,EAAE,CAAC;SACjC,GAAG,CAAC,6BAAmB,CAAC,cAAc,EAAE,CAAC,CAAA;IAE5C,mEAAmE;IACnE,GAAG,CAAC,GAAG,CAAC,IAAA,sDAAkB,EAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAC,CAAA;IAE9C,GAAG,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;IAEnB,GAAG,CAAC,GAAG,CACL,IAAA,oBAAS,EAAC,QAAQ,CAAC,UAAU,EAAE;QAC7B,KAAK,EAAE,KAAK;KACb,CAAC,CACH,CAAA;IAED,UAAU,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE;QACrC,YAAM,CAAC,IAAI,CAAC,qCAAqC,IAAI,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAA;QAC7E,YAAM,CAAC,IAAI,CAAC,0CAA0C,IAAI,GAAG,gBAAgB,EAAE,CAAC,CAAA;QAEhF,OAAO,CAAC,IAAI,CAAC,wBAA+B,EAAE,EAAE,GAAG,EAAE,MAAM,EAAN,YAAM,EAAE,WAAW,EAAE,UAAU,EAAS,CAAC,CAAA;IAChG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA;AAED,SAAS,EAAE,CAAA"}
@@ -0,0 +1,24 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ const webpackHotClient = require('@hatiolab/webpack-hot-client');
12
+ module.exports = {
13
+ getClient(compiler, options) {
14
+ if (!options.hotClient) {
15
+ return Promise.resolve(null);
16
+ }
17
+ return new Promise(resolve => {
18
+ const client = webpackHotClient(compiler, options.hotClient);
19
+ const { server } = client;
20
+ server.on('listening', () => resolve(client));
21
+ });
22
+ }
23
+ };
24
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../server/webpack/koa-webpack/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,MAAM,gBAAgB,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAA;AAEhE,MAAM,CAAC,OAAO,GAAG;IACf,SAAS,CAAC,QAAQ,EAAE,OAAO;QACzB,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE;YACtB,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;SAC7B;QAED,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;YAC3B,MAAM,MAAM,GAAG,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,SAAS,CAAC,CAAA;YAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;YAEzB,MAAM,CAAC,EAAE,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAA;QAC/C,CAAC,CAAC,CAAA;IACJ,CAAC;CACF,CAAA"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ Copyright © 2016 Andrew Powell
5
+
6
+ This Source Code Form is subject to the terms of the Mozilla Public
7
+ License, v. 2.0. If a copy of the MPL was not distributed with this
8
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
9
+
10
+ The above copyright notice and this permission notice shall be
11
+ included in all copies or substantial portions of this Source Code Form.
12
+ */
13
+ const { join } = require('path');
14
+ const root = require('app-root-path');
15
+ const chalk = require('chalk');
16
+ const webpack = require('webpack');
17
+ const webpackDevMiddleware = require('webpack-dev-middleware');
18
+ const { getClient } = require('./client');
19
+ const { getMiddleware } = require('./middleware');
20
+ const { validate } = require('./validate');
21
+ const defaults = { devMiddleware: {}, hotClient: {} };
22
+ exports.default = async (opts) => {
23
+ const valid = validate(opts);
24
+ if (valid.error) {
25
+ const { error } = console;
26
+ error(chalk.red('⬢ koa-webpack:'), 'An option was passed to koa-webpack that is not valid');
27
+ throw valid.error;
28
+ }
29
+ const options = Object.assign({}, defaults, opts);
30
+ let { compiler, config } = options;
31
+ if (!compiler) {
32
+ if (!config) {
33
+ // eslint-disable-next-line import/no-dynamic-require, global-require
34
+ config = require(options.configPath || join(root.path, 'webpack.config.js'));
35
+ }
36
+ compiler = webpack(config);
37
+ }
38
+ if (!options.devMiddleware.publicPath) {
39
+ const { publicPath } = compiler.options.output;
40
+ if (!publicPath) {
41
+ throw new Error("koa-webpack: publicPath must be set on `dev` options, or in a compiler's `output` configuration.");
42
+ }
43
+ options.devMiddleware.publicPath = publicPath;
44
+ }
45
+ const hotClient = await getClient(compiler, options);
46
+ const devMiddleware = webpackDevMiddleware(compiler, options.devMiddleware);
47
+ const middleware = getMiddleware(compiler, devMiddleware);
48
+ const close = callback => {
49
+ const next = hotClient ? () => hotClient.close(callback) : callback;
50
+ devMiddleware.close(next);
51
+ };
52
+ return Object.assign(middleware, {
53
+ hotClient,
54
+ devMiddleware,
55
+ close
56
+ });
57
+ };
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/webpack/koa-webpack/index.ts"],"names":[],"mappings":";;AAAA;;;;;;;;;EASE;AACF,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;AAEhC,MAAM,IAAI,GAAG,OAAO,CAAC,eAAe,CAAC,CAAA;AACrC,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAC9B,MAAM,OAAO,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;AAClC,MAAM,oBAAoB,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAA;AAE9D,MAAM,EAAE,SAAS,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC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AAG,MAAM,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IACpD,MAAM,aAAa,GAAG,oBAAoB,CAAC,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;IAC3E,MAAM,UAAU,GAAG,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAA;IACzD,MAAM,KAAK,GAAG,QAAQ,CAAC,EAAE;QACvB,MAAM,IAAI,GAAG,SAAS,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAA;QACnE,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAC3B,CAAC,CAAA;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE;QAC/B,SAAS;QACT,aAAa;QACb,KAAK;KACN,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -0,0 +1,42 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ module.exports = {
12
+ getMiddleware(compiler, devMiddleware) {
13
+ return (context, next) => {
14
+ // wait for webpack-dev-middleware to signal that the build is ready
15
+ const ready = new Promise((resolve, reject) => {
16
+ for (const comp of [].concat(compiler.compilers || compiler)) {
17
+ comp.hooks.failed.tap('KoaWebpack', error => {
18
+ reject(error);
19
+ });
20
+ }
21
+ devMiddleware.waitUntilValid(() => {
22
+ resolve(true);
23
+ });
24
+ });
25
+ // tell webpack-dev-middleware to handle the request
26
+ const init = new Promise(resolve => {
27
+ devMiddleware(context.req, {
28
+ end: content => {
29
+ // eslint-disable-next-line no-param-reassign
30
+ context.body = content;
31
+ resolve(null);
32
+ },
33
+ getHeader: context.get.bind(context),
34
+ setHeader: context.set.bind(context),
35
+ locals: context.state
36
+ }, () => resolve(next()));
37
+ });
38
+ return Promise.all([ready, init]);
39
+ };
40
+ }
41
+ };
42
+ //# sourceMappingURL=middleware.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"middleware.js","sourceRoot":"","sources":["../../../server/webpack/koa-webpack/middleware.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,MAAM,CAAC,OAAO,GAAG;IACf,aAAa,CAAC,QAAQ,EAAE,aAAa;QACnC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE;YACvB,oEAAoE;YACpE,MAAM,KAAK,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;gBAC5C,KAAK,MAAM,IAAI,IAAI,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,EAAE;oBAC5D,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,CAAC,EAAE;wBAC1C,MAAM,CAAC,KAAK,CAAC,CAAA;oBACf,CAAC,CAAC,CAAA;iBACH;gBAED,aAAa,CAAC,cAAc,CAAC,GAAG,EAAE;oBAChC,OAAO,CAAC,IAAI,CAAC,CAAA;gBACf,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;YACF,oDAAoD;YACpD,MAAM,IAAI,GAAG,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE;gBACjC,aAAa,CACX,OAAO,CAAC,GAAG,EACX;oBACE,GAAG,EAAE,OAAO,CAAC,EAAE;wBACb,6CAA6C;wBAC7C,OAAO,CAAC,IAAI,GAAG,OAAO,CAAA;wBACtB,OAAO,CAAC,IAAI,CAAC,CAAA;oBACf,CAAC;oBACD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;oBACpC,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC;oBACpC,MAAM,EAAE,OAAO,CAAC,KAAK;iBACtB,EACD,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CACtB,CAAA;YACH,CAAC,CAAC,CAAA;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;QACnC,CAAC,CAAA;IACH,CAAC;CACF,CAAA"}
@@ -0,0 +1,26 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ const Joi = require('joi');
12
+ module.exports = {
13
+ validate(options) {
14
+ const keys = {
15
+ compiler: [Joi.object().allow(null)],
16
+ config: [Joi.object().allow(null)],
17
+ configPath: [Joi.string().allow(null)],
18
+ devMiddleware: [Joi.object()],
19
+ hotClient: [Joi.boolean(), Joi.object().allow(null)]
20
+ };
21
+ const schema = Joi.object().keys(keys);
22
+ const results = schema.validate(options);
23
+ return results;
24
+ }
25
+ };
26
+ //# sourceMappingURL=validate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.js","sourceRoot":"","sources":["../../../server/webpack/koa-webpack/validate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;EASE;AACF,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;AAE3B,MAAM,CAAC,OAAO,GAAG;IACf,QAAQ,CAAC,OAAO;QACd,MAAM,IAAI,GAAG;YACX,QAAQ,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,MAAM,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YAClC,UAAU,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACtC,aAAa,EAAE,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;YAC7B,SAAS,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SACrD,CAAC;QACF,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;QAEzC,OAAO,OAAO,CAAC;IACjB,CAAC;CACF,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@things-factory/shell",
3
- "version": "4.0.25",
3
+ "version": "4.0.30",
4
4
  "description": "Core module for framework",
5
5
  "bin": {
6
6
  "things-factory": "bin/things-factory",
@@ -35,7 +35,8 @@
35
35
  "@graphql-tools/merge": "^7.0.0",
36
36
  "@graphql-tools/schema": "^8.2.0",
37
37
  "@graphql-tools/utils": "^8.3.0",
38
- "@hatiolab/things-scene": "^2.7.30",
38
+ "@hatiolab/koa-webpack": "^6.0.0",
39
+ "@hatiolab/things-scene": "^2.7.31",
39
40
  "@koa/cors": "^3.1.0",
40
41
  "@material/mwc-button": "^0.25.3",
41
42
  "@material/mwc-fab": "^0.25.3",
@@ -43,16 +44,19 @@
43
44
  "@material/mwc-icon-button": "^0.25.3",
44
45
  "@material/mwc-slider": "^0.25.3",
45
46
  "@material/mwc-textfield": "^0.25.3",
46
- "@operato/board": "^0.2.52",
47
- "@things-factory/ejs-remote": "^4.0.25",
48
- "@things-factory/env": "^4.0.25",
49
- "@things-factory/styles": "^4.0.25",
50
- "@things-factory/utils": "^4.0.25",
47
+ "@operato/board": "^0.3.7",
48
+ "@operato/graphql": "^0.3.7",
49
+ "@operato/utils": "^0.3.7",
50
+ "@things-factory/ejs-remote": "^4.0.30",
51
+ "@things-factory/env": "^4.0.30",
52
+ "@things-factory/styles": "^4.0.30",
53
+ "@things-factory/utils": "^4.0.30",
51
54
  "@webcomponents/webcomponentsjs": "^2.6.0",
55
+ "@webpack-contrib/schema-utils": "^1.0.0-beta.0",
52
56
  "apollo-server-core": "^3.5.0",
53
57
  "apollo-server-koa": "^3.5.0",
54
58
  "apollo-server-types": "^3.4.0",
55
- "apollo-upload-client": "^16.0.0",
59
+ "apollo-upload-client": "^17.0.0",
56
60
  "args": "^5.0.0",
57
61
  "broadcastchannel-polyfill": "^1.0.1",
58
62
  "chalk": "^4.1.0",
@@ -75,6 +79,7 @@
75
79
  "imports-loader": "^3.0.0",
76
80
  "inquirer": "^8.2.0",
77
81
  "ioredis": "^4.28.0",
82
+ "json-stringify-safe": "^5.0.1",
78
83
  "json5": "^2.2.0",
79
84
  "koa": "^2.13.4",
80
85
  "koa-bodyparser": "^4.2.0",
@@ -83,7 +88,6 @@
83
88
  "koa-send": "^5.0.0",
84
89
  "koa-static": "^5.0.0",
85
90
  "koa-unless": "^1.0.7",
86
- "koa-webpack": "^6.0.0",
87
91
  "koa2-connect-history-api-fallback": "^0.1.2",
88
92
  "lit": "^2.0.2",
89
93
  "loader-utils": "^2.0.0",
@@ -120,5 +124,5 @@
120
124
  "resolutions": {
121
125
  "core-js": "^3.16.0"
122
126
  },
123
- "gitHead": "9c44141d651dab7b4a9c0f0b6fecb8d6937d116f"
127
+ "gitHead": "4ab590326e3fc60d113fb438e90eefee708f1f19"
124
128
  }
@@ -1,5 +1,7 @@
1
+ // @prettier-ignore
1
2
  process.env.NODE_ENV = 'development'
2
3
  process.setMaxListeners(0)
4
+ /** Never move following lines */
3
5
 
4
6
  import { ConnectionContext, SubscriptionServer } from 'subscriptions-transport-ws'
5
7
  import { config, loader, logger, orderedModuleNames } from '@things-factory/env'
@@ -20,7 +22,7 @@ import { historyApiFallback } from 'koa2-connect-history-api-fallback'
20
22
  import ip from 'koa-ip'
21
23
  import koaBodyParser from 'koa-bodyparser'
22
24
  import koaStatic from 'koa-static'
23
- import koaWebpack from 'koa-webpack'
25
+ import koaWebpack from '@hatiolab/koa-webpack'
24
26
  import { schema } from './schema'
25
27
 
26
28
  const debug = require('debug')('things-factory:shell:server-dev')
@@ -192,7 +194,7 @@ const bootstrap = async () => {
192
194
  })
193
195
 
194
196
  // only for development mode. triggered after webpack compilation is done.
195
- compiler.plugin('done', stats => {
197
+ compiler.hooks.done.tap({ name: 'server-dev' }, stats => {
196
198
  process.emit('client-rebuilt' as any, app, compiler.outputFileSystem)
197
199
  })
198
200
 
@@ -0,0 +1,26 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ const webpackHotClient = require('@hatiolab/webpack-hot-client')
12
+
13
+ module.exports = {
14
+ getClient(compiler, options) {
15
+ if (!options.hotClient) {
16
+ return Promise.resolve(null)
17
+ }
18
+
19
+ return new Promise(resolve => {
20
+ const client = webpackHotClient(compiler, options.hotClient)
21
+ const { server } = client
22
+
23
+ server.on('listening', () => resolve(client))
24
+ })
25
+ }
26
+ }
@@ -0,0 +1,71 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ const { join } = require('path')
12
+
13
+ const root = require('app-root-path')
14
+ const chalk = require('chalk')
15
+ const webpack = require('webpack')
16
+ const webpackDevMiddleware = require('webpack-dev-middleware')
17
+
18
+ const { getClient } = require('./client')
19
+ const { getMiddleware } = require('./middleware')
20
+ const { validate } = require('./validate')
21
+
22
+ const defaults = { devMiddleware: {}, hotClient: {} }
23
+
24
+ export default async opts => {
25
+ const valid = validate(opts)
26
+
27
+ if (valid.error) {
28
+ const { error } = console
29
+ error(chalk.red('⬢ koa-webpack:'), 'An option was passed to koa-webpack that is not valid')
30
+ throw valid.error
31
+ }
32
+
33
+ const options = Object.assign({}, defaults, opts)
34
+
35
+ let { compiler, config } = options
36
+
37
+ if (!compiler) {
38
+ if (!config) {
39
+ // eslint-disable-next-line import/no-dynamic-require, global-require
40
+ config = require(options.configPath || join(root.path, 'webpack.config.js'))
41
+ }
42
+
43
+ compiler = webpack(config)
44
+ }
45
+
46
+ if (!options.devMiddleware.publicPath) {
47
+ const { publicPath } = compiler.options.output
48
+
49
+ if (!publicPath) {
50
+ throw new Error(
51
+ "koa-webpack: publicPath must be set on `dev` options, or in a compiler's `output` configuration."
52
+ )
53
+ }
54
+
55
+ options.devMiddleware.publicPath = publicPath
56
+ }
57
+
58
+ const hotClient = await getClient(compiler, options)
59
+ const devMiddleware = webpackDevMiddleware(compiler, options.devMiddleware)
60
+ const middleware = getMiddleware(compiler, devMiddleware)
61
+ const close = callback => {
62
+ const next = hotClient ? () => hotClient.close(callback) : callback
63
+ devMiddleware.close(next)
64
+ }
65
+
66
+ return Object.assign(middleware, {
67
+ hotClient,
68
+ devMiddleware,
69
+ close
70
+ })
71
+ }
@@ -0,0 +1,47 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ module.exports = {
12
+ getMiddleware(compiler, devMiddleware) {
13
+ return (context, next) => {
14
+ // wait for webpack-dev-middleware to signal that the build is ready
15
+ const ready = new Promise((resolve, reject) => {
16
+ for (const comp of [].concat(compiler.compilers || compiler)) {
17
+ comp.hooks.failed.tap('KoaWebpack', error => {
18
+ reject(error)
19
+ })
20
+ }
21
+
22
+ devMiddleware.waitUntilValid(() => {
23
+ resolve(true)
24
+ })
25
+ })
26
+ // tell webpack-dev-middleware to handle the request
27
+ const init = new Promise(resolve => {
28
+ devMiddleware(
29
+ context.req,
30
+ {
31
+ end: content => {
32
+ // eslint-disable-next-line no-param-reassign
33
+ context.body = content
34
+ resolve(null)
35
+ },
36
+ getHeader: context.get.bind(context),
37
+ setHeader: context.set.bind(context),
38
+ locals: context.state
39
+ },
40
+ () => resolve(next())
41
+ )
42
+ })
43
+
44
+ return Promise.all([ready, init])
45
+ }
46
+ }
47
+ }
@@ -0,0 +1,27 @@
1
+ /*
2
+ Copyright © 2016 Andrew Powell
3
+
4
+ This Source Code Form is subject to the terms of the Mozilla Public
5
+ License, v. 2.0. If a copy of the MPL was not distributed with this
6
+ file, You can obtain one at http://mozilla.org/MPL/2.0/.
7
+
8
+ The above copyright notice and this permission notice shall be
9
+ included in all copies or substantial portions of this Source Code Form.
10
+ */
11
+ const Joi = require('joi');
12
+
13
+ module.exports = {
14
+ validate(options) {
15
+ const keys = {
16
+ compiler: [Joi.object().allow(null)],
17
+ config: [Joi.object().allow(null)],
18
+ configPath: [Joi.string().allow(null)],
19
+ devMiddleware: [Joi.object()],
20
+ hotClient: [Joi.boolean(), Joi.object().allow(null)]
21
+ };
22
+ const schema = Joi.object().keys(keys);
23
+ const results = schema.validate(options);
24
+
25
+ return results;
26
+ }
27
+ };
@@ -1,15 +0,0 @@
1
- export const CONTEXT_KEY = '__context__'
2
-
3
- export function gqlContext() {
4
- const search = new URLSearchParams(location.search)
5
- return JSON.parse(search.get(CONTEXT_KEY)) || ''
6
- }
7
-
8
- export function buildGqlContext(context) {
9
- if (!context) throw new Error('context is not passed')
10
- if (typeof context !== 'string') {
11
- context = JSON.stringify(context)
12
- }
13
-
14
- return new URLSearchParams({ [CONTEXT_KEY]: context }).toString()
15
- }
@@ -1,161 +0,0 @@
1
- import { ApolloClient, ApolloLink, HttpLink, InMemoryCache, from } from '@apollo/client/core'
2
-
3
- import { SubscriptionClient } from 'subscriptions-transport-ws'
4
- import { createUploadLink } from 'apollo-upload-client'
5
- import { onError } from '@apollo/client/link/error'
6
-
7
- // import { persistCache } from 'apollo-cache-persist'
8
-
9
- export const GRAPHQL_URI = '/graphql'
10
-
11
- const defaultOptions = {
12
- watchQuery: {
13
- fetchPolicy: 'no-cache',
14
- errorPolicy: 'ignore'
15
- },
16
- query: {
17
- fetchPolicy: 'no-cache', //'network-only'
18
- errorPolicy: 'all'
19
- },
20
- mutate: {
21
- errorPolicy: 'all'
22
- }
23
- }
24
-
25
- const ERROR_HANDLER = ({ operation, graphQLErrors, networkError }) => {
26
- if (graphQLErrors) {
27
- document.dispatchEvent(
28
- new CustomEvent('notify', {
29
- detail: {
30
- level: 'error',
31
- message: graphQLErrors[0].message,
32
- ex: graphQLErrors
33
- }
34
- })
35
- )
36
- }
37
-
38
- if (networkError) {
39
- switch (networkError.statusCode) {
40
- case 401:
41
- /* 401 에러가 리턴되면, 인증이 필요하다는 메시지를 dispatch 한다. 이 auth 모듈 등에서 이 메시지를 받아서 signin 프로세스를 진행할 수 있다. */
42
- document.dispatchEvent(new CustomEvent('auth-required'))
43
- break
44
- case 403:
45
- /* 403 에러가 리턴되면, 도메인 정보가 필요하다는 메시지를 dispatch 한다. 이 auth 모듈 등에서 이 메시지를 받아서 domain-register 프로세스 등을 진행할 수 있다. */
46
- document.dispatchEvent(new CustomEvent('domain-required'))
47
- break
48
- default:
49
- var { name, response, statusCode, bodyText, message } = networkError
50
- if (name == 'ServerParseError') {
51
- message = `[ ${statusCode || ''} : ${response.statusText} ] ${bodyText}`
52
- } else {
53
- message = `[ ${statusCode || ''} : ${response.statusText} ] ${message}`
54
- }
55
-
56
- document.dispatchEvent(
57
- new CustomEvent('notify', {
58
- detail: {
59
- level: 'error',
60
- message,
61
- ex: networkError
62
- }
63
- })
64
- )
65
- }
66
- }
67
- }
68
-
69
- const cache = new InMemoryCache({
70
- addTypename: false
71
- // dataIdFromObject: object => object.key
72
- })
73
-
74
- const httpOptions = {
75
- GRAPHQL_URI,
76
- credentials: 'include'
77
- }
78
-
79
- const httpLink = ApolloLink.split(
80
- operation => operation.getContext().hasUpload,
81
- createUploadLink(httpOptions),
82
- new HttpLink(httpOptions)
83
- )
84
-
85
- // const initPersistCache = async () => {
86
- // persistCache({
87
- // cache,
88
- // storage: window.localStorage
89
- // })
90
- // }
91
-
92
- // initPersistCache()
93
-
94
- export const client = new ApolloClient({
95
- defaultOptions,
96
- cache,
97
- link: from([onError(ERROR_HANDLER), httpLink])
98
- })
99
-
100
- /* SubscriptionClient */
101
- var subscriptionClient
102
-
103
- const getSubscriptionClient = async () => {
104
- if (!subscriptionClient) {
105
- subscriptionClient = new Promise((resolve, reject) => {
106
- var client = new SubscriptionClient(location.origin.replace(/^http/, 'ws') + '/subscriptions', {
107
- reconnect: true,
108
- connectionParams: {
109
- headers: {
110
- /*
111
- 특정 도메인의 데이타만 받고자 하는 경우에, referer 정보를 제공해서 서버에서 서브도메인 정보를 취득하도록 한다.
112
- referer: location.href
113
- 또는, 이미 서브도메인 정보를 알고 있다면,
114
- 'x-things-factory-domain': '[subdomain]'
115
- 을 보낼 수 있다.
116
- 관련 정보를 보내지 않는다면, 사용자가 권한을 가진 모든 도메인의 데이타를 수신하게 된다.
117
- */
118
- referer: location.href
119
- }
120
- }
121
- })
122
-
123
- client.onError(err => {
124
- //readyState === 3 인 경우 url을 잘 못 입력했거나, 서버에 문제가 있는 경우이므로 reconnect = false로 변경한다.
125
- if (client.status === 3) {
126
- client.reconnect = false
127
- }
128
- reject(err)
129
- })
130
-
131
- client.onConnected(() => {
132
- resolve(client)
133
- })
134
- })
135
- }
136
-
137
- return await subscriptionClient
138
- }
139
-
140
- var subscriptions = []
141
-
142
- export const subscribe = async (request, subscribe) => {
143
- var client = await getSubscriptionClient()
144
- var { unsubscribe } = client.request(request).subscribe(subscribe)
145
-
146
- subscriptions.push(unsubscribe)
147
-
148
- return {
149
- unsubscribe() {
150
- subscriptions.splice(subscriptions.indexOf(unsubscribe), 1)
151
- unsubscribe()
152
-
153
- if (subscriptions.length == 0) {
154
- client.unsubscribeAll()
155
- client.close(true)
156
-
157
- subscriptionClient = null
158
- }
159
- }
160
- }
161
- }
@@ -1 +0,0 @@
1
- export { default as InfiniteScrollable } from './infinite-scrollable'
@@ -1,32 +0,0 @@
1
- import debounce from 'lodash/debounce'
2
- export default superclass => {
3
- return class A extends superclass {
4
- constructor() {
5
- super()
6
-
7
- this._infiniteScrollOptions = {
8
- threshold: 20,
9
- limit: 30,
10
- totalProp: '_total',
11
- pageProp: '_page'
12
- }
13
-
14
- this.onScroll = debounce(e => {
15
- var el = this.scrollTargetEl
16
- var { threshold = 0, limit, totalProp, pageProp } = this._infiniteScrollOptions
17
-
18
- if (this[pageProp] < this[totalProp] / limit && el.scrollHeight - el.clientHeight <= el.scrollTop + threshold) {
19
- this.scrollAction()
20
- }
21
- }, 300)
22
- }
23
-
24
- get scrollTargetEl() {
25
- console.warn('scroll target element is not defined.')
26
- }
27
-
28
- async scrollAction() {
29
- console.warn('scroll action not implemented.')
30
- }
31
- }
32
- }