@yadeck/slide-schema 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +11 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/interface.d.ts +27 -0
- package/dist/interface.d.ts.map +1 -0
- package/dist/interface.js +8 -0
- package/dist/interface.js.map +1 -0
- package/dist/nodes.d.ts +82 -0
- package/dist/nodes.d.ts.map +1 -0
- package/dist/nodes.js +40 -0
- package/dist/nodes.js.map +1 -0
- package/package.json +55 -4
- package/src/index.ts +2 -0
- package/src/interface.ts +38 -0
- package/src/nodes.ts +76 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 onfi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @yadeck/slide-schema
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
deck / slide / block の基底スキーマと、Layout の Interface(`DeckLayout` / `SlideLayout` / `BlockLayout`)。
|
|
4
|
+
|
|
5
|
+
YADECK は、AI が schema 付きの YAML に内容を書き、作り込みたいページだけを JSX で作るスライドジェネレータです。
|
|
6
|
+
|
|
7
|
+
- ドキュメント: https://onfi.github.io/yadeck/
|
|
8
|
+
- リポジトリ: https://github.com/onfi/yadeck
|
|
9
|
+
|
|
10
|
+
## License
|
|
11
|
+
|
|
12
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { BlockNode, DeckNode, SlideNode, Stage } from "./nodes.js";
|
|
4
|
+
/**
|
|
5
|
+
* DI コンテナの契約型。`Props` は実装コンポーネントが受け取る共通部で、
|
|
6
|
+
* 実体は識別用のトークン。型引数は phantom として推論にだけ使う。
|
|
7
|
+
*/
|
|
8
|
+
export interface Interface<Props, S extends Stage = Stage> {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
readonly stage: S;
|
|
11
|
+
readonly __props?: Props;
|
|
12
|
+
}
|
|
13
|
+
export declare function defineInterface<Props, S extends Stage = Stage>(name: string, stage: S): Interface<Props, S>;
|
|
14
|
+
/** Interface から共通 props を取り出す */
|
|
15
|
+
export type PropsOf<I> = I extends Interface<infer P, Stage> ? P : never;
|
|
16
|
+
/** 各段の Layout が受け取る props。段のノードそのもの */
|
|
17
|
+
export declare const DeckLayout: Interface<DeckNode, "deck">;
|
|
18
|
+
export declare const SlideLayout: Interface<SlideNode, "slide">;
|
|
19
|
+
export declare const BlockLayout: Interface<BlockNode, "block">;
|
|
20
|
+
/** Layout の実装。利用者は素の React コンポーネントを書く */
|
|
21
|
+
export type LayoutComponent<P> = (props: P) => ReactNode;
|
|
22
|
+
/** Layout の `type` に渡す zod。自分のフィールドのみを記述する */
|
|
23
|
+
export type FieldsSchema = z.ZodObject<z.ZodRawShape>;
|
|
24
|
+
export type DeckOf<T extends FieldsSchema> = DeckNode & z.infer<T>;
|
|
25
|
+
export type SlideOf<T extends FieldsSchema> = SlideNode & z.infer<T>;
|
|
26
|
+
export type BlockOf<T extends FieldsSchema> = BlockNode & z.infer<T>;
|
|
27
|
+
//# sourceMappingURL=interface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAExE;;;GAGG;AACH,MAAM,WAAW,SAAS,CAAC,KAAK,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC;CAC1B;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,CAAC,SAAS,KAAK,GAAG,KAAK,EAC5D,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,CAAC,GACP,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAErB;AAED,iCAAiC;AACjC,MAAM,MAAM,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;AAEzE,uCAAuC;AACvC,eAAO,MAAM,UAAU,6BAA0D,CAAC;AAClF,eAAO,MAAM,WAAW,+BAA8D,CAAC;AACvF,eAAO,MAAM,WAAW,+BAA8D,CAAC;AAEvF,yCAAyC;AACzC,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,SAAS,CAAC;AAEzD,8CAA8C;AAC9C,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;AAEtD,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,YAAY,IAAI,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACnE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,YAAY,IAAI,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AACrE,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,YAAY,IAAI,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export function defineInterface(name, stage) {
|
|
2
|
+
return Object.freeze({ name, stage });
|
|
3
|
+
}
|
|
4
|
+
/** 各段の Layout が受け取る props。段のノードそのもの */
|
|
5
|
+
export const DeckLayout = defineInterface("DeckLayout", "deck");
|
|
6
|
+
export const SlideLayout = defineInterface("SlideLayout", "slide");
|
|
7
|
+
export const BlockLayout = defineInterface("BlockLayout", "block");
|
|
8
|
+
//# sourceMappingURL=interface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interface.js","sourceRoot":"","sources":["../src/interface.ts"],"names":[],"mappings":"AAcA,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,KAAQ;IAER,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AACxC,CAAC;AAKD,uCAAuC;AACvC,MAAM,CAAC,MAAM,UAAU,GAAG,eAAe,CAAmB,YAAY,EAAE,MAAM,CAAC,CAAC;AAClF,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAqB,aAAa,EAAE,OAAO,CAAC,CAAC;AACvF,MAAM,CAAC,MAAM,WAAW,GAAG,eAAe,CAAqB,aAAa,EAAE,OAAO,CAAC,CAAC"}
|
package/dist/nodes.d.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** 段。deck > slide > block の3段構造で、block が末端 */
|
|
3
|
+
export type Stage = "deck" | "slide" | "block";
|
|
4
|
+
export declare const STAGES: readonly Stage[];
|
|
5
|
+
/** 各段の children を保持するキー。block は末端なので持たない */
|
|
6
|
+
export declare const CHILDREN_KEY: {
|
|
7
|
+
readonly deck: "slides";
|
|
8
|
+
readonly slide: "items";
|
|
9
|
+
};
|
|
10
|
+
export type Tags = string[];
|
|
11
|
+
/** 正規形スキーマのバージョン。data 側の `version` と照合する */
|
|
12
|
+
export declare const SCHEMA_VERSION = "1";
|
|
13
|
+
export declare const tagsSchema: z.ZodArray<z.ZodString>;
|
|
14
|
+
/** id は loader が付与する位置由来の識別子。React の key や検証エラーの位置表示に使う */
|
|
15
|
+
export declare const blockBase: z.ZodObject<{
|
|
16
|
+
id: z.ZodString;
|
|
17
|
+
tags: z.ZodArray<z.ZodString>;
|
|
18
|
+
text: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const slideBase: z.ZodObject<{
|
|
21
|
+
id: z.ZodString;
|
|
22
|
+
tags: z.ZodArray<z.ZodString>;
|
|
23
|
+
description: z.ZodOptional<z.ZodString>;
|
|
24
|
+
}, z.core.$strip>;
|
|
25
|
+
export declare const deckMeta: z.ZodObject<{
|
|
26
|
+
title: z.ZodOptional<z.ZodString>;
|
|
27
|
+
author: z.ZodOptional<z.ZodString>;
|
|
28
|
+
date: z.ZodOptional<z.ZodString>;
|
|
29
|
+
description: z.ZodOptional<z.ZodString>;
|
|
30
|
+
image: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, z.core.$loose>;
|
|
32
|
+
export declare const deckBase: z.ZodObject<{
|
|
33
|
+
id: z.ZodString;
|
|
34
|
+
version: z.ZodOptional<z.ZodString>;
|
|
35
|
+
tags: z.ZodArray<z.ZodString>;
|
|
36
|
+
meta: z.ZodObject<{
|
|
37
|
+
title: z.ZodOptional<z.ZodString>;
|
|
38
|
+
author: z.ZodOptional<z.ZodString>;
|
|
39
|
+
date: z.ZodOptional<z.ZodString>;
|
|
40
|
+
description: z.ZodOptional<z.ZodString>;
|
|
41
|
+
image: z.ZodOptional<z.ZodString>;
|
|
42
|
+
}, z.core.$loose>;
|
|
43
|
+
}, z.core.$strip>;
|
|
44
|
+
export type DeckMeta = z.infer<typeof deckMeta>;
|
|
45
|
+
/** 正規形のノード。自分のフィールドは Layout の type が決めるため index signature を持つ */
|
|
46
|
+
export interface BlockNode extends z.infer<typeof blockBase> {
|
|
47
|
+
[field: string]: unknown;
|
|
48
|
+
}
|
|
49
|
+
export interface SlideNode extends z.infer<typeof slideBase> {
|
|
50
|
+
items: BlockNode[];
|
|
51
|
+
[field: string]: unknown;
|
|
52
|
+
}
|
|
53
|
+
export interface DeckNode extends z.infer<typeof deckBase> {
|
|
54
|
+
slides: SlideNode[];
|
|
55
|
+
[field: string]: unknown;
|
|
56
|
+
}
|
|
57
|
+
export type NodeOf<S extends Stage> = S extends "deck" ? DeckNode : S extends "slide" ? SlideNode : BlockNode;
|
|
58
|
+
export declare const BASE_SCHEMAS: {
|
|
59
|
+
readonly deck: z.ZodObject<{
|
|
60
|
+
id: z.ZodString;
|
|
61
|
+
version: z.ZodOptional<z.ZodString>;
|
|
62
|
+
tags: z.ZodArray<z.ZodString>;
|
|
63
|
+
meta: z.ZodObject<{
|
|
64
|
+
title: z.ZodOptional<z.ZodString>;
|
|
65
|
+
author: z.ZodOptional<z.ZodString>;
|
|
66
|
+
date: z.ZodOptional<z.ZodString>;
|
|
67
|
+
description: z.ZodOptional<z.ZodString>;
|
|
68
|
+
image: z.ZodOptional<z.ZodString>;
|
|
69
|
+
}, z.core.$loose>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
readonly slide: z.ZodObject<{
|
|
72
|
+
id: z.ZodString;
|
|
73
|
+
tags: z.ZodArray<z.ZodString>;
|
|
74
|
+
description: z.ZodOptional<z.ZodString>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
readonly block: z.ZodObject<{
|
|
77
|
+
id: z.ZodString;
|
|
78
|
+
tags: z.ZodArray<z.ZodString>;
|
|
79
|
+
text: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
};
|
|
82
|
+
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8CAA8C;AAC9C,MAAM,MAAM,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAE/C,eAAO,MAAM,MAAM,EAAE,SAAS,KAAK,EAA+B,CAAC;AAEnE,4CAA4C;AAC5C,eAAO,MAAM,YAAY;;;CAA8C,CAAC;AAExE,MAAM,MAAM,IAAI,GAAG,MAAM,EAAE,CAAC;AAE5B,4CAA4C;AAC5C,eAAO,MAAM,cAAc,MAAM,CAAC;AAElC,eAAO,MAAM,UAAU,yBAA6B,CAAC;AAErD,2DAA2D;AAC3D,eAAO,MAAM,SAAS;;;;iBAIpB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;iBAKpB,CAAC;AAEH,eAAO,MAAM,QAAQ;;;;;;iBAQX,CAAC;AAEX,eAAO,MAAM,QAAQ;;;;;;;;;;;iBAKnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC,CAAC;AAEhD,iEAAiE;AACjE,MAAM,WAAW,SAAU,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC;IAC1D,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,SAAU,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,SAAS,CAAC;IAC1D,KAAK,EAAE,SAAS,EAAE,CAAC;IACnB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,WAAW,QAAS,SAAQ,CAAC,CAAC,KAAK,CAAC,OAAO,QAAQ,CAAC;IACxD,MAAM,EAAE,SAAS,EAAE,CAAC;IACpB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC;CAC1B;AAED,MAAM,MAAM,MAAM,CAAC,CAAC,SAAS,KAAK,IAAI,CAAC,SAAS,MAAM,GAClD,QAAQ,GACR,CAAC,SAAS,OAAO,GACf,SAAS,GACT,SAAS,CAAC;AAEhB,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;CAIf,CAAC"}
|
package/dist/nodes.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const STAGES = ["deck", "slide", "block"];
|
|
3
|
+
/** 各段の children を保持するキー。block は末端なので持たない */
|
|
4
|
+
export const CHILDREN_KEY = { deck: "slides", slide: "items" };
|
|
5
|
+
/** 正規形スキーマのバージョン。data 側の `version` と照合する */
|
|
6
|
+
export const SCHEMA_VERSION = "1";
|
|
7
|
+
export const tagsSchema = z.array(z.string().min(1));
|
|
8
|
+
/** id は loader が付与する位置由来の識別子。React の key や検証エラーの位置表示に使う */
|
|
9
|
+
export const blockBase = z.object({
|
|
10
|
+
id: z.string(),
|
|
11
|
+
tags: tagsSchema,
|
|
12
|
+
text: z.string().optional(),
|
|
13
|
+
});
|
|
14
|
+
export const slideBase = z.object({
|
|
15
|
+
id: z.string(),
|
|
16
|
+
tags: tagsSchema,
|
|
17
|
+
/** 見出しの下に添える 1 行の説明。ページが何を示すかを簡潔に。RichText */
|
|
18
|
+
description: z.string().optional().describe("見出しの下に添える 1 行の説明"),
|
|
19
|
+
});
|
|
20
|
+
export const deckMeta = z
|
|
21
|
+
.object({
|
|
22
|
+
title: z.string().optional().describe("発表タイトル。省略すると header の title、無ければファイル名"),
|
|
23
|
+
author: z.string().optional().describe("発表者。省略すると header の author"),
|
|
24
|
+
date: z.string().optional(),
|
|
25
|
+
description: z.string().optional().describe("検索結果や SNS のカードに出す説明。省略すると表紙の副題と各ページの見出しから作る"),
|
|
26
|
+
image: z.string().optional().describe("SNS のカードに出す画像。URL か、siteUrl からの相対パス"),
|
|
27
|
+
})
|
|
28
|
+
.loose();
|
|
29
|
+
export const deckBase = z.object({
|
|
30
|
+
id: z.string(),
|
|
31
|
+
version: z.string().optional(),
|
|
32
|
+
tags: tagsSchema,
|
|
33
|
+
meta: deckMeta,
|
|
34
|
+
});
|
|
35
|
+
export const BASE_SCHEMAS = {
|
|
36
|
+
deck: deckBase,
|
|
37
|
+
slide: slideBase,
|
|
38
|
+
block: blockBase,
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=nodes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../src/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,MAAM,CAAC,MAAM,MAAM,GAAqB,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAEnE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,YAAY,GAAG,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC;AAIxE,4CAA4C;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;AAErD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,IAAI,EAAE,UAAU;IAChB,8CAA8C;IAC9C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,kBAAkB,CAAC;CAChE,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC;KACtB,MAAM,CAAC;IACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,uCAAuC,CAAC;IAC9E,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2BAA2B,CAAC;IACnE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6CAA6C,CAAC;IAC1F,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,qCAAqC,CAAC;CAC7E,CAAC;KACD,KAAK,EAAE,CAAC;AAEX,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,QAAQ;CACf,CAAC,CAAC;AAyBH,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,IAAI,EAAE,QAAQ;IACd,KAAK,EAAE,SAAS;IAChB,KAAK,EAAE,SAAS;CACR,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,57 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yadeck/slide-schema",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "YADECK: base schema (version / meta / deck-slide-block) and layout interfaces",
|
|
5
|
+
"homepage": "https://onfi.github.io/yadeck/",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/onfi/yadeck.git",
|
|
9
|
+
"directory": "packages/slide-schema"
|
|
10
|
+
},
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/onfi/yadeck/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "./dist/index.js",
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"import": "./dist/index.js"
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
"files": [
|
|
24
|
+
"dist",
|
|
25
|
+
"src",
|
|
26
|
+
"!src/**/*.test.ts",
|
|
27
|
+
"!src/**/*.test.tsx",
|
|
28
|
+
"!src/**/__snapshots__"
|
|
29
|
+
],
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "tsc -b"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "^19.0.0",
|
|
35
|
+
"zod": "^4.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"react": "^19.3.0",
|
|
39
|
+
"zod": "^4.6.0"
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"author": "onfi",
|
|
43
|
+
"keywords": [
|
|
44
|
+
"yadeck",
|
|
45
|
+
"slides",
|
|
46
|
+
"presentation",
|
|
47
|
+
"yaml",
|
|
48
|
+
"react",
|
|
49
|
+
"ai"
|
|
50
|
+
],
|
|
51
|
+
"engines": {
|
|
52
|
+
"node": ">=22"
|
|
53
|
+
},
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
}
|
|
57
|
+
}
|
package/src/index.ts
ADDED
package/src/interface.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { z } from "zod";
|
|
3
|
+
import type { BlockNode, DeckNode, SlideNode, Stage } from "./nodes.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* DI コンテナの契約型。`Props` は実装コンポーネントが受け取る共通部で、
|
|
7
|
+
* 実体は識別用のトークン。型引数は phantom として推論にだけ使う。
|
|
8
|
+
*/
|
|
9
|
+
export interface Interface<Props, S extends Stage = Stage> {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly stage: S;
|
|
12
|
+
readonly __props?: Props;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function defineInterface<Props, S extends Stage = Stage>(
|
|
16
|
+
name: string,
|
|
17
|
+
stage: S,
|
|
18
|
+
): Interface<Props, S> {
|
|
19
|
+
return Object.freeze({ name, stage });
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** Interface から共通 props を取り出す */
|
|
23
|
+
export type PropsOf<I> = I extends Interface<infer P, Stage> ? P : never;
|
|
24
|
+
|
|
25
|
+
/** 各段の Layout が受け取る props。段のノードそのもの */
|
|
26
|
+
export const DeckLayout = defineInterface<DeckNode, "deck">("DeckLayout", "deck");
|
|
27
|
+
export const SlideLayout = defineInterface<SlideNode, "slide">("SlideLayout", "slide");
|
|
28
|
+
export const BlockLayout = defineInterface<BlockNode, "block">("BlockLayout", "block");
|
|
29
|
+
|
|
30
|
+
/** Layout の実装。利用者は素の React コンポーネントを書く */
|
|
31
|
+
export type LayoutComponent<P> = (props: P) => ReactNode;
|
|
32
|
+
|
|
33
|
+
/** Layout の `type` に渡す zod。自分のフィールドのみを記述する */
|
|
34
|
+
export type FieldsSchema = z.ZodObject<z.ZodRawShape>;
|
|
35
|
+
|
|
36
|
+
export type DeckOf<T extends FieldsSchema> = DeckNode & z.infer<T>;
|
|
37
|
+
export type SlideOf<T extends FieldsSchema> = SlideNode & z.infer<T>;
|
|
38
|
+
export type BlockOf<T extends FieldsSchema> = BlockNode & z.infer<T>;
|
package/src/nodes.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
|
|
3
|
+
/** 段。deck > slide > block の3段構造で、block が末端 */
|
|
4
|
+
export type Stage = "deck" | "slide" | "block";
|
|
5
|
+
|
|
6
|
+
export const STAGES: readonly Stage[] = ["deck", "slide", "block"];
|
|
7
|
+
|
|
8
|
+
/** 各段の children を保持するキー。block は末端なので持たない */
|
|
9
|
+
export const CHILDREN_KEY = { deck: "slides", slide: "items" } as const;
|
|
10
|
+
|
|
11
|
+
export type Tags = string[];
|
|
12
|
+
|
|
13
|
+
/** 正規形スキーマのバージョン。data 側の `version` と照合する */
|
|
14
|
+
export const SCHEMA_VERSION = "1";
|
|
15
|
+
|
|
16
|
+
export const tagsSchema = z.array(z.string().min(1));
|
|
17
|
+
|
|
18
|
+
/** id は loader が付与する位置由来の識別子。React の key や検証エラーの位置表示に使う */
|
|
19
|
+
export const blockBase = z.object({
|
|
20
|
+
id: z.string(),
|
|
21
|
+
tags: tagsSchema,
|
|
22
|
+
text: z.string().optional(),
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export const slideBase = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
tags: tagsSchema,
|
|
28
|
+
/** 見出しの下に添える 1 行の説明。ページが何を示すかを簡潔に。RichText */
|
|
29
|
+
description: z.string().optional().describe("見出しの下に添える 1 行の説明"),
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
export const deckMeta = z
|
|
33
|
+
.object({
|
|
34
|
+
title: z.string().optional().describe("発表タイトル。省略すると header の title、無ければファイル名"),
|
|
35
|
+
author: z.string().optional().describe("発表者。省略すると header の author"),
|
|
36
|
+
date: z.string().optional(),
|
|
37
|
+
description: z.string().optional().describe("検索結果や SNS のカードに出す説明。省略すると表紙の副題と各ページの見出しから作る"),
|
|
38
|
+
image: z.string().optional().describe("SNS のカードに出す画像。URL か、siteUrl からの相対パス"),
|
|
39
|
+
})
|
|
40
|
+
.loose();
|
|
41
|
+
|
|
42
|
+
export const deckBase = z.object({
|
|
43
|
+
id: z.string(),
|
|
44
|
+
version: z.string().optional(),
|
|
45
|
+
tags: tagsSchema,
|
|
46
|
+
meta: deckMeta,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
export type DeckMeta = z.infer<typeof deckMeta>;
|
|
50
|
+
|
|
51
|
+
/** 正規形のノード。自分のフィールドは Layout の type が決めるため index signature を持つ */
|
|
52
|
+
export interface BlockNode extends z.infer<typeof blockBase> {
|
|
53
|
+
[field: string]: unknown;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface SlideNode extends z.infer<typeof slideBase> {
|
|
57
|
+
items: BlockNode[];
|
|
58
|
+
[field: string]: unknown;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface DeckNode extends z.infer<typeof deckBase> {
|
|
62
|
+
slides: SlideNode[];
|
|
63
|
+
[field: string]: unknown;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export type NodeOf<S extends Stage> = S extends "deck"
|
|
67
|
+
? DeckNode
|
|
68
|
+
: S extends "slide"
|
|
69
|
+
? SlideNode
|
|
70
|
+
: BlockNode;
|
|
71
|
+
|
|
72
|
+
export const BASE_SCHEMAS = {
|
|
73
|
+
deck: deckBase,
|
|
74
|
+
slide: slideBase,
|
|
75
|
+
block: blockBase,
|
|
76
|
+
} as const;
|