Skip to content

Commit b1452b6

Browse files
committed
chore: bump versions
1 parent 868b788 commit b1452b6

21 files changed

+1061
-11
lines changed

.eslintrc.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"node": true
5+
},
6+
"globals": {
7+
"NodeJS": true
8+
},
9+
"extends": [
10+
"@cordisjs/eslint-config"
11+
]
12+
}

.eslintrc.yml

-10
This file was deleted.

biome.json

+99
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
{
2+
"$schema": "https://biomejs.dev/schemas/1.9.4/schema.json",
3+
"vcs": { "enabled": false, "clientKind": "git", "useIgnoreFile": false },
4+
"files": { "ignoreUnknown": false, "ignore": [] },
5+
"formatter": { "enabled": true, "indentStyle": "space" },
6+
"organizeImports": { "enabled": true },
7+
"linter": {
8+
"enabled": true,
9+
"rules": {
10+
"recommended": false,
11+
"complexity": {
12+
"noExtraBooleanCast": "error",
13+
"noMultipleSpacesInRegularExpressionLiterals": "error",
14+
"noUselessCatch": "error",
15+
"noUselessConstructor": "off",
16+
"noUselessLoneBlockStatements": "error",
17+
"noUselessRename": "error",
18+
"noUselessTernary": "error",
19+
"noUselessUndefinedInitialization": "error",
20+
"noVoid": "error",
21+
"noWith": "error",
22+
"useLiteralKeys": "off",
23+
"useRegexLiterals": "error"
24+
},
25+
"correctness": {
26+
"noConstAssign": "error",
27+
"noConstantCondition": "error",
28+
"noEmptyCharacterClassInRegex": "error",
29+
"noEmptyPattern": "error",
30+
"noGlobalObjectCalls": "error",
31+
"noInnerDeclarations": "off",
32+
"noInvalidConstructorSuper": "error",
33+
"noInvalidUseBeforeDeclaration": "off",
34+
"noNewSymbol": "error",
35+
"noPrecisionLoss": "error",
36+
"noSelfAssign": "error",
37+
"noSwitchDeclarations": "error",
38+
"noUndeclaredVariables": "off",
39+
"noUnreachable": "error",
40+
"noUnreachableSuper": "error",
41+
"noUnsafeFinally": "error",
42+
"noUnusedVariables": "error",
43+
"useArrayLiterals": "error",
44+
"useIsNan": "error"
45+
},
46+
"security": { "noGlobalEval": "error" },
47+
"style": {
48+
"noCommaOperator": "off",
49+
"noVar": "warn",
50+
"noYodaExpression": "error",
51+
"useBlockStatements": "error",
52+
"useConsistentArrayType": "error",
53+
"useConsistentBuiltinInstantiation": "error",
54+
"useConst": "error",
55+
"useDefaultParameterLast": "error",
56+
"useSingleVarDeclarator": "off"
57+
},
58+
"suspicious": {
59+
"noAsyncPromiseExecutor": "error",
60+
"noCatchAssign": "off",
61+
"noClassAssign": "error",
62+
"noCompareNegZero": "error",
63+
"noConsole": "error",
64+
"noControlCharactersInRegex": "error",
65+
"noDebugger": "error",
66+
"noDoubleEquals": "error",
67+
"noDuplicateCase": "error",
68+
"noDuplicateClassMembers": "error",
69+
"noDuplicateObjectKeys": "error",
70+
"noDuplicateParameters": "error",
71+
"noEmptyBlockStatements": "error",
72+
"noFallthroughSwitchClause": "error",
73+
"noFunctionAssign": "error",
74+
"noGlobalAssign": "error",
75+
"noImportAssign": "error",
76+
"noMisleadingCharacterClass": "error",
77+
"noPrototypeBuiltins": "error",
78+
"noRedeclare": "off",
79+
"noSelfCompare": "error",
80+
"noShadowRestrictedNames": "error",
81+
"noSparseArray": "error",
82+
"noUnsafeNegation": "error",
83+
"useDefaultSwitchClauseLast": "error",
84+
"useValidTypeof": "off"
85+
}
86+
},
87+
"ignore": ["./external", "**/dist", "**/lib", "**/tests", "**/*.js"]
88+
},
89+
"javascript": {
90+
"formatter": { "quoteStyle": "single", "semicolons": "asNeeded" },
91+
"globals": ["NodeJS", "document", "navigator", "window"]
92+
},
93+
"overrides": [
94+
{
95+
"include": ["**/test/**", "**/tests/**"],
96+
"linter": { "rules": { "suspicious": { "noConsole": "off" } } }
97+
}
98+
]
99+
}

