Initial commit: New MoreminiMore website with fresh design

This commit is contained in:
MoreminiMore
2026-04-22 01:59:05 +07:00
commit 76409638cc
14010 changed files with 2052041 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
import * as d from "../encoding/json/decode.js";
import * as proto from "./proto.js";
export declare function Error(obj: d.Obj): proto.Error;
export declare function StmtResult(obj: d.Obj): proto.StmtResult;
export declare function BatchResult(obj: d.Obj): proto.BatchResult;
export declare function CursorEntry(obj: d.Obj): proto.CursorEntry;
export declare function DescribeResult(obj: d.Obj): proto.DescribeResult;
export declare function Value(obj: d.Obj): proto.Value;

View File

@@ -0,0 +1,106 @@
import { Base64 } from "js-base64";
import { ProtoError } from "../errors.js";
import * as d from "../encoding/json/decode.js";
export function Error(obj) {
const message = d.string(obj["message"]);
const code = d.stringOpt(obj["code"]);
return { message, code };
}
export function StmtResult(obj) {
const cols = d.arrayObjectsMap(obj["cols"], Col);
const rows = d.array(obj["rows"]).map((rowObj) => d.arrayObjectsMap(rowObj, Value));
const affectedRowCount = d.number(obj["affected_row_count"]);
const lastInsertRowidStr = d.stringOpt(obj["last_insert_rowid"]);
const lastInsertRowid = lastInsertRowidStr !== undefined
? BigInt(lastInsertRowidStr) : undefined;
return { cols, rows, affectedRowCount, lastInsertRowid };
}
function Col(obj) {
const name = d.stringOpt(obj["name"]);
const decltype = d.stringOpt(obj["decltype"]);
return { name, decltype };
}
export function BatchResult(obj) {
const stepResults = new Map();
d.array(obj["step_results"]).forEach((value, i) => {
if (value !== null) {
stepResults.set(i, StmtResult(d.object(value)));
}
});
const stepErrors = new Map();
d.array(obj["step_errors"]).forEach((value, i) => {
if (value !== null) {
stepErrors.set(i, Error(d.object(value)));
}
});
return { stepResults, stepErrors };
}
export function CursorEntry(obj) {
const type = d.string(obj["type"]);
if (type === "step_begin") {
const step = d.number(obj["step"]);
const cols = d.arrayObjectsMap(obj["cols"], Col);
return { type: "step_begin", step, cols };
}
else if (type === "step_end") {
const affectedRowCount = d.number(obj["affected_row_count"]);
const lastInsertRowidStr = d.stringOpt(obj["last_insert_rowid"]);
const lastInsertRowid = lastInsertRowidStr !== undefined
? BigInt(lastInsertRowidStr) : undefined;
return { type: "step_end", affectedRowCount, lastInsertRowid };
}
else if (type === "step_error") {
const step = d.number(obj["step"]);
const error = Error(d.object(obj["error"]));
return { type: "step_error", step, error };
}
else if (type === "row") {
const row = d.arrayObjectsMap(obj["row"], Value);
return { type: "row", row };
}
else if (type === "error") {
const error = Error(d.object(obj["error"]));
return { type: "error", error };
}
else {
throw new ProtoError("Unexpected type of CursorEntry");
}
}
export function DescribeResult(obj) {
const params = d.arrayObjectsMap(obj["params"], DescribeParam);
const cols = d.arrayObjectsMap(obj["cols"], DescribeCol);
const isExplain = d.boolean(obj["is_explain"]);
const isReadonly = d.boolean(obj["is_readonly"]);
return { params, cols, isExplain, isReadonly };
}
function DescribeParam(obj) {
const name = d.stringOpt(obj["name"]);
return { name };
}
function DescribeCol(obj) {
const name = d.string(obj["name"]);
const decltype = d.stringOpt(obj["decltype"]);
return { name, decltype };
}
export function Value(obj) {
const type = d.string(obj["type"]);
if (type === "null") {
return null;
}
else if (type === "integer") {
const value = d.string(obj["value"]);
return BigInt(value);
}
else if (type === "float") {
return d.number(obj["value"]);
}
else if (type === "text") {
return d.string(obj["value"]);
}
else if (type === "blob") {
return Base64.toUint8Array(d.string(obj["base64"]));
}
else {
throw new ProtoError("Unexpected type of Value");
}
}

