dsh-peak-checker 0.0.0-stage → 0.1.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.
@@ -0,0 +1,6 @@
1
+ - op: add
2
+ path: /-
3
+ value:
4
+ id: dsh-peak-checker
5
+ name: dsh-peak-checker
6
+ config: {}
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { getPeakState } from "../peak.js";
3
+ import { badgeStyle } from "./styles.js";
4
+ export const name = 'dsh-peak-checker-client';
5
+ export const inject = ['slots'];
6
+ export function apply(ctx) {
7
+ const slots = ctx.slots;
8
+ if (!slots)
9
+ return;
10
+ slots.inject('conversation.input.left', () => {
11
+ slots.register({
12
+ name: 'conversation.input.left',
13
+ id: 'dsh-peak-indicator',
14
+ order: 30,
15
+ }, PeakIndicator);
16
+ });
17
+ }
18
+ function PeakIndicator() {
19
+ const state = getPeakState();
20
+ const isPeak = state === 'peak';
21
+ return (_jsxs("span", { title: isPeak
22
+ ? '当前为 DeepSeek API 高峰时段(北京时间周一至周五 09:00–12:00、14:00–18:00)'
23
+ : '当前为 DeepSeek API 空闲时段', style: badgeStyle(isPeak), children: [_jsx("span", { style: { fontSize: 8, lineHeight: 1 }, children: "\u25CF" }), isPeak ? '高峰' : '空闲'] }));
24
+ }
@@ -0,0 +1,25 @@
1
+ .dsh-peak-indicator {
2
+ display: inline-flex;
3
+ align-items: center;
4
+ gap: 4px;
5
+ padding: 2px 8px;
6
+ border-radius: 999px;
7
+ font-size: 11px;
8
+ font-weight: 500;
9
+ line-height: 18px;
10
+ white-space: nowrap;
11
+ user-select: none;
12
+ cursor: default;
13
+ }
14
+
15
+ .dsh-peak-indicator--peak {
16
+ color: var(--dsh-color-warning, #b45309);
17
+ background: rgba(234, 179, 8, 0.12);
18
+ border: 1px solid rgba(234, 179, 8, 0.35);
19
+ }
20
+
21
+ .dsh-peak-indicator--off-peak {
22
+ color: var(--dsh-color-success, #15803d);
23
+ background: rgba(34, 197, 94, 0.12);
24
+ border: 1px solid rgba(34, 197, 94, 0.35);
25
+ }
@@ -0,0 +1,18 @@
1
+ export function badgeStyle(isPeak) {
2
+ return {
3
+ display: 'inline-flex',
4
+ alignItems: 'center',
5
+ gap: 4,
6
+ padding: '2px 8px',
7
+ borderRadius: 999,
8
+ fontSize: 11,
9
+ fontWeight: 500,
10
+ lineHeight: '18px',
11
+ whiteSpace: 'nowrap',
12
+ userSelect: 'none',
13
+ cursor: 'default',
14
+ color: isPeak ? 'var(--dsh-color-warning, #b45309)' : 'var(--dsh-color-success, #15803d)',
15
+ background: isPeak ? 'rgba(234, 179, 8, 0.12)' : 'rgba(34, 197, 94, 0.12)',
16
+ border: `1px solid ${isPeak ? 'rgba(234, 179, 8, 0.35)' : 'rgba(34, 197, 94, 0.35)'}`,
17
+ };
18
+ }
@@ -0,0 +1 @@
1
+ export * from "../client/index.js";
@@ -0,0 +1 @@
1
+ export { badgeStyle } from "../client/styles.js";
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export const name = 'dsh-peak-checker';
2
+ export function apply(ctx) {
3
+ ctx.effect(() => {
4
+ console.log('[dsh-peak-indicator] host half loaded');
5
+ return () => {
6
+ console.log('[dsh-peak-indicator] host half unloaded');
7
+ };
8
+ });
9
+ }
package/lib/peak.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * 按北京时间 (UTC+8) 判断当前是否处于 DeepSeek API 高峰时段。
3
+ * 高峰:周一至周五 09:00–12:00、14:00–18:00
4
+ * 空闲:其余时间(含周末全天)
5
+ */
6
+ export function getPeakState(date = new Date()) {
7
+ const utcMs = date.getTime() + date.getTimezoneOffset() * 60_000;
8
+ const bj = new Date(utcMs + 8 * 3_600_000);
9
+ const day = bj.getDay(); // 0=周日, 1=周一, ..., 6=周六
10
+ const minutes = bj.getHours() * 60 + bj.getMinutes();
11
+ const isWeekday = day >= 1 && day <= 5;
12
+ if (!isWeekday)
13
+ return 'off-peak';
14
+ const inMorningPeak = minutes >= 9 * 60 && minutes < 12 * 60;
15
+ const inAfternoonPeak = minutes >= 14 * 60 && minutes < 18 * 60;
16
+ return inMorningPeak || inAfternoonPeak ? 'peak' : 'off-peak';
17
+ }
18
+ /** 供 UI 直接用:是否高峰 */
19
+ export function isPeakNow(date = new Date()) {
20
+ return getPeakState(date) === 'peak';
21
+ }
@@ -0,0 +1,4 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "dsh-peak-checker-client";
3
+ export declare const inject: readonly ["slots"];
4
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,2 @@
1
+ import type { CSSProperties } from 'react';
2
+ export declare function badgeStyle(isPeak: boolean): CSSProperties;
@@ -0,0 +1 @@
1
+ export * from '../client/index.tsx';
@@ -0,0 +1 @@
1
+ export { badgeStyle } from '../client/styles.ts';
@@ -0,0 +1,3 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ export declare const name = "dsh-peak-checker";
3
+ export declare function apply(ctx: Context): void;
@@ -0,0 +1,9 @@
1
+ export type PeakState = 'peak' | 'off-peak';
2
+ /**
3
+ * 按北京时间 (UTC+8) 判断当前是否处于 DeepSeek API 高峰时段。
4
+ * 高峰:周一至周五 09:00–12:00、14:00–18:00
5
+ * 空闲:其余时间(含周末全天)
6
+ */
7
+ export declare function getPeakState(date?: Date): PeakState;
8
+ /** 供 UI 直接用:是否高峰 */
9
+ export declare function isPeakNow(date?: Date): boolean;
package/package.json CHANGED
@@ -1,6 +1,46 @@
1
- {
2
- "name": "dsh-peak-checker",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
1
+ {
2
+ "name": "dsh-peak-checker",
3
+ "version": "0.1.0",
4
+ "description": "在 DSH 输入框工具行显示当前是否处于 DeepSeek API 高峰时段",
5
+ "type": "module",
6
+ "main": "lib/index.js",
7
+ "types": "lib/types/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./lib/types/index.d.ts",
11
+ "default": "./lib/index.js"
12
+ },
13
+ "./client": {
14
+ "types": "./lib/types/client/index.d.ts",
15
+ "default": "./lib/client/index.js"
16
+ },
17
+ "./package.json": "./package.json"
18
+ },
19
+ "files": [
20
+ "lib",
21
+ "cordis.patch.yml"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsc -p tsconfig.json && node -e \"require('fs').copyFileSync('src/client/styles.css','lib/client/styles.css')\"",
25
+ "typecheck": "tsc --noEmit",
26
+ "test": "vitest run"
27
+ },
28
+ "peerDependencies": {
29
+ "@deepseek-ai/cordis": "*"
30
+ },
31
+ "devDependencies": {
32
+ "@deepseek-ai/cordis": "latest",
33
+ "@types/react": "^18.3.0",
34
+ "@types/node": "^22.0.0",
35
+ "typescript": "^5.7.0",
36
+ "vitest": "^3.0.0"
37
+ },
38
+ "dsh": {
39
+ "bundle": {
40
+ "patch": "./cordis.patch.yml"
41
+ },
42
+ "client": {
43
+ "platform": "web"
44
+ }
45
+ }
6
46
  }
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.