Skip to content

Commit fb82b08

Browse files
authored
Merge pull request #25 from takker99/re-export
BREAKING CHANGES: Directoryをなくして、型の階層構造を修正した
2 parents ec2d394 + 0e002da commit fb82b08

File tree

10 files changed

+596
-376
lines changed

10 files changed

+596
-376
lines changed

base.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ export interface Line {
33
/** 行のid */ id: LineId;
44
/** 行のテキスト */ text: string;
55
/** 一番最後に行を編集した人のid */ userId: UserId;
6-
/** 行の作成日時 */ created: number;
7-
/** 行の最終更新日時 */ updated: number;
6+
/** 行の作成日時 */ created: UnixTime;
7+
/** 行の最終更新日時 */ updated: UnixTime;
88
}
99

1010
/** basic information about a page */
@@ -20,8 +20,8 @@ export interface Page {
2020
* the maximum number of lines is 5.
2121
*/
2222
descriptions: string[];
23-
/** ページの最終更新日時 */ updated: number;
24-
/** Date last visitedに使われる最終アクセス日時 */ accessed: number;
23+
/** ページの最終更新日時 */ updated: UnixTime;
24+
/** Date last visitedに使われる最終アクセス日時 */ accessed: UnixTime;
2525
}
2626

2727
/** the user id */
@@ -41,3 +41,5 @@ export type ProjectId = string;
4141
* - UPPER CASE -> upper_case
4242
*/
4343
export type StringLc = string;
44+
/** UNIX time */
45+
export type UnixTime = number;

userscript/blocks.ts renamed to blocks.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
import { Node, NodeWithoutIndent } from "./nodes.ts";
2-
import { Line } from "../base.ts";
1+
import type { Node, NodeWithoutIndent } from "./nodes.ts";
2+
import type { Line as LineBase } from "./base.ts";
33

4-
export type ParsedLine =
5-
& Line
4+
export type Line =
5+
& LineBase
66
& {
77
section: {
8+
/** section number */
89
number: number;
10+
/** section開始行なら`true` */
911
start: boolean;
12+
/** section終了行なら`true` */
1013
end: boolean;
1114
};
1215
}
1316
& ({
14-
title?: boolean;
17+
/** タイトル行だったときのみ生える */
18+
title?: true;
1519
} | {
1620
codeBlock: CodeBlock;
1721
} | {
@@ -21,12 +25,15 @@ export type ParsedLine =
2125
} | {
2226
cli: Cli;
2327
} | {
28+
/** 番号付きリストのときのみ生える */
29+
numberList?: {
30+
/** 番号の長さ */
31+
digit: number;
32+
};
33+
/** 数式を含む行のときのみ生える */
2434
formulaLine?: true;
25-
nodes: NodeWithoutIndent[];
26-
} | {
27-
numberList?: { digit: number };
28-
formulaLine?: true;
29-
nodes: Node[];
35+
/** 中に含まれるnodes */
36+
nodes: Node | NodeWithoutIndent[];
3037
});
3138

3239
/** the type which represents a line in a block */
@@ -47,11 +54,17 @@ export interface TableBlock extends Block {
4754
/** the title of the table block */ title: string;
4855
/** cells included in the present line */ cells: string[];
4956
}
50-
export type Helpfeel = {
57+
58+
/** Helpfeel記法 */
59+
export interface Helpfeel {
5160
prefix: "?";
61+
/** Helpfeel本文 */
5262
entry: string;
53-
};
54-
export type Cli = {
63+
}
64+
65+
/** Command Line記法 */
66+
export interface Cli {
5567
prefix: "$" | "%";
68+
/** Command Line本文 */
5669
command: string;
57-
};
70+
}

api/error.ts renamed to error.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
/** Scrapbox REST APIが返すエラーの型 */
1+
/** Scrapbox REST APIが返すエラーの型
2+
*
3+
* `name`はないことがある
4+
*/
25
export interface ErrorLike {
36
/** error name */ name: string;
47
/** error message */ message: string;
@@ -22,8 +25,10 @@ export interface NotPrivilegeError extends ErrorLike {
2225
/** Loginが必要なAPIをloginせずに叩いたときに発生するエラー */
2326
export interface NotLoggedInError extends ErrorLike {
2427
name: "NotLoggedInError";
25-
/** 詳細情報 */ details: {
26-
/** 使用できるログイン方法 */ loginStrategies: (
28+
/** 詳細情報 */
29+
details: {
30+
/** 使用できるログイン方法 */
31+
loginStrategies: (
2732
| "google"
2833
| "github"
2934
| "microsoft"

eventName.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/** built-in UserScript events
2+
*
3+
* | Event | Description |
4+
* | ------ | ----------- |
5+
* | lines:changed | 今開いているページの文章が変更された |
6+
* | page:changed | 別のページに遷移した |
7+
* | layout:changed | 別の種類のページに遷移した |
8+
* | project:changed | 別のprojectに遷移した |
9+
*/
10+
export type eventName =
11+
| "lines:changed"
12+
| "page:changed"
13+
| "layout:changed"
14+
| "project:changed";

mod.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
export * from "./api/response.ts";
2-
export * from "./api/error.ts";
3-
export * from "./userscript.ts";
4-
export * from "./userscript/blocks.ts";
5-
export * from "./userscript/nodes.ts";
1+
export * from "./response.ts";
2+
export * from "./error.ts";
3+
export * from "./error.ts";
4+
export type { Scrapbox } from "./userscript.ts";
5+
import * as UserScript from "./userscript.ts";
6+
export { UserScript };

0 commit comments

Comments
 (0)