@rentnerkev/pdf 1.0.0 → 1.0.2
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 +23 -7
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/ai.d.ts +53 -0
- package/dist/ai.d.ts.map +1 -0
- package/dist/ai.js +144 -0
- package/dist/ai.js.map +1 -0
- package/dist/components/Types/props.d.ts +2 -2
- package/dist/components/components.d.ts +5 -5
- package/dist/components/components.d.ts.map +1 -1
- package/dist/components/components.js +16 -16
- package/dist/components/components.js.map +1 -1
- package/dist/components/host.d.ts +2 -2
- package/dist/engine/Types/backend.d.ts +5 -5
- package/dist/engine/Types/engine.d.ts +8 -8
- package/dist/engine/Types/errors.d.ts +2 -2
- package/dist/engine/Types/render-options.d.ts +1 -1
- package/dist/engine/Types/render-result.d.ts +1 -1
- package/dist/engine/abort.d.ts +2 -2
- package/dist/engine/abort.d.ts.map +1 -1
- package/dist/engine/abort.js +2 -2
- package/dist/engine/abort.js.map +1 -1
- package/dist/engine/assets.d.ts +4 -3
- package/dist/engine/assets.d.ts.map +1 -1
- package/dist/engine/assets.js +19 -11
- package/dist/engine/assets.js.map +1 -1
- package/dist/engine/backend.d.ts +5 -5
- package/dist/engine/backend.d.ts.map +1 -1
- package/dist/engine/backend.js +12 -9
- package/dist/engine/backend.js.map +1 -1
- package/dist/engine/backends/native.d.ts +2 -2
- package/dist/engine/backends/wasm.d.ts +2 -2
- package/dist/engine/backends/wasm.d.ts.map +1 -1
- package/dist/engine/backends/wasm.js +12 -4
- package/dist/engine/backends/wasm.js.map +1 -1
- package/dist/engine/channel.d.ts +5 -8
- package/dist/engine/channel.d.ts.map +1 -1
- package/dist/engine/channel.js +71 -43
- package/dist/engine/channel.js.map +1 -1
- package/dist/engine/create-engine.d.ts +1 -1
- package/dist/engine/create-engine.d.ts.map +1 -1
- package/dist/engine/create-engine.js +11 -5
- package/dist/engine/create-engine.js.map +1 -1
- package/dist/engine/default-fonts.d.ts.map +1 -1
- package/dist/engine/default-fonts.js +24 -17
- package/dist/engine/default-fonts.js.map +1 -1
- package/dist/engine/encode.d.ts +5 -4
- package/dist/engine/encode.d.ts.map +1 -1
- package/dist/engine/encode.js +15 -10
- package/dist/engine/encode.js.map +1 -1
- package/dist/engine/errors.d.ts +3 -3
- package/dist/engine/fonts.d.ts +1 -1
- package/dist/engine/markup.d.ts +3 -3
- package/dist/engine/options.d.ts +2 -2
- package/dist/engine/prepare.d.ts +4 -4
- package/dist/engine/render-many.d.ts +3 -3
- package/dist/engine/render-result.d.ts +9 -3
- package/dist/engine/render-result.d.ts.map +1 -1
- package/dist/engine/render-result.js +8 -1
- package/dist/engine/render-result.js.map +1 -1
- package/dist/engine/render-stream.d.ts +1 -1
- package/dist/engine/render.d.ts +3 -3
- package/dist/index.d.ts +24 -24
- package/dist/ir/Types/input.d.ts +1 -1
- package/dist/ir/factories.d.ts +3 -3
- package/dist/ir/factories.d.ts.map +1 -1
- package/dist/ir/factories.js +8 -3
- package/dist/ir/factories.js.map +1 -1
- package/dist/ir/page-variants.d.ts +3 -0
- package/dist/ir/page-variants.d.ts.map +1 -0
- package/dist/ir/page-variants.js +3 -0
- package/dist/ir/page-variants.js.map +1 -0
- package/dist/jsx/Types/context.d.ts +1 -1
- package/dist/jsx/Types/evaluate.d.ts +4 -4
- package/dist/jsx/Types/jsx.d.ts +1 -1
- package/dist/jsx/context.d.ts +1 -1
- package/dist/jsx/element.d.ts +1 -1
- package/dist/jsx/evaluate.d.ts +3 -3
- package/dist/jsx/evaluate.d.ts.map +1 -1
- package/dist/jsx/evaluate.js +20 -52
- package/dist/jsx/evaluate.js.map +1 -1
- package/dist/jsx/source.d.ts +1 -1
- package/dist/jsx-dev-runtime.d.ts +3 -3
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/native/loader.d.ts.map +1 -1
- package/dist/native/loader.js +33 -27
- package/dist/native/loader.js.map +1 -1
- package/dist/native/rentnerpdf.linux-arm64-gnu.node +0 -0
- package/dist/native/rentnerpdf.linux-arm64-musl.node +0 -0
- package/dist/native/rentnerpdf.linux-x64-gnu.node +0 -0
- package/dist/native/rentnerpdf.linux-x64-musl.node +0 -0
- package/dist/native/rentnerpdf.win32-arm64-msvc.node +0 -0
- package/dist/native/rentnerpdf.win32-x64-msvc.node +0 -0
- package/dist/node.d.ts +2 -2
- package/dist/react/Types/preview.d.ts +16 -11
- package/dist/react/Types/preview.d.ts.map +1 -1
- package/dist/react/Types/preview.js.map +1 -1
- package/dist/react/Types/render.d.ts +1 -1
- package/dist/react/components.d.ts +4 -4
- package/dist/react/components.d.ts.map +1 -1
- package/dist/react/components.js +23 -23
- package/dist/react/components.js.map +1 -1
- package/dist/react/pdf-preview.d.ts +3 -2
- package/dist/react/pdf-preview.d.ts.map +1 -1
- package/dist/react/pdf-preview.js +2 -1
- package/dist/react/pdf-preview.js.map +1 -1
- package/dist/react/pdf-render.d.ts +4 -4
- package/dist/react/pdf-render.d.ts.map +1 -1
- package/dist/react/pdf-render.js +20 -12
- package/dist/react/pdf-render.js.map +1 -1
- package/dist/react/registry.d.ts +3 -3
- package/dist/react/registry.d.ts.map +1 -1
- package/dist/react/registry.js +6 -3
- package/dist/react/registry.js.map +1 -1
- package/dist/react/render.d.ts +4 -4
- package/dist/react/render.d.ts.map +1 -1
- package/dist/react/render.js +36 -54
- package/dist/react/render.js.map +1 -1
- package/dist/react/same-document.d.ts +2 -1
- package/dist/react/same-document.d.ts.map +1 -1
- package/dist/react/same-document.js +7 -1
- package/dist/react/same-document.js.map +1 -1
- package/dist/react/static.d.ts +5 -0
- package/dist/react/static.d.ts.map +1 -1
- package/dist/react/static.js +20 -16
- package/dist/react/static.js.map +1 -1
- package/dist/react/use-pdf.d.ts +5 -5
- package/dist/react/use-pdf.d.ts.map +1 -1
- package/dist/react/use-pdf.js +81 -14
- package/dist/react/use-pdf.js.map +1 -1
- package/dist/react.d.ts +8 -8
- package/dist/tailwind-merge.d.ts +2 -2
- package/dist/theme/Types/theme.d.ts +8 -1
- package/dist/theme/Types/theme.d.ts.map +1 -1
- package/dist/theme/Types/theme.js.map +1 -1
- package/dist/theme/css-imports.d.ts +1 -1
- package/dist/theme/normalize.d.ts +2 -2
- package/dist/theme/package-imports.d.ts +1 -8
- package/dist/theme/package-imports.d.ts.map +1 -1
- package/dist/theme/package-imports.js +4 -11
- package/dist/theme/package-imports.js.map +1 -1
- package/dist/theme/paths.d.ts +6 -0
- package/dist/theme/paths.d.ts.map +1 -0
- package/dist/theme/paths.js +13 -0
- package/dist/theme/paths.js.map +1 -0
- package/dist/theme/theme-from-css-file.d.ts +1 -3
- package/dist/theme/theme-from-css-file.d.ts.map +1 -1
- package/dist/theme/theme-from-css-file.js +16 -21
- package/dist/theme/theme-from-css-file.js.map +1 -1
- package/dist/theme/theme-from-css.d.ts +1 -1
- package/dist/theme/warnings.d.ts +1 -4
- package/dist/theme/warnings.d.ts.map +1 -1
- package/dist/theme/warnings.js +1 -1
- package/dist/theme/warnings.js.map +1 -1
- package/dist/vite/plugin.d.ts +3 -6
- package/dist/vite/plugin.d.ts.map +1 -1
- package/dist/vite/plugin.js +17 -7
- package/dist/vite/plugin.js.map +1 -1
- package/dist/vite.d.ts +2 -2
- package/dist/wasm/binding.generated.d.ts +19 -14
- package/dist/wasm/loader.d.ts.map +1 -1
- package/dist/wasm/loader.js +11 -3
- package/dist/wasm/loader.js.map +1 -1
- package/dist/wasm/node-path.d.ts +3 -0
- package/dist/wasm/node-path.d.ts.map +1 -0
- package/dist/wasm/node-path.js +4 -0
- package/dist/wasm/node-path.js.map +1 -0
- package/dist/wasm/pkg/rentnerpdf_wasm.d.ts +19 -14
- package/dist/wasm/pkg/rentnerpdf_wasm.js +39 -75
- package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm.d.ts +8 -7
- package/dist/worker/Types/connection.d.ts +1 -1
- package/dist/worker/Types/protocol.d.ts +2 -2
- package/dist/worker/Types/worker-engine.d.ts +3 -3
- package/dist/worker/client.d.ts +1 -1
- package/dist/worker/client.d.ts.map +1 -1
- package/dist/worker/client.js +10 -10
- package/dist/worker/client.js.map +1 -1
- package/dist/worker/connection.d.ts +2 -2
- package/dist/worker/protocol.d.ts +2 -2
- package/dist/worker/protocol.js.map +1 -1
- package/dist/worker/serve.d.ts +3 -5
- package/dist/worker/serve.d.ts.map +1 -1
- package/dist/worker/serve.js +1 -1
- package/dist/worker/serve.js.map +1 -1
- package/dist/worker.d.ts +3 -3
- package/docs/usage.md +1606 -0
- package/package.json +9 -1
- package/dist/engine/pdf-bytes.d.ts +0 -8
- package/dist/engine/pdf-bytes.d.ts.map +0 -1
- package/dist/engine/pdf-bytes.js +0 -9
- package/dist/engine/pdf-bytes.js.map +0 -1
- package/dist/theme/Types/warnings.d.ts +0 -9
- package/dist/theme/Types/warnings.d.ts.map +0 -1
- package/dist/theme/Types/warnings.js +0 -2
- package/dist/theme/Types/warnings.js.map +0 -1
package/README.md
CHANGED
|
@@ -31,16 +31,16 @@ RentnerPDF is a PDF engine for JavaScript and TypeScript with a Rust core. Descr
|
|
|
31
31
|
|
|
32
32
|
## Performance
|
|
33
33
|
|
|
34
|
-
From the [benchmark report](docs/benchmarks.md): GitHub-hosted Linux runners with 4 vCPUs, Node.js 24,
|
|
34
|
+
From the [benchmark report](docs/benchmarks.md): GitHub-hosted Linux runners with 4 vCPUs, Node.js 24, 03.12.2026, against React-PDF 4.9.2 and pdfmake 0.3.15. The numbers shown passed the same correctness gate.
|
|
35
35
|
|
|
36
36
|
| Focus area | RentnerPDF | pdfmake | React-PDF |
|
|
37
37
|
| --------------------------------------------------- | -------------------- | ------------------- | ------------------- |
|
|
38
|
-
| Mass generation: 10,000 invoices on 4 workers |
|
|
39
|
-
| Event loop while serving invoices: timer drift p99 | 3.
|
|
40
|
-
| 500-page statement, 24,000 rows with running totals |
|
|
41
|
-
| 100-page text report |
|
|
38
|
+
| Mass generation: 10,000 invoices on 4 workers | 943 docs/s, 203 MiB | 75 docs/s, 1.23 GiB | 60 docs/s, 7.59 GiB |
|
|
39
|
+
| Event loop while serving invoices: timer drift p99 | 3.8 ms at 749 PDFs/s | 323 ms at 27 PDFs/s | 457 ms at 20 PDFs/s |
|
|
40
|
+
| 500-page statement, 24,000 rows with running totals | 798 ms, 642 MiB | not supported | not supported |
|
|
41
|
+
| 100-page text report | 108 ms, 204 MiB | 681 ms, 589 MiB | 3.04 s, 1.69 GiB |
|
|
42
42
|
|
|
43
|
-
The report also covers the WebAssembly engine,
|
|
43
|
+
The report also covers the WebAssembly engine, cases where another library wins, and how to reproduce each number.
|
|
44
44
|
|
|
45
45
|
## Requirements
|
|
46
46
|
|
|
@@ -96,9 +96,26 @@ await writeFile('invoice.pdf', pdf)
|
|
|
96
96
|
| [Tailwind support matrix](docs/tailwind-support.md) | Every utility and what it does on paper |
|
|
97
97
|
| [Benchmarks](docs/benchmarks.md) | Every scenario against React-PDF and pdfmake, how to reproduce it; re-measured weekly |
|
|
98
98
|
| [IR versioning](docs/usage.md#ir-versioning) | IR compatibility, validation, and evolution |
|
|
99
|
+
| [Local documentation for tools](docs/usage.md#local-documentation-for-tools) | `@rentnerkev/pdf/ai`: guides and declarations of the installed version for AI agents |
|
|
99
100
|
|
|
100
101
|
The [playground](docs/usage.md#playground) is a local JSX editor with a live PDF preview: `bun run build:wasm`, then `bun run playground:dev`.
|
|
101
102
|
|
|
103
|
+
## AI and MCP access
|
|
104
|
+
|
|
105
|
+
AI agents and local tools read the installed version through `@rentnerkev/pdf/ai`: the README, the usage guide, package metadata and the public TypeScript declarations, without loading an engine or React and without network access. [Local documentation for tools](docs/usage.md#local-documentation-for-tools) shows the five read-only helpers. Keep the entry in Node.js or Bun tooling.
|
|
106
|
+
|
|
107
|
+
The [RentnerPackages website](https://packages.rentner.dev/docs/pdf) also serves the RentnerPDF documentation through a public read-only MCP server and [llms.txt](https://packages.rentner.dev/llms.txt). It needs no account and uses the website's documentation snapshot; prefer the installed `/ai` entry when the versions differ.
|
|
108
|
+
|
|
109
|
+
```json
|
|
110
|
+
{
|
|
111
|
+
"mcpServers": {
|
|
112
|
+
"rentnerPackages": {
|
|
113
|
+
"url": "https://packages.rentner.dev/mcp"
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
102
119
|
## Development
|
|
103
120
|
|
|
104
121
|
Requirements: [Bun](https://bun.com) 1.4.5 and [rustup](https://rustup.rs). The Rust toolchain is pinned in `core/rust-toolchain.toml`.
|
|
@@ -121,7 +138,6 @@ The WebAssembly tests load the local build from `bun run build:wasm` (wasm-bindg
|
|
|
121
138
|
| `core/` | Rust workspace: `rentnerpdf` (engine), `rentnerpdf-napi` (Node-API), `rentnerpdf-wasm` (WebAssembly) |
|
|
122
139
|
| `.github/` | Workflows, automation scripts and their tests |
|
|
123
140
|
| `docs` | Usage guide, migration guides, recipes, Tailwind support matrix, benchmarks |
|
|
124
|
-
| `docs/planning` | Architecture and planning documents |
|
|
125
141
|
|
|
126
142
|
See [CONTRIBUTING](.github/CONTRIBUTING.md) for the full workflow.
|
|
127
143
|
|
package/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Third-party notices
|
|
2
2
|
|
|
3
|
-
RentnerPDF is MIT-licensed (see [LICENSE](LICENSE)). The npm
|
|
3
|
+
RentnerPDF is MIT-licensed (see [LICENSE](LICENSE)). The npm package `@rentnerkev/pdf` ships this notice and the Noto Sans files. Its bundled engines include Tailwind's default theme, hyphenation patterns, tiny-skia-path and the sRGB ICC profiles of PDF/A output intents. Each third-party component is distributed under its own license.
|
|
4
4
|
|
|
5
5
|
## Noto Sans
|
|
6
6
|
|
package/dist/ai.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export interface PackageInfo {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
description: string;
|
|
5
|
+
license: string;
|
|
6
|
+
homepage: string;
|
|
7
|
+
repository: {
|
|
8
|
+
type: string;
|
|
9
|
+
url: string;
|
|
10
|
+
};
|
|
11
|
+
exports: Record<string, string | {
|
|
12
|
+
types?: string;
|
|
13
|
+
import?: string;
|
|
14
|
+
default?: string;
|
|
15
|
+
}>;
|
|
16
|
+
peerDependencies: Record<string, string>;
|
|
17
|
+
}
|
|
18
|
+
export interface PackageDocument {
|
|
19
|
+
path: string;
|
|
20
|
+
content: string;
|
|
21
|
+
}
|
|
22
|
+
export interface PackageApi {
|
|
23
|
+
package: string;
|
|
24
|
+
version: string;
|
|
25
|
+
subpaths: Record<string, string>;
|
|
26
|
+
declarations: PackageDocument[];
|
|
27
|
+
}
|
|
28
|
+
export interface PackageSearchMatch {
|
|
29
|
+
path: string;
|
|
30
|
+
line: number;
|
|
31
|
+
text: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PackageExample {
|
|
34
|
+
language: string;
|
|
35
|
+
code: string;
|
|
36
|
+
}
|
|
37
|
+
/** Read installed-package metadata without importing its UI entry point. */
|
|
38
|
+
export declare function getPackageInfo(): PackageInfo;
|
|
39
|
+
/** Only these two explicitly packaged documents can be read. */
|
|
40
|
+
export declare function getPackageDocumentation(document?: 'readme' | 'usage'): PackageDocument;
|
|
41
|
+
/** Return export entry declarations and their local declaration dependencies.
|
|
42
|
+
* The AI entry itself is excluded. No module is executed and callers cannot
|
|
43
|
+
* supply file paths. Symbols must be exported by a selected public entry.
|
|
44
|
+
*/
|
|
45
|
+
export declare function getPackageApi(options?: {
|
|
46
|
+
subpath?: string;
|
|
47
|
+
symbol?: string;
|
|
48
|
+
}): PackageApi;
|
|
49
|
+
/** Literal, case-insensitive search of the packaged guides. */
|
|
50
|
+
export declare function searchPackageDocumentation(query: string): PackageSearchMatch[];
|
|
51
|
+
/** Code examples come directly from the installed version's usage guide. */
|
|
52
|
+
export declare function getPackageExamples(): PackageExample[];
|
|
53
|
+
//# sourceMappingURL=ai.d.ts.map
|
package/dist/ai.d.ts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B,GACvC,eAAe,CAMjB;AAED;;;GAGG;AACH,wBAAgB,aAAa,CACzB,OAAO,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAO,GACpD,UAAU,CA0GZ;AAED,+DAA+D;AAC/D,wBAAgB,0BAA0B,CACtC,KAAK,EAAE,MAAM,GACd,kBAAkB,EAAE,CAatB;AAED,4EAA4E;AAC5E,wBAAgB,kBAAkB,IAAI,cAAc,EAAE,CASrD"}
|
package/dist/ai.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from 'node:fs';
|
|
2
|
+
import { isAbsolute, relative, sep } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
const packageRoot = new URL('../', import.meta.url);
|
|
5
|
+
/** Read installed-package metadata without importing its UI entry point. */
|
|
6
|
+
export function getPackageInfo() {
|
|
7
|
+
const manifest = JSON.parse(readFileSync(new URL('package.json', packageRoot), 'utf8'));
|
|
8
|
+
return {
|
|
9
|
+
name: manifest.name,
|
|
10
|
+
version: manifest.version,
|
|
11
|
+
description: manifest.description,
|
|
12
|
+
license: manifest.license,
|
|
13
|
+
homepage: manifest.homepage,
|
|
14
|
+
repository: manifest.repository,
|
|
15
|
+
exports: manifest.exports,
|
|
16
|
+
peerDependencies: manifest.peerDependencies,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/** Only these two explicitly packaged documents can be read. */
|
|
20
|
+
export function getPackageDocumentation(document = 'usage') {
|
|
21
|
+
if (document !== 'readme' && document !== 'usage') {
|
|
22
|
+
throw new Error('Unknown package document');
|
|
23
|
+
}
|
|
24
|
+
const path = document === 'readme' ? 'README.md' : 'docs/usage.md';
|
|
25
|
+
return { path, content: readFileSync(new URL(path, packageRoot), 'utf8') };
|
|
26
|
+
}
|
|
27
|
+
/** Return export entry declarations and their local declaration dependencies.
|
|
28
|
+
* The AI entry itself is excluded. No module is executed and callers cannot
|
|
29
|
+
* supply file paths. Symbols must be exported by a selected public entry.
|
|
30
|
+
*/
|
|
31
|
+
export function getPackageApi(options = {}) {
|
|
32
|
+
const info = getPackageInfo();
|
|
33
|
+
const subpaths = {};
|
|
34
|
+
for (const [subpath, entry] of Object.entries(info.exports)) {
|
|
35
|
+
if (subpath !== './ai' && typeof entry !== 'string' && entry.types) {
|
|
36
|
+
subpaths[subpath] = entry.types;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (options.subpath !== undefined &&
|
|
40
|
+
!Object.hasOwn(subpaths, options.subpath)) {
|
|
41
|
+
throw new Error(`Unknown public subpath: ${options.subpath}`);
|
|
42
|
+
}
|
|
43
|
+
if (options.symbol !== undefined &&
|
|
44
|
+
!/^[A-Za-z_$][\w$]*$/.test(options.symbol)) {
|
|
45
|
+
throw new Error('Invalid public symbol');
|
|
46
|
+
}
|
|
47
|
+
const selected = options.subpath === undefined
|
|
48
|
+
? subpaths
|
|
49
|
+
: { [options.subpath]: subpaths[options.subpath] };
|
|
50
|
+
const declarations = new Map();
|
|
51
|
+
const publicNames = new Set();
|
|
52
|
+
const distRoot = new URL('dist/', packageRoot);
|
|
53
|
+
const distPath = realpathSync(distRoot);
|
|
54
|
+
function readDeclaration(path) {
|
|
55
|
+
const url = new URL(path, packageRoot);
|
|
56
|
+
if (!url.href.startsWith(distRoot.href) ||
|
|
57
|
+
!url.pathname.endsWith('.d.ts')) {
|
|
58
|
+
throw new Error('Declaration must remain inside packaged dist');
|
|
59
|
+
}
|
|
60
|
+
const location = relative(distPath, realpathSync(fileURLToPath(url)));
|
|
61
|
+
if (isAbsolute(location) ||
|
|
62
|
+
location === '..' ||
|
|
63
|
+
location.startsWith('..' + sep)) {
|
|
64
|
+
throw new Error('Declaration must remain inside packaged dist');
|
|
65
|
+
}
|
|
66
|
+
const existing = declarations.get(url.href);
|
|
67
|
+
if (existing)
|
|
68
|
+
return existing.content;
|
|
69
|
+
const content = readFileSync(url, 'utf8');
|
|
70
|
+
declarations.set(url.href, {
|
|
71
|
+
path: decodeURIComponent(url.href.slice(packageRoot.href.length)),
|
|
72
|
+
content,
|
|
73
|
+
});
|
|
74
|
+
for (const match of content.matchAll(/(?:from\s*|import\s*\()(['"])(\.[^'"]+)\1/g)) {
|
|
75
|
+
const target = match[2].replace(/\.(?:tsx?|jsx?)$/, '.d.ts');
|
|
76
|
+
readDeclaration(new URL(target, url).href);
|
|
77
|
+
}
|
|
78
|
+
return content;
|
|
79
|
+
}
|
|
80
|
+
const publicEntries = new Set();
|
|
81
|
+
function collectPublicNames(path) {
|
|
82
|
+
const url = new URL(path, packageRoot);
|
|
83
|
+
if (publicEntries.has(url.href))
|
|
84
|
+
return;
|
|
85
|
+
publicEntries.add(url.href);
|
|
86
|
+
const content = readDeclaration(path);
|
|
87
|
+
for (const match of content.matchAll(/export\s+(?:declare\s+)?(?:abstract\s+)?(?:const|let|var|function|class|interface|type|enum)\s+([\w$]+)/g)) {
|
|
88
|
+
publicNames.add(match[1]);
|
|
89
|
+
}
|
|
90
|
+
for (const match of content.matchAll(/export\s+(?:type\s+)?\{([^}]+)\}/g)) {
|
|
91
|
+
for (const item of match[1].split(',')) {
|
|
92
|
+
const name = item
|
|
93
|
+
.trim()
|
|
94
|
+
.replace(/^type\s+/, '')
|
|
95
|
+
.split(/\s+as\s+/)
|
|
96
|
+
.at(-1);
|
|
97
|
+
if (name)
|
|
98
|
+
publicNames.add(name.trim());
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const match of content.matchAll(/export\s+(?:type\s+)?\*\s+as\s+([A-Za-z_$][\w$]*)\s+from\s*['"]/g)) {
|
|
102
|
+
publicNames.add(match[1]);
|
|
103
|
+
}
|
|
104
|
+
for (const match of content.matchAll(/export\s+(?:type\s+)?\*\s+from\s*(['"])(\.[^'"]+)\1/g)) {
|
|
105
|
+
collectPublicNames(new URL(match[2].replace(/\.(?:tsx?|jsx?)$/, '.d.ts'), url)
|
|
106
|
+
.href);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
for (const path of Object.values(selected))
|
|
110
|
+
collectPublicNames(path);
|
|
111
|
+
if (options.symbol !== undefined && !publicNames.has(options.symbol)) {
|
|
112
|
+
throw new Error(`Unknown public symbol: ${options.symbol}`);
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
package: info.name,
|
|
116
|
+
version: info.version,
|
|
117
|
+
subpaths: selected,
|
|
118
|
+
declarations: [...declarations.values()],
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
/** Literal, case-insensitive search of the packaged guides. */
|
|
122
|
+
export function searchPackageDocumentation(query) {
|
|
123
|
+
const needle = query.trim().toLowerCase();
|
|
124
|
+
if (!needle)
|
|
125
|
+
return [];
|
|
126
|
+
return ['readme', 'usage'].flatMap((name) => {
|
|
127
|
+
const document = getPackageDocumentation(name);
|
|
128
|
+
return document.content
|
|
129
|
+
.split('\n')
|
|
130
|
+
.flatMap((text, index) => text.toLowerCase().includes(needle)
|
|
131
|
+
? [{ path: document.path, line: index + 1, text }]
|
|
132
|
+
: []);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
/** Code examples come directly from the installed version's usage guide. */
|
|
136
|
+
export function getPackageExamples() {
|
|
137
|
+
return [
|
|
138
|
+
...getPackageDocumentation().content.matchAll(/```([^\n]*)\n([\s\S]*?)```/g),
|
|
139
|
+
].map((match) => ({
|
|
140
|
+
language: match[1].trim(),
|
|
141
|
+
code: match[2].trimEnd(),
|
|
142
|
+
}));
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=ai.js.map
|
package/dist/ai.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sourceRoot":"","sources":["../web/src/ai.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AACpD,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW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,CAAC,CAAC,EAAE,CACX,CAAA;IACT,CAAC,CAAC,CAAA;AACN,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,kBAAkB;IAC9B,OAAO;QACH,GAAG,uBAAuB,EAAE,CAAC,OAAO,CAAC,QAAQ,CACzC,6BAA6B,CAChC;KACJ,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACd,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,IAAI,EAAE;QAC1B,IAAI,EAAE,KAAK,CAAC,CAAC,CAAE,CAAC,OAAO,EAAE;KAC5B,CAAC,CAAC,CAAA;AACP,CAAC","sourcesContent":["import { readFileSync, realpathSync } from 'node:fs'\nimport { isAbsolute, relative, sep } from 'node:path'\nimport { fileURLToPath } from 'node:url'\n\nexport interface PackageInfo {\n name: string\n version: string\n description: string\n license: string\n homepage: string\n repository: { type: string; url: string }\n exports: Record<\n string,\n string | { types?: string; import?: string; default?: string }\n >\n peerDependencies: Record<string, string>\n}\n\nexport interface PackageDocument {\n path: string\n content: string\n}\n\nexport interface PackageApi {\n package: string\n version: string\n subpaths: Record<string, string>\n declarations: PackageDocument[]\n}\n\nexport interface PackageSearchMatch {\n path: string\n line: number\n text: string\n}\n\nexport interface PackageExample {\n language: string\n code: string\n}\n\nconst packageRoot = new URL('../', import.meta.url)\n\n/** Read installed-package metadata without importing its UI entry point. */\nexport function getPackageInfo(): PackageInfo {\n const manifest = JSON.parse(\n readFileSync(new URL('package.json', packageRoot), 'utf8'),\n ) as PackageInfo\n return {\n name: manifest.name,\n version: manifest.version,\n description: manifest.description,\n license: manifest.license,\n homepage: manifest.homepage,\n repository: manifest.repository,\n exports: manifest.exports,\n peerDependencies: manifest.peerDependencies,\n }\n}\n\n/** Only these two explicitly packaged documents can be read. */\nexport function getPackageDocumentation(\n document: 'readme' | 'usage' = 'usage',\n): PackageDocument {\n if (document !== 'readme' && document !== 'usage') {\n throw new Error('Unknown package document')\n }\n const path = document === 'readme' ? 'README.md' : 'docs/usage.md'\n return { path, content: readFileSync(new URL(path, packageRoot), 'utf8') }\n}\n\n/** Return export entry declarations and their local declaration dependencies.\n * The AI entry itself is excluded. No module is executed and callers cannot\n * supply file paths. Symbols must be exported by a selected public entry.\n */\nexport function getPackageApi(\n options: { subpath?: string; symbol?: string } = {},\n): PackageApi {\n const info = getPackageInfo()\n const subpaths: Record<string, string> = {}\n for (const [subpath, entry] of Object.entries(info.exports)) {\n if (subpath !== './ai' && typeof entry !== 'string' && entry.types) {\n subpaths[subpath] = entry.types\n }\n }\n if (\n options.subpath !== undefined &&\n !Object.hasOwn(subpaths, options.subpath)\n ) {\n throw new Error(`Unknown public subpath: ${options.subpath}`)\n }\n if (\n options.symbol !== undefined &&\n !/^[A-Za-z_$][\\w$]*$/.test(options.symbol)\n ) {\n throw new Error('Invalid public symbol')\n }\n const selected =\n options.subpath === undefined\n ? subpaths\n : { [options.subpath]: subpaths[options.subpath]! }\n const declarations = new Map<string, PackageDocument>()\n const publicNames = new Set<string>()\n const distRoot = new URL('dist/', packageRoot)\n const distPath = realpathSync(distRoot)\n function readDeclaration(path: string): string {\n const url = new URL(path, packageRoot)\n if (\n !url.href.startsWith(distRoot.href) ||\n !url.pathname.endsWith('.d.ts')\n ) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const location = relative(distPath, realpathSync(fileURLToPath(url)))\n if (\n isAbsolute(location) ||\n location === '..' ||\n location.startsWith('..' + sep)\n ) {\n throw new Error('Declaration must remain inside packaged dist')\n }\n const existing = declarations.get(url.href)\n if (existing) return existing.content\n const content = readFileSync(url, 'utf8')\n declarations.set(url.href, {\n path: decodeURIComponent(url.href.slice(packageRoot.href.length)),\n content,\n })\n for (const match of content.matchAll(\n /(?:from\\s*|import\\s*\\()(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n const target = match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts')\n readDeclaration(new URL(target, url).href)\n }\n return content\n }\n const publicEntries = new Set<string>()\n function collectPublicNames(path: string): void {\n const url = new URL(path, packageRoot)\n if (publicEntries.has(url.href)) return\n publicEntries.add(url.href)\n const content = readDeclaration(path)\n for (const match of content.matchAll(\n /export\\s+(?:declare\\s+)?(?:abstract\\s+)?(?:const|let|var|function|class|interface|type|enum)\\s+([\\w$]+)/g,\n )) {\n publicNames.add(match[1]!)\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\{([^}]+)\\}/g,\n )) {\n for (const item of match[1]!.split(',')) {\n const name = item\n .trim()\n .replace(/^type\\s+/, '')\n .split(/\\s+as\\s+/)\n .at(-1)\n if (name) publicNames.add(name.trim())\n }\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\*\\s+as\\s+([A-Za-z_$][\\w$]*)\\s+from\\s*['\"]/g,\n )) {\n publicNames.add(match[1]!)\n }\n for (const match of content.matchAll(\n /export\\s+(?:type\\s+)?\\*\\s+from\\s*(['\"])(\\.[^'\"]+)\\1/g,\n )) {\n collectPublicNames(\n new URL(match[2]!.replace(/\\.(?:tsx?|jsx?)$/, '.d.ts'), url)\n .href,\n )\n }\n }\n for (const path of Object.values(selected)) collectPublicNames(path)\n if (options.symbol !== undefined && !publicNames.has(options.symbol)) {\n throw new Error(`Unknown public symbol: ${options.symbol}`)\n }\n return {\n package: info.name,\n version: info.version,\n subpaths: selected,\n declarations: [...declarations.values()],\n }\n}\n\n/** Literal, case-insensitive search of the packaged guides. */\nexport function searchPackageDocumentation(\n query: string,\n): PackageSearchMatch[] {\n const needle = query.trim().toLowerCase()\n if (!needle) return []\n return (['readme', 'usage'] as const).flatMap((name) => {\n const document = getPackageDocumentation(name)\n return document.content\n .split('\\n')\n .flatMap((text, index) =>\n text.toLowerCase().includes(needle)\n ? [{ path: document.path, line: index + 1, text }]\n : [],\n )\n })\n}\n\n/** Code examples come directly from the installed version's usage guide. */\nexport function getPackageExamples(): PackageExample[] {\n return [\n ...getPackageDocumentation().content.matchAll(\n /```([^\\n]*)\\n([\\s\\S]*?)```/g,\n ),\n ].map((match) => ({\n language: match[1]!.trim(),\n code: match[2]!.trimEnd(),\n }))\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { Dir, FacturX, HeaderScope, TableColumn as IrTableColumn, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign } from '../../ir/ir.generated.
|
|
2
|
-
import type { AttachmentSource, ImageSource, LetterheadInput, SvgSource } from '../../ir/Types/input.
|
|
1
|
+
import type { Dir, FacturX, HeaderScope, TableColumn as IrTableColumn, MarkerSelect, NumberFormat, Orientation, PageNumberFormat, PageNumbering, PageScope, PageSize, Relationship, RunningTotals, Standard, Style, StyleLength, TableTotals, TextAlign } from '../../ir/ir.generated.js';
|
|
2
|
+
import type { AttachmentSource, ImageSource, LetterheadInput, SvgSource } from '../../ir/Types/input.js';
|
|
3
3
|
/**
|
|
4
4
|
* An outline entry (bookmark): a title, `{ title, level }`, or `false` to
|
|
5
5
|
* keep a heading (`role="h1"` … `"h6"`) out of the outline. Headings are
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PdfElement, PdfNode } from '../jsx/Types/element.
|
|
2
|
-
import type { CellProps, DataTableProps, DocumentProps, KeepProps, LinkProps, MarkerProps, PageBreakProps, PageNumberProps, PageProps, RowProps, TableProps, TextProps, TotalPagesProps, ViewProps } from './Types/props.
|
|
1
|
+
import type { PdfElement, PdfNode } from '../jsx/Types/element.js';
|
|
2
|
+
import type { CellProps, DataTableProps, DocumentProps, KeepProps, LinkProps, MarkerProps, PageBreakProps, PageNumberProps, PageProps, RowProps, TableProps, TextProps, TotalPagesProps, ViewProps } from './Types/props.js';
|
|
3
3
|
/** The root of every document: metadata and `Page` children. */
|
|
4
4
|
export declare const Document: (props: DocumentProps<PdfNode>) => PdfElement;
|
|
5
5
|
/**
|
|
@@ -23,14 +23,14 @@ export declare const Text: (props: TextProps<PdfNode>) => PdfElement;
|
|
|
23
23
|
* width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
|
|
24
24
|
* box with both sizes set.
|
|
25
25
|
*/
|
|
26
|
-
export declare const Image: (props: import("./Types/props.
|
|
26
|
+
export declare const Image: (props: import("./Types/props.js").ImageAttributes) => PdfElement;
|
|
27
27
|
/**
|
|
28
28
|
* An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
|
|
29
29
|
* image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
|
|
30
30
|
* container's width, aspect ratio kept. In a box of another aspect ratio it
|
|
31
31
|
* follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
|
|
32
32
|
*/
|
|
33
|
-
export declare const Svg: (props: import("./Types/props.
|
|
33
|
+
export declare const Svg: (props: import("./Types/props.js").SvgAttributes) => PdfElement;
|
|
34
34
|
/**
|
|
35
35
|
* A clickable box around its children (a `View` with `href`): `#id` jumps
|
|
36
36
|
* to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
|
|
@@ -42,7 +42,7 @@ export declare const Link: (props: LinkProps<PdfNode>) => PdfElement;
|
|
|
42
42
|
* `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
|
|
43
43
|
* a target through its own `id` too.
|
|
44
44
|
*/
|
|
45
|
-
export declare const Anchor: (props: import("./Types/props.
|
|
45
|
+
export declare const Anchor: (props: import("./Types/props.js").AnchorAttributes) => PdfElement;
|
|
46
46
|
/**
|
|
47
47
|
* Starts the content that follows it on a new page: an empty box with
|
|
48
48
|
* `break-after-page`. At the end of the content it adds no page.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,KAAK,EAER,SAAS,EACT,cAAc,EACd,aAAa,EAEb,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,SAAS,EAET,QAAQ,EACR,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACZ,MAAM,kBAAkB,CAAA;AAEzB,gEAAgE;AAChE,eAAO,MAAM,QAAQ,+
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,yBAAyB,CAAA;AAElE,OAAO,KAAK,EAER,SAAS,EACT,cAAc,EACd,aAAa,EAEb,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,SAAS,EAET,QAAQ,EACR,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACZ,MAAM,kBAAkB,CAAA;AAEzB,gEAAgE;AAChE,eAAO,MAAM,QAAQ,+CAAyD,CAAA;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE,oDAAoD;AACpD,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;;GAKG;AACH,eAAO,MAAM,KAAK,mEAA0C,CAAA;AAE5D;;;;;GAKG;AACH,eAAO,MAAM,GAAG,iEAAsC,CAAA;AAEtD;;;;GAIG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,MAAM,oEAA4C,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,SAAS,uCAAkD,CAAA;AAExE;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA;AAElE;;;;;;;GAOG;AACH,eAAO,MAAM,KAAK,EAEJ,CAAC,GAAG,SAAS,MAAM,EAC7B,KAAK,EAAE,UAAU,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,KAC/C,UAAU,CAAA;AAEf;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAoD,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,UAAU,wCAAoD,CAAA;AAE3E;;;GAGG;AACH,eAAO,MAAM,MAAM,oCAA4C,CAAA;AAE/D,oEAAoE;AACpE,eAAO,MAAM,GAAG,0CAA+C,CAAA;AAE/D;;;GAGG;AACH,eAAO,MAAM,IAAI,2CAAiD,CAAA"}
|
|
@@ -1,57 +1,57 @@
|
|
|
1
1
|
import { host } from './host.js';
|
|
2
2
|
/** The root of every document: metadata and `Page` children. */
|
|
3
|
-
export const Document = host('Document');
|
|
3
|
+
export const Document = /*#__PURE__*/ host('Document');
|
|
4
4
|
/**
|
|
5
5
|
* A page template: size, orientation, page box styling (`p-page` for
|
|
6
6
|
* margins), a `header` and `footer` on every page with `first`, `odd`,
|
|
7
7
|
* `even` and `last` variants, and `numbering`. Content that does not fit
|
|
8
8
|
* continues on further pages of the template.
|
|
9
9
|
*/
|
|
10
|
-
export const Page = host('Page');
|
|
10
|
+
export const Page = /*#__PURE__*/ host('Page');
|
|
11
11
|
/** A generic box: block, flex or grid container. */
|
|
12
|
-
export const View = host('View');
|
|
12
|
+
export const View = /*#__PURE__*/ host('View');
|
|
13
13
|
/**
|
|
14
14
|
* A paragraph of text; its string and number children are concatenated,
|
|
15
15
|
* and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
|
|
16
16
|
* per page.
|
|
17
17
|
*/
|
|
18
|
-
export const Text = host('Text');
|
|
18
|
+
export const Text = /*#__PURE__*/ host('Text');
|
|
19
19
|
/**
|
|
20
20
|
* A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
|
|
21
21
|
* `<img>` with Tailwind's preflight: natural size, at most the container's
|
|
22
22
|
* width, aspect ratio kept; `object-contain`/`object-cover` fit it into a
|
|
23
23
|
* box with both sizes set.
|
|
24
24
|
*/
|
|
25
|
-
export const Image = host('Image');
|
|
25
|
+
export const Image = /*#__PURE__*/ host('Image');
|
|
26
26
|
/**
|
|
27
27
|
* An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an
|
|
28
28
|
* image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the
|
|
29
29
|
* container's width, aspect ratio kept. In a box of another aspect ratio it
|
|
30
30
|
* follows its `preserveAspectRatio` unless `object-*` classes say otherwise.
|
|
31
31
|
*/
|
|
32
|
-
export const Svg = host('Svg');
|
|
32
|
+
export const Svg = /*#__PURE__*/ host('Svg');
|
|
33
33
|
/**
|
|
34
34
|
* A clickable box around its children (a `View` with `href`): `#id` jumps
|
|
35
35
|
* to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs
|
|
36
36
|
* open in the viewer's application. Every page fragment is clickable.
|
|
37
37
|
*/
|
|
38
|
-
export const Link = host('Link');
|
|
38
|
+
export const Link = /*#__PURE__*/ host('Link');
|
|
39
39
|
/**
|
|
40
40
|
* An invisible link target: `<Anchor id="terms" />` is where
|
|
41
41
|
* `<Link href="#terms">` jumps. Any `View`, `Text`, `Image` or `Svg` can be
|
|
42
42
|
* a target through its own `id` too.
|
|
43
43
|
*/
|
|
44
|
-
export const Anchor = host('Anchor');
|
|
44
|
+
export const Anchor = /*#__PURE__*/ host('Anchor');
|
|
45
45
|
/**
|
|
46
46
|
* Starts the content that follows it on a new page: an empty box with
|
|
47
47
|
* `break-after-page`. At the end of the content it adds no page.
|
|
48
48
|
*/
|
|
49
|
-
export const PageBreak = host('PageBreak');
|
|
49
|
+
export const PageBreak = /*#__PURE__*/ host('PageBreak');
|
|
50
50
|
/**
|
|
51
51
|
* Keeps its children together on one page when they fit on one: a box with
|
|
52
52
|
* `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
|
|
53
53
|
*/
|
|
54
|
-
export const Keep = host('Keep');
|
|
54
|
+
export const Keep = /*#__PURE__*/ host('Keep');
|
|
55
55
|
/**
|
|
56
56
|
* A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,
|
|
57
57
|
* percentages) and the cells' content, split between rows across pages
|
|
@@ -60,27 +60,27 @@ export const Keep = host('Keep');
|
|
|
60
60
|
* With `data` and `columns` it is a data-driven table: one row per item,
|
|
61
61
|
* cells rendered natively from compact column data (large tables).
|
|
62
62
|
*/
|
|
63
|
-
export const Table = host('Table');
|
|
63
|
+
export const Table = /*#__PURE__*/ host('Table');
|
|
64
64
|
/**
|
|
65
65
|
* The number of the page the text is on, inside a `Text`: counted from 1
|
|
66
66
|
* over the document unless a `Page` sets `numbering`.
|
|
67
67
|
*/
|
|
68
|
-
export const PageNumber = host('PageNumber');
|
|
68
|
+
export const PageNumber = /*#__PURE__*/ host('PageNumber');
|
|
69
69
|
/**
|
|
70
70
|
* The number of pages of the document (or of the page template with
|
|
71
71
|
* `scope="section"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.
|
|
72
72
|
*/
|
|
73
|
-
export const TotalPages = host('TotalPages');
|
|
73
|
+
export const TotalPages = /*#__PURE__*/ host('TotalPages');
|
|
74
74
|
/**
|
|
75
75
|
* The value of a running marker on the page, inside a `Text`, for example
|
|
76
76
|
* the current chapter in a header: nodes set it with their `marker` prop.
|
|
77
77
|
*/
|
|
78
|
-
export const Marker = host('Marker');
|
|
78
|
+
export const Marker = /*#__PURE__*/ host('Marker');
|
|
79
79
|
/** A table row; `header` and `footer` rows repeat on every page. */
|
|
80
|
-
export const Row = host('Row');
|
|
80
|
+
export const Row = /*#__PURE__*/ host('Row');
|
|
81
81
|
/**
|
|
82
82
|
* A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
|
|
83
83
|
* numbers become its text; `value` cells show a number in minor units.
|
|
84
84
|
*/
|
|
85
|
-
export const Cell = host('Cell');
|
|
85
|
+
export const Cell = /*#__PURE__*/ host('Cell');
|
|
86
86
|
//# sourceMappingURL=components.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../web/src/components/components.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAqBhC,g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M,CAAA;AAEf;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC,IAAI,CAAkB,YAAY,CAAC,CAAA;AAE3E;;;GAGG;AACH,MAAM,CAAC,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,CAAc,QAAQ,CAAC,CAAA;AAE/D,oEAAoE;AACpE,MAAM,CAAC,MAAM,GAAG,GAAG,aAAa,CAAC,IAAI,CAAoB,KAAK,CAAC,CAAA;AAE/D;;;GAGG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,aAAa,CAAC,IAAI,CAAqB,MAAM,CAAC,CAAA","sourcesContent":["import type { PdfElement, PdfNode } from '../jsx/Types/element.ts'\nimport { host } from './host.ts'\nimport type {\n AnchorProps,\n CellProps,\n DataTableProps,\n DocumentProps,\n ImageProps,\n KeepProps,\n LinkProps,\n MarkerProps,\n PageBreakProps,\n PageNumberProps,\n PageProps,\n SvgProps,\n RowProps,\n TableProps,\n TextProps,\n TotalPagesProps,\n ViewProps,\n} from './Types/props.ts'\n\n/** The root of every document: metadata and `Page` children. */\nexport const Document = /*#__PURE__*/ host<DocumentProps<PdfNode>>('Document')\n\n/**\n * A page template: size, orientation, page box styling (`p-page` for\n * margins), a `header` and `footer` on every page with `first`, `odd`,\n * `even` and `last` variants, and `numbering`. Content that does not fit\n * continues on further pages of the template.\n */\nexport const Page = /*#__PURE__*/ host<PageProps<PdfNode>>('Page')\n\n/** A generic box: block, flex or grid container. */\nexport const View = /*#__PURE__*/ host<ViewProps<PdfNode>>('View')\n\n/**\n * A paragraph of text; its string and number children are concatenated,\n * and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in\n * per page.\n */\nexport const Text = /*#__PURE__*/ host<TextProps<PdfNode>>('Text')\n\n/**\n * A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML\n * `<img>` with Tailwind's preflight: natural size, at most the container's\n * width, aspect ratio kept; `object-contain`/`object-cover` fit it into a\n * box with both sizes set.\n */\nexport const Image = /*#__PURE__*/ host<ImageProps>('Image')\n\n/**\n * An SVG drawn as vectors, from markup or `.svg` bytes. It sizes like an\n * image: its `width`/`height` (or `viewBox`) in CSS pixels, at most the\n * container's width, aspect ratio kept. In a box of another aspect ratio it\n * follows its `preserveAspectRatio` unless `object-*` classes say otherwise.\n */\nexport const Svg = /*#__PURE__*/ host<SvgProps>('Svg')\n\n/**\n * A clickable box around its children (a `View` with `href`): `#id` jumps\n * to the node with that `id`, `https:`, `http:`, `mailto:` and `tel:` URIs\n * open in the viewer's application. Every page fragment is clickable.\n */\nexport const Link = /*#__PURE__*/ host<LinkProps<PdfNode>>('Link')\n\n/**\n * An invisible link target: `<Anchor id=\"terms\" />` is where\n * `<Link href=\"#terms\">` jumps. Any `View`, `Text`, `Image` or `Svg` can be\n * a target through its own `id` too.\n */\nexport const Anchor = /*#__PURE__*/ host<AnchorProps>('Anchor')\n\n/**\n * Starts the content that follows it on a new page: an empty box with\n * `break-after-page`. At the end of the content it adds no page.\n */\nexport const PageBreak = /*#__PURE__*/ host<PageBreakProps>('PageBreak')\n\n/**\n * Keeps its children together on one page when they fit on one: a box with\n * `break-inside-avoid`, plus `break-after-avoid` with `withNext`.\n */\nexport const Keep = /*#__PURE__*/ host<KeepProps<PdfNode>>('Keep')\n\n/**\n * A table of `Row`s: columns sized from `columns` (`auto`, `fr`, lengths,\n * percentages) and the cells' content, split between rows across pages\n * with header and footer rows repeated and optional running totals.\n *\n * With `data` and `columns` it is a data-driven table: one row per item,\n * cells rendered natively from compact column data (large tables).\n */\nexport const Table = /*#__PURE__*/ host<\n TableProps<PdfNode> | DataTableProps<object>\n>('Table') as <Row extends object>(\n props: TableProps<PdfNode> | DataTableProps<Row>,\n) => PdfElement\n\n/**\n * The number of the page the text is on, inside a `Text`: counted from 1\n * over the document unless a `Page` sets `numbering`.\n */\nexport const PageNumber = /*#__PURE__*/ host<PageNumberProps>('PageNumber')\n\n/**\n * The number of pages of the document (or of the page template with\n * `scope=\"section\"`), inside a `Text`: `Page <PageNumber /> of <TotalPages />`.\n */\nexport const TotalPages = /*#__PURE__*/ host<TotalPagesProps>('TotalPages')\n\n/**\n * The value of a running marker on the page, inside a `Text`, for example\n * the current chapter in a header: nodes set it with their `marker` prop.\n */\nexport const Marker = /*#__PURE__*/ host<MarkerProps>('Marker')\n\n/** A table row; `header` and `footer` rows repeat on every page. */\nexport const Row = /*#__PURE__*/ host<RowProps<PdfNode>>('Row')\n\n/**\n * A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and\n * numbers become its text; `value` cells show a number in minor units.\n */\nexport const Cell = /*#__PURE__*/ host<CellProps<PdfNode>>('Cell')\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { PdfElement } from '../jsx/Types/element.
|
|
2
|
-
import type { HostName } from './Types/host.
|
|
1
|
+
import type { PdfElement } from '../jsx/Types/element.js';
|
|
2
|
+
import type { HostName } from './Types/host.js';
|
|
3
3
|
/** Creates a built-in component; rendering builds its IR node from the props. */
|
|
4
4
|
export declare function host<P>(name: HostName): (props: P) => PdfElement;
|
|
5
5
|
/** Returns the built-in component's name, or `undefined` for other types. */
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { BackendTheme } from '../../theme/Types/theme.
|
|
2
|
-
import type { DataChannel } from '../channel.
|
|
3
|
-
import type { Limits } from './limits.
|
|
4
|
-
import type { EngineStats } from './render-options.
|
|
5
|
-
import type { RenderWarning } from './render-result.
|
|
1
|
+
import type { BackendTheme } from '../../theme/Types/theme.js';
|
|
2
|
+
import type { DataChannel } from '../channel.js';
|
|
3
|
+
import type { Limits } from './limits.js';
|
|
4
|
+
import type { EngineStats } from './render-options.js';
|
|
5
|
+
import type { RenderWarning } from './render-result.js';
|
|
6
6
|
/** The engine implementations: the Node-API addon or the WebAssembly build. */
|
|
7
7
|
export type BackendName = 'native' | 'wasm';
|
|
8
8
|
/**
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference lib="esnext.disposable" preserve="true" />
|
|
2
|
-
import type { DocumentInput } from '../../ir/Types/input.
|
|
3
|
-
import type { ThemeInput } from '../../theme/Types/theme.
|
|
4
|
-
import type { PdfElement } from '../../jsx/Types/element.
|
|
5
|
-
import type { WasmModuleSource } from '../../wasm/loader.
|
|
6
|
-
import type { BackendChoice, BackendName } from './backend.
|
|
7
|
-
import type { LimitsInput } from './limits.
|
|
8
|
-
import type { BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions } from './render-options.
|
|
9
|
-
import type { PdfBytes, RenderResult, RenderWarning } from './render-result.
|
|
2
|
+
import type { DocumentInput } from '../../ir/Types/input.js';
|
|
3
|
+
import type { ThemeInput } from '../../theme/Types/theme.js';
|
|
4
|
+
import type { PdfElement } from '../../jsx/Types/element.js';
|
|
5
|
+
import type { WasmModuleSource } from '../../wasm/loader.js';
|
|
6
|
+
import type { BackendChoice, BackendName } from './backend.js';
|
|
7
|
+
import type { LimitsInput } from './limits.js';
|
|
8
|
+
import type { BatchOptions, BatchRendered, BatchResult, EngineStats, RenderOptions } from './render-options.js';
|
|
9
|
+
import type { PdfBytes, RenderResult, RenderWarning } from './render-result.js';
|
|
10
10
|
/**
|
|
11
11
|
* What the engine renders: a JSX element (evaluated to the IR first; its root
|
|
12
12
|
* must render a `Document`) or an IR document, for example from the
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { SourceLocation } from '../../jsx/Types/element.
|
|
2
|
-
import type { RentnerPdfWarningCode } from './render-result.
|
|
1
|
+
import type { SourceLocation } from '../../jsx/Types/element.js';
|
|
2
|
+
import type { RentnerPdfWarningCode } from './render-result.js';
|
|
3
3
|
/**
|
|
4
4
|
* Stable error codes shared with the Rust engine (`rentnerpdf::ErrorCode`).
|
|
5
5
|
* `ENGINE_CLOSED` is a call to an engine after its `close()`.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SourceLocation } from '../../jsx/Types/element.
|
|
1
|
+
import type { SourceLocation } from '../../jsx/Types/element.js';
|
|
2
2
|
/**
|
|
3
3
|
* Stable warning codes shared with the Rust engine (`rentnerpdf::WarningCode`).
|
|
4
4
|
* With `strict: true`, `UNKNOWN_CLASS`, `INVALID_VALUE` and `UNSUPPORTED_CLASS`
|
package/dist/engine/abort.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RentnerPdfError } from './errors.
|
|
1
|
+
import { RentnerPdfError } from './errors.js';
|
|
2
2
|
/** The `ABORTED` error for an abort `reason`; an `ABORTED` reason is kept. */
|
|
3
3
|
export declare const abortedError: (reason: unknown) => RentnerPdfError;
|
|
4
4
|
/** Throws the `ABORTED` error when `signal` has aborted. */
|
|
@@ -19,5 +19,5 @@ export interface Deadline {
|
|
|
19
19
|
* The timer is ref'd: a render that never finishes fails instead of
|
|
20
20
|
* letting the process exit with an unsettled promise.
|
|
21
21
|
*/
|
|
22
|
-
export declare function deadline(signal: AbortSignal | undefined, timeoutMs: number | undefined): Deadline;
|
|
22
|
+
export declare function deadline(signal: AbortSignal | undefined, timeoutMs: number | undefined, subject?: string): Deadline;
|
|
23
23
|
//# sourceMappingURL=abort.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../web/src/engine/abort.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,YAAY,WAAY,OAAO,KAAG,eAKnC,CAAA;AAEZ,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEpE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,GAChC,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACpB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,
|
|
1
|
+
{"version":3,"file":"abort.d.ts","sourceRoot":"","sources":["../../web/src/engine/abort.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAE7C,8EAA8E;AAC9E,eAAO,MAAM,YAAY,WAAY,OAAO,KAAG,eAKnC,CAAA;AAEZ,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,GAAG,IAAI,CAEpE;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,CAAC,EAC7B,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EACnB,MAAM,EAAE,WAAW,GAAG,SAAS,GAChC,OAAO,CAAC,CAAC,CAAC,CAiBZ;AAED,4EAA4E;AAC5E,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAA;IAC5B,wDAAwD;IACxD,KAAK,IAAI,IAAI,CAAA;CAChB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CACpB,MAAM,EAAE,WAAW,GAAG,SAAS,EAC/B,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,OAAO,SAAe,GACvB,QAAQ,CA0BV"}
|
package/dist/engine/abort.js
CHANGED
|
@@ -43,7 +43,7 @@ export async function raceAbort(promise, signal) {
|
|
|
43
43
|
* The timer is ref'd: a render that never finishes fails instead of
|
|
44
44
|
* letting the process exit with an unsettled promise.
|
|
45
45
|
*/
|
|
46
|
-
export function deadline(signal, timeoutMs) {
|
|
46
|
+
export function deadline(signal, timeoutMs, subject = 'the render') {
|
|
47
47
|
const controller = new AbortController();
|
|
48
48
|
const abort = (reason) => {
|
|
49
49
|
if (!controller.signal.aborted)
|
|
@@ -57,7 +57,7 @@ export function deadline(signal, timeoutMs) {
|
|
|
57
57
|
const timer = timeoutMs === undefined
|
|
58
58
|
? undefined
|
|
59
59
|
: setTimeout(() => {
|
|
60
|
-
abort(new RentnerPdfError('ABORTED',
|
|
60
|
+
abort(new RentnerPdfError('ABORTED', `${subject} did not finish within ${timeoutMs} ms (timeoutMs)`));
|
|
61
61
|
}, timeoutMs);
|
|
62
62
|
return {
|
|
63
63
|
signal: controller.signal,
|