Skip to content

Instantly share code, notes, and snippets.

@petamoriken
Last active September 27, 2021 01:52
Show Gist options
  • Save petamoriken/3802602b8e93d89e5b4c21e36683cadb to your computer and use it in GitHub Desktop.
Save petamoriken/3802602b8e93d89e5b4c21e36683cadb to your computer and use it in GitHub Desktop.
import idl from "@webref/idl";
const serializables = [];
const transferables = [];
const all = await idl.parseAll();
for (const file of Object.values(all)) {
for (const obj of file) {
if (obj.type !== "interface") {
continue;
}
let name = obj.name;
let isSerializable = false;
let isTransferable = false;
for (const attr of obj.extAttrs) {
switch (attr.name) {
case "LegacyNamespace":
name = `${attr.rhs.value}.${obj.name}`;
break;
case "Serializable":
isSerializable = true;
break;
case "Transferable":
isTransferable = true;
break;
}
}
/** @see https://webassembly.github.io/spec/web-api/index.html#serialization */
if (name === "WebAssembly.Module") {
isSerializable = true;
}
if (isSerializable) {
serializables.push(name);
}
if (isTransferable) {
transferables.push(name);
}
}
}
console.log("## Serializable\n");
for (const name of serializables) {
console.log(`* \`${name}\``);
}
console.log("");
console.log("## Transferable\n");
for (const name of transferables) {
console.log(`* \`${name}\``);
}
@petamoriken
Copy link
Author

petamoriken commented Sep 20, 2021

Serializable

  • Blob
  • File
  • FileList
  • CryptoKey
  • DOMException
  • FileSystemHandle
  • FileSystemFileHandle
  • FileSystemDirectoryHandle
  • DOMPointReadOnly
  • DOMPoint
  • DOMRectReadOnly
  • DOMRect
  • DOMQuad
  • DOMMatrixReadOnly
  • DOMMatrix
  • ImageData
  • ImageBitmap
  • WebAssembly.Module
  • AudioData
  • VideoFrame
  • GPUCompilationMessage
  • GPUCompilationInfo
  • RTCCertificate

Transferable

  • OffscreenCanvas
  • ImageBitmap
  • MessagePort
  • ReadableStream
  • WritableStream
  • TransformStream
  • AudioData
  • VideoFrame

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment