command-cmd 1.0.11 → 1.0.15

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/TODO.md ADDED
@@ -0,0 +1,16 @@
1
+ # TODO - Implementar delayGlobal/afterClickDelay
2
+
3
+ ## Objetivo
4
+ Adicionar delay configurável após cliques para garantir que o sistema registre o clique antes de executar a próxima ação.
5
+
6
+ ## Tarefas
7
+
8
+ - [x] 1. Modificar `normalizeMapObject` para ler `delayGlobal` do JSON
9
+ - [x] 2. Modificar `buildFallbackMap` para incluir `delayGlobal` padrão (200ms)
10
+ - [x] 3. Modificar `createMapStore` para passar `delayGlobal` para o store
11
+ - [x] 4. Modificar `buildCursorConfig` para ler `afterClickDelay` e mesclar com valor do map
12
+ - [x] 5. Modificar `clickPoint` para adicionar delay após clicar
13
+ - [x] 6. Atualizar `map.md` com documentação do novo campo `delayGlobal`
14
+ - [x] 7. Atualizar `docPTBR.md` com documentação em português
15
+ - [x] 8. Atualizar `mapPTBR.md` com documentação em português
16
+
package/cmd.js CHANGED
@@ -651,6 +651,7 @@ export async function cursorSequential(input, intervalMs = 3000, options = {}) {
651
651
  function createCursorRuntime(options) {
652
652
  const config = buildCursorConfig(options);
653
653
  let mapStorePromise;
654
+ let afterClickDelayResolved = false;
654
655
 
655
656
  return {
656
657
  config,
@@ -659,6 +660,20 @@ function createCursorRuntime(options) {
659
660
  return mapStorePromise;
660
661
  }
661
662
  mapStorePromise = createMapStore(config);
663
+
664
+ // After map is loaded, merge delayGlobal into config if available
665
+ if (!afterClickDelayResolved) {
666
+ try {
667
+ const mapStore = await mapStorePromise;
668
+ if (mapStore.map.delayGlobal !== undefined) {
669
+ config.afterClickDelay = mapStore.map.delayGlobal;
670
+ }
671
+ afterClickDelayResolved = true;
672
+ } catch (error) {
673
+ // ignore - use default config value
674
+ }
675
+ }
676
+
662
677
  return mapStorePromise;
663
678
  }
664
679
  };
@@ -692,7 +707,8 @@ function buildCursorConfig(options) {
692
707
  sequenceDoubleClick:
693
708
  parseBooleanValue(raw.sequenceDoubleClick) === true,
694
709
  defaultClosePoint: parsePoint(raw.defaultClosePoint) || { x: 1888, y: 16 },
695
- skipAdsPoint: parsePoint(raw.skipAdsPoint) || { x: 808, y: 569 }
710
+ skipAdsPoint: parsePoint(raw.skipAdsPoint) || { x: 808, y: 569 },
711
+ afterClickDelay: parseIntegerOption(raw.afterClickDelay, 200, 0)
696
712
  };
697
713
  }
698
714
 
@@ -1748,6 +1764,7 @@ function buildFallbackMap(config) {
1748
1764
 
1749
1765
  return {
1750
1766
  version: 1,
1767
+ delayGlobal: config.afterClickDelay || 200,
1751
1768
  apps
1752
1769
  };
1753
1770
  }
@@ -1755,7 +1772,8 @@ function buildFallbackMap(config) {
1755
1772
  function normalizeMapObject(rawMap) {
1756
1773
  const result = {
1757
1774
  version: 1,
1758
- apps: {}
1775
+ apps: {},
1776
+ delayGlobal: undefined
1759
1777
  };
1760
1778
 
1761
1779
  if (!rawMap || typeof rawMap !== 'object') {
@@ -1766,6 +1784,11 @@ function normalizeMapObject(rawMap) {
1766
1784
  result.version = Number(rawMap.version);
1767
1785
  }
1768
1786
 
1787
+ // Ler delayGlobal do map.json (valor global em milissegundos)
1788
+ if (Number.isFinite(rawMap.delayGlobal) && rawMap.delayGlobal >= 0) {
1789
+ result.delayGlobal = Math.floor(rawMap.delayGlobal);
1790
+ }
1791
+
1769
1792
  const rawApps =
1770
1793
  rawMap.apps !== undefined
1771
1794
  ? rawMap.apps
@@ -1799,6 +1822,9 @@ function mergeMaps(baseMap, overrideMap) {
1799
1822
  overrideMap && Number.isFinite(overrideMap.version)
1800
1823
  ? overrideMap.version
1801
1824
  : baseMap.version,
1825
+ delayGlobal: overrideMap && Number.isFinite(overrideMap.delayGlobal)
1826
+ ? overrideMap.delayGlobal
1827
+ : baseMap.delayGlobal,
1802
1828
  apps: {}
1803
1829
  };
1804
1830
 
@@ -1954,6 +1980,12 @@ function clickCurrentPosition(robot, doubleClick) {
1954
1980
  async function clickPoint(robot, point, config, clickOptions = {}) {
1955
1981
  await smoothMove(robot, point.x, point.y, config.moveSteps, config.moveDelay);
1956
1982
  clickCurrentPosition(robot, clickOptions.doubleClick === true);
1983
+
1984
+ // Apply after-click delay to ensure click is registered before next action
1985
+ const afterClickDelay = config.afterClickDelay || 0;
1986
+ if (afterClickDelay > 0) {
1987
+ await sleep(afterClickDelay);
1988
+ }
1957
1989
  }
1958
1990
 
1959
1991
  async function runConfiguredPath(robot, pathConfig, config) {
@@ -2009,6 +2041,7 @@ function createActionHandlers(robot, runtime) {
2009
2041
 
2010
2042
  async function openAppIfNeeded(appName, appConfig, mapStore) {
2011
2043
  if (getAppState(appConfig) === APP_STATE.OPEN) {
2044
+ // App is already open, don't reopen but allow subsequent operations to continue
2012
2045
  return;
2013
2046
  }
2014
2047
 
package/docPTBR.md CHANGED
@@ -382,6 +382,7 @@ await executarCursor({
382
382
  scrollSteps: 10,
383
383
  scrollDelay: 20,
384
384
  typeDelay: 50,
385
+ afterClickDelay: 200, // delay global apos cada clique (ms)
385
386
  sequenceInterval: 250, // intervalo padrao do mover_sequencia
386
387
  sequenceClick: 'none', // none|between|each|first|last
387
388
  sequenceDoubleClick: false, // clique duplo por padrao
@@ -389,6 +390,31 @@ await executarCursor({
389
390
  }
390
391
  ```
391
392
 
393
+ ## Configuracao global no map.json
394
+
395
+ Voce pode definir valores globais na raiz do `map.json`:
396
+
397
+ ```json
398
+ {
399
+ "version": 1,
400
+ "delayGlobal": 300,
401
+ "apps": {
402
+ "spotify": { ... }
403
+ }
404
+ }
405
+ ```
406
+
407
+ ### `delayGlobal`
408
+
409
+ - **Tipo**: inteiro (milissegundos)
410
+ - **Padrao**: 200
411
+ - **Descricao**: Delay global apos cada clique. Garante que o sistema operacional registre o clique antes da proxima acao (como digitacao). Aplicado a todas as operacoes de clique.
412
+
413
+ Isso e util quando:
414
+ - Digitacao nao funciona apos clicar em um campo de input
415
+ - Cliques precisam de tempo para registrar antes de operacoes subsequentes
416
+ - Diferentes aplicativos precisam de diferentes tempos de resposta
417
+
392
418
  ## map.json (doc dedicada)
393
419
 
394
420
  Voce pediu uma doc dedicada para o mapeador. Ela esta aqui:
package/map.md CHANGED
@@ -85,6 +85,31 @@ Even with minimal setup, the generated default map includes:
85
85
  }
86
86
  ```
87
87
 
88
+ ## Global configuration (map.json root)
89
+
90
+ You can also set global values at the root level of `map.json`:
91
+
92
+ ```json
93
+ {
94
+ "version": 1,
95
+ "delayGlobal": 300,
96
+ "apps": {
97
+ "spotify": { ... }
98
+ }
99
+ }
100
+ ```
101
+
102
+ ### `delayGlobal`
103
+
104
+ - **Type**: integer (milliseconds)
105
+ - **Default**: 200
106
+ - **Description**: Global delay after each click. This ensures the operating system registers the click before the next action (like typing) begins. Applied to all click operations.
107
+
108
+ This is useful when:
109
+ - Typing doesn't work after clicking an input field
110
+ - Click actions need time to register before subsequent operations
111
+ - Different applications need different response times
112
+
88
113
  ## App fields
89
114
 
90
115
  - `state`: `open`, `closed`, `aberto`, or `fechado`
package/mapPTBR.md CHANGED
@@ -93,6 +93,31 @@ Mesmo no arquivo minimo, o gerador padrao sempre inclui:
93
93
  - `buttons`: mapa de botoes do app
94
94
  - `caminho` dentro de `launcher` (opcional): rota de pontos antes do clique final no app
95
95
 
96
+ ## Configuracao global (raiz do map.json)
97
+
98
+ Voce tambem pode definir valores globais na raiz do `map.json`:
99
+
100
+ ```json
101
+ {
102
+ "version": 1,
103
+ "delayGlobal": 300,
104
+ "apps": {
105
+ "spotify": { ... }
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### `delayGlobal`
111
+
112
+ - **Tipo**: inteiro (milissegundos)
113
+ - **Padrao**: 200
114
+ - **Descricao**: Delay global apos cada clique. Garante que o sistema operacional registre o clique antes da proxima acao (como digitacao). Aplicado a todas as operacoes de clique.
115
+
116
+ Isso e util quando:
117
+ - Digitacao nao funciona apos clicar em um campo de input
118
+ - Cliques precisam de tempo para registrar antes de operacoes subsequentes
119
+ - Diferentes aplicativos precisam de diferentes tempos de resposta
120
+
96
121
  ## Campos de botao
97
122
 
98
123
  Formato simples:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "command-cmd",
3
- "version": "1.0.11",
3
+ "version": "1.0.15",
4
4
  "main": "cmd.js",
5
5
  "type": "module",
6
6
  "scripts": {