Skip to content

Commit

Permalink
Merge branch 'trunk' into add/logger-crash-event
Browse files Browse the repository at this point in the history
  • Loading branch information
bgrgicak authored Mar 12, 2024
2 parents a9dd3a9 + 954f0df commit 9762186
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/php-wasm/util/src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Semaphore from './semaphore';
export { Semaphore };
export { PhpWasmError } from './php-wasm-error';
export type { SemaphoreOptions } from './semaphore';
export { dirname, joinPaths, basename, normalizePath } from './paths';
export { createSpawnHandler } from './create-spawn-handler';
Expand Down
8 changes: 8 additions & 0 deletions packages/php-wasm/util/src/lib/php-wasm-error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export class PhpWasmError extends Error {
constructor(message: string, public userFriendlyMessage?: string) {
super(message);
if (!this.userFriendlyMessage) {
this.userFriendlyMessage = message;
}
}
}
16 changes: 10 additions & 6 deletions packages/php-wasm/web/src/lib/register-service-worker.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PhpWasmError } from '@php-wasm/util';
import type { WebPHPEndpoint } from './web-php-endpoint';
import { responseTo } from '@php-wasm/web-service-worker';
import { Remote } from 'comlink';
Expand All @@ -17,14 +18,17 @@ export async function registerServiceWorker<
>(phpApi: Client, scope: string, scriptUrl: string) {
const sw = navigator.serviceWorker;
if (!sw) {
if (location.protocol === 'https:') {
throw new Error(
'Service workers are not supported in this browser.'
/**
* Service workers may only run in secure contexts.
* See https://w3c.github.io/webappsec-secure-contexts/
*/
if (window.isSecureContext) {
throw new PhpWasmError(
'Service workers are not supported in your browser.'
);
} else {
throw new Error(
'WordPress Playground requires service workers which are only supported ' +
'on HTTPS sites. This site does not use HTTPS, please retry on one that does. '
throw new PhpWasmError(
'WordPress Playground uses service workers and may only work on HTTPS and http://localhost/ sites, but the current site is neither.'
);
}
}
Expand Down
7 changes: 6 additions & 1 deletion packages/playground/remote/remote.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,12 @@

const div = document.createElement('div');
div.className = 'error-message';
div.innerText = 'Ooops! WordPress Playground had a hiccup!';
const userFriendlyMessage =
e?.userFriendlyMessage ||
'See the developer tools for error details.';
div.innerHTML =
'Ooops! WordPress Playground had a hiccup! <br/><br/> ' +
userFriendlyMessage;
document.body.append(div);

const button = document.createElement('button');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ html:lang(he-il) .rtl #wpadminbar * {
#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item,
#wpadminbar .shortlink-input {
line-height: 2;
height: 1.625rem;
height: 26px;
white-space: nowrap;
min-width: 140px;
}
Expand Down Expand Up @@ -464,7 +464,7 @@ html:lang(he-il) .rtl #wpadminbar * {
#wpadminbar #wp-admin-bar-user-info span {
background: none;
padding: 0;
height: 1.125rem;
height: 18px;
}

#wpadminbar #wp-admin-bar-user-info .display-name,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ html:lang(he-il) .rtl #wpadminbar * {
#wpadminbar.nojs .quicklinks .menupop:hover ul li .ab-item,
#wpadminbar .shortlink-input {
line-height: 2;
height: 1.625rem;
height: 26px;
white-space: nowrap;
min-width: 140px;
}
Expand Down Expand Up @@ -463,7 +463,7 @@ html:lang(he-il) .rtl #wpadminbar * {
#wpadminbar #wp-admin-bar-user-info span {
background: none;
padding: 0;
height: 1.125rem;
height: 18px;
}

#wpadminbar #wp-admin-bar-user-info .display-name,
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function getWordPressModuleDetails(wpVersion: string = "6.4"): { size: nu
case 'nightly':
/** @ts-ignore */
return {
size: 5126888,
size: 5127434,
url: url_nightly,
};

Expand Down
Binary file modified packages/playground/wordpress/src/wordpress/wp-nightly.zip
Binary file not shown.

0 comments on commit 9762186

Please sign in to comment.