[pathkit] Add .ready() to initialize
See https://github.com/kripken/emscripten/issues/5820 and
https://skia-review.googlesource.com/c/skia/+/181177 for more context.
(Problem was discovered in CanvasKit, and this ports the same fix to
PathKit).
Bug: skia:
Change-Id: Ic8b2fb399210631a571595a5b3d11d1736c00def
Reviewed-on: https://skia-review.googlesource.com/c/181178
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
diff --git a/modules/pathkit/npm-wasm/README.md b/modules/pathkit/npm-wasm/README.md
index 571bcfa..815e417 100644
--- a/modules/pathkit/npm-wasm/README.md
+++ b/modules/pathkit/npm-wasm/README.md
@@ -5,7 +5,7 @@
<script src="/node_modules/pathkit-wasm/bin/pathkit.js"></script>
PathKitInit({
locateFile: (file) => '/node_modules/pathkit-wasm/bin/'+file,
- }).then((PathKit) => {
+ }).ready().then((PathKit) => {
// Code goes here using PathKit
});
@@ -14,7 +14,7 @@
is used to tell the JS loader where to find the .wasm file. By default, it will
look for /pathkit.wasm, so if this is not the case, use `locateFile` to configure
this properly.
-The `PathKit` object returned through the .then() callback is fully loaded and ready to use.
+The `PathKit` object returned upon resolution of the .ready() Promise is fully loaded and ready to use.
See the [API page](https://skia.org/user/modules/pathkit) and
[example.html](https://github.com/google/skia/blob/master/modules/pathkit/npm-wasm/example.html)
@@ -29,7 +29,7 @@
In the JS code, use require():
const PathKitInit = require('pathkit-wasm/bin/pathkit.js')
- PathKitInit().then((PathKit) => {
+ PathKitInit().ready().then((PathKit) => {
// Code goes here using PathKit
})
diff --git a/modules/pathkit/npm-wasm/example.html b/modules/pathkit/npm-wasm/example.html
index 488f6ec..d7c2469 100644
--- a/modules/pathkit/npm-wasm/example.html
+++ b/modules/pathkit/npm-wasm/example.html
@@ -53,7 +53,7 @@
PathKitInit({
locateFile: (file) => '/node_modules/pathkit-wasm/bin/'+file,
- }).then((PathKit) => {
+ }).ready().then((PathKit) => {
window.PathKit = PathKit;
OutputsExample(PathKit);
Path2DExample(PathKit);
diff --git a/modules/pathkit/npm-wasm/package.json b/modules/pathkit/npm-wasm/package.json
index ef70741..a09c0b3 100644
--- a/modules/pathkit/npm-wasm/package.json
+++ b/modules/pathkit/npm-wasm/package.json
@@ -1,6 +1,6 @@
{
"name": "pathkit-wasm",
- "version": "0.5.0",
+ "version": "0.5.1",
"description": "A WASM version of Skia's PathOps toolkit",
"main": "bin/pathkit.js",
"homepage": "https://github.com/google/skia/tree/master/modules/pathkit",