docblocks-react-ui 0.6.1 → 0.6.3
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/pdf/index.mjs +37 -19
- package/package.json +2 -2
- /package/dist/pdf/{pdf.worker.min.mjs → pdfjs-dist/build/pdf.worker.min.mjs} +0 -0
- /package/dist/pdf/{jbig2.wasm → pdfjs-dist/wasm/jbig2.wasm} +0 -0
- /package/dist/pdf/{jbig2_nowasm_fallback.js → pdfjs-dist/wasm/jbig2_nowasm_fallback.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# docblocks-react-ui
|
|
2
2
|
|
|
3
|
+
## 0.6.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 7bfbdff: Derive the PDF decoder directory without constructing a URL from a bundler-relative asset path, preserving compatibility with Turbopack's emitted URL objects.
|
|
8
|
+
|
|
9
|
+
## 0.6.2
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 631cdd4: Resolve the PDF worker and JBIG2 decoder through statically analyzable package asset URLs and fetch the decoder by its exact emitted URL, including hashed production bundles.
|
|
14
|
+
|
|
3
15
|
## 0.6.1
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -686,7 +686,7 @@ layout animation, the rendered list marker per row) — over the required
|
|
|
686
686
|
| `docblocks-react-ui/styles.css` | The compiled stylesheet: the utility layer + the token seed + the `--docblocks-*` mapping + the structural rules |
|
|
687
687
|
| `docblocks-react-ui/theme.css` | The pure token seed (standard tokens + the radius scale), no utility layer |
|
|
688
688
|
| `docblocks-react-ui/mermaid` | The `mermaid` renderer above `code { language: "mermaid" }` blocks (peer: `mermaid`) |
|
|
689
|
-
| `docblocks-react-ui/pdf` | `PdfFirstPage` (the first-page preview over `pdfjs-dist`;
|
|
689
|
+
| `docblocks-react-ui/pdf` | `PdfFirstPage` (the first-page preview over `pdfjs-dist`; static package asset URLs support consumer bundlers) |
|
|
690
690
|
|
|
691
691
|
The `./mermaid` and `./pdf` subpaths' wiring is opt-in (the `pdfPreview`
|
|
692
692
|
prop / the `code` block renderer): a consumer who skips a subpath imports
|
package/dist/index.d.mts
CHANGED
|
@@ -322,7 +322,7 @@ declare function AlertDescription({ className, ...props }: React.ComponentProps<
|
|
|
322
322
|
//#endregion
|
|
323
323
|
//#region src/shared/ui/Badge.d.ts
|
|
324
324
|
declare const badgeVariants: (props?: ({
|
|
325
|
-
variant?: "default" | "destructive" | "
|
|
325
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "custom" | null | undefined;
|
|
326
326
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
327
327
|
declare function Badge({ className, variant, asChild, ...props }: React.ComponentProps<"span"> & VariantProps<typeof badgeVariants> & {
|
|
328
328
|
asChild?: boolean;
|
|
@@ -333,7 +333,7 @@ declare function BareSelect({ className, children, ...props }: React.ComponentPr
|
|
|
333
333
|
//#endregion
|
|
334
334
|
//#region src/shared/ui/Button.d.ts
|
|
335
335
|
declare const buttonVariants: (props?: ({
|
|
336
|
-
variant?: "link" | "default" | "destructive" | "
|
|
336
|
+
variant?: "link" | "default" | "destructive" | "outline" | "secondary" | "ghost" | null | undefined;
|
|
337
337
|
size?: "default" | "icon" | "sm" | "lg" | "xl" | null | undefined;
|
|
338
338
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
339
339
|
declare function Button({ className, variant, size, asChild, type, ...props }: React.ComponentProps<"button"> & VariantProps<typeof buttonVariants> & {
|
package/dist/pdf/index.mjs
CHANGED
|
@@ -96,26 +96,42 @@ function StretchVertical(props) {
|
|
|
96
96
|
}
|
|
97
97
|
//#endregion
|
|
98
98
|
//#region src/pdf/pdf-worker.ts
|
|
99
|
-
/** The pdfjs
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
* rewrite cannot mangle the directory form. Scanned PDFs encode their
|
|
111
|
-
* text layers as JBIG2; without a resolvable wasmUrl the worker fails to
|
|
112
|
-
* initialize those layers and the page renders as a bare background image
|
|
113
|
-
* (the text is dropped). */
|
|
114
|
-
const WORKER_URL = new URL(`./pdf.worker.min.mjs`, import.meta.url);
|
|
99
|
+
/** The pdfjs worker and decoder assets use static package references so
|
|
100
|
+
* consumer bundlers can emit them. The decoder factory fetches the concrete
|
|
101
|
+
* emitted asset URL because a bundler may hash its filename. */
|
|
102
|
+
const WORKER_URL = new URL("pdfjs-dist/build/pdf.worker.min.mjs", import.meta.url);
|
|
103
|
+
const JBIG2_URL = new URL("pdfjs-dist/wasm/jbig2.wasm", import.meta.url);
|
|
104
|
+
/** Keep both absolute static-ESM URLs and bundler-relative asset paths valid. */
|
|
105
|
+
function directoryUrl(file) {
|
|
106
|
+
const url = file.toString();
|
|
107
|
+
return url.slice(0, url.lastIndexOf("/") + 1);
|
|
108
|
+
}
|
|
109
|
+
const WASM_URL = directoryUrl(JBIG2_URL);
|
|
115
110
|
GlobalWorkerOptions.workerSrc = WORKER_URL.toString();
|
|
116
|
-
|
|
111
|
+
async function fetchBytes(url) {
|
|
112
|
+
const response = await globalThis.fetch(url);
|
|
113
|
+
if (!response.ok) throw new URIError(`Unable to load PDF asset: ${url}`);
|
|
114
|
+
return new Uint8Array(await response.arrayBuffer());
|
|
115
|
+
}
|
|
116
|
+
/** Main-thread asset loader with an exact URL for the emitted JBIG2 module. */
|
|
117
|
+
var PdfBinaryDataFactory = class {
|
|
118
|
+
bases;
|
|
119
|
+
constructor(options) {
|
|
120
|
+
this.bases = {
|
|
121
|
+
cMapUrl: options.cMapUrl ?? null,
|
|
122
|
+
standardFontDataUrl: options.standardFontDataUrl ?? null,
|
|
123
|
+
wasmUrl: options.wasmUrl ?? null
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
async fetch({ kind, filename }) {
|
|
127
|
+
if (kind === "wasmUrl" && filename === "jbig2.wasm") return fetchBytes(JBIG2_URL);
|
|
128
|
+
const base = this.bases[kind];
|
|
129
|
+
if (base === null) throw new URIError(`The ${kind} API parameter is required for ${filename}`);
|
|
130
|
+
return fetchBytes(`${base}${filename}`);
|
|
131
|
+
}
|
|
132
|
+
};
|
|
117
133
|
if (typeof window !== "undefined") fetch(WORKER_URL, { method: "HEAD" }).catch(() => {
|
|
118
|
-
console.warn("docblocks: the pdf worker
|
|
134
|
+
console.warn("docblocks: the pdf worker asset is unreachable; the preview will use the native viewer fallback.");
|
|
119
135
|
});
|
|
120
136
|
//#endregion
|
|
121
137
|
//#region src/pdf/PdfFirstPage.tsx
|
|
@@ -195,7 +211,9 @@ function PdfFirstPage({ id, blockType, url, name }) {
|
|
|
195
211
|
if (cancelled) return;
|
|
196
212
|
const task = getDocument({
|
|
197
213
|
data,
|
|
198
|
-
wasmUrl: WASM_URL
|
|
214
|
+
wasmUrl: WASM_URL,
|
|
215
|
+
useWorkerFetch: false,
|
|
216
|
+
BinaryDataFactory: PdfBinaryDataFactory
|
|
199
217
|
});
|
|
200
218
|
loadingTaskRef.current = task;
|
|
201
219
|
const pdf = await task.promise;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docblocks-react-ui",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.3",
|
|
4
4
|
"description": "React rendering + editing layer for docblocks: hooks, block renderers, caret/selection, keyboard, clipboard.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"build": "tsdown && tailwindcss -i ui.entry.css -o dist/.tmp/ui-layer.css && node scripts/assemble-styles.mjs && node scripts/copy-pdf-worker.mjs",
|
|
81
81
|
"prepack": "npm run build",
|
|
82
82
|
"typecheck": "tsc --noEmit",
|
|
83
|
-
"test": "vitest run"
|
|
83
|
+
"test": "NODE_OPTIONS=--disable-warning=ExperimentalWarning vitest run"
|
|
84
84
|
},
|
|
85
85
|
"engines": {
|
|
86
86
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|