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,37 @@
import { t as JavaScriptRegexScannerOptions } from "./scanner-CFS1MV4a.mjs";
import { ToRegExpOptions } from "oniguruma-to-es";
import { RegexEngine } from "@shikijs/types";
//#region src/engine-compile.d.ts
interface JavaScriptRegexEngineOptions extends JavaScriptRegexScannerOptions {
/**
* The target ECMAScript version.
*
* Oniguruma-To-ES uses RegExp features from later versions of ECMAScript to add support for a
* few more grammars. If using target `ES2024` or later, the RegExp `v` flag is used which
* requires Node.js 20+ or Chrome 112+.
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/unicodeSets
*
* For maximum compatibility, you can set it to `ES2018` which uses the RegExp `u` flag.
*
* Set to `auto` to automatically detect the latest version supported by the environment.
*
* @default 'auto'
*/
target?: 'auto' | 'ES2025' | 'ES2024' | 'ES2018';
}
/**
* The default regex constructor for the JavaScript RegExp engine.
*/
declare function defaultJavaScriptRegexConstructor(pattern: string, options?: ToRegExpOptions): RegExp;
/**
* Use the modern JavaScript RegExp engine to implement the OnigScanner.
*
* As Oniguruma supports some features that can't be emulated using native JavaScript regexes, some
* patterns are not supported. Errors will be thrown when parsing TextMate grammars with
* unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
* Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
*/
declare function createJavaScriptRegexEngine(options?: JavaScriptRegexEngineOptions): RegexEngine;
//#endregion
export { JavaScriptRegexEngineOptions, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };

View File

@@ -0,0 +1,48 @@
import { t as JavaScriptScanner } from "./scanner-BFcBmQR1.mjs";
import { toRegExp } from "oniguruma-to-es";
//#region src/engine-compile.ts
/**
* The default regex constructor for the JavaScript RegExp engine.
*/
function defaultJavaScriptRegexConstructor(pattern, options) {
return toRegExp(pattern, {
global: true,
hasIndices: true,
lazyCompileLength: 3e3,
rules: {
allowOrphanBackrefs: true,
asciiWordBoundaries: true,
captureGroup: true,
recursionLimit: 5,
singleline: true
},
...options
});
}
/**
* Use the modern JavaScript RegExp engine to implement the OnigScanner.
*
* As Oniguruma supports some features that can't be emulated using native JavaScript regexes, some
* patterns are not supported. Errors will be thrown when parsing TextMate grammars with
* unsupported patterns, and when the grammar includes patterns that use invalid Oniguruma syntax.
* Set `forgiving` to `true` to ignore these errors and skip any unsupported or invalid patterns.
*/
function createJavaScriptRegexEngine(options = {}) {
const _options = Object.assign({
target: "auto",
cache: /* @__PURE__ */ new Map()
}, options);
_options.regexConstructor ||= (pattern) => defaultJavaScriptRegexConstructor(pattern, { target: _options.target });
return {
createScanner(patterns) {
return new JavaScriptScanner(patterns, _options);
},
createString(s) {
return { content: s };
}
};
}
//#endregion
export { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };

View File

@@ -0,0 +1,13 @@
import { RegexEngine } from "@shikijs/types";
//#region src/engine-raw.d.ts
/**
* Raw JavaScript regex engine that only supports precompiled grammars.
*
* This further simplifies the engine by excluding the regex compilation step.
*
* Zero dependencies.
*/
declare function createJavaScriptRawEngine(): RegexEngine;
//#endregion
export { createJavaScriptRawEngine };

View File

@@ -0,0 +1,29 @@
import { t as JavaScriptScanner } from "./scanner-BFcBmQR1.mjs";
//#region src/engine-raw.ts
/**
* Raw JavaScript regex engine that only supports precompiled grammars.
*
* This further simplifies the engine by excluding the regex compilation step.
*
* Zero dependencies.
*/
function createJavaScriptRawEngine() {
const options = {
cache: /* @__PURE__ */ new Map(),
regexConstructor: () => {
throw new Error("JavaScriptRawEngine: only support precompiled grammar");
}
};
return {
createScanner(patterns) {
return new JavaScriptScanner(patterns, options);
},
createString(s) {
return { content: s };
}
};
}
//#endregion
export { createJavaScriptRawEngine };

