@qvac/harness 1.0.0-rc.9 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +696 -7
- package/NOTICE.md +0 -16
- package/README.md +46 -5
- package/dist-lib/index.d.ts +23 -16
- package/dist-lib/index.js +127 -23
- package/dist-lib/lib/agent/delegate.d.ts +1 -0
- package/dist-lib/lib/agent/delegate.js +10 -9
- package/dist-lib/lib/agent/follow.d.ts +1 -0
- package/dist-lib/lib/agent/follow.js +12 -2
- package/dist-lib/lib/agent/resolve.js +11 -3
- package/dist-lib/lib/agent/tools.d.ts +1 -0
- package/dist-lib/lib/agent/tools.js +1 -1
- package/dist-lib/lib/capabilities/agent-ports.d.ts +1 -1
- package/dist-lib/lib/capabilities/agent-ports.js +8 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/answering.js +2 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/direct-search.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/execute.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/executing.js +79 -9
- package/dist-lib/lib/capabilities/completion-engine/actors/execution-plan.js +12 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/inspect-prepare.js +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.d.ts +1 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/inspecting.js +13 -8
- package/dist-lib/lib/capabilities/completion-engine/actors/loading-skill.js +3 -2
- package/dist-lib/lib/capabilities/completion-engine/actors/preparing.js +47 -22
- package/dist-lib/lib/capabilities/completion-engine/actors/rejecting.js +5 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/resolving.js +10 -4
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/actors/retrieving.js +19 -11
- package/dist-lib/lib/capabilities/completion-engine/actors/run-prepare.js +38 -23
- package/dist-lib/lib/capabilities/completion-engine/actors/skill-step.js +31 -10
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.d.ts +5 -3
- package/dist-lib/lib/capabilities/completion-engine/actors/stream.js +61 -7
- package/dist-lib/lib/capabilities/completion-engine/actors/streaming.js +41 -16
- package/dist-lib/lib/capabilities/completion-engine/actors/wrap-up.js +26 -10
- package/dist-lib/lib/capabilities/completion-engine/actors.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/actors.js +8 -8
- package/dist-lib/lib/capabilities/completion-engine/driver.d.ts +0 -1
- package/dist-lib/lib/capabilities/completion-engine/driver.js +30 -6
- package/dist-lib/lib/capabilities/completion-engine/durable.d.ts +2 -1
- package/dist-lib/lib/capabilities/completion-engine/durable.js +7 -1
- package/dist-lib/lib/capabilities/completion-engine/engine.d.ts +2 -0
- package/dist-lib/lib/capabilities/completion-engine/engine.js +35 -15
- package/dist-lib/lib/capabilities/completion-engine/index.d.ts +0 -1
- package/dist-lib/lib/capabilities/completion-engine/loop.d.ts +13 -3
- package/dist-lib/lib/capabilities/completion-engine/loop.js +7 -2
- package/dist-lib/lib/capabilities/completion-engine/model-round.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/model-round.js +2 -0
- package/dist-lib/lib/capabilities/completion-engine/operations.js +29 -9
- package/dist-lib/lib/capabilities/completion-engine/ports.d.ts +1 -0
- package/dist-lib/lib/capabilities/completion-engine/ports.js +6 -4
- package/dist-lib/lib/capabilities/completion-engine/prepare-step.d.ts +4 -1
- package/dist-lib/lib/capabilities/completion-engine/round.d.ts +14 -0
- package/dist-lib/lib/capabilities/completion-engine/round.js +102 -47
- package/dist-lib/lib/capabilities/completion-engine/session.d.ts +5 -3
- package/dist-lib/lib/capabilities/completion-engine/session.js +1 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-caller.js +3 -1
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.d.ts +5 -41
- package/dist-lib/lib/capabilities/completion-engine/tool-execution.js +21 -135
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-outcome.js +40 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.d.ts +43 -0
- package/dist-lib/lib/capabilities/completion-engine/tool-preflight.js +91 -0
- package/dist-lib/lib/capabilities/completion-engine/transition-log.d.ts +14 -0
- package/dist-lib/lib/capabilities/completion-engine/transition-log.js +44 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.d.ts +4 -0
- package/dist-lib/lib/capabilities/completion-engine/turns.js +36 -8
- package/dist-lib/lib/capabilities/enhance.js +3 -3
- package/dist-lib/lib/capabilities/kv-cache.js +11 -3
- package/dist-lib/lib/capabilities/prefix-template.d.ts +34 -0
- package/dist-lib/lib/capabilities/prefix-template.js +175 -0
- package/dist-lib/lib/capabilities/prompt-prefix.d.ts +2 -0
- package/dist-lib/lib/capabilities/prompt-prefix.js +8 -0
- package/dist-lib/lib/capabilities/sdk-tool.d.ts +4 -4
- package/dist-lib/lib/capabilities/sdk-tool.js +22 -6
- package/dist-lib/lib/capabilities/skill-entry.d.ts +13 -1
- package/dist-lib/lib/capabilities/skill-entry.js +33 -2
- package/dist-lib/lib/capabilities/tool-failed-note.d.ts +1 -0
- package/dist-lib/lib/capabilities/tool-failed-note.js +1 -0
- package/dist-lib/lib/capabilities/tool-turns/answered.d.ts +15 -0
- package/dist-lib/lib/capabilities/tool-turns/answered.js +16 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.d.ts +7 -0
- package/dist-lib/lib/capabilities/tool-turns/attachments.js +39 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.d.ts +13 -0
- package/dist-lib/lib/capabilities/tool-turns/copy.js +29 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.d.ts +22 -0
- package/dist-lib/lib/capabilities/tool-turns/result-turn.js +120 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.d.ts +6 -0
- package/dist-lib/lib/capabilities/tool-turns/run-limits.js +32 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.d.ts +9 -0
- package/dist-lib/lib/capabilities/tool-turns/skill-loads.js +71 -0
- package/dist-lib/lib/capabilities/tool-turns.d.ts +10 -43
- package/dist-lib/lib/capabilities/tool-turns.js +7 -262
- package/dist-lib/lib/capabilities/usage-breakdown.d.ts +1 -0
- package/dist-lib/lib/capabilities/usage-breakdown.js +4 -1
- package/dist-lib/lib/client/index.js +6 -5
- package/dist-lib/lib/connect/abort.d.ts +6 -0
- package/dist-lib/lib/connect/abort.js +52 -0
- package/dist-lib/lib/connect/bridges.d.ts +21 -0
- package/dist-lib/lib/connect/bridges.js +185 -0
- package/dist-lib/lib/connect/decode.d.ts +31 -0
- package/dist-lib/lib/connect/decode.js +114 -0
- package/dist-lib/lib/connect/host-run-log.d.ts +20 -0
- package/dist-lib/lib/connect/host-run-log.js +89 -0
- package/dist-lib/lib/connect/round-log.d.ts +8 -0
- package/dist-lib/lib/connect/round-log.js +33 -0
- package/dist-lib/lib/connect/served.d.ts +7 -0
- package/dist-lib/lib/connect/served.js +45 -0
- package/dist-lib/lib/connect.d.ts +5 -1
- package/dist-lib/lib/connect.js +102 -444
- package/dist-lib/lib/context-window.d.ts +13 -6
- package/dist-lib/lib/context-window.js +18 -5
- package/dist-lib/lib/contract/agent.d.ts +18 -1
- package/dist-lib/lib/contract/completion.d.ts +35 -3
- package/dist-lib/lib/contract/drive.d.ts +154 -4
- package/dist-lib/lib/contract/exec.d.ts +1 -0
- package/dist-lib/lib/contract/index.d.ts +1 -0
- package/dist-lib/lib/contract/knowledge.d.ts +10 -0
- package/dist-lib/lib/contract/media.d.ts +58 -0
- package/dist-lib/lib/contract/models.d.ts +6 -2
- package/dist-lib/lib/contract/ocr.d.ts +17 -0
- package/dist-lib/lib/contract/ocr.js +1 -0
- package/dist-lib/lib/contract/root-search.d.ts +34 -0
- package/dist-lib/lib/contract/root-search.js +1 -0
- package/dist-lib/lib/contract/run.d.ts +13 -0
- package/dist-lib/lib/contract-types.d.ts +10 -2
- package/dist-lib/lib/docx/index.js +1 -1
- package/dist-lib/lib/errors.d.ts +8 -4
- package/dist-lib/lib/errors.js +12 -8
- package/dist-lib/lib/fold/index.d.ts +4 -2
- package/dist-lib/lib/fold/index.js +15 -7
- package/dist-lib/lib/guards.d.ts +2 -0
- package/dist-lib/lib/guards.js +7 -0
- package/dist-lib/lib/hardware/capability-probe.js +10 -7
- package/dist-lib/lib/hardware/gpu-probe-addon.js +26 -11
- package/dist-lib/lib/hardware/gpu-stats.native.cjs +17 -1
- package/dist-lib/lib/helpers/completion-params.d.ts +2 -1
- package/dist-lib/lib/helpers/completion-params.js +18 -2
- package/dist-lib/lib/helpers/control-tokens.d.ts +3 -0
- package/dist-lib/lib/helpers/control-tokens.js +25 -0
- package/dist-lib/lib/helpers/drain.d.ts +1 -1
- package/dist-lib/lib/helpers/drain.js +1 -1
- package/dist-lib/lib/helpers/goal-check/asks.d.ts +25 -0
- package/dist-lib/lib/helpers/goal-check/asks.js +52 -0
- package/dist-lib/lib/helpers/goal-check/checks.d.ts +8 -0
- package/dist-lib/lib/helpers/goal-check/checks.js +92 -0
- package/dist-lib/lib/helpers/goal-check/commands.d.ts +7 -0
- package/dist-lib/lib/helpers/goal-check/commands.js +130 -0
- package/dist-lib/lib/helpers/goal-check/paths.d.ts +5 -0
- package/dist-lib/lib/helpers/goal-check/paths.js +44 -0
- package/dist-lib/lib/helpers/goal-check/shell.d.ts +9 -0
- package/dist-lib/lib/helpers/goal-check/shell.js +96 -0
- package/dist-lib/lib/helpers/goal-check.d.ts +36 -6
- package/dist-lib/lib/helpers/goal-check.js +34 -98
- package/dist-lib/lib/helpers/html-helpers.js +9 -6
- package/dist-lib/lib/helpers/recent-map.d.ts +7 -0
- package/dist-lib/lib/helpers/recent-map.js +23 -0
- package/dist-lib/lib/helpers/repeated-reply.js +9 -2
- package/dist-lib/lib/helpers/root-search.d.ts +3 -0
- package/dist-lib/lib/helpers/root-search.js +74 -0
- package/dist-lib/lib/helpers/run-latency.d.ts +14 -0
- package/dist-lib/lib/helpers/run-latency.js +63 -0
- package/dist-lib/lib/helpers/run-outcome.d.ts +2 -0
- package/dist-lib/lib/helpers/run-outcome.js +6 -2
- package/dist-lib/lib/helpers/spawn-path.d.ts +1 -0
- package/dist-lib/lib/helpers/spawn-path.js +2 -1
- package/dist-lib/lib/helpers/stable-stringify.js +10 -2
- package/dist-lib/lib/helpers/text-coalescer.d.ts +6 -0
- package/dist-lib/lib/helpers/text-coalescer.js +44 -4
- package/dist-lib/lib/helpers/tool-call-markup/emit.d.ts +6 -0
- package/dist-lib/lib/helpers/tool-call-markup/emit.js +15 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.d.ts +22 -0
- package/dist-lib/lib/helpers/tool-call-markup/recover.js +130 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.d.ts +3 -0
- package/dist-lib/lib/helpers/tool-call-markup/skill-recovery.js +56 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.d.ts +4 -0
- package/dist-lib/lib/helpers/tool-call-markup/strip.js +157 -0
- package/dist-lib/lib/helpers/tool-call-markup.d.ts +19 -24
- package/dist-lib/lib/helpers/tool-call-markup.js +17 -343
- package/dist-lib/lib/lifecycle/completion-run.js +2 -2
- package/dist-lib/lib/log.d.ts +3 -0
- package/dist-lib/lib/log.js +17 -1
- package/dist-lib/lib/machine/completion/actions/completion.d.ts +13 -16
- package/dist-lib/lib/machine/completion/actions/completion.js +110 -138
- package/dist-lib/lib/machine/completion/actions/goal.d.ts +10 -0
- package/dist-lib/lib/machine/completion/actions/goal.js +93 -0
- package/dist-lib/lib/machine/completion/actions/prepare.js +2 -1
- package/dist-lib/lib/machine/completion/actions/reject-tool.d.ts +16 -0
- package/dist-lib/lib/machine/completion/actions/reject-tool.js +147 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.d.ts +6 -0
- package/dist-lib/lib/machine/completion/actions/retry-round.js +50 -0
- package/dist-lib/lib/machine/completion/actions/rounds.d.ts +5 -0
- package/dist-lib/lib/machine/completion/actions/rounds.js +31 -0
- package/dist-lib/lib/machine/completion/actions/tools.d.ts +1 -16
- package/dist-lib/lib/machine/completion/actions/tools.js +73 -151
- package/dist-lib/lib/machine/completion/context.js +6 -1
- package/dist-lib/lib/machine/completion/guards/retry.d.ts +2 -1
- package/dist-lib/lib/machine/completion/guards/retry.js +4 -3
- package/dist-lib/lib/machine/completion/implementations.d.ts +8 -5
- package/dist-lib/lib/machine/completion/implementations.js +22 -7
- package/dist-lib/lib/machine/completion/machine.d.ts +15 -6
- package/dist-lib/lib/machine/completion/machine.js +25 -5
- package/dist-lib/lib/machine/completion/metrics.d.ts +25 -0
- package/dist-lib/lib/machine/completion/metrics.js +70 -0
- package/dist-lib/lib/machine/completion/nudges.d.ts +5 -0
- package/dist-lib/lib/machine/completion/nudges.js +33 -0
- package/dist-lib/lib/machine/completion/rules.d.ts +10 -33
- package/dist-lib/lib/machine/completion/rules.js +27 -103
- package/dist-lib/lib/machine/completion/splice.d.ts +9 -0
- package/dist-lib/lib/machine/completion/splice.js +19 -0
- package/dist-lib/lib/machine/completion/types.d.ts +37 -13
- package/dist-lib/lib/machine/index.d.ts +21 -7
- package/dist-lib/lib/machine/index.js +7 -2
- package/dist-lib/lib/media-host.d.ts +12 -0
- package/dist-lib/lib/media-host.js +52 -0
- package/dist-lib/lib/media-port.d.ts +20 -0
- package/dist-lib/lib/media-port.js +77 -0
- package/dist-lib/lib/media-wire.d.ts +8 -0
- package/dist-lib/lib/media-wire.js +111 -0
- package/dist-lib/lib/models/context-choice.js +8 -1
- package/dist-lib/lib/models/custom-model-cache.d.ts +1 -0
- package/dist-lib/lib/models/custom-model-cache.js +3 -0
- package/dist-lib/lib/models/gguf-header.d.ts +6 -0
- package/dist-lib/lib/models/gguf-header.js +38 -1
- package/dist-lib/lib/models/gpu-selection.d.ts +6 -1
- package/dist-lib/lib/models/gpu-selection.js +29 -5
- package/dist-lib/lib/models/kv-cache.d.ts +2 -0
- package/dist-lib/lib/models/kv-cache.js +8 -0
- package/dist-lib/lib/models/llm-presets.js +27 -1
- package/dist-lib/lib/models/load-requests.d.ts +9 -0
- package/dist-lib/lib/models/load-requests.js +42 -0
- package/dist-lib/lib/models/model-catalog-constants.d.ts +3 -2
- package/dist-lib/lib/models/model-catalog-constants.js +8 -5
- package/dist-lib/lib/models/model-catalog.d.ts +12 -3
- package/dist-lib/lib/models/model-catalog.js +40 -16
- package/dist-lib/lib/models/model-delete.js +3 -0
- package/dist-lib/lib/models/model-handle.d.ts +1 -0
- package/dist-lib/lib/models/model-list.d.ts +2 -1
- package/dist-lib/lib/models/model-list.js +5 -1
- package/dist-lib/lib/models/model-pool.d.ts +7 -1
- package/dist-lib/lib/models/model-pool.js +34 -13
- package/dist-lib/lib/models/tts-model-default.d.ts +2 -1
- package/dist-lib/lib/models/tts-model-default.js +8 -6
- package/dist-lib/lib/no-redirect-fetch-impl.d.ts +2 -1
- package/dist-lib/lib/no-redirect-fetch-impl.js +45 -8
- package/dist-lib/lib/office/index.js +1 -1
- package/dist-lib/lib/plugins/registry.d.ts +12 -0
- package/dist-lib/lib/plugins/registry.js +71 -15
- package/dist-lib/lib/plugins/require-bare.d.ts +1 -0
- package/dist-lib/lib/plugins/require-bare.js +13 -0
- package/dist-lib/lib/prompt.d.ts +7 -4
- package/dist-lib/lib/prompt.js +81 -24
- package/dist-lib/lib/residency/completion-runtime.d.ts +8 -6
- package/dist-lib/lib/residency/completion-runtime.js +53 -9
- package/dist-lib/lib/residency/index.d.ts +12 -3
- package/dist-lib/lib/residency/index.js +52 -16
- package/dist-lib/lib/round-host.js +3 -3
- package/dist-lib/lib/round-port.js +3 -3
- package/dist-lib/lib/run-log/boundary.d.ts +1 -4
- package/dist-lib/lib/run-log/boundary.js +4 -21
- package/dist-lib/lib/run-log/history-codec.d.ts +1 -1
- package/dist-lib/lib/run-log/history-codec.js +3 -3
- package/dist-lib/lib/run-log/protocol.js +17 -16
- package/dist-lib/lib/run-log/redact.d.ts +10 -1
- package/dist-lib/lib/run-log/redact.js +99 -9
- package/dist-lib/lib/run-log/request-codec.d.ts +3 -0
- package/dist-lib/lib/run-log/request-codec.js +19 -4
- package/dist-lib/lib/run-log/run-journal.js +1 -1
- package/dist-lib/lib/sdk-loader.d.ts +1 -0
- package/dist-lib/lib/sdk-loader.js +14 -0
- package/dist-lib/lib/serve/completion.d.ts +7 -0
- package/dist-lib/lib/serve/completion.js +571 -0
- package/dist-lib/lib/serve/downloads.d.ts +4 -0
- package/dist-lib/lib/serve/downloads.js +79 -0
- package/dist-lib/lib/serve/models.d.ts +5 -0
- package/dist-lib/lib/serve/models.js +120 -0
- package/dist-lib/lib/serve/noop.d.ts +1 -0
- package/dist-lib/lib/serve/noop.js +1 -0
- package/dist-lib/lib/serve/requests.d.ts +148 -0
- package/dist-lib/lib/serve/requests.js +1 -0
- package/dist-lib/lib/serve/rounds.d.ts +11 -0
- package/dist-lib/lib/serve/rounds.js +67 -0
- package/dist-lib/lib/serve/run-log-start.d.ts +37 -0
- package/dist-lib/lib/serve/run-log-start.js +253 -0
- package/dist-lib/lib/serve/skills.d.ts +32 -0
- package/dist-lib/lib/serve/skills.js +46 -0
- package/dist-lib/lib/serve.d.ts +5 -1
- package/dist-lib/lib/serve.js +23 -995
- package/dist-lib/lib/sidecar/index.d.ts +1 -1
- package/dist-lib/lib/sidecar/index.js +11 -19
- package/dist-lib/lib/sidecar/user-plugins.js +6 -4
- package/dist-lib/lib/skills-host/index.d.ts +6 -3
- package/dist-lib/lib/skills-host/index.js +39 -18
- package/dist-lib/lib/spawn.d.ts +14 -0
- package/dist-lib/lib/spawn.js +9 -5
- package/dist-lib/lib/tools/ask-user.d.ts +2 -0
- package/dist-lib/lib/tools/ask-user.js +137 -0
- package/dist-lib/lib/tools/attachments/delivered.d.ts +5 -0
- package/dist-lib/lib/tools/attachments/delivered.js +16 -0
- package/dist-lib/lib/tools/attachments/fetched-file.d.ts +32 -0
- package/dist-lib/lib/tools/attachments/fetched-file.js +134 -0
- package/dist-lib/lib/tools/attachments/staging.d.ts +1 -0
- package/dist-lib/lib/tools/attachments/staging.js +18 -22
- package/dist-lib/lib/tools/exec/runner.d.ts +4 -0
- package/dist-lib/lib/tools/exec/runner.js +20 -3
- package/dist-lib/lib/tools/exec.js +2 -1
- package/dist-lib/lib/tools/files/edit-file.d.ts +4 -1
- package/dist-lib/lib/tools/files/edit-file.js +220 -28
- package/dist-lib/lib/tools/files/glob.js +72 -11
- package/dist-lib/lib/tools/files/grep.js +65 -22
- package/dist-lib/lib/tools/files/index.js +3 -1
- package/dist-lib/lib/tools/files/read-file.js +199 -36
- package/dist-lib/lib/tools/fs/document-text.d.ts +7 -1
- package/dist-lib/lib/tools/fs/document-text.js +5 -21
- package/dist-lib/lib/tools/fs/drive.d.ts +1 -17
- package/dist-lib/lib/tools/fs/edit-match.d.ts +22 -0
- package/dist-lib/lib/tools/fs/edit-match.js +337 -45
- package/dist-lib/lib/tools/fs/engine.d.ts +9 -0
- package/dist-lib/lib/tools/fs/engine.js +28 -0
- package/dist-lib/lib/tools/fs/remote-protocol.d.ts +1 -81
- package/dist-lib/lib/tools/fs/scope.d.ts +2 -17
- package/dist-lib/lib/tools/fs/search.d.ts +2 -18
- package/dist-lib/lib/tools/fs/suggest.d.ts +8 -0
- package/dist-lib/lib/tools/fs/suggest.js +110 -0
- package/dist-lib/lib/tools/fs/tool-path.d.ts +3 -0
- package/dist-lib/lib/tools/fs/tool-path.js +13 -0
- package/dist-lib/lib/tools/fs/walk.d.ts +5 -5
- package/dist-lib/lib/tools/fs/walk.js +22 -21
- package/dist-lib/lib/tools/http-request/request.d.ts +4 -2
- package/dist-lib/lib/tools/http-request/request.js +2 -1
- package/dist-lib/lib/tools/http-request/truncate-response.d.ts +16 -1
- package/dist-lib/lib/tools/http-request/truncate-response.js +56 -11
- package/dist-lib/lib/tools/http-request.d.ts +1 -0
- package/dist-lib/lib/tools/http-request.js +88 -14
- package/dist-lib/lib/tools/index.d.ts +3 -1
- package/dist-lib/lib/tools/index.js +6 -2
- package/dist-lib/lib/tools/office/ops.d.ts +1 -0
- package/dist-lib/lib/tools/office/ops.js +5 -1
- package/dist-lib/lib/tools/office.d.ts +3 -2
- package/dist-lib/lib/tools/office.js +200 -39
- package/dist-lib/lib/tools/operations/builders.d.ts +4 -3
- package/dist-lib/lib/tools/operations/builders.js +41 -3
- package/dist-lib/lib/tools/operations/calendar-range.d.ts +16 -0
- package/dist-lib/lib/tools/operations/calendar-range.js +40 -0
- package/dist-lib/lib/tools/operations/compile.js +8 -6
- package/dist-lib/lib/tools/operations/manifest.d.ts +4 -0
- package/dist-lib/lib/tools/pdf/build.d.ts +13 -3
- package/dist-lib/lib/tools/pdf/build.js +52 -16
- package/dist-lib/lib/tools/pdf/pages.d.ts +12 -0
- package/dist-lib/lib/tools/pdf/pages.js +31 -0
- package/dist-lib/lib/tools/pdf/recognize.d.ts +13 -0
- package/dist-lib/lib/tools/pdf/recognize.js +55 -0
- package/dist-lib/lib/tools/pdf/request.d.ts +3 -8
- package/dist-lib/lib/tools/pdf/request.js +4 -4
- package/dist-lib/lib/tools/pdf.d.ts +0 -1
- package/dist-lib/lib/tools/pdf.js +42 -14
- package/dist-lib/lib/tools/skill.js +13 -4
- package/dist-lib/lib/tools/skills/bundled-dir.d.ts +8 -1
- package/dist-lib/lib/tools/skills/bundled-dir.js +38 -32
- package/dist-lib/lib/tools/skills/bundled-hash.d.ts +1 -0
- package/dist-lib/lib/tools/skills/bundled-hash.js +4 -1
- package/dist-lib/lib/tools/skills/catalog-loader.d.ts +12 -0
- package/dist-lib/lib/tools/skills/catalog-loader.js +173 -0
- package/dist-lib/lib/tools/skills/catalog.d.ts +5 -8
- package/dist-lib/lib/tools/skills/catalog.js +1 -162
- package/dist-lib/lib/tools/skills/credential-check.d.ts +1 -0
- package/dist-lib/lib/tools/skills/credential-check.js +3 -0
- package/dist-lib/lib/tools/skills/index.d.ts +1 -0
- package/dist-lib/lib/tools/skills/index.js +1 -0
- package/dist-lib/lib/tools/skills/manifest-parse.js +27 -3
- package/dist-lib/lib/tools/skills/manifest.d.ts +1 -0
- package/dist-lib/lib/tools/skills/overlay-crud.d.ts +3 -3
- package/dist-lib/lib/tools/skills/overlay-crud.js +4 -4
- package/dist-lib/lib/tools/skills/overlay-watch.d.ts +2 -2
- package/dist-lib/lib/tools/skills/overlay-watch.js +4 -3
- package/dist-lib/lib/tools/skills/scope-key.d.ts +1 -0
- package/dist-lib/lib/tools/skills/scope-key.js +4 -0
- package/dist-lib/lib/tools/skills/skill-tree.d.ts +5 -0
- package/dist-lib/lib/tools/skills/skill-tree.js +54 -0
- package/dist-lib/lib/tools/toolsets.d.ts +1 -1
- package/dist-lib/lib/tools/toolsets.js +2 -0
- package/dist-lib/lib/tools/web-fetch.js +41 -130
- package/dist-lib/lib/wire/download.d.ts +10 -0
- package/dist-lib/lib/wire/download.js +35 -0
- package/dist-lib/lib/wire/event.d.ts +41 -0
- package/dist-lib/lib/wire/event.js +306 -0
- package/dist-lib/lib/wire/fields.d.ts +3 -0
- package/dist-lib/lib/wire/fields.js +12 -0
- package/dist-lib/lib/wire/knowledge.d.ts +9 -0
- package/dist-lib/lib/wire/knowledge.js +68 -0
- package/dist-lib/lib/wire/round.d.ts +14 -0
- package/dist-lib/lib/wire/round.js +45 -0
- package/dist-lib/lib/wire/vectors.d.ts +6 -0
- package/dist-lib/lib/wire/vectors.js +33 -0
- package/dist-lib/lib/wire.d.ts +28 -77
- package/dist-lib/lib/wire.js +24 -463
- package/dist-lib/plugins/charts/chart-tool.d.ts +8 -0
- package/dist-lib/plugins/charts/chart-tool.js +175 -0
- package/dist-lib/plugins/charts/index.d.ts +16 -0
- package/dist-lib/plugins/charts/index.js +21 -0
- package/dist-lib/plugins/coding-guards/index.d.ts +25 -0
- package/dist-lib/plugins/coding-guards/index.js +126 -0
- package/dist-lib/plugins/diagrams/draw.d.ts +10 -0
- package/dist-lib/plugins/diagrams/draw.js +90 -0
- package/dist-lib/plugins/diagrams/index.d.ts +13 -0
- package/dist-lib/plugins/diagrams/index.js +15 -0
- package/dist-lib/plugins/diagrams/render.d.ts +16 -0
- package/dist-lib/plugins/diagrams/render.js +285 -0
- package/dist-lib/plugins/image/edit-image.d.ts +3 -22
- package/dist-lib/plugins/image/edit-image.js +20 -44
- package/dist-lib/plugins/image/fit.d.ts +31 -0
- package/dist-lib/plugins/image/fit.js +28 -0
- package/dist-lib/plugins/image/generate-image.d.ts +24 -4
- package/dist-lib/plugins/image/generate-image.js +198 -72
- package/dist-lib/plugins/image/index.d.ts +2 -1
- package/dist-lib/plugins/image/index.js +17 -8
- package/dist-lib/plugins/knowledge/index.d.ts +3 -0
- package/dist-lib/plugins/knowledge/index.js +5 -0
- package/dist-lib/plugins/knowledge/manifest.d.ts +53 -0
- package/dist-lib/plugins/knowledge/manifest.js +86 -0
- package/dist-lib/plugins/knowledge/search-tool.js +8 -8
- package/dist-lib/plugins/knowledge/store.d.ts +45 -8
- package/dist-lib/plugins/knowledge/store.js +428 -166
- package/dist-lib/plugins/mcp/call.js +15 -4
- package/dist-lib/plugins/mcp/protocol.d.ts +10 -2
- package/dist-lib/plugins/mcp/protocol.js +13 -12
- package/dist-lib/plugins/mcp/tool-listing.d.ts +6 -0
- package/dist-lib/plugins/mcp/tool-listing.js +97 -0
- package/dist-lib/plugins/music/generate-music.d.ts +21 -4
- package/dist-lib/plugins/music/generate-music.js +168 -65
- package/dist-lib/plugins/music/index.d.ts +2 -1
- package/dist-lib/plugins/music/index.js +11 -6
- package/dist-lib/plugins/obsidian/index.js +14 -4
- package/dist-lib/plugins/ocr/bmp.d.ts +2 -0
- package/dist-lib/plugins/ocr/bmp.js +27 -0
- package/dist-lib/plugins/ocr/coverage.d.ts +3 -0
- package/dist-lib/plugins/ocr/coverage.js +67 -0
- package/dist-lib/plugins/ocr/index.d.ts +12 -0
- package/dist-lib/plugins/ocr/index.js +20 -0
- package/dist-lib/plugins/ocr/ocr-runtime.d.ts +25 -0
- package/dist-lib/plugins/ocr/ocr-runtime.js +103 -0
- package/dist-lib/plugins/ocr/reading-order.d.ts +5 -0
- package/dist-lib/plugins/ocr/reading-order.js +218 -0
- package/dist-lib/plugins/python/bare-floor.d.ts +1 -0
- package/dist-lib/plugins/python/bare-floor.js +2 -0
- package/dist-lib/plugins/python/index.d.ts +4 -1
- package/dist-lib/plugins/python/index.js +5 -1
- package/dist-lib/plugins/python/language.js +11 -10
- package/dist-lib/plugins/python/python-adapter.d.ts +6 -1
- package/dist-lib/plugins/python/python-adapter.js +34 -1
- package/dist-lib/plugins/python/worker/client.js +1 -1
- package/dist-lib/plugins/python/worker/entry.js +2 -8
- package/dist-lib/plugins/python/worker/preload.d.ts +1 -0
- package/dist-lib/plugins/python/worker/preload.js +2 -0
- package/dist-lib/plugins/python/worker/spawn.js +1 -1
- package/dist-lib/plugins/ripgrep/index.d.ts +15 -0
- package/dist-lib/plugins/ripgrep/index.js +28 -0
- package/dist-lib/plugins/run-report/story.js +4 -1
- package/dist-lib/plugins/sandbox-linux/index.js +2 -2
- package/dist-lib/plugins/sandbox-macos/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/index.d.ts +2 -1
- package/dist-lib/plugins/sandbox-vm/index.js +2 -2
- package/dist-lib/plugins/sandbox-vm/vm-shell.d.ts +3 -1
- package/dist-lib/plugins/sandbox-vm/vm-shell.js +45 -16
- package/dist-lib/plugins/sandbox-windows/index.js +2 -2
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-arm64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/sandbox-windows/prebuilds/win32-x64/qvac-sandbox.exe +0 -0
- package/dist-lib/plugins/speech/speech-engine.d.ts +1 -1
- package/dist-lib/plugins/speech/speech-engine.js +10 -5
- package/dist-lib/plugins/speech/speech-text.d.ts +1 -0
- package/dist-lib/plugins/speech/speech-text.js +9 -4
- package/dist-lib/plugins/speech/voice.js +7 -2
- package/dist-lib/plugins/walkie-talkie/index.d.ts +2 -0
- package/dist-lib/plugins/walkie-talkie/index.js +6 -1
- package/dist-lib/plugins/weather/lookup.js +1 -0
- package/dist-lib/schema/baseline.d.ts +2 -1
- package/dist-lib/schema/baseline.js +2 -2
- package/dist-lib/schema/generate.js +8 -1
- package/dist-lib/schema/harness.js +34 -5
- package/dist-lib/schema/release-tags.d.ts +2 -1
- package/dist-lib/schema/release-tags.js +9 -10
- package/dist-lib/spec/bind.js +3 -0
- package/dist-lib/spec/calls.js +1 -0
- package/dist-lib/spec/hrpc/hrpc.json +13 -0
- package/dist-lib/spec/hrpc/index.js +15 -3
- package/dist-lib/spec/hrpc/messages.js +126 -13
- package/dist-lib/spec/hyperschema/index.js +126 -13
- package/dist-lib/spec/hyperschema/schema.json +86 -2
- package/dist-lib/spec/hyperschema/types.d.ts +18 -3
- package/package.json +96 -36
- package/scripts/addon-externals.cjs +7 -1
- package/worker/harness-sidecar.mjs +10 -0
- package/dist-lib/lib/helpers/buffer-burst.d.ts +0 -1
- package/dist-lib/lib/helpers/buffer-burst.js +0 -22
- package/dist-lib/lib/office/engine/codes.d.ts +0 -62
- package/dist-lib/lib/office/engine/codes.js +0 -61
- package/dist-lib/lib/office/engine/docx/document.d.ts +0 -216
- package/dist-lib/lib/office/engine/docx/document.js +0 -1152
- package/dist-lib/lib/office/engine/docx/index.d.ts +0 -7
- package/dist-lib/lib/office/engine/docx/index.js +0 -8
- package/dist-lib/lib/office/engine/docx/styles.d.ts +0 -31
- package/dist-lib/lib/office/engine/docx/styles.js +0 -173
- package/dist-lib/lib/office/engine/docx/template.d.ts +0 -18
- package/dist-lib/lib/office/engine/docx/template.js +0 -133
- package/dist-lib/lib/office/engine/docx/text.d.ts +0 -55
- package/dist-lib/lib/office/engine/docx/text.js +0 -538
- package/dist-lib/lib/office/engine/drawingml/chart.d.ts +0 -63
- package/dist-lib/lib/office/engine/drawingml/chart.js +0 -539
- package/dist-lib/lib/office/engine/drawingml/text.d.ts +0 -35
- package/dist-lib/lib/office/engine/drawingml/text.js +0 -352
- package/dist-lib/lib/office/engine/errors.d.ts +0 -6
- package/dist-lib/lib/office/engine/errors.js +0 -12
- package/dist-lib/lib/office/engine/image.d.ts +0 -8
- package/dist-lib/lib/office/engine/image.js +0 -48
- package/dist-lib/lib/office/engine/index.d.ts +0 -12
- package/dist-lib/lib/office/engine/index.js +0 -7
- package/dist-lib/lib/office/engine/opc/content-types.d.ts +0 -17
- package/dist-lib/lib/office/engine/opc/content-types.js +0 -74
- package/dist-lib/lib/office/engine/opc/media.d.ts +0 -13
- package/dist-lib/lib/office/engine/opc/media.js +0 -11
- package/dist-lib/lib/office/engine/opc/package.d.ts +0 -51
- package/dist-lib/lib/office/engine/opc/package.js +0 -324
- package/dist-lib/lib/office/engine/opc/paths.d.ts +0 -7
- package/dist-lib/lib/office/engine/opc/paths.js +0 -46
- package/dist-lib/lib/office/engine/opc/properties.d.ts +0 -7
- package/dist-lib/lib/office/engine/opc/properties.js +0 -75
- package/dist-lib/lib/office/engine/opc/relationships.d.ts +0 -23
- package/dist-lib/lib/office/engine/opc/relationships.js +0 -65
- package/dist-lib/lib/office/engine/opc/zip.d.ts +0 -15
- package/dist-lib/lib/office/engine/opc/zip.js +0 -264
- package/dist-lib/lib/office/engine/pptx/fit.d.ts +0 -12
- package/dist-lib/lib/office/engine/pptx/fit.js +0 -37
- package/dist-lib/lib/office/engine/pptx/index.d.ts +0 -8
- package/dist-lib/lib/office/engine/pptx/index.js +0 -8
- package/dist-lib/lib/office/engine/pptx/inherit.d.ts +0 -29
- package/dist-lib/lib/office/engine/pptx/inherit.js +0 -155
- package/dist-lib/lib/office/engine/pptx/notes.d.ts +0 -5
- package/dist-lib/lib/office/engine/pptx/notes.js +0 -85
- package/dist-lib/lib/office/engine/pptx/picture-area.d.ts +0 -23
- package/dist-lib/lib/office/engine/pptx/picture-area.js +0 -84
- package/dist-lib/lib/office/engine/pptx/presentation.d.ts +0 -56
- package/dist-lib/lib/office/engine/pptx/presentation.js +0 -787
- package/dist-lib/lib/office/engine/pptx/read.d.ts +0 -9
- package/dist-lib/lib/office/engine/pptx/read.js +0 -66
- package/dist-lib/lib/office/engine/pptx/shapes.d.ts +0 -52
- package/dist-lib/lib/office/engine/pptx/shapes.js +0 -276
- package/dist-lib/lib/office/engine/pptx/slides.d.ts +0 -27
- package/dist-lib/lib/office/engine/pptx/slides.js +0 -123
- package/dist-lib/lib/office/engine/pptx/template.d.ts +0 -20
- package/dist-lib/lib/office/engine/pptx/template.js +0 -391
- package/dist-lib/lib/office/engine/pptx/types.d.ts +0 -121
- package/dist-lib/lib/office/engine/units.d.ts +0 -3
- package/dist-lib/lib/office/engine/units.js +0 -12
- package/dist-lib/lib/office/engine/utf8.d.ts +0 -2
- package/dist-lib/lib/office/engine/utf8.js +0 -103
- package/dist-lib/lib/office/engine/xlsx/formula.d.ts +0 -49
- package/dist-lib/lib/office/engine/xlsx/formula.js +0 -381
- package/dist-lib/lib/office/engine/xlsx/index.d.ts +0 -8
- package/dist-lib/lib/office/engine/xlsx/index.js +0 -8
- package/dist-lib/lib/office/engine/xlsx/refs.d.ts +0 -22
- package/dist-lib/lib/office/engine/xlsx/refs.js +0 -82
- package/dist-lib/lib/office/engine/xlsx/reshape.d.ts +0 -21
- package/dist-lib/lib/office/engine/xlsx/reshape.js +0 -424
- package/dist-lib/lib/office/engine/xlsx/sheet.d.ts +0 -108
- package/dist-lib/lib/office/engine/xlsx/sheet.js +0 -662
- package/dist-lib/lib/office/engine/xlsx/strings.d.ts +0 -15
- package/dist-lib/lib/office/engine/xlsx/strings.js +0 -93
- package/dist-lib/lib/office/engine/xlsx/styles.d.ts +0 -38
- package/dist-lib/lib/office/engine/xlsx/styles.js +0 -369
- package/dist-lib/lib/office/engine/xlsx/template.d.ts +0 -7
- package/dist-lib/lib/office/engine/xlsx/template.js +0 -54
- package/dist-lib/lib/office/engine/xlsx/workbook.d.ts +0 -162
- package/dist-lib/lib/office/engine/xlsx/workbook.js +0 -881
- package/dist-lib/lib/office/engine/xlsx/write.d.ts +0 -2
- package/dist-lib/lib/office/engine/xlsx/write.js +0 -42
- package/dist-lib/lib/office/engine/xml.d.ts +0 -45
- package/dist-lib/lib/office/engine/xml.js +0 -258
- package/patches/localwatch@1.4.3.patch +0 -13
- /package/dist-lib/lib/{office/engine/pptx/types.js → contract/media.js} +0 -0
|
@@ -1,264 +0,0 @@
|
|
|
1
|
-
import { deflateRawSync, inflateRawSync } from '#zlib';
|
|
2
|
-
import { DocsError } from '../errors.js';
|
|
3
|
-
import { errorCode, errorMessage } from '../../../guards.js';
|
|
4
|
-
import * as utf8 from '../utf8.js';
|
|
5
|
-
const EOCD = 0x06054b50;
|
|
6
|
-
const EOCD64_LOCATOR = 0x07064b50;
|
|
7
|
-
const EOCD64 = 0x06064b50;
|
|
8
|
-
const CENTRAL = 0x02014b50;
|
|
9
|
-
const LOCAL = 0x04034b50;
|
|
10
|
-
const DOS_DATE = 33;
|
|
11
|
-
const UTF8_FLAG = 0x0800;
|
|
12
|
-
const CRC_TABLE = new Uint32Array(256).map((_, n) => {
|
|
13
|
-
let c = n;
|
|
14
|
-
for (let k = 0; k < 8; k++) {
|
|
15
|
-
c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1;
|
|
16
|
-
}
|
|
17
|
-
return c >>> 0;
|
|
18
|
-
});
|
|
19
|
-
export function crc32(data) {
|
|
20
|
-
let crc = 0xffffffff;
|
|
21
|
-
for (let i = 0; i < data.length; i++) {
|
|
22
|
-
crc = CRC_TABLE[(crc ^ data[i]) & 0xff] ^ (crc >>> 8);
|
|
23
|
-
}
|
|
24
|
-
return (crc ^ 0xffffffff) >>> 0;
|
|
25
|
-
}
|
|
26
|
-
function broken(why) {
|
|
27
|
-
return new DocsError('NOT_OOXML', `the file is not a readable zip archive: ${why}`);
|
|
28
|
-
}
|
|
29
|
-
function findDirectory(view) {
|
|
30
|
-
const min = Math.max(0, view.byteLength - 65557);
|
|
31
|
-
for (let at = view.byteLength - 22; at >= min; at--) {
|
|
32
|
-
if (view.getUint32(at, true) !== EOCD)
|
|
33
|
-
continue;
|
|
34
|
-
const count = view.getUint16(at + 10, true);
|
|
35
|
-
const offset = view.getUint32(at + 16, true);
|
|
36
|
-
const locator = at - 20;
|
|
37
|
-
if ((count === 0xffff || offset === 0xffffffff) &&
|
|
38
|
-
locator >= 0 &&
|
|
39
|
-
view.getUint32(locator, true) === EOCD64_LOCATOR) {
|
|
40
|
-
return zip64Directory(view, Number(view.getBigUint64(locator + 8, true)));
|
|
41
|
-
}
|
|
42
|
-
return { offset, count };
|
|
43
|
-
}
|
|
44
|
-
throw broken('no end of central directory');
|
|
45
|
-
}
|
|
46
|
-
function zip64Directory(view, at) {
|
|
47
|
-
if (at + 56 > view.byteLength || view.getUint32(at, true) !== EOCD64) {
|
|
48
|
-
throw broken('bad zip64 directory');
|
|
49
|
-
}
|
|
50
|
-
return {
|
|
51
|
-
count: Number(view.getBigUint64(at + 32, true)),
|
|
52
|
-
offset: Number(view.getBigUint64(at + 48, true))
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
function zip64Extra(view, entry, extra) {
|
|
56
|
-
for (let at = extra.start; at + 4 <= extra.end;) {
|
|
57
|
-
const id = view.getUint16(at, true);
|
|
58
|
-
const length = view.getUint16(at + 2, true);
|
|
59
|
-
if (id === 0x0001) {
|
|
60
|
-
let field = at + 4;
|
|
61
|
-
const take = () => {
|
|
62
|
-
if (field + 8 > extra.end) {
|
|
63
|
-
throw broken(`${entry.name} has a short zip64 field`);
|
|
64
|
-
}
|
|
65
|
-
const value = Number(view.getBigUint64(field, true));
|
|
66
|
-
field += 8;
|
|
67
|
-
return value;
|
|
68
|
-
};
|
|
69
|
-
if (entry.size === 0xffffffff) {
|
|
70
|
-
entry.size = take();
|
|
71
|
-
}
|
|
72
|
-
if (entry.compressed === 0xffffffff) {
|
|
73
|
-
entry.compressed = take();
|
|
74
|
-
}
|
|
75
|
-
if (entry.offset === 0xffffffff) {
|
|
76
|
-
entry.offset = take();
|
|
77
|
-
}
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
at += 4 + length;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
function readCentral(bytes, view, at) {
|
|
84
|
-
if (at + 46 > view.byteLength || view.getUint32(at, true) !== CENTRAL) {
|
|
85
|
-
throw broken('bad central directory entry');
|
|
86
|
-
}
|
|
87
|
-
const nameLength = view.getUint16(at + 28, true);
|
|
88
|
-
const extraLength = view.getUint16(at + 30, true);
|
|
89
|
-
const commentLength = view.getUint16(at + 32, true);
|
|
90
|
-
const entry = {
|
|
91
|
-
name: utf8.decode(bytes.subarray(at + 46, at + 46 + nameLength)),
|
|
92
|
-
flags: view.getUint16(at + 8, true),
|
|
93
|
-
method: view.getUint16(at + 10, true),
|
|
94
|
-
crc: view.getUint32(at + 16, true),
|
|
95
|
-
compressed: view.getUint32(at + 20, true),
|
|
96
|
-
size: view.getUint32(at + 24, true),
|
|
97
|
-
offset: view.getUint32(at + 42, true),
|
|
98
|
-
next: at + 46 + nameLength + extraLength + commentLength
|
|
99
|
-
};
|
|
100
|
-
const start = at + 46 + nameLength;
|
|
101
|
-
zip64Extra(view, entry, { start, end: start + extraLength });
|
|
102
|
-
return entry;
|
|
103
|
-
}
|
|
104
|
-
function checkLimits(entries, limits) {
|
|
105
|
-
if (entries.length > limits.maxEntries) {
|
|
106
|
-
throw new DocsError('TOO_LARGE', `the file has more than ${limits.maxEntries} entries`);
|
|
107
|
-
}
|
|
108
|
-
let declared = 0;
|
|
109
|
-
for (const entry of entries) {
|
|
110
|
-
declared += entry.size;
|
|
111
|
-
if (declared > limits.maxSize) {
|
|
112
|
-
throw new DocsError('TOO_LARGE', `the file expands past ${limits.maxSize} bytes`);
|
|
113
|
-
}
|
|
114
|
-
if (entry.size > 1024 * 1024 && entry.size / Math.max(1, entry.compressed) > limits.maxRatio) {
|
|
115
|
-
throw new DocsError('TOO_LARGE', `${entry.name} expands more than ${limits.maxRatio} times, which looks like a zip bomb`);
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
function extract(bytes, view, entry) {
|
|
120
|
-
const at = entry.offset;
|
|
121
|
-
if (at + 30 > view.byteLength || view.getUint32(at, true) !== LOCAL) {
|
|
122
|
-
throw broken(`bad local header for ${entry.name}`);
|
|
123
|
-
}
|
|
124
|
-
if (entry.flags & 1) {
|
|
125
|
-
throw broken(`${entry.name} is encrypted`);
|
|
126
|
-
}
|
|
127
|
-
const start = at + 30 + view.getUint16(at + 26, true) + view.getUint16(at + 28, true);
|
|
128
|
-
const raw = bytes.subarray(start, start + entry.compressed);
|
|
129
|
-
if (raw.length !== entry.compressed) {
|
|
130
|
-
throw broken(`${entry.name} is truncated`);
|
|
131
|
-
}
|
|
132
|
-
let data;
|
|
133
|
-
if (entry.method === 0) {
|
|
134
|
-
data = raw;
|
|
135
|
-
}
|
|
136
|
-
else if (entry.method === 8) {
|
|
137
|
-
data = inflate(raw, entry);
|
|
138
|
-
}
|
|
139
|
-
else {
|
|
140
|
-
throw broken(`${entry.name} uses compression method ${entry.method}`);
|
|
141
|
-
}
|
|
142
|
-
if (data.length !== entry.size) {
|
|
143
|
-
throw broken(`${entry.name} has the wrong size`);
|
|
144
|
-
}
|
|
145
|
-
if (crc32(data) !== entry.crc) {
|
|
146
|
-
throw broken(`${entry.name} fails its checksum`);
|
|
147
|
-
}
|
|
148
|
-
return data;
|
|
149
|
-
}
|
|
150
|
-
function inflate(raw, entry) {
|
|
151
|
-
try {
|
|
152
|
-
return new Uint8Array(inflateRawSync(raw, { maxOutputLength: Math.max(1, entry.size) }));
|
|
153
|
-
}
|
|
154
|
-
catch (err) {
|
|
155
|
-
if (isOverflow(err)) {
|
|
156
|
-
throw broken(`${entry.name} inflates past its declared size`);
|
|
157
|
-
}
|
|
158
|
-
throw broken(`${entry.name} does not inflate`);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function isOverflow(err) {
|
|
162
|
-
const code = errorCode(err);
|
|
163
|
-
return code === 'ERR_BUFFER_TOO_LARGE' || code === 'LIMIT_EXCEEDED';
|
|
164
|
-
}
|
|
165
|
-
export function read(bytes, limits) {
|
|
166
|
-
try {
|
|
167
|
-
return readEntries(bytes, limits);
|
|
168
|
-
}
|
|
169
|
-
catch (err) {
|
|
170
|
-
if (err instanceof DocsError) {
|
|
171
|
-
throw err;
|
|
172
|
-
}
|
|
173
|
-
throw broken(errorMessage(err));
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
function readEntries(bytes, limits) {
|
|
177
|
-
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
178
|
-
if (bytes.byteLength < 22) {
|
|
179
|
-
throw broken('too short');
|
|
180
|
-
}
|
|
181
|
-
const directory = findDirectory(view);
|
|
182
|
-
const entries = [];
|
|
183
|
-
for (let i = 0, at = directory.offset; i < directory.count; i++) {
|
|
184
|
-
const entry = readCentral(bytes, view, at);
|
|
185
|
-
entries.push(entry);
|
|
186
|
-
at = entry.next;
|
|
187
|
-
}
|
|
188
|
-
checkLimits(entries, limits);
|
|
189
|
-
return entries
|
|
190
|
-
.filter((entry) => !entry.name.endsWith('/'))
|
|
191
|
-
.map((entry) => ({ name: entry.name, data: extract(bytes, view, entry) }));
|
|
192
|
-
}
|
|
193
|
-
function encodeEntry(entry) {
|
|
194
|
-
const compressed = entry.compress && entry.data.length > 0;
|
|
195
|
-
return {
|
|
196
|
-
name: utf8.encode(entry.name),
|
|
197
|
-
data: entry.data,
|
|
198
|
-
raw: compressed ? new Uint8Array(deflateRawSync(entry.data, { level: 6 })) : entry.data,
|
|
199
|
-
crc: crc32(entry.data),
|
|
200
|
-
method: compressed ? 8 : 0
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
function header(size, fill) {
|
|
204
|
-
const out = new Uint8Array(size);
|
|
205
|
-
fill(new DataView(out.buffer));
|
|
206
|
-
return out;
|
|
207
|
-
}
|
|
208
|
-
function localHeader(e) {
|
|
209
|
-
return header(30, (v) => {
|
|
210
|
-
v.setUint32(0, LOCAL, true);
|
|
211
|
-
v.setUint16(4, 20, true);
|
|
212
|
-
v.setUint16(6, UTF8_FLAG, true);
|
|
213
|
-
v.setUint16(8, e.method, true);
|
|
214
|
-
v.setUint16(12, DOS_DATE, true);
|
|
215
|
-
v.setUint32(14, e.crc, true);
|
|
216
|
-
v.setUint32(18, e.raw.length, true);
|
|
217
|
-
v.setUint32(22, e.data.length, true);
|
|
218
|
-
v.setUint16(26, e.name.length, true);
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
function centralHeader(e, offset) {
|
|
222
|
-
return header(46, (v) => {
|
|
223
|
-
v.setUint32(0, CENTRAL, true);
|
|
224
|
-
v.setUint16(4, 20, true);
|
|
225
|
-
v.setUint16(6, 20, true);
|
|
226
|
-
v.setUint16(8, UTF8_FLAG, true);
|
|
227
|
-
v.setUint16(10, e.method, true);
|
|
228
|
-
v.setUint16(14, DOS_DATE, true);
|
|
229
|
-
v.setUint32(16, e.crc, true);
|
|
230
|
-
v.setUint32(20, e.raw.length, true);
|
|
231
|
-
v.setUint32(24, e.data.length, true);
|
|
232
|
-
v.setUint16(28, e.name.length, true);
|
|
233
|
-
v.setUint32(42, offset, true);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
function concat(parts) {
|
|
237
|
-
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
238
|
-
let at = 0;
|
|
239
|
-
for (const part of parts) {
|
|
240
|
-
out.set(part, at);
|
|
241
|
-
at += part.length;
|
|
242
|
-
}
|
|
243
|
-
return out;
|
|
244
|
-
}
|
|
245
|
-
export function write(entries) {
|
|
246
|
-
const encoded = entries.map(encodeEntry);
|
|
247
|
-
const body = [];
|
|
248
|
-
const central = [];
|
|
249
|
-
let offset = 0;
|
|
250
|
-
for (const e of encoded) {
|
|
251
|
-
central.push(centralHeader(e, offset), e.name);
|
|
252
|
-
body.push(localHeader(e), e.name, e.raw);
|
|
253
|
-
offset += 30 + e.name.length + e.raw.length;
|
|
254
|
-
}
|
|
255
|
-
const directory = concat(central);
|
|
256
|
-
const end = header(22, (v) => {
|
|
257
|
-
v.setUint32(0, EOCD, true);
|
|
258
|
-
v.setUint16(8, encoded.length, true);
|
|
259
|
-
v.setUint16(10, encoded.length, true);
|
|
260
|
-
v.setUint32(12, directory.length, true);
|
|
261
|
-
v.setUint32(16, offset, true);
|
|
262
|
-
});
|
|
263
|
-
return concat([...body, directory, end]);
|
|
264
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Box, Insets } from './inherit.ts';
|
|
2
|
-
export interface SizedParagraph {
|
|
3
|
-
text: string;
|
|
4
|
-
level: number;
|
|
5
|
-
size: number;
|
|
6
|
-
}
|
|
7
|
-
export interface Estimate {
|
|
8
|
-
overflow: boolean;
|
|
9
|
-
fontScale: number;
|
|
10
|
-
lineReduction: number;
|
|
11
|
-
}
|
|
12
|
-
export declare function estimate(paragraphs: SizedParagraph[], box: Box, insets: Insets): Estimate;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const EMU_PER_POINT = 12700;
|
|
2
|
-
const LEVEL_INDENT = 342900;
|
|
3
|
-
const FLOOR = { overflow: true, fontScale: 0.25, lineReduction: 0.2 };
|
|
4
|
-
function paragraphHeight(p, width, squeeze) {
|
|
5
|
-
const size = p.size * squeeze.scale * EMU_PER_POINT;
|
|
6
|
-
const available = Math.max(width - p.level * LEVEL_INDENT, width * 0.3);
|
|
7
|
-
const perLine = Math.max(1, Math.floor(available / (size * 0.5)));
|
|
8
|
-
let lines = 0;
|
|
9
|
-
for (const line of p.text.split('\n')) {
|
|
10
|
-
lines += Math.max(1, Math.ceil(line.length / perLine));
|
|
11
|
-
}
|
|
12
|
-
return lines * size * 1.2 * (1 - squeeze.reduction);
|
|
13
|
-
}
|
|
14
|
-
function neededHeight(paragraphs, width, squeeze) {
|
|
15
|
-
return paragraphs.reduce((total, p) => total + paragraphHeight(p, width, squeeze), 0);
|
|
16
|
-
}
|
|
17
|
-
export function estimate(paragraphs, box, insets) {
|
|
18
|
-
const width = box.width - insets.left - insets.right;
|
|
19
|
-
const height = box.height - insets.top - insets.bottom;
|
|
20
|
-
if (width <= 0 || height <= 0) {
|
|
21
|
-
return FLOOR;
|
|
22
|
-
}
|
|
23
|
-
if (neededHeight(paragraphs, width, { scale: 1, reduction: 0 }) <= height) {
|
|
24
|
-
return { overflow: false, fontScale: 1, lineReduction: 0 };
|
|
25
|
-
}
|
|
26
|
-
for (let scale = 0.975; scale >= 0.25; scale -= 0.025) {
|
|
27
|
-
const reduction = scale < 0.7 ? 0.2 : 0.1;
|
|
28
|
-
if (neededHeight(paragraphs, width, { scale, reduction }) <= height) {
|
|
29
|
-
return {
|
|
30
|
-
overflow: true,
|
|
31
|
-
fontScale: Math.round(scale * 1000) / 1000,
|
|
32
|
-
lineReduction: reduction
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return FLOOR;
|
|
37
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { Presentation } from './presentation.ts';
|
|
2
|
-
import type { OpenOptions } from '../opc/package.ts';
|
|
3
|
-
import type { CreateOptions } from './template.ts';
|
|
4
|
-
export { Presentation } from './presentation.ts';
|
|
5
|
-
export type * from './types.ts';
|
|
6
|
-
export type { CreateOptions, SlideSize, ThemeColor, ThemeFonts } from './template.ts';
|
|
7
|
-
export declare function open(bytes: Uint8Array, opts?: OpenOptions): Presentation;
|
|
8
|
-
export declare function create(opts?: CreateOptions): Presentation;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type { Element } from '../xml.ts';
|
|
2
|
-
import type { Package } from '../opc/package.ts';
|
|
3
|
-
export interface Box {
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
width: number;
|
|
7
|
-
height: number;
|
|
8
|
-
}
|
|
9
|
-
export interface Insets {
|
|
10
|
-
left: number;
|
|
11
|
-
right: number;
|
|
12
|
-
top: number;
|
|
13
|
-
bottom: number;
|
|
14
|
-
}
|
|
15
|
-
export interface PlaceholderKey {
|
|
16
|
-
type: string;
|
|
17
|
-
idx: string | null;
|
|
18
|
-
}
|
|
19
|
-
export interface ShapeInSlide {
|
|
20
|
-
pkg: Package;
|
|
21
|
-
slide: string;
|
|
22
|
-
el: Element;
|
|
23
|
-
}
|
|
24
|
-
export declare function placeholderOf(el: Element): PlaceholderKey | null;
|
|
25
|
-
export declare function xfrmOf(el: Element): Element | null;
|
|
26
|
-
export declare function explicitBox(el: Element): Box | null;
|
|
27
|
-
export declare function box(shape: ShapeInSlide): Box | null;
|
|
28
|
-
export declare function insets(shape: ShapeInSlide): Insets;
|
|
29
|
-
export declare function fontSize(shape: ShapeInSlide, level: number): number;
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
import * as xml from '../xml.js';
|
|
2
|
-
const { a: A, p: P } = xml.ns;
|
|
3
|
-
const REL_BASE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/';
|
|
4
|
-
const TITLE_TYPES = new Set(['title', 'ctrTitle']);
|
|
5
|
-
const DEFAULT_INSET = 91440;
|
|
6
|
-
const INSET_NAMES = {
|
|
7
|
-
left: 'lIns',
|
|
8
|
-
right: 'rIns',
|
|
9
|
-
top: 'tIns',
|
|
10
|
-
bottom: 'bIns'
|
|
11
|
-
};
|
|
12
|
-
const SIDES = ['left', 'right', 'top', 'bottom'];
|
|
13
|
-
export function placeholderOf(el) {
|
|
14
|
-
const nv = xml.children(el)[0];
|
|
15
|
-
const nvPr = nv ? xml.child(nv, P, 'nvPr') : null;
|
|
16
|
-
const ph = nvPr ? xml.child(nvPr, P, 'ph') : null;
|
|
17
|
-
if (!ph) {
|
|
18
|
-
return null;
|
|
19
|
-
}
|
|
20
|
-
return { type: ph.getAttribute('type') || 'obj', idx: ph.getAttribute('idx') || null };
|
|
21
|
-
}
|
|
22
|
-
export function xfrmOf(el) {
|
|
23
|
-
if (el.localName === 'graphicFrame') {
|
|
24
|
-
return xml.child(el, P, 'xfrm');
|
|
25
|
-
}
|
|
26
|
-
const props = xml.child(el, P, el.localName === 'grpSp' ? 'grpSpPr' : 'spPr');
|
|
27
|
-
return props ? xml.child(props, A, 'xfrm') : null;
|
|
28
|
-
}
|
|
29
|
-
export function explicitBox(el) {
|
|
30
|
-
const xfrm = xfrmOf(el);
|
|
31
|
-
const off = xfrm ? xml.child(xfrm, A, 'off') : null;
|
|
32
|
-
const ext = xfrm ? xml.child(xfrm, A, 'ext') : null;
|
|
33
|
-
if (!off || !ext) {
|
|
34
|
-
return null;
|
|
35
|
-
}
|
|
36
|
-
return {
|
|
37
|
-
x: Number(off.getAttribute('x')),
|
|
38
|
-
y: Number(off.getAttribute('y')),
|
|
39
|
-
width: Number(ext.getAttribute('cx')),
|
|
40
|
-
height: Number(ext.getAttribute('cy'))
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function spTreeShapes(doc) {
|
|
44
|
-
const tree = xml.descendants(doc, P, 'spTree')[0];
|
|
45
|
-
return tree ? xml.children(tree, P, 'sp') : [];
|
|
46
|
-
}
|
|
47
|
-
function matchLayout(doc, key) {
|
|
48
|
-
const shapes = spTreeShapes(doc).flatMap((el) => {
|
|
49
|
-
const ph = placeholderOf(el);
|
|
50
|
-
return ph ? [{ el, ph }] : [];
|
|
51
|
-
});
|
|
52
|
-
const byIdx = key.idx === null ? undefined : shapes.find((s) => s.ph.idx === key.idx);
|
|
53
|
-
if (byIdx) {
|
|
54
|
-
return byIdx.el;
|
|
55
|
-
}
|
|
56
|
-
return shapes.find((s) => s.ph.type === key.type)?.el ?? null;
|
|
57
|
-
}
|
|
58
|
-
function masterType(type) {
|
|
59
|
-
if (TITLE_TYPES.has(type))
|
|
60
|
-
return 'title';
|
|
61
|
-
if (['dt', 'ftr', 'sldNum'].includes(type))
|
|
62
|
-
return type;
|
|
63
|
-
return 'body';
|
|
64
|
-
}
|
|
65
|
-
function matchMaster(doc, key) {
|
|
66
|
-
const wanted = masterType(key.type);
|
|
67
|
-
const found = spTreeShapes(doc).find((el) => {
|
|
68
|
-
const ph = placeholderOf(el);
|
|
69
|
-
return ph !== null && masterType(ph.type) === wanted;
|
|
70
|
-
});
|
|
71
|
-
return found ?? null;
|
|
72
|
-
}
|
|
73
|
-
function layoutOf(pkg, slide) {
|
|
74
|
-
return pkg.related(slide, REL_BASE + 'slideLayout')[0];
|
|
75
|
-
}
|
|
76
|
-
function masterOf(pkg, layout) {
|
|
77
|
-
return pkg.related(layout, REL_BASE + 'slideMaster')[0];
|
|
78
|
-
}
|
|
79
|
-
function chain(shape) {
|
|
80
|
-
const { pkg, slide, el } = shape;
|
|
81
|
-
const key = placeholderOf(el);
|
|
82
|
-
const out = [el];
|
|
83
|
-
const layout = key ? layoutOf(pkg, slide) : undefined;
|
|
84
|
-
if (!key || !layout) {
|
|
85
|
-
return out;
|
|
86
|
-
}
|
|
87
|
-
const layoutShape = matchLayout(pkg.xml(layout), key);
|
|
88
|
-
if (layoutShape) {
|
|
89
|
-
out.push(layoutShape);
|
|
90
|
-
}
|
|
91
|
-
const master = masterOf(pkg, layout);
|
|
92
|
-
const masterShape = master ? matchMaster(pkg.xml(master), key) : null;
|
|
93
|
-
if (masterShape) {
|
|
94
|
-
out.push(masterShape);
|
|
95
|
-
}
|
|
96
|
-
return out;
|
|
97
|
-
}
|
|
98
|
-
export function box(shape) {
|
|
99
|
-
for (const node of chain(shape)) {
|
|
100
|
-
const found = explicitBox(node);
|
|
101
|
-
if (found) {
|
|
102
|
-
return found;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return null;
|
|
106
|
-
}
|
|
107
|
-
function bodyPrOf(node) {
|
|
108
|
-
const txBody = xml.child(node, P, 'txBody');
|
|
109
|
-
return txBody ? xml.child(txBody, A, 'bodyPr') : null;
|
|
110
|
-
}
|
|
111
|
-
export function insets(shape) {
|
|
112
|
-
const out = {
|
|
113
|
-
left: DEFAULT_INSET,
|
|
114
|
-
right: DEFAULT_INSET,
|
|
115
|
-
top: DEFAULT_INSET / 2,
|
|
116
|
-
bottom: DEFAULT_INSET / 2
|
|
117
|
-
};
|
|
118
|
-
const nodes = chain(shape);
|
|
119
|
-
for (const side of SIDES) {
|
|
120
|
-
const found = nodes.map(bodyPrOf).find((bodyPr) => bodyPr?.hasAttribute(INSET_NAMES[side]));
|
|
121
|
-
if (found) {
|
|
122
|
-
out[side] = Number(found.getAttribute(INSET_NAMES[side]));
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
return out;
|
|
126
|
-
}
|
|
127
|
-
function levelSize(list, level) {
|
|
128
|
-
const lvl = list ? xml.child(list, A, `lvl${level + 1}pPr`) : null;
|
|
129
|
-
const def = lvl ? xml.child(lvl, A, 'defRPr') : null;
|
|
130
|
-
return def?.hasAttribute('sz') ? Number(def.getAttribute('sz')) / 100 : null;
|
|
131
|
-
}
|
|
132
|
-
function styleName(key) {
|
|
133
|
-
if (!key)
|
|
134
|
-
return 'otherStyle';
|
|
135
|
-
if (masterType(key.type) === 'title')
|
|
136
|
-
return 'titleStyle';
|
|
137
|
-
return ['body', 'obj', 'subTitle'].includes(key.type) ? 'bodyStyle' : 'otherStyle';
|
|
138
|
-
}
|
|
139
|
-
export function fontSize(shape, level) {
|
|
140
|
-
for (const node of chain(shape)) {
|
|
141
|
-
const txBody = xml.child(node, P, 'txBody');
|
|
142
|
-
const size = levelSize(txBody ? xml.child(txBody, A, 'lstStyle') : null, level);
|
|
143
|
-
if (size) {
|
|
144
|
-
return size;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
const layout = layoutOf(shape.pkg, shape.slide);
|
|
148
|
-
const master = layout ? masterOf(shape.pkg, layout) : undefined;
|
|
149
|
-
if (!master) {
|
|
150
|
-
return 18;
|
|
151
|
-
}
|
|
152
|
-
const styles = xml.child(shape.pkg.root(master), P, 'txStyles');
|
|
153
|
-
const size = levelSize(styles ? xml.child(styles, P, styleName(placeholderOf(shape.el))) : null, level);
|
|
154
|
-
return size || 18;
|
|
155
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { Document, Element } from '../xml.ts';
|
|
2
|
-
import type { Deck } from './slides.ts';
|
|
3
|
-
export declare function notesBody(doc: Document, id: number): Element;
|
|
4
|
-
export declare function writeNotes(deck: Deck, slidePart: string, value: unknown): void;
|
|
5
|
-
export declare function notesText(deck: Deck, slidePart: string): string | null;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import * as xml from '../xml.js';
|
|
2
|
-
import * as text from '../drawingml/text.js';
|
|
3
|
-
import { SHAPE_ORDER, shapesOf, nextShapeId } from './shapes.js';
|
|
4
|
-
import { notesTheme } from './template.js';
|
|
5
|
-
import { PRESENTATION_ORDER } from './slides.js';
|
|
6
|
-
const { a: A, p: P, r: R } = xml.ns;
|
|
7
|
-
const REL_BASE = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/';
|
|
8
|
-
const REL = {
|
|
9
|
-
slide: REL_BASE + 'slide',
|
|
10
|
-
notesSlide: REL_BASE + 'notesSlide',
|
|
11
|
-
notesMaster: REL_BASE + 'notesMaster',
|
|
12
|
-
theme: REL_BASE + 'theme'
|
|
13
|
-
};
|
|
14
|
-
const NOTES_TYPE = 'application/vnd.openxmlformats-officedocument.presentationml.notesSlide+xml';
|
|
15
|
-
const NOTES_MASTER_TYPE = 'application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml';
|
|
16
|
-
const THEME_TYPE = 'application/vnd.openxmlformats-officedocument.theme+xml';
|
|
17
|
-
const NOTES_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<p:notes xmlns:a="${A}" xmlns:r="${R}" xmlns:p="${P}"><p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/><p:sp><p:nvSpPr><p:cNvPr id="2" name="Slide Image Placeholder 1"/><p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr><p:nvPr><p:ph type="sldImg"/></p:nvPr></p:nvSpPr><p:spPr/></p:sp></p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:notes>`;
|
|
18
|
-
const NOTES_MASTER_XML = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n<p:notesMaster xmlns:a="${A}" xmlns:r="${R}" xmlns:p="${P}"><p:cSld><p:bg><p:bgRef idx="1001"><a:schemeClr val="bg1"/></p:bgRef></p:bg><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/><p:sp><p:nvSpPr><p:cNvPr id="2" name="Slide Image Placeholder 1"/><p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr><p:nvPr><p:ph type="sldImg" idx="2"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x="381000" y="685800"/><a:ext cx="6096000" cy="3429000"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom><a:noFill/><a:ln w="12700"><a:solidFill><a:prstClr val="black"/></a:solidFill></a:ln></p:spPr></p:sp><p:sp><p:nvSpPr><p:cNvPr id="3" name="Notes Placeholder 2"/><p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr><p:nvPr><p:ph type="body" sz="quarter" idx="3"/></p:nvPr></p:nvSpPr><p:spPr><a:xfrm><a:off x="685800" y="4343400"/><a:ext cx="5486400" cy="4114800"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr><p:txBody><a:bodyPr vert="horz" lIns="91440" tIns="45720" rIns="91440" bIns="45720" rtlCol="0"/><a:lstStyle/><a:p><a:pPr lvl="0"/><a:r><a:rPr lang="en-US"/><a:t>Click to edit Master text styles</a:t></a:r></a:p></p:txBody></p:sp></p:spTree></p:cSld><p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/><p:notesStyle><a:lvl1pPr marL="0" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1"><a:defRPr sz="1200" kern="1200"><a:solidFill><a:schemeClr val="tx1"/></a:solidFill><a:latin typeface="+mn-lt"/><a:ea typeface="+mn-ea"/><a:cs typeface="+mn-cs"/></a:defRPr></a:lvl1pPr></p:notesStyle></p:notesMaster>`;
|
|
19
|
-
export function notesBody(doc, id) {
|
|
20
|
-
const p = xml.builder(doc, P);
|
|
21
|
-
const sp = p('sp');
|
|
22
|
-
const nv = xml.append(sp, p('nvSpPr'));
|
|
23
|
-
nv.appendChild(p('cNvPr', { id, name: `Notes Placeholder ${id - 1}` }));
|
|
24
|
-
xml.append(nv, p('cNvSpPr')).appendChild(xml.builder(doc, A)('spLocks', { noGrp: 1 }));
|
|
25
|
-
xml.append(nv, p('nvPr')).appendChild(p('ph', { type: 'body', idx: 1 }));
|
|
26
|
-
sp.appendChild(p('spPr'));
|
|
27
|
-
text.ensureTextBody(sp, SHAPE_ORDER);
|
|
28
|
-
return sp;
|
|
29
|
-
}
|
|
30
|
-
function createNotesMaster(deck) {
|
|
31
|
-
const { pkg } = deck;
|
|
32
|
-
const themeSource = pkg.related(deck.main, REL.theme)[0];
|
|
33
|
-
const theme = pkg.freeName('/ppt/theme/theme%d.xml');
|
|
34
|
-
pkg.add(theme, themeSource ? pkg.bytes(themeSource) : notesTheme(), THEME_TYPE);
|
|
35
|
-
const part = pkg.freeName('/ppt/notesMasters/notesMaster%d.xml');
|
|
36
|
-
pkg.add(part, xml.parse(NOTES_MASTER_XML), NOTES_MASTER_TYPE);
|
|
37
|
-
pkg.rels(part).add(REL.theme, theme);
|
|
38
|
-
const rId = pkg.rels(deck.main).add(REL.notesMaster, part);
|
|
39
|
-
const top = pkg.root(deck.main);
|
|
40
|
-
const p = xml.builder(xml.owner(top), P);
|
|
41
|
-
const list = xml.child(top, P, 'notesMasterIdLst') ??
|
|
42
|
-
xml.insertOrdered(top, p('notesMasterIdLst'), PRESENTATION_ORDER);
|
|
43
|
-
const ref = xml.append(list, p('notesMasterId'));
|
|
44
|
-
xml.setNsAttribute(ref, { namespace: R, local: 'id' }, rId);
|
|
45
|
-
pkg.touch(deck.main);
|
|
46
|
-
return part;
|
|
47
|
-
}
|
|
48
|
-
function createNotes(deck, slidePart) {
|
|
49
|
-
const { pkg } = deck;
|
|
50
|
-
const master = pkg.related(deck.main, REL.notesMaster)[0] ?? createNotesMaster(deck);
|
|
51
|
-
const part = pkg.freeName('/ppt/notesSlides/notesSlide%d.xml');
|
|
52
|
-
const doc = xml.parse(NOTES_XML);
|
|
53
|
-
xml.descendants(doc, P, 'spTree')[0]?.appendChild(notesBody(doc, 3));
|
|
54
|
-
pkg.add(part, doc, NOTES_TYPE);
|
|
55
|
-
pkg.rels(part).add(REL.notesMaster, master);
|
|
56
|
-
pkg.rels(part).add(REL.slide, slidePart);
|
|
57
|
-
pkg.rels(slidePart).add(REL.notesSlide, part);
|
|
58
|
-
return part;
|
|
59
|
-
}
|
|
60
|
-
function bodyOf(doc) {
|
|
61
|
-
const existing = shapesOf(doc).find((s) => s.placeholder === 'body');
|
|
62
|
-
if (existing) {
|
|
63
|
-
return existing.el;
|
|
64
|
-
}
|
|
65
|
-
const el = notesBody(doc, nextShapeId(doc));
|
|
66
|
-
xml.descendants(doc, P, 'spTree')[0]?.appendChild(el);
|
|
67
|
-
return el;
|
|
68
|
-
}
|
|
69
|
-
export function writeNotes(deck, slidePart, value) {
|
|
70
|
-
text.normalizeParagraphs(value);
|
|
71
|
-
const notes = deck.pkg.related(slidePart, REL.notesSlide)[0] ?? createNotes(deck, slidePart);
|
|
72
|
-
const txBody = text.ensureTextBody(bodyOf(deck.pkg.xml(notes)), SHAPE_ORDER);
|
|
73
|
-
text.writeParagraphs(txBody, value);
|
|
74
|
-
deck.pkg.touch(notes);
|
|
75
|
-
}
|
|
76
|
-
export function notesText(deck, slidePart) {
|
|
77
|
-
const notes = deck.pkg.related(slidePart, REL.notesSlide)[0];
|
|
78
|
-
if (!notes) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
const body = shapesOf(deck.pkg.xml(notes)).find((s) => s.placeholder === 'body');
|
|
82
|
-
const txBody = body ? xml.child(body.el, P, 'txBody') : null;
|
|
83
|
-
const value = txBody ? text.readText(txBody).trim() : '';
|
|
84
|
-
return value || null;
|
|
85
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { Box } from './inherit.ts';
|
|
2
|
-
import type { SlideSize } from './template.ts';
|
|
3
|
-
export type Role = 'slot' | 'blank' | 'body' | 'picture' | 'other';
|
|
4
|
-
export interface Size {
|
|
5
|
-
readonly width: number;
|
|
6
|
-
readonly height: number;
|
|
7
|
-
}
|
|
8
|
-
export interface Placed {
|
|
9
|
-
readonly box: Box;
|
|
10
|
-
readonly role: Role;
|
|
11
|
-
}
|
|
12
|
-
export interface Beside<T> {
|
|
13
|
-
readonly shape: T;
|
|
14
|
-
readonly box: Box;
|
|
15
|
-
}
|
|
16
|
-
export interface Area<T> {
|
|
17
|
-
readonly box: Box;
|
|
18
|
-
readonly cleared: readonly T[];
|
|
19
|
-
readonly beside: Beside<T> | null;
|
|
20
|
-
}
|
|
21
|
-
export declare function framed(slide: SlideSize): Box;
|
|
22
|
-
export declare function fitted(size: Size, area: Box): Box;
|
|
23
|
-
export declare function pictureArea<T extends Placed>(slide: SlideSize, shapes: readonly T[]): Area<T>;
|