hyper-scheduler 1.0.0 → 1.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.
Files changed (86) hide show
  1. package/README.md +17 -0
  2. package/dist/devtools-Bxtz0rO_.cjs +1 -0
  3. package/dist/devtools-ByJU-Gv1.js +2505 -0
  4. package/dist/index.cjs +1 -0
  5. package/dist/index.js +1048 -0
  6. package/dist/index.umd.cjs +1 -0
  7. package/docs/.vitepress/cache/deps/_metadata.json +31 -0
  8. package/docs/.vitepress/cache/deps/chunk-EKBJ2FPM.js +12798 -0
  9. package/docs/.vitepress/cache/deps/chunk-EKBJ2FPM.js.map +7 -0
  10. package/docs/.vitepress/cache/deps/package.json +3 -0
  11. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +4505 -0
  12. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js.map +7 -0
  13. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +9731 -0
  14. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js.map +7 -0
  15. package/docs/.vitepress/cache/deps/vue.js +347 -0
  16. package/docs/.vitepress/cache/deps/vue.js.map +7 -0
  17. package/docs/.vitepress/config.ts +4 -0
  18. package/docs/.vitepress/theme/components/DemoFrame.vue +111 -0
  19. package/docs/.vitepress/theme/custom.css +6 -0
  20. package/docs/.vitepress/theme/index.ts +10 -0
  21. package/docs/api/devtools.md +13 -0
  22. package/docs/api/scheduler.md +28 -8
  23. package/docs/examples/index.md +55 -8
  24. package/docs/guide/getting-started.md +38 -0
  25. package/package.json +13 -4
  26. package/.editorconfig +0 -21
  27. package/.eslintrc.cjs +0 -26
  28. package/GEMINI.md +0 -1
  29. package/examples/browser/index.html +0 -354
  30. package/examples/node/simple.js +0 -36
  31. package/examples/react-demo/index.html +0 -12
  32. package/examples/react-demo/package.json +0 -23
  33. package/examples/react-demo/src/App.css +0 -212
  34. package/examples/react-demo/src/App.jsx +0 -160
  35. package/examples/react-demo/src/main.jsx +0 -9
  36. package/examples/react-demo/vite.config.ts +0 -12
  37. package/examples/react-demo/yarn.lock +0 -752
  38. package/examples/vue-demo/index.html +0 -12
  39. package/examples/vue-demo/package.json +0 -21
  40. package/examples/vue-demo/src/App.vue +0 -373
  41. package/examples/vue-demo/src/main.ts +0 -4
  42. package/examples/vue-demo/vite.config.ts +0 -13
  43. package/examples/vue-demo/yarn.lock +0 -375
  44. package/src/constants.ts +0 -18
  45. package/src/core/retry-strategy.ts +0 -28
  46. package/src/core/scheduler.ts +0 -601
  47. package/src/core/task-registry.ts +0 -58
  48. package/src/index.ts +0 -74
  49. package/src/platform/browser/browser-timer.ts +0 -66
  50. package/src/platform/browser/main-thread-timer.ts +0 -16
  51. package/src/platform/browser/worker.ts +0 -31
  52. package/src/platform/node/debug-cli.ts +0 -19
  53. package/src/platform/node/node-timer.ts +0 -15
  54. package/src/platform/timer-strategy.ts +0 -19
  55. package/src/plugins/dev-tools.ts +0 -101
  56. package/src/types.ts +0 -115
  57. package/src/ui/components/devtools.ts +0 -525
  58. package/src/ui/components/floating-trigger.ts +0 -102
  59. package/src/ui/components/icons.ts +0 -16
  60. package/src/ui/components/resizer.ts +0 -129
  61. package/src/ui/components/task-detail.ts +0 -228
  62. package/src/ui/components/task-header.ts +0 -319
  63. package/src/ui/components/task-list.ts +0 -416
  64. package/src/ui/components/timeline.ts +0 -364
  65. package/src/ui/debug-panel.ts +0 -56
  66. package/src/ui/i18n/en.ts +0 -76
  67. package/src/ui/i18n/index.ts +0 -42
  68. package/src/ui/i18n/zh.ts +0 -76
  69. package/src/ui/store/dev-tools-store.ts +0 -191
  70. package/src/ui/styles/theme.css.ts +0 -56
  71. package/src/ui/styles.ts +0 -43
  72. package/src/utils/cron-lite.ts +0 -221
  73. package/src/utils/cron.ts +0 -20
  74. package/src/utils/id.ts +0 -10
  75. package/src/utils/schedule.ts +0 -93
  76. package/src/vite-env.d.ts +0 -1
  77. package/stats.html +0 -4949
  78. package/tests/integration/Debug.test.ts +0 -58
  79. package/tests/unit/Plugin.test.ts +0 -16
  80. package/tests/unit/RetryStrategy.test.ts +0 -21
  81. package/tests/unit/Scheduler.test.ts +0 -38
  82. package/tests/unit/schedule.test.ts +0 -70
  83. package/tests/unit/ui/DevToolsStore.test.ts +0 -67
  84. package/tsconfig.json +0 -28
  85. package/vite.config.ts +0 -51
  86. package/vitest.config.ts +0 -24
