From c1e135c9ad8d85618f7bbd7b1e2999139c8fe4d0 Mon Sep 17 00:00:00 2001 From: harlan Date: Fri, 29 Mar 2024 18:32:59 +1100 Subject: [PATCH] feat: start registry --- README.md | 47 +- client/package.json | 2 +- package.json | 16 +- playground/package.json | 2 +- playground/pages/analytics/cloudflare.vue | 46 -- .../pages/captcha/cloudflare-turnstile.vue | 9 - playground/pages/captcha/google-recaptcha.vue | 25 - playground/pages/index.vue | 170 +--- .../cloudflare-web-analytics.vue | 22 + .../pages/third-parties/facebook-pixel.vue | 30 + .../fathom-analytics.vue} | 5 +- playground/pages/third-parties/hotjar.vue | 28 + playground/pages/third-parties/intercom.vue | 37 + playground/pages/third-parties/segment.vue | 20 + pnpm-lock.yaml | 742 +++++++++--------- src/module.ts | 5 +- src/runtime/composables/useScript.ts | 8 +- src/runtime/registry/cloudflare-turnstile.ts | 3 + .../registry/cloudflare-web-analytics.ts | 55 ++ .../runtime/registry}/confetti.ts | 9 +- src/runtime/registry/facebook-pixel.ts | 78 ++ src/runtime/registry/fathom-analytics.ts | 42 + src/runtime/registry/google-analytics.ts | 3 + src/runtime/registry/google-tag-manager.ts | 3 + src/runtime/registry/hotjar.ts | 50 ++ src/runtime/registry/intercom.ts | 71 ++ src/runtime/registry/segment.ts | 64 ++ src/runtime/types.ts | 4 + .../composables/cloudflareAnalytics.ts | 29 - .../composables/cloudflareTurnstile.ts | 88 --- .../runtime/composables/fathomAnalytics.ts | 40 - .../src/runtime/composables/googleAdsense.ts | 28 - .../runtime/composables/googleRecaptcha.ts | 31 - 33 files changed, 979 insertions(+), 833 deletions(-) delete mode 100644 playground/pages/analytics/cloudflare.vue delete mode 100644 playground/pages/captcha/cloudflare-turnstile.vue delete mode 100644 playground/pages/captcha/google-recaptcha.vue create mode 100644 playground/pages/third-parties/cloudflare-web-analytics.vue create mode 100644 playground/pages/third-parties/facebook-pixel.vue rename playground/pages/{analytics/fathom.vue => third-parties/fathom-analytics.vue} (81%) create mode 100644 playground/pages/third-parties/hotjar.vue create mode 100644 playground/pages/third-parties/intercom.vue create mode 100644 playground/pages/third-parties/segment.vue create mode 100644 src/runtime/registry/cloudflare-turnstile.ts create mode 100644 src/runtime/registry/cloudflare-web-analytics.ts rename {third-parties/src/runtime/composables => src/runtime/registry}/confetti.ts (60%) create mode 100644 src/runtime/registry/facebook-pixel.ts create mode 100644 src/runtime/registry/fathom-analytics.ts create mode 100644 src/runtime/registry/google-analytics.ts create mode 100644 src/runtime/registry/google-tag-manager.ts create mode 100644 src/runtime/registry/hotjar.ts create mode 100644 src/runtime/registry/intercom.ts create mode 100644 src/runtime/registry/segment.ts delete mode 100644 third-parties/src/runtime/composables/cloudflareAnalytics.ts delete mode 100644 third-parties/src/runtime/composables/cloudflareTurnstile.ts delete mode 100644 third-parties/src/runtime/composables/fathomAnalytics.ts delete mode 100644 third-parties/src/runtime/composables/googleAdsense.ts delete mode 100644 third-parties/src/runtime/composables/googleRecaptcha.ts diff --git a/README.md b/README.md index c6042cd5..c5d410f2 100644 --- a/README.md +++ b/README.md @@ -59,32 +59,33 @@ addConfetti({ emojis: ['🌈', '⚡️', '💥', '✨', '💫', '🌸'] }) ### Using The Registry (TODO) -The registry is a collection of compatible Nuxt Modules that integrate with Nuxt Scripts and one-off composables provided -by the module. +The registry is a collection of composables and Nuxt Modules that directly integrate with Nuxt Scripts. -To use a script from the registry, simply use the composable or register them globally using the key. Consult the +To use a script from the registry, simply use the composable. Consult the below table for the available scripts. -| Key | Description | Composable | Source | -| --- | --- | --- | --- | -| `google-analytics` | Google Analytics | `useGoogleAnalytics` | Nuxt Third Party Capital | -| `google-tag-manager` | Google Tag Manager | `useGoogleTagManager` | Nuxt Third Party Capital | -| `hotjar` | Hotjar | `useHotjar` | Nuxt Third Party Capital | -| `cloudflare-turnstile` | CloudFlare Turnstile | `useCloudflareTurnstile` | Nuxt Cloudflare Turnstile | -| `intercom` | Intercom | `useIntercom` | Nuxt Scripts | -| `facebook-pixel` | Facebook Pixel | `useFacebookPixel` | -| `twitter-pixel` | Twitter Pixel | `useTwitterPixel` | -| `linkedin-insight-tag` | LinkedIn Insight Tag | `useLinkedInInsightTag` | -| `pinterest-tag` | Pinterest Tag | `usePinterestTag` | -| `google-ads-conversion-tracking` | Google Ads Conversion Tracking | `useGoogleAdsConversionTracking` | -| `google-ads-remarketing` | Google Ads Remarketing | `useGoogleAdsRemarketing` | -| `segment` | Segment | `useSegment` | -| `fathom-analytics` | Fathom Analytics | `useFathomAnalytics` | -| `plausible-analytics` | Plausible Analytics | `usePlausibleAnalytics` | -| `simple-analytics` | Simple Analytics | `useSimpleAnalytics` | -| `umami-analytics` | Umami Analytics | `useUmamiAnalytics` | -| `cloudflare-web-analytics` | Cloudflare Web Analytics | `useCloudflareWebAnalytics` | -| `matomo` | Matomo | `useMatomo` | +| Key | Description | Composable | Source | +|----------| | --- | --- | +| `cloudflare-web-analytics` | Cloudflare Web Analytics | `useScriptCloudflareWebAnalytics` | Core | +| `confetti` | [JS Confetti](https://github.com/loonywizard/js-confetti) | `useScriptCloudflareAnalytics` | Core | +| `facebook-pixel` | Facebook Pixel | `useScriptFacebookPixel` | Core | +| `fathom-analytics` | Fathom Analytics | `useScriptFathomAnalytics` | Core | +| `hotjar` | Hotjar | `useScriptHotjar` | Core | +| `intercom` | Intercom | `useScriptIntercom` | Core | +| `segment` | Segment | `useScriptSegment` | Core | +| `google-analytics` | Google Analytics | `useGoogleAnalytics` | [Nuxt Third Party Capital](https://github.com/nuxt/third-party-capital) | +| `google-tag-manager` | Google Tag Manager | `useGoogleTagManager` | [Nuxt Third Party Capital](https://github.com/nuxt/third-party-capital) | +| `cloudflare-turnstile` | CloudFlare Turnstile | `useCloudflareTurnstile` | [Nuxt Cloudflare Turnstile](https://github.com/nuxt-modules/turnstile) | + +TODO | `twitter-pixel` | Twitter Pixel | `useTwitterPixel` | +TODO | `pinterest-tag` | Pinterest Tag | `usePinterestTag` | +TODO | `google-ads-conversion-tracking` | Google Ads Conversion Tracking | `useGoogleAdsConversionTracking` | +TODO | `google-ads-remarketing` | Google Ads Remarketing | `useGoogleAdsRemarketing` | +TODO | `plausible-analytics` | Plausible Analytics | `usePlausibleAnalytics` | +TODO | `simple-analytics` | Simple Analytics | `useSimpleAnalytics` | +TODO | `umami-analytics` | Umami Analytics | `useUmamiAnalytics` | +TODO | `cloudflare-web-analytics` | Cloudflare Web Analytics | `useCloudflareWebAnalytics` | +TODO | `matomo` | Matomo | `useMatomo` | ### Loading Scripts Globally diff --git a/client/package.json b/client/package.json index a21a42af..fde41afd 100644 --- a/client/package.json +++ b/client/package.json @@ -12,7 +12,7 @@ }, "devDependencies": { "@iconify-json/carbon": "^1.1.31", - "@nuxt/devtools-kit": "^1.1.1", + "@nuxt/devtools-kit": "^1.1.5", "@nuxt/devtools-ui-kit": "latest", "@nuxt/kit": "^3.11.1", "nuxt": "latest", diff --git a/package.json b/package.json index 2a5a938f..71e3567c 100644 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "client:dev": "nuxi dev client --port 3300", "prepack": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxt-module-build build && npm run client:build", "dev": "nuxi dev playground", + "dev:ssl": "nuxi dev playground --https", "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground", "typecheck": "pnpm dlx vue-tsc --noEmit", "release": "pnpm build && bumpp && pnpm -r publish --no-git-checks", @@ -50,30 +51,31 @@ ] }, "dependencies": { - "@nuxt/devtools-kit": "^1.1.1", - "@nuxt/devtools-ui-kit": "^1.1.1", + "@nuxt/devtools-kit": "^1.1.5", + "@nuxt/devtools-ui-kit": "^1.1.5", "@nuxt/kit": "^3.11.1", "consola": "^3.2.3", "defu": "^6.1.4", "estree-walker": "^3.0.3", "h3": "^1.11.1", "magic-string": "^0.30.8", - "ofetch": "^1.3.3", + "ofetch": "^1.3.4", "ohash": "^1.1.3", "pathe": "^1.1.2", "pkg-types": "^1.0.3", - "shiki": "^1.2.0", + "shiki": "^1.2.1", "sirv": "^2.0.4", "ufo": "^1.5.3", "unplugin": "^1.10.0", - "unstorage": "^1.10.2" + "unstorage": "^1.10.2", + "valibot": "^0.30.0" }, "devDependencies": { "@antfu/eslint-config": "2.8.3", - "@nuxt/devtools-ui-kit": "^1.1.1", + "@nuxt/devtools-ui-kit": "^1.1.5", "@nuxt/module-builder": "^0.5.5", "@nuxt/test-utils": "3.12.0", - "@unhead/schema": "^1.8.20", + "@unhead/schema": "^1.9.3", "acorn-loose": "^8.4.0", "bumpp": "^9.4.0", "eslint": "8.57.0", diff --git a/playground/package.json b/playground/package.json index be91ca32..291f752b 100644 --- a/playground/package.json +++ b/playground/package.json @@ -3,7 +3,7 @@ "type": "module", "private": true, "scripts": { - "dev": "nuxi dev", + "dev": "nuxi dev --https", "build": "nuxi build", "generate": "nuxi generate" }, diff --git a/playground/pages/analytics/cloudflare.vue b/playground/pages/analytics/cloudflare.vue deleted file mode 100644 index a736e862..00000000 --- a/playground/pages/analytics/cloudflare.vue +++ /dev/null @@ -1,46 +0,0 @@ - - - diff --git a/playground/pages/captcha/cloudflare-turnstile.vue b/playground/pages/captcha/cloudflare-turnstile.vue deleted file mode 100644 index ba3e18d5..00000000 --- a/playground/pages/captcha/cloudflare-turnstile.vue +++ /dev/null @@ -1,9 +0,0 @@ - diff --git a/playground/pages/captcha/google-recaptcha.vue b/playground/pages/captcha/google-recaptcha.vue deleted file mode 100644 index a239f8d9..00000000 --- a/playground/pages/captcha/google-recaptcha.vue +++ /dev/null @@ -1,25 +0,0 @@ - - - diff --git a/playground/pages/index.vue b/playground/pages/index.vue index e65a82d6..f3973b56 100644 --- a/playground/pages/index.vue +++ b/playground/pages/index.vue @@ -1,156 +1,58 @@