@docx-editor.dev/pro 2.32.0 → 2.33.0

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.
Files changed (78) hide show
  1. package/README.md +17 -3
  2. package/dist/{chunk-3WTOHPAB.js → chunk-25A5N6OL.js} +1 -1
  3. package/dist/chunk-3HW2VWFW.js +1 -0
  4. package/dist/chunk-3MIZFGHH.cjs +1 -0
  5. package/dist/chunk-46N5DWZV.cjs +1 -0
  6. package/dist/chunk-65JEI6FY.cjs +5 -0
  7. package/dist/chunk-ENMURXLJ.js +1 -0
  8. package/dist/chunk-EOZ44UA7.js +1 -0
  9. package/dist/chunk-GLYQ72LS.cjs +6 -0
  10. package/dist/{chunk-RYF4SNKX.cjs → chunk-GOUTDQFX.cjs} +1 -1
  11. package/dist/chunk-HMU7J34H.js +1 -0
  12. package/dist/chunk-IULA3QRZ.cjs +1 -0
  13. package/dist/chunk-QEULTKCT.cjs +1 -0
  14. package/dist/{chunk-OT5R3IYV.cjs → chunk-QOXYHVBM.cjs} +1 -1
  15. package/dist/chunk-SINNHH3H.js +1 -0
  16. package/dist/chunk-SL6K2CUL.js +6 -0
  17. package/dist/chunk-STTJA26X.js +1 -0
  18. package/dist/chunk-VY7374QP.cjs +1 -0
  19. package/dist/chunk-WGBOER6G.js +1 -0
  20. package/dist/{chunk-MHB6ID2P.cjs → chunk-WX43PF3Z.cjs} +1 -1
  21. package/dist/chunk-WYVEFRAM.js +5 -0
  22. package/dist/collaboration/hocuspocus.cjs +1 -1
  23. package/dist/collaboration/hocuspocus.js +1 -1
  24. package/dist/collaboration/index.cjs +2 -2
  25. package/dist/collaboration/index.d.cts +2 -1
  26. package/dist/collaboration/index.d.ts +2 -1
  27. package/dist/collaboration/index.js +1 -1
  28. package/dist/collaboration/webrtc.cjs +1 -1
  29. package/dist/collaboration/webrtc.js +1 -1
  30. package/dist/{collaboration-module-DWn2heE1.d.cts → collaboration-module-02CIP5sN.d.cts} +2 -20
  31. package/dist/{collaboration-module-DWn2heE1.d.ts → collaboration-module-COZAgqwg.d.ts} +2 -20
  32. package/dist/{define-custom-node-D0c36PpZ.d.ts → define-custom-node-CISpZvVB.d.cts} +8 -3
  33. package/dist/{define-custom-node-CNRQG1TI.d.cts → define-custom-node-DE1KjR1r.d.ts} +8 -3
  34. package/dist/document-session-4NUOLWKQ.cjs +1 -0
  35. package/dist/document-session-5VAD24RH.js +1 -0
  36. package/dist/drawing/index.cjs +1 -0
  37. package/dist/drawing/index.d.cts +112 -0
  38. package/dist/drawing/index.d.ts +112 -0
  39. package/dist/drawing/index.js +1 -0
  40. package/dist/index.cjs +1 -1
  41. package/dist/index.d.cts +4 -3
  42. package/dist/index.d.ts +4 -3
  43. package/dist/index.js +1 -1
  44. package/dist/license-D-ds5Y7c.d.cts +20 -0
  45. package/dist/license-D-ds5Y7c.d.ts +20 -0
  46. package/dist/metafile-raster-3MCAHWYO.js +1 -0
  47. package/dist/metafile-raster-DWGCWQTU.cjs +1 -0
  48. package/dist/metafile-replay-GHPEUR2W.js +1 -0
  49. package/dist/metafile-replay-NZWGGGZR.cjs +1 -0
  50. package/dist/react/hocuspocus.cjs +1 -1
  51. package/dist/react/hocuspocus.js +1 -1
  52. package/dist/react/index.cjs +2 -2
  53. package/dist/react/index.d.cts +81 -22
  54. package/dist/react/index.d.ts +81 -22
  55. package/dist/react/index.js +2 -2
  56. package/dist/react/webrtc.cjs +1 -1
  57. package/dist/react/webrtc.js +1 -1
  58. package/dist/vue/hocuspocus.cjs +1 -1
  59. package/dist/vue/hocuspocus.js +1 -1
  60. package/dist/vue/index.cjs +2 -2
  61. package/dist/vue/index.d.cts +61 -18
  62. package/dist/vue/index.d.ts +61 -18
  63. package/dist/vue/index.js +2 -2
  64. package/dist/vue/webrtc.cjs +1 -1
  65. package/dist/vue/webrtc.js +1 -1
  66. package/package.json +11 -5
  67. package/dist/chunk-AVZO5ZHZ.js +0 -1
  68. package/dist/chunk-DLYVBBO7.js +0 -1
  69. package/dist/chunk-GAGYRL3L.js +0 -5
  70. package/dist/chunk-HMSOWKXT.js +0 -1
  71. package/dist/chunk-I6HVINA4.cjs +0 -1
  72. package/dist/chunk-MWO2ZUEJ.js +0 -1
  73. package/dist/chunk-PMS3PGOE.cjs +0 -1
  74. package/dist/chunk-Q2VBO66F.js +0 -1
  75. package/dist/chunk-QLZH2Q2C.cjs +0 -1
  76. package/dist/chunk-YOWEY5F3.cjs +0 -5
  77. package/dist/document-session-B35ZX2W4.js +0 -1
  78. package/dist/document-session-V3O7XBJY.cjs +0 -1
