@nuxt/scripts 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/dist/client/200.html +5 -5
  2. package/dist/client/404.html +5 -5
  3. package/dist/client/_nuxt/{C6qP6ksw.js → 7b-muJBz.js} +1 -1
  4. package/dist/client/_nuxt/{D2oMNJSZ.js → CFDTW01f.js} +1 -1
  5. package/dist/client/_nuxt/{BBafEUG8.js → LZrVsJnT.js} +1 -1
  6. package/dist/client/_nuxt/{YkgnKQjM.js → ZXwHJetA.js} +3 -3
  7. package/dist/client/_nuxt/builds/latest.json +1 -1
  8. package/dist/client/_nuxt/builds/meta/f0a0fb88-29eb-404a-b0c9-7ad64c942608.json +1 -0
  9. package/dist/client/index.html +5 -5
  10. package/dist/module.d.mts +13 -64
  11. package/dist/module.d.ts +13 -64
  12. package/dist/module.json +1 -1
  13. package/dist/module.mjs +83 -86
  14. package/dist/runtime/composables/useScript.mjs +3 -2
  15. package/dist/runtime/composables/validateScriptInputSchema.d.ts +2 -2
  16. package/dist/runtime/registry/cloudflare-web-analytics.mjs +0 -2
  17. package/dist/runtime/registry/confetti.d.ts +9 -1
  18. package/dist/runtime/registry/confetti.mjs +8 -5
  19. package/dist/runtime/registry/facebook-pixel.d.ts +1 -1
  20. package/dist/runtime/registry/facebook-pixel.mjs +1 -3
  21. package/dist/runtime/registry/fathom-analytics.d.ts +1 -2
  22. package/dist/runtime/registry/fathom-analytics.mjs +1 -1
  23. package/dist/runtime/registry/hotjar.d.ts +2 -3
  24. package/dist/runtime/registry/hotjar.mjs +2 -3
  25. package/dist/runtime/registry/intercom.d.ts +1 -2
  26. package/dist/runtime/registry/intercom.mjs +1 -3
  27. package/dist/runtime/registry/npm.d.ts +12 -0
  28. package/dist/runtime/registry/npm.mjs +22 -0
  29. package/dist/runtime/registry/segment.d.ts +1 -2
  30. package/dist/runtime/registry/segment.mjs +1 -3
  31. package/dist/runtime/types.d.ts +20 -2
  32. package/package.json +3 -3
  33. package/dist/client/_nuxt/builds/meta/72c1a85e-b70c-4e27-93ec-d6316f40b143.json +0 -1
@@ -0,0 +1,12 @@
1
+ import { type Input } from 'valibot';
2
+ import type { NuxtUseScriptOptions } from '#nuxt-scripts';
3
+ export declare const NpmOptions: import("valibot").ObjectSchema<{
4
+ packageName: import("valibot").StringSchema<string>;
5
+ file: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
+ version: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
7
+ }, undefined, {
8
+ packageName: string;
9
+ file?: string | undefined;
10
+ version?: string | undefined;
11
+ }>;
12
+ export declare function useScriptNpm<T>(options: Input<typeof NpmOptions>, _scriptOptions?: NuxtUseScriptOptions<T>): any;
@@ -0,0 +1,22 @@
1
+ import { object, optional, string } from "valibot";
2
+ import { withBase } from "ufo";
3
+ import { useScript, validateScriptInputSchema } from "#imports";
4
+ export const NpmOptions = object({
5
+ packageName: string(),
6
+ file: optional(string()),
7
+ version: optional(string())
8
+ });
9
+ export function useScriptNpm(options, _scriptOptions) {
10
+ const scriptOptions = _scriptOptions || {};
11
+ scriptOptions.beforeInit = () => {
12
+ validateScriptInputSchema(NpmOptions, options);
13
+ };
14
+ return useScript({
15
+ src: typeof options === "string" ? options : withBase(options.file || "", `https://unpkg.com/${options?.packageName}@${options.version}`)
16
+ }, {
17
+ ...scriptOptions,
18
+ use() {
19
+ return new window.JSConfetti();
20
+ }
21
+ });
22
+ }
@@ -1,6 +1,6 @@
1
1
  import { type Input } from 'valibot';
2
2
  import type { NuxtUseScriptOptions } from '#nuxt-scripts';
