From acc26756288dc685c3d48f836147b0cb2d697229 Mon Sep 17 00:00:00 2001 From: aaa_eee Date: Thu, 8 Aug 2024 18:49:26 +0200 Subject: [PATCH 1/3] chore: bump typescript version --- pnpm-lock.yaml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 61f2b340..ac95a633 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: '9.0' settings: - autoInstallPeers: true + autoInstallPeers: false excludeLinksFromLockfile: false importers: @@ -2008,14 +2008,14 @@ snapshots: '@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: From 68cf5b88c0fbe2e8d4fa151f93c0fdb98f45db4d Mon Sep 17 00:00:00 2001 From: aaa_eee Date: Wed, 11 Sep 2024 23:16:03 +0200 Subject: [PATCH 2/3] feat: allow to specify a scope for text/partytown scripts --- src/lib/main/snippet.ts | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/lib/main/snippet.ts b/src/lib/main/snippet.ts index 5cbc07b0..deb71693 100644 --- a/src/lib/main/snippet.ts +++ b/src/lib/main/snippet.ts @@ -96,7 +96,7 @@ export function snippet( doc.querySelector(config!.sandboxParent || 'body')!.appendChild(sandbox); } - function fallback(i?: number, script?: HTMLScriptElement) { + function fallback() { // no support or timeout reached // basically "undo" all of the text/partytown scripts // so they act as normal scripts @@ -114,16 +114,19 @@ export function snippet( }); } - for (i = 0; i < scripts!.length; i++) { - script = doc.createElement('script'); - script.innerHTML = scripts![i].innerHTML; - // We don't need to set a `nonce` on sandbox script since it is loaded via - // the `src` attribute. However, we do need to set a `nonce` on the current - // script because it contains an inline script. This action ensures that the - // script can still be executed even when inline scripts are blocked - // (assuming `unsafe-inline` is disabled and `nonce-*` is used instead). - script.nonce = config!.nonce; - doc.head.appendChild(script); + for (let i = 0; i < scripts!.length; i++) { + const script = scripts![i]; + if (script.getAttribute('ptScope') !== 'worker') { + const fallbackScript = doc.createElement('script'); + fallbackScript.innerHTML = script.innerHTML; + // We don't need to set a `nonce` on sandbox script since it is loaded via + // the `src` attribute. However, we do need to set a `nonce` on the current + // script because it contains an inline script. This action ensures that the + // script can still be executed even when inline scripts are blocked + // (assuming `unsafe-inline` is disabled and `nonce-*` is used instead). + fallbackScript.nonce = config!.nonce; + doc.head.appendChild(fallbackScript); + } } if (sandbox) { From cb1c578dcdf5063f439938c6e43fbb63bc5306e0 Mon Sep 17 00:00:00 2001 From: aaa_eee Date: Wed, 11 Sep 2024 23:16:45 +0200 Subject: [PATCH 3/3] Revert "chore: bump typescript version" This reverts commit acc26756288dc685c3d48f836147b0cb2d697229. --- pnpm-lock.yaml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ac95a633..61f2b340 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1,7 +1,7 @@ lockfileVersion: '9.0' settings: - autoInstallPeers: false + autoInstallPeers: true excludeLinksFromLockfile: false importers: @@ -2008,14 +2008,14 @@ snapshots: '@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,8 +2023,6 @@ 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: @@ -2041,7 +2039,6 @@ 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 @@ -2149,11 +2146,11 @@ snapshots: color-convert: 2.0.1 any-observable@0.3.0(rxjs@6.6.7): - optionalDependencies: + dependencies: rxjs: 6.6.7 any-observable@0.5.1(rxjs@6.6.7): - optionalDependencies: + dependencies: rxjs: 6.6.7 argparse@1.0.10: