This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(() => { | |
if (window.clickToSaveCanvas) { | |
return window.clickToSaveCanvas() | |
} | |
/** | |
* @param {HTMLCanvasElement} canvas | |
*/ | |
async function canvasToBlob(canvas) { | |
return new Promise((resolve) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @author dragon-fish <dragon-fish@qq.com> | |
* @lisence MIT | |
* @refered https://github.com/hongkiulam/ipad-cursor-js by @hongkiulam | |
*/ | |
const TEXT_ELEMENT_TAGS = ['P', 'SPAN', 'H1', 'H2', 'H3', 'H4', 'TEXTAREA'] | |
export class IpadCursor { | |
public cursor = document.createElement('div') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function animatedNumber({ | |
from = 0, | |
to = 0, | |
duration = 0, | |
onUpdate, | |
onFinish, | |
}) { | |
const startTime = performance.now() | |
;(function tick() { | |
const current = performance.now() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScriptAsync(src = '', { isModule = false, noCache = false }) { | |
return new Promise((resolve, reject) => { | |
const script = document.createElement('script') | |
script.async = true | |
if (noCache) { | |
src += `${src.includes('?') ? '&' : '?'}_=${Date.now()}` | |
} | |
script.src = src | |
isModule && (script.type = 'module') | |
script.addEventListener('load', resolve) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ObjectStorage | |
* @desc JSON localStorage with auto cache | |
* | |
* @author Dragon-Fish <dragon-fish@qq.com> | |
* @license MIT | |
*/ | |
export class ObjectStorage<T extends any> { | |
constructor(readonly name: string, readonly maxAge = 0) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* DOM generator | |
* @author Dragon-Fish | |
* @license MIT | |
*/ | |
export function createElement<K extends keyof ElementTagNameMap>( | |
tagName: K, | |
children?: ElementChildren | |
): ElementTagNameMap[K] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* A very simple JSONP package | |
* @author Dragon-Fish | |
* @license MIT | |
*/ | |
/** | |
* jsonp | |
* @example | |
* ```ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Core types */ | |
class InPageEdit { | |
constructor(options?: Partial<AppOptions>) {} | |
private plugins: Plugin[] | |
private pages: Page[] | |
fn: Record<string, any> | |
use: (payload: Plugin) => this | |
createPage: (title?: string) => Page | |
createPlugin: (name: string, apply: (ctx: Context) => VueInstance) => Plugin | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @name koishi-plugin-qq-channel-patch | |
* @author Dragon-Fish <dragon-fish@qq.com> | |
* | |
* @desc Temporary patch for QQ channel for koishi.js | |
*/ | |
// Packages | |
const { CQBot } = require('koishi-adapter-onebot') | |
const { segment } = require('koishi-core') |