3
- declare const SegmentOptions: import("valibot").ObjectSchema<{
3
+ export declare const SegmentOptions: import("valibot").ObjectSchema<{
4
4
  writeKey: import("valibot").StringSchema<string>;
5
5
  analyticsKey: import("valibot").OptionalSchema<import("valibot").StringSchema<string>, undefined, string | undefined>;
6
6
  }, undefined, {
@@ -22,4 +22,3 @@ declare global {
22
22
  }
23
23
  }
24
24
  export declare function useScriptSegment<T extends SegmentApi>(options?: Input<typeof SegmentOptions>, _scriptOptions?: Omit<NuxtUseScriptOptions<T>, 'beforeInit' | 'use'>): any;
25
- export {};
@@ -1,6 +1,6 @@
1
1
  import { object, optional, string } from "valibot";
2
2
  import { useScript, validateScriptInputSchema } from "#imports";
3
- const SegmentOptions = object({
3
+ export const SegmentOptions = object({
4
4
  writeKey: string(),
5
5
  analyticsKey: optional(string())
6
6
  });
@@ -33,9 +33,7 @@ export function useScriptSegment(options, _scriptOptions) {
33
33
  "src": `https://cdn.segment.com/analytics.js/v1/${options?.writeKey}/analytics.min.js`,
34
34
  "defer": true
35
35
  }, {
36
- trigger: "onNuxtReady",
37
36
  ...scriptOptions,
38
- assetStrategy: "bundle",
39
37
  use() {
40
38
  return { analytics: window[analyticsKey] };
41
39
  }
@@ -1,6 +1,13 @@
1
1
  import type { UseScriptOptions } from '@unhead/schema';
2
2
  import type { UseScriptInput, VueScriptInstance } from '@unhead/vue';
3
3
  import type { ComputedRef, Ref } from 'vue';
4
+ import type { Input, ObjectSchema } from 'valibot';
5
+ import type { CloudflareWebAnalyticsOptions } from '~/src/runtime/registry/cloudflare-web-analytics';
6
+ import type { FacebookPixelOptions } from '~/src/runtime/registry/facebook-pixel';
7
+ import type { FathomAnalyticsOptions } from '~/src/runtime/registry/fathom-analytics';
8
+ import type { HotjarOptions } from '~/src/runtime/registry/hotjar';
9
+ import type { SegmentOptions } from '~/src/runtime/registry/segment';
10
+ import type { IntercomOptions } from '~/src/runtime/registry/intercom';
4
11
  export type NuxtUseScriptOptions<T = any> = Omit<UseScriptOptions<T>, 'trigger'> & {
5
12
  /**
6
13
  * The trigger to load the script:
@@ -43,9 +50,20 @@ export interface NuxtAppScript {
43
50
  $script: VueScriptInstance<any>;
44
51
  events: {
45
52
  type: string;
46
- fn?: string;
53
+ fn?: string | symbol;
47
54
  args?: any;
48
- trigger?: string;
55
+ status?: string;
56
+ trigger?: NuxtUseScriptOptions['trigger'];
49
57
  at: number;
50
58
  }[];
51
59
  }
60
+ export type ScriptRegistryEntry<T extends ObjectSchema<any>> = Input<T> | [Input<T>, NuxtUseScriptOptions<T>];
61
+ export interface ScriptRegistry {
62
+ cloudflareWebAnalytics?: ScriptRegistryEntry<typeof CloudflareWebAnalyticsOptions>;
63
+ confetti?: ScriptRegistryEntry<typeof CloudflareWebAnalyticsOptions>;
64
+ facebookPixel?: ScriptRegistryEntry<typeof FacebookPixelOptions>;
65
+ fathomAnalytics?: ScriptRegistryEntry<typeof FathomAnalyticsOptions>;
66
+ hotjar?: ScriptRegistryEntry<typeof HotjarOptions>;
67
+ segment?: ScriptRegistryEntry<typeof SegmentOptions>;
68
+ intercom?: ScriptRegistryEntry<typeof IntercomOptions>;
69
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/scripts",
3
3
  "type": "module",
4
- "version": "0.1.5",
4
+ "version": "0.1.6",
5
5
  "packageManager": "pnpm@8.15.5",
6
6
  "description": "Next-gen Scripts for Nuxt",
7
7
  "author": {
@@ -56,7 +56,8 @@
56
56
  "ufo": "^1.5.3",
57
57
  "unplugin": "^1.10.0",
58
58
  "unstorage": "^1.10.2",
59
- "valibot": "^0.30.0"
59
+ "valibot": "^0.30.0",
60
+ "unimport": "^3.7.1"
60
61
  },
61
62
  "devDependencies": {
62
63
  "@antfu/eslint-config": "2.8.3",
@@ -71,7 +72,6 @@
71
72
  "nuxt-scripts-devtools": "latest",
72
73
  "playwright-core": "^1.42.1",
73
74
  "typescript": "^5.4.3",
74
- "unimport": "^3.7.1",
75
75
  "vitest": "^1.4.0"
76
76
  },
77
77
  "resolutions": {
@@ -1 +0,0 @@
1
- {"id":"72c1a85e-b70c-4e27-93ec-d6316f40b143","timestamp":1711777231401,"matcher":{"static":{},"wildcard":{},"dynamic":{}},"prerendered":[]}