@jbrowse/product-core 2.6.1 → 2.6.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.
Files changed (43) hide show
  1. package/dist/RootModel/FormatAbout.d.ts +22 -0
  2. package/dist/RootModel/FormatAbout.js +29 -0
  3. package/dist/RootModel/FormatDetails.d.ts +32 -0
  4. package/dist/RootModel/FormatDetails.js +39 -0
  5. package/dist/RootModel/HierarchicalConfig.d.ts +45 -0
  6. package/dist/RootModel/HierarchicalConfig.js +52 -0
  7. package/dist/RootModel/index.d.ts +3 -0
  8. package/dist/RootModel/index.js +3 -0
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/rpcWorker.d.ts +6 -0
  12. package/dist/rpcWorker.js +74 -0
  13. package/esm/RootModel/FormatAbout.d.ts +22 -0
  14. package/esm/RootModel/FormatAbout.js +25 -0
  15. package/esm/RootModel/FormatDetails.d.ts +32 -0
  16. package/esm/RootModel/FormatDetails.js +35 -0
  17. package/esm/RootModel/HierarchicalConfig.d.ts +45 -0
  18. package/esm/RootModel/HierarchicalConfig.js +48 -0
  19. package/esm/RootModel/index.d.ts +3 -0
  20. package/esm/RootModel/index.js +3 -0
  21. package/esm/index.d.ts +1 -0
  22. package/esm/index.js +1 -0
  23. package/esm/rpcWorker.d.ts +6 -0
  24. package/esm/rpcWorker.js +67 -0
  25. package/package.json +7 -6
  26. package/src/RootModel/BaseRootModel.ts +0 -131
  27. package/src/RootModel/InternetAccounts.ts +0 -126
  28. package/src/RootModel/index.ts +0 -2
  29. package/src/Session/BaseSession.ts +0 -129
  30. package/src/Session/Connections.ts +0 -145
  31. package/src/Session/DialogQueue.ts +0 -63
  32. package/src/Session/DrawerWidgets.ts +0 -222
  33. package/src/Session/MultipleViews.ts +0 -151
  34. package/src/Session/ReferenceManagement.ts +0 -134
  35. package/src/Session/SessionTracks.ts +0 -98
  36. package/src/Session/Themes.ts +0 -85
  37. package/src/Session/Tracks.ts +0 -72
  38. package/src/Session/index.ts +0 -10
  39. package/src/index.ts +0 -3
  40. package/src/ui/AboutDialog.tsx +0 -31
  41. package/src/ui/AboutDialogContents.tsx +0 -88
  42. package/src/ui/FileInfoPanel.tsx +0 -75
  43. package/src/ui/index.ts +0 -1
