@celljs/ta-app-use 4.22.0 → 4.24.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.
@@ -666,7 +666,7 @@ var SCREEN_TOOLS = [
666
666
  {
667
667
  name: "app_do",
668
668
  label: "Do on the screen",
669
- description: `Does something on the user's screen, as they would, their button pressed under your cursor, and says what was done and what changed since you looked (the whole screen when it is another). id: of the last app_look ([p1.2] a row, [p1] a part, [e3] a control); or, without a look first, find: its words as the screen shows them ("Captions"), with to: a place to go to first, as app_go (a step less, quicker in a call; when not found, you get the screen to choose by id). action: what of a part (open, pin, send, answer...; a row opens without), none to click a control; a text box takes input.text (input.submit: true presses Enter), a choice input.text. What cannot be undone waits for the user to agree on their screen. scroll, in place of action, scrolls the part id names ([p1]), or what app_look says scrolls without an id: "down" or "up" most of a screen (one screen a call at most: call again for more), "top" or "bottom" to an end, {"item": "p1.7"} a row of the last look, {"find": "words"} a row by its words (one drawn but out of sight too; one not drawn yet comes as you scroll toward it); it says where it is then and the rows that came into sight. A game (a part \`game-<n>\`: "Breakout — running · canvas 390×678 · score 12") is played by its actions, x and y from 0 to 1 across and down its canvas: point {x, y} taps there (to start, a button, a cell of a board); move {x, y?} puts the pointer there (a paddle follows it; y kept without), with drag: true drags it there pressed; key {key} presses ArrowLeft, ArrowRight, ArrowUp, ArrowDown, Space, Enter, Escape, a letter or a digit; hold {ms, x, y} or {ms, key} presses that long (30 to 5000 ms: to charge a jump). Each call is one step and answers with the game's state (its score, when it tells it): play in steps, not frame by frame. apart: true does it on Ta's own screen, where an action marked = app_run runs that action without the screen unless show: true.`,
669
+ description: `Does something on the user's screen, as they would, their button pressed under your cursor, and says what was done and what changed since you looked (the whole screen when it is another). id: of the last app_look ([p1.2] a row, [p1] a part, [e3] a control); or, without a look first, find: its words as the screen shows them ("Captions"), with to: a place to go to first, as app_go (a step less, quicker in a call; when not found, you get the screen to choose by id). action: what of a part (open, pin, send, answer...; a row opens without), none to click a control; a text box takes input.text (input.submit: true presses Enter, alone on what it holds: to send what was typed), a choice input.text. What cannot be undone waits for the user to agree on their screen. scroll, in place of action, scrolls the part id names ([p1]), or what app_look says scrolls without an id: "down" or "up" most of a screen (one screen a call at most: call again for more), "top" or "bottom" to an end, {"item": "p1.7"} a row of the last look, {"find": "words"} a row by its words (one drawn but out of sight too; one not drawn yet comes as you scroll toward it); it says where it is then and the rows that came into sight. A game (a part \`game-<n>\`: "Breakout — running · canvas 390×678 · score 12") is played by its actions, x and y from 0 to 1 across and down its canvas: point {x, y} taps there (to start, a button, a cell of a board); move {x, y?} puts the pointer there (a paddle follows it; y kept without), with drag: true drags it there pressed; key {key} presses ArrowLeft, ArrowRight, ArrowUp, ArrowDown, Space, Enter, Escape, a letter or a digit; hold {ms, x, y} or {ms, key} presses that long (30 to 5000 ms: to charge a jump). Each call is one step and answers with the game's state (its score, when it tells it): play in steps, not frame by frame. apart: true does it on Ta's own screen, where an action marked = app_run runs that action without the screen unless show: true.`,
670
670
  parameters: {
671
671
  type: "object",
672
672
  properties: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@celljs/ta-app-use",
3
- "version": "4.22.0",
3
+ "version": "4.24.0",
4
4
  "description": "A pi package for Ta: agents do to Ta what the user does with its pages, through the catalog of actions of ta serve (settings, conversations, extensions, what waits for the user) with a notice and an Undo, or on a screen of Ta's own with a cursor, as the user would",
5
5
  "keywords": [
6
6
  "pi-package"
@@ -27,8 +27,8 @@
27
27
  "watch": "tsc -b -w --preserveWatchOutput"
28
28
  },
29
29
  "devDependencies": {
30
- "@celljs/ta-protocol": "4.22.0",
31
- "@celljs/ta-web": "4.22.0"
30
+ "@celljs/ta-protocol": "4.24.0",
31
+ "@celljs/ta-web": "4.24.0"
32
32
  },
33
33
  "publishConfig": {
34
34
  "access": "public"
package/web/index.js CHANGED
@@ -1469,8 +1469,12 @@ ${this.look(target.part)}` };
1469
1469
  const text = typeof input.text === "string" ? input.text : typeof input.value === "string" ? input.value : undefined;
1470
1470
  const typing = element.matches('input:not([type=checkbox]):not([type=radio]):not([type=button]):not([type=submit]), textarea, [contenteditable="true"], [role=textbox]');
1471
1471
  const choosing = element.tagName.toLowerCase() === "select";
1472
- if ((typing || choosing) && text === undefined) {
1473
- throw new Error(`Say what to ${choosing ? "choose" : "type"}: input.text.`);
1472
+ const submit = typing && (input.submit === true || action === "submit" || action === "send");
1473
+ if (choosing && text === undefined) {
1474
+ throw new Error("Say what to choose: input.text.");
1475
+ }
1476
+ if (typing && text === undefined && !submit) {
1477
+ throw new Error("Say what to type: input.text (input.submit: true presses Enter, alone on what it holds).");
1474
1478
  }
1475
1479
  const danger = element.matches(".ta-danger, .ta-danger *, [data-danger]") || /\bdanger\b/.test(element.className);
1476
1480
  if (danger && !await this.agree(label, options)) {
@@ -1482,15 +1486,18 @@ ${this.look(target.part)}` };
1482
1486
  await this.cursor.press();
1483
1487
  }
1484
1488
  if (typing) {
1485
- const set = (value) => this.setValue(element, value);
1486
- if (watched) {
1487
- await this.cursor.type(text ?? "", set);
1488
- } else {
1489
- set(text ?? "");
1489
+ if (text !== undefined) {
1490
+ const set = (value) => this.setValue(element, value);
1491
+ if (watched) {
1492
+ await this.cursor.type(text, set);
1493
+ } else {
1494
+ set(text);
1495
+ }
1490
1496
  }
1491
- if (input.submit === true || action === "submit") {
1497
+ if (submit) {
1498
+ const window2 = this.window;
1492
1499
  for (const type of ["keydown", "keyup"]) {
1493
- element.dispatchEvent(new KeyboardEvent(type, { key: "Enter", code: "Enter", bubbles: true, cancelable: true }));
1500
+ element.dispatchEvent(new window2.KeyboardEvent(type, { key: "Enter", code: "Enter", bubbles: true, cancelable: true }));
1494
1501
  }
1495
1502
  }
1496
1503
  } else if (choosing) {