1importScripts('https://unpkg.com/canvaskit-wasm@0.25.0/bin/full/canvaskit.js'); 2importScripts('shared.js'); 3 4const transferCanvasToOffscreenPromise = 5 new Promise((resolve) => addEventListener('message', resolve)); 6const canvasKitInitPromise = 7 CanvasKitInit({locateFile: (file) => 'https://unpkg.com/canvaskit-wasm@0.25.0/bin/full/'+file}); 8const skottieJsonPromise = 9 fetch('https://storage.googleapis.com/skia-cdn/misc/lego_loader.json') 10 .then((response) => response.text()); 11 12Promise.all([ 13 transferCanvasToOffscreenPromise, 14 canvasKitInitPromise, 15 skottieJsonPromise 16]).then(([ 17 { data: { offscreenCanvas } }, 18 CanvasKit, 19 jsonStr 20]) => { 21 const surface = CanvasKit.MakeWebGLCanvasSurface(offscreenCanvas, null); 22 if (!surface) { 23 throw 'Could not make canvas surface'; 24 } 25 26 SkottieExample(CanvasKit, surface, jsonStr); 27}); 28