View File

@@ -0,0 +1,4 @@
import * as e from "../encoding/json/encode.js";
import * as proto from "./proto.js";
export declare function Stmt(w: e.ObjectWriter, msg: proto.Stmt): void;
export declare function Batch(w: e.ObjectWriter, msg: proto.Batch): void;

View File

@@ -0,0 +1,71 @@
import { Base64 } from "js-base64";
import { impossible } from "../util.js";
export function Stmt(w, msg) {
if (msg.sql !== undefined) {
w.string("sql", msg.sql);
}
if (msg.sqlId !== undefined) {
w.number("sql_id", msg.sqlId);
}
w.arrayObjects("args", msg.args, Value);
w.arrayObjects("named_args", msg.namedArgs, NamedArg);
w.boolean("want_rows", msg.wantRows);
}
function NamedArg(w, msg) {
w.string("name", msg.name);
w.object("value", msg.value, Value);
}
export function Batch(w, msg) {
w.arrayObjects("steps", msg.steps, BatchStep);
}
function BatchStep(w, msg) {
if (msg.condition !== undefined) {
w.object("condition", msg.condition, BatchCond);
}
w.object("stmt", msg.stmt, Stmt);
}
function BatchCond(w, msg) {
w.stringRaw("type", msg.type);
if (msg.type === "ok" || msg.type === "error") {
w.number("step", msg.step);
}
else if (msg.type === "not") {
w.object("cond", msg.cond, BatchCond);
}
else if (msg.type === "and" || msg.type === "or") {
w.arrayObjects("conds", msg.conds, BatchCond);
}
else if (msg.type === "is_autocommit") {
// do nothing
}
else {
throw impossible(msg, "Impossible type of BatchCond");
}
}
function Value(w, msg) {
if (msg === null) {
w.stringRaw("type", "null");
}
else if (typeof msg === "bigint") {
w.stringRaw("type", "integer");
w.stringRaw("value", "" + msg);
}
else if (typeof msg === "number") {
w.stringRaw("type", "float");
w.number("value", msg);
}
else if (typeof msg === "string") {
w.stringRaw("type", "text");
w.string("value", msg);
}
else if (msg instanceof Uint8Array) {
w.stringRaw("type", "blob");
w.stringRaw("base64", Base64.fromUint8Array(msg));
}
else if (msg === undefined) {
// do nothing
}
else {
throw impossible(msg, "Impossible type of Value");
}
}

View File

@@ -0,0 +1,96 @@
export type int32 = number;
export type uint32 = number;
export type Error = {
message: string;
code: string | undefined;
};
export type Stmt = {
sql: string | undefined;
sqlId: int32 | undefined;
args: Array<Value>;
namedArgs: Array<NamedArg>;
wantRows: boolean;
};
export type NamedArg = {
name: string;
value: Value;
};
export type StmtResult = {
cols: Array<Col>;
rows: Array<Array<Value>>;
affectedRowCount: number;
lastInsertRowid: bigint | undefined;
};
export type Col = {
name: string | undefined;
decltype: string | undefined;
};
export type Batch = {
steps: Array<BatchStep>;
};
export type BatchStep = {
condition: BatchCond | undefined;
stmt: Stmt;
};
export type BatchCond = {
type: "ok";
step: uint32;
} | {
type: "error";
step: uint32;
} | {
type: "not";
cond: BatchCond;
} | {
type: "and";
conds: Array<BatchCond>;
} | {
type: "or";
conds: Array<BatchCond>;
} | {
type: "is_autocommit";
};
export type BatchResult = {
stepResults: Map<uint32, StmtResult>;
stepErrors: Map<uint32, Error>;
};
export type CursorEntry = {
type: "none";
} | StepBeginEntry | StepEndEntry | StepErrorEntry | RowEntry | ErrorEntry;
export type StepBeginEntry = {
type: "step_begin";
step: uint32;
cols: Array<Col>;
};
export type StepEndEntry = {
type: "step_end";
affectedRowCount: number;
lastInsertRowid: bigint | undefined;
};
export type StepErrorEntry = {
type: "step_error";
step: uint32;
error: Error;
};
export type RowEntry = {
type: "row";
row: Array<Value>;
};
export type ErrorEntry = {
type: "error";
error: Error;
};
export type DescribeResult = {
params: Array<DescribeParam>;
cols: Array<DescribeCol>;
isExplain: boolean;
isReadonly: boolean;
};
export type DescribeParam = {
name: string | undefined;
};
export type DescribeCol = {
name: string;
decltype: string | undefined;
};
export type Value = undefined | null | bigint | number | string | Uint8Array;

