catlab-remote-client 5.0.0 → 5.0.2
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/iframe-host.html +31 -0
- package/dist/scripts/WorkerPolyfills.js +4 -2
- package/dist/scripts/catlabremote.js +1 -1
- package/dist/scripts/webcontrol.js +1 -1
- package/dist/scripts/webremote.js +1 -1
- package/dist/scripts/webworker.js +15 -122
- package/dist/scripts/worker-env.js +211 -0
- package/dist/vendor/requirejs/README.md +9 -0
- package/dist/vendor/requirejs/bin/r.js +30431 -0
- package/dist/vendor/requirejs/package.json +20 -0
- package/dist/vendor/requirejs/require.js +2145 -0
- package/package.json +2 -1
|
@@ -1,128 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* webworker.js — Entry point for the PlayerPool
|
|
2
|
+
* webworker.js — Entry point for the PlayerPool dedicated-Worker host.
|
|
3
3
|
*
|
|
4
|
-
* This file is loaded by new Worker('scripts/webworker.js') from the dist/
|
|
5
|
-
* It loads
|
|
6
|
-
* (
|
|
4
|
+
* This file is loaded by new Worker('scripts/webworker.js') from the dist/
|
|
5
|
+
* folder. It loads RequireJS, the WorkerPolyfills stubs, and worker-env.js
|
|
6
|
+
* (the environment shim shared with the iframe host, see
|
|
7
|
+
* iframe-host.html), then boots through it: configure RequireJS, stub
|
|
8
|
+
* jquery, wire up RequireJS error reporting, and boot the pool worker on
|
|
9
|
+
* the 'webcontrol' bundle.
|
|
7
10
|
*/
|
|
8
11
|
|
|
9
|
-
|
|
10
|
-
importScripts(
|
|
12
|
+
importScripts('../vendor/requirejs/require.js');
|
|
13
|
+
importScripts('WorkerPolyfills.js');
|
|
14
|
+
importScripts('worker-env.js');
|
|
11
15
|
|
|
12
|
-
|
|
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
|
-
// Single boot entry point: posts worker:modules-ready and boots
|
|
101
|
-
// on worker:init. No createGameLogic here — the library's own
|
|
102
|
-
// demo runs on the base GameLogic defaults.
|
|
103
|
-
PlayerPoolWorker.bootWorker({});
|
|
104
|
-
},
|
|
105
|
-
function (err) {
|
|
106
|
-
console.error('[worker] Failed to load PlayerPoolWorker:', err.message);
|
|
107
|
-
self.postMessage({
|
|
108
|
-
e: 'worker:fatal',
|
|
109
|
-
data: {
|
|
110
|
-
message: err.message,
|
|
111
|
-
modules: err.requireModules || []
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
);
|
|
116
|
-
},
|
|
117
|
-
function (err) {
|
|
118
|
-
console.error('[worker] Failed to load webcontrol bundle:', err.message);
|
|
119
|
-
self.postMessage({
|
|
120
|
-
e: 'worker:fatal',
|
|
121
|
-
data: {
|
|
122
|
-
message: err.message,
|
|
123
|
-
modules: err.requireModules || []
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
);
|
|
16
|
+
var __post = function (m) { self.postMessage(m); };
|
|
128
17
|
|
|
18
|
+
self.__catlabWorkerEnv.configureRequire(requirejs);
|
|
19
|
+
self.__catlabWorkerEnv.installJqueryStub(define);
|
|
20
|
+
self.__catlabWorkerEnv.onRequireError(requirejs, __post);
|
|
21
|
+
self.__catlabWorkerEnv.boot(require, __post);
|
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* worker-env.js — Shared environment shim for the two worker-entry loaders.
|
|
3
|
+
*
|
|
4
|
+
* Plain JS (no AMD, no ES6): loaded by webworker.js in the dedicated-Worker
|
|
5
|
+
* host (its Worker-global script loader), and via a <script> tag by
|
|
6
|
+
* iframe-host.html in the iframe host. Both loaders are otherwise identical
|
|
7
|
+
* -- this file holds the parts that would else be duplicated between them.
|
|
8
|
+
*
|
|
9
|
+
* This file must not post messages to the other side itself: every
|
|
10
|
+
* caller-visible side effect goes through the `post` function the loader
|
|
11
|
+
* passes in, so the same code runs unmodified in either host.
|
|
12
|
+
*
|
|
13
|
+
* Exposes self.__catlabWorkerEnv = {
|
|
14
|
+
* configureRequire: function (requirejs, options) {...},
|
|
15
|
+
* installJqueryStub: function (define) {...},
|
|
16
|
+
* onRequireError: function (requirejs, post) {...},
|
|
17
|
+
* boot: function (require, post) {...}
|
|
18
|
+
* }
|
|
19
|
+
*/
|
|
20
|
+
(function (scope) {
|
|
21
|
+
"use strict";
|
|
22
|
+
|
|
23
|
+
// Vendor paths, relative to options.vendor (a trailing-slash directory).
|
|
24
|
+
// Identical set/order to the pre-split webworker.js requirejs.config.
|
|
25
|
+
var VENDOR_PATHS = {
|
|
26
|
+
'viewport-units-buggyfill': 'viewport-units-buggyfill/viewport-units-buggyfill',
|
|
27
|
+
'viewport-units-buggyfill.hacks': 'viewport-units-buggyfill/viewport-units-buggyfill.hacks',
|
|
28
|
+
|
|
29
|
+
'easelbone': 'easelbone/dist/scripts/easelbone',
|
|
30
|
+
'easelhacks': 'easelhacks/dist/scripts/easelhacks',
|
|
31
|
+
|
|
32
|
+
'easeljs': 'easeljs/lib/easeljs',
|
|
33
|
+
'preloadjs': 'preloadjs/lib/preloadjs',
|
|
34
|
+
'tweenjs': 'tweenjs/lib/tweenjs',
|
|
35
|
+
|
|
36
|
+
'underscore': 'underscore/underscore',
|
|
37
|
+
'backbone': 'backbone/backbone',
|
|
38
|
+
|
|
39
|
+
'sprintf': 'sprintf-js/dist/sprintf.min',
|
|
40
|
+
'rivets': 'rivets/dist/rivets.min',
|
|
41
|
+
'sightglass': 'sightglass/index',
|
|
42
|
+
|
|
43
|
+
'emojione': 'emojione/lib/js/emojione',
|
|
44
|
+
'screenfull': 'screenfull/dist/screenfull',
|
|
45
|
+
'socket.io-client': 'socket.io-client/dist/socket.io',
|
|
46
|
+
|
|
47
|
+
'simple-keyboard': 'simple-keyboard/build/index',
|
|
48
|
+
'SimpleKeyboard': 'simple-keyboard/build/index',
|
|
49
|
+
|
|
50
|
+
'qrious': 'qrious/dist/qrious.min'
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Build a fatal-boot error record from a RequireJS error (or anything
|
|
55
|
+
* Error-shaped). This is the one deliberate raw-shaped post left in the
|
|
56
|
+
* worker entry: the bundle owning the port failed to load, so nothing
|
|
57
|
+
* past this point (PlayerPoolWorker, ChannelPort) is available to build
|
|
58
|
+
* a library-shaped error with.
|
|
59
|
+
*
|
|
60
|
+
* @param {Error|Object} err
|
|
61
|
+
* @returns {Object}
|
|
62
|
+
*/
|
|
63
|
+
function bootErrorRecord(err) {
|
|
64
|
+
return {
|
|
65
|
+
ch: 'control',
|
|
66
|
+
type: 'fatal',
|
|
67
|
+
error: {
|
|
68
|
+
__error: {
|
|
69
|
+
name: 'BootError',
|
|
70
|
+
message: err && err.message,
|
|
71
|
+
stack: '',
|
|
72
|
+
data: { modules: (err && err.requireModules) || [] }
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
scope.__catlabWorkerEnv = {
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Configure RequireJS paths/shim for the vendor bundle. Both loaders
|
|
82
|
+
* call this once, before requiring 'webcontrol'.
|
|
83
|
+
*
|
|
84
|
+
* @param {Object} requirejs
|
|
85
|
+
* @param {Object} [options]
|
|
86
|
+
* @param {string} [options.baseUrl] - default './' (the Worker: the
|
|
87
|
+
* script runs from dist/scripts/).
|
|
88
|
+
* @param {string} [options.vendor] - trailing-slash dir holding the
|
|
89
|
+
* vendor/ tree, RELATIVE TO baseUrl (that is how RequireJS
|
|
90
|
+
* resolves `paths`). Default '../vendor/': the Worker runs
|
|
91
|
+
* from dist/scripts/, so the tree is one level up. The frame
|
|
92
|
+
* page passes the same '../vendor/' — its own baseUrl is
|
|
93
|
+
* 'scripts/', so 'vendor/' would resolve to
|
|
94
|
+
* dist/scripts/vendor/... and 404 (Ruling P2-15).
|
|
95
|
+
*/
|
|
96
|
+
configureRequire: function (requirejs, options) {
|
|
97
|
+
options = options || {};
|
|
98
|
+
var baseUrl = options.baseUrl || './';
|
|
99
|
+
var vendor = options.vendor || '../vendor/';
|
|
100
|
+
|
|
101
|
+
var paths = { 'jquery': 'empty:' };
|
|
102
|
+
for (var name in VENDOR_PATHS) {
|
|
103
|
+
if (Object.prototype.hasOwnProperty.call(VENDOR_PATHS, name)) {
|
|
104
|
+
paths[name] = vendor + VENDOR_PATHS[name];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
requirejs.config({
|
|
109
|
+
baseUrl: baseUrl,
|
|
110
|
+
waitSeconds: 0,
|
|
111
|
+
paths: paths,
|
|
112
|
+
shim: {
|
|
113
|
+
easeljs: {
|
|
114
|
+
deps: ['tweenjs'],
|
|
115
|
+
exports: 'createjs'
|
|
116
|
+
},
|
|
117
|
+
preloadjs: {
|
|
118
|
+
deps: ['easeljs'],
|
|
119
|
+
exports: 'createjs'
|
|
120
|
+
},
|
|
121
|
+
emojione: {
|
|
122
|
+
exports: 'emojione'
|
|
123
|
+
},
|
|
124
|
+
screenfull: {
|
|
125
|
+
exports: 'screenfull'
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
},
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Stub out the 'jquery' AMD module -- neither host has (or needs) a
|
|
133
|
+
* real jQuery; the paths config above maps it to 'empty:', but a few
|
|
134
|
+
* modules `require(['jquery'])` directly rather than only depending
|
|
135
|
+
* on it, so a defined-but-empty module keeps those resolvable too.
|
|
136
|
+
*
|
|
137
|
+
* @param {Function} define - the global AMD define()
|
|
138
|
+
*/
|
|
139
|
+
installJqueryStub: function (define) {
|
|
140
|
+
define('jquery', function () {
|
|
141
|
+
return {};
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Install a requirejs.onError handler that reports load failures
|
|
147
|
+
* through `post` as a control:error record, instead of leaving
|
|
148
|
+
* RequireJS to throw uncaught.
|
|
149
|
+
*
|
|
150
|
+
* @param {Object} requirejs
|
|
151
|
+
* @param {Function} post - post(message)
|
|
152
|
+
*/
|
|
153
|
+
onRequireError: function (requirejs, post) {
|
|
154
|
+
requirejs.onError = function (err) {
|
|
155
|
+
if (typeof console !== 'undefined' && console.error) {
|
|
156
|
+
console.error('[worker-env] RequireJS error:', err && err.message);
|
|
157
|
+
if (err && err.originalError) {
|
|
158
|
+
console.error('[worker-env] Caused by:', err.originalError.message || err.originalError);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
post({
|
|
162
|
+
ch: 'control',
|
|
163
|
+
type: 'error',
|
|
164
|
+
context: 'require',
|
|
165
|
+
error: {
|
|
166
|
+
__error: {
|
|
167
|
+
name: 'RequireError',
|
|
168
|
+
message: err && err.message,
|
|
169
|
+
stack: '',
|
|
170
|
+
data: {
|
|
171
|
+
type: err && err.requireType,
|
|
172
|
+
modules: (err && err.requireModules) || []
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Load the 'webcontrol' bundle, then boot the pool worker on it.
|
|
182
|
+
* Shared by both loaders -- identical two-level require() chain,
|
|
183
|
+
* with the same raw-fatal handling on either level failing.
|
|
184
|
+
*
|
|
185
|
+
* @param {Function} require
|
|
186
|
+
* @param {Function} post - post(message)
|
|
187
|
+
*/
|
|
188
|
+
boot: function (require, post) {
|
|
189
|
+
var fatal = function (err) {
|
|
190
|
+
post(bootErrorRecord(err));
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
require(
|
|
194
|
+
['webcontrol'],
|
|
195
|
+
function (catlabremote) {
|
|
196
|
+
require(
|
|
197
|
+
['CatLab/Webremote/PlayerPool/PlayerPoolWorker'],
|
|
198
|
+
function (PlayerPoolWorker) {
|
|
199
|
+
PlayerPoolWorker.bootWorker({
|
|
200
|
+
port: catlabremote.Transport.WorkerPort.detect()
|
|
201
|
+
});
|
|
202
|
+
},
|
|
203
|
+
fatal
|
|
204
|
+
);
|
|
205
|
+
},
|
|
206
|
+
fatal
|
|
207
|
+
);
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
})(typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : this);
|