@nuxtjs/prismic 4.0.0 → 4.1.0-pr.235.94cfeb5

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 (44) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +18 -32
  3. package/dist/module.d.mts +48 -75
  4. package/dist/module.json +3 -3
  5. package/dist/module.mjs +193 -242
  6. package/dist/runtime/PrismicPreview.d.vue.ts +3 -0
  7. package/dist/runtime/PrismicPreview.vue +8 -14
  8. package/dist/runtime/PrismicPreview.vue.d.ts +3 -0
  9. package/dist/runtime/plugin.client.js +13 -7
  10. package/dist/runtime/plugin.js +89 -72
  11. package/dist/runtime/usePrismicPreview.d.ts +1 -5
  12. package/dist/runtime/usePrismicPreview.js +3 -3
  13. package/dist/types.d.mts +3 -1
  14. package/package.json +38 -45
  15. package/src/module.ts +352 -185
  16. package/src/runtime/PrismicPreview.vue +12 -16
  17. package/src/runtime/plugin.client.ts +16 -12
  18. package/src/runtime/plugin.ts +114 -103
  19. package/src/runtime/usePrismicPreview.ts +7 -11
  20. package/dist/client/200.html +0 -1
  21. package/dist/client/404.html +0 -1
  22. package/dist/client/_nuxt/BMD6bpEv.js +0 -1
  23. package/dist/client/_nuxt/BQB6UGbx.js +0 -25
  24. package/dist/client/_nuxt/CkG7IjgS.js +0 -1
  25. package/dist/client/_nuxt/DlAUqK2U.js +0 -1
  26. package/dist/client/_nuxt/H1okkFcd.js +0 -1
  27. package/dist/client/_nuxt/RYS3n4u0.js +0 -1
  28. package/dist/client/_nuxt/V_weDLQm.js +0 -1
  29. package/dist/client/_nuxt/builds/latest.json +0 -1
  30. package/dist/client/_nuxt/builds/meta/ef21bbff-0463-480b-852c-adffad3f33b7.json +0 -1
  31. package/dist/client/_nuxt/entry.BC9BDAld.css +0 -1
  32. package/dist/client/_nuxt/error-404.smTsHvdw.css +0 -1
  33. package/dist/client/_nuxt/error-500.Bo-s0s94.css +0 -1
  34. package/dist/client/_nuxt/index.C4BggqQh.css +0 -1
  35. package/dist/client/index.html +0 -1
  36. package/dist/module.cjs +0 -5
  37. package/dist/module.d.ts +0 -136
  38. package/dist/types.d.ts +0 -1
  39. package/src/devtools/index.ts +0 -127
  40. package/src/devtools/types.ts +0 -22
  41. package/src/lib/fileExists.ts +0 -15
  42. package/src/lib/index.ts +0 -2
  43. package/src/lib/logger.ts +0 -3
  44. package/src/types.ts +0 -137
@@ -1,15 +1,19 @@
1
- import type { PrismicModuleOptions } from '../types'
2
- import { defineNuxtPlugin } from '#app'
3
- import { refreshNuxtData, useRuntimeConfig } from '#imports'
1
+ import { defineNuxtPlugin } from "#app"
2
+ import { refreshNuxtData, useRuntimeConfig } from "#imports"
4
3
 
