@syncfusion/ej2-docx 0.0.0-stage → 35.1.40
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/.gitleaksignore +35 -0
- package/README.md +68 -2
- package/core.js +4 -0
- package/dist/ej2-docx.umd.min.js +11 -0
- package/dist/ej2-docx.umd.min.js.map +1 -0
- package/dist/es6/ej2-docx.es2015.js +66697 -0
- package/dist/es6/ej2-docx.es2015.js.map +1 -0
- package/dist/es6/ej2-docx.es5.js +77568 -0
- package/dist/es6/ej2-docx.es5.js.map +1 -0
- package/dist/global/ej2-docx.min.js +11 -0
- package/dist/global/ej2-docx.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/features.js +4 -0
- package/index.js +4 -0
- package/license +10 -0
- package/package.json +30 -3
- package/src/all.d.ts +50 -0
- package/src/all.js +147 -0
- package/src/core/compat/base64.d.ts +13 -0
- package/src/core/compat/base64.js +90 -0
- package/src/core/compat/object-compat.d.ts +30 -0
- package/src/core/compat/object-compat.js +40 -0
- package/src/core/compat/sha256.d.ts +9 -0
- package/src/core/compat/sha256.js +98 -0
- package/src/core/errors/docx-error.d.ts +89 -0
- package/src/core/errors/docx-error.js +138 -0
- package/src/core/errors/error-codes.d.ts +8 -0
- package/src/core/errors/error-codes.js +0 -0
- package/src/core/errors/index.d.ts +10 -0
- package/src/core/errors/index.js +9 -0
- package/src/core/index.d.ts +12 -0
- package/src/core/index.js +12 -0
- package/src/core/mc/alternate-content.d.ts +7 -0
- package/src/core/mc/alternate-content.js +67 -0
- package/src/core/mc/attributes.d.ts +24 -0
- package/src/core/mc/attributes.js +82 -0
- package/src/core/mc/index.d.ts +7 -0
- package/src/core/mc/index.js +5 -0
- package/src/core/mc/inspect.d.ts +16 -0
- package/src/core/mc/inspect.js +148 -0
- package/src/core/mc/namespaces.d.ts +4 -0
- package/src/core/mc/namespaces.js +4 -0
- package/src/core/mc/scope.d.ts +6 -0
- package/src/core/mc/scope.js +47 -0
- package/src/core/opc/content-types.d.ts +34 -0
- package/src/core/opc/content-types.js +162 -0
- package/src/core/opc/index.d.ts +8 -0
- package/src/core/opc/index.js +4 -0
- package/src/core/opc/package.d.ts +49 -0
- package/src/core/opc/package.js +324 -0
- package/src/core/opc/part-name.d.ts +47 -0
- package/src/core/opc/part-name.js +205 -0
- package/src/core/opc/relationships.d.ts +46 -0
- package/src/core/opc/relationships.js +212 -0
- package/src/core/preservation/index.d.ts +2 -0
- package/src/core/preservation/index.js +1 -0
- package/src/core/preservation/opaque-body.d.ts +16 -0
- package/src/core/preservation/opaque-body.js +69 -0
- package/src/core/registry/block-handlers.d.ts +30 -0
- package/src/core/registry/block-handlers.js +36 -0
- package/src/core/registry/create-defaults.d.ts +39 -0
- package/src/core/registry/create-defaults.js +42 -0
- package/src/core/registry/feature-registry.d.ts +20 -0
- package/src/core/registry/feature-registry.js +29 -0
- package/src/core/registry/index.d.ts +9 -0
- package/src/core/registry/index.js +8 -0
- package/src/core/registry/inline-handlers.d.ts +20 -0
- package/src/core/registry/inline-handlers.js +30 -0
- package/src/core/registry/materialize-handlers.d.ts +35 -0
- package/src/core/registry/materialize-handlers.js +75 -0
- package/src/core/registry/multi-part-handlers.d.ts +37 -0
- package/src/core/registry/multi-part-handlers.js +206 -0
- package/src/core/registry/package-part-handlers.d.ts +28 -0
- package/src/core/registry/package-part-handlers.js +190 -0
- package/src/core/registry/part-handlers.d.ts +24 -0
- package/src/core/registry/part-handlers.js +172 -0
- package/src/core/registry/run-leaf-handlers.d.ts +26 -0
- package/src/core/registry/run-leaf-handlers.js +72 -0
- package/src/core/security/limits.d.ts +40 -0
- package/src/core/security/limits.js +26 -0
- package/src/core/xml/index.d.ts +7 -0
- package/src/core/xml/index.js +3 -0
- package/src/core/xml/model.d.ts +66 -0
- package/src/core/xml/model.js +17 -0
- package/src/core/xml/parse.d.ts +12 -0
- package/src/core/xml/parse.js +382 -0
- package/src/core/xml/serialize.d.ts +6 -0
- package/src/core/xml/serialize.js +93 -0
- package/src/core/zip/crc32.d.ts +2 -0
- package/src/core/zip/crc32.js +25 -0
- package/src/core/zip/deflate.d.ts +6 -0
- package/src/core/zip/deflate.js +6 -0
- package/src/core/zip/index.d.ts +10 -0
- package/src/core/zip/index.js +4 -0
- package/src/core/zip/inflate-raw.d.ts +17 -0
- package/src/core/zip/inflate-raw.js +450 -0
- package/src/core/zip/names.d.ts +6 -0
- package/src/core/zip/names.js +52 -0
- package/src/core/zip/read.d.ts +8 -0
- package/src/core/zip/read.js +262 -0
- package/src/core/zip/write.d.ts +7 -0
- package/src/core/zip/write.js +189 -0
- package/src/core/zip/zip-entry.d.ts +4 -0
- package/src/core/zip/zip-entry.js +0 -0
- package/src/features/bibliography/index.d.ts +100 -0
- package/src/features/bibliography/index.js +290 -0
- package/src/features/bookmarks/index.d.ts +331 -0
- package/src/features/bookmarks/index.js +1009 -0
- package/src/features/comments/comment-extensions.d.ts +157 -0
- package/src/features/comments/comment-extensions.js +356 -0
- package/src/features/comments/index.d.ts +579 -0
- package/src/features/comments/index.js +1727 -0
- package/src/features/content-controls/index.d.ts +821 -0
- package/src/features/content-controls/index.js +2857 -0
- package/src/features/custom-xml/index.d.ts +236 -0
- package/src/features/custom-xml/index.js +661 -0
- package/src/features/document/alignment.d.ts +23 -0
- package/src/features/document/alignment.js +36 -0
- package/src/features/document/alt-chunk.d.ts +103 -0
- package/src/features/document/alt-chunk.js +221 -0
- package/src/features/document/assert-never.d.ts +1 -0
- package/src/features/document/assert-never.js +4 -0
- package/src/features/document/augmentations.d.ts +578 -0
- package/src/features/document/augmentations.js +0 -0
- package/src/features/document/body-always-on.d.ts +36 -0
- package/src/features/document/body-always-on.js +66 -0
- package/src/features/document/body-blocks.d.ts +7 -0
- package/src/features/document/body-blocks.js +78 -0
- package/src/features/document/body-item-adapters.d.ts +62 -0
- package/src/features/document/body-item-adapters.js +97 -0
- package/src/features/document/body-item-collection.d.ts +151 -0
- package/src/features/document/body-item-collection.js +440 -0
- package/src/features/document/body-item.d.ts +35 -0
- package/src/features/document/body-item.js +8 -0
- package/src/features/document/body.d.ts +150 -0
- package/src/features/document/body.js +263 -0
- package/src/features/document/character-format.d.ts +413 -0
- package/src/features/document/character-format.js +2054 -0
- package/src/features/document/color.d.ts +178 -0
- package/src/features/document/color.js +495 -0
- package/src/features/document/document.d.ts +410 -0
- package/src/features/document/document.js +1049 -0
- package/src/features/document/element-type.d.ts +68 -0
- package/src/features/document/element-type.js +133 -0
- package/src/features/document/entity-type.d.ts +92 -0
- package/src/features/document/entity-type.js +93 -0
- package/src/features/document/feature-block.d.ts +16 -0
- package/src/features/document/feature-block.js +0 -0
- package/src/features/document/feature-inline.d.ts +13 -0
- package/src/features/document/feature-inline.js +0 -0
- package/src/features/document/feature-multi-package-part.d.ts +19 -0
- package/src/features/document/feature-multi-package-part.js +8 -0
- package/src/features/document/feature-package-level-part.d.ts +18 -0
- package/src/features/document/feature-package-level-part.js +8 -0
- package/src/features/document/feature-package-part.d.ts +14 -0
- package/src/features/document/feature-package-part.js +0 -0
- package/src/features/document/feature-run-leaf.d.ts +9 -0
- package/src/features/document/feature-run-leaf.js +0 -0
- package/src/features/document/headers-footers.d.ts +206 -0
- package/src/features/document/headers-footers.js +384 -0
- package/src/features/document/index.d.ts +41 -0
- package/src/features/document/index.js +34 -0
- package/src/features/document/length.d.ts +152 -0
- package/src/features/document/length.js +245 -0
- package/src/features/document/load-options.d.ts +14 -0
- package/src/features/document/load-options.js +0 -0
- package/src/features/document/locale-ids.d.ts +227 -0
- package/src/features/document/locale-ids.js +485 -0
- package/src/features/document/on-off.d.ts +9 -0
- package/src/features/document/on-off.js +27 -0
- package/src/features/document/page-setup.d.ts +339 -0
- package/src/features/document/page-setup.js +244 -0
- package/src/features/document/paragraph-format.d.ts +880 -0
- package/src/features/document/paragraph-format.js +2807 -0
- package/src/features/document/paragraph-item-collection.d.ts +162 -0
- package/src/features/document/paragraph-item-collection.js +363 -0
- package/src/features/document/paragraph-item.d.ts +83 -0
- package/src/features/document/paragraph-item.js +103 -0
- package/src/features/document/paragraph.d.ts +435 -0
- package/src/features/document/paragraph.js +888 -0
- package/src/features/document/run.d.ts +1 -0
- package/src/features/document/run.js +768 -0
- package/src/features/document/section-partition-flatten.d.ts +124 -0
- package/src/features/document/section-partition-flatten.js +217 -0
- package/src/features/document/section-properties-model.d.ts +13 -0
- package/src/features/document/section-properties-model.js +0 -0
- package/src/features/document/section.d.ts +93 -0
- package/src/features/document/section.js +178 -0
- package/src/features/document/sections.d.ts +103 -0
- package/src/features/document/sections.js +217 -0
- package/src/features/document/sub-super-script.d.ts +23 -0
- package/src/features/document/sub-super-script.js +43 -0
- package/src/features/document/text-range.d.ts +445 -0
- package/src/features/document/text-range.js +1156 -0
- package/src/features/document/typed-body-collections.d.ts +162 -0
- package/src/features/document/typed-body-collections.js +371 -0
- package/src/features/document/underline-style.d.ts +38 -0
- package/src/features/document/underline-style.js +126 -0
- package/src/features/document/units.d.ts +8 -0
- package/src/features/document/units.js +7 -0
- package/src/features/document/wml.d.ts +16 -0
- package/src/features/document/wml.js +67 -0
- package/src/features/drawing/authoring.d.ts +27 -0
- package/src/features/drawing/authoring.js +271 -0
- package/src/features/drawing/body-pr.d.ts +271 -0
- package/src/features/drawing/body-pr.js +663 -0
- package/src/features/drawing/drawing-shape.d.ts +1192 -0
- package/src/features/drawing/drawing-shape.js +3239 -0
- package/src/features/drawing/encode-builders.d.ts +176 -0
- package/src/features/drawing/encode-builders.js +390 -0
- package/src/features/drawing/fill-format.d.ts +52 -0
- package/src/features/drawing/fill-format.js +124 -0
- package/src/features/drawing/host-codec.d.ts +632 -0
- package/src/features/drawing/host-codec.js +2595 -0
- package/src/features/drawing/index.d.ts +13 -0
- package/src/features/drawing/index.js +33 -0
- package/src/features/drawing/line-format.d.ts +76 -0
- package/src/features/drawing/line-format.js +343 -0
- package/src/features/drawing/parse-register.d.ts +50 -0
- package/src/features/drawing/parse-register.js +257 -0
- package/src/features/drawing/residual-utils.d.ts +47 -0
- package/src/features/drawing/residual-utils.js +290 -0
- package/src/features/drawing/shape-types.d.ts +433 -0
- package/src/features/drawing/shape-types.js +437 -0
- package/src/features/drawing/sp-pr.d.ts +396 -0
- package/src/features/drawing/sp-pr.js +610 -0
- package/src/features/drawing/text-frame.d.ts +90 -0
- package/src/features/drawing/text-frame.js +152 -0
- package/src/features/drawing/types.d.ts +352 -0
- package/src/features/drawing/types.js +60 -0
- package/src/features/drawing/wrap-format.d.ts +62 -0
- package/src/features/drawing/wrap-format.js +114 -0
- package/src/features/editable-ranges/index.d.ts +494 -0
- package/src/features/editable-ranges/index.js +1348 -0
- package/src/features/fields/index.d.ts +428 -0
- package/src/features/fields/index.js +2148 -0
- package/src/features/fields/paragraph-field.d.ts +187 -0
- package/src/features/fields/paragraph-field.js +692 -0
- package/src/features/font-table/font-substitution-table.d.ts +75 -0
- package/src/features/font-table/font-substitution-table.js +257 -0
- package/src/features/font-table/font-table-entry.d.ts +255 -0
- package/src/features/font-table/font-table-entry.js +823 -0
- package/src/features/font-table/font-table.d.ts +128 -0
- package/src/features/font-table/font-table.js +313 -0
- package/src/features/font-table/index.d.ts +27 -0
- package/src/features/font-table/index.js +48 -0
- package/src/features/glossary/index.d.ts +97 -0
- package/src/features/glossary/index.js +286 -0
- package/src/features/headers-footers/index.d.ts +506 -0
- package/src/features/headers-footers/index.js +1666 -0
- package/src/features/hyperlinks/index.d.ts +230 -0
- package/src/features/hyperlinks/index.js +685 -0
- package/src/features/images/caption-authoring-api.d.ts +33 -0
- package/src/features/images/caption-authoring-api.js +33 -0
- package/src/features/images/caption-enums.d.ts +52 -0
- package/src/features/images/caption-enums.js +141 -0
- package/src/features/images/caption-host.d.ts +10 -0
- package/src/features/images/caption-host.js +21 -0
- package/src/features/images/captions.d.ts +13 -0
- package/src/features/images/captions.js +142 -0
- package/src/features/images/host-codec.d.ts +103 -0
- package/src/features/images/host-codec.js +720 -0
- package/src/features/images/image-sniff.d.ts +21 -0
- package/src/features/images/image-sniff.js +71 -0
- package/src/features/images/index.d.ts +506 -0
- package/src/features/images/index.js +1429 -0
- package/src/features/images/layout-types.d.ts +232 -0
- package/src/features/images/layout-types.js +294 -0
- package/src/features/images/public-entry.d.ts +9 -0
- package/src/features/images/public-entry.js +9 -0
- package/src/features/index.d.ts +35 -0
- package/src/features/index.js +36 -0
- package/src/features/mail-merge/index.d.ts +113 -0
- package/src/features/mail-merge/index.js +315 -0
- package/src/features/notes/index.d.ts +573 -0
- package/src/features/notes/index.js +1725 -0
- package/src/features/numbering/abstract-numbering.d.ts +90 -0
- package/src/features/numbering/abstract-numbering.js +292 -0
- package/src/features/numbering/index.d.ts +182 -0
- package/src/features/numbering/index.js +668 -0
- package/src/features/numbering/list-format.d.ts +158 -0
- package/src/features/numbering/list-format.js +590 -0
- package/src/features/numbering/list-string.d.ts +7 -0
- package/src/features/numbering/list-string.js +423 -0
- package/src/features/numbering/list-style.d.ts +204 -0
- package/src/features/numbering/list-style.js +1084 -0
- package/src/features/numbering/numbering-instance.d.ts +101 -0
- package/src/features/numbering/numbering-instance.js +329 -0
- package/src/features/numbering/numbering-level.d.ts +118 -0
- package/src/features/numbering/numbering-level.js +501 -0
- package/src/features/numbering/picture-bullet.d.ts +34 -0
- package/src/features/numbering/picture-bullet.js +88 -0
- package/src/features/ole-object/catalog.d.ts +300 -0
- package/src/features/ole-object/catalog.js +908 -0
- package/src/features/ole-object/index.d.ts +526 -0
- package/src/features/ole-object/index.js +1421 -0
- package/src/features/ole-object/relationship.d.ts +27 -0
- package/src/features/ole-object/relationship.js +27 -0
- package/src/features/ole-object/typed-dom.d.ts +186 -0
- package/src/features/ole-object/typed-dom.js +595 -0
- package/src/features/properties/index.d.ts +205 -0
- package/src/features/properties/index.js +549 -0
- package/src/features/revisions/index.d.ts +204 -0
- package/src/features/revisions/index.js +695 -0
- package/src/features/sections/column-collection.d.ts +119 -0
- package/src/features/sections/column-collection.js +478 -0
- package/src/features/sections/column.d.ts +15 -0
- package/src/features/sections/column.js +37 -0
- package/src/features/sections/index.d.ts +91 -0
- package/src/features/sections/index.js +1096 -0
- package/src/features/sections/margins.d.ts +40 -0
- package/src/features/sections/margins.js +105 -0
- package/src/features/sections/page-number-style.d.ts +21 -0
- package/src/features/sections/page-number-style.js +62 -0
- package/src/features/sections/page-orientation.d.ts +10 -0
- package/src/features/sections/page-orientation.js +10 -0
- package/src/features/sections/page-setup.d.ts +435 -0
- package/src/features/sections/page-setup.js +1479 -0
- package/src/features/sections/page-size.d.ts +59 -0
- package/src/features/sections/page-size.js +68 -0
- package/src/features/sections/section-break-code.d.ts +27 -0
- package/src/features/sections/section-break-code.js +60 -0
- package/src/features/sections/section-document-association.d.ts +18 -0
- package/src/features/sections/section-document-association.js +31 -0
- package/src/features/sections/section-validation.d.ts +43 -0
- package/src/features/sections/section-validation.js +97 -0
- package/src/features/settings/attached-template.d.ts +35 -0
- package/src/features/settings/attached-template.js +98 -0
- package/src/features/settings/compat-settings.d.ts +216 -0
- package/src/features/settings/compat-settings.js +508 -0
- package/src/features/settings/document-background.d.ts +59 -0
- package/src/features/settings/document-background.js +131 -0
- package/src/features/settings/document-protection.d.ts +65 -0
- package/src/features/settings/document-protection.js +157 -0
- package/src/features/settings/document-settings-facades.d.ts +108 -0
- package/src/features/settings/document-settings-facades.js +312 -0
- package/src/features/settings/document-settings-values.d.ts +43 -0
- package/src/features/settings/document-settings-values.js +60 -0
- package/src/features/settings/footnote-properties.d.ts +211 -0
- package/src/features/settings/footnote-properties.js +591 -0
- package/src/features/settings/index.d.ts +356 -0
- package/src/features/settings/index.js +829 -0
- package/src/features/settings/settings-children.d.ts +151 -0
- package/src/features/settings/settings-children.js +505 -0
- package/src/features/settings/web-settings.d.ts +88 -0
- package/src/features/settings/web-settings.js +227 -0
- package/src/features/settings/zoom.d.ts +79 -0
- package/src/features/settings/zoom.js +147 -0
- package/src/features/styles/builtin-catalog.d.ts +159 -0
- package/src/features/styles/builtin-catalog.js +963 -0
- package/src/features/styles/builtin-resolver.d.ts +49 -0
- package/src/features/styles/builtin-resolver.js +165 -0
- package/src/features/styles/default-styles.d.ts +37 -0
- package/src/features/styles/default-styles.js +186 -0
- package/src/features/styles/default-theme.d.ts +13 -0
- package/src/features/styles/default-theme.js +13 -0
- package/src/features/styles/doc-defaults.d.ts +58 -0
- package/src/features/styles/doc-defaults.js +178 -0
- package/src/features/styles/formatting-resolver.d.ts +27 -0
- package/src/features/styles/formatting-resolver.js +72 -0
- package/src/features/styles/index.d.ts +256 -0
- package/src/features/styles/index.js +1325 -0
- package/src/features/styles/latent-styles.d.ts +68 -0
- package/src/features/styles/latent-styles.js +305 -0
- package/src/features/styles/paragraph-properties.d.ts +71 -0
- package/src/features/styles/paragraph-properties.js +237 -0
- package/src/features/styles/run-properties.d.ts +93 -0
- package/src/features/styles/run-properties.js +516 -0
- package/src/features/styles/style-base.d.ts +402 -0
- package/src/features/styles/style-base.js +1026 -0
- package/src/features/styles/style-collection.d.ts +264 -0
- package/src/features/styles/style-collection.js +714 -0
- package/src/features/styles/style-format-bridge.d.ts +64 -0
- package/src/features/styles/style-format-bridge.js +100 -0
- package/src/features/styles/style.d.ts +84 -0
- package/src/features/styles/style.js +375 -0
- package/src/features/styles/styles-with-effects.d.ts +71 -0
- package/src/features/styles/styles-with-effects.js +180 -0
- package/src/features/styles/table-style.d.ts +272 -0
- package/src/features/styles/table-style.js +1226 -0
- package/src/features/styles/theme.d.ts +126 -0
- package/src/features/styles/theme.js +377 -0
- package/src/features/tables/border-style-map.d.ts +24 -0
- package/src/features/tables/border-style-map.js +81 -0
- package/src/features/tables/borders.d.ts +126 -0
- package/src/features/tables/borders.js +527 -0
- package/src/features/tables/collections.d.ts +113 -0
- package/src/features/tables/collections.js +261 -0
- package/src/features/tables/format.d.ts +208 -0
- package/src/features/tables/format.js +716 -0
- package/src/features/tables/index.d.ts +597 -0
- package/src/features/tables/index.js +2386 -0
- package/src/features/tables/paddings.d.ts +41 -0
- package/src/features/tables/paddings.js +97 -0
- package/src/features/tables/tbl-pr-positioning.d.ts +27 -0
- package/src/features/tables/tbl-pr-positioning.js +178 -0
- package/src/features/tables/tbl-pr.d.ts +528 -0
- package/src/features/tables/tbl-pr.js +1208 -0
- package/src/features/tables/tc-pr.d.ts +168 -0
- package/src/features/tables/tc-pr.js +553 -0
- package/src/features/tables/tr-pr.d.ts +60 -0
- package/src/features/tables/tr-pr.js +215 -0
- package/src/features/watermark/detect.d.ts +76 -0
- package/src/features/watermark/detect.js +219 -0
- package/src/features/watermark/index.d.ts +28 -0
- package/src/features/watermark/index.js +91 -0
- package/src/features/watermark/logical-store.d.ts +29 -0
- package/src/features/watermark/logical-store.js +31 -0
- package/src/features/watermark/model.d.ts +285 -0
- package/src/features/watermark/model.js +597 -0
- package/src/features/watermark/parse.d.ts +84 -0
- package/src/features/watermark/parse.js +815 -0
- package/src/features/watermark/serialize.d.ts +98 -0
- package/src/features/watermark/serialize.js +1517 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +2 -0
- package/src/index.js +2 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { OpenXmlElement } from '../xml/index';
|
|
2
|
+
import { ZipEntry } from '../zip/zip-entry';
|
|
3
|
+
/** OPC Media Types stream ZIP item name (ECMA-376-2 §7.3.7). */
|
|
4
|
+
export declare const CONTENT_TYPES_ZIP_ITEM = "[Content_Types].xml";
|
|
5
|
+
/** `opc-contentTypes.xsd` targetNamespace. */
|
|
6
|
+
export declare const CONTENT_TYPES_NAMESPACE = "http://schemas.openxmlformats.org/package/2006/content-types";
|
|
7
|
+
/** ECMA-376-1 §11.3.10 Main Document content type. */
|
|
8
|
+
export declare const MAIN_DOCUMENT_CONTENT_TYPE = "application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml";
|
|
9
|
+
/** ECMA-376-1 §11.2 example Default for relationship parts. */
|
|
10
|
+
export declare const RELATIONSHIPS_CONTENT_TYPE = "application/vnd.openxmlformats-package.relationships+xml";
|
|
11
|
+
export declare type ContentTypeRecord = {
|
|
12
|
+
readonly kind: 'default';
|
|
13
|
+
readonly extension: string;
|
|
14
|
+
readonly contentType: string;
|
|
15
|
+
} | {
|
|
16
|
+
readonly kind: 'override';
|
|
17
|
+
readonly partName: string;
|
|
18
|
+
readonly contentType: string;
|
|
19
|
+
} | {
|
|
20
|
+
readonly kind: 'opaque';
|
|
21
|
+
readonly xml: OpenXmlElement;
|
|
22
|
+
};
|
|
23
|
+
export interface ContentTypes {
|
|
24
|
+
readonly records: ReadonlyArray<ContentTypeRecord>;
|
|
25
|
+
}
|
|
26
|
+
export declare function parseContentTypesXml(xml: string): ContentTypes;
|
|
27
|
+
export declare function readContentTypes(entries: ReadonlyArray<ZipEntry>): ContentTypes;
|
|
28
|
+
/**
|
|
29
|
+
* Lookup as specified by OPC: Override by part name, else Default by extension.
|
|
30
|
+
* ECMA-376-2: order of Default/Override is not significant for lookup.
|
|
31
|
+
*/
|
|
32
|
+
export declare function lookupContentType(types: ContentTypes, logicalPartName: string): string | undefined;
|
|
33
|
+
export declare function createTransitionalContentTypes(mainDocumentPartName?: string): ContentTypes;
|
|
34
|
+
export declare function serializeContentTypes(types: ContentTypes): string;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __values = (this && this.__values) || function (o) {
|
|
2
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
3
|
+
if (m) return m.call(o);
|
|
4
|
+
return {
|
|
5
|
+
next: function () {
|
|
6
|
+
if (o && i >= o.length) o = void 0;
|
|
7
|
+
return { value: o && o[i++], done: !o };
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
import { PackageError } from '../errors/docx-error';
|
|
12
|
+
import { parseXml, serializeXml } from '../xml/index';
|
|
13
|
+
/** OPC Media Types stream ZIP item name (ECMA-376-2 §7.3.7). */
|
|
14
|
+
export var CONTENT_TYPES_ZIP_ITEM = '[Content_Types].xml';
|
|
15
|
+
/** `opc-contentTypes.xsd` targetNamespace. */
|
|
16
|
+
export var CONTENT_TYPES_NAMESPACE = 'http://schemas.openxmlformats.org/package/2006/content-types';
|
|
17
|
+
/** ECMA-376-1 §11.3.10 Main Document content type. */
|
|
18
|
+
export var MAIN_DOCUMENT_CONTENT_TYPE = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml';
|
|
19
|
+
/** ECMA-376-1 §11.2 example Default for relationship parts. */
|
|
20
|
+
export var RELATIONSHIPS_CONTENT_TYPE = 'application/vnd.openxmlformats-package.relationships+xml';
|
|
21
|
+
function isTypesElement(el) {
|
|
22
|
+
return el.localName === 'Types' && el.namespaceUri === CONTENT_TYPES_NAMESPACE;
|
|
23
|
+
}
|
|
24
|
+
function childElements(el) {
|
|
25
|
+
return el.children.filter(function (c) { return c.kind === 'element'; });
|
|
26
|
+
}
|
|
27
|
+
function requiredAttr(el, localName, what) {
|
|
28
|
+
var attr = el.attributes.find(function (a) { return a.localName === localName && a.namespaceUri === ''; });
|
|
29
|
+
if (attr === undefined || attr.value.length === 0) {
|
|
30
|
+
throw new PackageError('package/invalid-content-types', what + " is missing " + localName);
|
|
31
|
+
}
|
|
32
|
+
return attr.value;
|
|
33
|
+
}
|
|
34
|
+
export function parseContentTypesXml(xml) {
|
|
35
|
+
var e_1, _a;
|
|
36
|
+
var root = parseXml(xml);
|
|
37
|
+
if (!isTypesElement(root)) {
|
|
38
|
+
throw new PackageError('package/invalid-content-types', "Expected Types in " + CONTENT_TYPES_NAMESPACE + ", found {" + root.namespaceUri + "}" + root.localName);
|
|
39
|
+
}
|
|
40
|
+
var records = [];
|
|
41
|
+
try {
|
|
42
|
+
for (var _b = __values(childElements(root)), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
43
|
+
var child = _c.value;
|
|
44
|
+
if (child.namespaceUri !== CONTENT_TYPES_NAMESPACE) {
|
|
45
|
+
records.push({ kind: 'opaque', xml: child });
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
if (child.localName === 'Default') {
|
|
49
|
+
records.push({
|
|
50
|
+
kind: 'default',
|
|
51
|
+
extension: requiredAttr(child, 'Extension', 'Default'),
|
|
52
|
+
contentType: requiredAttr(child, 'ContentType', 'Default'),
|
|
53
|
+
});
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
if (child.localName === 'Override') {
|
|
57
|
+
records.push({
|
|
58
|
+
kind: 'override',
|
|
59
|
+
partName: requiredAttr(child, 'PartName', 'Override'),
|
|
60
|
+
contentType: requiredAttr(child, 'ContentType', 'Override'),
|
|
61
|
+
});
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
records.push({ kind: 'opaque', xml: child });
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
68
|
+
finally {
|
|
69
|
+
try {
|
|
70
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
71
|
+
}
|
|
72
|
+
finally { if (e_1) throw e_1.error; }
|
|
73
|
+
}
|
|
74
|
+
return { records: records };
|
|
75
|
+
}
|
|
76
|
+
export function readContentTypes(entries) {
|
|
77
|
+
var item = entries.find(function (e) { return e.name === CONTENT_TYPES_ZIP_ITEM; });
|
|
78
|
+
if (item === undefined) {
|
|
79
|
+
throw new PackageError('package/missing-part', "ZIP item " + CONTENT_TYPES_ZIP_ITEM + " is required (ECMA-376-2 \u00A77.3.7)");
|
|
80
|
+
}
|
|
81
|
+
return parseContentTypesXml(new TextDecoder('utf-8').decode(item.data));
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Lookup as specified by OPC: Override by part name, else Default by extension.
|
|
85
|
+
* ECMA-376-2: order of Default/Override is not significant for lookup.
|
|
86
|
+
*/
|
|
87
|
+
export function lookupContentType(types, logicalPartName) {
|
|
88
|
+
var override = types.records.find(function (r) { return r.kind === 'override' && r.partName === logicalPartName; });
|
|
89
|
+
// Classic guards: TS 3.3 does not narrow after `(x == null ? undefined : x.kind) === …`.
|
|
90
|
+
if (override !== undefined && override.kind === 'override') {
|
|
91
|
+
return override.contentType;
|
|
92
|
+
}
|
|
93
|
+
var slash = logicalPartName.lastIndexOf('/');
|
|
94
|
+
var fileName = slash === -1 ? logicalPartName : logicalPartName.slice(slash + 1);
|
|
95
|
+
var dot = fileName.lastIndexOf('.');
|
|
96
|
+
if (dot <= 0 || dot === fileName.length - 1) {
|
|
97
|
+
return undefined;
|
|
98
|
+
}
|
|
99
|
+
var extension = fileName.slice(dot + 1);
|
|
100
|
+
var def = types.records.find(function (r) { return r.kind === 'default' && r.extension.toLowerCase() === extension.toLowerCase(); });
|
|
101
|
+
if (def !== undefined && def.kind === 'default') {
|
|
102
|
+
return def.contentType;
|
|
103
|
+
}
|
|
104
|
+
return undefined;
|
|
105
|
+
}
|
|
106
|
+
export function createTransitionalContentTypes(mainDocumentPartName) {
|
|
107
|
+
if (mainDocumentPartName === void 0) { mainDocumentPartName = '/word/document.xml'; }
|
|
108
|
+
return {
|
|
109
|
+
records: [
|
|
110
|
+
{ kind: 'default', extension: 'rels', contentType: RELATIONSHIPS_CONTENT_TYPE },
|
|
111
|
+
{ kind: 'default', extension: 'xml', contentType: 'application/xml' },
|
|
112
|
+
{
|
|
113
|
+
kind: 'override',
|
|
114
|
+
partName: mainDocumentPartName,
|
|
115
|
+
contentType: MAIN_DOCUMENT_CONTENT_TYPE,
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export function serializeContentTypes(types) {
|
|
121
|
+
var children = types.records.map(function (record) {
|
|
122
|
+
if (record.kind === 'opaque') {
|
|
123
|
+
return record.xml;
|
|
124
|
+
}
|
|
125
|
+
if (record.kind === 'default') {
|
|
126
|
+
return {
|
|
127
|
+
kind: 'element',
|
|
128
|
+
namespaceUri: CONTENT_TYPES_NAMESPACE,
|
|
129
|
+
localName: 'Default',
|
|
130
|
+
prefix: '',
|
|
131
|
+
attributes: [
|
|
132
|
+
{ namespaceUri: '', localName: 'Extension', prefix: '', value: record.extension },
|
|
133
|
+
{ namespaceUri: '', localName: 'ContentType', prefix: '', value: record.contentType },
|
|
134
|
+
],
|
|
135
|
+
namespaceDeclarations: [],
|
|
136
|
+
children: [],
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
kind: 'element',
|
|
141
|
+
namespaceUri: CONTENT_TYPES_NAMESPACE,
|
|
142
|
+
localName: 'Override',
|
|
143
|
+
prefix: '',
|
|
144
|
+
attributes: [
|
|
145
|
+
{ namespaceUri: '', localName: 'PartName', prefix: '', value: record.partName },
|
|
146
|
+
{ namespaceUri: '', localName: 'ContentType', prefix: '', value: record.contentType },
|
|
147
|
+
],
|
|
148
|
+
namespaceDeclarations: [],
|
|
149
|
+
children: [],
|
|
150
|
+
};
|
|
151
|
+
});
|
|
152
|
+
var root = {
|
|
153
|
+
kind: 'element',
|
|
154
|
+
namespaceUri: CONTENT_TYPES_NAMESPACE,
|
|
155
|
+
localName: 'Types',
|
|
156
|
+
prefix: '',
|
|
157
|
+
attributes: [],
|
|
158
|
+
namespaceDeclarations: [{ prefix: '', namespaceUri: CONTENT_TYPES_NAMESPACE }],
|
|
159
|
+
children: children,
|
|
160
|
+
};
|
|
161
|
+
return serializeXml(root);
|
|
162
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { CONTENT_TYPES_NAMESPACE, CONTENT_TYPES_ZIP_ITEM, MAIN_DOCUMENT_CONTENT_TYPE, RELATIONSHIPS_CONTENT_TYPE, createTransitionalContentTypes, lookupContentType, parseContentTypesXml, readContentTypes, serializeContentTypes, } from './content-types';
|
|
2
|
+
export { ContentTypeRecord, ContentTypes } from './content-types';
|
|
3
|
+
export { assertPartNameSetIntegrity, isPackageRelationshipsPartName, isPartNameDerivableFrom, isRelationshipsPartName, packageRelationshipsPartName, partName, partNameFromZipItem, partNameKey, partNamesEquivalent, partRelationshipsPartName, resolveInternalTarget, sourcePartNameFromRelationshipsPart, zipItemFromPartName, } from './part-name';
|
|
4
|
+
export { PartName } from './part-name';
|
|
5
|
+
export { OFFICE_DOCUMENT_RELATIONSHIP_TYPE, RELATIONSHIPS_NAMESPACE, STRICT_OFFICE_DOCUMENT_RELATIONSHIP_TYPE, TargetMode, allocateRelationshipId, emptyRelationships, findOfficeDocumentRelationship, isOfficeDocumentRelationshipType, parseRelationshipsXml, relationshipId, relationshipsWith, serializeRelationships, } from './relationships';
|
|
6
|
+
export { OpcRelationship, RelationshipId, Relationships } from './relationships';
|
|
7
|
+
export { createTransitionalWordPackage, getExternalRelationshipTargets, loadOpcPackage, officeDocumentPartName, partByName, relationshipsForPart, saveOpcPackage, transitionalDocumentStubXml, withReplacedPart, withAddedPart, withContentTypeOverride, withPartRelationships, withPackageRelationships, } from './package';
|
|
8
|
+
export { OpcPackage, PackagePart, PartRelationshipSet } from './package';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { CONTENT_TYPES_NAMESPACE, CONTENT_TYPES_ZIP_ITEM, MAIN_DOCUMENT_CONTENT_TYPE, RELATIONSHIPS_CONTENT_TYPE, createTransitionalContentTypes, lookupContentType, parseContentTypesXml, readContentTypes, serializeContentTypes, } from './content-types';
|
|
2
|
+
export { assertPartNameSetIntegrity, isPackageRelationshipsPartName, isPartNameDerivableFrom, isRelationshipsPartName, packageRelationshipsPartName, partName, partNameFromZipItem, partNameKey, partNamesEquivalent, partRelationshipsPartName, resolveInternalTarget, sourcePartNameFromRelationshipsPart, zipItemFromPartName, } from './part-name';
|
|
3
|
+
export { OFFICE_DOCUMENT_RELATIONSHIP_TYPE, RELATIONSHIPS_NAMESPACE, STRICT_OFFICE_DOCUMENT_RELATIONSHIP_TYPE, TargetMode, allocateRelationshipId, emptyRelationships, findOfficeDocumentRelationship, isOfficeDocumentRelationshipType, parseRelationshipsXml, relationshipId, relationshipsWith, serializeRelationships, } from './relationships';
|
|
4
|
+
export { createTransitionalWordPackage, getExternalRelationshipTargets, loadOpcPackage, officeDocumentPartName, partByName, relationshipsForPart, saveOpcPackage, transitionalDocumentStubXml, withReplacedPart, withAddedPart, withContentTypeOverride, withPartRelationships, withPackageRelationships, } from './package';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ResourceLimitOverrides } from '../security/limits';
|
|
2
|
+
import { ContentTypes } from './content-types';
|
|
3
|
+
import { PartName } from './part-name';
|
|
4
|
+
import { OpcRelationship, Relationships } from './relationships';
|
|
5
|
+
export interface PackagePart {
|
|
6
|
+
readonly name: PartName;
|
|
7
|
+
readonly contentType: string;
|
|
8
|
+
readonly data: Uint8Array;
|
|
9
|
+
}
|
|
10
|
+
export interface PartRelationshipSet {
|
|
11
|
+
readonly source: PartName;
|
|
12
|
+
readonly relationships: Relationships;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* In-memory OPC package (ZIP + content types + relationships + part payloads).
|
|
16
|
+
* Not the public WordDocument API (TASK-1010).
|
|
17
|
+
*/
|
|
18
|
+
export interface OpcPackage {
|
|
19
|
+
readonly contentTypes: ContentTypes;
|
|
20
|
+
readonly packageRelationships: Relationships;
|
|
21
|
+
readonly parts: ReadonlyArray<PackagePart>;
|
|
22
|
+
readonly partRelationships: ReadonlyArray<PartRelationshipSet>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Stub Transitional main document payload. Not a WML parser (TASK-1005 out of scope).
|
|
26
|
+
*/
|
|
27
|
+
export declare function transitionalDocumentStubXml(): string;
|
|
28
|
+
export declare function createTransitionalWordPackage(options?: {
|
|
29
|
+
readonly documentXml?: Uint8Array;
|
|
30
|
+
readonly extraParts?: ReadonlyArray<PackagePart>;
|
|
31
|
+
readonly extraPackageRelationships?: ReadonlyArray<OpcRelationship>;
|
|
32
|
+
}): OpcPackage;
|
|
33
|
+
export declare function officeDocumentPartName(pkg: OpcPackage): PartName;
|
|
34
|
+
export declare function loadOpcPackage(bytes: Uint8Array, limits?: ResourceLimitOverrides): OpcPackage;
|
|
35
|
+
/**
|
|
36
|
+
* External TargetMode values are stored only. This module never calls fetch or
|
|
37
|
+
* opens a network/filesystem URI (`.agent/policies/security.md`).
|
|
38
|
+
*/
|
|
39
|
+
export declare function getExternalRelationshipTargets(pkg: OpcPackage): ReadonlyArray<string>;
|
|
40
|
+
export declare function saveOpcPackage(pkg: OpcPackage): Uint8Array;
|
|
41
|
+
export declare function partByName(pkg: OpcPackage, name: PartName): PackagePart | undefined;
|
|
42
|
+
export declare function relationshipsForPart(pkg: OpcPackage, source: PartName): Relationships;
|
|
43
|
+
/** Replace one part's payload, keeping content type and other parts. */
|
|
44
|
+
export declare function withReplacedPart(pkg: OpcPackage, name: PartName, data: Uint8Array): OpcPackage;
|
|
45
|
+
/** Append a part if absent; replace payload if the name already exists. */
|
|
46
|
+
export declare function withAddedPart(pkg: OpcPackage, part: PackagePart): OpcPackage;
|
|
47
|
+
export declare function withContentTypeOverride(pkg: OpcPackage, logicalPartName: PartName, contentType: string): OpcPackage;
|
|
48
|
+
export declare function withPartRelationships(pkg: OpcPackage, source: PartName, relationships: Relationships): OpcPackage;
|
|
49
|
+
export declare function withPackageRelationships(pkg: OpcPackage, relationships: Relationships): OpcPackage;
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __read = (this && this.__read) || function (o, n) {
|
|
13
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
14
|
+
if (!m) return o;
|
|
15
|
+
var i = m.call(o), r, ar = [], e;
|
|
16
|
+
try {
|
|
17
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
18
|
+
}
|
|
19
|
+
catch (error) { e = { error: error }; }
|
|
20
|
+
finally {
|
|
21
|
+
try {
|
|
22
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
23
|
+
}
|
|
24
|
+
finally { if (e) throw e.error; }
|
|
25
|
+
}
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
var __spread = (this && this.__spread) || function () {
|
|
29
|
+
for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
var __values = (this && this.__values) || function (o) {
|
|
33
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
34
|
+
if (m) return m.call(o);
|
|
35
|
+
return {
|
|
36
|
+
next: function () {
|
|
37
|
+
if (o && i >= o.length) o = void 0;
|
|
38
|
+
return { value: o && o[i++], done: !o };
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
import { PackageError } from '../errors/docx-error';
|
|
43
|
+
import { resolveResourceLimits } from '../security/limits';
|
|
44
|
+
import { WML_TRANSITIONAL_NAMESPACE } from '../xml/index';
|
|
45
|
+
import { readZip } from '../zip/read';
|
|
46
|
+
import { writeZip } from '../zip/write';
|
|
47
|
+
import { CONTENT_TYPES_ZIP_ITEM, createTransitionalContentTypes, lookupContentType, MAIN_DOCUMENT_CONTENT_TYPE, readContentTypes, serializeContentTypes } from './content-types';
|
|
48
|
+
import { assertPartNameSetIntegrity, isPackageRelationshipsPartName, isRelationshipsPartName, packageRelationshipsPartName, partName, partNameFromZipItem, partNameKey, partRelationshipsPartName, resolveInternalTarget, sourcePartNameFromRelationshipsPart, zipItemFromPartName } from './part-name';
|
|
49
|
+
import { emptyRelationships, findOfficeDocumentRelationship, OFFICE_DOCUMENT_RELATIONSHIP_TYPE, parseRelationshipsXml, relationshipId, relationshipsWith, serializeRelationships, TargetMode } from './relationships';
|
|
50
|
+
var utf8 = new TextEncoder();
|
|
51
|
+
var utf8Decoder = new TextDecoder('utf-8');
|
|
52
|
+
function bytesOf(xml) {
|
|
53
|
+
return utf8.encode(xml);
|
|
54
|
+
}
|
|
55
|
+
function decodeXml(data) {
|
|
56
|
+
return utf8Decoder.decode(data);
|
|
57
|
+
}
|
|
58
|
+
function findPart(parts, name) {
|
|
59
|
+
var key = partNameKey(name);
|
|
60
|
+
return parts.find(function (part) { return partNameKey(part.name) === key; });
|
|
61
|
+
}
|
|
62
|
+
function findPartRels(sets, source) {
|
|
63
|
+
var __ts33_0;
|
|
64
|
+
var key = partNameKey(source);
|
|
65
|
+
return ((__ts33_0 = sets.find(function (set) { return partNameKey(set.source) === key; })), __ts33_0 == null ? undefined : __ts33_0.relationships);
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Stub Transitional main document payload. Not a WML parser (TASK-1005 out of scope).
|
|
69
|
+
*/
|
|
70
|
+
export function transitionalDocumentStubXml() {
|
|
71
|
+
return ("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>" +
|
|
72
|
+
("<w:document xmlns:w=\"" + WML_TRANSITIONAL_NAMESPACE + "\"><w:body/></w:document>"));
|
|
73
|
+
}
|
|
74
|
+
export function createTransitionalWordPackage(options) {
|
|
75
|
+
var __ts33_1, __ts33_2, __ts33_3;
|
|
76
|
+
var main = partName('/word/document.xml');
|
|
77
|
+
var documentXml = ((__ts33_1 = options == null ? undefined : options.documentXml), __ts33_1 != null ? __ts33_1 : bytesOf(transitionalDocumentStubXml()));
|
|
78
|
+
var officeRel = {
|
|
79
|
+
id: relationshipId('rId1'),
|
|
80
|
+
type: OFFICE_DOCUMENT_RELATIONSHIP_TYPE,
|
|
81
|
+
target: 'word/document.xml',
|
|
82
|
+
extraAttributes: [],
|
|
83
|
+
children: [],
|
|
84
|
+
};
|
|
85
|
+
var extra = ((__ts33_2 = options == null ? undefined : options.extraPackageRelationships), __ts33_2 != null ? __ts33_2 : []);
|
|
86
|
+
var packageRelationships = relationshipsWith(__spread([officeRel], extra));
|
|
87
|
+
var extraParts = ((__ts33_3 = options == null ? undefined : options.extraParts), __ts33_3 != null ? __ts33_3 : []);
|
|
88
|
+
var parts = __spread([
|
|
89
|
+
{ name: main, contentType: MAIN_DOCUMENT_CONTENT_TYPE, data: documentXml }
|
|
90
|
+
], extraParts);
|
|
91
|
+
assertPartNameSetIntegrity(parts.map(function (p) { return p.name; }));
|
|
92
|
+
return {
|
|
93
|
+
contentTypes: createTransitionalContentTypes(main),
|
|
94
|
+
packageRelationships: packageRelationships,
|
|
95
|
+
parts: parts,
|
|
96
|
+
partRelationships: [],
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export function officeDocumentPartName(pkg) {
|
|
100
|
+
var rel = findOfficeDocumentRelationship(pkg.packageRelationships);
|
|
101
|
+
if (rel === undefined) {
|
|
102
|
+
throw new PackageError('package/missing-part', 'Package Relationships part has no officeDocument relationship (ECMA-376-1 §11.2)');
|
|
103
|
+
}
|
|
104
|
+
if (rel.targetMode === TargetMode.External) {
|
|
105
|
+
throw new PackageError('package/missing-part', 'officeDocument relationship must not use TargetMode External');
|
|
106
|
+
}
|
|
107
|
+
return resolveInternalTarget(rel.target);
|
|
108
|
+
}
|
|
109
|
+
function parseRelsEntry(data, sourceLabel, relationshipCountLimit) {
|
|
110
|
+
return parseRelationshipsXml(decodeXml(data), { sourceLabel: sourceLabel, relationshipCountLimit: relationshipCountLimit });
|
|
111
|
+
}
|
|
112
|
+
export function loadOpcPackage(bytes, limits) {
|
|
113
|
+
var e_1, _a;
|
|
114
|
+
var __ts33_4;
|
|
115
|
+
var resolved = resolveResourceLimits(limits);
|
|
116
|
+
var entries = readZip(bytes, limits);
|
|
117
|
+
var contentTypes = readContentTypes(entries);
|
|
118
|
+
var parts = [];
|
|
119
|
+
var packageRelationships;
|
|
120
|
+
var partRelationships = [];
|
|
121
|
+
try {
|
|
122
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
123
|
+
var entry = entries_1_1.value;
|
|
124
|
+
if (entry.name === CONTENT_TYPES_ZIP_ITEM) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
// ZIP directory markers (name ends with '/') are not OPC parts
|
|
128
|
+
// (ECMA-376-2 §6.2.2.2 part_name has no trailing slash; ECMA-376-1:
|
|
129
|
+
// ZIP items that do not conform to OPC part naming are not parts).
|
|
130
|
+
if (entry.name.endsWith('/')) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
var logical = partNameFromZipItem(entry.name);
|
|
134
|
+
if (isRelationshipsPartName(logical)) {
|
|
135
|
+
var rels = parseRelsEntry(entry.data, entry.name, resolved.relationshipCountPerPart);
|
|
136
|
+
if (isPackageRelationshipsPartName(logical)) {
|
|
137
|
+
packageRelationships = rels;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
var source = sourcePartNameFromRelationshipsPart(logical);
|
|
141
|
+
if (source === undefined) {
|
|
142
|
+
throw new PackageError('package/invalid-relationships', "Could not invert Relationships part " + logical);
|
|
143
|
+
}
|
|
144
|
+
partRelationships.push({ source: source, relationships: rels });
|
|
145
|
+
}
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
var contentType = ((__ts33_4 = lookupContentType(contentTypes, logical)), __ts33_4 != null ? __ts33_4 : 'application/octet-stream');
|
|
149
|
+
parts.push({ name: logical, contentType: contentType, data: entry.data });
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
153
|
+
finally {
|
|
154
|
+
try {
|
|
155
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
156
|
+
}
|
|
157
|
+
finally { if (e_1) throw e_1.error; }
|
|
158
|
+
}
|
|
159
|
+
if (packageRelationships === undefined) {
|
|
160
|
+
throw new PackageError('package/missing-part', "Missing package Relationships part " + zipItemFromPartName(packageRelationshipsPartName()));
|
|
161
|
+
}
|
|
162
|
+
assertPartNameSetIntegrity(parts.map(function (p) { return p.name; }));
|
|
163
|
+
var pkg = {
|
|
164
|
+
contentTypes: contentTypes,
|
|
165
|
+
packageRelationships: packageRelationships,
|
|
166
|
+
parts: parts,
|
|
167
|
+
partRelationships: partRelationships,
|
|
168
|
+
};
|
|
169
|
+
var mainName = officeDocumentPartName(pkg);
|
|
170
|
+
if (findPart(parts, mainName) === undefined) {
|
|
171
|
+
throw new PackageError('package/missing-part', "officeDocument target part " + mainName + " is not in the package");
|
|
172
|
+
}
|
|
173
|
+
return pkg;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* External TargetMode values are stored only. This module never calls fetch or
|
|
177
|
+
* opens a network/filesystem URI (`.agent/policies/security.md`).
|
|
178
|
+
*/
|
|
179
|
+
export function getExternalRelationshipTargets(pkg) {
|
|
180
|
+
var e_2, _a;
|
|
181
|
+
var targets = [];
|
|
182
|
+
var collect = function (rels) {
|
|
183
|
+
var e_3, _a;
|
|
184
|
+
try {
|
|
185
|
+
for (var _b = __values(rels.items), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
186
|
+
var item = _c.value;
|
|
187
|
+
if (item.targetMode === TargetMode.External) {
|
|
188
|
+
targets.push(item.target);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
193
|
+
finally {
|
|
194
|
+
try {
|
|
195
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
196
|
+
}
|
|
197
|
+
finally { if (e_3) throw e_3.error; }
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
collect(pkg.packageRelationships);
|
|
201
|
+
try {
|
|
202
|
+
for (var _b = __values(pkg.partRelationships), _c = _b.next(); !_c.done; _c = _b.next()) {
|
|
203
|
+
var set = _c.value;
|
|
204
|
+
collect(set.relationships);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
208
|
+
finally {
|
|
209
|
+
try {
|
|
210
|
+
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
|
211
|
+
}
|
|
212
|
+
finally { if (e_2) throw e_2.error; }
|
|
213
|
+
}
|
|
214
|
+
return targets;
|
|
215
|
+
}
|
|
216
|
+
export function saveOpcPackage(pkg) {
|
|
217
|
+
var e_4, _a, e_5, _b;
|
|
218
|
+
officeDocumentPartName(pkg);
|
|
219
|
+
var entries = [
|
|
220
|
+
{ name: CONTENT_TYPES_ZIP_ITEM, data: bytesOf(serializeContentTypes(pkg.contentTypes)) },
|
|
221
|
+
{
|
|
222
|
+
name: zipItemFromPartName(packageRelationshipsPartName()),
|
|
223
|
+
data: bytesOf(serializeRelationships(pkg.packageRelationships)),
|
|
224
|
+
},
|
|
225
|
+
];
|
|
226
|
+
var seenZip = new Set(entries.map(function (e) { return e.name.toLowerCase(); }));
|
|
227
|
+
var push = function (name, data) {
|
|
228
|
+
var key = name.toLowerCase();
|
|
229
|
+
if (seenZip.has(key)) {
|
|
230
|
+
throw new PackageError('package/duplicate-zip-entry', "Duplicate ZIP item on save: " + name);
|
|
231
|
+
}
|
|
232
|
+
seenZip.add(key);
|
|
233
|
+
entries.push({ name: name, data: data });
|
|
234
|
+
};
|
|
235
|
+
try {
|
|
236
|
+
for (var _c = __values(pkg.parts), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
237
|
+
var part = _d.value;
|
|
238
|
+
push(zipItemFromPartName(part.name), part.data);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
242
|
+
finally {
|
|
243
|
+
try {
|
|
244
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
245
|
+
}
|
|
246
|
+
finally { if (e_4) throw e_4.error; }
|
|
247
|
+
}
|
|
248
|
+
try {
|
|
249
|
+
for (var _e = __values(pkg.partRelationships), _f = _e.next(); !_f.done; _f = _e.next()) {
|
|
250
|
+
var set = _f.value;
|
|
251
|
+
if (set.relationships.items.length === 0 && set.relationships.opaque.length === 0) {
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
push(zipItemFromPartName(partRelationshipsPartName(set.source)), bytesOf(serializeRelationships(set.relationships)));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
258
|
+
finally {
|
|
259
|
+
try {
|
|
260
|
+
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
|
|
261
|
+
}
|
|
262
|
+
finally { if (e_5) throw e_5.error; }
|
|
263
|
+
}
|
|
264
|
+
return writeZip(entries);
|
|
265
|
+
}
|
|
266
|
+
export function partByName(pkg, name) {
|
|
267
|
+
return findPart(pkg.parts, name);
|
|
268
|
+
}
|
|
269
|
+
export function relationshipsForPart(pkg, source) {
|
|
270
|
+
var __ts33_5;
|
|
271
|
+
return ((__ts33_5 = findPartRels(pkg.partRelationships, source)), __ts33_5 != null ? __ts33_5 : emptyRelationships());
|
|
272
|
+
}
|
|
273
|
+
/** Replace one part's payload, keeping content type and other parts. */
|
|
274
|
+
export function withReplacedPart(pkg, name, data) {
|
|
275
|
+
var key = partNameKey(name);
|
|
276
|
+
var index = pkg.parts.findIndex(function (part) { return partNameKey(part.name) === key; });
|
|
277
|
+
if (index < 0) {
|
|
278
|
+
throw new PackageError('package/invalid-part-name', "Part not in package: " + name);
|
|
279
|
+
}
|
|
280
|
+
var parts = pkg.parts.map(function (part, i) { return i === index ? { name: part.name, contentType: part.contentType, data: data } : part; });
|
|
281
|
+
return __assign({}, pkg, { parts: parts });
|
|
282
|
+
}
|
|
283
|
+
function upsertPartRelationships(sets, source, relationships) {
|
|
284
|
+
var key = partNameKey(source);
|
|
285
|
+
var index = sets.findIndex(function (set) { return partNameKey(set.source) === key; });
|
|
286
|
+
if (index < 0) {
|
|
287
|
+
return __spread(sets, [{ source: source, relationships: relationships }]);
|
|
288
|
+
}
|
|
289
|
+
var next = __spread(sets);
|
|
290
|
+
next[index] = { source: source, relationships: relationships };
|
|
291
|
+
return next;
|
|
292
|
+
}
|
|
293
|
+
function upsertContentTypeOverride(types, logicalPartName, contentType) {
|
|
294
|
+
var records = types.records.map(function (record) {
|
|
295
|
+
if (record.kind === 'override' && record.partName === logicalPartName) {
|
|
296
|
+
return { kind: 'override', partName: logicalPartName, contentType: contentType };
|
|
297
|
+
}
|
|
298
|
+
return record;
|
|
299
|
+
});
|
|
300
|
+
if (!records.some(function (record) { return record.kind === 'override' && record.partName === logicalPartName; })) {
|
|
301
|
+
records.push({ kind: 'override', partName: logicalPartName, contentType: contentType });
|
|
302
|
+
}
|
|
303
|
+
return { records: records };
|
|
304
|
+
}
|
|
305
|
+
/** Append a part if absent; replace payload if the name already exists. */
|
|
306
|
+
export function withAddedPart(pkg, part) {
|
|
307
|
+
var key = partNameKey(part.name);
|
|
308
|
+
var index = pkg.parts.findIndex(function (existing) { return partNameKey(existing.name) === key; });
|
|
309
|
+
if (index >= 0) {
|
|
310
|
+
var parts_1 = pkg.parts.map(function (existing, i) { return (i === index ? part : existing); });
|
|
311
|
+
return __assign({}, pkg, { parts: parts_1 });
|
|
312
|
+
}
|
|
313
|
+
var parts = __spread(pkg.parts, [part]);
|
|
314
|
+
return __assign({}, pkg, { parts: parts });
|
|
315
|
+
}
|
|
316
|
+
export function withContentTypeOverride(pkg, logicalPartName, contentType) {
|
|
317
|
+
return __assign({}, pkg, { contentTypes: upsertContentTypeOverride(pkg.contentTypes, logicalPartName, contentType) });
|
|
318
|
+
}
|
|
319
|
+
export function withPartRelationships(pkg, source, relationships) {
|
|
320
|
+
return __assign({}, pkg, { partRelationships: upsertPartRelationships(pkg.partRelationships, source, relationships) });
|
|
321
|
+
}
|
|
322
|
+
export function withPackageRelationships(pkg, relationships) {
|
|
323
|
+
return __assign({}, pkg, { packageRelationships: relationships });
|
|
324
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OPC part name. Branded so it is not interchangeable with a ZIP item name or a
|
|
3
|
+
* relationship Target string (`.agent/policies/typescript.md`).
|
|
4
|
+
*/
|
|
5
|
+
export declare type PartName = string & {
|
|
6
|
+
readonly __brand: 'PartName';
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* ASCII case-insensitive part-name key (ECMA-376-2 §6.2.2.3).
|
|
10
|
+
*/
|
|
11
|
+
export declare function partNameKey(name: string): string;
|
|
12
|
+
/**
|
|
13
|
+
* Validates and brands an OPC logical part name (leading `/`).
|
|
14
|
+
* ECMA-376-2 §6.2.2.2 production `part_name = 1*( "/" isegment-nz )`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function partName(value: string): PartName;
|
|
17
|
+
/** ZIP item name → logical part name (ECMA-376-2 §7.3.5). */
|
|
18
|
+
export declare function partNameFromZipItem(zipItemName: string): PartName;
|
|
19
|
+
/** Logical part name → ZIP item name (no leading `/`). */
|
|
20
|
+
export declare function zipItemFromPartName(name: PartName): string;
|
|
21
|
+
export declare function partNamesEquivalent(left: string, right: string): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* True when `candidate` is derivable from `base` (ECMA-376-2 §6.2.2.3):
|
|
24
|
+
* concatenating `base`, `/`, and some string S yields an equivalent name.
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPartNameDerivableFrom(candidate: string, base: string): boolean;
|
|
27
|
+
export declare function assertPartNameSetIntegrity(names: ReadonlyArray<PartName>): void;
|
|
28
|
+
/**
|
|
29
|
+
* Relationships parts: `/_rels/.rels` and `…/_rels/….rels` (ECMA-376-2 §6.5.2.2–§6.5.2.3).
|
|
30
|
+
*/
|
|
31
|
+
export declare function isRelationshipsPartName(name: PartName): boolean;
|
|
32
|
+
export declare function isPackageRelationshipsPartName(name: PartName): boolean;
|
|
33
|
+
/** Package Relationships part name (ECMA-376-2 §6.5.2.2). */
|
|
34
|
+
export declare function packageRelationshipsPartName(): PartName;
|
|
35
|
+
/**
|
|
36
|
+
* Part Relationships part name from a source part (ECMA-376-2 §6.5.2.3).
|
|
37
|
+
*/
|
|
38
|
+
export declare function partRelationshipsPartName(source: PartName): PartName;
|
|
39
|
+
/**
|
|
40
|
+
* Inverse of {@link partRelationshipsPartName}. Package rels yield `undefined`.
|
|
41
|
+
*/
|
|
42
|
+
export declare function sourcePartNameFromRelationshipsPart(relsPart: PartName): PartName | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve an Internal relationship Target against a source part, or against the
|
|
45
|
+
* package when `source` is omitted (package Relationships).
|
|
46
|
+
*/
|
|
47
|
+
export declare function resolveInternalTarget(target: string, source?: PartName): PartName;
|