@yuneta/gobj-ui 7.26.18 → 7.26.20

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.
@@ -2571,7 +2571,7 @@ function push_overlay_marker(gobj, entry) {
2571
2571
  } catch (e) {
2572
2572
  (0, _yuneta_gobj_js.log_warning)(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
2573
2573
  }
2574
- else (0, _yuneta_gobj_js.log_warning)("C_YUI_SHELL: the entry under an overlay holds a history state that is not a plain object, it cannot be stamped: Back will not close the overlay");
2574
+ else (0, _yuneta_gobj_js.log_warning)("C_YUI_SHELL: the entry under an overlay holds a history state that is not a plain object, it cannot be stamped: the overlay gets no history marker, Back will not close it (its own controls do)");
2575
2575
  if (!stamped) {
2576
2576
  entry.no_marker = true;
2577
2577
  return true;
@@ -2615,7 +2615,7 @@ function note_late_landing(gobj, ev) {
2615
2615
  let priv = gobj.priv;
2616
2616
  let given_up = priv.given_up;
2617
2617
  let st = ev && ev.state;
2618
- if (given_up && Date.now() > given_up.until) {
2618
+ if (given_up && performance.now() > given_up.until) {
2619
2619
  priv.given_up = null;
2620
2620
  return;
2621
2621
  }
@@ -2795,7 +2795,7 @@ function ac_back_wait_timeout(gobj, event, kw, src) {
2795
2795
  let given_up = {
2796
2796
  ids: priv.expected_pop_ids.slice(),
2797
2797
  route: priv.deferred_route,
2798
- until: Date.now() + LATE_LANDING_WINDOW_MS
2798
+ until: performance.now() + LATE_LANDING_WINDOW_MS
2799
2799
  };
2800
2800
  priv.expected_pops = 0;
2801
2801
  priv.expected_pop_hash = "";
@@ -13590,7 +13590,7 @@ function install_long_press_contextmenu(graph, options) {
13590
13590
  pending = {
13591
13591
  x,
13592
13592
  y,
13593
- t0: Date.now(),
13593
+ t0: performance.now(),
13594
13594
  event: Object.assign({}, event),
13595
13595
  tick: setTimeout(announce, 500)
13596
13596
  };
@@ -13616,7 +13616,7 @@ function install_long_press_contextmenu(graph, options) {
13616
13616
  let y = event.client?.y;
13617
13617
  if (x === void 0) x = press.x;
13618
13618
  if (y === void 0) y = press.y;
13619
- if (classify_press(press, x, y, Date.now()) !== "long") return;
13619
+ if (classify_press(press, x, y, performance.now()) !== "long") return;
13620
13620
  fire(press.event);
13621
13621
  };
13622
13622
  let on_touch_cancel = () => {
@@ -2566,7 +2566,7 @@ function push_overlay_marker(gobj, entry) {
2566
2566
  } catch (e) {
2567
2567
  log_warning(`C_YUI_SHELL: stamping the entry under an overlay failed: ${e}`);
2568
2568
  }
2569
- else log_warning("C_YUI_SHELL: the entry under an overlay holds a history state that is not a plain object, it cannot be stamped: Back will not close the overlay");
2569
+ else log_warning("C_YUI_SHELL: the entry under an overlay holds a history state that is not a plain object, it cannot be stamped: the overlay gets no history marker, Back will not close it (its own controls do)");
2570
2570
  if (!stamped) {
2571
2571
  entry.no_marker = true;
2572
2572
  return true;
@@ -2610,7 +2610,7 @@ function note_late_landing(gobj, ev) {
2610
2610
  let priv = gobj.priv;
2611
2611
  let given_up = priv.given_up;
2612
2612
  let st = ev && ev.state;
2613
- if (given_up && Date.now() > given_up.until) {
2613
+ if (given_up && performance.now() > given_up.until) {
2614
2614
  priv.given_up = null;
2615
2615
  return;
2616
2616
  }
@@ -2790,7 +2790,7 @@ function ac_back_wait_timeout(gobj, event, kw, src) {
2790
2790
  let given_up = {
2791
2791
  ids: priv.expected_pop_ids.slice(),
2792
2792
  route: priv.deferred_route,
2793
- until: Date.now() + LATE_LANDING_WINDOW_MS
2793
+ until: performance.now() + LATE_LANDING_WINDOW_MS
2794
2794
  };
2795
2795
  priv.expected_pops = 0;
2796
2796
  priv.expected_pop_hash = "";
@@ -13585,7 +13585,7 @@ function install_long_press_contextmenu(graph, options) {
13585
13585
  pending = {
13586
13586
  x,
13587
13587
  y,
13588
- t0: Date.now(),
13588
+ t0: performance.now(),
13589
13589
  event: Object.assign({}, event),
13590
13590
  tick: setTimeout(announce, 500)
13591
13591
  };
@@ -13611,7 +13611,7 @@ function install_long_press_contextmenu(graph, options) {
13611
13611
  let y = event.client?.y;
13612
13612
  if (x === void 0) x = press.x;
13613
13613
  if (y === void 0) y = press.y;
13614
- if (classify_press(press, x, y, Date.now()) !== "long") return;
13614
+ if (classify_press(press, x, y, performance.now()) !== "long") return;
13615
13615
  fire(press.event);
13616
13616
  };
13617
13617
  let on_touch_cancel = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuneta/gobj-ui",
3
- "version": "7.26.18",
3
+ "version": "7.26.20",
4
4
  "type": "module",
5
5
  "main": "dist/gobj-ui.cjs.js",
6
6
  "module": "dist/gobj-ui.es.js",
@@ -119,7 +119,13 @@ const PURE_METHODS = new Set([
119
119
  * 'abc'.replace('abc', '<i>' + y) is '<i>' + data: built). Where the
120
120
  * first match is decides it, so the replacement is the head only when the
121
121
  * pattern can match at 0: ('z' + name).replace('a', '<b>') starts with
122
- * 'z', and 'abc'.replace('x', '<i>' + y) is 'abc'.
122
+ * 'z', and 'abc'.replace('x', '<i>' + y) is 'abc'. With only blank
123
+ * before where it can match, the replacement still heads the content,
124
+ * since createElement2() trims.
125
+ * A regex on a receiver that carries data is not positioned at all:
126
+ * alternatives and lookaheads can make the data match first, so markup
127
+ * in the replacement is taken as the head (the conservative reading).
128
+ * A `$` in the replacement ends what is known of it.
123
129
  * Not seen: a replacement that is a function, a pattern in a variable. */
124
130
  function static_pattern(arg)
125
131
  {
@@ -202,8 +208,10 @@ function replaced(method, head, args)
202
208
  while(keep < head.text.length && !pattern.startsWith(head.text.slice(keep))) {
203
209
  keep++;
204
210
  }
205
- if(keep === 0) {
206
- return {text: rep_head, complete: false};
211
+ /* Only blank before the match: createElement2() trims, so the
212
+ * replacement's head is what starts the content (' <b>' is markup). */
213
+ if(head.text.slice(0, keep).trim() === "") {
214
+ return {text: head.text.slice(0, keep) + rep_head, complete: false};
207
215
  }
208
216
  return {text: head.text.slice(0, keep), complete: false};
209
217
  }
@@ -2820,7 +2820,8 @@ function push_overlay_marker(gobj, entry)
2820
2820
  } else {
2821
2821
  log_warning(
2822
2822
  `C_YUI_SHELL: the entry under an overlay holds a history state that ` +
2823
- `is not a plain object, it cannot be stamped: Back will not close the overlay`
2823
+ `is not a plain object, it cannot be stamped: the overlay gets no ` +
2824
+ `history marker, Back will not close it (its own controls do)`
2824
2825
  );
2825
2826
  }
2826
2827
  if(!stamped) {
@@ -2921,7 +2922,7 @@ function note_late_landing(gobj, ev)
2921
2922
  let priv = gobj.priv;
2922
2923
  let given_up = priv.given_up;
2923
2924
  let st = ev && ev.state;
2924
- if(given_up && Date.now() > given_up.until) {
2925
+ if(given_up && performance.now() > given_up.until) {
2925
2926
  priv.given_up = null; // too late to be that back(): a Back of the reader's
2926
2927
  return;
2927
2928
  }
@@ -3290,7 +3291,9 @@ function ac_back_wait_timeout(gobj, event, kw, src)
3290
3291
  let given_up = {
3291
3292
  ids: priv.expected_pop_ids.slice(),
3292
3293
  route: priv.deferred_route,
3293
- until: Date.now() + LATE_LANDING_WINDOW_MS
3294
+ /* A monotonic clock: a wall clock set back holds the window
3295
+ * open, set forward closes it early. */
3296
+ until: performance.now() + LATE_LANDING_WINDOW_MS
3294
3297
  };
3295
3298
  priv.expected_pops = 0;
3296
3299
  priv.expected_pop_hash = "";
@@ -461,7 +461,8 @@ export function install_long_press_contextmenu(graph, options)
461
461
  pending = {
462
462
  x: x,
463
463
  y: y,
464
- t0: Date.now(),
464
+ /* A monotonic clock: the wall clock may step mid-press. */
465
+ t0: performance.now(),
465
466
  event: Object.assign({}, event),
466
467
  tick: setTimeout(announce, LONG_PRESS_MS),
467
468
  };
@@ -505,7 +506,7 @@ export function install_long_press_contextmenu(graph, options)
505
506
  if(y === undefined) {
506
507
  y = press.y;
507
508
  }
508
- if(classify_press(press, x, y, Date.now()) !== "long") {
509
+ if(classify_press(press, x, y, performance.now()) !== "long") {
509
510
  return; /* a drag, or a tap: both are already served */
510
511
  }
511
512
  fire(press.event);
@@ -1029,8 +1029,8 @@ describe("V9: the warning of a late back() has a window", () => {
1029
1029
  await next_task();
1030
1030
  expect(shell_warnings().filter(m => m.includes("given up")).length).toBe(1);
1031
1031
 
1032
- const now = Date.now();
1033
- const spy = vi.spyOn(Date, "now").mockImplementation(() => now + 6000);
1032
+ const now = performance.now();
1033
+ const spy = vi.spyOn(performance, "now").mockImplementation(() => now + 6000);
1034
1034
  try {
1035
1035
  late(); // the reader's Back, 6 s later
1036
1036
  await next_task();