diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8d3f1a30..d4a14b3f 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,6 +1,6 @@
# Local Development
-Welcome 🎉!! If you've found a bug, or have an idea to add a feature we'd love to hear from you. It may save time to first ping the group on [Partytown's Discord channel](https://discord.gg/bNVSQmPzqy) to talk through any ideas or any issues that may be a bug.
+Welcome 🎉!! If you've found a bug, or have an idea to add a feature we'd love to hear from you. It may save time to first ping the group on [Partytown's Discord channel](https://discord.gg/aHKdpdWv7a) to talk through any ideas or any issues that may be a bug.
## Installation
diff --git a/docs/configuration.md b/docs/configuration.md
index b83a0867..a12288f9 100644
--- a/docs/configuration.md
+++ b/docs/configuration.md
@@ -7,11 +7,12 @@ Partytown does not require a config for it to work, however a config can be set
| Config | Description |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `debug` | When `true`, Partytown scripts are not inlined and not minified. See the [Debugging](/debugging) docs on how to enable more logging. |
-| `forward` | An array of strings representing function calls on the main thread to forward to the web worker. See [Forwarding Events and Triggers](/forwarding-events) for more info. |
+| `forward` | An array of strings representing function calls on the main thread to forward to the web worker. See [Forwarding Events and Triggers](/forwarding-events) for more info. |
| `lib` | Path where the Partytown library can be found your server. Note that the path must both start and end with a `/` character, and the files must be hosted from the same origin as the webpage. Default is `/~partytown/` |
| `loadScriptsOnMainThread` | An array of strings or regular expressions (RegExp) used to filter out which script are executed via Partytown and the main thread. An example is as follows: `loadScriptsOnMainThread: ["https://test.com/analytics.js", "inline-script-id", /regex-matched-script\.js/]`.|
| `resolveUrl` | Hook that is called to resolve URLs which can be used to modify URLs. The hook uses the API: `resolveUrl(url: URL, location: URL, method: string)`. See the [Proxying Requests](/proxying-requests) for more information. |
| `nonce` | The nonce property may be set on script elements created by Partytown. This should be set only when dealing with content security policies and when the use of `unsafe-inline` is disabled (using `nonce-*` instead). |
+| `fallbackTimeout` | A timeout in ms until Partytown initialization is considered as failed & fallbacks to the regular execution in main thread. Default is 9999 |
## Vanilla Config
diff --git a/docs/nextjs.md b/docs/nextjs.md
index 4dc5fa76..21b52115 100644
--- a/docs/nextjs.md
+++ b/docs/nextjs.md
@@ -8,6 +8,8 @@ The Next.js setup is largely the same as the [React integration guide](/react),
The Next.js `` component provides an experimental `worker` strategy, which uses Partytown under-the-hood. Please see the Next.js [Script documentation](https://nextjs.org/docs/api-reference/next/script#worker) for more information.
+> Note: The `worker` strategy is currently unsupported with the Next.js 13+ `app` directory.
+
---
> Below are the instructions if you are not using the experimental [Worker Strategy](#worker-strategy).
diff --git a/docs/sveltekit.md b/docs/sveltekit.md
index e7fd4cf3..9a28494f 100644
--- a/docs/sveltekit.md
+++ b/docs/sveltekit.md
@@ -73,12 +73,12 @@ Putting it together with the previous changes, our `+layout.svelte` looks like:
{@html ''}
-
+
```
diff --git a/package.json b/package.json
index 8e822df2..97d0b91b 100644
--- a/package.json
+++ b/package.json
@@ -88,7 +88,7 @@
},
"devDependencies": {
"@microsoft/api-extractor": "^7.19.5",
- "@playwright/test": "^1.17.1",
+ "@playwright/test": "^1.48.2",
"@rollup/plugin-terser": "^0.4.3",
"@types/fs-extra": "^11.0.2",
"@types/node": "^18.17.15",
@@ -98,12 +98,12 @@
"fs-extra": "^11.1.1",
"gzip-size": "^6.0.0",
"np": "^7.6.1",
- "playwright": "^1.17.2",
+ "playwright": "^1.48.2",
"prettier": "^2.6.0",
"rollup": "^3.29.1",
"tslib": "^2.3.1",
"tsm": "^2.2.1",
- "typescript": "^4.6.2",
+ "typescript": "^5.6.3",
"uvu": "^0.5.3"
},
"prettier": {
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 61f2b340..e514f319 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -12,8 +12,8 @@ importers:
specifier: ^7.19.5
version: 7.38.0(@types/node@18.18.4)
'@playwright/test':
- specifier: ^1.17.1
- version: 1.39.0
+ specifier: ^1.48.2
+ version: 1.48.2
'@rollup/plugin-terser':
specifier: ^0.4.3
version: 0.4.4(rollup@3.29.4)
@@ -42,8 +42,8 @@ importers:
specifier: ^7.6.1
version: 7.7.0
playwright:
- specifier: ^1.17.2
- version: 1.39.0
+ specifier: ^1.48.2
+ version: 1.48.2
prettier:
specifier: ^2.6.0
version: 2.8.8
@@ -57,8 +57,8 @@ importers:
specifier: ^2.2.1
version: 2.3.0
typescript:
- specifier: ^4.6.2
- version: 4.9.5
+ specifier: ^5.6.3
+ version: 5.6.3
uvu:
specifier: ^0.5.3
version: 0.5.6
@@ -139,9 +139,9 @@ packages:
resolution: {integrity: sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==}
engines: {node: '>= 8'}
- '@playwright/test@1.39.0':
- resolution: {integrity: sha512-3u1iFqgzl7zr004bGPYiN/5EZpRUSFddQBra8Rqll5N0/vfpqlP9I9EXqAoGacuAbX6c9Ulg/Cjqglp5VkK6UQ==}
- engines: {node: '>=16'}
+ '@playwright/test@1.48.2':
+ resolution: {integrity: sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw==}
+ engines: {node: '>=18'}
hasBin: true
'@rollup/plugin-terser@0.4.4':
@@ -1422,14 +1422,14 @@ packages:
resolution: {integrity: sha512-NPE8TDbzl/3YQYY7CSS228s3g2ollTFnc+Qi3tqmqJp9Vg2ovUpixcJEo2HJScN2Ez+kEaal6y70c0ehqJBJeA==}
engines: {node: '>=10'}
- playwright-core@1.39.0:
- resolution: {integrity: sha512-+k4pdZgs1qiM+OUkSjx96YiKsXsmb59evFoqv8SKO067qBA+Z2s/dCzJij/ZhdQcs2zlTAgRKfeiiLm8PQ2qvw==}
- engines: {node: '>=16'}
+ playwright-core@1.48.2:
+ resolution: {integrity: sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA==}
+ engines: {node: '>=18'}
hasBin: true
- playwright@1.39.0:
- resolution: {integrity: sha512-naE5QT11uC/Oiq0BwZ50gDmy8c8WLPRTEWuSSFVG2egBka/1qMoSqYQcROMT9zLwJ86oPofcTH2jBY/5wWOgIw==}
- engines: {node: '>=16'}
+ playwright@1.48.2:
+ resolution: {integrity: sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ==}
+ engines: {node: '>=18'}
hasBin: true
prepend-http@2.0.0:
@@ -1798,16 +1798,16 @@ packages:
typedarray-to-buffer@3.1.5:
resolution: {integrity: sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==}
- typescript@4.9.5:
- resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==}
- engines: {node: '>=4.2.0'}
- hasBin: true
-
typescript@5.0.4:
resolution: {integrity: sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==}
engines: {node: '>=12.20'}
hasBin: true
+ typescript@5.6.3:
+ resolution: {integrity: sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==}
+ engines: {node: '>=14.17'}
+ hasBin: true
+
unique-string@2.0.0:
resolution: {integrity: sha512-uNaeirEPvpZWSgzwsPGtU2zVSTrn/8L5q/IexZmH0eH6SA73CmAA5U4GwORTxQAZs95TAXLNqeLoPPNO5gZfWg==}
engines: {node: '>=8'}
@@ -2002,20 +2002,20 @@ snapshots:
'@nodelib/fs.scandir': 2.1.5
fastq: 1.15.0
- '@playwright/test@1.39.0':
+ '@playwright/test@1.48.2':
dependencies:
- playwright: 1.39.0
+ playwright: 1.48.2
'@rollup/plugin-terser@0.4.4(rollup@3.29.4)':
dependencies:
- rollup: 3.29.4
serialize-javascript: 6.0.1
smob: 1.4.1
terser: 5.21.0
+ optionalDependencies:
+ rollup: 3.29.4
'@rushstack/node-core-library@3.61.0(@types/node@18.18.4)':
dependencies:
- '@types/node': 18.18.4
colors: 1.2.5
fs-extra: 7.0.1
import-lazy: 4.0.0
@@ -2023,6 +2023,8 @@ snapshots:
resolve: 1.22.8
semver: 7.5.4
z-schema: 5.0.5
+ optionalDependencies:
+ '@types/node': 18.18.4
'@rushstack/rig-package@0.5.1':
dependencies:
@@ -2039,6 +2041,7 @@ snapshots:
'@samverschueren/stream-to-observable@0.3.1(rxjs@6.6.7)':
dependencies:
any-observable: 0.3.0(rxjs@6.6.7)
+ optionalDependencies:
rxjs: 6.6.7
transitivePeerDependencies:
- zenObservable
@@ -2146,11 +2149,11 @@ snapshots:
color-convert: 2.0.1
any-observable@0.3.0(rxjs@6.6.7):
- dependencies:
+ optionalDependencies:
rxjs: 6.6.7
any-observable@0.5.1(rxjs@6.6.7):
- dependencies:
+ optionalDependencies:
rxjs: 6.6.7
argparse@1.0.10:
@@ -3266,11 +3269,11 @@ snapshots:
dependencies:
find-up: 5.0.0
- playwright-core@1.39.0: {}
+ playwright-core@1.48.2: {}
- playwright@1.39.0:
+ playwright@1.48.2:
dependencies:
- playwright-core: 1.39.0
+ playwright-core: 1.48.2
optionalDependencies:
fsevents: 2.3.2
@@ -3592,10 +3595,10 @@ snapshots:
dependencies:
is-typedarray: 1.0.0
- typescript@4.9.5: {}
-
typescript@5.0.4: {}
+ typescript@5.6.3: {}
+
unique-string@2.0.0:
dependencies:
crypto-random-string: 2.0.0
diff --git a/scripts/build-atomics.ts b/scripts/build-atomics.ts
index 9130dbfc..e1e19cb4 100644
--- a/scripts/build-atomics.ts
+++ b/scripts/build-atomics.ts
@@ -1,6 +1,6 @@
import type { RollupOptions } from 'rollup';
import {
- BuildOptions,
+ type BuildOptions,
fileSize,
jsBannerPlugin,
syncCommunicationModulesPlugin,
diff --git a/scripts/build-integration.ts b/scripts/build-integration.ts
index f48b2902..d26a3f03 100644
--- a/scripts/build-integration.ts
+++ b/scripts/build-integration.ts
@@ -1,4 +1,4 @@
-import { BuildOptions, submodulePackageJson } from './utils.js';
+import { type BuildOptions, submodulePackageJson } from './utils.js';
import { join } from 'node:path';
import type { OutputOptions, RollupOptions } from 'rollup';
import fsExtra from 'fs-extra';
diff --git a/scripts/build-main-snippet.ts b/scripts/build-main-snippet.ts
index c65cbf7c..f952fbdc 100644
--- a/scripts/build-main-snippet.ts
+++ b/scripts/build-main-snippet.ts
@@ -1,4 +1,4 @@
-import { BuildOptions, fileSize, jsBannerPlugin, versionPlugin } from './utils.js';
+import { type BuildOptions, fileSize, jsBannerPlugin, versionPlugin } from './utils.js';
import { join } from 'node:path';
import { minifyPlugin } from './minify.js';
import type { OutputOptions, Plugin, RollupOptions } from 'rollup';
diff --git a/scripts/build-media-implementations.ts b/scripts/build-media-implementations.ts
index ba3426e1..f946f31a 100644
--- a/scripts/build-media-implementations.ts
+++ b/scripts/build-media-implementations.ts
@@ -1,5 +1,5 @@
import type { OutputOptions, RollupOptions } from 'rollup';
-import { BuildOptions, fileSize, jsBannerPlugin, versionPlugin, watchDir } from './utils.js';
+import { type BuildOptions, fileSize, jsBannerPlugin, versionPlugin, watchDir } from './utils.js';
import { join } from 'node:path';
import { minifyPlugin } from './minify.js';
diff --git a/scripts/build-react.ts b/scripts/build-react.ts
index 7a50ffdb..de565767 100644
--- a/scripts/build-react.ts
+++ b/scripts/build-react.ts
@@ -1,4 +1,4 @@
-import { BuildOptions, submodulePackageJson, submodulePath } from './utils.js';
+import { type BuildOptions, submodulePackageJson, submodulePath } from './utils.js';
import { join } from 'node:path';
import type { RollupOptions } from 'rollup';
diff --git a/scripts/build-service-worker.ts b/scripts/build-service-worker.ts
index 13a3af8f..232a71bc 100644
--- a/scripts/build-service-worker.ts
+++ b/scripts/build-service-worker.ts
@@ -1,9 +1,9 @@
-import { OutputOptions, Plugin, rollup, RollupOptions } from 'rollup';
+import { type OutputOptions, type Plugin, rollup, type RollupOptions } from 'rollup';
import {
- BuildOptions,
+ type BuildOptions,
fileSize,
jsBannerPlugin,
- MessageType,
+ type MessageType,
onwarn,
syncCommunicationModulesPlugin,
versionPlugin,
diff --git a/scripts/build-services.ts b/scripts/build-services.ts
index e641dbfe..eb7de1f4 100644
--- a/scripts/build-services.ts
+++ b/scripts/build-services.ts
@@ -1,4 +1,4 @@
-import { BuildOptions, submodulePackageJson } from './utils.js';
+import { type BuildOptions, submodulePackageJson } from './utils.js';
import { join } from 'node:path';
import type { OutputOptions, RollupOptions } from 'rollup';
diff --git a/scripts/build-utils.ts b/scripts/build-utils.ts
index f7c274e5..c3b70342 100644
--- a/scripts/build-utils.ts
+++ b/scripts/build-utils.ts
@@ -1,4 +1,4 @@
-import { BuildOptions, submodulePackageJson } from './utils.js';
+import { type BuildOptions, submodulePackageJson } from './utils.js';
import { join } from 'node:path';
import type { RollupOptions } from 'rollup';
diff --git a/scripts/build-web-worker.ts b/scripts/build-web-worker.ts
index 0e2cb1aa..76a8df22 100644
--- a/scripts/build-web-worker.ts
+++ b/scripts/build-web-worker.ts
@@ -1,8 +1,8 @@
-import { OutputOptions, Plugin, rollup } from 'rollup';
+import { type OutputOptions, type Plugin, rollup } from 'rollup';
import {
- BuildOptions,
+ type BuildOptions,
getJsBanner,
- MessageType,
+ type MessageType,
onwarn,
syncCommunicationModulesPlugin,
versionPlugin,
diff --git a/scripts/minify.ts b/scripts/minify.ts
index 58bddaf1..ff25b02b 100644
--- a/scripts/minify.ts
+++ b/scripts/minify.ts
@@ -1,4 +1,4 @@
-import terser, { Options } from '@rollup/plugin-terser';
+import terser, { type Options } from '@rollup/plugin-terser';
import type { Plugin } from 'rollup';
import type { BuildOptions } from './utils';
diff --git a/src/integration/api.md b/src/integration/api.md
index 9ffe0f06..21dfd32a 100644
--- a/src/integration/api.md
+++ b/src/integration/api.md
@@ -20,6 +20,7 @@ export interface PartytownConfig {
// (undocumented)
apply?: ApplyHook;
debug?: boolean;
+ fallbackTimeout?: number;
forward?: PartytownForwardProperty[];
// (undocumented)
get?: GetHook;
diff --git a/src/lib/atomics/sync-create-messenger-atomics.ts b/src/lib/atomics/sync-create-messenger-atomics.ts
index 405885e9..513bc155 100644
--- a/src/lib/atomics/sync-create-messenger-atomics.ts
+++ b/src/lib/atomics/sync-create-messenger-atomics.ts
@@ -1,8 +1,8 @@
import {
- MainAccessRequest,
- MessageFromWorkerToSandbox,
- Messenger,
- PartytownWebWorker,
+ type MainAccessRequest,
+ type MessageFromWorkerToSandbox,
+ type Messenger,
+ type PartytownWebWorker,
WorkerMessageType,
} from '../types';
import { onMessageFromWebWorker } from '../sandbox/on-messenge-from-worker';
diff --git a/src/lib/atomics/sync-send-message-to-main-atomics.ts b/src/lib/atomics/sync-send-message-to-main-atomics.ts
index 7b90f2ae..f9d6e7ef 100644
--- a/src/lib/atomics/sync-send-message-to-main-atomics.ts
+++ b/src/lib/atomics/sync-send-message-to-main-atomics.ts
@@ -1,7 +1,7 @@
import {
- MainAccessRequest,
- MainAccessResponse,
- WebWorkerContext,
+ type MainAccessRequest,
+ type MainAccessResponse,
+ type WebWorkerContext,
WorkerMessageType,
} from '../types';
diff --git a/src/lib/log.ts b/src/lib/log.ts
index bcf1f31c..0c16c3f8 100644
--- a/src/lib/log.ts
+++ b/src/lib/log.ts
@@ -1,11 +1,11 @@
import {
- ApplyPath,
+ type ApplyPath,
CallType,
- InstanceId,
+ type InstanceId,
InterfaceType,
NodeName,
- WebWorkerEnvironment,
- WinId,
+ type WebWorkerEnvironment,
+ type WinId,
} from './types';
import {
ApplyPathKey,
diff --git a/src/lib/main/snippet.ts b/src/lib/main/snippet.ts
index 5cbc07b0..d0bdb7c9 100644
--- a/src/lib/main/snippet.ts
+++ b/src/lib/main/snippet.ts
@@ -41,7 +41,7 @@ export function snippet(
top!.dispatchEvent(new CustomEvent('pt1', { detail: win }));
} else {
// set a timeout to fire if PT hasn't initialized in Xms
- timeout = setTimeout(fallback, 9999);
+ timeout = setTimeout(fallback, config?.fallbackTimeout || 9999);
doc.addEventListener('pt0', clearFallback);
if (useAtomics) {
diff --git a/src/lib/sandbox/index.ts b/src/lib/sandbox/index.ts
index e62ed10a..caa0fd35 100644
--- a/src/lib/sandbox/index.ts
+++ b/src/lib/sandbox/index.ts
@@ -4,9 +4,9 @@ import { libPath, mainWindow } from './main-globals';
import { logMain } from '../log';
import { mainAccessHandler } from './main-access-handler';
import {
- MessageFromWorkerToSandbox,
- MessengerRequestCallback,
- PartytownWebWorker,
+ type MessageFromWorkerToSandbox,
+ type MessengerRequestCallback,
+ type PartytownWebWorker,
WorkerMessageType,
} from '../types';
import { registerWindow } from './main-register-window';
diff --git a/src/lib/sandbox/main-access-handler.ts b/src/lib/sandbox/main-access-handler.ts
index 255cd53f..d7c4d372 100644
--- a/src/lib/sandbox/main-access-handler.ts
+++ b/src/lib/sandbox/main-access-handler.ts
@@ -1,11 +1,11 @@
import {
- ApplyPath,
+ type ApplyPath,
ApplyPathType,
- MainAccessRequest,
- MainAccessResponse,
- MainAccessTask,
- PartytownWebWorker,
- WinId,
+ type MainAccessRequest,
+ type MainAccessResponse,
+ type MainAccessTask,
+ type PartytownWebWorker,
+ type WinId,
} from '../types';
import { debug, getConstructorName, isPromise, len } from '../utils';
import { defineCustomElement } from './main-custom-element';
diff --git a/src/lib/sandbox/main-custom-element.ts b/src/lib/sandbox/main-custom-element.ts
index 4bbbc477..dcb04bd8 100644
--- a/src/lib/sandbox/main-custom-element.ts
+++ b/src/lib/sandbox/main-custom-element.ts
@@ -1,4 +1,9 @@
-import { CustomElementData, PartytownWebWorker, WinId, WorkerMessageType } from '../types';
+import {
+ type CustomElementData,
+ type PartytownWebWorker,
+ type WinId,
+ WorkerMessageType,
+} from '../types';
import { defineConstructorName } from '../utils';
import { getAndSetInstanceId } from './main-instances';
import { winCtxs } from './main-constants';
diff --git a/src/lib/sandbox/main-forward-trigger.ts b/src/lib/sandbox/main-forward-trigger.ts
index 2aaef22b..cd788145 100644
--- a/src/lib/sandbox/main-forward-trigger.ts
+++ b/src/lib/sandbox/main-forward-trigger.ts
@@ -4,7 +4,7 @@ import {
len,
resolvePartytownForwardProperty,
} from '../utils';
-import { MainWindow, PartytownWebWorker, WinId, WorkerMessageType } from '../types';
+import { type MainWindow, type PartytownWebWorker, type WinId, WorkerMessageType } from '../types';
import { serializeForWorker } from './main-serialization';
export const mainForwardTrigger = (worker: PartytownWebWorker, $winId$: WinId, win: MainWindow) => {
diff --git a/src/lib/sandbox/main-instances.ts b/src/lib/sandbox/main-instances.ts
index d0aad999..c128f8b9 100644
--- a/src/lib/sandbox/main-instances.ts
+++ b/src/lib/sandbox/main-instances.ts
@@ -1,5 +1,5 @@
import { CreatedKey, InstanceIdKey, instances, winCtxs, windowIds } from './main-constants';
-import { InstanceId, MainWindowContext, WinDocId, WinId } from '../types';
+import { type InstanceId, type MainWindowContext, WinDocId, type WinId } from '../types';
import { randomId } from '../utils';
export const getAndSetInstanceId = (instance: any, instanceId?: InstanceId) => {
diff --git a/src/lib/sandbox/main-register-window.ts b/src/lib/sandbox/main-register-window.ts
index 74c0d0b3..365822a8 100644
--- a/src/lib/sandbox/main-register-window.ts
+++ b/src/lib/sandbox/main-register-window.ts
@@ -1,9 +1,9 @@
import { debug } from '../utils';
import { logMain, normalizedWinId } from '../log';
import {
- MainWindow,
- PartytownWebWorker,
- WinId,
+ type MainWindow,
+ type PartytownWebWorker,
+ type WinId,
WorkerMessageType,
LocationUpdateType,
} from '../types';
diff --git a/src/lib/sandbox/main-serialization.ts b/src/lib/sandbox/main-serialization.ts
index 780d4631..57728715 100644
--- a/src/lib/sandbox/main-serialization.ts
+++ b/src/lib/sandbox/main-serialization.ts
@@ -2,14 +2,14 @@ import { getConstructorName, getNodeName, isValidMemberName, startsWith } from '
import { getInstance, getAndSetInstanceId } from './main-instances';
import { mainRefs } from './main-constants';
import {
- PartytownWebWorker,
- SerializedCSSRule,
- SerializedInstance,
- SerializedObject,
- SerializedRefTransferData,
- SerializedTransfer,
+ type PartytownWebWorker,
+ type SerializedCSSRule,
+ type SerializedInstance,
+ type SerializedObject,
+ type SerializedRefTransferData,
+ type SerializedTransfer,
SerializedType,
- WinId,
+ type WinId,
WorkerMessageType,
} from '../types';
diff --git a/src/lib/sandbox/on-messenge-from-worker.ts b/src/lib/sandbox/on-messenge-from-worker.ts
index 6187aaa5..9dc11870 100644
--- a/src/lib/sandbox/on-messenge-from-worker.ts
+++ b/src/lib/sandbox/on-messenge-from-worker.ts
@@ -1,10 +1,10 @@
import { initializedWorkerScript, readNextScript } from './read-main-scripts';
import { mainWindow } from './main-globals';
import {
- MainWindowContext,
- MessageFromWorkerToSandbox,
- PartytownWebWorker,
- WinId,
+ type MainWindowContext,
+ type MessageFromWorkerToSandbox,
+ type PartytownWebWorker,
+ type WinId,
WorkerMessageType,
} from '../types';
import { randomId } from '../utils';
diff --git a/src/lib/sandbox/read-main-platform.ts b/src/lib/sandbox/read-main-platform.ts
index bc4c85f1..6c0a8c6f 100644
--- a/src/lib/sandbox/read-main-platform.ts
+++ b/src/lib/sandbox/read-main-platform.ts
@@ -7,7 +7,12 @@ import {
serializeConfig,
} from '../utils';
import { config, docImpl, libPath, mainWindow } from './main-globals';
-import { InterfaceType, InterfaceInfo, InterfaceMember, InitWebWorkerData } from '../types';
+import {
+ InterfaceType,
+ type InterfaceInfo,
+ type InterfaceMember,
+ type InitWebWorkerData,
+} from '../types';
export const readMainPlatform = () => {
const elm = docImpl.createElement('i');
diff --git a/src/lib/sandbox/read-main-scripts.ts b/src/lib/sandbox/read-main-scripts.ts
index 17d94187..040c3f94 100644
--- a/src/lib/sandbox/read-main-scripts.ts
+++ b/src/lib/sandbox/read-main-scripts.ts
@@ -1,10 +1,10 @@
import { debug, SCRIPT_TYPE, SCRIPT_TYPE_EXEC } from '../utils';
import { getAndSetInstanceId } from './main-instances';
import {
- InitializeScriptData,
- InstanceId,
- MainWindowContext,
- PartytownWebWorker,
+ type InitializeScriptData,
+ type InstanceId,
+ type MainWindowContext,
+ type PartytownWebWorker,
WorkerMessageType,
} from '../types';
import { mainForwardTrigger } from './main-forward-trigger';
diff --git a/src/lib/service-worker/sync-create-messenger-sw.ts b/src/lib/service-worker/sync-create-messenger-sw.ts
index 1fff050f..0077701d 100644
--- a/src/lib/service-worker/sync-create-messenger-sw.ts
+++ b/src/lib/service-worker/sync-create-messenger-sw.ts
@@ -1,8 +1,8 @@
import {
- MainAccessRequest,
- MessageFromWorkerToSandbox,
- Messenger,
- PartytownWebWorker,
+ type MainAccessRequest,
+ type MessageFromWorkerToSandbox,
+ type Messenger,
+ type PartytownWebWorker,
WorkerMessageType,
} from '../types';
import { onMessageFromWebWorker } from '../sandbox/on-messenge-from-worker';
diff --git a/src/lib/types.ts b/src/lib/types.ts
index 42d95dcd..91060e19 100644
--- a/src/lib/types.ts
+++ b/src/lib/types.ts
@@ -444,6 +444,11 @@ export interface PartytownConfig {
* https://partytown.builder.io/forwarding-events
*/
forward?: PartytownForwardProperty[];
+ /**
+ * Timeout in ms before the initialization considered failed and the fallback solution is executed
+ * Default: 9999
+ */
+ fallbackTimeout?: number;
/**
* The css selector where the sandbox should be placed.
* Default: body
diff --git a/src/lib/web-worker/index.ts b/src/lib/web-worker/index.ts
index 89ce7d65..c86343b4 100644
--- a/src/lib/web-worker/index.ts
+++ b/src/lib/web-worker/index.ts
@@ -3,7 +3,11 @@ import { callWorkerRefHandler } from './worker-serialization';
import { createEnvironment } from './worker-environment';
import { debug } from '../utils';
import { environments, webWorkerCtx } from './worker-constants';
-import { ForwardMainTriggerData, MessageFromSandboxToWorker, WorkerMessageType } from '../types';
+import {
+ type ForwardMainTriggerData,
+ type MessageFromSandboxToWorker,
+ WorkerMessageType,
+} from '../types';
import { initNextScriptsInWebWorker } from './worker-exec';
import { initWebWorker } from './init-web-worker';
import { logWorker, normalizedWinId } from '../log';
diff --git a/src/lib/web-worker/media/canvas.ts b/src/lib/web-worker/media/canvas.ts
index 65d41912..fdc9a24b 100644
--- a/src/lib/web-worker/media/canvas.ts
+++ b/src/lib/web-worker/media/canvas.ts
@@ -8,7 +8,12 @@ import {
randomId,
} from './bridge';
import { ContextKey, defineCstr, notImpl } from './utils';
-import { CallType, WorkerConstructor, WorkerInstance, WorkerWindow } from '../../types';
+import {
+ CallType,
+ type WorkerConstructor,
+ type WorkerInstance,
+ type WorkerWindow,
+} from '../../types';
export const initCanvas = (WorkerBase: WorkerConstructor, win: WorkerWindow) => {
const HTMLCanvasDescriptorMap: PropertyDescriptorMap & ThisType = {
diff --git a/src/lib/web-worker/media/media.ts b/src/lib/web-worker/media/media.ts
index 64acd676..3d69906f 100644
--- a/src/lib/web-worker/media/media.ts
+++ b/src/lib/web-worker/media/media.ts
@@ -1,9 +1,9 @@
import {
CallType,
- MediaSelf,
- WebWorkerEnvironment,
- WorkerConstructor,
- WorkerWindow,
+ type MediaSelf,
+ type WebWorkerEnvironment,
+ type WorkerConstructor,
+ type WorkerWindow,
} from '../../types';
import {
defineCstr,
diff --git a/src/lib/web-worker/worker-anchor.ts b/src/lib/web-worker/worker-anchor.ts
index 83c2e8e3..8d60ee26 100644
--- a/src/lib/web-worker/worker-anchor.ts
+++ b/src/lib/web-worker/worker-anchor.ts
@@ -3,7 +3,7 @@ import { definePrototypePropertyDescriptor, isValidUrl } from '../utils';
import { getInstanceStateValue, setInstanceStateValue } from './worker-state';
import { getter, setter } from './worker-proxy';
import { resolveToUrl } from './worker-exec';
-import { StateProp, WebWorkerEnvironment, WorkerNode } from '../types';
+import { StateProp, type WebWorkerEnvironment, type WorkerNode } from '../types';
export const patchHTMLAnchorElement = (WorkerHTMLAnchorElement: any, env: WebWorkerEnvironment) => {
const HTMLAnchorDescriptorMap: PropertyDescriptorMap & ThisType = {};
diff --git a/src/lib/web-worker/worker-css-style-declaration.ts b/src/lib/web-worker/worker-css-style-declaration.ts
index 1192148a..9ce9c7b2 100644
--- a/src/lib/web-worker/worker-css-style-declaration.ts
+++ b/src/lib/web-worker/worker-css-style-declaration.ts
@@ -1,4 +1,10 @@
-import { ApplyPath, CallType, InstanceId, WinId, WorkerConstructor } from '../types';
+import {
+ type ApplyPath,
+ CallType,
+ type InstanceId,
+ type WinId,
+ type WorkerConstructor,
+} from '../types';
import { cachedDimensions, InstanceDataKey } from './worker-constants';
import { callMethod, getter, setter } from './worker-proxy';
import { defineConstructorName } from '../utils';
diff --git a/src/lib/web-worker/worker-document.ts b/src/lib/web-worker/worker-document.ts
index cb4eac1a..dadcdad5 100644
--- a/src/lib/web-worker/worker-document.ts
+++ b/src/lib/web-worker/worker-document.ts
@@ -3,9 +3,8 @@ import {
CallType,
NodeName,
StateProp,
- WebWorkerEnvironment,
- WinDocId,
- WorkerNode,
+ type WebWorkerEnvironment,
+ type WorkerNode,
} from '../types';
import {
cachedProps,
@@ -14,7 +13,6 @@ import {
getOrCreateNodeInstance,
} from './worker-constructors';
import { createEnvironment } from './worker-environment';
-import { createWindow } from './worker-window';
import { debug, definePrototypePropertyDescriptor, randomId, SCRIPT_TYPE } from '../utils';
import { ABOUT_BLANK, elementStructurePropNames, IS_TAG_REG, WinIdKey } from './worker-constants';
import { getInstanceStateValue } from './worker-state';
diff --git a/src/lib/web-worker/worker-environment.ts b/src/lib/web-worker/worker-environment.ts
index 82e1995f..5eb38fe1 100644
--- a/src/lib/web-worker/worker-environment.ts
+++ b/src/lib/web-worker/worker-environment.ts
@@ -1,7 +1,7 @@
import { createWindow } from './worker-window';
import { debug } from '../utils';
import { environments, webWorkerCtx } from './worker-constants';
-import { InitializeEnvironmentData, WorkerMessageType } from '../types';
+import { type InitializeEnvironmentData, WorkerMessageType } from '../types';
import { logWorker, normalizedWinId } from '../log';
export const createEnvironment = (
diff --git a/src/lib/web-worker/worker-exec.ts b/src/lib/web-worker/worker-exec.ts
index 9caee6de..2d5c37cb 100644
--- a/src/lib/web-worker/worker-exec.ts
+++ b/src/lib/web-worker/worker-exec.ts
@@ -1,15 +1,15 @@
import { VERSION } from '../build-modules/version';
import { logWorker } from '../log';
import {
- EventHandler,
- InitializeScriptData,
- InstanceId,
+ type EventHandler,
+ type InitializeScriptData,
+ type InstanceId,
NodeName,
- ResolveUrlType,
+ type ResolveUrlType,
StateProp,
- WebWorkerEnvironment,
- WinId,
- WorkerInstance,
+ type WebWorkerEnvironment,
+ type WinId,
+ type WorkerInstance,
WorkerMessageType,
} from '../types';
import { debug } from '../utils';
diff --git a/src/lib/web-worker/worker-iframe.ts b/src/lib/web-worker/worker-iframe.ts
index c57eb6b9..a9154404 100644
--- a/src/lib/web-worker/worker-iframe.ts
+++ b/src/lib/web-worker/worker-iframe.ts
@@ -13,10 +13,10 @@ import { HTMLSrcElementDescriptorMap } from './worker-src-element';
import { setInstanceStateValue, getInstanceStateValue } from './worker-state';
import {
StateProp,
- WebWorkerEnvironment,
- WorkerInstance,
+ type WebWorkerEnvironment,
+ type WorkerInstance,
WorkerMessageType,
- WorkerNode,
+ type WorkerNode,
} from '../types';
export const patchHTMLIFrameElement = (WorkerHTMLIFrameElement: any, env: WebWorkerEnvironment) => {
diff --git a/src/lib/web-worker/worker-location.ts b/src/lib/web-worker/worker-location.ts
index 7965c9a7..d8379e4c 100644
--- a/src/lib/web-worker/worker-location.ts
+++ b/src/lib/web-worker/worker-location.ts
@@ -1,4 +1,4 @@
-import { LocationUpdateData, LocationUpdateType, WebWorkerEnvironment } from '../types';
+import { type LocationUpdateData, LocationUpdateType, type WebWorkerEnvironment } from '../types';
export function forwardLocationChange(
$winId$: number,
diff --git a/src/lib/web-worker/worker-named-node-map.ts b/src/lib/web-worker/worker-named-node-map.ts
index a27df698..8f1e1b7c 100644
--- a/src/lib/web-worker/worker-named-node-map.ts
+++ b/src/lib/web-worker/worker-named-node-map.ts
@@ -1,10 +1,10 @@
import {
- ApplyPath,
+ type ApplyPath,
CallType,
- InstanceId,
- WinId,
- WorkerConstructor,
- WorkerInstance,
+ type InstanceId,
+ type WinId,
+ type WorkerConstructor,
+ type WorkerInstance,
} from '../types';
import { defineConstructorName } from '../utils';
import { callMethod, getter, setter } from './worker-proxy';
diff --git a/src/lib/web-worker/worker-node.ts b/src/lib/web-worker/worker-node.ts
index 9719d030..56939676 100644
--- a/src/lib/web-worker/worker-node.ts
+++ b/src/lib/web-worker/worker-node.ts
@@ -4,10 +4,10 @@ import {
CallType,
NodeName,
StateProp,
- WebWorkerEnvironment,
- WorkerConstructor,
+ type WebWorkerEnvironment,
+ type WorkerConstructor,
WorkerMessageType,
- WorkerNode,
+ type WorkerNode,
} from '../types';
import {
commaSplit,
diff --git a/src/lib/web-worker/worker-proxy.ts b/src/lib/web-worker/worker-proxy.ts
index 6f886aa2..0226da98 100644
--- a/src/lib/web-worker/worker-proxy.ts
+++ b/src/lib/web-worker/worker-proxy.ts
@@ -1,19 +1,19 @@
import {
- ApplyPath,
+ type ApplyPath,
ApplyPathType,
- AssignInstanceId,
- CallMethod,
+ type AssignInstanceId,
+ type CallMethod,
CallType,
- ConstructGlobal,
- Getter,
- HookOptions,
- MainAccessRequest,
- MainAccessResponse,
- MainAccessTask,
- Setter,
+ type ConstructGlobal,
+ type Getter,
+ type HookOptions,
+ type MainAccessRequest,
+ type MainAccessResponse,
+ type MainAccessTask,
+ type Setter,
WorkerMessageType,
- WorkerInstance,
- WorkerNode,
+ type WorkerInstance,
+ type WorkerNode,
} from '../types';
import {
ApplyPathKey,
diff --git a/src/lib/web-worker/worker-script.ts b/src/lib/web-worker/worker-script.ts
index 63b040de..5684b584 100644
--- a/src/lib/web-worker/worker-script.ts
+++ b/src/lib/web-worker/worker-script.ts
@@ -3,7 +3,7 @@ import { getInstanceStateValue, setInstanceStateValue } from './worker-state';
import { getter, setter } from './worker-proxy';
import { HTMLSrcElementDescriptorMap } from './worker-src-element';
import { resolveUrl } from './worker-exec';
-import { StateProp, WebWorkerEnvironment, WorkerNode } from '../types';
+import { StateProp, type WebWorkerEnvironment, type WorkerNode } from '../types';
import { webWorkerCtx } from './worker-constants';
export const patchHTMLScriptElement = (WorkerHTMLScriptElement: any, env: WebWorkerEnvironment) => {
diff --git a/src/lib/web-worker/worker-serialization.ts b/src/lib/web-worker/worker-serialization.ts
index 8e14b771..7630a808 100644
--- a/src/lib/web-worker/worker-serialization.ts
+++ b/src/lib/web-worker/worker-serialization.ts
@@ -1,18 +1,18 @@
import {
- ApplyPath,
+ type ApplyPath,
CallType,
- InstanceId,
- RefHandlerCallbackData,
- RefId,
- SerializedAttr,
- SerializedInstance,
- SerializedObject,
- SerializedRefTransferData,
- SerializedTransfer,
+ type InstanceId,
+ type RefHandlerCallbackData,
+ type RefId,
+ type SerializedAttr,
+ type SerializedInstance,
+ type SerializedObject,
+ type SerializedRefTransferData,
+ type SerializedTransfer,
SerializedType,
- WebWorkerEnvironment,
- WinId,
- WorkerNode,
+ type WebWorkerEnvironment,
+ type WinId,
+ type WorkerNode,
} from '../types';
import { callMethod } from './worker-proxy';
import {
diff --git a/src/lib/web-worker/worker-src-element.ts b/src/lib/web-worker/worker-src-element.ts
index e9f3eb65..998fe6d0 100644
--- a/src/lib/web-worker/worker-src-element.ts
+++ b/src/lib/web-worker/worker-src-element.ts
@@ -1,6 +1,6 @@
import { callMethod } from './worker-proxy';
import { commaSplit } from './worker-constants';
-import { EventHandler, StateProp, WorkerNode } from '../types';
+import { type EventHandler, StateProp, type WorkerNode } from '../types';
import { getInstanceStateValue, setInstanceStateValue } from './worker-state';
import { noop } from '../utils';
diff --git a/src/lib/web-worker/worker-storage.ts b/src/lib/web-worker/worker-storage.ts
index cb4f80d9..efa262fb 100644
--- a/src/lib/web-worker/worker-storage.ts
+++ b/src/lib/web-worker/worker-storage.ts
@@ -1,5 +1,5 @@
import { callMethod, getter } from './worker-proxy';
-import { CallType, WebWorkerEnvironment } from '../types';
+import { CallType, type WebWorkerEnvironment } from '../types';
import { EMPTY_ARRAY } from '../utils';
import { warnCrossOrigin } from '../log';
diff --git a/src/lib/web-worker/worker-style.ts b/src/lib/web-worker/worker-style.ts
index 045ec503..1491019e 100644
--- a/src/lib/web-worker/worker-style.ts
+++ b/src/lib/web-worker/worker-style.ts
@@ -1,6 +1,6 @@
import { cachedDimensions } from './worker-constants';
import { callMethod, getter } from './worker-proxy';
-import { CallType, StateProp, WorkerNode } from '../types';
+import { CallType, StateProp, type WorkerNode } from '../types';
import { defineConstructorName, definePrototypePropertyDescriptor } from '../utils';
import { getInstanceStateValue, setInstanceStateValue } from './worker-state';
import { logDimensionCacheClearMethod } from '../log';
diff --git a/src/lib/web-worker/worker-window.ts b/src/lib/web-worker/worker-window.ts
index dff93692..82d920a9 100644
--- a/src/lib/web-worker/worker-window.ts
+++ b/src/lib/web-worker/worker-window.ts
@@ -1,17 +1,17 @@
import { addStorageApi } from './worker-storage';
import {
- ApplyPath,
+ type ApplyPath,
CallType,
- InstanceId,
+ type InstanceId,
InterfaceType,
NodeName,
- WebWorkerEnvironment,
+ type WebWorkerEnvironment,
WinDocId,
- WinId,
- WorkerInstance,
- WorkerNode,
- WorkerNodeConstructors,
- WorkerWindow,
+ type WinId,
+ type WorkerInstance,
+ type WorkerNode,
+ type WorkerNodeConstructors,
+ type WorkerWindow,
} from '../types';
import {
ABOUT_BLANK,
diff --git a/src/react/index.ts b/src/react/index.ts
index f9943974..4e677bc2 100644
--- a/src/react/index.ts
+++ b/src/react/index.ts
@@ -1 +1,2 @@
-export { Partytown, PartytownProps } from './snippet';
+export { Partytown } from './snippet';
+export type { PartytownProps } from './snippet';
diff --git a/tsconfig.json b/tsconfig.json
index bab16d4b..0e1fed07 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -5,7 +5,7 @@
"module": "ES2020",
"lib": ["es2020", "DOM", "WebWorker"],
"strict": true,
- "importsNotUsedAsValues": "error",
+ "verbatimModuleSyntax": true,
"esModuleInterop": true,
"moduleResolution": "node",
"outDir": "tsc",