@@ -0,0 +1,347 @@
1
+ import {
2
+ BaseTransition,
3
+ BaseTransitionPropsValidators,
4
+ Comment,
5
+ DeprecationTypes,
6
+ EffectScope,
7
+ ErrorCodes,
8
+ ErrorTypeStrings,
9
+ Fragment,
10
+ KeepAlive,
11
+ ReactiveEffect,
12
+ Static,
13
+ Suspense,
14
+ Teleport,
15
+ Text,
16
+ TrackOpTypes,
17
+ Transition,
18
+ TransitionGroup,
19
+ TriggerOpTypes,
20
+ VueElement,
21
+ assertNumber,
22
+ callWithAsyncErrorHandling,
23
+ callWithErrorHandling,
24
+ camelize,
25
+ capitalize,
26
+ cloneVNode,
27
+ compatUtils,
28
+ compile,
29
+ computed,
30
+ createApp,
31
+ createBaseVNode,
32
+ createBlock,
33
+ createCommentVNode,
34
+ createElementBlock,
35
+ createHydrationRenderer,
36
+ createPropsRestProxy,
37
+ createRenderer,
38
+ createSSRApp,
39
+ createSlots,
40
+ createStaticVNode,
41
+ createTextVNode,
42
+ createVNode,
43
+ customRef,
44
+ defineAsyncComponent,
45
+ defineComponent,
46
+ defineCustomElement,
47
+ defineEmits,
48
+ defineExpose,
49
+ defineModel,
50
+ defineOptions,
51
+ defineProps,
52
+ defineSSRCustomElement,
53
+ defineSlots,
54
+ devtools,
55
+ effect,
56
+ effectScope,
57
+ getCurrentInstance,
58
+ getCurrentScope,
59
+ getCurrentWatcher,
60
+ getTransitionRawChildren,
61
+ guardReactiveProps,
62
+ h,
63
+ handleError,
64
+ hasInjectionContext,
65
+ hydrate,
66
+ hydrateOnIdle,
67
+ hydrateOnInteraction,
68
+ hydrateOnMediaQuery,
69
+ hydrateOnVisible,
70
+ initCustomFormatter,
71
+ initDirectivesForSSR,
72
+ inject,
73
+ isMemoSame,
74
+ isProxy,
75
+ isReactive,
76
+ isReadonly,
77
+ isRef,
78
+ isRuntimeOnly,
79
+ isShallow,
80
+ isVNode,
81
+ markRaw,
82
+ mergeDefaults,
83
+ mergeModels,
84
+ mergeProps,
85
+ nextTick,
86
+ nodeOps,
87
+ normalizeClass,
88
+ normalizeProps,
89
+ normalizeStyle,
90
+ onActivated,
91
+ onBeforeMount,
92
+ onBeforeUnmount,
93
+ onBeforeUpdate,
94
+ onDeactivated,
95
+ onErrorCaptured,
96
+ onMounted,
97
+ onRenderTracked,
98
+ onRenderTriggered,
99
+ onScopeDispose,
100
+ onServerPrefetch,
101
+ onUnmounted,
102
+ onUpdated,
103
+ onWatcherCleanup,
104
+ openBlock,
105
+ patchProp,
106
+ popScopeId,
107
+ provide,
108
+ proxyRefs,
109
+ pushScopeId,
110
+ queuePostFlushCb,
111
+ reactive,
112
+ readonly,
113
+ ref,
114
+ registerRuntimeCompiler,
115
+ render,
116
+ renderList,
117
+ renderSlot,
118
+ resolveComponent,
119
+ resolveDirective,
120
+ resolveDynamicComponent,
121
+ resolveFilter,
122
+ resolveTransitionHooks,
123
+ setBlockTracking,
124
+ setDevtoolsHook,
125
+ setTransitionHooks,
126
+ shallowReactive,
127
+ shallowReadonly,
128
+ shallowRef,
129
+ ssrContextKey,
130
+ ssrUtils,
131
+ stop,
132
+ toDisplayString,
133
+ toHandlerKey,
134
+ toHandlers,
135
+ toRaw,
136
+ toRef,
137
+ toRefs,
138
+ toValue,
139
+ transformVNodeArgs,
140
+ triggerRef,
141
+ unref,
142
+ useAttrs,
143
+ useCssModule,
144
+ useCssVars,
145
+ useHost,
146
+ useId,
147
+ useModel,
148
+ useSSRContext,
149
+ useShadowRoot,
150
+ useSlots,
151
+ useTemplateRef,
152
+ useTransitionState,
153
+ vModelCheckbox,
154
+ vModelDynamic,
155
+ vModelRadio,
156
+ vModelSelect,
157
+ vModelText,
158
+ vShow,
159
+ version,
160
+ warn,
161
+ watch,
162
+ watchEffect,
163
+ watchPostEffect,
164
+ watchSyncEffect,
165
+ withAsyncContext,
166
+ withCtx,
167
+ withDefaults,
168
+ withDirectives,
169
+ withKeys,
170
+ withMemo,
171
+ withModifiers,
172
+ withScopeId
173
+ } from "./chunk-EKBJ2FPM.js";
174
+ export {
175
+ BaseTransition,
176
+ BaseTransitionPropsValidators,
177
+ Comment,
178
+ DeprecationTypes,
179
+ EffectScope,
180
+ ErrorCodes,
181
+ ErrorTypeStrings,
182
+ Fragment,
183
+ KeepAlive,
184
+ ReactiveEffect,
185
+ Static,
186
+ Suspense,
187
+ Teleport,
188
+ Text,
189
+ TrackOpTypes,
190
+ Transition,
191
+ TransitionGroup,
192
+ TriggerOpTypes,
193
+ VueElement,
194
+ assertNumber,
195
+ callWithAsyncErrorHandling,
196
+ callWithErrorHandling,
197
+ camelize,
198
+ capitalize,
199
+ cloneVNode,
200
+ compatUtils,
201
+ compile,
202
+ computed,
203
+ createApp,
204
+ createBlock,
205
+ createCommentVNode,
206
+ createElementBlock,
207
+ createBaseVNode as createElementVNode,
208
+ createHydrationRenderer,
209
+ createPropsRestProxy,
210
+ createRenderer,
211
+ createSSRApp,
212
+ createSlots,
213
+ createStaticVNode,
214
+ createTextVNode,
215
+ createVNode,
216
+ customRef,
217
+ defineAsyncComponent,
218
+ defineComponent,
219
+ defineCustomElement,
220
+ defineEmits,
221
+ defineExpose,
222
+ defineModel,
223
+ defineOptions,
224
+ defineProps,
225
+ defineSSRCustomElement,
226
+ defineSlots,
227
+ devtools,
228
+ effect,
229
+ effectScope,
230
+ getCurrentInstance,
231
+ getCurrentScope,
232
+ getCurrentWatcher,
233
+ getTransitionRawChildren,
234
+ guardReactiveProps,
235
+ h,
236
+ handleError,
237
+ hasInjectionContext,
238
+ hydrate,
239
+ hydrateOnIdle,
240
+ hydrateOnInteraction,
241
+ hydrateOnMediaQuery,
242
+ hydrateOnVisible,
243
+ initCustomFormatter,
244
+ initDirectivesForSSR,
245
+ inject,
246
+ isMemoSame,
247
+ isProxy,
248
+ isReactive,
249
+ isReadonly,
250
+ isRef,
251
+ isRuntimeOnly,
252
+ isShallow,
253
+ isVNode,
254
+ markRaw,
255
+ mergeDefaults,
256
+ mergeModels,
257
+ mergeProps,
258
+ nextTick,
259
+ nodeOps,
260
+ normalizeClass,
261
+ normalizeProps,
262
+ normalizeStyle,
263
+ onActivated,
264
+ onBeforeMount,
265
+ onBeforeUnmount,
266
+ onBeforeUpdate,
267
+ onDeactivated,
268
+ onErrorCaptured,
269
+ onMounted,
270
+ onRenderTracked,
271
+ onRenderTriggered,
272
+ onScopeDispose,
273
+ onServerPrefetch,
274
+ onUnmounted,
275
+ onUpdated,
276
+ onWatcherCleanup,
277
+ openBlock,
278
+ patchProp,
279
+ popScopeId,
280
+ provide,
281
+ proxyRefs,
282
+ pushScopeId,
283
+ queuePostFlushCb,
284
+ reactive,
285
+ readonly,
286
+ ref,
287
+ registerRuntimeCompiler,
288
+ render,
289
+ renderList,
290
+ renderSlot,
291
+ resolveComponent,
292
+ resolveDirective,
293
+ resolveDynamicComponent,
294
+ resolveFilter,
295
+ resolveTransitionHooks,
296
+ setBlockTracking,
297
+ setDevtoolsHook,
298
+ setTransitionHooks,
299
+ shallowReactive,
300
+ shallowReadonly,
301
+ shallowRef,
302
+ ssrContextKey,
303
+ ssrUtils,
304
+ stop,
305
+ toDisplayString,
306
+ toHandlerKey,
307
+ toHandlers,
308
+ toRaw,
309
+ toRef,
310
+ toRefs,
311
+ toValue,
312
+ transformVNodeArgs,
313
+ triggerRef,
314
+ unref,
315
+ useAttrs,
316
+ useCssModule,
317
+ useCssVars,
318
+ useHost,
319
+ useId,
320
+ useModel,
321
+ useSSRContext,
322
+ useShadowRoot,
323
+ useSlots,
324
+ useTemplateRef,
325
+ useTransitionState,
326
+ vModelCheckbox,
327
+ vModelDynamic,
328
+ vModelRadio,
329
+ vModelSelect,
330
+ vModelText,
331
+ vShow,
332
+ version,
333
+ warn,
334
+ watch,
335
+ watchEffect,
336
+ watchPostEffect,
337
+ watchSyncEffect,
338
+ withAsyncContext,
339
+ withCtx,
340
+ withDefaults,
341
+ withDirectives,
342
+ withKeys,
343
+ withMemo,
344
+ withModifiers,
345
+ withScopeId
346
+ };
347
+ //# sourceMappingURL=vue.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,6 +1,7 @@
1
1
  import { defineConfig } from 'vitepress';