@@ -0,0 +1,112 @@
1
+ /**
2
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
3
+ *
4
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
5
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
6
+ * with its drawing. This module adds:
7
+ *
8
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
9
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
10
+ * - the layout of a SmartArt diagram saved without its drawing;
11
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
12
+ * dark-edged bevel;
13
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
14
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
15
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
16
+ * metafile's own drawing origin.
17
+ *
18
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
19
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
20
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
21
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
22
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
23
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
24
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
25
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
26
+ * this module.
27
+ *
28
+ * The renderers serve every editor and export in the process. Install them before any
29
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
30
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
31
+ * metafile picture.
32
+ *
33
+ * @example Enable advanced drawing rendering in an editor
34
+ * ```ts
35
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
36
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
37
+ *
38
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
39
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
40
+ * const editor = createDocxEditor({ document: bytes, modules });
41
+ * ```
42
+ *
43
+ * @packageDocumentation
44
+ * @public
45
+ */
46
+ import { EditorModule } from '@docx-editor.dev/core/editor';
47
+ import { P as ProLicenseOptions } from '../license-D-ds5Y7c.js';
48
+
49
+ /**
50
+ * `@docx-editor.dev/pro/drawing` — advanced drawing rendering.
51
+ *
52
+ * The free engine paints pictures, shapes with fills, gradients, patterns, lines and outer
53
+ * shadows, text boxes, groups, canvases, text watermarks, and every SmartArt diagram saved
54
+ * with its drawing. This module adds:
55
+ *
56
+ * - charts, drawn from the values cached in their chart parts. Treemap, sunburst and map
57
+ * charts, and charts that mix a pie or radar plot with other plot types, do not render;
58
+ * - the layout of a SmartArt diagram saved without its drawing;
59
+ * - shape and picture effects: glow, inner shadow, reflection, soft edge, and the rim of a
60
+ * dark-edged bevel;
61
+ * - WordArt: VML text paths outside a watermark, fitted to the shape, between two guides, or
62
+ * along an arch, with gradient fills, shadows and 3-D extrusion;
63
+ * - EMF and WMF pictures: a vector replay for PDF export, and a browser raster that honors a
64
+ * metafile's own drawing origin.
65
+ *
66
+ * Without it, or for a chart it does not render, a chart saved with a fallback picture or
67
+ * drawing shows that fallback. In every state a chart selects as an object: picture commands
68
+ * are refused, and deleting it removes the chart with its fallback, as one tracked deletion
69
+ * of the whole chart when change tracking is on. Copy and cut of a selection that includes a
70
+ * chart are refused. The editor shows a labeled placeholder for other visible charts with
71
+ * usable bounds, including a skipped `mc:Choice` with an empty `mc:Fallback`, and a diagram
72
+ * saved without its drawing, and inline WordArt; floating WordArt does not show. The editor still rasterizes
73
+ * EMF and WMF pictures, and a shape paints without those effects. PDF export always includes
74
+ * this module.
75
+ *
76
+ * The renderers serve every editor and export in the process. Install them before any
77
+ * document opens; a later install logs a console warning once. `reviewModule()` installs them
78
+ * too. The metafile replay and `emf-converter` load on first use, only when a document holds a
79
+ * metafile picture.
80
+ *
81
+ * @example Enable advanced drawing rendering in an editor
82
+ * ```ts
83
+ * import { createDocxEditor } from '@docx-editor.dev/core/editor';
84
+ * import { drawingModule } from '@docx-editor.dev/pro/drawing';
85
+ *
86
+ * // Next.js; with Vite, read import.meta.env.VITE_DOCX_LICENSE.
87
+ * const modules = [drawingModule({ licenseKey: process.env.NEXT_PUBLIC_DOCX_LICENSE })];
88
+ * const editor = createDocxEditor({ document: bytes, modules });
89
+ * ```
90
+ *
91
+ * @packageDocumentation
92
+ * @public
93
+ */
94
+
95
+ /**
96
+ * Install the drawing renderers (charts, SmartArt layout, effects, WordArt, and metafiles) for
97
+ * every editor and export in this process, without an editor module: for headless
98
+ * conversion. Installing again is harmless. A host without the EigenPal Pro License leaves
99
+ * this call out; its charts then show their fallback pictures or drawings, or placeholders.
100
+ *
101
+ * @public
102
+ */
103
+ declare function installDrawing(options?: ProLicenseOptions): void;
104
+ /**
105
+ * The drawing module for `createDocxEditor({ modules })`. Creating it installs the drawing
106
+ * renderers process-wide, as {@link installDrawing} does.
107
+ *
108
+ * @public
109
+ */
110
+ declare function drawingModule(options?: ProLicenseOptions): EditorModule;
111
+
112
+ export { ProLicenseOptions, drawingModule, installDrawing };
@@ -0,0 +1 @@
1
+ export{b as drawingModule,a as installDrawing}from'../chunk-SL6K2CUL.js';import'../chunk-HMU7J34H.js';
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- 'use strict';var chunkI6HVINA4_cjs=require('./chunk-I6HVINA4.cjs'),chunkQLZH2Q2C_cjs=require('./chunk-QLZH2Q2C.cjs'),store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkI6HVINA4_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkI6HVINA4_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkI6HVINA4_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkI6HVINA4_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkI6HVINA4_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!chunkI6HVINA4_cjs.k.test(t.tagPrefix)||!chunkI6HVINA4_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkI6HVINA4_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkI6HVINA4_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkI6HVINA4_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkI6HVINA4_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkI6HVINA4_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkI6HVINA4_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkI6HVINA4_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQLZH2Q2C_cjs.b}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;
1
+ 'use strict';var chunkVY7374QP_cjs=require('./chunk-VY7374QP.cjs'),chunkQEULTKCT_cjs=require('./chunk-QEULTKCT.cjs');require('./chunk-GLYQ72LS.cjs'),require('./chunk-IULA3QRZ.cjs');var store=require('@docx-editor.dev/core/store');function U(t,n={}){let r=L(t);if(!r)return [];let o=n.nodes??t.getCustomNodeDefinitions().filter(chunkVY7374QP_cjs.j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>chunkVY7374QP_cjs.n(e,o,{payloads:store.customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=store.readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=chunkVY7374QP_cjs.c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(chunkVY7374QP_cjs.h))],e=o.package,u=0,c=0,g=V(e);for(let i of g){let p=store.withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c+=p.removed;}let l=store.withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:store.writeOoxmlPackage(e),unwrapped:u,removed:c}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&store.isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(chunkVY7374QP_cjs.j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!chunkVY7374QP_cjs.k.test(t.tagPrefix)||!chunkVY7374QP_cjs.k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=chunkVY7374QP_cjs.b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:store.fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=chunkVY7374QP_cjs.i(t,n.data);if(!o.ok)return {reason:o.reason};let s=chunkVY7374QP_cjs.h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=store.datastoreItemIdFor(`${s} ${e} ${m}`),g=store.customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},chunkVY7374QP_cjs.g,m);if(!g)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g,store:{itemPartName:e,itemXml:`<${chunkVY7374QP_cjs.g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${chunkVY7374QP_cjs.g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${store.DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:store.CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:store.CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:store.CUSTOM_XML_PROPS_TYPE}}}}Object.defineProperty(exports,"CUSTOM_NODE_STORE_ROOT",{enumerable:true,get:function(){return chunkVY7374QP_cjs.g}});Object.defineProperty(exports,"MAX_CUSTOM_NODE_DATA_LENGTH",{enumerable:true,get:function(){return chunkVY7374QP_cjs.d}});Object.defineProperty(exports,"MAX_TAG_LENGTH",{enumerable:true,get:function(){return chunkVY7374QP_cjs.a}});Object.defineProperty(exports,"customNodeNamespace",{enumerable:true,get:function(){return chunkVY7374QP_cjs.h}});Object.defineProperty(exports,"customNodesModule",{enumerable:true,get:function(){return chunkVY7374QP_cjs.m}});Object.defineProperty(exports,"decodeCustomNodeTag",{enumerable:true,get:function(){return chunkVY7374QP_cjs.c}});Object.defineProperty(exports,"defineCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.l}});Object.defineProperty(exports,"encodeCustomNodeTag",{enumerable:true,get:function(){return chunkVY7374QP_cjs.b}});Object.defineProperty(exports,"insertCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.p}});Object.defineProperty(exports,"isCustomNodeDefinition",{enumerable:true,get:function(){return chunkVY7374QP_cjs.j}});Object.defineProperty(exports,"parseCustomNodeData",{enumerable:true,get:function(){return chunkVY7374QP_cjs.e}});Object.defineProperty(exports,"recognizeCustomNodes",{enumerable:true,get:function(){return chunkVY7374QP_cjs.n}});Object.defineProperty(exports,"removeCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.q}});Object.defineProperty(exports,"reviewModule",{enumerable:true,get:function(){return chunkVY7374QP_cjs.o}});Object.defineProperty(exports,"serializeCustomNodeData",{enumerable:true,get:function(){return chunkVY7374QP_cjs.f}});Object.defineProperty(exports,"updateCustomNode",{enumerable:true,get:function(){return chunkVY7374QP_cjs.r}});Object.defineProperty(exports,"collaborationModule",{enumerable:true,get:function(){return chunkQEULTKCT_cjs.a}});exports.customNodeXml=K;exports.customNodesOf=U;exports.prepareForExport=E;exports.saveForExport=G;
package/dist/index.d.cts CHANGED
@@ -23,9 +23,10 @@
23
23
  * @packageDocumentation
24
24
  * @public
25
25
  */
26
- import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-CNRQG1TI.cjs';
27
- export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-CNRQG1TI.cjs';
28
- export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-DWn2heE1.cjs';
26
+ import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-CISpZvVB.cjs';
27
+ export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-CISpZvVB.cjs';
28
+ export { C as CollaborationModuleOptions, c as collaborationModule } from './collaboration-module-02CIP5sN.cjs';
29
+ export { P as ProLicenseOptions } from './license-D-ds5Y7c.cjs';
29
30
  import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
30
31
  export { CommentMarkerStyle, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
31
32
  import '@docx-editor.dev/core/store';
package/dist/index.d.ts CHANGED
@@ -23,9 +23,10 @@
23
23
  * @packageDocumentation
24
24
  * @public
25
25
  */
26
- import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-D0c36PpZ.js';
27
- export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-D0c36PpZ.js';
28
- export { C as CollaborationModuleOptions, P as ProLicenseOptions, c as collaborationModule } from './collaboration-module-DWn2heE1.js';
26
+ import { A as AnyCustomNodeDefinition, C as CustomNodeDiagnostic, R as RecognizedCustomNode, S as StandardSchemaV1, I as InferSchemaInput, a as CustomNodeDefinition } from './define-custom-node-DE1KjR1r.js';
27
+ export { b as ActivatedCustomNode, c as CustomNode, d as CustomNodeDataRejection, e as CustomNodeDataResult, f as CustomNodePayloadSource, g as CustomNodesModuleOptions, h as InferSchemaOutput, M as MAX_CUSTOM_NODE_DATA_LENGTH, i as RecognizeCustomNodesOptions, j as ReviewModuleOptions, k as StandardSchemaIssue, l as StandardSchemaResult, m as customNodesModule, n as defineCustomNode, o as isCustomNodeDefinition, p as parseCustomNodeData, r as recognizeCustomNodes, q as reviewModule, s as serializeCustomNodeData } from './define-custom-node-DE1KjR1r.js';
28
+ export { C as CollaborationModuleOptions, c as collaborationModule } from './collaboration-module-COZAgqwg.js';
29
+ export { P as ProLicenseOptions } from './license-D-ds5Y7c.js';
29
30
  import { Editor, ExecResult } from '@docx-editor.dev/core/contracts/editor';
30
31
  export { CommentMarkerStyle, ResolvedReviewPane, ReviewPaneOpening, ReviewPaneOptions, ReviewPaneOverflow, RevisionDisplay } from '@docx-editor.dev/core/editor';
31
32
  import '@docx-editor.dev/core/store';
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import {j,n,h,k,b,i,g,c}from'./chunk-AVZO5ZHZ.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-AVZO5ZHZ.js';export{b as collaborationModule}from'./chunk-Q2VBO66F.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function U(t,n$1={}){let r=L(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,g=V(e);for(let i of g){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),g$1=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!g$1)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g$1,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{K as customNodeXml,U as customNodesOf,E as prepareForExport,G as saveForExport};
1
+ import {j,n,h,k,b,i,g,c}from'./chunk-WGBOER6G.js';export{g as CUSTOM_NODE_STORE_ROOT,d as MAX_CUSTOM_NODE_DATA_LENGTH,a as MAX_TAG_LENGTH,h as customNodeNamespace,m as customNodesModule,c as decodeCustomNodeTag,l as defineCustomNode,b as encodeCustomNodeTag,p as insertCustomNode,j as isCustomNodeDefinition,e as parseCustomNodeData,n as recognizeCustomNodes,q as removeCustomNode,o as reviewModule,f as serializeCustomNodeData,r as updateCustomNode}from'./chunk-WGBOER6G.js';export{a as collaborationModule}from'./chunk-EOZ44UA7.js';import'./chunk-SL6K2CUL.js';import'./chunk-HMU7J34H.js';import {customNodePayloadsByControl,readOoxmlPackage,withExportedCustomNodes,writeOoxmlPackage,isStoryPart,fnv1a32,datastoreItemIdFor,customNodeBinding,CUSTOM_XML_PROPS_TYPE,CUSTOM_XML_REL,CUSTOM_XML_PROPS_REL,DATASTORE_NAMESPACE_URI}from'@docx-editor.dev/core/store';function U(t,n$1={}){let r=L(t);if(!r)return [];let o=n$1.nodes??t.getCustomNodeDefinitions().filter(j);if(o.length===0)return [];let s=r.session.currentPackage(),d=r.session.part().name,m=n$1.onDiagnostic??(e=>{t.reportCustomNodeDiagnostic(e);});return r.session.storyParts().flatMap(e=>n(e,o,{payloads:customNodePayloadsByControl(s,e.name,d),onDiagnostic:m}))}function L(t){return t.surface??null}function E(t,n,r={}){if(r.destination==="internal")return {ok:true,bytes:t,unwrapped:0,removed:0};let o=readOoxmlPackage(t);if(!o.ok)return {ok:false,reason:`the document could not be read: ${o.reason}`};let s=new Map;for(let i of n)s.set(`${i.tagPrefix}:${i.name}`,i);let d=i=>{let p=c(i);if(!p)return "keep";let x=s.get(`${p.prefix}:${p.name}`);return x?x.preserveOnExport==="text"?"text":x.preserveOnExport===false?"remove":"keep":"keep"},m=[...new Set(n.filter(i=>i.preserveOnExport!==void 0).filter(i=>i.preserveOnExport!==true).map(h))],e=o.package,u=0,c$1=0,g=V(e);for(let i of g){let p=withExportedCustomNodes(e,{storyPartName:i,namespaces:[],decide:d});if(!p.ok)return {ok:false,reason:p.reason};e=p.pkg,u+=p.unwrapped,c$1+=p.removed;}let l=withExportedCustomNodes(e,{storyPartName:e.mainDocumentPart,namespaces:m,decide:()=>"keep"});return l.ok?(e=l.pkg,{ok:true,bytes:writeOoxmlPackage(e),unwrapped:u,removed:c$1}):{ok:false,reason:l.reason}}function V(t){let n=[];for(let[r,o]of t.parts)r!==t.mainDocumentPart&&isStoryPart(o)&&n.push(r);return [t.mainDocumentPart,...n]}async function G(t,n={}){let r=n.nodes??t.getCustomNodeDefinitions().filter(j),o=await t.save();return E(new Uint8Array(o),r,{...n.destination===void 0?{}:{destination:n.destination}})}function a(t){return t.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F]/g,"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;")}function K(t,n,r,o={}){if(!k.test(t.tagPrefix)||!k.test(t.name))return {ok:false,code:"invalidArgs",reason:"the definition identity must match defineCustomNode\u2019s charset ([A-Za-z0-9_.-])"};let s=b(t.tagPrefix,t.name,n);if(!s.ok)return {ok:false,code:"invalidArgs",reason:`the encoded tag is ${s.length} characters; Word caps w:tag at 64 \u2014 shorten the attrs`};let d=o.lock===void 0?"contentLocked":o.lock,m=o.id!==void 0&&Number.isInteger(o.id)&&o.id>0?o.id:fnv1a32(`${s.tag}\0${r}`)&2147483647||1,e=o.data===void 0?null:Q(t,o,r);if(e&&"reason"in e)return {ok:false,code:"invalidArgs",reason:e.reason};let u=(o.alias!==void 0?`<w:alias w:val="${a(o.alias)}"/>`:"")+`<w:tag w:val="${a(s.tag)}"/><w:id w:val="${m}"/>`+(d===false?"":`<w:lock w:val="${d}"/>`)+(e?`<w:dataBinding w:prefixMappings="${a(e.binding.prefixMappings)}" w:xpath="${a(e.binding.xpath)}" w:storeItemID="${a(e.binding.storeItemId)}"/>`:""),c=`<w:r><w:t xml:space="preserve">${a(r)}</w:t></w:r>`;return {ok:true,xml:`<w:sdt><w:sdtPr>${u}</w:sdtPr><w:sdtContent>${c}</w:sdtContent></w:sdt>`,...e?{store:e.store}:{}}}function Q(t,n,r){let o=i(t,n.data);if(!o.ok)return {reason:o.reason};let s=h(t),d=n.storeIndex!==void 0&&Number.isInteger(n.storeIndex)&&n.storeIndex>0?n.storeIndex:1,m=n.nodeId??"cx1",e=`/customXml/item${String(d)}.xml`,u=`/customXml/itemProps${String(d)}.xml`,c=datastoreItemIdFor(`${s} ${e} ${m}`),g$1=customNodeBinding({partName:e,propsPartName:u,itemId:c,namespaceUri:s},g,m);if(!g$1)return {reason:`the payload cannot be addressed by an XPath: check nodeId (${m}) and payloadNamespace`};let l=r===r.trim()?`<label>${a(r)}</label>`:`<label xml:space="preserve">${a(r)}</label>`;return {binding:g$1,store:{itemPartName:e,itemXml:`<${g} xmlns="${a(s)}"><node id="${a(m)}">${l}<data>${a(o.data)}</data></node></${g}>`,propsPartName:u,propsXml:`<ds:datastoreItem ds:itemID="${a(c)}" xmlns:ds="${DATASTORE_NAMESPACE_URI}"><ds:schemaRefs><ds:schemaRef ds:uri="${a(s)}"/></ds:schemaRefs></ds:datastoreItem>`,storeItemId:c,relationships:[{from:"/word/document.xml",type:CUSTOM_XML_REL,target:`../customXml/item${String(d)}.xml`},{from:e,type:CUSTOM_XML_PROPS_REL,target:`itemProps${String(d)}.xml`}],contentTypeOverride:{partName:u,contentType:CUSTOM_XML_PROPS_TYPE}}}}export{K as customNodeXml,U as customNodesOf,E as prepareForExport,G as saveForExport};
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensing, v1: honor system.
3
+ *
4
+ * The key is accepted and remembered so that adding offline (Ed25519)
5
+ * verification later is not a breaking change — but nothing validates it,
6
+ * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
7
+ * PROCESS: no network request is made for licensing, ever. That last property
8
+ * is a spec requirement (`pro-licensing`), not an implementation detail.
9
+ */
10
+ /** Accepted by every pro entry point. */
11
+ interface ProLicenseOptions {
12
+ /**
13
+ * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
14
+ * development and evaluation is permitted, production use requires a
15
+ * license (see LICENSE.md) — the package trusts you either way.
16
+ */
17
+ readonly licenseKey?: string;
18
+ }
19
+
20
+ export type { ProLicenseOptions as P };
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Licensing, v1: honor system.
3
+ *
4
+ * The key is accepted and remembered so that adding offline (Ed25519)
5
+ * verification later is not a breaking change — but nothing validates it,
6
+ * nothing warns, nothing renders differently, and NOTHING EVER LEAVES THE
7
+ * PROCESS: no network request is made for licensing, ever. That last property
8
+ * is a spec requirement (`pro-licensing`), not an implementation detail.
9
+ */
10
+ /** Accepted by every pro entry point. */
11
+ interface ProLicenseOptions {
12
+ /**
13
+ * Your license key from docx-editor.dev. Optional in v1: unlicensed use in
14
+ * development and evaluation is permitted, production use requires a
15
+ * license (see LICENSE.md) — the package trusts you either way.
16
+ */
17
+ readonly licenseKey?: string;
18
+ }
19
+
20
+ export type { ProLicenseOptions as P };
@@ -0,0 +1 @@
1
+ import {a,b as b$1,c}from'./chunk-ENMURXLJ.js';var b=Promise.resolve();function w(e,t){let n=/^(.*?\d+(?:\.\d+)?px(?:\/\S+)?)\s/.exec(e);return n?`${n[1]} "${t}", sans-serif`:e}function h(e){let t=/^(.*?\d+(?:\.\d+)?px(?:\/\S+)?)\s+(.*)$/.exec(e);return !t||!/[\x00-\x1f\x7f]/.test(t[2])?e:`${t[1]} sans-serif`}function v(e){for(let t=Object.getPrototypeOf(e);t;t=Object.getPrototypeOf(t)){let n=Object.getOwnPropertyDescriptor(t,"font");if(n)return n}}function T(e,t){let n=v(e);if(n?.get&&n.set){let{get:i,set:s}=n;Object.defineProperty(e,"font",{configurable:true,get:()=>i.call(e),set:a=>s.call(e,h(String(a)))});}let f=e.fillText.bind(e);e.fillText=(i,s,a,c)=>{let r=t(String(i));r?.face&&(e.font=w(e.font,r.face)),r&&(e.textBaseline=r.baseline,e.textAlign=r.align);let l=r?r.text:i;c===void 0?f(l,s,a):f(l,s,a,c);};}function C(e,t){let n=b$1(e);if(!n.length)return t();let f=b.then(async()=>{let i=globalThis,s=i.OffscreenCanvas;if(typeof s!="function")return t();let a=c(n),c$1=function(r,l){let o=new s(r,l),m=o.getContext.bind(o);return o.getContext=((u,y)=>{let g=m(u,y);return u==="2d"&&g&&T(g,a),g}),o};i.OffscreenCanvas=c$1;try{return await t()}finally{i.OffscreenCanvas=s;}});return b=f.catch(()=>{}),f}async function A(e,t,n){let{convertEmfToDataUrl:f,convertWmfToDataUrl:i}=await import('emf-converter'),s={maxWidth:n.maxEdge,maxHeight:n.maxEdge},a$1=new Uint8Array(t==="image/x-emf"?a(e,s):e),c=a$1.buffer.slice(a$1.byteOffset,a$1.byteOffset+a$1.byteLength),r=t==="image/x-emf"?await f(c,s):await C(a$1,()=>i(c,s));if(!r)return null;let l="data:image/png;base64,";if(!r.startsWith(l))return null;let o=atob(r.slice(l.length)),m=new Uint8Array(o.length);for(let u=0;u<o.length;u+=1)m[u]=o.charCodeAt(u);return Object.freeze({bytes:m,mime:"image/png"})}export{A as rasterizeMetafile};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk3MIZFGHH_cjs=require('./chunk-3MIZFGHH.cjs');var b=Promise.resolve();function w(e,t){let n=/^(.*?\d+(?:\.\d+)?px(?:\/\S+)?)\s/.exec(e);return n?`${n[1]} "${t}", sans-serif`:e}function h(e){let t=/^(.*?\d+(?:\.\d+)?px(?:\/\S+)?)\s+(.*)$/.exec(e);return !t||!/[\x00-\x1f\x7f]/.test(t[2])?e:`${t[1]} sans-serif`}function v(e){for(let t=Object.getPrototypeOf(e);t;t=Object.getPrototypeOf(t)){let n=Object.getOwnPropertyDescriptor(t,"font");if(n)return n}}function T(e,t){let n=v(e);if(n?.get&&n.set){let{get:i,set:s}=n;Object.defineProperty(e,"font",{configurable:true,get:()=>i.call(e),set:a=>s.call(e,h(String(a)))});}let f=e.fillText.bind(e);e.fillText=(i,s,a,c)=>{let r=t(String(i));r?.face&&(e.font=w(e.font,r.face)),r&&(e.textBaseline=r.baseline,e.textAlign=r.align);let l=r?r.text:i;c===void 0?f(l,s,a):f(l,s,a,c);};}function C(e,t){let n=chunk3MIZFGHH_cjs.b(e);if(!n.length)return t();let f=b.then(async()=>{let i=globalThis,s=i.OffscreenCanvas;if(typeof s!="function")return t();let a=chunk3MIZFGHH_cjs.c(n),c=function(r,l){let o=new s(r,l),m=o.getContext.bind(o);return o.getContext=((u,y)=>{let g=m(u,y);return u==="2d"&&g&&T(g,a),g}),o};i.OffscreenCanvas=c;try{return await t()}finally{i.OffscreenCanvas=s;}});return b=f.catch(()=>{}),f}async function A(e,t,n){let{convertEmfToDataUrl:f,convertWmfToDataUrl:i}=await import('emf-converter'),s={maxWidth:n.maxEdge,maxHeight:n.maxEdge},a=new Uint8Array(t==="image/x-emf"?chunk3MIZFGHH_cjs.a(e,s):e),c=a.buffer.slice(a.byteOffset,a.byteOffset+a.byteLength),r=t==="image/x-emf"?await f(c,s):await C(a,()=>i(c,s));if(!r)return null;let l="data:image/png;base64,";if(!r.startsWith(l))return null;let o=atob(r.slice(l.length)),m=new Uint8Array(o.length);for(let u=0;u<o.length;u+=1)m[u]=o.charCodeAt(u);return Object.freeze({bytes:m,mime:"image/png"})}exports.rasterizeMetafile=A;
@@ -0,0 +1 @@
1
+ import {a,b,c}from'./chunk-ENMURXLJ.js';var H=[1,0,0,1,0,0],Z={r:0,g:0,b:0,alpha:1},S=Math.PI*2,u=n=>typeof n=="number"&&Number.isFinite(n)?n:0;function L(n,t){return [n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function J(n){if(n instanceof U)return n.mean();if(typeof n!="string")return null;let t=n.trim().toLowerCase();if(t==="transparent")return {r:0,g:0,b:0,alpha:0};if(t==="black")return Z;if(t==="white")return {r:255,g:255,b:255,alpha:1};let e=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(t);if(e){let a=e[1].length===3?e[1].split("").map(o=>o+o).join(""):e[1],s=o=>Number.parseInt(a.slice(o,o+2),16);return {r:s(0),g:s(2),b:s(4),alpha:a.length===8?s(6)/255:1}}let i=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(t);if(!i)return null;let r=(a,s)=>Math.max(0,Math.min(s,Number(a)||0));return {r:r(i[1],255),g:r(i[2],255),b:r(i[3],255),alpha:i[4]===void 0?1:r(i[4],1)}}function ot(n){if(n.length<3)return n;let t=n.charCodeAt(0),e=n.charCodeAt(1),i=t&255,r=t>>8,a=e&255,s=e>>8;return i<=10&&(r&12)===0&&a<=6&&(s&12)===0&&(s&3)<=2&&s>>4<=5&&(t>127||e>127)?n.slice(2):n}function K(n){let t=/^\s*(italic\s+)?(?:(bold|[1-9]00)\s+)?([\d.]+)px\s+(.+?)\s*$/i.exec(n);if(!t)return {family:"Arial",sizePx:10,bold:false,italic:false};let e=t[2]?.toLowerCase();return {family:ot(t[4].split(",")[0].trim().replace(/^["']|["']$/g,""))||"Arial",sizePx:Math.min(1e4,Math.max(0,Number(t[3])||0)),bold:e==="bold"||e!==void 0&&Number(e)>=600,italic:t[1]!==void 0}}var U=class{stops=[];addColorStop(t,e){let i=J(e);i&&this.stops.length<256&&this.stops.push(i);}mean(){if(!this.stops.length)return Z;let t=e=>this.stops.reduce((i,r)=>i+r[e],0)/this.stops.length;return {r:t("r"),g:t("g"),b:t("b"),alpha:t("alpha")}}},P=class{data;width;height;constructor(t,e,i){typeof t=="number"?(this.width=Math.max(0,Math.floor(t)),this.height=Math.max(0,Math.floor(e)),this.data=new Uint8ClampedArray(this.width*this.height*4)):(this.data=t,this.width=Math.max(0,Math.floor(e)),this.height=Math.max(0,Math.floor(i??t.length/4/Math.max(1,e))));}},N=class{constructor(t,e,i){this.canvas=t;this.budget=e;this.measure=i;}canvas;budget;measure;commands=[];state={matrix:H,fillStyle:"#000000",strokeStyle:"#000000",lineWidth:1,dash:[],font:"10px Arial",textAlign:"left",textBaseline:"alphabetic",globalAlpha:1};stack=[];path=[];current=null;start=null;globalCompositeOperation="source-over";lineCap="butt";lineJoin="miter";miterLimit=10;imageSmoothingEnabled=true;lineDashOffset=0;get fillStyle(){return this.state.fillStyle}set fillStyle(t){this.state.fillStyle=t;}get strokeStyle(){return this.state.strokeStyle}set strokeStyle(t){this.state.strokeStyle=t;}get lineWidth(){return this.state.lineWidth}set lineWidth(t){Number.isFinite(t)&&t>0&&(this.state.lineWidth=t);}get font(){return this.state.font}set font(t){typeof t=="string"&&t.length<512&&(this.state.font=t);}get textAlign(){return this.state.textAlign}set textAlign(t){this.state.textAlign=String(t);}get textBaseline(){return this.state.textBaseline}set textBaseline(t){this.state.textBaseline=String(t);}get globalAlpha(){return this.state.globalAlpha}set globalAlpha(t){Number.isFinite(t)&&(this.state.globalAlpha=Math.max(0,Math.min(1,t)));}admits(t){return this.budget.exhausted?false:this.budget.points+t>2e6?(this.budget.exhausted=true,false):true}extend(t){this.admits(this.path.length+1)&&this.path.push(t);}push(t,e=0){if(!this.budget.exhausted){if(this.budget.commands+=1,this.budget.points+=e,this.budget.commands>2e5||this.budget.points>2e6){this.budget.exhausted=true;return}this.commands.push(t);}}paintOf(t){let e=J(t);if(!e)return null;let i=e.alpha*this.state.globalAlpha;return i>0?{...e,alpha:i}:null}device(t,e){let i=this.state.matrix,r=u(t),a=u(e);return {x:i[0]*r+i[2]*a+i[4],y:i[1]*r+i[3]*a+i[5]}}penScale(){let t=this.state.matrix;return Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))||1}save(){this.stack.length>=256||(this.stack.push({...this.state,dash:[...this.state.dash]}),this.push({kind:"save"}));}restore(){let t=this.stack.pop();t&&(this.state=t,this.push({kind:"restore"}));}setTransform(t,e,i,r,a,s){if(typeof t=="object"&&t!==null){let o=t;this.state.matrix=[o.a,o.b,o.c,o.d,o.e,o.f].map(u);return}this.state.matrix=[t,e,i,r,a,s].map(u);}resetTransform(){this.state.matrix=H;}transform(t,e,i,r,a,s){let o=[t,e,i,r,a,s].map(u);this.state.matrix=L(this.state.matrix,o);}translate(t,e){this.transform(1,0,0,1,t,e);}scale(t,e){this.transform(t,0,0,e,0,0);}rotate(t){let e=Math.cos(u(t)),i=Math.sin(u(t));this.transform(e,i,-i,e,0,0);}getTransform(){let[t,e,i,r,a,s]=this.state.matrix;return {a:t,b:e,c:i,d:r,e:a,f:s}}setLineDash(t){!Array.isArray(t)||t.length>64||(this.state.dash=t.map(u).map(e=>Math.max(0,e)));}getLineDash(){return [...this.state.dash]}beginPath(){this.path=[],this.current=null,this.start=null;}moveTo(t,e){this.extend({op:"M",...this.device(t,e)}),this.current={x:u(t),y:u(e)},this.start=this.current;}lineTo(t,e){if(!this.current)return this.moveTo(t,e);this.extend({op:"L",...this.device(t,e)}),this.current={x:u(t),y:u(e)};}bezierCurveTo(t,e,i,r,a,s){this.current||this.moveTo(t,e);let o=this.device(t,e),m=this.device(i,r),g=this.device(a,s);this.extend({op:"C",x1:o.x,y1:o.y,x2:m.x,y2:m.y,x:g.x,y:g.y}),this.current={x:u(a),y:u(s)};}quadraticCurveTo(t,e,i,r){let a=this.current??{x:u(t),y:u(e)};this.bezierCurveTo(a.x+2/3*(u(t)-a.x),a.y+2/3*(u(e)-a.y),u(i)+2/3*(u(t)-u(i)),u(r)+2/3*(u(e)-u(r)),i,r);}closePath(){this.current&&(this.extend({op:"Z"}),this.current=this.start);}rect(t,e,i,r){this.moveTo(t,e),this.lineTo(u(t)+u(i),e),this.lineTo(u(t)+u(i),u(e)+u(r)),this.lineTo(t,u(e)+u(r)),this.closePath();}arc(t,e,i,r,a,s=false){this.ellipse(t,e,i,i,0,r,a,s);}ellipse(t,e,i,r,a,s,o,m=false){let[g,h,c,v,A,M]=[t,e,i,r,a,s].map(u);if(c<0||v<0)return;let T=u(o)-M;m?T=-T>=S?-S:-((-T%S+S)%S):T=T>=S?S:(T%S+S)%S;let p=Math.cos(A),d=Math.sin(A),l=f=>{let b=c*Math.cos(f),C=v*Math.sin(f);return {x:g+b*p-C*d,y:h+b*d+C*p}},x=l(M);this.current?this.lineTo(x.x,x.y):this.moveTo(x.x,x.y);let y=Math.max(1,Math.ceil(Math.abs(T)/(Math.PI/2))),w=T/y,k=4/3*Math.tan(w/4);for(let f=0;f<y;f+=1){let b=M+w*f,C=b+w,I=l(b),R=l(C),_={x:-c*Math.sin(b),y:v*Math.cos(b)},D={x:-c*Math.sin(C),y:v*Math.cos(C)},E=O=>({x:O.x*p-O.y*d,y:O.x*d+O.y*p}),j=E(_),G=E(D);this.bezierCurveTo(I.x+k*j.x,I.y+k*j.y,R.x-k*G.x,R.y-k*G.y,R.x,R.y);}}arcTo(t,e,i,r,a){let s=u(a);this.current||this.moveTo(t,e);let o=this.current,m={x:u(t),y:u(e)},g={x:u(i),y:u(r)},h={x:o.x-m.x,y:o.y-m.y},c={x:g.x-m.x,y:g.y-m.y},v=Math.hypot(h.x,h.y),A=Math.hypot(c.x,c.y),M=h.x*c.y-h.y*c.x;if(s<=0||v===0||A===0||Math.abs(M)<1e-12*v*A){this.lineTo(m.x,m.y);return}let T=Math.acos(Math.max(-1,Math.min(1,(h.x*c.x+h.y*c.y)/(v*A)))),p=s/Math.tan(T/2),d={x:m.x+h.x/v*p,y:m.y+h.y/v*p},l={x:m.x+c.x/A*p,y:m.y+c.y/A*p},x={x:h.x/v+c.x/A,y:h.y/v+c.y/A},y=Math.hypot(x.x,x.y),w=s/Math.sin(T/2),k={x:m.x+x.x/y*w,y:m.y+x.y/y*w},f=Math.atan2(d.y-k.y,d.x-k.x),b=Math.atan2(l.y-k.y,l.x-k.x)-f;b>Math.PI&&(b-=S),b<-Math.PI&&(b+=S),this.lineTo(d.x,d.y),this.ellipse(k.x,k.y,s,s,0,f,f+b,b<0);}fill(t){let e=this.paintOf(this.state.fillStyle);!e||!this.path.length||!this.admits(this.path.length)||this.push({kind:"fill",path:[...this.path],evenOdd:t==="evenodd",paint:e},this.path.length);}stroke(){let t=this.paintOf(this.state.strokeStyle);if(!t||!this.path.length||!this.admits(this.path.length))return;let e=this.penScale();this.push({kind:"stroke",path:[...this.path],width:this.state.lineWidth*e,dash:this.state.dash.map(i=>i*e),paint:t},this.path.length);}clip(t){this.admits(this.path.length)&&this.push({kind:"clip",path:[...this.path],evenOdd:t==="evenodd"},this.path.length);}fillRect(t,e,i,r){let a={path:this.path,current:this.current,start:this.start};this.beginPath(),this.rect(t,e,i,r),this.fill(),Object.assign(this,a);}strokeRect(t,e,i,r){let a={path:this.path,current:this.current,start:this.start};this.beginPath(),this.rect(t,e,i,r),this.stroke(),Object.assign(this,a);}clearRect(){}measureText(t){return {width:this.measure(String(t),K(this.state.font))}}fillText(t,e,i){let r=this.paintOf(this.state.fillStyle),a=String(t);if(!r||!a||a.length>1e4)return;let s=this.state.textAlign,o=this.state.textBaseline;this.push({kind:"text",text:a,font:K(this.state.font),x:u(e),y:u(i),align:s==="center"?"center":s==="right"||s==="end"?"right":"left",baseline:o==="top"||o==="hanging"?"top":o==="bottom"||o==="ideographic"?"bottom":o==="middle"?"middle":"alphabetic",matrix:this.state.matrix,paint:r},a.length);}putImageData(t,e,i){let r=Math.floor(u(t?.width)),a=Math.floor(u(t?.height));if(!(!(r>0&&a>0)||!t.data||t.data.length<r*a*4)){if(this.budget.pixels+=r*a,this.budget.pixels>16e6){this.budget.exhausted=true;return}this.push({kind:"image",raster:{kind:"rgba",width:r,height:a,data:Uint8Array.from(t.data)},matrix:[r,0,0,a,u(e),u(i)]});}}getImageData(t,e,i,r){return new P(Math.min(4096,Math.max(0,u(i))),Math.min(4096,u(r)))}createImageData(t,e){return new P(Math.min(4096,Math.max(0,u(t))),Math.min(4096,u(e)))}createLinearGradient(){return new U}createRadialGradient(){return new U}createPattern(){return null}drawImage(t,...e){let i=ht(t);if(!i)return;let[r,a,s,o]=[e[0],e[1],i.width,i.height].map(u);e.length===4&&([r,a,s,o]=e.map(u));let m=null;if(e.length>=8&&(m=e.slice(0,4).map(u),[r,a,s,o]=e.slice(4,8).map(u)),s===0||o===0)return;let g=L(this.state.matrix,[s,0,0,o,r,a]);if(m){let[h,c,v,A]=m;if(!(v>0&&A>0))return;this.save(),this.beginPath(),this.rect(r,a,s,o),this.clip(),g=L(this.state.matrix,[s*i.width/v,0,0,o*i.height/A,r-h*s/v,a-c*o/A]);}i.raster?this.push({kind:"image",raster:i.raster,matrix:g}):i.drawing&&this.push({kind:"drawing",drawing:i.drawing,matrix:L(g,[1/i.width,0,0,1/i.height,0,0])}),m&&this.restore();}};function ht(n){if(n instanceof B){let t=n.drawing();if(!(t.width>0&&t.height>0))return null;let[e]=t.commands;return t.commands.length===1&&e.kind==="image"&&e.raster.width===t.width&&e.raster.height===t.height&&e.matrix[0]===t.width&&e.matrix[3]===t.height&&e.matrix[4]===0&&e.matrix[5]===0?{width:t.width,height:t.height,raster:e.raster}:{width:t.width,height:t.height,drawing:t}}if(n&&typeof n=="object"&&"width"in n&&"height"in n){let t=n;if(!(t.width>0&&t.height>0))return null;if(t.raster)return {width:t.width,height:t.height,raster:t.raster};if(t.drawing)return {width:t.width,height:t.height,drawing:t.drawing}}return null}var B=class{constructor(t,e,i,r,a){this.width=t;this.height=e;this.budget=i;this.measure=r;this.onExport=a;}width;height;budget;measure;onExport;context=null;getContext(t){return t!=="2d"?null:(this.context??=new N(this,this.budget,this.measure),this.context)}drawing(){return {width:Math.max(0,u(this.width)),height:Math.max(0,u(this.height)),commands:this.context?.commands??[]}}async convertToBlob(){return new Blob([this.onExport(this)],{type:F})}},F="application/x-docx-metafile-recording";var lt=2596720087,ut=523,mt=524,ct=3907,dt=2881,ft=2368,gt=1313,W="\x7F",Q=13369376,tt=8913094,pt=15597702,xt=2e5;function bt(n,t,e){if(t+12>e)return null;let i=n.getUint32(t,true),r,a,s,o=0,m=0,g=4;if(i===12)r=n.getUint16(t+4,true),a=n.getUint16(t+6,true),s=n.getUint16(t+10,true),g=3;else if(i>=40&&t+i<=e)r=n.getInt32(t+4,true),a=n.getInt32(t+8,true),s=n.getUint16(t+14,true),o=n.getUint32(t+16,true),m=n.getUint32(t+32,true);else return null;let h=a<0,c=Math.abs(a);if(!(r>0&&c>0)||r*c>16e6||o!==0||![1,4,8,16,24,32].includes(s))return null;let v=s<=8?m||1<<s:0,A=t+i,M=A+v*g,T=Math.floor((r*s+31)/32)*4;if(v>256||M+T*c>e)return null;let p=l=>{if(l>=v)return [0,0,0];let x=A+l*g;return [n.getUint8(x+2),n.getUint8(x+1),n.getUint8(x)]},d=new Uint8Array(r*c*4);for(let l=0;l<c;l+=1){let x=M+(h?l:c-1-l)*T;for(let y=0;y<r;y+=1){let w;if(s===24){let f=x+y*3;w=[n.getUint8(f+2),n.getUint8(f+1),n.getUint8(f)];}else if(s===32){let f=x+y*4;w=[n.getUint8(f+2),n.getUint8(f+1),n.getUint8(f)];}else if(s===16){let f=n.getUint16(x+y*2,true),b=C=>(f>>C&31)*255/31;w=[b(10),b(5),b(0)];}else {let f=y*s,C=n.getUint8(x+(f>>3))>>8-s-(f&7)&(1<<s)-1;w=p(C);}let k=(l*r+y)*4;d[k]=w[0],d[k+1]=w[1],d[k+2]=w[2],d[k+3]=255;}}return {width:r,height:c,topDown:h,data:d}}function et(n){if(!n.startsWith(W))return null;let t=n.slice(W.length);return /^\d{1,6}$/.test(t)?Number(t):null}function nt(n){let t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.length<22)return null;let e=0,i={x:0,y:0,width:0,height:0};if(t.getUint32(0,true)===lt){let o=t.getInt16(6,true),m=t.getInt16(8,true);i={x:o,y:m,width:t.getInt16(10,true)-o,height:t.getInt16(12,true)-m},e=22;}if(e+18>n.length)return null;e+=t.getUint16(e+2,true)*2;let r=[];for(let o=0;o<xt&&e+6<=n.length;o+=1){let m=t.getUint32(e,true)*2,g=t.getUint16(e+4,true);if(g===0||m<6||e+m>n.length)break;let h=c=>t.getInt16(e+6+c*2,true);if(g===ut&&m>=10)i={...i,y:h(0),x:h(1)};else if(g===mt&&m>=10)i={...i,height:h(0),width:h(1)};else if(g===ct&&m>=28)r.push({rop:t.getUint32(e+6,true),source:{height:h(3),width:h(4),y:h(5),x:h(6)},target:{height:h(7),width:h(8),y:h(9),x:h(10)},window:i,record:e,dib:e+28,end:e+m});else if(g===dt&&m>=26)r.push({rop:t.getUint32(e+6,true),source:{height:h(2),width:h(3),y:h(4),x:h(5)},target:{height:h(6),width:h(7),y:h(8),x:h(9)},window:i,record:e,dib:e+26,end:e+m});else if(g===ft&&m>=22){let c={height:h(4),width:h(5),y:h(6),x:h(7)};r.push({rop:t.getUint32(e+6,true),source:{height:c.height,width:c.width,y:h(2),x:h(3)},target:c,window:i,record:e,dib:e+22,end:e+m});}e+=m;}if(!r.length)return null;let a=n.slice(),s=new DataView(a.buffer);return r.forEach(({record:o},m)=>{let g=`${W}${m}`;s.setUint16(o+4,gt,true),s.setInt16(o+6,g.length,true);for(let c=0;c<g.length;c+=1)s.setUint8(o+8+c,g.charCodeAt(c));let h=o+8+g.length+g.length%2;s.setInt16(h,0,true),s.setInt16(h+2,0,true);}),{marked:a,placed:r}}function it(n,t,e,i,r){let a=new DataView(n.buffer,n.byteOffset,n.byteLength),s=t.map(()=>[]);for(let[o,{rop:m,source:g,target:h,window:c,dib:v,end:A}]of t.entries()){if(m!==Q&&m!==tt&&m!==pt||c.width===0||c.height===0)continue;let M=bt(a,v,A);if(!M)continue;let T=e/c.width,p=i/c.height,d=s[o];if(m!==Q){let b=m===tt?255:0;for(let C=0;C<M.data.length;C+=4){let I=M.data;I[C]===b&&I[C+1]===b&&I[C+2]===b&&(I[C+3]=0);}}if(r.pixels+=M.width*M.height,r.pixels>16e6){r.exhausted=true;break}let l=g.width||M.width,x=g.height||M.height,y=h.width/l*T,w=h.height/x*p,k=M.topDown?g.y:M.height-g.y-x,f=g.x!==0||k!==0||l!==M.width||x!==M.height;if(f){let b=(h.x-c.x)*T,C=(h.y-c.y)*p,I=b+h.width*T,R=C+h.height*p;d.push({kind:"save"},{kind:"clip",evenOdd:false,path:[{op:"M",x:b,y:C},{op:"L",x:I,y:C},{op:"L",x:I,y:R},{op:"L",x:b,y:R},{op:"Z"}]});}d.push({kind:"image",raster:{kind:"rgba",width:M.width,height:M.height,data:M.data},matrix:[M.width*y,0,0,M.height*w,(h.x-c.x)*T-g.x*y,(h.y-c.y)*p-k*w]}),f&&d.push({kind:"restore"});}return s}function rt(n,t,e){let i=[],r=0;for(t.forEach((a,s)=>{let o=e(s);if(!(o<0||!a.length)){for(;r<Math.min(o,n.length);)i.push(n[r++]);for(let m of a)i.push(m);}});r<n.length;)i.push(n[r++]);return i}function at(n,t){if(!t.length)return n;let e=c(t),i=false,r=n.map(a=>{if(a.kind!=="text")return a;let s=e(a.text);if(!s)return a;let o=s.face||a.font.family;return s.text===a.text&&o===a.font.family&&s.baseline===a.baseline&&s.align===a.align?a:(i=true,{...a,text:s.text,font:{...a.font,family:o},baseline:s.baseline,align:s.align})});return i?r:n}var Mt=2e5,z=4096,$=["OffscreenCanvas","ImageData","createImageBitmap","FileReader"],st=Promise.resolve();function yt(n){if(n.length>=24&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71){let t=new DataView(n.buffer,n.byteOffset,n.byteLength);return {mime:"image/png",width:t.getUint32(16),height:t.getUint32(20)}}if(n.length>=4&&n[0]===255&&n[1]===216){let t=2;for(;t+9<n.length;){if(n[t]!==255)return null;let e=n[t+1],i=n[t+2]<<8|n[t+3];if(e>=192&&e<=207&&e!==196&&e!==200&&e!==204)return {mime:"image/jpeg",height:n[t+5]<<8|n[t+6],width:n[t+7]<<8|n[t+8]};if(i<2)return null;t+=2+i;}}return null}function wt(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)}async function vt(n,t,e){let i={commands:0,points:0,pixels:0,exhausted:false},r=new Map,a$1=p=>{let d=`recording-${r.size}`;return r.set(d,p),d},s=(p,d)=>{let l=e.textAdvance(p,d);return Number.isFinite(l)&&l>=0?l:0},o=t==="image/x-wmf"?nt(n):null,m=new Map,g=new WeakSet;class h extends B{constructor(d,l){super(d,l,i,s,a$1);}getContext(d){let l=super.getContext(d);if(!o||!l||g.has(l))return l;g.add(l);let x=l.fillText.bind(l);return l.fillText=(y,w,k)=>{let f=et(String(y));if(f===null||f>=o.placed.length)return x(y,w,k);m.set(f,{commands:l.commands,at:l.commands.length});},l}}class c{result=null;error=null;onload=null;onerror=null;readAsDataURL(d){d.arrayBuffer().then(l=>{this.result=`data:${d.type||"application/octet-stream"};base64,${wt(new Uint8Array(l))}`,this.onload?.();}).catch(l=>{this.error=l,this.onerror?.();});}}let v=async p=>{let d=new Uint8Array(await p.arrayBuffer());if(p.type===F){let y=r.get(new TextDecoder().decode(d));if(!y)throw new Error("Unknown recording");let w=y.drawing();return {width:w.width,height:w.height,drawing:w,close(){}}}let l=yt(d);if(!l||!(l.width>0&&l.height>0))throw new Error("Unsupported bitmap");if(i.pixels+=l.width*l.height,i.pixels>16e6)throw i.exhausted=true,new Error("Bitmap past the pixel bound");let x={kind:"encoded",...l,bytes:d};return {width:l.width,height:l.height,raster:x,close(){}}},A=globalThis,M=$.map(p=>Object.getOwnPropertyDescriptor(A,p)),T={OffscreenCanvas:h,ImageData:P,createImageBitmap:v,FileReader:c};for(let p of $)Object.defineProperty(A,p,{value:T[p],configurable:true,writable:true});try{let{convertEmfToDataUrl:p,convertWmfToDataUrl:d}=await import('emf-converter'),l={dpiScale:1,maxWidth:z,maxHeight:z,maxCanvasDimension:z,maxRecords:Mt},x=(t==="image/x-emf"?a(n,l):o?.marked??n).slice().buffer,y=t==="image/x-emf"?await p(x,l):await d(x,l),w=y?.startsWith(`data:${F};base64,`)?y.slice(y.indexOf(",")+1):null,k=w?r.get(atob(w)):void 0;if(!k)return null;let f=k.drawing(),C=t==="image/x-wmf"?at(f.commands,b(n)):f.commands,I=o?it(n,o.placed,f.width,f.height,i):[],R=D=>{let E=m.get(D);return E&&E.commands===f.commands?E.at:-1},_=I.some(D=>D.length)?rt(C,I,R):C;return {drawing:_===f.commands?f:{...f,commands:_},complete:!i.exhausted}}catch{return null}finally{$.forEach((p,d)=>{let l=M[d];l?Object.defineProperty(A,p,l):delete A[p];});}}function Dt(n,t,e){let i=st.then(()=>vt(n,t,e));return st=i.catch(()=>{}),i}export{Dt as replayMetafile};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk3MIZFGHH_cjs=require('./chunk-3MIZFGHH.cjs');var H=[1,0,0,1,0,0],Z={r:0,g:0,b:0,alpha:1},S=Math.PI*2,u=n=>typeof n=="number"&&Number.isFinite(n)?n:0;function L(n,t){return [n[0]*t[0]+n[2]*t[1],n[1]*t[0]+n[3]*t[1],n[0]*t[2]+n[2]*t[3],n[1]*t[2]+n[3]*t[3],n[0]*t[4]+n[2]*t[5]+n[4],n[1]*t[4]+n[3]*t[5]+n[5]]}function J(n){if(n instanceof U)return n.mean();if(typeof n!="string")return null;let t=n.trim().toLowerCase();if(t==="transparent")return {r:0,g:0,b:0,alpha:0};if(t==="black")return Z;if(t==="white")return {r:255,g:255,b:255,alpha:1};let e=/^#([0-9a-f]{3}|[0-9a-f]{6}|[0-9a-f]{8})$/.exec(t);if(e){let a=e[1].length===3?e[1].split("").map(o=>o+o).join(""):e[1],s=o=>Number.parseInt(a.slice(o,o+2),16);return {r:s(0),g:s(2),b:s(4),alpha:a.length===8?s(6)/255:1}}let i=/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*(?:,\s*([\d.]+)\s*)?\)$/.exec(t);if(!i)return null;let r=(a,s)=>Math.max(0,Math.min(s,Number(a)||0));return {r:r(i[1],255),g:r(i[2],255),b:r(i[3],255),alpha:i[4]===void 0?1:r(i[4],1)}}function ot(n){if(n.length<3)return n;let t=n.charCodeAt(0),e=n.charCodeAt(1),i=t&255,r=t>>8,a=e&255,s=e>>8;return i<=10&&(r&12)===0&&a<=6&&(s&12)===0&&(s&3)<=2&&s>>4<=5&&(t>127||e>127)?n.slice(2):n}function K(n){let t=/^\s*(italic\s+)?(?:(bold|[1-9]00)\s+)?([\d.]+)px\s+(.+?)\s*$/i.exec(n);if(!t)return {family:"Arial",sizePx:10,bold:false,italic:false};let e=t[2]?.toLowerCase();return {family:ot(t[4].split(",")[0].trim().replace(/^["']|["']$/g,""))||"Arial",sizePx:Math.min(1e4,Math.max(0,Number(t[3])||0)),bold:e==="bold"||e!==void 0&&Number(e)>=600,italic:t[1]!==void 0}}var U=class{stops=[];addColorStop(t,e){let i=J(e);i&&this.stops.length<256&&this.stops.push(i);}mean(){if(!this.stops.length)return Z;let t=e=>this.stops.reduce((i,r)=>i+r[e],0)/this.stops.length;return {r:t("r"),g:t("g"),b:t("b"),alpha:t("alpha")}}},P=class{data;width;height;constructor(t,e,i){typeof t=="number"?(this.width=Math.max(0,Math.floor(t)),this.height=Math.max(0,Math.floor(e)),this.data=new Uint8ClampedArray(this.width*this.height*4)):(this.data=t,this.width=Math.max(0,Math.floor(e)),this.height=Math.max(0,Math.floor(i??t.length/4/Math.max(1,e))));}},N=class{constructor(t,e,i){this.canvas=t;this.budget=e;this.measure=i;}canvas;budget;measure;commands=[];state={matrix:H,fillStyle:"#000000",strokeStyle:"#000000",lineWidth:1,dash:[],font:"10px Arial",textAlign:"left",textBaseline:"alphabetic",globalAlpha:1};stack=[];path=[];current=null;start=null;globalCompositeOperation="source-over";lineCap="butt";lineJoin="miter";miterLimit=10;imageSmoothingEnabled=true;lineDashOffset=0;get fillStyle(){return this.state.fillStyle}set fillStyle(t){this.state.fillStyle=t;}get strokeStyle(){return this.state.strokeStyle}set strokeStyle(t){this.state.strokeStyle=t;}get lineWidth(){return this.state.lineWidth}set lineWidth(t){Number.isFinite(t)&&t>0&&(this.state.lineWidth=t);}get font(){return this.state.font}set font(t){typeof t=="string"&&t.length<512&&(this.state.font=t);}get textAlign(){return this.state.textAlign}set textAlign(t){this.state.textAlign=String(t);}get textBaseline(){return this.state.textBaseline}set textBaseline(t){this.state.textBaseline=String(t);}get globalAlpha(){return this.state.globalAlpha}set globalAlpha(t){Number.isFinite(t)&&(this.state.globalAlpha=Math.max(0,Math.min(1,t)));}admits(t){return this.budget.exhausted?false:this.budget.points+t>2e6?(this.budget.exhausted=true,false):true}extend(t){this.admits(this.path.length+1)&&this.path.push(t);}push(t,e=0){if(!this.budget.exhausted){if(this.budget.commands+=1,this.budget.points+=e,this.budget.commands>2e5||this.budget.points>2e6){this.budget.exhausted=true;return}this.commands.push(t);}}paintOf(t){let e=J(t);if(!e)return null;let i=e.alpha*this.state.globalAlpha;return i>0?{...e,alpha:i}:null}device(t,e){let i=this.state.matrix,r=u(t),a=u(e);return {x:i[0]*r+i[2]*a+i[4],y:i[1]*r+i[3]*a+i[5]}}penScale(){let t=this.state.matrix;return Math.sqrt(Math.abs(t[0]*t[3]-t[1]*t[2]))||1}save(){this.stack.length>=256||(this.stack.push({...this.state,dash:[...this.state.dash]}),this.push({kind:"save"}));}restore(){let t=this.stack.pop();t&&(this.state=t,this.push({kind:"restore"}));}setTransform(t,e,i,r,a,s){if(typeof t=="object"&&t!==null){let o=t;this.state.matrix=[o.a,o.b,o.c,o.d,o.e,o.f].map(u);return}this.state.matrix=[t,e,i,r,a,s].map(u);}resetTransform(){this.state.matrix=H;}transform(t,e,i,r,a,s){let o=[t,e,i,r,a,s].map(u);this.state.matrix=L(this.state.matrix,o);}translate(t,e){this.transform(1,0,0,1,t,e);}scale(t,e){this.transform(t,0,0,e,0,0);}rotate(t){let e=Math.cos(u(t)),i=Math.sin(u(t));this.transform(e,i,-i,e,0,0);}getTransform(){let[t,e,i,r,a,s]=this.state.matrix;return {a:t,b:e,c:i,d:r,e:a,f:s}}setLineDash(t){!Array.isArray(t)||t.length>64||(this.state.dash=t.map(u).map(e=>Math.max(0,e)));}getLineDash(){return [...this.state.dash]}beginPath(){this.path=[],this.current=null,this.start=null;}moveTo(t,e){this.extend({op:"M",...this.device(t,e)}),this.current={x:u(t),y:u(e)},this.start=this.current;}lineTo(t,e){if(!this.current)return this.moveTo(t,e);this.extend({op:"L",...this.device(t,e)}),this.current={x:u(t),y:u(e)};}bezierCurveTo(t,e,i,r,a,s){this.current||this.moveTo(t,e);let o=this.device(t,e),m=this.device(i,r),g=this.device(a,s);this.extend({op:"C",x1:o.x,y1:o.y,x2:m.x,y2:m.y,x:g.x,y:g.y}),this.current={x:u(a),y:u(s)};}quadraticCurveTo(t,e,i,r){let a=this.current??{x:u(t),y:u(e)};this.bezierCurveTo(a.x+2/3*(u(t)-a.x),a.y+2/3*(u(e)-a.y),u(i)+2/3*(u(t)-u(i)),u(r)+2/3*(u(e)-u(r)),i,r);}closePath(){this.current&&(this.extend({op:"Z"}),this.current=this.start);}rect(t,e,i,r){this.moveTo(t,e),this.lineTo(u(t)+u(i),e),this.lineTo(u(t)+u(i),u(e)+u(r)),this.lineTo(t,u(e)+u(r)),this.closePath();}arc(t,e,i,r,a,s=false){this.ellipse(t,e,i,i,0,r,a,s);}ellipse(t,e,i,r,a,s,o,m=false){let[g,h,c,v,A,M]=[t,e,i,r,a,s].map(u);if(c<0||v<0)return;let T=u(o)-M;m?T=-T>=S?-S:-((-T%S+S)%S):T=T>=S?S:(T%S+S)%S;let p=Math.cos(A),d=Math.sin(A),l=f=>{let b=c*Math.cos(f),C=v*Math.sin(f);return {x:g+b*p-C*d,y:h+b*d+C*p}},x=l(M);this.current?this.lineTo(x.x,x.y):this.moveTo(x.x,x.y);let y=Math.max(1,Math.ceil(Math.abs(T)/(Math.PI/2))),w=T/y,k=4/3*Math.tan(w/4);for(let f=0;f<y;f+=1){let b=M+w*f,C=b+w,I=l(b),R=l(C),_={x:-c*Math.sin(b),y:v*Math.cos(b)},D={x:-c*Math.sin(C),y:v*Math.cos(C)},E=O=>({x:O.x*p-O.y*d,y:O.x*d+O.y*p}),j=E(_),G=E(D);this.bezierCurveTo(I.x+k*j.x,I.y+k*j.y,R.x-k*G.x,R.y-k*G.y,R.x,R.y);}}arcTo(t,e,i,r,a){let s=u(a);this.current||this.moveTo(t,e);let o=this.current,m={x:u(t),y:u(e)},g={x:u(i),y:u(r)},h={x:o.x-m.x,y:o.y-m.y},c={x:g.x-m.x,y:g.y-m.y},v=Math.hypot(h.x,h.y),A=Math.hypot(c.x,c.y),M=h.x*c.y-h.y*c.x;if(s<=0||v===0||A===0||Math.abs(M)<1e-12*v*A){this.lineTo(m.x,m.y);return}let T=Math.acos(Math.max(-1,Math.min(1,(h.x*c.x+h.y*c.y)/(v*A)))),p=s/Math.tan(T/2),d={x:m.x+h.x/v*p,y:m.y+h.y/v*p},l={x:m.x+c.x/A*p,y:m.y+c.y/A*p},x={x:h.x/v+c.x/A,y:h.y/v+c.y/A},y=Math.hypot(x.x,x.y),w=s/Math.sin(T/2),k={x:m.x+x.x/y*w,y:m.y+x.y/y*w},f=Math.atan2(d.y-k.y,d.x-k.x),b=Math.atan2(l.y-k.y,l.x-k.x)-f;b>Math.PI&&(b-=S),b<-Math.PI&&(b+=S),this.lineTo(d.x,d.y),this.ellipse(k.x,k.y,s,s,0,f,f+b,b<0);}fill(t){let e=this.paintOf(this.state.fillStyle);!e||!this.path.length||!this.admits(this.path.length)||this.push({kind:"fill",path:[...this.path],evenOdd:t==="evenodd",paint:e},this.path.length);}stroke(){let t=this.paintOf(this.state.strokeStyle);if(!t||!this.path.length||!this.admits(this.path.length))return;let e=this.penScale();this.push({kind:"stroke",path:[...this.path],width:this.state.lineWidth*e,dash:this.state.dash.map(i=>i*e),paint:t},this.path.length);}clip(t){this.admits(this.path.length)&&this.push({kind:"clip",path:[...this.path],evenOdd:t==="evenodd"},this.path.length);}fillRect(t,e,i,r){let a={path:this.path,current:this.current,start:this.start};this.beginPath(),this.rect(t,e,i,r),this.fill(),Object.assign(this,a);}strokeRect(t,e,i,r){let a={path:this.path,current:this.current,start:this.start};this.beginPath(),this.rect(t,e,i,r),this.stroke(),Object.assign(this,a);}clearRect(){}measureText(t){return {width:this.measure(String(t),K(this.state.font))}}fillText(t,e,i){let r=this.paintOf(this.state.fillStyle),a=String(t);if(!r||!a||a.length>1e4)return;let s=this.state.textAlign,o=this.state.textBaseline;this.push({kind:"text",text:a,font:K(this.state.font),x:u(e),y:u(i),align:s==="center"?"center":s==="right"||s==="end"?"right":"left",baseline:o==="top"||o==="hanging"?"top":o==="bottom"||o==="ideographic"?"bottom":o==="middle"?"middle":"alphabetic",matrix:this.state.matrix,paint:r},a.length);}putImageData(t,e,i){let r=Math.floor(u(t?.width)),a=Math.floor(u(t?.height));if(!(!(r>0&&a>0)||!t.data||t.data.length<r*a*4)){if(this.budget.pixels+=r*a,this.budget.pixels>16e6){this.budget.exhausted=true;return}this.push({kind:"image",raster:{kind:"rgba",width:r,height:a,data:Uint8Array.from(t.data)},matrix:[r,0,0,a,u(e),u(i)]});}}getImageData(t,e,i,r){return new P(Math.min(4096,Math.max(0,u(i))),Math.min(4096,u(r)))}createImageData(t,e){return new P(Math.min(4096,Math.max(0,u(t))),Math.min(4096,u(e)))}createLinearGradient(){return new U}createRadialGradient(){return new U}createPattern(){return null}drawImage(t,...e){let i=ht(t);if(!i)return;let[r,a,s,o]=[e[0],e[1],i.width,i.height].map(u);e.length===4&&([r,a,s,o]=e.map(u));let m=null;if(e.length>=8&&(m=e.slice(0,4).map(u),[r,a,s,o]=e.slice(4,8).map(u)),s===0||o===0)return;let g=L(this.state.matrix,[s,0,0,o,r,a]);if(m){let[h,c,v,A]=m;if(!(v>0&&A>0))return;this.save(),this.beginPath(),this.rect(r,a,s,o),this.clip(),g=L(this.state.matrix,[s*i.width/v,0,0,o*i.height/A,r-h*s/v,a-c*o/A]);}i.raster?this.push({kind:"image",raster:i.raster,matrix:g}):i.drawing&&this.push({kind:"drawing",drawing:i.drawing,matrix:L(g,[1/i.width,0,0,1/i.height,0,0])}),m&&this.restore();}};function ht(n){if(n instanceof B){let t=n.drawing();if(!(t.width>0&&t.height>0))return null;let[e]=t.commands;return t.commands.length===1&&e.kind==="image"&&e.raster.width===t.width&&e.raster.height===t.height&&e.matrix[0]===t.width&&e.matrix[3]===t.height&&e.matrix[4]===0&&e.matrix[5]===0?{width:t.width,height:t.height,raster:e.raster}:{width:t.width,height:t.height,drawing:t}}if(n&&typeof n=="object"&&"width"in n&&"height"in n){let t=n;if(!(t.width>0&&t.height>0))return null;if(t.raster)return {width:t.width,height:t.height,raster:t.raster};if(t.drawing)return {width:t.width,height:t.height,drawing:t.drawing}}return null}var B=class{constructor(t,e,i,r,a){this.width=t;this.height=e;this.budget=i;this.measure=r;this.onExport=a;}width;height;budget;measure;onExport;context=null;getContext(t){return t!=="2d"?null:(this.context??=new N(this,this.budget,this.measure),this.context)}drawing(){return {width:Math.max(0,u(this.width)),height:Math.max(0,u(this.height)),commands:this.context?.commands??[]}}async convertToBlob(){return new Blob([this.onExport(this)],{type:F})}},F="application/x-docx-metafile-recording";var lt=2596720087,ut=523,mt=524,ct=3907,dt=2881,ft=2368,gt=1313,W="\x7F",Q=13369376,tt=8913094,pt=15597702,xt=2e5;function bt(n,t,e){if(t+12>e)return null;let i=n.getUint32(t,true),r,a,s,o=0,m=0,g=4;if(i===12)r=n.getUint16(t+4,true),a=n.getUint16(t+6,true),s=n.getUint16(t+10,true),g=3;else if(i>=40&&t+i<=e)r=n.getInt32(t+4,true),a=n.getInt32(t+8,true),s=n.getUint16(t+14,true),o=n.getUint32(t+16,true),m=n.getUint32(t+32,true);else return null;let h=a<0,c=Math.abs(a);if(!(r>0&&c>0)||r*c>16e6||o!==0||![1,4,8,16,24,32].includes(s))return null;let v=s<=8?m||1<<s:0,A=t+i,M=A+v*g,T=Math.floor((r*s+31)/32)*4;if(v>256||M+T*c>e)return null;let p=l=>{if(l>=v)return [0,0,0];let x=A+l*g;return [n.getUint8(x+2),n.getUint8(x+1),n.getUint8(x)]},d=new Uint8Array(r*c*4);for(let l=0;l<c;l+=1){let x=M+(h?l:c-1-l)*T;for(let y=0;y<r;y+=1){let w;if(s===24){let f=x+y*3;w=[n.getUint8(f+2),n.getUint8(f+1),n.getUint8(f)];}else if(s===32){let f=x+y*4;w=[n.getUint8(f+2),n.getUint8(f+1),n.getUint8(f)];}else if(s===16){let f=n.getUint16(x+y*2,true),b=C=>(f>>C&31)*255/31;w=[b(10),b(5),b(0)];}else {let f=y*s,C=n.getUint8(x+(f>>3))>>8-s-(f&7)&(1<<s)-1;w=p(C);}let k=(l*r+y)*4;d[k]=w[0],d[k+1]=w[1],d[k+2]=w[2],d[k+3]=255;}}return {width:r,height:c,topDown:h,data:d}}function et(n){if(!n.startsWith(W))return null;let t=n.slice(W.length);return /^\d{1,6}$/.test(t)?Number(t):null}function nt(n){let t=new DataView(n.buffer,n.byteOffset,n.byteLength);if(n.length<22)return null;let e=0,i={x:0,y:0,width:0,height:0};if(t.getUint32(0,true)===lt){let o=t.getInt16(6,true),m=t.getInt16(8,true);i={x:o,y:m,width:t.getInt16(10,true)-o,height:t.getInt16(12,true)-m},e=22;}if(e+18>n.length)return null;e+=t.getUint16(e+2,true)*2;let r=[];for(let o=0;o<xt&&e+6<=n.length;o+=1){let m=t.getUint32(e,true)*2,g=t.getUint16(e+4,true);if(g===0||m<6||e+m>n.length)break;let h=c=>t.getInt16(e+6+c*2,true);if(g===ut&&m>=10)i={...i,y:h(0),x:h(1)};else if(g===mt&&m>=10)i={...i,height:h(0),width:h(1)};else if(g===ct&&m>=28)r.push({rop:t.getUint32(e+6,true),source:{height:h(3),width:h(4),y:h(5),x:h(6)},target:{height:h(7),width:h(8),y:h(9),x:h(10)},window:i,record:e,dib:e+28,end:e+m});else if(g===dt&&m>=26)r.push({rop:t.getUint32(e+6,true),source:{height:h(2),width:h(3),y:h(4),x:h(5)},target:{height:h(6),width:h(7),y:h(8),x:h(9)},window:i,record:e,dib:e+26,end:e+m});else if(g===ft&&m>=22){let c={height:h(4),width:h(5),y:h(6),x:h(7)};r.push({rop:t.getUint32(e+6,true),source:{height:c.height,width:c.width,y:h(2),x:h(3)},target:c,window:i,record:e,dib:e+22,end:e+m});}e+=m;}if(!r.length)return null;let a=n.slice(),s=new DataView(a.buffer);return r.forEach(({record:o},m)=>{let g=`${W}${m}`;s.setUint16(o+4,gt,true),s.setInt16(o+6,g.length,true);for(let c=0;c<g.length;c+=1)s.setUint8(o+8+c,g.charCodeAt(c));let h=o+8+g.length+g.length%2;s.setInt16(h,0,true),s.setInt16(h+2,0,true);}),{marked:a,placed:r}}function it(n,t,e,i,r){let a=new DataView(n.buffer,n.byteOffset,n.byteLength),s=t.map(()=>[]);for(let[o,{rop:m,source:g,target:h,window:c,dib:v,end:A}]of t.entries()){if(m!==Q&&m!==tt&&m!==pt||c.width===0||c.height===0)continue;let M=bt(a,v,A);if(!M)continue;let T=e/c.width,p=i/c.height,d=s[o];if(m!==Q){let b=m===tt?255:0;for(let C=0;C<M.data.length;C+=4){let I=M.data;I[C]===b&&I[C+1]===b&&I[C+2]===b&&(I[C+3]=0);}}if(r.pixels+=M.width*M.height,r.pixels>16e6){r.exhausted=true;break}let l=g.width||M.width,x=g.height||M.height,y=h.width/l*T,w=h.height/x*p,k=M.topDown?g.y:M.height-g.y-x,f=g.x!==0||k!==0||l!==M.width||x!==M.height;if(f){let b=(h.x-c.x)*T,C=(h.y-c.y)*p,I=b+h.width*T,R=C+h.height*p;d.push({kind:"save"},{kind:"clip",evenOdd:false,path:[{op:"M",x:b,y:C},{op:"L",x:I,y:C},{op:"L",x:I,y:R},{op:"L",x:b,y:R},{op:"Z"}]});}d.push({kind:"image",raster:{kind:"rgba",width:M.width,height:M.height,data:M.data},matrix:[M.width*y,0,0,M.height*w,(h.x-c.x)*T-g.x*y,(h.y-c.y)*p-k*w]}),f&&d.push({kind:"restore"});}return s}function rt(n,t,e){let i=[],r=0;for(t.forEach((a,s)=>{let o=e(s);if(!(o<0||!a.length)){for(;r<Math.min(o,n.length);)i.push(n[r++]);for(let m of a)i.push(m);}});r<n.length;)i.push(n[r++]);return i}function at(n,t){if(!t.length)return n;let e=chunk3MIZFGHH_cjs.c(t),i=false,r=n.map(a=>{if(a.kind!=="text")return a;let s=e(a.text);if(!s)return a;let o=s.face||a.font.family;return s.text===a.text&&o===a.font.family&&s.baseline===a.baseline&&s.align===a.align?a:(i=true,{...a,text:s.text,font:{...a.font,family:o},baseline:s.baseline,align:s.align})});return i?r:n}var Mt=2e5,z=4096,$=["OffscreenCanvas","ImageData","createImageBitmap","FileReader"],st=Promise.resolve();function yt(n){if(n.length>=24&&n[0]===137&&n[1]===80&&n[2]===78&&n[3]===71){let t=new DataView(n.buffer,n.byteOffset,n.byteLength);return {mime:"image/png",width:t.getUint32(16),height:t.getUint32(20)}}if(n.length>=4&&n[0]===255&&n[1]===216){let t=2;for(;t+9<n.length;){if(n[t]!==255)return null;let e=n[t+1],i=n[t+2]<<8|n[t+3];if(e>=192&&e<=207&&e!==196&&e!==200&&e!==204)return {mime:"image/jpeg",height:n[t+5]<<8|n[t+6],width:n[t+7]<<8|n[t+8]};if(i<2)return null;t+=2+i;}}return null}function wt(n){let t="";for(let e=0;e<n.length;e+=32768)t+=String.fromCharCode(...n.subarray(e,e+32768));return btoa(t)}async function vt(n,t,e){let i={commands:0,points:0,pixels:0,exhausted:false},r=new Map,a=p=>{let d=`recording-${r.size}`;return r.set(d,p),d},s=(p,d)=>{let l=e.textAdvance(p,d);return Number.isFinite(l)&&l>=0?l:0},o=t==="image/x-wmf"?nt(n):null,m=new Map,g=new WeakSet;class h extends B{constructor(d,l){super(d,l,i,s,a);}getContext(d){let l=super.getContext(d);if(!o||!l||g.has(l))return l;g.add(l);let x=l.fillText.bind(l);return l.fillText=(y,w,k)=>{let f=et(String(y));if(f===null||f>=o.placed.length)return x(y,w,k);m.set(f,{commands:l.commands,at:l.commands.length});},l}}class c{result=null;error=null;onload=null;onerror=null;readAsDataURL(d){d.arrayBuffer().then(l=>{this.result=`data:${d.type||"application/octet-stream"};base64,${wt(new Uint8Array(l))}`,this.onload?.();}).catch(l=>{this.error=l,this.onerror?.();});}}let v=async p=>{let d=new Uint8Array(await p.arrayBuffer());if(p.type===F){let y=r.get(new TextDecoder().decode(d));if(!y)throw new Error("Unknown recording");let w=y.drawing();return {width:w.width,height:w.height,drawing:w,close(){}}}let l=yt(d);if(!l||!(l.width>0&&l.height>0))throw new Error("Unsupported bitmap");if(i.pixels+=l.width*l.height,i.pixels>16e6)throw i.exhausted=true,new Error("Bitmap past the pixel bound");let x={kind:"encoded",...l,bytes:d};return {width:l.width,height:l.height,raster:x,close(){}}},A=globalThis,M=$.map(p=>Object.getOwnPropertyDescriptor(A,p)),T={OffscreenCanvas:h,ImageData:P,createImageBitmap:v,FileReader:c};for(let p of $)Object.defineProperty(A,p,{value:T[p],configurable:true,writable:true});try{let{convertEmfToDataUrl:p,convertWmfToDataUrl:d}=await import('emf-converter'),l={dpiScale:1,maxWidth:z,maxHeight:z,maxCanvasDimension:z,maxRecords:Mt},x=(t==="image/x-emf"?chunk3MIZFGHH_cjs.a(n,l):o?.marked??n).slice().buffer,y=t==="image/x-emf"?await p(x,l):await d(x,l),w=y?.startsWith(`data:${F};base64,`)?y.slice(y.indexOf(",")+1):null,k=w?r.get(atob(w)):void 0;if(!k)return null;let f=k.drawing(),C=t==="image/x-wmf"?at(f.commands,chunk3MIZFGHH_cjs.b(n)):f.commands,I=o?it(n,o.placed,f.width,f.height,i):[],R=D=>{let E=m.get(D);return E&&E.commands===f.commands?E.at:-1},_=I.some(D=>D.length)?rt(C,I,R):C;return {drawing:_===f.commands?f:{...f,commands:_},complete:!i.exhausted}}catch{return null}finally{$.forEach((p,d)=>{let l=M[d];l?Object.defineProperty(A,p,l):delete A[p];});}}function Dt(n,t,e){let i=st.then(()=>vt(n,t,e));return st=i.catch(()=>{}),i}exports.replayMetafile=Dt;
@@ -1 +1 @@
1
- 'use strict';var chunkOT5R3IYV_cjs=require('../chunk-OT5R3IYV.cjs');require('../chunk-QLZH2Q2C.cjs');var react=require('react');var y=Symbol("useHocuspocusCollaboration.createRoom");function C(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function m(o){let{createHocuspocusCollaboration:t}=await import('../collaboration/hocuspocus.cjs');return t(o)}function b(o){return o[y]??m}function H(o={}){let t=react.useId(),e=chunkOT5R3IYV_cjs.b({ownerKey:`react-hocuspocus:${t}`,hookName:"useHocuspocusCollaboration",createRoom:b(o),hostModules:o.modules??chunkOT5R3IYV_cjs.a,autoRoom:o.room??null,autoKey:C(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room?.provider??null,i=react.useCallback(n=>r?(r.on("unsyncedChanges",n),()=>{r.off("unsyncedChanges",n);}):()=>{},[r]),s=react.useSyncExternalStore(i,()=>r?.unsyncedChanges??0,()=>0);return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:s,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,s])}exports.useHocuspocusCollaboration=H;
1
+ 'use strict';var chunkQOXYHVBM_cjs=require('../chunk-QOXYHVBM.cjs');require('../chunk-QEULTKCT.cjs'),require('../chunk-IULA3QRZ.cjs');var react=require('react');var y=Symbol("useHocuspocusCollaboration.createRoom");function C(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function m(o){let{createHocuspocusCollaboration:t}=await import('../collaboration/hocuspocus.cjs');return t(o)}function b(o){return o[y]??m}function H(o={}){let t=react.useId(),e=chunkQOXYHVBM_cjs.b({ownerKey:`react-hocuspocus:${t}`,hookName:"useHocuspocusCollaboration",createRoom:b(o),hostModules:o.modules??chunkQOXYHVBM_cjs.a,autoRoom:o.room??null,autoKey:C(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room?.provider??null,i=react.useCallback(n=>r?(r.on("unsyncedChanges",n),()=>{r.off("unsyncedChanges",n);}):()=>{},[r]),s=react.useSyncExternalStore(i,()=>r?.unsyncedChanges??0,()=>0);return react.useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:s,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,s])}exports.useHocuspocusCollaboration=H;
@@ -1 +1 @@
1
- import {b as b$1,a}from'../chunk-MWO2ZUEJ.js';import'../chunk-Q2VBO66F.js';import {useId,useCallback,useSyncExternalStore,useMemo}from'react';var y=Symbol("useHocuspocusCollaboration.createRoom");function C(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function m(o){let{createHocuspocusCollaboration:t}=await import('../collaboration/hocuspocus.js');return t(o)}function b(o){return o[y]??m}function H(o={}){let t=useId(),e=b$1({ownerKey:`react-hocuspocus:${t}`,hookName:"useHocuspocusCollaboration",createRoom:b(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:C(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room?.provider??null,i=useCallback(n=>r?(r.on("unsyncedChanges",n),()=>{r.off("unsyncedChanges",n);}):()=>{},[r]),s=useSyncExternalStore(i,()=>r?.unsyncedChanges??0,()=>0);return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:s,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,s])}export{H as useHocuspocusCollaboration};
1
+ import {b as b$1,a}from'../chunk-3HW2VWFW.js';import'../chunk-EOZ44UA7.js';import'../chunk-HMU7J34H.js';import {useId,useCallback,useSyncExternalStore,useMemo}from'react';var y=Symbol("useHocuspocusCollaboration.createRoom");function C(o){return o?`${o.url}:${o.roomId}:${o.bootstrap.kind}:${o.identity.actorId}`:""}async function m(o){let{createHocuspocusCollaboration:t}=await import('../collaboration/hocuspocus.js');return t(o)}function b(o){return o[y]??m}function H(o={}){let t=useId(),e=b$1({ownerKey:`react-hocuspocus:${t}`,hookName:"useHocuspocusCollaboration",createRoom:b(o),hostModules:o.modules??a,autoRoom:o.room??null,autoKey:C(o.room??null),rejoinOptionsOf:n=>({...n,bootstrap:{kind:"join"}}),identityOf:n=>n.identity}),r=e.room?.provider??null,i=useCallback(n=>r?(r.on("unsyncedChanges",n),()=>{r.off("unsyncedChanges",n);}):()=>{},[r]),s=useSyncExternalStore(i,()=>r?.unsyncedChanges??0,()=>0);return useMemo(()=>({document:e.document,modules:e.modules,session:e.session,ydoc:e.room?.ydoc??null,provider:e.room?.provider??null,pending:e.pending,unsyncedChanges:s,error:e.error,connect:e.connect,leave:e.leave,rejoin:e.rejoin}),[e,s])}export{H as useHocuspocusCollaboration};