6190 lines
197 KiB
JavaScript
6190 lines
197 KiB
JavaScript
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY VITE
|
|
if you want to view the source, please visit the github repository https://github.com/Myriad-Dreamin/typst.ts/blob/main/packages/typst.ts
|
|
*/
|
|
// Local CSP hardening: the generated wasm-bindgen glue requests only these
|
|
// trivial functions while constructing the Typst compiler. Keep JavaScript
|
|
// dynamic code generation disabled and fail closed if upstream adds another.
|
|
function createCspSafeFunction(...parts) {
|
|
const body = parts.pop();
|
|
if (parts.length === 0 && body === "return 0")
|
|
return () => 0;
|
|
if (parts.length === 0 && body === "return true")
|
|
return () => true;
|
|
if (parts.length === 1 && parts[0] === "path" && body === "return path")
|
|
return (path) => path;
|
|
const errors = {
|
|
"throw new Error('Dummy AccessModel, please initialize compiler with withAccessModel()')": "Dummy AccessModel, please initialize compiler with withAccessModel()",
|
|
"throw new Error('Dummy Registry, please initialize compiler with withPackageRegistry()')": "Dummy Registry, please initialize compiler with withPackageRegistry()"
|
|
};
|
|
if (parts.length === 0 && errors[body])
|
|
return () => {
|
|
throw new Error(errors[body]);
|
|
};
|
|
throw new Error("Unsupported dynamic function requested by the Typst compiler");
|
|
}
|
|
var gr = Object.defineProperty;
|
|
var fr = (r, e, t) => e in r ? gr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t;
|
|
var l = (r, e, t) => fr(r, typeof e != "symbol" ? e + "" : e, t);
|
|
const wr = [
|
|
"DejaVuSansMono-Bold.ttf",
|
|
"DejaVuSansMono-BoldOblique.ttf",
|
|
"DejaVuSansMono-Oblique.ttf",
|
|
"DejaVuSansMono.ttf",
|
|
"LibertinusSerif-Bold.otf",
|
|
"LibertinusSerif-BoldItalic.otf",
|
|
"LibertinusSerif-Italic.otf",
|
|
"LibertinusSerif-Regular.otf",
|
|
"LibertinusSerif-Semibold.otf",
|
|
"LibertinusSerif-SemiboldItalic.otf",
|
|
"NewCM10-Bold.otf",
|
|
"NewCM10-BoldItalic.otf",
|
|
"NewCM10-Italic.otf",
|
|
"NewCM10-Regular.otf",
|
|
"NewCMMath-Bold.otf",
|
|
"NewCMMath-Book.otf",
|
|
"NewCMMath-Regular.otf"
|
|
], hr = [
|
|
"InriaSerif-Bold.ttf",
|
|
"InriaSerif-BoldItalic.ttf",
|
|
"InriaSerif-Italic.ttf",
|
|
"InriaSerif-Regular.ttf",
|
|
"Roboto-Regular.ttf",
|
|
"NotoSerifCJKsc-Regular.otf"
|
|
], pr = ["TwitterColorEmoji.ttf", "NotoColorEmoji.ttf"];
|
|
function br() {
|
|
return ne([], { assets: !1 });
|
|
}
|
|
function mr(r) {
|
|
return ne([], r);
|
|
}
|
|
function yr(r) {
|
|
var t, n;
|
|
const e = [];
|
|
if (r && (r == null ? void 0 : r.assets) !== !1 && ((t = r == null ? void 0 : r.assets) != null && t.length) && ((n = r == null ? void 0 : r.assets) == null ? void 0 : n.length) > 0) {
|
|
let i = {
|
|
text: "https://cdn.jsdelivr.net/gh/typst/typst-assets@v0.13.1/files/fonts/",
|
|
_: "https://cdn.jsdelivr.net/gh/typst/typst-dev-assets@v0.13.1/files/fonts/"
|
|
}, s = r.assetUrlPrefix ?? i;
|
|
typeof s == "string" ? s = { _: s } : s = { ...i, ...s };
|
|
for (const a of Object.keys(s)) {
|
|
const d = s[a];
|
|
d[d.length - 1] !== "/" && (s[a] = d + "/");
|
|
}
|
|
const o = (a, d) => d.map((_) => (s[a] || s._) + _);
|
|
for (const a of r.assets)
|
|
switch (a) {
|
|
case "text":
|
|
e.push(...o(a, wr));
|
|
break;
|
|
case "cjk":
|
|
e.push(...o(a, hr));
|
|
break;
|
|
case "emoji":
|
|
e.push(...o(a, pr));
|
|
break;
|
|
}
|
|
}
|
|
return e;
|
|
}
|
|
function ne(r, e) {
|
|
const t = yr(e), n = async (i, { ref: s, builder: o }) => {
|
|
e != null && e.fetcher && s.setFetcher(e.fetcher), await s.loadFonts(o, [...r, ...t]);
|
|
};
|
|
return n._preloadRemoteFontOptions = e, n._kind = "fontLoader", n;
|
|
}
|
|
function Ze({ byFamily: r }) {
|
|
return async (e, { builder: t }) => {
|
|
const n = performance.now();
|
|
if ("queryLocalFonts" in window) {
|
|
const s = await window.queryLocalFonts();
|
|
r = r ?? [];
|
|
for (const o of s) {
|
|
if (!r.includes(o.family))
|
|
continue;
|
|
const a = await (await o.blob()).arrayBuffer();
|
|
await t.add_raw_font(new Uint8Array(a));
|
|
}
|
|
}
|
|
const i = performance.now();
|
|
console.log("preload system font time used:", i - n);
|
|
};
|
|
}
|
|
function fe(r) {
|
|
return async (e, { builder: t }) => new Promise((n) => {
|
|
t.set_package_registry(r, function(i) {
|
|
return r.resolve(i, this);
|
|
}), n();
|
|
});
|
|
}
|
|
function ze(r) {
|
|
return async (e, t) => {
|
|
var n;
|
|
if (t.alreadySetAccessModel)
|
|
throw new Error(
|
|
`already set some assess model before: ${(n = t.alreadySetAccessModel.constructor) == null ? void 0 : n.name}(${t.alreadySetAccessModel})`
|
|
);
|
|
return t.alreadySetAccessModel = r, new Promise((i) => {
|
|
t.builder.set_access_model(
|
|
r,
|
|
(s) => {
|
|
const o = r.getMTime(s);
|
|
return o ? o.getTime() : 0;
|
|
},
|
|
(s) => r.isFile(s) || !1,
|
|
(s) => r.getRealPath(s) || s,
|
|
(s) => r.readAll(s)
|
|
), i();
|
|
});
|
|
};
|
|
}
|
|
class vr {
|
|
constructor(e, t) {
|
|
l(this, "fullyCached");
|
|
l(this, "mTimes", /* @__PURE__ */ new Map());
|
|
l(this, "mRealPaths", /* @__PURE__ */ new Map());
|
|
l(this, "mData", /* @__PURE__ */ new Map());
|
|
this.root = e, e.endsWith("/") && (this.root = this.root.slice(0, this.root.length - 1)), t != null && t.polyfillHeadRequest, this.fullyCached = !!(t != null && t.fullyCached);
|
|
}
|
|
reset() {
|
|
this.mTimes.clear(), this.mRealPaths.clear(), this.mData.clear();
|
|
}
|
|
resolvePath(e) {
|
|
return this.root + e;
|
|
}
|
|
insertFile(e, t, n) {
|
|
this.mTimes.set(e, n), this.mData.set(e, t);
|
|
}
|
|
removeFile(e) {
|
|
this.mTimes.delete(e), this.mData.delete(e);
|
|
}
|
|
async getPreloadScript() {
|
|
const e = [];
|
|
e.push("((async () => {"), e.push(
|
|
"const snapshot = { root: '', mTimes: new Map(), mRealPaths: new Map(), mData: [],};"
|
|
), e.push("const runFetch = async (path) => {"), e.push(" const res = await fetch(snapshot.root + path);"), e.push(" const buffer = await res.arrayBuffer();"), e.push(" return [path, new Uint8Array(buffer)];"), e.push("};"), e.push(`snapshot.root = ${JSON.stringify(this.root)};`), e.push(
|
|
`snapshot.mTimes = new Map([${[...this.mTimes.entries()].map(([n, i]) => `[${JSON.stringify(n)}, ${(i == null ? void 0 : i.getTime()) || "undefined"}]`).join(", ")}]);`
|
|
), e.push(
|
|
`snapshot.mRealPaths = new Map([${[...this.mRealPaths.entries()].map(([n, i]) => `[${JSON.stringify(n)}, ${JSON.stringify(i)}]`).join(", ")}]);`
|
|
);
|
|
const t = await Promise.all(
|
|
[...this.mData.entries()].map(async ([n, i]) => (n = JSON.stringify(n), i ? `runFetch(${n})` : `Promise.resolve([${n}, undefined])`))
|
|
);
|
|
return e.push(`snapshot.mData = await Promise.all([${t.join(", ")}]);`), e.push("return snapshot;"), e.push("})())"), e.join(`
|
|
`);
|
|
}
|
|
getLastModified(e) {
|
|
const t = new XMLHttpRequest();
|
|
return t.open("HEAD", e, !1), t.send(null), t.status === 200 ? t.getResponseHeader("Last-Modified") : null;
|
|
}
|
|
getMTimeInternal(e) {
|
|
const t = this.getLastModified(this.resolvePath(e));
|
|
if (t)
|
|
return new Date(t);
|
|
}
|
|
getMTime(e) {
|
|
if (e.startsWith("/@memory/"))
|
|
return this.mTimes.has(e) ? this.mTimes.get(e) : void 0;
|
|
if (!this.fullyCached)
|
|
return this.getMTimeInternal(e);
|
|
if (this.mTimes.has(e))
|
|
return this.mTimes.get(e);
|
|
const t = this.getMTimeInternal(e);
|
|
return this.mTimes.set(e, t), t;
|
|
}
|
|
// todo: isFile
|
|
isFile() {
|
|
return !0;
|
|
}
|
|
// todo: getRealPath
|
|
getRealPath(e) {
|
|
return e;
|
|
}
|
|
readAllInternal(e) {
|
|
const t = new XMLHttpRequest();
|
|
if (t.overrideMimeType("text/plain; charset=x-user-defined"), t.open("GET", this.resolvePath(e), !1), t.send(null), t.status === 200 && (t.response instanceof String || typeof t.response == "string"))
|
|
return Uint8Array.from(t.response, (n) => n.charCodeAt(0));
|
|
}
|
|
readAll(e) {
|
|
if (e.startsWith("/@memory/"))
|
|
return this.mData.has(e) ? this.mData.get(e) : void 0;
|
|
if (!this.fullyCached)
|
|
return this.readAllInternal(e);
|
|
if (this.mData.has(e))
|
|
return this.mData.get(e);
|
|
const t = this.readAllInternal(e);
|
|
return this.mData.set(e, t), t;
|
|
}
|
|
}
|
|
class qe {
|
|
constructor() {
|
|
l(this, "mTimes", /* @__PURE__ */ new Map());
|
|
l(this, "mData", /* @__PURE__ */ new Map());
|
|
}
|
|
reset() {
|
|
this.mTimes.clear(), this.mData.clear();
|
|
}
|
|
insertFile(e, t, n) {
|
|
this.mTimes.set(e, n), this.mData.set(e, t);
|
|
}
|
|
removeFile(e) {
|
|
this.mTimes.delete(e), this.mData.delete(e);
|
|
}
|
|
getMTime(e) {
|
|
if (e.startsWith("/@memory/") && this.mTimes.has(e))
|
|
return this.mTimes.get(e);
|
|
}
|
|
isFile() {
|
|
return !0;
|
|
}
|
|
getRealPath(e) {
|
|
return e;
|
|
}
|
|
readAll(e) {
|
|
if (e.startsWith("/@memory/") && this.mData.has(e))
|
|
return this.mData.get(e);
|
|
}
|
|
}
|
|
class Ne {
|
|
constructor(e) {
|
|
l(this, "cache", /* @__PURE__ */ new Map());
|
|
this.am = e;
|
|
}
|
|
resolvePath(e) {
|
|
return `https://packages.typst.org/preview/${e.name}-${e.version}.tar.gz`;
|
|
}
|
|
pullPackageData(e) {
|
|
const t = new XMLHttpRequest();
|
|
if (t.overrideMimeType("text/plain; charset=x-user-defined"), t.open("GET", this.resolvePath(e), !1), t.send(null), t.status === 200 && (t.response instanceof String || typeof t.response == "string"))
|
|
return Uint8Array.from(t.response, (n) => n.charCodeAt(0));
|
|
}
|
|
resolve(e, t) {
|
|
if (e.namespace !== "preview")
|
|
return;
|
|
const n = this.resolvePath(e);
|
|
if (this.cache.has(n))
|
|
return this.cache.get(n)();
|
|
const i = this.pullPackageData(e);
|
|
if (!i)
|
|
return;
|
|
const s = `/@memory/fetch/packages/preview/${e.namespace}/${e.name}/${e.version}`, o = [];
|
|
t.untar(i, (d, _, f) => {
|
|
o.push([s + "/" + d, _, new Date(f)]);
|
|
});
|
|
const a = () => {
|
|
for (const [d, _, f] of o)
|
|
this.am.insertFile(d, _, f);
|
|
return s;
|
|
};
|
|
return this.cache.set(n, a), a();
|
|
}
|
|
}
|
|
function Sr(r) {
|
|
return Math.random().toString(36).replace("0.", "");
|
|
}
|
|
const Cr = (
|
|
// @ts-ignore
|
|
typeof process < "u" && process.versions != null && process.versions.node != null
|
|
);
|
|
class U {
|
|
/**
|
|
* Create a new instance of {@link TypstSnippet}.
|
|
* @param cc the compiler instance, see {@link PromiseJust} and {@link TypstCompiler}.
|
|
* @param ex the renderer instance, see {@link PromiseJust} and {@link TypstRenderer}.
|
|
*
|
|
* @example
|
|
*
|
|
* Passes a global shared compiler instance that get initialized lazily:
|
|
* ```typescript
|
|
* const $typst = new TypstSnippet(() => {
|
|
* return createGlobalCompiler(createTypstCompiler, initOptions);
|
|
* });
|
|
*
|
|
*/
|
|
constructor(e) {
|
|
/** @internal */
|
|
l(this, "mainFilePath");
|
|
/** @internal */
|
|
l(this, "cc");
|
|
/** @internal */
|
|
l(this, "ex");
|
|
l(this, "providers");
|
|
/** @internal */
|
|
l(this, "ccOptions");
|
|
/** @internal */
|
|
l(this, "exOptions");
|
|
this.cc = (e == null ? void 0 : e.compiler) || U.buildLocalCompiler, this.ex = (e == null ? void 0 : e.renderer) || U.buildLocalRenderer, this.mainFilePath = "/main.typ", this.providers = [];
|
|
}
|
|
/**
|
|
* Set lazy initialized compiler instance for the utility instance.
|
|
* @param cc the compiler instance, see {@link PromiseJust} and {@link TypstCompiler}.
|
|
*/
|
|
setCompiler(e) {
|
|
this.cc = e;
|
|
}
|
|
/**
|
|
* Get an initialized compiler instance from the utility instance.
|
|
*/
|
|
async getCompiler() {
|
|
return typeof this.cc == "function" ? this.cc = await this.cc() : this.cc;
|
|
}
|
|
/**
|
|
* Set lazy initialized renderer instance for the utility instance.
|
|
* @param ex the renderer instance, see {@link PromiseJust} and {@link TypstRenderer}.
|
|
*/
|
|
setRenderer(e) {
|
|
this.ex = e;
|
|
}
|
|
/**
|
|
* Get an initialized renderer instance from the utility instance.
|
|
*/
|
|
async getRenderer() {
|
|
return typeof this.ex == "function" ? this.ex = await this.ex() : this.ex;
|
|
}
|
|
/**
|
|
* add providers for bullding the compiler or renderer component.
|
|
*/
|
|
use(...e) {
|
|
if (!this.providers)
|
|
throw new Error("already prepare uses for instances");
|
|
this.providers.push(...e);
|
|
}
|
|
/**
|
|
* todo: add docs
|
|
*/
|
|
static preloadFontFromUrl(e) {
|
|
return U.preloadFonts([e]);
|
|
}
|
|
/**
|
|
* todo: add docs
|
|
*/
|
|
static preloadFontData(e) {
|
|
return U.preloadFonts([e]);
|
|
}
|
|
/**
|
|
* todo: add docs
|
|
*/
|
|
static preloadFonts(e) {
|
|
return {
|
|
key: "access-model",
|
|
forRoles: ["compiler"],
|
|
provides: [ne(e)]
|
|
};
|
|
}
|
|
/**
|
|
* don't load any default font assets.
|
|
* todo: add docs
|
|
*/
|
|
static disableDefaultFontAssets() {
|
|
return {
|
|
key: "access-model",
|
|
forRoles: ["compiler"],
|
|
provides: [br()]
|
|
};
|
|
}
|
|
/**
|
|
* todo: add docs
|
|
*/
|
|
static preloadFontAssets(e) {
|
|
return {
|
|
key: "access-model",
|
|
forRoles: ["compiler"],
|
|
provides: [mr(e)]
|
|
};
|
|
}
|
|
/**
|
|
* Set accessl model for the compiler instance
|
|
* @example
|
|
*
|
|
* use memory access model
|
|
*
|
|
* ```typescript
|
|
* const m = new MemoryAccessModel();
|
|
* $typst.use(TypstSnippet.withAccessModel(m));
|
|
* ```
|
|
*/
|
|
static withAccessModel(e) {
|
|
return {
|
|
key: "access-model",
|
|
forRoles: ["compiler"],
|
|
provides: [ze(e)]
|
|
};
|
|
}
|
|
/**
|
|
* Set package registry for the compiler instance
|
|
* @example
|
|
*
|
|
* use a customized package registry
|
|
*
|
|
* ```typescript
|
|
* const n = new NodeFetchPackageRegistry();
|
|
* $typst.use(TypstSnippet.withPackageRegistry(n));
|
|
* ```
|
|
*/
|
|
static withPackageRegistry(e) {
|
|
return {
|
|
key: "package-registry",
|
|
forRoles: ["compiler"],
|
|
provides: [fe(e)]
|
|
};
|
|
}
|
|
/**
|
|
* Retrieve an access model to store the data of fetched files.
|
|
* Provide a PackageRegistry instance for the compiler instance.
|
|
*
|
|
* @example
|
|
*
|
|
* use default (memory) access model
|
|
*
|
|
* ```typescript
|
|
* $typst.use(await TypstSnippet.fetchPackageRegistry());
|
|
* ```
|
|
*
|
|
* @example
|
|
*
|
|
* use external access model
|
|
*
|
|
* ```typescript
|
|
* const m = new MemoryAccessModel();
|
|
* $typst.use(TypstSnippet.withAccessModel(m), await TypstSnippet.fetchPackageRegistry(m));
|
|
* ```
|
|
*/
|
|
static fetchPackageRegistry(e) {
|
|
const t = e || new qe(), n = [
|
|
...e ? [] : [ze(t)],
|
|
fe(new Ne(t))
|
|
];
|
|
return {
|
|
key: "package-registry$fetch",
|
|
forRoles: ["compiler"],
|
|
provides: n
|
|
};
|
|
}
|
|
/**
|
|
* Retrieve a fetcher for fetching package data.
|
|
* Provide a PackageRegistry instance for the compiler instance.
|
|
* @example
|
|
*
|
|
* use a customized fetcher
|
|
*
|
|
* ```typescript
|
|
* import request from 'sync-request-curl';
|
|
* const m = new MemoryAccessModel();
|
|
* $typst.use(TypstSnippet.withAccessModel(m), await TypstSnippet.fetchPackageBy(m, (_, httpUrl) => {
|
|
* const response = request('GET', this.resolvePath(path), {
|
|
* insecure: true,
|
|
* });
|
|
*
|
|
* if (response.statusCode === 200) {
|
|
* return response.getBody(undefined);
|
|
* }
|
|
* return undefined;
|
|
* }));
|
|
* ```
|
|
*/
|
|
static fetchPackageBy(e, t) {
|
|
class n extends Ne {
|
|
pullPackageData(s) {
|
|
return t(s, this.resolvePath(s));
|
|
}
|
|
}
|
|
return {
|
|
key: "package-registry$lambda",
|
|
forRoles: ["compiler"],
|
|
provides: [fe(new n(e))]
|
|
};
|
|
}
|
|
/**
|
|
* Set compiler init options for initializing global instance {@link $typst}.
|
|
* See {@link InitOptions}.
|
|
*/
|
|
setCompilerInitOptions(e) {
|
|
this.requireIsUninitialized("compiler", this.cc), this.ccOptions = e;
|
|
}
|
|
/**
|
|
* Set renderer init options for initializing global instance {@link $typst}.
|
|
* See {@link InitOptions}.
|
|
*/
|
|
setRendererInitOptions(e) {
|
|
this.requireIsUninitialized("renderer", this.ex), this.exOptions = e;
|
|
}
|
|
/**
|
|
* Set shared main file path.
|
|
*/
|
|
setMainFilePath(e) {
|
|
this.mainFilePath = e;
|
|
}
|
|
/**
|
|
* Get shared main file path.
|
|
*/
|
|
getMainFilePath() {
|
|
return this.mainFilePath;
|
|
}
|
|
removeTmp(e) {
|
|
return e.mainFilePath.startsWith("/tmp/") ? this.unmapShadow(e.mainFilePath) : Promise.resolve();
|
|
}
|
|
/**
|
|
* Add a source file to the compiler.
|
|
* See {@link TypstCompiler#addSource}.
|
|
*/
|
|
async addSource(e, t) {
|
|
(await this.getCompiler()).addSource(e, t);
|
|
}
|
|
/**
|
|
* Reset the shadow files.
|
|
* Note: this function is independent to the {@link reset} function.
|
|
* See {@link TypstCompiler#resetShadow}.
|
|
*/
|
|
async resetShadow() {
|
|
(await this.getCompiler()).resetShadow();
|
|
}
|
|
/**
|
|
* Add a shadow file to the compiler.
|
|
* See {@link TypstCompiler#mapShadow}.
|
|
*/
|
|
async mapShadow(e, t) {
|
|
(await this.getCompiler()).mapShadow(e, t);
|
|
}
|
|
/**
|
|
* Remove a shadow file from the compiler.
|
|
* See {@link TypstCompiler#unmapShadow}.
|
|
*/
|
|
async unmapShadow(e) {
|
|
(await this.getCompiler()).unmapShadow(e);
|
|
}
|
|
/**
|
|
* Compile the document to vector (IR) format.
|
|
* See {@link SweetCompileOptions}.
|
|
*/
|
|
async vector(e) {
|
|
const t = await this.getCompileOptions(e);
|
|
return (await this.getCompiler()).compile(t).then((n) => n.result).finally(() => this.removeTmp(t));
|
|
}
|
|
/**
|
|
* Compile the document to PDF format.
|
|
* See {@link SweetCompileOptions}.
|
|
*/
|
|
async pdf(e) {
|
|
const t = await this.getCompileOptions(e);
|
|
return t.format = "pdf", (await this.getCompiler()).compile(t).then((n) => n.result).finally(() => this.removeTmp(t));
|
|
}
|
|
/**
|
|
* Compile the document to SVG format.
|
|
* See {@link SweetRenderOptions} and {@link RenderSvgOptions}.
|
|
*/
|
|
async svg(e) {
|
|
return this.transientRender(
|
|
e,
|
|
(t, n) => t.renderSvg({
|
|
...e,
|
|
renderSession: n
|
|
})
|
|
);
|
|
}
|
|
/**
|
|
* Compile the document to canvas operations.
|
|
* See {@link SweetRenderOptions} and {@link RenderToCanvasOptions}.
|
|
*/
|
|
async canvas(e, t) {
|
|
return this.transientRender(
|
|
t,
|
|
(n, i) => n.renderToCanvas({
|
|
container: e,
|
|
...t,
|
|
renderSession: i
|
|
})
|
|
);
|
|
}
|
|
/**
|
|
* Get semantic tokens for the document.
|
|
*/
|
|
async query(e) {
|
|
const t = await this.getCompileOptions(e);
|
|
return (await this.getCompiler()).query({
|
|
...e,
|
|
...t
|
|
}).finally(() => this.removeTmp(t));
|
|
}
|
|
/**
|
|
* Get token legend for semantic tokens.
|
|
*/
|
|
async getSemanticTokenLegend() {
|
|
return (await this.getCompiler()).getSemanticTokenLegend();
|
|
}
|
|
/**
|
|
* Get semantic tokens for the document.
|
|
* See {@link SweetCompileOptions}.
|
|
* See {@link TypstCompiler#getSemanticTokens}.
|
|
*/
|
|
async getSemanticTokens(e) {
|
|
const t = await this.getCompileOptions(e);
|
|
return (await this.getCompiler()).getSemanticTokens({
|
|
mainFilePath: t.mainFilePath,
|
|
resultId: e.resultId
|
|
}).finally(() => this.removeTmp(t));
|
|
}
|
|
async getCompileOptions(e) {
|
|
if (e === void 0)
|
|
return { mainFilePath: this.mainFilePath, diagnostics: "none" };
|
|
if (typeof e == "string")
|
|
throw new Error("please specify opts as {mainContent: '...'} or {mainFilePath: '...'}");
|
|
if ("mainFilePath" in e)
|
|
return { ...e, diagnostics: "none" };
|
|
{
|
|
const t = `/tmp/${Sr()}.typ`;
|
|
return await this.addSource(t, e.mainContent), { mainFilePath: t, inputs: e.inputs, diagnostics: "none" };
|
|
}
|
|
}
|
|
async getVector(e) {
|
|
if (e && "vectorData" in e)
|
|
return e.vectorData;
|
|
const t = await this.getCompileOptions(e);
|
|
return (await this.getCompiler()).compile(t).then((n) => n.result).finally(() => this.removeTmp(t));
|
|
}
|
|
async transientRender(e, t) {
|
|
const n = await this.getRenderer();
|
|
if (!n)
|
|
throw new Error("does not provide renderer instance");
|
|
const i = await this.getVector(e);
|
|
return await n.runWithSession(async (s) => (n.manipulateData({
|
|
renderSession: s,
|
|
action: "reset",
|
|
data: i
|
|
}), t(n, s)));
|
|
}
|
|
async prepareUse() {
|
|
if (!this.providers)
|
|
return;
|
|
const e = await Promise.all(
|
|
this.providers.map((a) => typeof a == "function" ? a() : a)
|
|
);
|
|
if (this.providers = [], we == this && !e.some((a) => a.key.includes("package-registry") || a.key.includes("access-model")))
|
|
if (Cr) {
|
|
const a = (m) => import(m);
|
|
try {
|
|
const d = new qe(), { default: _ } = await a("sync-request");
|
|
we.use(
|
|
U.withAccessModel(d),
|
|
U.fetchPackageBy(d, (f, w) => {
|
|
const P = _("GET", w);
|
|
if (P.statusCode === 200)
|
|
return P.getBody(void 0);
|
|
})
|
|
);
|
|
} catch {
|
|
}
|
|
} else
|
|
we.use(U.fetchPackageRegistry());
|
|
const t = await Promise.all(
|
|
this.providers.map((a) => typeof a == "function" ? a() : a)
|
|
), n = this.ccOptions || (this.ccOptions = {}), i = n.beforeBuild || (n.beforeBuild = []), s = this.exOptions || (this.exOptions = {}), o = s.beforeBuild || (s.beforeBuild = []);
|
|
for (const a of [...e, ...t])
|
|
a.forRoles.includes("compiler") && (this.requireIsUninitialized("compiler", this.cc), i.push(...a.provides)), a.forRoles.includes("renderer") && (this.requireIsUninitialized("renderer", this.ex), o.push(...a.provides));
|
|
this.providers = void 0;
|
|
}
|
|
requireIsUninitialized(e, t, n) {
|
|
if (t && typeof t != "function")
|
|
throw new Error(`${e} has been initialized: ${t}`);
|
|
}
|
|
/** @internal */
|
|
static async buildLocalCompiler() {
|
|
const { createTypstCompiler: e } = await Promise.resolve().then(() => at);
|
|
await this.prepareUse();
|
|
const t = e();
|
|
return await t.init(this.ccOptions), t;
|
|
}
|
|
/** @internal */
|
|
static async buildGlobalCompiler() {
|
|
const { createGlobalCompiler: e } = await Promise.resolve().then(() => rn), { createTypstCompiler: t } = await Promise.resolve().then(() => at);
|
|
return await this.prepareUse(), e(t, this.ccOptions);
|
|
}
|
|
/** @internal */
|
|
static async buildLocalRenderer() {
|
|
const { createTypstRenderer: e } = await Promise.resolve().then(() => ut);
|
|
await this.prepareUse();
|
|
const t = e();
|
|
return await t.init(this.exOptions), t;
|
|
}
|
|
/** @internal */
|
|
static async buildGlobalRenderer() {
|
|
const { createGlobalRenderer: e } = await Promise.resolve().then(() => fn), { createTypstRenderer: t } = await Promise.resolve().then(() => ut);
|
|
return await this.prepareUse(), e(t, this.exOptions);
|
|
}
|
|
}
|
|
const we = new U({
|
|
compiler: U.buildGlobalCompiler,
|
|
renderer: U.buildGlobalRenderer
|
|
}), R = Symbol.for("reflexo-obj");
|
|
var Ge = /* @__PURE__ */ ((r) => (r[r.PIXEL_PER_PT = 3] = "PIXEL_PER_PT", r))(Ge || {});
|
|
let Ot = class {
|
|
constructor(e, t, n) {
|
|
l(this, "loadPageCount");
|
|
l(this, "imageScaleFactor");
|
|
l(this, "container");
|
|
l(this, "canvasList");
|
|
l(this, "textLayerList");
|
|
l(this, "commonList");
|
|
l(this, "textLayerParentList");
|
|
l(this, "semanticLayerList");
|
|
this.pageInfos = e, this.imageScaleFactor = n.pixelPerPt ?? Ge.PIXEL_PER_PT, t.innerHTML = "", t.style.width = "100%", this.container = t, this.canvasList = new Array(this.loadPageCount), this.textLayerList = new Array(this.loadPageCount), this.commonList = new Array(this.loadPageCount), this.textLayerParentList = new Array(this.loadPageCount), this.semanticLayerList = new Array(this.loadPageCount);
|
|
const i = (s, o, a) => {
|
|
const d = Math.ceil(o.width) * this.imageScaleFactor, _ = Math.ceil(o.height) * this.imageScaleFactor, f = this.canvasList[s] = document.createElement("canvas"), w = this.semanticLayerList[s] = document.createElement("div"), P = this.textLayerList[s] = document.createElement("div"), C = this.textLayerParentList[s] = document.createElement("div");
|
|
if (f.getContext("2d")) {
|
|
const A = document.createElement("div");
|
|
f.width = d, f.height = _, A.appendChild(f), a.appendChild(A), A.style.position = "absolute";
|
|
}
|
|
{
|
|
C.appendChild(P), C.className = "typst-html-semantics";
|
|
const A = t.offsetWidth, $ = A / o.width;
|
|
C.style.width = `${A}px`, C.style.height = `${o.height * $}px`, C.style.setProperty("--data-text-width", `${$}px`), C.style.setProperty("--data-text-height", `${$}px`), a.classList.add("typst-page"), a.classList.add("canvas"), a.style.width = `${A}px`, a.style.height = `${_ * $}px`, a.style.position = "relative", w.appendChild(C), a.appendChild(w);
|
|
}
|
|
};
|
|
for (let s = 0; s < this.pageInfos.length; s++) {
|
|
const o = this.pageInfos[s];
|
|
let a;
|
|
a = this.commonList[s] = document.createElement("div"), t.appendChild(a), i(s, o, a);
|
|
}
|
|
}
|
|
resetLayout() {
|
|
for (let e = 0; e < this.pageInfos.length; e++) {
|
|
const t = this.pageInfos[e], n = Math.ceil(t.width) * this.imageScaleFactor, i = Math.ceil(t.height) * this.imageScaleFactor, s = this.canvasList[e].parentElement;
|
|
if (!s)
|
|
throw new Error(
|
|
`canvasDiv is null for page ${e}, canvas list length ${this.canvasList.length}`
|
|
);
|
|
const o = this.commonList[e], a = this.textLayerParentList[e], d = this.container.offsetWidth, _ = d / n;
|
|
a.style.width = `${d}px`, a.style.height = `${i * _}px`, o.style.width = `${d}px`, o.style.height = `${i * _}px`;
|
|
const f = this.container.offsetWidth / n;
|
|
s.style.transformOrigin = "0px 0px", s.style.transform = `scale(${f})`;
|
|
}
|
|
}
|
|
};
|
|
const xr = (r) => {
|
|
let e = !1, t;
|
|
return () => e ? t : (e = !0, t = r());
|
|
};
|
|
let Ft = class {
|
|
constructor(e) {
|
|
l(this, "wasmBin");
|
|
l(this, "initOnce");
|
|
if (typeof e != "function")
|
|
throw new Error("initFn is not a function");
|
|
this.initOnce = xr(async () => {
|
|
await e(this.wasmBin);
|
|
});
|
|
}
|
|
async init(e) {
|
|
this.wasmBin = e, await this.initOnce();
|
|
}
|
|
};
|
|
const kr = (r, e) => e.some((t) => r instanceof t);
|
|
let et, tt;
|
|
function Rr() {
|
|
return et || (et = [
|
|
IDBDatabase,
|
|
IDBObjectStore,
|
|
IDBIndex,
|
|
IDBCursor,
|
|
IDBTransaction
|
|
]);
|
|
}
|
|
function Er() {
|
|
return tt || (tt = [
|
|
IDBCursor.prototype.advance,
|
|
IDBCursor.prototype.continue,
|
|
IDBCursor.prototype.continuePrimaryKey
|
|
]);
|
|
}
|
|
const Dt = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), $t = /* @__PURE__ */ new WeakMap(), Le = /* @__PURE__ */ new WeakMap(), Qe = /* @__PURE__ */ new WeakMap();
|
|
function Pr(r) {
|
|
const e = new Promise((t, n) => {
|
|
const i = () => {
|
|
r.removeEventListener("success", s), r.removeEventListener("error", o);
|
|
}, s = () => {
|
|
t(ae(r.result)), i();
|
|
}, o = () => {
|
|
n(r.error), i();
|
|
};
|
|
r.addEventListener("success", s), r.addEventListener("error", o);
|
|
});
|
|
return e.then((t) => {
|
|
t instanceof IDBCursor && Dt.set(t, r);
|
|
}).catch(() => {
|
|
}), Qe.set(e, r), e;
|
|
}
|
|
function Ir(r) {
|
|
if (Ue.has(r))
|
|
return;
|
|
const e = new Promise((t, n) => {
|
|
const i = () => {
|
|
r.removeEventListener("complete", s), r.removeEventListener("error", o), r.removeEventListener("abort", o);
|
|
}, s = () => {
|
|
t(), i();
|
|
}, o = () => {
|
|
n(r.error || new DOMException("AbortError", "AbortError")), i();
|
|
};
|
|
r.addEventListener("complete", s), r.addEventListener("error", o), r.addEventListener("abort", o);
|
|
});
|
|
Ue.set(r, e);
|
|
}
|
|
let He = {
|
|
get(r, e, t) {
|
|
if (r instanceof IDBTransaction) {
|
|
if (e === "done")
|
|
return Ue.get(r);
|
|
if (e === "objectStoreNames")
|
|
return r.objectStoreNames || $t.get(r);
|
|
if (e === "store")
|
|
return t.objectStoreNames[1] ? void 0 : t.objectStore(t.objectStoreNames[0]);
|
|
}
|
|
return ae(r[e]);
|
|
},
|
|
set(r, e, t) {
|
|
return r[e] = t, !0;
|
|
},
|
|
has(r, e) {
|
|
return r instanceof IDBTransaction && (e === "done" || e === "store") ? !0 : e in r;
|
|
}
|
|
};
|
|
function Mr(r) {
|
|
He = r(He);
|
|
}
|
|
function Lr(r) {
|
|
return r === IDBDatabase.prototype.transaction && !("objectStoreNames" in IDBTransaction.prototype) ? function(e, ...t) {
|
|
const n = r.call(Ae(this), e, ...t);
|
|
return $t.set(n, e.sort ? e.sort() : [e]), ae(n);
|
|
} : Er().includes(r) ? function(...e) {
|
|
return r.apply(Ae(this), e), ae(Dt.get(this));
|
|
} : function(...e) {
|
|
return ae(r.apply(Ae(this), e));
|
|
};
|
|
}
|
|
function Ar(r) {
|
|
return typeof r == "function" ? Lr(r) : (r instanceof IDBTransaction && Ir(r), kr(r, Rr()) ? new Proxy(r, He) : r);
|
|
}
|
|
function ae(r) {
|
|
if (r instanceof IDBRequest)
|
|
return Pr(r);
|
|
if (Le.has(r))
|
|
return Le.get(r);
|
|
const e = Ar(r);
|
|
return e !== r && (Le.set(r, e), Qe.set(e, r)), e;
|
|
}
|
|
const Ae = (r) => Qe.get(r), Tr = ["get", "getKey", "getAll", "getAllKeys", "count"], Or = ["put", "add", "delete", "clear"], Te = /* @__PURE__ */ new Map();
|
|
function rt(r, e) {
|
|
if (!(r instanceof IDBDatabase && !(e in r) && typeof e == "string"))
|
|
return;
|
|
if (Te.get(e))
|
|
return Te.get(e);
|
|
const t = e.replace(/FromIndex$/, ""), n = e !== t, i = Or.includes(t);
|
|
if (
|
|
// Bail if the target doesn't exist on the target. Eg, getAll isn't in Edge.
|
|
!(t in (n ? IDBIndex : IDBObjectStore).prototype) || !(i || Tr.includes(t))
|
|
)
|
|
return;
|
|
const s = async function(o, ...a) {
|
|
const d = this.transaction(o, i ? "readwrite" : "readonly");
|
|
let _ = d.store;
|
|
return n && (_ = _.index(a.shift())), (await Promise.all([
|
|
_[t](...a),
|
|
i && d.done
|
|
]))[0];
|
|
};
|
|
return Te.set(e, s), s;
|
|
}
|
|
Mr((r) => ({
|
|
...r,
|
|
get: (e, t, n) => rt(e, t) || r.get(e, t, n),
|
|
has: (e, t) => !!rt(e, t) || r.has(e, t)
|
|
}));
|
|
let Fr = class {
|
|
constructor() {
|
|
l(this, "loadedFonts", /* @__PURE__ */ new Set());
|
|
l(this, "fetcher", fetch);
|
|
}
|
|
setFetcher(e) {
|
|
this.fetcher = e;
|
|
}
|
|
async loadFonts(e, t) {
|
|
const n = (m) => import(m), i = this.fetcher || (this.fetcher = await async function() {
|
|
const { fetchBuilder: a, FileSystemCache: d } = await n("node-fetch-cache"), _ = new d({
|
|
/// By default, we don't have a complicated cache policy.
|
|
cacheDirectory: ".cache/typst/fonts"
|
|
}), f = a.withCache(_);
|
|
return function(w, P) {
|
|
const C = setTimeout(() => {
|
|
console.warn("font fetching is stucking:", w);
|
|
}, 15e3);
|
|
return f(w, P).finally(() => {
|
|
clearTimeout(C);
|
|
});
|
|
};
|
|
}()), s = t.filter((a) => a instanceof Uint8Array ? !0 : this.loadedFonts.has(a) ? !1 : (this.loadedFonts.add(a), !0)), o = await Promise.all(
|
|
s.map(async (a) => {
|
|
if (a instanceof Uint8Array) {
|
|
await e.add_raw_font(a);
|
|
return;
|
|
}
|
|
return new Uint8Array(await (await i(a)).arrayBuffer());
|
|
})
|
|
);
|
|
for (const a of o)
|
|
a && await e.add_raw_font(a);
|
|
}
|
|
async build(e, t, n) {
|
|
const i = { ref: this, builder: t, hooks: n };
|
|
for (const o of (e == null ? void 0 : e.beforeBuild) ?? [])
|
|
await o(void 0, i);
|
|
return n.latelyBuild && n.latelyBuild(i), await t.build();
|
|
}
|
|
};
|
|
async function jt(r, e, t, n) {
|
|
var i;
|
|
return await e.init((i = r == null ? void 0 : r.getModule) == null ? void 0 : i.call(r)), await new Fr().build(r, new t(), n);
|
|
}
|
|
let Dr = class Bt {
|
|
constructor(e) {
|
|
l(this, "hookedElem");
|
|
l(this, "kModule");
|
|
l(this, "opts");
|
|
l(this, "modes", []);
|
|
/// Configuration fields
|
|
/// enable partial rendering
|
|
l(this, "partialRendering", !0);
|
|
/// underlying renderer
|
|
l(this, "renderMode", "svg");
|
|
l(this, "r");
|
|
/// preview mode
|
|
l(this, "previewMode", 0);
|
|
/// whether this is a content preview
|
|
l(this, "isContentPreview", !1);
|
|
/// whether this content preview will mix outline titles
|
|
l(this, "isMixinOutline", !1);
|
|
/// background color
|
|
l(this, "backgroundColor", "black");
|
|
/// default page color (empty string means transparent)
|
|
l(this, "pageColor", "white");
|
|
/// pixel per pt
|
|
l(this, "pixelPerPt", 3);
|
|
/// customized way to retrieving dom state
|
|
l(this, "retrieveDOMState");
|
|
/// State fields
|
|
/// whether svg is updating (in triggerSvgUpdate)
|
|
l(this, "isRendering", !1);
|
|
/// whether kModule is initialized
|
|
l(this, "moduleInitialized", !1);
|
|
/// patch queue for updating data.
|
|
l(this, "patchQueue", []);
|
|
/// resources to dispose
|
|
l(this, "disposeList", []);
|
|
/// canvas render ctoken
|
|
l(this, "canvasRenderCToken");
|
|
/// There are two scales in this class: The real scale is to adjust the size
|
|
/// of `hookedElem` to fit the svg. The virtual scale (scale ratio) is to let
|
|
/// user zoom in/out the svg. For example:
|
|
/// + the default value of virtual scale is 1, which means the svg is totally
|
|
/// fit in `hookedElem`.
|
|
/// + if user set virtual scale to 0.5, then the svg will be zoomed out to fit
|
|
/// in half width of `hookedElem`. "real" current scale of `hookedElem`
|
|
l(this, "currentRealScale", 1);
|
|
/// "virtual" current scale of `hookedElem`
|
|
l(this, "currentScaleRatio", 1);
|
|
/// timeout for delayed viewport change
|
|
l(this, "vpTimeout");
|
|
/// sampled by last render time.
|
|
l(this, "sampledRenderTime", 0);
|
|
/// page to partial render
|
|
l(this, "partialRenderPage", 0);
|
|
/// outline data
|
|
l(this, "outline");
|
|
/// cursor position in form of [page, x, y]
|
|
l(this, "cursorPosition");
|
|
// id: number = rnd++;
|
|
/// Cache fields
|
|
/// cached state of container, default to retrieve state from `this.hookedElem`
|
|
l(this, "cachedDOMState", {
|
|
width: 0,
|
|
height: 0,
|
|
window: {
|
|
innerWidth: 0,
|
|
innerHeight: 0
|
|
},
|
|
boundingRect: {
|
|
left: 0,
|
|
top: 0,
|
|
right: 0
|
|
}
|
|
});
|
|
var t, n;
|
|
this.hookedElem = e.hookedElem, this.kModule = e.kModule, this.opts = e || {};
|
|
{
|
|
const { renderMode: i, previewMode: s, isContentPreview: o, retrieveDOMState: a } = e || {};
|
|
this.partialRendering = !1, this.renderMode = i ?? this.renderMode, this.previewMode = s ?? this.previewMode, this.isContentPreview = o || !1, this.retrieveDOMState = a ?? (() => ({
|
|
width: this.hookedElem.offsetWidth,
|
|
height: this.hookedElem.offsetHeight,
|
|
window: {
|
|
innerWidth: window.innerWidth,
|
|
innerHeight: window.innerHeight
|
|
},
|
|
boundingRect: this.hookedElem.getBoundingClientRect()
|
|
})), this.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue(
|
|
"--typst-preview-background-color"
|
|
);
|
|
}
|
|
this.hookedElem.classList.add("hide-scrollbar-x"), (t = this.hookedElem.parentElement) == null || t.classList.add("hide-scrollbar-x"), this.previewMode === 1 && (this.hookedElem.classList.add("hide-scrollbar-y"), (n = this.hookedElem.parentElement) == null || n.classList.add("hide-scrollbar-y")), this.installCtrlWheelHandler();
|
|
}
|
|
reset() {
|
|
this.kModule.reset(), this.moduleInitialized = !1;
|
|
}
|
|
dispose() {
|
|
const e = this.disposeList;
|
|
this.disposeList = [], e.forEach((t) => t());
|
|
}
|
|
static derive(e, t) {
|
|
return ["rescale", "rerender", "postRender"].reduce((n, i) => (n[i] = e[`${i}$${t}`].bind(e), console.assert(n[i] !== void 0, `${i}$${t} is undefined`), n), {});
|
|
}
|
|
registerMode(e) {
|
|
const t = Bt.derive(this, e);
|
|
this.modes.push([e, t]), e === this.renderMode && (this.r = t);
|
|
}
|
|
installCtrlWheelHandler() {
|
|
const e = [
|
|
0.1,
|
|
0.2,
|
|
0.3,
|
|
0.4,
|
|
0.5,
|
|
0.6,
|
|
0.7,
|
|
0.8,
|
|
0.9,
|
|
1,
|
|
1.1,
|
|
1.3,
|
|
1.5,
|
|
1.7,
|
|
1.9,
|
|
2.1,
|
|
2.4,
|
|
2.7,
|
|
3,
|
|
3.3,
|
|
3.7,
|
|
4.1,
|
|
4.6,
|
|
5.1,
|
|
5.7,
|
|
6.3,
|
|
7,
|
|
7.7,
|
|
8.5,
|
|
9.4,
|
|
10
|
|
], t = (n) => {
|
|
var i, s, o, a;
|
|
if (n.ctrlKey) {
|
|
n.preventDefault(), this.cachedDOMState = this.retrieveDOMState(), window.onresize !== null && (window.onresize = null);
|
|
const d = this.currentScaleRatio;
|
|
if (n.deltaY < 0) {
|
|
if (this.currentScaleRatio >= e.at(-1))
|
|
return;
|
|
this.currentScaleRatio = e.filter((C) => C > this.currentScaleRatio).at(0);
|
|
} else if (n.deltaY > 0) {
|
|
if (this.currentScaleRatio <= e.at(0))
|
|
return;
|
|
this.currentScaleRatio = e.filter((C) => C < this.currentScaleRatio).at(-1);
|
|
} else
|
|
return;
|
|
const _ = this.currentScaleRatio / d, f = n.pageX * (_ - 1), w = n.pageY * (_ - 1);
|
|
Math.abs(this.currentScaleRatio - 1) < 1e-5 ? (this.hookedElem.classList.add("hide-scrollbar-x"), (i = this.hookedElem.parentElement) == null || i.classList.add("hide-scrollbar-x"), this.previewMode === 1 && (this.hookedElem.classList.add("hide-scrollbar-y"), (s = this.hookedElem.parentElement) == null || s.classList.add("hide-scrollbar-y"))) : (this.hookedElem.classList.remove("hide-scrollbar-x"), (o = this.hookedElem.parentElement) == null || o.classList.remove("hide-scrollbar-x"), this.previewMode === 1 && (this.hookedElem.classList.remove("hide-scrollbar-y"), (a = this.hookedElem.parentElement) == null || a.classList.remove("hide-scrollbar-y")));
|
|
const P = this.hookedElem.firstElementChild;
|
|
if (P) {
|
|
const C = this.getSvgScaleRatio(), F = Number.parseFloat(P.getAttribute("data-height")), A = Math.ceil(F * C);
|
|
this.hookedElem.style.height = `${A * 2}px`;
|
|
}
|
|
return window.scrollBy(f, w), this.addViewportChange(), !1;
|
|
}
|
|
};
|
|
this.renderMode !== "dom" && (typeof acquireVsCodeApi < "u" ? (window.addEventListener("wheel", t, {
|
|
passive: !1
|
|
}), this.disposeList.push(() => {
|
|
window.removeEventListener("wheel", t);
|
|
})) : (document.body.addEventListener("wheel", t, {
|
|
passive: !1
|
|
}), this.disposeList.push(() => {
|
|
document.body.removeEventListener("wheel", t);
|
|
})));
|
|
}
|
|
/// Get current scale from html to svg
|
|
// Note: one should retrieve dom state before rescale
|
|
getSvgScaleRatio() {
|
|
const e = this.hookedElem.firstElementChild;
|
|
if (!e)
|
|
return 0;
|
|
const t = this.cachedDOMState, n = Number.parseFloat(
|
|
e.getAttribute("data-width") || e.getAttribute("width") || "1"
|
|
), i = Number.parseFloat(
|
|
e.getAttribute("data-height") || e.getAttribute("height") || "1"
|
|
);
|
|
return this.currentRealScale = this.previewMode === 1 ? Math.min(t.width / n, t.height / i) : t.width / n, this.currentRealScale * this.currentScaleRatio;
|
|
}
|
|
processQueue(e) {
|
|
const t = e[0];
|
|
switch (t) {
|
|
case "new":
|
|
case "diff-v1":
|
|
return t === "new" && this.reset(), this.kModule.manipulateData({
|
|
action: "merge",
|
|
data: e[1]
|
|
}), this.moduleInitialized = !0, !0;
|
|
case "viewport-change":
|
|
return this.moduleInitialized ? !0 : (console.log("viewport-change before initialization"), !1);
|
|
default:
|
|
return console.log("svgUpdateEvent", e), !1;
|
|
}
|
|
}
|
|
triggerUpdate() {
|
|
if (this.isRendering)
|
|
return;
|
|
this.isRendering = !0;
|
|
const e = async () => {
|
|
if (this.cachedDOMState = this.retrieveDOMState(), this.patchQueue.length === 0) {
|
|
this.isRendering = !1, this.postprocessChanges();
|
|
return;
|
|
}
|
|
try {
|
|
let t = performance.now();
|
|
const n = this.canvasRenderCToken;
|
|
n && (await n.cancel(), await n.wait(), this.canvasRenderCToken = void 0, console.log("cancel canvas rendering"));
|
|
let i = !1;
|
|
for (; this.patchQueue.length > 0; )
|
|
i = this.processQueue(this.patchQueue.shift()) || i;
|
|
let s = performance.now();
|
|
i && (this.r.rescale(), await this.r.rerender(), this.r.rescale());
|
|
let o = performance.now();
|
|
const a = (d, _, f) => `${d} ${(f - _).toFixed(2)} ms`;
|
|
this.sampledRenderTime = o - t, console.log([a("parse", t, s), a("rerender", s, o), a("total", t, o)].join(", ")), requestAnimationFrame(e);
|
|
} catch (t) {
|
|
console.error(t), this.isRendering = !1, this.postprocessChanges();
|
|
}
|
|
};
|
|
requestAnimationFrame(e);
|
|
}
|
|
postprocessChanges() {
|
|
this.r.postRender(), this.previewMode === 1 && document.querySelectorAll(".typst-page-number-indicator").forEach((e) => {
|
|
e.textContent = `${this.kModule.retrievePagesInfo().length}`;
|
|
});
|
|
}
|
|
addChangement(e) {
|
|
e[0] === "new" && this.patchQueue.splice(0, this.patchQueue.length);
|
|
const t = () => {
|
|
this.vpTimeout = void 0, this.patchQueue.push(e), this.triggerUpdate();
|
|
};
|
|
this.vpTimeout !== void 0 && clearTimeout(this.vpTimeout), e[0] === "viewport-change" && this.isRendering ? this.vpTimeout = setTimeout(t, this.sampledRenderTime || 100) : t();
|
|
}
|
|
addViewportChange() {
|
|
this.addChangement(["viewport-change", ""]);
|
|
}
|
|
};
|
|
function $r(r) {
|
|
return class {
|
|
constructor(t) {
|
|
l(this, "impl");
|
|
l(this, "kModule");
|
|
if (t.isContentPreview && (t.renderMode = "canvas"), this.kModule = t.kModule, this.impl = new r(t), !this.impl.r)
|
|
throw new Error(`mode is not supported, ${t == null ? void 0 : t.renderMode}`);
|
|
t.isContentPreview && (this.impl.partialRendering = !0, this.impl.pixelPerPt = 1, this.impl.isMixinOutline = !0);
|
|
}
|
|
dispose() {
|
|
this.impl.dispose();
|
|
}
|
|
reset() {
|
|
this.impl.reset();
|
|
}
|
|
addChangement(t) {
|
|
this.impl.addChangement(t);
|
|
}
|
|
addViewportChange() {
|
|
this.impl.addViewportChange();
|
|
}
|
|
setPageColor(t) {
|
|
this.impl.pageColor = t, this.addViewportChange();
|
|
}
|
|
setPartialRendering(t) {
|
|
this.impl.partialRendering = t;
|
|
}
|
|
setCursor(t, n, i) {
|
|
this.impl.cursorPosition = [t, n, i];
|
|
}
|
|
setPartialPageNumber(t) {
|
|
return t <= 0 || t > this.kModule.retrievePagesInfo().length ? !1 : (this.impl.partialRenderPage = t - 1, this.addViewportChange(), !0);
|
|
}
|
|
getPartialPageNumber() {
|
|
return this.impl.partialRenderPage + 1;
|
|
}
|
|
setOutineData(t) {
|
|
this.impl.outline = t, this.addViewportChange();
|
|
}
|
|
};
|
|
}
|
|
function jr(r, ...e) {
|
|
return e.reduce((t, n) => n(t), r);
|
|
}
|
|
let Br = class {
|
|
constructor() {
|
|
l(this, "isCancellationRequested", !1);
|
|
l(this, "_onCancelled");
|
|
l(this, "_onCancelledResolveResolved");
|
|
let e, t;
|
|
this._onCancelled = new Promise((n) => {
|
|
e = n, t && t(n);
|
|
}), this._onCancelledResolveResolved = new Promise((n) => {
|
|
t = n, e && n(e);
|
|
});
|
|
}
|
|
async cancel() {
|
|
await this._onCancelledResolveResolved, this.isCancellationRequested = !0;
|
|
}
|
|
isCancelRequested() {
|
|
return this.isCancellationRequested;
|
|
}
|
|
async consume() {
|
|
(await this._onCancelledResolveResolved)();
|
|
}
|
|
wait() {
|
|
return this._onCancelled;
|
|
}
|
|
};
|
|
const Wr = () => new Promise((r) => requestAnimationFrame(r));
|
|
function zr(r) {
|
|
return class extends r {
|
|
constructor(...n) {
|
|
super(...n);
|
|
/// The template element for creating DOM by string.
|
|
l(this, "tmpl", document.createElement("template"));
|
|
/// The stub element for replacing an invisible element.
|
|
l(this, "stub", this.createElement("<stub></stub>"));
|
|
/// Typescript side of lib.
|
|
l(this, "plugin");
|
|
/// Rust side of kernel.
|
|
l(this, "docKernel");
|
|
/// The element to track.
|
|
l(this, "resourceHeader");
|
|
/// Expected exact state of the current DOM.
|
|
/// Initially it is empty meaning no any page is rendered.
|
|
l(this, "pages", []);
|
|
/// The virtual scale of the document.
|
|
l(this, "domScale", 1);
|
|
/// Track mode.
|
|
l(this, "track_mode", 0);
|
|
/// Current executing task.
|
|
l(this, "current_task");
|
|
/// The currently maintained viewport.
|
|
l(this, "viewport");
|
|
if (this.registerMode("dom"), this.disposeList.push(() => {
|
|
this.dispose();
|
|
}), this.plugin = this.opts.renderer, this.opts.domScale !== void 0) {
|
|
if (this.opts.domScale <= 0)
|
|
throw new Error("domScale must be positive");
|
|
this.domScale = this.opts.domScale;
|
|
}
|
|
}
|
|
dispose() {
|
|
for (const n of this.pages)
|
|
n.dispose();
|
|
this.docKernel && this.docKernel.free();
|
|
}
|
|
createElement(n) {
|
|
return this.tmpl.innerHTML = n, this.tmpl.content.firstElementChild;
|
|
}
|
|
async mountDom(n) {
|
|
if (console.log("mountDom", n), this.docKernel)
|
|
throw new Error("already mounted");
|
|
this.hookedElem.innerHTML = '<svg class="typst-svg-resources" viewBox="0 0 0 0" width="0" height="0" style="opacity: 0; position: absolute;"></svg>', this.resourceHeader = this.hookedElem.querySelector(".typst-svg-resources"), this.docKernel = await this.plugin.renderer.mount_dom(this.kModule[R], this.hookedElem), this.docKernel.bind_functions({
|
|
populateGlyphs: (i) => {
|
|
let s = this.createElement(i);
|
|
console.log("populateGlyphs", s);
|
|
let o = s.firstElementChild;
|
|
this.resourceHeader.append(o);
|
|
}
|
|
});
|
|
}
|
|
async cancelAnyway$dom() {
|
|
if (console.log("cancelAnyway$dom"), this.current_task) {
|
|
const n = this.current_task;
|
|
this.current_task = void 0, await n.cancel();
|
|
}
|
|
}
|
|
retrieveDOMPages() {
|
|
return Array.from(this.hookedElem.querySelectorAll(".typst-dom-page"));
|
|
}
|
|
// doesn't need to postRender
|
|
postRender$dom() {
|
|
}
|
|
// doesn't need to rescale
|
|
rescale$dom() {
|
|
}
|
|
getDomViewport(n, i) {
|
|
const s = i.left, o = -i.top, a = i.right, d = n.innerHeight - i.top, _ = {
|
|
x: 0,
|
|
y: o / this.domScale,
|
|
width: Math.max(a - s, 0) / this.domScale,
|
|
height: Math.max(d - o, 0) / this.domScale
|
|
};
|
|
return (_.width <= 0 || _.height <= 0) && (_.x = _.y = _.width = _.height = 0), _;
|
|
}
|
|
// fast mode
|
|
async rerender$dom() {
|
|
const n = this.retrieveDOMState(), { x: i, y: s, width: o, height: a } = this.getDomViewport(n.window, n.boundingRect);
|
|
if (!await this.docKernel.relayout(i, s, o, a))
|
|
return;
|
|
const _ = new Br();
|
|
this.doRender$dom(_), this.current_task = _;
|
|
}
|
|
async doRender$dom(n) {
|
|
const i = (d, _) => {
|
|
if (d && !n.isCancelRequested() && _)
|
|
return _();
|
|
}, s = this.retrieveDOMPages().map((d) => {
|
|
const { innerWidth: _, innerHeight: f } = window, w = d.getBoundingClientRect();
|
|
return {
|
|
inWindow: !(w.left > _ || w.right < 0 || w.top > f || w.bottom < 0),
|
|
page: d
|
|
};
|
|
}), o = async (d) => {
|
|
if (await Wr(), n.isCancelRequested()) {
|
|
console.log("cancel stage", 0, d);
|
|
return;
|
|
}
|
|
const _ = s[d].page, f = _.getBoundingClientRect(), w = this.getDomViewport(window, f), P = (D) => this.docKernel.need_repaint(d, w.x, w.y, w.width, w.height, D), C = (D) => this.docKernel.repaint(d, w.x, w.y, w.width, w.height, D), F = (D) => {
|
|
if (!n.isCancelRequested())
|
|
return i(P(D), () => C(D));
|
|
};
|
|
await F(
|
|
0
|
|
/* Layout */
|
|
);
|
|
const A = (f.width ? Number.parseFloat(_.getAttribute("data-width")) / f.width : 1) * this.domScale, $ = (f.height ? Number.parseFloat(_.getAttribute("data-height")) / f.height : 1) * this.domScale;
|
|
if (w.x *= A, w.y *= $, w.y -= 100, w.width *= A, w.height *= $, w.height += 200, await F(
|
|
1
|
|
/* Svg */
|
|
), await F(
|
|
2
|
|
/* Semantics */
|
|
), n.isCancelRequested()) {
|
|
console.log("cancel stage", 2, d);
|
|
return;
|
|
}
|
|
P(
|
|
3
|
|
/* PrepareCanvas */
|
|
) ? (async () => {
|
|
if (await C(
|
|
3
|
|
/* PrepareCanvas */
|
|
), !n.isCancelRequested())
|
|
return F(
|
|
4
|
|
/* Canvas */
|
|
);
|
|
})() : await F(
|
|
4
|
|
/* Canvas */
|
|
);
|
|
}, a = async (d) => {
|
|
for (let _ = 0; _ < s.length; ++_) {
|
|
if (n.isCancelRequested()) {
|
|
console.log("cancel page", 0, _);
|
|
return;
|
|
}
|
|
s[_].inWindow === d && await o(_);
|
|
}
|
|
};
|
|
this.cancelAnyway$dom(), await a(!0), await a(!1), !n.isCancelRequested() && console.log(
|
|
"finished",
|
|
0
|
|
/* Layout */
|
|
);
|
|
}
|
|
};
|
|
}
|
|
let qr = class extends $r(
|
|
jr(
|
|
Dr,
|
|
zr
|
|
)
|
|
) {
|
|
};
|
|
var Pt;
|
|
let Oe = (Pt = R, class {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e, t) {
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, Pt);
|
|
this.plugin = e, this[R] = t;
|
|
}
|
|
/**
|
|
* @deprecated set in {@link RenderToCanvasOptions} instead
|
|
*
|
|
* Set the background color of the Typst document.
|
|
* @param {string} t - The background color in format of `^#?[0-9a-f]{6}$`
|
|
*
|
|
* Note: Default to `#ffffff`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
set backgroundColor(e) {
|
|
e !== void 0 && (this[R].background_color = e);
|
|
}
|
|
/**
|
|
* Get the background color of the Typst document.
|
|
*
|
|
* Note: Default to `#ffffff`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
get backgroundColor() {
|
|
return this[R].background_color;
|
|
}
|
|
/**
|
|
* Set the pixel per point scale up the canvas panel.
|
|
*
|
|
* Note: Default to `3`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
set pixelPerPt(e) {
|
|
e !== void 0 && (this[R].pixel_per_pt = e);
|
|
}
|
|
/**
|
|
* @deprecated set in {@link RenderToCanvasOptions} instead
|
|
*
|
|
* Get the pixel per point scale up the canvas panel.
|
|
*
|
|
* Note: Default to `3`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
get pixelPerPt() {
|
|
return this[R].pixel_per_pt;
|
|
}
|
|
/**
|
|
* Reset state
|
|
*/
|
|
reset() {
|
|
this.plugin.resetSession(this);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link docWidth} instead
|
|
*/
|
|
get doc_width() {
|
|
return this[R].doc_width;
|
|
}
|
|
get docWidth() {
|
|
return this[R].doc_width;
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link docHeight} instead
|
|
*/
|
|
get doc_height() {
|
|
return this[R].doc_height;
|
|
}
|
|
get docHeight() {
|
|
return this[R].doc_height;
|
|
}
|
|
retrievePagesInfo() {
|
|
const e = this[R].pages_info, t = [], n = e.page_count;
|
|
for (let i = 0; i < n; i++) {
|
|
const s = e.page(i);
|
|
t.push({
|
|
pageOffset: s.page_off,
|
|
width: s.width_pt,
|
|
height: s.height_pt
|
|
});
|
|
}
|
|
return t;
|
|
}
|
|
getSourceLoc(e) {
|
|
return this[R].source_span(e);
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderSvg} for more details.
|
|
*/
|
|
renderSvg(e) {
|
|
return this.plugin.renderSvg({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderToSvg} for more details.
|
|
*/
|
|
renderToSvg(e) {
|
|
return this.plugin.renderToSvg({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderCanvas} for more details.
|
|
*/
|
|
renderCanvas(e) {
|
|
return this.plugin.renderCanvas({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#manipulateData} for more details.
|
|
*/
|
|
manipulateData(e) {
|
|
this.plugin.manipulateData({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderSvgDiff} for more details.
|
|
*/
|
|
renderSvgDiff(e) {
|
|
return this.plugin.renderSvgDiff({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link getSourceLoc} instead
|
|
*/
|
|
get_source_loc(e) {
|
|
return this[R].source_span(e);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link renderSvgDiff} instead
|
|
*/
|
|
render_in_window(e, t, n, i) {
|
|
return this[R].render_in_window(e, t, n, i);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link manipulateData} instead
|
|
*/
|
|
merge_delta(e) {
|
|
this.plugin.manipulateData({
|
|
renderSession: this,
|
|
action: "merge",
|
|
data: e
|
|
});
|
|
}
|
|
});
|
|
var It;
|
|
let Nr = (It = R, class {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e, t) {
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, It);
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, "managedCanvasElemList", /* @__PURE__ */ new Map());
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, "canvasCounter", Math.random());
|
|
this.plugin = e, this[R] = t;
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#manipulateData} for more details.
|
|
*/
|
|
manipulateData(e, t) {
|
|
return this[R].manipulate_data(e, t);
|
|
}
|
|
/**
|
|
* You must submit all canvas in pages to ensure synchronization with the background worker
|
|
*
|
|
* See {@link TypstRenderer#renderCanvas} for more details.
|
|
*/
|
|
renderCanvas(e) {
|
|
const t = this.managedCanvasElemList;
|
|
for (const [a, d] of t)
|
|
d[0] = 0;
|
|
for (const a of e) {
|
|
const d = a.canvas;
|
|
let _ = d.dataset.manageId, f = 2;
|
|
_ || (_ = this.canvasCounter.toFixed(5), this.canvasCounter += 1, d.dataset.manageId = _, f = 1);
|
|
let w = t.get(_);
|
|
if (w && w[0] !== 0)
|
|
throw new Error("cannot update a canvas for two times in batch");
|
|
t.set(_, [f, { ...a }]);
|
|
}
|
|
const n = Array.from(t.entries()), i = new Uint8Array(n.length), s = new Array(n.length), o = n.map(([a, [d, _]], f) => (d || t.delete(a), i[f] = d, s[f] = _.canvas, this.plugin.canvasOptionsToRust(_)));
|
|
return this[R].render_canvas(i, s, o);
|
|
}
|
|
async retrievePagesInfo() {
|
|
const e = await this[R].get_pages_info();
|
|
console.log(e);
|
|
const t = [], n = e.page_count;
|
|
for (let i = 0; i < n; i++) {
|
|
const s = e.page(i);
|
|
t.push({
|
|
pageOffset: s.page_off,
|
|
width: s.width_pt,
|
|
height: s.height_pt
|
|
});
|
|
}
|
|
return t;
|
|
}
|
|
});
|
|
const Ur = (r) => new Ft(async (e) => await r.default(e));
|
|
function nt() {
|
|
return new Wt();
|
|
}
|
|
function ni() {
|
|
return new Wt();
|
|
}
|
|
async function ii() {
|
|
return (await Promise.resolve().then(() => Ye)).renderer_build_info();
|
|
}
|
|
let it = !0, Wt = class {
|
|
constructor() {
|
|
l(this, "renderer");
|
|
l(this, "rendererJs");
|
|
}
|
|
async init(e) {
|
|
var n;
|
|
this.rendererJs = await (((n = e == null ? void 0 : e.getWrapper) == null ? void 0 : n.call(e)) || Promise.resolve().then(() => Ye));
|
|
const t = this.rendererJs.TypstRendererBuilder;
|
|
this.renderer = await jt(
|
|
e,
|
|
Ur(this.rendererJs),
|
|
t,
|
|
{}
|
|
);
|
|
}
|
|
loadGlyphPack(e) {
|
|
return Promise.resolve();
|
|
}
|
|
createOptionsToRust(e) {
|
|
const t = new this.rendererJs.CreateSessionOptions();
|
|
return e.format !== void 0 && (t.format = e.format), e.artifactContent !== void 0 && (t.artifact_content = e.artifactContent), t;
|
|
}
|
|
canvasOptionsToRust(e) {
|
|
const t = new this.rendererJs.RenderPageImageOptions();
|
|
if (e.pageOffset === void 0)
|
|
throw new Error("pageOffset is required in reflexo v0.5.0");
|
|
if (t.page_off = e.pageOffset, e.cacheKey !== void 0 && (t.cache_key = e.cacheKey), e.backgroundColor !== void 0 && (t.background_color = e.backgroundColor), e.pixelPerPt !== void 0 && (t.pixel_per_pt = e.pixelPerPt), e.dataSelection !== void 0) {
|
|
let n = 0;
|
|
e.dataSelection.body ? n |= 1 : e.canvas && it && (it = !1, console.warn("dataSelection.body is not set but providing canvas for body")), (e.dataSelection.text || e.dataSelection.annotation) && console.error("dataSelection.text and dataSelection.annotation are deprecated"), e.dataSelection.semantics && (n |= 8), t.data_selection = n;
|
|
}
|
|
return t;
|
|
}
|
|
retrievePagesInfoFromSession(e) {
|
|
return e.retrievePagesInfo();
|
|
}
|
|
/**
|
|
* Render a Typst document to canvas.
|
|
*/
|
|
renderCanvas(e) {
|
|
return this.withinOptionSession(e, async (t) => this.renderer.render_page_to_canvas(
|
|
t[R],
|
|
e.canvas || void 0,
|
|
this.canvasOptionsToRust(e)
|
|
));
|
|
}
|
|
// async renderPdf(artifactContent: string): Promise<Uint8Array> {
|
|
// return this.renderer.render_to_pdf(artifactContent);
|
|
// }
|
|
async inAnimationFrame(e) {
|
|
return new Promise((t, n) => {
|
|
requestAnimationFrame(() => {
|
|
try {
|
|
t(e());
|
|
} catch (i) {
|
|
n(i);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
async renderDisplayLayer(e, t, n) {
|
|
const s = e[R].pages_info.page_count, o = async (f, w) => {
|
|
const C = t[f].getContext("2d");
|
|
if (!C)
|
|
throw new Error("canvas context is null");
|
|
return await this.renderCanvas({
|
|
...n,
|
|
canvas: C,
|
|
renderSession: e,
|
|
pageOffset: w
|
|
});
|
|
}, a = performance.now(), d = await (async () => {
|
|
const f = [];
|
|
for (let w = 0; w < s; w++)
|
|
f.push(await this.inAnimationFrame(() => o(w, w)));
|
|
return f;
|
|
})(), _ = performance.now();
|
|
return console.log(`display layer used: render = ${(_ - a).toFixed(1)}ms`), d;
|
|
}
|
|
renderTextLayer(e, t) {
|
|
const n = performance.now();
|
|
e.forEach((s, o) => {
|
|
s.innerHTML = t[o].htmlSemantics[0];
|
|
});
|
|
const i = performance.now();
|
|
console.log(`text layer used: render = ${(i - n).toFixed(1)}ms`);
|
|
}
|
|
async render(e) {
|
|
if ("format" in e && e.format !== "vector" && ["serde_json", "js", "ir"].includes(e.format))
|
|
throw new Error(`deprecated format ${e.format}, please use vector format`);
|
|
return this.renderToCanvas(e);
|
|
}
|
|
async renderDom(e) {
|
|
if ("format" in e && e.format !== "vector" && ["serde_json", "js", "ir"].includes(e.format))
|
|
throw new Error(`deprecated format ${e.format}, please use vector format`);
|
|
return this.withinOptionSession(e, async (t) => {
|
|
const n = new qr({
|
|
...e,
|
|
renderMode: "dom",
|
|
hookedElem: e.container,
|
|
kModule: t,
|
|
renderer: this
|
|
});
|
|
return await n.impl.mountDom(e.pixelPerPt), n;
|
|
});
|
|
}
|
|
async renderToCanvas(e) {
|
|
let t, n;
|
|
const i = e.container;
|
|
i.style.visibility = "hidden";
|
|
const s = async (o, a) => {
|
|
try {
|
|
n = await this.renderDisplayLayer(t, o, e), a();
|
|
} finally {
|
|
i.style.visibility = "visible";
|
|
}
|
|
};
|
|
return this.withinOptionSession(e, async (o) => {
|
|
if (t = o, t[R].pages_info.page_count === 0)
|
|
throw new Error("No page found in session");
|
|
if (e.pixelPerPt !== void 0 && e.pixelPerPt <= 0)
|
|
throw new Error(
|
|
"Invalid typst.RenderOptions.pixelPerPt, should be a positive number " + e.pixelPerPt
|
|
);
|
|
let a = e.backgroundColor;
|
|
if (a !== void 0 && !/^#[0-9a-f]{6}$/.test(a))
|
|
throw new Error(
|
|
"Invalid typst.backgroundColor color for matching ^#?[0-9a-f]{6}$ " + a
|
|
);
|
|
t.pixelPerPt = e.pixelPerPt ?? Ge.PIXEL_PER_PT, t.backgroundColor = a ?? "#ffffff";
|
|
const d = performance.now(), _ = new Ot(
|
|
this.retrievePagesInfoFromSession(t),
|
|
i,
|
|
e
|
|
), f = performance.now();
|
|
console.log(`layer used: retrieve = ${(f - d).toFixed(1)}ms`), await s(_.canvasList, () => _.resetLayout()), this.renderTextLayer(_.textLayerList, n);
|
|
});
|
|
}
|
|
createModule(e) {
|
|
return Promise.resolve(
|
|
new Oe(
|
|
this,
|
|
this.renderer.create_session(
|
|
e && this.createOptionsToRust({
|
|
format: "vector",
|
|
artifactContent: e
|
|
})
|
|
)
|
|
)
|
|
);
|
|
}
|
|
async createWorkerV0(e) {
|
|
return new Nr(this, await this.renderer.create_worker(e));
|
|
}
|
|
workerBridge() {
|
|
return this.renderer.create_worker_bridge();
|
|
}
|
|
renderSvg(e, t) {
|
|
if (e instanceof Oe || t)
|
|
throw new Error("removed api, please use renderToSvg({ renderSession, container }) instead");
|
|
return this.withinOptionSession(e, async (n) => {
|
|
let i;
|
|
return e.data_selection && (i = 0, e.data_selection.body && (i |= 1), e.data_selection.defs && (i |= 2), e.data_selection.css && (i |= 4), e.data_selection.js && (i |= 8)), Promise.resolve(this.renderer.svg_data(n[R], i));
|
|
});
|
|
}
|
|
renderSvgDiff(e) {
|
|
return e.window ? this.renderer.render_svg_diff(
|
|
e.renderSession[R],
|
|
e.window.lo.x,
|
|
e.window.lo.y,
|
|
e.window.hi.x,
|
|
e.window.hi.y
|
|
) : this.renderer.render_svg_diff(
|
|
e.renderSession[R],
|
|
0,
|
|
0,
|
|
1e33,
|
|
1e33
|
|
);
|
|
}
|
|
renderToSvg(e) {
|
|
return this.withinOptionSession(e, async (t) => Promise.resolve(this.renderer.render_svg(t[R], e.container)));
|
|
}
|
|
getCustomV1(e) {
|
|
return Promise.resolve(this.renderer.get_customs(e.renderSession[R]));
|
|
}
|
|
resetSession(e) {
|
|
return this.renderer.reset(e[R]);
|
|
}
|
|
manipulateData(e) {
|
|
return this.renderer.manipulate_data(
|
|
e.renderSession[R],
|
|
e.action ?? "reset",
|
|
e.data
|
|
);
|
|
}
|
|
withinOptionSession(e, t) {
|
|
function n(i) {
|
|
return "artifactContent" in i;
|
|
}
|
|
if ("renderSession" in e)
|
|
return t(e.renderSession);
|
|
if (n(e))
|
|
return this.runWithSession(e, t);
|
|
throw new Error(
|
|
"Invalid render options, should be one of RenderByContentOptions|RenderBySessionOptions"
|
|
);
|
|
}
|
|
async runWithSession(e, t) {
|
|
let n = e, i = t;
|
|
t || (n = void 0, i = e);
|
|
const s = this.renderer.create_session(
|
|
/* moved */
|
|
n && this.createOptionsToRust(n)
|
|
);
|
|
try {
|
|
const o = await i(new Oe(this, s));
|
|
return s.free(), o;
|
|
} catch (o) {
|
|
throw s.free(), o;
|
|
}
|
|
}
|
|
};
|
|
var Mt;
|
|
let Hr = (Mt = R, class {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e) {
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, Mt);
|
|
this[R] = e;
|
|
}
|
|
/**
|
|
* Reset the incremental server to the initial state.
|
|
*/
|
|
reset() {
|
|
this[R].reset();
|
|
}
|
|
/**
|
|
* Return current result.
|
|
*/
|
|
current() {
|
|
return this[R].current();
|
|
}
|
|
/**
|
|
* Also attach the debug info to the result.
|
|
*/
|
|
setAttachDebugInfo(e) {
|
|
this[R].set_attach_debug_info(e);
|
|
}
|
|
});
|
|
const Vr = new Ft(async (r) => await (await Promise.resolve().then(() => Me)).default(r));
|
|
function zt() {
|
|
return new qt();
|
|
}
|
|
var Y;
|
|
let qt = (Y = class {
|
|
constructor() {
|
|
l(this, "compiler");
|
|
l(this, "compilerJs");
|
|
}
|
|
async init(e) {
|
|
this.compilerJs = await Promise.resolve().then(() => Me);
|
|
const t = this.compilerJs.TypstCompilerBuilder, n = { ...e || {} }, i = n.beforeBuild ?? (n.beforeBuild = []), s = i.some(
|
|
(_) => _._preloadRemoteFontOptions !== void 0
|
|
), o = i.some(
|
|
(_) => {
|
|
var f;
|
|
return ((f = _._preloadRemoteFontOptions) == null ? void 0 : f.assets) !== void 0;
|
|
}
|
|
), a = i.some(
|
|
(_) => {
|
|
var f;
|
|
return ((f = _._preloadRemoteFontOptions) == null ? void 0 : f.assets) === !1;
|
|
}
|
|
);
|
|
if ((!s || !o && !a) && i.push(ne([], { assets: Y.defaultAssets })), !i.some((_) => _._kind === "fontLoader"))
|
|
throw new Error(
|
|
"TypstCompiler: no font loader found, please use font loaders, e.g. preloadRemoteFonts or preloadSystemFonts"
|
|
);
|
|
this.compiler = await jt(e, Vr, t, {});
|
|
}
|
|
compile(e) {
|
|
return new Promise((t) => {
|
|
if ("incrementalServer" in e) {
|
|
t(
|
|
this.compiler.incr_compile(
|
|
e.mainFilePath,
|
|
Fe(e.inputs),
|
|
e.incrementalServer[R],
|
|
st(e.diagnostics)
|
|
)
|
|
);
|
|
return;
|
|
}
|
|
t(
|
|
this.compiler.compile(
|
|
e.mainFilePath,
|
|
Fe(e.inputs),
|
|
e.format || "vector",
|
|
st(e.diagnostics)
|
|
)
|
|
);
|
|
});
|
|
}
|
|
query(e) {
|
|
return new Promise((t) => {
|
|
t(
|
|
JSON.parse(
|
|
this.compiler.query(
|
|
e.mainFilePath,
|
|
Fe(e.inputs),
|
|
e.selector,
|
|
e.field
|
|
)
|
|
)
|
|
);
|
|
});
|
|
}
|
|
getSemanticTokenLegend() {
|
|
return new Promise((e) => {
|
|
e(this.compiler.get_semantic_token_legend());
|
|
});
|
|
}
|
|
getSemanticTokens(e) {
|
|
return new Promise((t) => {
|
|
this.compiler.reset(), t(
|
|
this.compiler.get_semantic_tokens(
|
|
e.offsetEncoding || "utf-16",
|
|
e.mainFilePath,
|
|
e.resultId
|
|
)
|
|
);
|
|
});
|
|
}
|
|
async withIncrementalServer(e) {
|
|
const t = new Hr(this.compiler.create_incr_server());
|
|
try {
|
|
return await e(t);
|
|
} finally {
|
|
t[R].free();
|
|
}
|
|
}
|
|
async getAst(e) {
|
|
return this.compiler.get_ast(e);
|
|
}
|
|
async reset() {
|
|
await new Promise((e) => {
|
|
this.compiler.reset(), e(void 0);
|
|
});
|
|
}
|
|
addSource(e, t) {
|
|
if (arguments.length > 2)
|
|
throw new Error(
|
|
"use of addSource(path, source, isMain) is deprecated, please use addSource(path, source) instead"
|
|
);
|
|
this.compiler.add_source(e, t);
|
|
}
|
|
mapShadow(e, t) {
|
|
this.compiler.map_shadow(e, t);
|
|
}
|
|
unmapShadow(e) {
|
|
this.compiler.unmap_shadow(e);
|
|
}
|
|
resetShadow() {
|
|
this.compiler.reset_shadow();
|
|
}
|
|
renderPageToCanvas() {
|
|
throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0");
|
|
}
|
|
}, l(Y, "defaultAssets", ["text"]), Y);
|
|
zt._impl = qt;
|
|
function Fe(r) {
|
|
return r ? Object.entries(r) : void 0;
|
|
}
|
|
function st(r) {
|
|
switch (r) {
|
|
case "none":
|
|
return 1;
|
|
case "unix":
|
|
return 2;
|
|
case "full":
|
|
default:
|
|
return 3;
|
|
}
|
|
}
|
|
typeof window < "u" && (window.TypstRenderModule = {
|
|
RenderView: Ot,
|
|
createTypstRenderer: nt,
|
|
createTypstSvgRenderer: nt,
|
|
preloadRemoteFonts: ne,
|
|
preloadSystemFonts: Ze
|
|
}, window.TypstCompileModule = {
|
|
createTypstCompiler: zt,
|
|
preloadRemoteFonts: ne,
|
|
preloadSystemFonts: Ze,
|
|
FetchAccessModel: vr,
|
|
MemoryAccessModel: qe,
|
|
FetchPackageRegistry: Ne,
|
|
withAccessModel: ze,
|
|
withPackageRegistry: fe
|
|
});
|
|
window.$typst = we;
|
|
window.TypstSnippet = U;
|
|
class Jr {
|
|
constructor() {
|
|
l(this, "loadedFonts", /* @__PURE__ */ new Set());
|
|
l(this, "fetcher", fetch);
|
|
}
|
|
setFetcher(e) {
|
|
this.fetcher = e;
|
|
}
|
|
async loadFonts(e, t) {
|
|
const n = (m) => import(m), i = this.fetcher || (this.fetcher = await async function() {
|
|
const { fetchBuilder: a, FileSystemCache: d } = await n("node-fetch-cache"), _ = new d({
|
|
/// By default, we don't have a complicated cache policy.
|
|
cacheDirectory: ".cache/typst/fonts"
|
|
}), f = a.withCache(_);
|
|
return function(w, P) {
|
|
const C = setTimeout(() => {
|
|
console.warn("font fetching is stucking:", w);
|
|
}, 15e3);
|
|
return f(w, P).finally(() => {
|
|
clearTimeout(C);
|
|
});
|
|
};
|
|
}()), s = t.filter((a) => a instanceof Uint8Array ? !0 : this.loadedFonts.has(a) ? !1 : (this.loadedFonts.add(a), !0)), o = await Promise.all(s.map(async (a) => {
|
|
if (a instanceof Uint8Array) {
|
|
await e.add_raw_font(a);
|
|
return;
|
|
}
|
|
return new Uint8Array(await (await i(a)).arrayBuffer());
|
|
}));
|
|
for (const a of o)
|
|
a && await e.add_raw_font(a);
|
|
}
|
|
async build(e, t, n) {
|
|
const i = { ref: this, builder: t, hooks: n };
|
|
for (const o of (e == null ? void 0 : e.beforeBuild) ?? [])
|
|
await o(void 0, i);
|
|
return n.latelyBuild && n.latelyBuild(i), await t.build();
|
|
}
|
|
}
|
|
async function Nt(r, e, t, n) {
|
|
var i;
|
|
return await e.init((i = r == null ? void 0 : r.getModule) == null ? void 0 : i.call(r)), await new Jr().build(r, new t(), n);
|
|
}
|
|
const E = Symbol.for("reflexo-obj");
|
|
var me;
|
|
(function(r) {
|
|
r[r.PIXEL_PER_PT = 3] = "PIXEL_PER_PT";
|
|
})(me || (me = {}));
|
|
const Kr = [
|
|
"DejaVuSansMono-Bold.ttf",
|
|
"DejaVuSansMono-BoldOblique.ttf",
|
|
"DejaVuSansMono-Oblique.ttf",
|
|
"DejaVuSansMono.ttf",
|
|
"LibertinusSerif-Bold.otf",
|
|
"LibertinusSerif-BoldItalic.otf",
|
|
"LibertinusSerif-Italic.otf",
|
|
"LibertinusSerif-Regular.otf",
|
|
"LibertinusSerif-Semibold.otf",
|
|
"LibertinusSerif-SemiboldItalic.otf",
|
|
"NewCM10-Bold.otf",
|
|
"NewCM10-BoldItalic.otf",
|
|
"NewCM10-Italic.otf",
|
|
"NewCM10-Regular.otf",
|
|
"NewCMMath-Bold.otf",
|
|
"NewCMMath-Book.otf",
|
|
"NewCMMath-Regular.otf"
|
|
], Gr = [
|
|
"InriaSerif-Bold.ttf",
|
|
"InriaSerif-BoldItalic.ttf",
|
|
"InriaSerif-Italic.ttf",
|
|
"InriaSerif-Regular.ttf",
|
|
"Roboto-Regular.ttf",
|
|
"NotoSerifCJKsc-Regular.otf"
|
|
], Qr = ["TwitterColorEmoji.ttf", "NotoColorEmoji.ttf"];
|
|
function Xr(r) {
|
|
var t, n;
|
|
const e = [];
|
|
if (r && (r == null ? void 0 : r.assets) !== !1 && ((t = r == null ? void 0 : r.assets) != null && t.length) && ((n = r == null ? void 0 : r.assets) == null ? void 0 : n.length) > 0) {
|
|
let i = {
|
|
text: "https://cdn.jsdelivr.net/gh/typst/typst-assets@v0.13.1/files/fonts/",
|
|
_: "https://cdn.jsdelivr.net/gh/typst/typst-dev-assets@v0.13.1/files/fonts/"
|
|
}, s = r.assetUrlPrefix ?? i;
|
|
typeof s == "string" ? s = { _: s } : s = { ...i, ...s };
|
|
for (const a of Object.keys(s)) {
|
|
const d = s[a];
|
|
d[d.length - 1] !== "/" && (s[a] = d + "/");
|
|
}
|
|
const o = (a, d) => d.map((_) => (s[a] || s._) + _);
|
|
for (const a of r.assets)
|
|
switch (a) {
|
|
case "text":
|
|
e.push(...o(a, Kr));
|
|
break;
|
|
case "cjk":
|
|
e.push(...o(a, Gr));
|
|
break;
|
|
case "emoji":
|
|
e.push(...o(a, Qr));
|
|
break;
|
|
}
|
|
}
|
|
return e;
|
|
}
|
|
function Yr(r, e) {
|
|
const t = Xr(e), n = async (i, { ref: s, builder: o }) => {
|
|
e != null && e.fetcher && s.setFetcher(e.fetcher), await s.loadFonts(o, [...r, ...t]);
|
|
};
|
|
return n._preloadRemoteFontOptions = e, n._kind = "fontLoader", n;
|
|
}
|
|
const Zr = (r) => {
|
|
let e = !1, t;
|
|
return () => e ? t : (e = !0, t = r());
|
|
};
|
|
class Ut {
|
|
constructor(e) {
|
|
l(this, "wasmBin");
|
|
l(this, "initOnce");
|
|
if (typeof e != "function")
|
|
throw new Error("initFn is not a function");
|
|
this.initOnce = Zr(async () => {
|
|
await e(this.wasmBin);
|
|
});
|
|
}
|
|
async init(e) {
|
|
this.wasmBin = e, await this.initOnce();
|
|
}
|
|
}
|
|
var Lt;
|
|
Lt = E;
|
|
class Ht {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e) {
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, Lt);
|
|
this[E] = e;
|
|
}
|
|
/**
|
|
* Reset the incremental server to the initial state.
|
|
*/
|
|
reset() {
|
|
this[E].reset();
|
|
}
|
|
/**
|
|
* Return current result.
|
|
*/
|
|
current() {
|
|
return this[E].current();
|
|
}
|
|
/**
|
|
* Also attach the debug info to the result.
|
|
*/
|
|
setAttachDebugInfo(e) {
|
|
this[E].set_attach_debug_info(e);
|
|
}
|
|
}
|
|
const en = new Ut(async (r) => await (await Promise.resolve().then(() => Me)).default(r));
|
|
function Vt() {
|
|
return new ye();
|
|
}
|
|
const Ce = class Ce {
|
|
constructor() {
|
|
l(this, "compiler");
|
|
l(this, "compilerJs");
|
|
}
|
|
async init(e) {
|
|
this.compilerJs = await Promise.resolve().then(() => Me);
|
|
const t = this.compilerJs.TypstCompilerBuilder, n = { ...e || {} }, i = n.beforeBuild ?? (n.beforeBuild = []), s = i.some((_) => _._preloadRemoteFontOptions !== void 0), o = i.some((_) => {
|
|
var f;
|
|
return ((f = _._preloadRemoteFontOptions) == null ? void 0 : f.assets) !== void 0;
|
|
}), a = i.some((_) => {
|
|
var f;
|
|
return ((f = _._preloadRemoteFontOptions) == null ? void 0 : f.assets) === !1;
|
|
});
|
|
if ((!s || !o && !a) && i.push(Yr([], { assets: Ce.defaultAssets })), !i.some((_) => _._kind === "fontLoader"))
|
|
throw new Error("TypstCompiler: no font loader found, please use font loaders, e.g. preloadRemoteFonts or preloadSystemFonts");
|
|
this.compiler = await Nt(e, en, t, {});
|
|
}
|
|
compile(e) {
|
|
return new Promise((t) => {
|
|
if ("incrementalServer" in e) {
|
|
t(this.compiler.incr_compile(e.mainFilePath, De(e.inputs), e.incrementalServer[E], ot(e.diagnostics)));
|
|
return;
|
|
}
|
|
t(this.compiler.compile(e.mainFilePath, De(e.inputs), e.format || "vector", ot(e.diagnostics)));
|
|
});
|
|
}
|
|
query(e) {
|
|
return new Promise((t) => {
|
|
t(JSON.parse(this.compiler.query(e.mainFilePath, De(e.inputs), e.selector, e.field)));
|
|
});
|
|
}
|
|
getSemanticTokenLegend() {
|
|
return new Promise((e) => {
|
|
e(this.compiler.get_semantic_token_legend());
|
|
});
|
|
}
|
|
getSemanticTokens(e) {
|
|
return new Promise((t) => {
|
|
this.compiler.reset(), t(this.compiler.get_semantic_tokens(e.offsetEncoding || "utf-16", e.mainFilePath, e.resultId));
|
|
});
|
|
}
|
|
async withIncrementalServer(e) {
|
|
const t = new Ht(this.compiler.create_incr_server());
|
|
try {
|
|
return await e(t);
|
|
} finally {
|
|
t[E].free();
|
|
}
|
|
}
|
|
async getAst(e) {
|
|
return this.compiler.get_ast(e);
|
|
}
|
|
async reset() {
|
|
await new Promise((e) => {
|
|
this.compiler.reset(), e(void 0);
|
|
});
|
|
}
|
|
addSource(e, t) {
|
|
if (arguments.length > 2)
|
|
throw new Error("use of addSource(path, source, isMain) is deprecated, please use addSource(path, source) instead");
|
|
this.compiler.add_source(e, t);
|
|
}
|
|
mapShadow(e, t) {
|
|
this.compiler.map_shadow(e, t);
|
|
}
|
|
unmapShadow(e) {
|
|
this.compiler.unmap_shadow(e);
|
|
}
|
|
resetShadow() {
|
|
this.compiler.reset_shadow();
|
|
}
|
|
renderPageToCanvas() {
|
|
throw new Error("Please use the api TypstRenderer.renderToCanvas in v0.4.0");
|
|
}
|
|
};
|
|
l(Ce, "defaultAssets", ["text"]);
|
|
let ye = Ce;
|
|
Vt._impl = ye;
|
|
function De(r) {
|
|
return r ? Object.entries(r) : void 0;
|
|
}
|
|
function ot(r) {
|
|
switch (r) {
|
|
case "none":
|
|
return 1;
|
|
case "unix":
|
|
return 2;
|
|
case "full":
|
|
default:
|
|
return 3;
|
|
}
|
|
}
|
|
const at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
IncrementalServer: Ht,
|
|
createTypstCompiler: Vt
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
let ct, $e;
|
|
function tn(r, e) {
|
|
const t = ct || r();
|
|
return $e !== void 0 ? $e : $e = (async () => (await t.init(e), ct = t))();
|
|
}
|
|
const rn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
createGlobalCompiler: tn
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
class nn {
|
|
constructor(e, t, n) {
|
|
l(this, "pageInfos");
|
|
l(this, "loadPageCount");
|
|
l(this, "imageScaleFactor");
|
|
l(this, "container");
|
|
l(this, "canvasList");
|
|
l(this, "textLayerList");
|
|
l(this, "commonList");
|
|
l(this, "textLayerParentList");
|
|
l(this, "semanticLayerList");
|
|
this.pageInfos = e, this.imageScaleFactor = n.pixelPerPt ?? me.PIXEL_PER_PT, t.innerHTML = "", t.style.width = "100%", this.container = t, this.canvasList = new Array(this.loadPageCount), this.textLayerList = new Array(this.loadPageCount), this.commonList = new Array(this.loadPageCount), this.textLayerParentList = new Array(this.loadPageCount), this.semanticLayerList = new Array(this.loadPageCount);
|
|
const i = (s, o, a) => {
|
|
const d = Math.ceil(o.width) * this.imageScaleFactor, _ = Math.ceil(o.height) * this.imageScaleFactor, f = this.canvasList[s] = document.createElement("canvas"), w = this.semanticLayerList[s] = document.createElement("div"), P = this.textLayerList[s] = document.createElement("div"), C = this.textLayerParentList[s] = document.createElement("div");
|
|
if (f.getContext("2d")) {
|
|
const A = document.createElement("div");
|
|
f.width = d, f.height = _, A.appendChild(f), a.appendChild(A), A.style.position = "absolute";
|
|
}
|
|
{
|
|
C.appendChild(P), C.className = "typst-html-semantics";
|
|
const A = t.offsetWidth, $ = A / o.width;
|
|
C.style.width = `${A}px`, C.style.height = `${o.height * $}px`, C.style.setProperty("--data-text-width", `${$}px`), C.style.setProperty("--data-text-height", `${$}px`), a.classList.add("typst-page"), a.classList.add("canvas"), a.style.width = `${A}px`, a.style.height = `${_ * $}px`, a.style.position = "relative", w.appendChild(C), a.appendChild(w);
|
|
}
|
|
};
|
|
for (let s = 0; s < this.pageInfos.length; s++) {
|
|
const o = this.pageInfos[s];
|
|
let a;
|
|
a = this.commonList[s] = document.createElement("div"), t.appendChild(a), i(s, o, a);
|
|
}
|
|
}
|
|
resetLayout() {
|
|
for (let e = 0; e < this.pageInfos.length; e++) {
|
|
const t = this.pageInfos[e], n = Math.ceil(t.width) * this.imageScaleFactor, i = Math.ceil(t.height) * this.imageScaleFactor, s = this.canvasList[e].parentElement;
|
|
if (!s)
|
|
throw new Error(`canvasDiv is null for page ${e}, canvas list length ${this.canvasList.length}`);
|
|
const o = this.commonList[e], a = this.textLayerParentList[e], d = this.container.offsetWidth, _ = d / n;
|
|
a.style.width = `${d}px`, a.style.height = `${i * _}px`, o.style.width = `${d}px`, o.style.height = `${i * _}px`;
|
|
const f = this.container.offsetWidth / n;
|
|
s.style.transformOrigin = "0px 0px", s.style.transform = `scale(${f})`;
|
|
}
|
|
}
|
|
}
|
|
var G;
|
|
(function(r) {
|
|
r[r.Doc = 0] = "Doc", r[r.Slide = 1] = "Slide";
|
|
})(G || (G = {}));
|
|
class Xe {
|
|
constructor(e) {
|
|
l(this, "hookedElem");
|
|
l(this, "kModule");
|
|
l(this, "opts");
|
|
l(this, "modes", []);
|
|
/// Configuration fields
|
|
/// enable partial rendering
|
|
l(this, "partialRendering", !0);
|
|
/// underlying renderer
|
|
l(this, "renderMode", "svg");
|
|
l(this, "r");
|
|
/// preview mode
|
|
l(this, "previewMode", G.Doc);
|
|
/// whether this is a content preview
|
|
l(this, "isContentPreview", !1);
|
|
/// whether this content preview will mix outline titles
|
|
l(this, "isMixinOutline", !1);
|
|
/// background color
|
|
l(this, "backgroundColor", "black");
|
|
/// default page color (empty string means transparent)
|
|
l(this, "pageColor", "white");
|
|
/// pixel per pt
|
|
l(this, "pixelPerPt", 3);
|
|
/// customized way to retrieving dom state
|
|
l(this, "retrieveDOMState");
|
|
/// State fields
|
|
/// whether svg is updating (in triggerSvgUpdate)
|
|
l(this, "isRendering", !1);
|
|
/// whether kModule is initialized
|
|
l(this, "moduleInitialized", !1);
|
|
/// patch queue for updating data.
|
|
l(this, "patchQueue", []);
|
|
/// resources to dispose
|
|
l(this, "disposeList", []);
|
|
/// canvas render ctoken
|
|
l(this, "canvasRenderCToken");
|
|
/// There are two scales in this class: The real scale is to adjust the size
|
|
/// of `hookedElem` to fit the svg. The virtual scale (scale ratio) is to let
|
|
/// user zoom in/out the svg. For example:
|
|
/// + the default value of virtual scale is 1, which means the svg is totally
|
|
/// fit in `hookedElem`.
|
|
/// + if user set virtual scale to 0.5, then the svg will be zoomed out to fit
|
|
/// in half width of `hookedElem`. "real" current scale of `hookedElem`
|
|
l(this, "currentRealScale", 1);
|
|
/// "virtual" current scale of `hookedElem`
|
|
l(this, "currentScaleRatio", 1);
|
|
/// timeout for delayed viewport change
|
|
l(this, "vpTimeout");
|
|
/// sampled by last render time.
|
|
l(this, "sampledRenderTime", 0);
|
|
/// page to partial render
|
|
l(this, "partialRenderPage", 0);
|
|
/// outline data
|
|
l(this, "outline");
|
|
/// cursor position in form of [page, x, y]
|
|
l(this, "cursorPosition");
|
|
// id: number = rnd++;
|
|
/// Cache fields
|
|
/// cached state of container, default to retrieve state from `this.hookedElem`
|
|
l(this, "cachedDOMState", {
|
|
width: 0,
|
|
height: 0,
|
|
window: {
|
|
innerWidth: 0,
|
|
innerHeight: 0
|
|
},
|
|
boundingRect: {
|
|
left: 0,
|
|
top: 0,
|
|
right: 0
|
|
}
|
|
});
|
|
var t, n;
|
|
this.hookedElem = e.hookedElem, this.kModule = e.kModule, this.opts = e || {};
|
|
{
|
|
const { renderMode: i, previewMode: s, isContentPreview: o, retrieveDOMState: a } = e || {};
|
|
this.partialRendering = !1, this.renderMode = i ?? this.renderMode, this.previewMode = s ?? this.previewMode, this.isContentPreview = o || !1, this.retrieveDOMState = a ?? (() => ({
|
|
width: this.hookedElem.offsetWidth,
|
|
height: this.hookedElem.offsetHeight,
|
|
window: {
|
|
innerWidth: window.innerWidth,
|
|
innerHeight: window.innerHeight
|
|
},
|
|
boundingRect: this.hookedElem.getBoundingClientRect()
|
|
})), this.backgroundColor = getComputedStyle(document.documentElement).getPropertyValue("--typst-preview-background-color");
|
|
}
|
|
this.hookedElem.classList.add("hide-scrollbar-x"), (t = this.hookedElem.parentElement) == null || t.classList.add("hide-scrollbar-x"), this.previewMode === G.Slide && (this.hookedElem.classList.add("hide-scrollbar-y"), (n = this.hookedElem.parentElement) == null || n.classList.add("hide-scrollbar-y")), this.installCtrlWheelHandler();
|
|
}
|
|
reset() {
|
|
this.kModule.reset(), this.moduleInitialized = !1;
|
|
}
|
|
dispose() {
|
|
const e = this.disposeList;
|
|
this.disposeList = [], e.forEach((t) => t());
|
|
}
|
|
static derive(e, t) {
|
|
return ["rescale", "rerender", "postRender"].reduce((n, i) => (n[i] = e[`${i}$${t}`].bind(e), console.assert(n[i] !== void 0, `${i}$${t} is undefined`), n), {});
|
|
}
|
|
registerMode(e) {
|
|
const t = Xe.derive(this, e);
|
|
this.modes.push([e, t]), e === this.renderMode && (this.r = t);
|
|
}
|
|
installCtrlWheelHandler() {
|
|
const e = [
|
|
0.1,
|
|
0.2,
|
|
0.3,
|
|
0.4,
|
|
0.5,
|
|
0.6,
|
|
0.7,
|
|
0.8,
|
|
0.9,
|
|
1,
|
|
1.1,
|
|
1.3,
|
|
1.5,
|
|
1.7,
|
|
1.9,
|
|
2.1,
|
|
2.4,
|
|
2.7,
|
|
3,
|
|
3.3,
|
|
3.7,
|
|
4.1,
|
|
4.6,
|
|
5.1,
|
|
5.7,
|
|
6.3,
|
|
7,
|
|
7.7,
|
|
8.5,
|
|
9.4,
|
|
10
|
|
], t = (n) => {
|
|
var i, s, o, a;
|
|
if (n.ctrlKey) {
|
|
n.preventDefault(), this.cachedDOMState = this.retrieveDOMState(), window.onresize !== null && (window.onresize = null);
|
|
const d = this.currentScaleRatio;
|
|
if (n.deltaY < 0) {
|
|
if (this.currentScaleRatio >= e.at(-1))
|
|
return;
|
|
this.currentScaleRatio = e.filter((C) => C > this.currentScaleRatio).at(0);
|
|
} else if (n.deltaY > 0) {
|
|
if (this.currentScaleRatio <= e.at(0))
|
|
return;
|
|
this.currentScaleRatio = e.filter((C) => C < this.currentScaleRatio).at(-1);
|
|
} else
|
|
return;
|
|
const _ = this.currentScaleRatio / d, f = n.pageX * (_ - 1), w = n.pageY * (_ - 1);
|
|
Math.abs(this.currentScaleRatio - 1) < 1e-5 ? (this.hookedElem.classList.add("hide-scrollbar-x"), (i = this.hookedElem.parentElement) == null || i.classList.add("hide-scrollbar-x"), this.previewMode === G.Slide && (this.hookedElem.classList.add("hide-scrollbar-y"), (s = this.hookedElem.parentElement) == null || s.classList.add("hide-scrollbar-y"))) : (this.hookedElem.classList.remove("hide-scrollbar-x"), (o = this.hookedElem.parentElement) == null || o.classList.remove("hide-scrollbar-x"), this.previewMode === G.Slide && (this.hookedElem.classList.remove("hide-scrollbar-y"), (a = this.hookedElem.parentElement) == null || a.classList.remove("hide-scrollbar-y")));
|
|
const P = this.hookedElem.firstElementChild;
|
|
if (P) {
|
|
const C = this.getSvgScaleRatio(), F = Number.parseFloat(P.getAttribute("data-height")), A = Math.ceil(F * C);
|
|
this.hookedElem.style.height = `${A * 2}px`;
|
|
}
|
|
return window.scrollBy(f, w), this.addViewportChange(), !1;
|
|
}
|
|
};
|
|
this.renderMode !== "dom" && (typeof acquireVsCodeApi < "u" ? (window.addEventListener("wheel", t, {
|
|
passive: !1
|
|
}), this.disposeList.push(() => {
|
|
window.removeEventListener("wheel", t);
|
|
})) : (document.body.addEventListener("wheel", t, {
|
|
passive: !1
|
|
}), this.disposeList.push(() => {
|
|
document.body.removeEventListener("wheel", t);
|
|
})));
|
|
}
|
|
/// Get current scale from html to svg
|
|
// Note: one should retrieve dom state before rescale
|
|
getSvgScaleRatio() {
|
|
const e = this.hookedElem.firstElementChild;
|
|
if (!e)
|
|
return 0;
|
|
const t = this.cachedDOMState, n = Number.parseFloat(e.getAttribute("data-width") || e.getAttribute("width") || "1"), i = Number.parseFloat(e.getAttribute("data-height") || e.getAttribute("height") || "1");
|
|
return this.currentRealScale = this.previewMode === G.Slide ? Math.min(t.width / n, t.height / i) : t.width / n, this.currentRealScale * this.currentScaleRatio;
|
|
}
|
|
processQueue(e) {
|
|
const t = e[0];
|
|
switch (t) {
|
|
case "new":
|
|
case "diff-v1":
|
|
return t === "new" && this.reset(), this.kModule.manipulateData({
|
|
action: "merge",
|
|
data: e[1]
|
|
}), this.moduleInitialized = !0, !0;
|
|
case "viewport-change":
|
|
return this.moduleInitialized ? !0 : (console.log("viewport-change before initialization"), !1);
|
|
default:
|
|
return console.log("svgUpdateEvent", e), !1;
|
|
}
|
|
}
|
|
triggerUpdate() {
|
|
if (this.isRendering)
|
|
return;
|
|
this.isRendering = !0;
|
|
const e = async () => {
|
|
if (this.cachedDOMState = this.retrieveDOMState(), this.patchQueue.length === 0) {
|
|
this.isRendering = !1, this.postprocessChanges();
|
|
return;
|
|
}
|
|
try {
|
|
let t = performance.now();
|
|
const n = this.canvasRenderCToken;
|
|
n && (await n.cancel(), await n.wait(), this.canvasRenderCToken = void 0, console.log("cancel canvas rendering"));
|
|
let i = !1;
|
|
for (; this.patchQueue.length > 0; )
|
|
i = this.processQueue(this.patchQueue.shift()) || i;
|
|
let s = performance.now();
|
|
i && (this.r.rescale(), await this.r.rerender(), this.r.rescale());
|
|
let o = performance.now();
|
|
const a = (d, _, f) => `${d} ${(f - _).toFixed(2)} ms`;
|
|
this.sampledRenderTime = o - t, console.log([a("parse", t, s), a("rerender", s, o), a("total", t, o)].join(", ")), requestAnimationFrame(e);
|
|
} catch (t) {
|
|
console.error(t), this.isRendering = !1, this.postprocessChanges();
|
|
}
|
|
};
|
|
requestAnimationFrame(e);
|
|
}
|
|
postprocessChanges() {
|
|
this.r.postRender(), this.previewMode === G.Slide && document.querySelectorAll(".typst-page-number-indicator").forEach((e) => {
|
|
e.textContent = `${this.kModule.retrievePagesInfo().length}`;
|
|
});
|
|
}
|
|
addChangement(e) {
|
|
e[0] === "new" && this.patchQueue.splice(0, this.patchQueue.length);
|
|
const t = () => {
|
|
this.vpTimeout = void 0, this.patchQueue.push(e), this.triggerUpdate();
|
|
};
|
|
this.vpTimeout !== void 0 && clearTimeout(this.vpTimeout), e[0] === "viewport-change" && this.isRendering ? this.vpTimeout = setTimeout(t, this.sampledRenderTime || 100) : t();
|
|
}
|
|
addViewportChange() {
|
|
this.addChangement(["viewport-change", ""]);
|
|
}
|
|
}
|
|
function sn(r) {
|
|
return class {
|
|
constructor(t) {
|
|
l(this, "impl");
|
|
l(this, "kModule");
|
|
if (t.isContentPreview && (t.renderMode = "canvas"), this.kModule = t.kModule, this.impl = new r(t), !this.impl.r)
|
|
throw new Error(`mode is not supported, ${t == null ? void 0 : t.renderMode}`);
|
|
t.isContentPreview && (this.impl.partialRendering = !0, this.impl.pixelPerPt = 1, this.impl.isMixinOutline = !0);
|
|
}
|
|
dispose() {
|
|
this.impl.dispose();
|
|
}
|
|
reset() {
|
|
this.impl.reset();
|
|
}
|
|
addChangement(t) {
|
|
this.impl.addChangement(t);
|
|
}
|
|
addViewportChange() {
|
|
this.impl.addViewportChange();
|
|
}
|
|
setPageColor(t) {
|
|
this.impl.pageColor = t, this.addViewportChange();
|
|
}
|
|
setPartialRendering(t) {
|
|
this.impl.partialRendering = t;
|
|
}
|
|
setCursor(t, n, i) {
|
|
this.impl.cursorPosition = [t, n, i];
|
|
}
|
|
setPartialPageNumber(t) {
|
|
return t <= 0 || t > this.kModule.retrievePagesInfo().length ? !1 : (this.impl.partialRenderPage = t - 1, this.addViewportChange(), !0);
|
|
}
|
|
getPartialPageNumber() {
|
|
return this.impl.partialRenderPage + 1;
|
|
}
|
|
setOutineData(t) {
|
|
this.impl.outline = t, this.addViewportChange();
|
|
}
|
|
};
|
|
}
|
|
function on(r, ...e) {
|
|
return e.reduce((t, n) => n(t), r);
|
|
}
|
|
class an {
|
|
constructor() {
|
|
l(this, "isCancellationRequested", !1);
|
|
l(this, "_onCancelled");
|
|
l(this, "_onCancelledResolveResolved");
|
|
let e, t;
|
|
this._onCancelled = new Promise((n) => {
|
|
e = n, t && t(n);
|
|
}), this._onCancelledResolveResolved = new Promise((n) => {
|
|
t = n, e && n(e);
|
|
});
|
|
}
|
|
async cancel() {
|
|
await this._onCancelledResolveResolved, this.isCancellationRequested = !0;
|
|
}
|
|
isCancelRequested() {
|
|
return this.isCancellationRequested;
|
|
}
|
|
async consume() {
|
|
(await this._onCancelledResolveResolved)();
|
|
}
|
|
wait() {
|
|
return this._onCancelled;
|
|
}
|
|
}
|
|
const cn = () => new Promise((r) => requestAnimationFrame(r));
|
|
var Ve;
|
|
(function(r) {
|
|
r[r.Doc = 0] = "Doc", r[r.Pages = 1] = "Pages";
|
|
})(Ve || (Ve = {}));
|
|
var q;
|
|
(function(r) {
|
|
r[r.Layout = 0] = "Layout", r[r.Svg = 1] = "Svg", r[r.Semantics = 2] = "Semantics", r[r.PrepareCanvas = 3] = "PrepareCanvas", r[r.Canvas = 4] = "Canvas";
|
|
})(q || (q = {}));
|
|
function _n(r) {
|
|
return class extends r {
|
|
constructor(...n) {
|
|
super(...n);
|
|
/// The template element for creating DOM by string.
|
|
l(this, "tmpl", document.createElement("template"));
|
|
/// The stub element for replacing an invisible element.
|
|
l(this, "stub", this.createElement("<stub></stub>"));
|
|
/// Typescript side of lib.
|
|
l(this, "plugin");
|
|
/// Rust side of kernel.
|
|
l(this, "docKernel");
|
|
/// The element to track.
|
|
l(this, "resourceHeader");
|
|
/// Expected exact state of the current DOM.
|
|
/// Initially it is empty meaning no any page is rendered.
|
|
l(this, "pages", []);
|
|
/// The virtual scale of the document.
|
|
l(this, "domScale", 1);
|
|
/// Track mode.
|
|
l(this, "track_mode", Ve.Doc);
|
|
/// Current executing task.
|
|
l(this, "current_task");
|
|
/// The currently maintained viewport.
|
|
l(this, "viewport");
|
|
if (this.registerMode("dom"), this.disposeList.push(() => {
|
|
this.dispose();
|
|
}), this.plugin = this.opts.renderer, this.opts.domScale !== void 0) {
|
|
if (this.opts.domScale <= 0)
|
|
throw new Error("domScale must be positive");
|
|
this.domScale = this.opts.domScale;
|
|
}
|
|
}
|
|
dispose() {
|
|
for (const n of this.pages)
|
|
n.dispose();
|
|
this.docKernel && this.docKernel.free();
|
|
}
|
|
createElement(n) {
|
|
return this.tmpl.innerHTML = n, this.tmpl.content.firstElementChild;
|
|
}
|
|
async mountDom(n) {
|
|
if (console.log("mountDom", n), this.docKernel)
|
|
throw new Error("already mounted");
|
|
this.hookedElem.innerHTML = '<svg class="typst-svg-resources" viewBox="0 0 0 0" width="0" height="0" style="opacity: 0; position: absolute;"></svg>', this.resourceHeader = this.hookedElem.querySelector(".typst-svg-resources"), this.docKernel = await this.plugin.renderer.mount_dom(this.kModule[E], this.hookedElem), this.docKernel.bind_functions({
|
|
populateGlyphs: (i) => {
|
|
let s = this.createElement(i);
|
|
console.log("populateGlyphs", s);
|
|
let o = s.firstElementChild;
|
|
this.resourceHeader.append(o);
|
|
}
|
|
});
|
|
}
|
|
async cancelAnyway$dom() {
|
|
if (console.log("cancelAnyway$dom"), this.current_task) {
|
|
const n = this.current_task;
|
|
this.current_task = void 0, await n.cancel();
|
|
}
|
|
}
|
|
retrieveDOMPages() {
|
|
return Array.from(this.hookedElem.querySelectorAll(".typst-dom-page"));
|
|
}
|
|
// doesn't need to postRender
|
|
postRender$dom() {
|
|
}
|
|
// doesn't need to rescale
|
|
rescale$dom() {
|
|
}
|
|
getDomViewport(n, i) {
|
|
const s = i.left, o = -i.top, a = i.right, d = n.innerHeight - i.top, _ = {
|
|
x: 0,
|
|
y: o / this.domScale,
|
|
width: Math.max(a - s, 0) / this.domScale,
|
|
height: Math.max(d - o, 0) / this.domScale
|
|
};
|
|
return (_.width <= 0 || _.height <= 0) && (_.x = _.y = _.width = _.height = 0), _;
|
|
}
|
|
// fast mode
|
|
async rerender$dom() {
|
|
const n = this.retrieveDOMState(), { x: i, y: s, width: o, height: a } = this.getDomViewport(n.window, n.boundingRect);
|
|
if (!await this.docKernel.relayout(i, s, o, a))
|
|
return;
|
|
const _ = new an();
|
|
this.doRender$dom(_), this.current_task = _;
|
|
}
|
|
async doRender$dom(n) {
|
|
const i = (d, _) => {
|
|
if (d && !n.isCancelRequested() && _)
|
|
return _();
|
|
}, s = this.retrieveDOMPages().map((d) => {
|
|
const { innerWidth: _, innerHeight: f } = window, w = d.getBoundingClientRect();
|
|
return {
|
|
inWindow: !(w.left > _ || w.right < 0 || w.top > f || w.bottom < 0),
|
|
page: d
|
|
};
|
|
}), o = async (d) => {
|
|
if (await cn(), n.isCancelRequested()) {
|
|
console.log("cancel stage", q.Layout, d);
|
|
return;
|
|
}
|
|
const _ = s[d].page, f = _.getBoundingClientRect(), w = this.getDomViewport(window, f), P = (D) => this.docKernel.need_repaint(d, w.x, w.y, w.width, w.height, D), C = (D) => this.docKernel.repaint(d, w.x, w.y, w.width, w.height, D), F = (D) => {
|
|
if (!n.isCancelRequested())
|
|
return i(P(D), () => C(D));
|
|
};
|
|
await F(q.Layout);
|
|
const A = (f.width ? Number.parseFloat(_.getAttribute("data-width")) / f.width : 1) * this.domScale, $ = (f.height ? Number.parseFloat(_.getAttribute("data-height")) / f.height : 1) * this.domScale;
|
|
if (w.x *= A, w.y *= $, w.y -= 100, w.width *= A, w.height *= $, w.height += 200, await F(q.Svg), await F(q.Semantics), n.isCancelRequested()) {
|
|
console.log("cancel stage", q.Semantics, d);
|
|
return;
|
|
}
|
|
P(q.PrepareCanvas) ? (async () => {
|
|
if (await C(q.PrepareCanvas), !n.isCancelRequested())
|
|
return F(q.Canvas);
|
|
})() : await F(q.Canvas);
|
|
}, a = async (d) => {
|
|
for (let _ = 0; _ < s.length; ++_) {
|
|
if (n.isCancelRequested()) {
|
|
console.log("cancel page", q.Layout, _);
|
|
return;
|
|
}
|
|
s[_].inWindow === d && await o(_);
|
|
}
|
|
};
|
|
this.cancelAnyway$dom(), await a(!0), await a(!1), !n.isCancelRequested() && console.log("finished", q.Layout);
|
|
}
|
|
};
|
|
}
|
|
class un extends sn(on(Xe, _n)) {
|
|
}
|
|
var At;
|
|
let he = (At = E, class {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e, t) {
|
|
l(this, "plugin");
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, At);
|
|
this.plugin = e, this[E] = t;
|
|
}
|
|
/**
|
|
* @deprecated set in {@link RenderToCanvasOptions} instead
|
|
*
|
|
* Set the background color of the Typst document.
|
|
* @param {string} t - The background color in format of `^#?[0-9a-f]{6}$`
|
|
*
|
|
* Note: Default to `#ffffff`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
set backgroundColor(e) {
|
|
e !== void 0 && (this[E].background_color = e);
|
|
}
|
|
/**
|
|
* Get the background color of the Typst document.
|
|
*
|
|
* Note: Default to `#ffffff`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
get backgroundColor() {
|
|
return this[E].background_color;
|
|
}
|
|
/**
|
|
* Set the pixel per point scale up the canvas panel.
|
|
*
|
|
* Note: Default to `3`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
set pixelPerPt(e) {
|
|
e !== void 0 && (this[E].pixel_per_pt = e);
|
|
}
|
|
/**
|
|
* @deprecated set in {@link RenderToCanvasOptions} instead
|
|
*
|
|
* Get the pixel per point scale up the canvas panel.
|
|
*
|
|
* Note: Default to `3`.
|
|
*
|
|
* Note: Only available in canvas rendering mode.
|
|
*/
|
|
get pixelPerPt() {
|
|
return this[E].pixel_per_pt;
|
|
}
|
|
/**
|
|
* Reset state
|
|
*/
|
|
reset() {
|
|
this.plugin.resetSession(this);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link docWidth} instead
|
|
*/
|
|
get doc_width() {
|
|
return this[E].doc_width;
|
|
}
|
|
get docWidth() {
|
|
return this[E].doc_width;
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link docHeight} instead
|
|
*/
|
|
get doc_height() {
|
|
return this[E].doc_height;
|
|
}
|
|
get docHeight() {
|
|
return this[E].doc_height;
|
|
}
|
|
retrievePagesInfo() {
|
|
const e = this[E].pages_info, t = [], n = e.page_count;
|
|
for (let i = 0; i < n; i++) {
|
|
const s = e.page(i);
|
|
t.push({
|
|
pageOffset: s.page_off,
|
|
width: s.width_pt,
|
|
height: s.height_pt
|
|
});
|
|
}
|
|
return t;
|
|
}
|
|
getSourceLoc(e) {
|
|
return this[E].source_span(e);
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderSvg} for more details.
|
|
*/
|
|
renderSvg(e) {
|
|
return this.plugin.renderSvg({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderToSvg} for more details.
|
|
*/
|
|
renderToSvg(e) {
|
|
return this.plugin.renderToSvg({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderCanvas} for more details.
|
|
*/
|
|
renderCanvas(e) {
|
|
return this.plugin.renderCanvas({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#manipulateData} for more details.
|
|
*/
|
|
manipulateData(e) {
|
|
this.plugin.manipulateData({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#renderSvgDiff} for more details.
|
|
*/
|
|
renderSvgDiff(e) {
|
|
return this.plugin.renderSvgDiff({
|
|
renderSession: this,
|
|
...e
|
|
});
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link getSourceLoc} instead
|
|
*/
|
|
get_source_loc(e) {
|
|
return this[E].source_span(e);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link renderSvgDiff} instead
|
|
*/
|
|
render_in_window(e, t, n, i) {
|
|
return this[E].render_in_window(e, t, n, i);
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* use {@link manipulateData} instead
|
|
*/
|
|
merge_delta(e) {
|
|
this.plugin.manipulateData({
|
|
renderSession: this,
|
|
action: "merge",
|
|
data: e
|
|
});
|
|
}
|
|
});
|
|
var ee;
|
|
(function(r) {
|
|
r[r.Delete = 0] = "Delete", r[r.New = 1] = "New", r[r.Update = 2] = "Update";
|
|
})(ee || (ee = {}));
|
|
var Tt;
|
|
let Jt = (Tt = E, class {
|
|
/**
|
|
* @internal
|
|
*/
|
|
constructor(e, t) {
|
|
l(this, "plugin");
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, Tt);
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, "managedCanvasElemList", /* @__PURE__ */ new Map());
|
|
/**
|
|
* @internal
|
|
*/
|
|
l(this, "canvasCounter", Math.random());
|
|
this.plugin = e, this[E] = t;
|
|
}
|
|
/**
|
|
* See {@link TypstRenderer#manipulateData} for more details.
|
|
*/
|
|
manipulateData(e, t) {
|
|
return this[E].manipulate_data(e, t);
|
|
}
|
|
/**
|
|
* You must submit all canvas in pages to ensure synchronization with the background worker
|
|
*
|
|
* See {@link TypstRenderer#renderCanvas} for more details.
|
|
*/
|
|
renderCanvas(e) {
|
|
const t = this.managedCanvasElemList;
|
|
for (const [a, d] of t)
|
|
d[0] = ee.Delete;
|
|
for (const a of e) {
|
|
const d = a.canvas;
|
|
let _ = d.dataset.manageId, f = ee.Update;
|
|
_ || (_ = this.canvasCounter.toFixed(5), this.canvasCounter += 1, d.dataset.manageId = _, f = ee.New);
|
|
let w = t.get(_);
|
|
if (w && w[0] !== ee.Delete)
|
|
throw new Error("cannot update a canvas for two times in batch");
|
|
t.set(_, [f, { ...a }]);
|
|
}
|
|
const n = Array.from(t.entries()), i = new Uint8Array(n.length), s = new Array(n.length), o = n.map(([a, [d, _]], f) => (d || t.delete(a), i[f] = d, s[f] = _.canvas, this.plugin.canvasOptionsToRust(_)));
|
|
return this[E].render_canvas(i, s, o);
|
|
}
|
|
async retrievePagesInfo() {
|
|
const e = await this[E].get_pages_info();
|
|
console.log(e);
|
|
const t = [], n = e.page_count;
|
|
for (let i = 0; i < n; i++) {
|
|
const s = e.page(i);
|
|
t.push({
|
|
pageOffset: s.page_off,
|
|
width: s.width_pt,
|
|
height: s.height_pt
|
|
});
|
|
}
|
|
return t;
|
|
}
|
|
});
|
|
const dn = (r) => new Ut(async (e) => await r.default(e));
|
|
function ln() {
|
|
return new Kt();
|
|
}
|
|
let _t = !0;
|
|
class Kt {
|
|
constructor() {
|
|
l(this, "renderer");
|
|
l(this, "rendererJs");
|
|
}
|
|
async init(e) {
|
|
var n;
|
|
this.rendererJs = await (((n = e == null ? void 0 : e.getWrapper) == null ? void 0 : n.call(e)) || Promise.resolve().then(() => Ye));
|
|
const t = this.rendererJs.TypstRendererBuilder;
|
|
this.renderer = await Nt(e, dn(this.rendererJs), t, {});
|
|
}
|
|
loadGlyphPack(e) {
|
|
return Promise.resolve();
|
|
}
|
|
createOptionsToRust(e) {
|
|
const t = new this.rendererJs.CreateSessionOptions();
|
|
return e.format !== void 0 && (t.format = e.format), e.artifactContent !== void 0 && (t.artifact_content = e.artifactContent), t;
|
|
}
|
|
canvasOptionsToRust(e) {
|
|
const t = new this.rendererJs.RenderPageImageOptions();
|
|
if (e.pageOffset === void 0)
|
|
throw new Error("pageOffset is required in reflexo v0.5.0");
|
|
if (t.page_off = e.pageOffset, e.cacheKey !== void 0 && (t.cache_key = e.cacheKey), e.backgroundColor !== void 0 && (t.background_color = e.backgroundColor), e.pixelPerPt !== void 0 && (t.pixel_per_pt = e.pixelPerPt), e.dataSelection !== void 0) {
|
|
let n = 0;
|
|
e.dataSelection.body ? n |= 1 : e.canvas && _t && (_t = !1, console.warn("dataSelection.body is not set but providing canvas for body")), (e.dataSelection.text || e.dataSelection.annotation) && console.error("dataSelection.text and dataSelection.annotation are deprecated"), e.dataSelection.semantics && (n |= 8), t.data_selection = n;
|
|
}
|
|
return t;
|
|
}
|
|
retrievePagesInfoFromSession(e) {
|
|
return e.retrievePagesInfo();
|
|
}
|
|
/**
|
|
* Render a Typst document to canvas.
|
|
*/
|
|
renderCanvas(e) {
|
|
return this.withinOptionSession(e, async (t) => this.renderer.render_page_to_canvas(t[E], e.canvas || void 0, this.canvasOptionsToRust(e)));
|
|
}
|
|
// async renderPdf(artifactContent: string): Promise<Uint8Array> {
|
|
// return this.renderer.render_to_pdf(artifactContent);
|
|
// }
|
|
async inAnimationFrame(e) {
|
|
return new Promise((t, n) => {
|
|
requestAnimationFrame(() => {
|
|
try {
|
|
t(e());
|
|
} catch (i) {
|
|
n(i);
|
|
}
|
|
});
|
|
});
|
|
}
|
|
async renderDisplayLayer(e, t, n) {
|
|
const s = e[E].pages_info.page_count, o = async (f, w) => {
|
|
const C = t[f].getContext("2d");
|
|
if (!C)
|
|
throw new Error("canvas context is null");
|
|
return await this.renderCanvas({
|
|
...n,
|
|
canvas: C,
|
|
renderSession: e,
|
|
pageOffset: w
|
|
});
|
|
}, a = performance.now(), d = await (async () => {
|
|
const f = [];
|
|
for (let w = 0; w < s; w++)
|
|
f.push(await this.inAnimationFrame(() => o(w, w)));
|
|
return f;
|
|
})(), _ = performance.now();
|
|
return console.log(`display layer used: render = ${(_ - a).toFixed(1)}ms`), d;
|
|
}
|
|
renderTextLayer(e, t) {
|
|
const n = performance.now();
|
|
e.forEach((s, o) => {
|
|
s.innerHTML = t[o].htmlSemantics[0];
|
|
});
|
|
const i = performance.now();
|
|
console.log(`text layer used: render = ${(i - n).toFixed(1)}ms`);
|
|
}
|
|
async render(e) {
|
|
if ("format" in e && e.format !== "vector" && ["serde_json", "js", "ir"].includes(e.format))
|
|
throw new Error(`deprecated format ${e.format}, please use vector format`);
|
|
return this.renderToCanvas(e);
|
|
}
|
|
async renderDom(e) {
|
|
if ("format" in e && e.format !== "vector" && ["serde_json", "js", "ir"].includes(e.format))
|
|
throw new Error(`deprecated format ${e.format}, please use vector format`);
|
|
return this.withinOptionSession(e, async (t) => {
|
|
const n = new un({
|
|
...e,
|
|
renderMode: "dom",
|
|
hookedElem: e.container,
|
|
kModule: t,
|
|
renderer: this
|
|
});
|
|
return await n.impl.mountDom(e.pixelPerPt), n;
|
|
});
|
|
}
|
|
async renderToCanvas(e) {
|
|
let t, n;
|
|
const i = e.container;
|
|
i.style.visibility = "hidden";
|
|
const s = async (o, a) => {
|
|
try {
|
|
n = await this.renderDisplayLayer(t, o, e), a();
|
|
} finally {
|
|
i.style.visibility = "visible";
|
|
}
|
|
};
|
|
return this.withinOptionSession(e, async (o) => {
|
|
if (t = o, t[E].pages_info.page_count === 0)
|
|
throw new Error("No page found in session");
|
|
if (e.pixelPerPt !== void 0 && e.pixelPerPt <= 0)
|
|
throw new Error("Invalid typst.RenderOptions.pixelPerPt, should be a positive number " + e.pixelPerPt);
|
|
let a = e.backgroundColor;
|
|
if (a !== void 0 && !/^#[0-9a-f]{6}$/.test(a))
|
|
throw new Error("Invalid typst.backgroundColor color for matching ^#?[0-9a-f]{6}$ " + a);
|
|
t.pixelPerPt = e.pixelPerPt ?? me.PIXEL_PER_PT, t.backgroundColor = a ?? "#ffffff";
|
|
const d = performance.now(), _ = new nn(this.retrievePagesInfoFromSession(t), i, e), f = performance.now();
|
|
console.log(`layer used: retrieve = ${(f - d).toFixed(1)}ms`), await s(_.canvasList, () => _.resetLayout()), this.renderTextLayer(_.textLayerList, n);
|
|
});
|
|
}
|
|
createModule(e) {
|
|
return Promise.resolve(new he(this, this.renderer.create_session(e && this.createOptionsToRust({
|
|
format: "vector",
|
|
artifactContent: e
|
|
}))));
|
|
}
|
|
async createWorkerV0(e) {
|
|
return new Jt(this, await this.renderer.create_worker(e));
|
|
}
|
|
workerBridge() {
|
|
return this.renderer.create_worker_bridge();
|
|
}
|
|
renderSvg(e, t) {
|
|
if (e instanceof he || t)
|
|
throw new Error("removed api, please use renderToSvg({ renderSession, container }) instead");
|
|
return this.withinOptionSession(e, async (n) => {
|
|
let i;
|
|
return e.data_selection && (i = 0, e.data_selection.body && (i |= 1), e.data_selection.defs && (i |= 2), e.data_selection.css && (i |= 4), e.data_selection.js && (i |= 8)), Promise.resolve(this.renderer.svg_data(n[E], i));
|
|
});
|
|
}
|
|
renderSvgDiff(e) {
|
|
return e.window ? this.renderer.render_svg_diff(e.renderSession[E], e.window.lo.x, e.window.lo.y, e.window.hi.x, e.window.hi.y) : this.renderer.render_svg_diff(e.renderSession[E], 0, 0, 1e33, 1e33);
|
|
}
|
|
renderToSvg(e) {
|
|
return this.withinOptionSession(e, async (t) => Promise.resolve(this.renderer.render_svg(t[E], e.container)));
|
|
}
|
|
getCustomV1(e) {
|
|
return Promise.resolve(this.renderer.get_customs(e.renderSession[E]));
|
|
}
|
|
resetSession(e) {
|
|
return this.renderer.reset(e[E]);
|
|
}
|
|
manipulateData(e) {
|
|
return this.renderer.manipulate_data(e.renderSession[E], e.action ?? "reset", e.data);
|
|
}
|
|
withinOptionSession(e, t) {
|
|
function n(i) {
|
|
return "artifactContent" in i;
|
|
}
|
|
if ("renderSession" in e)
|
|
return t(e.renderSession);
|
|
if (n(e))
|
|
return this.runWithSession(e, t);
|
|
throw new Error("Invalid render options, should be one of RenderByContentOptions|RenderBySessionOptions");
|
|
}
|
|
async runWithSession(e, t) {
|
|
let n = e, i = t;
|
|
t || (n = void 0, i = e);
|
|
const s = this.renderer.create_session(
|
|
/* moved */
|
|
n && this.createOptionsToRust(n)
|
|
);
|
|
try {
|
|
const o = await i(new he(this, s));
|
|
return s.free(), o;
|
|
} catch (o) {
|
|
throw s.free(), o;
|
|
}
|
|
}
|
|
}
|
|
const ut = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
RenderSession: he,
|
|
TypstRendererDriver: Kt,
|
|
TypstWorker: Jt,
|
|
createTypstRenderer: ln
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
let dt, je;
|
|
function gn(r, e) {
|
|
const t = dt || r();
|
|
return je !== void 0 ? je : je = (async () => (await t.init(e), dt = t))();
|
|
}
|
|
const fn = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
createGlobalRenderer: gn
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
let c;
|
|
const J = new Array(128).fill(void 0);
|
|
J.push(void 0, null, !0, !1);
|
|
function u(r) {
|
|
return J[r];
|
|
}
|
|
let te = J.length;
|
|
function y(r) {
|
|
te === J.length && J.push(J.length + 1);
|
|
const e = te;
|
|
if (te = J[e], typeof te != "number") throw new Error("corrupt heap");
|
|
return J[e] = r, e;
|
|
}
|
|
function x(r, e) {
|
|
try {
|
|
return r.apply(this, e);
|
|
} catch (t) {
|
|
c.__wbindgen_export_0(y(t));
|
|
}
|
|
}
|
|
function h(r, e) {
|
|
try {
|
|
return r.apply(this, e);
|
|
} catch (t) {
|
|
let n = function() {
|
|
try {
|
|
return t instanceof Error ? `${t.message}
|
|
|
|
Stack:
|
|
${t.stack}` : t.toString();
|
|
} catch {
|
|
return "<failed to stringify thrown value>";
|
|
}
|
|
}();
|
|
throw console.error("wasm-bindgen: imported JS function that was not marked as `catch` threw an error:", n), t;
|
|
}
|
|
}
|
|
function p(r) {
|
|
if (typeof r != "number") throw new Error(`expected a number argument, found ${typeof r}`);
|
|
}
|
|
const Gt = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => {
|
|
throw Error("TextDecoder not available");
|
|
} };
|
|
typeof TextDecoder < "u" && Gt.decode();
|
|
let ie = null;
|
|
function ce() {
|
|
return (ie === null || ie.byteLength === 0) && (ie = new Uint8Array(c.memory.buffer)), ie;
|
|
}
|
|
function k(r, e) {
|
|
return r = r >>> 0, Gt.decode(ce().subarray(r, r + e));
|
|
}
|
|
let O = 0;
|
|
const pe = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => {
|
|
throw Error("TextEncoder not available");
|
|
} }, wn = typeof pe.encodeInto == "function" ? function(r, e) {
|
|
return pe.encodeInto(r, e);
|
|
} : function(r, e) {
|
|
const t = pe.encode(r);
|
|
return e.set(t), {
|
|
read: r.length,
|
|
written: t.length
|
|
};
|
|
};
|
|
function W(r, e, t) {
|
|
if (typeof r != "string") throw new Error(`expected a string argument, found ${typeof r}`);
|
|
if (t === void 0) {
|
|
const a = pe.encode(r), d = e(a.length, 1) >>> 0;
|
|
return ce().subarray(d, d + a.length).set(a), O = a.length, d;
|
|
}
|
|
let n = r.length, i = e(n, 1) >>> 0;
|
|
const s = ce();
|
|
let o = 0;
|
|
for (; o < n; o++) {
|
|
const a = r.charCodeAt(o);
|
|
if (a > 127) break;
|
|
s[i + o] = a;
|
|
}
|
|
if (o !== n) {
|
|
o !== 0 && (r = r.slice(o)), i = t(i, n, n = o + r.length * 3, 1) >>> 0;
|
|
const a = ce().subarray(i + o, i + n), d = wn(r, a);
|
|
if (d.read !== r.length) throw new Error("failed to pass whole string");
|
|
o += d.written, i = t(i, n, o, 1) >>> 0;
|
|
}
|
|
return O = o, i;
|
|
}
|
|
let Q = null;
|
|
function m() {
|
|
return (Q === null || Q.buffer.detached === !0 || Q.buffer.detached === void 0 && Q.buffer !== c.memory.buffer) && (Q = new DataView(c.memory.buffer)), Q;
|
|
}
|
|
function L(r) {
|
|
return r == null;
|
|
}
|
|
function j(r) {
|
|
if (typeof r != "boolean")
|
|
throw new Error(`expected a boolean argument, found ${typeof r}`);
|
|
}
|
|
function hn(r) {
|
|
r < 132 || (J[r] = te, te = r);
|
|
}
|
|
function M(r) {
|
|
const e = u(r);
|
|
return hn(r), e;
|
|
}
|
|
const ve = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => {
|
|
c.__wbindgen_export_4.get(r.dtor)(r.a, r.b);
|
|
});
|
|
function lt(r, e, t, n) {
|
|
const i = { a: r, b: e, cnt: 1, dtor: t }, s = (...o) => {
|
|
i.cnt++;
|
|
try {
|
|
return n(i.a, i.b, ...o);
|
|
} finally {
|
|
--i.cnt === 0 && (c.__wbindgen_export_4.get(i.dtor)(i.a, i.b), i.a = 0, ve.unregister(i));
|
|
}
|
|
};
|
|
return s.original = i, ve.register(s, i, i), s;
|
|
}
|
|
function pn(r, e, t, n) {
|
|
const i = { a: r, b: e, cnt: 1, dtor: t }, s = (...o) => {
|
|
i.cnt++;
|
|
const a = i.a;
|
|
i.a = 0;
|
|
try {
|
|
return n(a, i.b, ...o);
|
|
} finally {
|
|
--i.cnt === 0 ? (c.__wbindgen_export_4.get(i.dtor)(a, i.b), ve.unregister(i)) : i.a = a;
|
|
}
|
|
};
|
|
return s.original = i, ve.register(s, i, i), s;
|
|
}
|
|
function Je(r) {
|
|
const e = typeof r;
|
|
if (e == "number" || e == "boolean" || r == null)
|
|
return `${r}`;
|
|
if (e == "string")
|
|
return `"${r}"`;
|
|
if (e == "symbol") {
|
|
const i = r.description;
|
|
return i == null ? "Symbol" : `Symbol(${i})`;
|
|
}
|
|
if (e == "function") {
|
|
const i = r.name;
|
|
return typeof i == "string" && i.length > 0 ? `Function(${i})` : "Function";
|
|
}
|
|
if (Array.isArray(r)) {
|
|
const i = r.length;
|
|
let s = "[";
|
|
i > 0 && (s += Je(r[0]));
|
|
for (let o = 1; o < i; o++)
|
|
s += ", " + Je(r[o]);
|
|
return s += "]", s;
|
|
}
|
|
const t = /\[object ([^\]]+)\]/.exec(toString.call(r));
|
|
let n;
|
|
if (t && t.length > 1)
|
|
n = t[1];
|
|
else
|
|
return toString.call(r);
|
|
if (n == "Object")
|
|
try {
|
|
return "Object(" + JSON.stringify(r) + ")";
|
|
} catch {
|
|
return "Object";
|
|
}
|
|
return r instanceof Error ? `${r.name}: ${r.message}
|
|
${r.stack}` : n;
|
|
}
|
|
function Se(r, e) {
|
|
const t = e(r.length * 1, 1) >>> 0;
|
|
return ce().set(r, t / 1), O = r.length, t;
|
|
}
|
|
function gt(r, e) {
|
|
const t = e(r.length * 4, 4) >>> 0, n = m();
|
|
for (let i = 0; i < r.length; i++)
|
|
n.setUint32(t + 4 * i, y(r[i]), !0);
|
|
return O = r.length, t;
|
|
}
|
|
function H(r, e) {
|
|
if (!(r instanceof e))
|
|
throw new Error(`expected instance of ${e.name}`);
|
|
}
|
|
let se = null;
|
|
function bn() {
|
|
return (se === null || se.byteLength === 0) && (se = new Uint32Array(c.memory.buffer)), se;
|
|
}
|
|
function mn(r, e) {
|
|
const t = e(r.length * 4, 4) >>> 0;
|
|
return bn().set(r, t / 4), O = r.length, t;
|
|
}
|
|
function yn() {
|
|
const r = c.renderer_build_info();
|
|
return M(r);
|
|
}
|
|
function vn(r, e) {
|
|
p(r), p(e), c.__wbindgen_export_5(r, e);
|
|
}
|
|
function Sn(r, e, t) {
|
|
p(r), p(e), c.__wbindgen_export_6(r, e, y(t));
|
|
}
|
|
function Cn(r, e, t) {
|
|
p(r), p(e), c.__wbindgen_export_7(r, e, y(t));
|
|
}
|
|
function xn(r, e, t, n) {
|
|
p(r), p(e), c.__wbindgen_export_8(r, e, y(t), y(n));
|
|
}
|
|
const ft = ["nonzero", "evenodd"], wt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_createsessionoptions_free(r >>> 0, 1));
|
|
class Qt {
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, wt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_createsessionoptions_free(e, 0);
|
|
}
|
|
constructor() {
|
|
const e = c.createsessionoptions_new();
|
|
return this.__wbg_ptr = e >>> 0, wt.register(this, this.__wbg_ptr, this), this;
|
|
}
|
|
/**
|
|
* @param {string} format
|
|
*/
|
|
set format(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.createsessionoptions_set_format(this.__wbg_ptr, t, n);
|
|
}
|
|
/**
|
|
* @param {Uint8Array} artifact_content
|
|
*/
|
|
set artifact_content(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = Se(e, c.__wbindgen_export_1), n = O;
|
|
c.createsessionoptions_set_artifact_content(this.__wbg_ptr, t, n);
|
|
}
|
|
}
|
|
const ht = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_incrdomdocclient_free(r >>> 0, 1));
|
|
class xe {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(xe.prototype);
|
|
return t.__wbg_ptr = e, ht.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, ht.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_incrdomdocclient_free(e, 0);
|
|
}
|
|
/**
|
|
* @param {any} functions
|
|
*/
|
|
bind_functions(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), c.incrdomdocclient_bind_functions(this.__wbg_ptr, y(e));
|
|
}
|
|
/**
|
|
* Relayout the document in the given window.
|
|
* @param {number} x
|
|
* @param {number} y
|
|
* @param {number} w
|
|
* @param {number} h
|
|
* @returns {Promise<boolean>}
|
|
*/
|
|
relayout(e, t, n, i) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const s = c.incrdomdocclient_relayout(this.__wbg_ptr, e, t, n, i);
|
|
return M(s);
|
|
}
|
|
/**
|
|
* @param {number} page_num
|
|
* @param {number} x
|
|
* @param {number} y
|
|
* @param {number} w
|
|
* @param {number} h
|
|
* @param {number} stage
|
|
* @returns {boolean}
|
|
*/
|
|
need_repaint(e, t, n, i, s, o) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const f = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), p(e), p(o), c.incrdomdocclient_need_repaint(f, this.__wbg_ptr, e, t, n, i, s, o);
|
|
var a = m().getInt32(f + 4 * 0, !0), d = m().getInt32(f + 4 * 1, !0), _ = m().getInt32(f + 4 * 2, !0);
|
|
if (_)
|
|
throw M(d);
|
|
return a !== 0;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {number} page_num
|
|
* @param {number} x
|
|
* @param {number} y
|
|
* @param {number} w
|
|
* @param {number} h
|
|
* @param {number} stage
|
|
* @returns {any}
|
|
*/
|
|
repaint(e, t, n, i, s, o) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const f = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), p(e), p(o), c.incrdomdocclient_repaint(f, this.__wbg_ptr, e, t, n, i, s, o);
|
|
var a = m().getInt32(f + 4 * 0, !0), d = m().getInt32(f + 4 * 1, !0), _ = m().getInt32(f + 4 * 2, !0);
|
|
if (_)
|
|
throw M(d);
|
|
return M(a);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const pt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_pageinfo_free(r >>> 0, 1));
|
|
class ue {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(ue.prototype);
|
|
return t.__wbg_ptr = e, pt.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, pt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_pageinfo_free(e, 0);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get page_off() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pageinfo_page_off(this.__wbg_ptr) >>> 0;
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get width_pt() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pageinfo_width_pt(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get height_pt() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pageinfo_height_pt(this.__wbg_ptr);
|
|
}
|
|
}
|
|
const bt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_pagesinfo_free(r >>> 0, 1));
|
|
class ke {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(ke.prototype);
|
|
return t.__wbg_ptr = e, bt.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, bt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_pagesinfo_free(e, 0);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get page_count() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pagesinfo_page_count(this.__wbg_ptr) >>> 0;
|
|
}
|
|
/**
|
|
* @param {number} num
|
|
* @returns {PageInfo | undefined}
|
|
*/
|
|
page_by_number(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), p(e);
|
|
const t = c.pagesinfo_page_by_number(this.__wbg_ptr, e);
|
|
return t === 0 ? void 0 : ue.__wrap(t);
|
|
}
|
|
/**
|
|
* @param {number} i
|
|
* @returns {PageInfo}
|
|
*/
|
|
page(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), p(e);
|
|
const t = c.pagesinfo_page(this.__wbg_ptr, e);
|
|
return ue.__wrap(t);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
width() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pagesinfo_width(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
height() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.pagesinfo_height(this.__wbg_ptr);
|
|
}
|
|
}
|
|
const mt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_renderpageimageoptions_free(r >>> 0, 1));
|
|
class le {
|
|
static __unwrap(e) {
|
|
return e instanceof le ? e.__destroy_into_raw() : 0;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, mt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_renderpageimageoptions_free(e, 0);
|
|
}
|
|
constructor() {
|
|
const e = c.renderpageimageoptions_new();
|
|
return this.__wbg_ptr = e >>> 0, mt.register(this, this.__wbg_ptr, this), this;
|
|
}
|
|
/**
|
|
* @returns {number | undefined}
|
|
*/
|
|
get pixel_per_pt() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.renderpageimageoptions_pixel_per_pt(this.__wbg_ptr);
|
|
return e === 4294967297 ? void 0 : e;
|
|
}
|
|
/**
|
|
* @param {number | null} [pixel_per_pt]
|
|
*/
|
|
set pixel_per_pt(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), L(e) || p(e), c.renderpageimageoptions_set_pixel_per_pt(this.__wbg_ptr, L(e) ? 4294967297 : Math.fround(e));
|
|
}
|
|
/**
|
|
* @returns {string | undefined}
|
|
*/
|
|
get background_color() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const n = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.renderpageimageoptions_background_color(n, this.__wbg_ptr);
|
|
var e = m().getInt32(n + 4 * 0, !0), t = m().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = k(e, t).slice(), c.__wbindgen_export_3(e, t * 1, 1)), i;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string | null} [background_color]
|
|
*/
|
|
set background_color(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
var t = L(e) ? 0 : W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.renderpageimageoptions_set_background_color(this.__wbg_ptr, t, n);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get page_off() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.renderpageimageoptions_page_off(this.__wbg_ptr) >>> 0;
|
|
}
|
|
/**
|
|
* @param {number} page_off
|
|
*/
|
|
set page_off(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), p(e), c.renderpageimageoptions_set_page_off(this.__wbg_ptr, e);
|
|
}
|
|
/**
|
|
* @returns {string | undefined}
|
|
*/
|
|
get cache_key() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const n = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.renderpageimageoptions_cache_key(n, this.__wbg_ptr);
|
|
var e = m().getInt32(n + 4 * 0, !0), t = m().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = k(e, t).slice(), c.__wbindgen_export_3(e, t * 1, 1)), i;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string | null} [cache_key]
|
|
*/
|
|
set cache_key(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
var t = L(e) ? 0 : W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.renderpageimageoptions_set_cache_key(this.__wbg_ptr, t, n);
|
|
}
|
|
/**
|
|
* @returns {number | undefined}
|
|
*/
|
|
get data_selection() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.renderpageimageoptions_data_selection(this.__wbg_ptr);
|
|
return e === 4294967297 ? void 0 : e;
|
|
}
|
|
/**
|
|
* @param {number | null} [data_selection]
|
|
*/
|
|
set data_selection(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), L(e) || p(e), c.renderpageimageoptions_set_data_selection(this.__wbg_ptr, L(e) ? 4294967297 : e >>> 0);
|
|
}
|
|
}
|
|
const yt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_rendersession_free(r >>> 0, 1));
|
|
class N {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(N.prototype);
|
|
return t.__wbg_ptr = e, yt.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, yt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_rendersession_free(e, 0);
|
|
}
|
|
/**
|
|
* @param {number} rect_lo_x
|
|
* @param {number} rect_lo_y
|
|
* @param {number} rect_hi_x
|
|
* @param {number} rect_hi_y
|
|
* @returns {string}
|
|
*/
|
|
render_in_window(e, t, n, i) {
|
|
let s, o;
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const _ = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.rendersession_render_in_window(_, this.__wbg_ptr, e, t, n, i);
|
|
var a = m().getInt32(_ + 4 * 0, !0), d = m().getInt32(_ + 4 * 1, !0);
|
|
return s = a, o = d, k(a, d);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export_3(s, o, 1);
|
|
}
|
|
}
|
|
/**
|
|
* @returns {number | undefined}
|
|
*/
|
|
get pixel_per_pt() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.renderpageimageoptions_pixel_per_pt(this.__wbg_ptr);
|
|
return e === 4294967297 ? void 0 : e;
|
|
}
|
|
/**
|
|
* @param {number | null} [pixel_per_pt]
|
|
*/
|
|
set pixel_per_pt(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), L(e) || p(e), c.renderpageimageoptions_set_pixel_per_pt(this.__wbg_ptr, L(e) ? 4294967297 : Math.fround(e));
|
|
}
|
|
/**
|
|
* @returns {string | undefined}
|
|
*/
|
|
get background_color() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const n = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.rendersession_background_color(n, this.__wbg_ptr);
|
|
var e = m().getInt32(n + 4 * 0, !0), t = m().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = k(e, t).slice(), c.__wbindgen_export_3(e, t * 1, 1)), i;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string | null} [background_color]
|
|
*/
|
|
set background_color(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
var t = L(e) ? 0 : W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.rendersession_set_background_color(this.__wbg_ptr, t, n);
|
|
}
|
|
/**
|
|
* @returns {PagesInfo}
|
|
*/
|
|
get pages_info() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.rendersession_pages_info(this.__wbg_ptr);
|
|
return ke.__wrap(e);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get doc_width() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.rendersession_doc_width(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* @returns {number}
|
|
*/
|
|
get doc_height() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
return p(this.__wbg_ptr), c.rendersession_doc_height(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* @param {Uint32Array} path
|
|
* @returns {string | undefined}
|
|
*/
|
|
source_span(e) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const o = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr);
|
|
const a = mn(e, c.__wbindgen_export_1), d = O;
|
|
c.rendersession_source_span(o, this.__wbg_ptr, a, d);
|
|
var t = m().getInt32(o + 4 * 0, !0), n = m().getInt32(o + 4 * 1, !0), i = m().getInt32(o + 4 * 2, !0), s = m().getInt32(o + 4 * 3, !0);
|
|
if (s)
|
|
throw M(i);
|
|
let _;
|
|
return t !== 0 && (_ = k(t, n).slice(), c.__wbindgen_export_3(t, n * 1, 1)), _;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const vt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_rendersessionoptions_free(r >>> 0, 1));
|
|
class kn {
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, vt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_rendersessionoptions_free(e, 0);
|
|
}
|
|
constructor() {
|
|
const e = c.rendersessionoptions_new();
|
|
return this.__wbg_ptr = e >>> 0, vt.register(this, this.__wbg_ptr, this), this;
|
|
}
|
|
/**
|
|
* @returns {number | undefined}
|
|
*/
|
|
get pixel_per_pt() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.renderpageimageoptions_pixel_per_pt(this.__wbg_ptr);
|
|
return e === 4294967297 ? void 0 : e;
|
|
}
|
|
/**
|
|
* @param {number | null} [pixel_per_pt]
|
|
*/
|
|
set pixel_per_pt(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr), L(e) || p(e), c.renderpageimageoptions_set_pixel_per_pt(this.__wbg_ptr, L(e) ? 4294967297 : Math.fround(e));
|
|
}
|
|
/**
|
|
* @returns {string | undefined}
|
|
*/
|
|
get background_color() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const n = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.rendersessionoptions_background_color(n, this.__wbg_ptr);
|
|
var e = m().getInt32(n + 4 * 0, !0), t = m().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = k(e, t).slice(), c.__wbindgen_export_3(e, t * 1, 1)), i;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string | null} [background_color]
|
|
*/
|
|
set background_color(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
var t = L(e) ? 0 : W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.rendersessionoptions_set_background_color(this.__wbg_ptr, t, n);
|
|
}
|
|
/**
|
|
* @returns {string | undefined}
|
|
*/
|
|
get format() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const n = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.rendersessionoptions_format(n, this.__wbg_ptr);
|
|
var e = m().getInt32(n + 4 * 0, !0), t = m().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = k(e, t).slice(), c.__wbindgen_export_3(e, t * 1, 1)), i;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string | null} [format]
|
|
*/
|
|
set format(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
var t = L(e) ? 0 : W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), n = O;
|
|
c.rendersessionoptions_set_format(this.__wbg_ptr, t, n);
|
|
}
|
|
}
|
|
const Be = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_typstrenderer_free(r >>> 0, 1));
|
|
class Re {
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(Re.prototype);
|
|
return t.__wbg_ptr = e, Be.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, Be.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_typstrenderer_free(e, 0);
|
|
}
|
|
/**
|
|
* @param {any} _w
|
|
* @returns {Promise<TypstWorker>}
|
|
*/
|
|
create_worker(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = c.typstrenderer_create_worker(this.__wbg_ptr, y(e));
|
|
return M(t);
|
|
}
|
|
/**
|
|
* @returns {WorkerBridge}
|
|
*/
|
|
create_worker_bridge() {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const i = this.__destroy_into_raw(), s = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(i), c.typstrenderer_create_worker_bridge(s, i);
|
|
var e = m().getInt32(s + 4 * 0, !0), t = m().getInt32(s + 4 * 1, !0), n = m().getInt32(s + 4 * 2, !0);
|
|
if (n)
|
|
throw M(t);
|
|
return Ee.__wrap(e);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {any} _v
|
|
*/
|
|
load_glyph_pack(e) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const i = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr), c.typstrenderer_load_glyph_pack(i, this.__wbg_ptr, y(e));
|
|
var t = m().getInt32(i + 4 * 0, !0), n = m().getInt32(i + 4 * 1, !0);
|
|
if (n)
|
|
throw M(t);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
* @param {number} rect_lo_x
|
|
* @param {number} rect_lo_y
|
|
* @param {number} rect_hi_x
|
|
* @param {number} rect_hi_y
|
|
* @returns {string}
|
|
*/
|
|
render_svg_diff(e, t, n, i, s) {
|
|
let o, a;
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const f = c.__wbindgen_add_to_stack_pointer(-16);
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
c.typstrenderer_render_svg_diff(f, this.__wbg_ptr, e.__wbg_ptr, t, n, i, s);
|
|
var d = m().getInt32(f + 4 * 0, !0), _ = m().getInt32(f + 4 * 1, !0);
|
|
return o = d, a = _, k(d, _);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export_3(o, a, 1);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
* @param {number | null} [parts]
|
|
* @returns {string}
|
|
*/
|
|
svg_data(e, t) {
|
|
let n, i;
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const w = c.__wbindgen_add_to_stack_pointer(-16);
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
L(t) || p(t), c.typstrenderer_svg_data(w, this.__wbg_ptr, e.__wbg_ptr, L(t) ? 4294967297 : t >>> 0);
|
|
var s = m().getInt32(w + 4 * 0, !0), o = m().getInt32(w + 4 * 1, !0), a = m().getInt32(w + 4 * 2, !0), d = m().getInt32(w + 4 * 3, !0), _ = s, f = o;
|
|
if (d)
|
|
throw _ = 0, f = 0, M(a);
|
|
return n = _, i = f, k(_, f);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16), c.__wbindgen_export_3(n, i, 1);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
* @returns {Array<any> | undefined}
|
|
*/
|
|
get_customs(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
const t = c.typstrenderer_get_customs(this.__wbg_ptr, e.__wbg_ptr);
|
|
return M(t);
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
* @param {HTMLElement} root
|
|
* @returns {boolean}
|
|
*/
|
|
render_svg(e, t) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const o = c.__wbindgen_add_to_stack_pointer(-16);
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
c.typstrenderer_render_svg(o, this.__wbg_ptr, e.__wbg_ptr, y(t));
|
|
var n = m().getInt32(o + 4 * 0, !0), i = m().getInt32(o + 4 * 1, !0), s = m().getInt32(o + 4 * 2, !0);
|
|
if (s)
|
|
throw M(i);
|
|
return n !== 0;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} ses
|
|
* @param {HTMLElement} elem
|
|
* @returns {Promise<IncrDomDocClient>}
|
|
*/
|
|
mount_dom(e, t) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
const n = c.typstrenderer_mount_dom(this.__wbg_ptr, e.__wbg_ptr, y(t));
|
|
return M(n);
|
|
}
|
|
/**
|
|
* @param {RenderSession} ses
|
|
* @param {any} canvas
|
|
* @param {RenderPageImageOptions | null} [options]
|
|
* @returns {Promise<any>}
|
|
*/
|
|
render_page_to_canvas(e, t, n) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
let i = 0;
|
|
if (!L(n)) {
|
|
if (H(n, le), n.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
i = n.__destroy_into_raw();
|
|
}
|
|
const s = c.typstrenderer_render_page_to_canvas(this.__wbg_ptr, e.__wbg_ptr, y(t), i);
|
|
return M(s);
|
|
}
|
|
constructor() {
|
|
const e = c.typstrenderer_new();
|
|
return this.__wbg_ptr = e >>> 0, Be.register(this, this.__wbg_ptr, this), this;
|
|
}
|
|
/**
|
|
* @param {CreateSessionOptions | null} [options]
|
|
* @returns {RenderSession}
|
|
*/
|
|
create_session(e) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const s = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr);
|
|
let o = 0;
|
|
if (!L(e)) {
|
|
if (H(e, Qt), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
o = e.__destroy_into_raw();
|
|
}
|
|
c.typstrenderer_create_session(s, this.__wbg_ptr, o);
|
|
var t = m().getInt32(s + 4 * 0, !0), n = m().getInt32(s + 4 * 1, !0), i = m().getInt32(s + 4 * 2, !0);
|
|
if (i)
|
|
throw M(n);
|
|
return N.__wrap(t);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
*/
|
|
reset(e) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const i = c.__wbindgen_add_to_stack_pointer(-16);
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
c.typstrenderer_reset(i, this.__wbg_ptr, e.__wbg_ptr);
|
|
var t = m().getInt32(i + 4 * 0, !0), n = m().getInt32(i + 4 * 1, !0);
|
|
if (n)
|
|
throw M(t);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {RenderSession} session
|
|
* @param {string} action
|
|
* @param {Uint8Array} data
|
|
*/
|
|
manipulate_data(e, t, n) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const o = c.__wbindgen_add_to_stack_pointer(-16);
|
|
if (p(this.__wbg_ptr), H(e, N), e.__wbg_ptr === 0)
|
|
throw new Error("Attempt to use a moved value");
|
|
const a = W(t, c.__wbindgen_export_1, c.__wbindgen_export_2), d = O, _ = Se(n, c.__wbindgen_export_1), f = O;
|
|
c.typstrenderer_manipulate_data(o, this.__wbg_ptr, e.__wbg_ptr, a, d, _, f);
|
|
var i = m().getInt32(o + 4 * 0, !0), s = m().getInt32(o + 4 * 1, !0);
|
|
if (s)
|
|
throw M(i);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {Uint8Array} artifact_content
|
|
* @param {string} decoder
|
|
* @returns {RenderSession}
|
|
*/
|
|
session_from_artifact(e, t) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const o = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr);
|
|
const a = Se(e, c.__wbindgen_export_1), d = O, _ = W(t, c.__wbindgen_export_1, c.__wbindgen_export_2), f = O;
|
|
c.typstrenderer_session_from_artifact(o, this.__wbg_ptr, a, d, _, f);
|
|
var n = m().getInt32(o + 4 * 0, !0), i = m().getInt32(o + 4 * 1, !0), s = m().getInt32(o + 4 * 2, !0);
|
|
if (s)
|
|
throw M(i);
|
|
return N.__wrap(n);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const St = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_typstrendererbuilder_free(r >>> 0, 1));
|
|
class Rn {
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, St.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_typstrendererbuilder_free(e, 0);
|
|
}
|
|
constructor() {
|
|
try {
|
|
const i = c.__wbindgen_add_to_stack_pointer(-16);
|
|
c.typstrendererbuilder_new(i);
|
|
var e = m().getInt32(i + 4 * 0, !0), t = m().getInt32(i + 4 * 1, !0), n = m().getInt32(i + 4 * 2, !0);
|
|
if (n)
|
|
throw M(t);
|
|
return this.__wbg_ptr = e >>> 0, St.register(this, this.__wbg_ptr, this), this;
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @returns {Promise<TypstRenderer>}
|
|
*/
|
|
build() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const e = this.__destroy_into_raw();
|
|
p(e);
|
|
const t = c.typstrendererbuilder_build(e);
|
|
return M(t);
|
|
}
|
|
/**
|
|
* @param {any} _pack
|
|
* @returns {Promise<void>}
|
|
*/
|
|
add_glyph_pack(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = c.typstrendererbuilder_add_glyph_pack(this.__wbg_ptr, y(e));
|
|
return M(t);
|
|
}
|
|
/**
|
|
* @param {Uint8Array} _font_buffer
|
|
* @returns {Promise<void>}
|
|
*/
|
|
add_raw_font(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = c.typstrendererbuilder_add_raw_font(this.__wbg_ptr, y(e));
|
|
return M(t);
|
|
}
|
|
/**
|
|
* @param {Array<any>} _fonts
|
|
* @returns {Promise<void>}
|
|
*/
|
|
add_web_fonts(e) {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const t = c.typstrendererbuilder_add_web_fonts(this.__wbg_ptr, y(e));
|
|
return M(t);
|
|
}
|
|
}
|
|
const En = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_typstworker_free(r >>> 0, 1));
|
|
class Pn {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, En.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_typstworker_free(e, 0);
|
|
}
|
|
/**
|
|
* @param {string} _action
|
|
* @param {Uint8Array} _data
|
|
* @returns {Promise<any>}
|
|
*/
|
|
manipulate_data(e, t) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const o = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr);
|
|
const a = W(e, c.__wbindgen_export_1, c.__wbindgen_export_2), d = O;
|
|
c.typstworker_manipulate_data(o, this.__wbg_ptr, a, d, y(t));
|
|
var n = m().getInt32(o + 4 * 0, !0), i = m().getInt32(o + 4 * 1, !0), s = m().getInt32(o + 4 * 2, !0);
|
|
if (s)
|
|
throw M(i);
|
|
return M(n);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @returns {Promise<any>}
|
|
*/
|
|
get_pages_info() {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
p(this.__wbg_ptr);
|
|
const e = c.typstworker_get_pages_info(this.__wbg_ptr);
|
|
return M(e);
|
|
}
|
|
/**
|
|
* @param {Uint8Array} _actions
|
|
* @param {HTMLCanvasElement[]} _canvas_list
|
|
* @param {RenderPageImageOptions[]} _data
|
|
* @returns {Promise<any>}
|
|
*/
|
|
render_canvas(e, t, n) {
|
|
try {
|
|
if (this.__wbg_ptr == 0) throw new Error("Attempt to use a moved value");
|
|
const a = c.__wbindgen_add_to_stack_pointer(-16);
|
|
p(this.__wbg_ptr);
|
|
const d = Se(e, c.__wbindgen_export_1), _ = O, f = gt(t, c.__wbindgen_export_1), w = O, P = gt(n, c.__wbindgen_export_1), C = O;
|
|
c.typstworker_render_canvas(a, this.__wbg_ptr, d, _, f, w, P, C);
|
|
var i = m().getInt32(a + 4 * 0, !0), s = m().getInt32(a + 4 * 1, !0), o = m().getInt32(a + 4 * 2, !0);
|
|
if (o)
|
|
throw M(s);
|
|
return M(i);
|
|
} finally {
|
|
c.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const Ct = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => c.__wbg_workerbridge_free(r >>> 0, 1));
|
|
class Ee {
|
|
constructor() {
|
|
throw new Error("cannot invoke `new` directly");
|
|
}
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(Ee.prototype);
|
|
return t.__wbg_ptr = e, Ct.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, Ct.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
c.__wbg_workerbridge_free(e, 0);
|
|
}
|
|
}
|
|
async function In(r, e) {
|
|
if (typeof Response == "function" && r instanceof Response) {
|
|
if (typeof WebAssembly.instantiateStreaming == "function")
|
|
try {
|
|
return await WebAssembly.instantiateStreaming(r, e);
|
|
} catch (n) {
|
|
if (r.headers.get("Content-Type") != "application/wasm")
|
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", n);
|
|
else
|
|
throw n;
|
|
}
|
|
const t = await r.arrayBuffer();
|
|
return await WebAssembly.instantiate(t, e);
|
|
} else {
|
|
const t = await WebAssembly.instantiate(r, e);
|
|
return t instanceof WebAssembly.Instance ? { instance: t, module: r } : t;
|
|
}
|
|
}
|
|
function Xt() {
|
|
const r = {};
|
|
return r.wbg = {}, r.wbg.__wbg_appendChild_8204974b7328bf98 = function() {
|
|
return x(function(e, t) {
|
|
const n = u(e).appendChild(u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_buffer_609cc3eee51ed158 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).buffer;
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_672a4d21634d4a24 = function() {
|
|
return x(function(e, t) {
|
|
const n = u(e).call(u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_7cccdd69e0791ae2 = function() {
|
|
return x(function(e, t, n) {
|
|
const i = u(e).call(u(t), u(n));
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_833bed5770ea2041 = function() {
|
|
return x(function(e, t, n, i) {
|
|
const s = u(e).call(u(t), u(n), u(i));
|
|
return y(s);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_b8adc8b1d0a0d8eb = function() {
|
|
return x(function(e, t, n, i, s) {
|
|
const o = u(e).call(u(t), u(n), u(i), u(s));
|
|
return y(o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_clearRect_8e4ba7ea0e06711a = function() {
|
|
return h(function(e, t, n, i, s) {
|
|
u(e).clearRect(t, n, i, s);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_clientWidth_ce67a04dc15fce39 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).clientWidth;
|
|
return p(t), t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_clip_8e8cfb00a055cd03 = function() {
|
|
return h(function(e, t) {
|
|
u(e).clip(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_clip_f584e320f8a2b022 = function() {
|
|
return h(function(e, t) {
|
|
u(e).clip(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_cloneNode_e35b333b87d51340 = function() {
|
|
return x(function(e) {
|
|
const t = u(e).cloneNode();
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_content_537e4105afcd9cee = function() {
|
|
return h(function(e) {
|
|
const t = u(e).content;
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_createElement_8c9931a732ee2fea = function() {
|
|
return x(function(e, t, n) {
|
|
const i = u(e).createElement(k(t, n));
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_createImageBitmap_705010fb21a22922 = function() {
|
|
return x(function(e, t) {
|
|
const n = u(e).createImageBitmap(u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_createImageBitmap_b814e27800576bdb = function() {
|
|
return x(function(e, t) {
|
|
const n = u(e).createImageBitmap(u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_createObjectURL_6e98d2f9c7bd9764 = function() {
|
|
return x(function(e, t) {
|
|
const n = URL.createObjectURL(u(t)), i = W(n, c.__wbindgen_export_1, c.__wbindgen_export_2), s = O;
|
|
m().setInt32(e + 4 * 1, s, !0), m().setInt32(e + 4 * 0, i, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_document_d249400bd7bd996d = function() {
|
|
return h(function(e) {
|
|
const t = u(e).document;
|
|
return L(t) ? 0 : y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_0915f348c5d54848 = function() {
|
|
return x(function(e, t, n, i) {
|
|
u(e).drawImage(u(t), n, i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_16485aae76d89dbf = function() {
|
|
return x(function(e, t, n, i, s, o) {
|
|
u(e).drawImage(u(t), n, i, s, o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_468585e3ecfa189a = function() {
|
|
return x(function(e, t, n, i, s, o) {
|
|
u(e).drawImage(u(t), n, i, s, o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_472a4d5b6df3739a = function() {
|
|
return x(function(e, t, n, i) {
|
|
u(e).drawImage(u(t), n, i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_473e6602e24e18aa = function() {
|
|
return x(function(e, t, n, i) {
|
|
u(e).drawImage(u(t), n, i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_86fd8465c00c7bc6 = function() {
|
|
return x(function(e, t, n, i, s, o) {
|
|
u(e).drawImage(u(t), n, i, s, o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_drawImage_ff273710b96c85cc = function() {
|
|
return x(function(e, t, n, i, s, o) {
|
|
u(e).drawImage(u(t), n, i, s, o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_error_7534b8e9a36f1ab4 = function() {
|
|
return h(function(e, t) {
|
|
let n, i;
|
|
try {
|
|
n = e, i = t, console.error(k(e, t));
|
|
} finally {
|
|
c.__wbindgen_export_3(n, i, 1);
|
|
}
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fillRect_b1529535ac758d4c = function() {
|
|
return h(function(e, t, n, i, s) {
|
|
u(e).fillRect(t, n, i, s);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fillRect_c38d5d56492a2368 = function() {
|
|
return h(function(e, t, n, i, s) {
|
|
u(e).fillRect(t, n, i, s);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fill_51814702df845abd = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).fill(u(t), ft[n]);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fill_5d26765e6d1d8f6b = function() {
|
|
return h(function(e, t) {
|
|
u(e).fill(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fill_64902335a40baa8d = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).fill(u(t), ft[n]);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_fill_cbb22e6ac4da5b1b = function() {
|
|
return h(function(e, t) {
|
|
u(e).fill(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_firstElementChild_21331181ca115bcc = function() {
|
|
return h(function(e) {
|
|
const t = u(e).firstElementChild;
|
|
return L(t) ? 0 : y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_firstElementChild_d75d385f5abd1414 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).firstElementChild;
|
|
return L(t) ? 0 : y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_getAttribute_ea5166be2deba45e = function() {
|
|
return h(function(e, t, n, i) {
|
|
const s = u(t).getAttribute(k(n, i));
|
|
var o = L(s) ? 0 : W(s, c.__wbindgen_export_1, c.__wbindgen_export_2), a = O;
|
|
m().setInt32(e + 4 * 1, a, !0), m().setInt32(e + 4 * 0, o, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_getContext_e9cf379449413580 = function() {
|
|
return x(function(e, t, n) {
|
|
const i = u(e).getContext(k(t, n));
|
|
return L(i) ? 0 : y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_getContext_f65a0debd1e8f8e8 = function() {
|
|
return x(function(e, t, n) {
|
|
const i = u(e).getContext(k(t, n));
|
|
return L(i) ? 0 : y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_get_67b2ba62fc30de12 = function() {
|
|
return x(function(e, t) {
|
|
const n = Reflect.get(u(e), u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_globalCompositeOperation_154b0f30008caa5e = function() {
|
|
return x(function(e, t) {
|
|
const n = u(t).globalCompositeOperation, i = W(n, c.__wbindgen_export_1, c.__wbindgen_export_2), s = O;
|
|
m().setInt32(e + 4 * 1, s, !0), m().setInt32(e + 4 * 0, i, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_globalCompositeOperation_1f405e2ef7c5118b = function() {
|
|
return x(function(e, t) {
|
|
const n = u(t).globalCompositeOperation, i = W(n, c.__wbindgen_export_1, c.__wbindgen_export_2), s = O;
|
|
m().setInt32(e + 4 * 1, s, !0), m().setInt32(e + 4 * 0, i, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_height_d3f39e12f0f62121 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).height;
|
|
return p(t), t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_incrdomdocclient_new = function() {
|
|
return h(function(e) {
|
|
const t = xe.__wrap(e);
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_CanvasRenderingContext2d_df82a4d3437bf1cc = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof CanvasRenderingContext2D;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_Element_0af65443936d5154 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof Element;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_HtmlCanvasElement_2ea67072a7624ac5 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof HTMLCanvasElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_HtmlDivElement_dbc6eb62eb772174 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof HTMLDivElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_HtmlElement_51378c201250b16c = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof HTMLElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_HtmlTemplateElement_7929a67c77198607 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof HTMLTemplateElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_ImageBitmap_d093d508663e313d = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof ImageBitmap;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_OffscreenCanvasRenderingContext2d_a070fdde7ba760a3 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof OffscreenCanvasRenderingContext2D;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_OffscreenCanvas_d55760945f91bf51 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof OffscreenCanvas;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_Promise_935168b8f4b49db3 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof Promise;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_SvgGraphicsElement_8b2cbd8116680c53 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof SVGGraphicsElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_SvgsvgElement_6a0d878e0d0f979c = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof SVGSVGElement;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_Window_def73ea0955fc569 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof Window;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_instanceof_WorkerGlobalScope_dbdbdea7e3b56493 = function() {
|
|
return h(function(e) {
|
|
let t;
|
|
try {
|
|
t = u(e) instanceof WorkerGlobalScope;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
const n = t;
|
|
return j(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_lastElementChild_1269b660ec3e6985 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).lastElementChild;
|
|
return L(t) ? 0 : y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_length_a446193dc22c12f8 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).length;
|
|
return p(t), t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_log_1ae1e9f741096e91 = function() {
|
|
return h(function(e, t) {
|
|
console.log(u(e), u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_log_c222819a41e063d3 = function() {
|
|
return h(function(e) {
|
|
console.log(u(e));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_measureText_f0f078704231c37f = function() {
|
|
return x(function(e, t, n) {
|
|
const i = u(e).measureText(k(t, n));
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_23a2665fac83c611 = function() {
|
|
return h(function(e, t) {
|
|
try {
|
|
var n = { a: e, b: t }, i = (o, a) => {
|
|
const d = n.a;
|
|
n.a = 0;
|
|
try {
|
|
return xn(d, n.b, o, a);
|
|
} finally {
|
|
n.a = d;
|
|
}
|
|
};
|
|
const s = new Promise(i);
|
|
return y(s);
|
|
} finally {
|
|
n.a = n.b = 0;
|
|
}
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_2ef971087cb43792 = function() {
|
|
return x(function(e, t) {
|
|
const n = new OffscreenCanvas(e >>> 0, t >>> 0);
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
return h(function() {
|
|
const e = new Object();
|
|
return y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_6377da097a44ce6e = function() {
|
|
return x(function() {
|
|
const e = new Image();
|
|
return y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
return h(function() {
|
|
const e = new Array();
|
|
return y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
return h(function() {
|
|
const e = new Error();
|
|
return y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_a12002a7f91c75be = function() {
|
|
return h(function(e) {
|
|
const t = new Uint8Array(u(e));
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_new_c68d7209be747379 = function() {
|
|
return h(function(e, t) {
|
|
const n = new Error(k(e, t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_newnoargs_105ed471475aaf50 = function() {
|
|
return h(function(e, t) {
|
|
const n = createCspSafeFunction(k(e, t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function() {
|
|
return h(function(e, t, n) {
|
|
const i = new Uint8Array(u(e), t >>> 0, n >>> 0);
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_newwithlength_a381634e90c276d4 = function() {
|
|
return h(function(e) {
|
|
const t = new Uint8Array(e >>> 0);
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_newwithpathstring_e9586ab3affcd4fd = function() {
|
|
return x(function(e, t) {
|
|
const n = new Path2D(k(e, t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_newwithu8arraysequenceandoptions_068570c487f69127 = function() {
|
|
return x(function(e, t) {
|
|
const n = new Blob(u(e), u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_nextElementSibling_8472709bec4de113 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).nextElementSibling;
|
|
return L(t) ? 0 : y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_push_737cfc8c1432c2c6 = function() {
|
|
return h(function(e, t) {
|
|
const n = u(e).push(u(t));
|
|
return p(n), n;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_putImageData_4c5aa10f3b3e4924 = function() {
|
|
return x(function(e, t, n, i) {
|
|
u(e).putImageData(u(t), n, i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_putImageData_6d5d5ef6ee83898b = function() {
|
|
return x(function(e, t, n, i) {
|
|
u(e).putImageData(u(t), n, i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function() {
|
|
return h(function(e) {
|
|
queueMicrotask(u(e));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_queueMicrotask_d3219def82552485 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).queueMicrotask;
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_removeProperty_0e85471f4dfc00ae = function() {
|
|
return x(function(e, t, n, i) {
|
|
const s = u(t).removeProperty(k(n, i)), o = W(s, c.__wbindgen_export_1, c.__wbindgen_export_2), a = O;
|
|
m().setInt32(e + 4 * 1, a, !0), m().setInt32(e + 4 * 0, o, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_remove_e2d2659f3128c045 = function() {
|
|
return h(function(e) {
|
|
u(e).remove();
|
|
}, arguments);
|
|
}, r.wbg.__wbg_renderpageimageoptions_unwrap = function() {
|
|
return h(function(e) {
|
|
const t = le.__unwrap(M(e));
|
|
return p(t), t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_replaceWith_9ce9927e3141d0f6 = function() {
|
|
return x(function(e, t) {
|
|
u(e).replaceWith(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_resolve_4851785c9c5f573d = function() {
|
|
return h(function(e) {
|
|
const t = Promise.resolve(u(e));
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_restore_1ef50af0835a4649 = function() {
|
|
return h(function(e) {
|
|
u(e).restore();
|
|
}, arguments);
|
|
}, r.wbg.__wbg_restore_cc5ae2746f7b5043 = function() {
|
|
return h(function(e) {
|
|
u(e).restore();
|
|
}, arguments);
|
|
}, r.wbg.__wbg_revokeObjectURL_27267efebeb457c7 = function() {
|
|
return x(function(e, t) {
|
|
URL.revokeObjectURL(k(e, t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_save_5f563096e64939da = function() {
|
|
return h(function(e) {
|
|
u(e).save();
|
|
}, arguments);
|
|
}, r.wbg.__wbg_save_c675a7a4bbd44e4a = function() {
|
|
return h(function(e) {
|
|
u(e).save();
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setAttribute_2704501201f15687 = function() {
|
|
return x(function(e, t, n, i, s) {
|
|
u(e).setAttribute(k(t, n), k(i, s));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setLineDash_0e3f3e194352a774 = function() {
|
|
return x(function(e, t) {
|
|
u(e).setLineDash(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setLineDash_325e094206df53e9 = function() {
|
|
return x(function(e, t) {
|
|
u(e).setLineDash(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setProperty_f2cf326652b9a713 = function() {
|
|
return x(function(e, t, n, i, s) {
|
|
u(e).setProperty(k(t, n), k(i, s));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setTransform_8c4d954cafb34b75 = function() {
|
|
return x(function(e, t, n, i, s, o, a) {
|
|
u(e).setTransform(t, n, i, s, o, a);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setTransform_da2f0baec3f09522 = function() {
|
|
return x(function(e, t, n, i, s, o, a) {
|
|
u(e).setTransform(t, n, i, s, o, a);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_set_37837023f3d740e8 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e)[t >>> 0] = M(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_set_65595bdd868b3009 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).set(u(t), n >>> 0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_set_bb8cecf6a62b9f46 = function() {
|
|
return x(function(e, t, n) {
|
|
const i = Reflect.set(u(e), u(t), u(n));
|
|
return j(i), i;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setfillStyle_2205fca942c641ba = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).fillStyle = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setfillStyle_cb059a69ce15cc28 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).fillStyle = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setfont_4c3584ef2f5c9f7e = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).font = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setglobalCompositeOperation_9a7a92bac2fb7ffd = function() {
|
|
return x(function(e, t, n) {
|
|
u(e).globalCompositeOperation = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setglobalCompositeOperation_b000e874f8f4a9d3 = function() {
|
|
return x(function(e, t, n) {
|
|
u(e).globalCompositeOperation = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setheight_da683a33fa99843c = function() {
|
|
return h(function(e, t) {
|
|
u(e).height = t >>> 0;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setinnerHTML_31bde41f835786f7 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).innerHTML = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineCap_3a3987ad3f03b31d = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).lineCap = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineCap_52b6d742c95a5630 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).lineCap = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineDashOffset_030d80d07cd52ee4 = function() {
|
|
return h(function(e, t) {
|
|
u(e).lineDashOffset = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineDashOffset_59f274962f6a0553 = function() {
|
|
return h(function(e, t) {
|
|
u(e).lineDashOffset = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineJoin_79ca64e7e9efaff7 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).lineJoin = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineJoin_7e005d90ef83d627 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).lineJoin = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineWidth_3c8b7156949a9f4b = function() {
|
|
return h(function(e, t) {
|
|
u(e).lineWidth = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setlineWidth_ec730c524f09baa9 = function() {
|
|
return h(function(e, t) {
|
|
u(e).lineWidth = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setmiterLimit_26162c359bb28eb2 = function() {
|
|
return h(function(e, t) {
|
|
u(e).miterLimit = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setmiterLimit_9ffca64ec692501d = function() {
|
|
return h(function(e, t) {
|
|
u(e).miterLimit = t;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setonerror_e94ca1221abc457f = function() {
|
|
return h(function(e, t) {
|
|
u(e).onerror = u(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setonload_264a0d330b7166fb = function() {
|
|
return h(function(e, t) {
|
|
u(e).onload = u(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setsrc_c239193cc7ab0470 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).src = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setstrokeStyle_070920f27992b9a6 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).strokeStyle = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setstrokeStyle_415833f3f0eb5076 = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).strokeStyle = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_settype_39ed370d3edd403c = function() {
|
|
return h(function(e, t, n) {
|
|
u(e).type = k(t, n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_setwidth_c5fed9f5e7f0b406 = function() {
|
|
return h(function(e, t) {
|
|
u(e).width = t >>> 0;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_stack_0ed75d68575b0f3c = function() {
|
|
return h(function(e, t) {
|
|
const n = u(t).stack, i = W(n, c.__wbindgen_export_1, c.__wbindgen_export_2), s = O;
|
|
m().setInt32(e + 4 * 1, s, !0), m().setInt32(e + 4 * 0, i, !0);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
return h(function() {
|
|
const e = typeof global > "u" ? null : global;
|
|
return L(e) ? 0 : y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
return h(function() {
|
|
const e = typeof globalThis > "u" ? null : globalThis;
|
|
return L(e) ? 0 : y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
return h(function() {
|
|
const e = typeof self > "u" ? null : self;
|
|
return L(e) ? 0 : y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
return h(function() {
|
|
const e = typeof window > "u" ? null : window;
|
|
return L(e) ? 0 : y(e);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_stringify_f7ed6987935b4a24 = function() {
|
|
return x(function(e) {
|
|
const t = JSON.stringify(u(e));
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_stroke_1b0348380fb5a54b = function() {
|
|
return h(function(e, t) {
|
|
u(e).stroke(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_stroke_e9b15e77122a9be9 = function() {
|
|
return h(function(e, t) {
|
|
u(e).stroke(u(t));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_style_fb30c14e5815805c = function() {
|
|
return h(function(e) {
|
|
const t = u(e).style;
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_then_44b73946d2fb3e7d = function() {
|
|
return h(function(e, t) {
|
|
const n = u(e).then(u(t));
|
|
return y(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_then_48b406749878a531 = function() {
|
|
return h(function(e, t, n) {
|
|
const i = u(e).then(u(t), u(n));
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_transferToImageBitmap_4b1cc41c0f7e5de5 = function() {
|
|
return x(function(e) {
|
|
const t = u(e).transferToImageBitmap();
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_typstrenderer_new = function() {
|
|
return h(function(e) {
|
|
const t = Re.__wrap(e);
|
|
return y(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_warn_4ca3906c248c47c4 = function() {
|
|
return h(function(e) {
|
|
console.warn(u(e));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_width_2fafd30484634e26 = function() {
|
|
return h(function(e) {
|
|
return u(e).width;
|
|
}, arguments);
|
|
}, r.wbg.__wbg_width_4f334fc47ef03de1 = function() {
|
|
return h(function(e) {
|
|
const t = u(e).width;
|
|
return p(t), t;
|
|
}, arguments);
|
|
}, r.wbg.__wbindgen_cb_drop = function(e) {
|
|
const t = M(e).original;
|
|
if (t.cnt-- == 1)
|
|
return t.a = 0, !0;
|
|
const n = !1;
|
|
return j(n), n;
|
|
}, r.wbg.__wbindgen_closure_wrapper1625 = function() {
|
|
return h(function(e, t, n) {
|
|
const i = lt(e, t, 134, vn);
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbindgen_closure_wrapper1626 = function() {
|
|
return h(function(e, t, n) {
|
|
const i = lt(e, t, 134, Sn);
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbindgen_closure_wrapper2253 = function() {
|
|
return h(function(e, t, n) {
|
|
const i = pn(e, t, 134, Cn);
|
|
return y(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbindgen_debug_string = function(e, t) {
|
|
const n = Je(u(t)), i = W(n, c.__wbindgen_export_1, c.__wbindgen_export_2), s = O;
|
|
m().setInt32(e + 4 * 1, s, !0), m().setInt32(e + 4 * 0, i, !0);
|
|
}, r.wbg.__wbindgen_is_function = function(e) {
|
|
const t = typeof u(e) == "function";
|
|
return j(t), t;
|
|
}, r.wbg.__wbindgen_is_undefined = function(e) {
|
|
const t = u(e) === void 0;
|
|
return j(t), t;
|
|
}, r.wbg.__wbindgen_jsval_eq = function(e, t) {
|
|
const n = u(e) === u(t);
|
|
return j(n), n;
|
|
}, r.wbg.__wbindgen_memory = function() {
|
|
const e = c.memory;
|
|
return y(e);
|
|
}, r.wbg.__wbindgen_number_new = function(e) {
|
|
return y(e);
|
|
}, r.wbg.__wbindgen_object_clone_ref = function(e) {
|
|
const t = u(e);
|
|
return y(t);
|
|
}, r.wbg.__wbindgen_object_drop_ref = function(e) {
|
|
M(e);
|
|
}, r.wbg.__wbindgen_string_get = function(e, t) {
|
|
const n = u(t), i = typeof n == "string" ? n : void 0;
|
|
var s = L(i) ? 0 : W(i, c.__wbindgen_export_1, c.__wbindgen_export_2), o = O;
|
|
m().setInt32(e + 4 * 1, o, !0), m().setInt32(e + 4 * 0, s, !0);
|
|
}, r.wbg.__wbindgen_string_new = function(e, t) {
|
|
const n = k(e, t);
|
|
return y(n);
|
|
}, r.wbg.__wbindgen_throw = function(e, t) {
|
|
throw new Error(k(e, t));
|
|
}, r;
|
|
}
|
|
function Yt(r, e) {
|
|
return c = r.exports, Zt.__wbindgen_wasm_module = e, Q = null, se = null, ie = null, c;
|
|
}
|
|
function Mn(r) {
|
|
if (c !== void 0) return c;
|
|
typeof r < "u" && (Object.getPrototypeOf(r) === Object.prototype ? { module: r } = r : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
const e = Xt();
|
|
r instanceof WebAssembly.Module || (r = new WebAssembly.Module(r));
|
|
const t = new WebAssembly.Instance(r, e);
|
|
return Yt(t, r);
|
|
}
|
|
async function Zt(r) {
|
|
if (c !== void 0) return c;
|
|
typeof r < "u" && (Object.getPrototypeOf(r) === Object.prototype ? { module_or_path: r } = r : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof r > "u" && (r = er("typst_ts_renderer_bg.wasm", import.meta.url));
|
|
const e = Xt();
|
|
(typeof r == "string" || typeof Request == "function" && r instanceof Request || typeof URL == "function" && r instanceof URL) && (r = fetch(r));
|
|
const { instance: t, module: n } = await In(await r, e);
|
|
return Yt(t, n);
|
|
}
|
|
let er = async function(r, e) {
|
|
throw new Error("Cannot import wasm module without importer: " + r + " " + e);
|
|
};
|
|
function tr(r) {
|
|
er = r;
|
|
}
|
|
let Ln = async function(r, e) {
|
|
const t = (m) => import(m), { readFileSync: n } = await t("fs"), i = new URL(r, e);
|
|
return await n(i).buffer;
|
|
};
|
|
const An = typeof process < "u" && process.versions != null && process.versions.node != null;
|
|
An && tr(Ln);
|
|
const Ye = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
CreateSessionOptions: Qt,
|
|
IncrDomDocClient: xe,
|
|
PageInfo: ue,
|
|
PagesInfo: ke,
|
|
RenderPageImageOptions: le,
|
|
RenderSession: N,
|
|
RenderSessionOptions: kn,
|
|
TypstRenderer: Re,
|
|
TypstRendererBuilder: Rn,
|
|
TypstWorker: Pn,
|
|
WorkerBridge: Ee,
|
|
default: Zt,
|
|
initSync: Mn,
|
|
renderer_build_info: yn,
|
|
setImportWasmModule: tr
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
let g;
|
|
const K = new Array(128).fill(void 0);
|
|
K.push(void 0, null, !0, !1);
|
|
function b(r) {
|
|
return K[r];
|
|
}
|
|
let _e = K.length;
|
|
function v(r) {
|
|
_e === K.length && K.push(K.length + 1);
|
|
const e = _e;
|
|
return _e = K[e], K[e] = r, e;
|
|
}
|
|
function Z(r, e) {
|
|
try {
|
|
return r.apply(this, e);
|
|
} catch (t) {
|
|
g.__wbindgen_export_0(v(t));
|
|
}
|
|
}
|
|
const rr = typeof TextDecoder < "u" ? new TextDecoder("utf-8", { ignoreBOM: !0, fatal: !0 }) : { decode: () => {
|
|
throw Error("TextDecoder not available");
|
|
} };
|
|
typeof TextDecoder < "u" && rr.decode();
|
|
let oe = null;
|
|
function re() {
|
|
return (oe === null || oe.byteLength === 0) && (oe = new Uint8Array(g.memory.buffer)), oe;
|
|
}
|
|
function V(r, e) {
|
|
return r = r >>> 0, rr.decode(re().subarray(r, r + e));
|
|
}
|
|
function Tn(r) {
|
|
r < 132 || (K[r] = _e, _e = r);
|
|
}
|
|
function I(r) {
|
|
const e = b(r);
|
|
return Tn(r), e;
|
|
}
|
|
let T = 0;
|
|
const be = typeof TextEncoder < "u" ? new TextEncoder("utf-8") : { encode: () => {
|
|
throw Error("TextEncoder not available");
|
|
} }, On = typeof be.encodeInto == "function" ? function(r, e) {
|
|
return be.encodeInto(r, e);
|
|
} : function(r, e) {
|
|
const t = be.encode(r);
|
|
return e.set(t), {
|
|
read: r.length,
|
|
written: t.length
|
|
};
|
|
};
|
|
function B(r, e, t) {
|
|
if (t === void 0) {
|
|
const a = be.encode(r), d = e(a.length, 1) >>> 0;
|
|
return re().subarray(d, d + a.length).set(a), T = a.length, d;
|
|
}
|
|
let n = r.length, i = e(n, 1) >>> 0;
|
|
const s = re();
|
|
let o = 0;
|
|
for (; o < n; o++) {
|
|
const a = r.charCodeAt(o);
|
|
if (a > 127) break;
|
|
s[i + o] = a;
|
|
}
|
|
if (o !== n) {
|
|
o !== 0 && (r = r.slice(o)), i = t(i, n, n = o + r.length * 3, 1) >>> 0;
|
|
const a = re().subarray(i + o, i + n), d = On(r, a);
|
|
o += d.written, i = t(i, n, o, 1) >>> 0;
|
|
}
|
|
return T = o, i;
|
|
}
|
|
let X = null;
|
|
function S() {
|
|
return (X === null || X.buffer.detached === !0 || X.buffer.detached === void 0 && X.buffer !== g.memory.buffer) && (X = new DataView(g.memory.buffer)), X;
|
|
}
|
|
function z(r) {
|
|
return r == null;
|
|
}
|
|
const xt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => {
|
|
g.__wbindgen_export_4.get(r.dtor)(r.a, r.b);
|
|
});
|
|
function Fn(r, e, t, n) {
|
|
const i = { a: r, b: e, cnt: 1, dtor: t }, s = (...o) => {
|
|
i.cnt++;
|
|
const a = i.a;
|
|
i.a = 0;
|
|
try {
|
|
return n(a, i.b, ...o);
|
|
} finally {
|
|
--i.cnt === 0 ? (g.__wbindgen_export_4.get(i.dtor)(a, i.b), xt.unregister(i)) : i.a = a;
|
|
}
|
|
};
|
|
return s.original = i, xt.register(s, i, i), s;
|
|
}
|
|
function Ke(r) {
|
|
const e = typeof r;
|
|
if (e == "number" || e == "boolean" || r == null)
|
|
return `${r}`;
|
|
if (e == "string")
|
|
return `"${r}"`;
|
|
if (e == "symbol") {
|
|
const i = r.description;
|
|
return i == null ? "Symbol" : `Symbol(${i})`;
|
|
}
|
|
if (e == "function") {
|
|
const i = r.name;
|
|
return typeof i == "string" && i.length > 0 ? `Function(${i})` : "Function";
|
|
}
|
|
if (Array.isArray(r)) {
|
|
const i = r.length;
|
|
let s = "[";
|
|
i > 0 && (s += Ke(r[0]));
|
|
for (let o = 1; o < i; o++)
|
|
s += ", " + Ke(r[o]);
|
|
return s += "]", s;
|
|
}
|
|
const t = /\[object ([^\]]+)\]/.exec(toString.call(r));
|
|
let n;
|
|
if (t && t.length > 1)
|
|
n = t[1];
|
|
else
|
|
return toString.call(r);
|
|
if (n == "Object")
|
|
try {
|
|
return "Object(" + JSON.stringify(r) + ")";
|
|
} catch {
|
|
return "Object";
|
|
}
|
|
return r instanceof Error ? `${r.name}: ${r.message}
|
|
${r.stack}` : n;
|
|
}
|
|
function nr(r, e) {
|
|
const t = e(r.length * 1, 1) >>> 0;
|
|
return re().set(r, t / 1), T = r.length, t;
|
|
}
|
|
function Dn(r, e) {
|
|
return r = r >>> 0, re().subarray(r / 1, r / 1 + e);
|
|
}
|
|
function $n(r) {
|
|
const e = g.get_font_info(v(r));
|
|
return I(e);
|
|
}
|
|
function jn(r, e) {
|
|
r = r >>> 0;
|
|
const t = S(), n = [];
|
|
for (let i = r; i < r + 4 * e; i += 4)
|
|
n.push(I(t.getUint32(i, !0)));
|
|
return n;
|
|
}
|
|
function ge(r, e) {
|
|
const t = e(r.length * 4, 4) >>> 0, n = S();
|
|
for (let i = 0; i < r.length; i++)
|
|
n.setUint32(t + 4 * i, v(r[i]), !0);
|
|
return T = r.length, t;
|
|
}
|
|
function Bn(r, e) {
|
|
if (!(r instanceof e))
|
|
throw new Error(`expected instance of ${e.name}`);
|
|
}
|
|
function Wn(r, e, t) {
|
|
g.__wbindgen_export_5(r, e, v(t));
|
|
}
|
|
function zn(r, e, t, n) {
|
|
g.__wbindgen_export_6(r, e, v(t), v(n));
|
|
}
|
|
const kt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => g.__wbg_incrserver_free(r >>> 0, 1));
|
|
class de {
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(de.prototype);
|
|
return t.__wbg_ptr = e, kt.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, kt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
g.__wbg_incrserver_free(e, 0);
|
|
}
|
|
/**
|
|
* @param {boolean} attach
|
|
*/
|
|
set_attach_debug_info(e) {
|
|
g.incrserver_set_attach_debug_info(this.__wbg_ptr, e);
|
|
}
|
|
/**
|
|
* @returns {Uint8Array | undefined}
|
|
*/
|
|
current() {
|
|
try {
|
|
const n = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.incrserver_current(n, this.__wbg_ptr);
|
|
var e = S().getInt32(n + 4 * 0, !0), t = S().getInt32(n + 4 * 1, !0);
|
|
let i;
|
|
return e !== 0 && (i = Dn(e, t).slice(), g.__wbindgen_export_1(e, t * 1, 1)), i;
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
reset() {
|
|
g.incrserver_reset(this.__wbg_ptr);
|
|
}
|
|
}
|
|
const We = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => g.__wbg_proxycontext_free(r >>> 0, 1));
|
|
class Pe {
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(Pe.prototype);
|
|
return t.__wbg_ptr = e, We.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, We.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
g.__wbg_proxycontext_free(e, 0);
|
|
}
|
|
/**
|
|
* Creates a new `ProxyContext` instance.
|
|
* @param {any} context
|
|
*/
|
|
constructor(e) {
|
|
const t = g.proxycontext_new(v(e));
|
|
return this.__wbg_ptr = t >>> 0, We.register(this, this.__wbg_ptr, this), this;
|
|
}
|
|
/**
|
|
* Returns the JavaScript this.
|
|
* @returns {any}
|
|
*/
|
|
get context() {
|
|
const e = g.proxycontext_context(this.__wbg_ptr);
|
|
return I(e);
|
|
}
|
|
/**
|
|
* A convenience function to untar a tarball and call a callback for each
|
|
* entry.
|
|
* @param {Uint8Array} data
|
|
* @param {Function} cb
|
|
*/
|
|
untar(e, t) {
|
|
try {
|
|
const s = g.__wbindgen_add_to_stack_pointer(-16), o = nr(e, g.__wbindgen_export_2), a = T;
|
|
g.proxycontext_untar(s, this.__wbg_ptr, o, a, v(t));
|
|
var n = S().getInt32(s + 4 * 0, !0), i = S().getInt32(s + 4 * 1, !0);
|
|
if (i)
|
|
throw I(n);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const Rt = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => g.__wbg_typstcompiler_free(r >>> 0, 1));
|
|
class Ie {
|
|
static __wrap(e) {
|
|
e = e >>> 0;
|
|
const t = Object.create(Ie.prototype);
|
|
return t.__wbg_ptr = e, Rt.register(t, t.__wbg_ptr, t), t;
|
|
}
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, Rt.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
g.__wbg_typstcompiler_free(e, 0);
|
|
}
|
|
reset() {
|
|
try {
|
|
const n = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompiler_reset(n, this.__wbg_ptr);
|
|
var e = S().getInt32(n + 4 * 0, !0), t = S().getInt32(n + 4 * 1, !0);
|
|
if (t)
|
|
throw I(e);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {any} inputs
|
|
*/
|
|
set_inputs(e) {
|
|
try {
|
|
const i = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompiler_set_inputs(i, this.__wbg_ptr, v(e));
|
|
var t = S().getInt32(i + 4 * 0, !0), n = S().getInt32(i + 4 * 1, !0);
|
|
if (n)
|
|
throw I(t);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} path
|
|
* @param {string} content
|
|
* @returns {boolean}
|
|
*/
|
|
add_source(e, t) {
|
|
const n = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), i = T, s = B(t, g.__wbindgen_export_2, g.__wbindgen_export_3), o = T;
|
|
return g.typstcompiler_add_source(this.__wbg_ptr, n, i, s, o) !== 0;
|
|
}
|
|
/**
|
|
* @param {string} path
|
|
* @param {Uint8Array} content
|
|
* @returns {boolean}
|
|
*/
|
|
map_shadow(e, t) {
|
|
const n = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), i = T, s = nr(t, g.__wbindgen_export_2), o = T;
|
|
return g.typstcompiler_map_shadow(this.__wbg_ptr, n, i, s, o) !== 0;
|
|
}
|
|
/**
|
|
* @param {string} path
|
|
* @returns {boolean}
|
|
*/
|
|
unmap_shadow(e) {
|
|
const t = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), n = T;
|
|
return g.typstcompiler_unmap_shadow(this.__wbg_ptr, t, n) !== 0;
|
|
}
|
|
reset_shadow() {
|
|
g.typstcompiler_reset_shadow(this.__wbg_ptr);
|
|
}
|
|
/**
|
|
* @returns {string[]}
|
|
*/
|
|
get_loaded_fonts() {
|
|
try {
|
|
const i = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompiler_get_loaded_fonts(i, this.__wbg_ptr);
|
|
var e = S().getInt32(i + 4 * 0, !0), t = S().getInt32(i + 4 * 1, !0), n = jn(e, t).slice();
|
|
return g.__wbindgen_export_1(e, t * 4, 4), n;
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} main_file_path
|
|
* @returns {string}
|
|
*/
|
|
get_ast(e) {
|
|
let t, n;
|
|
try {
|
|
const f = g.__wbindgen_add_to_stack_pointer(-16), w = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), P = T;
|
|
g.typstcompiler_get_ast(f, this.__wbg_ptr, w, P);
|
|
var i = S().getInt32(f + 4 * 0, !0), s = S().getInt32(f + 4 * 1, !0), o = S().getInt32(f + 4 * 2, !0), a = S().getInt32(f + 4 * 3, !0), d = i, _ = s;
|
|
if (a)
|
|
throw d = 0, _ = 0, I(o);
|
|
return t = d, n = _, V(d, _);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16), g.__wbindgen_export_1(t, n, 1);
|
|
}
|
|
}
|
|
/**
|
|
* @returns {any}
|
|
*/
|
|
get_semantic_token_legend() {
|
|
try {
|
|
const i = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompiler_get_semantic_token_legend(i, this.__wbg_ptr);
|
|
var e = S().getInt32(i + 4 * 0, !0), t = S().getInt32(i + 4 * 1, !0), n = S().getInt32(i + 4 * 2, !0);
|
|
if (n)
|
|
throw I(t);
|
|
return I(e);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} offset_encoding
|
|
* @param {string | null} [file_path]
|
|
* @param {string | null} [result_id]
|
|
* @returns {object}
|
|
*/
|
|
get_semantic_tokens(e, t, n) {
|
|
try {
|
|
const w = g.__wbindgen_add_to_stack_pointer(-16), P = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), C = T;
|
|
var i = z(t) ? 0 : B(t, g.__wbindgen_export_2, g.__wbindgen_export_3), s = T, o = z(n) ? 0 : B(n, g.__wbindgen_export_2, g.__wbindgen_export_3), a = T;
|
|
g.typstcompiler_get_semantic_tokens(w, this.__wbg_ptr, P, C, i, s, o, a);
|
|
var d = S().getInt32(w + 4 * 0, !0), _ = S().getInt32(w + 4 * 1, !0), f = S().getInt32(w + 4 * 2, !0);
|
|
if (f)
|
|
throw I(_);
|
|
return I(d);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} fmt
|
|
* @param {number} diagnostics_format
|
|
* @returns {any}
|
|
*/
|
|
get_artifact(e, t) {
|
|
try {
|
|
const o = g.__wbindgen_add_to_stack_pointer(-16), a = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), d = T;
|
|
g.typstcompiler_get_artifact(o, this.__wbg_ptr, a, d, t);
|
|
var n = S().getInt32(o + 4 * 0, !0), i = S().getInt32(o + 4 * 1, !0), s = S().getInt32(o + 4 * 2, !0);
|
|
if (s)
|
|
throw I(i);
|
|
return I(n);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} main_file_path
|
|
* @param {(Array<any>)[] | null} [inputs]
|
|
*/
|
|
set_compiler_options(e, t) {
|
|
try {
|
|
const a = g.__wbindgen_add_to_stack_pointer(-16), d = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), _ = T;
|
|
var n = z(t) ? 0 : ge(t, g.__wbindgen_export_2), i = T;
|
|
g.typstcompiler_set_compiler_options(a, this.__wbg_ptr, d, _, n, i);
|
|
var s = S().getInt32(a + 4 * 0, !0), o = S().getInt32(a + 4 * 1, !0);
|
|
if (o)
|
|
throw I(s);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} main_file_path
|
|
* @param {(Array<any>)[] | null | undefined} inputs
|
|
* @param {string} selector
|
|
* @param {string | null} [field]
|
|
* @returns {string}
|
|
*/
|
|
query(e, t, n, i) {
|
|
let s, o;
|
|
try {
|
|
const D = g.__wbindgen_add_to_stack_pointer(-16), _r = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), ur = T;
|
|
var a = z(t) ? 0 : ge(t, g.__wbindgen_export_2), d = T;
|
|
const dr = B(n, g.__wbindgen_export_2, g.__wbindgen_export_3), lr = T;
|
|
var _ = z(i) ? 0 : B(i, g.__wbindgen_export_2, g.__wbindgen_export_3), f = T;
|
|
g.typstcompiler_query(D, this.__wbg_ptr, _r, ur, a, d, dr, lr, _, f);
|
|
var w = S().getInt32(D + 4 * 0, !0), P = S().getInt32(D + 4 * 1, !0), C = S().getInt32(D + 4 * 2, !0), F = S().getInt32(D + 4 * 3, !0), A = w, $ = P;
|
|
if (F)
|
|
throw A = 0, $ = 0, I(C);
|
|
return s = A, o = $, V(A, $);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16), g.__wbindgen_export_1(s, o, 1);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} main_file_path
|
|
* @param {(Array<any>)[] | null | undefined} inputs
|
|
* @param {string} fmt
|
|
* @param {number} diagnostics_format
|
|
* @returns {any}
|
|
*/
|
|
compile(e, t, n, i) {
|
|
try {
|
|
const f = g.__wbindgen_add_to_stack_pointer(-16), w = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), P = T;
|
|
var s = z(t) ? 0 : ge(t, g.__wbindgen_export_2), o = T;
|
|
const C = B(n, g.__wbindgen_export_2, g.__wbindgen_export_3), F = T;
|
|
g.typstcompiler_compile(f, this.__wbg_ptr, w, P, s, o, C, F, i);
|
|
var a = S().getInt32(f + 4 * 0, !0), d = S().getInt32(f + 4 * 1, !0), _ = S().getInt32(f + 4 * 2, !0);
|
|
if (_)
|
|
throw I(d);
|
|
return I(a);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @returns {IncrServer}
|
|
*/
|
|
create_incr_server() {
|
|
try {
|
|
const i = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompiler_create_incr_server(i, this.__wbg_ptr);
|
|
var e = S().getInt32(i + 4 * 0, !0), t = S().getInt32(i + 4 * 1, !0), n = S().getInt32(i + 4 * 2, !0);
|
|
if (n)
|
|
throw I(t);
|
|
return de.__wrap(e);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {string} main_file_path
|
|
* @param {(Array<any>)[] | null | undefined} inputs
|
|
* @param {IncrServer} state
|
|
* @param {number} diagnostics_format
|
|
* @returns {any}
|
|
*/
|
|
incr_compile(e, t, n, i) {
|
|
try {
|
|
const f = g.__wbindgen_add_to_stack_pointer(-16), w = B(e, g.__wbindgen_export_2, g.__wbindgen_export_3), P = T;
|
|
var s = z(t) ? 0 : ge(t, g.__wbindgen_export_2), o = T;
|
|
Bn(n, de), g.typstcompiler_incr_compile(f, this.__wbg_ptr, w, P, s, o, n.__wbg_ptr, i);
|
|
var a = S().getInt32(f + 4 * 0, !0), d = S().getInt32(f + 4 * 1, !0), _ = S().getInt32(f + 4 * 2, !0);
|
|
if (_)
|
|
throw I(d);
|
|
return I(a);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
}
|
|
const Et = typeof FinalizationRegistry > "u" ? { register: () => {
|
|
}, unregister: () => {
|
|
} } : new FinalizationRegistry((r) => g.__wbg_typstcompilerbuilder_free(r >>> 0, 1));
|
|
class qn {
|
|
__destroy_into_raw() {
|
|
const e = this.__wbg_ptr;
|
|
return this.__wbg_ptr = 0, Et.unregister(this), e;
|
|
}
|
|
free() {
|
|
const e = this.__destroy_into_raw();
|
|
g.__wbg_typstcompilerbuilder_free(e, 0);
|
|
}
|
|
constructor() {
|
|
try {
|
|
const i = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompilerbuilder_new(i);
|
|
var e = S().getInt32(i + 4 * 0, !0), t = S().getInt32(i + 4 * 1, !0), n = S().getInt32(i + 4 * 2, !0);
|
|
if (n)
|
|
throw I(t);
|
|
return this.__wbg_ptr = e >>> 0, Et.register(this, this.__wbg_ptr, this), this;
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
set_dummy_access_model() {
|
|
try {
|
|
const n = g.__wbindgen_add_to_stack_pointer(-16);
|
|
g.typstcompilerbuilder_set_dummy_access_model(n, this.__wbg_ptr);
|
|
var e = S().getInt32(n + 4 * 0, !0), t = S().getInt32(n + 4 * 1, !0);
|
|
if (t)
|
|
throw I(e);
|
|
} finally {
|
|
g.__wbindgen_add_to_stack_pointer(16);
|
|
}
|
|
}
|
|
/**
|
|
* @param {any} context
|
|
* @param {Function} mtime_fn
|
|
* @param {Function} is_file_fn
|
|
* @param {Function} real_path_fn
|
|
* @param {Function} read_all_fn
|
|
* @returns {Promise<void>}
|
|
*/
|
|
set_access_model(e, t, n, i, s) {
|
|
const o = g.typstcompilerbuilder_set_access_model(this.__wbg_ptr, v(e), v(t), v(n), v(i), v(s));
|
|
return I(o);
|
|
}
|
|
/**
|
|
* @param {any} context
|
|
* @param {Function} real_resolve_fn
|
|
* @returns {Promise<void>}
|
|
*/
|
|
set_package_registry(e, t) {
|
|
const n = g.typstcompilerbuilder_set_package_registry(this.__wbg_ptr, v(e), v(t));
|
|
return I(n);
|
|
}
|
|
/**
|
|
* @param {Uint8Array} data
|
|
* @returns {Promise<void>}
|
|
*/
|
|
add_raw_font(e) {
|
|
const t = g.typstcompilerbuilder_add_raw_font(this.__wbg_ptr, v(e));
|
|
return I(t);
|
|
}
|
|
/**
|
|
* @param {Array<any>} fonts
|
|
* @returns {Promise<void>}
|
|
*/
|
|
add_web_fonts(e) {
|
|
const t = g.typstcompilerbuilder_add_web_fonts(this.__wbg_ptr, v(e));
|
|
return I(t);
|
|
}
|
|
/**
|
|
* @returns {Promise<TypstCompiler>}
|
|
*/
|
|
build() {
|
|
const e = this.__destroy_into_raw(), t = g.typstcompilerbuilder_build(e);
|
|
return I(t);
|
|
}
|
|
}
|
|
async function Nn(r, e) {
|
|
if (typeof Response == "function" && r instanceof Response) {
|
|
if (typeof WebAssembly.instantiateStreaming == "function")
|
|
try {
|
|
return await WebAssembly.instantiateStreaming(r, e);
|
|
} catch (n) {
|
|
if (r.headers.get("Content-Type") != "application/wasm")
|
|
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", n);
|
|
else
|
|
throw n;
|
|
}
|
|
const t = await r.arrayBuffer();
|
|
return await WebAssembly.instantiate(t, e);
|
|
} else {
|
|
const t = await WebAssembly.instantiate(r, e);
|
|
return t instanceof WebAssembly.Instance ? { instance: t, module: r } : t;
|
|
}
|
|
}
|
|
function ir() {
|
|
const r = {};
|
|
return r.wbg = {}, r.wbg.__wbg_buffer_609cc3eee51ed158 = function(e) {
|
|
const t = b(e).buffer;
|
|
return v(t);
|
|
}, r.wbg.__wbg_call_672a4d21634d4a24 = function() {
|
|
return Z(function(e, t) {
|
|
const n = b(e).call(b(t));
|
|
return v(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_7cccdd69e0791ae2 = function() {
|
|
return Z(function(e, t, n) {
|
|
const i = b(e).call(b(t), b(n));
|
|
return v(i);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_call_b8adc8b1d0a0d8eb = function() {
|
|
return Z(function(e, t, n, i, s) {
|
|
const o = b(e).call(b(t), b(n), b(i), b(s));
|
|
return v(o);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_done_769e5ede4b31c67b = function(e) {
|
|
return b(e).done;
|
|
}, r.wbg.__wbg_entries_3265d4158b33e5dc = function(e) {
|
|
const t = Object.entries(b(e));
|
|
return v(t);
|
|
}, r.wbg.__wbg_error_13f62fdb4fc06f92 = function(e, t, n) {
|
|
console.error(b(e), b(t), b(n));
|
|
}, r.wbg.__wbg_error_7534b8e9a36f1ab4 = function(e, t) {
|
|
let n, i;
|
|
try {
|
|
n = e, i = t, console.error(V(e, t));
|
|
} finally {
|
|
g.__wbindgen_export_1(n, i, 1);
|
|
}
|
|
}, r.wbg.__wbg_getTimezoneOffset_6b5752021c499c47 = function(e) {
|
|
return b(e).getTimezoneOffset();
|
|
}, r.wbg.__wbg_get_67b2ba62fc30de12 = function() {
|
|
return Z(function(e, t) {
|
|
const n = Reflect.get(b(e), b(t));
|
|
return v(n);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_get_b9b93047fe3cf45b = function(e, t) {
|
|
const n = b(e)[t >>> 0];
|
|
return v(n);
|
|
}, r.wbg.__wbg_getwithrefkey_1dc361bd10053bfe = function(e, t) {
|
|
const n = b(e)[b(t)];
|
|
return v(n);
|
|
}, r.wbg.__wbg_info_3daf2e093e091b66 = function(e) {
|
|
console.info(b(e));
|
|
}, r.wbg.__wbg_instanceof_ArrayBuffer_e14585432e3737fc = function(e) {
|
|
let t;
|
|
try {
|
|
t = b(e) instanceof ArrayBuffer;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
return t;
|
|
}, r.wbg.__wbg_instanceof_Map_f3469ce2244d2430 = function(e) {
|
|
let t;
|
|
try {
|
|
t = b(e) instanceof Map;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
return t;
|
|
}, r.wbg.__wbg_instanceof_Object_7f2dcef8f78644a4 = function(e) {
|
|
let t;
|
|
try {
|
|
t = b(e) instanceof Object;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
return t;
|
|
}, r.wbg.__wbg_instanceof_Uint8Array_17156bcf118086a9 = function(e) {
|
|
let t;
|
|
try {
|
|
t = b(e) instanceof Uint8Array;
|
|
} catch {
|
|
t = !1;
|
|
}
|
|
return t;
|
|
}, r.wbg.__wbg_isArray_a1eab7e0d067391b = function(e) {
|
|
return Array.isArray(b(e));
|
|
}, r.wbg.__wbg_isSafeInteger_343e2beeeece1bb0 = function(e) {
|
|
return Number.isSafeInteger(b(e));
|
|
}, r.wbg.__wbg_iterator_9a24c88df860dc65 = function() {
|
|
return v(Symbol.iterator);
|
|
}, r.wbg.__wbg_length_a446193dc22c12f8 = function(e) {
|
|
return b(e).length;
|
|
}, r.wbg.__wbg_length_e2d2a49132c1b256 = function(e) {
|
|
return b(e).length;
|
|
}, r.wbg.__wbg_log_53ca6abb454c8644 = function(e, t, n) {
|
|
console.log(b(e), b(t), b(n));
|
|
}, r.wbg.__wbg_new_23a2665fac83c611 = function(e, t) {
|
|
try {
|
|
var n = { a: e, b: t }, i = (o, a) => {
|
|
const d = n.a;
|
|
n.a = 0;
|
|
try {
|
|
return zn(d, n.b, o, a);
|
|
} finally {
|
|
n.a = d;
|
|
}
|
|
};
|
|
const s = new Promise(i);
|
|
return v(s);
|
|
} finally {
|
|
n.a = n.b = 0;
|
|
}
|
|
}, r.wbg.__wbg_new_31a97dac4f10fab7 = function(e) {
|
|
const t = new Date(b(e));
|
|
return v(t);
|
|
}, r.wbg.__wbg_new_405e22f390576ce2 = function() {
|
|
const e = new Object();
|
|
return v(e);
|
|
}, r.wbg.__wbg_new_78feb108b6472713 = function() {
|
|
const e = new Array();
|
|
return v(e);
|
|
}, r.wbg.__wbg_new_8a6f238a6ece86ea = function() {
|
|
const e = new Error();
|
|
return v(e);
|
|
}, r.wbg.__wbg_new_a12002a7f91c75be = function(e) {
|
|
const t = new Uint8Array(b(e));
|
|
return v(t);
|
|
}, r.wbg.__wbg_new_c68d7209be747379 = function(e, t) {
|
|
const n = new Error(V(e, t));
|
|
return v(n);
|
|
}, r.wbg.__wbg_new_e3b321dcfef89fc7 = function(e) {
|
|
const t = new Uint32Array(b(e));
|
|
return v(t);
|
|
}, r.wbg.__wbg_newnoargs_105ed471475aaf50 = function(e, t) {
|
|
const n = createCspSafeFunction(V(e, t));
|
|
return v(n);
|
|
}, r.wbg.__wbg_newwithargs_ab6ffe8cd6c19c04 = function(e, t, n, i) {
|
|
const s = createCspSafeFunction(V(e, t), V(n, i));
|
|
return v(s);
|
|
}, r.wbg.__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a = function(e, t, n) {
|
|
const i = new Uint8Array(b(e), t >>> 0, n >>> 0);
|
|
return v(i);
|
|
}, r.wbg.__wbg_newwithbyteoffsetandlength_f1dead44d1fc7212 = function(e, t, n) {
|
|
const i = new Uint32Array(b(e), t >>> 0, n >>> 0);
|
|
return v(i);
|
|
}, r.wbg.__wbg_next_25feadfc0913fea9 = function(e) {
|
|
const t = b(e).next;
|
|
return v(t);
|
|
}, r.wbg.__wbg_next_6574e1a8a62d1055 = function() {
|
|
return Z(function(e) {
|
|
const t = b(e).next();
|
|
return v(t);
|
|
}, arguments);
|
|
}, r.wbg.__wbg_now_807e54c39636c349 = function() {
|
|
return Date.now();
|
|
}, r.wbg.__wbg_proxycontext_new = function(e) {
|
|
const t = Pe.__wrap(e);
|
|
return v(t);
|
|
}, r.wbg.__wbg_push_737cfc8c1432c2c6 = function(e, t) {
|
|
return b(e).push(b(t));
|
|
}, r.wbg.__wbg_queueMicrotask_97d92b4fcc8a61c5 = function(e) {
|
|
queueMicrotask(b(e));
|
|
}, r.wbg.__wbg_queueMicrotask_d3219def82552485 = function(e) {
|
|
const t = b(e).queueMicrotask;
|
|
return v(t);
|
|
}, r.wbg.__wbg_resolve_4851785c9c5f573d = function(e) {
|
|
const t = Promise.resolve(b(e));
|
|
return v(t);
|
|
}, r.wbg.__wbg_set_37837023f3d740e8 = function(e, t, n) {
|
|
b(e)[t >>> 0] = I(n);
|
|
}, r.wbg.__wbg_set_3f1d0b984ed272ed = function(e, t, n) {
|
|
b(e)[I(t)] = I(n);
|
|
}, r.wbg.__wbg_set_65595bdd868b3009 = function(e, t, n) {
|
|
b(e).set(b(t), n >>> 0);
|
|
}, r.wbg.__wbg_set_bb8cecf6a62b9f46 = function() {
|
|
return Z(function(e, t, n) {
|
|
return Reflect.set(b(e), b(t), b(n));
|
|
}, arguments);
|
|
}, r.wbg.__wbg_stack_0ed75d68575b0f3c = function(e, t) {
|
|
const n = b(t).stack, i = B(n, g.__wbindgen_export_2, g.__wbindgen_export_3), s = T;
|
|
S().setInt32(e + 4 * 1, s, !0), S().setInt32(e + 4 * 0, i, !0);
|
|
}, r.wbg.__wbg_static_accessor_GLOBAL_88a902d13a557d07 = function() {
|
|
const e = typeof global > "u" ? null : global;
|
|
return z(e) ? 0 : v(e);
|
|
}, r.wbg.__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0 = function() {
|
|
const e = typeof globalThis > "u" ? null : globalThis;
|
|
return z(e) ? 0 : v(e);
|
|
}, r.wbg.__wbg_static_accessor_SELF_37c5d418e4bf5819 = function() {
|
|
const e = typeof self > "u" ? null : self;
|
|
return z(e) ? 0 : v(e);
|
|
}, r.wbg.__wbg_static_accessor_WINDOW_5de37043a91a9c40 = function() {
|
|
const e = typeof window > "u" ? null : window;
|
|
return z(e) ? 0 : v(e);
|
|
}, r.wbg.__wbg_then_44b73946d2fb3e7d = function(e, t) {
|
|
const n = b(e).then(b(t));
|
|
return v(n);
|
|
}, r.wbg.__wbg_typstcompiler_new = function(e) {
|
|
const t = Ie.__wrap(e);
|
|
return v(t);
|
|
}, r.wbg.__wbg_value_cd1ffa7b1ab794f1 = function(e) {
|
|
const t = b(e).value;
|
|
return v(t);
|
|
}, r.wbg.__wbindgen_as_number = function(e) {
|
|
return +b(e);
|
|
}, r.wbg.__wbindgen_bigint_from_i64 = function(e) {
|
|
return v(e);
|
|
}, r.wbg.__wbindgen_bigint_from_u64 = function(e) {
|
|
const t = BigInt.asUintN(64, e);
|
|
return v(t);
|
|
}, r.wbg.__wbindgen_bigint_get_as_i64 = function(e, t) {
|
|
const n = b(t), i = typeof n == "bigint" ? n : void 0;
|
|
S().setBigInt64(e + 8 * 1, z(i) ? BigInt(0) : i, !0), S().setInt32(e + 4 * 0, !z(i), !0);
|
|
}, r.wbg.__wbindgen_boolean_get = function(e) {
|
|
const t = b(e);
|
|
return typeof t == "boolean" ? t ? 1 : 0 : 2;
|
|
}, r.wbg.__wbindgen_cb_drop = function(e) {
|
|
const t = I(e).original;
|
|
return t.cnt-- == 1 ? (t.a = 0, !0) : !1;
|
|
}, r.wbg.__wbindgen_closure_wrapper16165 = function(e, t, n) {
|
|
const i = Fn(e, t, 1133, Wn);
|
|
return v(i);
|
|
}, r.wbg.__wbindgen_debug_string = function(e, t) {
|
|
const n = Ke(b(t)), i = B(n, g.__wbindgen_export_2, g.__wbindgen_export_3), s = T;
|
|
S().setInt32(e + 4 * 1, s, !0), S().setInt32(e + 4 * 0, i, !0);
|
|
}, r.wbg.__wbindgen_error_new = function(e, t) {
|
|
const n = new Error(V(e, t));
|
|
return v(n);
|
|
}, r.wbg.__wbindgen_in = function(e, t) {
|
|
return b(e) in b(t);
|
|
}, r.wbg.__wbindgen_is_bigint = function(e) {
|
|
return typeof b(e) == "bigint";
|
|
}, r.wbg.__wbindgen_is_function = function(e) {
|
|
return typeof b(e) == "function";
|
|
}, r.wbg.__wbindgen_is_object = function(e) {
|
|
const t = b(e);
|
|
return typeof t == "object" && t !== null;
|
|
}, r.wbg.__wbindgen_is_string = function(e) {
|
|
return typeof b(e) == "string";
|
|
}, r.wbg.__wbindgen_is_undefined = function(e) {
|
|
return b(e) === void 0;
|
|
}, r.wbg.__wbindgen_jsval_eq = function(e, t) {
|
|
return b(e) === b(t);
|
|
}, r.wbg.__wbindgen_jsval_loose_eq = function(e, t) {
|
|
return b(e) == b(t);
|
|
}, r.wbg.__wbindgen_memory = function() {
|
|
const e = g.memory;
|
|
return v(e);
|
|
}, r.wbg.__wbindgen_number_get = function(e, t) {
|
|
const n = b(t), i = typeof n == "number" ? n : void 0;
|
|
S().setFloat64(e + 8 * 1, z(i) ? 0 : i, !0), S().setInt32(e + 4 * 0, !z(i), !0);
|
|
}, r.wbg.__wbindgen_number_new = function(e) {
|
|
return v(e);
|
|
}, r.wbg.__wbindgen_object_clone_ref = function(e) {
|
|
const t = b(e);
|
|
return v(t);
|
|
}, r.wbg.__wbindgen_object_drop_ref = function(e) {
|
|
I(e);
|
|
}, r.wbg.__wbindgen_string_get = function(e, t) {
|
|
const n = b(t), i = typeof n == "string" ? n : void 0;
|
|
var s = z(i) ? 0 : B(i, g.__wbindgen_export_2, g.__wbindgen_export_3), o = T;
|
|
S().setInt32(e + 4 * 1, o, !0), S().setInt32(e + 4 * 0, s, !0);
|
|
}, r.wbg.__wbindgen_string_new = function(e, t) {
|
|
const n = V(e, t);
|
|
return v(n);
|
|
}, r.wbg.__wbindgen_throw = function(e, t) {
|
|
throw new Error(V(e, t));
|
|
}, r;
|
|
}
|
|
function sr(r, e) {
|
|
return g = r.exports, or.__wbindgen_wasm_module = e, X = null, oe = null, g;
|
|
}
|
|
function Un(r) {
|
|
if (g !== void 0) return g;
|
|
typeof r < "u" && (Object.getPrototypeOf(r) === Object.prototype ? { module: r } = r : console.warn("using deprecated parameters for `initSync()`; pass a single object instead"));
|
|
const e = ir();
|
|
r instanceof WebAssembly.Module || (r = new WebAssembly.Module(r));
|
|
const t = new WebAssembly.Instance(r, e);
|
|
return sr(t, r);
|
|
}
|
|
async function or(r) {
|
|
if (g !== void 0) return g;
|
|
typeof r < "u" && (Object.getPrototypeOf(r) === Object.prototype ? { module_or_path: r } = r : console.warn("using deprecated parameters for the initialization function; pass a single object instead")), typeof r > "u" && (r = ar("typst_ts_web_compiler_bg.wasm", import.meta.url));
|
|
const e = ir();
|
|
(typeof r == "string" || typeof Request == "function" && r instanceof Request || typeof URL == "function" && r instanceof URL) && (r = fetch(r));
|
|
const { instance: t, module: n } = await Nn(await r, e);
|
|
return sr(t, n);
|
|
}
|
|
let ar = async function(r, e) {
|
|
throw new Error("Cannot import wasm module without importer: " + r + " " + e);
|
|
};
|
|
function cr(r) {
|
|
ar = r;
|
|
}
|
|
let Hn = async function(r, e) {
|
|
const t = (m) => import(m), { readFileSync: n } = await t("fs"), i = new URL(r, e);
|
|
return await n(i).buffer;
|
|
};
|
|
const Vn = typeof process < "u" && process.versions != null && process.versions.node != null;
|
|
Vn && cr(Hn);
|
|
const Me = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
IncrServer: de,
|
|
ProxyContext: Pe,
|
|
TypstCompiler: Ie,
|
|
TypstCompilerBuilder: qn,
|
|
default: or,
|
|
get_font_info: $n,
|
|
initSync: Un,
|
|
setImportWasmModule: cr
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
export {
|
|
we as $typst,
|
|
vr as FetchAccessModel,
|
|
Ne as FetchPackageRegistry,
|
|
U as TypstSnippet,
|
|
zt as createTypstCompiler,
|
|
nt as createTypstRenderer,
|
|
ni as createTypstSvgRenderer,
|
|
ne as preloadRemoteFonts,
|
|
Ze as preloadSystemFonts,
|
|
ii as rendererBuildInfo
|
|
};
|