View File

@@ -0,0 +1,4 @@
import { n as JavaScriptScanner, t as JavaScriptRegexScannerOptions } from "./scanner-CFS1MV4a.mjs";
import { JavaScriptRegexEngineOptions, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from "./engine-compile.mjs";
import { createJavaScriptRawEngine } from "./engine-raw.mjs";
export { JavaScriptRegexEngineOptions, JavaScriptRegexScannerOptions, JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };

View File

@@ -0,0 +1,5 @@
import { t as JavaScriptScanner } from "./scanner-BFcBmQR1.mjs";
import { createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor } from "./engine-compile.mjs";
import { createJavaScriptRawEngine } from "./engine-raw.mjs";
export { JavaScriptScanner, createJavaScriptRawEngine, createJavaScriptRegexEngine, defaultJavaScriptRegexConstructor };

View File

@@ -0,0 +1,76 @@
//#region src/scanner.ts
const MAX = 4294967295;
var JavaScriptScanner = class {
regexps;
constructor(patterns, options = {}) {
this.patterns = patterns;
this.options = options;
const { forgiving = false, cache, regexConstructor } = options;
if (!regexConstructor) throw new Error("Option `regexConstructor` is not provided");
this.regexps = patterns.map((p) => {
if (typeof p !== "string") return p;
const cached = cache?.get(p);
if (cached) {
if (cached instanceof RegExp) return cached;
if (forgiving) return null;
throw cached;
}
try {
const regex = regexConstructor(p);
cache?.set(p, regex);
return regex;
} catch (e) {
cache?.set(p, e);
if (forgiving) return null;
throw e;
}
});
}
findNextMatchSync(string, startPosition, _options) {
const str = typeof string === "string" ? string : string.content;
const pending = [];
function toResult(index, match, offset = 0) {
return {
index,
captureIndices: match.indices.map((indice) => {
if (indice == null) return {
start: MAX,
end: MAX,
length: 0
};
return {
start: indice[0] + offset,
end: indice[1] + offset,
length: indice[1] - indice[0]
};
})
};
}
for (let i = 0; i < this.regexps.length; i++) {
const regexp = this.regexps[i];
if (!regexp) continue;
try {
regexp.lastIndex = startPosition;
const match = regexp.exec(str);
if (!match) continue;
if (match.index === startPosition) return toResult(i, match, 0);
pending.push([
i,
match,
0
]);
} catch (e) {
if (this.options.forgiving) continue;
throw e;
}
}
if (pending.length) {
const minIndex = Math.min(...pending.map((m) => m[1].index));
for (const [i, match, offset] of pending) if (match.index === minIndex) return toResult(i, match, offset);
}
return null;
}
};
//#endregion
export { JavaScriptScanner as t };

View File

@@ -0,0 +1,31 @@
import { PatternScanner, RegexEngineString } from "@shikijs/types";
import { IOnigMatch } from "@shikijs/vscode-textmate";
//#region src/scanner.d.ts
interface JavaScriptRegexScannerOptions {
/**
* Whether to allow invalid regex patterns.
*
* @default false
*/
forgiving?: boolean;
/**
* Cache for regex patterns.
*/
cache?: Map<string, RegExp | Error> | null;
/**
* Custom pattern to RegExp constructor.
*
* By default `oniguruma-to-es` is used.
*/
regexConstructor?: (pattern: string) => RegExp;
}
declare class JavaScriptScanner implements PatternScanner {
patterns: (string | RegExp)[];
options: JavaScriptRegexScannerOptions;
regexps: (RegExp | null)[];
constructor(patterns: (string | RegExp)[], options?: JavaScriptRegexScannerOptions);
findNextMatchSync(string: string | RegexEngineString, startPosition: number, _options: number): IOnigMatch | null;
}
//#endregion
export { JavaScriptScanner as n, JavaScriptRegexScannerOptions as t };