@goodandready/dsh-cron 0.1.2 → 0.1.4

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 (2) hide show
  1. package/lib/client.js +67 -28
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -1,7 +1,8 @@
1
- (function () {
2
- 'use strict';
3
-
4
- function dshCronModule(require, exports, module) {
1
+ window.__ModuleLoader__.load({
2
+ id: '@goodandready/dsh-cron',
3
+ factory: (require) => {
4
+ var module = { exports: {} };
5
+ var exports = module.exports;
5
6
  const React = require('react');
6
7
  const ReactDOM = require('react-dom/client');
7
8
 
@@ -89,6 +90,11 @@
89
90
  .dsh-cron-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
90
91
  .dsh-cron-btn-primary { background: #ededed; color: #111; border: none; border-radius: 8px; padding: 7px 16px; font-size: 13.5px; font-weight: 500; cursor: pointer; }
91
92
  .dsh-cron-btn-secondary { background: transparent; color: #999; border: 1px solid #383838; border-radius: 8px; padding: 7px 16px; font-size: 13.5px; cursor: pointer; }
93
+
94
+ .dsh-cron-card { background: var(--dsw-alias-bg-layer-2, #1f1f1f); border: 1px solid var(--dsw-alias-border-l1, #333); border-radius: 12px; padding: 18px 20px; margin-bottom: 16px; }
95
+ .dsh-cron-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
96
+ .dsh-cron-card-title { font-size: 15px; font-weight: 600; color: var(--dsw-alias-label-primary, #fff); }
97
+ .dsh-cron-card-desc { font-size: 13px; color: var(--dsw-alias-label-secondary, #888); margin-bottom: 16px; line-height: 1.4; }
92
98
  `;
93
99
 
94
100
  function ensureStyles() {
@@ -375,22 +381,27 @@
375
381
  );
376
382
  }
377
383
 
384
+ function CronSettingsCard(props) {
385
+ const { ctx, toggle } = props;
386
+ return React.createElement('div', { className: 'dsh-cron-card' },
387
+ React.createElement('div', { className: 'dsh-cron-card-head' },
388
+ React.createElement('span', { className: 'dsh-cron-card-title' }, '⏰ Планировщик задач (Cron)'),
389
+ React.createElement('button', {
390
+ type: 'button',
391
+ className: 'dsh-cron-btn-primary',
392
+ onClick: () => { if (toggle) toggle.set(true); }
393
+ }, 'Открыть запланированные задачи')
394
+ ),
395
+ React.createElement('div', { className: 'dsh-cron-card-desc' },
396
+ 'Автоматическое выполнение задач в фоновом режиме по заданному расписанию (cron/интервалы), отслеживание логов и интеграция с чатом через команду /cron.'
397
+ )
398
+ );
399
+ }
400
+
378
401
  function nativeButton() {
379
- const candidates = [
380
- 'nav button[class*="sidebar-entry"]',
381
- 'aside button[class*="sidebar-entry"]',
382
- '[class*="sidebar"] button[class*="sidebar-entry"]',
383
- 'nav button',
384
- 'aside button',
385
- '[class*="sidebar"] button'
386
- ];
387
- for (const sel of candidates) {
388
- const found = document.querySelectorAll(sel);
389
- for (const el of found) {
390
- if (el.hasAttribute(ENTRY_ATTR)) continue;
391
- if (el.dataset && el.dataset.dshPart === 'sidebar-entry') continue;
392
- if (el.offsetWidth > 0 || el.offsetHeight > 0) return el;
393
- }
402
+ const nodes = document.querySelectorAll('button[class*="newSession"]');
403
+ for (const node of nodes) {
404
+ if (String(node.className).indexOf('newSessionLabel') === -1) return node;
394
405
  }
395
406
  return undefined;
396
407
  }
@@ -427,7 +438,7 @@
427
438
  let anchor = target;
428
439
  let next = target.nextElementSibling;
429
440
  while (next !== null && next.tagName === 'BUTTON'
430
- && (String(next.className).indexOf('sidebar-entry') >= 0 || next.hasAttribute('data-dsh-part'))) {
441
+ && String(next.className).indexOf('sidebar-entry') >= 0) {
431
442
  anchor = next;
432
443
  next = next.nextElementSibling;
433
444
  }
@@ -522,9 +533,42 @@
522
533
  };
523
534
  }
524
535
 
536
+ function registerFirst(ctx, candidates, component) {
537
+ if (!ctx || !ctx.slots) return undefined;
538
+ for (const entry of candidates) {
539
+ try {
540
+ let ok = false;
541
+ ctx.slots.inject(entry.name, () => {
542
+ ctx.slots.register(entry, component);
543
+ ok = true;
544
+ });
545
+ if (ok) return entry.name;
546
+ } catch (e) {}
547
+ }
548
+ return undefined;
549
+ }
550
+
525
551
  function apply(ctx) {
526
552
  ensureStyles();
527
553
  const toggle = createToggle();
554
+
555
+ // Карточка в Настройках -> Плагины
556
+ const cardSlot = registerFirst(ctx, [
557
+ { name: 'settings.plugin.item', key: NS, inject: () => ({ ctx, toggle }) },
558
+ { name: 'settings.section', id: '@goodandready/dsh-cron', order: 34, label: () => 'Cron Задачи', inject: () => ({ ctx, toggle }) }
559
+ ], CronSettingsCard);
560
+
561
+ // Чип в шапке диалога
562
+ const chipSlot = registerFirst(ctx, [
563
+ { name: 'conversation.session.header.utilities', id: '@goodandready/dsh-cron.chip', order: 27, inject: () => ({ ctx, toggle }) }
564
+ ], () => React.createElement('button', {
565
+ type: 'button',
566
+ style: { background: 'none', border: 'none', color: 'var(--dsw-alias-label-secondary, #999)', cursor: 'pointer', padding: '4px', display: 'inline-flex', alignItems: 'center' },
567
+ title: 'Запланированные задачи (Cron)',
568
+ onClick: () => toggle.toggle(),
569
+ dangerouslySetInnerHTML: { __html: ICON_TIMER }
570
+ }));
571
+
528
572
  ctx.effect(() => {
529
573
  const off = [
530
574
  mountSidebarEntry(toggle, 'Запланированные задачи'),
@@ -532,16 +576,11 @@
532
576
  ];
533
577
  return () => { for (const dispose of off) dispose(); };
534
578
  }, 'dsh-cron: client overlay');
579
+
580
+ exports.slots = { card: cardSlot, chip: chipSlot };
535
581
  }
536
582
 
537
583
  module.exports = { apply, inject: ['slots', 'locale', 'settingsScope'] };
538
584
  return module.exports;
539
585
  }
540
-
541
- if (typeof window !== 'undefined' && window.__ModuleLoader__) {
542
- window.__ModuleLoader__.load({
543
- id: '@goodandready/dsh-cron',
544
- factory: dshCronModule
545
- });
546
- }
547
- })();
586
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@goodandready/dsh-cron",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "Scheduled cron tasks, background automation and agent execution for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",