5
- export default defineNuxtPlugin((_nuxtApp) => {
6
- const options: PrismicModuleOptions = useRuntimeConfig().public.prismic
4
+ export default defineNuxtPlugin({
5
+ name: "prismic:plugin:client",
6
+ parallel: true,
7
+ setup() {
8
+ hotReloadPrismicPreview()
7
9
 
8
- // Hot reload preview updates
9
- if (options.preview) {
10
- window.addEventListener('prismicPreviewUpdate', (event) => {
11
- event.preventDefault()
12
- refreshNuxtData()
13
- })
14
- }
10
+ function hotReloadPrismicPreview() {
11
+ if (useRuntimeConfig().public.prismic?.preview) {
12
+ window.addEventListener("prismicPreviewUpdate", (event) => {
13
+ event.preventDefault()
14
+ refreshNuxtData()
15
+ })
16
+ }
17
+ }
18
+ },
15
19
  })
@@ -1,127 +1,138 @@
1
- import { createClient, type Client } from '@prismicio/client'
2
- import { createPrismic } from '@prismicio/vue'
3
-
4
- import type { PrismicModuleOptions } from '../types'
5
- import { defineNuxtPlugin } from '#app'
6
- import NuxtLink from '#app/components/nuxt-link'
7
- import { useCookie, useRequestEvent, onNuxtReady, refreshNuxtData, useHead, useRuntimeConfig, useRouter } from '#imports'
8
-
9
- // @ts-expect-error vfs cannot be resolved here
10
- import _client from '#build/prismic/proxy/client'
11
- // @ts-expect-error vfs cannot be resolved here
12
- import linkResolver from '#build/prismic/proxy/linkResolver'
13
- // @ts-expect-error vfs cannot be resolved here
14
- import richTextSerializer from '#build/prismic/proxy/richTextSerializer'
15
- // @ts-expect-error vfs cannot be resolved here
16
- import linkRel from '#build/prismic/proxy/linkRel'
17
- // @ts-expect-error vfs cannot be resolved here
18
- import richTextComponents from '#build/prismic/proxy/richTextComponents'
19
- // @ts-expect-error vfs cannot be resolved here
20
- import sliceZoneDefaultComponent from '#build/prismic/proxy/sliceZoneDefaultComponent'
1
+ import { defineNuxtPlugin } from "#app"
2
+ import NuxtLink from "#app/components/nuxt-link"
3
+ import _client from "#build/prismic/proxy/client"
4
+ // @ts-expect-error - Proxy file
5
+ import defaultComponents from "#build/prismic/proxy/defaultComponents"
6
+ // @ts-expect-error - Proxy file
7
+ import linkResolver from "#build/prismic/proxy/linkResolver"
8
+ import {
9
+ onNuxtReady,
10
+ refreshNuxtData,
11
+ useCookie,
12
+ useHead,
13
+ useRequestEvent,
14
+ useRouter,
15
+ useRuntimeConfig,
16
+ } from "#imports"
17
+ import { Client, createClient } from "@prismicio/client"
18
+ import { createPrismic } from "@prismicio/vue"
21
19
 
22
20
  export default defineNuxtPlugin({
23
- name: 'prismic:setup',
21
+ name: "prismic:setup",
24
22
  parallel: true,
25
23
  async setup(nuxtApp) {
26
- const options: PrismicModuleOptions = useRuntimeConfig().public.prismic
27
- let client: Client | undefined
28
- if (typeof _client === 'function') {
29
- try {
30
- client = await nuxtApp.runWithContext(() => _client())
31
- }
32
- catch (error) {
33
- console.error('[@nuxtjs/prismic] An error happened while resolving your Prismic custom client, disabling Prismic module gracefully...', error)
24
+ const options = useRuntimeConfig().public.prismic
25
+
26
+ const client = await resolveClient()
27
+ handlePreview()
28
+ addToolbar()
34
29
 
35
- // The Vue plugin still requires a client to work, we're providing an obviously broken one.
36
- client = createClient(
37
- 'error-resolving-custom-client',
38
- { ...options, documentAPIEndpoint: undefined },
30
+ async function resolveClient() {
31
+ if ((_client as unknown) instanceof Client) {
32
+ return _client!
33
+ } else if (typeof _client === "function") {
34
+ try {
35
+ return await nuxtApp.runWithContext(() =>
36
+ (_client as unknown as () => Client)(),
37
+ )
38
+ } catch (error) {
39
+ console.error(
40
+ "[@nuxtjs/prismic] An error happened while resolving your Prismic custom client, disabling Prismic module gracefully...",
41
+ error,
42
+ )
43
+
44
+ // The Vue plugin still requires a client to work, we're providing an obviously broken one.
45
+ return createClient(
46
+ "error-resolving-custom-client",
47
+ options.clientConfig,
48
+ )
49
+ }
50
+ } else {
51
+ return createClient(
52
+ options.environment || options.endpoint || "endpoint-not-provided",
53
+ options.clientConfig,
39
54
  )
40
55
  }
41
56
  }
42
- else {
43
- client = _client
44
- }
45
-
46
- const endpoint = options.environment || options.endpoint || client?.documentAPIEndpoint || ''
47
-
48
- const prismicPlugin = createPrismic({
49
- ...options,
50
- endpoint,
51
- // TypeScript expects either an endpoint of a client, not both
52
- client: client as undefined,
53
- linkResolver,
54
- richTextSerializer,
55
- injectComponents: false, // Handled at module level
56
- components: {
57
- linkInternalComponent: NuxtLink,
58
- linkExternalComponent: NuxtLink,
59
- ...options.components,
60
- linkRel,
61
- richTextComponents,
62
- sliceZoneDefaultComponent,
63
- },
64
- })
65
57
 
66
- nuxtApp.vueApp.use(prismicPlugin)
67
-
68
- if (options.preview) {
69
- const previewCookie = useCookie('io.prismic.preview').value
58
+ function handlePreview() {
59
+ if (options.preview) {
60
+ const previewCookie = useCookie("io.prismic.preview").value
70
61
 
71
- // Update client with req when running server side
72
- if (import.meta.server) {
73
- const req = useRequestEvent()?.node.req
74
- if (req) {
75
- prismicPlugin.client.enableAutoPreviewsFromReq(req)
62
+ // Update client with req when running server side
63
+ if (import.meta.server) {
64
+ const req = useRequestEvent()?.node.req
65
+ if (req) {
66
+ client.enableAutoPreviewsFromReq(req)
67
+ }
76
68
  }
77
- }
78
69
 
79
- if (previewCookie) {
80
- try {
81
- const session = typeof previewCookie === 'string' ? JSON.parse(decodeURIComponent(previewCookie)) : previewCookie
70
+ if (previewCookie) {
71
+ try {
72
+ const session =
73
+ typeof previewCookie === "string"
74
+ ? JSON.parse(decodeURIComponent(previewCookie))
75
+ : previewCookie
82
76
 
83
- if (Object.keys(session).some(key =>
84
- key in session
85
- && typeof session[key] === 'object'
86
- && session[key] !== null
87
- && 'preview' in session[key]
88
- && session[key].preview)
89
- ) {
90
- let afterEachCalled = false
91
- onNuxtReady(() => {
92
- if (!afterEachCalled) {
77
+ if (
78
+ Object.keys(session).some(
79
+ (key) =>
80
+ key in session &&
81
+ typeof session[key] === "object" &&
82
+ session[key] !== null &&
83
+ "preview" in session[key] &&
84
+ session[key].preview,
85
+ )
86
+ ) {
87
+ let afterEachCalled = false
88
+ onNuxtReady(() => {
89
+ if (!afterEachCalled) {
90
+ refreshNuxtData()
91
+ }
92
+ })
93
+ useRouter().afterEach(() => {
94
+ afterEachCalled = true
93
95
  refreshNuxtData()
94
- }
95
- })
96
- useRouter().afterEach(() => {
97
- afterEachCalled = true
98
- refreshNuxtData()
99
- })
96
+ })
97
+ }
98
+ } catch (error) {
99
+ console.warn("Failed to parse Prismic preview cookie", error)
100
100
  }
101
101
  }
102
- catch (error) {
103
- console.warn('Failed to parse Prismic preview cookie', error)
104
- }
105
102
  }
106
103
  }
107
104
 
108
- if (options.toolbar && prismicPlugin.client?.repositoryName) {
109
- // Add toolbar
110
- useHead({
111
- script: [{
112
- key: 'prismic-preview',
113
- src: `https://static.cdn.prismic.io/prismic.min.js?repo=${prismicPlugin.client.repositoryName}&new=true`,
114
- async: true,
115
- defer: true,
116
- crossorigin: 'anonymous',
117
- }],
118
- })
119
- }
120
- else {
121
- // TODO: We might want to let user disable this behavior because it might have unexpected side effects
122
- useCookie('io.prismic.preview').value = null
105
+ function addToolbar() {
106
+ if (options.toolbar) {
107
+ // Add toolbar
108
+ useHead({
109
+ script: [
110
+ {
111
+ key: "prismic-preview",
112
+ src: `https://static.cdn.prismic.io/prismic.min.js?repo=${client.repositoryName}&new=true`,
113
+ async: true,
114
+ defer: true,
115
+ crossorigin: "anonymous",
116
+ },
117
+ ],
118
+ })
119
+ } else {
120
+ // TODO: We might want to let user disable this behavior because it might have unexpected side effects
121
+ useCookie("io.prismic.preview").value = null
122
+ }
123
123
  }
124
124
 
125
+ const prismicPlugin = createPrismic({
126
+ client,
127
+ componentsConfig: {
128
+ linkResolver,
129
+ linkInternalComponent: NuxtLink,
130
+ linkExternalComponent: NuxtLink,
131
+ defaultComponents,
132
+ },
133
+ })
134
+
135
+ nuxtApp.vueApp.use(prismicPlugin)
125
136
  return {
126
137
  provide: { prismic: prismicPlugin },
127
138
  }
@@ -1,18 +1,14 @@
1
- import { onMounted } from 'vue'
1
+ // @ts-expect-error - Proxy file
2
+ import { usePrismic, useRouter } from "#imports"
3
+ import { onMounted } from "vue"
2
4
 
3
- import { useRouter, usePrismic } from '#imports'
4
-
5
- /**
6
- * Resolves Prismic previews on the preview entry page (`/preview`)
7
- *
8
- * @param defaultURL - The default URL to redirect to if the previewed document doesn't map to one.
9
- */
10
- export const usePrismicPreview = (defaultURL = '/'): void => {
11
- const { client, options: { linkResolver } } = usePrismic()
5
+ /** Resolves Prismic previews on the preview entry page (`/preview`) */
6
+ export const usePrismicPreview = (defaultURL = "/"): void => {
7
+ const { client, componentsConfig } = usePrismic()
12
8
  const { push } = useRouter()
13
9
  onMounted(async () => {
14
10
  const redirectURL = await client.resolvePreviewURL({
15
- linkResolver,
11
+ linkResolver: componentsConfig.linkResolver,
16
12
  defaultURL,
17
13
  })
18
14
 
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__prismic-client/_nuxt/entry.BC9BDAld.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__prismic-client/_nuxt/BQB6UGbx.js"><link rel="prefetch" as="style" crossorigin href="/__prismic-client/_nuxt/error-404.smTsHvdw.css"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/V_weDLQm.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/BMD6bpEv.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/DlAUqK2U.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/CkG7IjgS.js"><link rel="prefetch" as="style" crossorigin href="/__prismic-client/_nuxt/error-500.Bo-s0s94.css"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/H1okkFcd.js"><script type="module" src="/__prismic-client/_nuxt/BQB6UGbx.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1737402154202,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__prismic-client",buildId:"ef21bbff-0463-480b-852c-adffad3f33b7",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +0,0 @@
1
- <!DOCTYPE html><html data-capo=""><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="/__prismic-client/_nuxt/entry.BC9BDAld.css" crossorigin><link rel="modulepreload" as="script" crossorigin href="/__prismic-client/_nuxt/BQB6UGbx.js"><link rel="prefetch" as="style" crossorigin href="/__prismic-client/_nuxt/error-404.smTsHvdw.css"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/V_weDLQm.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/BMD6bpEv.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/DlAUqK2U.js"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/CkG7IjgS.js"><link rel="prefetch" as="style" crossorigin href="/__prismic-client/_nuxt/error-500.Bo-s0s94.css"><link rel="prefetch" as="script" crossorigin href="/__prismic-client/_nuxt/H1okkFcd.js"><script type="module" src="/__prismic-client/_nuxt/BQB6UGbx.js" crossorigin></script></head><body><div id="__nuxt"></div><div id="teleports"></div><script type="application/json" data-nuxt-data="nuxt-app" data-ssr="false" id="__NUXT_DATA__">[{"prerenderedAt":1,"serverRendered":2},1737402154202,false]</script><script>window.__NUXT__={};window.__NUXT__.config={public:{},app:{baseURL:"/__prismic-client",buildId:"ef21bbff-0463-480b-852c-adffad3f33b7",buildAssetsDir:"/_nuxt/",cdnURL:""}}</script></body></html>
@@ -1 +0,0 @@
1
- import{B as S,m as B,r as w,C as _,D as E,E as T,F as U,g as I,G as F,H as A,I as L,J as H,K as D,u as x,L as N,M as O,N as V,O as M,P as z,Q as W,R as G}from"./BQB6UGbx.js";async function j(t,a=S()){const{path:v,matched:p}=a.resolve(t);if(!p.length||(a._routePreloaded||(a._routePreloaded=new Set),a._routePreloaded.has(v)))return;const g=a._preloadPromises=a._preloadPromises||[];if(g.length>4)return Promise.all(g).then(()=>j(t,a));a._routePreloaded.add(v);const e=p.map(n=>{var s;return(s=n.components)==null?void 0:s.default}).filter(n=>typeof n=="function");for(const n of e){const s=Promise.resolve(n()).catch(()=>{}).finally(()=>g.splice(g.indexOf(s)));g.push(s)}await Promise.all(g)}const Q=(...t)=>t.find(a=>a!==void 0);function $(t){const a=t.componentName||"NuxtLink";function v(e){return typeof e=="string"&&e.startsWith("#")}function p(e,n){if(!e||t.trailingSlash!=="append"&&t.trailingSlash!=="remove")return e;if(typeof e=="string")return k(e,t.trailingSlash);const s="path"in e&&e.path!==void 0?e.path:n(e).path;return{...e,name:void 0,path:k(s,t.trailingSlash)}}function g(e){const n=S(),s=z(),u=x(()=>!!e.target&&e.target!=="_self"),d=x(()=>{const f=e.to||e.href||"";return typeof f=="string"&&N(f,{acceptRelative:!0})}),P=L("RouterLink"),y=P&&typeof P!="string"?P.useLink:void 0,m=x(()=>{if(e.external)return!0;const f=e.to||e.href||"";return typeof f=="object"?!1:f===""||d.value}),r=x(()=>{const f=e.to||e.href||"";return m.value?f:p(f,n.resolve)}),c=m.value||y==null?void 0:y({...e,to:r}),b=x(()=>{var f;if(!r.value||d.value||v(r.value))return r.value;if(m.value){const C=typeof r.value=="object"&&"path"in r.value?O(r.value):r.value,R=typeof C=="object"?n.resolve(C).href:C;return p(R,n.resolve)}return typeof r.value=="object"?((f=n.resolve(r.value))==null?void 0:f.href)??null:p(V(s.app.baseURL,r.value),n.resolve)});return{to:r,hasTarget:u,isAbsoluteUrl:d,isExternal:m,href:b,isActive:(c==null?void 0:c.isActive)??x(()=>r.value===n.currentRoute.value.path),isExactActive:(c==null?void 0:c.isExactActive)??x(()=>r.value===n.currentRoute.value.path),route:(c==null?void 0:c.route)??x(()=>n.resolve(r.value)),async navigate(){await M(b.value,{replace:e.replace,external:m.value||u.value})}}}return B({name:a,props:{to:{type:[String,Object],default:void 0,required:!1},href:{type:[String,Object],default:void 0,required:!1},target:{type:String,default:void 0,required:!1},rel:{type:String,default:void 0,required:!1},noRel:{type:Boolean,default:void 0,required:!1},prefetch:{type:Boolean,default:void 0,required:!1},prefetchOn:{type:[String,Object],default:void 0,required:!1},noPrefetch:{type:Boolean,default:void 0,required:!1},activeClass:{type:String,default:void 0,required:!1},exactActiveClass:{type:String,default:void 0,required:!1},prefetchedClass:{type:String,default:void 0,required:!1},replace:{type:Boolean,default:void 0,required:!1},ariaCurrentValue:{type:String,default:void 0,required:!1},external:{type:Boolean,default:void 0,required:!1},custom:{type:Boolean,default:void 0,required:!1}},useLink:g,setup(e,{slots:n}){const s=S(),{to:u,href:d,navigate:P,isExternal:y,hasTarget:m,isAbsoluteUrl:r}=g(e),c=w(!1),b=w(null),f=l=>{var o;b.value=e.custom?(o=l==null?void 0:l.$el)==null?void 0:o.nextElementSibling:l==null?void 0:l.$el};function C(l){var o,i;return!c.value&&(typeof e.prefetchOn=="string"?e.prefetchOn===l:((o=e.prefetchOn)==null?void 0:o[l])??((i=t.prefetchOn)==null?void 0:i[l]))&&(e.prefetch??t.prefetch)!==!1&&e.noPrefetch!==!0&&e.target!=="_blank"&&!X()}async function R(l=_()){if(c.value)return;c.value=!0;const o=typeof u.value=="string"?u.value:y.value?O(u.value):s.resolve(u.value).fullPath,i=y.value?new URL(o,window.location.href).href:o;await Promise.all([l.hooks.callHook("link:prefetch",i).catch(()=>{}),!y.value&&!m.value&&j(u.value,s).catch(()=>{})])}if(C("visibility")){const l=_();let o,i=null;E(()=>{const h=J();T(()=>{o=U(()=>{var q;(q=b==null?void 0:b.value)!=null&&q.tagName&&(i=h.observe(b.value,async()=>{i==null||i(),i=null,await R(l)}))})})}),I(()=>{o&&F(o),i==null||i(),i=null})}return()=>{var i;if(!y.value&&!m.value&&!v(u.value)){const h={ref:f,to:u.value,activeClass:e.activeClass||t.activeClass,exactActiveClass:e.exactActiveClass||t.exactActiveClass,replace:e.replace,ariaCurrentValue:e.ariaCurrentValue,custom:e.custom};return e.custom||(C("interaction")&&(h.onPointerenter=R.bind(null,void 0),h.onFocus=R.bind(null,void 0)),c.value&&(h.class=e.prefetchedClass||t.prefetchedClass),h.rel=e.rel||void 0),A(L("RouterLink"),h,n.default)}const l=e.target||null,o=Q(e.noRel?"":e.rel,t.externalRelAttribute,r.value||m.value?"noopener noreferrer":"")||null;return e.custom?n.default?n.default({href:d.value,navigate:P,prefetch:R,get route(){if(!d.value)return;const h=new URL(d.value,window.location.href);return{path:h.pathname,fullPath:h.pathname,get query(){return H(h.search)},hash:h.hash,params:{},name:void 0,matched:[],redirectedFrom:void 0,meta:{},href:d.value}},rel:o,target:l,isExternal:y.value||m.value,isActive:!1,isExactActive:!1}):null:A("a",{ref:b,href:d.value||null,rel:o,target:l},(i=n.default)==null?void 0:i.call(n))}}})}const Z=$(D);function k(t,a){const v=a==="append"?W:G;return N(t)&&!t.startsWith("http")?t:v(t,!0)}function J(){const t=_();if(t._observer)return t._observer;let a=null;const v=new Map,p=(e,n)=>(a||(a=new IntersectionObserver(s=>{for(const u of s){const d=v.get(u.target);(u.isIntersecting||u.intersectionRatio>0)&&d&&d()}})),v.set(e,n),a.observe(e),()=>{v.delete(e),a==null||a.unobserve(e),v.size===0&&(a==null||a.disconnect(),a=null)});return t._observer={observe:p}}const K=/2g/;function X(){const t=navigator.connection;return!!(t&&(t.saveData||K.test(t.effectiveType)))}export{Z as _};