Skip to content

Commit

Permalink
Merge branch 'main' into tests/e2etpc
Browse files Browse the repository at this point in the history
  • Loading branch information
harlan-zw authored Aug 5, 2024
2 parents f05dd22 + 9285284 commit 4f9d5df
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 15 deletions.
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default createConfigForNuxt({
})
.override('nuxt/typescript/rules', {
rules: {
'@typescript-eslint/no-empty-object-type': ['off'],
'@typescript-eslint/ban-ts-comment': [
'error',
{
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,13 @@
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test": "vitest",
"test:types": "npx nuxi typecheck",
"test:types": "echo 'broken due to type regeneration, use pnpm typecheck' && npx nuxi typecheck",
"script:generate-tpc": "bun ./scripts/generateTpcScripts.ts && pnpm lint:fix"
},
"build": {
"externals": [
"@unhead/vue",
"@unhead/schema",
"#nuxt-scripts",
"#nuxt-scripts-validator",
"third-party-capital",
"knitwork",
"estree-walker",
Expand Down
3 changes: 3 additions & 0 deletions src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ export default defineNuxtModule<ModuleOptions>({
async setup(config, nuxt) {
const { resolve } = createResolver(import.meta.url)
const { version, name } = await readPackageJSON(resolve('../package.json'))
nuxt.options.alias['#nuxt-scripts-validator'] = resolve(`./runtime/validation/${(nuxt.options.dev || nuxt.options._prepare) ? 'valibot' : 'mock'}`)
nuxt.options.alias['#nuxt-scripts'] = resolve('./runtime/types')
nuxt.options.alias['#nuxt-scripts-utils'] = resolve('./runtime/utils')
if (!config.enabled) {
// TODO fallback to useHead?
logger.debug('The module is disabled, skipping setup.')
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/clarity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface ClarityApi {
}

declare global {
type Window = ClarityApi
interface Window extends ClarityApi {}
}

export const ClarityOptions = object({
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/cloudflare-web-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface CloudflareWebAnalyticsApi {
}

declare global {
type Window = CloudflareWebAnalyticsApi
interface Window extends CloudflareWebAnalyticsApi {}
}

export const CloudflareWebAnalyticsOptions = object({
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/google-adsense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export interface GoogleAdsenseApi {
}

declare global {
type Window = GoogleAdsenseApi
interface Window extends GoogleAdsenseApi {}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/registry/google-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useRegistryScript } from '../utils'
import { array, literal, object, optional, string, union } from '#nuxt-scripts-validator'
import type { RegistryScriptInput } from '#nuxt-scripts'

// eslint-disable-next-line @typescript-eslint/no-namespace
// eslint-disable-next-line
declare namespace google {
// eslint-disable-next-line @typescript-eslint/no-namespace
export namespace maps {
Expand All @@ -23,7 +23,7 @@ export const GoogleMapsOptions = object({

export type GoogleMapsInput = RegistryScriptInput<typeof GoogleMapsOptions>

type MapsNamespace = google.maps
type MapsNamespace = typeof google.maps
export interface GoogleMapsApi {
maps: MapsNamespace | Promise<MapsNamespace>
}
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/google-tag-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import type { RegistryScriptInput } from '#nuxt-scripts'
import { object, string, optional } from '#nuxt-scripts-validator'

declare global {
type Window = GoogleTagManagerApi
interface Window extends GoogleTagManagerApi {}
}
export const GoogleTagManagerOptions = object({
id: string(),
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/matomo-analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ interface MatomoAnalyticsApi {
}

declare global {
type Window = MatomoAnalyticsApi
interface Window extends MatomoAnalyticsApi {}
}

export function useScriptMatomoAnalytics<T extends MatomoAnalyticsApi>(_options?: MatomoAnalyticsInput) {
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/registry/meta-pixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ export interface MetaPixelApi {
queue: any[]
}
_fbq: MetaPixelApi['fbq']
callMethod?: FbqFns
}

declare global {
type Window = MetaPixelApi
interface Window extends MetaPixelApi {}
}

export const MetaPixelOptions = object({
Expand All @@ -56,7 +57,9 @@ export function useScriptMetaPixel<T extends MetaPixelApi>(_options?: MetaPixelI
? undefined
: () => {
const fbq: MetaPixelApi['fbq'] = window.fbq = function (...params: any[]) {
// @ts-expect-error untypeds
if (fbq.callMethod) {
// @ts-expect-error untyped
fbq.callMethod(...params)
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/segment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ interface AnalyticsApi {
export type SegmentApi = Pick<AnalyticsApi, 'track' | 'page' | 'identify' | 'group' | 'alias' | 'reset'>

declare global {
type Window = SegmentApi
interface Window extends SegmentApi {}
}

const methods = ['track', 'page', 'identify', 'group', 'alias', 'reset']
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/stripe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface StripeApi {
}

declare global {
type Window = StripeApi
interface Window extends StripeApi {}
}

export function useScriptStripe<T extends StripeApi>(_options?: StripeInput) {
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/registry/vimeo-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export interface VimeoPlayerApi {
export type VimeoPlayerInput = RegistryScriptInput

declare global {
type Window = VimeoPlayerApi
interface Window extends VimeoPlayerApi {}
}

export function useScriptVimeoPlayer<T extends VimeoPlayerApi>(_options?: VimeoPlayerInput) {
Expand Down
5 changes: 4 additions & 1 deletion src/runtime/registry/x-pixel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface XPixelApi {
}

declare global {
type Window = XPixelApi
interface Window extends XPixelApi {}
}

export const XPixelOptions = object({
Expand All @@ -57,10 +57,13 @@ export function useScriptXPixel<T extends XPixelApi>(_options?: XPixelInput) {
: () => {
// @ts-expect-error untyped
const s = window.twq = function (...args) {
// @ts-expect-error untyped
if (e.exe) {
// @ts-expect-error untyped
s.exe(s, args)
}
else {
// @ts-expect-error untyped
s.queue.push(args)
}
}
Expand Down

0 comments on commit 4f9d5df

Please sign in to comment.