allyhub 0.10.0 → 0.11.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.
- package/CHANGELOG.md +8 -0
- package/dist/commands/dev.js +2 -2
- package/dist/commands/frames/report.js +2 -0
- package/dist/commands/frames.js +11 -9
- package/dist/commands/render.js +2 -2
- package/dist/node_modules/@allyhub/3d-extension/dist/stage-routes.js +1 -1
- package/dist/node_modules/@allyhub/3d-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/browser/dist/emoji.d.ts +29 -0
- package/dist/node_modules/@allyhub/browser/dist/emoji.js +57 -0
- package/dist/node_modules/@allyhub/browser/dist/picture.d.ts +18 -0
- package/dist/node_modules/@allyhub/browser/dist/picture.js +2 -0
- package/dist/node_modules/@allyhub/browser/package.json +9 -1
- package/dist/node_modules/@allyhub/build/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/build/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/build/dist/kind-build.d.ts +7 -0
- package/dist/node_modules/@allyhub/build/dist/made-notes.d.ts +9 -0
- package/dist/node_modules/@allyhub/build/dist/made-notes.js +2 -0
- package/dist/node_modules/@allyhub/build/dist/project-tool.d.ts +17 -0
- package/dist/node_modules/@allyhub/build/dist/stage-route.d.ts +7 -0
- package/dist/node_modules/@allyhub/build/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/canvas-model/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/check/package.json +1 -1
- package/dist/node_modules/@allyhub/cloud/dist/client.js +1 -1
- package/dist/node_modules/@allyhub/cloud/package.json +1 -1
- package/dist/node_modules/@allyhub/components/package.json +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/exports.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/inputs.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/live.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/pages.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/ports.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/project.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/record.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/respond.js +2 -0
- package/dist/node_modules/@allyhub/dev-server/dist/reveal.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/server.js +2 -2
- package/dist/node_modules/@allyhub/dev-server/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/dist/watcher.js +1 -1
- package/dist/node_modules/@allyhub/dev-server/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/dist/problem.d.ts +7 -0
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/doc/dist/html.js +15 -59
- package/dist/node_modules/@allyhub/doc/dist/page.js +1 -1
- package/dist/node_modules/@allyhub/doc/package.json +1 -1
- package/dist/node_modules/@allyhub/doc-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/doc-extension/package.json +12 -14
- package/dist/node_modules/@allyhub/doc-print/dist/pages.js +5 -5
- package/dist/node_modules/@allyhub/doc-print/dist/print.js +10 -10
- package/dist/node_modules/@allyhub/doc-print/package.json +1 -1
- package/dist/node_modules/@allyhub/export/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-api/package.json +1 -1
- package/dist/node_modules/@allyhub/extension-host/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/note-shape.d.ts +20 -0
- package/dist/node_modules/@allyhub/formats/dist/note-shape.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/i18n/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-extension/dist/export.js +4 -1
- package/dist/node_modules/@allyhub/image-extension/package.json +1 -6
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-psd/package.json +1 -1
- package/dist/node_modules/@allyhub/image-render/package.json +1 -1
- package/dist/node_modules/@allyhub/image-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/jobs/package.json +1 -1
- package/dist/node_modules/@allyhub/linkedin-extension/LICENSE +241 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/article-build.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/article-kind.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/build-plugins.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/build.js +5 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/media.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/stage-module.js +82 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/dist/workspace.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-extension/package.json +287 -0
- package/dist/node_modules/@allyhub/linkedin-extension/skills/allyhub/references/linkedin.md +12 -0
- package/dist/node_modules/@allyhub/linkedin-model/LICENSE +241 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/article-check.js +5 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/article.js +3 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/check.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/count.js +3 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/edit.js +3 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/html.js +19 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/limits.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/little.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/post.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/dist/requests.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-model/package.json +14 -0
- package/dist/node_modules/@allyhub/linkedin-view/LICENSE +241 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/article.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/fold.js +3 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/index.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/post.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/stage.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-view/dist/text.js +2 -0
- package/dist/node_modules/@allyhub/linkedin-view/package.json +21 -0
- package/dist/node_modules/@allyhub/linkedin-view/src/style.css +600 -0
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/media/package.json +1 -1
- package/dist/node_modules/@allyhub/media-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/model/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/package.json +1 -1
- package/dist/node_modules/@allyhub/piece/dist/layer.d.ts +2 -0
- package/dist/node_modules/@allyhub/piece/dist/page/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/piece/dist/page/index.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/page/locate.d.ts +14 -1
- package/dist/node_modules/@allyhub/piece/dist/page/locate.js +1 -1
- package/dist/node_modules/@allyhub/piece/dist/stage.d.ts +12 -0
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/project/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +8 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +4 -0
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +6 -0
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +61 -1
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +0 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/notes.d.ts +41 -3
- package/dist/node_modules/@allyhub/protocol/dist/notes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +17 -0
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/teams.d.ts +7 -0
- package/dist/node_modules/@allyhub/protocol/dist/teams.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +12 -0
- package/dist/node_modules/@allyhub/protocol/dist/tools.js +1 -1
- package/dist/node_modules/@allyhub/protocol/package.json +1 -5
- package/dist/node_modules/@allyhub/registry/package.json +1 -1
- package/dist/node_modules/@allyhub/render/dist/encode.js +1 -1
- package/dist/node_modules/@allyhub/render/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/render/dist/render.js +2 -2
- package/dist/node_modules/@allyhub/render/package.json +1 -1
- package/dist/node_modules/@allyhub/report-extension/LICENSE +241 -0
- package/dist/node_modules/@allyhub/report-extension/dist/build.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/check.js +3 -0
- package/dist/node_modules/@allyhub/report-extension/dist/cli/find.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/cli/index.js +5 -0
- package/dist/node_modules/@allyhub/report-extension/dist/cli/picture.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/export.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/inline.js +58 -0
- package/dist/node_modules/@allyhub/report-extension/dist/page.js +21 -0
- package/dist/node_modules/@allyhub/report-extension/dist/project-tools.js +21 -0
- package/dist/node_modules/@allyhub/report-extension/dist/styles.js +5 -0
- package/dist/node_modules/@allyhub/report-extension/dist/theme.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/tools.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/dist/workspace.js +2 -0
- package/dist/node_modules/@allyhub/report-extension/package.json +182 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/STYLE.md +132 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.css +105 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/style.json +17 -0
- package/dist/node_modules/@allyhub/report-extension/styles/allyhub/tokens.js +38 -0
- package/dist/node_modules/@allyhub/runtime/dist/compose.js +1 -1
- package/dist/node_modules/@allyhub/runtime/dist/player/player.js +1 -1
- package/dist/node_modules/@allyhub/runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scaffold/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/layer/index.js +1 -1
- package/dist/node_modules/@allyhub/scenery-host/dist/viewer.d.ts +6 -0
- package/dist/node_modules/@allyhub/scenery-host/dist/viewer.js +1 -1
- package/dist/node_modules/@allyhub/scenery-host/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/export.js +2 -4
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet-extension/dist/export.js +2 -6
- package/dist/node_modules/@allyhub/sheet-extension/package.json +3 -7
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/slides-extension/package.json +3 -16
- package/dist/node_modules/@allyhub/slides-pptx/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/dist/draw.js +1 -1
- package/dist/node_modules/@allyhub/slides-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/stage/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/install.js +1 -1
- package/dist/node_modules/@allyhub/stage-page/dist/runtime/stage.js +1 -1
- package/dist/node_modules/@allyhub/stage-page/package.json +1 -1
- package/dist/node_modules/@allyhub/stage-runtime/dist/runtime.js +14 -14
- package/dist/node_modules/@allyhub/stage-runtime/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-extension/dist/export.js +1 -1
- package/dist/node_modules/@allyhub/video-extension/package.json +2 -4
- package/dist/node_modules/@allyhub/video-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/website/package.json +1 -1
- package/dist/node_modules/@allyhub/website-extension/dist/preview.js +5 -5
- package/dist/node_modules/@allyhub/website-extension/dist/project-tools.js +2 -2
- package/dist/node_modules/@allyhub/website-extension/package.json +1 -1
- package/dist/node_modules/@allyhub/x-extension/dist/build.js +4 -3
- package/dist/node_modules/@allyhub/x-extension/package.json +10 -12
- package/dist/node_modules/@allyhub/x-model/package.json +1 -1
- package/dist/node_modules/@allyhub/x-view/package.json +1 -1
- package/dist/package.json +12 -10
- package/dist/works.js +1 -1
- package/editor-web/assets/{abnfDiagram-WEYOIA3C-CjAmWsNR.js → abnfDiagram-WEYOIA3C-BKmMA6gn.js} +1 -1
- package/editor-web/assets/{architecture-WOLXFQ4H-DeeKhyhZ.js → architecture-WOLXFQ4H-BEFBgb4k.js} +1 -1
- package/editor-web/assets/{architectureDiagram-ZHVYKT53-b32qTaJg.js → architectureDiagram-ZHVYKT53-_u5YfCjY.js} +1 -1
- package/editor-web/assets/{arrow-up-L4YV_65f.js → arrow-up-B5rJbBv0.js} +1 -1
- package/editor-web/assets/article-BUmD3xtR.js +8 -0
- package/editor-web/assets/article-DNioBb3p.js +7 -0
- package/editor-web/assets/{audio-lines-BFcM7G2L.js → audio-lines-CzuzsGjI.js} +1 -1
- package/editor-web/assets/{blockDiagram-RJAE7QA3-BNbnMNmw.js → blockDiagram-RJAE7QA3-DybfaO3Z.js} +1 -1
- package/editor-web/assets/bookmark-Dsd3kHJJ.js +1 -0
- package/editor-web/assets/button-eGxLxbv9.js +41 -0
- package/editor-web/assets/{c4Diagram-XDPPPE54-BEuemvMw.js → c4Diagram-XDPPPE54-BfqLHB5i.js} +1 -1
- package/editor-web/assets/channel-TNPgFDrw.js +1 -0
- package/editor-web/assets/chart-C37xvZT2.js +1 -0
- package/editor-web/assets/chart-no-axes-column-BVkeF_Mr.js +1 -0
- package/editor-web/assets/{chunk-2E7WHVMD-Zb5nPx_e.js → chunk-2E7WHVMD-BVp1I_d0.js} +1 -1
- package/editor-web/assets/{chunk-4EMNKR2T-DSEM2reX.js → chunk-4EMNKR2T-CTdgWEMr.js} +1 -1
- package/editor-web/assets/{chunk-55XCU76K-BOZa_65H.js → chunk-55XCU76K-7pnsxeaP.js} +1 -1
- package/editor-web/assets/{chunk-7S6XSTFO-DeiGeVpB.js → chunk-7S6XSTFO-Dc0Dvkq7.js} +1 -1
- package/editor-web/assets/{chunk-AQDTSKZB-fPuQFBJc.js → chunk-AQDTSKZB-VAILIsfx.js} +1 -1
- package/editor-web/assets/{chunk-DSNLSHJZ-5vdnoak2.js → chunk-DSNLSHJZ-CUDx1Rv5.js} +1 -1
- package/editor-web/assets/{chunk-HAGFOTED-DFF2mZJ1.js → chunk-HAGFOTED-DAoEe-dJ.js} +1 -1
- package/editor-web/assets/{chunk-HNE4Q36P-g6-ZLbTg.js → chunk-HNE4Q36P-g0akya12.js} +1 -1
- package/editor-web/assets/{chunk-NQOKRVIF-o3hNcHMJ.js → chunk-NQOKRVIF-hTGjzXdJ.js} +1 -1
- package/editor-web/assets/{chunk-UHW7PFBP-BQiDI9dK.js → chunk-UHW7PFBP-BgLV8BIJ.js} +1 -1
- package/editor-web/assets/{chunk-VQ5W62QI-CJlMXWWz.js → chunk-VQ5W62QI-Bw19OOSD.js} +1 -1
- package/editor-web/assets/{chunk-WQQL4CDK-pNBU8dXv.js → chunk-WQQL4CDK-CMST9dyE.js} +1 -1
- package/editor-web/assets/{chunk-YZO67HFG-2x-BiWd-.js → chunk-YZO67HFG-Bbpu36XF.js} +1 -1
- package/editor-web/assets/{chunk-ZAUX2LTX-etFStEM8.js → chunk-ZAUX2LTX-C48Ri0Gs.js} +1 -1
- package/editor-web/assets/{chunk-ZCHMQSOR-B3AYRhIY.js → chunk-ZCHMQSOR-DN1g01Oe.js} +1 -1
- package/editor-web/assets/{classDiagram-v2-4MYWR3UA-6y2yX0oq.js → classDiagram-v2-4MYWR3UA-U6jbPr2d.js} +1 -1
- package/editor-web/assets/{collaborator-LRd0hELn.js → collaborator-B1u2td9m.js} +1 -1
- package/editor-web/assets/{createLucideIcon-CPS-TrJJ.js → createLucideIcon-GFZ_fxLc.js} +1 -1
- package/editor-web/assets/{cynefin-EF2NZ3EQ-CX4BTQQe.js → cynefin-EF2NZ3EQ-gzkai_7-.js} +1 -1
- package/editor-web/assets/{cynefinDiagram-WF24UDRP-LbDkOTy3.js → cynefinDiagram-WF24UDRP-DtSekSr6.js} +1 -1
- package/editor-web/assets/{dagre-NK4GIZVX-wCKQk7hi.js → dagre-NK4GIZVX-CiUwYVT6.js} +1 -1
- package/editor-web/assets/{diagram-CBK3MWTC-a9fofQwk.js → diagram-CBK3MWTC-r9XHCV-k.js} +1 -1
- package/editor-web/assets/{diagram-I5XIIV2D-UCLZWch5.js → diagram-I5XIIV2D-DxVsDZ34.js} +1 -1
- package/editor-web/assets/{diagram-ODIL2UCW-CAEe88Lp.js → diagram-ODIL2UCW-B0eNQoHV.js} +1 -1
- package/editor-web/assets/{diagram-PFBEJUXE-Cp1o45bs.js → diagram-PFBEJUXE-C7f2MfJT.js} +1 -1
- package/editor-web/assets/{diagram-RJA3I4VV-c6OVxDyq.js → diagram-RJA3I4VV-CSXcnvct.js} +1 -1
- package/editor-web/assets/{diagram-TYUNFSNR-BVRWslDM.js → diagram-TYUNFSNR-DXzOD_ii.js} +1 -1
- package/editor-web/assets/dist-BGRwhCQO.js +1 -0
- package/editor-web/assets/{dist-DwGhfliS.js → dist-BW4X7BrF.js} +1 -1
- package/editor-web/assets/dist-BgDRE85b.js +2 -0
- package/editor-web/assets/dist-Blq5nJnU.js +24 -0
- package/editor-web/assets/dist-BuWaZ3Y4.js +274 -0
- package/editor-web/assets/dist-C1emZ9wX.js +37 -0
- package/editor-web/assets/dist-CC7OeU1e.js +6 -0
- package/editor-web/assets/{dist-j6ZLVcgf.js → dist-CX-fiPSn.js} +16 -16
- package/editor-web/assets/dist-C_VvG-_9.js +5 -0
- package/editor-web/assets/dist-Ce7HrBxv.js +3 -0
- package/editor-web/assets/dist-D2k6w-_a.js +1 -0
- package/editor-web/assets/dist-DDv_SbKw.js +84 -0
- package/editor-web/assets/dist-DEoEO4zs.js +1 -0
- package/editor-web/assets/dist-DlDxxPIP.js +16 -0
- package/editor-web/assets/dist-Gz6NDS0J.js +4 -0
- package/editor-web/assets/{ebnfDiagram-V4P3TTPT-KdOTJgFu.js → ebnfDiagram-V4P3TTPT-Cs4YRvDD.js} +1 -1
- package/editor-web/assets/{elk-QONTBCTQ-Cmlrp7qB.js → elk-QONTBCTQ-Bh3LZ9WI.js} +1 -1
- package/editor-web/assets/{erDiagram-KYQIGQAA-CBM7-aQm.js → erDiagram-KYQIGQAA-C4vYTYXp.js} +1 -1
- package/editor-web/assets/{eventmodeling-K75KTNOO-CEoJkbuW.js → eventmodeling-K75KTNOO-BN1kkHWS.js} +1 -1
- package/editor-web/assets/flowDiagram-IUGLLWBU-B04NGsyi.js +1 -0
- package/editor-web/assets/{ganttDiagram-R7GPNTJY-D4S6ZSYD.js → ganttDiagram-R7GPNTJY-CA1LkkC5.js} +1 -1
- package/editor-web/assets/{gitGraph-VSP46ZUC-BvkL6RSh.js → gitGraph-VSP46ZUC-Dy5tA7dG.js} +1 -1
- package/editor-web/assets/{gitGraphDiagram-PDYL7XHY-lTGguloH.js → gitGraphDiagram-PDYL7XHY-hJIB8EkH.js} +1 -1
- package/editor-web/assets/{hint-BimUgJms.js → hint-B8JpEypy.js} +1 -1
- package/editor-web/assets/index-CgB5osVc.js +28 -0
- package/editor-web/assets/index-Daytem9N.css +2 -0
- package/editor-web/assets/{info-OHQRW6UA-DvKzqNvp.js → info-OHQRW6UA-DvzSf7rQ.js} +1 -1
- package/editor-web/assets/{infoDiagram-MVDRKAX5-D7hCpehs.js → infoDiagram-MVDRKAX5-BjIMm4Af.js} +1 -1
- package/editor-web/assets/{ishikawaDiagram-HPEHV2GE-Bg93sZQe.js → ishikawaDiagram-HPEHV2GE-Bpz71S40.js} +1 -1
- package/editor-web/assets/{italic-BQBwRTe8.js → italic-D10w8n6C.js} +1 -1
- package/editor-web/assets/{journeyDiagram-BOSHW7O7-CKm_KONJ.js → journeyDiagram-BOSHW7O7-DAB-pZjD.js} +1 -1
- package/editor-web/assets/{kanban-definition-FNSA4HC5-BKknnpTR.js → kanban-definition-FNSA4HC5-cYeyh3P6.js} +1 -1
- package/editor-web/assets/katex-5Z2zF-9g.js +257 -0
- package/editor-web/assets/link-BC5xK1-1.js +1 -0
- package/editor-web/assets/{mermaid-parser.core-BzqkDnqL.js → mermaid-parser.core-req5LE0X.js} +3 -3
- package/editor-web/assets/{mermaid.core-CEpvTOAe.js → mermaid.core-zFwZug4C.js} +4 -4
- package/editor-web/assets/{mindmap-definition-6OY57UG3-BJ0qG8Wi.js → mindmap-definition-6OY57UG3-TStWb7DG.js} +1 -1
- package/editor-web/assets/minus-DaWs5i8B.js +1 -0
- package/editor-web/assets/{packet-JDAUHWVQ-ew3kvyFm.js → packet-JDAUHWVQ-smFhVKcB.js} +1 -1
- package/editor-web/assets/palette-BIOudGkm.js +1 -0
- package/editor-web/assets/{pegDiagram-ECIUJNBX-DqUS2xit.js → pegDiagram-ECIUJNBX-DvSNRv0-.js} +1 -1
- package/editor-web/assets/{pie-XZMESJXO-DTIAMPGm.js → pie-XZMESJXO-qjaGsBZG.js} +1 -1
- package/editor-web/assets/{pieDiagram-GNMPY74T-DoKOE02-.js → pieDiagram-GNMPY74T-Dd9P-Pdc.js} +1 -1
- package/editor-web/assets/play-CrMmPghG.js +1 -0
- package/editor-web/assets/{progress-CPEbDOoN.js → progress-DE4C5_3x.js} +1 -1
- package/editor-web/assets/props-form-CsmDBqzy.js +1 -0
- package/editor-web/assets/{quadrantDiagram-D57K4MC3-DauOpYun.js → quadrantDiagram-D57K4MC3-h2IIKUUA.js} +1 -1
- package/editor-web/assets/{radar-ABXABTNO-BvMJXUU-.js → radar-ABXABTNO-DlVrSA1d.js} +1 -1
- package/editor-web/assets/{railroad-I3PHUGI6-D3jdJmhM.js → railroad-I3PHUGI6-nFbuLAtc.js} +1 -1
- package/editor-web/assets/{railroad-abnf-LNEFI6M7-Dm8ZpmPj.js → railroad-abnf-LNEFI6M7-Daj8h2iV.js} +1 -1
- package/editor-web/assets/{railroad-ebnf-DWYD2UWJ-oc0Du7Ag.js → railroad-ebnf-DWYD2UWJ-eYJyl5PH.js} +1 -1
- package/editor-web/assets/{railroad-peg-JR7BVNR7-CMrQL_7U.js → railroad-peg-JR7BVNR7-BTRhKZQq.js} +1 -1
- package/editor-web/assets/{railroadDiagram-Y72NRBL7-y99z0C7i.js → railroadDiagram-Y72NRBL7-CeLGUjdp.js} +1 -1
- package/editor-web/assets/{react-DztDSW4P.js → react-WA6wlt8S.js} +1 -1
- package/editor-web/assets/{repeat-2-DJi4LW5C.js → repeat-2-VQP1EVOZ.js} +1 -1
- package/editor-web/assets/{requirementDiagram-EQYSW5RA-jMr_uoF6.js → requirementDiagram-EQYSW5RA-Dmk9XRM5.js} +1 -1
- package/editor-web/assets/{row-ClBisiBs.js → row-BRlEWRrK.js} +1 -1
- package/editor-web/assets/{sankeyDiagram-SY24JHO5-DcUyx03Q.js → sankeyDiagram-SY24JHO5-Yn4zlrAM.js} +1 -1
- package/editor-web/assets/{schemas-68mjUjP5.js → schemas-VikZYZIK.js} +1 -1
- package/editor-web/assets/{sequenceDiagram-BLEHNHQU-R4X8wRCd.js → sequenceDiagram-BLEHNHQU-BTRnp_PW.js} +1 -1
- package/editor-web/assets/{session-2u9U7koW.js → session-Do9AqS38.js} +1 -1
- package/editor-web/assets/{slides-BByblSSR.js → slides-diTEQ3C5.js} +1 -1
- package/editor-web/assets/{snapshots-C9KV-Y2_.js → snapshots-BUGlKQIB.js} +1 -1
- package/editor-web/assets/{sound-DExlNJbb.js → sound-Bj3o9_Fa.js} +1 -1
- package/editor-web/assets/split-CNU1RHcX.js +3 -0
- package/editor-web/assets/{stateDiagram-v2-A6IESKWZ-BqvXKbCA.js → stateDiagram-v2-A6IESKWZ-kstrRKv2.js} +1 -1
- package/editor-web/assets/{strikethrough-CyUBnGTl.js → strikethrough-CfXx6IYH.js} +1 -1
- package/editor-web/assets/{svg-lBRT-uhy.js → svg-Cx50MpxK.js} +1 -1
- package/editor-web/assets/{swatch-1c1uVn1z.js → swatch-WeJD41aW.js} +1 -1
- package/editor-web/assets/{swimlanes-B3ENRKFQ-hjTXIc6M.js → swimlanes-B3ENRKFQ-DaZsZkeP.js} +1 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-CBZAujYY.js +8 -0
- package/editor-web/assets/{switch-D0K-K8-C.js → switch-N0G_sbqt.js} +1 -1
- package/editor-web/assets/syntax-BVsgRJ4I.js +66 -0
- package/editor-web/assets/syntax-oWsKBWFw.js +1 -0
- package/editor-web/assets/table-B6hVZAMi.js +1 -0
- package/editor-web/assets/{tabs-CxxOnGLR.js → tabs-DIFDqj-l.js} +1 -1
- package/editor-web/assets/{textarea-Fu93tFO3.js → textarea-tEWvBY9p.js} +1 -1
- package/editor-web/assets/{timeline-definition-JXYKGLGB-BcSoN4Dq.js → timeline-definition-JXYKGLGB-CLCvY-Yf.js} +1 -1
- package/editor-web/assets/{trash-2-BAKAeziW.js → trash-2-BP6nqpg2.js} +1 -1
- package/editor-web/assets/{treeView-D4JQ5SDB-CsFN2jrc.js → treeView-D4JQ5SDB-BmN0gwdC.js} +1 -1
- package/editor-web/assets/{treemap-SAJKECNS-DP1eqXJ2.js → treemap-SAJKECNS-DN29G_E_.js} +1 -1
- package/editor-web/assets/{undo-2-DQ5CBmki.js → undo-2-CHR0nvWL.js} +1 -1
- package/editor-web/assets/{usecaseDiagram-WPOLBNNX-BGxa0osF.js → usecaseDiagram-WPOLBNNX-DTRS54cB.js} +1 -1
- package/editor-web/assets/{vennDiagram-Q3Y3IDCW-D2XhTF49.js → vennDiagram-Q3Y3IDCW-DAAc11Hx.js} +1 -1
- package/editor-web/assets/{video-CDbPX4Cr.js → video-BlvmR8BK.js} +1 -1
- package/editor-web/assets/{wardley-7MLQ67FV-DM3jMAbZ.js → wardley-7MLQ67FV-B-UYkmdB.js} +1 -1
- package/editor-web/assets/{wardleyDiagram-IVAIDKWA-Bf-DaZEg.js → wardleyDiagram-IVAIDKWA-BmbwCaky.js} +1 -1
- package/editor-web/assets/words-D_4T9Adq.js +3 -0
- package/editor-web/assets/words-WgdEQdYP.js +2 -0
- package/editor-web/assets/{xychartDiagram-4URNHDU4-dp-mdcWd.js → xychartDiagram-4URNHDU4-ChAfAq1U.js} +1 -1
- package/editor-web/index.html +6 -6
- package/package.json +8 -2
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.d.ts +0 -337
- package/dist/node_modules/@allyhub/protocol/dist/browser-bridge.js +0 -2
- package/editor-web/assets/alt-DnBZJzEh.js +0 -4
- package/editor-web/assets/article-DLMjAdbP.js +0 -73
- package/editor-web/assets/button-Chk675Xu.js +0 -41
- package/editor-web/assets/channel-EzYq4r0d.js +0 -1
- package/editor-web/assets/chart-Be9Hj5GL.js +0 -1
- package/editor-web/assets/choice-BgmBh4yu.js +0 -1
- package/editor-web/assets/dist--KKyT5zP.js +0 -340
- package/editor-web/assets/dist-1k0MHB3i.js +0 -1
- package/editor-web/assets/dist-B9KHJqL5.js +0 -4
- package/editor-web/assets/dist-BbJyrhIY.js +0 -1
- package/editor-web/assets/dist-CJXCQxQM.js +0 -37
- package/editor-web/assets/dist-D9xQGwe9.js +0 -5
- package/editor-web/assets/dist-DFiLzbx8.js +0 -219
- package/editor-web/assets/dist-DIPV6xfF.js +0 -2
- package/editor-web/assets/dist-Dp-fQMtx.js +0 -6
- package/editor-web/assets/dist-Duw28VxJ.js +0 -16
- package/editor-web/assets/dist-OBE2IIYP.js +0 -24
- package/editor-web/assets/flowDiagram-IUGLLWBU-Xm2E2ib_.js +0 -1
- package/editor-web/assets/index-C-i_iuxN.js +0 -28
- package/editor-web/assets/index-Cxh_Shkm.css +0 -2
- package/editor-web/assets/minus-oPj1GxwA.js +0 -1
- package/editor-web/assets/swimlanesDiagram-AYQRV4AK-BLfytmPY.js +0 -8
- package/editor-web/assets/syntax-Bih_jv7W.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{chartColor as te,chartFrame as ne,docChartSvg as ie}from"./chart.js";import{BACKGROUNDS as B,TEXT_COLORS as D}from"./color.js";import{columnWidths as
|
|
3
|
-
`)}function
|
|
4
|
-
`).map(n=>`<span class="line">${p(n)}</span>`).join(""),
|
|
2
|
+
import{chartColor as te,chartFrame as ne,docChartSvg as ie}from"./chart.js";import{emojiPicturesScript as oe}from"@allyhub/browser/emoji";export{EMOJI_PATTERN}from"@allyhub/browser/emoji";import{BACKGROUNDS as B,TEXT_COLORS as D}from"./color.js";import{columnWidths as ae,COLUMN_GAP as se}from"./columns.js";import{COMPONENT_WIDTH as U,componentName as re}from"./component.js";import{citationText as de,citedOf as le,sourceList as ce}from"./cite.js";import{blockId as pe,captionNumbers as fe,contentsTitle as he,numberedCaption as R,writtenInChinese as ge,withoutTitle as ue}from"./captions.js";import{DRAWN_CODE as K,mathHtml as me}from"./math.js";import{charsAcross as X,columnShares as $e,emptyHead as be,numberColumns as ke}from"./table.js";import{splitTitle as xe}from"./title.js";import{PAPER as c,TONE_COLORS as Z,tagColors as we}from"./paper.js";import{COVER_HEIGHT_MM as ye,everyBlock as q,innerBlocks as Se,noteNumbers as ve,statTone as Ce}from"./model.js";import{effectiveLook as H,lineMultiple as ze,resolvePage as j,SINGLE_LINE as I}from"./page.js";export const PAGE_FACES={sans:'Carlito, Calibri, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif',serif:'Caladea, Cambria, "Noto Serif SC", "Songti SC", Georgia, serif',times:'Tinos, "Times New Roman", Times, "Noto Serif SC", serif',mono:'Cousine, "Courier New", "Noto Sans SC", monospace',song:'"Noto Serif SC", "Songti SC", SimSun, "宋体", serif',hei:'"Noto Sans SC", "PingFang SC", SimHei, "黑体", sans-serif',fangsong:'FangSong, STFangsong, "仿宋", "FangSong_GB2312", "Noto Serif SC", serif',kai:'"LXGW WenKai", KaiTi, STKaiti, "楷体", "Noto Serif SC", serif',xiaobiaosong:'"FZXiaoBiaoSong-B05S", "方正小标宋简体", "Noto Serif SC", "Songti SC", serif'};export function pageFaces(i={}){const n=H(i).font??"sans";return{text:PAGE_FACES[n],heading:PAGE_FACES[n],mono:PAGE_FACES.mono}}export const pageAccent=(i={})=>i.accent===void 0?void 0:te(i.accent);export{BACKGROUNDS,TEXT_COLORS}from"./color.js";export function blockNumbers(i){const n=new Map;for(const e of q(i))n.set(e,n.size);return n}const p=i=>i.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),O=(i,n)=>n[i]??(/^(#[0-9a-f]{3,8}|[a-z]+|(rgb|hsl)a?\([\d\s.,%/]+\))$/i.test(i)?i:void 0),h=(i,n)=>{const e=n.ids?.get(i);return e===void 0?"":` data-b="${String(e)}"`};export function headingAnchors(i){const n=new Map,e=new Map;for(const a of q(i)){if(a.type!=="heading")continue;const s=a.content.map(r=>r.text).join("").trim().toLowerCase().replace(/[^\p{L}\p{N}\s-]/gu,"").replace(/\s/gu,"-"),t=s===""?"section":s,o=e.get(t)??0;e.set(t,o+1),n.set(a,o===0?t:`${t}-${String(o)}`)}return n}function x(i,n){return i.map(e=>{if(e.cite!==void 0){const{items:d,numbers:l,style:f}=n.sources,g=le(e.cite).keys[0],w=p(de(e.cite,d,l,f));return g!==void 0&&l.has(g)?`<a class="cite" href="#source-${p(g)}">${w}</a>`:`<span class="cite">${w}</span>`}if(e.note!==void 0){const d=n.notes.get(e.note.toLowerCase());return d===void 0?`<sup class="fn">[${p(e.note)}]</sup>`:`<sup class="fn"><a href="#note-${String(d)}">${String(d)}</a></sup>`}const a=e.text===""&&e.href?.startsWith("#")===!0?n.refs.get(decodeURIComponent(e.href.slice(1)))??"":e.text;let s=p(a).replace(/\n/g,"<br>");const t=e.styles;t.code&&(s=`<code>${s}</code>`),t.strike&&(s=`<s>${s}</s>`),t.italic&&(s=`<em>${s}</em>`),t.bold&&(s=`<strong>${s}</strong>`),t.underline&&(s=`<u>${s}</u>`);const o=t.color===void 0?void 0:O(t.color,D),r=t.background===void 0?void 0:O(t.background,B);if((o!==void 0||r!==void 0)&&(s=`<span style="${o===void 0?"":`color:${o};`}${r===void 0?"":`background:${r};`}">${s}</span>`),t.tag!==void 0){const d=we(t.tag);s=`<span class="tag" style="background:${d.bg};color:${d.fg}">${s}</span>`}return e.href!==void 0&&/^(https?:|mailto:|#|\/|\.)/i.test(e.href)&&(s=`<a href="${p(e.href)}">${s}</a>`),s}).join("")}function N(i,n=!1){if(!i)return"";const e=i.color===void 0?void 0:O(i.color,D),a=i.background===void 0?void 0:O(i.background,B),s=[i.align===void 0?"":`text-align:${i.align};`,e===void 0?"":`color:${e};`,a===void 0?"":n?`background:${a};`:`background:${a};padding:0.15em 0.4em;border-radius:3px;`].join("");return s===""?"":` style="${s}"`}const Y=i=>i.type==="bullet"||i.type==="numbered"||i.type==="check";function y(i,n,e){const a=[];let s=0;for(;s<i.length;){const t=i[s];if(t===void 0)break;if(Y(t)){const o=t.type==="numbered";let r=s;const d=[];for(;r<i.length;){const f=i[r];if(!f||!Y(f)||f.type==="numbered"!==o)break;const g=f.type==="check"?`<span class="box${f.checked?" done":""}"></span>`:"";d.push(`<li${h(f,e)}${f.type==="check"?` class="task${f.checked?" done":""}"`:""}${N(f.look)}>${g}<span class="words">${x(f.content,e)}</span>${y(f.children??[],n,e)}</li>`),r++}const l=t.type==="numbered"&&t.start!==void 0?` start="${String(t.start)}"`:"";a.push(o?`<ol${l}>${d.join("")}</ol>`:`<ul>${d.join("")}</ul>`),s=r;continue}switch(s++,t.type){case"paragraph":a.push(`<p${h(t,e)}${N(t.look)}>${x(t.content,e)||" "}</p>${W(t.children,n,e)}`);break;case"heading":{const o=`h${String(t.level)}`;a.push(`<${o} id="${p(e.anchors.get(t)??"")}"${h(t,e)}${N(t.look)}>${x(t.content,e)}</${o}>${W(t.children,n,e)}`);break}case"toggle":a.push(`<p${h(t,e)}${N(t.look)}>${x(t.content,e)}</p>${W(t.children,n,e)}`);break;case"quote":a.push(`<blockquote${h(t,e)}${N(t.look)}><p>${x(t.content,e)}</p>${y(t.children??[],n,e)}</blockquote>`);break;case"callout":a.push(`<div class="callout"${h(t,e)}${N(t.look,!0)}>${t.icon===void 0?"":`<span class="callout-icon">${p(t.icon)}</span>`}<div><p>${x(t.content,e)}</p>${y(t.children??[],n,e)}</div></div>`);break;case"card":a.push(`<div class="card${cardKept(t,j(n.page))?" kept":""}"${h(t,e)}>${t.title===void 0&&t.subtitle===void 0?"":`<div class="card-head">${t.title===void 0?"":`<p class="card-title">${p(t.title)}</p>`}${t.subtitle===void 0?"":`<p class="card-subtitle">${p(t.subtitle)}</p>`}</div>`}${y(t.children??[],{...n,room:(n.room??U)-2*Te},e)}</div>`);break;case"stats":a.push(`<div class="stats"${h(t,e)} style="grid-template-columns:repeat(${String(t.stats.length)},minmax(0,1fr))">${t.stats.map(o=>{const r=Ce(o),d=o.delta===void 0&&o.note===void 0?"":`<p class="stat-foot">${o.delta===void 0?"":`<span class="stat-delta" style="color:${Z[r]}">${p(o.delta)}</span>`}${o.delta!==void 0&&o.note!==void 0?" ":""}${o.note===void 0?"":p(o.note)}</p>`,l=o.trend===void 0?"":trendSvg(o.trend,Z[r==="flat"?"flat":r]);return`<div class="stat"><p class="stat-label">${p(o.label)}</p><p class="stat-value">${p(o.value)}</p>${d}${l}</div>`}).join("")}</div>`);break;case"code":a.push(Ne(t,n,h(t,e)));break;case"columns":{const o=t.columns.map(d=>`${String(d.width??1)}fr`).join(" "),r=ae(t,n.room);a.push(`<div class="columns${columnsKept(t,j(n.page))?" kept":""}"${h(t,e)} style="grid-template-columns:${o}">${t.columns.map((d,l)=>`<div class="column">${y(d.blocks,{...n,room:r[l]??U},e)}</div>`).join("")}</div>`);break}case"chart":{const o=e.numbers.get(t),r=o===void 0?t:ue(t),{svg:d,problems:l}=ie(r,{...n,font:pageFaces(n.page).text}),{width:f}=ne(t,n.room),g=o===void 0||t.title===void 0?"":`<figcaption>${p(R(t.title,o))}</figcaption>`;a.push(d===void 0?`<div class="embed"${h(t,e)} data-chart>${p(t.title??"Chart")}<br><small>${p(l.join("; "))}</small></div>`:`<figure class="chart"${L(t.id)}${h(t,e)} style="max-width:${String(f)}px">${d}${g}</figure>`);break}case"image":{const o=n.image?.(t.src)??t.src;a.push(`<figure${L(t.id)}${h(t,e)}${t.align===void 0?"":` style="text-align:${t.align}"`}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"table":{const o=t.head===void 0||t.head==="both",r=t.head==="column"||t.head==="both",d=ke(t),l=be(t),f=(m,b,T)=>`<tr${e.ids===void 0?"":` data-row="${String(T)}"`}>${m.map((_,F)=>{const G=b||r&&F===0?"th":"td",ee=d.has(F)?' class="num"':"";return`<${G}${ee}>${x(_,e)}</${G}>`}).join("")}</tr>`,g=j(n.page),w=(t.widths??[]).reduce((m,b)=>m+(b??0),0),M=n.room??g.textWidth*96/25.4,C=$e(t,{across:X(Math.max(M-w,0),g.spacing.small),margins:X(2*g.spacing.cell.side*96/72,g.spacing.small)}),z=C.reduce((m,b,T)=>m+(t.widths?.[T]?0:b),0)||1,P=`<colgroup>${C.map((m,b)=>{const T=t.widths?.[b],_=$(m/z*100);return T?`<col style="width:${String(T)}px">`:w===0?`<col style="width:${_}%">`:`<col style="width:calc((100% - ${String(w)}px) * ${$(m/z)})">`}).join("")}</colgroup>`,[E,...A]=t.rows,u=o&&E!==void 0&&!l?`<thead>${f(E,!0,0)}</thead>`:"",S=(o?A:t.rows).map((m,b)=>f(m,!1,o?b+1:b)).join(""),v=t.caption===void 0?"":`<caption>${p(R(t.caption,e.numbers.get(t)))}</caption>`;a.push(`<table${L(t.id)}${h(t,e)}>${v}${P}${u}<tbody>${S}</tbody></table>`);break}case"divider":a.push(`<hr${h(t,e)}>`);break;case"pagebreak":a.push(`<div class="page-break"${h(t,e)}></div>`);break;case"toc":a.push(Ee(t,e));break;case"bibliography":e.listed||(e.listed=!0,a.push(J(e,h(t,e))));break;case"note":break;case"component":{const o=n.component?.(t),r=t.align===void 0?"":` style="text-align:${t.align}"`;a.push(o===void 0?`<div class="embed"${h(t,e)} data-component>${p(re(t))}</div>`:`<figure${L(t.id)}${h(t,e)}${r}><img src="${p(o)}" alt="${p(t.alt??"")}"${t.width===void 0?"":` width="${String(t.width)}"`}>${t.caption===void 0?"":`<figcaption>${p(R(t.caption,e.numbers.get(t)))}</figcaption>`}</figure>`);break}case"embed":{const o=n.embed?.(t.source,e.embeds);e.embeds++;const r=/^<\s*([A-Za-z][\w.]*)/.exec(t.source.trim())?.[1];a.push(o===void 0?`<div class="embed"${h(t,e)} data-embed>${p(r??"")}</div>`:`<div${h(t,e)}>${o}</div>`);break}case"source":break}}return a.join(`
|
|
3
|
+
`)}function J(i,n=""){const{list:e,style:a}=i.sources;return e.length===0?"":`<section class="sources" data-style="${a}"${n}><ol>${e.map(s=>`<li id="source-${p(s.item.id)}">${s.pieces.map(t=>t.italic?`<i>${p(t.text)}</i>`:p(t.text)).join("")}</li>`).join("")}</ol></section>`}const L=i=>i===void 0?"":` id="${p(i)}"`;function Ee(i,n){const e=i.levels??3,a=n.headings.filter(r=>r.block.level<=e),s=Math.min(...a.map(r=>r.block.level)),t=a.map(({block:r,anchor:d})=>{const l=n.headingPage?.(d);return`<li style="padding-left:${String(r.level-s)}em"><a href="#${p(d)}"><span class="toc-words">${x(r.content,n)}</span>${l===void 0?"":`<span class="toc-fill"></span><span class="toc-page">${String(l)}</span>`}</a></li>`}),o=he(i,n.chinese);return`<nav class="toc"${h(i,n)}>${o===""?"":`<p class="toc-title">${p(o)}</p>`}<ol>${t.join("")}</ol></nav>`}export function keptWhole(i,n,e=0){const a=.35277777777777775,s="pt"in n.lineHeight?n.lineHeight.pt:n.lineHeight.multiple*(I[n.font]??1.22)*n.size,t=Math.max(20,(n.textWidth/a-30)/(n.size*.5)),o=r=>r.reduce((d,l)=>{if(l.type==="table")return d+l.rows.length*1.6+1;if(l.type==="chart"||l.type==="image"||l.type==="component")return d+18;if(l.type==="card")return d+2+o(l.children??[]);const f="content"in l?Math.max(1,Math.ceil(l.content.map(g=>g.text).join("").length/t))+.5:2;return d+f+o(Se(l))},0);return(e+o(i))*s<n.textHeight/a*.6}export const cardKept=(i,n)=>keptWhole(i.children??[],n,2),columnsKept=(i,n)=>i.columns.every(e=>keptWhole(e.blocks,n));const Te=15;export function trendSvg(i,n){const s=Math.min(...i),o=Math.max(...i)-s||1,d=i.map((l,f)=>[f/Math.max(1,i.length-1)*100,22-(l-s)/o*20]).map(([l,f],g)=>`${g===0?"M":"L"}${(l??0).toFixed(1)} ${(f??0).toFixed(1)}`).join(" ");return`<svg class="stat-trend" viewBox="0 0 ${String(100)} ${String(24)}" preserveAspectRatio="none" aria-hidden="true"><path d="${d}" fill="none" stroke="${n}" stroke-width="1.5" vector-effect="non-scaling-stroke" stroke-linejoin="round" stroke-linecap="round"/></svg>`}function Ne(i,n,e=""){if(i.language===K.math)return`<div class="math"${e}>${me(i.code).html}</div>`;if(i.language===K.mermaid){const a=n.diagram?.(i.code);if(a?.svg!==void 0)return`<figure class="diagram"${e}>${a.svg}</figure>`;if(a?.error!==void 0)return`<pre${e}><code>${p(i.code)}</code></pre><p class="drawn-error">Mermaid: ${p(a.error)}</p>`}return`<pre${e}><code>${je(i.code)}</code></pre>`}const je=i=>i.split(`
|
|
4
|
+
`).map(n=>`<span class="line">${p(n)}</span>`).join(""),W=(i,n,e)=>i?.length?`<div class="under">${y(i,n,e)}</div>`:"";export const DOC_CSS=`
|
|
5
5
|
/* The page's side margins are the text column's own padding, so a cover
|
|
6
6
|
can reach the page's edges. The default page is Letter (PAGE_DEFAULTS). */
|
|
7
7
|
@page { size: 215.9mm 279.4mm; margin: 18mm 0; }
|
|
@@ -44,8 +44,6 @@ table > tbody > tr:last-child > * { border-bottom: 1pt solid ${c.ruleStrong}; }
|
|
|
44
44
|
th { font-weight: 600; }
|
|
45
45
|
thead th { border-bottom: 0.75pt solid ${c.ruleStrong}; background: ${c.stone3}; }
|
|
46
46
|
th.num, td.num { text-align: right; }
|
|
47
|
-
/* An emoji drawn as a picture of itself (EMOJI_PICTURES): an em square on the line, as Twemoji sets one. */
|
|
48
|
-
img.emoji { display: inline; width: 1em; height: 1em; margin: 0 0.05em; vertical-align: -0.12em; }
|
|
49
47
|
figure { break-inside: avoid; }
|
|
50
48
|
img { max-width: 100%; }
|
|
51
49
|
figcaption { color: ${c.leadSoft}; }
|
|
@@ -73,7 +71,7 @@ a { color: inherit; text-decoration: underline; text-decoration-color: ${c.ruleS
|
|
|
73
71
|
.embed { border: 1px dashed ${c.ruleMid}; border-radius: 6px; padding: 1.5em; text-align: center; color: ${c.leadSoft}; break-inside: avoid; }
|
|
74
72
|
/* A cover: a band of a picture across the top of the first page, edge to
|
|
75
73
|
edge (Notion's). */
|
|
76
|
-
.cover { height: ${String(
|
|
74
|
+
.cover { height: ${String(ye)}mm; margin: 0 -20mm 2.4em; overflow: hidden; break-inside: avoid; }
|
|
77
75
|
.cover img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
|
|
78
76
|
/* A footnote's mark, and the notes at the end under a short rule. */
|
|
79
77
|
sup.fn { font-size: 0.72em; line-height: 0; margin-left: 0.02em; font-variant-numeric: tabular-nums; }
|
|
@@ -96,7 +94,7 @@ a.cite { color: inherit; text-decoration: none; }
|
|
|
96
94
|
.sources ol { list-style: none; padding-left: 0; }
|
|
97
95
|
.sources li { text-align: left; text-indent: calc(-1 * var(--hang, 2em)); padding-left: var(--hang, 2em); }
|
|
98
96
|
.sources[data-style="gbt7714"] li { --hang: 2.2em; }
|
|
99
|
-
.columns { display: grid; gap: 0 ${String(
|
|
97
|
+
.columns { display: grid; gap: 0 ${String(se)}px; }
|
|
100
98
|
.column { min-width: 0; }
|
|
101
99
|
.column > :first-child, .callout > div > :first-child { margin-top: 0; }
|
|
102
100
|
figure.chart { margin-left: auto; margin-right: auto; }
|
|
@@ -112,52 +110,10 @@ figure.chart svg, figure.diagram svg { display: inline-block; max-width: 100%; h
|
|
|
112
110
|
a row never split, a table's head again on each page. */
|
|
113
111
|
p, li { orphans: 2; widows: 2; }
|
|
114
112
|
tr { break-inside: avoid; }
|
|
115
|
-
`;function
|
|
116
|
-
`)}export function docParts(i){const n=[];let e=[],a=!1;for(const s of i)s.type==="pagebreak"&&s.orientation!==void 0?(n.push({blocks:e,landscape:a}),e=[],a=s.orientation==="landscape"):e.push(s);return n.push({blocks:e,landscape:a}),n}
|
|
117
|
-
window.allyhubReady = (
|
|
118
|
-
|
|
119
|
-
const walker = document.createTreeWalker(document.querySelector("main"), NodeFilter.SHOW_TEXT);
|
|
120
|
-
const nodes = [];
|
|
121
|
-
for (let n = walker.nextNode(); n; n = walker.nextNode()) if (pattern.test(n.data)) nodes.push(n);
|
|
122
|
-
pattern.lastIndex = 0;
|
|
123
|
-
if (nodes.length === 0) return;
|
|
124
|
-
const all = nodes.map((n) => n.data.match(pattern).join("")).join("");
|
|
125
|
-
const faces = await document.fonts.load('64px "Noto Color Emoji"', all).catch(() => []);
|
|
126
|
-
if (faces.length === 0) return;
|
|
127
|
-
const size = 128;
|
|
128
|
-
const canvas = document.createElement("canvas");
|
|
129
|
-
canvas.width = canvas.height = size;
|
|
130
|
-
const ctx = canvas.getContext("2d");
|
|
131
|
-
ctx.font = (size * 0.86) + 'px "Noto Color Emoji"';
|
|
132
|
-
ctx.textAlign = "center";
|
|
133
|
-
ctx.textBaseline = "middle";
|
|
134
|
-
const drawn = new Map();
|
|
135
|
-
const picture = (e) => {
|
|
136
|
-
if (!drawn.has(e)) {
|
|
137
|
-
ctx.clearRect(0, 0, size, size);
|
|
138
|
-
ctx.fillText(e, size / 2, size / 2);
|
|
139
|
-
drawn.set(e, canvas.toDataURL("image/png"));
|
|
140
|
-
}
|
|
141
|
-
const img = document.createElement("img");
|
|
142
|
-
img.className = "emoji";
|
|
143
|
-
img.alt = e;
|
|
144
|
-
img.src = drawn.get(e);
|
|
145
|
-
return img;
|
|
146
|
-
};
|
|
147
|
-
for (const n of nodes) {
|
|
148
|
-
const parts = [];
|
|
149
|
-
let at = 0;
|
|
150
|
-
for (const m of n.data.matchAll(pattern)) {
|
|
151
|
-
if (m.index > at) parts.push(document.createTextNode(n.data.slice(at, m.index)));
|
|
152
|
-
parts.push(picture(m[0]));
|
|
153
|
-
at = m.index + m[0].length;
|
|
154
|
-
}
|
|
155
|
-
if (at < n.data.length) parts.push(document.createTextNode(n.data.slice(at)));
|
|
156
|
-
n.replaceWith(...parts);
|
|
157
|
-
}
|
|
158
|
-
await Promise.all([...document.querySelectorAll("img.emoji")].map((i) => i.decode().catch(() => undefined)));
|
|
159
|
-
})();
|
|
160
|
-
<\/script>`,Re=`<script>
|
|
113
|
+
`;function Me(i,n,e){const a=[...q(i)].filter(o=>o.type==="note");return a.length===0?"":`<section class="notes"><ol>${a.map(o=>({note:o,n:e.notes.get(o.label.toLowerCase())})).sort((o,r)=>(o.n??1/0)-(r.n??1/0)).map(({note:o,n:r})=>`<li${h(o,e)}${r===void 0?"":` id="note-${String(r)}" value="${String(r)}"`}><p>${x(o.content,e)}</p>${y(o.children??[],n,e)}</li>`).join("")}</ol></section>`}const Q="body > h1:first-child, main > h1:first-child, article > h1:first-child, main > .cover + h1",k=i=>`${String(Math.round(i*100)/100)}mm`,$=i=>String(Math.round(i*1e3)/1e3);function Ae(i){const n=i.spacing,e=o=>`${$(o)}pt`,a=e(n.after),s=e(n.step),t="pt"in i.lineHeight?e(i.lineHeight.pt):$(i.lineHeight.multiple*(I.mono??1));return[`p, ul, ol, blockquote, pre, table, figure, .math, .callout, .card, .stats, .embed, .sources li { margin: 0 0 ${a}; }`,`h1, h2, h3, h4, h5, h6 { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`.toc-title { margin: ${e(n.heading.before)} 0 ${e(n.heading.after)}; }`,`${Q} { margin-top: 0; margin-bottom: ${e(n.title)}; }`,`ul, ol { padding-left: ${s}; } li ul, li ol { margin-bottom: 0; } li.task { margin-left: -${s}; } .under { margin-left: ${s}; }`,`:is(ul, ol) + :is(ul, ol) { margin-top: -${a}; }`,`blockquote { padding-left: calc(${e(n.quote)} - var(--quote-rule, 1px)); }`,`pre { padding: ${e(n.box.top)} ${e(n.box.side)}; font-size: ${e(n.small)}; line-height: ${t}; } pre code { font-size: inherit; }`,`.callout { padding: ${e(n.box.top)} ${e(n.box.side)} ${e(Math.max(n.box.top-n.after,0))}; }`,`.card { padding: ${e(n.card.top)} ${e(n.card.side)} ${e(Math.max(n.card.top-n.after,0))}; } .card-head { margin-bottom: ${a}; } .card-subtitle { font-size: ${e(n.small)}; }`,`.stats { gap: ${e(n.gap)}; } .stat { padding: ${e(n.card.top)} ${e(n.card.side)}; } .stat-label, .stat-foot { font-size: ${e(n.small)}; } .stat-value { font-size: ${e(n.figure)}; line-height: ${$(I[i.font]??I.sans??1.22)}; }`,`table { font-size: ${e(n.small)}; } th, td { padding: ${e(n.cell.top)} ${e(n.cell.side)}; }`,`caption { font-size: ${e(n.small)}; padding-bottom: ${e(n.caption)}; }`,`figcaption { font-size: ${e(n.small)}; margin-top: ${e(n.caption)}; }`,`hr { height: 1pt; margin: ${e(n.divider)} 0; }`,`.toc ol { margin: 0; } .toc li { margin: 0 0 ${e(n.contents)}; } .sources ol { margin: 0; }`]}function V(i,n,e){if(n===void 0)return;const a=[n.font===void 0?"":`font-family: ${PAGE_FACES[e.font]};`,n.size===void 0?"":`font-size: ${$(e.size)}pt;`,e.font==="xiaobiaosong"?"font-weight: 700;":n.weight===void 0?"":`font-weight: ${e.weight==="bold"?"700":"400"};`,n.align===void 0?"":`text-align: ${e.align};`,n.italic===void 0?"":`font-style: ${e.italic?"italic":"normal"};`,e.rule?`border-bottom: 0.5pt solid ${c.rule}; padding-bottom: ${$(HEADING_RULE_SPACE)}pt;`:""].join(" ");return a.trim()===""?void 0:`${i} { ${a.trim()} }`}export const HEADING_RULE_SPACE=3;export function pageCss(i={}){const n=H(i),e=j(i),a=pageFaces(i),s=pageAccent(n),t=[];if(n.paper!==void 0||n.orientation!==void 0||n.margins!==void 0){const{top:r,right:d,bottom:l,left:f}=e.margins;t.push(`@page { size: ${k(e.width)} ${k(e.height)}; margin: ${k(r)} 0 ${k(l)}; }`,`main { max-width: ${k(e.width)}; padding: 0 ${k(d)} 0 ${k(f)}; }`,`.cover { margin-left: -${k(f)}; margin-right: -${k(d)}; }`)}n.font!==void 0&&n.font!=="sans"&&t.push(`body { font-family: ${a.text}; }`,`h1, h2, h3, h4, h5, h6 { font-family: ${a.heading}; }`,`.toc-title { font-family: ${a.heading}; }`),(n.size!==void 0||n.grid!==void 0)&&t.push(`html { font-size: ${$(e.size)}pt; }`),t.push(`body { line-height: ${"pt"in e.lineHeight?`${$(e.lineHeight.pt)}pt`:$(ze(e)??1)}; }`),t.push(...Ae(e)),e.letterSpacing!==0&&t.push(`body { letter-spacing: ${$(e.letterSpacing)}em; }`),n.textIndent!==void 0&&n.textIndent>0&&t.push(`.sources { --hang: ${$(n.textIndent)}em; }`,`p { text-indent: ${$(n.textIndent)}em; }`,"blockquote p, .callout p, .notes p, .toc p { text-indent: 0; }"),n.textAlign==="justify"&&t.push("p, li { text-align: justify; }");const o=V(Q,n.title,e.title);o!==void 0&&t.push(o);for(const r of[1,2,3,4,5,6]){const d=V(r===1?"h1, .toc-title":`h${String(r)}`,n.headings?.[r],e.headings[r]);d!==void 0&&t.push(d)}return s!==void 0&&t.push(`a { color: ${s}; text-decoration-color: color-mix(in oklab, ${s} 45%, transparent); }`,`blockquote { --quote-rule: 2px; border-left-color: ${s}; }`),t.join(`
|
|
114
|
+
`)}export function docParts(i){const n=[];let e=[],a=!1;for(const s of i)s.type==="pagebreak"&&s.orientation!==void 0?(n.push({blocks:e,landscape:a}),e=[],a=s.orientation==="landscape"):e.push(s);return n.push({blocks:e,landscape:a}),n}const Re=`<script>
|
|
115
|
+
window.allyhubReady = ${oe({scope:"main",face:"Noto Color Emoji"})};
|
|
116
|
+
<\/script>`,qe=`<script>
|
|
161
117
|
window.allyhubReady = (async (before) => {
|
|
162
118
|
await before;
|
|
163
119
|
await document.fonts.ready;
|
|
@@ -173,7 +129,7 @@ window.allyhubReady = (async (before) => {
|
|
|
173
129
|
if (el.matches("p") || el.children.length === el.querySelectorAll(":scope > .words, :scope > .box").length)
|
|
174
130
|
if (lines(el) < 4) el.style.breakInside = "avoid";
|
|
175
131
|
})(window.allyhubReady);
|
|
176
|
-
<\/script>`,
|
|
132
|
+
<\/script>`,He=`<script>
|
|
177
133
|
window.allyhubReady = (async (before) => {
|
|
178
134
|
await before;
|
|
179
135
|
await document.fonts.ready;
|
|
@@ -258,8 +214,8 @@ window.allyhubReady = (async (before) => {
|
|
|
258
214
|
}
|
|
259
215
|
}
|
|
260
216
|
})(window.allyhubReady);
|
|
261
|
-
<\/script>`;export function docHtml(i,n={}){const e=headingAnchors(i),a=
|
|
262
|
-
`}${y(g,n,r)}${M&&!r.listed?
|
|
217
|
+
<\/script>`;export function docHtml(i,n={}){const e=headingAnchors(i),a=fe(i,n.page),{title:s}=xe(i),t=new Map,o=[];for(const u of q(i)){const S=pe(u),v=a.get(u);if(S!==void 0&&v!==void 0&&t.set(S,v.label),u.type==="heading"){const m=e.get(u)??"";t.set(m,u.content.map(b=>b.text).join("")),u!==s&&o.push({block:u,anchor:m})}}const r={embeds:0,notes:ve(i),anchors:e,ids:n.ids?blockNumbers(i):void 0,numbers:a,refs:t,headings:o,headingPage:n.headingPage,chinese:ge(i),sources:(()=>{const u=H(n.page??{}).citationStyle??"apa",S=n.sources??[],v=ce(i,S,u);return{items:S,style:u,numbers:new Map(v.map(m=>[m.item.id,m.n])),list:v}})(),listed:!1},d=docParts(i),l=n.part,f=l===void 0?void 0:d[l],g=f===void 0?d.flatMap(u=>u.blocks):f.blocks,w=l===void 0||l===0,M=l===void 0||l===d.length-1,C=w?n.page?.cover:void 0,z=C===void 0?void 0:n.image?.(C)??C,P=`${z===void 0?"":`<figure class="cover"><img src="${p(z)}" alt="" style="object-position:50% ${String(n.page?.coverY??50)}%"></figure>
|
|
218
|
+
`}${y(g,n,r)}${M&&!r.listed?J(r):""}${M?Me(i,n,r):""}`,E=j(n.page),A=[pageCss(n.page),...f?.landscape===!0?[`@page { size: ${k(E.height)} ${k(E.width)}; }`,`main { max-width: ${k(E.height)}; }`]:[],...z===void 0?[]:["@page :first { margin-top: 0; }"]].filter(u=>u!=="").join(`
|
|
263
219
|
`);return`<!doctype html>
|
|
264
220
|
<html>
|
|
265
221
|
<head>
|
|
@@ -271,11 +227,11 @@ ${A}`}</style>
|
|
|
271
227
|
</head>
|
|
272
228
|
<body>
|
|
273
229
|
<main>
|
|
274
|
-
${
|
|
230
|
+
${P}
|
|
275
231
|
</main>
|
|
276
|
-
${Ae}
|
|
277
|
-
${I(n.page??{}).grid===void 0?"":qe}
|
|
278
232
|
${Re}
|
|
233
|
+
${H(n.page??{}).grid===void 0?"":He}
|
|
234
|
+
${qe}
|
|
279
235
|
</body>
|
|
280
236
|
</html>
|
|
281
237
|
`}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{CITATION_STYLES as x}from"./cite.js";export const PAPERS={a3:[297,420],a4:[210,297],a5:[148,210],b5:[176,250],letter:[215.9,279.4],legal:[215.9,355.6]},PAGE_FONTS=["sans","serif","mono","times","song","hei","fangsong","kai","xiaobiaosong"],CHINESE_SIZES={初号:42,小初:36,一号:26,小一:24,二号:22,小二:18,三号:16,小三:15,四号:14,小四:12,五号:10.5,小五:9,六号:7.5,小六:6.5,七号:5.5,八号:5},RUNNING_PLACES=["left","center","right","outside","inside"],PAGE_PRESETS=["apa","mla","report","memo","business-letter"];const $={apa:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:2,textIndent:3,paragraphSpacing:0,textAlign:"left",title:{size:12,weight:"bold",align:"center"},headings:{1:{size:12,weight:"bold",align:"center"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold",italic:!0},6:{size:12,weight:"bold"}},header:{right:"{page}"},footer:!1,citationStyle:"apa"},mla:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:2,textIndent:3,paragraphSpacing:0,textAlign:"left",title:{size:12,weight:"normal",align:"center"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:{right:"{page}"},footer:!1,citationStyle:"mla"},report:{size:10.5,lineHeight:1.2,paragraphSpacing:.7,title:{size:24,weight:"bold"},headings:{1:{size:18,weight:"bold"},2:{size:14,weight:"bold",rule:!0},3:{size:11.5,weight:"bold"}}},memo:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:1,textIndent:0,paragraphSpacing:1,textAlign:"left",title:{size:12,weight:"bold"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:!1,footer:{center:"{page}"}},"business-letter":{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:1,textIndent:0,paragraphSpacing:1,textAlign:"left",title:{size:12,weight:"bold"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold"},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:!1,footer:!1,pageNumbers:!1}};export const presetLook=e=>$[e];export function effectiveLook(e){if(e.preset===void 0)return e;const i=$[e.preset],n={...i.headings};for(const[a,t]of Object.entries(e.headings??{}))n[Number(a)]={...i.headings?.[Number(a)],...t};return{...i,...e,...i.title||e.title?{title:{...i.title,...e.title}}:{},...Object.keys(n).length>0?{headings:n}:{}}}export const sizePt=e=>typeof e=="number"?e:CHINESE_SIZES[e];export function marginBox(e){return typeof e=="number"?{top:e,right:e,bottom:e,left:e}:e.length===2?{top:e[0],right:e[1],bottom:e[0],left:e[1]}:{top:e[0],right:e[1],bottom:e[2],left:e[3]}}export const PAGE_DEFAULTS={paper:"letter",margins:{top:18,right:20,bottom:18,left:20},size:11,lineHeight:1.15,textIndent:0,paragraphSpacing:.5,headingScale:{title:2.3,1:1.75,2:1.45,3:1.15,4:1,5:1,6:1},footer:{left:"{title}",right:"{page} / {pages}"}};const w=25.4/72;export const paperSize=e=>e===void 0?PAPERS[PAGE_DEFAULTS.paper]:typeof e=="string"?PAPERS[e]:e;export function resolvePage(e={}){const i=effectiveLook(e),[n,a]=paperSize(i.paper),t=i.orientation==="landscape",s=t?Math.max(n,a):Math.min(n,a),r=t?Math.min(n,a):Math.max(n,a),f=i.margins===void 0?{...PAGE_DEFAULTS.margins}:marginBox(i.margins),g=s-f.left-f.right,p=r-f.top-f.bottom,y=i.font??"sans";let d=i.size===void 0?PAGE_DEFAULTS.size:sizePt(i.size),h=i.lineHeight===void 0?{multiple:PAGE_DEFAULTS.lineHeight}:typeof i.lineHeight=="number"?{multiple:i.lineHeight}:{pt:Number.parseFloat(i.lineHeight)},z=0;if(i.grid){h={pt:p/w/i.grid.lines};const o=g/w/i.grid.chars;i.size===void 0&&(d=Math.floor(o*2)/2),z=(o*.998-d)/d}const m=(o,E)=>({font:o?.font??y,size:o?.size===void 0?d*E:sizePt(o.size),weight:o?.weight??"bold",align:o?.align??"left",italic:o?.italic??!1,rule:o?.rule??!1}),S=PAGE_DEFAULTS.headingScale,A=Object.fromEntries([1,2,3,4,5,6].map(o=>[o,m(i.headings?.[o],S[o])])),I=i.footer===!1||i.footer===void 0&&i.pageNumbers===!1?void 0:i.footer??PAGE_DEFAULTS.footer;return{width:s,height:r,margins:f,textWidth:g,textHeight:p,font:y,size:d,lineHeight:h,letterSpacing:z,textIndent:i.textIndent??PAGE_DEFAULTS.textIndent,paragraphSpacing:i.paragraphSpacing??PAGE_DEFAULTS.paragraphSpacing,textAlign:i.textAlign??"left",title:m(i.title,S.title),headings:A,header:i.header===!1?void 0:i.header,footer:I,captions:i.captions!=="plain",spacing:H(d,i.paragraphSpacing??PAGE_DEFAULTS.paragraphSpacing,i.grid===void 0||!("pt"in h)?void 0:h.pt)}}export const LIST_STEP=18;function H(e,i,n){const a=n!==void 0||i===0;return{after:i*e,heading:a?{before:0,after:0}:{before:14,after:6},title:n??(a?0:12),caption:4,box:{top:6,side:8},cell:{top:4,side:7},divider:12,contents:5,quote:12,step:LIST_STEP,small:Math.round(e*.9*2)/2,card:{top:9,side:11},gap:8,figure:Math.round(e*2.2)}}export const SINGLE_LINE={sans:1.2207,serif:1.1719,mono:1.1328,times:1.1499},lineMultiple=e=>"pt"in e.lineHeight?void 0:e.lineHeight.multiple*(SINGLE_LINE[e.font]??1),lineHeightPt=(e,i=e.size)=>"pt"in e.lineHeight?e.lineHeight.pt:(lineMultiple(e)??1)*i,PAGE_KEYS=["preset","paper","orientation","margins","font","size","line-height","text-indent","paragraph-spacing","text-align","grid","title","headings","header","footer","captions","bibliography","citation-style","accent","cover","cover-y","page-numbers","picture-dpi"];const J=["left","center","right"],c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),l=e=>typeof e=="number"&&Number.isFinite(e)&&e>0;function u(e){if(l(e))return e;if(typeof e=="string"){const i=e.trim();if(Object.hasOwn(CHINESE_SIZES,i))return i;const n=/^(\d+(?:\.\d+)?)\s*pt$/u.exec(i);if(n)return Number(n[1])}}const b=`a size in pt (12) or a Chinese size (${Object.keys(CHINESE_SIZES).join(", ")})`;function N(e,i,n){if(!c(e)){n(`${i} holds font, size, weight, align, italic and rule`);return}const a={};for(const[t,s]of Object.entries(e))if(t==="font")PAGE_FONTS.includes(s)?a.font=s:n(`${i}'s font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(s)}`);else if(t==="size"){const r=u(s);r===void 0?n(`${i}'s size is ${b}`):a.size=r}else t==="weight"?s==="normal"||s==="bold"?a.weight=s:n(`${i}'s weight is normal or bold, not ${JSON.stringify(s)}`):t==="align"?J.includes(s)?a.align=s:n(`${i}'s align is left, center or right, not ${JSON.stringify(s)}`):t==="italic"?typeof s=="boolean"?a.italic=s:n(`${i}'s italic is true or false, not ${JSON.stringify(s)}`):t==="rule"?typeof s=="boolean"?a.rule=s:n(`${i}'s rule is true or false, not ${JSON.stringify(s)}`):n(`${i} holds font, size, weight, align, italic and rule: ${t} is not one of them`);return a}function P(e,i,n){if(e===!1)return!1;if(typeof e=="string")return{center:e};if(!c(e)){n(`a page's ${i} is false, words, or words by place (${RUNNING_PLACES.join(", ")}) with a font and a size`);return}const a={};for(const[t,s]of Object.entries(e))if(t==="font")PAGE_FONTS.includes(s)?a.font=s:n(`a page's ${i} font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(s)}`);else if(t==="size"){const r=u(s);r===void 0?n(`a page's ${i} size is ${b}`):a.size=r}else RUNNING_PLACES.includes(t)?typeof s!="string"&&typeof s!="number"?n(`a page's ${i} ${t} is words`):a[t]=String(s):n(`a page's ${i} holds ${RUNNING_PLACES.join(", ")}, font and size: ${t} is not one of them`);return a}export function readPageLook(e,i){const n={};for(const[a,t]of Object.entries(e))switch(a){case"preset":PAGE_PRESETS.includes(t)?n.preset=t:i(`a page's preset is ${PAGE_PRESETS.join(" or ")}, not ${JSON.stringify(t)}`);break;case"paper":{const s=typeof t=="string"?t.trim().toLowerCase():void 0;s!==void 0&&Object.hasOwn(PAPERS,s)?n.paper=s:Array.isArray(t)&&t.length===2&&t.every(l)?n.paper=t:i(`a page's paper is ${Object.keys(PAPERS).join(", ")} or its width and height in mm ([210, 297]), not ${JSON.stringify(t)}`);break}case"orientation":t==="portrait"||t==="landscape"?n.orientation=t:i(`a page's orientation is portrait or landscape, not ${JSON.stringify(t)}`);break;case"margins":typeof t=="number"&&t>=0||Array.isArray(t)&&(t.length===2||t.length===4)&&t.every(s=>typeof s=="number"&&s>=0)?n.margins=t:i("a page's margins are mm: one for all four, [top and bottom, sides], or [top, right, bottom, left]");break;case"font":PAGE_FONTS.includes(t)?n.font=t:i(`a page's font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(t)}`);break;case"size":{const s=u(t);s===void 0?i(`a page's size is ${b}`):n.size=s;break}case"line-height":l(t)?n.lineHeight=t:typeof t=="string"&&/^\d+(\.\d+)?pt$/u.test(t.trim())?n.lineHeight=t.trim():i(`a page's line-height is a multiple (1.5) or pt (28pt), not ${JSON.stringify(t)}`);break;case"text-indent":typeof t=="number"&&t>=0?n.textIndent=t:i("a page's text-indent is how many characters a paragraph's first line is set in (2)");break;case"paragraph-spacing":typeof t=="number"&&t>=0?n.paragraphSpacing=t:i("a page's paragraph-spacing is the space between paragraphs in em (0.5)");break;case"text-align":t==="left"||t==="justify"?n.textAlign=t:i(`a page's text-align is left or justify, not ${JSON.stringify(t)}`);break;case"grid":{const s=c(t)?t.chars:void 0,r=c(t)?t.lines:void 0;c(t)&&Object.keys(t).length===2&&l(s)&&l(r)&&Number.isInteger(s)&&Number.isInteger(r)?n.grid={chars:s,lines:r}:i("a page's grid is { chars, lines }: characters to a line and lines to a page");break}case"title":{const s=N(t,"the title",i);s&&(n.title=s);break}case"headings":{if(!c(t)){i("a page's headings are by level: { 1: { font, size }, 2: … }");break}const s={};for(const[r,f]of Object.entries(t)){const g=Number(r);if(!Number.isInteger(g)||g<1||g>6){i(`a heading's level is 1 to 6, not ${r}`);continue}const p=N(f,`heading ${r}`,i);p&&(s[g]=p)}n.headings=s;break}case"header":case"footer":{const s=P(t,a,i);s!==void 0&&(n[a]=s);break}case"captions":t==="numbered"||t==="plain"?n.captions=t:i(`a page's captions are numbered or plain, not ${JSON.stringify(t)}`);break;case"bibliography":typeof t=="string"&&t.trim()!==""?n.bibliography=t.trim():i("a page's bibliography is a CSL-JSON file's path");break;case"citation-style":x.includes(t)?n.citationStyle=t:i(`a page's citation-style is ${x.join(" or ")}, not ${JSON.stringify(t)}`);break;case"accent":typeof t=="string"&&t.trim()!==""?n.accent=t.trim():i("a page's accent is a colour");break;case"cover":typeof t=="string"&&t.trim()!==""?n.cover=t.trim():i("a page's cover is a picture's path");break;case"cover-y":typeof t=="number"&&t>=0&&t<=100?n.coverY=t:i(`a cover's cover-y is 0 (its top) to 100 (its bottom), not ${JSON.stringify(t)}`);break;case"picture-dpi":t===!1?n.pictureDpi=!1:typeof t=="number"&&t>=72&&t<=2400?n.pictureDpi=t:i(`a page's picture-dpi is 72 to 2400 (dots an inch of paper), or false to print pictures as they are, not ${JSON.stringify(t)}`);break;case"page-numbers":t===!1?n.pageNumbers=!1:t!==!0&&i(`a page's page-numbers is true or false, not ${JSON.stringify(t)}`);break;default:i(`the front matter holds ${PAGE_KEYS.join(", ")}: ${a} is not one of them`)}return n}const O=e=>({...e.font===void 0?{}:{font:e.font},...e.size===void 0?{}:{size:e.size},...e.weight===void 0?{}:{weight:e.weight},...e.align===void 0?{}:{align:e.align},...e.italic===void 0?{}:{italic:e.italic},...e.rule===void 0?{}:{rule:e.rule}}),j=e=>e===!1?!1:Object.keys(e).length===1&&e.center!==void 0?e.center:{...e},v=e=>/^[ab]\d$/u.test(e)?e.toUpperCase():`${e.charAt(0).toUpperCase()}${e.slice(1)}`;export function pageLookYaml(e){return{...e.preset===void 0?{}:{preset:e.preset},...e.paper===void 0?{}:{paper:typeof e.paper=="string"?v(e.paper):[...e.paper]},...e.orientation===void 0?{}:{orientation:e.orientation},...e.margins===void 0?{}:{margins:typeof e.margins=="number"?e.margins:[...e.margins]},...e.font===void 0?{}:{font:e.font},...e.size===void 0?{}:{size:e.size},...e.lineHeight===void 0?{}:{"line-height":e.lineHeight},...e.textIndent===void 0?{}:{"text-indent":e.textIndent},...e.paragraphSpacing===void 0?{}:{"paragraph-spacing":e.paragraphSpacing},...e.textAlign===void 0?{}:{"text-align":e.textAlign},...e.grid===void 0?{}:{grid:{...e.grid}},...e.title===void 0?{}:{title:O(e.title)},...e.headings===void 0?{}:{headings:Object.fromEntries(Object.entries(e.headings).map(([n,a])=>[n,O(a)]))},...e.header===void 0?{}:{header:j(e.header)},...e.footer===void 0?{}:{footer:j(e.footer)},...e.captions===void 0?{}:{captions:e.captions},...e.bibliography===void 0?{}:{bibliography:e.bibliography},...e.citationStyle===void 0?{}:{"citation-style":e.citationStyle},...e.accent===void 0?{}:{accent:e.accent},...e.cover===void 0?{}:{cover:e.cover},...e.cover===void 0||e.coverY===void 0?{}:{"cover-y":e.coverY},...e.pageNumbers===!1?{"page-numbers":!1}:{},...e.pictureDpi===void 0?{}:{"picture-dpi":e.pictureDpi}}}
|
|
2
|
+
import{CITATION_STYLES as x}from"./cite.js";export const PAPERS={a3:[297,420],a4:[210,297],a5:[148,210],b5:[176,250],letter:[215.9,279.4],legal:[215.9,355.6]},PAGE_FONTS=["sans","serif","mono","times","song","hei","fangsong","kai","xiaobiaosong"],CHINESE_SIZES={初号:42,小初:36,一号:26,小一:24,二号:22,小二:18,三号:16,小三:15,四号:14,小四:12,五号:10.5,小五:9,六号:7.5,小六:6.5,七号:5.5,八号:5},RUNNING_PLACES=["left","center","right","outside","inside"],PAGE_PRESETS=["apa","mla","brief","memo","business-letter"];const H=new Map([["report","brief"]]),$={apa:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:2,textIndent:3,paragraphSpacing:0,textAlign:"left",title:{size:12,weight:"bold",align:"center"},headings:{1:{size:12,weight:"bold",align:"center"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold",italic:!0},6:{size:12,weight:"bold"}},header:{right:"{page}"},footer:!1,citationStyle:"apa"},mla:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:2,textIndent:3,paragraphSpacing:0,textAlign:"left",title:{size:12,weight:"normal",align:"center"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:{right:"{page}"},footer:!1,citationStyle:"mla"},brief:{size:10.5,lineHeight:1.2,paragraphSpacing:.7,title:{size:24,weight:"bold"},headings:{1:{size:18,weight:"bold"},2:{size:14,weight:"bold",rule:!0},3:{size:11.5,weight:"bold"}}},memo:{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:1,textIndent:0,paragraphSpacing:1,textAlign:"left",title:{size:12,weight:"bold"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold",italic:!0},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:!1,footer:{center:"{page}"}},"business-letter":{paper:"letter",margins:25.4,font:"times",size:12,lineHeight:1,textIndent:0,paragraphSpacing:1,textAlign:"left",title:{size:12,weight:"bold"},headings:{1:{size:12,weight:"bold"},2:{size:12,weight:"bold"},3:{size:12,weight:"bold"},4:{size:12,weight:"bold"},5:{size:12,weight:"bold"},6:{size:12,weight:"bold"}},header:!1,footer:!1,pageNumbers:!1}};export const presetLook=e=>$[e];export function effectiveLook(e){if(e.preset===void 0)return e;const i=$[e.preset],n={...i.headings};for(const[a,t]of Object.entries(e.headings??{}))n[Number(a)]={...i.headings?.[Number(a)],...t};return{...i,...e,...i.title||e.title?{title:{...i.title,...e.title}}:{},...Object.keys(n).length>0?{headings:n}:{}}}export const sizePt=e=>typeof e=="number"?e:CHINESE_SIZES[e];export function marginBox(e){return typeof e=="number"?{top:e,right:e,bottom:e,left:e}:e.length===2?{top:e[0],right:e[1],bottom:e[0],left:e[1]}:{top:e[0],right:e[1],bottom:e[2],left:e[3]}}export const PAGE_DEFAULTS={paper:"letter",margins:{top:18,right:20,bottom:18,left:20},size:11,lineHeight:1.15,textIndent:0,paragraphSpacing:.5,headingScale:{title:2.3,1:1.75,2:1.45,3:1.15,4:1,5:1,6:1},footer:{left:"{title}",right:"{page} / {pages}"}};const w=25.4/72;export const paperSize=e=>e===void 0?PAPERS[PAGE_DEFAULTS.paper]:typeof e=="string"?PAPERS[e]:e;export function resolvePage(e={}){const i=effectiveLook(e),[n,a]=paperSize(i.paper),t=i.orientation==="landscape",s=t?Math.max(n,a):Math.min(n,a),r=t?Math.min(n,a):Math.max(n,a),o=i.margins===void 0?{...PAGE_DEFAULTS.margins}:marginBox(i.margins),g=s-o.left-o.right,p=r-o.top-o.bottom,y=i.font??"sans";let d=i.size===void 0?PAGE_DEFAULTS.size:sizePt(i.size),h=i.lineHeight===void 0?{multiple:PAGE_DEFAULTS.lineHeight}:typeof i.lineHeight=="number"?{multiple:i.lineHeight}:{pt:Number.parseFloat(i.lineHeight)},z=0;if(i.grid){h={pt:p/w/i.grid.lines};const f=g/w/i.grid.chars;i.size===void 0&&(d=Math.floor(f*2)/2),z=(f*.998-d)/d}const S=(f,I)=>({font:f?.font??y,size:f?.size===void 0?d*I:sizePt(f.size),weight:f?.weight??"bold",align:f?.align??"left",italic:f?.italic??!1,rule:f?.rule??!1}),m=PAGE_DEFAULTS.headingScale,A=Object.fromEntries([1,2,3,4,5,6].map(f=>[f,S(i.headings?.[f],m[f])])),E=i.footer===!1||i.footer===void 0&&i.pageNumbers===!1?void 0:i.footer??PAGE_DEFAULTS.footer;return{width:s,height:r,margins:o,textWidth:g,textHeight:p,font:y,size:d,lineHeight:h,letterSpacing:z,textIndent:i.textIndent??PAGE_DEFAULTS.textIndent,paragraphSpacing:i.paragraphSpacing??PAGE_DEFAULTS.paragraphSpacing,textAlign:i.textAlign??"left",title:S(i.title,m.title),headings:A,header:i.header===!1?void 0:i.header,footer:E,captions:i.captions!=="plain",spacing:J(d,i.paragraphSpacing??PAGE_DEFAULTS.paragraphSpacing,i.grid===void 0||!("pt"in h)?void 0:h.pt)}}export const LIST_STEP=18;function J(e,i,n){const a=n!==void 0||i===0;return{after:i*e,heading:a?{before:0,after:0}:{before:14,after:6},title:n??(a?0:12),caption:4,box:{top:6,side:8},cell:{top:4,side:7},divider:12,contents:5,quote:12,step:LIST_STEP,small:Math.round(e*.9*2)/2,card:{top:9,side:11},gap:8,figure:Math.round(e*2.2)}}export const SINGLE_LINE={sans:1.2207,serif:1.1719,mono:1.1328,times:1.1499},lineMultiple=e=>"pt"in e.lineHeight?void 0:e.lineHeight.multiple*(SINGLE_LINE[e.font]??1),lineHeightPt=(e,i=e.size)=>"pt"in e.lineHeight?e.lineHeight.pt:(lineMultiple(e)??1)*i,PAGE_KEYS=["preset","paper","orientation","margins","font","size","line-height","text-indent","paragraph-spacing","text-align","grid","title","headings","header","footer","captions","bibliography","citation-style","accent","cover","cover-y","page-numbers","picture-dpi"];const P=["left","center","right"],c=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),l=e=>typeof e=="number"&&Number.isFinite(e)&&e>0;function u(e){if(l(e))return e;if(typeof e=="string"){const i=e.trim();if(Object.hasOwn(CHINESE_SIZES,i))return i;const n=/^(\d+(?:\.\d+)?)\s*pt$/u.exec(i);if(n)return Number(n[1])}}const b=`a size in pt (12) or a Chinese size (${Object.keys(CHINESE_SIZES).join(", ")})`;function N(e,i,n){if(!c(e)){n(`${i} holds font, size, weight, align, italic and rule`);return}const a={};for(const[t,s]of Object.entries(e))if(t==="font")PAGE_FONTS.includes(s)?a.font=s:n(`${i}'s font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(s)}`);else if(t==="size"){const r=u(s);r===void 0?n(`${i}'s size is ${b}`):a.size=r}else t==="weight"?s==="normal"||s==="bold"?a.weight=s:n(`${i}'s weight is normal or bold, not ${JSON.stringify(s)}`):t==="align"?P.includes(s)?a.align=s:n(`${i}'s align is left, center or right, not ${JSON.stringify(s)}`):t==="italic"?typeof s=="boolean"?a.italic=s:n(`${i}'s italic is true or false, not ${JSON.stringify(s)}`):t==="rule"?typeof s=="boolean"?a.rule=s:n(`${i}'s rule is true or false, not ${JSON.stringify(s)}`):n(`${i} holds font, size, weight, align, italic and rule: ${t} is not one of them`);return a}function v(e,i,n){if(e===!1)return!1;if(typeof e=="string")return{center:e};if(!c(e)){n(`a page's ${i} is false, words, or words by place (${RUNNING_PLACES.join(", ")}) with a font and a size`);return}const a={};for(const[t,s]of Object.entries(e))if(t==="font")PAGE_FONTS.includes(s)?a.font=s:n(`a page's ${i} font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(s)}`);else if(t==="size"){const r=u(s);r===void 0?n(`a page's ${i} size is ${b}`):a.size=r}else RUNNING_PLACES.includes(t)?typeof s!="string"&&typeof s!="number"?n(`a page's ${i} ${t} is words`):a[t]=String(s):n(`a page's ${i} holds ${RUNNING_PLACES.join(", ")}, font and size: ${t} is not one of them`);return a}export function readPageLook(e,i){const n={};for(const[a,t]of Object.entries(e))switch(a){case"preset":{const s=typeof t=="string"?H.get(t):void 0;PAGE_PRESETS.includes(t)?n.preset=t:s!==void 0?n.preset=s:i(`a page's preset is ${PAGE_PRESETS.join(" or ")}, not ${JSON.stringify(t)}`);break}case"paper":{const s=typeof t=="string"?t.trim().toLowerCase():void 0;s!==void 0&&Object.hasOwn(PAPERS,s)?n.paper=s:Array.isArray(t)&&t.length===2&&t.every(l)?n.paper=t:i(`a page's paper is ${Object.keys(PAPERS).join(", ")} or its width and height in mm ([210, 297]), not ${JSON.stringify(t)}`);break}case"orientation":t==="portrait"||t==="landscape"?n.orientation=t:i(`a page's orientation is portrait or landscape, not ${JSON.stringify(t)}`);break;case"margins":typeof t=="number"&&t>=0||Array.isArray(t)&&(t.length===2||t.length===4)&&t.every(s=>typeof s=="number"&&s>=0)?n.margins=t:i("a page's margins are mm: one for all four, [top and bottom, sides], or [top, right, bottom, left]");break;case"font":PAGE_FONTS.includes(t)?n.font=t:i(`a page's font is ${PAGE_FONTS.join(", ")}, not ${JSON.stringify(t)}`);break;case"size":{const s=u(t);s===void 0?i(`a page's size is ${b}`):n.size=s;break}case"line-height":l(t)?n.lineHeight=t:typeof t=="string"&&/^\d+(\.\d+)?pt$/u.test(t.trim())?n.lineHeight=t.trim():i(`a page's line-height is a multiple (1.5) or pt (28pt), not ${JSON.stringify(t)}`);break;case"text-indent":typeof t=="number"&&t>=0?n.textIndent=t:i("a page's text-indent is how many characters a paragraph's first line is set in (2)");break;case"paragraph-spacing":typeof t=="number"&&t>=0?n.paragraphSpacing=t:i("a page's paragraph-spacing is the space between paragraphs in em (0.5)");break;case"text-align":t==="left"||t==="justify"?n.textAlign=t:i(`a page's text-align is left or justify, not ${JSON.stringify(t)}`);break;case"grid":{const s=c(t)?t.chars:void 0,r=c(t)?t.lines:void 0;c(t)&&Object.keys(t).length===2&&l(s)&&l(r)&&Number.isInteger(s)&&Number.isInteger(r)?n.grid={chars:s,lines:r}:i("a page's grid is { chars, lines }: characters to a line and lines to a page");break}case"title":{const s=N(t,"the title",i);s&&(n.title=s);break}case"headings":{if(!c(t)){i("a page's headings are by level: { 1: { font, size }, 2: … }");break}const s={};for(const[r,o]of Object.entries(t)){const g=Number(r);if(!Number.isInteger(g)||g<1||g>6){i(`a heading's level is 1 to 6, not ${r}`);continue}const p=N(o,`heading ${r}`,i);p&&(s[g]=p)}n.headings=s;break}case"header":case"footer":{const s=v(t,a,i);s!==void 0&&(n[a]=s);break}case"captions":t==="numbered"||t==="plain"?n.captions=t:i(`a page's captions are numbered or plain, not ${JSON.stringify(t)}`);break;case"bibliography":typeof t=="string"&&t.trim()!==""?n.bibliography=t.trim():i("a page's bibliography is a CSL-JSON file's path");break;case"citation-style":x.includes(t)?n.citationStyle=t:i(`a page's citation-style is ${x.join(" or ")}, not ${JSON.stringify(t)}`);break;case"accent":typeof t=="string"&&t.trim()!==""?n.accent=t.trim():i("a page's accent is a colour");break;case"cover":typeof t=="string"&&t.trim()!==""?n.cover=t.trim():i("a page's cover is a picture's path");break;case"cover-y":typeof t=="number"&&t>=0&&t<=100?n.coverY=t:i(`a cover's cover-y is 0 (its top) to 100 (its bottom), not ${JSON.stringify(t)}`);break;case"picture-dpi":t===!1?n.pictureDpi=!1:typeof t=="number"&&t>=72&&t<=2400?n.pictureDpi=t:i(`a page's picture-dpi is 72 to 2400 (dots an inch of paper), or false to print pictures as they are, not ${JSON.stringify(t)}`);break;case"page-numbers":t===!1?n.pageNumbers=!1:t!==!0&&i(`a page's page-numbers is true or false, not ${JSON.stringify(t)}`);break;default:i(`the front matter holds ${PAGE_KEYS.join(", ")}: ${a} is not one of them`)}return n}const O=e=>({...e.font===void 0?{}:{font:e.font},...e.size===void 0?{}:{size:e.size},...e.weight===void 0?{}:{weight:e.weight},...e.align===void 0?{}:{align:e.align},...e.italic===void 0?{}:{italic:e.italic},...e.rule===void 0?{}:{rule:e.rule}}),j=e=>e===!1?!1:Object.keys(e).length===1&&e.center!==void 0?e.center:{...e},L=e=>/^[ab]\d$/u.test(e)?e.toUpperCase():`${e.charAt(0).toUpperCase()}${e.slice(1)}`;export function pageLookYaml(e){return{...e.preset===void 0?{}:{preset:e.preset},...e.paper===void 0?{}:{paper:typeof e.paper=="string"?L(e.paper):[...e.paper]},...e.orientation===void 0?{}:{orientation:e.orientation},...e.margins===void 0?{}:{margins:typeof e.margins=="number"?e.margins:[...e.margins]},...e.font===void 0?{}:{font:e.font},...e.size===void 0?{}:{size:e.size},...e.lineHeight===void 0?{}:{"line-height":e.lineHeight},...e.textIndent===void 0?{}:{"text-indent":e.textIndent},...e.paragraphSpacing===void 0?{}:{"paragraph-spacing":e.paragraphSpacing},...e.textAlign===void 0?{}:{"text-align":e.textAlign},...e.grid===void 0?{}:{grid:{...e.grid}},...e.title===void 0?{}:{title:O(e.title)},...e.headings===void 0?{}:{headings:Object.fromEntries(Object.entries(e.headings).map(([n,a])=>[n,O(a)]))},...e.header===void 0?{}:{header:j(e.header)},...e.footer===void 0?{}:{footer:j(e.footer)},...e.captions===void 0?{}:{captions:e.captions},...e.bibliography===void 0?{}:{bibliography:e.bibliography},...e.citationStyle===void 0?{}:{"citation-style":e.citationStyle},...e.accent===void 0?{}:{accent:e.accent},...e.cover===void 0?{}:{cover:e.cover},...e.cover===void 0||e.coverY===void 0?{}:{"cover-y":e.coverY},...e.pageNumbers===!1?{"page-numbers":!1}:{},...e.pictureDpi===void 0?{}:{"picture-dpi":e.pictureDpi}}}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{
|
|
2
|
+
import{readFile as x}from"node:fs/promises";import{basename as P,dirname as b,join as m}from"node:path";import{componentDraws as M,parseDoc as w}from"@allyhub/doc";import{PAGE_FACT_DEFAULTS as j,pageFacts as v,printDoc as S,renderDoc as A,renderWord as E}from"@allyhub/doc-print";import{createPackages as T}from"@allyhub/runtimes";export const DOC_TYPES=["pdf","docx","png"];async function W(i){const t=T(),e=()=>i?.("Getting docx, once, to write Word documents…"),[s,a]=await Promise.all([t.load("docx",{onFetch:e}),t.load("docx",{module:"fflate",onFetch:e})]);return{docx:s,zip:a}}export async function renderDocFiles(i,t){const e=t.prepared.docs.find(o=>o.place===i.id);if(!e||t.types.length===0)return[];const{root:s,log:a,types:r}=t;a?.(`Rendering ${e.file}…`);const d=[],p={file:e.file,dir:e.dir,path:e.place,title:e.title,data:e.data,sources:e.sources},f=t.prepared.messages.locales[0],c=e.components.length===0?new Map:await t.session.componentStills(e,M(w(await x(m(t.prepared.root,e.file),"utf8")).blocks),f===void 0?{}:{lang:f});if(r.includes("docx")){const o=t.out("docx");await E({root:s,doc:p,out:o,...await W(a),stills:c}),d.push({type:"docx",files:[o]})}const n=r.filter(o=>o==="pdf"||o==="png"),h=async o=>{const l=w(await x(m(s,e.file),"utf8"));for(const F of pagesLines(e.file,e.place,l,o))a?.(F)};if(n.length===0){if(r.includes("docx")){const o=await S({root:s,doc:p,stills:c});await h(o);for(const l of paperNotes(e.file,o))a?.(l)}return d}const g=t.out("pdf"),$={},D=await A({root:s,doc:p,out:b(g),name:P(g,".pdf"),types:n,stills:c,onPrinted:o=>{$.done=o}}),u=$.done??(r.includes("docx")?await S({root:s,doc:p,stills:c}):void 0);u!==void 0&&await h(u);const y=u===void 0?[]:paperNotes(e.file,u);for(const o of D){const l=o.endsWith(".png")?"png":"pdf";d.push({type:l,files:[m(b(g),o)],...l==="pdf"&&y.length>0?{notes:y}:{}})}return d}export function pagesLines(i,t,e,s){const a=v(e,s.layout,t,{...j,all:!1}),r=n=>`${String(Math.round(n*100))}%`,d=a.flatMap(n=>n.kind==="page-fill"?[n.data]:[]),p=a.flatMap(n=>n.kind==="page-split"?[n.data]:[]),f=s.layout.pages.length,c=[`${i}: ${String(f)} page${f===1?"":"s"} as it prints; left empty at each page's foot: ${d.map(n=>`page ${String(n.page)} ${r(n.share)}`).join(", ")}.`];return p.length>0&&c.push(`${i}: broken over pages: ${p.map(n=>`line ${String(n.line)} ${n.block} (pages ${n.pages.join(", ")})`).join("; ")}.`),c.push(`allyhub inspect pages ${t} has every fact, and a picture of the pages.`),c}export function paperNotes(i,t){const e=[],s=[...t.layout.blocks.values()].filter(a=>a.pastPaper>.1).length;return s>0&&e.push(`${i}: ${String(s)} block${s===1?" runs":"s run"} past the paper's edge, which cuts ${s===1?"it":"them"}.`),t.settled||e.push(`${i}: its contents' page numbers did not hold after ${String(t.passes)} printings; one may be a page off.`),e}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allyhub/doc-extension",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./cli": {
|
|
@@ -48,15 +48,15 @@
|
|
|
48
48
|
"editor": "allyhub.doc.editor",
|
|
49
49
|
"shown": {
|
|
50
50
|
"line": {
|
|
51
|
-
"en": "
|
|
52
|
-
"zh-cn": "
|
|
53
|
-
"zh-tw": "
|
|
54
|
-
"ja": "
|
|
55
|
-
"ko": "
|
|
56
|
-
"es": "
|
|
57
|
-
"pt": "
|
|
58
|
-
"de": "
|
|
59
|
-
"fr": "
|
|
51
|
+
"en": "Briefs, memos and docs, page by page",
|
|
52
|
+
"zh-cn": "简报、备忘录和文档,逐页排版",
|
|
53
|
+
"zh-tw": "簡報、備忘錄和文件,逐頁排版",
|
|
54
|
+
"ja": "ブリーフ、メモ、ドキュメントをページ単位で",
|
|
55
|
+
"ko": "브리프, 메모, 문서를 페이지 단위로",
|
|
56
|
+
"es": "Briefs, memorandos y documentos, página a página",
|
|
57
|
+
"pt": "Briefings, memorandos e documentos, página a página",
|
|
58
|
+
"de": "Briefings, Memos und Dokumente, Seite für Seite",
|
|
59
|
+
"fr": "Briefs, notes et documents, page par page"
|
|
60
60
|
},
|
|
61
61
|
"order": 10
|
|
62
62
|
},
|
|
@@ -66,8 +66,7 @@
|
|
|
66
66
|
"types": [
|
|
67
67
|
"pdf",
|
|
68
68
|
"docx",
|
|
69
|
-
"png"
|
|
70
|
-
"md"
|
|
69
|
+
"png"
|
|
71
70
|
],
|
|
72
71
|
"extras": []
|
|
73
72
|
},
|
|
@@ -75,8 +74,7 @@
|
|
|
75
74
|
"types": [
|
|
76
75
|
"pdf",
|
|
77
76
|
"docx",
|
|
78
|
-
"png"
|
|
79
|
-
"md"
|
|
77
|
+
"png"
|
|
80
78
|
],
|
|
81
79
|
"defaults": [
|
|
82
80
|
"pdf"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{readFile as g}from"node:fs/promises";import{createRequire as w}from"node:module";import{dirname as x,join as l}from"node:path";import{drawHtml as b,openPage as y,startBrowser as m,startServer as v}from"@allyhub/browser";import{createPackages as k}from"@allyhub/runtimes";import{printDoc as
|
|
2
|
+
import{readFile as g}from"node:fs/promises";import{createRequire as w}from"node:module";import{dirname as x,join as l}from"node:path";import{drawHtml as b,openPage as y,startBrowser as m,startServer as v}from"@allyhub/browser";import{createPackages as k}from"@allyhub/runtimes";import{printDoc as S}from"./layout.js";export class DocPageError extends Error{page;count;constructor(a,o){super(`The doc has ${String(o)} page${o===1?"":"s"}: there is no page ${String(a)}.`),this.page=a,this.count=o}}const f=16,j=22;export function placesOf(t){const a=new Map,o=e=>{const r=a.get(e.page);a.set(e.page,r===void 0?{...e}:{page:e.page,top:Math.min(r.top,e.top),bottom:Math.max(r.bottom,e.bottom),left:Math.min(r.left,e.left),right:Math.max(r.right,e.right)})},s=t.boxes[0],n=e=>s===void 0?e:{...e,left:s.left,right:s.right};if(t.lines.length>0){for(const e of t.lines)o(n(e));if(t.end&&o(n(t.end)),s&&t.boxes.length===1)o(s);else if(s){const e=a.get(s.page);e&&(e.top=Math.min(e.top,s.top))}}else if(t.rows.length>0)for(const e of t.rows)o(e);else for(const e of t.boxes)o(e);return[...a.values()].sort((e,r)=>e.page-r.page)}function $(t,a){const o=[],s=[...t.blocks.values()].map(n=>({b:n,places:placesOf(n)}));for(const n of t.pages){o.push({page:n.n,...n.text,label:"",kind:"area"});let e=n.text.top;for(const{b:p,places:d}of s)for(const c of d.filter(i=>i.page===n.n)){e=Math.max(e,c.bottom);const i=a.get(p.n);i!==void 0&&o.push({...c,label:i,kind:"block"})}const r=n.text.bottom-e;r>.5&&o.push({page:n.n,top:e,bottom:n.text.bottom,left:n.text.left,right:n.text.right,label:`${r.toFixed(1)} mm`,kind:"foot"})}return o}function M(t,a,o,s,n){return`<!doctype html><meta charset="utf-8">
|
|
3
3
|
<style>
|
|
4
4
|
body{margin:0;background:#e7e5e0;font:12px/1 system-ui,sans-serif;color:#57534e}
|
|
5
5
|
.grid{display:grid;grid-template-columns:repeat(${String(s)},${String(o)}px);gap:${String(f)}px;padding:${String(f)}px;width:max-content}
|
|
6
6
|
figure{margin:0;position:relative}
|
|
7
7
|
canvas{display:block;width:${String(o)}px;background:#fff;box-shadow:0 1px 3px rgba(0,0,0,.2)}
|
|
8
|
-
figcaption{height:${String(
|
|
8
|
+
figcaption{height:${String(j-6)}px;padding-top:6px;text-align:center}
|
|
9
9
|
.o{position:absolute;box-sizing:border-box;pointer-events:none}
|
|
10
10
|
.o.area{border:1px dashed rgba(37,99,235,.45)}
|
|
11
11
|
.o.block{border:1px solid rgba(225,29,72,.7)}
|
|
@@ -54,7 +54,7 @@ window.allyhubReady = (async () => {
|
|
|
54
54
|
grid.append(figure);
|
|
55
55
|
}
|
|
56
56
|
})();
|
|
57
|
-
<\/script>`}async function E(t){try{return x(w(import.meta.url).resolve("pdfjs-dist/package.json"))}catch{}const{dir:a}=await k().ensure("pdfjs-dist",{...t===void 0?{}:{onFetch:t}});return l(a,"node_modules","pdfjs-dist")}async function u(t,a){const o=await E(a);return[{at:"/pdf.mjs",body:await g(l(o,"build","pdf.min.mjs")),type:"text/javascript"},{at:"/pdf.worker.mjs",body:await g(l(o,"build","pdf.worker.min.mjs")),type:"text/javascript"},{at:"/doc.pdf",body:t,type:"application/pdf"}]}export async function docPages(t){const a=await
|
|
57
|
+
<\/script>`}async function E(t){try{return x(w(import.meta.url).resolve("pdfjs-dist/package.json"))}catch{}const{dir:a}=await k().ensure("pdfjs-dist",{...t===void 0?{}:{onFetch:t}});return l(a,"node_modules","pdfjs-dist")}async function u(t,a){const o=await E(a);return[{at:"/pdf.mjs",body:await g(l(o,"build","pdf.min.mjs")),type:"text/javascript"},{at:"/pdf.worker.mjs",body:await g(l(o,"build","pdf.worker.min.mjs")),type:"text/javascript"},{at:"/doc.pdf",body:t,type:"application/pdf"}]}export async function docPages(t){const a=await S({root:t.root,doc:t.doc,stills:t.stills}),o=a.layout.pages.length,s=a.layout.pages[0],n=t.pages!==void 0&&t.pages.length>0;for(const i of t.pages??[])if(!Number.isInteger(i)||i<1||i>o)throw new DocPageError(i,o);const e=n?[...new Set(t.pages)]:Array.from({length:o},(i,h)=>h+1),r=t.pageWidth??(n?760:360),p=Math.max(1,Math.min(t.columns??(n?2:4),e.length)),d=t.outlines===void 0?[]:$(a.layout,t.outlines),c=await m({gpu:!1,htmlInCanvas:!1});try{const i=await b(c,{html:M(e,o,r,p,d),width:p*r+(p+1)*f,format:t.format??"png",...t.format==="webp"?{quality:90}:{},mounts:await u(a.pdf,t.onFetch)});return{count:o,paper:{width:Math.round(s?.width??210),height:Math.round(s?.height??297)},drawn:e,picture:i,layout:a.layout,printing:{passes:a.passes,settled:a.settled}}}finally{await c.close()}}export async function pagePictures(t,a,o,s,n="webp"){if(a.length===0)return[];const e=await v([...await u(t.pdf,s),{at:"/index.html",body:`<!doctype html><meta charset="utf-8"><script type="module">
|
|
58
58
|
import * as pdfjs from "/pdf.mjs";
|
|
59
59
|
pdfjs.GlobalWorkerOptions.workerSrc = "/pdf.worker.mjs";
|
|
60
60
|
window.drawn = (async () => {
|
|
@@ -70,8 +70,8 @@ window.drawn = (async () => {
|
|
|
70
70
|
context.fillStyle = "#fff";
|
|
71
71
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
72
72
|
await page.render({ canvasContext: context, canvas, viewport }).promise;
|
|
73
|
-
out.push(canvas.toDataURL(
|
|
73
|
+
out.push(canvas.toDataURL(${JSON.stringify(`image/${n}`)}, 0.9));
|
|
74
74
|
}
|
|
75
75
|
return out;
|
|
76
76
|
})();
|
|
77
|
-
<\/script>`,type:"text/html; charset=utf-8"}]),
|
|
77
|
+
<\/script>`,type:"text/html; charset=utf-8"}]),r=await m({gpu:!1,htmlInCanvas:!1});try{const p=await y(r,{width:800,height:600,allow:e.allow});return await p.goto(`${e.origin}/index.html`),(await p.evaluate("window.drawn")).map(c=>Buffer.from(c.slice(c.indexOf(",")+1),"base64"))}finally{await r.close(),await e.close()}}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{mkdir as C,readFile as S,writeFile as D}from"node:fs/promises";import{cpus as
|
|
2
|
+
import{mkdir as C,readFile as S,writeFile as D}from"node:fs/promises";import{cpus as N}from"node:os";import{dirname as $,extname as z,join as u,posix as j}from"node:path";import{openPage as I,startBrowser as v}from"@allyhub/browser";import{pagePicture as J}from"@allyhub/browser/picture";import{DRAWN_CODE as w,componentDrawingKey as R,docHtml as H,everyBlock as E,COVER_ASPECT as k,mathHtml as T,pageAccent as B,pageFaces as A,parseDoc as F}from"@allyhub/doc";import{docxOf as V}from"@allyhub/doc/docx";import{drawDiagrams as L,katexCss as q,mathPictures as Q}from"./drawn.js";import{docFaces as Y,docFontsCss as G}from"./fonts.js";import{PdfJoiner as K}from"./pdf.js";const x=(t,e)=>[...new Set([...E(t)].flatMap(a=>a.type==="code"&&a.language===e?[a.code]:[]))];async function X(t,e){const a=x(t,w.mermaid);if(a.length===0)return new Map;const n=await v({gpu:!1,htmlInCanvas:!1});try{return await L(n,a,{font:A(e).text,accent:B(e)})}finally{await n.close()}}const Z={".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".avif":"image/avif",".svg":"image/svg+xml"},tt=/^([a-z][a-z0-9+.-]*:|\/\/)/i,et=(t,e)=>{const a=t?.get(R(e));return a?{type:"image/webp",bytes:Buffer.from(a)}:void 0};async function U(t,e,a,n={}){const s=new Map,i=[...n.cover===void 0?[]:[n.cover],...[...E(a)].flatMap(r=>r.type==="image"?[r.src]:[])];for(const r of i){if(tt.test(r)||s.has(r))continue;const g=j.normalize(j.join(e.dir,decodeURIComponent(r))),d=Z[z(g).toLowerCase()];if(d===void 0||g.startsWith(".."))continue;const o=await S(u(t,g)).catch(()=>{});o&&s.set(r,{type:d,bytes:o})}return s}const W=1600;async function at(t,e,a){const n=await t.evaluate(`(async () => {
|
|
3
3
|
const image = new Image();
|
|
4
4
|
image.src = ${JSON.stringify(P(e))};
|
|
5
5
|
try { await image.decode(); } catch { return null; }
|
|
6
6
|
const w = image.naturalWidth || 1600;
|
|
7
7
|
const h = image.naturalHeight || 900;
|
|
8
|
-
const width = Math.min(${String(
|
|
8
|
+
const width = Math.min(${String(W)}, w);
|
|
9
9
|
const height = Math.round(width * ${String(k)});
|
|
10
10
|
// As object-fit: cover, at object-position 50% y%.
|
|
11
11
|
const scale = Math.max(width / w, height / h);
|
|
@@ -20,16 +20,16 @@ import{mkdir as C,readFile as S,writeFile as D}from"node:fs/promises";import{cpu
|
|
|
20
20
|
context.fillStyle = "#fff";
|
|
21
21
|
context.fillRect(0, 0, width, height);
|
|
22
22
|
context.drawImage(image, sx, sy, sw, sh, 0, 0, width, height);
|
|
23
|
-
return canvas.toDataURL("image/jpeg", ${String(
|
|
24
|
-
})()`);if(n===null)return;const s=
|
|
25
|
-
`),...n.ids===!0?{ids:!0}:{},...n.part===void 0?{}:{part:n.part},headingPage:n.headingPage})}const
|
|
23
|
+
return canvas.toDataURL("image/jpeg", ${String(M)});
|
|
24
|
+
})()`);if(n===null)return;const s=W;return{data:Buffer.from(n.slice(n.indexOf(",")+1),"base64"),type:"jpg",width:s,height:Math.round(s*k)}}const P=({type:t,bytes:e})=>`data:${t};base64,${e.toString("base64")}`;export async function docPage(t,e,a,n={}){const s=await S(u(t,e.file),"utf8"),i=F(s),r=await U(t,e,i.blocks,i.page),g=await X(i.blocks,i.page),d=x(i.blocks,w.math).length>0;return H(i.blocks,{title:e.title??e.path,page:i.page,base:e.dir,data:o=>e.data?.[o],sources:e.sources,diagram:o=>g.get(o),image:o=>{const f=r.get(o);return f&&P(f)},component:o=>{const f=et(a,o);return f&&P(f)},fonts:[await G(s,Y(i.page)),...d?[await q()]:[]].join(`
|
|
25
|
+
`),...n.ids===!0?{ids:!0}:{},...n.part===void 0?{}:{part:n.part},headingPage:n.headingPage})}const nt={"image/png":"png","image/jpeg":"jpg","image/gif":"gif"},it=2,M=.92;async function st(t,e){const a=nt[e.type],n=await t.evaluate(`(async () => {
|
|
26
26
|
const image = new Image();
|
|
27
27
|
image.src = ${JSON.stringify(P(e))};
|
|
28
28
|
try { await image.decode(); } catch { return null; }
|
|
29
29
|
const width = image.naturalWidth || 1024;
|
|
30
30
|
const height = image.naturalHeight || 768;
|
|
31
31
|
if (${JSON.stringify(a!==void 0)}) return { width, height };
|
|
32
|
-
const scale = ${JSON.stringify(e.type==="image/svg+xml"?
|
|
32
|
+
const scale = ${JSON.stringify(e.type==="image/svg+xml"?it:1)};
|
|
33
33
|
const canvas = document.createElement("canvas");
|
|
34
34
|
canvas.width = width * scale;
|
|
35
35
|
canvas.height = height * scale;
|
|
@@ -37,8 +37,8 @@ import{mkdir as C,readFile as S,writeFile as D}from"node:fs/promises";import{cpu
|
|
|
37
37
|
context.fillStyle = "#fff";
|
|
38
38
|
context.fillRect(0, 0, canvas.width, canvas.height);
|
|
39
39
|
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
40
|
-
return { width, height, jpeg: canvas.toDataURL("image/jpeg", ${String(
|
|
41
|
-
})()`);if(!n)return;const{width:s,height:i,jpeg:r}=n;if(a!==void 0)return{data:e.bytes,type:a,width:s,height:i};if(r!==void 0)return{data:Buffer.from(r.slice(r.indexOf(",")+1),"base64"),type:"jpg",width:s,height:i}}export async function renderWord(t){const{root:e,doc:a}=t,{blocks:n,page:s}=F(await S(
|
|
40
|
+
return { width, height, jpeg: canvas.toDataURL("image/jpeg", ${String(M)}) };
|
|
41
|
+
})()`);if(!n)return;const{width:s,height:i,jpeg:r}=n;if(a!==void 0)return{data:e.bytes,type:a,width:s,height:i};if(r!==void 0)return{data:Buffer.from(r.slice(r.indexOf(",")+1),"base64"),type:"jpg",width:s,height:i}}export async function renderWord(t){const{root:e,doc:a}=t,{blocks:n,page:s}=F(await S(u(e,a.file),"utf8")),i=await U(e,a,n,s);let r;if([...E(n)].some(c=>c.type==="toc")){const{printDoc:c,headingPages:m}=await import("./layout.js"),b=await c({root:e,doc:a,stills:t.stills}),p=m(b.layout,n);r=y=>p.get(y)}for(const[c,m]of t.stills??[])i.set(`component:${c}`,{type:"image/webp",bytes:Buffer.from(m)});const g=x(n,w.math),d=x(n,w.mermaid),o=new Map;let f;if(i.size>0||g.length>0||d.length>0){const c=await v({gpu:!1,htmlInCanvas:!1});try{const m=await L(c,d,{font:A(s).text,accent:B(s)});for(const[h,l]of m)l.svg!==void 0&&i.set(`diagram:${h}`,{type:"image/svg+xml",bytes:Buffer.from(l.svg)});const b=await Q(c,g.map(h=>T(h).html));g.forEach(h=>{const l=b.get(T(h).html);l&&o.set(`math:${h}`,{data:l.data,type:"png",width:l.width,height:l.height})});const p=await I(c,{width:900,height:1200,allow:()=>!1});for(const[h,l]of i){const O=await st(p,l);O&&o.set(h,O)}const y=s.cover===void 0?void 0:i.get(s.cover);y&&(f=await at(p,y,s.coverY??50))}finally{await c.close()}}const _=await V(t.docx,t.zip,n,{title:a.title??a.path,page:s,headingPage:r,sources:a.sources,cover:f,base:a.dir,data:c=>a.data?.[c],picture:c=>o.get(c),component:c=>o.get(`component:${R(c)}`),drawn:c=>o.get(c.language===w.math?`math:${c.code}`:`diagram:${c.code}`)});await C($(t.out),{recursive:!0}),await D(t.out,_)}export async function setContent(t,e){const{frameTree:a}=await t.session.send("Page.getFrameTree");await t.session.send("Page.setDocumentContent",{frameId:a.frame.id,html:e}),await t.evaluate("new Promise((r) => (document.readyState === 'complete' ? r() : addEventListener('load', () => r(), { once: true }))).then(() => document.fonts.ready).then(() => window.allyhubReady).then(() => true)")}export const PICTURE_DPI=220;export async function shrinkPictures(t,e){await t.evaluate(`(async () => {
|
|
42
42
|
const k = ${String(e)} / 96;
|
|
43
43
|
for (const img of document.querySelectorAll("img")) {
|
|
44
44
|
if (!img.src.startsWith("data:image/") || img.src.startsWith("data:image/svg")) continue;
|
|
@@ -59,10 +59,10 @@ import{mkdir as C,readFile as S,writeFile as D}from"node:fs/promises";import{cpu
|
|
|
59
59
|
const px = c.getImageData(0, 0, w, h).data;
|
|
60
60
|
let clear = false;
|
|
61
61
|
for (let i = 3; i < px.length; i += 4) if (px[i] < 255) { clear = true; break; }
|
|
62
|
-
const src = clear ? canvas.toDataURL("image/png") : canvas.toDataURL("image/jpeg", ${String(
|
|
62
|
+
const src = clear ? canvas.toDataURL("image/png") : canvas.toDataURL("image/jpeg", ${String(M)});
|
|
63
63
|
if (src.length >= img.src.length) continue;
|
|
64
64
|
img.src = src;
|
|
65
65
|
try { await img.decode(); } catch {}
|
|
66
66
|
}
|
|
67
67
|
return true;
|
|
68
|
-
})()`)}
|
|
68
|
+
})()`)}const rt=Math.max(1,Math.min(4,Math.floor(N().length/2)));export async function printOne(t,e,a){const{stream:n}=await t.session.send("Page.printToPDF",{...a===void 0?{}:{displayHeaderFooter:!0,headerTemplate:"<span></span>",footerTemplate:a},preferCSSPageSize:!0,printBackground:!0,generateTaggedPDF:e,generateDocumentOutline:!1,transferMode:"ReturnAsStream"});if(n===void 0)throw new Error("Chrome gave no PDF.");const s=[];for(;;){const i=await t.session.send("IO.read",{handle:n,size:1048576});if(s.push(Buffer.from(i.data,i.base64Encoded?"base64":"latin1")),i.eof)break}return await t.session.send("IO.close",{handle:n}),Buffer.concat(s)}export async function printPdf(t){await C($(t.file),{recursive:!0});const e=await v({gpu:!1,htmlInCanvas:!1}),a=await K.create(t.file),n=t.tagged??!0,s=async i=>{t.signal?.throwIfAborted();const r=await I(e,{width:900,height:1200,allow:()=>!1});try{return await setContent(r,await t.parts.html(i)),await printOne(r,n,t.footer)}finally{await r.close()}};try{const i=[];let r=0;const g=()=>{r<t.parts.count&&i.push(s(r++))};for(let d=0;d<rt;d++)g();for(let d=0;d<t.parts.count;d++){const o=i.shift();if(!o)break;const f=await o;g(),await a.add(f)}await Promise.allSettled(i)}finally{await a.close(t.title===void 0?{}:{title:t.title}),await e.close()}}export async function printPage(t){const e=[];for(const a of t.types){const n=u(t.out,`${t.name}.${a}`);await C($(n),{recursive:!0}),a==="pdf"?await printPdf({parts:{count:1,html:()=>t.html},file:n,...t.title===void 0?{}:{title:t.title},footer:t.footer}):await D(n,await ct(t)),e.push(`${t.name}.${a}`)}return e}async function ct(t){const e=await v({gpu:!1,htmlInCanvas:!1});try{const a=await I(e,{width:t.width??900,height:1200,scale:2,allow:()=>!1});return await setContent(a,t.html),t.pictureCss!==void 0&&await a.evaluate(`(() => { const s = document.createElement('style'); s.textContent = ${JSON.stringify(t.pictureCss)}; document.head.append(s); return true; })()`),(await J(a)).png}finally{await e.close()}}export async function renderDoc(t){const e=t.name??"doc",a=t.types?.length?t.types:["pdf"],n=[];for(const s of a){if(s==="pdf"){const{writeDocPdf:i}=await import("./layout.js"),r=await i({root:t.root,doc:t.doc,stills:t.stills,file:u(t.out,`${e}.pdf`),title:t.doc.title??t.doc.path});t.onPrinted?.(r)}else await printPage({html:await docPage(t.root,t.doc,t.stills),out:t.out,name:e,types:[s],pictureCss:"body{padding:48px 0;background:#fff}",title:t.doc.title??t.doc.path});n.push(`${e}.${s}`)}return n}
|
|
@@ -36,4 +36,24 @@ export declare function touches(shape: NoteShape, box: NoteBox): boolean;
|
|
|
36
36
|
export declare function pointsOf(shape: NoteShape): NotePoint[];
|
|
37
37
|
/** A shape moved into another frame, as a stage's own. */
|
|
38
38
|
export declare function mapShape(shape: NoteShape, map: (p: NotePoint) => NotePoint): NoteShape;
|
|
39
|
+
/**
|
|
40
|
+
* An element's edge as it is drawn, for a person who picks it rather than
|
|
41
|
+
* drawing round it (docs/design/notes.md, "Select"): closed outlines, each a
|
|
42
|
+
* ring of points in the surface's pixels. A box is one ring of four, a box
|
|
43
|
+
* turned its four corners turned, words a ring a line, a round shape its
|
|
44
|
+
* edge in steps.
|
|
45
|
+
*/
|
|
46
|
+
export type NoteOutline = NotePoint[][];
|
|
47
|
+
/** A box's outline. */
|
|
48
|
+
export declare function rectOutline(box: NoteBox): NoteOutline;
|
|
49
|
+
/** A box turned about its middle, degrees clockwise: its four corners where they are drawn. */
|
|
50
|
+
export declare function turnedOutline(box: NoteBox, degrees: number): NoteOutline;
|
|
51
|
+
/** The round in a box: its edge in steps. */
|
|
52
|
+
export declare function roundOutline(box: NoteBox): NoteOutline;
|
|
53
|
+
/** An outline moved into another frame. */
|
|
54
|
+
export declare function mapOutline(outline: readonly (readonly NotePoint[])[], map: (p: NotePoint) => NotePoint): NoteOutline;
|
|
55
|
+
/** The box round an outline. */
|
|
56
|
+
export declare function outlineBox(outline: readonly (readonly NotePoint[])[]): NoteBox;
|
|
57
|
+
/** Whether a point is inside an outline: inside one of its rings (the even-odd rule a ring). */
|
|
58
|
+
export declare function insideOutline(outline: readonly (readonly NotePoint[])[], p: NotePoint): boolean;
|
|
39
59
|
//# sourceMappingURL=note-shape.d.ts.map
|