@joplo-app/kit 0.2.17 → 0.2.18
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 +35 -2
- package/dist/index.js +21 -3
- package/dist/ui.d.ts +16 -0
- package/dist/ui.js +6 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -239,10 +239,22 @@ export type EffectDef = {
|
|
|
239
239
|
kind: 'effect';
|
|
240
240
|
type: 'narrate';
|
|
241
241
|
text: string;
|
|
242
|
+
} | {
|
|
243
|
+
kind: 'effect';
|
|
244
|
+
type: 'camera';
|
|
245
|
+
targets: string[];
|
|
246
|
+
pad?: number;
|
|
247
|
+
zoom?: number;
|
|
248
|
+
ms?: number;
|
|
242
249
|
};
|
|
243
250
|
/** 标注气泡放在目标的哪一侧;不写时自动选画面里放得下的一侧(右、左、下、上)。 */
|
|
244
251
|
export type CalloutSide = 'top' | 'right' | 'bottom' | 'left';
|
|
245
252
|
export declare const set: (target: Bind, value: Json) => EffectDef;
|
|
253
|
+
/**
|
|
254
|
+
* 一次改多处:patch($.data, { cam: 'chat', score: 3 }) 等于对每个键各写一个 set()。
|
|
255
|
+
* 嵌套对象整体替换(与 set 相同);步骤参数里直接展开数组即可:.system('…', patch($.data, {…}), hold(3))。
|
|
256
|
+
*/
|
|
257
|
+
export declare const patch: (target: Bind | Record<string, unknown>, values: Record<string, Json>) => EffectDef[];
|
|
246
258
|
export declare const push: (target: Bind, value: Json) => EffectDef;
|
|
247
259
|
/** 与 sonner 一致:toast('…')、toast.success('…')、toast.error('…')。 */
|
|
248
260
|
export declare const toast: ((text: string) => EffectDef) & {
|
|
@@ -275,6 +287,19 @@ export declare const uses: (...rules: string[]) => EffectDef;
|
|
|
275
287
|
* 没有声明 layers 的方案:shot 在路径页面里聚焦。
|
|
276
288
|
*/
|
|
277
289
|
export declare const shot: (...targets: string[]) => EffectDef;
|
|
290
|
+
/** camera() 的选项:pad 取景留白(设计像素,默认 48);zoom 最大放大倍数(默认 3);ms 镜头运动时长(默认 1200)。 */
|
|
291
|
+
export type CameraOpts = {
|
|
292
|
+
pad?: number;
|
|
293
|
+
zoom?: number;
|
|
294
|
+
ms?: number;
|
|
295
|
+
};
|
|
296
|
+
/**
|
|
297
|
+
* 画布镜头:<Canvas> 里的镜头对准这些元素(取它们合起来的范围,按画布的设计尺寸等比放进画面),平滑推、拉、摇,不画焦点框。
|
|
298
|
+
* 镜头位置会保留到下一次 camera();camera() 不带元素 = 回到整张画布。导演会切到目标所在的层。
|
|
299
|
+
* .system('读入', camera('tape', 'machine'))
|
|
300
|
+
* .system('全景', camera({ ms: 2000 }))
|
|
301
|
+
*/
|
|
302
|
+
export declare const camera: (...args: (string | CameraOpts)[]) => EffectDef;
|
|
278
303
|
/**
|
|
279
304
|
* 解说:这一步补充的一句话,显示在画面下方字幕区的第二行(说明下方、小一号);建议不超过 48 个字(check 会提示)。
|
|
280
305
|
* 自动播放时这一步停留的时长也按说明加解说的字数计算。不改变状态。
|
|
@@ -368,7 +393,8 @@ export declare const layer: (title: string, tree: JNode | JNode[], opts?: {
|
|
|
368
393
|
icon?: LayerIcon;
|
|
369
394
|
}) => LayerDef;
|
|
370
395
|
/** 步骤参数:字符串是字幕(可省略,省略时自动生成),其余是效果。 */
|
|
371
|
-
|
|
396
|
+
/** 步骤参数:字幕、效果,或一组效果(patch() 返回数组,直接传入即可)。 */
|
|
397
|
+
export type StepArg = string | EffectDef | readonly EffectDef[];
|
|
372
398
|
/**
|
|
373
399
|
* 过渡卡(D56)的内容:整屏一句大字,用于开场、收尾、时间跳跃(「3 天后」)和换人。
|
|
374
400
|
* sub:小一号的补充;points:收尾时列几条要点;role:换到哪个人(feature.roles 的键),卡片显示这个人,
|
|
@@ -424,6 +450,13 @@ export type FlowOpts = {
|
|
|
424
450
|
start?: string;
|
|
425
451
|
/** 在 option.state 之上覆盖的初始状态。 */
|
|
426
452
|
state?: StateInit;
|
|
453
|
+
/**
|
|
454
|
+
* 接着另一个场景演(同一方案的场景键):初始状态 = 那个场景最后一步之后的状态(路径、ui / data / inputs、画布镜头、导演层),
|
|
455
|
+
* 再叠上这里的 state。讲解片的章节、长流程的分段都用它,每一段从上一段结尾的画面开始,不用手抄状态。
|
|
456
|
+
*/
|
|
457
|
+
from?: string;
|
|
458
|
+
/** 从哪一层开始(layers 的键);缺省为第一层,写了 from 时为那个场景结尾的导演层。 */
|
|
459
|
+
layer?: string;
|
|
427
460
|
description?: string;
|
|
428
461
|
expected?: string;
|
|
429
462
|
};
|
|
@@ -451,7 +484,7 @@ export declare class Flow {
|
|
|
451
484
|
* .card('出发前一天', set($.data.weather, 'rain'))
|
|
452
485
|
* .card('这个方案确认了', { points: ['行程单可以分享', '天气变了会主动提醒'] })
|
|
453
486
|
*/
|
|
454
|
-
card(title: string, ...
|
|
487
|
+
card(title: string, ...rest: (CardOpts | EffectDef | readonly EffectDef[])[]): this;
|
|
455
488
|
/** 系统事件,例如“请求成功(模拟)”。 */
|
|
456
489
|
system(name: string, ...args: StepArg[]): this;
|
|
457
490
|
}
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,11 @@ export const notApplicable = (reason) => ({ kind: 'coverage', status: 'not_appli
|
|
|
46
46
|
export const excluded = (reason) => ({ kind: 'coverage', status: 'excluded', reason });
|
|
47
47
|
const pathOf = (b) => (isBind(b) ? bindPath(b) : b);
|
|
48
48
|
export const set = (target, value) => ({ kind: 'effect', type: 'set', path: pathOf(target), value });
|
|
49
|
+
/**
|
|
50
|
+
* 一次改多处:patch($.data, { cam: 'chat', score: 3 }) 等于对每个键各写一个 set()。
|
|
51
|
+
* 嵌套对象整体替换(与 set 相同);步骤参数里直接展开数组即可:.system('…', patch($.data, {…}), hold(3))。
|
|
52
|
+
*/
|
|
53
|
+
export const patch = (target, values) => Object.entries(values).map(([k, v]) => ({ kind: 'effect', type: 'set', path: `${pathOf(target)}.${k}`, value: v }));
|
|
49
54
|
export const push = (target, value) => ({ kind: 'effect', type: 'append', path: pathOf(target), value });
|
|
50
55
|
/** 与 sonner 一致:toast('…')、toast.success('…')、toast.error('…')。 */
|
|
51
56
|
export const toast = Object.assign((text) => ({ kind: 'effect', type: 'toast', text, tone: 'info' }), {
|
|
@@ -75,6 +80,17 @@ export const uses = (...rules) => ({ kind: 'effect', type: 'uses', rules });
|
|
|
75
80
|
* 没有声明 layers 的方案:shot 在路径页面里聚焦。
|
|
76
81
|
*/
|
|
77
82
|
export const shot = (...targets) => ({ kind: 'effect', type: 'shot', targets });
|
|
83
|
+
/**
|
|
84
|
+
* 画布镜头:<Canvas> 里的镜头对准这些元素(取它们合起来的范围,按画布的设计尺寸等比放进画面),平滑推、拉、摇,不画焦点框。
|
|
85
|
+
* 镜头位置会保留到下一次 camera();camera() 不带元素 = 回到整张画布。导演会切到目标所在的层。
|
|
86
|
+
* .system('读入', camera('tape', 'machine'))
|
|
87
|
+
* .system('全景', camera({ ms: 2000 }))
|
|
88
|
+
*/
|
|
89
|
+
export const camera = (...args) => {
|
|
90
|
+
const targets = args.filter((a) => typeof a === 'string');
|
|
91
|
+
const o = Object.assign({}, ...args.filter((a) => typeof a === 'object' && a !== null));
|
|
92
|
+
return { kind: 'effect', type: 'camera', targets, ...(o.pad !== undefined ? { pad: o.pad } : {}), ...(o.zoom !== undefined ? { zoom: o.zoom } : {}), ...(o.ms !== undefined ? { ms: o.ms } : {}) };
|
|
93
|
+
};
|
|
78
94
|
/**
|
|
79
95
|
* 解说:这一步补充的一句话,显示在画面下方字幕区的第二行(说明下方、小一号);建议不超过 48 个字(check 会提示)。
|
|
80
96
|
* 自动播放时这一步停留的时长也按说明加解说的字数计算。不改变状态。
|
|
@@ -160,8 +176,9 @@ export class Flow {
|
|
|
160
176
|
this.source = callsite(4);
|
|
161
177
|
}
|
|
162
178
|
add(kind, action, args) {
|
|
163
|
-
const
|
|
164
|
-
const
|
|
179
|
+
const flat = args.flat();
|
|
180
|
+
const caption = flat.find((a) => typeof a === 'string');
|
|
181
|
+
const effects = flat.filter((a) => typeof a !== 'string');
|
|
165
182
|
this.steps.push({ kind, action, ...(caption ? { caption } : {}), effects, source: callsite(4) });
|
|
166
183
|
return this;
|
|
167
184
|
}
|
|
@@ -201,7 +218,8 @@ export class Flow {
|
|
|
201
218
|
* .card('出发前一天', set($.data.weather, 'rain'))
|
|
202
219
|
* .card('这个方案确认了', { points: ['行程单可以分享', '天气变了会主动提醒'] })
|
|
203
220
|
*/
|
|
204
|
-
card(title, ...
|
|
221
|
+
card(title, ...rest) {
|
|
222
|
+
const args = rest.flat();
|
|
205
223
|
const effects = args.filter((a) => a.kind === 'effect');
|
|
206
224
|
const opts = Object.assign({}, ...args.filter((a) => a.kind !== 'effect'));
|
|
207
225
|
const { sub, points, role } = opts;
|
package/dist/ui.d.ts
CHANGED
|
@@ -29,6 +29,16 @@ export type JoploProps = {
|
|
|
29
29
|
note?: string;
|
|
30
30
|
/** 敏感信息(D70):内容模糊显示、布局不变;可以写条件(redact={not($.ui.revealed)}),点“显示”后再看清。 */
|
|
31
31
|
redact?: boolean | Bind | CondExpr;
|
|
32
|
+
/**
|
|
33
|
+
* 变形键(magic move):两步之间位置或大小变了的元素,从旧位置平滑移到新位置;同一个键的元素换了容器(一个隐藏、另一个出现)
|
|
34
|
+
* 也会从旧元素的位置飞过来。只在 <Canvas> 里生效。motionDelay 是这个元素的延迟毫秒数(错峰)。
|
|
35
|
+
*/
|
|
36
|
+
motion?: string;
|
|
37
|
+
motionDelay?: number;
|
|
38
|
+
/** 这个元素飞行的毫秒数(默认 900)。 */
|
|
39
|
+
motionMs?: number;
|
|
40
|
+
/** <Canvas> 的直接子元素:固定在屏幕上(按 view 坐标),不随镜头移动。 */
|
|
41
|
+
screen?: boolean;
|
|
32
42
|
visibleFrom?: Size;
|
|
33
43
|
hiddenFrom?: Size;
|
|
34
44
|
/** 逃生口:Tailwind 类名。优先使用布局组件与样式属性。 */
|
|
@@ -161,6 +171,12 @@ export declare const Terminal: C & {
|
|
|
161
171
|
};
|
|
162
172
|
/** 手机外框:子节点按手机宽度排版。页面写 viewport: 'mobile' 时舞台会自动套上,不用写它。 */
|
|
163
173
|
export declare const Phone: C;
|
|
174
|
+
/**
|
|
175
|
+
* 画布(讲解片、动态图形):按设计尺寸 view(默认 1280×800)等比缩放进层里,不重排;里面是一张 w×h 的世界,子元素用设计像素摆放。
|
|
176
|
+
* 镜头用步骤里的 camera('元素', …) 推拉摇;带 motion 键的元素换位置、换容器时自动从旧位置飞到新位置。
|
|
177
|
+
* <Canvas w={2560} h={1600}>…</Canvas>
|
|
178
|
+
*/
|
|
179
|
+
export declare const Canvas: C;
|
|
164
180
|
/** 节点 kind(决定图标与外形)。 */
|
|
165
181
|
export type DiagramKind = 'client' | 'service' | 'model' | 'database' | 'queue' | 'storage' | 'external' | 'tool' | 'user';
|
|
166
182
|
/** 分组图标:节点 kind 之外再加几种常用的“域”图标。 */
|
package/dist/ui.js
CHANGED
|
@@ -116,6 +116,12 @@ export const Artifact = Object.assign(c('Artifact'), { Ref: c('Artifact.Ref') })
|
|
|
116
116
|
export const Terminal = Object.assign(c('Terminal'), { Command: c('Terminal.Command'), Output: c('Terminal.Output'), Input: c('Terminal.Input') });
|
|
117
117
|
/** 手机外框:子节点按手机宽度排版。页面写 viewport: 'mobile' 时舞台会自动套上,不用写它。 */
|
|
118
118
|
export const Phone = c('Phone');
|
|
119
|
+
/**
|
|
120
|
+
* 画布(讲解片、动态图形):按设计尺寸 view(默认 1280×800)等比缩放进层里,不重排;里面是一张 w×h 的世界,子元素用设计像素摆放。
|
|
121
|
+
* 镜头用步骤里的 camera('元素', …) 推拉摇;带 motion 键的元素换位置、换容器时自动从旧位置飞到新位置。
|
|
122
|
+
* <Canvas w={2560} h={1600}>…</Canvas>
|
|
123
|
+
*/
|
|
124
|
+
export const Canvas = c('Canvas');
|
|
119
125
|
/**
|
|
120
126
|
* 架构图(D41 / D69):布局在编译期算好(ELK 分层 + 分组 + 正交走线),每一步坐标都相同。按业务域分组:
|
|
121
127
|
* <Diagram id="arch" h="100%"> // 不写 direction:按舞台比例自动选
|