aklinker1/webext-core

Using @webext-core/proxy-service, the blob data transfer is empty

Closed this issue · 1 comments

Replication with examples/vanilla-indexed-db

  1. utils/todos-repo.ts
export interface Todo {
  id: string;
  title: string;
  done?: boolean;
+ blob?: Blob
}
  1. entrypoints/popup/main.ts
(async () => {
  todosRepo.createOrUpdate({
    id: '2',
    title: 'Another TODO',
+   blob: new Blob(['Blob TODO'], { type: 'text/plain' }),
  });

  const all = await todosRepo.getAll();
  console.log('All todos:', all);
})();
  1. utils/todos-repo.ts
async createOrUpdate(todo) {
+ console.log('createOrUpdate', todo);
  await (await db).put('todos', todo);
},
  1. output
{
  "id": "2",
  "title": "Another TODO",
  "blob": {} // The blob here is an empty object.
}

This proxy uses the browser messaging APIs, which doesn't support class instances, like blobs. You can only pass primitives, arrays, or objects.

Transferring blobs is only supported by the window.postMessage API, which is completely unrelated to this library.