@vvfx/artis 0.0.1-alpha.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/LICENSE +22 -0
- package/dist/artis/artis.d.ts +44 -0
- package/dist/artis/base-artis.d.ts +520 -0
- package/dist/artis/canvas-layer-order.d.ts +19 -0
- package/dist/artis/create-info-to-schema.d.ts +21 -0
- package/dist/artis/index.d.ts +15 -0
- package/dist/artis/operations/index.d.ts +3 -0
- package/dist/artis/operations/operations.d.ts +362 -0
- package/dist/artis/operations/scene-operations.d.ts +26 -0
- package/dist/artis/operations/types.d.ts +39 -0
- package/dist/artis/scene-artis.d.ts +386 -0
- package/dist/artis/screenshot-service.d.ts +83 -0
- package/dist/artis/types.d.ts +130 -0
- package/dist/artis/wiring/index.d.ts +17 -0
- package/dist/artis/wiring/register-commands.d.ts +44 -0
- package/dist/artis/wiring/setup-commands.d.ts +5 -0
- package/dist/artis/wiring/setup-event-bindings.d.ts +16 -0
- package/dist/artis/wiring/setup-keybindings.d.ts +38 -0
- package/dist/artis/wiring/setup-plugins.d.ts +5 -0
- package/dist/artis/wiring/wiring-context.d.ts +34 -0
- package/dist/artis-sdk/artis-sdk.d.ts +1117 -0
- package/dist/artis-sdk/index.d.ts +1 -0
- package/dist/core/asset/asset-manager.d.ts +288 -0
- package/dist/core/asset/index.d.ts +3 -0
- package/dist/core/command/command-service.d.ts +315 -0
- package/dist/core/command/commands/composite-command.d.ts +45 -0
- package/dist/core/command/commands/frame-layout-command.d.ts +81 -0
- package/dist/core/command/commands/frame-layout-mode-command.d.ts +55 -0
- package/dist/core/command/commands/frame-move-in-command.d.ts +54 -0
- package/dist/core/command/commands/frame-move-out-command.d.ts +54 -0
- package/dist/core/command/commands/group-children-detach-command.d.ts +28 -0
- package/dist/core/command/commands/index.d.ts +98 -0
- package/dist/core/command/commands/item-align-command.d.ts +52 -0
- package/dist/core/command/commands/item-create-command.d.ts +66 -0
- package/dist/core/command/commands/item-delete-command.d.ts +40 -0
- package/dist/core/command/commands/item-distribute-command.d.ts +53 -0
- package/dist/core/command/commands/item-group-command.d.ts +41 -0
- package/dist/core/command/commands/item-reorder-command.d.ts +41 -0
- package/dist/core/command/commands/item-replace-source-command.d.ts +48 -0
- package/dist/core/command/commands/item-set-font-family-command.d.ts +46 -0
- package/dist/core/command/commands/item-set-generator-resource-command.d.ts +40 -0
- package/dist/core/command/commands/item-transform-command.d.ts +51 -0
- package/dist/core/command/commands/item-ungroup-command.d.ts +34 -0
- package/dist/core/command/commands/item-update-property-by-create-info-command.d.ts +41 -0
- package/dist/core/command/commands/item-update-property-command.d.ts +82 -0
- package/dist/core/command/commands/mask-commit-command.d.ts +53 -0
- package/dist/core/command/commands/page-auto-layout-command.d.ts +53 -0
- package/dist/core/command/commands/picture-cut-commit-command.d.ts +43 -0
- package/dist/core/command/commands/picture-expand-commit-command.d.ts +35 -0
- package/dist/core/command/commands/scene-switch-command.d.ts +35 -0
- package/dist/core/command/commands/selection-set-command.d.ts +38 -0
- package/dist/core/command/commands/sprite-image-command.d.ts +36 -0
- package/dist/core/command/commands/sprite-text-edit-commit-command.d.ts +43 -0
- package/dist/core/command/commands/state-hand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-cut-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-expand-command.d.ts +14 -0
- package/dist/core/command/commands/state-image-mask-command.d.ts +15 -0
- package/dist/core/command/commands/state-image-text-edit-command.d.ts +14 -0
- package/dist/core/command/commands/state-item-create-command.d.ts +34 -0
- package/dist/core/command/commands/state-move-command.d.ts +14 -0
- package/dist/core/command/commands/state-switch-command-base.d.ts +41 -0
- package/dist/core/command/commands/text-move-command.d.ts +47 -0
- package/dist/core/command/commands/text-rotate-command.d.ts +52 -0
- package/dist/core/command/commands/text-scale-command.d.ts +56 -0
- package/dist/core/command/commands/text-update-content-command.d.ts +51 -0
- package/dist/core/command/commands/transform-move-command.d.ts +56 -0
- package/dist/core/command/commands/transform-move-with-frame-change-command.d.ts +80 -0
- package/dist/core/command/commands/transform-move-with-layout-command.d.ts +56 -0
- package/dist/core/command/commands/transform-rotate-command.d.ts +51 -0
- package/dist/core/command/commands/transform-scale-command.d.ts +54 -0
- package/dist/core/command/commands/video-play-command.d.ts +28 -0
- package/dist/core/command/commands/video-source-command.d.ts +39 -0
- package/dist/core/command/commands/viewport-fit-to-box-command.d.ts +37 -0
- package/dist/core/command/commands/viewport-fit-to-items-command.d.ts +43 -0
- package/dist/core/command/commands/viewport-move-command.d.ts +34 -0
- package/dist/core/command/commands/viewport-zoom-command.d.ts +35 -0
- package/dist/core/command/index.d.ts +5 -0
- package/dist/core/command/registry.d.ts +246 -0
- package/dist/core/command/types.d.ts +124 -0
- package/dist/core/element-registry/element-facade.d.ts +35 -0
- package/dist/core/element-registry/element-identity-strategy.d.ts +75 -0
- package/dist/core/element-registry/element-registry.d.ts +72 -0
- package/dist/core/element-registry/index.d.ts +5 -0
- package/dist/core/element-registry/types.d.ts +15 -0
- package/dist/core/gizmo/gizmo-bootstrap.d.ts +70 -0
- package/dist/core/gizmo/gizmo-command-binder.d.ts +55 -0
- package/dist/core/gizmo/gizmo-config-override.d.ts +24 -0
- package/dist/core/gizmo/gizmo-registry.d.ts +39 -0
- package/dist/core/gizmo/index.d.ts +19 -0
- package/dist/core/gizmo/register-gizmo-command-bindings.d.ts +20 -0
- package/dist/core/gizmo/state-gizmo-controller.d.ts +20 -0
- package/dist/core/history/history-manager.d.ts +174 -0
- package/dist/core/history/index.d.ts +1 -0
- package/dist/core/index.d.ts +25 -0
- package/dist/core/item/base-item.d.ts +154 -0
- package/dist/core/item/card-item.d.ts +91 -0
- package/dist/core/item/default-item-schema.d.ts +20 -0
- package/dist/core/item/effects-item.d.ts +99 -0
- package/dist/core/item/frame-item.d.ts +153 -0
- package/dist/core/item/generator-item.d.ts +114 -0
- package/dist/core/item/group-item.d.ts +51 -0
- package/dist/core/item/index.d.ts +25 -0
- package/dist/core/item/sprite-item.d.ts +80 -0
- package/dist/core/item/text-item.d.ts +171 -0
- package/dist/core/item/types.d.ts +158 -0
- package/dist/core/item/video-item.d.ts +120 -0
- package/dist/core/keybinding/index.d.ts +11 -0
- package/dist/core/keybinding/key-binding-controller.d.ts +44 -0
- package/dist/core/keybinding/key-binding-registry.d.ts +92 -0
- package/dist/core/keybinding/key-binding-store.d.ts +29 -0
- package/dist/core/keybinding/key-matcher.d.ts +24 -0
- package/dist/core/keybinding/types.d.ts +84 -0
- package/dist/core/plugin/index.d.ts +3 -0
- package/dist/core/plugin/io-plugin.d.ts +167 -0
- package/dist/core/plugin/plugin-system.d.ts +77 -0
- package/dist/core/predict/align-predict.d.ts +20 -0
- package/dist/core/predict/base/box-ops.d.ts +40 -0
- package/dist/core/predict/base/index.d.ts +14 -0
- package/dist/core/predict/base/parent-coord.d.ts +29 -0
- package/dist/core/predict/base/schema-box.d.ts +21 -0
- package/dist/core/predict/distribute-predict.d.ts +19 -0
- package/dist/core/predict/frame-layout-predict.d.ts +24 -0
- package/dist/core/predict/index.d.ts +12 -0
- package/dist/core/preferences/index.d.ts +2 -0
- package/dist/core/preferences/user-preferences-manager.d.ts +130 -0
- package/dist/core/quality/error-monitor/error-monitor-facade.d.ts +73 -0
- package/dist/core/quality/error-monitor/error-monitor.d.ts +106 -0
- package/dist/core/quality/error-monitor/index.d.ts +4 -0
- package/dist/core/quality/error-monitor/types.d.ts +198 -0
- package/dist/core/quality/index.d.ts +3 -0
- package/dist/core/quality/perf-monitor/index.d.ts +5 -0
- package/dist/core/quality/perf-monitor/perf-monitor-facade.d.ts +45 -0
- package/dist/core/quality/perf-monitor/perf-monitor.d.ts +60 -0
- package/dist/core/quality/perf-monitor/types.d.ts +66 -0
- package/dist/core/quality/stability-monitor/index.d.ts +5 -0
- package/dist/core/quality/stability-monitor/stability-monitor-facade.d.ts +50 -0
- package/dist/core/quality/stability-monitor/stability-monitor.d.ts +61 -0
- package/dist/core/quality/stability-monitor/types.d.ts +69 -0
- package/dist/core/renderer/background-controller.d.ts +56 -0
- package/dist/core/renderer/index.d.ts +5 -0
- package/dist/core/renderer/player-adapter.d.ts +129 -0
- package/dist/core/renderer/renderer.d.ts +134 -0
- package/dist/core/service/frame-service.d.ts +116 -0
- package/dist/core/service/index.d.ts +9 -0
- package/dist/core/service/interaction-providers.d.ts +20 -0
- package/dist/core/service/interaction-service.d.ts +211 -0
- package/dist/core/service/item-asset-service.d.ts +120 -0
- package/dist/core/service/item-creator-service.d.ts +211 -0
- package/dist/core/service/item-service.d.ts +641 -0
- package/dist/core/service/item-sync-service.d.ts +66 -0
- package/dist/core/service/json-scene-sync-service.d.ts +140 -0
- package/dist/core/service/refresh-animation-base-service.d.ts +1 -0
- package/dist/core/service/scene-data-assembler.d.ts +166 -0
- package/dist/core/service/view-service.d.ts +202 -0
- package/dist/core/state/base-state.d.ts +28 -0
- package/dist/core/state/index.d.ts +6 -0
- package/dist/core/state/presets.d.ts +25 -0
- package/dist/core/state/state-manager.d.ts +50 -0
- package/dist/core/state/types.d.ts +52 -0
- package/dist/core/store/index.d.ts +3 -0
- package/dist/core/store/scene-store.d.ts +194 -0
- package/dist/core/store/store.d.ts +36 -0
- package/dist/core/types/artis-config.d.ts +186 -0
- package/dist/core/types/artis-events.d.ts +101 -0
- package/dist/core/types/frame.d.ts +3 -0
- package/dist/core/types/generator.d.ts +28 -0
- package/dist/core/types/index.d.ts +15 -0
- package/dist/core/types/item-create-info.d.ts +205 -0
- package/dist/core/types/item-property.d.ts +149 -0
- package/dist/core/types/item-reorder.d.ts +12 -0
- package/dist/core/types/item-schema.d.ts +263 -0
- package/dist/core/types/item-set-property.d.ts +48 -0
- package/dist/core/types/page.d.ts +40 -0
- package/dist/core/types/sdk.d.ts +28 -0
- package/dist/core/types/view.d.ts +39 -0
- package/dist/helper/exporter/config.d.ts +18 -0
- package/dist/helper/exporter/const.d.ts +71 -0
- package/dist/helper/exporter/export-media.d.ts +189 -0
- package/dist/helper/exporter/exporter.d.ts +58 -0
- package/dist/helper/exporter/index.d.ts +2 -0
- package/dist/helper/exporter/types.d.ts +194 -0
- package/dist/helper/exporter/utils.d.ts +71 -0
- package/dist/helper/exporter/wav-audio.d.ts +35 -0
- package/dist/helper/html-overlay/anchor-navigation-runtime.d.ts +1 -0
- package/dist/helper/html-overlay/auto-height-layout.d.ts +16 -0
- package/dist/helper/html-overlay/auto-height-runtime.d.ts +40 -0
- package/dist/helper/html-overlay/document-runtime.d.ts +18 -0
- package/dist/helper/html-overlay/document-transform.d.ts +46 -0
- package/dist/helper/html-overlay/dom-order.d.ts +5 -0
- package/dist/helper/html-overlay/host-message-runtime.d.ts +15 -0
- package/dist/helper/html-overlay/html-capture-runtime.d.ts +12 -0
- package/dist/helper/html-overlay/html-card-service.d.ts +287 -0
- package/dist/helper/html-overlay/html-viewport-style.d.ts +6 -0
- package/dist/helper/html-overlay/index.d.ts +1 -0
- package/dist/helper/html-overlay/inline-script-json.d.ts +1 -0
- package/dist/helper/html-overlay/mime-utils.d.ts +13 -0
- package/dist/helper/html-overlay/overlay-transform.d.ts +30 -0
- package/dist/helper/html-overlay/path-utils.d.ts +34 -0
- package/dist/helper/html-overlay/runtime-context.d.ts +2 -0
- package/dist/helper/html-overlay/shell-runtime.d.ts +13 -0
- package/dist/helper/index.d.ts +5 -0
- package/dist/helper/scene-builder.d.ts +111 -0
- package/dist/helper/screen-shot.d.ts +51 -0
- package/dist/helper/size-adapt.d.ts +88 -0
- package/dist/index.cjs +69350 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.mjs +68963 -0
- package/dist/index.mjs.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/player.d.ts +9 -0
- package/dist/utils/background-manager.d.ts +76 -0
- package/dist/utils/common-utils.d.ts +39 -0
- package/dist/utils/container-size.d.ts +7 -0
- package/dist/utils/find-player-item.d.ts +9 -0
- package/dist/utils/index.d.ts +11 -0
- package/dist/utils/json-data-utils.d.ts +198 -0
- package/dist/utils/layout-utils.d.ts +144 -0
- package/dist/utils/pixel-box-utils.d.ts +26 -0
- package/dist/utils/player-data-utils.d.ts +9 -0
- package/dist/utils/player-utils.d.ts +42 -0
- package/dist/utils/replay-utils.d.ts +22 -0
- package/dist/utils/types.d.ts +130 -0
- package/package.json +66 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { Img2WebPCore } from './types';
|
|
2
|
+
import { Player } from '@galacean/effects';
|
|
3
|
+
/**
|
|
4
|
+
* 将数字保留两位小数
|
|
5
|
+
* @param num 输入数字
|
|
6
|
+
* @returns 保留两位小数后的数字
|
|
7
|
+
*/
|
|
8
|
+
export declare function getTwoDecimal(num: number): number;
|
|
9
|
+
/**
|
|
10
|
+
* 将播放器画布按背景色/背景画布合成绘制到输出画布
|
|
11
|
+
* @param playerCanvas 播放器画布
|
|
12
|
+
* @param canvas 输出画布
|
|
13
|
+
* @param backgroundColor 背景色
|
|
14
|
+
* @param backgroundCanvas 可选背景画布
|
|
15
|
+
*/
|
|
16
|
+
export declare function drawToOutputCanvas(playerCanvas: HTMLCanvasElement, canvas: HTMLCanvasElement, backgroundColor: string, backgroundCanvas?: HTMLCanvasElement): void;
|
|
17
|
+
/**
|
|
18
|
+
* 按AlphaMask视频格式将输入画布拆分rgb与alpha通道拼接到输出画布
|
|
19
|
+
* @param inputCanvas 输入画布
|
|
20
|
+
* @param outputCanvas 输出画布(宽度为输入的两倍)
|
|
21
|
+
*/
|
|
22
|
+
export declare function getAlphaMaskImage(inputCanvas: HTMLCanvasElement, outputCanvas: HTMLCanvasElement): void;
|
|
23
|
+
/**
|
|
24
|
+
* 将字符串参数数组写入 img2webp 内核内存,返回 argc/argv 指针
|
|
25
|
+
* @param Core img2webp 内核实例
|
|
26
|
+
* @param args 命令行参数数组
|
|
27
|
+
* @returns [参数个数, 参数指针数组地址]
|
|
28
|
+
*/
|
|
29
|
+
export declare function parseArgs(Core: Img2WebPCore, args: string[]): number[];
|
|
30
|
+
/**
|
|
31
|
+
* 将 canvas 转为 ArrayBuffer,底层走 toBlob
|
|
32
|
+
* @param canvas 目标画布
|
|
33
|
+
* @param mime 输出 MIME 类型
|
|
34
|
+
* @param quality 输出质量(0-1)
|
|
35
|
+
* @returns 图片对应的 ArrayBuffer
|
|
36
|
+
*/
|
|
37
|
+
export declare function canvasToArrayBuffer(canvas: HTMLCanvasElement, mime?: string, quality?: number): Promise<ArrayBuffer>;
|
|
38
|
+
/** 等待一帧(requestAnimationFrame)后 resolve */
|
|
39
|
+
export declare function sleepForOneFrame(): Promise<unknown>;
|
|
40
|
+
/**
|
|
41
|
+
* 数字前补零到指定长度
|
|
42
|
+
* @param num 原数字
|
|
43
|
+
* @param length 目标字符串长度
|
|
44
|
+
* @returns 补零后的字符串
|
|
45
|
+
*/
|
|
46
|
+
export declare function padZero(num: number, length: number): string;
|
|
47
|
+
/**
|
|
48
|
+
* 异步加载 img2webp 脚本并初始化内核实例
|
|
49
|
+
* @returns 初始化完成的 Img2WebPCore 实例
|
|
50
|
+
*/
|
|
51
|
+
export declare function loadWebpHelper(): Promise<Img2WebPCore>;
|
|
52
|
+
export type LoadFFmpegHelperOptions = {
|
|
53
|
+
multiThreading?: boolean;
|
|
54
|
+
};
|
|
55
|
+
export type LoadConfig = {
|
|
56
|
+
coreURL: string;
|
|
57
|
+
wasmURL: string;
|
|
58
|
+
workerURL?: string;
|
|
59
|
+
classWorkerURL?: string;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* 动态加载并初始化 FFmpeg 实例,按需选择多线程/单线程内核
|
|
63
|
+
* @param options 加载选项,可指定多线程
|
|
64
|
+
* @returns 加载完成的 FFmpeg 实例
|
|
65
|
+
*/
|
|
66
|
+
export declare function loadFFmpegHelper(options?: LoadFFmpegHelperOptions): Promise<import("@ffmpeg/ffmpeg").FFmpeg>;
|
|
67
|
+
/**
|
|
68
|
+
* 清理播放器当前合成相关的纹理与合成资源
|
|
69
|
+
* @param player 目标播放器
|
|
70
|
+
*/
|
|
71
|
+
export declare function clearPlayerAssets(player: Player): void;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 生成 wav 音轨文件
|
|
3
|
+
* NOTE: 为什么不直接使用 ffmpeg 命令生成音轨?
|
|
4
|
+
* 因为直接使用 ffmpeg 命令生成音轨,会造成视频转码过程中存在 blocking 问题,
|
|
5
|
+
* 这里对于音轨要求不高,只是生成一个静音音轨,所以手动生成 wav 文件
|
|
6
|
+
*/
|
|
7
|
+
export type WavAudioOptions = {
|
|
8
|
+
/**
|
|
9
|
+
* 采样率,默认 44100(标准采用率)
|
|
10
|
+
*/
|
|
11
|
+
sampleRate?: number;
|
|
12
|
+
/**
|
|
13
|
+
* 时长,单位秒,默认 1
|
|
14
|
+
*/
|
|
15
|
+
duration?: number;
|
|
16
|
+
/**
|
|
17
|
+
* 通道数,默认 2
|
|
18
|
+
*/
|
|
19
|
+
channels?: number;
|
|
20
|
+
};
|
|
21
|
+
export declare class WavAudio {
|
|
22
|
+
sampleRate: number;
|
|
23
|
+
duration: number;
|
|
24
|
+
channels: number;
|
|
25
|
+
/**
|
|
26
|
+
* 构造 WavAudio,按参数生成静音 wav 配置
|
|
27
|
+
* @param options 采样率/时长/通道数选项
|
|
28
|
+
*/
|
|
29
|
+
constructor(options?: WavAudioOptions);
|
|
30
|
+
/**
|
|
31
|
+
* 按RIFF/WAVE规范生成静音 wav 文件字节
|
|
32
|
+
* @returns wav 文件对应的 Uint8Array
|
|
33
|
+
*/
|
|
34
|
+
getBuffer(): Uint8Array;
|
|
35
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function withCardHTMLAnchorNavigationGuard(html: string, allowAnchorNavigation?: boolean): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type AutoHeightFeedback = {
|
|
2
|
+
nextHeight: number;
|
|
3
|
+
offset: number;
|
|
4
|
+
steps: number;
|
|
5
|
+
};
|
|
6
|
+
export declare function resolveTopAnchoredCardPosition({ nextHeight, position, previousHeight, scaleY, }: {
|
|
7
|
+
nextHeight: number;
|
|
8
|
+
position: [number, number];
|
|
9
|
+
previousHeight: number;
|
|
10
|
+
scaleY: number;
|
|
11
|
+
}): [number, number];
|
|
12
|
+
export declare function clampCardAutoHeight(height: number, initialHeight: number): number;
|
|
13
|
+
export declare function trackAutoHeightFeedback(previous: AutoHeightFeedback | undefined, currentHeight: number, nextHeight: number): {
|
|
14
|
+
feedback?: AutoHeightFeedback;
|
|
15
|
+
loopDetected: boolean;
|
|
16
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { CardHTMLRenderCleanup } from '../../core';
|
|
2
|
+
export type CardHTMLAutoHeightMessage = {
|
|
3
|
+
source: 'vvfx-card-html-auto-height';
|
|
4
|
+
id: string;
|
|
5
|
+
height: number;
|
|
6
|
+
};
|
|
7
|
+
export type CardHTMLAutoHeightRequest = {
|
|
8
|
+
source: 'vvfx-card-html-auto-height-request';
|
|
9
|
+
id: string;
|
|
10
|
+
};
|
|
11
|
+
export type CardHTMLAutoHeightOptions = {
|
|
12
|
+
autoHeightId?: string;
|
|
13
|
+
onAutoHeight?: (height: number) => void;
|
|
14
|
+
onStreamRuntimePhase?: (phase: CardHTMLStreamRuntimePhase) => void;
|
|
15
|
+
streamRuntimeId?: string;
|
|
16
|
+
};
|
|
17
|
+
export type CardHTMLStreamRuntimePhase = 'parsing' | 'draining' | 'complete' | 'finalizing' | 'disposed' | 'error';
|
|
18
|
+
/**
|
|
19
|
+
* 为 iframe 创建自动高度消息监听,未配置自动高度时返回空清理函数
|
|
20
|
+
* @param iframe 监听目标的 iframe
|
|
21
|
+
* @param options 自动高度 ID 与回调
|
|
22
|
+
* @returns 注销监听的清理函数
|
|
23
|
+
*/
|
|
24
|
+
export declare function createAutoHeightMessageListener(iframe: HTMLIFrameElement, options?: CardHTMLAutoHeightOptions): CardHTMLRenderCleanup;
|
|
25
|
+
export declare function getCardHTMLStreamRuntimePhase(data: unknown, expectedRuntimeId: string): CardHTMLStreamRuntimePhase | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* 类型守卫:判断消息是否为指定卡片的自动高度消息
|
|
28
|
+
* @param data 待判断的消息
|
|
29
|
+
* @param id 卡片 ID
|
|
30
|
+
* @returns 是否匹配
|
|
31
|
+
*/
|
|
32
|
+
export declare function isCardHTMLAutoHeightMessage(data: unknown, id: string): data is CardHTMLAutoHeightMessage;
|
|
33
|
+
export declare function requestCardHTMLAutoHeight(iframe: HTMLIFrameElement, id: string): void;
|
|
34
|
+
/**
|
|
35
|
+
* 在 HTML 中注入自动高度桥接脚本,无 id 时原样返回
|
|
36
|
+
* @param html 原始 HTML
|
|
37
|
+
* @param id 自动高度卡片 ID
|
|
38
|
+
* @returns 注入脚本后的 HTML
|
|
39
|
+
*/
|
|
40
|
+
export declare function withCardHTMLAutoHeightBridge(html: string, id?: string): string;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type CardHTMLAutoHeightOptions } from './auto-height-runtime';
|
|
2
|
+
import { CardHTMLContentCleanup, CardHTMLDocumentContent, CardHTMLDOMRenderer, CardHTMLRenderCleanup } from '../../core/types';
|
|
3
|
+
/**
|
|
4
|
+
* 将文档型卡片内容渲染到 iframe 中,挂载消息与自动高度桥接
|
|
5
|
+
* @param overlay 内容容器
|
|
6
|
+
* @param content 文档型卡片内容
|
|
7
|
+
* @param options 自动高度相关参数
|
|
8
|
+
* @returns 清空 iframe 与监听的清理函数
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderDocumentContent(overlay: HTMLElement, content: CardHTMLDocumentContent, options?: CardHTMLAutoHeightOptions): CardHTMLRenderCleanup;
|
|
11
|
+
/**
|
|
12
|
+
* 在 iframe 中渲染 DOM 型卡片内容,每次 load 重新挂载并清理上一轮
|
|
13
|
+
* @param overlay 内容容器
|
|
14
|
+
* @param render DOM 渲染函数
|
|
15
|
+
* @param cleanup 可选的 DOM 清理函数
|
|
16
|
+
* @returns 移除 iframe 与相关监听的清理函数
|
|
17
|
+
*/
|
|
18
|
+
export declare function renderDOMContentInIframe(overlay: HTMLElement, render: CardHTMLDOMRenderer, cleanup?: CardHTMLContentCleanup): CardHTMLRenderCleanup;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type DocumentFileUrlFactory = (rawPath: string, fromPath: string) => string;
|
|
2
|
+
/**
|
|
3
|
+
* 将文件记录归一化为路径到源的 Map
|
|
4
|
+
* @param files 原始文件记录
|
|
5
|
+
* @returns 归一化后的 Map
|
|
6
|
+
*/
|
|
7
|
+
export declare function normalizeDocumentFiles(files: Record<string, string>): Map<string, string>;
|
|
8
|
+
/**
|
|
9
|
+
* 创建文件路径到 data URL 的工厂函数,带缓存与循环引用保护
|
|
10
|
+
* @param files 归一化后的文件表
|
|
11
|
+
* @returns URL 工厂函数
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDocumentFileUrlFactory(files: Map<string, string>): DocumentFileUrlFactory;
|
|
14
|
+
/**
|
|
15
|
+
* 按文件扩展名分发返回变换后的源码,未匹配类型原样返回
|
|
16
|
+
* @param path 文件路径
|
|
17
|
+
* @param source 原始源码
|
|
18
|
+
* @param createFileUrl URL 工厂
|
|
19
|
+
* @param resolving 正在解析的路径集合,防止循环
|
|
20
|
+
* @returns 变换后的源码
|
|
21
|
+
*/
|
|
22
|
+
export declare function transformDocumentFile(path: string, source: string, createFileUrl: DocumentFileUrlFactory, resolving?: Set<string>): string;
|
|
23
|
+
/**
|
|
24
|
+
* 重写 HTML 中的资源引用并把内联 style/script 交由对应变换器处理
|
|
25
|
+
* @param path 当前文件路径
|
|
26
|
+
* @param source 原始 HTML
|
|
27
|
+
* @param createFileUrl URL 工厂
|
|
28
|
+
* @returns 变换后的 HTML
|
|
29
|
+
*/
|
|
30
|
+
export declare function transformHTMLDocument(path: string, source: string, createFileUrl: DocumentFileUrlFactory): string;
|
|
31
|
+
/**
|
|
32
|
+
* 重写 CSS 中 url() 与 @import 的资源引用为 data URL
|
|
33
|
+
* @param path 当前文件路径
|
|
34
|
+
* @param source 原始 CSS
|
|
35
|
+
* @param createFileUrl URL 工厂
|
|
36
|
+
* @returns 变换后的 CSS
|
|
37
|
+
*/
|
|
38
|
+
export declare function transformCSSDocument(path: string, source: string, createFileUrl: DocumentFileUrlFactory): string;
|
|
39
|
+
/**
|
|
40
|
+
* 重写 JS 中静态 import、动态 import 与 from 的模块引用为 data URL
|
|
41
|
+
* @param path 当前文件路径
|
|
42
|
+
* @param source 原始 JS
|
|
43
|
+
* @param createFileUrl URL 工厂
|
|
44
|
+
* @returns 变换后的 JS
|
|
45
|
+
*/
|
|
46
|
+
export declare function transformJSDocument(path: string, source: string, createFileUrl: DocumentFileUrlFactory): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { CardHTMLDocumentContent, CardHTMLDocumentMessage, CardHTMLRenderCleanup } from '../../core';
|
|
2
|
+
/**
|
|
3
|
+
* 创建监听 iframe 内卡片 HTML 文档消息的宿主监听器,返回用于卸载监听的清理函数。
|
|
4
|
+
* 仅当内容声明启用 host messaging 且提供 onMessage 回调时才绑定,否则返回空函数。
|
|
5
|
+
* @param iframe 承载卡片 HTML 文档的 iframe 元素,用于校验消息来源。
|
|
6
|
+
* @param content 卡片 HTML 文档内容,提供是否启用宿主消息及消息回调。
|
|
7
|
+
* @returns 卸载监听的清理函数。
|
|
8
|
+
*/
|
|
9
|
+
export declare function createHostMessageListener(iframe: HTMLIFrameElement, content: CardHTMLDocumentContent): CardHTMLRenderCleanup;
|
|
10
|
+
/**
|
|
11
|
+
* 判断未知数据是否符合卡片 HTML 文档消息结构,来源需为 'vvfx-card-html' 且 type 为字符串。
|
|
12
|
+
* @param data 待校验的消息数据。
|
|
13
|
+
* @returns 命中消息结构则返回 true,作为类型守卫收窄类型。
|
|
14
|
+
*/
|
|
15
|
+
export declare function isCardHTMLDocumentMessage(data: unknown): data is CardHTMLDocumentMessage;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type HTMLCaptureViewportSize = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
5
|
+
export type HTMLCaptureTarget = {
|
|
6
|
+
cleanup: () => void;
|
|
7
|
+
target: HTMLElement;
|
|
8
|
+
};
|
|
9
|
+
export declare function captureViewportSize(logicalSize: HTMLCaptureViewportSize, _displayedBounds?: Pick<DOMRectReadOnly, 'width' | 'height'>): HTMLCaptureViewportSize;
|
|
10
|
+
export declare function serializeComputedCaptureStyle(style: CSSStyleDeclaration): string;
|
|
11
|
+
export declare function createHTMLCaptureReplica(ownerDocument: Document, html: string, logicalSize: HTMLCaptureViewportSize): Promise<HTMLCaptureTarget | undefined>;
|
|
12
|
+
export declare function createHTMLCaptureReplicaFromDocument(ownerDocument: Document, sourceDocument: Document, logicalSize: HTMLCaptureViewportSize): Promise<HTMLCaptureTarget | undefined>;
|
|
@@ -0,0 +1,287 @@
|
|
|
1
|
+
import { CardHTML, CardTypeConfig, type CardItem } from '../../core';
|
|
2
|
+
/**
|
|
3
|
+
* HTML 卡片服务。
|
|
4
|
+
*
|
|
5
|
+
* 对外提供内容解析、刷新、增量更新与跨文档通信;同一实例在内部负责
|
|
6
|
+
* HTML 覆盖层的挂载、布局、交互和栅格化,不再维护独立的 manager。
|
|
7
|
+
*/
|
|
8
|
+
export declare class HTMLCardService {
|
|
9
|
+
private options;
|
|
10
|
+
private isAutoHeightMessage;
|
|
11
|
+
private eventCleanups;
|
|
12
|
+
private htmlRootConfigCleanups;
|
|
13
|
+
private pendingContentInteractionEvent?;
|
|
14
|
+
private contentInteractionFrame?;
|
|
15
|
+
private state;
|
|
16
|
+
/** HTML 卡片根层,由 Artis 装配层统一管理画布层级。 */
|
|
17
|
+
get layerElement(): HTMLElement;
|
|
18
|
+
/** 按注册的 cardType 动态解析卡片 HTML。 */
|
|
19
|
+
resolveHTML(item: CardItem): CardHTML | undefined;
|
|
20
|
+
/** 从实例级卡片注册表解析类型配置。 */
|
|
21
|
+
resolveTypeConfig(item: CardItem): CardTypeConfig | undefined;
|
|
22
|
+
/** 重新解析并挂载指定卡片的 HTML。 */
|
|
23
|
+
refresh(id: string): boolean;
|
|
24
|
+
/** 向卡片内容注册的 patch handler 派发增量更新。 */
|
|
25
|
+
patch(id: string, patch: unknown): boolean;
|
|
26
|
+
/** 获取 HTML 卡片 iframe window。 */
|
|
27
|
+
getWindow(id: string): Window | null | undefined;
|
|
28
|
+
/** 向 HTML 卡片 iframe 派发跨文档事件。 */
|
|
29
|
+
dispatchEvent(id: string, type: string, detail?: unknown): boolean;
|
|
30
|
+
private invalidateCardHTML;
|
|
31
|
+
/**
|
|
32
|
+
* 订阅宿主事件并返回清理函数列表
|
|
33
|
+
*/
|
|
34
|
+
private initEvents;
|
|
35
|
+
/**
|
|
36
|
+
* 在容器上绑定鼠标事件,使用捕获阶段
|
|
37
|
+
*/
|
|
38
|
+
private initDOMEvents;
|
|
39
|
+
/**
|
|
40
|
+
* 双击进入卡片编辑,已处于编辑目标内部时忽略
|
|
41
|
+
* @param event 鼠标事件
|
|
42
|
+
*/
|
|
43
|
+
private handleContainerDoubleClick;
|
|
44
|
+
/**
|
|
45
|
+
* 在编辑态外按下鼠标时退出编辑
|
|
46
|
+
* @param event 鼠标事件
|
|
47
|
+
*/
|
|
48
|
+
private handleContainerMouseDown;
|
|
49
|
+
private selectHTMLInteractionCard;
|
|
50
|
+
/**
|
|
51
|
+
* 悬停态切换时同步可交互元素的指针事件
|
|
52
|
+
* @param event 鼠标事件
|
|
53
|
+
*/
|
|
54
|
+
private handleContainerMouseMove;
|
|
55
|
+
/**
|
|
56
|
+
* 鼠标离开容器时清除悬停态
|
|
57
|
+
*/
|
|
58
|
+
private handleContainerMouseLeave;
|
|
59
|
+
private isMouseLeaveWithinContainer;
|
|
60
|
+
private handleContainerContextMenu;
|
|
61
|
+
private isHTMLContextMenuEvent;
|
|
62
|
+
/**
|
|
63
|
+
* 视口被外部改变时使保存的恢复视口失效
|
|
64
|
+
*/
|
|
65
|
+
private handleViewportTransform;
|
|
66
|
+
/**
|
|
67
|
+
* 主渲染流程:刷新帧与卡片覆盖层,清理不可见项并同步堆叠顺序
|
|
68
|
+
*/
|
|
69
|
+
private render;
|
|
70
|
+
/**
|
|
71
|
+
* 按顺序同步根级元素与各帧内子元素的堆叠层级
|
|
72
|
+
* @param items 全部画布项
|
|
73
|
+
* @param frameByChildId 卡片所属帧映射
|
|
74
|
+
* @param visibleCardIds 当前可见卡片集合
|
|
75
|
+
*/
|
|
76
|
+
private syncOverlayOrder;
|
|
77
|
+
private getOrCreateSelectionLayer;
|
|
78
|
+
/**
|
|
79
|
+
* 渲染可见帧覆盖层并清理消失的帧,返回子卡片到所属帧的映射
|
|
80
|
+
* @param items 全部画布项
|
|
81
|
+
* @param layer 覆盖层根节点
|
|
82
|
+
* @returns 子卡片 ID 到帧 ID 的映射
|
|
83
|
+
*/
|
|
84
|
+
private renderFrameOverlays;
|
|
85
|
+
/**
|
|
86
|
+
* 获取或创建帧覆盖层元素
|
|
87
|
+
* @param id 帧 ID
|
|
88
|
+
* @param layer 覆盖层根节点
|
|
89
|
+
* @returns 帧覆盖层 DOM
|
|
90
|
+
*/
|
|
91
|
+
private getOrCreateFrameOverlay;
|
|
92
|
+
/**
|
|
93
|
+
* 获取或创建卡片覆盖层元素,必要时迁移父节点
|
|
94
|
+
* @param id 卡片 ID
|
|
95
|
+
* @param parent 父节点
|
|
96
|
+
* @param elements 元素缓存表
|
|
97
|
+
* @returns 卡片覆盖层 DOM
|
|
98
|
+
*/
|
|
99
|
+
private getOrCreateOverlay;
|
|
100
|
+
private getOrCreateSelectionOverlay;
|
|
101
|
+
private syncOverlaySelection;
|
|
102
|
+
private getSelectionBoxShadow;
|
|
103
|
+
private getPreSelectionBoxShadow;
|
|
104
|
+
/**
|
|
105
|
+
* 通过事件命中点反查最上层的可双击卡片
|
|
106
|
+
* @param event 鼠标事件
|
|
107
|
+
* @returns 命中的卡片 ID 或 undefined
|
|
108
|
+
*/
|
|
109
|
+
private getHTMLCardIdByEvent;
|
|
110
|
+
/**
|
|
111
|
+
* 判断事件是否落在壳层可交互元素上,返回对应卡片 ID
|
|
112
|
+
* @param event 鼠标事件
|
|
113
|
+
* @returns 命中的卡片 ID 或 undefined
|
|
114
|
+
*/
|
|
115
|
+
private getHoverShellInteractiveIdByEvent;
|
|
116
|
+
private syncActiveContentInteraction;
|
|
117
|
+
private scheduleActiveContentInteractionSync;
|
|
118
|
+
private setActiveContentInteraction;
|
|
119
|
+
private shouldKeepActiveContentInteractionForFocusedElement;
|
|
120
|
+
private resolveHTMLInteractionTarget;
|
|
121
|
+
private getActiveSubtreeInteractionAtEvent;
|
|
122
|
+
private resolveContentInteractionZone;
|
|
123
|
+
private getContentInteractionZones;
|
|
124
|
+
private getContentInteractiveSelector;
|
|
125
|
+
private isContentInteractionDisabled;
|
|
126
|
+
private getContentInteractionZoneMode;
|
|
127
|
+
private invalidateContentInteractionZones;
|
|
128
|
+
private observeContentInteractionZoneResizes;
|
|
129
|
+
/**
|
|
130
|
+
* 将事件客户端坐标转换为覆盖层相对坐标
|
|
131
|
+
* @param event 鼠标事件
|
|
132
|
+
* @returns 覆盖层局部坐标
|
|
133
|
+
*/
|
|
134
|
+
private getLayerPoint;
|
|
135
|
+
/**
|
|
136
|
+
* 获取或创建内容容器与缩放容器并维持父子关系
|
|
137
|
+
* @param id 卡片 ID
|
|
138
|
+
* @param overlay 卡片覆盖层
|
|
139
|
+
* @returns 内容容器 DOM
|
|
140
|
+
*/
|
|
141
|
+
private getOrCreateContentOverlay;
|
|
142
|
+
/**
|
|
143
|
+
* 创建内容缩放容器 DOM
|
|
144
|
+
* @param id 卡片 ID
|
|
145
|
+
* @returns 缩放容器 DOM
|
|
146
|
+
*/
|
|
147
|
+
private createContentScaleOverlay;
|
|
148
|
+
/**
|
|
149
|
+
* 按卡片尺寸同步缩放与内容容器尺寸,无效尺寸跳过
|
|
150
|
+
* @param id 卡片 ID
|
|
151
|
+
* @param width 卡片宽度
|
|
152
|
+
* @param height 卡片高度
|
|
153
|
+
*/
|
|
154
|
+
private syncContentScale;
|
|
155
|
+
private requestAutoHeightFromIframes;
|
|
156
|
+
/**
|
|
157
|
+
* 根据编辑态与悬停态切换各层与可交互元素指针事件
|
|
158
|
+
* @param id 卡片 ID
|
|
159
|
+
*/
|
|
160
|
+
private syncContentInteraction;
|
|
161
|
+
private syncContentInteractionZones;
|
|
162
|
+
private clearContentInteractionState;
|
|
163
|
+
/**
|
|
164
|
+
* 同步壳层与编辑态可交互元素的指针事件和数据属性
|
|
165
|
+
* @param id 卡片 ID
|
|
166
|
+
* @param contentOverlay 内容容器
|
|
167
|
+
* @param isEditing 是否处于编辑态
|
|
168
|
+
*/
|
|
169
|
+
private syncShellInteraction;
|
|
170
|
+
/**
|
|
171
|
+
* 进入指定卡片编辑态,必要时调整视口并记录恢复信息
|
|
172
|
+
* @param id 卡片 ID
|
|
173
|
+
*/
|
|
174
|
+
private enterEditing;
|
|
175
|
+
private isEditableCard;
|
|
176
|
+
/**
|
|
177
|
+
* 退出当前编辑态,可控制是否恢复视口
|
|
178
|
+
* @param options restoreZoom 设为 false 时不恢复视口
|
|
179
|
+
*/
|
|
180
|
+
private exitEditing;
|
|
181
|
+
/**
|
|
182
|
+
* 计算使卡片居中放大的目标缩放,视口不可用时返回 undefined
|
|
183
|
+
* @param box 卡片包围盒
|
|
184
|
+
* @param currentZoom 当前视口缩放
|
|
185
|
+
* @returns 目标缩放值或 undefined
|
|
186
|
+
*/
|
|
187
|
+
private getEditingFitZoom;
|
|
188
|
+
/**
|
|
189
|
+
* 判断事件目标是否落在指定卡片覆盖层内部
|
|
190
|
+
* @param id 卡片 ID
|
|
191
|
+
* @param event 鼠标事件
|
|
192
|
+
* @returns 是否在覆盖层内
|
|
193
|
+
*/
|
|
194
|
+
private isEventInsideOverlay;
|
|
195
|
+
/**
|
|
196
|
+
* 重置覆盖层内容并挂载壳层与内容,注册清理函数
|
|
197
|
+
* @param id 卡片 ID
|
|
198
|
+
* @param overlay 卡片覆盖层
|
|
199
|
+
* @param html 卡片 HTML 描述
|
|
200
|
+
*/
|
|
201
|
+
private renderOverlayHTML;
|
|
202
|
+
private observeContentInteractionZones;
|
|
203
|
+
private createPatchContext;
|
|
204
|
+
private applyHTMLRootConfig;
|
|
205
|
+
private makeSelectionOverlayTransparent;
|
|
206
|
+
/**
|
|
207
|
+
* 按内容类型分发渲染到内联、DOM 或文档模式
|
|
208
|
+
* @param overlay 内容容器
|
|
209
|
+
* @param content 卡片 HTML 内容
|
|
210
|
+
* @param options 自动高度相关参数
|
|
211
|
+
* @returns 渲染清理函数或 undefined
|
|
212
|
+
*/
|
|
213
|
+
private renderOverlayContent;
|
|
214
|
+
/**
|
|
215
|
+
* 将多个清理函数组合为单个清理函数,全为空时返回 undefined
|
|
216
|
+
* @param cleanups 待组合的清理函数
|
|
217
|
+
* @returns 组合后的清理函数或 undefined
|
|
218
|
+
*/
|
|
219
|
+
private chainCleanups;
|
|
220
|
+
/**
|
|
221
|
+
* 清理指定卡片的内容、自动高度监听及相关状态
|
|
222
|
+
* @param id 卡片 ID
|
|
223
|
+
*/
|
|
224
|
+
private cleanupOverlayContent;
|
|
225
|
+
/**
|
|
226
|
+
* 移除卡片覆盖层及其内容并清理缓存
|
|
227
|
+
* @param id 卡片 ID
|
|
228
|
+
*/
|
|
229
|
+
private removeOverlay;
|
|
230
|
+
/**
|
|
231
|
+
* 同步自动高度监听状态,禁用时清理
|
|
232
|
+
* @param id 卡片 ID
|
|
233
|
+
* @param enabled 是否启用自动高度
|
|
234
|
+
*/
|
|
235
|
+
private syncAutoHeight;
|
|
236
|
+
private ensureAutoHeightMode;
|
|
237
|
+
/**
|
|
238
|
+
* 为卡片挂载 Resize/Mutation 观察与 iframe 消息监听,返回清理函数
|
|
239
|
+
* @param id 卡片 ID
|
|
240
|
+
* @returns 注销观察与监听的清理函数
|
|
241
|
+
*/
|
|
242
|
+
private createAutoHeightObserver;
|
|
243
|
+
/**
|
|
244
|
+
* 调度一帧后的高度测量,已在队列中则跳过
|
|
245
|
+
* @param id 卡片 ID
|
|
246
|
+
*/
|
|
247
|
+
private scheduleAutoHeightMeasure;
|
|
248
|
+
/**
|
|
249
|
+
* 测量卡片自然高度并应用,未启用或无挂载时清理
|
|
250
|
+
* @param id 卡片 ID
|
|
251
|
+
*/
|
|
252
|
+
private measureAutoHeight;
|
|
253
|
+
/**
|
|
254
|
+
* 计算内容容器的自然高度,优先取 iframe 与子元素高度
|
|
255
|
+
* @param element 内容挂载元素
|
|
256
|
+
* @returns 自然内容高度
|
|
257
|
+
*/
|
|
258
|
+
private getNaturalContentHeight;
|
|
259
|
+
/**
|
|
260
|
+
* 计算 iframe 内文档的自然高度
|
|
261
|
+
* @param iframe iframe 元素
|
|
262
|
+
* @returns 高度或 undefined
|
|
263
|
+
*/
|
|
264
|
+
private getIframeNaturalContentHeight;
|
|
265
|
+
/**
|
|
266
|
+
* 取直接子元素底部最大偏移作为高度
|
|
267
|
+
* @param element 容器元素
|
|
268
|
+
* @returns 子元素最大底部偏移
|
|
269
|
+
*/
|
|
270
|
+
private getChildrenNaturalHeight;
|
|
271
|
+
/**
|
|
272
|
+
* 清理自动高度观察与待执行测量帧
|
|
273
|
+
* @param id 卡片 ID
|
|
274
|
+
*/
|
|
275
|
+
private cleanupAutoHeight;
|
|
276
|
+
/**
|
|
277
|
+
* 应用自然高度到卡片项,忽略非启用项与无效或微小变化
|
|
278
|
+
* @param id 卡片 ID
|
|
279
|
+
* @param height 测得的高度
|
|
280
|
+
*/
|
|
281
|
+
private applyAutoHeight;
|
|
282
|
+
private setAutoHeightStreamPhase;
|
|
283
|
+
private isAutoHeightStreamActive;
|
|
284
|
+
private getAutoHeightItemHeight;
|
|
285
|
+
private isAutoHeightEnabled;
|
|
286
|
+
private isAutoScaleEnabled;
|
|
287
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { HTMLCardService } from './html-card-service';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function serializeInlineScriptJson(value: unknown): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 根据路径扩展名推断 MIME 类型,未匹配时回退为 text/plain。
|
|
3
|
+
* @param path 资源路径,按扩展名映射 MIME 类型。
|
|
4
|
+
* @returns 对应的 MIME 类型字符串。
|
|
5
|
+
*/
|
|
6
|
+
export declare function getMimeType(path: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 将源文本内容编码为指定 MIME 类型的 data URL。
|
|
9
|
+
* @param source 待编码的源文本内容。
|
|
10
|
+
* @param mimeType 内容的 MIME 类型。
|
|
11
|
+
* @returns 形如 data:{mimeType};charset=utf-8,{encoded} 的 data URL。
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDataUrl(source: string, mimeType: string): string;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Box2 } from '@vvfx/gizmo';
|
|
2
|
+
export type CardOverlayBoxStyle = {
|
|
3
|
+
left: string;
|
|
4
|
+
top: string;
|
|
5
|
+
width: string;
|
|
6
|
+
height: string;
|
|
7
|
+
contentWidth: number;
|
|
8
|
+
contentHeight: number;
|
|
9
|
+
transform: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 根据卡片叠加盒子的四角与目标宽高计算 CSS 定位样式,四角齐全且尺寸有效时用矩阵变换,否则退化为边界框定位。
|
|
13
|
+
* @param box 卡片叠加盒子,提供四角与最小/最大边界。
|
|
14
|
+
* @param width 目标渲染宽度,需大于 0 才走矩阵路径。
|
|
15
|
+
* @param height 目标渲染高度,需大于 0 才走矩阵路径。
|
|
16
|
+
* @param offsetX 横向偏移量,用于平移坐标原点,默认 0。
|
|
17
|
+
* @param offsetY 纵向偏移量,用于平移坐标原点,默认 0。
|
|
18
|
+
* @returns 包含 left/top/width/height/transform 的样式对象。
|
|
19
|
+
*/
|
|
20
|
+
export declare function getCardOverlayBoxStyle(box: Box2, width: number, height: number, offsetX?: number, offsetY?: number): CardOverlayBoxStyle;
|
|
21
|
+
/**
|
|
22
|
+
* 判断点是否落在卡片叠加盒子内,四角齐全时用射线法判定多边形包含,否则用轴对齐边界框判定。
|
|
23
|
+
* @param box 卡片叠加盒子。
|
|
24
|
+
* @param point 待判定的二维点。
|
|
25
|
+
* @returns 点在盒子内返回 true。
|
|
26
|
+
*/
|
|
27
|
+
export declare function isPointInCardOverlayBox(box: Box2, point: {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
}): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 规范化路径,处理 . 与 .. 段并折叠冗余分隔,返回无头尾斜杠的相对路径形式。
|
|
3
|
+
* @param path 待规范化的路径字符串。
|
|
4
|
+
* @returns 规范化后的路径。
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizePath(path: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* 取路径的目录部分,先规范化再截取最后一个分隔符之前的内容,无分隔符返回空串。
|
|
9
|
+
* @param path 待提取目录的路径字符串。
|
|
10
|
+
* @returns 目录路径,根或仅文件名时返回空串。
|
|
11
|
+
*/
|
|
12
|
+
export declare function dirname(path: string): string;
|
|
13
|
+
/**
|
|
14
|
+
* 相对基准路径解析目标路径,绝对路径直接规范化,否则相对基准路径的目录拼接后规范化。
|
|
15
|
+
* @param path 待解析的目标路径。
|
|
16
|
+
* @param fromPath 解析基准路径,提供相对解析的参照目录。
|
|
17
|
+
* @returns 解析后的绝对形式路径字符串。
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolvePath(path: string, fromPath: string): string;
|
|
20
|
+
/**
|
|
21
|
+
* 将资源路径拆分为纯路径与查询/锚点后缀两部分。
|
|
22
|
+
* @param path 含可能的 query 或 hash 后缀的资源路径。
|
|
23
|
+
* @returns 包含纯路径 path 与后缀 suffix 的对象,无后缀时 suffix 为空串。
|
|
24
|
+
*/
|
|
25
|
+
export declare function splitResourcePath(path: string): {
|
|
26
|
+
path: string;
|
|
27
|
+
suffix: string;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* 判断资源 URL 是否需要改写,命中协议头、//、# 开头等绝对或锚点形式时跳过改写。
|
|
31
|
+
* @param url 待判定的资源 URL。
|
|
32
|
+
* @returns 需要改写返回 true。
|
|
33
|
+
*/
|
|
34
|
+
export declare function shouldRewriteResource(url: string): boolean;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CardHTMLContent, CardHTMLRenderCleanup, CardHTMLShellContent } from '../../core';
|
|
2
|
+
export type MountedHTMLShell = {
|
|
3
|
+
contentContainer: HTMLElement;
|
|
4
|
+
cleanup?: CardHTMLRenderCleanup;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* 挂载卡片 HTML 壳层;未提供 shell 时直接使用容器作为内容容器
|
|
8
|
+
* @param container 宿主容器
|
|
9
|
+
* @param content 卡片 HTML 内容
|
|
10
|
+
* @param shell 可选的壳层描述
|
|
11
|
+
* @returns 挂载结果,含内容容器与清理函数
|
|
12
|
+
*/
|
|
13
|
+
export declare function mountHTMLShell(container: HTMLElement, content: CardHTMLContent, shell?: CardHTMLShellContent): MountedHTMLShell;
|