@zenaigc/zenmcp 0.1.9 → 0.1.11
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/INSTALL.md +114 -102
- package/dist/src/assets/index.js +1 -1
- package/dist/src/assets/model-library.js +157 -16
- package/dist/src/core/schema.js +1 -0
- package/dist/src/doctor.js +0 -0
- package/dist/src/effects/index.js +54 -13
- package/dist/src/engine/card.js +5 -2
- package/dist/src/engine/direct.js +2 -0
- package/dist/src/engine/generate.js +15 -2
- package/dist/src/engine/steps.js +84 -9
- package/dist/src/inspect/index.js +51 -12
- package/dist/src/mcp/guidance.js +1 -1
- package/dist/src/mcp/server.js +247 -19
- package/dist/src/timeline/conform.js +19 -5
- package/dist/src/timeline/cuts.js +13 -13
- package/dist/src/timeline/diff.js +25 -7
- package/dist/src/timeline/index.js +2 -2
- package/dist/templates/pop-title/render.js +28 -8
- package/package.json +1 -1
- package/skills/zenmcp/SKILL.md +77 -46
- package/skills/zenmcp/references/00-model-card.md +165 -0
- package/skills/zenmcp/references/01-dissect-and-checkpoints.md +68 -0
- package/skills/zenmcp/references/02-character-and-tryon.md +63 -0
- package/skills/zenmcp/references/03-wan3-camera-and-audio.md +43 -0
- package/skills/zenmcp/references/04-hyperframes-effects.md +61 -0
- package/skills/zenmcp/references/05-interaction-and-media.md +203 -0
- package/skills/zenmcp/references/06-work-delivery.md +29 -0
- package/skills/zenmcp/scripts/build-contact-sheet.mjs +179 -0
- package/skills/zenmcp/scripts/build-dissect-report.mjs +1233 -0
- package/skills/zenmcp/scripts/build-height-ruler.mjs +49 -0
- package/skills/zenmcp/scripts/build-side-by-side.mjs +56 -0
- package/skills/zenmcp/widgets/fixtures/zenmcp-budget-confirm.readonly.json +31 -0
- package/skills/zenmcp/widgets/zenmcp-account/template.json +1 -1
- package/skills/zenmcp/widgets/zenmcp-account/widget.html +8 -10
- package/skills/zenmcp/widgets/zenmcp-budget-confirm/template.json +5 -2
- package/skills/zenmcp/widgets/zenmcp-budget-confirm/widget.html +50 -13
- package/skills/zenmcp/widgets/zenmcp-install-checklist/template.json +1 -1
- package/skills/zenmcp/widgets/zenmcp-install-checklist/widget.html +18 -12
- package/skills/zenmcp/widgets/zenmcp-spend-confirm/template.json +13 -83
- package/skills/zenmcp/widgets/zenmcp-spend-confirm/widget.html +88 -65
- package/dist/src/setup/targets.js +0 -314
- package/skills/zenmcp/widgets/fixtures/zenmcp-asset-roles.json +0 -24
- package/skills/zenmcp/widgets/fixtures/zenmcp-model-picker.json +0 -25
- package/skills/zenmcp/widgets/fixtures/zenmcp-trim-range.json +0 -19
- package/skills/zenmcp/widgets/zenmcp-asset-roles/template.json +0 -54
- package/skills/zenmcp/widgets/zenmcp-asset-roles/widget.html +0 -73
- package/skills/zenmcp/widgets/zenmcp-model-picker/template.json +0 -31
- package/skills/zenmcp/widgets/zenmcp-model-picker/widget.html +0 -28
- package/skills/zenmcp/widgets/zenmcp-trim-range/template.json +0 -53
- package/skills/zenmcp/widgets/zenmcp-trim-range/widget.html +0 -52
package/dist/src/mcp/server.js
CHANGED
|
@@ -6,8 +6,10 @@ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
|
6
6
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { readFile } from 'node:fs/promises';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { homedir, platform } from 'node:os';
|
|
10
|
+
import { basename, join, resolve } from 'node:path';
|
|
11
|
+
import { jobSchema, assetSchema, isSafeId } from '../core/index.js';
|
|
12
|
+
import { ModelLibrary, MODEL_REF_LABEL_PATTERN } from '../assets/model-library.js';
|
|
11
13
|
import { CloudGateway, scrub } from '../gateway/index.js';
|
|
12
14
|
import { PopTitleRenderer } from '../effects/index.js';
|
|
13
15
|
import { Engine, analyzeReference, draftJob, safeError } from '../engine/steps.js';
|
|
@@ -17,11 +19,11 @@ import { trimMedia } from '../acquire/trim.js';
|
|
|
17
19
|
import { ACCOUNT_URL, ERROR_GUIDANCE, POLL_AFTER_SECONDS, LARGE_AMOUNT_CREDITS, LARGE_BALANCE_RATIO, errorGuidance } from './guidance.js';
|
|
18
20
|
import { createDefaultTokenProvider } from '../setup/credentials.js';
|
|
19
21
|
export const DEFAULT_BASE_URL = 'https://api.zenaigc.com/api/v1';
|
|
20
|
-
export const CLIENT_VERSION = '0.1.
|
|
22
|
+
export const CLIENT_VERSION = '0.1.11';
|
|
21
23
|
const inputSchema = z.object({
|
|
22
24
|
job: jobSchema, reference: z.string().min(1),
|
|
23
25
|
output: z.object({ duration_seconds: z.number().int(), resolution: z.enum(['480P', '720P', '1080P']), ratio: z.string(), seed: z.number().int().optional() }),
|
|
24
|
-
slots: z.record(z.string(), z.string()).optional(), retryReserveCredits: z.number().int().nonnegative(), audio: z.string().optional(),
|
|
26
|
+
slots: z.record(z.string(), z.string()).optional(), actions: z.record(z.string(), z.string()).optional(), retryReserveCredits: z.number().int().nonnegative(), audio: z.string().optional(),
|
|
25
27
|
});
|
|
26
28
|
function response(data) {
|
|
27
29
|
const result = data;
|
|
@@ -82,7 +84,7 @@ export async function failure(error, tokens) {
|
|
|
82
84
|
}
|
|
83
85
|
const SERVER_INSTRUCTIONS = `Zenmcp tools are atomic. Combine them as follows.
|
|
84
86
|
0. Direct image/video generation
|
|
85
|
-
- list_models → quote_generation → show the quote and obtain explicit credit approval → run_generation → get_generation. Use a new empty directory for each generation. Local uploads require user consent and consent_confirmed: true. Retrying a released attempt requires explicit approval and retryAfterRelease: true. Only use analyze_reference when replicating reference video shots or rhythm.
|
|
87
|
+
- list_models → quote_generation → show the quote and obtain explicit credit approval → run_generation → get_generation. Use a new empty directory for each generation. Default image tier: unless the user explicitly asks for higher quality or 2K/4K resolution, always keep the catalog defaults quality="medium" and resolution="1K" (omit them or pass medium/1K; never default to quality="high" or 2K/4K, which wastes credits). Local uploads require user consent and consent_confirmed: true. Retrying a released attempt requires explicit approval and retryAfterRelease: true. Only use analyze_reference when replicating reference video shots or rhythm.
|
|
86
88
|
1. Input source
|
|
87
89
|
- Social share text or link (Douyin, Xiaohongshu, Bilibili, TikTok, Instagram, X): call fetch_social_post first. Never scrape pages yourself. Use a new empty directory per post and do not fetch the same link twice in one task; the service has a daily limit.
|
|
88
90
|
- Local video file from the user: skip fetching and go straight to step 2 with that path.
|
|
@@ -91,6 +93,7 @@ const SERVER_INSTRUCTIONS = `Zenmcp tools are atomic. Combine them as follows.
|
|
|
91
93
|
- If the video is longer than about 30 seconds, or plan_job reports a duration limit, ask the user once which segment to keep, call trim_media, then analyze the trimmed file.
|
|
92
94
|
3. Images (kind = images)
|
|
93
95
|
- Show the downloaded images and ask which ones are product or model assets. Call import_assets with confirmed: true only after the user confirms.
|
|
96
|
+
- Call model_library (list or get) to reuse saved local model/subject reference packs across tasks; only call save or remove on explicit user request with confirmed: true (save requires portrait/subject usage authorization; remove permanently deletes all versions).
|
|
94
97
|
4. Text
|
|
95
98
|
- title, text and hashtags from fetch_social_post are the post caption, not a transcript of speech in the video. Do not claim to know what is said in the video.
|
|
96
99
|
5. Paid steps
|
|
@@ -105,15 +108,112 @@ const SERVER_INSTRUCTIONS = `Zenmcp tools are atomic. Combine them as follows.
|
|
|
105
108
|
- rate_limited: tell the user the daily limit is reached and to try again tomorrow.
|
|
106
109
|
- post_unavailable: the post was deleted, is private, or is region-locked.
|
|
107
110
|
8. 展示与确认
|
|
108
|
-
-
|
|
109
|
-
- 原样展示工具的 markdown
|
|
110
|
-
-
|
|
111
|
+
- 参数从用户需求与目录默认值填入,不逐项询问;用户未明确要求高画质或高分辨率时,生图一律默认使用 quality="medium"、resolution="1K"(直接省略或传 medium/1K,切勿擅自选 high 或 2K/4K 浪费积分);报价前仅将没有默认值的必填缺项合并问一次,其余参数在确认卡中展示和修改。
|
|
112
|
+
- 原样展示工具的 markdown 确认卡;每个付费步骤只发起一次合并确认(若需上传本地文件,在同一道确认选项中一并说明将上传的 N 个本地文件名,获批即视为同意上传并传 consent_confirmed: true,勿拆成两次询问)。单一交互面:每回合最多调用一次选项式提问工具且置于最后,同一回合的展示卡片不带交互提交按钮,绝不重复提问。
|
|
113
|
+
- 仅当用户对当前任务明确给出免再问的总额上限时,可在该额度内执行;在已获批预算内且 large:false 时直接调用 run_generation,请勿逐张重复弹出报价确认卡刷屏,并在阶段结果统一报告已花及剩余额度。retryAfterRelease、音色授权、价格变化后的重新报价及 large:true 的单项始终另需明确批准。
|
|
111
114
|
- 平台 Key 推荐请用户在终端运行 zenmcp login(或桌面环境运行 zenmcp-setup)写入本机安全凭据库,保存后无需重启立即生效;兼容写入 MCP 客户端配置 env.ZENMCP_TOKEN。绝不要求用户在聊天中提供 Key。若用户自行粘贴,不回显,引导立即在账户页撤销重建,因为原 Key 已留在聊天记录。
|
|
112
115
|
- 提交后只向用户说明一次正在运行、稍后可查询;按 poll_after_seconds 在同一目录轮询,不逐次播报,避免重复提交。扣费状态待确认时保留同一目录续查。
|
|
113
116
|
- 使用当前客户端提供的媒体展示能力展示输出;不支持时提供文件路径。`;
|
|
117
|
+
function defaultLibraryRoot() {
|
|
118
|
+
if (process.env.ZENMCP_LIBRARY_DIR?.trim())
|
|
119
|
+
return resolve(process.env.ZENMCP_LIBRARY_DIR.trim());
|
|
120
|
+
if (platform() === 'win32')
|
|
121
|
+
return join(process.env.APPDATA?.trim() || join(homedir(), 'AppData', 'Roaming'), 'zenmcp', 'library');
|
|
122
|
+
return join(process.env.XDG_DATA_HOME?.trim() || join(homedir(), '.config'), 'zenmcp', 'library');
|
|
123
|
+
}
|
|
124
|
+
const PARAM_LABELS_ZH = {
|
|
125
|
+
quality: '画质',
|
|
126
|
+
resolution: '分辨率',
|
|
127
|
+
ratio: '画面比例',
|
|
128
|
+
aspect_ratio: '画面比例',
|
|
129
|
+
duration: '时长',
|
|
130
|
+
duration_seconds: '时长',
|
|
131
|
+
audio: '声音',
|
|
132
|
+
with_audio: '声音',
|
|
133
|
+
enable_audio: '声音',
|
|
134
|
+
watermark: '水印',
|
|
135
|
+
seed: '随机种子',
|
|
136
|
+
style: '风格',
|
|
137
|
+
speed: '语速',
|
|
138
|
+
voice_id: '音色',
|
|
139
|
+
voice: '音色',
|
|
140
|
+
format: '输出格式',
|
|
141
|
+
output_format: '输出格式',
|
|
142
|
+
fps: '帧率',
|
|
143
|
+
n: '生成数量',
|
|
144
|
+
count: '生成数量',
|
|
145
|
+
num_images: '生成数量',
|
|
146
|
+
size: '尺寸',
|
|
147
|
+
guidance_scale: '引导强度',
|
|
148
|
+
cfg_scale: '引导强度',
|
|
149
|
+
camera_fixed: '固定机位',
|
|
150
|
+
};
|
|
151
|
+
const VALUE_LABELS_ZH = {
|
|
152
|
+
low: '基础',
|
|
153
|
+
basic: '基础',
|
|
154
|
+
draft: '基础',
|
|
155
|
+
medium: '标准',
|
|
156
|
+
med: '标准',
|
|
157
|
+
standard: '标准',
|
|
158
|
+
normal: '标准',
|
|
159
|
+
high: '高清',
|
|
160
|
+
hd: '高清',
|
|
161
|
+
xhigh: '超清',
|
|
162
|
+
ultra: '超清',
|
|
163
|
+
max: '超清',
|
|
164
|
+
uhd: '超清',
|
|
165
|
+
auto: '自动',
|
|
166
|
+
};
|
|
167
|
+
const RATIO_LABELS_ZH = {
|
|
168
|
+
'9:16': '竖屏 9:16',
|
|
169
|
+
'16:9': '横屏 16:9',
|
|
170
|
+
'1:1': '方图 1:1',
|
|
171
|
+
'3:4': '竖版 3:4',
|
|
172
|
+
'4:3': '横版 4:3',
|
|
173
|
+
};
|
|
174
|
+
function localizeParamLabel(key, rawLabel) {
|
|
175
|
+
if (rawLabel && /[\u4e00-\u9fff]/.test(rawLabel))
|
|
176
|
+
return rawLabel;
|
|
177
|
+
return PARAM_LABELS_ZH[key.toLowerCase()] ?? rawLabel ?? key;
|
|
178
|
+
}
|
|
179
|
+
function localizeParamValue(key, value, optionLabel) {
|
|
180
|
+
if (optionLabel && /[\u4e00-\u9fff]/.test(optionLabel))
|
|
181
|
+
return optionLabel;
|
|
182
|
+
if (typeof value === 'boolean')
|
|
183
|
+
return value ? '开启' : '关闭';
|
|
184
|
+
if (typeof value === 'string') {
|
|
185
|
+
const mapped = VALUE_LABELS_ZH[value.toLowerCase()];
|
|
186
|
+
if (mapped)
|
|
187
|
+
return mapped;
|
|
188
|
+
if ((key === 'ratio' || key === 'aspect_ratio') && RATIO_LABELS_ZH[value])
|
|
189
|
+
return RATIO_LABELS_ZH[value];
|
|
190
|
+
}
|
|
191
|
+
return optionLabel ?? value;
|
|
192
|
+
}
|
|
193
|
+
function localizeModelLabel(capability, rawName, medium) {
|
|
194
|
+
if (rawName && /[\u4e00-\u9fff]/.test(rawName))
|
|
195
|
+
return rawName;
|
|
196
|
+
const id = `${capability} ${rawName ?? ''}`.toLowerCase();
|
|
197
|
+
if (id.includes('tts') || id.includes('speech') || medium === 'audio')
|
|
198
|
+
return '语音合成';
|
|
199
|
+
if (id.includes('kling'))
|
|
200
|
+
return '可灵视频生成';
|
|
201
|
+
if (id.includes('seedance') || (id.includes('jimeng') && medium === 'video'))
|
|
202
|
+
return '即梦视频生成';
|
|
203
|
+
if (id.includes('seedream') || id.includes('jimeng'))
|
|
204
|
+
return '即梦图像生成';
|
|
205
|
+
if (id.includes('wan') || medium === 'video')
|
|
206
|
+
return '视频生成';
|
|
207
|
+
if (id.includes('soul'))
|
|
208
|
+
return '写实人像生成';
|
|
209
|
+
if (id.includes('image') || medium === 'image')
|
|
210
|
+
return '图像生成';
|
|
211
|
+
return '云端生成服务';
|
|
212
|
+
}
|
|
114
213
|
/** Background tasks live in this MCP process; state and attempts survive its restart. */
|
|
115
|
-
export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
214
|
+
export function createServer(engine, socialOptions = {}, speechOptions = {}, libraryRoot = defaultLibraryRoot()) {
|
|
116
215
|
const server = new McpServer({ name: 'zenmcp', version: CLIENT_VERSION }, { instructions: SERVER_INSTRUCTIONS });
|
|
216
|
+
const modelLibrary = new ModelLibrary(libraryRoot);
|
|
117
217
|
const active = new Map();
|
|
118
218
|
server.registerTool('fetch_social_post', {
|
|
119
219
|
description: '解析抖音/小红书/B站/TikTok/Instagram/X 分享口令或链接,下载视频或图集到本地目录,返回本地路径与标题/正文/话题。免费、限次;不分析内容。视频可直接交给 analyze_reference。',
|
|
@@ -147,12 +247,13 @@ export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
|
147
247
|
const jobObj = (savedInput?.job && typeof savedInput.job === 'object' ? savedInput.job : input?.job);
|
|
148
248
|
const segmentCount = Array.isArray(jobObj?.storyboard?.segments) ? jobObj.storyboard.segments.length : null;
|
|
149
249
|
const lineItems = Array.isArray(data.lineItems) ? data.lineItems : [];
|
|
250
|
+
const opLabels = { generate: '视频生成', tts: '语音合成', image: '图像生成' };
|
|
150
251
|
const segments = lineItems
|
|
151
252
|
.filter(item => typeof item?.credits === 'number')
|
|
152
253
|
.map(item => ({
|
|
153
254
|
label: item.operation === 'generate'
|
|
154
|
-
? (segmentCount ?
|
|
155
|
-
: String(item.operation ?? '项目'),
|
|
255
|
+
? (segmentCount ? `整片一次生成(含 ${segmentCount} 个分镜切点)` : '整片视频生成')
|
|
256
|
+
: (opLabels[String(item.operation ?? '')] ?? String(item.operation ?? '项目')),
|
|
156
257
|
credits: Number(item.credits),
|
|
157
258
|
}));
|
|
158
259
|
const roleLabels = { identity: '身份', motion_ref: '动作参考', product: '服装', scene: '场景', detail: '细节' };
|
|
@@ -306,18 +407,23 @@ export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
|
306
407
|
const cell = (value) => value.replace(/\|/g, '\\|').replace(/[\r\n]+/g, ' ');
|
|
307
408
|
const rows = result.models.map(model => [model.id, model.medium, model.model,
|
|
308
409
|
model.assets.filter(a => a.required).map(a => `${a.key} (${a.type ?? '目录未标明类型'})`).join('、') || '无',
|
|
309
|
-
model.params.filter(p => p.required).map(p => `${p.key} (${p.type}${p.options?.length ? `;${p.options.map(o => o.value).join('/')}` : ''})`).join('、') || '无',
|
|
410
|
+
model.params.filter(p => p.required).map(p => `${p.key} (${p.type}${p.options?.length ? `;${p.options.map(o => o.value).join('/')}` : ''}${p.default !== undefined ? `;默认=${p.default},可省略` : ''})`).join('、') || '无',
|
|
310
411
|
].map(cell).join(' | '));
|
|
311
|
-
return { ...result, markdown: ['| 能力 id | 媒介 | 模型 | 必填素材 | 必填参数 |', '| --- | --- | --- | --- | --- |', ...rows.map(row => `| ${row} |`), '', '下一步:选择能力并调用 quote_generation
|
|
412
|
+
return { ...result, markdown: ['| 能力 id | 媒介 | 模型 | 必填素材 | 必填参数 |', '| --- | --- | --- | --- | --- |', ...rows.map(row => `| ${row} |`), '', '下一步:选择能力并调用 quote_generation 免费报价(带「默认=...」的参数在用户未指定时请直接省略或保持默认,生图默认 quality=medium、resolution=1K,勿擅自选 high/2K);本地文件上传前须取得用户同意。'].join('\n') };
|
|
312
413
|
}));
|
|
313
|
-
server.registerTool('quote_generation', { description: '
|
|
414
|
+
server.registerTool('quote_generation', { description: '免费报价,不提交生成;会上传本地素材,须先取得上传同意。用户未明确指定生图画质/分辨率时默认保持 quality="medium"、resolution="1K"(可直接省略,勿擅自选 high 或 2K/4K)。报价后一次性展示模型、关键参数、上传文件数和积分,取得明确批准后携带 requestDigest 调用 run_generation。', inputSchema: { directory: z.string(), capability: z.string(), prompt: z.string().optional(), voice_id: z.string().min(1).optional(), voice_authorized: z.boolean().optional(), params: z.record(z.string(), z.union([z.string(), z.number(), z.boolean()])).optional(), inputs: z.record(z.string(), z.string()).optional(), consent_confirmed: z.boolean().optional() } }, guarded(async (i) => {
|
|
314
415
|
// The engine remains the execution authority; its request and catalog entry are reused for presentation only.
|
|
315
416
|
const { quote: result, request, capability: model } = await direct.quoteDetailed(i);
|
|
316
417
|
const me = await engine.options.gateway.me().catch(() => null);
|
|
317
418
|
const params = Object.entries(request.params).filter(([key]) => key !== 'prompt').map(([key, value]) => {
|
|
318
419
|
const spec = model.params.find(p => p.key === key);
|
|
319
|
-
return {
|
|
420
|
+
return {
|
|
421
|
+
key,
|
|
422
|
+
label: localizeParamLabel(key, spec?.label),
|
|
423
|
+
value: localizeParamValue(key, value, spec?.options?.find(o => o.value === value)?.label),
|
|
424
|
+
};
|
|
320
425
|
});
|
|
426
|
+
const model_label = localizeModelLabel(request.capability, model.name, model.medium);
|
|
321
427
|
const prompt = String(request.params.prompt ?? '');
|
|
322
428
|
const preview = [...prompt].slice(0, 120).join('') + ([...prompt].length > 120 ? '…' : '');
|
|
323
429
|
const uploads = Object.values(i.inputs ?? {}).map(path => basename(path.replace(/\\/g, '/')));
|
|
@@ -327,7 +433,7 @@ export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
|
327
433
|
const large = credits >= LARGE_AMOUNT_CREDITS || (balance !== null && credits > balance * LARGE_BALANCE_RATIO);
|
|
328
434
|
const confirmation = { kind: 'spend', credits, balance_before: balance, balance_after: balance === null ? null : balance - credits, sufficient, large, params, uploads, prompt_preview: preview };
|
|
329
435
|
const markdown = [
|
|
330
|
-
'### 生成确认', `- 模型:${
|
|
436
|
+
'### 生成确认', `- 模型:${model_label}(${request.capability})`,
|
|
331
437
|
`- 参数:${params.length ? params.map(p => `${p.label}=${p.value}`).join(' · ') : '无额外参数'}`,
|
|
332
438
|
...(preview ? [`- 提示词:${preview}`] : []),
|
|
333
439
|
...(uploads.length ? [`- 上传:本次报价已上传 ${uploads.length} 个本地文件(${uploads.join('、')})`] : []),
|
|
@@ -338,9 +444,9 @@ export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
|
338
444
|
GETTING_STARTED.billing_rule,
|
|
339
445
|
].join('\n');
|
|
340
446
|
const next_action = sufficient === false ? `请展示卡片并引导用户前往 ${ACCOUNT_URL} 补足额度后调用 account_status 核实;现在不要请求积分批准或执行。`
|
|
341
|
-
:
|
|
447
|
+
: `未获批或 large=true 时请展示确认卡片并只确认一次,获批准后调用 run_generation,approvedCredits=${credits},requestDigest=${result.requestDigest};若已在用户明确批准的当前阶段预算上限内且非 large,请勿重复弹出单张报价确认卡,直接在余额度内执行并在阶段产出中汇总实扣与剩余额度(重试、音色授权及价格变化须另获批准)。`;
|
|
342
448
|
const secret = await engine.tokens.token().catch(() => '');
|
|
343
|
-
return scrub({ ...result, confirmation, markdown, next_action }, secret);
|
|
449
|
+
return scrub({ ...result, model_label, confirmation, markdown, next_action }, secret);
|
|
344
450
|
}));
|
|
345
451
|
server.registerTool('run_generation', { description: '携带用户一次合并确认明确批准的积分与 requestDigest,后台执行或恢复同一付款尝试。接受后按 poll_after_seconds 等待并在同一目录用 get_generation 查询,勿重复提交。释放后重试需用户重新批准。', inputSchema: { directory: z.string(), approvedCredits: z.number().int().nonnegative(), requestDigest: z.string(), retryAfterRelease: z.boolean().optional(), voice_id: z.string().min(1).optional(), voice_authorized: z.boolean().optional() } }, guarded(async (i) => {
|
|
346
452
|
const result = await direct.run(i);
|
|
@@ -387,8 +493,130 @@ export function createServer(engine, socialOptions = {}, speechOptions = {}) {
|
|
|
387
493
|
inputSchema: cloneInputSchema.shape,
|
|
388
494
|
}, guarded(input => speech.clone(input)));
|
|
389
495
|
server.registerTool('list_voices', { description: '查询当前账户定制音色及 training、ready、active、failed、expired 状态;不启用、不收费。', inputSchema: {} }, guarded(() => speech.list()));
|
|
496
|
+
server.registerTool('model_library', {
|
|
497
|
+
description: '本地持久模特/主体资产库(只操作本机文件,不联网、不收费):list 列出已保存资产(可传 query 按名称/备注过滤);get 按 id 或 query(支持中文昵称/描述模糊检索)读取指定资产及带真实图片扩展名的本地路径(含 preview 总览拼图与 references 标签参考图);save 保存新版本(须用户明确要求并确认拥有人像/主体使用授权,传 confirmed:true);remove 永久删除该 id 下的全部历史版本且不可恢复(须用户明确确认,传 confirmed:true)。',
|
|
498
|
+
inputSchema: {
|
|
499
|
+
action: z.enum(['list', 'get', 'save', 'remove']),
|
|
500
|
+
id: z.string().min(1).optional(),
|
|
501
|
+
query: z.string().min(1).optional(),
|
|
502
|
+
version: z.number().int().positive().optional(),
|
|
503
|
+
name: z.string().min(1).optional(),
|
|
504
|
+
description: z.string().optional(),
|
|
505
|
+
notes: z.string().optional(),
|
|
506
|
+
originalImage: z.string().min(1).optional(),
|
|
507
|
+
identityImage: z.string().min(1).optional(),
|
|
508
|
+
previewImage: z.string().min(1).optional(),
|
|
509
|
+
references: z.array(z.object({ label: z.string().regex(MODEL_REF_LABEL_PATTERN), image: z.string().min(1) })).max(16).optional(),
|
|
510
|
+
confirmed: z.boolean().optional(),
|
|
511
|
+
},
|
|
512
|
+
}, guarded(async (input) => {
|
|
513
|
+
const summarizeCandidates = async (records) => Promise.all(records.map(async (m) => {
|
|
514
|
+
const resolved = await modelLibrary.resolvePaths(m.id).catch(() => null);
|
|
515
|
+
return {
|
|
516
|
+
...m,
|
|
517
|
+
previewPath: resolved?.paths.preview ?? resolved?.paths.identity ?? null,
|
|
518
|
+
};
|
|
519
|
+
}));
|
|
520
|
+
const formatResolved = (record, paths) => {
|
|
521
|
+
const refLines = Object.entries(paths.references).map(([label, path]) => `- 参考图 [${label}]:${path}`);
|
|
522
|
+
return {
|
|
523
|
+
match: 'unique',
|
|
524
|
+
record,
|
|
525
|
+
paths,
|
|
526
|
+
markdown: [
|
|
527
|
+
`### 模特/主体 ${record.name}(\`${record.id}\` v${record.version})`,
|
|
528
|
+
...(paths.preview ? [`- 预览总览图:${paths.preview}`] : []),
|
|
529
|
+
`- 身份参考图:${paths.identity}`,
|
|
530
|
+
`- 原始参考图:${paths.original}`,
|
|
531
|
+
...(record.notes ? [`- 备注:${record.notes}`] : []),
|
|
532
|
+
...refLines,
|
|
533
|
+
].join('\n'),
|
|
534
|
+
};
|
|
535
|
+
};
|
|
536
|
+
if (input.action === 'list') {
|
|
537
|
+
const base = input.query ? await modelLibrary.find(input.query) : await modelLibrary.list();
|
|
538
|
+
const models = await summarizeCandidates(base);
|
|
539
|
+
const lines = models.length
|
|
540
|
+
? models.map(m => `- **${m.name}** (\`${m.id}\` v${m.version}):${m.description}${m.notes ? ` · 备注:${m.notes}` : ''}${m.previewPath ? ` · 预览:${m.previewPath}` : ''}`)
|
|
541
|
+
: ['当前本机尚未保存任何匹配的模特或主体资产。'];
|
|
542
|
+
return { models, markdown: ['### 已保存模特/主体库', ...lines].join('\n') };
|
|
543
|
+
}
|
|
544
|
+
if (input.action === 'get') {
|
|
545
|
+
if (!input.id && !input.query)
|
|
546
|
+
throw new Error('invalid_input:get 须提供 id 或 query。');
|
|
547
|
+
if (input.id && (input.id.includes('..') || input.id.includes('/') || input.id.includes('\\'))) {
|
|
548
|
+
throw new Error('invalid_input:非法资产 id。');
|
|
549
|
+
}
|
|
550
|
+
if (input.id && !input.query && isSafeId(input.id)) {
|
|
551
|
+
const directHit = await modelLibrary.resolvePaths(input.id, input.version).catch((err) => {
|
|
552
|
+
if (err?.code === 'ENOENT')
|
|
553
|
+
return null;
|
|
554
|
+
throw err;
|
|
555
|
+
});
|
|
556
|
+
if (directHit)
|
|
557
|
+
return formatResolved(directHit.record, directHit.paths);
|
|
558
|
+
}
|
|
559
|
+
const q = (input.query ?? input.id);
|
|
560
|
+
const hits = await modelLibrary.find(q);
|
|
561
|
+
if (hits.length === 1) {
|
|
562
|
+
const { record, paths } = await modelLibrary.resolvePaths(hits[0].id, input.version);
|
|
563
|
+
return formatResolved(record, paths);
|
|
564
|
+
}
|
|
565
|
+
if (hits.length > 1) {
|
|
566
|
+
const candidates = await summarizeCandidates(hits);
|
|
567
|
+
return {
|
|
568
|
+
match: 'ambiguous',
|
|
569
|
+
query: q,
|
|
570
|
+
candidates,
|
|
571
|
+
markdown: [
|
|
572
|
+
`查询「${q}」命中 ${candidates.length} 个候选模特,请向用户展示预览并让用户单选:`,
|
|
573
|
+
...candidates.map(m => `- **${m.name}** (\`${m.id}\` v${m.version}):${m.description}${m.previewPath ? ` · 预览:${m.previewPath}` : ''}`),
|
|
574
|
+
].join('\n'),
|
|
575
|
+
};
|
|
576
|
+
}
|
|
577
|
+
const candidates = await summarizeCandidates(await modelLibrary.list());
|
|
578
|
+
return {
|
|
579
|
+
match: 'none',
|
|
580
|
+
query: q,
|
|
581
|
+
candidates,
|
|
582
|
+
markdown: candidates.length
|
|
583
|
+
? [
|
|
584
|
+
`未找到精确匹配「${q}」的模特;当前库内共有 ${candidates.length} 个可选资产:`,
|
|
585
|
+
...candidates.map(m => `- **${m.name}** (\`${m.id}\` v${m.version}):${m.description}${m.previewPath ? ` · 预览:${m.previewPath}` : ''}`),
|
|
586
|
+
].join('\n')
|
|
587
|
+
: `未找到「${q}」,且当前本机尚未保存任何模特资产。`,
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
if (!input.id)
|
|
591
|
+
throw new Error('invalid_input:请提供资产 id。');
|
|
592
|
+
if (input.confirmed !== true)
|
|
593
|
+
throw new Error('confirmation_required:保存(须确认人像/主体使用授权)或永久删除(将删除全部历史版本且不可恢复)持久资产须经用户明确同意并传 confirmed:true。');
|
|
594
|
+
if (input.action === 'remove') {
|
|
595
|
+
await modelLibrary.remove(input.id);
|
|
596
|
+
return { removed: input.id, markdown: `已从本机资产库永久移除 \`${input.id}\` 的全部版本。` };
|
|
597
|
+
}
|
|
598
|
+
if (!input.name || !input.originalImage || !input.identityImage) {
|
|
599
|
+
throw new Error('invalid_input:save 须提供 id、name、originalImage、identityImage。');
|
|
600
|
+
}
|
|
601
|
+
const saved = await modelLibrary.save({
|
|
602
|
+
id: input.id,
|
|
603
|
+
name: input.name,
|
|
604
|
+
description: input.description ?? '',
|
|
605
|
+
originalImage: input.originalImage,
|
|
606
|
+
identityImage: input.identityImage,
|
|
607
|
+
...(input.previewImage ? { previewImage: input.previewImage } : {}),
|
|
608
|
+
...(input.notes !== undefined ? { notes: input.notes } : {}),
|
|
609
|
+
...(input.references ? { references: input.references } : {}),
|
|
610
|
+
});
|
|
611
|
+
const { paths } = await modelLibrary.resolvePaths(saved.id, saved.version);
|
|
612
|
+
return {
|
|
613
|
+
record: saved,
|
|
614
|
+
paths,
|
|
615
|
+
markdown: `已保存资产 **${saved.name}**(\`${saved.id}\` v${saved.version})${paths.preview ? `,预览图:${paths.preview}` : ''}。`,
|
|
616
|
+
};
|
|
617
|
+
}));
|
|
390
618
|
const prompts = [
|
|
391
|
-
{ name: 'generate_media', title: '生成图片或视频', text: '请帮我生成图片或视频:先 list_models,再 quote_generation
|
|
619
|
+
{ name: 'generate_media', title: '生成图片或视频', text: '请帮我生成图片或视频:先 list_models,再 quote_generation 免费报价(用户未指定生图画质/分辨率时默认保持 quality="medium"、resolution="1K",勿擅自选 high/2K)。本地素材上传前取得同意;一次性确认模型、关键参数、上传文件数及积分后,携带 requestDigest 调用 run_generation;按 poll_after_seconds 等待后在同一目录 get_generation,并展示输出。' },
|
|
392
620
|
{ name: 'replicate_video', title: '拆解二创短视频', text: '请拆解二创我提供的短视频:链接先 fetch_social_post,本地文件直接 analyze_reference;必要时选段并 trim_media。展示素材并确认最终属性后 import_assets,再 plan_job;一次合并确认模型、关键参数、上传文件数及积分后 execute_job,按 poll_after_seconds 在同一目录 get_job,展示输出。' },
|
|
393
621
|
{ name: 'check_setup', title: '检查安装与账户', text: `请检查 Zenmcp 安装和账户:环境异常时运行 zenmcp-doctor,随后 account_status 查询积分与客户端版本。缺少或无效的 Key 请引导用户前往 ${ACCOUNT_URL} 创建,在终端运行 zenmcp login(或桌面运行 zenmcp-setup)粘贴保存即可立即生效,或写入 MCP 客户端配置 env.ZENMCP_TOKEN 后重新加载;绝不在聊天中索取 Key。` },
|
|
394
622
|
];
|
|
@@ -4,6 +4,15 @@ import { TimelineError } from "./errors.js";
|
|
|
4
4
|
import { collectStderr, readRawFrames, spawnIo, waitClose, writeRawFrame } from "./ffmpeg.js";
|
|
5
5
|
import { timelineParams } from "./params.js";
|
|
6
6
|
import { probe } from "./probe.js";
|
|
7
|
+
export const CONFORM_MIN_NORMAL_RATIO = 0.7;
|
|
8
|
+
export const CONFORM_MAX_NORMAL_RATIO = 1.45;
|
|
9
|
+
export function classifySegmentSpeed(ratio) {
|
|
10
|
+
if (ratio < CONFORM_MIN_NORMAL_RATIO)
|
|
11
|
+
return "slowdown";
|
|
12
|
+
if (ratio > CONFORM_MAX_NORMAL_RATIO)
|
|
13
|
+
return "speedup";
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
7
16
|
/**
|
|
8
17
|
* Rebuild `input` so each target segment has exactly its target length.
|
|
9
18
|
*
|
|
@@ -44,11 +53,16 @@ export async function conform(input, plan, output, params = timelineParams) {
|
|
|
44
53
|
}
|
|
45
54
|
return {
|
|
46
55
|
frames: written.frames,
|
|
47
|
-
segments: segments.map((segment) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
segments: segments.map((segment) => {
|
|
57
|
+
const ratio = segment.sourceFrames / segment.targetFrames;
|
|
58
|
+
const warning = classifySegmentSpeed(ratio);
|
|
59
|
+
return {
|
|
60
|
+
source_frames: segment.sourceFrames,
|
|
61
|
+
target_frames: segment.targetFrames,
|
|
62
|
+
ratio,
|
|
63
|
+
...(warning ? { speed_warning: warning } : {}),
|
|
64
|
+
};
|
|
65
|
+
}),
|
|
52
66
|
};
|
|
53
67
|
}
|
|
54
68
|
function planSegments(plan, sourceFrames) {
|
|
@@ -7,19 +7,15 @@ const NOT_FOUND = {
|
|
|
7
7
|
score: 0,
|
|
8
8
|
status: "not_found",
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
* Unknown hard cuts from the diff series.
|
|
12
|
-
*
|
|
13
|
-
* A sample is hot when it clears median + madK * MAD by more than gateSlack
|
|
14
|
-
* gray levels. MAD is the raw median absolute deviation. Adjacent hot
|
|
15
|
-
* samples are one run.
|
|
16
|
-
* `start` is the frame of the first hot difference (diff index i maps to
|
|
17
|
-
* frame i + 1). `frame` is the first frame after the run. `span` is the
|
|
18
|
-
* number of hot samples. A run longer than `maxSpan` is gradual motion and
|
|
19
|
-
* is dropped. `score` is the maximum diff inside the run.
|
|
20
|
-
*/
|
|
21
|
-
export function detectCuts(diffs, params = timelineParams) {
|
|
10
|
+
export function detectCuts(diffs, params = timelineParams, opts) {
|
|
22
11
|
assertDetectionParams(params);
|
|
12
|
+
const minChanged = opts?.minChangedFraction ?? 0;
|
|
13
|
+
if (!Number.isFinite(minChanged) || minChanged < 0 || minChanged > 1) {
|
|
14
|
+
throw new TimelineError("bad_params", "minChangedFraction must be in [0, 1]");
|
|
15
|
+
}
|
|
16
|
+
if (opts?.changedFractions !== undefined && opts.changedFractions.length !== diffs.length) {
|
|
17
|
+
throw new TimelineError("bad_params", "changedFractions length must match diffs length");
|
|
18
|
+
}
|
|
23
19
|
if (diffs.length === 0) {
|
|
24
20
|
return [];
|
|
25
21
|
}
|
|
@@ -34,12 +30,16 @@ export function detectCuts(diffs, params = timelineParams) {
|
|
|
34
30
|
}
|
|
35
31
|
const first = index;
|
|
36
32
|
let score = value;
|
|
33
|
+
let maxChanged = opts?.changedFractions ? (opts.changedFractions[index] ?? 0) : 1;
|
|
37
34
|
while (index + 1 < diffs.length && (diffs[index + 1] ?? 0) > threshold) {
|
|
38
35
|
index += 1;
|
|
39
36
|
score = Math.max(score, diffs[index] ?? 0);
|
|
37
|
+
if (opts?.changedFractions) {
|
|
38
|
+
maxChanged = Math.max(maxChanged, opts.changedFractions[index] ?? 0);
|
|
39
|
+
}
|
|
40
40
|
}
|
|
41
41
|
const span = index - first + 1;
|
|
42
|
-
if (span <= params.maxSpan) {
|
|
42
|
+
if (span <= params.maxSpan && maxChanged >= minChanged) {
|
|
43
43
|
cuts.push({
|
|
44
44
|
start: first + 1,
|
|
45
45
|
frame: index + 1,
|
|
@@ -2,19 +2,24 @@ import { TimelineError } from "./errors.js";
|
|
|
2
2
|
import { collectStderr, readRawFrames, spawnIo, waitClose } from "./ffmpeg.js";
|
|
3
3
|
import { timelineParams } from "./params.js";
|
|
4
4
|
import { probe } from "./probe.js";
|
|
5
|
+
const DEFAULT_PIXEL_DELTA = 20;
|
|
5
6
|
/**
|
|
6
|
-
* Mean absolute difference of successive frames.
|
|
7
|
+
* Mean absolute difference and changed-pixel fraction of successive frames.
|
|
7
8
|
*
|
|
8
9
|
* Index i compares frame i and frame i+1. The clip is scaled to `width`
|
|
9
10
|
* with proportional height (nearest integer, at least 1) and read as
|
|
10
11
|
* gray, one frame at a time. A hard cut whose new shot starts at frame f
|
|
11
12
|
* therefore peaks at index f-1.
|
|
12
13
|
*/
|
|
13
|
-
export async function
|
|
14
|
+
export async function frameDiffSeries(path, opts) {
|
|
14
15
|
const width = opts?.width ?? timelineParams.diffWidth;
|
|
16
|
+
const pixelDelta = opts?.pixelDelta ?? DEFAULT_PIXEL_DELTA;
|
|
15
17
|
if (!Number.isInteger(width) || width <= 0) {
|
|
16
18
|
throw new TimelineError("bad_params", `diff width must be a positive integer, got ${width}`);
|
|
17
19
|
}
|
|
20
|
+
if (!Number.isFinite(pixelDelta) || pixelDelta < 0) {
|
|
21
|
+
throw new TimelineError("bad_params", `pixel delta must be a non-negative number, got ${pixelDelta}`);
|
|
22
|
+
}
|
|
18
23
|
const meta = await probe(path);
|
|
19
24
|
const height = proportionalHeight(meta.width, meta.height, width);
|
|
20
25
|
const frameBytes = width * height;
|
|
@@ -38,6 +43,7 @@ export async function frameDiffs(path, opts) {
|
|
|
38
43
|
const stderr = collectStderr(decoder.stderr);
|
|
39
44
|
const done = waitClose(decoder);
|
|
40
45
|
const diffs = [];
|
|
46
|
+
const changed = [];
|
|
41
47
|
let previous = null;
|
|
42
48
|
if (decoder.stdout === null) {
|
|
43
49
|
decoder.kill("SIGKILL");
|
|
@@ -47,7 +53,9 @@ export async function frameDiffs(path, opts) {
|
|
|
47
53
|
try {
|
|
48
54
|
await readRawFrames(decoder.stdout, frameBytes, (frame) => {
|
|
49
55
|
if (previous !== null) {
|
|
50
|
-
|
|
56
|
+
const stats = pairDiffStats(previous, frame, pixelDelta);
|
|
57
|
+
diffs.push(stats.mean);
|
|
58
|
+
changed.push(stats.changedFraction);
|
|
51
59
|
}
|
|
52
60
|
previous = frame;
|
|
53
61
|
return Promise.resolve("continue");
|
|
@@ -67,16 +75,26 @@ export async function frameDiffs(path, opts) {
|
|
|
67
75
|
if (code !== 0) {
|
|
68
76
|
throw new TimelineError("ffmpeg_failed", `frame diff decode failed (${code})${stderr() ? `\n${stderr()}` : ""}`);
|
|
69
77
|
}
|
|
70
|
-
return
|
|
78
|
+
return {
|
|
79
|
+
diffs: Float64Array.from(diffs),
|
|
80
|
+
changed_fractions: Float64Array.from(changed),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
export async function frameDiffs(path, opts) {
|
|
84
|
+
return (await frameDiffSeries(path, opts)).diffs;
|
|
71
85
|
}
|
|
72
86
|
function proportionalHeight(srcWidth, srcHeight, width) {
|
|
73
87
|
return Math.max(1, Math.round((srcHeight * width) / srcWidth));
|
|
74
88
|
}
|
|
75
|
-
function
|
|
89
|
+
function pairDiffStats(left, right, pixelDelta) {
|
|
76
90
|
const n = left.length;
|
|
77
91
|
let sum = 0;
|
|
92
|
+
let hot = 0;
|
|
78
93
|
for (let i = 0; i < n; i += 1) {
|
|
79
|
-
|
|
94
|
+
const d = Math.abs(left[i] - right[i]);
|
|
95
|
+
sum += d;
|
|
96
|
+
if (d > pixelDelta)
|
|
97
|
+
hot += 1;
|
|
80
98
|
}
|
|
81
|
-
return sum / n;
|
|
99
|
+
return { mean: sum / n, changedFraction: hot / n };
|
|
82
100
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { TimelineError } from "./errors.js";
|
|
2
2
|
export { PARAMS_VERSION, timelineParams } from "./params.js";
|
|
3
3
|
export { probe } from "./probe.js";
|
|
4
|
-
export { frameDiffs } from "./diff.js";
|
|
4
|
+
export { frameDiffSeries, frameDiffs } from "./diff.js";
|
|
5
5
|
export { detectCuts, locateCuts } from "./cuts.js";
|
|
6
|
-
export { conform } from "./conform.js";
|
|
6
|
+
export { CONFORM_MAX_NORMAL_RATIO, CONFORM_MIN_NORMAL_RATIO, classifySegmentSpeed, conform, } from "./conform.js";
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
// All text and frame ranges are authored by the task composition, not sample defaults.
|
|
2
2
|
(function () {
|
|
3
|
+
function parseTokens(text) {
|
|
4
|
+
var out = [];
|
|
5
|
+
var hl = false;
|
|
6
|
+
Array.from(text).forEach(function (ch) {
|
|
7
|
+
if (ch === '{' && !hl) { hl = true; return; }
|
|
8
|
+
if (ch === '}' && hl) { hl = false; return; }
|
|
9
|
+
out.push({ ch: ch, hl: hl });
|
|
10
|
+
});
|
|
11
|
+
return out;
|
|
12
|
+
}
|
|
3
13
|
var root = document.getElementById('root');
|
|
4
14
|
var config = JSON.parse(document.getElementById('task').textContent);
|
|
5
15
|
var timeline = gsap.timeline({ paused: true });
|
|
@@ -10,29 +20,39 @@
|
|
|
10
20
|
block.style.left = (layer.x * 100) + '%';
|
|
11
21
|
block.style.top = (layer.y * 100) + '%';
|
|
12
22
|
block.style.color = layer.color;
|
|
23
|
+
if (layer.size) block.style.fontSize = layer.size + 'px';
|
|
13
24
|
root.appendChild(block);
|
|
14
25
|
var glyphs = [];
|
|
15
26
|
layer.lines.forEach(function (text) {
|
|
16
27
|
var line = document.createElement('div');
|
|
17
28
|
block.appendChild(line);
|
|
18
|
-
|
|
29
|
+
parseTokens(text).forEach(function (tok) {
|
|
19
30
|
var glyph = document.createElement('span');
|
|
20
31
|
glyph.className = 'glyph';
|
|
21
|
-
glyph.textContent = ch;
|
|
32
|
+
glyph.textContent = tok.ch;
|
|
33
|
+
if (tok.hl) glyph.style.color = layer.highlight_color || '#ffe14d';
|
|
22
34
|
line.appendChild(glyph);
|
|
23
35
|
glyphs.push(glyph);
|
|
24
36
|
});
|
|
25
37
|
});
|
|
26
38
|
var start = layer.start_frame / config.fps;
|
|
27
39
|
var end = layer.end_frame / config.fps;
|
|
28
|
-
var
|
|
29
|
-
var
|
|
40
|
+
var tpl = layer.template || 'pop-title';
|
|
41
|
+
var isCaption = tpl === 'voice-caption';
|
|
42
|
+
var isTag = tpl === 'top-tag';
|
|
43
|
+
var entrance = isCaption ? Math.min(0.16, (end - start) * 0.25)
|
|
44
|
+
: isTag ? Math.min(0.28, (end - start) * 0.35)
|
|
45
|
+
: Math.min(0.9, (end - start) * 0.45);
|
|
46
|
+
var exit = isCaption ? Math.min(0.10, (end - start) * 0.12)
|
|
47
|
+
: Math.min(0.22, (end - start) * 0.2);
|
|
48
|
+
var startScale = isCaption ? 0.92 : isTag ? 0.72 : 0.35;
|
|
30
49
|
glyphs.forEach(function (glyph, i) {
|
|
31
|
-
|
|
32
|
-
|
|
50
|
+
var stagger = isCaption ? 0 : (glyphs.length > 1 ? i / (glyphs.length - 1) * entrance * 0.75 : 0);
|
|
51
|
+
timeline.fromTo(glyph, { opacity: 0, scale: startScale }, {
|
|
52
|
+
opacity: 1, scale: 1, duration: isCaption ? entrance : entrance * 0.35,
|
|
33
53
|
ease: 'power3.out', immediateRender: false
|
|
34
|
-
}, start +
|
|
35
|
-
timeline.to(glyph, { opacity: 0, scale: 0.85, duration: exit, ease: 'power2.in' }, end - exit);
|
|
54
|
+
}, start + stagger);
|
|
55
|
+
timeline.to(glyph, { opacity: 0, scale: isCaption ? 0.96 : 0.85, duration: exit, ease: 'power2.in' }, end - exit);
|
|
36
56
|
timeline.set(glyph, { opacity: 0 }, end);
|
|
37
57
|
});
|
|
38
58
|
});
|