Skip to content

Commit f6c523c

Browse files
committed
Docs: Add back 0.18.1 playground elements
1 parent 0edfae4 commit f6c523c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

docs/public/sandbox/playground-service-worker-proxy.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,9 @@
33
* Copyright 2019 Google LLC
44
* SPDX-License-Identifier: BSD-3-Clause
55
*/
6+
/**
7+
* @license
8+
* Copyright 2020 Google LLC
9+
* SPDX-License-Identifier: BSD-3-Clause
10+
*/
611
(async()=>{try{parent.window.console.warn("Playground sandbox is executing with the same origin as its parent.","This is a security risk.","https://github.com/google/playground-elements#sandbox-security")}catch{}const{scope:e,port:t}=await new Promise((e=>{const t=a=>{1===a.data.type&&(window.removeEventListener("message",t),e(a.data))};window.addEventListener("message",t)})),a=await navigator.serviceWorker.register(new URL("playground-service-worker.js",import.meta.url).href,{scope:e}),n=()=>{var e,t;return null!==(t=null!==(e=a.installing)&&void 0!==e?e:a.waiting)&&void 0!==t?t:a.active};let r=null;const s=async(e=!1)=>{const a=n();if(!e&&a===r)return;if(r=a,null===a)return void console.error("No playground service worker found.");if(await(async e=>{if("activated"!==e.state)return new Promise((t=>{const a=new AbortController;e.addEventListener("statechange",(()=>{"activated"===e.state&&(t(),a.abort())}),{signal:a.signal})}))})(a),a!==r)return;const{port1:s,port2:o}=new MessageChannel,i={type:3,port:s};t.postMessage(i,[s]);const d={type:2,port:o};a.postMessage(d,[o])};s(),a.addEventListener("updatefound",(()=>{s()})),navigator.serviceWorker.addEventListener("message",(e=>{e.source===r&&5===e.data.type&&s(!0)})),window.addEventListener("message",(async e=>{if(6===e.data.type){const e=n();await a.update(),n()===e&&console.error("Playground service worker update failed.")}}))})();</script>

docs/public/sandbox/playground-service-worker.js

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

0 commit comments

Comments
 (0)