View File

@@ -0,0 +1,2 @@
// Types for the protocol structures that are shared for WebSocket and HTTP
export {};

View File

@@ -0,0 +1,7 @@
import * as d from "../encoding/protobuf/decode.js";
import * as proto from "./proto.js";
export declare const Error: d.MessageDef<proto.Error>;
export declare const StmtResult: d.MessageDef<proto.StmtResult>;
export declare const BatchResult: d.MessageDef<proto.BatchResult>;
export declare const CursorEntry: d.MessageDef<proto.CursorEntry>;
export declare const DescribeResult: d.MessageDef<proto.DescribeResult>;

View File

@@ -0,0 +1,115 @@
export const Error = {
default() { return { message: "", code: undefined }; },
1(r, msg) { msg.message = r.string(); },
2(r, msg) { msg.code = r.string(); },
};
export const StmtResult = {
default() {
return {
cols: [],
rows: [],
affectedRowCount: 0,
lastInsertRowid: undefined,
};
},
1(r, msg) { msg.cols.push(r.message(Col)); },
2(r, msg) { msg.rows.push(r.message(Row)); },
3(r, msg) { msg.affectedRowCount = Number(r.uint64()); },
4(r, msg) { msg.lastInsertRowid = r.sint64(); },
};
const Col = {
default() { return { name: undefined, decltype: undefined }; },
1(r, msg) { msg.name = r.string(); },
2(r, msg) { msg.decltype = r.string(); },
};
const Row = {
default() { return []; },
1(r, msg) { msg.push(r.message(Value)); },
};
export const BatchResult = {
default() { return { stepResults: new Map(), stepErrors: new Map() }; },
1(r, msg) {
const [key, value] = r.message(BatchResultStepResult);
msg.stepResults.set(key, value);
},
2(r, msg) {
const [key, value] = r.message(BatchResultStepError);
msg.stepErrors.set(key, value);
},
};
const BatchResultStepResult = {
default() { return [0, StmtResult.default()]; },
1(r, msg) { msg[0] = r.uint32(); },
2(r, msg) { msg[1] = r.message(StmtResult); },
};
const BatchResultStepError = {
default() { return [0, Error.default()]; },
1(r, msg) { msg[0] = r.uint32(); },
2(r, msg) { msg[1] = r.message(Error); },
};
export const CursorEntry = {
default() { return { type: "none" }; },
1(r) { return r.message(StepBeginEntry); },
2(r) { return r.message(StepEndEntry); },
3(r) { return r.message(StepErrorEntry); },
4(r) { return { type: "row", row: r.message(Row) }; },
5(r) { return { type: "error", error: r.message(Error) }; },
};
const StepBeginEntry = {
default() { return { type: "step_begin", step: 0, cols: [] }; },
1(r, msg) { msg.step = r.uint32(); },
2(r, msg) { msg.cols.push(r.message(Col)); },
};
const StepEndEntry = {
default() {
return {
type: "step_end",
affectedRowCount: 0,
lastInsertRowid: undefined,
};
},
1(r, msg) { msg.affectedRowCount = r.uint32(); },
2(r, msg) { msg.lastInsertRowid = r.uint64(); },
};
const StepErrorEntry = {
default() {
return {
type: "step_error",
step: 0,
error: Error.default(),
};
},
1(r, msg) { msg.step = r.uint32(); },
2(r, msg) { msg.error = r.message(Error); },
};
export const DescribeResult = {
default() {
return {
params: [],
cols: [],
isExplain: false,
isReadonly: false,
};
},
1(r, msg) { msg.params.push(r.message(DescribeParam)); },
2(r, msg) { msg.cols.push(r.message(DescribeCol)); },
3(r, msg) { msg.isExplain = r.bool(); },
4(r, msg) { msg.isReadonly = r.bool(); },
};
const DescribeParam = {
default() { return { name: undefined }; },
1(r, msg) { msg.name = r.string(); },
};
const DescribeCol = {
default() { return { name: "", decltype: undefined }; },
1(r, msg) { msg.name = r.string(); },
2(r, msg) { msg.decltype = r.string(); },
};
const Value = {
default() { return undefined; },
1(r) { return null; },
2(r) { return r.sint64(); },
3(r) { return r.double(); },
4(r) { return r.string(); },
5(r) { return r.bytes(); },
};

