@tldraw/utils
Version:
tldraw infinite canvas SDK (private utilities).
8 lines (7 loc) • 1.66 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/lib/network.ts"],
"sourcesContent": ["/**\n * Just a wrapper around `window.fetch` that sets the `referrerPolicy` to `strict-origin-when-cross-origin`.\n *\n * @param input - A Request object or string containing the URL to fetch\n * @param init - Optional request initialization options\n * @returns Promise that resolves to the Response object\n * @internal\n */\nexport async function fetch(input: RequestInfo | URL, init?: RequestInit): Promise<Response> {\n\t// eslint-disable-next-line no-restricted-properties\n\treturn window.fetch(input, {\n\t\t// We want to make sure that the referrer is not sent to other domains.\n\t\treferrerPolicy: 'strict-origin-when-cross-origin',\n\t\t...init,\n\t})\n}\n\n/**\n * Just a wrapper around `new Image`, and yeah, it's a bit strange that it's in the network.ts file\n * but the main concern here is the referrerPolicy and setting it correctly.\n *\n * @param width - Optional width for the image element\n * @param height - Optional height for the image element\n * @returns HTMLImageElement with referrerPolicy set to 'strict-origin-when-cross-origin'\n * @internal\n */\nexport const Image = (width?: number, height?: number) => {\n\t// eslint-disable-next-line no-restricted-properties\n\tconst img = new window.Image(width, height)\n\timg.referrerPolicy = 'strict-origin-when-cross-origin'\n\treturn img\n}\n"],
"mappings": "AAQA,eAAsB,MAAM,OAA0B,MAAuC;AAE5F,SAAO,OAAO,MAAM,OAAO;AAAA;AAAA,IAE1B,gBAAgB;AAAA,IAChB,GAAG;AAAA,EACJ,CAAC;AACF;AAWO,MAAM,QAAQ,CAAC,OAAgB,WAAoB;AAEzD,QAAM,MAAM,IAAI,OAAO,MAAM,OAAO,MAAM;AAC1C,MAAI,iBAAiB;AACrB,SAAO;AACR;",
"names": []
}