2
2
 
3
3
  export default defineConfig({
4
+ base: '/hyper-scheduler/', // 设置 GitHub Pages 的基础路径
4
5
  lang: 'zh-CN', // 设置语言为中文
5
6
  title: 'Hyper Scheduler', // 更新标题
6
7
  description: '轻量级全局任务调度 JavaScript 库。', // 更新描述
@@ -9,6 +10,9 @@ export default defineConfig({
9
10
  ],
10
11
  themeConfig: {
11
12
  logo: '/logo.svg',
13
+ socialLinks: [
14
+ { icon: 'github', link: 'https://github.com/CrazyMrYan/hyper-scheduler' }
15
+ ],
12
16
  nav: [
13
17
  { text: '指南', link: '/guide/getting-started' }, // 更新导航文本
14
18
  { text: 'API 参考', link: '/api/scheduler' }, // 更新导航文本
@@ -0,0 +1,111 @@
1
+ <script setup>
2
+ import { defineProps, computed, ref, onMounted } from 'vue';
3
+ import { useData } from 'vitepress';
4
+
5
+ const { site } = useData();
6
+
7
+ const props = defineProps({
8
+ path: {
9
+ type: String,
10
+ required: true
11
+ },
12
+ devPort: {
13
+ type: Number,
14
+ default: null
15
+ },
16
+ devPath: {
17
+ type: String,
18
+ default: '/'
19
+ },
20
+ title: {
21
+ type: String,
22
+ default: 'Demo'
23
+ }
24
+ });
25
+
26
+ const src = computed(() => {
27
+ const isDev = import.meta.env.DEV;
28
+
29
+ // 如果在本地开发环境,且指定了端口,则使用 localhost
30
+ if (isDev && props.devPort) {
31
+ return `http://localhost:${props.devPort}${props.devPath}`;
32
+ }
33
+
34
+ // 否则(生产环境构建或未指定端口),使用相对路径,并加上 base
35
+ const base = site.value.base || '/';
36
+ // 移除 path 开头的 /,避免双重斜杠或绝对路径问题
37
+ const cleanPath = props.path.startsWith('/') ? props.path.slice(1) : props.path;
38
+ // 确保 base 以 / 结尾
39
+ const cleanBase = base.endsWith('/') ? base : `${base}/`;
40
+
41
+ return `${cleanBase}${cleanPath}`;
42
+ });
43
+ </script>
44
+
45
+ <template>
46
+ <div class="demo-frame-container">
47
+ <div class="demo-header">
48
+ <span class="dot red"></span>
49
+ <span class="dot yellow"></span>
50
+ <span class="dot green"></span>
51
+ <span class="title">{{ title }}</span>
52
+ <a :href="src" target="_blank" class="open-btn" title="在新窗口打开">↗</a>
53
+ </div>
54
+ <iframe :src="src" class="demo-frame"></iframe>
55
+ </div>
56
+ </template>
57
+
58
+ <style scoped>
59
+ .demo-frame-container {
60
+ border: 1px solid var(--vp-c-divider);
61
+ border-radius: 8px;
62
+ overflow: hidden;
63
+ margin: 16px 0;
64
+ box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
65
+ background: var(--vp-c-bg);
66
+ }
67
+
68
+ .demo-header {
69
+ background: var(--vp-c-bg-soft);
70
+ padding: 8px 12px;
71
+ display: flex;
72
+ align-items: center;
73
+ border-bottom: 1px solid var(--vp-c-divider);
74
+ }
75
+
76
+ .dot {
77
+ width: 10px;
78
+ height: 10px;
79
+ border-radius: 50%;
80
+ margin-right: 6px;
81
+ }
82
+
83
+ .red { background-color: #ff5f56; }
84
+ .yellow { background-color: #ffbd2e; }
85
+ .green { background-color: #27c93f; }
86
+
87
+ .title {
88
+ margin-left: 8px;
89
+ font-size: 12px;
90
+ color: var(--vp-c-text-2);
91
+ font-family: monospace;
92
+ flex: 1;
93
+ }
94
+
95
+ .open-btn {
96
+ text-decoration: none;
97
+ color: var(--vp-c-text-2);
98
+ font-size: 14px;
99
+ }
100
+
101
+ .open-btn:hover {
102
+ color: var(--vp-c-brand);
103
+ }
104
+
105
+ .demo-frame {
106
+ width: 100%;
107
+ height: 500px;
108
+ border: none;
109
+ display: block;
110
+ }
111
+ </style>
@@ -0,0 +1,6 @@
1
+ /* 自定义样式 */
2
+ :root {
3
+ --vp-c-brand: #3b82f6;
4
+ --vp-c-brand-light: #60a5fa;
5
+ --vp-c-brand-dark: #2563eb;
6
+ }
@@ -0,0 +1,10 @@
1
+ import DefaultTheme from 'vitepress/theme';
2
+ import DemoFrame from './components/DemoFrame.vue';
3
+ import './custom.css';
4
+
5
+ export default {
6
+ extends: DefaultTheme,
7
+ enhanceApp({ app }) {
8
+ app.component('DemoFrame', DemoFrame);
9
+ }
10
+ };
@@ -18,6 +18,7 @@ new DevTools(options?: DevToolsOptions)
18
18
  | `dockPosition` | `'right' \| 'bottom'` | `'right'` | 面板停靠位置 |
19
19
  | `language` | `'en' \| 'zh'` | `'en'` | 界面语言 |
20
20
  | `defaultZoom` | `number` | `1` | 时间线默认缩放级别 (0.5-5) |
21
+ | `zoomStep` | `number` | `1000` | 缩放时间步长 (ms) |
21
22
  | `trigger` | `TriggerOptions` | - | 悬浮按钮配置 |
22
23
 
23
24
  ### TriggerOptions
@@ -190,6 +191,18 @@ new DevTools({
190
191
  - `2` - 显示更多细节
191
192
  - `5` - 最大缩放
192
193
 
194
+ ## 缩放步长
195
+
196
+ 配置时间线缩放的步长,单位为毫秒:
197
+
198
+ ```typescript
199
+ new DevTools({
200
+ zoomStep: 60000 // 1分钟
201
+ })
202
+ ```
203
+
204
+ 默认值为 `1000` (1秒)。
205
+
193
206
  ## 悬浮按钮自定义
194
207
 
195
208
  ### 位置
@@ -112,13 +112,21 @@ scheduler.createTask({
112
112
  启动调度器,开始执行所有已注册的任务。
113
113
 
114
114
  ```typescript
115
- start(): void
115
+ start(scope?: string): void
116
116
  ```
117
117
 
118
+ #### 参数
119
+
120
+ - **scope** `string` - 可选。指定要启动的任务的命名空间。如果省略,则启动所有任务。
121
+
118
122
  #### 示例
119
123
 
120
124
  ```typescript
125
+ // 启动所有任务
121
126
  scheduler.start();
127
+
128
+ // 仅启动 'system' 命名空间下的任务
129
+ scheduler.start('system');
122
130
  ```
123
131
 
124
132
  ### stop()
@@ -126,13 +134,21 @@ scheduler.start();
126
134
  停止调度器,暂停所有任务的调度。已经在执行的任务会继续完成。
127
135
 
128
136
  ```typescript
129
- stop(): void
137
+ stop(scope?: string): void
130
138
  ```
131
139
 
140
+ #### 参数
141
+
142
+ - **scope** `string` - 可选。指定要停止的任务的命名空间。如果省略,则停止所有任务。
143
+
132
144
  #### 示例
133
145
 
134
146
  ```typescript
147
+ // 停止所有任务
135
148
  scheduler.stop();
149
+
150
+ // 仅停止 'system' 命名空间下的任务
151
+ scheduler.stop('system');
136
152
  ```
137
153
 
138
154
  ### startTask()
@@ -250,9 +266,13 @@ if (task) {
250
266
  获取所有已注册任务的列表。
251
267
 
252
268
  ```typescript
253
- getAllTasks(): Task[]
269
+ getAllTasks(namespace?: string): Task[]
254
270
  ```
255
271
 
272
+ #### 参数
273
+
274
+ - **namespace** `string` - 可选。指定要获取的任务的命名空间。如果省略,则返回所有任务。
275
+
256
276
  #### 返回值
257
277
 
258
278
  - `Task[]` - 任务对象数组
@@ -260,12 +280,12 @@ getAllTasks(): Task[]
260
280
  #### 示例
261
281
 
262
282
  ```typescript
263
- const tasks = scheduler.getAllTasks();
264
- console.log(`Total tasks: ${tasks.length}`);
283
+ // 获取所有任务
284
+ const allTasks = scheduler.getAllTasks();
265
285
 
266
- tasks.forEach(task => {
267
- console.log(`${task.id}: ${task.status}`);
268
- });
286
+ // 获取 'system' 命名空间下的任务
287
+ const systemTasks = scheduler.getAllTasks('system');
288
+ console.log(`System tasks: ${systemTasks.length}`);
269
289
  ```
270
290
 
271
291
  ### on()