@web-ppt/edit-core 0.5.0-beta.1 → 0.5.0-beta.7
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 +188 -0
- package/README.md +165 -22
- package/dist/alt-text.d.ts +5 -0
- package/dist/appearance/index.d.ts +12 -0
- package/dist/appearance/materialize.d.ts +4 -0
- package/dist/appearance/types.d.ts +26 -0
- package/dist/appearance/values.d.ts +9 -0
- package/dist/appearance.js +301 -0
- package/dist/cfb/index.d.ts +5 -0
- package/dist/cfb/read.d.ts +16 -0
- package/dist/cfb/write.d.ts +3 -0
- package/dist/cfb.js +208 -0
- package/dist/change-classification.d.ts +3 -3
- package/dist/chart/category-binding.d.ts +4 -0
- package/dist/chart/category-commands.d.ts +23 -0
- package/dist/chart/category-levels.d.ts +14 -0
- package/dist/chart/category-matrix.d.ts +2 -0
- package/dist/chart/category-value.d.ts +2 -0
- package/dist/chart/category-workbook.d.ts +13 -0
- package/dist/chart/commands.d.ts +28 -0
- package/dist/chart/context.d.ts +12 -0
- package/dist/chart/dataset-merge.d.ts +5 -0
- package/dist/chart/formula.d.ts +13 -0
- package/dist/chart/identity-frames.d.ts +4 -0
- package/dist/chart/identity-scopes.d.ts +6 -0
- package/dist/chart/identity.d.ts +24 -0
- package/dist/chart/index.d.ts +8 -0
- package/dist/chart/limits.d.ts +6 -0
- package/dist/chart/locator.d.ts +4 -0
- package/dist/chart/materialize.d.ts +7 -0
- package/dist/chart/ordering.d.ts +9 -0
- package/dist/chart/part-graph.d.ts +5 -0
- package/dist/chart/patch-validation.d.ts +3 -0
- package/dist/chart/plot-kinds.d.ts +2 -0
- package/dist/chart/projection.d.ts +8 -0
- package/dist/chart/save.d.ts +4 -0
- package/dist/chart/shared-added-plan.d.ts +19 -0
- package/dist/chart/shared-added-records.d.ts +8 -0
- package/dist/chart/shared-address.d.ts +5 -0
- package/dist/chart/shared-allocate.d.ts +7 -0
- package/dist/chart/shared-cache-codec.d.ts +5 -0
- package/dist/chart/shared-cache-identities.d.ts +3 -0
- package/dist/chart/shared-cache-migration.d.ts +7 -0
- package/dist/chart/shared-cache-save.d.ts +3 -0
- package/dist/chart/shared-cache-scopes.d.ts +13 -0
- package/dist/chart/shared-cache.d.ts +11 -0
- package/dist/chart/shared-category.d.ts +4 -0
- package/dist/chart/shared-cell.d.ts +9 -0
- package/dist/chart/shared-family.d.ts +26 -0
- package/dist/chart/shared-fields.d.ts +18 -0
- package/dist/chart/shared-graph.d.ts +19 -0
- package/dist/chart/shared-growth-space.d.ts +5 -0
- package/dist/chart/shared-inserted-cells.d.ts +14 -0
- package/dist/chart/shared-inserted-command.d.ts +7 -0
- package/dist/chart/shared-inserted-layout.d.ts +16 -0
- package/dist/chart/shared-inserted-project.d.ts +14 -0
- package/dist/chart/shared-inserted-records.d.ts +16 -0
- package/dist/chart/shared-inserted-save.d.ts +6 -0
- package/dist/chart/shared-joint-command.d.ts +9 -0
- package/dist/chart/shared-joint-records.d.ts +9 -0
- package/dist/chart/shared-record-axis.d.ts +25 -0
- package/dist/chart/shared-record-remove.d.ts +13 -0
- package/dist/chart/shared-record-stage.d.ts +2 -0
- package/dist/chart/shared-records.d.ts +2 -0
- package/dist/chart/shared-rows.d.ts +17 -0
- package/dist/chart/shared-runtime.d.ts +19 -0
- package/dist/chart/shared-save-plan.d.ts +4 -0
- package/dist/chart/shared-save.d.ts +3 -0
- package/dist/chart/shared-series.d.ts +6 -0
- package/dist/chart/shared-source-cache.d.ts +4 -0
- package/dist/chart/shared-topology.d.ts +9 -0
- package/dist/chart/shared-unresolved.d.ts +3 -0
- package/dist/chart/shared-validation.d.ts +6 -0
- package/dist/chart/shared-workbook-source.d.ts +6 -0
- package/dist/chart/shared-xy-command.d.ts +7 -0
- package/dist/chart/shared-xy-family.d.ts +16 -0
- package/dist/chart/shared-xy-project.d.ts +6 -0
- package/dist/chart/shared-xy-records.d.ts +23 -0
- package/dist/chart/shared-xy-save.d.ts +5 -0
- package/dist/chart/shared-xy-source.d.ts +39 -0
- package/dist/chart/shared.d.ts +13 -0
- package/dist/chart/source.d.ts +11 -0
- package/dist/chart/types.d.ts +86 -0
- package/dist/chart/validation.d.ts +24 -0
- package/dist/chart/workbook-range.d.ts +16 -0
- package/dist/chart/workbook-read.d.ts +7 -0
- package/dist/chart/workbook-write.d.ts +9 -0
- package/dist/chart/workbook.d.ts +25 -0
- package/dist/chart/xml-data.d.ts +14 -0
- package/dist/chart/xml-namespaces.d.ts +16 -0
- package/dist/chart-design/index.d.ts +10 -0
- package/dist/chart-design/types.d.ts +11 -0
- package/dist/chart-design/xml.d.ts +2 -0
- package/dist/chart-design.js +361 -0
- package/dist/chart-ex/index.d.ts +15 -0
- package/dist/chart-ex/workbook.d.ts +6 -0
- package/dist/chart-ex/xml.d.ts +14 -0
- package/dist/chart-ex.js +457 -0
- package/dist/chart-shared/index.d.ts +12 -0
- package/dist/chart-shared.js +1 -0
- package/dist/chart.js +1 -0
- package/dist/clipboard-links-GuPtqr1z.js +778 -0
- package/dist/clipboard-package.d.ts +4 -0
- package/dist/clipboard-source.d.ts +6 -2
- package/dist/clipboard-trees.d.ts +9 -0
- package/dist/collaboration-identity.d.ts +3 -0
- package/dist/commands/add-slide-identity.d.ts +4 -0
- package/dist/commands/bullet-image-resource.d.ts +11 -0
- package/dist/commands/clear-format.d.ts +4 -0
- package/dist/commands/common-object-slide-patch.d.ts +4 -0
- package/dist/commands/common-object-slide-types.d.ts +68 -0
- package/dist/commands/convert-to-custom-geometry.d.ts +4 -0
- package/dist/commands/direct-format-patches.d.ts +11 -5
- package/dist/commands/distribute-elements.d.ts +4 -0
- package/dist/commands/edit-table-grid.d.ts +10 -0
- package/dist/commands/element-alt-text.d.ts +8 -0
- package/dist/commands/element-arrangement.d.ts +17 -0
- package/dist/commands/element-effects.d.ts +1 -1
- package/dist/commands/element-fill.d.ts +1 -1
- package/dist/commands/element-geometry.d.ts +9 -0
- package/dist/commands/element-hierarchy.d.ts +6 -0
- package/dist/commands/element-image-content.d.ts +2 -2
- package/dist/commands/element-link.d.ts +1 -1
- package/dist/commands/element-name.d.ts +1 -1
- package/dist/commands/element-stroke.d.ts +1 -1
- package/dist/commands/element-table-style.d.ts +5 -0
- package/dist/commands/element-text.d.ts +1 -1
- package/dist/commands/element-transform.d.ts +2 -2
- package/dist/commands/frame-decomposition.d.ts +10 -0
- package/dist/commands/generated-creation-defaults.d.ts +4 -0
- package/dist/commands/geometry-types.d.ts +44 -0
- package/dist/commands/group-types.d.ts +24 -0
- package/dist/commands/group.d.ts +4 -0
- package/dist/commands/hierarchy-record.d.ts +5 -0
- package/dist/commands/image-resource.d.ts +8 -1
- package/dist/commands/insertion-host.d.ts +16 -0
- package/dist/commands/insertion-rect.d.ts +2 -0
- package/dist/commands/layout-property.d.ts +7 -0
- package/dist/commands/master-property.d.ts +5 -0
- package/dist/commands/master-text-style-types.d.ts +27 -0
- package/dist/commands/master-text-style.d.ts +7 -0
- package/dist/commands/paste-resources.d.ts +9 -5
- package/dist/commands/patch-apply.d.ts +3 -0
- package/dist/commands/patch-count.d.ts +1 -0
- package/dist/commands/patch-invalidation.d.ts +4 -0
- package/dist/commands/patch-stage.d.ts +4 -0
- package/dist/commands/patch.d.ts +4 -0
- package/dist/commands/record-clone.d.ts +3 -0
- package/dist/commands/record-override.d.ts +5 -0
- package/dist/commands/replace-image.d.ts +6 -1
- package/dist/commands/sections.d.ts +10 -0
- package/dist/commands/set-geometry.d.ts +4 -0
- package/dist/commands/set-preset.d.ts +5 -0
- package/dist/commands/set-table-style.d.ts +3 -0
- package/dist/commands/slide-property-types.d.ts +55 -5
- package/dist/commands/slide-size.d.ts +7 -0
- package/dist/commands/spid.d.ts +2 -1
- package/dist/commands/table-grid-patch.d.ts +12 -0
- package/dist/commands/table-style-types.d.ts +28 -0
- package/dist/commands/text-target.d.ts +3 -2
- package/dist/commands/theme-types.d.ts +47 -0
- package/dist/commands/theme.d.ts +9 -0
- package/dist/commands/types.d.ts +219 -17
- package/dist/commands/ungroup-source.d.ts +3 -0
- package/dist/commands/ungroup.d.ts +4 -0
- package/dist/comments/index.d.ts +35 -0
- package/dist/comments/save.d.ts +3 -0
- package/dist/comments/state.d.ts +10 -0
- package/dist/comments/xml.d.ts +12 -0
- package/dist/comments.js +782 -0
- package/dist/common-object-slide-types.d.ts +34 -0
- package/dist/custom-geometry-path.d.ts +3 -0
- package/dist/custom-geometry.d.ts +12 -0
- package/dist/data-validation.d.ts +1 -1
- package/dist/describe/budget.d.ts +3 -0
- package/dist/describe/index.d.ts +5 -0
- package/dist/describe/read.d.ts +4 -0
- package/dist/describe/types.d.ts +103 -0
- package/dist/describe.js +192 -0
- package/dist/design-dependencies.d.ts +8 -0
- package/dist/design-projection-package.d.ts +10 -0
- package/dist/design-target.d.ts +10 -0
- package/dist/design.d.ts +3 -0
- package/dist/document-extensions.d.ts +9 -0
- package/dist/document.d.ts +1 -1
- package/dist/dynamic-projection.d.ts +6 -0
- package/dist/edit-core.js +5680 -3413
- package/dist/editor.d.ts +19 -2
- package/dist/element-source.d.ts +11 -0
- package/dist/element-spids.d.ts +4 -0
- package/dist/extension-address-journal.d.ts +9 -0
- package/dist/extension-address-remap.d.ts +14 -0
- package/dist/extension-addresses.d.ts +20 -0
- package/dist/extension-copy-history.d.ts +7 -0
- package/dist/extension-copy.d.ts +16 -0
- package/dist/extension-migration-receipt.d.ts +34 -0
- package/dist/extension-recovery-context.d.ts +5 -0
- package/dist/extension-runtime.d.ts +64 -0
- package/dist/generate/comments.d.ts +3 -0
- package/dist/generate/compatibility-parts.d.ts +14 -0
- package/dist/generate/compatibility-references.d.ts +3 -0
- package/dist/generate/compatibility.d.ts +4 -0
- package/dist/generate/custom-geometry.d.ts +2 -0
- package/dist/generate/index.d.ts +13 -0
- package/dist/generate/links.d.ts +3 -0
- package/dist/generate/master-defaults.d.ts +4 -0
- package/dist/generate/materialize.d.ts +2 -0
- package/dist/generate/math.d.ts +3 -0
- package/dist/generate/media.d.ts +13 -0
- package/dist/generate/portable-clipboard.d.ts +4 -0
- package/dist/generate/projection-tree.d.ts +8 -0
- package/dist/generate/table.d.ts +4 -0
- package/dist/generate/template.d.ts +70 -0
- package/dist/generate/text-body.d.ts +2 -0
- package/dist/generate/text-effects.d.ts +5 -0
- package/dist/generate/text-override.d.ts +8 -0
- package/dist/generate/validation.d.ts +3 -0
- package/dist/generate/warp.d.ts +2 -0
- package/dist/generate.js +1464 -0
- package/dist/history.d.ts +11 -1
- package/dist/hyperlink.d.ts +2 -0
- package/dist/identities.d.ts +4 -0
- package/dist/identity-allocation.d.ts +12 -0
- package/dist/identity-watermark.d.ts +4 -0
- package/dist/image-content.d.ts +5 -2
- package/dist/image-resource-history.d.ts +2 -0
- package/dist/index-C2r7c6G6.js +714 -0
- package/dist/index-CYDvbiwF.js +1 -0
- package/dist/index.d.ts +43 -7
- package/dist/ink/index.d.ts +27 -0
- package/dist/ink/model.d.ts +4 -0
- package/dist/ink/save.d.ts +3 -0
- package/dist/ink/source.d.ts +7 -0
- package/dist/ink.js +324 -0
- package/dist/layout-assets.d.ts +3 -1
- package/dist/layout-projection.d.ts +19 -5
- package/dist/layout-state.d.ts +2 -0
- package/dist/layout-types.d.ts +42 -0
- package/dist/layout.d.ts +5 -0
- package/dist/lint/color.d.ts +5 -0
- package/dist/lint/index.d.ts +7 -0
- package/dist/lint/prompts.d.ts +3 -0
- package/dist/lint/report.d.ts +21 -0
- package/dist/lint/sampler-batch.d.ts +4 -0
- package/dist/lint/sampler-images.d.ts +2 -0
- package/dist/lint/sampler.d.ts +9 -0
- package/dist/lint/snapshot.d.ts +34 -0
- package/dist/lint/types.d.ts +67 -0
- package/dist/lint-sampler.js +187 -0
- package/dist/lint.js +659 -0
- package/dist/master-state.d.ts +3 -0
- package/dist/master-text-style-state.d.ts +3 -0
- package/dist/master-types.d.ts +55 -0
- package/dist/master.d.ts +5 -0
- package/dist/media/audio-icon.d.ts +2 -0
- package/dist/media/commands.d.ts +3 -0
- package/dist/media/index.d.ts +10 -0
- package/dist/media/markup.d.ts +10 -0
- package/dist/media/mp4-boxes.d.ts +12 -0
- package/dist/media/mp4-fragments.d.ts +8 -0
- package/dist/media/mp4-samples.d.ts +4 -0
- package/dist/media/mp4.d.ts +2 -0
- package/dist/media/poster.d.ts +2 -0
- package/dist/media/replace-poster.d.ts +3 -0
- package/dist/media/resource.d.ts +4 -0
- package/dist/media/source.d.ts +14 -0
- package/dist/media/types.d.ts +33 -0
- package/dist/media-properties.d.ts +4 -0
- package/dist/media.js +1630 -0
- package/dist/model-invariants-BM19JVxy.js +8980 -0
- package/dist/object-source.d.ts +11 -0
- package/dist/ole/container.d.ts +14 -0
- package/dist/ole/content.d.ts +94 -0
- package/dist/ole/index.d.ts +20 -0
- package/dist/ole/preview.d.ts +3 -0
- package/dist/ole/save.d.ts +2 -0
- package/dist/ole/state.d.ts +16 -0
- package/dist/ole.js +870 -0
- package/dist/opc/patch.d.ts +2 -0
- package/dist/opc.js +1 -1
- package/dist/paragraph-level.d.ts +11 -0
- package/dist/paragraph-property-schema.d.ts +5 -2
- package/dist/{patch-DO8497wO.js → patch-BwhfBbYE.js} +112 -95
- package/dist/patch-change.d.ts +4 -0
- package/dist/patch-events.d.ts +16 -0
- package/dist/ppt/appearance.d.ts +11 -0
- package/dist/ppt/binary.d.ts +20 -0
- package/dist/ppt/drawing.d.ts +18 -0
- package/dist/ppt/geometry.d.ts +4 -0
- package/dist/ppt/index.d.ts +12 -0
- package/dist/ppt/pictures.d.ts +11 -0
- package/dist/ppt/text.d.ts +9 -0
- package/dist/ppt.js +774 -0
- package/dist/preset-geometry.d.ts +6 -0
- package/dist/projection.d.ts +2 -0
- package/dist/query-BHLjWjnu.js +903 -0
- package/dist/recovery-identity.d.ts +3 -1
- package/dist/recovery-migrations.d.ts +3 -0
- package/dist/recovery.d.ts +3 -0
- package/dist/resize/index.d.ts +6 -0
- package/dist/resize/text.d.ts +4 -0
- package/dist/resize.js +5090 -0
- package/dist/retained-element-origins.d.ts +6 -0
- package/dist/run-property-fields.d.ts +12 -0
- package/dist/run-property-schema.d.ts +3 -1
- package/dist/run-style.d.ts +15 -0
- package/dist/save/alt-text.d.ts +4 -0
- package/dist/save/comments.d.ts +3 -0
- package/dist/save/effects.d.ts +2 -1
- package/dist/save/extension-availability.d.ts +3 -0
- package/dist/save/extension-elements.d.ts +26 -0
- package/dist/save/geometry.d.ts +5 -0
- package/dist/save/index.d.ts +6 -1
- package/dist/save/insertion.d.ts +7 -3
- package/dist/save/layout-properties.d.ts +4 -0
- package/dist/save/master-properties.d.ts +5 -0
- package/dist/save/notes.d.ts +2 -0
- package/dist/save/paragraph-overrides.d.ts +3 -0
- package/dist/save/run-overrides.d.ts +10 -0
- package/dist/save/shape-format.d.ts +3 -0
- package/dist/save/slide-parts.d.ts +1 -0
- package/dist/save/table-style-part.d.ts +11 -0
- package/dist/save/table.d.ts +5 -0
- package/dist/save/text-source-less.d.ts +6 -0
- package/dist/save/xfrm.d.ts +8 -2
- package/dist/save.js +502 -1480
- package/dist/sections.d.ts +8 -0
- package/dist/session-assets.d.ts +4 -0
- package/dist/slide-parts-D0o_DDhi.js +1331 -0
- package/dist/slide-size.d.ts +6 -0
- package/dist/smartart/drawing.d.ts +3 -0
- package/dist/smartart/index.d.ts +16 -0
- package/dist/smartart/model.d.ts +18 -0
- package/dist/smartart/save.d.ts +3 -0
- package/dist/smartart.js +604 -0
- package/dist/source-retention.d.ts +7 -0
- package/dist/space.d.ts +37 -0
- package/dist/table-cell.d.ts +7 -1
- package/dist/table-direct-markup.d.ts +7 -1
- package/dist/table-grid-projection.d.ts +6 -0
- package/dist/table-grid.d.ts +45 -0
- package/dist/table-invariants.d.ts +4 -0
- package/dist/table-rows.d.ts +2 -1
- package/dist/table-scale.d.ts +4 -0
- package/dist/table-style.d.ts +21 -0
- package/dist/templates/index.d.ts +4 -0
- package/dist/templates/recipes.d.ts +5 -0
- package/dist/templates/types.d.ts +17 -0
- package/dist/templates.js +543 -0
- package/dist/text-flatten.d.ts +6 -0
- package/dist/text-fragment.d.ts +5 -0
- package/dist/text-model.d.ts +8 -8
- package/dist/text-override-validation.d.ts +6 -2
- package/dist/text-selection.d.ts +4 -0
- package/dist/theme-projection.d.ts +8 -0
- package/dist/theme-xml.d.ts +3 -0
- package/dist/theme.d.ts +14 -0
- package/dist/types.d.ts +217 -8
- package/dist/xml/index.d.ts +1 -1
- package/dist/xml/nodes.d.ts +2 -2
- package/dist/xml/shape-ids.d.ts +3 -0
- package/dist/xml.js +19 -16
- package/package.json +77 -5
- package/schemas/describe.schema.json +479 -0
- package/schemas/lint.schema.json +145 -0
- package/dist/index-D4ZTaYOa.js +0 -706
- package/dist/insertion-DabLme_U.js +0 -5471
package/dist/chart-ex.js
ADDED
|
@@ -0,0 +1,457 @@
|
|
|
1
|
+
import { readChartExData as Ce, renderChartExXml as we } from "@web-ppt/core/chart-ex";
|
|
2
|
+
import { sourcePartBytes as D } from "@web-ppt/edit-core";
|
|
3
|
+
import { xmlElementChildren as R, parseXmlTree as O, findXmlAttribute as K, cloneXmlNodeWithNamespaceClosure as ye, removeXmlChild as _, insertXmlChildUnchecked as Q, setXmlAttribute as W, serializeXmlTree as Ne, createXmlElement as Se, createXmlText as $e, reorderXmlChildren as Oe, serializeXmlTreeBytes as V } from "@web-ppt/edit-core/xml";
|
|
4
|
+
import { unzipSync as ke } from "fflate";
|
|
5
|
+
import { patchOpcPackage as Pe, disposeOpcPackage as Re } from "@web-ppt/edit-core/opc";
|
|
6
|
+
function Z(e, t, r) {
|
|
7
|
+
if (!e || typeof e != "object" || Object.getPrototypeOf(e) !== Object.prototype && Object.getPrototypeOf(e) !== null)
|
|
8
|
+
throw new Error(`${r} 必须是纯数据对象`);
|
|
9
|
+
const n = Array.isArray(t) ? new Set(t) : t;
|
|
10
|
+
for (const o of Reflect.ownKeys(e)) {
|
|
11
|
+
const s = Object.getOwnPropertyDescriptor(e, o);
|
|
12
|
+
if (typeof o != "string" || !n.has(o) || !(s != null && s.enumerable) || !("value" in s))
|
|
13
|
+
throw new Error(`${r} 包含不可序列化或未知字段:${String(o)}`);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function X(e, t) {
|
|
17
|
+
if (!Array.isArray(e) || Object.getPrototypeOf(e) !== Array.prototype)
|
|
18
|
+
throw new Error(`${t} 必须是纯数据数组`);
|
|
19
|
+
const r = Reflect.ownKeys(e);
|
|
20
|
+
if (r.length !== e.length + 1 || r[r.length - 1] !== "length")
|
|
21
|
+
throw new Error(`${t} 必须是没有附加字段的稠密数组`);
|
|
22
|
+
for (let n = 0; n < e.length; n++) {
|
|
23
|
+
const o = String(n), s = Object.getOwnPropertyDescriptor(e, o);
|
|
24
|
+
if (r[n] !== o || !(s != null && s.enumerable) || !("value" in s))
|
|
25
|
+
throw new Error(`${t}[${n}] 必须是可序列化的数据项`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const ne = Symbol.for("@web-ppt/edit-core/extensions/v1"), ue = Symbol.for("@web-ppt/edit-core/extensions-generation/v1"), oe = Symbol.for("@web-ppt/edit-core/extensions-listeners/v1"), Te = /^[a-z][a-z0-9-]{0,63}$/;
|
|
29
|
+
function se() {
|
|
30
|
+
const e = globalThis;
|
|
31
|
+
return e[oe] ?? (e[oe] = { documents: /* @__PURE__ */ new WeakMap(), pending: /* @__PURE__ */ new Map(), active: /* @__PURE__ */ new Set(), resolvers: /* @__PURE__ */ new WeakMap() });
|
|
32
|
+
}
|
|
33
|
+
function Ue(e) {
|
|
34
|
+
if (!Te.test(e))
|
|
35
|
+
throw new Error(`编辑扩展命名空间无效:${e}`);
|
|
36
|
+
}
|
|
37
|
+
function je() {
|
|
38
|
+
const e = globalThis;
|
|
39
|
+
return e[ne] ?? (e[ne] = /* @__PURE__ */ new Map());
|
|
40
|
+
}
|
|
41
|
+
function Ae(e, t) {
|
|
42
|
+
var o;
|
|
43
|
+
Ue(e), je().set(e, t);
|
|
44
|
+
const r = globalThis;
|
|
45
|
+
r[ue] = (r[ue] ?? 0) + 1;
|
|
46
|
+
const n = new Set(se().pending.get(e));
|
|
47
|
+
if (t.migrate) for (const s of se().active) n.add(s);
|
|
48
|
+
se().pending.delete(e);
|
|
49
|
+
for (const s of n ?? [])
|
|
50
|
+
try {
|
|
51
|
+
s(e);
|
|
52
|
+
} catch (a) {
|
|
53
|
+
(o = globalThis.reportError) == null || o.call(globalThis, a);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const Ie = "http://schemas.openxmlformats.org/presentationml/2006/main", De = "http://schemas.openxmlformats.org/package/2006/relationships", Me = "http://purl.oclc.org/ooxml", _e = `${Me}/presentationml/main`, Xe = (e, t, r) => e === t || e === r, We = (e) => Xe(e, Ie, _e), ge = D, pe = /* @__PURE__ */ new WeakMap(), ze = {
|
|
57
|
+
bg1: "lt1",
|
|
58
|
+
tx1: "dk1",
|
|
59
|
+
bg2: "lt2",
|
|
60
|
+
tx2: "dk2",
|
|
61
|
+
accent1: "accent1",
|
|
62
|
+
accent2: "accent2",
|
|
63
|
+
accent3: "accent3",
|
|
64
|
+
accent4: "accent4",
|
|
65
|
+
accent5: "accent5",
|
|
66
|
+
accent6: "accent6",
|
|
67
|
+
hlink: "hlink",
|
|
68
|
+
folHlink: "folHlink"
|
|
69
|
+
};
|
|
70
|
+
function Le(e) {
|
|
71
|
+
const t = e.lastIndexOf("/");
|
|
72
|
+
return `${e.slice(0, t + 1)}_rels/${e.slice(t + 1)}.rels`;
|
|
73
|
+
}
|
|
74
|
+
function Fe(e, t) {
|
|
75
|
+
if (t.startsWith("/")) return t.slice(1);
|
|
76
|
+
const r = e.slice(0, e.lastIndexOf("/") + 1).split("/").filter(Boolean);
|
|
77
|
+
for (const n of t.split("/"))
|
|
78
|
+
n === ".." ? r.pop() : n && n !== "." && r.push(n);
|
|
79
|
+
return r.join("/");
|
|
80
|
+
}
|
|
81
|
+
function xe(e, t) {
|
|
82
|
+
var a, i, m, d;
|
|
83
|
+
const r = ge(e, Le(t));
|
|
84
|
+
if (!r) return {};
|
|
85
|
+
let n = pe.get(r);
|
|
86
|
+
n || (n = /* @__PURE__ */ new Map(), pe.set(r, n));
|
|
87
|
+
const o = n.get(t);
|
|
88
|
+
if (o) return o;
|
|
89
|
+
const s = /* @__PURE__ */ Object.create(null);
|
|
90
|
+
for (const f of R(O(r).root, {
|
|
91
|
+
localName: "Relationship",
|
|
92
|
+
namespaceUri: De
|
|
93
|
+
})) {
|
|
94
|
+
const h = (a = K(f, { localName: "Id", namespaceUri: null })) == null ? void 0 : a.value, c = (i = K(f, { localName: "Type", namespaceUri: null })) == null ? void 0 : i.value, u = (m = K(f, { localName: "Target", namespaceUri: null })) == null ? void 0 : m.value, g = ((d = K(f, {
|
|
95
|
+
localName: "TargetMode",
|
|
96
|
+
namespaceUri: null
|
|
97
|
+
})) == null ? void 0 : d.value) === "External";
|
|
98
|
+
h && c && u && (s[h] = { type: c, target: g ? u : Fe(t, u), ...g ? { external: !0 } : {} });
|
|
99
|
+
}
|
|
100
|
+
return n.set(t, s), s;
|
|
101
|
+
}
|
|
102
|
+
function Be(e, t) {
|
|
103
|
+
var n;
|
|
104
|
+
let r = (n = e.elements[t]) == null ? void 0 : n.parent;
|
|
105
|
+
for (; r && e.elements[r]; ) r = e.elements[r].parent;
|
|
106
|
+
return r ? e.slides[r] : void 0;
|
|
107
|
+
}
|
|
108
|
+
const Je = (e) => {
|
|
109
|
+
var r;
|
|
110
|
+
const t = (r = e.match(/rgba?\(([^)]+)\)/)) == null ? void 0 : r[1].split(",").slice(0, 3).map((n) => Math.max(0, Math.min(255, Math.round(Number(n.trim())))));
|
|
111
|
+
return (t == null ? void 0 : t.length) === 3 && t.every(Number.isFinite) ? t.map((n) => n.toString(16).padStart(2, "0")).join("").toUpperCase() : e.replace("#", "");
|
|
112
|
+
};
|
|
113
|
+
function qe(e, t, r) {
|
|
114
|
+
var g;
|
|
115
|
+
const n = Be(e, t), o = n != null && n.layoutId ? e.layouts[n.layoutId] : void 0, s = o ? e.masters[o.origin.masterPart] : void 0, a = (o == null ? void 0 : o.themeId) ?? (s == null ? void 0 : s.themeId), i = a ? e.themes[a] : void 0, m = { ...i == null ? void 0 : i.src.colors, ...i == null ? void 0 : i.ovr.colors }, d = structuredClone((i == null ? void 0 : i.src.fonts) ?? {
|
|
116
|
+
major: { latin: "", ea: "", cs: "", scripts: {} },
|
|
117
|
+
minor: { latin: "", ea: "", cs: "", scripts: {} }
|
|
118
|
+
});
|
|
119
|
+
for (const l of ["major", "minor"])
|
|
120
|
+
Object.assign(d[l], (g = i == null ? void 0 : i.ovr.fonts) == null ? void 0 : g[l]);
|
|
121
|
+
const f = { ...ze }, h = s && ge(e, s.id), c = h ? O(h).root : null, u = c && We(c.namespaceUri) ? R(c).find((l) => l.localName === "clrMap" && l.namespaceUri === c.namespaceUri) : null;
|
|
122
|
+
for (const l of (u == null ? void 0 : u.attributes) ?? []) f[l.localName] = l.value;
|
|
123
|
+
return {
|
|
124
|
+
ctx: { theme: Object.fromEntries(Object.entries(m).map(([l, p]) => [l, Je(p)])), clrMap: f },
|
|
125
|
+
fonts: d,
|
|
126
|
+
rels: structuredClone(xe(e, r))
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function ie(e, t, r, n = "id") {
|
|
130
|
+
var u, g, l, p;
|
|
131
|
+
const o = e.elements[t], s = o == null ? void 0 : o.meta.origin;
|
|
132
|
+
if (!s || o.meta.editable !== "frame") return null;
|
|
133
|
+
let a = o.parent;
|
|
134
|
+
for (; e.elements[a]; ) a = e.elements[a].parent;
|
|
135
|
+
const i = ((g = (u = e.slides[a]) == null ? void 0 : u.creation) == null ? void 0 : g.duplicateSourcePart) ?? s.part, m = D(e, i);
|
|
136
|
+
if (!m) return null;
|
|
137
|
+
const d = O(m).root, f = [d], h = d.namespaceUri, c = xe(e, i);
|
|
138
|
+
for (; f.length; ) {
|
|
139
|
+
const x = f.pop(), w = R(x);
|
|
140
|
+
if (x.localName !== "graphicFrame" || x.namespaceUri !== h) {
|
|
141
|
+
f.push(...w);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
const C = w.find((b) => b.localName === "nvGraphicFramePr" && b.namespaceUri === h), M = C && R(C).find((b) => b.localName === "cNvPr" && b.namespaceUri === h);
|
|
145
|
+
if (Number((l = M == null ? void 0 : M.attributes.find((b) => b.localName === "id" && !b.namespaceUri)) == null ? void 0 : l.value) !== s.spid) continue;
|
|
146
|
+
const j = [...w];
|
|
147
|
+
for (; j.length; ) {
|
|
148
|
+
const b = j.pop();
|
|
149
|
+
if (b.localName === "graphicData" && b.attributes.some((S) => S.localName === "uri" && !S.namespaceUri && S.value === r)) {
|
|
150
|
+
const S = R(b).find((v) => v.namespaceUri === r || r.endsWith("/ole") && v.namespaceUri === h && v.localName === "oleObj"), A = Object.fromEntries(((S == null ? void 0 : S.attributes) ?? []).filter((v) => {
|
|
151
|
+
var U;
|
|
152
|
+
return ((U = v.namespaceUri) == null ? void 0 : U.endsWith("/relationships")) && c[v.value];
|
|
153
|
+
}).map((v) => [v.localName, c[v.value].target])), B = (p = S == null ? void 0 : S.attributes.find((v) => {
|
|
154
|
+
var U;
|
|
155
|
+
return v.localName === n && ((U = v.namespaceUri) == null ? void 0 : U.endsWith("/relationships"));
|
|
156
|
+
})) == null ? void 0 : p.value, J = B && c[B], T = J && J.target, I = T && D(e, T);
|
|
157
|
+
if (T && I) return {
|
|
158
|
+
part: T,
|
|
159
|
+
hostPart: i,
|
|
160
|
+
references: A,
|
|
161
|
+
xml: new TextDecoder().decode(I),
|
|
162
|
+
context: { ...qe(e, t, T), readPart: (v) => D(e, v) }
|
|
163
|
+
};
|
|
164
|
+
}
|
|
165
|
+
j.push(...R(b));
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
const z = "http://schemas.microsoft.com/office/drawing/2014/chartex", L = "http://schemas.openxmlformats.org/officeDocument/2006/relationships", N = (e, t) => e ? R(e).filter((r) => r.namespaceUri === e.namespaceUri && (!t || r.localName === t)) : [], y = (e, t) => N(e, t)[0] ?? null, P = (e, t) => {
|
|
171
|
+
var r;
|
|
172
|
+
return (r = e == null ? void 0 : e.attributes.find((n) => n.localName === t && !n.namespaceUri)) == null ? void 0 : r.value;
|
|
173
|
+
}, $ = (e, t, r = [], n) => {
|
|
174
|
+
const o = Se(e.prefix ? `${e.prefix}:${t}` : t, { attributes: r });
|
|
175
|
+
return Q(e, o, y(e, "extLst")), n !== void 0 && Q(o, $e(n)), o;
|
|
176
|
+
};
|
|
177
|
+
function le(e, t, r) {
|
|
178
|
+
const n = O(e), o = y(n.root, "chartData");
|
|
179
|
+
for (const [a, i] of t.data.entries()) {
|
|
180
|
+
const m = N(o, "data").find((f) => P(f, "id") === i.id);
|
|
181
|
+
if (!m) throw new Error("ChartEx 数据源缺失");
|
|
182
|
+
const d = N(m).filter((f) => ["numDim", "strDim"].includes(f.localName));
|
|
183
|
+
for (const [f, h] of i.dimensions.entries()) {
|
|
184
|
+
const c = d[f];
|
|
185
|
+
if (!c) throw new Error("ChartEx 维度源缺失");
|
|
186
|
+
const u = N(c, "lvl").map((l) => ye(l, c));
|
|
187
|
+
for (const l of N(c).filter((p) => ["f", "lvl"].includes(p.localName))) _(c, l);
|
|
188
|
+
const g = r == null ? void 0 : r(a, f);
|
|
189
|
+
if (g) {
|
|
190
|
+
const l = $(c, "f", [["dir", "col"]], g);
|
|
191
|
+
_(c, l), Q(c, l, c.children[0] ?? null);
|
|
192
|
+
} else {
|
|
193
|
+
const l = y(c, "nf");
|
|
194
|
+
l && _(c, l);
|
|
195
|
+
}
|
|
196
|
+
for (const [l, p] of h.levels.entries()) {
|
|
197
|
+
const x = u[l] ?? $(c, "lvl");
|
|
198
|
+
u[l] && Q(c, x, y(c, "extLst")), W(x, "ptCount", String(p.length));
|
|
199
|
+
for (const w of N(x, "pt")) _(x, w);
|
|
200
|
+
!u[l] && h.format && W(x, "formatCode", h.format);
|
|
201
|
+
for (const [w, C] of p.entries()) C !== null && $(x, "pt", [["idx", String(w)]], String(C));
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const s = y(y(y(n.root, "chart"), "plotArea"), "plotAreaRegion");
|
|
206
|
+
for (const a of N(s, "series")) {
|
|
207
|
+
const i = t.rows[P(y(a, "dataId"), "val") ?? ""];
|
|
208
|
+
if (!i) continue;
|
|
209
|
+
const m = (d, f, h) => {
|
|
210
|
+
for (const c of N(d, f)) {
|
|
211
|
+
const u = i.indexOf(Number(P(c, h)));
|
|
212
|
+
u < 0 ? _(d, c) : W(c, h, String(u));
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
m(a, "dataPt", "idx"), m(y(y(a, "layoutPr"), "subtotals"), "idx", "val"), m(y(a, "dataLabels"), "dataLabel", "idx");
|
|
216
|
+
}
|
|
217
|
+
return Ne(n);
|
|
218
|
+
}
|
|
219
|
+
const Ee = 16384, Ge = 1048576;
|
|
220
|
+
function ae(e) {
|
|
221
|
+
if (!Number.isInteger(e) || e < 1 || e > Ee) throw new Error("工作簿列号越界");
|
|
222
|
+
let t = "";
|
|
223
|
+
for (let r = e; r; r = Math.floor((r - 1) / 26))
|
|
224
|
+
t = String.fromCharCode(65 + (r - 1) % 26) + t;
|
|
225
|
+
return t;
|
|
226
|
+
}
|
|
227
|
+
const He = (e) => /^[A-Za-z_][A-Za-z0-9_.]*$/.test(e) ? e : `'${e.replace(/'/g, "''")}'`;
|
|
228
|
+
function Ke(e) {
|
|
229
|
+
if (![e.startColumn, e.endColumn, e.startRow, e.endRow].every(Number.isInteger) || e.startColumn < 1 || e.endColumn > Ee || e.startColumn > e.endColumn || e.startRow < 1 || e.endRow > Ge || e.startRow > e.endRow)
|
|
230
|
+
throw new Error("工作簿范围越界");
|
|
231
|
+
const t = `$${ae(e.startColumn)}$${e.startRow}`, r = `$${ae(e.endColumn)}$${e.endRow}`;
|
|
232
|
+
return `${He(e.sheet)}!${t}${t === r ? "" : `:${r}`}`;
|
|
233
|
+
}
|
|
234
|
+
const Ve = "http://schemas.openxmlformats.org/package/2006/relationships", Ze = "http://schemas.openxmlformats.org/spreadsheetml/2006/main", Qe = (e) => e.replace(/([^/]+)$/, "_rels/$1.rels"), Ye = (e, t) => {
|
|
235
|
+
if (/[:\\?#]/.test(t)) throw new Error("工作簿关系必须指向包内文件");
|
|
236
|
+
const r = t.startsWith("/") ? [] : e.split("/").slice(0, -1);
|
|
237
|
+
for (const n of t.split("/"))
|
|
238
|
+
if (n === "..") {
|
|
239
|
+
if (!r.length) throw new Error("工作簿关系越界");
|
|
240
|
+
r.pop();
|
|
241
|
+
} else n && n !== "." && r.push(n);
|
|
242
|
+
return r.join("/");
|
|
243
|
+
};
|
|
244
|
+
function et(e, t) {
|
|
245
|
+
var U;
|
|
246
|
+
let r = 0, n = 0;
|
|
247
|
+
if (e.length > 16 * 1024 * 1024) throw new Error("ChartEx 工作簿超限");
|
|
248
|
+
const o = ke(e, { filter(E) {
|
|
249
|
+
if (r += E.originalSize, r > 64 * 1024 * 1024 || ++n > 512) throw new Error("ChartEx 工作簿解压超限");
|
|
250
|
+
return !0;
|
|
251
|
+
} }), s = O(o["_rels/.rels"]).root, a = N(s, "Relationship").filter((E) => P(E, "Type") === `${L}/officeDocument` && P(E, "TargetMode") !== "External");
|
|
252
|
+
if (a.length !== 1) throw new Error("ChartEx 工作簿入口不唯一");
|
|
253
|
+
const i = Ye("", P(a[0], "Target") ?? ""), m = O(o[i]), d = Qe(i), f = o[d] ? O(o[d]) : O(`<Relationships xmlns="${Ve}"/>`), h = O(o["[Content_Types].xml"]), c = y(m.root, "sheets");
|
|
254
|
+
if (!c) throw new Error("工作簿缺少 sheets");
|
|
255
|
+
const u = new Set(N(c, "sheet").map((E) => {
|
|
256
|
+
var k;
|
|
257
|
+
return (k = P(E, "name")) == null ? void 0 : k.toLowerCase();
|
|
258
|
+
})), g = new Set(N(c, "sheet").map((E) => P(E, "sheetId"))), l = new Set(N(f.root, "Relationship").map((E) => P(E, "Id")));
|
|
259
|
+
let p = 1;
|
|
260
|
+
for (; u.has(`webppt ${p}`) || g.has(String(p)) || l.has(`webPpt${p}`) || o[`web-ppt/chart-data${p}.xml`]; ) p++;
|
|
261
|
+
const x = `WebPPT ${p}`, w = `web-ppt/chart-data${p}.xml`, C = `webPpt${p}`, M = $(c, "sheet", [["name", x], ["sheetId", String(p)], ["xmlns:r", L], ["r:id", C]]);
|
|
262
|
+
W(M, "state", "visible");
|
|
263
|
+
for (const E of N(y(m.root, "bookViews"), "workbookView")) W(E, "activeTab", String(N(c, "sheet").length - 1));
|
|
264
|
+
$(f.root, "Relationship", [["Id", C], ["Type", `${L}/worksheet`], ["Target", `/${w}`]]), $(h.root, "Override", [["PartName", `/${w}`], ["ContentType", "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml"]]);
|
|
265
|
+
const j = O(`<worksheet xmlns="${Ze}"><sheetData/></worksheet>`), b = /* @__PURE__ */ new Map(), S = [];
|
|
266
|
+
let A = 1;
|
|
267
|
+
for (const E of t) {
|
|
268
|
+
const k = [];
|
|
269
|
+
S.push(k);
|
|
270
|
+
for (const te of E.dimensions) {
|
|
271
|
+
const q = [...te.levels].reverse(), he = ((U = q[0]) == null ? void 0 : U.length) ?? 0;
|
|
272
|
+
if (A + q.length > 16385) throw new Error("ChartEx 数据列超限");
|
|
273
|
+
if (!he) {
|
|
274
|
+
k.push("");
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
k.push(Ke({ sheet: x, startColumn: A, endColumn: A + q.length - 1, startRow: 1, endRow: he }));
|
|
278
|
+
for (const ve of q) {
|
|
279
|
+
for (const [G, re] of ve.entries()) {
|
|
280
|
+
if (re === null) continue;
|
|
281
|
+
let H = b.get(G);
|
|
282
|
+
H || (H = $(y(j.root, "sheetData"), "row", [["r", String(G + 1)]]), b.set(G, H));
|
|
283
|
+
const me = $(H, "c", [["r", `${ae(A)}${G + 1}`], ...te.numeric ? [] : [["t", "inlineStr"]]]);
|
|
284
|
+
te.numeric ? $(me, "v", [], String(re)) : $($(me, "is"), "t", [["xml:space", "preserve"]], String(re));
|
|
285
|
+
}
|
|
286
|
+
A++;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
const B = y(j.root, "sheetData"), J = [...b].sort(([E], [k]) => E - k).map(([, E]) => E);
|
|
291
|
+
Oe(B, J);
|
|
292
|
+
const T = { format: "pptx", bytes: e, parts: o, assets: {}, disposed: !1 }, I = Pe(T, {
|
|
293
|
+
[w]: V(j),
|
|
294
|
+
[i]: V(m),
|
|
295
|
+
[d]: V(f),
|
|
296
|
+
"[Content_Types].xml": V(h)
|
|
297
|
+
}), v = I.bytes.slice();
|
|
298
|
+
return I.package !== T && Re(I.package), { bytes: v, formula: (E, k) => S[E][k] || void 0 };
|
|
299
|
+
}
|
|
300
|
+
const F = "chart-ex-data", ce = (e, t) => {
|
|
301
|
+
var r, n, o;
|
|
302
|
+
return (o = (n = (r = e.elements[t]) == null ? void 0 : r.ovr.extensions) == null ? void 0 : n[F]) == null ? void 0 : o.value;
|
|
303
|
+
}, Y = (e, t) => {
|
|
304
|
+
const r = ie(e, t, z);
|
|
305
|
+
if (!r) throw new Error("对象没有现代图表数据");
|
|
306
|
+
return r;
|
|
307
|
+
}, be = (e, t) => {
|
|
308
|
+
const r = Y(e, t);
|
|
309
|
+
return Ce(r.xml, r.context);
|
|
310
|
+
};
|
|
311
|
+
function fe(e, t) {
|
|
312
|
+
const r = ce(e, t);
|
|
313
|
+
if (r) return JSON.parse(r);
|
|
314
|
+
const n = be(e, t);
|
|
315
|
+
return { data: n, rows: Object.fromEntries(n.map((o) => {
|
|
316
|
+
var s, a;
|
|
317
|
+
return [
|
|
318
|
+
o.id,
|
|
319
|
+
Array.from({ length: ((a = (s = o.dimensions[0]) == null ? void 0 : s.levels[0]) == null ? void 0 : a.length) ?? 0 }, (i, m) => m)
|
|
320
|
+
];
|
|
321
|
+
})) };
|
|
322
|
+
}
|
|
323
|
+
function ee(e, t, r) {
|
|
324
|
+
var m, d;
|
|
325
|
+
Z(r, ["data", "rows"], "ChartEx 编辑数据");
|
|
326
|
+
const n = r, o = be(e, t);
|
|
327
|
+
if (X(n.data, "ChartEx 数据集"), Z(n.rows, o.map((f) => f.id), "ChartEx 行映射"), n.data.length !== o.length) throw new Error("ChartEx 数据集结构不同");
|
|
328
|
+
let s = 0;
|
|
329
|
+
for (const [f, h] of n.data.entries()) {
|
|
330
|
+
const c = o[f];
|
|
331
|
+
if (Z(h, ["id", "dimensions"], "ChartEx 数据集"), h.id !== c.id) throw new Error("ChartEx 数据身份不同");
|
|
332
|
+
if (X(h.dimensions, "ChartEx 维度"), h.dimensions.length !== c.dimensions.length) throw new Error("ChartEx 维度结构不同");
|
|
333
|
+
const u = n.rows[h.id];
|
|
334
|
+
X(u, "ChartEx 行映射");
|
|
335
|
+
const g = ((d = (m = c.dimensions[0]) == null ? void 0 : m.levels[0]) == null ? void 0 : d.length) ?? 0;
|
|
336
|
+
if (u.length > 1e4 || new Set(u.filter((l) => l !== null)).size !== u.filter((l) => l !== null).length || u.some((l) => l !== null && (!Number.isInteger(l) || l < 0 || l >= g))) throw new Error("ChartEx 行映射无效");
|
|
337
|
+
for (const [l, p] of h.dimensions.entries()) {
|
|
338
|
+
const x = c.dimensions[l];
|
|
339
|
+
Z(p, ["type", "numeric", "source", "levels", "format"], "ChartEx 维度");
|
|
340
|
+
for (const w of ["type", "numeric", "source", "format"]) if (p[w] !== x[w]) throw new Error("ChartEx 维度元数据不能改写");
|
|
341
|
+
if (X(p.levels, "ChartEx 层级"), p.levels.length !== x.levels.length) throw new Error("ChartEx 层级结构不同");
|
|
342
|
+
for (const w of p.levels) {
|
|
343
|
+
if (X(w, "ChartEx 数据点"), w.length !== u.length || (s += w.length) > 1e5) throw new Error("ChartEx 数据长度无效");
|
|
344
|
+
for (const C of w) if (C !== null && (p.numeric ? typeof C != "number" || !Number.isFinite(C) : typeof C != "string" || C.length > 32767 || /[\u0000-\u0008\u000b\u000c\u000e-\u001f\ud800-\udfff\ufffe\uffff]/u.test(C))) throw new Error("ChartEx 数据值无效");
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
const a = Y(e, t), i = e.elements[t].src;
|
|
349
|
+
if (!we(le(a.xml, n), i.w, i.h, a.context).length)
|
|
350
|
+
throw new Error("数据不满足当前图表布局;分层图需要完整类别路径和有效数值");
|
|
351
|
+
return structuredClone(n);
|
|
352
|
+
}
|
|
353
|
+
function tt(e, t) {
|
|
354
|
+
if (t.path[0] !== "elements" || t.path.length !== 6 || t.path[5] !== "value") throw new Error("ChartEx 补丁路径无效");
|
|
355
|
+
if (t.op === "set") {
|
|
356
|
+
if (typeof t.value != "string" || t.value.length > 1e6) throw new Error("ChartEx 补丁值无效");
|
|
357
|
+
ee(e, t.path[1], JSON.parse(t.value));
|
|
358
|
+
} else Y(e, t.path[1]);
|
|
359
|
+
}
|
|
360
|
+
function rt(e, t, r) {
|
|
361
|
+
if (e.meta.readonly) throw new Error("文稿只读");
|
|
362
|
+
const n = t.payload === null ? void 0 : JSON.stringify(ee(e, t.id, t.payload)), o = ce(e, t.id), s = ["elements", t.id, "ovr", "extensions", F, "value"];
|
|
363
|
+
if (o === n) return { forward: [], inverse: [] };
|
|
364
|
+
const a = (i) => i === void 0 ? { op: "del", path: s, origin: r } : { op: "set", path: s, value: i, origin: r };
|
|
365
|
+
return { forward: [a(n)], inverse: [a(o)] };
|
|
366
|
+
}
|
|
367
|
+
function de(e) {
|
|
368
|
+
var o;
|
|
369
|
+
const t = {}, r = {}, n = /* @__PURE__ */ new Map();
|
|
370
|
+
for (const s of Object.values(e.elements)) {
|
|
371
|
+
const a = ie(e, s.id, z);
|
|
372
|
+
if (!a) continue;
|
|
373
|
+
const i = ce(e, s.id), m = !!e.saveState.baselines[a.part];
|
|
374
|
+
if (!i && !m) continue;
|
|
375
|
+
if (n.has(a.part)) {
|
|
376
|
+
if (n.get(a.part) !== i) throw new Error("共享 ChartEx 不能设置不同数据");
|
|
377
|
+
continue;
|
|
378
|
+
}
|
|
379
|
+
n.set(a.part, i), r[a.part] = D(e, a.part);
|
|
380
|
+
const d = O(a.xml).root, f = R(d).find((w) => w.namespaceUri === z && w.localName === "chartData"), h = f && R(f).find((w) => w.namespaceUri === z && w.localName === "externalData"), c = (o = h == null ? void 0 : h.attributes.find((w) => w.localName === "id" && w.namespaceUri === L)) == null ? void 0 : o.value, u = c && a.context.rels[c], g = u && u.type === `${L}/package` ? u.target : null, l = g ? D(e, g) : void 0;
|
|
381
|
+
if (g && l && (r[g] = l), !i) {
|
|
382
|
+
t[a.part] = r[a.part], g && l && !t[g] && (t[g] = l);
|
|
383
|
+
continue;
|
|
384
|
+
}
|
|
385
|
+
const p = ee(e, s.id, JSON.parse(i)), x = l && et(t[g] ?? l, p.data);
|
|
386
|
+
x && g && (t[g] = x.bytes), t[a.part] = new TextEncoder().encode(le(a.xml, p, x == null ? void 0 : x.formula));
|
|
387
|
+
}
|
|
388
|
+
return { changes: t, baselines: r };
|
|
389
|
+
}
|
|
390
|
+
Ae(F, {
|
|
391
|
+
command: rt,
|
|
392
|
+
validatePatch: tt,
|
|
393
|
+
project(e, t, r) {
|
|
394
|
+
if (r.kind !== "group") return r;
|
|
395
|
+
const n = Y(e, t), o = ee(e, t, fe(e, t)), s = we(le(n.xml, o), r.w, r.h, n.context);
|
|
396
|
+
if (!s.length) throw new Error("ChartEx 数据无法形成当前布局");
|
|
397
|
+
return { ...r, children: s };
|
|
398
|
+
},
|
|
399
|
+
beforeSave: de,
|
|
400
|
+
generateParts(e, t) {
|
|
401
|
+
Object.assign(t, de(e).changes);
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
function ct(e) {
|
|
405
|
+
return Object.values(e.elements).filter((t) => ie(e, t.id, z)).map((t) => ({ id: t.id, name: t.src.name ?? "ChartEx" }));
|
|
406
|
+
}
|
|
407
|
+
function nt(e, t) {
|
|
408
|
+
return fe(e, t).data;
|
|
409
|
+
}
|
|
410
|
+
function ft(e) {
|
|
411
|
+
const t = (n, o) => {
|
|
412
|
+
const s = fe(e.doc, n);
|
|
413
|
+
o(s), e.exec({ type: "Extension", namespace: F, id: n, payload: s });
|
|
414
|
+
}, r = (n, o) => {
|
|
415
|
+
const s = n.data.find((a) => a.id === o);
|
|
416
|
+
if (!s) throw new Error("ChartEx 数据集不存在");
|
|
417
|
+
return s;
|
|
418
|
+
};
|
|
419
|
+
return {
|
|
420
|
+
query: (n) => nt(e.doc, n),
|
|
421
|
+
setCell(n, o, s, a, i, m) {
|
|
422
|
+
t(n, (d) => {
|
|
423
|
+
var h;
|
|
424
|
+
const f = (h = r(d, o).dimensions[s]) == null ? void 0 : h.levels[a];
|
|
425
|
+
if (!f || !Number.isInteger(i) || i < 0 || i >= f.length) throw new Error("ChartEx 数据坐标越界");
|
|
426
|
+
f[i] = m;
|
|
427
|
+
});
|
|
428
|
+
},
|
|
429
|
+
insertRow(n, o, s) {
|
|
430
|
+
t(n, (a) => {
|
|
431
|
+
const i = r(a, o), m = a.rows[o];
|
|
432
|
+
if (!Number.isInteger(s) || s < 0 || s > m.length) throw new Error("ChartEx 行号越界");
|
|
433
|
+
const d = new Set(i.dimensions.flatMap((h) => h.levels.flat()));
|
|
434
|
+
let f = m.length + 1;
|
|
435
|
+
for (; d.has(`新数据 ${f}`); ) f++;
|
|
436
|
+
m.splice(s, 0, null);
|
|
437
|
+
for (const h of i.dimensions) for (const c of h.levels) c.splice(s, 0, h.numeric ? null : `新数据 ${f}`);
|
|
438
|
+
});
|
|
439
|
+
},
|
|
440
|
+
removeRow(n, o, s) {
|
|
441
|
+
t(n, (a) => {
|
|
442
|
+
const i = r(a, o), m = a.rows[o];
|
|
443
|
+
if (!Number.isInteger(s) || s < 0 || s >= m.length) throw new Error("ChartEx 行号越界");
|
|
444
|
+
m.splice(s, 1);
|
|
445
|
+
for (const d of i.dimensions) for (const f of d.levels) f.splice(s, 1);
|
|
446
|
+
});
|
|
447
|
+
},
|
|
448
|
+
reset(n) {
|
|
449
|
+
e.exec({ type: "Extension", namespace: F, id: n, payload: null });
|
|
450
|
+
}
|
|
451
|
+
};
|
|
452
|
+
}
|
|
453
|
+
export {
|
|
454
|
+
ft as createChartExEditor,
|
|
455
|
+
ct as listEditableChartEx,
|
|
456
|
+
nt as queryChartExData
|
|
457
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { EditDoc, ElementId } from '../types';
|
|
2
|
+
import * as chart from '../chart/index';
|
|
3
|
+
export type * from '../chart/index';
|
|
4
|
+
export declare function registerSharedChartEditing(): void;
|
|
5
|
+
export declare function listEditableCharts(doc: EditDoc): chart.EditableChart[];
|
|
6
|
+
export declare function queryChartData(doc: EditDoc, id: ElementId): chart.ChartDataset;
|
|
7
|
+
export declare function createChartDataEditor(editor: Parameters<typeof chart.createChartDataEditor>[0]): chart.ChartDataEditor;
|
|
8
|
+
export declare function chartProjection(doc: EditDoc, id: ElementId): {
|
|
9
|
+
xml: string;
|
|
10
|
+
context: import("@web-ppt/core").ChartEnv;
|
|
11
|
+
part: string;
|
|
12
|
+
};
|