@build-qube/papyra-tauri 0.0.0-stage → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -2
- package/dist/engine.d.ts +74 -0
- package/dist/engine.d.ts.map +1 -0
- package/dist/engine.js +177 -0
- package/dist/engine.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -4
package/README.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @build-qube/papyra-tauri
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A Tauri engine for papyra's PDF viewer: documents are parsed and rendered by papyra in
|
|
4
|
+
the app's host process, through the `tauri-plugin-papyra` crate.
|
|
5
|
+
|
|
6
|
+
A Tauri app's WebView is never cross-origin isolated on Android or iOS, so papyra's
|
|
7
|
+
wasm build cannot run there. This engine does not need it: the Rust side renders on
|
|
8
|
+
the device's real cores, and the WebView only paints.
|
|
9
|
+
|
|
10
|
+
Installing it, wiring `tauri-plugin-papyra` into the app, and keeping papyra's
|
|
11
|
+
wasm out of the bundle are in the [Tauri guide](https://buildqube.github.io/Papyra/docs/guides/tauri).
|
|
12
|
+
|
|
13
|
+
## Pages and lifetimes
|
|
14
|
+
|
|
15
|
+
Pages travel over a `papyra://` protocol, as PNG by default. `new TauriEngine({
|
|
16
|
+
format: 'rgba' })` sends raw pixels instead: no encode or decode, four times the
|
|
17
|
+
bytes. Which is faster depends on the device.
|
|
18
|
+
|
|
19
|
+
Documents stay in the host until closed. The viewer's store and file preview close
|
|
20
|
+
what they open; if you call the engine yourself, `await engine.close(doc)` — it
|
|
21
|
+
rejects if the host could not release the document. When a WebView loads a page —
|
|
22
|
+
a reload, HMR, the app restarting its UI — the host drops every document that
|
|
23
|
+
WebView had open, since nothing on the new page could close them.
|
package/dist/engine.d.ts
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type Attachment, type Availability, type BackendRenderOptions, type Capabilities, type DocumentMetadata, type OpenOptions, type OutlineNode, type PageBitmap, type PageLink, type PageSize, type PageText, type PdfBackend, PdfEngine, type PdfSource, type StructNode } from '@build-qube/papyra/core';
|
|
2
|
+
type NativeInfo = {
|
|
3
|
+
[K in keyof DocumentMetadata]?: string | null;
|
|
4
|
+
};
|
|
5
|
+
/** How pages travel from the host. */
|
|
6
|
+
export type TauriPageFormat = 'png' | 'rgba';
|
|
7
|
+
/** Options for {@link TauriEngine}. */
|
|
8
|
+
export interface TauriEngineOptions {
|
|
9
|
+
/**
|
|
10
|
+
* How pages come back from the host. `'png'` (the default) costs an encode in Rust
|
|
11
|
+
* and a decode in the WebView, off its main thread; `'rgba'` costs neither and is
|
|
12
|
+
* four times the bytes over an in-process channel, painted with `putImageData`.
|
|
13
|
+
* Which is faster depends on the device — measure on yours.
|
|
14
|
+
*/
|
|
15
|
+
format?: TauriPageFormat;
|
|
16
|
+
}
|
|
17
|
+
/** The plugin's answer to `open`. */
|
|
18
|
+
interface Opened {
|
|
19
|
+
id: number;
|
|
20
|
+
sizes: [number, number][];
|
|
21
|
+
info: NativeInfo;
|
|
22
|
+
pdfVersion: string | null;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* PDFs parsed and rendered by papyra in the Tauri app's host process, through
|
|
26
|
+
* `tauri-plugin-papyra`.
|
|
27
|
+
*
|
|
28
|
+
* For a Tauri app's WebView, which is never cross-origin isolated on Android or iOS
|
|
29
|
+
* and so cannot run papyra's wasm. Here the work runs on the host's real cores with
|
|
30
|
+
* no wasm at all, and the WebView only paints.
|
|
31
|
+
*
|
|
32
|
+
* The app registers the plugin (`.plugin(tauri_plugin_papyra::init())`) and allows
|
|
33
|
+
* `papyra:default` in its capabilities. Everything papyra's own engine reads, this one
|
|
34
|
+
* does: same parser, same text, same structure tree.
|
|
35
|
+
*
|
|
36
|
+
* Documents live in the host until closed, so close what you open — the viewer's
|
|
37
|
+
* store and file preview do.
|
|
38
|
+
*/
|
|
39
|
+
export declare class TauriEngine extends PdfEngine<TauriBackend> {
|
|
40
|
+
#private;
|
|
41
|
+
readonly id = "tauri";
|
|
42
|
+
constructor(options?: TauriEngineOptions);
|
|
43
|
+
availability(): Availability;
|
|
44
|
+
protected load(source: PdfSource, options: OpenOptions): Promise<TauriBackend>;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One document held by the host, as a papyra backend.
|
|
48
|
+
*
|
|
49
|
+
* @internal Exported for tests.
|
|
50
|
+
*/
|
|
51
|
+
export declare class TauriBackend implements PdfBackend {
|
|
52
|
+
#private;
|
|
53
|
+
readonly fingerprint: string;
|
|
54
|
+
readonly format: TauriPageFormat;
|
|
55
|
+
readonly capabilities: Capabilities;
|
|
56
|
+
readonly abortable = false;
|
|
57
|
+
readonly concurrency = 4;
|
|
58
|
+
constructor(opened: Opened, fingerprint: string, format: TauriPageFormat);
|
|
59
|
+
get pageCount(): number;
|
|
60
|
+
pageSize(index: number): PageSize;
|
|
61
|
+
renderPage(index: number, options: BackendRenderOptions, signal?: AbortSignal): Promise<PageBitmap>;
|
|
62
|
+
metadata(): DocumentMetadata;
|
|
63
|
+
pdfVersion(): string | null;
|
|
64
|
+
pageText(index: number): Promise<PageText>;
|
|
65
|
+
outline(): Promise<OutlineNode[]>;
|
|
66
|
+
links(index: number): Promise<readonly PageLink[]>;
|
|
67
|
+
pageLabels(): Promise<readonly string[]>;
|
|
68
|
+
attachments(): Promise<readonly Attachment[]>;
|
|
69
|
+
attachmentData(index: number): Promise<Uint8Array>;
|
|
70
|
+
structTree(): Promise<StructNode[]>;
|
|
71
|
+
close(): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,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CAAC,SAAS,SAAS;IAC3B,QAAQ,CAAC,WAAW,KAAK;IAOzB,YACE,MAAM,EAAE,MAAM,EACL,WAAW,EAAE,MAAM,EACnB,MAAM,EAAE,eAAe,EAmBjC;IAED,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAIhC;IAEK,UAAU,CACd,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,oBAAoB,EAC7B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,UAAU,CAAC,CAiBrB;IAED,QAAQ,IAAI,gBAAgB,CAE3B;IAED,UAAU,IAAI,MAAM,GAAG,IAAI,CAE1B;IAMK,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAU/C;IAEK,OAAO,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC,CAEtC;IAEK,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,QAAQ,EAAE,CAAC,CAKvD;IAED,UAAU,IAAI,OAAO,CAAC,SAAS,MAAM,EAAE,CAAC,CAEvC;IAEK,WAAW,IAAI,OAAO,CAAC,SAAS,UAAU,EAAE,CAAC,CAGlD;IAEK,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAIvD;IAEK,UAAU,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAIxC;IAED,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAErB;CACF"}
|
package/dist/engine.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { buildOutlineTree, buildStructTree, fingerprint, PdfEngine, rethrowLoadError, toAttachment, toBytes, toPageLink, toPageText, } from '@build-qube/papyra/core';
|
|
2
|
+
import { convertFileSrc, invoke } from '@tauri-apps/api/core';
|
|
3
|
+
/** papyra's engine reads everything, and so does the host running it. */
|
|
4
|
+
const EVERYTHING = {
|
|
5
|
+
text: true,
|
|
6
|
+
outline: true,
|
|
7
|
+
links: true,
|
|
8
|
+
attachments: true,
|
|
9
|
+
structure: true,
|
|
10
|
+
pageLabels: true,
|
|
11
|
+
annotationsToggle: true,
|
|
12
|
+
};
|
|
13
|
+
/** The plugin's commands, by the name Tauri routes them under. */
|
|
14
|
+
const command = (name) => `plugin:papyra|${name}`;
|
|
15
|
+
/**
|
|
16
|
+
* PDFs parsed and rendered by papyra in the Tauri app's host process, through
|
|
17
|
+
* `tauri-plugin-papyra`.
|
|
18
|
+
*
|
|
19
|
+
* For a Tauri app's WebView, which is never cross-origin isolated on Android or iOS
|
|
20
|
+
* and so cannot run papyra's wasm. Here the work runs on the host's real cores with
|
|
21
|
+
* no wasm at all, and the WebView only paints.
|
|
22
|
+
*
|
|
23
|
+
* The app registers the plugin (`.plugin(tauri_plugin_papyra::init())`) and allows
|
|
24
|
+
* `papyra:default` in its capabilities. Everything papyra's own engine reads, this one
|
|
25
|
+
* does: same parser, same text, same structure tree.
|
|
26
|
+
*
|
|
27
|
+
* Documents live in the host until closed, so close what you open — the viewer's
|
|
28
|
+
* store and file preview do.
|
|
29
|
+
*/
|
|
30
|
+
export class TauriEngine extends PdfEngine {
|
|
31
|
+
id = 'tauri';
|
|
32
|
+
#format;
|
|
33
|
+
constructor(options = {}) {
|
|
34
|
+
super();
|
|
35
|
+
this.#format = options.format ?? 'png';
|
|
36
|
+
}
|
|
37
|
+
availability() {
|
|
38
|
+
if ('__TAURI_INTERNALS__' in globalThis)
|
|
39
|
+
return { ok: true };
|
|
40
|
+
return {
|
|
41
|
+
ok: false,
|
|
42
|
+
title: 'Not running inside a Tauri app',
|
|
43
|
+
reason: 'This engine renders in the app’s host process, through ' +
|
|
44
|
+
'tauri-plugin-papyra, and this page is not in a Tauri WebView.',
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
async load(source, options) {
|
|
48
|
+
const bytes = await toBytes(source);
|
|
49
|
+
let opened;
|
|
50
|
+
try {
|
|
51
|
+
opened = await invoke(command('open'), bytes, {
|
|
52
|
+
headers: options.password === undefined
|
|
53
|
+
? {}
|
|
54
|
+
: // Headers are ASCII; a password need not be.
|
|
55
|
+
{ 'x-papyra-password': encodeURIComponent(options.password) },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
rethrowLoadError(e);
|
|
60
|
+
}
|
|
61
|
+
return new TauriBackend(opened, fingerprint(bytes), this.#format);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* One document held by the host, as a papyra backend.
|
|
66
|
+
*
|
|
67
|
+
* @internal Exported for tests.
|
|
68
|
+
*/
|
|
69
|
+
export class TauriBackend {
|
|
70
|
+
fingerprint;
|
|
71
|
+
format;
|
|
72
|
+
capabilities = EVERYTHING;
|
|
73
|
+
// A fetch can be aborted, but the render in Rust runs on regardless; abandoning it
|
|
74
|
+
// would only make a page scrolled back to render twice.
|
|
75
|
+
abortable = false;
|
|
76
|
+
concurrency = 4;
|
|
77
|
+
#id;
|
|
78
|
+
#sizes;
|
|
79
|
+
#info;
|
|
80
|
+
#version;
|
|
81
|
+
#pages;
|
|
82
|
+
constructor(opened, fingerprint, format) {
|
|
83
|
+
this.fingerprint = fingerprint;
|
|
84
|
+
this.format = format;
|
|
85
|
+
this.#id = opened.id;
|
|
86
|
+
this.#sizes = opened.sizes.map(([width, height]) => ({ width, height }));
|
|
87
|
+
const i = opened.info;
|
|
88
|
+
this.#info = {
|
|
89
|
+
title: i.title ?? null,
|
|
90
|
+
author: i.author ?? null,
|
|
91
|
+
subject: i.subject ?? null,
|
|
92
|
+
keywords: i.keywords ?? null,
|
|
93
|
+
creator: i.creator ?? null,
|
|
94
|
+
producer: i.producer ?? null,
|
|
95
|
+
created: i.created ?? null,
|
|
96
|
+
modified: i.modified ?? null,
|
|
97
|
+
};
|
|
98
|
+
this.#version = opened.pdfVersion ?? null;
|
|
99
|
+
// `papyra://localhost/` on macOS, iOS and Linux, `http://papyra.localhost/` on
|
|
100
|
+
// Android and Windows — Tauri knows which, so ask it rather than sniff.
|
|
101
|
+
this.#pages = `${convertFileSrc('', 'papyra')}${this.#id}/`;
|
|
102
|
+
}
|
|
103
|
+
get pageCount() {
|
|
104
|
+
return this.#sizes.length;
|
|
105
|
+
}
|
|
106
|
+
pageSize(index) {
|
|
107
|
+
const size = this.#sizes[index];
|
|
108
|
+
if (!size)
|
|
109
|
+
throw new RangeError(`page ${index} is out of range`);
|
|
110
|
+
return size;
|
|
111
|
+
}
|
|
112
|
+
async renderPage(index, options, signal) {
|
|
113
|
+
const query = `dpi=${options.dpi}&annots=${options.annotations === false ? 0 : 1}&format=${this.format}`;
|
|
114
|
+
const res = await fetch(`${this.#pages}${index}?${query}`, { signal });
|
|
115
|
+
if (!res.ok)
|
|
116
|
+
throw new Error(await res.text());
|
|
117
|
+
if (this.format === 'png') {
|
|
118
|
+
// Decoded off the main thread.
|
|
119
|
+
return createImageBitmap(await res.blob());
|
|
120
|
+
}
|
|
121
|
+
const width = Number(res.headers.get('x-width'));
|
|
122
|
+
const height = Number(res.headers.get('x-height'));
|
|
123
|
+
return {
|
|
124
|
+
width,
|
|
125
|
+
height,
|
|
126
|
+
stride: width * 4,
|
|
127
|
+
format: 'rgba8',
|
|
128
|
+
data: new Uint8Array(await res.arrayBuffer()),
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
metadata() {
|
|
132
|
+
return this.#info;
|
|
133
|
+
}
|
|
134
|
+
pdfVersion() {
|
|
135
|
+
return this.#version;
|
|
136
|
+
}
|
|
137
|
+
#call(name, args = {}) {
|
|
138
|
+
return invoke(command(name), { id: this.#id, ...args });
|
|
139
|
+
}
|
|
140
|
+
async pageText(index) {
|
|
141
|
+
const text = await this.#call('page_text', { index });
|
|
142
|
+
// JSON carries offsets as numbers; papyra's lines hold a Float32Array.
|
|
143
|
+
return toPageText(index, {
|
|
144
|
+
...text,
|
|
145
|
+
lines: text.lines.map((line) => ({
|
|
146
|
+
...line,
|
|
147
|
+
offsets: Float32Array.from(line.offsets),
|
|
148
|
+
})),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async outline() {
|
|
152
|
+
return buildOutlineTree(await this.#call('outline'));
|
|
153
|
+
}
|
|
154
|
+
async links(index) {
|
|
155
|
+
const links = await this.#call('links', { index });
|
|
156
|
+
return links
|
|
157
|
+
.map(toPageLink)
|
|
158
|
+
.filter((link) => link !== null);
|
|
159
|
+
}
|
|
160
|
+
pageLabels() {
|
|
161
|
+
return this.#call('page_labels');
|
|
162
|
+
}
|
|
163
|
+
async attachments() {
|
|
164
|
+
const files = await this.#call('attachments');
|
|
165
|
+
return files.map(toAttachment);
|
|
166
|
+
}
|
|
167
|
+
async attachmentData(index) {
|
|
168
|
+
return new Uint8Array(await this.#call('attachment_data', { index }));
|
|
169
|
+
}
|
|
170
|
+
async structTree() {
|
|
171
|
+
return buildStructTree(await this.#call('struct_tree'));
|
|
172
|
+
}
|
|
173
|
+
close() {
|
|
174
|
+
return this.#call('close');
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,gBAAgB,EAChB,eAAe,EAGf,WAAW,EAQX,SAAS,EAET,gBAAgB,EAEhB,YAAY,EACZ,OAAO,EACP,UAAU,EACV,UAAU,GACX,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAgC9D,yEAAyE;AACzE,MAAM,UAAU,GAAiB;IAC/B,IAAI,EAAE,IAAI;IACV,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;CACxB,CAAC;AAEF,kEA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AAa,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,WAAW;QACf,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAqB,aAAa,CAAC,CAAC;QAClE,OAAO,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,KAAa;QAChC,OAAO,IAAI,UAAU,CACnB,MAAM,IAAI,CAAC,KAAK,CAAc,iBAAiB,EAAE,EAAE,KAAK,EAAE,CAAC,CAC5D,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,UAAU;QACd,OAAO,eAAe,CACpB,MAAM,IAAI,CAAC,KAAK,CAAsB,aAAa,CAAC,CACrD,CAAC;IACJ,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,KAAK,CAAO,OAAO,CAAC,CAAC;IACnC,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tauri engine for papyra's viewer: PDFs parsed and rendered by papyra in the
|
|
3
|
+
* app's host process, through `tauri-plugin-papyra`.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* import { TauriEngine } from '@build-qube/papyra-tauri';
|
|
7
|
+
* import { PdfEngineProvider } from '@/components/pdf-engine';
|
|
8
|
+
*
|
|
9
|
+
* <PdfEngineProvider engine={new TauriEngine()}>{app}</PdfEngineProvider>
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export { TauriEngine, type TauriEngineOptions, type TauriPageFormat, } from './engine.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,WAAW,EACX,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Tauri engine for papyra's viewer: PDFs parsed and rendered by papyra in the
|
|
3
|
+
* app's host process, through `tauri-plugin-papyra`.
|
|
4
|
+
*
|
|
5
|
+
* ```tsx
|
|
6
|
+
* import { TauriEngine } from '@build-qube/papyra-tauri';
|
|
7
|
+
* import { PdfEngineProvider } from '@/components/pdf-engine';
|
|
8
|
+
*
|
|
9
|
+
* <PdfEngineProvider engine={new TauriEngine()}>{app}</PdfEngineProvider>
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export { TauriEngine, } from './engine.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EACL,WAAW,GAGZ,MAAM,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,49 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@build-qube/papyra-tauri",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.5.0",
|
|
4
|
+
"description": "A Tauri engine for papyra's viewer: PDFs parsed and rendered in the app's host process by tauri-plugin-papyra",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/BuildQube/papyra.git",
|
|
9
|
+
"directory": "packages/tauri"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [
|
|
12
|
+
"pdf",
|
|
13
|
+
"tauri",
|
|
14
|
+
"papyra",
|
|
15
|
+
"viewer",
|
|
16
|
+
"mobile"
|
|
17
|
+
],
|
|
18
|
+
"type": "module",
|
|
19
|
+
"main": "./dist/index.js",
|
|
20
|
+
"types": "./dist/index.d.ts",
|
|
21
|
+
"exports": {
|
|
22
|
+
".": {
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"files": [
|
|
28
|
+
"dist"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"registry": "https://registry.npmjs.org/",
|
|
32
|
+
"access": "public"
|
|
33
|
+
},
|
|
34
|
+
"scripts": {
|
|
35
|
+
"build": "tsc -p tsconfig.json",
|
|
36
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
37
|
+
"clean": "rm -rf dist *.tsbuildinfo",
|
|
38
|
+
"test:integration": "bun test test/integration"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@build-qube/papyra": "^0.5.0",
|
|
42
|
+
"@tauri-apps/api": "^2.0.0"
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@build-qube/papyra": "0.5.0",
|
|
46
|
+
"@tauri-apps/api": "^2.9.0",
|
|
47
|
+
"typescript": "^7.0.2"
|
|
48
|
+
}
|
|
49
|
+
}
|