@joplo-app/kit 0.5.0 → 0.6.1
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 +47 -24
- package/dist/index.js +20 -5
- package/dist/node.d.ts +1 -1
- package/dist/node.js +1 -1
- package/dist/plugin.d.ts +47 -12
- package/dist/renderer-internal.d.ts +27 -0
- package/dist/renderer-internal.js +14 -0
- package/dist/renderer.d.ts +11 -21
- package/dist/renderer.js +3 -14
- package/package.json +6 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* layouts/<id>.tsx layout(<div>…<Outlet/>…</div>)
|
|
6
6
|
* routes/<path>/page.tsx page({ title }, <…/>) 文件夹路径 = 页面路径
|
|
7
7
|
* features/<f>/feature.ts feature({ name, goal, cases, rules, pick })
|
|
8
|
-
* features/<f>/
|
|
8
|
+
* features/<f>/works/<w>.tsx work({ title, summary, on, routes, state, scenarios })
|
|
9
|
+
* works/<key>.tsx work({ title, summary, stage, scenarios })
|
|
9
10
|
*
|
|
10
11
|
* 所有函数只返回数据;画板不会执行这些代码,只消费编译出的 IR。
|
|
11
12
|
*/
|
|
@@ -149,7 +150,7 @@ export type FeatureDef = {
|
|
|
149
150
|
cases: Record<string, CaseDef>;
|
|
150
151
|
rules?: Record<string, RuleDef>;
|
|
151
152
|
questions?: Record<string, QuestionDef>;
|
|
152
|
-
/** 选定的方案(
|
|
153
|
+
/** 选定的方案(works/ 下的文件名);build 只发布它。 */
|
|
153
154
|
pick?: string | null;
|
|
154
155
|
source?: string;
|
|
155
156
|
};
|
|
@@ -275,7 +276,7 @@ export declare const mark: (target: string, opts?: {
|
|
|
275
276
|
export declare const go: (route: string) => EffectDef;
|
|
276
277
|
/** 场景结束。 */
|
|
277
278
|
export declare const done: (text: string, outcome?: "success" | "failure" | "cancelled") => EffectDef;
|
|
278
|
-
/** 这一步依据哪些规则(
|
|
279
|
+
/** 这一步依据哪些规则(work 或 feature 中的规则键)。 */
|
|
279
280
|
export declare const uses: (...rules: string[]) => EffectDef;
|
|
280
281
|
/**
|
|
281
282
|
* 镜头(D43):这一步要看哪些元素。每个 id 在包含它的层级里解析(多层都有同名 id 时各层都生效),只影响那些层级的镜头;
|
|
@@ -447,7 +448,7 @@ export type FlowOpts = {
|
|
|
447
448
|
outcome?: 'success' | 'failure' | 'denied' | 'other';
|
|
448
449
|
/** 起始路径;缺省为方案 on/routes 中的第一个路径。 */
|
|
449
450
|
start?: string;
|
|
450
|
-
/** 在
|
|
451
|
+
/** 在 work.state 之上覆盖的初始状态。 */
|
|
451
452
|
state?: StateInit;
|
|
452
453
|
/**
|
|
453
454
|
* 接着另一个场景演(同一方案的场景键):初始状态 = 那个场景最后一步之后的状态(路径、ui / data / inputs、导演层),
|
|
@@ -461,13 +462,13 @@ export type FlowOpts = {
|
|
|
461
462
|
description?: string;
|
|
462
463
|
expected?: string;
|
|
463
464
|
};
|
|
464
|
-
export declare class Flow {
|
|
465
|
+
export declare class Flow<Kind extends 'flow' | 'chapter' = 'flow'> {
|
|
465
466
|
readonly name: string;
|
|
466
467
|
readonly opts: FlowOpts;
|
|
467
|
-
readonly kind
|
|
468
|
+
readonly kind: Kind;
|
|
468
469
|
readonly steps: StepDef[];
|
|
469
470
|
readonly source: string | undefined;
|
|
470
|
-
constructor(name: string, opts: FlowOpts);
|
|
471
|
+
constructor(name: string, opts: FlowOpts, kind?: Kind);
|
|
471
472
|
private add;
|
|
472
473
|
/** Give the preceding step a stable key. Keep it when editing or moving the same action. */
|
|
473
474
|
key(key: string): this;
|
|
@@ -518,27 +519,49 @@ export declare const free: {
|
|
|
518
519
|
}, ...args: StepArg[]) => StepDef;
|
|
519
520
|
act: (name: string, target: string, data: Record<string, unknown>, ...args: StepArg[]) => StepDef;
|
|
520
521
|
};
|
|
521
|
-
export type
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
522
|
+
export type { CondExpr as Condition };
|
|
523
|
+
export type { JoploProps } from './props.js';
|
|
524
|
+
export type ChapterOpts = Omit<FlowOpts, 'from'> & {
|
|
525
|
+
/** 缺省接声明顺序里的上一章;null 从初始状态重新开始。只在编译时解析。 */
|
|
526
|
+
from?: string | null;
|
|
527
|
+
};
|
|
528
|
+
export declare class Chapter extends Flow<'chapter'> {
|
|
529
|
+
readonly chapterOptions: ChapterOpts;
|
|
530
|
+
readonly source: string | undefined;
|
|
531
|
+
constructor(title: string, chapterOptions?: ChapterOpts);
|
|
532
|
+
}
|
|
533
|
+
/** 任意作品中的一章:步骤、效果和插件能力与 flow() 相同。 */
|
|
534
|
+
export declare const chapter: (title: string, opts?: ChapterOpts) => Chapter;
|
|
535
|
+
export type WorkDef = {
|
|
536
|
+
/** 两处都可用:作品内容、画面、状态与切片。 */
|
|
537
|
+
kind: 'work';
|
|
538
|
+
title: string;
|
|
539
|
+
summary: string;
|
|
540
|
+
/** stage 与 layers 二选一。 */
|
|
541
|
+
stage?: JNode;
|
|
542
|
+
layers?: Record<string, LayerDef>;
|
|
543
|
+
/** 复用项目页面的插槽与新增页面;两种位置共用同一编译路径。 */
|
|
529
544
|
on?: Record<string, Record<string, JNode | JNode[]>>;
|
|
530
|
-
/** 本方案新增的路径。 */
|
|
531
545
|
routes?: Record<string, PageDef>;
|
|
546
|
+
/** 只对 stage 生效。 */
|
|
547
|
+
viewport?: 'desktop' | 'mobile';
|
|
532
548
|
state?: StateInit;
|
|
549
|
+
free?: Record<string, StepDef>;
|
|
550
|
+
scenarios: Record<string, Flow | Chapter>;
|
|
551
|
+
source?: string;
|
|
552
|
+
/** 只在功能下面:设计评审信息与规则。 */
|
|
553
|
+
focus?: string;
|
|
554
|
+
tradeoffs?: string[];
|
|
533
555
|
rules?: Record<string, RuleDef>;
|
|
534
556
|
questions?: Record<string, QuestionDef>;
|
|
535
557
|
coverage?: Record<string, CoverageDecl>;
|
|
536
|
-
/**
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
558
|
+
/** 只在独立作品:受众、角色、草稿与首页排序。 */
|
|
559
|
+
/** 给观众看的受众说明,参与作者内容翻译。空字符串等于未写。 */
|
|
560
|
+
audience?: string;
|
|
561
|
+
roles?: Record<string, RoleDef>;
|
|
562
|
+
/** 草稿只进入 dev IR。 */
|
|
563
|
+
draft?: boolean;
|
|
564
|
+
order?: number;
|
|
541
565
|
};
|
|
542
|
-
|
|
543
|
-
export
|
|
544
|
-
export type { JoploProps } from './props.js';
|
|
566
|
+
/** 一件作品;键来自所在 works/<key>.tsx 的文件名。结构错误由编译器带源位置报告。 */
|
|
567
|
+
export declare const work: (f: Omit<WorkDef, "kind" | "source">) => WorkDef;
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
* layouts/<id>.tsx layout(<div>…<Outlet/>…</div>)
|
|
6
6
|
* routes/<path>/page.tsx page({ title }, <…/>) 文件夹路径 = 页面路径
|
|
7
7
|
* features/<f>/feature.ts feature({ name, goal, cases, rules, pick })
|
|
8
|
-
* features/<f>/
|
|
8
|
+
* features/<f>/works/<w>.tsx work({ title, summary, on, routes, state, scenarios })
|
|
9
|
+
* works/<key>.tsx work({ title, summary, stage, scenarios })
|
|
9
10
|
*
|
|
10
11
|
* 所有函数只返回数据;画板不会执行这些代码,只消费编译出的 IR。
|
|
11
12
|
*/
|
|
@@ -72,7 +73,7 @@ export const mark = (target, opts = {}) => ({ kind: 'effect', type: 'mark', targ
|
|
|
72
73
|
export const go = (route) => ({ kind: 'effect', type: 'go', route });
|
|
73
74
|
/** 场景结束。 */
|
|
74
75
|
export const done = (text, outcome = 'success') => ({ kind: 'effect', type: 'complete', text, outcome });
|
|
75
|
-
/** 这一步依据哪些规则(
|
|
76
|
+
/** 这一步依据哪些规则(work 或 feature 中的规则键)。 */
|
|
76
77
|
export const uses = (...rules) => ({ kind: 'effect', type: 'uses', rules });
|
|
77
78
|
/**
|
|
78
79
|
* 镜头(D43):这一步要看哪些元素。每个 id 在包含它的层级里解析(多层都有同名 id 时各层都生效),只影响那些层级的镜头;
|
|
@@ -145,12 +146,13 @@ const flattenArgs = (args) => args.flat(Infinity);
|
|
|
145
146
|
export class Flow {
|
|
146
147
|
name;
|
|
147
148
|
opts;
|
|
148
|
-
kind
|
|
149
|
+
kind;
|
|
149
150
|
steps = [];
|
|
150
151
|
source;
|
|
151
|
-
constructor(name, opts) {
|
|
152
|
+
constructor(name, opts, kind = 'flow') {
|
|
152
153
|
this.name = name;
|
|
153
154
|
this.opts = opts;
|
|
155
|
+
this.kind = kind;
|
|
154
156
|
this.source = callsite(4);
|
|
155
157
|
}
|
|
156
158
|
add(kind, action, args) {
|
|
@@ -237,4 +239,17 @@ export const free = {
|
|
|
237
239
|
scroll: (target, to, ...args) => reaction(f => f.scroll(target, to, ...args)),
|
|
238
240
|
act: (name, target, data, ...args) => reaction(f => f.act(name, target, data, ...args)),
|
|
239
241
|
};
|
|
240
|
-
export
|
|
242
|
+
export class Chapter extends Flow {
|
|
243
|
+
chapterOptions;
|
|
244
|
+
source;
|
|
245
|
+
constructor(title, chapterOptions = {}) {
|
|
246
|
+
const { from, ...opts } = chapterOptions;
|
|
247
|
+
super(title, { ...opts, ...(typeof from === 'string' ? { from } : {}) }, 'chapter');
|
|
248
|
+
this.chapterOptions = chapterOptions;
|
|
249
|
+
this.source = callsite(4);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
/** 任意作品中的一章:步骤、效果和插件能力与 flow() 相同。 */
|
|
253
|
+
export const chapter = (title, opts = {}) => new Chapter(title, opts);
|
|
254
|
+
/** 一件作品;键来自所在 works/<key>.tsx 的文件名。结构错误由编译器带源位置报告。 */
|
|
255
|
+
export const work = (f) => ({ kind: 'work', ...f, source: callsite() });
|
package/dist/node.d.ts
CHANGED
|
@@ -63,6 +63,6 @@ export declare const or: (...xs: Operand[]) => CondExpr;
|
|
|
63
63
|
export declare const isCond: (v: unknown) => v is CondExpr;
|
|
64
64
|
/** 把 Bind 或条件表达式转成 IR 条件。 */
|
|
65
65
|
export declare const toCondition: (x: unknown) => unknown;
|
|
66
|
-
/** 取调用者位置,用于给 feature/
|
|
66
|
+
/** 取调用者位置,用于给 feature/work/flow 步骤记录源位置。 */
|
|
67
67
|
export declare function callsite(depth?: number): string | undefined;
|
|
68
68
|
export {};
|
package/dist/node.js
CHANGED
|
@@ -91,7 +91,7 @@ export const or = (...xs) => cond({ or: xs.map(asCond) });
|
|
|
91
91
|
export const isCond = (v) => typeof v === 'object' && v !== null && '$cond' in v;
|
|
92
92
|
/** 把 Bind 或条件表达式转成 IR 条件。 */
|
|
93
93
|
export const toCondition = (x) => (isBind(x) ? { truthy: bindPath(x) } : isCond(x) ? x.$cond : x);
|
|
94
|
-
/** 取调用者位置,用于给 feature/
|
|
94
|
+
/** 取调用者位置,用于给 feature/work/flow 步骤记录源位置。 */
|
|
95
95
|
export function callsite(depth = 3) {
|
|
96
96
|
const line = new Error().stack?.split('\n')[depth];
|
|
97
97
|
const m = line && /\(?((?:file:\/\/)?[^()\s]+?):(\d+):(\d+)\)?\s*$/.exec(line);
|
package/dist/plugin.d.ts
CHANGED
|
@@ -20,16 +20,38 @@ import type { JoploProps } from './props.js';
|
|
|
20
20
|
export type { JoploProps } from './props.js';
|
|
21
21
|
/** 插件接口版本:v2 宿主同时兼容 v1 的 mount 运行时。 */
|
|
22
22
|
export declare const PLUGIN_API_VERSION: 2;
|
|
23
|
-
/**
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
/**
|
|
24
|
+
* 元素特性——稳定层:任何插件都可以声明。编译器把它抄到节点上,播放只读 IR。
|
|
25
|
+
* 改动这里的字段要升插件接口版本(PLUGIN_API_VERSION)。
|
|
26
|
+
*/
|
|
27
|
+
export type PublicTraits = {
|
|
28
|
+
/** 显示用的属性:参与翻译、自动字幕与元素的显示名。 */
|
|
29
|
+
text?: string[];
|
|
30
|
+
/** 嵌套在属性里的显示文字的路径;* 表示数组的每一项或对象的每个值。 */
|
|
31
|
+
textPaths?: string[][];
|
|
32
|
+
/** 自己表现状态变化,不叠加自动 reveal。 */
|
|
33
|
+
selfEvident?: boolean;
|
|
34
|
+
/** 观众可以拖动(自由体验里跟随指针;脚本的 drag 步骤照常演示)。 */
|
|
35
|
+
draggable?: boolean;
|
|
36
|
+
/** 悬停是一种有意义的操作(hover 步骤、自由体验里的悬停反应)。 */
|
|
37
|
+
hover?: boolean;
|
|
38
|
+
/** 组件原生的本机取值行为(输入、开关、选择):只改观众本机的游玩层,不写时间线状态。 */
|
|
26
39
|
native?: {
|
|
27
40
|
action: 'type' | 'toggle' | 'select';
|
|
28
41
|
prop: string;
|
|
29
42
|
deselect?: boolean;
|
|
30
43
|
};
|
|
31
|
-
|
|
32
|
-
|
|
44
|
+
/** 接受 type / toggle / select 步骤的输入类元素:single = 一个值,multiple = 多选。 */
|
|
45
|
+
input?: 'single' | 'multiple';
|
|
46
|
+
/** 自带外框的容器(窗口、设备、编辑器):镜头对准里面的元素时,取景以这个外框为界。 */
|
|
47
|
+
frame?: boolean;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* 元素特性——标准库内部层:把标准 UI 组件原来写在引擎里的行为(选项推导、面板门控、分栏折叠、子视口宽度、
|
|
51
|
+
* 禁用外观、输入类别)改成清单数据后的形状。只有仓库内与引擎同版本发布的标准库(ui / diagram / content)使用,
|
|
52
|
+
* 字段会跟着标准库的需要变,不保证兼容;第三方与二方插件不要依赖。
|
|
53
|
+
*/
|
|
54
|
+
export type StandardLibraryTraits = {
|
|
33
55
|
/** Visibility of a panel selected by an ancestor value control. */
|
|
34
56
|
selectionGate?: {
|
|
35
57
|
owner: string;
|
|
@@ -37,8 +59,6 @@ export type ElementTraits = {
|
|
|
37
59
|
value: string;
|
|
38
60
|
fallbackFirst?: boolean;
|
|
39
61
|
};
|
|
40
|
-
input?: 'single' | 'multiple';
|
|
41
|
-
frame?: boolean;
|
|
42
62
|
disabledPresentation?: boolean;
|
|
43
63
|
/** First defined property controls visibility of this node and its descendants. */
|
|
44
64
|
gate?: string[];
|
|
@@ -53,7 +73,6 @@ export type ElementTraits = {
|
|
|
53
73
|
range: string;
|
|
54
74
|
};
|
|
55
75
|
toggleCaption?: 'check';
|
|
56
|
-
selfEvident?: boolean;
|
|
57
76
|
/** Region names are arbitrary plugin-owned properties on the layout node. */
|
|
58
77
|
layout?: Record<string, {
|
|
59
78
|
size: string;
|
|
@@ -69,13 +88,29 @@ export type ElementTraits = {
|
|
|
69
88
|
width: number;
|
|
70
89
|
};
|
|
71
90
|
};
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
};
|
|
92
|
+
/** 编译器与 IR 里的元素特性 = 稳定层 + 标准库内部层。 */
|
|
93
|
+
export type ElementTraits = PublicTraits & StandardLibraryTraits;
|
|
94
|
+
/** 给人看的文字:英文,或「语言 → 文字」(必须有 en;看板按界面语言取,没有时退回 en)。 */
|
|
95
|
+
export type PluginText = string | Record<string, string>;
|
|
96
|
+
/**
|
|
97
|
+
* 看板检查抽屉里这个组件的一行专属信息:把几个属性的当前值连起来显示。
|
|
98
|
+
* values:属性值 → 显示文字(例如状态名);flags:某个布尔属性为 true 时追加的文字;fallback:属性没写时当作哪个值。
|
|
99
|
+
*/
|
|
100
|
+
export type PluginInspectField = {
|
|
101
|
+
label: PluginText;
|
|
102
|
+
props: string[];
|
|
103
|
+
join?: string;
|
|
104
|
+
values?: Record<string, PluginText>;
|
|
105
|
+
flags?: Record<string, PluginText>;
|
|
106
|
+
fallback?: string;
|
|
76
107
|
};
|
|
77
108
|
/** 插件组件的声明:编译、检查、技能都只读这里,不执行运行时代码。 */
|
|
78
109
|
export type PluginComponentSpec = {
|
|
110
|
+
/** 看板里给人看的组件名(检查抽屉)。只进 dev IR,发布与评审版不带。 */
|
|
111
|
+
label?: PluginText;
|
|
112
|
+
/** 检查抽屉里的专属信息行。只进 dev IR。 */
|
|
113
|
+
inspect?: PluginInspectField[];
|
|
79
114
|
/** 一行用法(`npx joplo skill <插件>` 列出),例如 'focus, height; root of a 3D scene'。 */
|
|
80
115
|
doc: string;
|
|
81
116
|
example?: string;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 渲染服务——第一方内部层:只给仓库内的标准库(ui / diagram / content)用,和引擎同版本发布,不保证兼容。
|
|
3
|
+
* 这些是把标准组件原来写在引擎里的能力(手绘描边、响应式取值、选项与分栏推导、主题外观)交还给插件用的通道,
|
|
4
|
+
* 形状跟着标准库的需要变。第三方与二方插件只用 `@joplo-app/kit/renderer`(稳定层)。
|
|
5
|
+
*/
|
|
6
|
+
import type { ReactNode } from 'react';
|
|
7
|
+
import { type RendererContext, type RendererServices } from './renderer.js';
|
|
8
|
+
export declare const useR: RendererServices['useR'];
|
|
9
|
+
export declare const useStroke: () => "rough" | "clean";
|
|
10
|
+
export declare const useLook: () => {
|
|
11
|
+
theme: string;
|
|
12
|
+
font: string | null;
|
|
13
|
+
style: Record<string, string> | undefined;
|
|
14
|
+
};
|
|
15
|
+
export declare const Rough: (p: any) => ReactNode;
|
|
16
|
+
export declare const RoughPath: (p: any) => ReactNode;
|
|
17
|
+
export declare const roundRectPath: RendererServices['roundRectPath'];
|
|
18
|
+
export declare const RendererContextProvider: (props: {
|
|
19
|
+
value: Pick<RendererContext, "width" | "dialogLayer">;
|
|
20
|
+
children?: ReactNode;
|
|
21
|
+
}) => ReactNode;
|
|
22
|
+
export declare const atWidth: RendererServices['atWidth'];
|
|
23
|
+
export declare const childWidth: RendererServices['childWidth'];
|
|
24
|
+
export declare const choicesOf: RendererServices['choicesOf'];
|
|
25
|
+
export declare const layoutRegions: RendererServices['layoutRegions'];
|
|
26
|
+
export declare const resolveValue: RendererServices['resolveValue'];
|
|
27
|
+
export declare const styleOf: RendererServices['styleOf'];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { rendererHost as host } from "./renderer.js";
|
|
2
|
+
export const useR = (...args) => host().useR(...args);
|
|
3
|
+
export const useStroke = () => host().useStroke();
|
|
4
|
+
export const useLook = () => host().useLook();
|
|
5
|
+
export const Rough = (p) => host().Rough(p);
|
|
6
|
+
export const RoughPath = (p) => host().RoughPath(p);
|
|
7
|
+
export const roundRectPath = (...args) => host().roundRectPath(...args);
|
|
8
|
+
export const RendererContextProvider = (props) => host().RendererContextProvider(props);
|
|
9
|
+
export const atWidth = (...args) => host().atWidth(...args);
|
|
10
|
+
export const childWidth = (...args) => host().childWidth(...args);
|
|
11
|
+
export const choicesOf = (...args) => host().choicesOf(...args);
|
|
12
|
+
export const layoutRegions = (...args) => host().layoutRegions(...args);
|
|
13
|
+
export const resolveValue = (...args) => host().resolveValue(...args);
|
|
14
|
+
export const styleOf = (...args) => host().styleOf(...args);
|
package/dist/renderer.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* 渲染服务(浏览器端,由宿主注入)——稳定层。
|
|
3
|
+
*
|
|
4
|
+
* 任何插件的运行时都可以依赖这里的导出:读渲染上下文与引擎时钟、给根元素加上引擎要的属性、渲染子节点、
|
|
5
|
+
* 取属性的当前值、量元素位置。改动这里的签名要升插件接口版本(PLUGIN_API_VERSION)。
|
|
6
|
+
*
|
|
7
|
+
* 只给仓库内标准库(ui / diagram / content)用的服务(手绘描边、响应式取值、选项与分栏推导、外观)在
|
|
8
|
+
* `@joplo-app/kit/renderer-internal`,不保证兼容,第三方与二方插件不要依赖。
|
|
9
|
+
*/
|
|
2
10
|
import type { CSSProperties, ReactNode, ComponentType } from 'react';
|
|
3
11
|
import type { ActionDispatch, EngineFrame, ActionPresentation, PluginIRNode, PluginState } from './plugin.js';
|
|
4
12
|
export type NodeProps = {
|
|
@@ -100,6 +108,8 @@ export type RendererServices = {
|
|
|
100
108
|
walkNodes(n: PluginIRNode, visit: (node: PluginIRNode) => void): void;
|
|
101
109
|
};
|
|
102
110
|
export declare function registerRendererServices(services: RendererServices): void;
|
|
111
|
+
/** 宿主注入的全部服务。插件不要直接用它:稳定层从本模块导入,内部层从 renderer-internal 导入。 */
|
|
112
|
+
export declare const rendererHost: () => RendererServices;
|
|
103
113
|
export declare const useCtx: () => RendererContext;
|
|
104
114
|
export declare const useEngineFrame: (enabled?: boolean) => Readonly<{
|
|
105
115
|
timeMs: number;
|
|
@@ -114,35 +124,15 @@ export declare const useI18n: <Messages extends Record<string, unknown>>() => {
|
|
|
114
124
|
stage: Messages;
|
|
115
125
|
};
|
|
116
126
|
};
|
|
117
|
-
export declare const useR: RendererServices['useR'];
|
|
118
127
|
export declare const useRoot: RendererServices['useRoot'];
|
|
119
128
|
export declare const useRootAttrs: RendererServices['useRootAttrs'];
|
|
120
|
-
export declare const useStroke: () => "rough" | "clean";
|
|
121
129
|
export declare const RenderNode: (p: {
|
|
122
130
|
node: PluginIRNode;
|
|
123
131
|
}) => ReactNode;
|
|
124
|
-
export declare const Rough: (p: any) => ReactNode;
|
|
125
|
-
export declare const RoughPath: (p: any) => ReactNode;
|
|
126
|
-
export declare const roundRectPath: RendererServices['roundRectPath'];
|
|
127
132
|
export declare const rectOf: RendererServices['rectOf'];
|
|
128
133
|
export declare const resolveProps: RendererServices['resolveProps'];
|
|
129
134
|
export declare const isSelfVisible: RendererServices['isSelfVisible'];
|
|
130
135
|
export declare const walkNodes: RendererServices['walkNodes'];
|
|
131
|
-
export declare const RendererContextProvider: (props: {
|
|
132
|
-
value: Pick<RendererContext, "width" | "dialogLayer">;
|
|
133
|
-
children?: ReactNode;
|
|
134
|
-
}) => ReactNode;
|
|
135
|
-
export declare const useLook: () => {
|
|
136
|
-
theme: string;
|
|
137
|
-
font: string | null;
|
|
138
|
-
style: Record<string, string> | undefined;
|
|
139
|
-
};
|
|
140
|
-
export declare const atWidth: RendererServices['atWidth'];
|
|
141
|
-
export declare const childWidth: RendererServices['childWidth'];
|
|
142
|
-
export declare const choicesOf: RendererServices['choicesOf'];
|
|
143
|
-
export declare const layoutRegions: RendererServices['layoutRegions'];
|
|
144
|
-
export declare const resolveValue: RendererServices['resolveValue'];
|
|
145
|
-
export declare const styleOf: RendererServices['styleOf'];
|
|
146
136
|
export declare const nodeLabel: RendererServices['nodeLabel'];
|
|
147
137
|
/** Clocked drawing primitives provided by the host; no plugin animation timers. */
|
|
148
138
|
export declare const motion: Record<keyof import("react").JSX.IntrinsicElements, ComponentType<any>>;
|
package/dist/renderer.js
CHANGED
|
@@ -1,32 +1,21 @@
|
|
|
1
1
|
const KEY = Symbol.for('joplo.renderer.services.v2');
|
|
2
2
|
const global = globalThis;
|
|
3
3
|
export function registerRendererServices(services) { global[KEY] = Object.freeze(services); }
|
|
4
|
-
|
|
4
|
+
/** 宿主注入的全部服务。插件不要直接用它:稳定层从本模块导入,内部层从 renderer-internal 导入。 */
|
|
5
|
+
export const rendererHost = () => { if (!global[KEY])
|
|
5
6
|
throw new Error('Joplo renderer services are not initialized'); return global[KEY]; };
|
|
7
|
+
const host = rendererHost;
|
|
6
8
|
export const useCtx = () => host().useCtx();
|
|
7
9
|
export const useEngineFrame = (enabled = true) => host().useEngineFrame(enabled);
|
|
8
10
|
export const useI18n = () => host().useI18n();
|
|
9
|
-
export const useR = (...args) => host().useR(...args);
|
|
10
11
|
export const useRoot = (...args) => host().useRoot(...args);
|
|
11
12
|
export const useRootAttrs = (...args) => host().useRootAttrs(...args);
|
|
12
|
-
export const useStroke = () => host().useStroke();
|
|
13
13
|
// Function components delegate to the host's identical React context, adding no DOM wrapper.
|
|
14
14
|
export const RenderNode = (p) => host().RenderNode(p);
|
|
15
|
-
export const Rough = (p) => host().Rough(p);
|
|
16
|
-
export const RoughPath = (p) => host().RoughPath(p);
|
|
17
|
-
export const roundRectPath = (...args) => host().roundRectPath(...args);
|
|
18
15
|
export const rectOf = (...args) => host().rectOf(...args);
|
|
19
16
|
export const resolveProps = (...args) => host().resolveProps(...args);
|
|
20
17
|
export const isSelfVisible = (...args) => host().isSelfVisible(...args);
|
|
21
18
|
export const walkNodes = (...args) => host().walkNodes(...args);
|
|
22
|
-
export const RendererContextProvider = (props) => host().RendererContextProvider(props);
|
|
23
|
-
export const useLook = () => host().useLook();
|
|
24
|
-
export const atWidth = (...args) => host().atWidth(...args);
|
|
25
|
-
export const childWidth = (...args) => host().childWidth(...args);
|
|
26
|
-
export const choicesOf = (...args) => host().choicesOf(...args);
|
|
27
|
-
export const layoutRegions = (...args) => host().layoutRegions(...args);
|
|
28
|
-
export const resolveValue = (...args) => host().resolveValue(...args);
|
|
29
|
-
export const styleOf = (...args) => host().styleOf(...args);
|
|
30
19
|
export const nodeLabel = (...args) => host().nodeLabel(...args);
|
|
31
20
|
/** Clocked drawing primitives provided by the host; no plugin animation timers. */
|
|
32
21
|
export const motion = new Proxy({}, { get: (_target, key) => host().motion[key] });
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@joplo-app/kit",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "Joplo 创作 SDK
|
|
3
|
+
"version": "0.6.1",
|
|
4
|
+
"description": "Joplo 创作 SDK:用 work、切片与步骤编写可播放、可上手体验的作品;功能评审为作品添加方案比较、情况与规则;含 JSX 运行时(收集为数据,不作为 React 执行)",
|
|
5
5
|
"license": "PolyForm-Shield-1.0.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -30,6 +30,10 @@
|
|
|
30
30
|
"types": "./dist/renderer.d.ts",
|
|
31
31
|
"default": "./dist/renderer.js"
|
|
32
32
|
},
|
|
33
|
+
"./renderer-internal": {
|
|
34
|
+
"types": "./dist/renderer-internal.d.ts",
|
|
35
|
+
"default": "./dist/renderer-internal.js"
|
|
36
|
+
},
|
|
33
37
|
"./renderer-style": {
|
|
34
38
|
"types": "./dist/renderer-style.d.ts",
|
|
35
39
|
"default": "./dist/renderer-style.js"
|