@@ -0,0 +1,22 @@
1
+ /**
2
+ * #config FormatAbout
3
+ * generally exists on the config.json or root config as configuration.formatAbout
4
+ */
5
+ export declare function FormatAboutConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ /**
7
+ * #slot configuration.formatAbout.config
8
+ */
9
+ config: {
10
+ type: string;
11
+ description: string;
12
+ defaultValue: {};
13
+ contextVariable: string[];
14
+ };
15
+ /**
16
+ * #slot configuration.formatAbout.hideUris
17
+ */
18
+ hideUris: {
19
+ type: string;
20
+ defaultValue: boolean;
21
+ };
22
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormatAboutConfigSchemaFactory = void 0;
4
+ const configuration_1 = require("@jbrowse/core/configuration");
5
+ /**
6
+ * #config FormatAbout
7
+ * generally exists on the config.json or root config as configuration.formatAbout
8
+ */
9
+ function FormatAboutConfigSchemaFactory() {
10
+ return (0, configuration_1.ConfigurationSchema)('FormatAbout', {
11
+ /**
12
+ * #slot configuration.formatAbout.config
13
+ */
14
+ config: {
15
+ type: 'frozen',
16
+ description: 'formats configuration object in about dialog',
17
+ defaultValue: {},
18
+ contextVariable: ['config'],
19
+ },
20
+ /**
21
+ * #slot configuration.formatAbout.hideUris
22
+ */
23
+ hideUris: {
24
+ type: 'boolean',
25
+ defaultValue: false,
26
+ },
27
+ });
28
+ }
29
+ exports.FormatAboutConfigSchemaFactory = FormatAboutConfigSchemaFactory;
@@ -0,0 +1,32 @@
1
+ /**
2
+ * #config FormatDetails
3
+ * generally exists on the config.json or root config as configuration.formatDetails
4
+ */
5
+ export declare function FormatDetailsConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ /**
7
+ * #slot configuration.formatDetails.feature
8
+ */
9
+ feature: {
10
+ type: string;
11
+ description: string;
12
+ defaultValue: {};
13
+ contextVariable: string[];
14
+ };
15
+ /**
16
+ * #slot configuration.formatDetails.subfeatures
17
+ */
18
+ subfeatures: {
19
+ type: string;
20
+ description: string;
21
+ defaultValue: {};
22
+ contextVariable: string[];
23
+ };
24
+ /**
25
+ * #slot configuration.formatDetails.depth
26
+ */
27
+ depth: {
28
+ type: string;
29
+ defaultValue: number;
30
+ description: string;
31
+ };
32
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FormatDetailsConfigSchemaFactory = void 0;
4
+ const configuration_1 = require("@jbrowse/core/configuration");
5
+ /**
6
+ * #config FormatDetails
7
+ * generally exists on the config.json or root config as configuration.formatDetails
8
+ */
9
+ function FormatDetailsConfigSchemaFactory() {
10
+ return (0, configuration_1.ConfigurationSchema)('FormatDetails', {
11
+ /**
12
+ * #slot configuration.formatDetails.feature
13
+ */
14
+ feature: {
15
+ type: 'frozen',
16
+ description: 'adds extra fields to the feature details',
17
+ defaultValue: {},
18
+ contextVariable: ['feature'],
19
+ },
20
+ /**
21
+ * #slot configuration.formatDetails.subfeatures
22
+ */
23
+ subfeatures: {
24
+ type: 'frozen',
25
+ description: 'adds extra fields to the subfeatures of a feature',
26
+ defaultValue: {},
27
+ contextVariable: ['feature'],
28
+ },
29
+ /**
30
+ * #slot configuration.formatDetails.depth
31
+ */
32
+ depth: {
33
+ type: 'number',
34
+ defaultValue: 2,
35
+ description: 'depth to iterate on subfeatures',
36
+ },
37
+ });
38
+ }
39
+ exports.FormatDetailsConfigSchemaFactory = FormatDetailsConfigSchemaFactory;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * #config HierarchicalConfigSchema
3
+ * generally exists on the config.json or root config as configuration.hierarchical
4
+ */
5
+ export declare function HierarchicalConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ sort: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
7
+ /**
8
+ * #slot configuration.hierarchical.sort.trackNames
9
+ */
10
+ trackNames: {
11
+ type: string;
12
+ defaultValue: boolean;
13
+ };
14
+ /**
15
+ * #slot configuration.hierarchical.sort.categories
16
+ */
17
+ categories: {
18
+ type: string;
19
+ defaultValue: boolean;
20
+ };
21
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
22
+ defaultCollapsed: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
23
+ /**
24
+ * #slot configuration.hierarchical.defaultCollapse.categoryNames
25
+ */
26
+ categoryNames: {
27
+ type: string;
28
+ defaultValue: never[];
29
+ };
30
+ /**
31
+ * #slot configuration.hierarchical.defaultCollapse.topLevelCategories
32
+ */
33
+ topLevelCategories: {
34
+ type: string;
35
+ defaultValue: boolean;
36
+ };
37
+ /**
38
+ * #slot configuration.hierarchical.defaultCollapse.subCategories
39
+ */
40
+ subCategories: {
41
+ type: string;
42
+ defaultValue: boolean;
43
+ };
44
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
45
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HierarchicalConfigSchemaFactory = void 0;
4
+ const configuration_1 = require("@jbrowse/core/configuration");
5
+ /**
6
+ * #config HierarchicalConfigSchema
7
+ * generally exists on the config.json or root config as configuration.hierarchical
8
+ */
9
+ function HierarchicalConfigSchemaFactory() {
10
+ return (0, configuration_1.ConfigurationSchema)('hierarchical', {
11
+ sort: (0, configuration_1.ConfigurationSchema)('hierarchicalSort', {
12
+ /**
13
+ * #slot configuration.hierarchical.sort.trackNames
14
+ */
15
+ trackNames: {
16
+ type: 'boolean',
17
+ defaultValue: false,
18
+ },
19
+ /**
20
+ * #slot configuration.hierarchical.sort.categories
21
+ */
22
+ categories: {
23
+ type: 'boolean',
24
+ defaultValue: false,
25
+ },
26
+ }),
27
+ defaultCollapsed: (0, configuration_1.ConfigurationSchema)('defaultCollapsed', {
28
+ /**
29
+ * #slot configuration.hierarchical.defaultCollapse.categoryNames
30
+ */
31
+ categoryNames: {
32
+ type: 'stringArray',
33
+ defaultValue: [],
34
+ },
35
+ /**
36
+ * #slot configuration.hierarchical.defaultCollapse.topLevelCategories
37
+ */
38
+ topLevelCategories: {
39
+ type: 'boolean',
40
+ defaultValue: false,
41
+ },
42
+ /**
43
+ * #slot configuration.hierarchical.defaultCollapse.subCategories
44
+ */
45
+ subCategories: {
46
+ type: 'boolean',
47
+ defaultValue: false,
48
+ },
49
+ }),
50
+ });
51
+ }
52
+ exports.HierarchicalConfigSchemaFactory = HierarchicalConfigSchemaFactory;
@@ -1,2 +1,5 @@
1
1
  export * from './BaseRootModel';
