Skip to content

Commit 2eedd4a

Browse files
committed
fix: disallow overriding registry key name
1 parent ed115d8 commit 2eedd4a

19 files changed

+19
-20
lines changed

src/runtime/registry/clarity.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ export type ClarityInput = RegistryScriptInput<typeof ClarityOptions>
4848
export function useScriptClarity<T extends ClarityApi>(
4949
_options?: ClarityInput,
5050
) {
51-
return useRegistryScript<T, typeof ClarityOptions>(
52-
_options?.key || 'clarity',
51+
return useRegistryScript<T, typeof ClarityOptions>('clarity',
5352
options => ({
5453
scriptInput: {
5554
src: `https://www.clarity.ms/tag/${options.id}`,

src/runtime/registry/cloudflare-web-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const CloudflareWebAnalyticsOptions = object({
3838
export type CloudflareWebAnalyticsInput = RegistryScriptInput<typeof CloudflareWebAnalyticsOptions>
3939

4040
export function useScriptCloudflareWebAnalytics<T extends CloudflareWebAnalyticsApi>(_options?: CloudflareWebAnalyticsInput) {
41-
return useRegistryScript<T, typeof CloudflareWebAnalyticsOptions>(_options?.key || 'cloudflareWebAnalytics', options => ({
41+
return useRegistryScript<T, typeof CloudflareWebAnalyticsOptions>('cloudflareWebAnalytics', options => ({
4242
scriptInput: {
4343
'src': 'https://static.cloudflareinsights.com/beacon.min.js',
4444
'data-cf-beacon': JSON.stringify({ token: options.token, spa: options.spa || true }),

src/runtime/registry/crisp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ declare global {
6464

6565
export function useScriptCrisp<T extends CrispApi>(_options?: CrispInput) {
6666
let readyPromise: Promise<void> = Promise.resolve()
67-
return useRegistryScript<T, typeof CrispOptions>(_options?.key || 'crisp', options => ({
67+
return useRegistryScript<T, typeof CrispOptions>('crisp', options => ({
6868
scriptInput: {
6969
src: 'https://client.crisp.chat/l.js', // can't be bundled
7070
},

src/runtime/registry/fathom-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ declare global {
4747
}
4848

4949
export function useScriptFathomAnalytics<T extends FathomAnalyticsApi>(_options?: FathomAnalyticsInput) {
50-
return useRegistryScript<T, typeof FathomAnalyticsOptions>(_options?.key || 'fathomAnalytics', options => ({
50+
return useRegistryScript<T, typeof FathomAnalyticsOptions>('fathomAnalytics', options => ({
5151
scriptInput: {
5252
src: 'https://cdn.usefathom.com/script.js', // can't be bundled
5353
// append the data attr's

src/runtime/registry/google-adsense.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ declare global {
3131
*/
3232
export function useScriptGoogleAdsense<T extends GoogleAdsenseApi>(_options?: GoogleAdsenseInput) {
3333
// Note: inputs.useScriptInput is not usable, needs to be normalized
34-
return useRegistryScript<T, typeof GoogleAdsenseOptions>(_options?.key || 'googleAdsense', options => ({
34+
return useRegistryScript<T, typeof GoogleAdsenseOptions>('googleAdsense', options => ({
3535
scriptInput: {
3636
src: 'https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js',
3737
},

src/runtime/registry/google-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,6 @@ export function useScriptGoogleAnalytics<T extends GoogleAnalyticsApi>(_options?
2727
...({ tagPriority: 1 }),
2828
},
2929
// eslint-disable-next-line
30-
clientInit: import.meta.server ? undefined : () => {window.dataLayers=window.dataLayers||{};window.dataLayers[options.dataLayerName!]=window.dataLayers[options.dataLayerName!]||[];window.gtag=function gtag(){window.dataLayers[options.dataLayerName!].push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id!)},
30+
clientInit: import.meta.server ? undefined : () => {window.dataLayers=window.dataLayers||{};window.dataLayers[options.dataLayerName!]=window.dataLayers[options.dataLayerName!]||[];window.gtag=function gtag(){window.dataLayer.push(arguments);};window.gtag('js',new Date());window.gtag('config',options.id!)},
3131
}), _options)
3232
}

src/runtime/registry/google-maps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare global {
3838

3939
export function useScriptGoogleMaps<T extends GoogleMapsApi>(_options?: GoogleMapsInput) {
4040
let readyPromise: Promise<void> = Promise.resolve()
41-
return useRegistryScript<T, typeof GoogleMapsOptions>(_options?.key || 'googleMaps', (options) => {
41+
return useRegistryScript<T, typeof GoogleMapsOptions>('googleMaps', (options) => {
4242
const libraries = options?.libraries || ['places']
4343
return {
4444
scriptInput: {

src/runtime/registry/hotjar.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export const HotjarOptions = object({
2222
export type HotjarInput = RegistryScriptInput<typeof HotjarOptions, true, false, false>
2323

2424
export function useScriptHotjar<T extends HotjarApi>(_options?: HotjarInput) {
25-
return useRegistryScript<T, typeof HotjarOptions>(_options?.key || 'hotjar', options => ({
25+
return useRegistryScript<T, typeof HotjarOptions>('hotjar', options => ({
2626
scriptInput: {
2727
src: `https://static.hotjar.com/c/hotjar-${options?.id}.js?sv=${options?.sv || 6}`,
2828
},

src/runtime/registry/intercom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ declare global {
5050
}
5151

5252
export function useScriptIntercom<T extends IntercomApi>(_options?: IntercomInput) {
53-
return useRegistryScript<T, typeof IntercomOptions>(_options?.key || 'intercom', options => ({
53+
return useRegistryScript<T, typeof IntercomOptions>('intercom', options => ({
5454
scriptInput: {
5555
src: joinURL(`https://widget.intercom.io/widget`, options?.app_id || ''),
5656
},

src/runtime/registry/lemon-squeezy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ declare global {
7070
}
7171

7272
export function useScriptLemonSqueezy<T extends LemonSqueezyApi>(_options?: LemonSqueezyInput) {
73-
return useRegistryScript<T>(_options?.key || 'lemonSqueezy', () => ({
73+
return useRegistryScript<T>('lemonSqueezy', () => ({
7474
scriptInput: {
7575
src: 'https://assets.lemonsqueezy.com/lemon.js',
7676
crossorigin: false,

0 commit comments

Comments
 (0)