v1.0 with SW PWA enabled
This commit is contained in:
8
frontend/node_modules/@surma/rollup-plugin-off-main-thread/.travis.yml
generated
vendored
Normal file
8
frontend/node_modules/@surma/rollup-plugin-off-main-thread/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
sudo: required
|
||||
|
||||
services:
|
||||
- docker
|
||||
|
||||
script:
|
||||
- docker build -t omt .
|
||||
- docker run --rm -v `pwd`:/usr/src omt
|
||||
1
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CODEOWNERS
generated
vendored
Normal file
1
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CODEOWNERS
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
* @surma
|
||||
27
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CONTRIBUTING
generated
vendored
Normal file
27
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CONTRIBUTING
generated
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
Want to contribute? Great! First, read this page (including the small print at the end).
|
||||
|
||||
### Before you contribute
|
||||
Before we can use your code, you must sign the
|
||||
[Google Individual Contributor License Agreement]
|
||||
(https://cla.developers.google.com/about/google-individual)
|
||||
(CLA), which you can do online. The CLA is necessary mainly because you own the
|
||||
copyright to your changes, even after your contribution becomes part of our
|
||||
codebase, so we need your permission to use and distribute your code. We also
|
||||
need to be sure of various other things—for instance that you'll tell us if you
|
||||
know that your code infringes on other people's patents. You don't have to sign
|
||||
the CLA until after you've submitted your code for review and a member has
|
||||
approved it, but you must do it before we can put your code into our codebase.
|
||||
Before you start working on a larger contribution, you should get in touch with
|
||||
us first through the issue tracker with your idea so that we can help out and
|
||||
possibly guide you. Coordinating up front makes it much easier to avoid
|
||||
frustration later on.
|
||||
|
||||
### Code reviews
|
||||
All submissions, including submissions by project members, require review. We
|
||||
use Github pull requests for this purpose.
|
||||
|
||||
### The small print
|
||||
Contributions made by corporations are covered by a different agreement than
|
||||
the one above, the
|
||||
[Software Grant and Corporate Contributor License Agreement]
|
||||
(https://cla.developers.google.com/about/google-corporate).
|
||||
11
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CONTRIBUTORS
generated
vendored
Normal file
11
frontend/node_modules/@surma/rollup-plugin-off-main-thread/CONTRIBUTORS
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
# People who have agreed to one of the CLAs and can contribute patches.
|
||||
# The AUTHORS file lists the copyright holders; this file
|
||||
# lists people. For example, Google employees are listed here
|
||||
# but not in AUTHORS, because Google holds the copyright.
|
||||
#
|
||||
# https://developers.google.com/open-source/cla/individual
|
||||
# https://developers.google.com/open-source/cla/corporate
|
||||
#
|
||||
# Names should be added to this file as:
|
||||
# Name <email address>
|
||||
Surma <surma@google.com>
|
||||
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/Dockerfile
generated
vendored
Normal file
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/Dockerfile
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
FROM selenium/node-chrome:latest
|
||||
|
||||
USER root
|
||||
|
||||
RUN apt-get update -qqy \
|
||||
&& rm -rf /var/lib/apt/lists/* /var/cache/apt/* \
|
||||
&& rm /bin/sh && ln -s /bin/bash /bin/sh \
|
||||
&& chown seluser /usr/local
|
||||
|
||||
ENV NVM_DIR /usr/local/nvm
|
||||
RUN mkdir -p $NVM_DIR \
|
||||
&& wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.35.2/install.sh | bash \
|
||||
&& source $NVM_DIR/nvm.sh \
|
||||
&& nvm install v12
|
||||
|
||||
ENV CHROME_BIN /opt/google/chrome/chrome
|
||||
ENV INSIDE_DOCKER=1
|
||||
|
||||
WORKDIR /usr/src
|
||||
ENTRYPOINT source $NVM_DIR/nvm.sh && npm i && npm test
|
||||
202
frontend/node_modules/@surma/rollup-plugin-off-main-thread/LICENSE
generated
vendored
Normal file
202
frontend/node_modules/@surma/rollup-plugin-off-main-thread/LICENSE
generated
vendored
Normal file
@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2018 Google Inc.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
97
frontend/node_modules/@surma/rollup-plugin-off-main-thread/README.md
generated
vendored
Normal file
97
frontend/node_modules/@surma/rollup-plugin-off-main-thread/README.md
generated
vendored
Normal file
@ -0,0 +1,97 @@
|
||||
# rollup-plugin-off-main-thread
|
||||
|
||||
Use Rollup with workers and ES6 modules _today_.
|
||||
|
||||
```
|
||||
$ npm install --save @surma/rollup-plugin-off-main-thread
|
||||
```
|
||||
|
||||
Workers are JavaScript’s version of threads. [Workers are important to use][when workers] as the main thread is already overloaded, especially on slower or older devices.
|
||||
|
||||
This plugin takes care of shimming module support in workers and allows you to use `new Worker()`.
|
||||
|
||||
OMT is the result of merging loadz0r and workz0r.
|
||||
|
||||
## Usage
|
||||
|
||||
I set up [a gist] to show a full setup with OMT.
|
||||
|
||||
### Config
|
||||
|
||||
```js
|
||||
// rollup.config.js
|
||||
import OMT from "@surma/rollup-plugin-off-main-thread";
|
||||
|
||||
export default {
|
||||
input: ["src/main.js"],
|
||||
output: {
|
||||
dir: "dist",
|
||||
// You _must_ use either “amd” or “esm” as your format.
|
||||
// But note that only very few browsers have native support for
|
||||
// modules in workers.
|
||||
format: "amd"
|
||||
},
|
||||
plugins: [OMT()]
|
||||
};
|
||||
```
|
||||
|
||||
### Auto bundling
|
||||
|
||||
In your project's code use a module-relative path via `new URL` to include a Worker:
|
||||
|
||||
```js
|
||||
const worker = new Worker(new URL("worker.js", import.meta.url), {
|
||||
type: "module"
|
||||
});
|
||||
```
|
||||
|
||||
This will just work.
|
||||
|
||||
If required, the plugin also supports plain literal paths:
|
||||
|
||||
```js
|
||||
const worker = new Worker("./worker.js", { type: "module" });
|
||||
```
|
||||
|
||||
However, those are less portable: in Rollup they would result in module-relative
|
||||
path, but if used directly in the browser, they'll be relative to the document
|
||||
URL instead.
|
||||
|
||||
Hence, they're deprecated and `new URL` pattern is encouraged instead for portability.
|
||||
|
||||
### Importing workers as URLs
|
||||
|
||||
If your worker constructor doesn't match `workerRegexp` (see options below), you might find it easier to import the worker as a URL. In your project's code:
|
||||
|
||||
```js
|
||||
import workerURL from "omt:./worker.js";
|
||||
import paintWorkletURL from "omt:./paint-worklet.js";
|
||||
|
||||
const worker = new Worker(workerURL, { name: "main-worker" });
|
||||
CSS.paintWorklet.addModule(paintWorkletURL);
|
||||
```
|
||||
|
||||
`./worker.js` and `./paint-worklet.js` will be added to the output as chunks.
|
||||
|
||||
## Options
|
||||
|
||||
```js
|
||||
{
|
||||
// ...
|
||||
plugins: [OMT(options)];
|
||||
}
|
||||
```
|
||||
|
||||
- `loader`: A string containing the EJS template for the amd loader. If `undefined`, OMT will use `loader.ejs`.
|
||||
- `useEval`: Use `fetch()` + `eval()` to load dependencies instead of `<script>` tags and `importScripts()`. _This is not CSP compliant, but is required if you want to use dynamic imports in ServiceWorker_.
|
||||
- `workerRegexp`: A RegExp to find `new Workers()` calls. The second capture group _must_ capture the provided file name without the quotes.
|
||||
- `amdFunctionName`: Function name to use instead of AMD’s `define`.
|
||||
- `prependLoader`: A function that determines whether the loader code should be prepended to a certain chunk. Should return true if the load is suppsoed to be prepended.
|
||||
- `urlLoaderScheme`: Scheme to use when importing workers as URLs. If `undefined`, OMT will use `"omt"`.
|
||||
|
||||
[when workers]: https://dassur.ma/things/when-workers
|
||||
[a gist]: https://gist.github.com/surma/a02db7b53eb3e7870bf539b906ff6ff6
|
||||
|
||||
---
|
||||
|
||||
License Apache-2.0
|
||||
318
frontend/node_modules/@surma/rollup-plugin-off-main-thread/index.js
generated
vendored
Normal file
318
frontend/node_modules/@surma/rollup-plugin-off-main-thread/index.js
generated
vendored
Normal file
@ -0,0 +1,318 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
const { readFileSync } = require("fs");
|
||||
const { join } = require("path");
|
||||
const ejs = require("ejs");
|
||||
const MagicString = require("magic-string");
|
||||
const json5 = require("json5");
|
||||
// See https://github.com/surma/rollup-plugin-off-main-thread/issues/49
|
||||
const matchAll = require("string.prototype.matchall");
|
||||
|
||||
const defaultOpts = {
|
||||
// A string containing the EJS template for the amd loader. If `undefined`,
|
||||
// OMT will use `loader.ejs`.
|
||||
loader: readFileSync(join(__dirname, "/loader.ejs"), "utf8"),
|
||||
// Use `fetch()` + `eval()` to load dependencies instead of `<script>` tags
|
||||
// and `importScripts()`. _This is not CSP compliant, but is required if you
|
||||
// want to use dynamic imports in ServiceWorker_.
|
||||
useEval: false,
|
||||
// Function name to use instead of AMD’s `define`.
|
||||
amdFunctionName: "define",
|
||||
// A function that determines whether the loader code should be prepended to a
|
||||
// certain chunk. Should return true if the load is supposed to be prepended.
|
||||
prependLoader: (chunk, workerFiles) =>
|
||||
chunk.isEntry || workerFiles.includes(chunk.facadeModuleId),
|
||||
// The scheme used when importing workers as a URL.
|
||||
urlLoaderScheme: "omt",
|
||||
// Silence the warning about ESM being badly supported in workers.
|
||||
silenceESMWorkerWarning: false
|
||||
};
|
||||
|
||||
// A regexp to find static `new Worker` invocations.
|
||||
// Matches `new Worker(...file part...`
|
||||
// File part matches one of:
|
||||
// - '...'
|
||||
// - "..."
|
||||
// - `import.meta.url`
|
||||
// - new URL('...', import.meta.url)
|
||||
// - new URL("...", import.meta.url)
|
||||
const workerRegexpForTransform = /(new\s+Worker\()\s*(('.*?'|".*?")|import\.meta\.url|new\s+URL\(('.*?'|".*?"),\s*import\.meta\.url\))/gs;
|
||||
|
||||
// A regexp to find static `new Worker` invocations we've rewritten during the transform phase.
|
||||
// Matches `new Worker(...file part..., ...options...`.
|
||||
// File part matches one of:
|
||||
// - new URL('...', module.uri)
|
||||
// - new URL("...", module.uri)
|
||||
const workerRegexpForOutput = /new\s+Worker\(new\s+URL\((?:'.*?'|".*?"),\s*module\.uri\)\s*(,([^)]+))/gs;
|
||||
|
||||
let longWarningAlreadyShown = false;
|
||||
|
||||
module.exports = function(opts = {}) {
|
||||
opts = Object.assign({}, defaultOpts, opts);
|
||||
|
||||
opts.loader = ejs.render(opts.loader, opts);
|
||||
|
||||
const urlLoaderPrefix = opts.urlLoaderScheme + ":";
|
||||
|
||||
let workerFiles;
|
||||
let isEsmOutput = () => { throw new Error("outputOptions hasn't been called yet") };
|
||||
return {
|
||||
name: "off-main-thread",
|
||||
|
||||
async buildStart(options) {
|
||||
workerFiles = [];
|
||||
},
|
||||
|
||||
async resolveId(id, importer) {
|
||||
if (!id.startsWith(urlLoaderPrefix)) return;
|
||||
|
||||
const path = id.slice(urlLoaderPrefix.length);
|
||||
const resolved = await this.resolve(path, importer);
|
||||
if (!resolved)
|
||||
throw Error(`Cannot find module '${path}' from '${importer}'`);
|
||||
const newId = resolved.id;
|
||||
|
||||
return urlLoaderPrefix + newId;
|
||||
},
|
||||
|
||||
load(id) {
|
||||
if (!id.startsWith(urlLoaderPrefix)) return;
|
||||
|
||||
const realId = id.slice(urlLoaderPrefix.length);
|
||||
const chunkRef = this.emitFile({ id: realId, type: "chunk" });
|
||||
return `export default import.meta.ROLLUP_FILE_URL_${chunkRef};`;
|
||||
},
|
||||
|
||||
async transform(code, id) {
|
||||
const ms = new MagicString(code);
|
||||
|
||||
const replacementPromises = [];
|
||||
|
||||
for (const match of matchAll(code, workerRegexpForTransform)) {
|
||||
let [
|
||||
fullMatch,
|
||||
partBeforeArgs,
|
||||
workerSource,
|
||||
directWorkerFile,
|
||||
workerFile,
|
||||
] = match;
|
||||
|
||||
const workerParametersEndIndex = match.index + fullMatch.length;
|
||||
const matchIndex = match.index;
|
||||
const workerParametersStartIndex = matchIndex + partBeforeArgs.length;
|
||||
|
||||
let workerIdPromise;
|
||||
if (workerSource === "import.meta.url") {
|
||||
// Turn the current file into a chunk
|
||||
workerIdPromise = Promise.resolve(id);
|
||||
} else {
|
||||
// Otherwise it's a string literal either directly or in the `new URL(...)`.
|
||||
if (directWorkerFile) {
|
||||
const fullMatchWithOpts = `${fullMatch}, …)`;
|
||||
const fullReplacement = `new Worker(new URL(${directWorkerFile}, import.meta.url), …)`;
|
||||
|
||||
if (!longWarningAlreadyShown) {
|
||||
this.warn(
|
||||
`rollup-plugin-off-main-thread:
|
||||
\`${fullMatchWithOpts}\` suggests that the Worker should be relative to the document, not the script.
|
||||
In the bundler, we don't know what the final document's URL will be, and instead assume it's a URL relative to the current module.
|
||||
This might lead to incorrect behaviour during runtime.
|
||||
If you did mean to use a URL relative to the current module, please change your code to the following form:
|
||||
\`${fullReplacement}\`
|
||||
This will become a hard error in the future.`,
|
||||
matchIndex
|
||||
);
|
||||
longWarningAlreadyShown = true;
|
||||
} else {
|
||||
this.warn(
|
||||
`rollup-plugin-off-main-thread: Treating \`${fullMatchWithOpts}\` as \`${fullReplacement}\``,
|
||||
matchIndex
|
||||
);
|
||||
}
|
||||
workerFile = directWorkerFile;
|
||||
}
|
||||
|
||||
// Cut off surrounding quotes.
|
||||
workerFile = workerFile.slice(1, -1);
|
||||
|
||||
if (!/^\.{1,2}\//.test(workerFile)) {
|
||||
let isError = false;
|
||||
if (directWorkerFile) {
|
||||
// If direct worker file, it must be in `./something` form.
|
||||
isError = true;
|
||||
} else {
|
||||
// If `new URL(...)` it can be in `new URL('something', import.meta.url)` form too,
|
||||
// so just check it's not absolute.
|
||||
if (/^(\/|https?:)/.test(workerFile)) {
|
||||
isError = true;
|
||||
} else {
|
||||
// If it does turn out to be `new URL('something', import.meta.url)` form,
|
||||
// prepend `./` so that it becomes valid module specifier.
|
||||
workerFile = `./${workerFile}`;
|
||||
}
|
||||
}
|
||||
if (isError) {
|
||||
this.warn(
|
||||
`Paths passed to the Worker constructor must be relative to the current file, i.e. start with ./ or ../ (just like dynamic import!). Ignoring "${workerFile}".`,
|
||||
matchIndex
|
||||
);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
workerIdPromise = this.resolve(workerFile, id).then(res => res.id);
|
||||
}
|
||||
|
||||
replacementPromises.push(
|
||||
(async () => {
|
||||
const resolvedWorkerFile = await workerIdPromise;
|
||||
workerFiles.push(resolvedWorkerFile);
|
||||
const chunkRefId = this.emitFile({
|
||||
id: resolvedWorkerFile,
|
||||
type: "chunk"
|
||||
});
|
||||
|
||||
ms.overwrite(
|
||||
workerParametersStartIndex,
|
||||
workerParametersEndIndex,
|
||||
`new URL(import.meta.ROLLUP_FILE_URL_${chunkRefId}, import.meta.url)`
|
||||
);
|
||||
})()
|
||||
);
|
||||
}
|
||||
|
||||
// No matches found.
|
||||
if (!replacementPromises.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Wait for all the scheduled replacements to finish.
|
||||
await Promise.all(replacementPromises);
|
||||
|
||||
return {
|
||||
code: ms.toString(),
|
||||
map: ms.generateMap({ hires: true })
|
||||
};
|
||||
},
|
||||
|
||||
resolveFileUrl(chunk) {
|
||||
return JSON.stringify(chunk.relativePath);
|
||||
},
|
||||
|
||||
outputOptions({ format }) {
|
||||
if (format === "esm" || format === "es") {
|
||||
if (!opts.silenceESMWorkerWarning) {
|
||||
this.warn(
|
||||
'Very few browsers support ES modules in Workers. If you want to your code to run in all browsers, set `output.format = "amd";`'
|
||||
);
|
||||
}
|
||||
// In ESM, we never prepend a loader.
|
||||
isEsmOutput = () => true;
|
||||
} else if (format !== "amd") {
|
||||
this.error(
|
||||
`\`output.format\` must either be "amd" or "esm", got "${format}"`
|
||||
);
|
||||
} else {
|
||||
isEsmOutput = () => false;
|
||||
}
|
||||
},
|
||||
|
||||
renderDynamicImport() {
|
||||
if (isEsmOutput()) return;
|
||||
|
||||
// In our loader, `require` simply return a promise directly.
|
||||
// This is tinier and simpler output than the Rollup's default.
|
||||
return {
|
||||
left: 'require(',
|
||||
right: ')'
|
||||
};
|
||||
},
|
||||
|
||||
resolveImportMeta(property) {
|
||||
if (isEsmOutput()) return;
|
||||
|
||||
if (property === 'url') {
|
||||
// In our loader, `module.uri` is already fully resolved
|
||||
// so we can emit something shorter than the Rollup's default.
|
||||
return `module.uri`;
|
||||
}
|
||||
},
|
||||
|
||||
renderChunk(code, chunk, outputOptions) {
|
||||
// We don’t need to do any loader processing when targeting ESM format.
|
||||
if (isEsmOutput()) return;
|
||||
|
||||
if (outputOptions.banner && outputOptions.banner.length > 0) {
|
||||
this.error(
|
||||
"OMT currently doesn’t work with `banner`. Feel free to submit a PR at https://github.com/surma/rollup-plugin-off-main-thread"
|
||||
);
|
||||
return;
|
||||
}
|
||||
const ms = new MagicString(code);
|
||||
|
||||
for (const match of matchAll(code, workerRegexpForOutput)) {
|
||||
let [fullMatch, optionsWithCommaStr, optionsStr] = match;
|
||||
let options;
|
||||
try {
|
||||
options = json5.parse(optionsStr);
|
||||
} catch (e) {
|
||||
// If we couldn't parse the options object, maybe it's something dynamic or has nested
|
||||
// parentheses or something like that. In that case, treat it as a warning
|
||||
// and not a hard error, just like we wouldn't break on unmatched regex.
|
||||
console.warn("Couldn't match options object", fullMatch, ": ", e);
|
||||
continue;
|
||||
}
|
||||
if (!("type" in options)) {
|
||||
// Nothing to do.
|
||||
continue;
|
||||
}
|
||||
delete options.type;
|
||||
const replacementEnd = match.index + fullMatch.length;
|
||||
const replacementStart = replacementEnd - optionsWithCommaStr.length;
|
||||
optionsStr = json5.stringify(options);
|
||||
optionsWithCommaStr = optionsStr === "{}" ? "" : `, ${optionsStr}`;
|
||||
ms.overwrite(
|
||||
replacementStart,
|
||||
replacementEnd,
|
||||
optionsWithCommaStr
|
||||
);
|
||||
}
|
||||
|
||||
// Mangle define() call
|
||||
ms.remove(0, "define(".length);
|
||||
// If the module does not have any dependencies, it’s technically okay
|
||||
// to skip the dependency array. But our minimal loader expects it, so
|
||||
// we add it back in.
|
||||
if (!code.startsWith("define([")) {
|
||||
ms.prepend("[],");
|
||||
}
|
||||
ms.prepend(`${opts.amdFunctionName}(`);
|
||||
|
||||
// Prepend loader if it’s an entry point or a worker file
|
||||
if (opts.prependLoader(chunk, workerFiles)) {
|
||||
ms.prepend(opts.loader);
|
||||
}
|
||||
|
||||
const newCode = ms.toString();
|
||||
const hasCodeChanged = code !== newCode;
|
||||
return {
|
||||
code: newCode,
|
||||
// Avoid generating sourcemaps if possible as it can be a very expensive operation
|
||||
map: hasCodeChanged ? ms.generateMap({ hires: true }) : null
|
||||
};
|
||||
}
|
||||
};
|
||||
};
|
||||
46
frontend/node_modules/@surma/rollup-plugin-off-main-thread/karma.conf.js
generated
vendored
Normal file
46
frontend/node_modules/@surma/rollup-plugin-off-main-thread/karma.conf.js
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
module.exports = function(config) {
|
||||
const configuration = {
|
||||
basePath: "",
|
||||
frameworks: ["mocha", "chai"],
|
||||
files: [
|
||||
{
|
||||
pattern: "tests/fixtures/**",
|
||||
included: false
|
||||
},
|
||||
{
|
||||
pattern: "tests/*.test.js"
|
||||
}
|
||||
],
|
||||
reporters: ["progress"],
|
||||
port: 9876,
|
||||
colors: true,
|
||||
logLevel: config.LOG_INFO,
|
||||
autoWatch: true,
|
||||
singleRun: true,
|
||||
concurrency: 1,
|
||||
browsers: ["Chrome", "Firefox", "Safari"],
|
||||
customLaunchers: {
|
||||
DockerChrome: {
|
||||
base: "ChromeHeadless",
|
||||
flags: ["--no-sandbox"]
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if (process.env.INSIDE_DOCKER) configuration.browsers = ["DockerChrome"];
|
||||
|
||||
config.set(configuration);
|
||||
};
|
||||
76
frontend/node_modules/@surma/rollup-plugin-off-main-thread/loader.ejs
generated
vendored
Normal file
76
frontend/node_modules/@surma/rollup-plugin-off-main-thread/loader.ejs
generated
vendored
Normal file
@ -0,0 +1,76 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// If the loader is already loaded, just stop.
|
||||
if (!self.<%- amdFunctionName %>) {
|
||||
let registry = {};
|
||||
|
||||
// Used for `eval` and `importScripts` where we can't get script URL by other means.
|
||||
// In both cases, it's safe to use a global var because those functions are synchronous.
|
||||
let nextDefineUri;
|
||||
|
||||
const singleRequire = (uri, parentUri) => {
|
||||
uri = new URL(uri + ".js", parentUri).href;
|
||||
return registry[uri] || (
|
||||
<% if (useEval) { %>
|
||||
fetch(uri)
|
||||
.then(resp => resp.text())
|
||||
.then(code => {
|
||||
nextDefineUri = uri;
|
||||
eval(code);
|
||||
})
|
||||
<% } else { %>
|
||||
new Promise(resolve => {
|
||||
if ("document" in self) {
|
||||
const script = document.createElement("script");
|
||||
script.src = uri;
|
||||
script.onload = resolve;
|
||||
document.head.appendChild(script);
|
||||
} else {
|
||||
nextDefineUri = uri;
|
||||
importScripts(uri);
|
||||
resolve();
|
||||
}
|
||||
})
|
||||
<% } %>
|
||||
.then(() => {
|
||||
let promise = registry[uri];
|
||||
if (!promise) {
|
||||
throw new Error(`Module ${uri} didn’t register its module`);
|
||||
}
|
||||
return promise;
|
||||
})
|
||||
);
|
||||
};
|
||||
|
||||
self.<%- amdFunctionName %> = (depsNames, factory) => {
|
||||
const uri = nextDefineUri || ("document" in self ? document.currentScript.src : "") || location.href;
|
||||
if (registry[uri]) {
|
||||
// Module is already loading or loaded.
|
||||
return;
|
||||
}
|
||||
let exports = {};
|
||||
const require = depUri => singleRequire(depUri, uri);
|
||||
const specialDeps = {
|
||||
module: { uri },
|
||||
exports,
|
||||
require
|
||||
};
|
||||
registry[uri] = Promise.all(depsNames.map(
|
||||
depName => specialDeps[depName] || require(depName)
|
||||
)).then(deps => {
|
||||
factory(...deps);
|
||||
return exports;
|
||||
});
|
||||
};
|
||||
}
|
||||
36
frontend/node_modules/@surma/rollup-plugin-off-main-thread/package.json
generated
vendored
Normal file
36
frontend/node_modules/@surma/rollup-plugin-off-main-thread/package.json
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"name": "@surma/rollup-plugin-off-main-thread",
|
||||
"version": "2.2.3",
|
||||
"description": "Use Rollup with workers and ES6 modules today.",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"fmt": "prettier --write 'tests/**/*.js' *.js *.md *.json",
|
||||
"test": "node ./run_tests.js"
|
||||
},
|
||||
"author": "Surma <surma@google.com>",
|
||||
"license": "Apache-2.0",
|
||||
"devDependencies": {
|
||||
"chai": "4.2.0",
|
||||
"chalk": "^2.4.2",
|
||||
"karma": "4.2.0",
|
||||
"karma-chai": "0.1.0",
|
||||
"karma-chrome-launcher": "3.0.0",
|
||||
"karma-firefox-launcher": "1.1.0",
|
||||
"karma-mocha": "1.3.0",
|
||||
"karma-safari-launcher": "1.0.0",
|
||||
"karma-safaritechpreview-launcher": "2.0.2",
|
||||
"mocha": "6.1.4",
|
||||
"prettier": "1.18.2",
|
||||
"rollup": "2.2.0"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/surma/rollup-plugin-off-main-thread"
|
||||
},
|
||||
"dependencies": {
|
||||
"ejs": "^3.1.6",
|
||||
"json5": "^2.2.0",
|
||||
"magic-string": "^0.25.0",
|
||||
"string.prototype.matchall": "^4.0.6"
|
||||
}
|
||||
}
|
||||
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/renovate.json
generated
vendored
Normal file
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/renovate.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": ["config:base"]
|
||||
}
|
||||
105
frontend/node_modules/@surma/rollup-plugin-off-main-thread/run_tests.js
generated
vendored
Normal file
105
frontend/node_modules/@surma/rollup-plugin-off-main-thread/run_tests.js
generated
vendored
Normal file
@ -0,0 +1,105 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const rollup = require("rollup");
|
||||
const path = require("path");
|
||||
const omt = require(".");
|
||||
const fs = require("fs");
|
||||
const chalk = require("chalk");
|
||||
|
||||
const karma = require("karma");
|
||||
const myKarmaConfig = require("./karma.conf.js");
|
||||
|
||||
async function fileExists(file) {
|
||||
try {
|
||||
const stat = await fs.promises.stat(file);
|
||||
return stat.isFile();
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
async function init() {
|
||||
await Promise.all(
|
||||
[
|
||||
"./tests/fixtures/simple-bundle/entry.js",
|
||||
"./tests/fixtures/import-meta/entry.js",
|
||||
"./tests/fixtures/dynamic-import/entry.js",
|
||||
"./tests/fixtures/public-path/entry.js",
|
||||
"./tests/fixtures/worker/entry.js",
|
||||
"./tests/fixtures/module-worker/entry.js",
|
||||
"./tests/fixtures/more-workers/entry.js",
|
||||
"./tests/fixtures/amd-function-name/entry.js",
|
||||
"./tests/fixtures/single-default/entry.js",
|
||||
"./tests/fixtures/import-worker-url/entry.js",
|
||||
"./tests/fixtures/import-meta-worker/entry.js",
|
||||
"./tests/fixtures/import-worker-url-custom-scheme/entry.js",
|
||||
"./tests/fixtures/assets-in-worker/entry.js",
|
||||
"./tests/fixtures/url-import-meta-worker/entry.js"
|
||||
].map(async input => {
|
||||
const pathName = path.dirname(input);
|
||||
const outputOptions = {
|
||||
dir: path.join(pathName, "build"),
|
||||
format: "amd"
|
||||
};
|
||||
let rollupConfig = {
|
||||
input,
|
||||
strictDeprecations: true,
|
||||
// Copied / adapted from default `onwarn` in Rollup CLI.
|
||||
onwarn: warning => {
|
||||
console.warn(`⚠️ ${chalk.bold(warning.message)}`);
|
||||
|
||||
if (warning.url) {
|
||||
console.warn(chalk.cyan(warning.url));
|
||||
}
|
||||
|
||||
if (warning.loc) {
|
||||
console.warn(
|
||||
`${warning.loc.file} (${warning.loc.line}:${warning.loc.column})`
|
||||
);
|
||||
}
|
||||
|
||||
if (warning.frame) {
|
||||
console.warn(chalk.dim(warning.frame));
|
||||
}
|
||||
|
||||
console.warn("");
|
||||
}
|
||||
};
|
||||
const rollupConfigPath = "./" + path.join(pathName, "rollup.config.js");
|
||||
const configPath = "./" + path.join(pathName, "config.json");
|
||||
if (await fileExists(rollupConfigPath)) {
|
||||
require(rollupConfigPath)(rollupConfig, outputOptions, omt);
|
||||
} else if (await fileExists(configPath)) {
|
||||
rollupConfig.plugins = [omt(require(configPath))];
|
||||
} else {
|
||||
rollupConfig.plugins = [omt()];
|
||||
}
|
||||
const bundle = await rollup.rollup(rollupConfig);
|
||||
await bundle.write(outputOptions);
|
||||
})
|
||||
);
|
||||
|
||||
const karmaConfig = { port: 9876 };
|
||||
myKarmaConfig({
|
||||
set(config) {
|
||||
Object.assign(karmaConfig, config);
|
||||
}
|
||||
});
|
||||
const server = new karma.Server(karmaConfig, code => {
|
||||
console.log(`Karma exited with code ${code}`);
|
||||
process.exit(code);
|
||||
});
|
||||
server.start();
|
||||
}
|
||||
init();
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/amd-function-name.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/amd-function-name.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("AMD Function Name", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads with a different AMD function name", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/amd-function-name/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/asset-in-worker.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/asset-in-worker.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Assets in workers", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("can be fetched", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "assetcontent") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/assets-in-worker/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/dynamic-import.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/dynamic-import.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Dynamic import", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/dynamic-import/build/runner.html";
|
||||
});
|
||||
});
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return 4;
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/config.json
generated
vendored
Normal file
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/config.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"amdFunctionName": "foo"
|
||||
}
|
||||
22
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/entry.js
generated
vendored
Normal file
22
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/amd-function-name/entry.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import("./a.js").then(m => {
|
||||
if (m.default() != 4) {
|
||||
return;
|
||||
}
|
||||
if (!self.foo) {
|
||||
return;
|
||||
}
|
||||
window.parent.postMessage("a", "*");
|
||||
});
|
||||
1
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/build/assets/my-asset-620b911b.bin
generated
vendored
Normal file
1
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/build/assets/my-asset-620b911b.bin
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
assetcontent
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/entry.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/entry.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const w = new Worker("./worker.js");
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
25
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/rollup.config.js
generated
vendored
Normal file
25
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/rollup.config.js
generated
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
const MARKER = "my-special-import";
|
||||
module.exports = (config, outputOptions, omt) => {
|
||||
config.plugins = [
|
||||
omt(),
|
||||
{
|
||||
resolveId(id) {
|
||||
if (id !== MARKER) {
|
||||
return;
|
||||
}
|
||||
return id;
|
||||
},
|
||||
load(id) {
|
||||
if (id !== MARKER) {
|
||||
return;
|
||||
}
|
||||
const referenceId = this.emitFile({
|
||||
type: "asset",
|
||||
name: "my-asset.bin",
|
||||
source: "assetcontent"
|
||||
});
|
||||
return `export default import.meta.ROLLUP_FILE_URL_${referenceId}`;
|
||||
}
|
||||
}
|
||||
];
|
||||
};
|
||||
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/worker.js
generated
vendored
Normal file
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/assets-in-worker/worker.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import url from "my-special-import";
|
||||
|
||||
fetch(url)
|
||||
.then(resp => resp.text())
|
||||
.then(text => postMessage(text));
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
window.parent.postMessage("a", "*");
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/entry.js
generated
vendored
Normal file
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/dynamic-import/entry.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import("./a.js").then(m => m.default());
|
||||
0
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/empty.js
generated
vendored
Normal file
0
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/empty.js
generated
vendored
Normal file
12
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/a.js
generated
vendored
Normal file
12
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/a.js
generated
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
let worker;
|
||||
|
||||
if (self.document) {
|
||||
worker = new Worker(import.meta.url);
|
||||
}
|
||||
if (self.postMessage) {
|
||||
setTimeout(() => {
|
||||
postMessage("a");
|
||||
}, 500);
|
||||
}
|
||||
|
||||
export { worker };
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2020 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
22
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/entry.js
generated
vendored
Normal file
22
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta-worker/entry.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import { worker } from "./a.js";
|
||||
if (worker) {
|
||||
worker.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
}
|
||||
// This should not get bundled into the worker module
|
||||
if (self.postMessage) {
|
||||
postMessage("xxx");
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
window.parent.postMessage(import.meta.url, "*");
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/entry.js
generated
vendored
Normal file
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-meta/entry.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import("./a.js").then(m => m.default());
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
self.postMessage("a");
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/b.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/b.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return 1;
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2020 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/config.json
generated
vendored
Normal file
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/config.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"urlLoaderScheme": "fancy-custom-scheme"
|
||||
}
|
||||
21
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/entry.js
generated
vendored
Normal file
21
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/entry.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import workerURL from "fancy-custom-scheme:./worker.js";
|
||||
|
||||
// Set this, so it can be picked up in the test.
|
||||
self.workerURL = workerURL;
|
||||
|
||||
const w = new Worker(workerURL);
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/worker.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url-custom-scheme/worker.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
|
||||
a();
|
||||
import("./b.js");
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
self.postMessage("a");
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/b.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/b.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return 1;
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2020 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
21
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/entry.js
generated
vendored
Normal file
21
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/entry.js
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
import workerURL from "omt:./worker.js";
|
||||
|
||||
// Set this, so it can be picked up in the test.
|
||||
self.workerURL = workerURL;
|
||||
|
||||
const w = new Worker(workerURL);
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/worker.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/import-worker-url/worker.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
|
||||
a();
|
||||
import("./b.js");
|
||||
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/a.js
generated
vendored
Normal file
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/a.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default async function(f) {
|
||||
self.postMessage(f());
|
||||
}
|
||||
|
||||
export function someValue() {
|
||||
return self.String("a");
|
||||
}
|
||||
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/b.js
generated
vendored
Normal file
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/b.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// Import for side-effects (of which there are none)
|
||||
// to make sure that a.js gets its own chunk.
|
||||
import {someValue} from "./a.js";
|
||||
|
||||
export default function() {
|
||||
return someValue();
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js" type="module"></script>
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/entry.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/entry.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
const w = new Worker("./worker.js", { type: "module" });
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
4
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/rollup.config.js
generated
vendored
Normal file
4
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/rollup.config.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
module.exports = (config, outputOptions, omt) => {
|
||||
outputOptions.format = "esm";
|
||||
config.plugins = [omt()];
|
||||
};
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/worker.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/module-worker/worker.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
import("./b.js").then(({default: f}) => {
|
||||
a(f);
|
||||
})
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
self.postMessage("a");
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/b.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/b.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
self.postMessage("b");
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
34
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/entry.js
generated
vendored
Normal file
34
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/entry.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
async function run() {
|
||||
await new Promise(resolve => {
|
||||
const w = new Worker("./worker_a.js");
|
||||
w.addEventListener("message", ev => {
|
||||
if (ev.data === "a") {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
await new Promise(resolve => {
|
||||
const w = new Worker("./worker_b.js");
|
||||
w.addEventListener("message", ev => {
|
||||
if (ev.data === "b") {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
window.parent.postMessage("a", "*");
|
||||
}
|
||||
|
||||
run();
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/worker_a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/worker_a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
|
||||
a();
|
||||
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/worker_b.js
generated
vendored
Normal file
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/more-workers/worker_b.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
async function run() {
|
||||
const { default: b } = await import("./b.js");
|
||||
b();
|
||||
}
|
||||
run();
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
window.parent.postMessage("a", "*");
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/config.json
generated
vendored
Normal file
3
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/config.json
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"publicPath": "/base/tests/fixtures/public-path/build"
|
||||
}
|
||||
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/entry.js
generated
vendored
Normal file
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/public-path/entry.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import("./a.js").then(m => m.default());
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/a.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/a.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
window.parent.postMessage("a", "*");
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/entry.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/simple-bundle/entry.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import A from "./a.js";
|
||||
|
||||
A();
|
||||
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/a.js
generated
vendored
Normal file
14
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/a.js
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default 4;
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/entry.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/single-default/entry.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import A from "./a.js";
|
||||
|
||||
window.parent.postMessage(A, "*");
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/a.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/a.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default async function() {
|
||||
const { default: f } = await import("./b.js");
|
||||
self.postMessage(f());
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/b.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/b.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return "a";
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/entry.js
generated
vendored
Normal file
20
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/entry.js
generated
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// The type module should get removed for AMD format!
|
||||
const w = new Worker(new URL("worker.js", import.meta.url), {
|
||||
type: "module"
|
||||
});
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/worker.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/url-import-meta-worker/worker.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
|
||||
a();
|
||||
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/a.js
generated
vendored
Normal file
17
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/a.js
generated
vendored
Normal file
@ -0,0 +1,17 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default async function() {
|
||||
const { default: f } = await import("./b.js");
|
||||
self.postMessage(f());
|
||||
}
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/b.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/b.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
export default function() {
|
||||
return "a";
|
||||
}
|
||||
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/build/runner.html
generated
vendored
Normal file
15
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/build/runner.html
generated
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
<!--
|
||||
Copyright 2018 Google Inc. All Rights Reserved.
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!doctype html>
|
||||
<script src="entry.js"></script>
|
||||
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/entry.js
generated
vendored
Normal file
18
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/entry.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
// The type module should get removed for AMD format!
|
||||
const w = new Worker("./worker.js", { type: "module" });
|
||||
w.addEventListener("message", ev => {
|
||||
window.parent.postMessage(ev.data, "*");
|
||||
});
|
||||
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/worker.js
generated
vendored
Normal file
16
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/fixtures/worker/worker.js
generated
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import a from "./a.js";
|
||||
|
||||
a();
|
||||
37
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-meta-worker.test.js
generated
vendored
Normal file
37
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-meta-worker.test.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("omt: use import.meta.url in Worker constructor", function() {
|
||||
const runner = "/base/tests/fixtures/import-meta-worker/build/runner.html";
|
||||
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads itself as a module", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
} else {
|
||||
done(`Unexpected message! ${ev.data}`);
|
||||
}
|
||||
});
|
||||
this.ifr.src = runner;
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-meta.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-meta.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("import.meta", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (/^https?:\/\/.+\.js$/.test(ev.data)) {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/import-meta/build/runner.html";
|
||||
});
|
||||
});
|
||||
42
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-worker-url-custom-scheme.test.js
generated
vendored
Normal file
42
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-worker-url-custom-scheme.test.js
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("omt: URL import with custom scheme", function() {
|
||||
const runner =
|
||||
"/base/tests/fixtures/import-worker-url-custom-scheme/build/runner.html";
|
||||
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("imports as string", async function() {
|
||||
this.ifr.src = runner;
|
||||
await new Promise(resolve => this.ifr.addEventListener("load", resolve));
|
||||
assert.typeOf(this.ifr.contentWindow.workerURL, "string");
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = runner;
|
||||
});
|
||||
});
|
||||
41
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-worker-url.test.js
generated
vendored
Normal file
41
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/import-worker-url.test.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Copyright 2020 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("omt: URL import", function() {
|
||||
const runner = "/base/tests/fixtures/import-worker-url/build/runner.html";
|
||||
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("imports as string", async function() {
|
||||
this.ifr.src = runner;
|
||||
await new Promise(resolve => this.ifr.addEventListener("load", resolve));
|
||||
assert.typeOf(this.ifr.contentWindow.workerURL, "string");
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = runner;
|
||||
});
|
||||
});
|
||||
47
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/module-worker.test.js
generated
vendored
Normal file
47
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/module-worker.test.js
generated
vendored
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Module Worker", function() {
|
||||
const blob = new Blob([""], { type: "text/javascript" });
|
||||
const url = URL.createObjectURL(blob);
|
||||
let supportsModuleWorker = false;
|
||||
const options = {
|
||||
get type() {
|
||||
supportsModuleWorker = true;
|
||||
}
|
||||
};
|
||||
new Worker(url, options).terminate();
|
||||
URL.revokeObjectURL(url);
|
||||
|
||||
beforeEach(function() {
|
||||
if (!supportsModuleWorker) {
|
||||
return this.skip();
|
||||
}
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("work", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/module-worker/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/more-workers.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/more-workers.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Worker", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("can load multiple workers", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/more-workers/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/public-path.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/public-path.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Public Path", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/public-path/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/simple-bundle.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/simple-bundle.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Simple bundle", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/simple-bundle/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/single-default.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/single-default.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Single default const export", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === 4) {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/single-default/build/runner.html";
|
||||
});
|
||||
});
|
||||
34
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/url-import-meta-worker.test.js
generated
vendored
Normal file
34
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/url-import-meta-worker.test.js
generated
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Worker", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads module-relative worker paths", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src =
|
||||
"/base/tests/fixtures/url-import-meta-worker/build/runner.html";
|
||||
});
|
||||
});
|
||||
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/worker.test.js
generated
vendored
Normal file
33
frontend/node_modules/@surma/rollup-plugin-off-main-thread/tests/worker.test.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Copyright 2018 Google Inc. All Rights Reserved.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
describe("Worker", function() {
|
||||
beforeEach(function() {
|
||||
this.ifr = document.createElement("iframe");
|
||||
document.body.append(this.ifr);
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
this.ifr.remove();
|
||||
});
|
||||
|
||||
it("loads transpiled modules", function(done) {
|
||||
window.addEventListener("message", function l(ev) {
|
||||
if (ev.data === "a") {
|
||||
window.removeEventListener("message", l);
|
||||
done();
|
||||
}
|
||||
});
|
||||
this.ifr.src = "/base/tests/fixtures/worker/build/runner.html";
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user