Skip to content

Commit 9ea9288

Browse files
committed
0.17.24
1 parent 7faa66c commit 9ea9288

File tree

14 files changed

+183
-175
lines changed

14 files changed

+183
-175
lines changed

docs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/service-worker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
import s from"https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js";if(!globalThis.crossOriginIsolated){const{isArray:r}=Array,t=s=>s.length&&"object"==typeof s[0]&&null!==s[0];globalThis.Blob=class extends Blob{constructor(s,...e){t(e)&&"text/javascript"===e[0].type&&r(s)&&"string"==typeof s.at(0)&&(s[0]=s[0].replace(/^\/\*@\*\//,'import "https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js";')),super(s,...e)}},globalThis.Worker=class extends Worker{constructor(r,...e){if(t(e)){const r=e[0].serviceWorker||e[0].service_worker;r&&s(r)}super(r,...e)}}}
1+

docs/toml-BK2RWy-G.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/toml-BK2RWy-G.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/zip-BKVoQflw.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/zip-BKVoQflw.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

esm/interpreter/webr.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const run = async (interpreter, code) => {
1919
export default {
2020
type,
2121
experimental: true,
22-
module: (version = '0.5.0') =>
22+
module: (version = '0.5.1') =>
2323
`https://cdn.jsdelivr.net/npm/webr@${version}/dist/webr.mjs`,
2424
async engine(module, config, _, baseURL) {
2525
const { get } = stdio();

esm/service-worker.js

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,38 @@
1-
import sabayon from 'https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js';
1+
// Let's avoid 404s *but* this should not be needed anymore*
22

3-
// ignore browsers that already support SharedArrayBuffer
4-
if (!globalThis.crossOriginIsolated) {
5-
const { isArray } = Array;
6-
const isOptions = args => args.length && typeof args[0] === 'object' && args[0] !== null;
3+
// import sabayon from 'https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js';
74

8-
// early patch Blob to inject sabayon polyfill for service-worker
9-
globalThis.Blob = class extends Blob {
10-
constructor(blobParts, ...args) {
11-
if (
12-
isOptions(args) &&
13-
args[0].type === 'text/javascript' &&
14-
isArray(blobParts) &&
15-
typeof blobParts.at(0) === 'string'
16-
) {
17-
blobParts[0] = blobParts[0].replace(
18-
/^\/\*@\*\//,
19-
'import "https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js";'
20-
);
21-
}
22-
super(blobParts, ...args);
23-
}
24-
};
5+
// // ignore browsers that already support SharedArrayBuffer
6+
// if (!globalThis.crossOriginIsolated) {
7+
// const { isArray } = Array;
8+
// const isOptions = args => args.length && typeof args[0] === 'object' && args[0] !== null;
259

26-
// early patch Worker to bootstrap sabayon for service-worker
27-
globalThis.Worker = class extends Worker {
28-
constructor(url, ...args) {
29-
if (isOptions(args)) {
30-
const sw = args[0].serviceWorker || args[0].service_worker;
31-
if (sw) sabayon(sw);
32-
}
33-
super(url, ...args);
34-
}
35-
};
36-
}
10+
// // early patch Blob to inject sabayon polyfill for service-worker
11+
// globalThis.Blob = class extends Blob {
12+
// constructor(blobParts, ...args) {
13+
// if (
14+
// isOptions(args) &&
15+
// args[0].type === 'text/javascript' &&
16+
// isArray(blobParts) &&
17+
// typeof blobParts.at(0) === 'string'
18+
// ) {
19+
// blobParts[0] = blobParts[0].replace(
20+
// /^\/\*@\*\//,
21+
// 'import "https://cdn.jsdelivr.net/npm/sabayon/dist/polyfill.js";'
22+
// );
23+
// }
24+
// super(blobParts, ...args);
25+
// }
26+
// };
27+
28+
// // early patch Worker to bootstrap sabayon for service-worker
29+
// globalThis.Worker = class extends Worker {
30+
// constructor(url, ...args) {
31+
// if (isOptions(args)) {
32+
// const sw = args[0].serviceWorker || args[0].service_worker;
33+
// if (sw) sabayon(sw);
34+
// }
35+
// super(url, ...args);
36+
// }
37+
// };
38+
// }

esm/worker/_template.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,23 @@ const add = (type, fn) => {
3434

3535
const {
3636
proxy: sync,
37+
sync: polyfill,
3738
native,
3839
window,
39-
isWindowProxy
40+
isWindowProxy,
41+
ffi,
4042
} = await coincident({
4143
transfer: false,
4244
transform: value => transform ? transform(value) : value
4345
});
4446

4547
const xworker = {
4648
// propagate the fact SharedArrayBuffer is polyfilled
47-
polyfill: !native,
49+
polyfill,
4850
// allows synchronous utilities between this worker and the main thread
4951
sync,
5052
// allow access to the main thread world whenever it's possible
51-
window: native ? window : null,
53+
window: (native || polyfill) ? window : null,
5254
// allow introspection for foreign (main thread) refrences
5355
isWindowProxy,
5456
// standard worker related events / features
@@ -127,7 +129,7 @@ add('message', ({ data: { options, config: baseURL, configURL, code, hooks } })
127129
// there's no way to query the DOM, use foreign CustomEvent and so on
128130
// in case there's no SharedArrayBuffer around.
129131
let CustomEvent, document, notify, currentScript = null, target = '';
130-
if (native) {
132+
if (native || polyfill) {
131133
({ CustomEvent, document } = window);
132134
currentScript = id && document.getElementById(id) || null;
133135
notify = kind => dispatch(currentScript, custom || type, kind, true, CustomEvent);
@@ -145,6 +147,7 @@ add('message', ({ data: { options, config: baseURL, configURL, code, hooks } })
145147
currentScript,
146148
config: resolved.config,
147149
js_modules: JSModules,
150+
ffi,
148151
get target() {
149152
if (!target && currentScript) {
150153
if (tag === 'SCRIPT') {
@@ -217,7 +220,7 @@ add('message', ({ data: { options, config: baseURL, configURL, code, hooks } })
217220
add('error');
218221
add('message');
219222
add('messageerror');
220-
if (native) {
223+
if (native || polyfill) {
221224
addEventListener('py:progress', ({ type, detail }) => {
222225
window.dispatchEvent(new window.CustomEvent(type, { detail }));
223226
});

esm/worker/class.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ export default (...args) =>
6262
defineProperties(worker, {
6363
sync: { value: sync },
6464
ready: { value: resolver.promise },
65+
ffi: {
66+
direct: worker.direct,
67+
},
6568
postMessage: {
6669
value: (data, ...rest) => bootstrap.then(
6770
() => postMessage.call(worker, data, ...rest),

0 commit comments

Comments
 (0)