catlab-remote-client 1.3.8 → 2.0.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.
@@ -0,0 +1,134 @@
1
+ /**
2
+ * webworker.js — Entry point for the PlayerPool WebWorker.
3
+ *
4
+ * This file is loaded by new Worker('scripts/webworker.js') from the dist/ folder.
5
+ * It loads polyfills, configures RequireJS, loads the built webcontrol bundle
6
+ * (which contains all AMD modules), then boots the PlayerPoolWorker.
7
+ */
8
+
9
+ // Load RequireJS (dist/vendor/requirejs/require.js)
10
+ importScripts("../vendor/requirejs/require.js");
11
+
12
+ // Load polyfills for browser APIs not available in workers
13
+ importScripts("WorkerPolyfills.js");
14
+
15
+ // Configure RequireJS paths for vendor dependencies
16
+ requirejs.config({
17
+ baseUrl: './',
18
+ waitSeconds: 0,
19
+ paths: {
20
+ 'jquery': 'empty:',
21
+
22
+ 'viewport-units-buggyfill': '../vendor/viewport-units-buggyfill/viewport-units-buggyfill',
23
+ 'viewport-units-buggyfill.hacks': '../vendor/viewport-units-buggyfill/viewport-units-buggyfill.hacks',
24
+
25
+ 'easelbone': '../vendor/easelbone/dist/scripts/easelbone',
26
+ 'easelhacks': '../vendor/easelhacks/dist/scripts/easelhacks',
27
+
28
+ 'easeljs': '../vendor/easeljs/lib/easeljs',
29
+ 'preloadjs': '../vendor/preloadjs/lib/preloadjs',
30
+ 'tweenjs': '../vendor/tweenjs/lib/tweenjs',
31
+
32
+ 'underscore': '../vendor/underscore/underscore',
33
+ 'backbone': '../vendor/backbone/backbone',
34
+
35
+ 'sprintf': '../vendor/sprintf-js/dist/sprintf.min',
36
+ 'rivets': '../vendor/rivets/dist/rivets.min',
37
+ 'sightglass': '../vendor/sightglass/index',
38
+
39
+ 'emojione': '../vendor/emojione/lib/js/emojione',
40
+ 'screenfull': '../vendor/screenfull/dist/screenfull',
41
+ 'socket.io-client': '../vendor/socket.io-client/dist/socket.io',
42
+
43
+ 'simple-keyboard': '../vendor/simple-keyboard/build/index',
44
+ 'SimpleKeyboard': '../vendor/simple-keyboard/build/index',
45
+
46
+ 'qrious': '../vendor/qrious/dist/qrious.min'
47
+ },
48
+
49
+ shim: {
50
+ easeljs: {
51
+ deps: ['tweenjs'],
52
+ exports: 'createjs'
53
+ },
54
+ preloadjs: {
55
+ deps: ['easeljs'],
56
+ exports: 'createjs'
57
+ },
58
+ emojione: {
59
+ exports: 'emojione'
60
+ },
61
+ screenfull: {
62
+ exports: 'screenfull'
63
+ }
64
+ }
65
+ });
66
+
67
+ // Stub out jquery for worker context
68
+ define('jquery', function () {
69
+ return {};
70
+ });
71
+
72
+ // Capture requirejs errors
73
+ requirejs.onError = function (err) {
74
+ var msg = '[worker] RequireJS error: ' + (err.requireType || 'unknown') + ': ' + err.message;
75
+ if (err.requireModules) {
76
+ msg += ' | modules: ' + err.requireModules.join(', ');
77
+ }
78
+ console.error(msg);
79
+ if (err.originalError) {
80
+ console.error('[worker] Caused by:', err.originalError.message || err.originalError);
81
+ }
82
+ self.postMessage({
83
+ e: 'worker:error',
84
+ data: {
85
+ type: err.requireType || 'unknown',
86
+ message: err.message,
87
+ modules: err.requireModules || []
88
+ }
89
+ });
90
+ };
91
+
92
+ // Load the built webcontrol bundle (contains all AMD module definitions),
93
+ // then wait for an 'init' message from the main thread before booting.
94
+ require(
95
+ ['webcontrol'],
96
+ function () {
97
+ require(
98
+ ['CatLab/Webremote/PlayerPool/PlayerPoolWorker'],
99
+ function (PlayerPoolWorker) {
100
+ // Signal that modules are loaded; wait for init options
101
+ self.postMessage({ type: 'worker:modules-ready' });
102
+
103
+ self.addEventListener('message', function initHandler(e) {
104
+ if (e.data && e.data.type === 'worker:init') {
105
+ self.removeEventListener('message', initHandler);
106
+ var worker = new PlayerPoolWorker();
107
+ worker.start(e.data.options || {});
108
+ }
109
+ });
110
+ },
111
+ function (err) {
112
+ console.error('[worker] Failed to load PlayerPoolWorker:', err.message);
113
+ self.postMessage({
114
+ e: 'worker:fatal',
115
+ data: {
116
+ message: err.message,
117
+ modules: err.requireModules || []
118
+ }
119
+ });
120
+ }
121
+ );
122
+ },
123
+ function (err) {
124
+ console.error('[worker] Failed to load webcontrol bundle:', err.message);
125
+ self.postMessage({
126
+ e: 'worker:fatal',
127
+ data: {
128
+ message: err.message,
129
+ modules: err.requireModules || []
130
+ }
131
+ });
132
+ }
133
+ );
134
+