Spaces:
Running
Running
Download src/sample.mjs from NagaYu/dasumae-doc: direct link, hf CLI and curl.
- Browser
- Download file 5.97 kB
-
https://huggingface.co/spaces/NagaYu/dasumae-doc/resolve/main/src/sample.mjs
- Command line
-
hf download hf://spaces/NagaYu/dasumae-doc/src/sample.mjs
-
curl -L -o sample.mjs https://huggingface.co/spaces/NagaYu/dasumae-doc/resolve/main/src/sample.mjs
5.97 kB
| // DasuMae Doc -- in-browser sample document generator. | |
| // Builds a small planted .docx using the core's own ZIP writer (Pkg/fflate), so | |
| // a visitor without a dirty file sees the X-ray immediately. All content is | |
| // obviously fictional. Runs through the same inspect() / scrub() flow as a real | |
| // upload. | |
| import { Pkg } from './ooxml.mjs'; | |
| const XD = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'; | |
| const W = 'http://schemas.openxmlformats.org/wordprocessingml/2006/main'; | |
| const R = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'; | |
| const PR = 'http://schemas.openxmlformats.org/package/2006/relationships'; | |
| const CT = 'http://schemas.openxmlformats.org/package/2006/content-types'; | |
| // Fictional sample content (clearly not real). | |
| export const SAMPLE = { | |
| filename: 'sample-proposal.docx', | |
| creator: 'Pat Rivera', | |
| company: 'Nimbus Partners LLC (sample)', | |
| clientCode: 'NIMBUS-DEMO-2024', | |
| deleted: 'Our actual floor price is 30 percent lower than this quote.', | |
| comment: 'Do not send this version to the client.', | |
| }; | |
| export function sampleDocxBytes() { | |
| const pkg = new Pkg(); | |
| pkg.setText('[Content_Types].xml', XD | |
| + `<Types xmlns="${CT}">` | |
| + '<Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/>' | |
| + '<Default Extension="xml" ContentType="application/xml"/>' | |
| + '<Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/>' | |
| + '<Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/>' | |
| + '<Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/>' | |
| + '<Override PartName="/word/comments.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml"/>' | |
| + '<Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>' | |
| + '<Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/>' | |
| + '<Override PartName="/docProps/custom.xml" ContentType="application/vnd.openxmlformats-officedocument.custom-properties+xml"/>' | |
| + '</Types>'); | |
| pkg.setText('_rels/.rels', XD | |
| + `<Relationships xmlns="${PR}">` | |
| + `<Relationship Id="rIdDoc" Type="${R}/officeDocument" Target="word/document.xml"/>` | |
| + '<Relationship Id="rIdCore" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/>' | |
| + `<Relationship Id="rIdApp" Type="${R}/extended-properties" Target="docProps/app.xml"/>` | |
| + `<Relationship Id="rIdCustom" Type="${R}/custom-properties" Target="docProps/custom.xml"/>` | |
| + '</Relationships>'); | |
| pkg.setText('docProps/core.xml', XD | |
| + '<cp:coreProperties ' | |
| + 'xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" ' | |
| + 'xmlns:dc="http://purl.org/dc/elements/1.1/" ' | |
| + 'xmlns:dcterms="http://purl.org/dc/terms/" ' | |
| + 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">' | |
| + `<dc:creator>${SAMPLE.creator}</dc:creator>` | |
| + `<cp:lastModifiedBy>${SAMPLE.creator}</cp:lastModifiedBy>` | |
| + '<cp:revision>4</cp:revision>' | |
| + '<dc:title>Draft proposal</dc:title>' | |
| + '<dcterms:created xsi:type="dcterms:W3CDTF">2026-02-10T08:00:00Z</dcterms:created>' | |
| + '<dcterms:modified xsi:type="dcterms:W3CDTF">2026-02-11T09:30:00Z</dcterms:modified>' | |
| + '</cp:coreProperties>'); | |
| pkg.setText('docProps/app.xml', XD | |
| + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">' | |
| + `<Application></Application><Company>${SAMPLE.company}</Company>` | |
| + '</Properties>'); | |
| pkg.setText('docProps/custom.xml', XD | |
| + '<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/custom-properties" ' | |
| + 'xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">' | |
| + '<property fmtid="{D5CDD505-2E9C-101B-9397-08002B2CF9AE}" pid="2" name="ClientCode">' | |
| + `<vt:lpwstr>${SAMPLE.clientCode}</vt:lpwstr></property></Properties>`); | |
| pkg.setText('word/styles.xml', XD | |
| + `<w:styles xmlns:w="${W}"><w:docDefaults><w:rPrDefault/><w:pPrDefault/></w:docDefaults></w:styles>`); | |
| pkg.setText('word/settings.xml', XD | |
| + `<w:settings xmlns:w="${W}" xmlns:r="${R}">` | |
| + '<w:rsids><w:rsidRoot w:val="00C2A1B4"/><w:rsid w:val="00C2A1B4"/></w:rsids>' | |
| + '</w:settings>'); | |
| pkg.setText('word/_rels/document.xml.rels', XD | |
| + `<Relationships xmlns="${PR}">` | |
| + `<Relationship Id="rIdStyles" Type="${R}/styles" Target="styles.xml"/>` | |
| + `<Relationship Id="rIdSettings" Type="${R}/settings" Target="settings.xml"/>` | |
| + `<Relationship Id="rIdComments" Type="${R}/comments" Target="comments.xml"/>` | |
| + '</Relationships>'); | |
| pkg.setText('word/document.xml', XD | |
| + `<w:document xmlns:w="${W}" xmlns:r="${R}"><w:body>` | |
| + '<w:p><w:r><w:t>Nimbus Partners — Proposal (sample)</w:t></w:r></w:p>' | |
| + '<w:p>' | |
| + '<w:r><w:t xml:space="preserve">Thank you for the opportunity. </w:t></w:r>' | |
| + '<w:del w:id="1" w:author="Pat Rivera" w:date="2026-02-11T09:12:00Z">' | |
| + `<w:r><w:delText xml:space="preserve">${SAMPLE.deleted} </w:delText></w:r></w:del>` | |
| + '<w:commentRangeStart w:id="0"/>' | |
| + '<w:r><w:t>Our quoted price is final.</w:t></w:r>' | |
| + '<w:commentRangeEnd w:id="0"/>' | |
| + '<w:r><w:commentReference w:id="0"/></w:r>' | |
| + '</w:p>' | |
| + '<w:sectPr><w:pgSz w:w="12240" w:h="15840"/></w:sectPr>' | |
| + '</w:body></w:document>'); | |
| pkg.setText('word/comments.xml', XD | |
| + `<w:comments xmlns:w="${W}">` | |
| + '<w:comment w:id="0" w:author="Pat Rivera" w:date="2026-02-11T09:15:00Z" w:initials="PR">' | |
| + `<w:p><w:r><w:t>${SAMPLE.comment}</w:t></w:r></w:p></w:comment></w:comments>`); | |
| return pkg.write(); | |
| } | |