@image-marker/web 0.1.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 +11 -0
- package/README.md +100 -0
- package/api-contract.json +224 -0
- package/lib/commonjs/core/batch.d.ts +32 -0
- package/lib/commonjs/core/batch.js +85 -0
- package/lib/commonjs/core/content-credentials.d.ts +53 -0
- package/lib/commonjs/core/content-credentials.js +96 -0
- package/lib/commonjs/core/image-info.d.ts +30 -0
- package/lib/commonjs/core/image-info.js +348 -0
- package/lib/commonjs/core/index.d.ts +1014 -0
- package/lib/commonjs/core/index.js +92 -0
- package/lib/commonjs/core/invisible-watermark.d.ts +102 -0
- package/lib/commonjs/core/invisible-watermark.js +913 -0
- package/lib/commonjs/core/job.d.ts +57 -0
- package/lib/commonjs/core/job.js +151 -0
- package/lib/commonjs/core/layout.d.ts +19 -0
- package/lib/commonjs/core/layout.js +75 -0
- package/lib/commonjs/core/marker.d.ts +1 -0
- package/lib/commonjs/core/marker.js +11 -0
- package/lib/commonjs/core/recipe.d.ts +44 -0
- package/lib/commonjs/core/recipe.js +175 -0
- package/lib/commonjs/core/result.d.ts +34 -0
- package/lib/commonjs/core/result.js +41 -0
- package/lib/commonjs/core/trace-runtime.d.ts +43 -0
- package/lib/commonjs/core/trace-runtime.js +92 -0
- package/lib/commonjs/core/validate.d.ts +4 -0
- package/lib/commonjs/core/validate.js +192 -0
- package/lib/commonjs/core/web/browser.d.ts +105 -0
- package/lib/commonjs/core/web/browser.js +434 -0
- package/lib/commonjs/core/web/helpers.d.ts +41 -0
- package/lib/commonjs/core/web/helpers.js +264 -0
- package/lib/commonjs/core/web/index.d.ts +59 -0
- package/lib/commonjs/core/web/index.js +724 -0
- package/lib/commonjs/core/web/invisible-worker-client.d.ts +13 -0
- package/lib/commonjs/core/web/invisible-worker-client.js +140 -0
- package/lib/commonjs/core/web/renderer.d.ts +20 -0
- package/lib/commonjs/core/web/renderer.js +665 -0
- package/lib/commonjs/core/web/runtime.d.ts +106 -0
- package/lib/commonjs/core/web/runtime.js +2 -0
- package/lib/commonjs/editor/adapter.d.ts +26 -0
- package/lib/commonjs/editor/adapter.js +102 -0
- package/lib/commonjs/editor/controller.d.ts +106 -0
- package/lib/commonjs/editor/controller.js +919 -0
- package/lib/commonjs/editor/core-contract.d.ts +2 -0
- package/lib/commonjs/editor/core-contract.js +23 -0
- package/lib/commonjs/editor/geometry.d.ts +8 -0
- package/lib/commonjs/editor/geometry.js +109 -0
- package/lib/commonjs/editor/headless.d.ts +5 -0
- package/lib/commonjs/editor/headless.js +22 -0
- package/lib/commonjs/editor/presets.d.ts +19 -0
- package/lib/commonjs/editor/presets.js +64 -0
- package/lib/commonjs/editor/projection.d.ts +12 -0
- package/lib/commonjs/editor/projection.js +195 -0
- package/lib/commonjs/editor/types.d.ts +166 -0
- package/lib/commonjs/editor/types.js +2 -0
- package/lib/commonjs/editor-adapter.d.ts +7 -0
- package/lib/commonjs/editor-adapter.js +17 -0
- package/lib/commonjs/headless.d.ts +2 -0
- package/lib/commonjs/headless.js +26 -0
- package/lib/commonjs/index.d.ts +5 -0
- package/lib/commonjs/index.js +27 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/core/batch.d.ts +32 -0
- package/lib/module/core/batch.js +82 -0
- package/lib/module/core/content-credentials.d.ts +53 -0
- package/lib/module/core/content-credentials.js +92 -0
- package/lib/module/core/image-info.d.ts +30 -0
- package/lib/module/core/image-info.js +343 -0
- package/lib/module/core/index.d.ts +1014 -0
- package/lib/module/core/index.js +56 -0
- package/lib/module/core/invisible-watermark.d.ts +102 -0
- package/lib/module/core/invisible-watermark.js +897 -0
- package/lib/module/core/job.d.ts +57 -0
- package/lib/module/core/job.js +143 -0
- package/lib/module/core/layout.d.ts +19 -0
- package/lib/module/core/layout.js +70 -0
- package/lib/module/core/marker.d.ts +1 -0
- package/lib/module/core/marker.js +4 -0
- package/lib/module/core/recipe.d.ts +44 -0
- package/lib/module/core/recipe.js +169 -0
- package/lib/module/core/result.d.ts +34 -0
- package/lib/module/core/result.js +38 -0
- package/lib/module/core/trace-runtime.d.ts +43 -0
- package/lib/module/core/trace-runtime.js +89 -0
- package/lib/module/core/validate.d.ts +4 -0
- package/lib/module/core/validate.js +187 -0
- package/lib/module/core/web/browser.d.ts +105 -0
- package/lib/module/core/web/browser.js +427 -0
- package/lib/module/core/web/helpers.d.ts +41 -0
- package/lib/module/core/web/helpers.js +251 -0
- package/lib/module/core/web/index.d.ts +59 -0
- package/lib/module/core/web/index.js +709 -0
- package/lib/module/core/web/invisible-worker-client.d.ts +13 -0
- package/lib/module/core/web/invisible-worker-client.js +137 -0
- package/lib/module/core/web/renderer.d.ts +20 -0
- package/lib/module/core/web/renderer.js +661 -0
- package/lib/module/core/web/runtime.d.ts +106 -0
- package/lib/module/core/web/runtime.js +1 -0
- package/lib/module/editor/adapter.d.ts +26 -0
- package/lib/module/editor/adapter.js +99 -0
- package/lib/module/editor/controller.d.ts +106 -0
- package/lib/module/editor/controller.js +915 -0
- package/lib/module/editor/core-contract.d.ts +2 -0
- package/lib/module/editor/core-contract.js +2 -0
- package/lib/module/editor/geometry.d.ts +8 -0
- package/lib/module/editor/geometry.js +103 -0
- package/lib/module/editor/headless.d.ts +5 -0
- package/lib/module/editor/headless.js +4 -0
- package/lib/module/editor/presets.d.ts +19 -0
- package/lib/module/editor/presets.js +57 -0
- package/lib/module/editor/projection.d.ts +12 -0
- package/lib/module/editor/projection.js +188 -0
- package/lib/module/editor/types.d.ts +166 -0
- package/lib/module/editor/types.js +1 -0
- package/lib/module/editor-adapter.d.ts +7 -0
- package/lib/module/editor-adapter.js +10 -0
- package/lib/module/headless.d.ts +2 -0
- package/lib/module/headless.js +2 -0
- package/lib/module/index.d.ts +5 -0
- package/lib/module/index.js +3 -0
- package/lib/module/package.json +1 -0
- package/lib/source-manifest.json +34 -0
- package/lib/worker/invisible-watermark.js +1 -0
- package/package.json +85 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ImageMarkOptions, ImageOptions, MarkOptions, TextMarkOptions } from '../index.js';
|
|
2
|
+
import type { ContentCredentialsVerificationResult, EmbedInvisibleWithCredentialsOptions, EmbedInvisibleWithCredentialsResult, VerifyContentCredentialsOptions } from '../content-credentials.js';
|
|
3
|
+
import type { DetectInvisibleWatermarkOptions, EmbedInvisibleWatermarkOptions, InvisibleWatermarkDetectionResult } from '../invisible-watermark.js';
|
|
4
|
+
import type { MarkerJobOptions } from '../job.js';
|
|
5
|
+
import type { MarkerImageInfo } from '../image-info.js';
|
|
6
|
+
import type { WatermarkBatchOptions, WatermarkBatchResult } from '../batch.js';
|
|
7
|
+
import type { WatermarkBlobRecipeResultOptions, WatermarkRecipe, WatermarkRecipeDocument, WatermarkRecipeOptions, WatermarkRecipeResultOptions } from '../recipe.js';
|
|
8
|
+
import type { MarkerOperation, MarkerResult } from '../result.js';
|
|
9
|
+
import type { WebResourceAdapter } from './browser.js';
|
|
10
|
+
/** Public operations that a host executor can take outside the DOM realm. */
|
|
11
|
+
export type WebMarkerExecutionOperation = MarkerOperation | 'getImageInfo';
|
|
12
|
+
/** The shape of a value returned by an isolated host executor. */
|
|
13
|
+
export type WebMarkerExecutionResultKind = 'marker-result' | 'blob' | 'detection' | 'image-info';
|
|
14
|
+
/** A cooperative or host-enforced stop request for one execution task. */
|
|
15
|
+
export interface WebMarkerExecutionTermination {
|
|
16
|
+
reason: 'cancel' | 'dispose' | 'signal' | 'timeout';
|
|
17
|
+
/** The instance-specific id supplied to `start`. */
|
|
18
|
+
taskId: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A real execution unit returned by a host adapter. `result` must settle only
|
|
22
|
+
* when the unit has actually stopped or completed. `terminate` is the hook
|
|
23
|
+
* used by `cancel()`/`dispose()` to ask an isolated Tauri Worker, process, or
|
|
24
|
+
* other host-owned unit to stop; its fulfilled promise is the acknowledgement.
|
|
25
|
+
*/
|
|
26
|
+
export interface WebMarkerExecutionTask<Result = unknown> {
|
|
27
|
+
result: Promise<Result>;
|
|
28
|
+
terminate?: (termination: WebMarkerExecutionTermination) => Promise<void> | void;
|
|
29
|
+
/** Alias for hosts whose task API calls the real stop operation `cancel`. */
|
|
30
|
+
cancel?: (termination: WebMarkerExecutionTermination) => Promise<void> | void;
|
|
31
|
+
/** Releases task-local host resources after a completed or stopped task. */
|
|
32
|
+
dispose?: () => Promise<void> | void;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Task request for a host execution boundary. The host owns transport and
|
|
36
|
+
* isolation: map image resources and observer callbacks to your IPC protocol,
|
|
37
|
+
* and forward cancellation explicitly. AbortSignal and loaded DOM images are
|
|
38
|
+
* not directly transferable. The SDK does not pass an executable task closure.
|
|
39
|
+
*/
|
|
40
|
+
export interface WebMarkerExecutionRequest {
|
|
41
|
+
taskId: string;
|
|
42
|
+
operation: WebMarkerExecutionOperation;
|
|
43
|
+
resultKind: WebMarkerExecutionResultKind;
|
|
44
|
+
options: TextMarkOptions | ImageMarkOptions | MarkOptions | EmbedInvisibleWatermarkOptions | DetectInvisibleWatermarkOptions | ImageOptions['src'];
|
|
45
|
+
signal: AbortSignal;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Optional boundary for dispatching whole image operations to a host-owned
|
|
49
|
+
* execution unit. It is intentionally task based, so a Tauri application can
|
|
50
|
+
* adapt it to its own IPC rather than relying on a JavaScript closure.
|
|
51
|
+
*/
|
|
52
|
+
export interface WebMarkerExecutionAdapter {
|
|
53
|
+
start<Result = unknown>(request: WebMarkerExecutionRequest): WebMarkerExecutionTask<Result>;
|
|
54
|
+
}
|
|
55
|
+
export type WebMarkerCancellationMode = 'cooperative' | 'host-termination-required';
|
|
56
|
+
/** Runtime facts a desktop host can use when selecting an execution boundary. */
|
|
57
|
+
export interface WebMarkerCapabilities {
|
|
58
|
+
visibleRendering: {
|
|
59
|
+
engine: 'canvas-2d';
|
|
60
|
+
cancellation: 'host-termination-required';
|
|
61
|
+
};
|
|
62
|
+
invisibleEmbedding: {
|
|
63
|
+
engine: 'canvas-2d-pixels';
|
|
64
|
+
cancellation: 'host-termination-required';
|
|
65
|
+
};
|
|
66
|
+
invisibleDetection: {
|
|
67
|
+
engine: 'dedicated-worker-when-configured-or-main-thread';
|
|
68
|
+
workerCancellation: 'cooperative';
|
|
69
|
+
mainThreadCancellation: 'host-termination-required';
|
|
70
|
+
};
|
|
71
|
+
execution: {
|
|
72
|
+
mode: 'default-dom' | 'host-adapter';
|
|
73
|
+
supportsTerminationAcknowledgement: boolean;
|
|
74
|
+
};
|
|
75
|
+
resources: {
|
|
76
|
+
localBlobInput: true;
|
|
77
|
+
blobOutput: true;
|
|
78
|
+
objectUrlCleanup: true;
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface WebMarkerRuntimeOptions {
|
|
82
|
+
/** Supplies DOM-adjacent resources such as Image, Canvas, and object URLs. */
|
|
83
|
+
resources?: WebResourceAdapter;
|
|
84
|
+
/** Takes complete tasks in a host-owned execution or isolation boundary. */
|
|
85
|
+
execution?: WebMarkerExecutionAdapter;
|
|
86
|
+
}
|
|
87
|
+
export interface WebMarkerInstance {
|
|
88
|
+
readonly capabilities: WebMarkerCapabilities;
|
|
89
|
+
readonly disposed: boolean;
|
|
90
|
+
getImageInfo(source: ImageOptions['src']): Promise<MarkerImageInfo>;
|
|
91
|
+
markText(options: TextMarkOptions, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
92
|
+
markImage(options: ImageMarkOptions, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
93
|
+
mark(options: MarkOptions, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
94
|
+
embedInvisible(options: EmbedInvisibleWatermarkOptions, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
95
|
+
detectInvisible(options: DetectInvisibleWatermarkOptions, control?: MarkerJobOptions): Promise<InvisibleWatermarkDetectionResult>;
|
|
96
|
+
embedInvisibleMany(inputs: readonly EmbedInvisibleWatermarkOptions[], options?: WatermarkBatchOptions<MarkerResult>): Promise<Array<WatermarkBatchResult<MarkerResult>>>;
|
|
97
|
+
detectInvisibleMany(inputs: readonly DetectInvisibleWatermarkOptions[], options?: WatermarkBatchOptions<InvisibleWatermarkDetectionResult>): Promise<Array<WatermarkBatchResult<InvisibleWatermarkDetectionResult>>>;
|
|
98
|
+
createRecipe<ResultOptions extends WatermarkRecipeResultOptions | undefined = undefined>(options: WatermarkRecipeOptions, resultOptions?: ResultOptions): WatermarkRecipe<ResultOptions extends WatermarkBlobRecipeResultOptions ? Blob : MarkerResult>;
|
|
99
|
+
importRecipe<ResultOptions extends WatermarkRecipeResultOptions | undefined = undefined>(document: WatermarkRecipeDocument, resultOptions?: ResultOptions): WatermarkRecipe<ResultOptions extends WatermarkBlobRecipeResultOptions ? Blob : MarkerResult>;
|
|
100
|
+
embedInvisibleWithCredentials(options: EmbedInvisibleWithCredentialsOptions, control?: MarkerJobOptions): Promise<EmbedInvisibleWithCredentialsResult>;
|
|
101
|
+
verifyContentCredentials(options: VerifyContentCredentialsOptions): Promise<ContentCredentialsVerificationResult>;
|
|
102
|
+
/** Abort all current instance tasks and await host termination acknowledgements. */
|
|
103
|
+
cancel(): Promise<void>;
|
|
104
|
+
/** Cancel current work, release task resources, and reject future operations. */
|
|
105
|
+
dispose(): Promise<void>;
|
|
106
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type EmbedInvisibleWatermarkOptions, type EmbedInvisibleWithCredentialsOptions, type EmbedInvisibleWithCredentialsResult, type MarkerImageInfo, type MarkerJobOptions, type MarkerResult } from './core-contract.js';
|
|
2
|
+
import type { WatermarkRecipeDefinition, WatermarkRecipeInput } from '@image-marker/recipe';
|
|
3
|
+
import type { ImageMarkerEditorRenderAdapter } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The smallest Core surface needed by the reusable editor renderer.
|
|
6
|
+
*
|
|
7
|
+
* It deliberately receives the engine instead of importing a platform Marker
|
|
8
|
+
* implementation. Legacy `core-adapter` passes the native-aware Core binding;
|
|
9
|
+
* the standalone Web package passes the Canvas Web binding.
|
|
10
|
+
*/
|
|
11
|
+
export interface EditorMarkerEngine {
|
|
12
|
+
getImageInfo(source: unknown): Promise<MarkerImageInfo>;
|
|
13
|
+
createRecipe(recipe: WatermarkRecipeDefinition): {
|
|
14
|
+
apply(input: WatermarkRecipeInput, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
15
|
+
};
|
|
16
|
+
embedInvisible(options: EmbedInvisibleWatermarkOptions, control?: MarkerJobOptions): Promise<MarkerResult>;
|
|
17
|
+
embedInvisibleWithCredentials(options: EmbedInvisibleWithCredentialsOptions, control?: MarkerJobOptions): Promise<EmbedInvisibleWithCredentialsResult>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Bind editor rendering to a supplied Core-compatible Marker engine.
|
|
21
|
+
*
|
|
22
|
+
* No static Marker implementation is imported here, so the same adapter logic
|
|
23
|
+
* can be used by React Native Core and a browser-only Web Core binding.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createEditorRenderAdapter(engine: EditorMarkerEngine, previewMaxSize?: number): ImageMarkerEditorRenderAdapter;
|
|
26
|
+
export type { EditorExportResult, EditorRenderRequest, ImageMarkerEditorRenderAdapter, } from './types.js';
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createEditorRenderAdapter = createEditorRenderAdapter;
|
|
4
|
+
const core_contract_js_1 = require("./core-contract.js");
|
|
5
|
+
const projection_js_1 = require("./projection.js");
|
|
6
|
+
function withMaxSize(recipe, maxSize) {
|
|
7
|
+
return {
|
|
8
|
+
schemaVersion: 2,
|
|
9
|
+
layers: recipe.layers,
|
|
10
|
+
output: {
|
|
11
|
+
...recipe.output,
|
|
12
|
+
maxSize: maxSize ?? recipe.output.maxSize,
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function signedResult(watermarked, signedImage) {
|
|
17
|
+
return {
|
|
18
|
+
...watermarked,
|
|
19
|
+
uri: signedImage,
|
|
20
|
+
output: signedImage.startsWith('data:') ? 'data-url' : 'file',
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function toCoreSaveFormat(value) {
|
|
24
|
+
switch (value) {
|
|
25
|
+
case 'jpg':
|
|
26
|
+
return core_contract_js_1.ImageFormat.jpg;
|
|
27
|
+
case 'png':
|
|
28
|
+
return core_contract_js_1.ImageFormat.png;
|
|
29
|
+
case 'webp':
|
|
30
|
+
return core_contract_js_1.ImageFormat.webp;
|
|
31
|
+
case 'base64':
|
|
32
|
+
return core_contract_js_1.ImageFormat.base64;
|
|
33
|
+
default:
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Bind editor rendering to a supplied Core-compatible Marker engine.
|
|
39
|
+
*
|
|
40
|
+
* No static Marker implementation is imported here, so the same adapter logic
|
|
41
|
+
* can be used by React Native Core and a browser-only Web Core binding.
|
|
42
|
+
*/
|
|
43
|
+
function createEditorRenderAdapter(engine, previewMaxSize = 1024) {
|
|
44
|
+
const getSourceInfo = (source) => engine.getImageInfo(source);
|
|
45
|
+
const renderVisible = async (request, maxSize) => {
|
|
46
|
+
const sourceSize = request.sourceSize ??
|
|
47
|
+
(await getSourceInfo(request.input.backgroundImage.src));
|
|
48
|
+
const targetSize = maxSize
|
|
49
|
+
? (0, projection_js_1.fitEditorSizeWithinMax)(sourceSize, maxSize)
|
|
50
|
+
: undefined;
|
|
51
|
+
const recipe = targetSize &&
|
|
52
|
+
(targetSize.width !== sourceSize.width ||
|
|
53
|
+
targetSize.height !== sourceSize.height)
|
|
54
|
+
? (0, projection_js_1.projectEditorRecipe)(request.recipe, sourceSize, targetSize)
|
|
55
|
+
: request.recipe;
|
|
56
|
+
return engine
|
|
57
|
+
.createRecipe(withMaxSize(recipe, maxSize))
|
|
58
|
+
.apply(request.input, request.control);
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
getSourceInfo,
|
|
62
|
+
renderPreview(request) {
|
|
63
|
+
return renderVisible(request, request.maxSize ?? previewMaxSize);
|
|
64
|
+
},
|
|
65
|
+
async exportOriginal(request) {
|
|
66
|
+
const visible = await renderVisible(request, request.recipe.output.maxSize);
|
|
67
|
+
const invisible = request.options?.invisible;
|
|
68
|
+
const credentials = request.options?.contentCredentials;
|
|
69
|
+
if (credentials && !invisible) {
|
|
70
|
+
throw new Error('Content Credentials export requires invisible locator options so the signed claim can reference a stable locator.');
|
|
71
|
+
}
|
|
72
|
+
if (invisible && credentials) {
|
|
73
|
+
const result = await engine.embedInvisibleWithCredentials({
|
|
74
|
+
watermark: {
|
|
75
|
+
image: { src: visible.uri },
|
|
76
|
+
...invisible,
|
|
77
|
+
saveFormat: toCoreSaveFormat(request.recipe.output.saveFormat),
|
|
78
|
+
quality: request.recipe.output.quality,
|
|
79
|
+
maxSize: request.recipe.output.maxSize,
|
|
80
|
+
},
|
|
81
|
+
adapter: credentials.adapter,
|
|
82
|
+
claim: credentials.claim,
|
|
83
|
+
}, request.control);
|
|
84
|
+
return {
|
|
85
|
+
visible,
|
|
86
|
+
final: signedResult(result.watermarkedImage, result.signedImage),
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
if (invisible) {
|
|
90
|
+
const final = await engine.embedInvisible({
|
|
91
|
+
image: { src: visible.uri },
|
|
92
|
+
...invisible,
|
|
93
|
+
saveFormat: toCoreSaveFormat(request.recipe.output.saveFormat),
|
|
94
|
+
quality: request.recipe.output.quality,
|
|
95
|
+
maxSize: request.recipe.output.maxSize,
|
|
96
|
+
}, request.control);
|
|
97
|
+
return { visible, final };
|
|
98
|
+
}
|
|
99
|
+
return { visible, final: visible };
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { type WatermarkRecipeDefinition, type WatermarkRecipeDefinitionLayer, type WatermarkRecipeDocument, type WatermarkRecipeLayer } from './core-contract.js';
|
|
2
|
+
import type { EditorAlignment, EditorClipboardDocument, EditorDistribution, EditorExportOptions, EditorKeyCommand, EditorLayerBounds, EditorPoint, EditorSafeArea, EditorSelectionMode, EditorSnapContext, EditorState, EditorTemplate, EditorTextLayerPatch, ImageMarkerEditorControllerOptions } from './types.js';
|
|
3
|
+
type Listener = (state: EditorState) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Headless state engine shared by native and Web editor surfaces.
|
|
6
|
+
*
|
|
7
|
+
* Recipe state, multi-selection, history, clipboard, grouping, alignment,
|
|
8
|
+
* viewport state, and optional autosave live here. Rendering and application
|
|
9
|
+
* design-system choices remain injectable.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ImageMarkerEditorController {
|
|
12
|
+
private recipe;
|
|
13
|
+
private selectedLayerIds;
|
|
14
|
+
private safeArea;
|
|
15
|
+
private exportOptions;
|
|
16
|
+
private viewport;
|
|
17
|
+
private snapGuides;
|
|
18
|
+
private readonly past;
|
|
19
|
+
private readonly future;
|
|
20
|
+
private readonly listeners;
|
|
21
|
+
private readonly historyLimit;
|
|
22
|
+
private readonly autosave?;
|
|
23
|
+
private readonly onChange?;
|
|
24
|
+
private autosaveTimer?;
|
|
25
|
+
private clipboard?;
|
|
26
|
+
private idSequence;
|
|
27
|
+
private groupSequence;
|
|
28
|
+
private historyGroupActive;
|
|
29
|
+
private historyGroupCaptured;
|
|
30
|
+
constructor(document: WatermarkRecipeDocument, historyLimit?: number);
|
|
31
|
+
constructor(options: ImageMarkerEditorControllerOptions);
|
|
32
|
+
getState(): EditorState;
|
|
33
|
+
subscribe(listener: Listener): () => void;
|
|
34
|
+
dispose(): void;
|
|
35
|
+
beginHistoryGroup(): void;
|
|
36
|
+
endHistoryGroup(): void;
|
|
37
|
+
selectLayer(id: string | undefined, mode?: EditorSelectionMode): void;
|
|
38
|
+
selectLayers(ids: readonly string[]): void;
|
|
39
|
+
selectAll(): void;
|
|
40
|
+
clearSelection(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Synchronize a controlled Editor state. History capture is opt-in so parent
|
|
43
|
+
* renders do not create undo entries.
|
|
44
|
+
*/
|
|
45
|
+
replaceState(state: EditorState, recordHistory?: boolean): void;
|
|
46
|
+
importRecipe(document: WatermarkRecipeDocument): void;
|
|
47
|
+
applyTemplate(template: EditorTemplate): void;
|
|
48
|
+
exportRecipe(): WatermarkRecipeDefinition;
|
|
49
|
+
addLayer(layer: WatermarkRecipeLayer, index?: number): string;
|
|
50
|
+
duplicateLayers(ids?: readonly string[]): string[];
|
|
51
|
+
removeLayer(id?: string | undefined): boolean;
|
|
52
|
+
removeLayers(ids?: readonly string[]): number;
|
|
53
|
+
setLayerVisible(id: string, visible: boolean): void;
|
|
54
|
+
setLayerLocked(id: string, locked: boolean): void;
|
|
55
|
+
renameLayer(id: string, name: string | undefined): void;
|
|
56
|
+
patchLayer(id: string, patch: Partial<WatermarkRecipeDefinitionLayer>): void;
|
|
57
|
+
updateTextLayer(id: string, patch: EditorTextLayerPatch): void;
|
|
58
|
+
replaceImage(id: string, source: unknown): void;
|
|
59
|
+
moveLayer(id: string, point: EditorPoint, snapContext?: EditorSnapContext): EditorPoint;
|
|
60
|
+
nudgeLayer(id: string, delta: EditorPoint): void;
|
|
61
|
+
nudgeSelection(delta: EditorPoint): void;
|
|
62
|
+
scaleLayer(id: string, scale: number): void;
|
|
63
|
+
rotateLayer(id: string, degrees: number): void;
|
|
64
|
+
reorderLayer(id: string, targetIndex: number): void;
|
|
65
|
+
groupLayers(ids?: readonly string[], requestedGroupId?: string): string;
|
|
66
|
+
ungroupLayers(ids?: readonly string[]): string[];
|
|
67
|
+
alignLayers(alignment: EditorAlignment, bounds: readonly EditorLayerBounds[], canvas?: {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
70
|
+
}): void;
|
|
71
|
+
distributeLayers(direction: EditorDistribution, bounds: readonly EditorLayerBounds[]): void;
|
|
72
|
+
copyLayers(ids?: readonly string[]): string;
|
|
73
|
+
canPaste(): boolean;
|
|
74
|
+
pasteLayers(serialized?: string | EditorClipboardDocument, offset?: EditorPoint): string[];
|
|
75
|
+
setSafeArea(safeArea: Partial<EditorSafeArea>): void;
|
|
76
|
+
setExportOptions(options: EditorExportOptions): void;
|
|
77
|
+
setViewportZoom(zoom: number, anchor?: EditorPoint): void;
|
|
78
|
+
zoomViewportBy(factor: number, anchor?: EditorPoint): void;
|
|
79
|
+
panViewport(delta: EditorPoint): void;
|
|
80
|
+
fitViewport(): void;
|
|
81
|
+
handleKeyCommand(command: EditorKeyCommand): boolean;
|
|
82
|
+
undo(): boolean;
|
|
83
|
+
redo(): boolean;
|
|
84
|
+
serializeState(): string;
|
|
85
|
+
restoreSerializedState(serialized: string): void;
|
|
86
|
+
restoreAutosave(): Promise<boolean>;
|
|
87
|
+
flushAutosave(): Promise<boolean>;
|
|
88
|
+
clearAutosave(): Promise<boolean>;
|
|
89
|
+
private updateLayer;
|
|
90
|
+
private requireEditableLayer;
|
|
91
|
+
private editableLayers;
|
|
92
|
+
private layersByIds;
|
|
93
|
+
private transformLayerIds;
|
|
94
|
+
private moveLayersBy;
|
|
95
|
+
private layerIndex;
|
|
96
|
+
private nextLayerId;
|
|
97
|
+
private uniqueLayerId;
|
|
98
|
+
private uniqueGroupId;
|
|
99
|
+
private commit;
|
|
100
|
+
private snapshot;
|
|
101
|
+
private restore;
|
|
102
|
+
private scheduleAutosave;
|
|
103
|
+
private reportAutosaveError;
|
|
104
|
+
private emit;
|
|
105
|
+
}
|
|
106
|
+
export {};
|