@joplo-app/kit 0.7.1 → 0.7.3
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 +55 -2
- package/dist/index.js +21 -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,27 @@ 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;
|
|
260
|
+
} | {
|
|
261
|
+
kind: 'effect';
|
|
262
|
+
type: 'call';
|
|
263
|
+
mock: MockDef;
|
|
247
264
|
};
|
|
248
265
|
/** 标注气泡放在目标的哪一侧;不写时自动选画面里放得下的一侧(右、左、下、上)。 */
|
|
249
266
|
export type CalloutSide = 'top' | 'right' | 'bottom' | 'left';
|
|
@@ -296,6 +313,7 @@ export declare const explain: (text: string) => EffectDef;
|
|
|
296
313
|
/**
|
|
297
314
|
* 旁白(D74):讲解人用旁白的声音说的话,像在给同事介绍功能,不是把字幕念出来。和字幕分开存。
|
|
298
315
|
* 朗读的优先级:narrate() > say()(角色台词)> 字幕(过渡卡读标题和副标题);explain 不读。字幕兜底时也用旁白的声音。
|
|
316
|
+
* opts.audio:asset() 或已准备的 localResource() 音频;沿用字幕/旁白轨,绝不调用 TTS。
|
|
299
317
|
* 自动播放会等它读完再进下一步。narrate(false) 显式静音整步(包括 say 与字幕兜底);空字符串不是静音。
|
|
300
318
|
*
|
|
301
319
|
* 写法(详见 npx joplo skill story 第 6 节):
|
|
@@ -306,16 +324,20 @@ export declare const explain: (text: string) => EffectDef;
|
|
|
306
324
|
* .click('share', '小雨把行程单分享给阿杰', narrate('行程用链接发给阿杰,他不用装 App。'))
|
|
307
325
|
* .card('现在是阿杰', { role: 'ajie' }, narrate('换到阿杰这边,他只收到一条消息。'))
|
|
308
326
|
*/
|
|
309
|
-
export declare const narrate: (text: string | false
|
|
327
|
+
export declare const narrate: (text: string | false, opts?: {
|
|
328
|
+
audio?: AudioSource;
|
|
329
|
+
}) => EffectDef;
|
|
310
330
|
/**
|
|
311
331
|
* 角色台词(D74):这一步里角色亲口说的话,用这个角色的声音读(feature.roles 与层级的 role;没有角色时用旁白的声音)。
|
|
312
332
|
* 写第一人称、像真人说话:.click('can_go', '阿杰回复:我能去', say('我能去!'))。
|
|
313
333
|
* 同一步写了 narrate() 时只读旁白。讲解、过渡、总结请用 narrate()。
|
|
334
|
+
* opts.audio 与 narrate 一样接受现成音频;缺失或解码失败报错,不回退供应商。
|
|
314
335
|
* opts.role(D100):写明是谁在说(feature.roles 的键)。系统步骤没有“操作的人”,要角色的声音时必须写;
|
|
315
336
|
* 操作步骤写了也以它为准:.system('说', '“帮我写一封”', say('帮我写一封', { role: 'me' }))。
|
|
316
337
|
*/
|
|
317
338
|
export declare const say: (text: string, opts?: {
|
|
318
339
|
role?: string;
|
|
340
|
+
audio?: AudioSource;
|
|
319
341
|
}) => EffectDef;
|
|
320
342
|
/**
|
|
321
343
|
* 聚光:这一步只照亮这些元素,画面其余部分压暗(不遮挡、不拦截点击,下一步要点的元素也保持明亮)。
|
|
@@ -343,10 +365,15 @@ export declare const callout: (target: string, text: string, opts?: {
|
|
|
343
365
|
}) => EffectDef;
|
|
344
366
|
/**
|
|
345
367
|
* 停留:自动播放时这一步至少停 seconds 秒(0.5–30,按播放速度缩放),给观众时间看画面(图表、对比、一大段结果)。
|
|
368
|
+
* hold('voice', { pad: 0.4 }) / hold('audio', audio, { pad: 0 }) 按实测音频加余量;缺实测时明确估算。
|
|
369
|
+
* 这两种显式音频停留替代字幕阅读下限,仍取动作/镜头/流式输出和插件 effectHold 的最大值。
|
|
370
|
+
* pad 默认 0.45 秒(0–30),只加一次;数字 hold 的原义不变。
|
|
346
371
|
* 不写时按字幕字数自动计算。
|
|
347
372
|
* .system('对比两种结果', '左边是旧流程,右边是新流程', hold(5))
|
|
348
373
|
*/
|
|
349
|
-
export declare
|
|
374
|
+
export declare function hold(seconds: number): EffectDef;
|
|
375
|
+
export declare function hold(source: 'voice', opts?: AudioHoldOptions): EffectDef;
|
|
376
|
+
export declare function hold(source: 'audio', audio: AudioSource, opts?: AudioHoldOptions): EffectDef;
|
|
350
377
|
/**
|
|
351
378
|
* 层级(视角,D43 / T-layers):一个完全独立的画面,有自己的 JSX 树,单独渲染、按自己的布局占满舞台。
|
|
352
379
|
* 各层共享同一份场景状态(ui / data / inputs),切层时步骤不变。需要全景就自己声明一个 overview 层。
|
|
@@ -464,7 +491,33 @@ export type FlowOpts = {
|
|
|
464
491
|
layer?: string;
|
|
465
492
|
description?: string;
|
|
466
493
|
expected?: string;
|
|
494
|
+
/**
|
|
495
|
+
* 写法 v2:这个切片里每个模拟请求依次用哪个结果,例如 { sendInvite: ['timeout', 'ok'] }(第一次超时、第二次成功)。
|
|
496
|
+
* 每次调用恰好用掉一个;没写的请求缺省用第一个结果。
|
|
497
|
+
*/
|
|
498
|
+
api?: Record<string, string[]>;
|
|
467
499
|
};
|
|
500
|
+
/** 模拟请求的一种结果:参数和 .system(name, ...args) 相同(字符串是说明,其余是效果),剧本里展开成一个系统步骤。 */
|
|
501
|
+
export type ResponseDef = {
|
|
502
|
+
kind: 'response';
|
|
503
|
+
name: string;
|
|
504
|
+
caption?: string;
|
|
505
|
+
effects: EffectDef[];
|
|
506
|
+
source?: string;
|
|
507
|
+
};
|
|
508
|
+
export declare const response: (name: string, ...args: StepArg[]) => ResponseDef;
|
|
509
|
+
/** 一个模拟请求和它的各种结果。名字在一件作品里唯一,flow({ api }) 用它选结果。 */
|
|
510
|
+
export type MockDef = {
|
|
511
|
+
name: string;
|
|
512
|
+
outcomes: Record<string, ResponseDef>;
|
|
513
|
+
source?: string;
|
|
514
|
+
};
|
|
515
|
+
/**
|
|
516
|
+
* 写法 v2:系统响应写一次。把返回值放进元素的 onClick 或步骤的效果里,表示“这里发出了这个请求”:
|
|
517
|
+
* 剧本里这一步之后自动接一个系统步骤(结果由 flow({ api }) 依次选,缺省第一个);观众接管时用第一个结果的本地效果。
|
|
518
|
+
* const sendInvite = mock('sendInvite', { ok: response('Request succeeded (mock)', set($.ui.sent, true)), timeout: response('Timed out (mock)', set($.ui.error, 'Timeout')) });
|
|
519
|
+
*/
|
|
520
|
+
export declare const mock: (name: string, outcomes: Record<string, ResponseDef>) => EffectDef;
|
|
468
521
|
export declare class Flow<Kind extends 'flow' | 'chapter' = 'flow'> {
|
|
469
522
|
readonly name: string;
|
|
470
523
|
readonly opts: FlowOpts;
|
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,15 +136,26 @@ 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);
|
|
148
|
+
export const response = (name, ...args) => {
|
|
149
|
+
const flat = flattenArgs(args);
|
|
150
|
+
const caption = flat.find((a) => typeof a === 'string');
|
|
151
|
+
return { kind: 'response', name, ...(caption ? { caption } : {}), effects: flat.filter((a) => typeof a !== 'string'), source: callsite(3) };
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* 写法 v2:系统响应写一次。把返回值放进元素的 onClick 或步骤的效果里,表示“这里发出了这个请求”:
|
|
155
|
+
* 剧本里这一步之后自动接一个系统步骤(结果由 flow({ api }) 依次选,缺省第一个);观众接管时用第一个结果的本地效果。
|
|
156
|
+
* const sendInvite = mock('sendInvite', { ok: response('Request succeeded (mock)', set($.ui.sent, true)), timeout: response('Timed out (mock)', set($.ui.error, 'Timeout')) });
|
|
157
|
+
*/
|
|
158
|
+
export const mock = (name, outcomes) => ({ kind: 'effect', type: 'call', mock: { name, outcomes, source: callsite(3) } });
|
|
146
159
|
export class Flow {
|
|
147
160
|
name;
|
|
148
161
|
opts;
|
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