@things-factory/board-service 6.2.86 → 7.0.0-alpha.1
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/dist-server/controllers/headless-pool-for-label.js +4 -4
- package/dist-server/controllers/headless-pool-for-label.js.map +1 -1
- package/dist-server/service/board/board-subscription.js +4 -4
- package/dist-server/service/board/board-subscription.js.map +1 -1
- package/dist-server/service/play-group/play-group-subscription.js +4 -4
- package/dist-server/service/play-group/play-group-subscription.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/server/controllers/headless-pool-for-label.ts +2 -2
- package/server/service/board/board-subscription.ts +7 -7
- package/server/service/play-group/play-group-subscription.ts +7 -7
|
@@ -42,10 +42,10 @@ function getHeadlessPool() {
|
|
|
42
42
|
});
|
|
43
43
|
setTimeout(async () => {
|
|
44
44
|
var _a, e_1, _b, _c;
|
|
45
|
-
const
|
|
45
|
+
const eventSource = shell_1.pubsub.subscribe('notify-font-changed');
|
|
46
46
|
try {
|
|
47
|
-
for (var _d = true,
|
|
48
|
-
_c =
|
|
47
|
+
for (var _d = true, eventSource_1 = tslib_1.__asyncValues(eventSource), eventSource_1_1; eventSource_1_1 = await eventSource_1.next(), _a = eventSource_1_1.done, !_a;) {
|
|
48
|
+
_c = eventSource_1_1.value;
|
|
49
49
|
_d = false;
|
|
50
50
|
try {
|
|
51
51
|
const data = _c;
|
|
@@ -59,7 +59,7 @@ function getHeadlessPool() {
|
|
|
59
59
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
60
60
|
finally {
|
|
61
61
|
try {
|
|
62
|
-
if (!_d && !_a && (_b =
|
|
62
|
+
if (!_d && !_a && (_b = eventSource_1.return)) await _b.call(eventSource_1);
|
|
63
63
|
}
|
|
64
64
|
finally { if (e_1) throw e_1.error; }
|
|
65
65
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headless-pool-for-label.js","sourceRoot":"","sources":["../../server/controllers/headless-pool-for-label.ts"],"names":[],"mappings":";;;;AAAA,kEAA2C;AAE3C,6CAAoD;AACpD,iDAA8C;AAE9C,mCAA+B;AAE/B,IAAI;IACF,IAAI,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA;CACrC;AAAC,OAAO,GAAG,EAAE;IACZ,YAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;CAClB;AAED,IAAI,YAAY,CAAA;AAEhB,SAAgB,eAAe;IAC7B,IAAI,CAAC,YAAY,EAAE;QACjB,YAAY,GAAG,WAAW,CAAC,UAAU,CACnC;YACE,MAAM;gBACJ,OAAO,CAAC,GAAG,CAAC,yCAAyC,CAAC,CAAA;gBACtD,OAAO,mBAAmB,EAAE,CAAA;YAC9B,CAAC;YACD,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;gBACxB,OAAO,OAAO,CAAC,IAAI,CAAC;oBAClB,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,IAAI,CAAC,CAAC;oBACtD,OAAO;wBACL,YAAY;yBACX,OAAO,EAAE;yBACT,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC;yBACf,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;iBACrB,CAAC,CAAA;YACJ,CAAC;YACD,OAAO,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;gBACvB,YAAY;gBACZ,OAAO,OAAO,CAAC,KAAK,EAAE,CAAA;YACxB,CAAC;SACF,EACD;YACE,GAAG,EAAE,CAAC;YACN,GAAG,EAAE,EAAE;YACP,YAAY,EAAE,IAAI;YAClB,oBAAoB,EAAE,KAAK;SAC5B,CACF,CAAA;QAED,UAAU,CAAC,KAAK,IAAI,EAAE;;YACpB,MAAM,
|
|
1
|
+
{"version":3,"file":"headless-pool-for-label.js","sourceRoot":"","sources":["../../server/controll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AO,EAAE,CAAA;IACpC,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,IAAA,aAAK,GAAE,CAAA;IAE9C,MAAM,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;IACvC,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,EAAC,GAAG,EAAC,EAAE;QAC7B,OAAO,CAAC,GAAG,CAAC,YAAY,GAAG,CAAC,IAAI,EAAE,KAAK,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,EAAE,CAAC,eAAe,EAAE,OAAO,CAAC,EAAE;QACjC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;IAC/C,CAAC,CAAC,CAAA;IAEF,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE;QAC3B,IAAI,OAAO,CAAC,GAAG,EAAE,KAAK,GAAG,EAAE;YACzB,OAAO,CAAC,QAAQ,CAAC;gBACf,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC;oBACvB,KAAK,EAAE,UAAU;oBACjB,UAAU;iBACX,CAAC;aACH,CAAC,CAAA;SACH;aAAM;YACL,OAAO,CAAC,QAAQ,EAAE,CAAA;SACnB;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC,CAAA;IAEvD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import * as genericPool from 'generic-pool'\n\nimport { config, logger } from '@things-factory/env'\nimport { pubsub } from '@things-factory/shell'\n\nimport { fonts } from './fonts'\n\ntry {\n var puppeteer = require('puppeteer')\n} catch (err) {\n logger.error(err)\n}\n\nvar headlessPool\n\nexport function getHeadlessPool() {\n if (!headlessPool) {\n headlessPool = genericPool.createPool(\n {\n create() {\n console.log('headless-pool-for-label about to create')\n return initializeScenePage()\n },\n validate({ browser, page }) {\n return Promise.race([\n new Promise(res => setTimeout(() => res(false), 1500)),\n browser\n //@ts-ignore\n .version()\n .then(_ => true)\n .catch(_ => false)\n ])\n },\n destroy({ browser, page }) {\n //@ts-ignore\n return browser.close()\n }\n },\n {\n min: 2,\n max: 10,\n testOnBorrow: true,\n acquireTimeoutMillis: 15000\n }\n )\n\n setTimeout(async () => {\n const eventSource = pubsub.subscribe('notify-font-changed')\n for await (const data of eventSource) {\n headlessPool.clear()\n }\n })\n }\n\n return headlessPool\n}\n\nconst CHROMIUM_PATH = config.get('CHROMIUM_PATH')\n\nasync function initializeChromium() {\n try {\n if (!puppeteer) {\n return\n }\n\n var launchSetting = {\n args: ['--hide-scrollbars', '--mute-audio', '--no-sandbox', '--use-gl=egl'],\n headless: 'new'\n }\n\n if (CHROMIUM_PATH) {\n launchSetting['executablePath'] = CHROMIUM_PATH\n }\n\n const browser = await puppeteer.launch(launchSetting)\n\n return browser\n } catch (err) {\n logger.error(err)\n }\n}\n\nasync function initializeScenePage() {\n /* get brand new browser for every request */\n const browser = await initializeChromium()\n\n if (!browser) {\n return\n }\n\n const protocol = 'http'\n const host = 'localhost'\n const path = '/internal-label-command-view'\n\n const port = process.env.PORT\n const url = `${protocol}://${host}:${port}${path}`\n\n const page = await browser.newPage()\n const [fontsToUse, fontStyles] = await fonts()\n\n await page.setRequestInterception(true)\n page.on('console', async msg => {\n console.log(`[browser ${msg.type()}] ${msg.text()}`)\n })\n\n page.on('requestfailed', request => {\n console.log('Request failed:', request.url())\n })\n\n page.on('request', request => {\n if (request.url() === url) {\n request.continue({\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json'\n },\n postData: JSON.stringify({\n fonts: fontsToUse,\n fontStyles\n })\n })\n } else {\n request.continue()\n }\n })\n\n await page.goto(url, { timeout: 0, waitUntil: 'load' })\n\n return { browser, page }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.BoardSubscription = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const
|
|
6
|
+
const graphql_yoga_1 = require("graphql-yoga");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const board_1 = require("./board");
|
|
9
9
|
let BoardSubscription = class BoardSubscription {
|
|
@@ -13,7 +13,7 @@ let BoardSubscription = class BoardSubscription {
|
|
|
13
13
|
};
|
|
14
14
|
tslib_1.__decorate([
|
|
15
15
|
(0, type_graphql_1.Subscription)({
|
|
16
|
-
subscribe: (
|
|
16
|
+
subscribe: ({ args, context, info }) => {
|
|
17
17
|
var _a;
|
|
18
18
|
const { domain, user } = context.state;
|
|
19
19
|
const { id } = args;
|
|
@@ -24,7 +24,7 @@ tslib_1.__decorate([
|
|
|
24
24
|
if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
|
|
25
25
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
|
26
26
|
}
|
|
27
|
-
return (0,
|
|
27
|
+
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('board'), (0, graphql_yoga_1.filter)((payload) => {
|
|
28
28
|
const { domainId, id: boardId } = payload.board;
|
|
29
29
|
if (domainId !== domain.id) {
|
|
30
30
|
return false;
|
|
@@ -33,7 +33,7 @@ tslib_1.__decorate([
|
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
return true;
|
|
36
|
-
})
|
|
36
|
+
}));
|
|
37
37
|
}
|
|
38
38
|
}),
|
|
39
39
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"board-subscription.js","sourceRoot":"","sources":["../../../server/service/board/board-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE
|
|
1
|
+
{"version":3,"file":"board-subscription.js","sourceRoot":"","sources":["../../../server/service/board/board-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,+CAA2C;AAC3C,iDAA8C;AAC9C,mCAA+B;AAGxB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAiC5B,KAAK,CAAS,OAAyB,EAAa,EAAU;QAC5D,OAAO,OAAO,CAAC,KAAK,CAAA;IACtB,CAAC;CACF,CAAA;AAnCC;IAAC,IAAA,2BAAY,EAAC;QACZ,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE;;YACrC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;YACtC,MAAM,EAAE,EAAE,EAAE,GAAG,IAAI,CAAA;YACnB,MAAM,SAAS,GAAG,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,SAAS,CAAA;YAEnC,IAAI,CAAC,MAAM,EAAE;gBACX,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;aACnC;YAED,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAA,IAAI,CAAC,OAAO,CAAC,gBAAgB,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE;gBAClG,MAAM,IAAI,KAAK,CAAC,UAAU,SAAS,6BAA6B,IAAI,CAAC,KAAK,IAAI,CAAC,CAAA;aAChF;YAED,OAAO,IAAA,mBAAI,EACT,cAAM,CAAC,SAAS,CAAC,OAAO,CAAC,EACzB,IAAA,qBAAM,EAAC,CAAC,OAAyB,EAAE,EAAE;gBACnC,MAAM,EAAE,QAAQ,EAAE,EAAE,EAAE,OAAO,EAAE,GAAG,OAAO,CAAC,KAAK,CAAA;gBAE/C,IAAI,QAAQ,KAAK,MAAM,CAAC,EAAE,EAAE;oBAC1B,OAAO,KAAK,CAAA;iBACb;gBAED,IAAI,EAAE,KAAK,OAAO,EAAE;oBAClB,OAAO,KAAK,CAAA;iBACb;gBAED,OAAO,IAAI,CAAA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACK,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAA6B,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;;;4CAAc,aAAK;8CAErE;AAnCU,iBAAiB;IAD7B,IAAA,uBAAQ,EAAC,aAAK,CAAC;GACH,iBAAiB,CAoC7B;AApCY,8CAAiB","sourcesContent":["import { Resolver, Subscription, Root, Arg } from 'type-graphql'\nimport { filter, pipe } from 'graphql-yoga'\nimport { pubsub } from '@things-factory/shell'\nimport { Board } from './board'\n\n@Resolver(Board)\nexport class BoardSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { id } = args\n const subdomain = domain?.subdomain\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('board'),\n filter((payload: { board: Board }) => {\n const { domainId, id: boardId } = payload.board\n\n if (domainId !== domain.id) {\n return false\n }\n\n if (id !== boardId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n board(@Root() payload: { board: Board }, @Arg('id') id: string): Board {\n return payload.board\n }\n}\n"]}
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.PlayGroupSubscription = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const type_graphql_1 = require("type-graphql");
|
|
6
|
-
const
|
|
6
|
+
const graphql_yoga_1 = require("graphql-yoga");
|
|
7
7
|
const shell_1 = require("@things-factory/shell");
|
|
8
8
|
const play_group_1 = require("./play-group");
|
|
9
9
|
let PlayGroupSubscription = class PlayGroupSubscription {
|
|
@@ -13,7 +13,7 @@ let PlayGroupSubscription = class PlayGroupSubscription {
|
|
|
13
13
|
};
|
|
14
14
|
tslib_1.__decorate([
|
|
15
15
|
(0, type_graphql_1.Subscription)({
|
|
16
|
-
subscribe: (
|
|
16
|
+
subscribe: ({ args, context, info }) => {
|
|
17
17
|
var _a;
|
|
18
18
|
const { domain, user } = context.state;
|
|
19
19
|
const { id } = args;
|
|
@@ -24,7 +24,7 @@ tslib_1.__decorate([
|
|
|
24
24
|
if (!((_a = user.domains) === null || _a === void 0 ? void 0 : _a.find(d => d.subdomain === subdomain)) && !process.superUserGranted(domain, user)) {
|
|
25
25
|
throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`);
|
|
26
26
|
}
|
|
27
|
-
return (0,
|
|
27
|
+
return (0, graphql_yoga_1.pipe)(shell_1.pubsub.subscribe('play-group'), (0, graphql_yoga_1.filter)((payload) => {
|
|
28
28
|
const { id: playGroupId, domainId } = payload.playGroup;
|
|
29
29
|
if (domainId !== domain.id) {
|
|
30
30
|
return false;
|
|
@@ -33,7 +33,7 @@ tslib_1.__decorate([
|
|
|
33
33
|
return false;
|
|
34
34
|
}
|
|
35
35
|
return true;
|
|
36
|
-
})
|
|
36
|
+
}));
|
|
37
37
|
}
|
|
38
38
|
}),
|
|
39
39
|
tslib_1.__param(0, (0, type_graphql_1.Root)()),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"play-group-subscription.js","sourceRoot":"","sources":["../../../server/service/play-group/play-group-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE
|
|
1
|
+
{"version":3,"file":"play-group-subscription.js","sourceRoot":"","sources":["../../../server/service/play-group/play-group-subscription.ts"],"names":[],"mappings":";;;;AAAA,+CAAgE;AAChE,+CAA2C;AAC3C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AA;YACb,CAAC,CAAC,CACH,CAAA;QACH,CAAC;KACF,CAAC;IACS,mBAAA,IAAA,mBAAI,GAAE,CAAA;IAAqC,mBAAA,IAAA,kBAAG,EAAC,IAAI,CAAC,CAAA;;;4CAAc,sBAAS;sDAErF;AAnCU,qBAAqB;IADjC,IAAA,uBAAQ,EAAC,sBAAS,CAAC;GACP,qBAAqB,CAoCjC;AApCY,sDAAqB","sourcesContent":["import { Resolver, Subscription, Root, Arg } from 'type-graphql'\nimport { filter, pipe } from 'graphql-yoga'\nimport { pubsub } from '@things-factory/shell'\nimport { PlayGroup } from './play-group'\n\n@Resolver(PlayGroup)\nexport class PlayGroupSubscription {\n @Subscription({\n subscribe: ({ args, context, info }) => {\n const { domain, user } = context.state\n const { id } = args\n const subdomain = domain?.subdomain\n\n if (!domain) {\n throw new Error('domain required')\n }\n\n if (!user.domains?.find(d => d.subdomain === subdomain) && !process.superUserGranted(domain, user)) {\n throw new Error(`domain(${subdomain}) is not working for user(${user.email}).`)\n }\n\n return pipe(\n pubsub.subscribe('play-group'),\n filter((payload: { playGroup: PlayGroup }) => {\n const { id: playGroupId, domainId } = payload.playGroup\n\n if (domainId !== domain.id) {\n return false\n }\n\n if (id !== playGroupId) {\n return false\n }\n\n return true\n })\n )\n }\n })\n playGroup(@Root() payload: { playGroup: PlayGroup }, @Arg('id') id: string): PlayGroup {\n return payload.playGroup\n }\n}\n"]}
|