{"_id":"@aryagg/viewer-kit","name":"@aryagg/viewer-kit","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"@aryagg/viewer-kit","version":"0.0.1","description":"Extensible Svelte 5 viewers for documents, Office files, local DWG drawings, and open BIM models.","type":"module","sideEffects":["**/*.css"],"svelte":"./dist/index.js","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","svelte":"./dist/index.js"}},"scripts":{"dev":"vite dev --port 5173","build":"npm run prepack","prepack":"svelte-package && publint","check":"svelte-check --tsconfig ./tsconfig.json","check:watch":"svelte-check --tsconfig ./tsconfig.json --watch","lint":"prettier --check . && eslint .","format":"prettier --write ."},"peerDependencies":{"svelte":"^5.0.0"},"dependencies":{"@cadview/core":"^0.5.0","@node-projects/acad-ts":"2.4.0","three":"^0.185.0","web-ifc":"^0.0.77"},"devDependencies":{"@eslint/js":"^10.0.1","@sveltejs/package":"^2.5.8","@sveltejs/vite-plugin-svelte":"^6.2.4","@tailwindcss/vite":"^4.0.0","@types/node":"^22.20.1","@types/three":"^0.185.4","eslint":"^10.4.1","eslint-config-prettier":"^10.1.8","eslint-plugin-svelte":"^3.19.0","globals":"^17.6.0","prettier":"^3.8.3","prettier-plugin-svelte":"^4.1.0","publint":"^0.3.21","svelte":"^5.56.1","svelte-check":"^4.6.0","typescript":"^6.0.3","typescript-eslint":"^8.60.1","vite":"^7.3.6"},"keywords":["svelte","pdf","dwg","ifc","bim","gltf","file-viewer"],"repository":{"type":"git","url":"git+https://github.com/iron-throne/skeleton-packages.git","directory":"packages/viewer-kit"},"_id":"@aryagg/viewer-kit@0.0.1","gitHead":"e4b03911e609474505797432a27ac802af3f54fc","bugs":{"url":"https://github.com/iron-throne/skeleton-packages/issues"},"homepage":"https://github.com/iron-throne/skeleton-packages#readme","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-3nYGb0vw5E2RNKdTSWXW4UGbXNRDoJV3mkIWbbUviTcbNGHBbSKvuuNirIQpRObo2ajAhumZaSBAyykousKljQ==","shasum":"bc893422fb51a85aea7ca785630ed2a7cf2a6ca5","tarball":"https://registry.npmjs.org/@aryagg/viewer-kit/-/viewer-kit-0.0.1.tgz","fileCount":40,"unpackedSize":224690,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDA5HzMHkn0k2QYnD8MYyqPS1lo8UnZ6QbGaam70H6j3QIhAMdef7+p18uzsSiZ9f3PwvLqH46Jk9b5mNs/3Q0CMv5r"}]},"_npmUser":{"name":"aryagg","email":"aryaglekshmi@gmail.com"},"directories":{},"maintainers":[{"name":"aryagg","email":"aryaglekshmi@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/viewer-kit_0.0.1_1788509440303_0.6352215980111624"},"_hasShrinkwrap":false}},"time":{"created":"2026-09-04T08:10:40.053Z","0.0.1":"2026-09-04T08:10:40.506Z","modified":"2026-09-04T08:10:40.773Z"},"maintainers":[{"name":"aryagg","email":"aryaglekshmi@gmail.com"}],"description":"Extensible Svelte 5 viewers for documents, Office files, local DWG drawings, and open BIM models.","homepage":"https://github.com/iron-throne/skeleton-packages#readme","keywords":["svelte","pdf","dwg","ifc","bim","gltf","file-viewer"],"repository":{"type":"git","url":"git+https://github.com/iron-throne/skeleton-packages.git","directory":"packages/viewer-kit"},"bugs":{"url":"https://github.com/iron-throne/skeleton-packages/issues"},"readme":"# @aryagg/viewer-kit\r\n\r\nExtensible Svelte 5 file viewing components for documents, Office files, DWG drawings, and open BIM models. DWG, IFC, GLB, glTF, and SVG render locally in the browser without uploading files to a conversion service.\r\n\r\n## Install\r\n\r\n```sh\r\nnpm install @aryagg/viewer-kit\r\n```\r\n\r\n## Unified viewer\r\n\r\n```svelte\r\n<script lang=\"ts\">\r\n\timport { FileViewer } from '@aryagg/viewer-kit';\r\n</script>\r\n\r\n<FileViewer source=\"/documents/report.pdf\" heightClass=\"h-[80vh]\" />\r\n<FileViewer source=\"https://files.example.com/slides.pptx\" />\r\n<FileViewer source=\"https://files.example.com/budget.xlsx\" />\r\n<FileViewer source=\"/models/building.glb\" />\r\n<FileViewer source={localDwgFile} fileName={localDwgFile.name} />\r\n```\r\n\r\nThe type is detected from the URL, `fileName`, or `mimeType`. It can also be explicit:\r\n\r\n```svelte\r\n<FileViewer source={pdfBlob} type=\"pdf\" />\r\n```\r\n\r\nYou may import `PdfViewer`, `PowerPointViewer`, and `ExcelViewer` directly when automatic detection is not needed.\r\n\r\n## Local BIM and DWG viewer\r\n\r\nIFC is decoded locally with WebAssembly. IFC and GLB/glTF models include orbit, pan, zoom-to-fit, lighting, a reference grid, element picking, and property display. SVG drawings open directly:\r\n\r\n```svelte\r\n<FileViewer source=\"/models/coordination.glb\" />\r\n<FileViewer source=\"/drawings/level-01.svg\" />\r\n```\r\n\r\nDWG is decoded by local browser workers and rendered as an interactive 2D drawing. It includes pan, zoom, fit, entity selection, measurement, and layer visibility:\r\n\r\n```svelte\r\n<FileViewer source={dwgFile} fileName={dwgFile.name} />\r\n```\r\n\r\nThe DWG toolbar also includes a browser-local review layer. Reviewers can draw freehand strokes, arrows, and rectangles; place text and comment pins; resolve or reopen comments; delete marks; and use undo/redo. Markups are stored in drawing coordinates, so they remain aligned while panning, zooming, or switching between Model and the saved Sheet. Completed edits are saved automatically in this browser, while **Save** writes immediately. **Export** creates a validated `*.dwg-review.json` sidecar for sharing or backup, and **Import** restores a matching review. This never writes into or changes the source DWG, and local saves do not synchronize between devices without exporting the JSON or adding a backend.\r\n\r\nLocal files should come from a browser file input. A Windows path such as `C:/Models/building.ifc` is not a browser-readable URL:\r\n\r\n```svelte\r\n<script lang=\"ts\">\r\n\timport { FileViewer } from '@aryagg/viewer-kit';\r\n\tlet model = $state<File>();\r\n</script>\r\n\r\n<input\r\n\ttype=\"file\"\r\n\taccept=\".dwg,.ifc,.glb,.gltf,.svg\"\r\n\tonchange={(event) => (model = event.currentTarget.files?.[0])}\r\n/>\r\n{#if model}<FileViewer source={model} fileName={model.name} />{/if}\r\n```\r\n\r\nServe the built app over HTTP or HTTPS (an existing static web server is enough). Browsers do not reliably allow module workers or local-file fetching from an SMB/`file://` page.\r\n\r\nThe DWG bridge uses the pure-TypeScript `@node-projects/acad-ts` reader inside a terminable browser worker with file-size, output-size, and elapsed-time safety limits. It writes the graphical DXF sections needed for preview while deliberately excluding the non-graphical object dictionary. Generated DXF is displayed only when it parses, contains a complete `ENTITIES` section, ends with `EOF`, and has finite geometry. The viewer reports when model-space entities could not be represented, and no drawing bytes are uploaded.\r\n\r\nDWGs up to 64 MiB start automatically. Files from 64 to 192 MiB require an explicit confirmation because local decoding can consume more than 1 GB of memory; larger files are rejected to protect the tab. Selected `File`/`Blob` data is passed directly to the worker so the main page does not make another full-size copy.\r\n\r\nAutoCAD Architecture and Civil 3D AEC/custom objects are not ordinary DWG drawing entities. If a drawing contains only those objects, the viewer reports that no browser-renderable model-space geometry exists. Use a matching PDF/DXF export for viewing, or use the authoring application to flatten/export the objects to standard AutoCAD entities first. Merely changing the DWG release number does not convert custom objects into standard geometry.\r\n\r\nWhen a rejected DWG contains an embedded PNG or BMP thumbnail, the error view displays it as a clearly marked, non-interactive reference. `ViewerModal` also offers a companion-PDF picker and switches its header and content to that PDF without closing. The user must select the PDF explicitly: browser file pickers intentionally do not reveal the selected DWG's folder or grant access to sibling files.\r\n\r\nThis means no backend, cloud converter, hosted SDK, account, or upload is required. It is not literally dependency-free: the viewer embeds open-source parsing and rendering libraries. DWG is presented as 2D CAD geometry; use IFC/GLB for BIM elements and properties. Password-protected, damaged, or application-specific custom objects can still be rejected or omitted.\r\n\r\nRVT, NWD, and NWC still require export to IFC or GLB before opening. The DWG reader and 2D renderer are MIT-licensed open-source dependencies; review the [acad-ts source](https://github.com/node-projects/acad-ts) and [CadView core source](https://github.com/wiscaksono/cadview/tree/main/packages/core) when preparing a distribution.\r\n\r\n## Page and popup viewers\r\n\r\nUse `ViewerPage` for a complete document-viewing screen with a modern header and file actions:\r\n\r\n```svelte\r\n<ViewerPage source={documentUrl} fileName=\"Project presentation.pptx\" />\r\n```\r\n\r\nThe parent controls the header branding and typography:\r\n\r\n```svelte\r\n<ViewerPage\r\n\t{source}\r\n\tfileName=\"Project presentation.pptx\"\r\n\tappTitle=\"ARYA Document Center\"\r\n\tappSubtitle=\"Project files and presentations\"\r\n\theaderClass=\"border-slate-700 bg-slate-950 font-mono text-white\"\r\n\ttitleClass=\"text-base tracking-tight\"\r\n\tsubtitleClass=\"text-slate-400\"\r\n\taccentClass=\"bg-cyan-400/10 text-cyan-300 ring-cyan-400/30\"\r\n\tprimaryActionClass=\"border-cyan-500 bg-cyan-500 text-slate-950\"\r\n/>\r\n```\r\n\r\nThe same Tailwind class properties work on `ViewerModal`. When `appTitle` or `appSubtitle` is omitted, the viewer falls back to the file name and detected format. Components contain no internal CSS or inline styles.\r\n\r\nUse `ViewerModal` for an accessible popup. `open` is bindable and the popup closes from its button, backdrop, or Escape key:\r\n\r\n```svelte\r\n<script lang=\"ts\">\r\n\timport { ViewerModal } from '@aryagg/viewer-kit';\r\n\tlet open = $state(false);\r\n</script>\r\n\r\n<button onclick={() => (open = true)}>Preview</button>\r\n<ViewerModal bind:open {source} fileName=\"Report.pdf\" />\r\n```\r\n\r\n## PowerPoint limitation\r\n\r\nBrowsers do not render PowerPoint files natively. By default, `PowerPointViewer` uses Microsoft Office's online embed viewer, so the document URL must be reachable by that service. Private files, authenticated URLs, `Blob`s, and localhost files need to be converted to PDF/images on a backend or served through a custom viewer.\r\n\r\nSupply a custom embed adapter when your project has one:\r\n\r\n```svelte\r\n<FileViewer\r\n\tsource={privatePresentationUrl}\r\n\ttype=\"pptx\"\r\n\tpowerPointEmbedUrl={(url) => `/presentation-preview?source=${encodeURIComponent(url)}`}\r\n/>\r\n```\r\n\r\nExcel uses the same Office web-viewer requirement. Public workbook URLs work by default. For private workbooks, provide `excelEmbedUrl` with your own preview service.\r\n\r\n## Events and errors\r\n\r\nUse callback props for loading and error handling:\r\n\r\n```svelte\r\n<FileViewer\r\n\t{source}\r\n\tonload={() => console.log('loaded')}\r\n\tonerror={(error) => console.error(error.code, error.message)}\r\n/>\r\n```\r\n\r\n## Development\r\n\r\n```sh\r\nnpm install\r\nnpm run check\r\nnpm run build\r\nnpm run dev\r\n```\r\n","readmeFilename":"README.md","_rev":"1-3e029e7c57204e05a8ca712fe02f2fda"}