@pi-outpost/embed 0.60.0 → 0.61.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,4 +1,4 @@
1
- import { t as e } from "./download-DVJ5QY85.js";
1
+ import { n as e } from "./download-C9gupL_X.js";
2
2
  import { a as t, c as n, d as r, f as i, h as a, m as o, p as s } from "./mermaidToImage-CViP9wx2.js";
3
3
  import { n as c, t as l } from "./loadReferencedImage-VNYxXIzB.js";
4
4
  //#region ../ui/src/export/markdownToDocx.ts
@@ -1,3 +1,3 @@
1
- const e=require("./download-U7JEZ6c9.cjs"),t=require("./mermaidToImage-B7I6iJ9s.cjs"),n=require("./loadReferencedImage-D47xCpa7.cjs");async function r(e,r){let i=r?.path??``,a=r?.serverUrl??``,o=r?.token??null,s=r?.workspace;return t.d(e,{imageKey:e=>n.n(i,e,a,o,s),loadImage:e=>n.t(i,e,a,o,s),renderDiagram:t.a})}var i=`Consolas, Courier New, monospace`;function a(e){return e.replace(/\r\n/g,`
1
+ const e=require("./download-CVl_k6EM.cjs"),t=require("./mermaidToImage-B7I6iJ9s.cjs"),n=require("./loadReferencedImage-D47xCpa7.cjs");async function r(e,r){let i=r?.path??``,a=r?.serverUrl??``,o=r?.token??null,s=r?.workspace;return t.d(e,{imageKey:e=>n.n(i,e,a,o,s),loadImage:e=>n.t(i,e,a,o,s),renderDiagram:t.a})}var i=`Consolas, Courier New, monospace`;function a(e){return e.replace(/\r\n/g,`
2
2
  `).replace(/\n$/,``).split(`
3
- `).map(e=>new t.m({children:[new t.h({text:t.f(e===``?` `:e),font:i})],spacing:{before:0,after:0}}))}function o(e){let t=e.split(/[/\\]/).pop()??`document`,n=t.lastIndexOf(`.`);return`${n>0?t.slice(0,n):t}.docx`}function s(e){return/\.(md|markdown)$/i.test(e)}async function c(e,n,r){return t.p.toBlob(t.c(await l(e,n,r)))}async function l(e,t,n){return s(t)?r(e,{...n,path:t}):a(e)}async function u(t,n,r){e.t(await c(t,n,r),o(n))}var d=`application/vnd.openxmlformats-officedocument.wordprocessingml.document`;async function f(e,t,n){let r=await c(e,t,n),i={"Content-Type":d};n?.token&&(i.Authorization=`Bearer ${n.token}`);let a=await fetch(`${n?.serverUrl??``}/files/docx-template`,{method:`POST`,headers:i,body:r});if(!a.ok){let e=await a.json().catch(()=>null);throw Error(e?.message??`the server answered ${a.status}`)}return a.blob()}async function p(t,n,r){e.t(await f(t,n,r),o(n))}exports.downloadDocx=u,exports.downloadDocxInTemplate=p;
3
+ `).map(e=>new t.m({children:[new t.h({text:t.f(e===``?` `:e),font:i})],spacing:{before:0,after:0}}))}function o(e){let t=e.split(/[/\\]/).pop()??`document`,n=t.lastIndexOf(`.`);return`${n>0?t.slice(0,n):t}.docx`}function s(e){return/\.(md|markdown)$/i.test(e)}async function c(e,n,r){return t.p.toBlob(t.c(await l(e,n,r)))}async function l(e,t,n){return s(t)?r(e,{...n,path:t}):a(e)}async function u(t,n,r){e.n(await c(t,n,r),o(n))}var d=`application/vnd.openxmlformats-officedocument.wordprocessingml.document`;async function f(e,t,n){let r=await c(e,t,n),i={"Content-Type":d};n?.token&&(i.Authorization=`Bearer ${n.token}`);let a=await fetch(`${n?.serverUrl??``}/files/docx-template`,{method:`POST`,headers:i,body:r});if(!a.ok){let e=await a.json().catch(()=>null);throw Error(e?.message??`the server answered ${a.status}`)}return a.blob()}async function p(t,n,r){e.n(await f(t,n,r),o(n))}exports.downloadDocx=u,exports.downloadDocxInTemplate=p;
@@ -0,0 +1,45 @@
1
+ //#region ../ui/src/util/download.ts
2
+ function e(e, t) {
3
+ let n = URL.createObjectURL(e), r = document.createElement("a");
4
+ r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
5
+ }
6
+ function t(e, t) {
7
+ let n = t.map((e) => `path=${encodeURIComponent(e)}`);
8
+ return e.token && n.push(`token=${encodeURIComponent(e.token)}`), e.workspace !== void 0 && n.push(`workspace=${encodeURIComponent(e.workspace)}`), `${e.serverUrl}/files/download?${n.join("&")}`;
9
+ }
10
+ var n = class extends Error {};
11
+ function r(e) {
12
+ if (!e) return null;
13
+ let t = /filename\*=UTF-8''([^;]+)/i.exec(e);
14
+ if (t) try {
15
+ return decodeURIComponent(t[1].trim());
16
+ } catch {}
17
+ let n = /filename="([^"]*)"/i.exec(e);
18
+ return n ? n[1] : null;
19
+ }
20
+ var i = () => ({
21
+ fetch: (...e) => fetch(...e),
22
+ document,
23
+ save: e
24
+ });
25
+ async function a(e, a, o, s = i()) {
26
+ if (a.length === 0) return { skipped: 0 };
27
+ let c = t(e, a);
28
+ if (o.singleFile && a.length === 1) {
29
+ let e = s.document.createElement("a");
30
+ return e.href = c, e.download = a[0].split("/").pop() ?? "", e.rel = "noopener", e.click(), { skipped: 0 };
31
+ }
32
+ let l = await s.fetch(c);
33
+ if (!l.ok) {
34
+ let e = `The download failed (${l.status})`;
35
+ try {
36
+ let t = await l.json();
37
+ typeof t.message == "string" ? e = t.message : typeof t.error == "string" && (e = `The download failed: ${t.error}`);
38
+ } catch {}
39
+ throw new n(e);
40
+ }
41
+ let u = Number(l.headers.get("X-Pi-Outpost-Skipped") ?? "0") || 0, d = r(l.headers.get("Content-Disposition")) ?? "files.zip";
42
+ return s.save(await l.blob(), d), { skipped: u };
43
+ }
44
+ //#endregion
45
+ export { e as n, a as t };
@@ -0,0 +1 @@
1
+ function e(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function t(e,t){let n=t.map(e=>`path=${encodeURIComponent(e)}`);return e.token&&n.push(`token=${encodeURIComponent(e.token)}`),e.workspace!==void 0&&n.push(`workspace=${encodeURIComponent(e.workspace)}`),`${e.serverUrl}/files/download?${n.join(`&`)}`}var n=class extends Error{};function r(e){if(!e)return null;let t=/filename\*=UTF-8''([^;]+)/i.exec(e);if(t)try{return decodeURIComponent(t[1].trim())}catch{}let n=/filename="([^"]*)"/i.exec(e);return n?n[1]:null}var i=()=>({fetch:(...e)=>fetch(...e),document,save:e});async function a(e,a,o,s=i()){if(a.length===0)return{skipped:0};let c=t(e,a);if(o.singleFile&&a.length===1){let e=s.document.createElement(`a`);return e.href=c,e.download=a[0].split(`/`).pop()??``,e.rel=`noopener`,e.click(),{skipped:0}}let l=await s.fetch(c);if(!l.ok){let e=`The download failed (${l.status})`;try{let t=await l.json();typeof t.message==`string`?e=t.message:typeof t.error==`string`&&(e=`The download failed: ${t.error}`)}catch{}throw new n(e)}let u=Number(l.headers.get(`X-Pi-Outpost-Skipped`)??`0`)||0,d=r(l.headers.get(`Content-Disposition`))??`files.zip`;return s.save(await l.blob(),d),{skipped:u}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});