@rentnerkev/pdf 0.0.0-stage → 0.1.1
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/LICENSE +21 -0
- package/README.md +135 -2
- package/THIRD_PARTY_NOTICES.md +152 -0
- package/dist/components/Types/host.d.ts +3 -0
- package/dist/components/Types/host.d.ts.map +1 -0
- package/dist/components/Types/host.js +2 -0
- package/dist/components/Types/host.js.map +1 -0
- package/dist/components/Types/props.d.ts +504 -0
- package/dist/components/Types/props.d.ts.map +1 -0
- package/dist/components/Types/props.js +2 -0
- package/dist/components/Types/props.js.map +1 -0
- package/dist/components/components.d.ts +87 -0
- package/dist/components/components.d.ts.map +1 -0
- package/dist/components/components.js +86 -0
- package/dist/components/components.js.map +1 -0
- package/dist/components/host.d.ts +7 -0
- package/dist/components/host.d.ts.map +1 -0
- package/dist/components/host.js +15 -0
- package/dist/components/host.js.map +1 -0
- package/dist/engine/Types/backend.d.ts +120 -0
- package/dist/engine/Types/backend.d.ts.map +1 -0
- package/dist/engine/Types/backend.js +2 -0
- package/dist/engine/Types/backend.js.map +1 -0
- package/dist/engine/Types/engine.d.ts +192 -0
- package/dist/engine/Types/engine.d.ts.map +1 -0
- package/dist/engine/Types/engine.js +2 -0
- package/dist/engine/Types/engine.js.map +1 -0
- package/dist/engine/Types/errors.d.ts +16 -0
- package/dist/engine/Types/errors.d.ts.map +1 -0
- package/dist/engine/Types/errors.js +2 -0
- package/dist/engine/Types/errors.js.map +1 -0
- package/dist/engine/Types/limits.d.ts +55 -0
- package/dist/engine/Types/limits.d.ts.map +1 -0
- package/dist/engine/Types/limits.js +2 -0
- package/dist/engine/Types/limits.js.map +1 -0
- package/dist/engine/Types/render-options.d.ts +71 -0
- package/dist/engine/Types/render-options.d.ts.map +1 -0
- package/dist/engine/Types/render-options.js +2 -0
- package/dist/engine/Types/render-options.js.map +1 -0
- package/dist/engine/Types/render-result.d.ts +80 -0
- package/dist/engine/Types/render-result.d.ts.map +1 -0
- package/dist/engine/Types/render-result.js +2 -0
- package/dist/engine/Types/render-result.js.map +1 -0
- package/dist/engine/abort.d.ts +23 -0
- package/dist/engine/abort.d.ts.map +1 -0
- package/dist/engine/abort.js +71 -0
- package/dist/engine/abort.js.map +1 -0
- package/dist/engine/assets.d.ts +22 -0
- package/dist/engine/assets.d.ts.map +1 -0
- package/dist/engine/assets.js +40 -0
- package/dist/engine/assets.js.map +1 -0
- package/dist/engine/backend.d.ts +16 -0
- package/dist/engine/backend.d.ts.map +1 -0
- package/dist/engine/backend.js +43 -0
- package/dist/engine/backend.js.map +1 -0
- package/dist/engine/backends/native.d.ts +11 -0
- package/dist/engine/backends/native.d.ts.map +1 -0
- package/dist/engine/backends/native.js +62 -0
- package/dist/engine/backends/native.js.map +1 -0
- package/dist/engine/backends/wasm.d.ts +16 -0
- package/dist/engine/backends/wasm.d.ts.map +1 -0
- package/dist/engine/backends/wasm.js +216 -0
- package/dist/engine/backends/wasm.js.map +1 -0
- package/dist/engine/channel.d.ts +41 -0
- package/dist/engine/channel.d.ts.map +1 -0
- package/dist/engine/channel.js +140 -0
- package/dist/engine/channel.js.map +1 -0
- package/dist/engine/create-engine.d.ts +8 -0
- package/dist/engine/create-engine.d.ts.map +1 -0
- package/dist/engine/create-engine.js +120 -0
- package/dist/engine/create-engine.js.map +1 -0
- package/dist/engine/default-fonts.d.ts +9 -0
- package/dist/engine/default-fonts.d.ts.map +1 -0
- package/dist/engine/default-fonts.js +42 -0
- package/dist/engine/default-fonts.js.map +1 -0
- package/dist/engine/encode.d.ts +9 -0
- package/dist/engine/encode.d.ts.map +1 -0
- package/dist/engine/encode.js +199 -0
- package/dist/engine/encode.js.map +1 -0
- package/dist/engine/errors.d.ts +37 -0
- package/dist/engine/errors.d.ts.map +1 -0
- package/dist/engine/errors.js +71 -0
- package/dist/engine/errors.js.map +1 -0
- package/dist/engine/fonts.d.ts +9 -0
- package/dist/engine/fonts.d.ts.map +1 -0
- package/dist/engine/fonts.js +14 -0
- package/dist/engine/fonts.js.map +1 -0
- package/dist/engine/lifecycle.d.ts +40 -0
- package/dist/engine/lifecycle.d.ts.map +1 -0
- package/dist/engine/lifecycle.js +104 -0
- package/dist/engine/lifecycle.js.map +1 -0
- package/dist/engine/markup.d.ts +13 -0
- package/dist/engine/markup.d.ts.map +1 -0
- package/dist/engine/markup.js +14 -0
- package/dist/engine/markup.js.map +1 -0
- package/dist/engine/options.d.ts +12 -0
- package/dist/engine/options.d.ts.map +1 -0
- package/dist/engine/options.js +71 -0
- package/dist/engine/options.js.map +1 -0
- package/dist/engine/pdf-bytes.d.ts +8 -0
- package/dist/engine/pdf-bytes.d.ts.map +1 -0
- package/dist/engine/pdf-bytes.js +9 -0
- package/dist/engine/pdf-bytes.js.map +1 -0
- package/dist/engine/prepare.d.ts +17 -0
- package/dist/engine/prepare.d.ts.map +1 -0
- package/dist/engine/prepare.js +44 -0
- package/dist/engine/prepare.js.map +1 -0
- package/dist/engine/render-many.d.ts +14 -0
- package/dist/engine/render-many.d.ts.map +1 -0
- package/dist/engine/render-many.js +156 -0
- package/dist/engine/render-many.js.map +1 -0
- package/dist/engine/render-result.d.ts +12 -0
- package/dist/engine/render-result.d.ts.map +1 -0
- package/dist/engine/render-result.js +62 -0
- package/dist/engine/render-result.js.map +1 -0
- package/dist/engine/render-stream.d.ts +7 -0
- package/dist/engine/render-stream.d.ts.map +1 -0
- package/dist/engine/render-stream.js +56 -0
- package/dist/engine/render-stream.js.map +1 -0
- package/dist/engine/render.d.ts +15 -0
- package/dist/engine/render.d.ts.map +1 -0
- package/dist/engine/render.js +23 -0
- package/dist/engine/render.js.map +1 -0
- package/dist/fonts/NotoSans-Bold.ttf +0 -0
- package/dist/fonts/NotoSans-BoldItalic.ttf +0 -0
- package/dist/fonts/NotoSans-Italic.ttf +0 -0
- package/dist/fonts/NotoSans-Regular.ttf +0 -0
- package/dist/fonts/OFL.txt +94 -0
- package/dist/fonts/sources.json +32 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -0
- package/dist/ir/Types/input.d.ts +111 -0
- package/dist/ir/Types/input.d.ts.map +1 -0
- package/dist/ir/Types/input.js +2 -0
- package/dist/ir/Types/input.js.map +1 -0
- package/dist/ir/factories.d.ts +108 -0
- package/dist/ir/factories.d.ts.map +1 -0
- package/dist/ir/factories.js +410 -0
- package/dist/ir/factories.js.map +1 -0
- package/dist/ir/ir.generated.d.ts +811 -0
- package/dist/ir/ir.generated.d.ts.map +1 -0
- package/dist/ir/ir.generated.js +4 -0
- package/dist/ir/ir.generated.js.map +1 -0
- package/dist/ir/version.d.ts +9 -0
- package/dist/ir/version.d.ts.map +1 -0
- package/dist/ir/version.js +13 -0
- package/dist/ir/version.js.map +1 -0
- package/dist/jsx/Types/context.d.ts +24 -0
- package/dist/jsx/Types/context.d.ts.map +1 -0
- package/dist/jsx/Types/context.js +2 -0
- package/dist/jsx/Types/context.js.map +1 -0
- package/dist/jsx/Types/element.d.ts +30 -0
- package/dist/jsx/Types/element.d.ts.map +1 -0
- package/dist/jsx/Types/element.js +2 -0
- package/dist/jsx/Types/element.js.map +1 -0
- package/dist/jsx/Types/evaluate.d.ts +61 -0
- package/dist/jsx/Types/evaluate.d.ts.map +1 -0
- package/dist/jsx/Types/evaluate.js +2 -0
- package/dist/jsx/Types/evaluate.js.map +1 -0
- package/dist/jsx/Types/jsx.d.ts +16 -0
- package/dist/jsx/Types/jsx.d.ts.map +1 -0
- package/dist/jsx/Types/jsx.js +2 -0
- package/dist/jsx/Types/jsx.js.map +1 -0
- package/dist/jsx/context.d.ts +21 -0
- package/dist/jsx/context.d.ts.map +1 -0
- package/dist/jsx/context.js +49 -0
- package/dist/jsx/context.js.map +1 -0
- package/dist/jsx/element.d.ts +10 -0
- package/dist/jsx/element.d.ts.map +1 -0
- package/dist/jsx/element.js +19 -0
- package/dist/jsx/element.js.map +1 -0
- package/dist/jsx/evaluate.d.ts +16 -0
- package/dist/jsx/evaluate.d.ts.map +1 -0
- package/dist/jsx/evaluate.js +616 -0
- package/dist/jsx/evaluate.js.map +1 -0
- package/dist/jsx/source.d.ts +13 -0
- package/dist/jsx/source.d.ts.map +1 -0
- package/dist/jsx/source.js +49 -0
- package/dist/jsx/source.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +9 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +24 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +12 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +15 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/native/binding.generated.d.ts +227 -0
- package/dist/native/loader.d.ts +22 -0
- package/dist/native/loader.d.ts.map +1 -0
- package/dist/native/loader.js +98 -0
- package/dist/native/loader.js.map +1 -0
- 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 +3 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +6 -0
- package/dist/node.js.map +1 -0
- package/dist/react/Types/preview.d.ts +74 -0
- package/dist/react/Types/preview.d.ts.map +1 -0
- package/dist/react/Types/preview.js +2 -0
- package/dist/react/Types/preview.js.map +1 -0
- package/dist/react/Types/render.d.ts +24 -0
- package/dist/react/Types/render.d.ts.map +1 -0
- package/dist/react/Types/render.js +2 -0
- package/dist/react/Types/render.js.map +1 -0
- package/dist/react/attributes.d.ts +8 -0
- package/dist/react/attributes.d.ts.map +1 -0
- package/dist/react/attributes.js +44 -0
- package/dist/react/attributes.js.map +1 -0
- package/dist/react/components.d.ts +60 -0
- package/dist/react/components.d.ts.map +1 -0
- package/dist/react/components.js +266 -0
- package/dist/react/components.js.map +1 -0
- package/dist/react/pdf-preview.d.ts +16 -0
- package/dist/react/pdf-preview.d.ts.map +1 -0
- package/dist/react/pdf-preview.js +26 -0
- package/dist/react/pdf-preview.js.map +1 -0
- package/dist/react/pdf-render.d.ts +15 -0
- package/dist/react/pdf-render.d.ts.map +1 -0
- package/dist/react/pdf-render.js +60 -0
- package/dist/react/pdf-render.js.map +1 -0
- package/dist/react/registry.d.ts +44 -0
- package/dist/react/registry.d.ts.map +1 -0
- package/dist/react/registry.js +105 -0
- package/dist/react/registry.js.map +1 -0
- package/dist/react/render.d.ts +36 -0
- package/dist/react/render.d.ts.map +1 -0
- package/dist/react/render.js +212 -0
- package/dist/react/render.js.map +1 -0
- package/dist/react/same-document.d.ts +8 -0
- package/dist/react/same-document.d.ts.map +1 -0
- package/dist/react/same-document.js +59 -0
- package/dist/react/same-document.js.map +1 -0
- package/dist/react/static.d.ts +13 -0
- package/dist/react/static.d.ts.map +1 -0
- package/dist/react/static.js +65 -0
- package/dist/react/static.js.map +1 -0
- package/dist/react/use-pdf.d.ts +25 -0
- package/dist/react/use-pdf.d.ts.map +1 -0
- package/dist/react/use-pdf.js +59 -0
- package/dist/react/use-pdf.js.map +1 -0
- package/dist/react.d.ts +9 -0
- package/dist/react.d.ts.map +1 -0
- package/dist/react.js +10 -0
- package/dist/react.js.map +1 -0
- package/dist/tailwind/Types/merge-config.d.ts +28 -0
- package/dist/tailwind/Types/merge-config.d.ts.map +1 -0
- package/dist/tailwind/Types/merge-config.js +2 -0
- package/dist/tailwind/Types/merge-config.js.map +1 -0
- package/dist/tailwind/merge-config.d.ts +45 -0
- package/dist/tailwind/merge-config.d.ts.map +1 -0
- package/dist/tailwind/merge-config.js +46 -0
- package/dist/tailwind/merge-config.js.map +1 -0
- package/dist/tailwind-merge.d.ts +3 -0
- package/dist/tailwind-merge.d.ts.map +1 -0
- package/dist/tailwind-merge.js +4 -0
- package/dist/tailwind-merge.js.map +1 -0
- package/dist/tailwind.css +61 -0
- package/dist/theme/Types/css-imports.d.ts +38 -0
- package/dist/theme/Types/css-imports.d.ts.map +1 -0
- package/dist/theme/Types/css-imports.js +2 -0
- package/dist/theme/Types/css-imports.js.map +1 -0
- package/dist/theme/Types/theme.d.ts +70 -0
- package/dist/theme/Types/theme.d.ts.map +1 -0
- package/dist/theme/Types/theme.js +2 -0
- package/dist/theme/Types/theme.js.map +1 -0
- package/dist/theme/Types/warnings.d.ts +9 -0
- package/dist/theme/Types/warnings.d.ts.map +1 -0
- package/dist/theme/Types/warnings.js +2 -0
- package/dist/theme/Types/warnings.js.map +1 -0
- package/dist/theme/css-imports.d.ts +11 -0
- package/dist/theme/css-imports.d.ts.map +1 -0
- package/dist/theme/css-imports.js +138 -0
- package/dist/theme/css-imports.js.map +1 -0
- package/dist/theme/normalize.d.ts +15 -0
- package/dist/theme/normalize.d.ts.map +1 -0
- package/dist/theme/normalize.js +51 -0
- package/dist/theme/normalize.js.map +1 -0
- package/dist/theme/package-imports.d.ts +16 -0
- package/dist/theme/package-imports.d.ts.map +1 -0
- package/dist/theme/package-imports.js +90 -0
- package/dist/theme/package-imports.js.map +1 -0
- package/dist/theme/theme-from-css-file.d.ts +35 -0
- package/dist/theme/theme-from-css-file.d.ts.map +1 -0
- package/dist/theme/theme-from-css-file.js +223 -0
- package/dist/theme/theme-from-css-file.js.map +1 -0
- package/dist/theme/theme-from-css.d.ts +28 -0
- package/dist/theme/theme-from-css.d.ts.map +1 -0
- package/dist/theme/theme-from-css.js +62 -0
- package/dist/theme/theme-from-css.js.map +1 -0
- package/dist/theme/warnings.d.ts +13 -0
- package/dist/theme/warnings.d.ts.map +1 -0
- package/dist/theme/warnings.js +34 -0
- package/dist/theme/warnings.js.map +1 -0
- package/dist/vite/Types/plugin.d.ts +47 -0
- package/dist/vite/Types/plugin.d.ts.map +1 -0
- package/dist/vite/Types/plugin.js +5 -0
- package/dist/vite/Types/plugin.js.map +1 -0
- package/dist/vite/plugin.d.ts +30 -0
- package/dist/vite/plugin.d.ts.map +1 -0
- package/dist/vite/plugin.js +80 -0
- package/dist/vite/plugin.js.map +1 -0
- package/dist/vite.d.ts +3 -0
- package/dist/vite.d.ts.map +1 -0
- package/dist/vite.js +6 -0
- package/dist/vite.js.map +1 -0
- package/dist/wasm/binding.generated.d.ts +259 -0
- package/dist/wasm/loader.d.ts +17 -0
- package/dist/wasm/loader.d.ts.map +1 -0
- package/dist/wasm/loader.js +74 -0
- package/dist/wasm/loader.js.map +1 -0
- package/dist/wasm/pkg/rentnerpdf_wasm.d.ts +259 -0
- package/dist/wasm/pkg/rentnerpdf_wasm.js +883 -0
- package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm +0 -0
- package/dist/wasm/pkg/rentnerpdf_wasm_bg.wasm.d.ts +40 -0
- package/dist/worker/Types/connection.d.ts +25 -0
- package/dist/worker/Types/connection.d.ts.map +1 -0
- package/dist/worker/Types/connection.js +2 -0
- package/dist/worker/Types/connection.js.map +1 -0
- package/dist/worker/Types/protocol.d.ts +62 -0
- package/dist/worker/Types/protocol.d.ts.map +1 -0
- package/dist/worker/Types/protocol.js +2 -0
- package/dist/worker/Types/protocol.js.map +1 -0
- package/dist/worker/Types/worker-engine.d.ts +91 -0
- package/dist/worker/Types/worker-engine.d.ts.map +1 -0
- package/dist/worker/Types/worker-engine.js +2 -0
- package/dist/worker/Types/worker-engine.js.map +1 -0
- package/dist/worker/client.d.ts +20 -0
- package/dist/worker/client.d.ts.map +1 -0
- package/dist/worker/client.js +131 -0
- package/dist/worker/client.js.map +1 -0
- package/dist/worker/connection.d.ts +5 -0
- package/dist/worker/connection.d.ts.map +1 -0
- package/dist/worker/connection.js +119 -0
- package/dist/worker/connection.js.map +1 -0
- package/dist/worker/protocol.d.ts +24 -0
- package/dist/worker/protocol.d.ts.map +1 -0
- package/dist/worker/protocol.js +71 -0
- package/dist/worker/protocol.js.map +1 -0
- package/dist/worker/serve.d.ts +26 -0
- package/dist/worker/serve.d.ts.map +1 -0
- package/dist/worker/serve.js +119 -0
- package/dist/worker/serve.js.map +1 -0
- package/dist/worker.d.ts +4 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +8 -0
- package/dist/worker.js.map +1 -0
- package/package.json +80 -5
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../web/src/native/loader.ts"],"names":[],"mappings":"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","sourcesContent":["import { readFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\n\n/** Exports of the native Node-API module, typed by the generated declarations. */\nexport type NativeBinding = typeof import('./binding.generated.js')\n\n/** Options for {@link loadNativeBinding}; defaults come from the running process. */\nexport interface NativeLoadOptions {\n /** Absolute path to a `.node` file that is tried first (development override). */\n libraryPath?: string | undefined\n /** napi-rs target name such as `linux-x64-gnu`; detected when omitted. */\n target?: string | undefined\n}\n\n// `createRequire` is only called inside functions: browser bundles of the\n// main entry replace `node:module` with an empty module, so nothing may call\n// it while loading.\nlet nodeRequire: NodeJS.Require | undefined\nconst requireFile = (id: string): NativeBinding =>\n (nodeRequire ??= createRequire(import.meta.url))(id) as NativeBinding\n\n// macOS uses the bundled WebAssembly engine.\nconst supportedTargets = new Set([\n 'win32-x64-msvc',\n 'win32-arm64-msvc',\n 'linux-x64-gnu',\n 'linux-x64-musl',\n 'linux-arm64-gnu',\n 'linux-arm64-musl',\n])\n\n/**\n * Loads the selected addon. Literal paths keep the binaries visible to file\n * tracers such as Next.js and Nitro.\n */\nfunction requireBundledBinary(target: string): NativeBinding {\n const require = createRequire(import.meta.url)\n switch (target) {\n case 'win32-x64-msvc':\n return require('./rentnerpdf.win32-x64-msvc.node') as NativeBinding\n case 'win32-arm64-msvc':\n return require('./rentnerpdf.win32-arm64-msvc.node') as NativeBinding\n case 'linux-x64-gnu':\n return require('./rentnerpdf.linux-x64-gnu.node') as NativeBinding\n case 'linux-x64-musl':\n return require('./rentnerpdf.linux-x64-musl.node') as NativeBinding\n case 'linux-arm64-gnu':\n return require('./rentnerpdf.linux-arm64-gnu.node') as NativeBinding\n case 'linux-arm64-musl':\n return require('./rentnerpdf.linux-arm64-musl.node') as NativeBinding\n default:\n throw new Error(`No bundled native binary for ${target}`)\n }\n}\n\nlet cachedBinding: NativeBinding | undefined\n\n/**\n * Returns the napi-rs target name for a platform, for example `linux-x64-musl`,\n * or `undefined` when RentnerPDF ships no native binary for it.\n */\nexport function nativeTargetName(\n platform: string,\n arch: string,\n musl: boolean,\n): string | undefined {\n let name: string\n if (platform === 'win32') name = `win32-${arch}-msvc`\n else if (platform === 'linux')\n name = `linux-${arch}-${musl ? 'musl' : 'gnu'}`\n else name = `${platform}-${arch}`\n return supportedTargets.has(name) ? name : undefined\n}\n\nfunction isMusl(): boolean {\n if (process.platform !== 'linux') return false\n try {\n return readFileSync('/usr/bin/ldd', 'utf8').includes('musl')\n } catch {\n const report = process.report?.getReport() as\n { header?: { glibcVersionRuntime?: string } } | undefined\n return report?.header?.glibcVersionRuntime === undefined\n }\n}\n\n/**\n * Loads an explicit library path first, then the matching binary next to this\n * loader, whether built locally or installed from npm.\n */\nexport function loadNativeBinding(\n options: NativeLoadOptions = {},\n): NativeBinding {\n const libraryPath =\n options.libraryPath ?? process.env.RENTNERPDF_NATIVE_LIBRARY_PATH\n const target =\n options.target ??\n nativeTargetName(process.platform, process.arch, isMusl())\n const candidates: (() => NativeBinding)[] = [\n ...(libraryPath ? [() => requireFile(libraryPath)] : []),\n ...(target ? [() => requireBundledBinary(target)] : []),\n ]\n const failures: unknown[] = []\n for (const load of candidates) {\n try {\n return load()\n } catch (error) {\n failures.push(error)\n }\n }\n const platform = `${process.platform}-${process.arch}`\n const message = target\n ? `Cannot load rentnerpdf.${target}.node from @rentnerkev/pdf. Reinstall the package or build the native binding from source.`\n : `RentnerPDF has no native binding for ${platform}. Use the bundled WebAssembly backend (\\`backend: 'auto'\\` or \\`'wasm'\\`).`\n throw new Error(message, { cause: failures })\n}\n\n/** Returns the native binding, loading it once on first use. */\nexport function nativeBinding(): NativeBinding {\n cachedBinding ??= loadNativeBinding()\n return cachedBinding\n}\n"]}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../web/src/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA;AACjE,YAAY,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAA"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// `@rentnerkev/pdf/node`: helpers that read files with `node:fs`. Browser
|
|
2
|
+
// and edge bundles import `@rentnerkev/pdf` only and never touch the file
|
|
3
|
+
// system. The theme reader's limits are documented in 07 – Security and
|
|
4
|
+
// not exported: they are tuning constants, not API.
|
|
5
|
+
export { themeFromCssFile } from './theme/theme-from-css-file.js';
|
|
6
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../web/src/node.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,0EAA0E;AAC1E,wEAAwE;AACxE,oDAAoD;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAA","sourcesContent":["// `@rentnerkev/pdf/node`: helpers that read files with `node:fs`. Browser\n// and edge bundles import `@rentnerkev/pdf` only and never touch the file\n// system. The theme reader's limits are documented in 07 – Security and\n// not exported: they are tuning constants, not API.\nexport { themeFromCssFile } from './theme/theme-from-css-file.ts'\nexport type { ThemeFromCssFileOptions } from './theme/Types/theme.ts'\n"]}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { IframeHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import type { RenderInput } from '../../engine/Types/engine.ts';
|
|
3
|
+
import type { RenderOptions } from '../../engine/Types/render-options.ts';
|
|
4
|
+
import type { PdfBytes, RenderResult, RenderWarning, WrapDiagnostic } from '../../engine/Types/render-result.ts';
|
|
5
|
+
/**
|
|
6
|
+
* What `usePdf` renders with: an engine from `createWorkerEngine()`
|
|
7
|
+
* (`@rentnerkev/pdf/worker`, keeps the page responsive) or from
|
|
8
|
+
* `createEngine()`.
|
|
9
|
+
*/
|
|
10
|
+
export interface PdfRenderer {
|
|
11
|
+
renderDetailed(input: RenderInput, options?: RenderOptions): Promise<RenderResult>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* `UsePdfOptions.engine`: a renderer, a promise of one, or a function that
|
|
15
|
+
* returns either. A function is called only when a render starts, so
|
|
16
|
+
* server rendering never creates a worker. Keep its identity across
|
|
17
|
+
* renders (a module-level value or function): a new engine starts a new
|
|
18
|
+
* render.
|
|
19
|
+
*/
|
|
20
|
+
export type PdfRendererSource = PdfRenderer | Promise<PdfRenderer> | (() => PdfRenderer | Promise<PdfRenderer>);
|
|
21
|
+
export interface UsePdfOptions {
|
|
22
|
+
readonly engine: PdfRendererSource;
|
|
23
|
+
/**
|
|
24
|
+
* Milliseconds the document has to stay unchanged before it renders,
|
|
25
|
+
* so typing in an editor does not start a render per key. Defaults to
|
|
26
|
+
* 200; `0` renders at once.
|
|
27
|
+
*/
|
|
28
|
+
readonly debounceMs?: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* `idle`: no document. `rendering`: waiting for `debounceMs` or the
|
|
32
|
+
* engine. `done`: the latest document rendered. `failed`: it failed (see
|
|
33
|
+
* `error`); the PDF of an earlier document stays.
|
|
34
|
+
*/
|
|
35
|
+
export type PdfStatus = 'idle' | 'rendering' | 'done' | 'failed';
|
|
36
|
+
export interface UsePdfState {
|
|
37
|
+
readonly status: PdfStatus;
|
|
38
|
+
/** The latest PDF; it stays while a newer document renders or fails. */
|
|
39
|
+
readonly pdf?: PdfBytes;
|
|
40
|
+
/**
|
|
41
|
+
* An object URL of `pdf` for an `<iframe>` or a download link, revoked
|
|
42
|
+
* when a newer PDF replaces it and on unmount.
|
|
43
|
+
*/
|
|
44
|
+
readonly url?: string;
|
|
45
|
+
readonly pageCount?: number;
|
|
46
|
+
/** Warnings of the latest PDF. */
|
|
47
|
+
readonly warnings: readonly RenderWarning[];
|
|
48
|
+
/** Wrap diagnostics of the latest PDF. */
|
|
49
|
+
readonly diagnostics: readonly WrapDiagnostic[];
|
|
50
|
+
/**
|
|
51
|
+
* Why the latest document failed (`status: 'failed'`): a
|
|
52
|
+
* `RentnerPdfError` or what a component threw.
|
|
53
|
+
*/
|
|
54
|
+
readonly error?: unknown;
|
|
55
|
+
}
|
|
56
|
+
export interface UsePdfResult {
|
|
57
|
+
readonly state: UsePdfState;
|
|
58
|
+
}
|
|
59
|
+
/** Applies a change to the state, like React's functional `setState`. */
|
|
60
|
+
export type PdfStateUpdate = (change: (state: UsePdfState) => UsePdfState) => void;
|
|
61
|
+
/** What `schedulePdfRender` needs for one document. */
|
|
62
|
+
export interface PdfRenderSchedule {
|
|
63
|
+
readonly document: RenderInput;
|
|
64
|
+
readonly engine: PdfRendererSource;
|
|
65
|
+
readonly debounceMs: number;
|
|
66
|
+
readonly update: PdfStateUpdate;
|
|
67
|
+
}
|
|
68
|
+
export interface PdfPreviewProps extends UsePdfOptions, Omit<IframeHTMLAttributes<HTMLIFrameElement>, 'src' | 'children'> {
|
|
69
|
+
/** The document to show; `null` shows `fallback`. */
|
|
70
|
+
readonly document: RenderInput | null | undefined;
|
|
71
|
+
/** Shown until the first PDF is ready. Defaults to nothing. */
|
|
72
|
+
readonly fallback?: ReactNode;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=preview.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../web/src/react/Types/preview.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAA;AACzE,OAAO,KAAK,EACR,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,cAAc,EACjB,MAAM,qCAAqC,CAAA;AAE5C;;;;GAIG;AACH,MAAM,WAAW,WAAW;IACxB,cAAc,CACV,KAAK,EAAE,WAAW,EAClB,OAAO,CAAC,EAAE,aAAa,GACxB,OAAO,CAAC,YAAY,CAAC,CAAA;CAC3B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB,GACvB,WAAW,GACX,OAAO,CAAC,WAAW,CAAC,GACpB,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAA;AAEhD,MAAM,WAAW,aAAa;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAC/B;AAED;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,WAAW,GAAG,MAAM,GAAG,QAAQ,CAAA;AAEhE,MAAM,WAAW,WAAW;IACxB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B,wEAAwE;IACxE,QAAQ,CAAC,GAAG,CAAC,EAAE,QAAQ,CAAA;IACvB;;;OAGG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;IAC3B,kCAAkC;IAClC,QAAQ,CAAC,QAAQ,EAAE,SAAS,aAAa,EAAE,CAAA;IAC3C,0CAA0C;IAC1C,QAAQ,CAAC,WAAW,EAAE,SAAS,cAAc,EAAE,CAAA;IAC/C;;;OAGG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAC3B;AAED,MAAM,WAAW,YAAY;IACzB,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAA;CAC9B;AAED,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,CACzB,MAAM,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,WAAW,KAC1C,IAAI,CAAA;AAET,uDAAuD;AACvD,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAA;IAC9B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAA;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;IAC3B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAA;CAClC;AAED,MAAM,WAAW,eACb,SACI,aAAa,EACb,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC;IACrE,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,WAAW,GAAG,IAAI,GAAG,SAAS,CAAA;IACjD,+DAA+D;IAC/D,QAAQ,CAAC,QAAQ,CAAC,EAAE,SAAS,CAAA;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"preview.js","sourceRoot":"","sources":["../../../web/src/react/Types/preview.ts"],"names":[],"mappings":"","sourcesContent":["import type { IframeHTMLAttributes, ReactNode } from 'react'\nimport type { RenderInput } from '../../engine/Types/engine.ts'\nimport type { RenderOptions } from '../../engine/Types/render-options.ts'\nimport type {\n PdfBytes,\n RenderResult,\n RenderWarning,\n WrapDiagnostic,\n} from '../../engine/Types/render-result.ts'\n\n/**\n * What `usePdf` renders with: an engine from `createWorkerEngine()`\n * (`@rentnerkev/pdf/worker`, keeps the page responsive) or from\n * `createEngine()`.\n */\nexport interface PdfRenderer {\n renderDetailed(\n input: RenderInput,\n options?: RenderOptions,\n ): Promise<RenderResult>\n}\n\n/**\n * `UsePdfOptions.engine`: a renderer, a promise of one, or a function that\n * returns either. A function is called only when a render starts, so\n * server rendering never creates a worker. Keep its identity across\n * renders (a module-level value or function): a new engine starts a new\n * render.\n */\nexport type PdfRendererSource =\n | PdfRenderer\n | Promise<PdfRenderer>\n | (() => PdfRenderer | Promise<PdfRenderer>)\n\nexport interface UsePdfOptions {\n readonly engine: PdfRendererSource\n /**\n * Milliseconds the document has to stay unchanged before it renders,\n * so typing in an editor does not start a render per key. Defaults to\n * 200; `0` renders at once.\n */\n readonly debounceMs?: number\n}\n\n/**\n * `idle`: no document. `rendering`: waiting for `debounceMs` or the\n * engine. `done`: the latest document rendered. `failed`: it failed (see\n * `error`); the PDF of an earlier document stays.\n */\nexport type PdfStatus = 'idle' | 'rendering' | 'done' | 'failed'\n\nexport interface UsePdfState {\n readonly status: PdfStatus\n /** The latest PDF; it stays while a newer document renders or fails. */\n readonly pdf?: PdfBytes\n /**\n * An object URL of `pdf` for an `<iframe>` or a download link, revoked\n * when a newer PDF replaces it and on unmount.\n */\n readonly url?: string\n readonly pageCount?: number\n /** Warnings of the latest PDF. */\n readonly warnings: readonly RenderWarning[]\n /** Wrap diagnostics of the latest PDF. */\n readonly diagnostics: readonly WrapDiagnostic[]\n /**\n * Why the latest document failed (`status: 'failed'`): a\n * `RentnerPdfError` or what a component threw.\n */\n readonly error?: unknown\n}\n\nexport interface UsePdfResult {\n readonly state: UsePdfState\n}\n\n/** Applies a change to the state, like React's functional `setState`. */\nexport type PdfStateUpdate = (\n change: (state: UsePdfState) => UsePdfState,\n) => void\n\n/** What `schedulePdfRender` needs for one document. */\nexport interface PdfRenderSchedule {\n readonly document: RenderInput\n readonly engine: PdfRendererSource\n readonly debounceMs: number\n readonly update: PdfStateUpdate\n}\n\nexport interface PdfPreviewProps\n extends\n UsePdfOptions,\n Omit<IframeHTMLAttributes<HTMLIFrameElement>, 'src' | 'children'> {\n /** The document to show; `null` shows `fallback`. */\n readonly document: RenderInput | null | undefined\n /** Shown until the first PDF is ready. Defaults to nothing. */\n readonly fallback?: ReactNode\n}\n"]}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Engine } from '../../engine/Types/engine.ts';
|
|
2
|
+
/** Options of `renderToPdf` and `renderToPdfDetailed`. */
|
|
3
|
+
export interface RenderToPdfOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The engine to render with, from `createEngine()`. Defaults to the
|
|
6
|
+
* engine `render()` uses: the bundled Noto Sans fonts and default
|
|
7
|
+
* options, created on first use.
|
|
8
|
+
*/
|
|
9
|
+
readonly engine?: Engine;
|
|
10
|
+
/**
|
|
11
|
+
* Aborts the render (for example a request that was cancelled): the
|
|
12
|
+
* React render, and the engine's work at its next page or paragraph;
|
|
13
|
+
* the promise rejects with an `ABORTED` error.
|
|
14
|
+
*/
|
|
15
|
+
readonly signal?: AbortSignal;
|
|
16
|
+
/**
|
|
17
|
+
* Fails the render with `ABORTED` when it has not finished after this
|
|
18
|
+
* many milliseconds, React and the engine together, for example when
|
|
19
|
+
* data that `use()` waits for never arrives. The timer keeps the
|
|
20
|
+
* process alive until then.
|
|
21
|
+
*/
|
|
22
|
+
readonly timeoutMs?: number;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../web/src/react/Types/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AAE1D,0DAA0D;AAC1D,MAAM,WAAW,kBAAkB;IAC/B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAA;IAC7B;;;;;OAKG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAC9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../web/src/react/Types/render.ts"],"names":[],"mappings":"","sourcesContent":["import type { Engine } from '../../engine/Types/engine.ts'\n\n/** Options of `renderToPdf` and `renderToPdfDetailed`. */\nexport interface RenderToPdfOptions {\n /**\n * The engine to render with, from `createEngine()`. Defaults to the\n * engine `render()` uses: the bundled Noto Sans fonts and default\n * options, created on first use.\n */\n readonly engine?: Engine\n /**\n * Aborts the render (for example a request that was cancelled): the\n * React render, and the engine's work at its next page or paragraph;\n * the promise rejects with an `ABORTED` error.\n */\n readonly signal?: AbortSignal\n /**\n * Fails the render with `ABORTED` when it has not finished after this\n * many milliseconds, React and the engine together, for example when\n * data that `use()` waits for never arrives. The timer keeps the\n * process alive until then.\n */\n readonly timeoutMs?: number\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** The attributes of an `rpdf-*` element, as React props. */
|
|
2
|
+
export type MarkupProps = Record<string, string>;
|
|
3
|
+
/**
|
|
4
|
+
* The markup attributes of an IR node's fields; `t` and `children` are left
|
|
5
|
+
* out, and so are unset fields.
|
|
6
|
+
*/
|
|
7
|
+
export declare function markupProps(fields: object): MarkupProps;
|
|
8
|
+
//# sourceMappingURL=attributes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.d.ts","sourceRoot":"","sources":["../../web/src/react/attributes.ts"],"names":[],"mappings":"AAQA,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAmBhD;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAevD"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
// Explicit prop serialization for the `rpdf-*` markup (D-09). React renders
|
|
2
|
+
// strings and numbers on custom elements and drops objects, arrays,
|
|
3
|
+
// functions and `false`, so every IR field becomes a string attribute here:
|
|
4
|
+
// `className` stays `className` (React writes `class`), `style` becomes the
|
|
5
|
+
// JSON attribute `style-json` (the IR's numbers are points, not React's
|
|
6
|
+
// pixels), booleans are `''` and `'false'`, structured values JSON. Names
|
|
7
|
+
// are the IR field names in kebab case (`cellClassName` → `cell-class-name`).
|
|
8
|
+
const kebab = (name) => name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
9
|
+
const attributeValue = (value) => {
|
|
10
|
+
switch (typeof value) {
|
|
11
|
+
case 'string':
|
|
12
|
+
return value;
|
|
13
|
+
case 'number':
|
|
14
|
+
case 'bigint':
|
|
15
|
+
return String(value);
|
|
16
|
+
case 'boolean':
|
|
17
|
+
return value ? '' : 'false';
|
|
18
|
+
default:
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* The markup attributes of an IR node's fields; `t` and `children` are left
|
|
24
|
+
* out, and so are unset fields.
|
|
25
|
+
*/
|
|
26
|
+
export function markupProps(fields) {
|
|
27
|
+
const props = {};
|
|
28
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
29
|
+
if (value === undefined || name === 't' || name === 'children') {
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (name === 'className') {
|
|
33
|
+
props.className = attributeValue(value);
|
|
34
|
+
}
|
|
35
|
+
else if (name === 'style') {
|
|
36
|
+
props['style-json'] = JSON.stringify(value);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
props[kebab(name)] = attributeValue(value);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return props;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=attributes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attributes.js","sourceRoot":"","sources":["../../web/src/react/attributes.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,oEAAoE;AACpE,4EAA4E;AAC5E,4EAA4E;AAC5E,wEAAwE;AACxE,0EAA0E;AAC1E,8EAA8E;AAK9E,MAAM,KAAK,GAAG,CAAC,IAAY,EAAU,EAAE,CACnC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC,CAAA;AAElE,MAAM,cAAc,GAAG,CAAC,KAAc,EAAU,EAAE;IAC9C,QAAQ,OAAO,KAAK,EAAE,CAAC;QACnB,KAAK,QAAQ;YACT,OAAO,KAAK,CAAA;QAChB,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACT,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;QACxB,KAAK,SAAS;YACV,OAAO,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAA;QAC/B;YACI,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACpC,CAAC;AACL,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,MAAc;IACtC,MAAM,KAAK,GAAgB,EAAE,CAAA;IAC7B,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACjD,IAAI,KAAK,KAAK,SAAS,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,UAAU,EAAE,CAAC;YAC7D,SAAQ;QACZ,CAAC;QACD,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;YACvB,KAAK,CAAC,SAAS,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QAC3C,CAAC;aAAM,IAAI,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,KAAK,CAAC,YAAY,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;QAC/C,CAAC;aAAM,CAAC;YACJ,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,CAAA;QAC9C,CAAC;IACL,CAAC;IACD,OAAO,KAAK,CAAA;AAChB,CAAC","sourcesContent":["// Explicit prop serialization for the `rpdf-*` markup (D-09). React renders\n// strings and numbers on custom elements and drops objects, arrays,\n// functions and `false`, so every IR field becomes a string attribute here:\n// `className` stays `className` (React writes `class`), `style` becomes the\n// JSON attribute `style-json` (the IR's numbers are points, not React's\n// pixels), booleans are `''` and `'false'`, structured values JSON. Names\n// are the IR field names in kebab case (`cellClassName` → `cell-class-name`).\n\n/** The attributes of an `rpdf-*` element, as React props. */\nexport type MarkupProps = Record<string, string>\n\nconst kebab = (name: string): string =>\n name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`)\n\nconst attributeValue = (value: unknown): string => {\n switch (typeof value) {\n case 'string':\n return value\n case 'number':\n case 'bigint':\n return String(value)\n case 'boolean':\n return value ? '' : 'false'\n default:\n return JSON.stringify(value)\n }\n}\n\n/**\n * The markup attributes of an IR node's fields; `t` and `children` are left\n * out, and so are unset fields.\n */\nexport function markupProps(fields: object): MarkupProps {\n const props: MarkupProps = {}\n for (const [name, value] of Object.entries(fields)) {\n if (value === undefined || name === 't' || name === 'children') {\n continue\n }\n if (name === 'className') {\n props.className = attributeValue(value)\n } else if (name === 'style') {\n props['style-json'] = JSON.stringify(value)\n } else {\n props[kebab(name)] = attributeValue(value)\n }\n }\n return props\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ReactElement, ReactNode } from 'react';
|
|
2
|
+
import type { CellProps, DataTableProps, DocumentProps, KeepProps, LinkProps, MarkerProps, PageBreakProps, PageNumberProps, PageProps, RowProps, TableProps, TextProps, TotalPagesProps, ViewProps } from '../components/Types/props.ts';
|
|
3
|
+
/** The root of every document: metadata and `Page` children. */
|
|
4
|
+
export declare const Document: (props: DocumentProps<ReactNode>) => ReactElement;
|
|
5
|
+
/**
|
|
6
|
+
* A page template: size, orientation, page box styling (`p-page` for
|
|
7
|
+
* margins), a `header` and `footer` on every page with `first`, `odd`,
|
|
8
|
+
* `even` and `last` variants, and `numbering`. Content that does not fit
|
|
9
|
+
* continues on further pages of the template.
|
|
10
|
+
*/
|
|
11
|
+
export declare const Page: (props: PageProps<ReactNode>) => ReactElement;
|
|
12
|
+
/** A generic box: block, flex or grid container. */
|
|
13
|
+
export declare const View: (props: ViewProps<ReactNode>) => ReactElement;
|
|
14
|
+
/**
|
|
15
|
+
* A paragraph of text; its string and number children are concatenated,
|
|
16
|
+
* and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
|
|
17
|
+
* per page.
|
|
18
|
+
*/
|
|
19
|
+
export declare const Text: (props: TextProps<ReactNode>) => ReactElement;
|
|
20
|
+
/**
|
|
21
|
+
* A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
|
|
22
|
+
* `<img>` with Tailwind's preflight.
|
|
23
|
+
*/
|
|
24
|
+
export declare const Image: (props: import("../index.ts").ImageAttributes) => ReactElement;
|
|
25
|
+
/** An SVG drawn as vectors, from markup or `.svg` bytes; it sizes like an image. */
|
|
26
|
+
export declare const Svg: (props: import("../index.ts").SvgAttributes) => ReactElement;
|
|
27
|
+
/**
|
|
28
|
+
* A clickable box around its children (a `View` with `href`): `#id` jumps
|
|
29
|
+
* to the node with that `id`; `https:`, `http:`, `mailto:` and `tel:` URIs
|
|
30
|
+
* open in the viewer's application.
|
|
31
|
+
*/
|
|
32
|
+
export declare const Link: (props: LinkProps<ReactNode>) => ReactElement;
|
|
33
|
+
/** An invisible link target: `<Anchor id="terms" />` is where `<Link href="#terms">` jumps. */
|
|
34
|
+
export declare const Anchor: (props: import("../index.ts").AnchorAttributes) => ReactElement;
|
|
35
|
+
/** Starts the content that follows it on a new page (`break-after-page`). */
|
|
36
|
+
export declare const PageBreak: (props: PageBreakProps) => ReactElement;
|
|
37
|
+
/**
|
|
38
|
+
* Keeps its children together on one page when they fit on one: a box with
|
|
39
|
+
* `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
|
|
40
|
+
*/
|
|
41
|
+
export declare const Keep: (props: KeepProps<ReactNode>) => ReactElement;
|
|
42
|
+
/**
|
|
43
|
+
* A table of `Row`s, or with `data` and `columns` a data-driven table: one
|
|
44
|
+
* row per item, cells rendered natively from compact column data.
|
|
45
|
+
*/
|
|
46
|
+
export declare const Table: <Row extends object>(props: TableProps<ReactNode> | DataTableProps<Row>) => ReactElement;
|
|
47
|
+
/** A table row; `header` and `footer` rows repeat on every page. */
|
|
48
|
+
export declare const Row: (props: RowProps<ReactNode>) => ReactElement;
|
|
49
|
+
/**
|
|
50
|
+
* A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
|
|
51
|
+
* numbers become its text; `value` cells show a number in minor units.
|
|
52
|
+
*/
|
|
53
|
+
export declare const Cell: (props: CellProps<ReactNode>) => ReactElement;
|
|
54
|
+
/** The number of the page the text is on, inside a `Text`. */
|
|
55
|
+
export declare const PageNumber: (props: PageNumberProps) => ReactElement;
|
|
56
|
+
/** The number of pages of the document (or of the page template with `scope="section"`). */
|
|
57
|
+
export declare const TotalPages: (props: TotalPagesProps) => ReactElement;
|
|
58
|
+
/** The value of a running marker on the page, inside a `Text`. */
|
|
59
|
+
export declare const Marker: (props: MarkerProps) => ReactElement;
|
|
60
|
+
//# sourceMappingURL=components.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../web/src/react/components.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAEpD,OAAO,KAAK,EAER,SAAS,EAET,cAAc,EAEd,aAAa,EAEb,SAAS,EACT,SAAS,EACT,WAAW,EACX,cAAc,EACd,eAAe,EACf,SAAS,EAET,QAAQ,EAER,UAAU,EACV,SAAS,EACT,eAAe,EACf,SAAS,EACZ,MAAM,8BAA8B,CAAA;AAoKrC,gEAAgE;AAChE,eAAO,MAAM,QAAQ,uCArEJ,YA8EhB,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,IAAI,mCAtFA,YA2IhB,CAAA;AAED,oDAAoD;AACpD,eAAO,MAAM,IAAI,mCA9IA,YAkJhB,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,IAAI,mCAzJA,YA+JhB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,oDArKD,YAiLf,CAAA;AAEF,oFAAoF;AACpF,eAAO,MAAM,GAAG,kDApLC,YAgMf,CAAA;AAEF;;;;GAIG;AACH,eAAO,MAAM,IAAI,mCAvMA,YA2MhB,CAAA;AAED,+FAA+F;AAC/F,eAAO,MAAM,MAAM,qDA9MF,YAiNf,CAAA;AAEF,6EAA6E;AAC7E,eAAO,MAAM,SAAS,6BApNL,YA0NhB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,mCAhOA,YAoOhB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,KAAK,EAoBb,CAAC,GAAG,SAAS,MAAM,EACpB,KAAK,EAAE,UAAU,CAAC,SAAS,CAAC,GAAG,cAAc,CAAC,GAAG,CAAC,KACjD,YAAY,CAAA;AAEjB,oEAAoE;AACpE,eAAO,MAAM,GAAG,kCAnQC,YAuQhB,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,IAAI,mCA7QA,YAiRhB,CAAA;AAED,8DAA8D;AAC9D,eAAO,MAAM,UAAU,8BApRN,YA0RhB,CAAA;AAED,4FAA4F;AAC5F,eAAO,MAAM,UAAU,8BA7RN,YAmShB,CAAA;AAED,kEAAkE;AAClE,eAAO,MAAM,MAAM,0BAtSF,YAySf,CAAA"}
|
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
// The React components of `@rentnerkev/pdf/react` (D-09): the same names and
|
|
2
|
+
// props as the own JSX runtime's components. Each one renders an `rpdf-*`
|
|
3
|
+
// custom element whose attributes are the IR fields the factories build from
|
|
4
|
+
// the props, so both paths produce the same IR. Bytes and table data go to
|
|
5
|
+
// the render's registry; the markup holds their indices.
|
|
6
|
+
import * as React from 'react';
|
|
7
|
+
import { isAttachmentSource, isImageSource } from '../engine/assets.js';
|
|
8
|
+
import { RentnerPdfError } from '../engine/errors.js';
|
|
9
|
+
import { anchor, cell, document, image, keep, link, marker, page, pageBreak, pageNumber, row, svg, table, text, totalPages, view, } from '../ir/factories.js';
|
|
10
|
+
import { markupProps } from './attributes.js';
|
|
11
|
+
import { RegistryContext } from './registry.js';
|
|
12
|
+
/** Marks the React components, so the own JSX runtime can name the mix-up. */
|
|
13
|
+
const REACT_COMPONENT = Symbol.for('rentnerpdf.react-component');
|
|
14
|
+
const invalid = (message) => new RentnerPdfError('INVALID_DOCUMENT', message);
|
|
15
|
+
/** The owner stack of the element being rendered (React development builds). */
|
|
16
|
+
const ownerStack = () => {
|
|
17
|
+
const capture = Reflect.get(React, 'captureOwnerStack');
|
|
18
|
+
if (typeof capture !== 'function')
|
|
19
|
+
return undefined;
|
|
20
|
+
const stack = capture();
|
|
21
|
+
return typeof stack === 'string' && stack !== '' ? stack : undefined;
|
|
22
|
+
};
|
|
23
|
+
/** An `rpdf-*` element with the IR fields as attributes. */
|
|
24
|
+
const element = (registry, tag, fields, ...children) => {
|
|
25
|
+
const props = markupProps(fields);
|
|
26
|
+
const stack = ownerStack();
|
|
27
|
+
if (stack !== undefined)
|
|
28
|
+
props.debug = registry.debugId(stack);
|
|
29
|
+
return React.createElement(tag, props, ...children);
|
|
30
|
+
};
|
|
31
|
+
/** Whether children render nothing: nullish, booleans and blank strings. */
|
|
32
|
+
const isEmpty = (children) => {
|
|
33
|
+
if (children === null || children === undefined)
|
|
34
|
+
return true;
|
|
35
|
+
if (typeof children === 'boolean')
|
|
36
|
+
return true;
|
|
37
|
+
if (typeof children === 'string')
|
|
38
|
+
return /^\s*$/.test(children);
|
|
39
|
+
if (Array.isArray(children))
|
|
40
|
+
return children.every(isEmpty);
|
|
41
|
+
return false;
|
|
42
|
+
};
|
|
43
|
+
const describe = (node) => {
|
|
44
|
+
if (Array.isArray(node)) {
|
|
45
|
+
return describe(node.find((child) => !isEmpty(child)));
|
|
46
|
+
}
|
|
47
|
+
if (React.isValidElement(node)) {
|
|
48
|
+
const { type } = node;
|
|
49
|
+
const name = typeof type === 'string'
|
|
50
|
+
? type
|
|
51
|
+
: typeof type === 'function' && type.name !== ''
|
|
52
|
+
? type.name
|
|
53
|
+
: 'Anonymous';
|
|
54
|
+
return `<${name}>`;
|
|
55
|
+
}
|
|
56
|
+
return typeof node === 'string'
|
|
57
|
+
? `text ${JSON.stringify(node)}`
|
|
58
|
+
: String(node);
|
|
59
|
+
};
|
|
60
|
+
/** `Image`, `Svg`, `Anchor`, `PageBreak` and the placeholders render no children. */
|
|
61
|
+
const noChildren = (name, props) => {
|
|
62
|
+
const children = Reflect.get(props, 'children');
|
|
63
|
+
if (!isEmpty(children)) {
|
|
64
|
+
throw invalid(`<${name}> has no children; found ${describe(children)}`);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Creates a component: it reads the render's registry from context and
|
|
69
|
+
* renders its markup element.
|
|
70
|
+
*/
|
|
71
|
+
function component(name, render) {
|
|
72
|
+
const host = (props) => {
|
|
73
|
+
const registry = React.useContext(RegistryContext);
|
|
74
|
+
if (registry === null) {
|
|
75
|
+
throw invalid(`<${name}> from @rentnerkev/pdf/react renders only inside renderToPdf()`);
|
|
76
|
+
}
|
|
77
|
+
return render(props, registry);
|
|
78
|
+
};
|
|
79
|
+
Object.defineProperty(host, 'name', { value: name });
|
|
80
|
+
Object.defineProperty(host, REACT_COMPONENT, { value: name });
|
|
81
|
+
return host;
|
|
82
|
+
}
|
|
83
|
+
const letterheadFields = (registry, { src, page: index }) => {
|
|
84
|
+
if (!isImageSource(src)) {
|
|
85
|
+
throw invalid('letterhead src must be the bytes of a PDF file (Uint8Array or ArrayBuffer)');
|
|
86
|
+
}
|
|
87
|
+
const asset = registry.asset(src);
|
|
88
|
+
return index === undefined ? { asset } : { asset, page: index };
|
|
89
|
+
};
|
|
90
|
+
const variantNames = ['first', 'odd', 'even', 'last'];
|
|
91
|
+
/**
|
|
92
|
+
* The document's fields as markup attributes: the metadata, standards,
|
|
93
|
+
* `tagged` and Factur-X descriptor, and attachments with their content in
|
|
94
|
+
* the registry.
|
|
95
|
+
*/
|
|
96
|
+
const documentFields = (registry, attributes) => {
|
|
97
|
+
const { meta, standards, attachments, facturX, tagged } = document(attributes);
|
|
98
|
+
const fields = {
|
|
99
|
+
...meta,
|
|
100
|
+
standards,
|
|
101
|
+
facturX,
|
|
102
|
+
tagged,
|
|
103
|
+
};
|
|
104
|
+
if (attachments !== undefined) {
|
|
105
|
+
const seen = new Map();
|
|
106
|
+
const encoded = [];
|
|
107
|
+
for (const [index, { src, ...rest }] of attachments.entries()) {
|
|
108
|
+
if (!isAttachmentSource(src)) {
|
|
109
|
+
throw invalid(`attachment src must be the file's bytes (Uint8Array or ArrayBuffer) or a string (at attachments[${index}].src)`);
|
|
110
|
+
}
|
|
111
|
+
const occurrence = seen.get(src) ?? 0;
|
|
112
|
+
seen.set(src, occurrence + 1);
|
|
113
|
+
encoded.push({
|
|
114
|
+
asset: registry.attachment(src, occurrence),
|
|
115
|
+
...rest,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
fields.attachments = encoded;
|
|
119
|
+
}
|
|
120
|
+
return fields;
|
|
121
|
+
};
|
|
122
|
+
/** The root of every document: metadata and `Page` children. */
|
|
123
|
+
export const Document = component('Document', ({ children, ...attributes }, registry) => element(registry, 'rpdf-document', documentFields(registry, attributes), children));
|
|
124
|
+
/**
|
|
125
|
+
* A page template: size, orientation, page box styling (`p-page` for
|
|
126
|
+
* margins), a `header` and `footer` on every page with `first`, `odd`,
|
|
127
|
+
* `even` and `last` variants, and `numbering`. Content that does not fit
|
|
128
|
+
* continues on further pages of the template.
|
|
129
|
+
*/
|
|
130
|
+
export const Page = component('Page', (props, registry) => {
|
|
131
|
+
const { children, header, footer, first, odd, even, last, letterhead, ...attributes } = props;
|
|
132
|
+
const fields = { ...page(attributes) };
|
|
133
|
+
if (letterhead !== undefined) {
|
|
134
|
+
fields.letterhead = letterheadFields(registry, letterhead);
|
|
135
|
+
}
|
|
136
|
+
// Header and footer elements render inside `rpdf-slot`s.
|
|
137
|
+
const slots = [];
|
|
138
|
+
const slot = (name, content) => {
|
|
139
|
+
slots.push(React.createElement('rpdf-slot', { name }, content));
|
|
140
|
+
};
|
|
141
|
+
if (header !== undefined && header !== null)
|
|
142
|
+
slot('header', header);
|
|
143
|
+
if (footer !== undefined && footer !== null)
|
|
144
|
+
slot('footer', footer);
|
|
145
|
+
const variants = {
|
|
146
|
+
first,
|
|
147
|
+
odd,
|
|
148
|
+
even,
|
|
149
|
+
last,
|
|
150
|
+
};
|
|
151
|
+
for (const key of variantNames) {
|
|
152
|
+
const variant = variants[key];
|
|
153
|
+
if (typeof variant !== 'object' || variant === null)
|
|
154
|
+
continue;
|
|
155
|
+
const value = {};
|
|
156
|
+
if (variant.letterhead !== undefined) {
|
|
157
|
+
value.letterhead =
|
|
158
|
+
variant.letterhead === null
|
|
159
|
+
? null
|
|
160
|
+
: letterheadFields(registry, variant.letterhead);
|
|
161
|
+
}
|
|
162
|
+
fields[key] = value;
|
|
163
|
+
for (const region of ['header', 'footer']) {
|
|
164
|
+
const content = variant[region];
|
|
165
|
+
// An empty slot removes the template's header or footer there.
|
|
166
|
+
if (content !== undefined)
|
|
167
|
+
slot(`${key}.${region}`, content);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return element(registry, 'rpdf-page', fields, ...slots, children);
|
|
171
|
+
});
|
|
172
|
+
/** A generic box: block, flex or grid container. */
|
|
173
|
+
export const View = component('View', ({ children, ...attributes }, registry) => element(registry, 'rpdf-view', view(attributes), children));
|
|
174
|
+
/**
|
|
175
|
+
* A paragraph of text; its string and number children are concatenated,
|
|
176
|
+
* and `PageNumber`, `TotalPages` and `Marker` placeholders are filled in
|
|
177
|
+
* per page.
|
|
178
|
+
*/
|
|
179
|
+
export const Text = component('Text', ({ children, ...attributes }, registry) => {
|
|
180
|
+
const { text: _content, ...fields } = text(attributes);
|
|
181
|
+
return element(registry, 'rpdf-text', fields, children);
|
|
182
|
+
});
|
|
183
|
+
/**
|
|
184
|
+
* A raster image from bytes (PNG, JPEG, GIF, WebP), sized like an HTML
|
|
185
|
+
* `<img>` with Tailwind's preflight.
|
|
186
|
+
*/
|
|
187
|
+
export const Image = component('Image', (props, registry) => {
|
|
188
|
+
noChildren('Image', props);
|
|
189
|
+
const { src, ...fields } = image(props);
|
|
190
|
+
if (!isImageSource(src)) {
|
|
191
|
+
throw invalid('image src must be the image bytes (Uint8Array or ArrayBuffer); read files or fetch URLs before rendering');
|
|
192
|
+
}
|
|
193
|
+
return element(registry, 'rpdf-image', {
|
|
194
|
+
...fields,
|
|
195
|
+
asset: registry.asset(src),
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
/** An SVG drawn as vectors, from markup or `.svg` bytes; it sizes like an image. */
|
|
199
|
+
export const Svg = component('Svg', (props, registry) => {
|
|
200
|
+
noChildren('Svg', props);
|
|
201
|
+
const { src, ...fields } = svg(props);
|
|
202
|
+
if (typeof src !== 'string' && !isImageSource(src)) {
|
|
203
|
+
throw invalid('svg src must be SVG markup (a string) or the bytes of an SVG file (Uint8Array or ArrayBuffer)');
|
|
204
|
+
}
|
|
205
|
+
return element(registry, 'rpdf-svg', {
|
|
206
|
+
...fields,
|
|
207
|
+
asset: registry.asset(src),
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
/**
|
|
211
|
+
* A clickable box around its children (a `View` with `href`): `#id` jumps
|
|
212
|
+
* to the node with that `id`; `https:`, `http:`, `mailto:` and `tel:` URIs
|
|
213
|
+
* open in the viewer's application.
|
|
214
|
+
*/
|
|
215
|
+
export const Link = component('Link', ({ children, ...attributes }, registry) => element(registry, 'rpdf-view', link(attributes), children));
|
|
216
|
+
/** An invisible link target: `<Anchor id="terms" />` is where `<Link href="#terms">` jumps. */
|
|
217
|
+
export const Anchor = component('Anchor', (props, registry) => {
|
|
218
|
+
noChildren('Anchor', props);
|
|
219
|
+
return element(registry, 'rpdf-view', anchor(props));
|
|
220
|
+
});
|
|
221
|
+
/** Starts the content that follows it on a new page (`break-after-page`). */
|
|
222
|
+
export const PageBreak = component('PageBreak', (props, registry) => {
|
|
223
|
+
noChildren('PageBreak', props);
|
|
224
|
+
return element(registry, 'rpdf-view', pageBreak());
|
|
225
|
+
});
|
|
226
|
+
/**
|
|
227
|
+
* Keeps its children together on one page when they fit on one: a box with
|
|
228
|
+
* `break-inside-avoid`, plus `break-after-avoid` with `withNext`.
|
|
229
|
+
*/
|
|
230
|
+
export const Keep = component('Keep', ({ children, ...attributes }, registry) => element(registry, 'rpdf-view', keep(attributes), children));
|
|
231
|
+
/**
|
|
232
|
+
* A table of `Row`s, or with `data` and `columns` a data-driven table: one
|
|
233
|
+
* row per item, cells rendered natively from compact column data.
|
|
234
|
+
*/
|
|
235
|
+
export const Table = component('Table', (props, registry) => {
|
|
236
|
+
const { children, ...attributes } = props;
|
|
237
|
+
if (attributes.data === undefined) {
|
|
238
|
+
return element(registry, 'rpdf-table', table(attributes), children);
|
|
239
|
+
}
|
|
240
|
+
const { data, columns = [], ...fields } = table(attributes);
|
|
241
|
+
// A data table has no children; the engine rejects them.
|
|
242
|
+
return element(registry, 'rpdf-table', { ...fields, ...registry.dataTable(data, columns) }, children);
|
|
243
|
+
});
|
|
244
|
+
/** A table row; `header` and `footer` rows repeat on every page. */
|
|
245
|
+
export const Row = component('Row', ({ children, ...attributes }, registry) => element(registry, 'rpdf-row', row(attributes), children));
|
|
246
|
+
/**
|
|
247
|
+
* A table cell spanning `colSpan` columns and `rowSpan` rows. Strings and
|
|
248
|
+
* numbers become its text; `value` cells show a number in minor units.
|
|
249
|
+
*/
|
|
250
|
+
export const Cell = component('Cell', ({ children, ...attributes }, registry) => element(registry, 'rpdf-cell', cell(attributes), children));
|
|
251
|
+
/** The number of the page the text is on, inside a `Text`. */
|
|
252
|
+
export const PageNumber = component('PageNumber', (props, registry) => {
|
|
253
|
+
noChildren('PageNumber', props);
|
|
254
|
+
return element(registry, 'rpdf-page-number', pageNumber(props));
|
|
255
|
+
});
|
|
256
|
+
/** The number of pages of the document (or of the page template with `scope="section"`). */
|
|
257
|
+
export const TotalPages = component('TotalPages', (props, registry) => {
|
|
258
|
+
noChildren('TotalPages', props);
|
|
259
|
+
return element(registry, 'rpdf-total-pages', totalPages(props));
|
|
260
|
+
});
|
|
261
|
+
/** The value of a running marker on the page, inside a `Text`. */
|
|
262
|
+
export const Marker = component('Marker', (props, registry) => {
|
|
263
|
+
noChildren('Marker', props);
|
|
264
|
+
return element(registry, 'rpdf-marker', marker(props));
|
|
265
|
+
});
|
|
266
|
+
//# sourceMappingURL=components.js.map
|