@datadog/vite-plugin 3.3.2-dev.4 → 3.3.3-dev.0

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.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@datadog/vite-plugin",
3
3
  "packageManager": "yarn@4.0.2",
4
- "version": "3.3.2-dev.4",
4
+ "version": "3.3.3-dev.0",
5
5
  "license": "MIT",
6
6
  "author": "Datadog",
7
7
  "description": "Datadog Vite Plugin",
@@ -1 +0,0 @@
1
- const n=["datadoghq.com","us3.datadoghq.com","us5.datadoghq.com","datadoghq.eu","ddog-gov.com","us2.ddog-gov.com","ap1.datadoghq.com","ap2.datadoghq.com","datad0g.com"];function e(n){return null!==n&&"object"==typeof n}let t=0;function o(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();t+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${t}-${n}`}function r(e){let t;try{t=new URL(e)}catch{return!1}const o=t.hostname.endsWith(".")?t.hostname.slice(0,-1):t.hostname;return"https:"===t.protocol&&""===t.port&&void 0!==(e=>{if("string"!=typeof e)return;const t=e.toLowerCase(),o=n.find((n=>n===t));if(o)return{site:o};const r=n.filter((n=>t.endsWith(`.${n}`)));if(!r.length)return;const i=r.reduce(((n,e)=>e.length>n.length?e:n)),a=t.slice(0,t.length-i.length-1);return a&&/^[a-z0-9-]+$/.test(a)?{site:i,subdomain:a}:void 0})(o)}let i,a,s=0,d=!1;function c(n){var t;n.source===window.parent&&(e(t=n.data)&&"type"in t&&("app-builder:pong"===t.type||"app-builder:run-query:response"===t.type))&&(i=n.origin,window.removeEventListener("message",c),a?.end())}async function u(n){const e=window.location.ancestorOrigins;return e?e[0]:(n&&await function(){if(void 0!==a)return a.answered;window.addEventListener("message",c);let n=()=>{};const e=new Promise((e=>{n=e})),t=setTimeout(i,2e3);function r(){clearTimeout(t),a=void 0,n()}function i(){s+=1,r()}a={answered:e,end:r};const d={type:"app-builder:ping",requestId:o()};try{window.parent.postMessage(d,"*")}catch{i()}return e}(),i)}function l(n,e){console.warn(`[dd-apps] Sending "${n}" without its dev server bundle: ${e}`)}async function g(n){const t={functionName:n},o=JSON.stringify(t),r=new AbortController,i=setTimeout((()=>{const n=new Error("timed out after 60000ms");r.abort(n)}),6e4);try{const n=await fetch("/__dd/debugBundle",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o,signal:r.signal});if(!n.ok){const t=await async function(n){const t=`HTTP ${n.status}`;try{const o=await n.json();return e(o)&&"error"in o&&"string"==typeof o.error?`${t}: ${o.error}`:t}catch{return t}}(n);return{failure:t}}const t=await n.json();return e(a=t)&&"code"in a&&"string"==typeof a.code&&a.code.length>0&&"allowedConnectionIds"in a&&Array.isArray(a.allowedConnectionIds)&&a.allowedConnectionIds.every((n=>"string"==typeof n))?{bundle:{code:t.code,allowedConnectionIds:t.allowedConnectionIds}}:{failure:"the dev server response is not a bundle"}}catch(n){return{failure:n instanceof Error?n.message:String(n)}}finally{clearTimeout(i)}var a}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async n=>{const e=!window.location.ancestorOrigins&&window.parent!==window&&void 0===i&&s<2,t=e?g(n):void 0,o=await u(e);if(void 0===o&&e&&function(n){d||(d=!0,l(n,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(n),void 0===o||!r(o))return{};const a=await(t??g(n));return"failure"in a?(l(n,a.failure),{targetOrigin:o}):{targetOrigin:o,bundle:a.bundle}}));