@delta-comic/core 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["random","random","clamp"],"sources":["../lib/temp.ts","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/random.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/randomInt.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/random.mjs","../lib/ipc.ts","../lib/fc.ts"],"sourcesContent":["import { useGlobalVar } from '@delta-comic/utils'\nimport { defineStore } from 'pinia'\nimport { reactive, shallowReactive, type Reactive } from 'vue'\n\nconst _useTemp = useGlobalVar(\n defineStore('core:temp', helper => {\n const tempBase = shallowReactive(new Map<string, any>())\n const $apply = <T extends object>(id: string, def: () => T) => {\n id = `reactive:${id}`\n if (!tempBase.has(id)) tempBase.set(id, reactive(def()))\n const store: Reactive<T> = tempBase.get(id)\n return store\n }\n const $has = helper.action((id: string): boolean => {\n id = `reactive:${id}`\n return tempBase.has(id)\n }, 'has')\n const $onlyGet = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `reactive:${id}`\n return tempBase.get(id)\n }, 'onlyGet')\n const $applyRaw = helper.action(<T extends object>(id: string, def: () => T) => {\n id = `raw:${id}`\n if (!tempBase.has(id)) tempBase.set(id, def())\n const store: T = tempBase.get(id)\n return store\n }, 'applyRaw')\n const $hasRaw = helper.action((id: string): boolean => {\n id = `raw:${id}`\n return tempBase.has(id)\n }, 'hasRaw')\n const $onlyGetRaw = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `raw:${id}`\n return tempBase.get(id)\n }, 'onlyGetRaw')\n return { $apply, $has, $onlyGet, $applyRaw, $hasRaw, $onlyGetRaw }\n }),\n 'store/temp'\n)\n\nexport const useTemp = () => _useTemp(window.$api.piniaInstance)","function random(minimum, maximum) {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n return Math.random() * (maximum - minimum) + minimum;\n}\n\nexport { random };\n","import { random } from './random.mjs';\n\nfunction randomInt(minimum, maximum) {\n return Math.floor(random(minimum, maximum));\n}\n\nexport { randomInt };\n","function clamp(value, bound1, bound2) {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n return Math.min(Math.max(value, bound1), bound2);\n}\n\nexport { clamp };\n","import { clamp as clamp$1 } from '../../math/clamp.mjs';\n\nfunction clamp(value, bound1, bound2) {\n if (Number.isNaN(bound1)) {\n bound1 = 0;\n }\n if (Number.isNaN(bound2)) {\n bound2 = 0;\n }\n return clamp$1(value, bound1, bound2);\n}\n\nexport { clamp };\n","import { clamp } from './clamp.mjs';\nimport { random as random$1 } from '../../math/random.mjs';\nimport { randomInt } from '../../math/randomInt.mjs';\n\nfunction random(...args) {\n let minimum = 0;\n let maximum = 1;\n let floating = false;\n switch (args.length) {\n case 1: {\n if (typeof args[0] === 'boolean') {\n floating = args[0];\n }\n else {\n maximum = args[0];\n }\n break;\n }\n case 2: {\n if (typeof args[1] === 'boolean') {\n maximum = args[0];\n floating = args[1];\n }\n else {\n minimum = args[0];\n maximum = args[1];\n }\n }\n case 3: {\n if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {\n minimum = 0;\n maximum = args[0];\n floating = false;\n }\n else {\n minimum = args[0];\n maximum = args[1];\n floating = args[2];\n }\n }\n }\n if (typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n if (typeof maximum !== 'number') {\n minimum = Number(maximum);\n }\n if (!minimum) {\n minimum = 0;\n }\n if (!maximum) {\n maximum = 0;\n }\n if (minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n if (minimum === maximum) {\n return minimum;\n }\n if (floating) {\n return random$1(minimum, maximum + 1);\n }\n else {\n return randomInt(minimum, maximum + 1);\n }\n}\n\nexport { random };\n","import type { uni } from '@delta-comic/model'\n\nimport { useGlobalVar } from '@delta-comic/utils'\nimport { random } from 'es-toolkit/compat'\n\nexport type SharedFunctions = {\n getRandomProvide(signal?: AbortSignal): PromiseLike<uni.item.Item[]>\n\n addRecent(item: uni.item.Item): PromiseLike<any>\n routeToContent(\n contentType_: uni.content.ContentType_,\n id: string,\n ep: string,\n preload?: uni.content.PreloadValue\n ): PromiseLike<any>\n routeToSearch(\n input: string,\n source?: [plugin: string, name: string],\n sort?: string\n ): PromiseLike<any>\n\n addAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n removeAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n getIsAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<boolean>\n\n triggerSharePopup(page: uni.content.ContentPage): PromiseLike<void>\n triggerShareToken(token: string): PromiseLike<void>\n pushShareToken(token: string): PromiseLike<void>\n}\n\nexport class SharedFunction {\n private static sharedFunctions = useGlobalVar(\n new Map<string, { fn: SharedFunctions[keyof SharedFunctions]; plugin: string }[]>(),\n 'utils/SharedFunction/sharedFunctions'\n )\n public static define<TKey extends keyof SharedFunctions>(\n fn: SharedFunctions[TKey],\n plugin: string,\n name: TKey\n ) {\n console.debug('[SharedFunction.define] defined new function', plugin, ':', name, '->', fn)\n this.sharedFunctions.set(name, [...(this.sharedFunctions.get(name) ?? []), { fn, plugin }])\n return fn\n }\n public static call<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const ins =\n this.sharedFunctions.get(name)?.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n }) ?? []\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n public static callRandom<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const index = random(0, all.length - 1)\n const it = all[index]\n if (!it)\n throw new Error(`[SharedFunction.callRandom] call ${name}, but not resigner any function.`)\n console.log(`[SharedFunction.callRandom] call index: ${index} in ${all.length}`, it)\n const result: ReturnType<SharedFunctions[TKey]> = (<any>it.fn)(...args)\n const ins = { result, ...it }\n const results = (async () => ({ ...it, result: await result }))()\n return Object.assign(ins, results)\n }\n public static callWitch<TKey extends keyof SharedFunctions>(\n name: TKey,\n plugin: string,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const them = all.filter(c => c.plugin === plugin)\n if (!them.length)\n throw new Error(\n `[SharedFunction.callWitch] not found plugin function (plugin: ${plugin}, name: ${name})`\n )\n\n const ins = them.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n })\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n}","import { useGlobalVar } from '@delta-comic/utils'\nimport { shallowRef } from 'vue'\n\nconst isFullscreen = useGlobalVar(\n (() => {\n const isFc = shallowRef(!!document.fullscreenElement)\n document.addEventListener('fullscreenchange', () => {\n isFc.value = !!document.fullscreenElement\n })\n return isFc\n })(),\n 'core/isFc'\n)\n\nexport const useFullscreen = () => ({\n isFullscreen,\n entry() {\n isFullscreen.value = true\n },\n exit() {\n isFullscreen.value = false\n },\n toggle() {\n isFullscreen.value = !isFullscreen.value\n }\n})"],"x_google_ignoreList":[1,2,3,4,5],"mappings":";;;AAIA,IAAM,I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AAkB;AAIrD,QAHA,SAAS,iBAAiB,0BAA0B;AAClD,IAAK,QAAQ,CAAC,CAAC,SAAS;GACxB,EACK;IACL,EACJ,YACD;AAED,MAAa,WAAuB;CAClC;CACA,QAAQ;AACN,IAAa,QAAQ;;CAEvB,OAAO;AACL,IAAa,QAAQ;;CAEvB,SAAS;AACP,IAAa,QAAQ,CAAC,EAAa;;CAEtC"}
1
+ {"version":3,"file":"index.js","names":["random","random","clamp"],"sources":["../lib/temp.ts","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/random.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/randomInt.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/random.mjs","../lib/ipc.ts","../lib/fc.ts"],"sourcesContent":["import { useGlobalVar } from '@delta-comic/utils'\nimport { defineStore } from 'pinia'\nimport { reactive, shallowReactive, type Reactive } from 'vue'\n\nconst _useTemp = useGlobalVar(\n defineStore('core:temp', helper => {\n const tempBase = shallowReactive(new Map<string, any>())\n const $apply = <T extends object>(id: string, def: () => T) => {\n id = `reactive:${id}`\n if (!tempBase.has(id)) tempBase.set(id, reactive(def()))\n const store: Reactive<T> = tempBase.get(id)\n return store\n }\n const $has = helper.action((id: string): boolean => {\n id = `reactive:${id}`\n return tempBase.has(id)\n }, 'has')\n const $onlyGet = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `reactive:${id}`\n return tempBase.get(id)\n }, 'onlyGet')\n const $applyRaw = helper.action(<T extends object>(id: string, def: () => T) => {\n id = `raw:${id}`\n if (!tempBase.has(id)) tempBase.set(id, def())\n const store: T = tempBase.get(id)\n return store\n }, 'applyRaw')\n const $hasRaw = helper.action((id: string): boolean => {\n id = `raw:${id}`\n return tempBase.has(id)\n }, 'hasRaw')\n const $onlyGetRaw = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `raw:${id}`\n return tempBase.get(id)\n }, 'onlyGetRaw')\n return { $apply, $has, $onlyGet, $applyRaw, $hasRaw, $onlyGetRaw }\n }),\n 'store/temp'\n)\n\nexport const useTemp = () => _useTemp(window.$api.piniaInstance)","function random(minimum, maximum) {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n return Math.random() * (maximum - minimum) + minimum;\n}\n\nexport { random };\n","import { random } from './random.mjs';\n\nfunction randomInt(minimum, maximum) {\n return Math.floor(random(minimum, maximum));\n}\n\nexport { randomInt };\n","function clamp(value, bound1, bound2) {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n return Math.min(Math.max(value, bound1), bound2);\n}\n\nexport { clamp };\n","import { clamp as clamp$1 } from '../../math/clamp.mjs';\n\nfunction clamp(value, bound1, bound2) {\n if (Number.isNaN(bound1)) {\n bound1 = 0;\n }\n if (Number.isNaN(bound2)) {\n bound2 = 0;\n }\n return clamp$1(value, bound1, bound2);\n}\n\nexport { clamp };\n","import { clamp } from './clamp.mjs';\nimport { random as random$1 } from '../../math/random.mjs';\nimport { randomInt } from '../../math/randomInt.mjs';\n\nfunction random(...args) {\n let minimum = 0;\n let maximum = 1;\n let floating = false;\n switch (args.length) {\n case 1: {\n if (typeof args[0] === 'boolean') {\n floating = args[0];\n }\n else {\n maximum = args[0];\n }\n break;\n }\n case 2: {\n if (typeof args[1] === 'boolean') {\n maximum = args[0];\n floating = args[1];\n }\n else {\n minimum = args[0];\n maximum = args[1];\n }\n }\n case 3: {\n if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {\n minimum = 0;\n maximum = args[0];\n floating = false;\n }\n else {\n minimum = args[0];\n maximum = args[1];\n floating = args[2];\n }\n }\n }\n if (typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n if (typeof maximum !== 'number') {\n minimum = Number(maximum);\n }\n if (!minimum) {\n minimum = 0;\n }\n if (!maximum) {\n maximum = 0;\n }\n if (minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n if (minimum === maximum) {\n return minimum;\n }\n if (floating) {\n return random$1(minimum, maximum + 1);\n }\n else {\n return randomInt(minimum, maximum + 1);\n }\n}\n\nexport { random };\n","import type { uni } from '@delta-comic/model'\nimport { useGlobalVar } from '@delta-comic/utils'\nimport { random } from 'es-toolkit/compat'\n\nexport interface SharedFunctions {\n getRandomProvide(signal?: AbortSignal): PromiseLike<uni.item.Item[]>\n\n addRecent(item: uni.item.Item): PromiseLike<any>\n routeToContent(\n contentType_: uni.content.ContentType_,\n id: string,\n ep: string,\n preload?: uni.content.PreloadValue\n ): PromiseLike<any>\n routeToSearch(\n input: string,\n source?: [plugin: string, name: string],\n sort?: string\n ): PromiseLike<any>\n\n addAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n removeAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n getIsAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<boolean>\n\n triggerSharePopup(page: uni.content.ContentPage): PromiseLike<void>\n triggerShareToken(token: string): PromiseLike<void>\n pushShareToken(token: string): PromiseLike<void>\n}\n\nexport class SharedFunction {\n private static sharedFunctions = useGlobalVar(\n new Map<string, { fn: SharedFunctions[keyof SharedFunctions]; plugin: string }[]>(),\n 'utils/SharedFunction/sharedFunctions'\n )\n public static define<TKey extends keyof SharedFunctions>(\n fn: SharedFunctions[TKey],\n plugin: string,\n name: TKey\n ) {\n console.debug('[SharedFunction.define] defined new function', plugin, ':', name, '->', fn)\n this.sharedFunctions.set(name, [...(this.sharedFunctions.get(name) ?? []), { fn, plugin }])\n return fn\n }\n public static call<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const ins =\n this.sharedFunctions.get(name)?.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n }) ?? []\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n public static callRandom<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const index = random(0, all.length - 1)\n const it = all[index]\n if (!it)\n throw new Error(`[SharedFunction.callRandom] call ${name}, but not resigner any function.`)\n console.log(`[SharedFunction.callRandom] call index: ${index} in ${all.length}`, it)\n const result: ReturnType<SharedFunctions[TKey]> = (<any>it.fn)(...args)\n const ins = { result, ...it }\n const results = (async () => ({ ...it, result: await result }))()\n return Object.assign(ins, results)\n }\n public static callWitch<TKey extends keyof SharedFunctions>(\n name: TKey,\n plugin: string,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const them = all.filter(c => c.plugin === plugin)\n if (!them.length)\n throw new Error(\n `[SharedFunction.callWitch] not found plugin function (plugin: ${plugin}, name: ${name})`\n )\n\n const ins = them.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n })\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n}","import { useGlobalVar } from '@delta-comic/utils'\nimport { shallowRef } from 'vue'\n\nconst isFullscreen = useGlobalVar(\n (() => {\n const isFc = shallowRef(!!document.fullscreenElement)\n document.addEventListener('fullscreenchange', () => {\n isFc.value = !!document.fullscreenElement\n })\n return isFc\n })(),\n 'core/isFc'\n)\n\nexport const useFullscreen = () => ({\n isFullscreen,\n entry() {\n isFullscreen.value = true\n },\n exit() {\n isFullsc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AACnF,SAAO,OAAO,OAAO,GAAK,EAAQ;;GCpFhC,IAAe,SACZ;CACL,IAAM,IAAO,EAAW,CAAC,CAAC,SAAS,kBAAkB;AAIrD,QAHA,SAAS,iBAAiB,0BAA0B;AAClD,IAAK,QAAQ,CAAC,CAAC,SAAS;GACxB,EACK;IACL,EACJ,YACD;AAED,MAAa,WAAuB;CAClC;CACA,QAAQ;AACN,IAAa,QAAQ;;CAEvB,OAAO;AACL,IAAa,QAAQ;;CAEvB,SAAS;AACP,IAAa,QAAQ,CAAC,EAAa;;CAEtC"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.cjs","names":["random","random","clamp"],"sources":["../lib/temp.ts","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/random.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/randomInt.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/random.mjs","../lib/ipc.ts","../lib/fc.ts"],"sourcesContent":["import { useGlobalVar } from '@delta-comic/utils'\nimport { defineStore } from 'pinia'\nimport { reactive, shallowReactive, type Reactive } from 'vue'\n\nconst _useTemp = useGlobalVar(\n defineStore('core:temp', helper => {\n const tempBase = shallowReactive(new Map<string, any>())\n const $apply = <T extends object>(id: string, def: () => T) => {\n id = `reactive:${id}`\n if (!tempBase.has(id)) tempBase.set(id, reactive(def()))\n const store: Reactive<T> = tempBase.get(id)\n return store\n }\n const $has = helper.action((id: string): boolean => {\n id = `reactive:${id}`\n return tempBase.has(id)\n }, 'has')\n const $onlyGet = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `reactive:${id}`\n return tempBase.get(id)\n }, 'onlyGet')\n const $applyRaw = helper.action(<T extends object>(id: string, def: () => T) => {\n id = `raw:${id}`\n if (!tempBase.has(id)) tempBase.set(id, def())\n const store: T = tempBase.get(id)\n return store\n }, 'applyRaw')\n const $hasRaw = helper.action((id: string): boolean => {\n id = `raw:${id}`\n return tempBase.has(id)\n }, 'hasRaw')\n const $onlyGetRaw = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `raw:${id}`\n return tempBase.get(id)\n }, 'onlyGetRaw')\n return { $apply, $has, $onlyGet, $applyRaw, $hasRaw, $onlyGetRaw }\n }),\n 'store/temp'\n)\n\nexport const useTemp = () => _useTemp(window.$api.piniaInstance)","function random(minimum, maximum) {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n return Math.random() * (maximum - minimum) + minimum;\n}\n\nexport { random };\n","import { random } from './random.mjs';\n\nfunction randomInt(minimum, maximum) {\n return Math.floor(random(minimum, maximum));\n}\n\nexport { randomInt };\n","function clamp(value, bound1, bound2) {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n return Math.min(Math.max(value, bound1), bound2);\n}\n\nexport { clamp };\n","import { clamp as clamp$1 } from '../../math/clamp.mjs';\n\nfunction clamp(value, bound1, bound2) {\n if (Number.isNaN(bound1)) {\n bound1 = 0;\n }\n if (Number.isNaN(bound2)) {\n bound2 = 0;\n }\n return clamp$1(value, bound1, bound2);\n}\n\nexport { clamp };\n","import { clamp } from './clamp.mjs';\nimport { random as random$1 } from '../../math/random.mjs';\nimport { randomInt } from '../../math/randomInt.mjs';\n\nfunction random(...args) {\n let minimum = 0;\n let maximum = 1;\n let floating = false;\n switch (args.length) {\n case 1: {\n if (typeof args[0] === 'boolean') {\n floating = args[0];\n }\n else {\n maximum = args[0];\n }\n break;\n }\n case 2: {\n if (typeof args[1] === 'boolean') {\n maximum = args[0];\n floating = args[1];\n }\n else {\n minimum = args[0];\n maximum = args[1];\n }\n }\n case 3: {\n if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {\n minimum = 0;\n maximum = args[0];\n floating = false;\n }\n else {\n minimum = args[0];\n maximum = args[1];\n floating = args[2];\n }\n }\n }\n if (typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n if (typeof maximum !== 'number') {\n minimum = Number(maximum);\n }\n if (!minimum) {\n minimum = 0;\n }\n if (!maximum) {\n maximum = 0;\n }\n if (minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n if (minimum === maximum) {\n return minimum;\n }\n if (floating) {\n return random$1(minimum, maximum + 1);\n }\n else {\n return randomInt(minimum, maximum + 1);\n }\n}\n\nexport { random };\n","import type { uni } from '@delta-comic/model'\n\nimport { useGlobalVar } from '@delta-comic/utils'\nimport { random } from 'es-toolkit/compat'\n\nexport type SharedFunctions = {\n getRandomProvide(signal?: AbortSignal): PromiseLike<uni.item.Item[]>\n\n addRecent(item: uni.item.Item): PromiseLike<any>\n routeToContent(\n contentType_: uni.content.ContentType_,\n id: string,\n ep: string,\n preload?: uni.content.PreloadValue\n ): PromiseLike<any>\n routeToSearch(\n input: string,\n source?: [plugin: string, name: string],\n sort?: string\n ): PromiseLike<any>\n\n addAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n removeAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n getIsAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<boolean>\n\n triggerSharePopup(page: uni.content.ContentPage): PromiseLike<void>\n triggerShareToken(token: string): PromiseLike<void>\n pushShareToken(token: string): PromiseLike<void>\n}\n\nexport class SharedFunction {\n private static sharedFunctions = useGlobalVar(\n new Map<string, { fn: SharedFunctions[keyof SharedFunctions]; plugin: string }[]>(),\n 'utils/SharedFunction/sharedFunctions'\n )\n public static define<TKey extends keyof SharedFunctions>(\n fn: SharedFunctions[TKey],\n plugin: string,\n name: TKey\n ) {\n console.debug('[SharedFunction.define] defined new function', plugin, ':', name, '->', fn)\n this.sharedFunctions.set(name, [...(this.sharedFunctions.get(name) ?? []), { fn, plugin }])\n return fn\n }\n public static call<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const ins =\n this.sharedFunctions.get(name)?.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n }) ?? []\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n public static callRandom<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const index = random(0, all.length - 1)\n const it = all[index]\n if (!it)\n throw new Error(`[SharedFunction.callRandom] call ${name}, but not resigner any function.`)\n console.log(`[SharedFunction.callRandom] call index: ${index} in ${all.length}`, it)\n const result: ReturnType<SharedFunctions[TKey]> = (<any>it.fn)(...args)\n const ins = { result, ...it }\n const results = (async () => ({ ...it, result: await result }))()\n return Object.assign(ins, results)\n }\n public static callWitch<TKey extends keyof SharedFunctions>(\n name: TKey,\n plugin: string,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const them = all.filter(c => c.plugin === plugin)\n if (!them.length)\n throw new Error(\n `[SharedFunction.callWitch] not found plugin function (plugin: ${plugin}, name: ${name})`\n )\n\n const ins = them.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n })\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n}","import { useGlobalVar } from '@delta-comic/utils'\nimport { shallowRef } from 'vue'\n\nconst isFullscreen = useGlobalVar(\n (() => {\n const isFc = shallowRef(!!document.fullscreenElement)\n document.addEventListener('fullscreenchange', () => {\n isFc.value = !!document.fullscreenElement\n })\n return isFc\n })(),\n 'core/isFc'\n)\n\nexport const useFullscreen = () => ({\n isFullscreen,\n entry() {\n isFullscreen.value = true\n },\n exit() {\n isFullscreen.value = false\n },\n toggle() {\n isFullscreen.value = !isFullscreen.value\n }\n})"],"x_google_ignoreList":[1,2,3,4,5],"mappings":"0bAIA,IAAM,GAAA,EAAA,EAAA,eAAA,EAAA,EAAA,aACQ,YAAa,GAAU,CACjC,IAAM,GAAA,EAAA,EAAA,iBAA2B,IAAI,IAAmB,CA6BxD,MAAO,CAAE,QA5ByB,EAAY,KAC5C,EAAK,YAAY,IACZ,EAAS,IAAI,EAAG,EAAE,EAAS,IAAI,GAAA,EAAA,EAAA,UAAa,GAAK,CAAC,CAAC,CAC7B,EAAS,IAAI,EAAG,EAyB5B,KAtBJ,EAAO,OAAQ,IAC1B,EAAK,YAAY,IACV,EAAS,IAAI,EAAG,EACtB,MAAM,CAmBc,SAlBN,EAAO,OAA0B,IAChD,EAAK,YAAY,IACV,EAAS,IAAI,EAAG,EACtB,UAAU,CAeoB,UAdf,EAAO,QAA0B,EAAY,KAC7D,EAAK,OAAO,IACP,EAAS,IAAI,EAAG,EAAE,EAAS,IAAI,EAAI,GAAK,CAAC,CAC7B,EAAS,IAAI,EAAG,EAEhC,WAAW,CAS8B,QAR5B,EAAO,OAAQ,IAC7B,EAAK,OAAO,IACL,EAAS,IAAI,EAAG,EACtB,SAAS,CAKyC,YAJjC,EAAO,OAA0B,IACnD,EAAK,OAAO,IACL,EAAS,IAAI,EAAG,EACtB,aAAa,CACkD,EAClE,CACF,aACD,CAED,IAAa,MAAgB,EAAS,OAAO,KAAK,cAAA,CCxClD,SAASA,EAAO,EAAS,EAAS,CAK9B,GAJI,IACA,EAAU,EACV,EAAU,GAEV,GAAW,EACX,MAAU,MAAM,2EAA2E,CAE/F,OAAO,KAAK,QAAQ,EAAI,EAAU,GAAW,ECNjD,SAAS,EAAU,EAAS,EAAS,CACjC,OAAO,KAAK,M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G,EAAK,CACrD,GAAG,EAAG,EACvB,CACI,EAAU,QAAQ,IAAI,EAAI,IAAI,KAAM,KAAM,CAAE,GAAG,EAAG,OAAQ,MAAM,EAAE,OAAQ,EAAE,CAAC,CACnF,OAAO,OAAO,OAAO,EAAK,EAAQ,GCrFhC,GAAA,EAAA,EAAA,mBACG,CACL,IAAM,GAAA,EAAA,EAAA,YAAkB,CAAC,CAAC,SAAS,kBAAkB,CAIrD,OAHA,SAAS,iBAAiB,uBAA0B,CAClD,EAAK,MAAQ,CAAC,CAAC,SAAS,mBACxB,CACK,KACL,CACJ,YACD,yCAEmC,CAClC,eACA,OAAQ,CACN,EAAa,MAAQ,IAEvB,MAAO,CACL,EAAa,MAAQ,IAEvB,QAAS,CACP,EAAa,MAAQ,CAAC,EAAa,OAEtC"}
1
+ {"version":3,"file":"index.umd.cjs","names":["random","random","clamp"],"sources":["../lib/temp.ts","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/random.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/randomInt.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/clamp.mjs","../../../node_modules/.pnpm/es-toolkit@1.40.0/node_modules/es-toolkit/dist/compat/math/random.mjs","../lib/ipc.ts","../lib/fc.ts"],"sourcesContent":["import { useGlobalVar } from '@delta-comic/utils'\nimport { defineStore } from 'pinia'\nimport { reactive, shallowReactive, type Reactive } from 'vue'\n\nconst _useTemp = useGlobalVar(\n defineStore('core:temp', helper => {\n const tempBase = shallowReactive(new Map<string, any>())\n const $apply = <T extends object>(id: string, def: () => T) => {\n id = `reactive:${id}`\n if (!tempBase.has(id)) tempBase.set(id, reactive(def()))\n const store: Reactive<T> = tempBase.get(id)\n return store\n }\n const $has = helper.action((id: string): boolean => {\n id = `reactive:${id}`\n return tempBase.has(id)\n }, 'has')\n const $onlyGet = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `reactive:${id}`\n return tempBase.get(id)\n }, 'onlyGet')\n const $applyRaw = helper.action(<T extends object>(id: string, def: () => T) => {\n id = `raw:${id}`\n if (!tempBase.has(id)) tempBase.set(id, def())\n const store: T = tempBase.get(id)\n return store\n }, 'applyRaw')\n const $hasRaw = helper.action((id: string): boolean => {\n id = `raw:${id}`\n return tempBase.has(id)\n }, 'hasRaw')\n const $onlyGetRaw = helper.action(<T extends object>(id: string): Reactive<T> => {\n id = `raw:${id}`\n return tempBase.get(id)\n }, 'onlyGetRaw')\n return { $apply, $has, $onlyGet, $applyRaw, $hasRaw, $onlyGetRaw }\n }),\n 'store/temp'\n)\n\nexport const useTemp = () => _useTemp(window.$api.piniaInstance)","function random(minimum, maximum) {\n if (maximum == null) {\n maximum = minimum;\n minimum = 0;\n }\n if (minimum >= maximum) {\n throw new Error('Invalid input: The maximum value must be greater than the minimum value.');\n }\n return Math.random() * (maximum - minimum) + minimum;\n}\n\nexport { random };\n","import { random } from './random.mjs';\n\nfunction randomInt(minimum, maximum) {\n return Math.floor(random(minimum, maximum));\n}\n\nexport { randomInt };\n","function clamp(value, bound1, bound2) {\n if (bound2 == null) {\n return Math.min(value, bound1);\n }\n return Math.min(Math.max(value, bound1), bound2);\n}\n\nexport { clamp };\n","import { clamp as clamp$1 } from '../../math/clamp.mjs';\n\nfunction clamp(value, bound1, bound2) {\n if (Number.isNaN(bound1)) {\n bound1 = 0;\n }\n if (Number.isNaN(bound2)) {\n bound2 = 0;\n }\n return clamp$1(value, bound1, bound2);\n}\n\nexport { clamp };\n","import { clamp } from './clamp.mjs';\nimport { random as random$1 } from '../../math/random.mjs';\nimport { randomInt } from '../../math/randomInt.mjs';\n\nfunction random(...args) {\n let minimum = 0;\n let maximum = 1;\n let floating = false;\n switch (args.length) {\n case 1: {\n if (typeof args[0] === 'boolean') {\n floating = args[0];\n }\n else {\n maximum = args[0];\n }\n break;\n }\n case 2: {\n if (typeof args[1] === 'boolean') {\n maximum = args[0];\n floating = args[1];\n }\n else {\n minimum = args[0];\n maximum = args[1];\n }\n }\n case 3: {\n if (typeof args[2] === 'object' && args[2] != null && args[2][args[1]] === args[0]) {\n minimum = 0;\n maximum = args[0];\n floating = false;\n }\n else {\n minimum = args[0];\n maximum = args[1];\n floating = args[2];\n }\n }\n }\n if (typeof minimum !== 'number') {\n minimum = Number(minimum);\n }\n if (typeof maximum !== 'number') {\n minimum = Number(maximum);\n }\n if (!minimum) {\n minimum = 0;\n }\n if (!maximum) {\n maximum = 0;\n }\n if (minimum > maximum) {\n [minimum, maximum] = [maximum, minimum];\n }\n minimum = clamp(minimum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n maximum = clamp(maximum, -Number.MAX_SAFE_INTEGER, Number.MAX_SAFE_INTEGER);\n if (minimum === maximum) {\n return minimum;\n }\n if (floating) {\n return random$1(minimum, maximum + 1);\n }\n else {\n return randomInt(minimum, maximum + 1);\n }\n}\n\nexport { random };\n","import type { uni } from '@delta-comic/model'\nimport { useGlobalVar } from '@delta-comic/utils'\nimport { random } from 'es-toolkit/compat'\n\nexport interface SharedFunctions {\n getRandomProvide(signal?: AbortSignal): PromiseLike<uni.item.Item[]>\n\n addRecent(item: uni.item.Item): PromiseLike<any>\n routeToContent(\n contentType_: uni.content.ContentType_,\n id: string,\n ep: string,\n preload?: uni.content.PreloadValue\n ): PromiseLike<any>\n routeToSearch(\n input: string,\n source?: [plugin: string, name: string],\n sort?: string\n ): PromiseLike<any>\n\n addAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n removeAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<void>\n getIsAuthorSubscribe(author: uni.item.Author, plugin: string): PromiseLike<boolean>\n\n triggerSharePopup(page: uni.content.ContentPage): PromiseLike<void>\n triggerShareToken(token: string): PromiseLike<void>\n pushShareToken(token: string): PromiseLike<void>\n}\n\nexport class SharedFunction {\n private static sharedFunctions = useGlobalVar(\n new Map<string, { fn: SharedFunctions[keyof SharedFunctions]; plugin: string }[]>(),\n 'utils/SharedFunction/sharedFunctions'\n )\n public static define<TKey extends keyof SharedFunctions>(\n fn: SharedFunctions[TKey],\n plugin: string,\n name: TKey\n ) {\n console.debug('[SharedFunction.define] defined new function', plugin, ':', name, '->', fn)\n this.sharedFunctions.set(name, [...(this.sharedFunctions.get(name) ?? []), { fn, plugin }])\n return fn\n }\n public static call<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const ins =\n this.sharedFunctions.get(name)?.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n }) ?? []\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n public static callRandom<TKey extends keyof SharedFunctions>(\n name: TKey,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const index = random(0, all.length - 1)\n const it = all[index]\n if (!it)\n throw new Error(`[SharedFunction.callRandom] call ${name}, but not resigner any function.`)\n console.log(`[SharedFunction.callRandom] call index: ${index} in ${all.length}`, it)\n const result: ReturnType<SharedFunctions[TKey]> = (<any>it.fn)(...args)\n const ins = { result, ...it }\n const results = (async () => ({ ...it, result: await result }))()\n return Object.assign(ins, results)\n }\n public static callWitch<TKey extends keyof SharedFunctions>(\n name: TKey,\n plugin: string,\n ...args: Parameters<SharedFunctions[TKey]>\n ) {\n const all = this.sharedFunctions.get(name) ?? []\n const them = all.filter(c => c.plugin === plugin)\n if (!them.length)\n throw new Error(\n `[SharedFunction.callWitch] not found plugin function (plugin: ${plugin}, name: ${name})`\n )\n\n const ins = them.map(v => {\n const result: ReturnType<SharedFunctions[TKey]> = (<any>v.fn)(...args)\n return { result, ...v }\n })\n const results = Promise.all(ins.map(async v => ({ ...v, result: await v.result })))\n return Object.assign(ins, results)\n }\n}","import { useGlobalVar } from '@delta-comic/utils'\nimport { shallowRef } from 'vue'\n\nconst isFullscreen = useGlobalVar(\n (() => {\n const isFc = shallowRef(!!document.fullscreenElement)\n document.addEventListener('fullscreenchange', () => {\n isFc.value = !!document.fullscreenElement\n })\n return isFc\n })(),\n 'core/isFc'\n)\n\nexport const useFullscreen = () => ({\n isFullscreen,\n entry() {\n isFullscreen.value = true\n },\n exit() {\n isFullscreen.value = false\n },\n toggle() {\n isFullscreen.value = !isFullscreen.value\n }\n})"],"x_google_ignoreList":[1,2,3,4,5],"mappings":"0bAIA,IAAM,GAAA,EAAA,EAAA,eAAA,EAAA,EAAA,aACQ,YAAa,GAAU,CACjC,IAAM,GAAA,EAAA,EAAA,iBAA2B,IAAI,IAAmB,CA6BxD,MAAO,CAAE,QA5ByB,EAAY,KAC5C,EAAK,YAAY,IACZ,EAAS,IAAI,EAAG,EAAE,EAAS,IAAI,GAAA,EAAA,EAAA,UAAa,GAAK,CAAC,CAAC,CAC7B,EAAS,IAAI,EAAG,EAyB5B,KAtBJ,EAAO,OAAQ,IAC1B,EAAK,YAAY,IACV,EAAS,IAAI,EAAG,EACtB,MAAM,CAmBc,SAlBN,EAAO,OAA0B,IAChD,EAAK,YAAY,IACV,EAAS,IAAI,EAAG,EACtB,UAAU,CAeoB,UAdf,EAAO,QAA0B,EAAY,KAC7D,EAAK,OAAO,IACP,EAAS,IAAI,EAAG,EAAE,EAAS,IAAI,EAAI,GAAK,CAAC,CAC7B,EAAS,IAAI,EAAG,EAEhC,WAAW,CAS8B,QAR5B,EAAO,OAAQ,IAC7B,EAAK,OAAO,IACL,EAAS,IAAI,EAAG,EACtB,SAAS,CAKyC,YAJjC,EAAO,OAA0B,IACnD,EAAK,OAAO,IACL,EAAS,IAAI,EAAG,EACtB,aAAa,CACkD,EAClE,CACF,aACD,CAED,IAAa,MAAgB,EAAS,OAAO,KAAK,cAAA,CCxClD,SAASA,EAAO,EAAS,EAAS,CAK9B,GAJI,IACA,EAAU,EACV,EAAU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,GAAI,CAAC,EAAK,OACR,MAAU,MACR,iEAAiE,EAAO,UAAU,EAAK,GACxF,CAEH,IAAM,EAAM,EAAK,IAAI,IAEZ,CAAE,OAD+C,EAAE,GAAI,GAAG,EAAK,CACrD,GAAG,EAAG,EACvB,CACI,EAAU,QAAQ,IAAI,EAAI,IAAI,KAAM,KAAM,CAAE,GAAG,EAAG,OAAQ,MAAM,EAAE,OAAQ,EAAE,CAAC,CACnF,OAAO,OAAO,OAAO,EAAK,EAAQ,GCpFhC,GAAA,EAAA,EAAA,mBACG,CACL,IAAM,GAAA,EAAA,EAAA,YAAkB,CAAC,CAAC,SAAS,kBAAkB,CAIrD,OAHA,SAAS,iBAAiB,uBAA0B,CAClD,EAAK,MAAQ,CAAC,CAAC,SAAS,mBACxB,CACK,KACL,CACJ,YACD,yCAEmC,CAClC,eACA,OAAQ,CACN,EAAa,MAAQ,IAEvB,MAAO,CACL,EAAa,MAAQ,IAEvB,QAAS,CACP,EAAa,MAAQ,CAAC,EAAa,OAEtC"}
package/dist/lib/ipc.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { uni } from '@delta-comic/model';
2
- export type SharedFunctions = {
2
+ export interface SharedFunctions {
3
3
  getRandomProvide(signal?: AbortSignal): PromiseLike<uni.item.Item[]>;
4
4
  addRecent(item: uni.item.Item): PromiseLike<any>;
5
5
  routeToContent(contentType_: uni.content.ContentType_, id: string, ep: string, preload?: uni.content.PreloadValue): PromiseLike<any>;
@@ -10,7 +10,7 @@ export type SharedFunctions = {
10
10
  triggerSharePopup(page: uni.content.ContentPage): PromiseLike<void>;
11
11
  triggerShareToken(token: string): PromiseLike<void>;
12
12
  pushShareToken(token: string): PromiseLike<void>;
13
- };
13
+ }
14
14
  export declare class SharedFunction {
15
15
  private static sharedFunctions;
16
16
  static define<TKey extends keyof SharedFunctions>(fn: SharedFunctions[TKey], plugin: string, name: TKey): SharedFunctions[TKey];
package/dist/pack.tgz CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@delta-comic/core",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "空阙虱楼",
5
5
  "homepage": "https://github.com/delta-comic/delta-comic-core",
6
6
  "license": "AGPL-3.0-only",
@@ -42,6 +42,9 @@
42
42
  "tarball": "./dist/pack.tgz"
43
43
  },
44
44
  "readme": "./README.md",
45
+ "devDependencies": {
46
+ "vue-component-type-helpers": "^3.2.4"
47
+ },
45
48
  "scripts": {
46
49
  "build": "vite build && pnpm pack --out ./dist/pack.tgz",
47
50
  "version:major": "pnpm version major --no-git-tag-version",