@datadog/webpack-plugin 3.3.2-dev.4 → 3.3.2-dev.5

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.
@@ -1 +1 @@
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}}));
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","uk1.datadoghq.com","datad0g.com"];function t(n){return null!==n&&"object"==typeof n}function e(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e]);return t}function o(n){return Array.isArray(n)&&n.every((n=>"string"==typeof n))}function r(n){return t(n)&&(!("connectionId"in n)||"string"==typeof n.connectionId)&&"inputs"in n&&function(n){return t(n)&&Object.values(n).every((n=>"string"==typeof n))}(n.inputs)}function i(n){return t(n)&&"fqn"in n&&"string"==typeof n.fqn&&"connectionIds"in n&&o(n.connectionIds)&&"calls"in n&&Array.isArray(n.calls)&&n.calls.every(r)}function a(n){const t=Object.keys(n).map((t=>[t,Reflect.get(n,t)]));return Object.fromEntries(t)}function c(n,t){return Object.prototype.hasOwnProperty.call(n,t)?Reflect.get(n,t):void 0}function s(n){if(!t(n))return;const e=c(n,"inputs");return{...Object.prototype.hasOwnProperty.call(n,"connectionId")&&{connectionId:Reflect.get(n,"connectionId")},inputs:t(e)&&!Array.isArray(e)?a(e):void 0}}let d=0;function u(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();d+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${d}-${n}`}const l=new Set(["app-builder:pong","app-builder:run-query:response","app-builder:run-query:keepalive"]);function f(t){let e;try{e=new URL(t)}catch{return!1}const o=e.hostname.endsWith(".")?e.hostname.slice(0,-1):e.hostname;return"https:"===e.protocol&&""===e.port&&void 0!==(t=>{if("string"!=typeof t)return;const e=t.toLowerCase(),o=n.find((n=>n===e));if(o)return{site:o};const r=n.filter((n=>e.endsWith(`.${n}`)));if(!r.length)return;const i=r.reduce(((n,t)=>t.length>n.length?t:n)),a=e.slice(0,e.length-i.length-1);return a&&/^[a-z0-9-]+$/.test(a)?{site:i,subdomain:a}:void 0})(o)}let p,g,y=0,w=!1,h=!1;function m(n){var e;n.source===window.parent&&(t(e=n.data)&&"type"in e&&l.has(e.type))&&(p=n.origin,window.removeEventListener("message",m),g?.end())}async function v(n){const t=window.location.ancestorOrigins;return t?t[0]:(n&&await function(){if(void 0!==g)return g.answered;window.addEventListener("message",m);let n=()=>{};const t=new Promise((t=>{n=t})),e=setTimeout(r,2e3);function o(){clearTimeout(e),g=void 0,n()}function r(){y+=1,o()}g={answered:t,end:o};const i={type:"app-builder:ping",requestId:u()};try{window.parent.postMessage(i,"*")}catch{r()}return t}(),p)}function b(n,t){console.warn(`[dd-apps] Sending "${n}" without its dev server bundle: ${t}`)}async function A(n){const r={functionName:n},a=JSON.stringify(r),d=new AbortController,u=setTimeout((()=>{const n=new Error("timed out after 60000ms");d.abort(n)}),6e4);try{const n=await fetch("/__dd/debugBundle",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:a,signal:d.signal});if(!n.ok){const e=await async function(n){const e=`HTTP ${n.status}`;try{const o=await n.json();return t(o)&&"error"in o&&"string"==typeof o.error?`${e}: ${o.error}`:e}catch{return e}}(n);return{failure:e}}const r=await n.json();if(!(t(l=r)&&"code"in l&&"string"==typeof l.code&&l.code.length>0&&"allowedConnectionIds"in l&&o(l.allowedConnectionIds)))return{failure:"the dev server response is not a bundle"};const u=function(n){try{const o=c(n,"actions");if(!Array.isArray(o))return;const r=e(o).map((n=>{if(!t(n))return;const o=c(n,"connectionIds"),r=c(n,"calls");return{fqn:c(n,"fqn"),connectionIds:Array.isArray(o)?e(o):void 0,calls:Array.isArray(r)?e(r).map(s):void 0}}));return r.every(i)?r:void 0}catch{return}}(r),{code:f,allowedConnectionIds:p}=r;return{bundle:{code:f,allowedConnectionIds:p,...u&&{actions:u}}}}catch(n){return{failure:n instanceof Error?n.message:String(n)}}finally{clearTimeout(u)}var l}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async n=>{const t=!window.location.ancestorOrigins&&window.parent!==window&&void 0===p&&y<2,e=t?A(n):void 0,o=await v(t);if(void 0===o&&t&&function(n){w||(w=!0,b(n,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(n),"null"===o&&function(n){h||(h=!0,b(n,'the parent page has an opaque origin ("null"), so it can\'t be confirmed as a Datadog page'))}(n),void 0===o||!f(o))return{};const r=await(e??A(n));return"failure"in r?(b(n,r.failure),{targetOrigin:o}):{targetOrigin:o,bundle:r.bundle}}));
@@ -1 +1 @@
1
- class e extends Error{constructor(e,n,t){super(e),this.functionName=n,this.statusCode=t,this.name="BackendFunctionError"}}const n=async(n,t)=>{const r={functionName:n,args:t};let o,i;try{o=await fetch("/__dd/executeAction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch(t){throw new e(`Network error while executing backend function "${n}": ${t instanceof Error?t.message:String(t)}`,n)}if(!o.ok){let t=`Backend function "${n}" failed with status ${o.status}`;try{const e=await o.text();e&&(t+=`: ${e}`)}catch{}throw new e(t,n,o.status)}try{i=await o.json()}catch(t){throw new e(`Failed to parse response from backend function "${n}": ${t instanceof Error?t.message:String(t)}`,n,o.status)}if(!i.success)throw new e(`Backend function "${n}" returned an error: ${i.error}`,n,o.status);return i.result.data};function t(e){return null!==e&&"object"==typeof e}let r=0;const o=12e4;function i(e){if(!t(e))return;const n="allowedConnectionIds"in e?e.allowedConnectionIds:void 0,r={code:"code"in e?e.code:void 0,allowedConnectionIds:Array.isArray(n)?n.slice():void 0};return t(o=r)&&"code"in o&&"string"==typeof o.code&&o.code.length>0&&"allowedConnectionIds"in o&&Array.isArray(o.allowedConnectionIds)&&o.allowedConnectionIds.every((e=>"string"==typeof e))?r:void 0;var o}function c(e){try{if(!t(e))return{};const n="targetOrigin"in e?e.targetOrigin:void 0;if(!function(e){if("string"!=typeof e)return!1;try{return new URL(e).origin===e}catch{return!1}}(n))return{};const r=i("bundle"in e?e.bundle:void 0);return void 0===r?{targetOrigin:n}:{targetOrigin:n,bundle:r}}catch{return{}}}function s(n,i,{targetOrigin:c,bundle:s}){const a=function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();r+=1;const e=Math.random().toString(36).slice(2);return`req-${Date.now()}-${r}-${e}`}();return new Promise(((r,u)=>{let d;function f(){window.removeEventListener("message",l),clearTimeout(d)}function l(o){const i=o.data;if(o.source!==window.parent||!function(e,n){return t(e)&&"type"in e&&"app-builder:run-query:response"===e.type&&"requestId"in e&&e.requestId===n}(i,a))return;if(f(),!0===i.success&&t(i.result))return void r(i.result.data);const c="error"in i?i.error:void 0,s=new e("string"==typeof c?c:`Backend function "${n}" failed`,n);u(s)}window.addEventListener("message",l),d=setTimeout((()=>{f(),u(new e(`Backend function "${n}" timed out waiting for response`,n))}),o);const w={type:"app-builder:run-query",requestId:a,queryName:n,args:i,...s&&{bundle:s}};try{window.parent.postMessage(w,c??"*")}catch(e){f(),u(e)}}))}const a=(e,n)=>{const t=function(){try{return Reflect.get(globalThis,"DD_APPS_PREPARE_CALL")}catch{return}}();if("function"!=typeof t)return s(e,n,{});let r;const i=new Promise((e=>{r=setTimeout((()=>e({})),o)})),a=Promise.resolve().then((()=>t(e))).catch((()=>({})));return Promise.race([a,i]).then((t=>{clearTimeout(r);const o=c(t);return s(e,n,o)}))};function u(){return function(){try{return"undefined"!=typeof window&&window.parent!==window}catch{return!0}}()?a:n}globalThis.DD_APPS_RUNTIME={executeBackendFunction:async function(e,n){return u()(e,n)}};
1
+ class n extends Error{constructor(n,t,e){super(n),this.functionName=t,this.statusCode=e,this.name="BackendFunctionError"}}const t=async(t,e)=>{const r={functionName:t,args:e};let o,i;try{o=await fetch("/__dd/executeAction",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(r)})}catch(e){throw new n(`Network error while executing backend function "${t}": ${e instanceof Error?e.message:String(e)}`,t)}if(!o.ok){let e=`Backend function "${t}" failed with status ${o.status}`;try{const n=await o.text();n&&(e+=`: ${n}`)}catch{}throw new n(e,t,o.status)}try{i=await o.json()}catch(e){throw new n(`Failed to parse response from backend function "${t}": ${e instanceof Error?e.message:String(e)}`,t,o.status)}if(!i.success)throw new n(`Backend function "${t}" returned an error: ${i.error}`,t,o.status);return i.result.data};function e(n){return null!==n&&"object"==typeof n}function r(n){const t=[];for(let e=0;e<n.length;e++)t.push(n[e]);return t}function o(n){return Array.isArray(n)&&n.every((n=>"string"==typeof n))}function i(n){return e(n)&&(!("connectionId"in n)||"string"==typeof n.connectionId)&&"inputs"in n&&function(n){return e(n)&&Object.values(n).every((n=>"string"==typeof n))}(n.inputs)}function c(n){return e(n)&&"fqn"in n&&"string"==typeof n.fqn&&"connectionIds"in n&&o(n.connectionIds)&&"calls"in n&&Array.isArray(n.calls)&&n.calls.every(i)}function s(n){const t=Object.keys(n).map((t=>[t,Reflect.get(n,t)]));return Object.fromEntries(t)}function u(n,t){return Object.prototype.hasOwnProperty.call(n,t)?Reflect.get(n,t):void 0}function a(n){if(!e(n))return;const t=u(n,"inputs");return{...Object.prototype.hasOwnProperty.call(n,"connectionId")&&{connectionId:Reflect.get(n,"connectionId")},inputs:e(t)&&!Array.isArray(t)?s(t):void 0}}let d=0;const f=12e4;function l(n,t,r){return e(n)&&"type"in n&&n.type===t&&"requestId"in n&&n.requestId===r}function y(n){if(!e(n))return;const t="allowedConnectionIds"in n?n.allowedConnectionIds:void 0,i={code:"code"in n?n.code:void 0,allowedConnectionIds:Array.isArray(t)?r(t):void 0};if(!(e(s=i)&&"code"in s&&"string"==typeof s.code&&s.code.length>0&&"allowedConnectionIds"in s&&o(s.allowedConnectionIds)))return;var s;const d=function(n){try{const t=u(n,"actions");if(!Array.isArray(t))return;const o=r(t).map((n=>{if(!e(n))return;const t=u(n,"connectionIds"),o=u(n,"calls");return{fqn:u(n,"fqn"),connectionIds:Array.isArray(t)?r(t):void 0,calls:Array.isArray(o)?r(o).map(a):void 0}}));return o.every(c)?o:void 0}catch{return}}(n);return{...i,...d&&{actions:d}}}function p(n){try{if(!e(n))return{};const t="targetOrigin"in n?n.targetOrigin:void 0;if(!function(n){if("string"!=typeof n)return!1;try{return new URL(n).origin===n}catch{return!1}}(t))return{};const r=y("bundle"in n?n.bundle:void 0);return void 0===r?{targetOrigin:t}:{targetOrigin:t,bundle:r}}catch{return{}}}function w(t,r,{targetOrigin:o,bundle:i}){const c=function(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();d+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${d}-${n}`}();return new Promise(((s,u)=>{const a=Date.now()+36e5;let d,y=Date.now()+f;function p(){window.removeEventListener("message",g),clearTimeout(d)}function w(){p();const e=new n(`Backend function "${t}" timed out waiting for response`,t);u(e)}function g(r){if(!function(n){return n.source===window.parent&&(void 0===o||n.origin===o)}(r))return;const i=r.data;if(function(n,t){return l(n,"app-builder:run-query:keepalive",t)}(i,c))return Date.now()>=y?void w():void(y=Math.min(Date.now()+f,a));if(!function(n,t){return l(n,"app-builder:run-query:response",t)}(i,c))return;if(p(),!0===i.success&&e(i.result))return void s(i.result.data);const d="error"in i?i.error:void 0,g=new n("string"==typeof d?d:`Backend function "${t}" failed`,t);u(g)}window.addEventListener("message",g),function n(){const t=y-Date.now();t<=0?w():d=setTimeout(n,t)}();const h={type:"app-builder:run-query",requestId:c,queryName:t,args:r,...i&&{bundle:i}};try{window.parent.postMessage(h,o??"*")}catch(n){p(),u(n)}}))}const g=(n,t)=>{const e=function(){try{return Reflect.get(globalThis,"DD_APPS_PREPARE_CALL")}catch{return}}();if("function"!=typeof e)return w(n,t,{});let r;const o=new Promise((n=>{r=setTimeout((()=>n({})),f)})),i=Promise.resolve().then((()=>e(n))).catch((()=>({})));return Promise.race([i,o]).then((e=>{clearTimeout(r);const o=p(e);return w(n,t,o)}))};function h(){return function(){try{return"undefined"!=typeof window&&window.parent!==window}catch{return!0}}()?g:t}globalThis.DD_APPS_RUNTIME={executeBackendFunction:async function(n,t){return h()(n,t)}};
@@ -5180,6 +5180,7 @@ declare const SITES: readonly [
5180
5180
  "us2.ddog-gov.com",
5181
5181
  "ap1.datadoghq.com",
5182
5182
  "ap2.datadoghq.com",
5183
+ "uk1.datadoghq.com",
5183
5184
  "datad0g.com"
5184
5185
  ];
5185
5186
  type Assign<A, B> = Omit<A, keyof B> & B;