2
2
  export * from './InternetAccounts';
3
+ export * from './FormatAbout';
4
+ export * from './FormatDetails';
5
+ export * from './HierarchicalConfig';
@@ -16,3 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./BaseRootModel"), exports);
18
18
  __exportStar(require("./InternetAccounts"), exports);
19
+ __exportStar(require("./FormatAbout"), exports);
20
+ __exportStar(require("./FormatDetails"), exports);
21
+ __exportStar(require("./HierarchicalConfig"), exports);
package/dist/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './RootModel';
2
2
  export * from './Session';
3
3
  export * from './ui';
4
+ export * from './rpcWorker';
package/dist/index.js CHANGED
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./RootModel"), exports);
18
18
  __exportStar(require("./Session"), exports);
19
19
  __exportStar(require("./ui"), exports);
20
+ __exportStar(require("./rpcWorker"), exports);
@@ -0,0 +1,6 @@
1
+ import { LoadedPlugin } from '@jbrowse/core/PluginLoader';
2
+ import { PluginConstructor } from '@jbrowse/core/Plugin';
3
+ export declare function initializeWorker(corePlugins: PluginConstructor[], opts: {
4
+ fetchESM?: (url: string) => Promise<LoadedPlugin>;
5
+ fetchCJS?: (url: string) => Promise<LoadedPlugin>;
6
+ }): Promise<void>;
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.initializeWorker = void 0;
7
+ /* eslint-disable no-restricted-globals */
8
+ const librpc_web_mod_1 = __importDefault(require("librpc-web-mod"));
9
+ const PluginManager_1 = __importDefault(require("@jbrowse/core/PluginManager"));
10
+ const remoteAbortSignals_1 = require("@jbrowse/core/rpc/remoteAbortSignals");
11
+ const PluginLoader_1 = __importDefault(require("@jbrowse/core/PluginLoader"));
12
+ const serialize_error_1 = require("serialize-error");
13
+ // waits for a message from the main thread containing our configuration, which
14
+ // must be sent on boot
15
+ function receiveConfiguration() {
16
+ const configurationP = new Promise(resolve => {
17
+ function listener(e) {
18
+ if (e.data.message === 'config') {
19
+ resolve(e.data.config);
20
+ removeEventListener('message', listener);
21
+ }
22
+ }
23
+ self.addEventListener('message', listener);
24
+ });
25
+ postMessage({ message: 'readyForConfig' });
26
+ return configurationP;
27
+ }
28
+ async function getPluginManager(corePlugins, opts) {
29
+ // Load runtime plugins
30
+ const config = await receiveConfiguration();
31
+ const pluginLoader = new PluginLoader_1.default(config.plugins, opts);
32
+ pluginLoader.installGlobalReExports(self);
33
+ const runtimePlugins = await pluginLoader.load(config.windowHref);
34
+ const plugins = [...corePlugins.map(p => ({ plugin: p })), ...runtimePlugins];
35
+ const pluginManager = new PluginManager_1.default(plugins.map(P => new P.plugin()));
36
+ pluginManager.createPluggableElements();
37
+ pluginManager.configure();
38
+ return pluginManager;
39
+ }
40
+ function wrapForRpc(func) {
41
+ return (args) => {
42
+ const { channel, rpcDriverClassName } = args;
43
+ return func({
44
+ ...args,
45
+ statusCallback: (message) => {
46
+ // @ts-expect-error
47
+ self.rpcServer.emit(channel, message);
48
+ },
49
+ }, rpcDriverClassName);
50
+ };
51
+ }
52
+ async function initializeWorker(corePlugins, opts) {
53
+ try {
54
+ const pluginManager = await getPluginManager(corePlugins, opts);
55
+ const rpcConfig = Object.fromEntries(pluginManager
56
+ .getRpcElements()
57
+ .map(e => [e.name, wrapForRpc(e.execute.bind(e))]));
58
+ // @ts-expect-error
59
+ self.rpcServer = new librpc_web_mod_1.default.Server({
60
+ ...rpcConfig,
61
+ ...(0, remoteAbortSignals_1.remoteAbortRpcHandler)(),
62
+ ping: () => {
63
+ // the ping method is required by the worker driver for checking the
64
+ // health of the worker
65
+ },
66
+ });
67
+ postMessage({ message: 'ready' });
68
+ }
69
+ catch (e) {
70
+ postMessage({ message: 'error', error: (0, serialize_error_1.serializeError)(e) });
71
+ }
72
+ /* do nothing */
73
+ }
74
+ exports.initializeWorker = initializeWorker;
@@ -0,0 +1,22 @@
1
+ /**
2
+ * #config FormatAbout
3
+ * generally exists on the config.json or root config as configuration.formatAbout
4
+ */
5
+ export declare function FormatAboutConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ /**
7
+ * #slot configuration.formatAbout.config
8
+ */
9
+ config: {
10
+ type: string;
11
+ description: string;
12
+ defaultValue: {};
13
+ contextVariable: string[];
14
+ };
15
+ /**
16
+ * #slot configuration.formatAbout.hideUris
17
+ */
18
+ hideUris: {
19
+ type: string;
20
+ defaultValue: boolean;
21
+ };
22
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,25 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ /**
3
+ * #config FormatAbout
4
+ * generally exists on the config.json or root config as configuration.formatAbout
5
+ */
6
+ export function FormatAboutConfigSchemaFactory() {
7
+ return ConfigurationSchema('FormatAbout', {
8
+ /**
9
+ * #slot configuration.formatAbout.config
10
+ */
11
+ config: {
12
+ type: 'frozen',
13
+ description: 'formats configuration object in about dialog',
14
+ defaultValue: {},
15
+ contextVariable: ['config'],
16
+ },
17
+ /**
18
+ * #slot configuration.formatAbout.hideUris
19
+ */
20
+ hideUris: {
21
+ type: 'boolean',
22
+ defaultValue: false,
23
+ },
24
+ });
25
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * #config FormatDetails
3
+ * generally exists on the config.json or root config as configuration.formatDetails
4
+ */
5
+ export declare function FormatDetailsConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ /**
7
+ * #slot configuration.formatDetails.feature
8
+ */
9
+ feature: {
10
+ type: string;
11
+ description: string;
12
+ defaultValue: {};
13
+ contextVariable: string[];
14
+ };
15
+ /**
16
+ * #slot configuration.formatDetails.subfeatures
17
+ */
18
+ subfeatures: {
19
+ type: string;
20
+ description: string;
21
+ defaultValue: {};
22
+ contextVariable: string[];
23
+ };
24
+ /**
25
+ * #slot configuration.formatDetails.depth
26
+ */
27
+ depth: {
28
+ type: string;
29
+ defaultValue: number;
30
+ description: string;
31
+ };
32
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,35 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ /**
3
+ * #config FormatDetails
4
+ * generally exists on the config.json or root config as configuration.formatDetails
5
+ */
6
+ export function FormatDetailsConfigSchemaFactory() {
7
+ return ConfigurationSchema('FormatDetails', {
8
+ /**
9
+ * #slot configuration.formatDetails.feature
10
+ */
11
+ feature: {
12
+ type: 'frozen',
13
+ description: 'adds extra fields to the feature details',
14
+ defaultValue: {},
15
+ contextVariable: ['feature'],
16
+ },
17
+ /**
18
+ * #slot configuration.formatDetails.subfeatures
19
+ */
20
+ subfeatures: {
21
+ type: 'frozen',
22
+ description: 'adds extra fields to the subfeatures of a feature',
23
+ defaultValue: {},
24
+ contextVariable: ['feature'],
25
+ },
26
+ /**
27
+ * #slot configuration.formatDetails.depth
28
+ */
29
+ depth: {
30
+ type: 'number',
31
+ defaultValue: 2,
32
+ description: 'depth to iterate on subfeatures',
33
+ },
34
+ });
35
+ }
@@ -0,0 +1,45 @@
1
+ /**
2
+ * #config HierarchicalConfigSchema
3
+ * generally exists on the config.json or root config as configuration.hierarchical
4
+ */
5
+ export declare function HierarchicalConfigSchemaFactory(): import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
6
+ sort: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
7
+ /**
8
+ * #slot configuration.hierarchical.sort.trackNames
9
+ */
10
+ trackNames: {
11
+ type: string;
12
+ defaultValue: boolean;
13
+ };
14
+ /**
15
+ * #slot configuration.hierarchical.sort.categories
16
+ */
17
+ categories: {
18
+ type: string;
19
+ defaultValue: boolean;
20
+ };
21
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
22
+ defaultCollapsed: import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaType<{
23
+ /**
24
+ * #slot configuration.hierarchical.defaultCollapse.categoryNames
25
+ */
26
+ categoryNames: {
27
+ type: string;
28
+ defaultValue: never[];
29
+ };
30
+ /**
31
+ * #slot configuration.hierarchical.defaultCollapse.topLevelCategories
32
+ */
33
+ topLevelCategories: {
34
+ type: string;
35
+ defaultValue: boolean;
36
+ };
37
+ /**
38
+ * #slot configuration.hierarchical.defaultCollapse.subCategories
39
+ */
40
+ subCategories: {
41
+ type: string;
42
+ defaultValue: boolean;
43
+ };
44
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
45
+ }, import("@jbrowse/core/configuration/configurationSchema").ConfigurationSchemaOptions<undefined, undefined>>;
@@ -0,0 +1,48 @@
1
+ import { ConfigurationSchema } from '@jbrowse/core/configuration';
2
+ /**
3
+ * #config HierarchicalConfigSchema
4
+ * generally exists on the config.json or root config as configuration.hierarchical
5
+ */
6
+ export function HierarchicalConfigSchemaFactory() {
7
+ return ConfigurationSchema('hierarchical', {
8
+ sort: ConfigurationSchema('hierarchicalSort', {
9
+ /**
10
+ * #slot configuration.hierarchical.sort.trackNames
11
+ */
12
+ trackNames: {
13
+ type: 'boolean',
14
+ defaultValue: false,
15
+ },
16
+ /**
17
+ * #slot configuration.hierarchical.sort.categories
18
+ */
19
+ categories: {
20
+ type: 'boolean',
21
+ defaultValue: false,
22
+ },
23
+ }),
24
+ defaultCollapsed: ConfigurationSchema('defaultCollapsed', {
25
+ /**
26
+ * #slot configuration.hierarchical.defaultCollapse.categoryNames
27
+ */
28
+ categoryNames: {
29
+ type: 'stringArray',
30
+ defaultValue: [],
31
+ },
32
+ /**
33
+ * #slot configuration.hierarchical.defaultCollapse.topLevelCategories
34
+ */
35
+ topLevelCategories: {
36
+ type: 'boolean',
37
+ defaultValue: false,
38
+ },
39
+ /**
40
+ * #slot configuration.hierarchical.defaultCollapse.subCategories
41
+ */
42
+ subCategories: {
43
+ type: 'boolean',
44
+ defaultValue: false,
45
+ },
46
+ }),
47
+ });
48
+ }
@@ -1,2 +1,5 @@
1
1
  export * from './BaseRootModel';
2
2
  export * from './InternetAccounts';
3
+ export * from './FormatAbout';
4
+ export * from './FormatDetails';
5
+ export * from './HierarchicalConfig';
@@ -1,2 +1,5 @@
1
1
  export * from './BaseRootModel';
2
2
  export * from './InternetAccounts';
3
+ export * from './FormatAbout';
4
+ export * from './FormatDetails';
5
+ export * from './HierarchicalConfig';
package/esm/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './RootModel';
2
2
  export * from './Session';
3
3
  export * from './ui';
4
+ export * from './rpcWorker';
package/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './RootModel';
2
2
  export * from './Session';
3
3
  export * from './ui';
4
+ export * from './rpcWorker';
@@ -0,0 +1,6 @@
1
+ import { LoadedPlugin } from '@jbrowse/core/PluginLoader';
2
+ import { PluginConstructor } from '@jbrowse/core/Plugin';
3
+ export declare function initializeWorker(corePlugins: PluginConstructor[], opts: {
4
+ fetchESM?: (url: string) => Promise<LoadedPlugin>;
5
+ fetchCJS?: (url: string) => Promise<LoadedPlugin>;
6
+ }): Promise<void>;
@@ -0,0 +1,67 @@
1
+ /* eslint-disable no-restricted-globals */
2
+ import RpcServer from 'librpc-web-mod';
3
+ import PluginManager from '@jbrowse/core/PluginManager';
4
+ import { remoteAbortRpcHandler } from '@jbrowse/core/rpc/remoteAbortSignals';
5
+ import PluginLoader from '@jbrowse/core/PluginLoader';
6
+ import { serializeError } from 'serialize-error';
7
+ // waits for a message from the main thread containing our configuration, which
8
+ // must be sent on boot
9
+ function receiveConfiguration() {
10
+ const configurationP = new Promise(resolve => {
11
+ function listener(e) {
12
+ if (e.data.message === 'config') {
13
+ resolve(e.data.config);
14
+ removeEventListener('message', listener);
15
+ }
16
+ }
17
+ self.addEventListener('message', listener);
18
+ });
19
+ postMessage({ message: 'readyForConfig' });
20
+ return configurationP;
21
+ }
22
+ async function getPluginManager(corePlugins, opts) {
23
+ // Load runtime plugins
24
+ const config = await receiveConfiguration();
25
+ const pluginLoader = new PluginLoader(config.plugins, opts);
26
+ pluginLoader.installGlobalReExports(self);
27
+ const runtimePlugins = await pluginLoader.load(config.windowHref);
28
+ const plugins = [...corePlugins.map(p => ({ plugin: p })), ...runtimePlugins];
29
+ const pluginManager = new PluginManager(plugins.map(P => new P.plugin()));
30
+ pluginManager.createPluggableElements();
31
+ pluginManager.configure();
32
+ return pluginManager;
33
+ }
34
+ function wrapForRpc(func) {
35
+ return (args) => {
36
+ const { channel, rpcDriverClassName } = args;
37
+ return func({
38
+ ...args,
39
+ statusCallback: (message) => {
40
+ // @ts-expect-error
41
+ self.rpcServer.emit(channel, message);
42
+ },
43
+ }, rpcDriverClassName);
44
+ };
45
+ }
46
+ export async function initializeWorker(corePlugins, opts) {
47
+ try {
48
+ const pluginManager = await getPluginManager(corePlugins, opts);
49
+ const rpcConfig = Object.fromEntries(pluginManager
50
+ .getRpcElements()
51
+ .map(e => [e.name, wrapForRpc(e.execute.bind(e))]));
52
+ // @ts-expect-error
53
+ self.rpcServer = new RpcServer.Server({
54
+ ...rpcConfig,
55
+ ...remoteAbortRpcHandler(),
56
+ ping: () => {
57
+ // the ping method is required by the worker driver for checking the
58
+ // health of the worker
59
+ },
60
+ });
61
+ postMessage({ message: 'ready' });
62
+ }
63
+ catch (e) {
64
+ postMessage({ message: 'error', error: serializeError(e) });
65
+ }
66
+ /* do nothing */
67
+ }