@joplo-app/kit 0.7.1 → 0.7.2
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/dist/index.d.ts +25 -2
- package/dist/index.js +10 -8
- package/dist/plugin.d.ts +18 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -167,6 +167,11 @@ export declare const undecided: (reason: string) => CoverageDecl;
|
|
|
167
167
|
export declare const missing: (reason?: string) => CoverageDecl;
|
|
168
168
|
export declare const notApplicable: (reason: string) => CoverageDecl;
|
|
169
169
|
export declare const excluded: (reason: string) => CoverageDecl;
|
|
170
|
+
/** An embedded asset() audio URL or an existing resource-plugin reference. */
|
|
171
|
+
export type AudioSource = string | ReturnType<typeof import('./plugin.js').localResource>;
|
|
172
|
+
export type AudioHoldOptions = {
|
|
173
|
+
pad?: number;
|
|
174
|
+
};
|
|
170
175
|
export type EffectDef = {
|
|
171
176
|
kind: 'effect';
|
|
172
177
|
type: 'set';
|
|
@@ -235,15 +240,23 @@ export type EffectDef = {
|
|
|
235
240
|
kind: 'effect';
|
|
236
241
|
type: 'hold';
|
|
237
242
|
seconds: number;
|
|
243
|
+
} | {
|
|
244
|
+
kind: 'effect';
|
|
245
|
+
type: 'hold';
|
|
246
|
+
timing: 'voice' | 'audio';
|
|
247
|
+
audio?: AudioSource;
|
|
248
|
+
pad?: number;
|
|
238
249
|
} | {
|
|
239
250
|
kind: 'effect';
|
|
240
251
|
type: 'say';
|
|
241
252
|
text: string;
|
|
242
253
|
role?: string;
|
|
254
|
+
audio?: AudioSource;
|
|
243
255
|
} | {
|
|
244
256
|
kind: 'effect';
|
|
245
257
|
type: 'narrate';
|
|
246
258
|
text: string | false;
|
|
259
|
+
audio?: AudioSource;
|
|
247
260
|
};
|
|
248
261
|
/** 标注气泡放在目标的哪一侧;不写时自动选画面里放得下的一侧(右、左、下、上)。 */
|
|
249
262
|
export type CalloutSide = 'top' | 'right' | 'bottom' | 'left';
|
|
@@ -296,6 +309,7 @@ export declare const explain: (text: string) => EffectDef;
|
|
|
296
309
|
/**
|
|
297
310
|
* 旁白(D74):讲解人用旁白的声音说的话,像在给同事介绍功能,不是把字幕念出来。和字幕分开存。
|
|
298
311
|
* 朗读的优先级:narrate() > say()(角色台词)> 字幕(过渡卡读标题和副标题);explain 不读。字幕兜底时也用旁白的声音。
|
|
312
|
+
* opts.audio:asset() 或已准备的 localResource() 音频;沿用字幕/旁白轨,绝不调用 TTS。
|
|
299
313
|
* 自动播放会等它读完再进下一步。narrate(false) 显式静音整步(包括 say 与字幕兜底);空字符串不是静音。
|
|
300
314
|
*
|
|
301
315
|
* 写法(详见 npx joplo skill story 第 6 节):
|
|
@@ -306,16 +320,20 @@ export declare const explain: (text: string) => EffectDef;
|
|
|
306
320
|
* .click('share', '小雨把行程单分享给阿杰', narrate('行程用链接发给阿杰,他不用装 App。'))
|
|
307
321
|
* .card('现在是阿杰', { role: 'ajie' }, narrate('换到阿杰这边,他只收到一条消息。'))
|
|
308
322
|
*/
|
|
309
|
-
export declare const narrate: (text: string | false
|
|
323
|
+
export declare const narrate: (text: string | false, opts?: {
|
|
324
|
+
audio?: AudioSource;
|
|
325
|
+
}) => EffectDef;
|
|
310
326
|
/**
|
|
311
327
|
* 角色台词(D74):这一步里角色亲口说的话,用这个角色的声音读(feature.roles 与层级的 role;没有角色时用旁白的声音)。
|
|
312
328
|
* 写第一人称、像真人说话:.click('can_go', '阿杰回复:我能去', say('我能去!'))。
|
|
313
329
|
* 同一步写了 narrate() 时只读旁白。讲解、过渡、总结请用 narrate()。
|
|
330
|
+
* opts.audio 与 narrate 一样接受现成音频;缺失或解码失败报错,不回退供应商。
|
|
314
331
|
* opts.role(D100):写明是谁在说(feature.roles 的键)。系统步骤没有“操作的人”,要角色的声音时必须写;
|
|
315
332
|
* 操作步骤写了也以它为准:.system('说', '“帮我写一封”', say('帮我写一封', { role: 'me' }))。
|
|
316
333
|
*/
|
|
317
334
|
export declare const say: (text: string, opts?: {
|
|
318
335
|
role?: string;
|
|
336
|
+
audio?: AudioSource;
|
|
319
337
|
}) => EffectDef;
|
|
320
338
|
/**
|
|
321
339
|
* 聚光:这一步只照亮这些元素,画面其余部分压暗(不遮挡、不拦截点击,下一步要点的元素也保持明亮)。
|
|
@@ -343,10 +361,15 @@ export declare const callout: (target: string, text: string, opts?: {
|
|
|
343
361
|
}) => EffectDef;
|
|
344
362
|
/**
|
|
345
363
|
* 停留:自动播放时这一步至少停 seconds 秒(0.5–30,按播放速度缩放),给观众时间看画面(图表、对比、一大段结果)。
|
|
364
|
+
* hold('voice', { pad: 0.4 }) / hold('audio', audio, { pad: 0 }) 按实测音频加余量;缺实测时明确估算。
|
|
365
|
+
* 这两种显式音频停留替代字幕阅读下限,仍取动作/镜头/流式输出和插件 effectHold 的最大值。
|
|
366
|
+
* pad 默认 0.45 秒(0–30),只加一次;数字 hold 的原义不变。
|
|
346
367
|
* 不写时按字幕字数自动计算。
|
|
347
368
|
* .system('对比两种结果', '左边是旧流程,右边是新流程', hold(5))
|
|
348
369
|
*/
|
|
349
|
-
export declare
|
|
370
|
+
export declare function hold(seconds: number): EffectDef;
|
|
371
|
+
export declare function hold(source: 'voice', opts?: AudioHoldOptions): EffectDef;
|
|
372
|
+
export declare function hold(source: 'audio', audio: AudioSource, opts?: AudioHoldOptions): EffectDef;
|
|
350
373
|
/**
|
|
351
374
|
* 层级(视角,D43 / T-layers):一个完全独立的画面,有自己的 JSX 树,单独渲染、按自己的布局占满舞台。
|
|
352
375
|
* 各层共享同一份场景状态(ui / data / inputs),切层时步骤不变。需要全景就自己声明一个 overview 层。
|
package/dist/index.js
CHANGED
|
@@ -90,6 +90,7 @@ export const explain = (text) => ({ kind: 'effect', type: 'explain', text });
|
|
|
90
90
|
/**
|
|
91
91
|
* 旁白(D74):讲解人用旁白的声音说的话,像在给同事介绍功能,不是把字幕念出来。和字幕分开存。
|
|
92
92
|
* 朗读的优先级:narrate() > say()(角色台词)> 字幕(过渡卡读标题和副标题);explain 不读。字幕兜底时也用旁白的声音。
|
|
93
|
+
* opts.audio:asset() 或已准备的 localResource() 音频;沿用字幕/旁白轨,绝不调用 TTS。
|
|
93
94
|
* 自动播放会等它读完再进下一步。narrate(false) 显式静音整步(包括 say 与字幕兜底);空字符串不是静音。
|
|
94
95
|
*
|
|
95
96
|
* 写法(详见 npx joplo skill story 第 6 节):
|
|
@@ -100,15 +101,16 @@ export const explain = (text) => ({ kind: 'effect', type: 'explain', text });
|
|
|
100
101
|
* .click('share', '小雨把行程单分享给阿杰', narrate('行程用链接发给阿杰,他不用装 App。'))
|
|
101
102
|
* .card('现在是阿杰', { role: 'ajie' }, narrate('换到阿杰这边,他只收到一条消息。'))
|
|
102
103
|
*/
|
|
103
|
-
export const narrate = (text) => ({ kind: 'effect', type: 'narrate', text });
|
|
104
|
+
export const narrate = (text, opts = {}) => ({ kind: 'effect', type: 'narrate', text, ...(opts.audio !== undefined ? { audio: opts.audio } : {}) });
|
|
104
105
|
/**
|
|
105
106
|
* 角色台词(D74):这一步里角色亲口说的话,用这个角色的声音读(feature.roles 与层级的 role;没有角色时用旁白的声音)。
|
|
106
107
|
* 写第一人称、像真人说话:.click('can_go', '阿杰回复:我能去', say('我能去!'))。
|
|
107
108
|
* 同一步写了 narrate() 时只读旁白。讲解、过渡、总结请用 narrate()。
|
|
109
|
+
* opts.audio 与 narrate 一样接受现成音频;缺失或解码失败报错,不回退供应商。
|
|
108
110
|
* opts.role(D100):写明是谁在说(feature.roles 的键)。系统步骤没有“操作的人”,要角色的声音时必须写;
|
|
109
111
|
* 操作步骤写了也以它为准:.system('说', '“帮我写一封”', say('帮我写一封', { role: 'me' }))。
|
|
110
112
|
*/
|
|
111
|
-
export const say = (text, opts = {}) => ({ kind: 'effect', type: 'say', text, ...(opts.role !== undefined ? { role: opts.role } : {}) });
|
|
113
|
+
export const say = (text, opts = {}) => ({ kind: 'effect', type: 'say', text, ...(opts.role !== undefined ? { role: opts.role } : {}), ...(opts.audio !== undefined ? { audio: opts.audio } : {}) });
|
|
112
114
|
// ---------- 焦点与呈现形式(D70):这一步观众看哪里、用什么形式看 ----------
|
|
113
115
|
// 镜头(shot)负责“取景”:推近、跟随。下面这些只负责“强调”:都不推近镜头;目标不在当前镜头里时,镜头先退回整层。
|
|
114
116
|
// 都只作用于这一步(下一步消失),跳到任意一步、前后翻、回放结果一致。
|
|
@@ -134,12 +136,12 @@ export const numbered = (...targets) => ({ kind: 'effect', type: 'cue', cue: 'nu
|
|
|
134
136
|
* callout('btn_pay', '按比例只收 18 天', { side: 'left' })
|
|
135
137
|
*/
|
|
136
138
|
export const callout = (target, text, opts = {}) => ({ kind: 'effect', type: 'callout', target, text, ...(opts.side ? { side: opts.side } : {}) });
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
139
|
+
export function hold(source, audioOrOptions, opts = {}) {
|
|
140
|
+
if (typeof source === 'number')
|
|
141
|
+
return { kind: 'effect', type: 'hold', seconds: source };
|
|
142
|
+
const options = source === 'voice' ? audioOrOptions : opts;
|
|
143
|
+
return { kind: 'effect', type: 'hold', timing: source, ...(source === 'audio' ? { audio: audioOrOptions } : {}), ...(options?.pad !== undefined ? { pad: options.pad } : {}) };
|
|
144
|
+
}
|
|
143
145
|
/** opts.role:这一层是谁的画面(feature.roles 的键,D56);画面角落显示这个人的名牌,层级标签带上头像。 */
|
|
144
146
|
export const layer = (title, tree, opts = {}) => ({ kind: 'layer', title, tree, ...opts, source: callsite() });
|
|
145
147
|
const flattenArgs = (args) => args.flat(Infinity);
|
package/dist/plugin.d.ts
CHANGED
|
@@ -208,7 +208,8 @@ export type PluginCompileHooks = {
|
|
|
208
208
|
scenes: readonly PluginScene[];
|
|
209
209
|
state: PluginState;
|
|
210
210
|
previousState?: PluginState;
|
|
211
|
-
resolveProps: (node: PluginIRNode, previous?: boolean) => Record<string, unknown>;
|
|
211
|
+
resolveProps: (node: PluginIRNode, previous?: boolean) => Record<string, unknown>; /** 当前快照的声明式可见性,包含祖先条件与舞台断点;不测量 DOM。 */
|
|
212
|
+
isVisible: (sceneId: string, nodeId: string) => boolean;
|
|
212
213
|
data: unknown;
|
|
213
214
|
previousData: unknown;
|
|
214
215
|
position: number;
|
|
@@ -260,7 +261,8 @@ export type LocalCompiler = {
|
|
|
260
261
|
mime: string;
|
|
261
262
|
timeoutMs?: number;
|
|
262
263
|
inspect?: (input: string, ctx: {
|
|
263
|
-
directory: string;
|
|
264
|
+
readonly directory: string; /** Project root for read-only inspection; no spending authorization or keys are provided. */
|
|
265
|
+
readonly projectDir: string;
|
|
264
266
|
}) => Promise<LocalResourceInfo>;
|
|
265
267
|
persistent?: boolean;
|
|
266
268
|
estimate?: (input: string) => {
|
|
@@ -286,6 +288,7 @@ export type PluginKey = {
|
|
|
286
288
|
export type PluginLocal = {
|
|
287
289
|
compilers: Record<string, LocalCompiler>;
|
|
288
290
|
};
|
|
291
|
+
/** startDelayMs waits after commit on engine time; offsetMs remains a source seek. duck defaults true. maxRetiring (0–32) caps exiting voices of this named track, excluding current. */
|
|
289
292
|
export type MediaCommand = {
|
|
290
293
|
track: string;
|
|
291
294
|
action: 'play';
|
|
@@ -293,6 +296,9 @@ export type MediaCommand = {
|
|
|
293
296
|
oneShot?: boolean;
|
|
294
297
|
durationMs?: number;
|
|
295
298
|
offsetMs?: number;
|
|
299
|
+
startDelayMs?: number;
|
|
300
|
+
duck?: boolean;
|
|
301
|
+
maxRetiring?: number;
|
|
296
302
|
volume?: number;
|
|
297
303
|
loop?: boolean;
|
|
298
304
|
fadeMs?: number;
|
|
@@ -301,12 +307,17 @@ export type MediaCommand = {
|
|
|
301
307
|
action: 'stop';
|
|
302
308
|
fadeMs?: number;
|
|
303
309
|
};
|
|
304
|
-
/** Full state at a step boundary; elapsed time is in unscaled engine milliseconds. */
|
|
310
|
+
/** Full state at a step boundary; elapsed time is in unscaled engine milliseconds. startDelayMs is the original plan, delayRemainingMs the remaining wait, startEventId distinguishes explicit delayed plays. endAfterMs excludes waiting. */
|
|
305
311
|
export type MediaSnapshot = Record<string, {
|
|
306
312
|
plugin: string;
|
|
307
313
|
resource: string;
|
|
308
314
|
offsetMs: number;
|
|
309
315
|
startOffsetMs?: number;
|
|
316
|
+
startDelayMs?: number;
|
|
317
|
+
delayRemainingMs?: number;
|
|
318
|
+
startEventId?: string;
|
|
319
|
+
duck?: boolean;
|
|
320
|
+
maxRetiring?: number;
|
|
310
321
|
volume: number;
|
|
311
322
|
loop: boolean;
|
|
312
323
|
fadeInMs: number;
|
|
@@ -502,6 +513,8 @@ export type ActionPresentation = {
|
|
|
502
513
|
export type ActionDispatch = (id: string, action: ActionGesture, native?: AudienceAction) => void;
|
|
503
514
|
/** 演示此刻的情况:只读。 */
|
|
504
515
|
export type PluginFrame = {
|
|
516
|
+
/** Frozen engine-time export. Missing/false means ordinary real-time presentation, not automation detection. */
|
|
517
|
+
sampling?: boolean;
|
|
505
518
|
/** Only time source for demonstrations. Missing in old hosts; draw the final state then. */
|
|
506
519
|
clock?: EngineFrame;
|
|
507
520
|
gesture?: ActionPresentation | null;
|
|
@@ -549,6 +562,8 @@ export type ComponentCtx = {
|
|
|
549
562
|
}) => void;
|
|
550
563
|
/** 截图、导出前要等待的工作(加载模型、首帧渲染):返回一个 done 函数,完成后调用。 */
|
|
551
564
|
hold: () => () => void;
|
|
565
|
+
/** Register async presentation of the current sampled state. Resolve after pixels are committed; reject on failure. Return value cancels registration and aborts its signal. Host also cancels on component unmount. Never wait for future engine time here. */
|
|
566
|
+
frameReady: (task: (signal: AbortSignal) => Promise<void>) => () => void;
|
|
552
567
|
};
|
|
553
568
|
export type ComponentInstance = {
|
|
554
569
|
update(ctx: ComponentCtx): void;
|
package/package.json
CHANGED