Skip to content
10 changes: 6 additions & 4 deletions base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ export interface Line {
/** 行のid */ id: LineId;
/** 行のテキスト */ text: string;
/** 一番最後に行を編集した人のid */ userId: UserId;
/** 行の作成日時 */ created: number;
/** 行の最終更新日時 */ updated: number;
/** 行の作成日時 */ created: UnixTime;
/** 行の最終更新日時 */ updated: UnixTime;
}

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

/** the user id */
Expand All @@ -41,3 +41,5 @@ export type ProjectId = string;
* - UPPER CASE -> upper_case
*/
export type StringLc = string;
/** UNIX time */
export type UnixTime = number;
41 changes: 27 additions & 14 deletions userscript/blocks.ts → blocks.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
import { Node, NodeWithoutIndent } from "./nodes.ts";
import { Line } from "../base.ts";
import type { Node, NodeWithoutIndent } from "./nodes.ts";
import type { Line as LineBase } from "./base.ts";

export type ParsedLine =
& Line
export type Line =
& LineBase
& {
section: {
/** section number */
number: number;
/** section開始行なら`true` */
start: boolean;
/** section終了行なら`true` */
end: boolean;
};
}
& ({
title?: boolean;
/** タイトル行だったときのみ生える */
title?: true;
} | {
codeBlock: CodeBlock;
} | {
Expand All @@ -21,12 +25,15 @@ export type ParsedLine =
} | {
cli: Cli;
} | {
/** 番号付きリストのときのみ生える */
numberList?: {
/** 番号の長さ */
digit: number;
};
/** 数式を含む行のときのみ生える */
formulaLine?: true;
nodes: NodeWithoutIndent[];
} | {
numberList?: { digit: number };
formulaLine?: true;
nodes: Node[];
/** 中に含まれるnodes */
nodes: Node | NodeWithoutIndent[];
});

/** the type which represents a line in a block */
Expand All @@ -47,11 +54,17 @@ export interface TableBlock extends Block {
/** the title of the table block */ title: string;
/** cells included in the present line */ cells: string[];
}
export type Helpfeel = {

/** Helpfeel記法 */
export interface Helpfeel {
prefix: "?";
/** Helpfeel本文 */
entry: string;
};
export type Cli = {
}

/** Command Line記法 */
export interface Cli {
prefix: "$" | "%";
/** Command Line本文 */
command: string;
};
}
11 changes: 8 additions & 3 deletions api/error.ts → error.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
/** Scrapbox REST APIが返すエラーの型 */
/** Scrapbox REST APIが返すエラーの型
*
* `name`はないことがある
*/
export interface ErrorLike {
/** error name */ name: string;
/** error message */ message: string;
Expand All @@ -22,8 +25,10 @@ export interface NotPrivilegeError extends ErrorLike {
/** Loginが必要なAPIをloginせずに叩いたときに発生するエラー */
export interface NotLoggedInError extends ErrorLike {
name: "NotLoggedInError";
/** 詳細情報 */ details: {
/** 使用できるログイン方法 */ loginStrategies: (
/** 詳細情報 */
details: {
/** 使用できるログイン方法 */
loginStrategies: (
| "google"
| "github"
| "microsoft"
Expand Down
14 changes: 14 additions & 0 deletions eventName.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/** built-in UserScript events
*
* | Event | Description |
* | ------ | ----------- |
* | lines:changed | 今開いているページの文章が変更された |
* | page:changed | 別のページに遷移した |
* | layout:changed | 別の種類のページに遷移した |
* | project:changed | 別のprojectに遷移した |
*/
export type eventName =
| "lines:changed"
| "page:changed"
| "layout:changed"
| "project:changed";
11 changes: 6 additions & 5 deletions mod.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from "./api/response.ts";
export * from "./api/error.ts";
export * from "./userscript.ts";
export * from "./userscript/blocks.ts";
export * from "./userscript/nodes.ts";
export * from "./response.ts";
export * from "./error.ts";
export * from "./error.ts";
export type { Scrapbox } from "./userscript.ts";
import * as UserScript from "./userscript.ts";
export { UserScript };
Loading