typst-wasm 0.0.1-alpha

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,186 @@
1
+ import { WasmCompileOptions, WasmCompileOutput, WasmDiagnostic } from "./wasm.js";
2
+ import { a as DependencyInfo, c as TypstCompiler, i as CompileResult, l as TypstCompilerOptions, n as CompileFormat, o as PackageCache, r as CompileOptions, s as PageOutput, t as BundleFile, u as WasmModuleOrPath } from "./types-BoGtHbqQ.js";
3
+ export * from "@typst-wasm/fonts";
4
+
5
+ //#region src/protocol.d.ts
6
+ declare const SharedMemoryCommunicationStatus: {
7
+ readonly None: 0;
8
+ readonly Pending: 1;
9
+ readonly Error: 2;
10
+ readonly Success: 3;
11
+ };
12
+ type SharedMemoryCommunicationStatus = (typeof SharedMemoryCommunicationStatus)[keyof typeof SharedMemoryCommunicationStatus];
13
+ declare class SharedMemoryCommunication {
14
+ dataBuf: SharedArrayBuffer;
15
+ statusBuf: SharedArrayBuffer;
16
+ sizeBuf: SharedArrayBuffer;
17
+ constructor();
18
+ getStatus(): SharedMemoryCommunicationStatus;
19
+ setStatus(status: SharedMemoryCommunicationStatus): void;
20
+ setBuffer(buf: Uint8Array): void;
21
+ getBuffer(): Uint8Array;
22
+ waitForStatusChange(expectedStatus: SharedMemoryCommunicationStatus, timeoutMs?: number): boolean;
23
+ static hydrateObj(obj: SharedMemoryCommunication): SharedMemoryCommunication;
24
+ }
25
+ interface TypstWorkerProtocol {
26
+ init: {
27
+ request: {
28
+ sharedMemoryCommunication: SharedMemoryCommunication;
29
+ moduleOrPath: WasmModuleOrPath;
30
+ };
31
+ response: void;
32
+ };
33
+ add_file: {
34
+ request: {
35
+ path: string;
36
+ data: Uint8Array;
37
+ };
38
+ response: void;
39
+ };
40
+ add_source: {
41
+ request: {
42
+ path: string;
43
+ text: string;
44
+ };
45
+ response: void;
46
+ };
47
+ add_font: {
48
+ request: {
49
+ data: Uint8Array;
50
+ };
51
+ response: void;
52
+ };
53
+ remove_file: {
54
+ request: {
55
+ path: string;
56
+ };
57
+ response: void;
58
+ };
59
+ clear_files: {
60
+ request: void;
61
+ response: void;
62
+ };
63
+ set_main: {
64
+ request: {
65
+ path: string;
66
+ };
67
+ response: void;
68
+ };
69
+ compile: {
70
+ request: {
71
+ options: WasmCompileOptions;
72
+ };
73
+ response: WasmCompileOutput;
74
+ };
75
+ list_files: {
76
+ request: void;
77
+ response: string[];
78
+ };
79
+ has_file: {
80
+ request: {
81
+ path: string;
82
+ };
83
+ response: boolean;
84
+ };
85
+ }
86
+ type NoPayload = Record<never, never>;
87
+ type ExcludePayloadIfEmpty<P> = P extends void ? NoPayload : {
88
+ payload: P;
89
+ };
90
+ type RpcRequestMessage<T> = { [K in keyof T]: {
91
+ kind: K;
92
+ requestId: number;
93
+ } & (T[K] extends {
94
+ request: infer P;
95
+ } ? ExcludePayloadIfEmpty<P> : NoPayload) }[keyof T];
96
+ type RpcResponseMessage<TResult = unknown, TError = unknown> = {
97
+ requestId: number;
98
+ result: TResult;
99
+ } | {
100
+ requestId: number;
101
+ error: TError;
102
+ };
103
+ //#endregion
104
+ //#region src/messages.d.ts
105
+ type MainToWorkerMessage = RpcRequestMessage<TypstWorkerProtocol>;
106
+ type WorkerEventMessage = {
107
+ kind: "web_fetch";
108
+ payload: {
109
+ path: string;
110
+ };
111
+ };
112
+ type WorkerToMainMessage = RpcResponseMessage | WorkerEventMessage;
113
+ //#endregion
114
+ //#region src/errors.d.ts
115
+ declare class TypstError extends Error {
116
+ constructor(message: string, options?: {
117
+ cause?: unknown;
118
+ });
119
+ }
120
+ declare class CompileError extends TypstError {
121
+ readonly diagnostics: WasmDiagnostic[];
122
+ constructor(message: string, options?: {
123
+ diagnostics?: WasmDiagnostic[];
124
+ cause?: unknown;
125
+ });
126
+ }
127
+ declare class CompilerNotInitializedError extends TypstError {}
128
+ declare class CompilerDisposedError extends TypstError {}
129
+ declare class FontLoadError extends TypstError {
130
+ readonly fontName: string;
131
+ constructor(fontName: string, cause: unknown);
132
+ }
133
+ declare class FetchError extends TypstError {
134
+ readonly path: string;
135
+ constructor(path: string, cause: unknown);
136
+ }
137
+ declare class PackageParseError extends TypstError {
138
+ readonly spec: string;
139
+ constructor(spec: string, message: string);
140
+ }
141
+ declare class PackageFetchError extends TypstError {
142
+ readonly url: string;
143
+ constructor(url: string, cause: unknown);
144
+ }
145
+ declare class FileNotFoundError extends TypstError {
146
+ readonly filePath: string;
147
+ constructor(filePath: string);
148
+ }
149
+ declare class WorkerError extends TypstError {}
150
+ //#endregion
151
+ //#region src/package-manager.d.ts
152
+ interface PackageManagerOptions {
153
+ fetch?: typeof fetch;
154
+ packageBaseUrl?: string;
155
+ cache?: PackageCache;
156
+ memoryPackageCacheCapacity?: number;
157
+ }
158
+ declare class PackageManager {
159
+ private readonly fetchImpl;
160
+ private readonly packageBaseUrl;
161
+ private readonly cache;
162
+ private readonly loadedPackages;
163
+ private readonly loadingPackages;
164
+ constructor(options?: PackageManagerOptions);
165
+ getFile(spec: string): Promise<Uint8Array>;
166
+ private loadPackageDeduped;
167
+ private loadPackage;
168
+ }
169
+ //#endregion
170
+ //#region src/cache-abstraction.d.ts
171
+ declare const makeBrowserCacheStorage: () => PackageCache;
172
+ declare const makeMemoryCacheStorage: (capacity: number) => PackageCache;
173
+ declare const makeDefaultPackageCache: (capacity?: number) => PackageCache;
174
+ //#endregion
175
+ //#region src/backend-support.d.ts
176
+ declare const supportsWorkerBackend: () => boolean;
177
+ declare const supportsJspiBackend: () => boolean;
178
+ //#endregion
179
+ //#region src/compiler-backend.d.ts
180
+ declare const selectAutomaticBackendKind: () => "worker" | "jspi" | "none";
181
+ //#endregion
182
+ //#region src/index.d.ts
183
+ declare const createTypstCompiler: (options: TypstCompilerOptions) => Promise<TypstCompiler>;
184
+ //#endregion
185
+ export { type BundleFile, CompileError, type CompileFormat, type CompileOptions, type CompileResult, CompilerDisposedError, CompilerNotInitializedError, type DependencyInfo, FetchError, FileNotFoundError, FontLoadError, type MainToWorkerMessage, type PackageCache, PackageFetchError, PackageManager, PackageParseError, type PageOutput, SharedMemoryCommunication, type TypstCompiler, type TypstCompilerOptions, TypstError, type WasmDiagnostic, type WasmModuleOrPath, WorkerError, type WorkerToMainMessage, createTypstCompiler, makeBrowserCacheStorage, makeDefaultPackageCache, makeMemoryCacheStorage, selectAutomaticBackendKind, supportsJspiBackend, supportsWorkerBackend };
186
+ //# sourceMappingURL=index.d.ts.map