View File

@@ -0,0 +1,4 @@
import * as e from "../encoding/protobuf/encode.js";
import * as proto from "./proto.js";
export declare function Stmt(w: e.MessageWriter, msg: proto.Stmt): void;
export declare function Batch(w: e.MessageWriter, msg: proto.Batch): void;

View File

@@ -0,0 +1,85 @@
import { impossible } from "../util.js";
export function Stmt(w, msg) {
if (msg.sql !== undefined) {
w.string(1, msg.sql);
}
if (msg.sqlId !== undefined) {
w.int32(2, msg.sqlId);
}
for (const arg of msg.args) {
w.message(3, arg, Value);
}
for (const arg of msg.namedArgs) {
w.message(4, arg, NamedArg);
}
w.bool(5, msg.wantRows);
}
function NamedArg(w, msg) {
w.string(1, msg.name);
w.message(2, msg.value, Value);
}
export function Batch(w, msg) {
for (const step of msg.steps) {
w.message(1, step, BatchStep);
}
}
function BatchStep(w, msg) {
if (msg.condition !== undefined) {
w.message(1, msg.condition, BatchCond);
}
w.message(2, msg.stmt, Stmt);
}
function BatchCond(w, msg) {
if (msg.type === "ok") {
w.uint32(1, msg.step);
}
else if (msg.type === "error") {
w.uint32(2, msg.step);
}
else if (msg.type === "not") {
w.message(3, msg.cond, BatchCond);
}
else if (msg.type === "and") {
w.message(4, msg.conds, BatchCondList);
}
else if (msg.type === "or") {
w.message(5, msg.conds, BatchCondList);
}
else if (msg.type === "is_autocommit") {
w.message(6, undefined, Empty);
}
else {
throw impossible(msg, "Impossible type of BatchCond");
}
}
function BatchCondList(w, msg) {
for (const cond of msg) {
w.message(1, cond, BatchCond);
}
}
function Value(w, msg) {
if (msg === null) {
w.message(1, undefined, Empty);
}
else if (typeof msg === "bigint") {
w.sint64(2, msg);
}
else if (typeof msg === "number") {
w.double(3, msg);
}
else if (typeof msg === "string") {
w.string(4, msg);
}
else if (msg instanceof Uint8Array) {
w.bytes(5, msg);
}
else if (msg === undefined) {
// do nothing
}
else {
throw impossible(msg, "Impossible type of Value");
}
}
function Empty(_w, _msg) {
// do nothing
}