deno.lock

+100
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"version": "0.0.0",
66
"workspaces": [
77
"external/*",
8-
"packages/*"
8+
"packages/*",
9+
"plugins/*"
910
],
1011
"license": "MIT",
1112
"scripts": {

plugins/scheduler/mod.ts

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
import { type Context, Service } from '@cordisjs/core'
2+
import z from 'schemastery'
3+
import { Time } from 'cosmokit'
4+
import ScheduleState from './state/mod.ts'
5+
import { kScheduleState } from './mod.ts'
6+
7+
declare module '@cordisjs/core' {
8+
interface Context {
9+
scheduler: Scheduler
10+
}
11+
}
12+
13+
export { kScheduleState } from './state/mod.ts'
14+
export { withRetry } from './utils.ts'
15+
export { ScheduleState, ScheduleState as SchedulerState }
16+
17+
export interface ScheduleOptions extends ScheduleState.Config {
18+
id?: string | number
19+
cap: number
20+
period: number
21+
}
22+
23+
export interface Scheduler {
24+
// biome-ignore lint/style/useShorthandFunctionType: scheduler is callable
25+
(options?: Partial<ScheduleOptions>): ScheduleState
26+
}
27+
28+
export class Scheduler extends Service {
29+
protected states: Map<number | string, ScheduleState> = new Map()
30+
31+
protected constructor(
32+
ctx: Context,
33+
public options: Scheduler.Config,
34+
) {
35+
super(ctx, 'scheduler')
36+
37+
ctx.accessor('$scheduler', {
38+
get: () => this[kScheduleState],
39+
set: (value: ScheduleState, receiver) => Reflect.set(this, kScheduleState, receiver),
40+
})
41+
}
42+
43+
[Service.invoke](options: Partial<ScheduleOptions> = {}) {
44+
options.id ??= this.ctx.scope.uid
45+
if (this.states.has(options.id)) return this.states.get(options.id)
46+
const state = ScheduleState.pluggedOn(this.ctx, {
47+
...this.options.default,
48+
...options,
49+
})
50+
this.states.set(options.id, state)
51+
return state
52+
}
53+
}
54+
55+
export namespace Scheduler {
56+
export interface Config {
57+
default: ScheduleState.Config
58+
}
59+
60+
export const Config: z<Config> = z.object({
61+
default: ScheduleState.Config.default({
62+
mode: 'semaphore',
63+
cap: 99999,
64+
period: Time.second,
65+
}).description('Default Scheduler Options'),
66+
})
67+
}
68+
69+
export default Scheduler

plugins/scheduler/package.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "cordis-plugin-scheduler",
3+
"version": "0.3.4",
4+
"files": ["mod.ts", "utils.ts", "state.ts", "waiter.ts", "dist"],
5+
"type": "module",
6+
"license": "BSD-3-Clause",
7+
"exports": {
8+
".": {
9+
"bun": "./mod.ts",
10+
"deno": "./mod.ts",
11+
"node": "./dist/mod.js",
12+
"default": "./dist/mod.js",
13+
"types": "./dist/mod.d.ts"
14+
},
15+
"./retry": {
16+
"bun": "./utils.ts",
17+
"deno": "./utils.ts",
18+
"node": "./dist/utils.js",
19+
"default": "./dist/utils.js",
20+
"types": "./dist/utils.d.ts"
21+
},
22+
"./state": {
23+
"bun": "./state/mod.ts",
24+
"deno": "./state/mod.ts",
25+
"node": "./dist/state/mod.js",
26+
"default": "./dist/state/mod.js",
27+
"types": "./dist/state/mod.d.ts"
28+
}
29+
},
30+
"scripts": {
31+
"build": "tsc && bun build mod.ts state/mod.ts utils.ts --sourcemap=inline -e @cordisjs/core -e cosmokit -e schemastery -e linked-list --outdir dist/"
32+
},
33+
"cordis": {
34+
"service": {
35+
"implements": ["scheduler"]
36+
}
37+
},
38+
"peerDependencies": {
39+
"@cordisjs/core": "^4.0.0-alpha.2"
40+
},
41+
"dependencies": {
42+
"linked-list": "^3.1.0",
43+
"schemastery": "^3.16.0",
44+
"cosmokit": "~1"
45+
}
46+
}

0 commit comments

Comments
 (0)