All Projects → squidfunk → iframe-worker

squidfunk / iframe-worker

Licence: MIT license
A tiny WebWorker polyfill for the file:// protocol

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to iframe-worker

data-transport
A generic and responsible communication transporter(iframe/Broadcast/Web Worker/Service Worker/Shared Worker/WebRTC/Electron, etc.)
Stars: ✭ 27 (+17.39%)
Mutual labels:  iframe, webworker
react-use-comlink
Three ways to use Comlink web workers through React Hooks (and in a typesafe manner).
Stars: ✭ 39 (+69.57%)
Mutual labels:  webworker
rx-postmessenger
Minimal RxJS adapter for the window.postMessage API for request-response streams and notification streams across frame windows.
Stars: ✭ 27 (+17.39%)
Mutual labels:  iframe
react-native-drawer-layout-polyfill
A polyfill for React Natives DrawerLayoutAndroid
Stars: ✭ 48 (+108.7%)
Mutual labels:  polyfill
sanitizer-polyfill
rewrite constructor arguments, call DOMPurify, profit
Stars: ✭ 46 (+100%)
Mutual labels:  polyfill
PostEvent
A Cross-Domain Event Handler javascript library. Pure Vanilla JS, no dependencies.
Stars: ✭ 14 (-39.13%)
Mutual labels:  iframe
react-responsive-embed
⚛️ Embed iframes responsively
Stars: ✭ 39 (+69.57%)
Mutual labels:  iframe
fetch
A fetch API polyfill for React Native with text streaming support.
Stars: ✭ 27 (+17.39%)
Mutual labels:  polyfill
Object.getOwnPropertyDescriptors
Spec-compliant shim for `Object.getOwnPropertyDescriptors` that works in ES5.
Stars: ✭ 19 (-17.39%)
Mutual labels:  polyfill
cardboard-vr-display
A JavaScript implementation of a WebVR 1.1 VRDisplay
Stars: ✭ 84 (+265.22%)
Mutual labels:  polyfill
deno-fetch-event-adapter
Dispatches global fetch events using Deno's native http server.
Stars: ✭ 18 (-21.74%)
Mutual labels:  polyfill
iframe-communication
Basic two way iframe communication
Stars: ✭ 88 (+282.61%)
Mutual labels:  iframe
noita-tools
A collection of tools for Nolla's Noita that help get insight into seeds and find ones with special constraints.
Stars: ✭ 22 (-4.35%)
Mutual labels:  webworker
seamless-scroll-polyfill
Scroll Behavior polyfill
Stars: ✭ 134 (+482.61%)
Mutual labels:  polyfill
Promise.allSettled
ES Proposal spec-compliant shim for Promise.allSettled
Stars: ✭ 93 (+304.35%)
Mutual labels:  polyfill
array-includes
Array.prototype.includes spec-compliant polyfill
Stars: ✭ 42 (+82.61%)
Mutual labels:  polyfill
ember-on-modifier
Implements the `{{on eventName this.someAction}}` element modifier from https://github.com/emberjs/rfcs/blob/master/text/0471-on-modifier.md
Stars: ✭ 37 (+60.87%)
Mutual labels:  polyfill
Boundary
Boundary is a CSS+Javascript library for Chrome extension developers to easily create HTML elements that won’t affect or be affected by the current webpage’s CSS. Strongly recommended if you are considering adding a sticker, a sidebar or any overlay box using content script.
Stars: ✭ 59 (+156.52%)
Mutual labels:  iframe
oembed
A simple plugin to extract media information from websites, like youtube videos, twitter statuses or blog articles.
Stars: ✭ 34 (+47.83%)
Mutual labels:  iframe
parcel-plugin-goodie-bag
provides the Promise and fetch goodies needed for IE(11) support w/ parcel bundle loading
Stars: ✭ 15 (-34.78%)
Mutual labels:  polyfill

Github Action Codecov Gitter Bundlephobia npm

iframe-worker

A tiny WebWorker polyfill for the file:// protocol in less than 900b

Like pseudo-worker but using an iframe instead of XMLHTTPRequest. This polyfill should be mostly spec-compliant and supports importScripts. It should pretty much be a drop-in replacement, at least for modern browsers which include a constructable EventTarget and Promise._

Installation

npm install iframe-worker

Usage

You can use the polyfill from unpkg.com (recommended):

<script src="https://unpkg.com/iframe-worker/polyfill"></script>

... or bundle the polyfill with your application:

import "iframe-worker/polyfill"

... or use IFrameWorker programmatically:

import { IFrameWorker } from "iframe-worker"

The polyfill will only mount if the document is served via file://.

Caveats

In a WebWorker script, importScripts is a synchronous operation, as it will block the thread until the script was fully loaded and evaluated. This is not supported in an iframe. For this reason, the polyfill for importScripts included with this library will return a Promise, chaining all passed URLs into a sequence, making it awaitable.

Since awaiting anything else than a Promise will wrap the awaited thing into a Promise, calls to importScripts should practically behave the same way for all protocols other than file://. Thus, if you want to make sure that your WebWorker works for all protocols, always await all calls to importScripts.

License

MIT License

Copyright (c) 2020-2022 Martin Donath

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].