@datadog/rollup-plugin 3.4.0 → 3.5.1-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.
@@ -1 +1 @@
1
- const e=["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"],n=new Set(["api","app"]);function t(e){return null!==e&&"object"==typeof e}let o=0;function r(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();o+=1;const e=Math.random().toString(36).slice(2);return`req-${Date.now()}-${o}-${e}`}function a(t){let o;try{o=new URL(t)}catch{return!1}const r=o.hostname.endsWith(".")?o.hostname.slice(0,-1):o.hostname;return"https:"===o.protocol&&""===o.port&&void 0!==(t=>{if("string"!=typeof t)return;const o=(e=>(e.trim().replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").split(/[/?#]/)[0]??"").trim().toLowerCase())(t),r=e.find((e=>e===o));if(r)return{site:r};const a=e.filter((e=>o.endsWith(`.${e}`)));if(!a.length)return;const i=a.reduce(((e,n)=>n.length>e.length?n:e)),s=o.slice(0,o.length-i.length-1);return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)?n.has(s)?{site:i}:{site:i,subdomain:s}:void 0})(r)}let i,s,c=0,d=!1,u=!1;function l(e){var n;e.source===window.parent&&(t(n=e.data)&&"type"in n&&("app-builder:pong"===n.type||"app-builder:run-query:response"===n.type))&&(i=e.origin,window.removeEventListener("message",l),s?.end())}async function p(e){const n=window.location.ancestorOrigins;return n?n[0]:(e&&await function(){if(void 0!==s)return s.answered;window.addEventListener("message",l);let e=()=>{};const n=new Promise((n=>{e=n})),t=setTimeout(a,2e3);function o(){clearTimeout(t),s=void 0,e()}function a(){c+=1,o()}s={answered:n,end:o};const i={type:"app-builder:ping",requestId:r()};try{window.parent.postMessage(i,"*")}catch{a()}return n}(),i)}function g(e,n){console.warn(`[dd-apps] Sending "${e}" without its dev server bundle: ${n}`)}async function f(e){const n={functionName:e},o=JSON.stringify(n),r=new AbortController,a=setTimeout((()=>{const e=new Error("timed out after 60000ms");r.abort(e)}),6e4);try{const e=await fetch("/__dd/debugBundle",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:o,signal:r.signal});if(!e.ok){const n=await async function(e){const n=`HTTP ${e.status}`;try{const o=await e.json();return t(o)&&"error"in o&&"string"==typeof o.error?`${n}: ${o.error}`:n}catch{return n}}(e);return{failure:n}}const n=await e.json();return t(i=n)&&"code"in i&&"string"==typeof i.code&&i.code.length>0&&"allowedConnectionIds"in i&&Array.isArray(i.allowedConnectionIds)&&i.allowedConnectionIds.every((e=>"string"==typeof e))?{bundle:{code:n.code,allowedConnectionIds:n.allowedConnectionIds}}:{failure:"the dev server response is not a bundle"}}catch(e){return{failure:e instanceof Error?e.message:String(e)}}finally{clearTimeout(a)}var i}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async e=>{const n=!window.location.ancestorOrigins&&window.parent!==window&&void 0===i&&c<2,t=n?f(e):void 0,o=await p(n);if(void 0===o&&n&&function(e){d||(d=!0,g(e,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(e),"null"===o&&function(e){u||(u=!0,g(e,'the parent page has an opaque origin ("null"), so it can\'t be confirmed as a Datadog page'))}(e),void 0===o||!a(o))return{};const r=await(t??f(e));return"failure"in r?(g(e,r.failure),{targetOrigin:o}):{targetOrigin:o,bundle:r.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"],e=new Set(["api","app"]);function t(n){return null!==n&&"object"==typeof n}let o=0;function r(){if("undefined"!=typeof crypto&&crypto.randomUUID)return crypto.randomUUID();o+=1;const n=Math.random().toString(36).slice(2);return`req-${Date.now()}-${o}-${n}`}function a(t){let o;try{o=new URL(t)}catch{return!1}const r=o.hostname.endsWith(".")?o.hostname.slice(0,-1):o.hostname;return"https:"===o.protocol&&""===o.port&&void 0!==(t=>{if("string"!=typeof t)return;const o=(n=>(n.trim().replace(/^[a-z][a-z0-9+.-]*:\/\//i,"").split(/[/?#]/)[0]??"").trim().toLowerCase())(t),r=n.find((n=>n===o));if(r)return{site:r};const a=n.filter((n=>o.endsWith(`.${n}`)));if(!a.length)return;const i=a.reduce(((n,e)=>e.length>n.length?e:n)),s=o.slice(0,o.length-i.length-1);return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(s)?e.has(s)?{site:i}:{site:i,subdomain:s}:void 0})(r)}let i,s,c=0,d=!1,u=!1;function l(n){var e;n.source===window.parent&&(t(e=n.data)&&"type"in e&&("app-builder:pong"===e.type||"app-builder:run-query:response"===e.type))&&(i=n.origin,window.removeEventListener("message",l),s?.end())}function p(){const n=window.location.ancestorOrigins;return Boolean(n)&&"null"!==n[0]}async function g(n){return p()?window.location.ancestorOrigins[0]:(n&&await function(){if(void 0!==s)return s.answered;window.addEventListener("message",l);let n=()=>{};const e=new Promise((e=>{n=e})),t=setTimeout(a,2e3);function o(){clearTimeout(t),s=void 0,n()}function a(){c+=1,o()}s={answered:e,end:o};const i={type:"app-builder:ping",requestId:r()};try{window.parent.postMessage(i,"*")}catch{a()}return e}(),i)}function f(n,e){console.warn(`[dd-apps] Sending "${n}" without its dev server bundle: ${e}`)}async function w(n){const e={functionName:n},o=JSON.stringify(e),r=new AbortController,a=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 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 e=await n.json();return t(i=e)&&"code"in i&&"string"==typeof i.code&&i.code.length>0&&"allowedConnectionIds"in i&&Array.isArray(i.allowedConnectionIds)&&i.allowedConnectionIds.every((n=>"string"==typeof n))?{bundle:{code:e.code,allowedConnectionIds:e.allowedConnectionIds}}:{failure:"the dev server response is not a bundle"}}catch(n){return{failure:n instanceof Error?n.message:String(n)}}finally{clearTimeout(a)}var i}Reflect.set(globalThis,"DD_APPS_PREPARE_CALL",(async n=>{const e=!p()&&window.parent!==window&&void 0===i&&c<2,t=e?w(n):void 0,o=await g(e);if(void 0===o&&e&&function(n){d||(d=!0,f(n,"no answer came back from the parent page, so it can't be confirmed as a Datadog page"))}(n),"null"===o&&function(n){u||(u=!0,f(n,'the parent page has an opaque origin ("null"), so it can\'t be confirmed as a Datadog page'))}(n),void 0===o||!a(o))return{};const r=await(t??w(n));return"failure"in r?(f(n,r.failure),{targetOrigin:o}):{targetOrigin:o,bundle:r.bundle}}));
@@ -37,6 +37,14 @@ type AppsParameters = {
37
37
  type AppsOptions = {
38
38
  enable?: boolean;
39
39
  include?: string[];
40
+ /**
41
+ * Leave `*.map` files out of the deployable package. Sourcemaps needed for
42
+ * error tracking are uploaded to Datadog directly by the error-tracking
43
+ * plugin, so serving them with the app is rarely necessary; excluding them
44
+ * keeps packages small and reduces the decompressed size counted against
45
+ * the upload API's limit. Default: `false` (maps are packaged as today).
46
+ */
47
+ excludeSourcemaps?: boolean;
40
48
  /**
41
49
  * Tags to add to the app, e.g. `team:my-team`. The package also carries a `surface:<id>` tag
42
50
  * for each surface declared by an `@datadog/apps-frontend` input the app uses.