visio-react-viewer 0.0.2 → 0.1.1
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/LICENSE +202 -0
- package/NOTICE +10 -0
- package/README.md +80 -3
- package/dist/assets/edit-worker-DRgXgRud.js +55992 -0
- package/dist/assets/parse-worker-B8EBQQpD.js +53971 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4236 -0
- package/dist/third-party/Inter-OFL.txt +92 -0
- package/dist/types/packages/bindings/src/common.d.ts +29 -0
- package/dist/types/packages/bindings/src/react.d.ts +10 -0
- package/dist/types/packages/react/src/index.d.ts +3 -0
- package/dist/types/src/arrowheads.d.ts +3 -0
- package/dist/types/src/binding.d.ts +27 -0
- package/dist/types/src/contract.d.ts +32 -0
- package/dist/types/src/controller.d.ts +66 -0
- package/dist/types/src/demo-document.d.ts +3 -0
- package/dist/types/src/diagnostics.d.ts +9 -0
- package/dist/types/src/document-history.d.ts +42 -0
- package/dist/types/src/document-text-search.d.ts +44 -0
- package/dist/types/src/edit-commands.d.ts +3 -0
- package/dist/types/src/edit-error.d.ts +4 -0
- package/dist/types/src/edit-worker.d.ts +1 -0
- package/dist/types/src/export-svg.d.ts +25 -0
- package/dist/types/src/foreign-vector-budget.d.ts +24 -0
- package/dist/types/src/index.d.ts +14 -0
- package/dist/types/src/paragraph-layout.d.ts +18 -0
- package/dist/types/src/parse-worker.d.ts +1 -0
- package/dist/types/src/print-snapshot.d.ts +87 -0
- package/dist/types/src/render-fill.d.ts +2 -0
- package/dist/types/src/render-foreign-vector-shape.d.ts +4 -0
- package/dist/types/src/render-foreign-vector.d.ts +3 -0
- package/dist/types/src/render-image.d.ts +4 -0
- package/dist/types/src/render-resources.d.ts +10 -0
- package/dist/types/src/render-svg.d.ts +17 -0
- package/dist/types/src/render-text.d.ts +4 -0
- package/dist/types/src/scene-details.d.ts +7 -0
- package/dist/types/src/scene-validation.d.ts +4 -0
- package/dist/types/src/shape-inspector.d.ts +5 -0
- package/dist/types/src/snapshot-scene.d.ts +8 -0
- package/dist/types/src/styles.d.ts +2 -0
- package/dist/types/src/text-layout.d.ts +45 -0
- package/dist/types/src/viewer-chrome.d.ts +10 -0
- package/dist/types/src/viewer-edit-controls.d.ts +12 -0
- package/dist/types/src/viewer-element.d.ts +44 -0
- package/dist/types/src/viewer-geometry-controls.d.ts +14 -0
- package/dist/types/src/viewer-input.d.ts +10 -0
- package/dist/types/src/viewer-layer-controls.d.ts +5 -0
- package/dist/types/src/viewer-layers.d.ts +22 -0
- package/dist/types/src/viewer-search.d.ts +10 -0
- package/dist/types/src/worker-editor.d.ts +23 -0
- package/dist/types/src/worker-parser.d.ts +13 -0
- package/package.json +22 -7
- package/index.js +0 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
Copyright (c) 2016 The Inter Project Authors (https://github.com/rsms/inter)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
-----------------------------------------------------------
|
|
8
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
9
|
+
-----------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
PREAMBLE
|
|
12
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
13
|
+
development of collaborative font projects, to support the font creation
|
|
14
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
15
|
+
open framework in which fonts may be shared and improved in partnership
|
|
16
|
+
with others.
|
|
17
|
+
|
|
18
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
19
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
20
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
21
|
+
redistributed and/or sold with any software provided that any reserved
|
|
22
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
23
|
+
however, cannot be released under any other type of license. The
|
|
24
|
+
requirement for fonts to remain under this license does not apply
|
|
25
|
+
to any document created using the fonts or their derivatives.
|
|
26
|
+
|
|
27
|
+
DEFINITIONS
|
|
28
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
29
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
30
|
+
include source files, build scripts and documentation.
|
|
31
|
+
|
|
32
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
33
|
+
copyright statement(s).
|
|
34
|
+
|
|
35
|
+
"Original Version" refers to the collection of Font Software components as
|
|
36
|
+
distributed by the Copyright Holder(s).
|
|
37
|
+
|
|
38
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
39
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
40
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
41
|
+
new environment.
|
|
42
|
+
|
|
43
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
44
|
+
writer or other person who contributed to the Font Software.
|
|
45
|
+
|
|
46
|
+
PERMISSION AND CONDITIONS
|
|
47
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
48
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
49
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
50
|
+
Software, subject to the following conditions:
|
|
51
|
+
|
|
52
|
+
1) Neither the Font Software nor any of its individual components,
|
|
53
|
+
in Original or Modified Versions, may be sold by itself.
|
|
54
|
+
|
|
55
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
56
|
+
redistributed and/or sold with any software, provided that each copy
|
|
57
|
+
contains the above copyright notice and this license. These can be
|
|
58
|
+
included either as stand-alone text files, human-readable headers or
|
|
59
|
+
in the appropriate machine-readable metadata fields within text or
|
|
60
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
61
|
+
|
|
62
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
63
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
64
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
65
|
+
presented to the users.
|
|
66
|
+
|
|
67
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
68
|
+
Software shall not be used to promote, endorse or advertise any
|
|
69
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
70
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
71
|
+
permission.
|
|
72
|
+
|
|
73
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
74
|
+
must be distributed entirely under this license, and must not be
|
|
75
|
+
distributed under any other license. The requirement for fonts to
|
|
76
|
+
remain under this license does not apply to any document created
|
|
77
|
+
using the Font Software.
|
|
78
|
+
|
|
79
|
+
TERMINATION
|
|
80
|
+
This license becomes null and void if any of the above conditions are
|
|
81
|
+
not met.
|
|
82
|
+
|
|
83
|
+
DISCLAIMER
|
|
84
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
85
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
86
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
87
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
88
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
89
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
90
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
91
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
92
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { mountViewer, type MountedViewer } from '../../../src/binding.js';
|
|
2
|
+
import { eventKeys, propertyKeys, type ViewerCallbacks, type ViewerOptions, type ViewerProperties } from '../../../src/contract.js';
|
|
3
|
+
/** Framework props permit undefined; omitted values preserve the shared binding's state. */
|
|
4
|
+
export type ViewerProps = {
|
|
5
|
+
[K in keyof ViewerProperties]?: ViewerProperties[K] | undefined;
|
|
6
|
+
} & {
|
|
7
|
+
events?: ViewerCallbacks | undefined;
|
|
8
|
+
};
|
|
9
|
+
export type ViewerHandle = Pick<MountedViewer, 'element' | 'controller' | 'load' | 'applyEdits' | 'replacePlainText' | 'undo' | 'redo' | 'cancelEdit' | 'exportVsdx' | 'fit' | 'setLayerVisibility' | 'resetLayerVisibility' | 'exportSvg' | 'createPrintSnapshot'>;
|
|
10
|
+
/** One mapping for every property and event, shared by every framework adapter. */
|
|
11
|
+
export declare function viewerOptions(props: ViewerProps): ViewerOptions;
|
|
12
|
+
/**
|
|
13
|
+
* Native props are snapshots, while the browser binding accepts explicit patches. Forward only
|
|
14
|
+
* changed properties so a callback/class update cannot undo an imperative load or user zoom.
|
|
15
|
+
*/
|
|
16
|
+
export declare function mountFrameworkViewer(container: HTMLElement, initial: ViewerOptions): MountedViewer;
|
|
17
|
+
/** Lazy imperative methods reject both before mount and after unmount. */
|
|
18
|
+
export declare function viewerHandle(current: () => MountedViewer | undefined): ViewerHandle;
|
|
19
|
+
/** Native framework emits and callback-map props share one complete event inventory. */
|
|
20
|
+
export declare function withEventEmitter(props: ViewerProps, emit: (name: keyof ViewerCallbacks, value: unknown) => void): ViewerOptions;
|
|
21
|
+
export { mountViewer };
|
|
22
|
+
export type { MountedViewer, ViewerCallbacks, ViewerOptions, ViewerProperties };
|
|
23
|
+
export { eventKeys, propertyKeys };
|
|
24
|
+
export type { ViewerEvents, VsdxSource } from '../../../src/contract.js';
|
|
25
|
+
export { ViewerController, type ViewerState } from '../../../src/controller.js';
|
|
26
|
+
export type { SvgExportOptions, SvgExportResult } from '../../../src/export-svg.js';
|
|
27
|
+
export type { CurrentPagePrintSnapshotOptions, PrintSnapshot, PrintSnapshotPage, PrintSnapshotOptions, PrintSnapshotLimits, PrintSnapshotUsage, } from '../../../src/print-snapshot.js';
|
|
28
|
+
export type { ViewerEditState, VsdxExportResult } from '../../../src/document-history.js';
|
|
29
|
+
export type { VisioEdit, VisioGeometryEdit } from 'ooxml-core/visio';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type CSSProperties } from 'react';
|
|
2
|
+
import { type ViewerHandle, type ViewerProps } from './common.js';
|
|
3
|
+
export interface VisioViewerProps extends ViewerProps {
|
|
4
|
+
className?: string | undefined;
|
|
5
|
+
style?: CSSProperties | undefined;
|
|
6
|
+
'aria-label'?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
/** React owns only the host and lifecycle; the shared element owns all viewer behavior. */
|
|
9
|
+
export declare const VisioViewer: import("react").ForwardRefExoticComponent<VisioViewerProps & import("react").RefAttributes<ViewerHandle>>;
|
|
10
|
+
export type { ViewerHandle, ViewerCallbacks, ViewerOptions, ViewerEvents, ViewerEditState, VsdxExportResult, } from './common.js';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { VisioStyle } from 'ooxml-core/visio';
|
|
2
|
+
/** Common Visio line/triangle and concave arrow styles. Sizes remain a documented visual approximation. */
|
|
3
|
+
export declare function applyArrowheads(path: SVGPathElement, style: VisioStyle, defs: SVGDefsElement, warnings: Set<string>): void;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { VisioEdit } from 'ooxml-core/visio';
|
|
2
|
+
import type { ViewerOptions, VsdxSource } from './contract.js';
|
|
3
|
+
import { type VisioViewerElement } from './viewer-element.js';
|
|
4
|
+
import type { ViewerController } from './controller.js';
|
|
5
|
+
import type { SvgExportOptions, SvgExportResult } from './export-svg.js';
|
|
6
|
+
import type { CurrentPagePrintSnapshotOptions, PrintSnapshot } from './print-snapshot.js';
|
|
7
|
+
import type { VsdxExportResult } from './document-history.js';
|
|
8
|
+
export interface MountedViewer {
|
|
9
|
+
readonly element: VisioViewerElement;
|
|
10
|
+
readonly controller: ViewerController;
|
|
11
|
+
update(options: ViewerOptions): void;
|
|
12
|
+
load(source: VsdxSource): Promise<void>;
|
|
13
|
+
applyEdits(edits: readonly VisioEdit[]): Promise<void>;
|
|
14
|
+
replacePlainText(pageId: string, shapeId: string, text: string): Promise<void>;
|
|
15
|
+
undo(): Promise<void>;
|
|
16
|
+
redo(): Promise<void>;
|
|
17
|
+
cancelEdit(): void;
|
|
18
|
+
exportVsdx(): VsdxExportResult;
|
|
19
|
+
fit(): void;
|
|
20
|
+
setLayerVisibility(pageId: string, layerId: string, visible: boolean | null): void;
|
|
21
|
+
resetLayerVisibility(pageId?: string): void;
|
|
22
|
+
exportSvg(options?: SvgExportOptions): SvgExportResult;
|
|
23
|
+
createPrintSnapshot(options?: CurrentPagePrintSnapshotOptions): PrintSnapshot;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
}
|
|
26
|
+
/** One client-only lifecycle adapter; framework wrappers forward to this implementation. */
|
|
27
|
+
export declare function mountViewer(container: HTMLElement, initial?: ViewerOptions): MountedViewer;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { VisioDocument } from 'ooxml-core/visio';
|
|
2
|
+
export interface ViewerProperties {
|
|
3
|
+
document: VisioDocument | null;
|
|
4
|
+
pageIndex: number;
|
|
5
|
+
zoom: number;
|
|
6
|
+
showToolbar: boolean;
|
|
7
|
+
}
|
|
8
|
+
export interface ViewerEvents {
|
|
9
|
+
'document-load': VisioDocument;
|
|
10
|
+
'document-change': {
|
|
11
|
+
document: VisioDocument;
|
|
12
|
+
dirty: boolean;
|
|
13
|
+
kind: 'edit' | 'undo' | 'redo';
|
|
14
|
+
};
|
|
15
|
+
'document-error': Error;
|
|
16
|
+
'page-change': number;
|
|
17
|
+
'zoom-change': number;
|
|
18
|
+
'shape-select': {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
pageId?: string;
|
|
22
|
+
} | null;
|
|
23
|
+
}
|
|
24
|
+
export type ViewerCallbacks = {
|
|
25
|
+
[K in keyof ViewerEvents]?: (detail: ViewerEvents[K]) => void;
|
|
26
|
+
};
|
|
27
|
+
export declare const propertyKeys: readonly ["document", "pageIndex", "zoom", "showToolbar"];
|
|
28
|
+
export declare const eventKeys: readonly ["document-load", "document-change", "document-error", "page-change", "zoom-change", "shape-select"];
|
|
29
|
+
export type VsdxSource = ArrayBuffer | Uint8Array | Blob;
|
|
30
|
+
export interface ViewerOptions extends Partial<ViewerProperties> {
|
|
31
|
+
events?: ViewerCallbacks;
|
|
32
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type ViewerEditState, type VsdxExportResult } from './document-history.js';
|
|
2
|
+
import { type CancellableEditor } from './worker-editor.js';
|
|
3
|
+
import { type VisioDocument, type VisioEdit } from 'ooxml-core/visio';
|
|
4
|
+
import { type LayerVisibilityOverride } from './viewer-layers.js';
|
|
5
|
+
import type { CancellableParser } from './worker-parser.js';
|
|
6
|
+
import type { ViewerEvents } from './contract.js';
|
|
7
|
+
import { type TextSearchState } from './document-text-search.js';
|
|
8
|
+
export interface ViewerState {
|
|
9
|
+
readonly document: VisioDocument | null;
|
|
10
|
+
readonly edit: ViewerEditState;
|
|
11
|
+
readonly pageIndex: number;
|
|
12
|
+
readonly zoom: number;
|
|
13
|
+
readonly loading: boolean;
|
|
14
|
+
readonly error: Error | null;
|
|
15
|
+
readonly search: TextSearchState;
|
|
16
|
+
/** Viewer-only display overrides, independent of saved model and print policy. */
|
|
17
|
+
readonly layerVisibilityOverrides: readonly LayerVisibilityOverride[];
|
|
18
|
+
readonly selectedShape: {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
pageId?: string;
|
|
22
|
+
} | null;
|
|
23
|
+
}
|
|
24
|
+
type Parser = CancellableParser;
|
|
25
|
+
type EventListener = <K extends keyof ViewerEvents>(name: K, detail: ViewerEvents[K]) => void;
|
|
26
|
+
export declare class ViewerController {
|
|
27
|
+
#private;
|
|
28
|
+
private readonly parser;
|
|
29
|
+
private readonly listenerError;
|
|
30
|
+
private readonly editor;
|
|
31
|
+
constructor(parser?: Parser, listenerError?: (error: unknown) => void, editor?: CancellableEditor);
|
|
32
|
+
get state(): ViewerState;
|
|
33
|
+
/** Accepted document replacements, including the same object, invalidate captured artifacts. */
|
|
34
|
+
get documentGeneration(): number;
|
|
35
|
+
/** Accepted source/model replacements invalidate drafts; edit/undo/redo keep this source epoch. */
|
|
36
|
+
get sourceGeneration(): number;
|
|
37
|
+
subscribe(listener: (state: ViewerState) => void): () => void;
|
|
38
|
+
onEvent(listener: EventListener): () => void;
|
|
39
|
+
setDocument(document: VisioDocument | null): void;
|
|
40
|
+
setPage(index: number): void;
|
|
41
|
+
setZoom(zoom: number): void;
|
|
42
|
+
selectShape(shape: ViewerState['selectedShape']): void;
|
|
43
|
+
/** Override one source-page layer for viewing. null restores its saved display flag. */
|
|
44
|
+
setLayerVisibility(pageId: string, layerId: string, visible: boolean | null): void;
|
|
45
|
+
/** Reset a source page, or all pages when omitted. Does not modify the document. */
|
|
46
|
+
resetLayerVisibility(pageId?: string): void;
|
|
47
|
+
/** Search does not change the page or selection until explicit result navigation. */
|
|
48
|
+
setSearchQuery(query: string): void;
|
|
49
|
+
selectSearchResult(index: number): void;
|
|
50
|
+
nextSearchResult(): void;
|
|
51
|
+
previousSearchResult(): void;
|
|
52
|
+
load(bytes: Uint8Array | ArrayBuffer): Promise<void>;
|
|
53
|
+
/** Reading bytes shares the same request epoch and error state as parsing them. */
|
|
54
|
+
loadSource(read: () => Uint8Array | ArrayBuffer | Promise<Uint8Array | ArrayBuffer>): Promise<void>;
|
|
55
|
+
cancelLoad(): void;
|
|
56
|
+
destroy(): void;
|
|
57
|
+
/** Replace one source-backed local plain-text target. Core decides target support. */
|
|
58
|
+
replacePlainText(pageId: string, shapeId: string, text: string): Promise<void>;
|
|
59
|
+
/** Atomic source-backed edits. Core owns protection, dependency and target validation. */
|
|
60
|
+
applyEdits(edits: readonly VisioEdit[]): Promise<void>;
|
|
61
|
+
undo(): Promise<void>;
|
|
62
|
+
redo(): Promise<void>;
|
|
63
|
+
cancelEdit(): void;
|
|
64
|
+
exportVsdx(): VsdxExportResult;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { VisioDiagnostic } from 'ooxml-core/visio';
|
|
2
|
+
export interface CompatibilityNote {
|
|
3
|
+
message: string;
|
|
4
|
+
count: number;
|
|
5
|
+
severity: 'info' | 'warning';
|
|
6
|
+
}
|
|
7
|
+
/** Presentation-only grouping keeps repeated per-shape diagnostics readable without losing counts. */
|
|
8
|
+
export declare function compatibilityNotes(diagnostics: readonly VisioDiagnostic[], renderWarnings?: readonly string[]): CompatibilityNote[];
|
|
9
|
+
export declare function compatibilityText(note: CompatibilityNote): string;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** Source snapshots only. No document model is serialized by the viewer. */
|
|
2
|
+
export interface EditDiagnostic {
|
|
3
|
+
readonly code: string;
|
|
4
|
+
readonly message: string;
|
|
5
|
+
}
|
|
6
|
+
export interface VsdxExportResult {
|
|
7
|
+
bytes: Uint8Array;
|
|
8
|
+
dirty: boolean;
|
|
9
|
+
diagnostics: readonly EditDiagnostic[];
|
|
10
|
+
}
|
|
11
|
+
export interface ViewerEditState {
|
|
12
|
+
readonly sourceAvailable: boolean;
|
|
13
|
+
readonly busy: boolean;
|
|
14
|
+
readonly dirty: boolean;
|
|
15
|
+
readonly canUndo: boolean;
|
|
16
|
+
readonly canRedo: boolean;
|
|
17
|
+
readonly historyTruncated: boolean;
|
|
18
|
+
readonly error: Error | null;
|
|
19
|
+
readonly diagnostics: readonly EditDiagnostic[];
|
|
20
|
+
}
|
|
21
|
+
export declare const EMPTY_EDIT_STATE: ViewerEditState;
|
|
22
|
+
export declare const EDIT_HISTORY_LIMITS: Readonly<{
|
|
23
|
+
maxBytes: number;
|
|
24
|
+
maxEntries: 20;
|
|
25
|
+
}>;
|
|
26
|
+
export interface SourceSnapshot {
|
|
27
|
+
readonly bytes: Uint8Array;
|
|
28
|
+
readonly diagnostics: readonly EditDiagnostic[];
|
|
29
|
+
}
|
|
30
|
+
/** Private controller-owned bytes; transient worker copies and models are separate from this budget. */
|
|
31
|
+
export declare class DocumentHistory {
|
|
32
|
+
#private;
|
|
33
|
+
readonly original: SourceSnapshot;
|
|
34
|
+
constructor(bytes: Uint8Array);
|
|
35
|
+
get current(): SourceSnapshot;
|
|
36
|
+
get undoTarget(): SourceSnapshot | undefined;
|
|
37
|
+
get redoTarget(): SourceSnapshot | undefined;
|
|
38
|
+
get state(): ViewerEditState;
|
|
39
|
+
append(bytes: Uint8Array, diagnostics: readonly EditDiagnostic[]): void;
|
|
40
|
+
move(target: SourceSnapshot): void;
|
|
41
|
+
export(): VsdxExportResult;
|
|
42
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { VisioDocument, VisioShape } from 'ooxml-core/visio';
|
|
2
|
+
/** UTF-16 character bounds, applied before copying or case conversion. */
|
|
3
|
+
export declare const TEXT_SEARCH_LIMITS: Readonly<{
|
|
4
|
+
queryCharacters: 256;
|
|
5
|
+
results: 500;
|
|
6
|
+
indexedCharacters: 2000000;
|
|
7
|
+
shapeCharacters: 32768;
|
|
8
|
+
previewCharacters: 160;
|
|
9
|
+
shapes: 25000;
|
|
10
|
+
depth: 64;
|
|
11
|
+
}>;
|
|
12
|
+
export interface TextSearchResult {
|
|
13
|
+
readonly pageIndex: number;
|
|
14
|
+
readonly pageId: string;
|
|
15
|
+
readonly pageName: string;
|
|
16
|
+
readonly shapeId: string;
|
|
17
|
+
readonly shapeName: string;
|
|
18
|
+
/** Bounded start-of-text preview, not a match offset or highlighted excerpt. */
|
|
19
|
+
readonly preview: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TextSearchState {
|
|
22
|
+
readonly query: string;
|
|
23
|
+
readonly results: readonly TextSearchResult[];
|
|
24
|
+
/** -1 until the user explicitly navigates, or after manual page/shape selection. */
|
|
25
|
+
readonly activeIndex: number;
|
|
26
|
+
readonly indexTruncated: boolean;
|
|
27
|
+
readonly resultsTruncated: boolean;
|
|
28
|
+
}
|
|
29
|
+
interface SearchEntry {
|
|
30
|
+
readonly result: TextSearchResult;
|
|
31
|
+
readonly foldedText: string;
|
|
32
|
+
}
|
|
33
|
+
export interface DocumentTextIndex {
|
|
34
|
+
readonly entries: readonly SearchEntry[];
|
|
35
|
+
readonly truncated: boolean;
|
|
36
|
+
}
|
|
37
|
+
export declare const EMPTY_TEXT_SEARCH: TextSearchState;
|
|
38
|
+
/** Index canonical text for the current display state. No XML, DOM or layout parsing. */
|
|
39
|
+
export declare function indexDocumentText(model: VisioDocument | null, isVisible?: (shape: VisioShape) => boolean): DocumentTextIndex;
|
|
40
|
+
export declare function validateSearchQuery(query: string): void;
|
|
41
|
+
/** One match per shape, literal ECMAScript lowercase comparison; no regex or language collation. */
|
|
42
|
+
export declare function searchDocumentText(index: DocumentTextIndex, query: string): TextSearchState;
|
|
43
|
+
export declare function textSearchStatus(search: TextSearchState): string;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Core error codes remain visible for a refused transaction; document content is plain text. */
|
|
2
|
+
export declare function editErrorMessage(error: unknown): string;
|
|
3
|
+
/** Superseded worker/load operations are cancellation, not a refused document edit. */
|
|
4
|
+
export declare function isEditCancellation(error: unknown): boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type VisioDocument, type VisioPage } from 'ooxml-core/visio';
|
|
2
|
+
import { type CompatibilityNote } from './diagnostics.js';
|
|
3
|
+
export declare const MAX_SVG_EXPORT_BYTES: number;
|
|
4
|
+
export interface SvgExportOptions {
|
|
5
|
+
/** UTF-8 output ceiling. May lower, but never raise, the 16 MiB safety limit. */
|
|
6
|
+
maxBytes?: number;
|
|
7
|
+
}
|
|
8
|
+
export interface SvgExportResult {
|
|
9
|
+
readonly svg: string;
|
|
10
|
+
readonly byteLength: number;
|
|
11
|
+
readonly pageIndex: number;
|
|
12
|
+
readonly pageName: string;
|
|
13
|
+
/** Saved page dimensions in inches, independent of viewport zoom. */
|
|
14
|
+
readonly width: number;
|
|
15
|
+
readonly height: number;
|
|
16
|
+
readonly diagnostics: CompatibilityNote[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Export one page through the shared renderer, including its resolved backgrounds.
|
|
20
|
+
* Requires a browser DOM at call time, never uploads, downloads or mutates viewer state.
|
|
21
|
+
* Conservative preflight limits can reject a page whose eventual serialization would be smaller.
|
|
22
|
+
*/
|
|
23
|
+
export declare function exportPageSvg(model: VisioDocument, pageIndex?: number, options?: SvgExportOptions): SvgExportResult;
|
|
24
|
+
/** @internal Call only after canonical scene validation. Shared conservative allocation preflight. */
|
|
25
|
+
export declare function estimatePageSvgBytes(model: VisioDocument, page: VisioPage, maxBytes: number): number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type VisioForeignVector } from 'ooxml-core/visio';
|
|
2
|
+
/** UI allocation limits, charged for every instance, including repeated shared resources. */
|
|
3
|
+
export declare const FOREIGN_VECTOR_SCENE_LIMITS: Readonly<{
|
|
4
|
+
maxNodes: 100000;
|
|
5
|
+
maxCommands: 400000;
|
|
6
|
+
maxOperands: 1000000;
|
|
7
|
+
}>;
|
|
8
|
+
export interface ForeignVectorResource {
|
|
9
|
+
readonly vector: VisioForeignVector;
|
|
10
|
+
readonly nodes: number;
|
|
11
|
+
readonly commands: number;
|
|
12
|
+
readonly operands: number;
|
|
13
|
+
readonly svgBytes: number;
|
|
14
|
+
readonly validationWork: number;
|
|
15
|
+
}
|
|
16
|
+
/** Count work only after canonical validation. Interpretation and safety remain in core. */
|
|
17
|
+
export declare function inspectForeignVectorResource(source: unknown): ForeignVectorResource;
|
|
18
|
+
/** Invocation-local budget. Never trusts frozen host objects or caches across calls. */
|
|
19
|
+
export declare class ForeignVectorBudget {
|
|
20
|
+
private nodes;
|
|
21
|
+
private commands;
|
|
22
|
+
private operands;
|
|
23
|
+
take(source: unknown): ForeignVectorResource;
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { ViewerController, type ViewerState } from './controller.js';
|
|
2
|
+
export { mountViewer, type MountedViewer } from './binding.js';
|
|
3
|
+
export { VisioViewerElement, registerVisioViewer } from './viewer-element.js';
|
|
4
|
+
export { renderPage, type RenderResult, type RenderOptions } from './render-svg.js';
|
|
5
|
+
export { exportPageSvg, MAX_SVG_EXPORT_BYTES, type SvgExportOptions, type SvgExportResult, } from './export-svg.js';
|
|
6
|
+
export { createPrintSnapshot, PRINT_SNAPSHOT_LIMITS, type PrintSnapshot, type PrintSnapshotPage, type PrintSnapshotOptions, type PrintSnapshotLimits, type PrintSnapshotUsage, type CurrentPagePrintSnapshotOptions, } from './print-snapshot.js';
|
|
7
|
+
export { eventKeys, propertyKeys, type ViewerProperties, type ViewerEvents, type ViewerCallbacks, type ViewerOptions, type VsdxSource, } from './contract.js';
|
|
8
|
+
export type { VisioDocument, VisioPage, VisioShape, VisioDiagnostic } from 'ooxml-core/visio';
|
|
9
|
+
export { createWorkerParser, type CancellableParser } from './worker-parser.js';
|
|
10
|
+
export { compatibilityNotes, compatibilityText, type CompatibilityNote } from './diagnostics.js';
|
|
11
|
+
export { TEXT_SEARCH_LIMITS, type TextSearchResult, type TextSearchState, } from './document-text-search.js';
|
|
12
|
+
export { VIEWER_LAYER_LIMITS, type LayerVisibilityOverride } from './viewer-layers.js';
|
|
13
|
+
export type { ViewerEditState, VsdxExportResult } from './document-history.js';
|
|
14
|
+
export type { VisioEdit, VisioGeometryEdit } from 'ooxml-core/visio';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { VisioParagraph, VisioText } from 'ooxml-core/visio';
|
|
2
|
+
import { type TextLayoutBudget, type MeasureText, type TextLine } from './text-layout.js';
|
|
3
|
+
export interface PositionedLine extends TextLine {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
availableWidth: number;
|
|
7
|
+
align: VisioParagraph['horizontalAlign'];
|
|
8
|
+
direction: 'ltr' | 'rtl';
|
|
9
|
+
last: boolean;
|
|
10
|
+
bullet?: NonNullable<VisioParagraph['bullet']> & {
|
|
11
|
+
x: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
export interface ParagraphLayout {
|
|
15
|
+
lines: PositionedLine[];
|
|
16
|
+
height: number;
|
|
17
|
+
}
|
|
18
|
+
export declare function layoutParagraphs(text: VisioText, measure?: MeasureText, budget?: TextLayoutBudget): ParagraphLayout;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { type VisioDocument } from 'ooxml-core/visio';
|
|
2
|
+
import type { CompatibilityNote } from './diagnostics.js';
|
|
3
|
+
/** Application guardrails, not printer capabilities or Microsoft Visio limits. */
|
|
4
|
+
export declare const PRINT_SNAPSHOT_LIMITS: Readonly<{
|
|
5
|
+
maxPages: 32;
|
|
6
|
+
maxTotalBytes: number;
|
|
7
|
+
maxPageBytes: number;
|
|
8
|
+
maxShapeInstances: 100000;
|
|
9
|
+
maxGeometryInstances: 100000;
|
|
10
|
+
maxPathCharacters: 16000000;
|
|
11
|
+
maxTextCharacters: 1000000;
|
|
12
|
+
maxTextRuns: 100000;
|
|
13
|
+
maxImageBytes: number;
|
|
14
|
+
maxUniqueImagePixels: 64000000;
|
|
15
|
+
maxImageInstancePixels: 256000000;
|
|
16
|
+
maxVectorNodes: 100000;
|
|
17
|
+
maxVectorCommands: 400000;
|
|
18
|
+
maxVectorOperands: 1000000;
|
|
19
|
+
maxPageAxisCssPixels: 4096;
|
|
20
|
+
maxPageAreaCssPixels: 16000000;
|
|
21
|
+
maxTotalAreaCssPixels: 64000000;
|
|
22
|
+
maxValidationShapeVisits: 1000000;
|
|
23
|
+
maxValidationWork: number;
|
|
24
|
+
}>;
|
|
25
|
+
export type PrintSnapshotLimits = {
|
|
26
|
+
-readonly [K in keyof typeof PRINT_SNAPSHOT_LIMITS]: number;
|
|
27
|
+
};
|
|
28
|
+
export interface PrintSnapshotOptions {
|
|
29
|
+
/** Explicit output order. Background pages are included as sheets only when selected. */
|
|
30
|
+
readonly pageIndices: readonly number[];
|
|
31
|
+
/** Positive integer limits may lower, but never raise, the hard ceilings. */
|
|
32
|
+
readonly limits?: Partial<PrintSnapshotLimits>;
|
|
33
|
+
}
|
|
34
|
+
/** Viewer handles always capture exactly the current page. */
|
|
35
|
+
export type CurrentPagePrintSnapshotOptions = Omit<PrintSnapshotOptions, 'pageIndices'>;
|
|
36
|
+
export interface PrintSnapshotPage {
|
|
37
|
+
readonly pageIndex: number;
|
|
38
|
+
readonly pageId: string;
|
|
39
|
+
readonly pageName: string;
|
|
40
|
+
/** Saved drawing dimensions, not printer paper, margins, orientation or scale. */
|
|
41
|
+
readonly drawingSize: Readonly<{
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
unit: 'in';
|
|
45
|
+
}>;
|
|
46
|
+
/** An isolated SVG document. Do not concatenate page trees with colliding resource IDs. */
|
|
47
|
+
readonly svg: string;
|
|
48
|
+
readonly byteLength: number;
|
|
49
|
+
readonly diagnostics: readonly Readonly<CompatibilityNote>[];
|
|
50
|
+
}
|
|
51
|
+
export interface PrintSnapshotUsage {
|
|
52
|
+
readonly estimatedSvgBytes: number;
|
|
53
|
+
readonly svgBytes: number;
|
|
54
|
+
readonly shapeInstances: number;
|
|
55
|
+
readonly geometryInstances: number;
|
|
56
|
+
readonly pathCharacters: number;
|
|
57
|
+
readonly textCharacters: number;
|
|
58
|
+
readonly textRuns: number;
|
|
59
|
+
/** Raw resources counted once per byte identity per output page, including backgrounds. */
|
|
60
|
+
readonly imageBytes: number;
|
|
61
|
+
readonly uniqueImagePixels: number;
|
|
62
|
+
readonly imageInstancePixels: number;
|
|
63
|
+
/** Includes all clip reference expansions and repeated/background vector instances. */
|
|
64
|
+
readonly vectorNodes: number;
|
|
65
|
+
readonly vectorCommands: number;
|
|
66
|
+
readonly vectorOperands: number;
|
|
67
|
+
readonly totalAreaCssPixels: number;
|
|
68
|
+
readonly validationShapeVisits: number;
|
|
69
|
+
/** Conservative bytes, characters and records across validation and the private copy pass. */
|
|
70
|
+
readonly validationWork: number;
|
|
71
|
+
}
|
|
72
|
+
export interface PrintSnapshot {
|
|
73
|
+
readonly appearance: 'saved-display';
|
|
74
|
+
readonly pageIndices: readonly number[];
|
|
75
|
+
readonly pages: readonly PrintSnapshotPage[];
|
|
76
|
+
readonly byteLength: number;
|
|
77
|
+
readonly limits: Readonly<PrintSnapshotLimits>;
|
|
78
|
+
readonly usage: PrintSnapshotUsage;
|
|
79
|
+
readonly limitations: readonly string[];
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Synchronously prepare bounded, immutable page artifacts through the shared SVG renderer.
|
|
83
|
+
* Requires its DOM/serializer, but never mounts nodes, downloads, fetches, opens frames or prints.
|
|
84
|
+
* Canonical scene/raster validation is repeated on every call. No source object is frozen.
|
|
85
|
+
* Conservative budgets include hidden content and can reject otherwise exportable individual pages.
|
|
86
|
+
*/
|
|
87
|
+
export declare function createPrintSnapshot(model: VisioDocument, options: PrintSnapshotOptions): PrintSnapshot;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VisioShape } from 'ooxml-core/visio';
|
|
2
|
+
import type { ForeignVectorBudget } from './foreign-vector-budget.js';
|
|
3
|
+
/** Core supplies shape-local placement; converter coordinates have a downward Y axis. */
|
|
4
|
+
export declare function renderForeignVectorShape(shape: VisioShape, budget: ForeignVectorBudget): SVGGElement | undefined;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ForeignVectorBudget } from './foreign-vector-budget.js';
|
|
2
|
+
/** Render an independently validated inert scene. Never forwards source tags, IDs or attributes. */
|
|
3
|
+
export declare function renderForeignVector(source: unknown, owner?: Document, budget?: ForeignVectorBudget): SVGSVGElement;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VisioShape } from 'ooxml-core/visio';
|
|
2
|
+
import type { RenderResources } from './render-resources.js';
|
|
3
|
+
/** URLs are created only from bounded embedded raster bytes, never from document strings. */
|
|
4
|
+
export declare function renderImage(shape: VisioShape, resources: RenderResources): SVGGElement | undefined;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { VisioImage } from 'ooxml-core/visio';
|
|
2
|
+
/** One reference per shared core image resource, with explicit per-render disposal. */
|
|
3
|
+
export declare class RenderResources {
|
|
4
|
+
#private;
|
|
5
|
+
private readonly definitions?;
|
|
6
|
+
constructor(definitions?: SVGDefsElement | undefined);
|
|
7
|
+
get portable(): boolean;
|
|
8
|
+
imageUrl(image: VisioImage): string;
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type VisioDocument, type VisioPage, type VisioMatrix } from 'ooxml-core/visio';
|
|
2
|
+
import { type LayerVisibilityOverride } from './viewer-layers.js';
|
|
3
|
+
export declare function svgElement<K extends keyof SVGElementTagNameMap>(name: K): SVGElementTagNameMap[K];
|
|
4
|
+
export declare function safeColor(value: string, fallback?: string): string;
|
|
5
|
+
export declare function matrix(value: VisioMatrix): string;
|
|
6
|
+
export interface RenderResult {
|
|
7
|
+
svg: SVGSVGElement;
|
|
8
|
+
warnings: string[];
|
|
9
|
+
dispose(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface RenderOptions {
|
|
12
|
+
/** Static output embeds rasters and omits viewer selection semantics. Prefer exportPageSvg for bounded serialization. */
|
|
13
|
+
static?: boolean;
|
|
14
|
+
/** Optional viewer display state. Export/print snapshot APIs deliberately use saved display. */
|
|
15
|
+
layerVisibilityOverrides?: readonly LayerVisibilityOverride[];
|
|
16
|
+
}
|
|
17
|
+
export declare function renderPage(model: VisioDocument, page: VisioPage, options?: RenderOptions): RenderResult;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VisioText } from 'ooxml-core/visio';
|
|
2
|
+
import type { TextLayoutBudget } from './text-layout.js';
|
|
3
|
+
/** Browser-font layout is approximate until compared with the licensed Visio reference corpus. */
|
|
4
|
+
export declare function renderText(text: VisioText, warnings: Set<string>, budget?: TextLayoutBudget): SVGGElement;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { VisioShape } from 'ooxml-core/visio';
|
|
2
|
+
export interface DetailBudget {
|
|
3
|
+
rows: number;
|
|
4
|
+
characters: number;
|
|
5
|
+
}
|
|
6
|
+
/** Runtime model checks prevent implicit DOM stringification of host-provided objects. */
|
|
7
|
+
export declare function assertShapeDetails(shape: VisioShape, budget: DetailBudget): void;
|