@g9tm/lynxcontrols 1.4.11 → 1.5.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/anchor/context.d.ts +15 -0
- package/dist/anchor/context.d.ts.map +1 -0
- package/dist/anchor/context.jsx +10 -0
- package/dist/anchor/context.jsx.map +1 -0
- package/dist/anchor/hooks.d.ts +72 -0
- package/dist/anchor/hooks.d.ts.map +1 -0
- package/dist/anchor/hooks.jsx +147 -0
- package/dist/anchor/hooks.jsx.map +1 -0
- package/dist/anchor/index.d.ts +6 -0
- package/dist/anchor/index.d.ts.map +1 -0
- package/dist/anchor/index.jsx +5 -0
- package/dist/anchor/measure.d.ts +22 -0
- package/dist/anchor/measure.d.ts.map +1 -0
- package/dist/anchor/measure.jsx +110 -0
- package/dist/anchor/measure.jsx.map +1 -0
- package/dist/anchor/registry.d.ts +108 -0
- package/dist/anchor/registry.d.ts.map +1 -0
- package/dist/anchor/registry.jsx +142 -0
- package/dist/anchor/registry.jsx.map +1 -0
- package/dist/anchor/scroll.d.ts +34 -0
- package/dist/anchor/scroll.d.ts.map +1 -0
- package/dist/anchor/scroll.jsx +255 -0
- package/dist/anchor/scroll.jsx.map +1 -0
- package/dist/base/control.d.ts +10 -3
- package/dist/base/control.d.ts.map +1 -1
- package/dist/base/control.jsx +17 -2
- package/dist/base/control.jsx.map +1 -1
- package/dist/base/pressable.d.ts.map +1 -1
- package/dist/base/pressable.jsx +7 -1
- package/dist/base/pressable.jsx.map +1 -1
- package/dist/button/button.d.ts.map +1 -1
- package/dist/button/button.jsx +11 -1
- package/dist/button/button.jsx.map +1 -1
- package/dist/button/header-action-button.d.ts.map +1 -1
- package/dist/button/header-action-button.jsx +10 -1
- package/dist/button/header-action-button.jsx.map +1 -1
- package/dist/button/icon-button.d.ts.map +1 -1
- package/dist/button/icon-button.jsx +11 -1
- package/dist/button/icon-button.jsx.map +1 -1
- package/dist/button/nav-card.d.ts.map +1 -1
- package/dist/button/nav-card.jsx +10 -1
- package/dist/button/nav-card.jsx.map +1 -1
- package/dist/button/vertical-icon-text-button.d.ts.map +1 -1
- package/dist/button/vertical-icon-text-button.jsx +10 -1
- package/dist/button/vertical-icon-text-button.jsx.map +1 -1
- package/dist/expander/expander.d.ts.map +1 -1
- package/dist/expander/expander.jsx +14 -1
- package/dist/expander/expander.jsx.map +1 -1
- package/dist/fields/editor.d.ts.map +1 -1
- package/dist/fields/editor.jsx +17 -1
- package/dist/fields/editor.jsx.map +1 -1
- package/dist/fields/outlined-field.d.ts +6 -0
- package/dist/fields/outlined-field.d.ts.map +1 -1
- package/dist/fields/outlined-field.jsx +14 -3
- package/dist/fields/outlined-field.jsx.map +1 -1
- package/dist/fields/text-entry.d.ts.map +1 -1
- package/dist/fields/text-entry.jsx +17 -1
- package/dist/fields/text-entry.jsx.map +1 -1
- package/dist/guide/guide.css +453 -0
- package/dist/guide/guide.css.map +1 -0
- package/dist/guide/index.d.ts +5 -0
- package/dist/guide/index.d.ts.map +1 -0
- package/dist/guide/index.jsx +4 -0
- package/dist/guide/journey.d.ts +46 -0
- package/dist/guide/journey.d.ts.map +1 -0
- package/dist/guide/journey.jsx +464 -0
- package/dist/guide/journey.jsx.map +1 -0
- package/dist/guide/placement.d.ts +44 -0
- package/dist/guide/placement.d.ts.map +1 -0
- package/dist/guide/placement.jsx +119 -0
- package/dist/guide/placement.jsx.map +1 -0
- package/dist/guide/service.d.ts +85 -0
- package/dist/guide/service.d.ts.map +1 -0
- package/dist/guide/service.jsx +620 -0
- package/dist/guide/service.jsx.map +1 -0
- package/dist/guide/settings.d.ts +50 -0
- package/dist/guide/settings.d.ts.map +1 -0
- package/dist/guide/settings.jsx +60 -0
- package/dist/guide/settings.jsx.map +1 -0
- package/dist/host/host.d.ts +5 -1
- package/dist/host/host.d.ts.map +1 -1
- package/dist/host/host.jsx +12 -0
- package/dist/host/host.jsx.map +1 -1
- package/dist/host/layers.d.ts +3 -1
- package/dist/host/layers.d.ts.map +1 -1
- package/dist/host/layers.jsx +4 -2
- package/dist/host/layers.jsx.map +1 -1
- package/dist/host/registry.d.ts +3 -0
- package/dist/host/registry.d.ts.map +1 -1
- package/dist/host/registry.jsx.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/provider/contexts.d.ts +3 -0
- package/dist/provider/contexts.d.ts.map +1 -1
- package/dist/provider/contexts.jsx.map +1 -1
- package/dist/provider/provider.d.ts.map +1 -1
- package/dist/provider/provider.jsx +24 -17
- package/dist/provider/provider.jsx.map +1 -1
- package/dist/provider/settings.d.ts +4 -0
- package/dist/provider/settings.d.ts.map +1 -1
- package/dist/provider/settings.jsx +3 -2
- package/dist/provider/settings.jsx.map +1 -1
- package/dist/route/hooks.d.ts +34 -0
- package/dist/route/hooks.d.ts.map +1 -0
- package/dist/route/hooks.jsx +147 -0
- package/dist/route/hooks.jsx.map +1 -0
- package/dist/route/index.d.ts +3 -0
- package/dist/route/index.d.ts.map +1 -0
- package/dist/route/index.jsx +2 -0
- package/dist/route/router.d.ts +201 -0
- package/dist/route/router.d.ts.map +1 -0
- package/dist/route/router.jsx +810 -0
- package/dist/route/router.jsx.map +1 -0
- package/dist/sheet/frame.d.ts +3 -1
- package/dist/sheet/frame.d.ts.map +1 -1
- package/dist/sheet/frame.jsx +67 -25
- package/dist/sheet/frame.jsx.map +1 -1
- package/dist/sheet/options.d.ts +10 -0
- package/dist/sheet/options.d.ts.map +1 -1
- package/dist/sheet/options.jsx.map +1 -1
- package/dist/sheet/service.d.ts +5 -0
- package/dist/sheet/service.d.ts.map +1 -1
- package/dist/sheet/service.jsx +14 -2
- package/dist/sheet/service.jsx.map +1 -1
- package/dist/sheet/sheet.css +9 -0
- package/dist/sheet/sheet.css.map +1 -1
- package/dist/tabs/tab-view.d.ts +14 -0
- package/dist/tabs/tab-view.d.ts.map +1 -1
- package/dist/tabs/tab-view.jsx +59 -3
- package/dist/tabs/tab-view.jsx.map +1 -1
- package/dist/toggle/checkbox.d.ts.map +1 -1
- package/dist/toggle/checkbox.jsx +15 -1
- package/dist/toggle/checkbox.jsx.map +1 -1
- package/dist/toggle/chip-group.d.ts.map +1 -1
- package/dist/toggle/chip-group.jsx +12 -1
- package/dist/toggle/chip-group.jsx.map +1 -1
- package/dist/toggle/switch.d.ts.map +1 -1
- package/dist/toggle/switch.jsx +15 -1
- package/dist/toggle/switch.jsx.map +1 -1
- package/package.json +17 -2
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
import { confirmSeconds, g9RuntimeTimers, journeyAuthority, matchesAddress, textIn, tryParseAddress } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
import { windowRect } from "../anchor/measure.jsx";
|
|
3
|
+
import { revealAnchor } from "../anchor/scroll.jsx";
|
|
4
|
+
function _define_property(obj, key, value) {
|
|
5
|
+
if (key in obj) Object.defineProperty(obj, key, {
|
|
6
|
+
value: value,
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true
|
|
10
|
+
});
|
|
11
|
+
else obj[key] = value;
|
|
12
|
+
return obj;
|
|
13
|
+
}
|
|
14
|
+
class Stopped extends Error {
|
|
15
|
+
constructor(reason, message){
|
|
16
|
+
super(message), _define_property(this, "reason", void 0), this.reason = reason;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const sleep = (ms)=>new Promise((r)=>g9RuntimeTimers.setTimeout(r, ms));
|
|
20
|
+
const RANK = {
|
|
21
|
+
engine: 0,
|
|
22
|
+
'engine-confirm': 1,
|
|
23
|
+
user: 2
|
|
24
|
+
};
|
|
25
|
+
function runJourney(journey, options) {
|
|
26
|
+
var _options_personTimeoutMs;
|
|
27
|
+
const { guide, router, language, source } = options;
|
|
28
|
+
const anchors = guide.anchors;
|
|
29
|
+
const personTimeout = null != (_options_personTimeoutMs = options.personTimeoutMs) ? _options_personTimeoutMs : 120000;
|
|
30
|
+
let state = {
|
|
31
|
+
index: 0,
|
|
32
|
+
status: 'running',
|
|
33
|
+
downgraded: []
|
|
34
|
+
};
|
|
35
|
+
const listeners = new Set();
|
|
36
|
+
const set = (patch)=>{
|
|
37
|
+
state = {
|
|
38
|
+
...state,
|
|
39
|
+
...patch
|
|
40
|
+
};
|
|
41
|
+
for (const l of Array.from(listeners))l();
|
|
42
|
+
};
|
|
43
|
+
let cancelled = false;
|
|
44
|
+
let nextWaiter = null;
|
|
45
|
+
const marks = new Set();
|
|
46
|
+
const cancelHooks = new Set();
|
|
47
|
+
const show = (spec)=>{
|
|
48
|
+
const h = guide.show({
|
|
49
|
+
language,
|
|
50
|
+
...spec
|
|
51
|
+
});
|
|
52
|
+
marks.add(h);
|
|
53
|
+
h.result.then(()=>marks.delete(h));
|
|
54
|
+
return h;
|
|
55
|
+
};
|
|
56
|
+
const text = (t)=>void 0 === t ? '' : textIn(t, language);
|
|
57
|
+
const check = ()=>{
|
|
58
|
+
if (cancelled) throw new Stopped('cancelled', 'cancelled');
|
|
59
|
+
};
|
|
60
|
+
const until = (condition, timeoutMs, mark)=>new Promise((resolve)=>{
|
|
61
|
+
let done = false;
|
|
62
|
+
let poll = null;
|
|
63
|
+
const finish = (why)=>{
|
|
64
|
+
if (done) return;
|
|
65
|
+
done = true;
|
|
66
|
+
g9RuntimeTimers.clearTimeout(timer);
|
|
67
|
+
if (null !== poll) g9RuntimeTimers.clearTimeout(poll);
|
|
68
|
+
cancelHooks.delete(onCancel);
|
|
69
|
+
if (nextWaiter === onNext) nextWaiter = null;
|
|
70
|
+
resolve(why);
|
|
71
|
+
};
|
|
72
|
+
const onCancel = ()=>finish('cancelled');
|
|
73
|
+
const onNext = ()=>finish('next');
|
|
74
|
+
cancelHooks.add(onCancel);
|
|
75
|
+
nextWaiter = onNext;
|
|
76
|
+
const timer = g9RuntimeTimers.setTimeout(()=>finish('timeout'), timeoutMs);
|
|
77
|
+
null == mark || mark.result.then((o)=>'next' === o || 'done' === o || 'skip' === o || 'tapped' === o ? finish('next') : 'target-lost' === o ? finish('target-lost') : 'hidden' === o || 'unmount' === o ? finish('cancelled') : void 0);
|
|
78
|
+
if (condition) {
|
|
79
|
+
const tick = async ()=>{
|
|
80
|
+
poll = null;
|
|
81
|
+
if (done) return;
|
|
82
|
+
let met = false;
|
|
83
|
+
try {
|
|
84
|
+
met = await condition();
|
|
85
|
+
} catch {
|
|
86
|
+
met = false;
|
|
87
|
+
}
|
|
88
|
+
if (met) finish('met');
|
|
89
|
+
else if (!done) poll = g9RuntimeTimers.setTimeout(()=>void tick(), 250);
|
|
90
|
+
};
|
|
91
|
+
tick();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
const anchorFor = async (id)=>{
|
|
95
|
+
const r = await revealAnchor(anchors, id, {
|
|
96
|
+
smooth: true
|
|
97
|
+
});
|
|
98
|
+
if (!r.anchor) throw new Stopped('not-found', `The control "${id}" is not on screen.`);
|
|
99
|
+
return r.anchor;
|
|
100
|
+
};
|
|
101
|
+
const routeMet = (pattern)=>()=>{
|
|
102
|
+
var _ref;
|
|
103
|
+
const here = null != (_ref = null == router ? void 0 : router.where().unique) ? _ref : '';
|
|
104
|
+
return here === pattern || tryParseAddress(here).ok && safeMatch(here, pattern);
|
|
105
|
+
};
|
|
106
|
+
const valueMet = (target, equals, start)=>()=>{
|
|
107
|
+
var _anchors_find_info_capabilities_getValue, _anchors_find_info_capabilities, _anchors_find;
|
|
108
|
+
const v = null == (_anchors_find = anchors.find(target)) ? void 0 : null == (_anchors_find_info_capabilities = _anchors_find.info().capabilities) ? void 0 : null == (_anchors_find_info_capabilities_getValue = _anchors_find_info_capabilities.getValue) ? void 0 : _anchors_find_info_capabilities_getValue.call(_anchors_find_info_capabilities);
|
|
109
|
+
return void 0 === equals ? v !== start : v === equals;
|
|
110
|
+
};
|
|
111
|
+
const untilOf = async (u, mark, fallbackNext)=>{
|
|
112
|
+
var _anchors_find_info_capabilities_getValue, _anchors_find_info_capabilities, _anchors_find;
|
|
113
|
+
if (void 0 === u || 'next' === u || 'tap' === u) return until(null, personTimeout, mark);
|
|
114
|
+
if ('ms' in u) {
|
|
115
|
+
await sleep(u.ms);
|
|
116
|
+
return 'met';
|
|
117
|
+
}
|
|
118
|
+
if ('route' in u) return until(routeMet(u.route), personTimeout, fallbackNext ? mark : null);
|
|
119
|
+
const start = null == (_anchors_find = anchors.find(u.value.target)) ? void 0 : null == (_anchors_find_info_capabilities = _anchors_find.info().capabilities) ? void 0 : null == (_anchors_find_info_capabilities_getValue = _anchors_find_info_capabilities.getValue) ? void 0 : _anchors_find_info_capabilities_getValue.call(_anchors_find_info_capabilities);
|
|
120
|
+
return until(valueMet(u.value.target, u.value.equals, start), personTimeout, fallbackNext ? mark : null);
|
|
121
|
+
};
|
|
122
|
+
const authorityOf = (step, action, risk)=>{
|
|
123
|
+
var _ref;
|
|
124
|
+
var _options_authority;
|
|
125
|
+
const base = journeyAuthority(source, action, risk);
|
|
126
|
+
const app = null != (_ref = null == (_options_authority = options.authority) ? void 0 : _options_authority.call(options, step, risk)) ? _ref : null;
|
|
127
|
+
return app && RANK[app] > RANK[base] ? app : base;
|
|
128
|
+
};
|
|
129
|
+
const point = (target, words, gesture = 'tap')=>show({
|
|
130
|
+
target,
|
|
131
|
+
effects: [
|
|
132
|
+
{
|
|
133
|
+
type: 'spotlight'
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
type: 'highlight',
|
|
137
|
+
pulse: true,
|
|
138
|
+
opacity: 0.08
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
type: 'pointer',
|
|
142
|
+
gesture
|
|
143
|
+
},
|
|
144
|
+
...words ? [
|
|
145
|
+
{
|
|
146
|
+
type: 'caption',
|
|
147
|
+
text: words
|
|
148
|
+
}
|
|
149
|
+
] : []
|
|
150
|
+
],
|
|
151
|
+
buttons: [
|
|
152
|
+
'next'
|
|
153
|
+
]
|
|
154
|
+
});
|
|
155
|
+
const steps = {
|
|
156
|
+
go: async (step)=>{
|
|
157
|
+
var _step_by;
|
|
158
|
+
if (!router) throw new Stopped('no-router', 'There is no router to go with.');
|
|
159
|
+
const by = null != (_step_by = step.by) ? _step_by : 'jump';
|
|
160
|
+
const r = 'jump' === by ? await router.go(step.to, {
|
|
161
|
+
source: 'link' === source ? 'link' : 'assistant' === source ? 'assistant' : 'user'
|
|
162
|
+
}) : await router.walk(step.to, {
|
|
163
|
+
by,
|
|
164
|
+
presenter: guide.presenter()
|
|
165
|
+
}).result;
|
|
166
|
+
if (!r.ok) throw new Stopped(r.reason, r.message);
|
|
167
|
+
},
|
|
168
|
+
show: async (step)=>{
|
|
169
|
+
const effects = step.effects ? step.effects.slice() : [
|
|
170
|
+
{
|
|
171
|
+
type: 'spotlight'
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
type: 'highlight',
|
|
175
|
+
pulse: true,
|
|
176
|
+
opacity: 0.08
|
|
177
|
+
}
|
|
178
|
+
];
|
|
179
|
+
if (step.text && !effects.some((e)=>'caption' === e.type)) effects.push({
|
|
180
|
+
type: 'caption',
|
|
181
|
+
text: step.text
|
|
182
|
+
});
|
|
183
|
+
const m = show({
|
|
184
|
+
target: step.target,
|
|
185
|
+
effects,
|
|
186
|
+
buttons: [
|
|
187
|
+
'next'
|
|
188
|
+
]
|
|
189
|
+
});
|
|
190
|
+
const why = await untilOf(step.until, m, true);
|
|
191
|
+
m.hide();
|
|
192
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
193
|
+
if ('timeout' === why || 'target-lost' === why) throw new Stopped(why, `"${step.target}" ${'timeout' === why ? 'was not reached in time' : 'left the screen'}.`);
|
|
194
|
+
},
|
|
195
|
+
say: async (step)=>{
|
|
196
|
+
const w = windowRect();
|
|
197
|
+
const m = show({
|
|
198
|
+
target: {
|
|
199
|
+
x: w.width / 2 - 1,
|
|
200
|
+
y: 0.42 * w.height,
|
|
201
|
+
width: 2,
|
|
202
|
+
height: 2
|
|
203
|
+
},
|
|
204
|
+
effects: [
|
|
205
|
+
{
|
|
206
|
+
type: 'caption',
|
|
207
|
+
text: step.text,
|
|
208
|
+
placement: 'below'
|
|
209
|
+
}
|
|
210
|
+
],
|
|
211
|
+
buttons: [
|
|
212
|
+
'next'
|
|
213
|
+
],
|
|
214
|
+
reveal: false
|
|
215
|
+
});
|
|
216
|
+
const why = await untilOf(step.until, m, true);
|
|
217
|
+
m.hide();
|
|
218
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
219
|
+
if ('timeout' === why) throw new Stopped('timeout', 'No answer in time.');
|
|
220
|
+
},
|
|
221
|
+
fill: async (step, index)=>{
|
|
222
|
+
var _caps_getValue;
|
|
223
|
+
const anchor = await anchorFor(step.target);
|
|
224
|
+
const caps = anchor.info().capabilities;
|
|
225
|
+
if ('user' === step.by || !(null == caps ? void 0 : caps.setValue)) {
|
|
226
|
+
if ('user' !== step.by) set({
|
|
227
|
+
downgraded: [
|
|
228
|
+
...state.downgraded,
|
|
229
|
+
index
|
|
230
|
+
]
|
|
231
|
+
});
|
|
232
|
+
const m = point(step.target, step.value);
|
|
233
|
+
const why = await until(valueMet(step.target, step.value, null), personTimeout, m);
|
|
234
|
+
m.hide();
|
|
235
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
236
|
+
if ('timeout' === why) throw new Stopped('timeout', `"${step.target}" was not filled in time.`);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
const m = show({
|
|
240
|
+
target: step.target,
|
|
241
|
+
effects: [
|
|
242
|
+
{
|
|
243
|
+
type: 'highlight',
|
|
244
|
+
pulse: true
|
|
245
|
+
}
|
|
246
|
+
],
|
|
247
|
+
reveal: false
|
|
248
|
+
});
|
|
249
|
+
try {
|
|
250
|
+
var _caps_focus;
|
|
251
|
+
await (null == (_caps_focus = caps.focus) ? void 0 : _caps_focus.call(caps));
|
|
252
|
+
const chars = Array.from(step.value);
|
|
253
|
+
const per = Math.min(guide.settings.typeMsPerChar, chars.length > 0 ? 1200 / chars.length : 0);
|
|
254
|
+
if (per > 0) for(let i = 1; i < chars.length; i++){
|
|
255
|
+
check();
|
|
256
|
+
await caps.setValue(chars.slice(0, i).join(''));
|
|
257
|
+
await sleep(per);
|
|
258
|
+
}
|
|
259
|
+
check();
|
|
260
|
+
await caps.setValue(step.value);
|
|
261
|
+
} finally{
|
|
262
|
+
m.hide();
|
|
263
|
+
}
|
|
264
|
+
const read = null == (_caps_getValue = caps.getValue) ? void 0 : _caps_getValue.call(caps);
|
|
265
|
+
if (null != read && read !== step.value) throw new Stopped('failed', `"${step.target}" holds "${read}", not the value given.`);
|
|
266
|
+
},
|
|
267
|
+
select: async (step, index)=>{
|
|
268
|
+
const anchor = await anchorFor(step.target);
|
|
269
|
+
const caps = anchor.info().capabilities;
|
|
270
|
+
const has = ()=>{
|
|
271
|
+
var _ref;
|
|
272
|
+
var _caps_getValue;
|
|
273
|
+
return (null != (_ref = null == caps ? void 0 : null == (_caps_getValue = caps.getValue) ? void 0 : _caps_getValue.call(caps)) ? _ref : '').split(',').indexOf(step.item) >= 0;
|
|
274
|
+
};
|
|
275
|
+
if ('user' === step.by || !(null == caps ? void 0 : caps.selectItem)) {
|
|
276
|
+
if ('user' !== step.by) set({
|
|
277
|
+
downgraded: [
|
|
278
|
+
...state.downgraded,
|
|
279
|
+
index
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
const m = point(step.target, '');
|
|
283
|
+
const why = await until(has, personTimeout, m);
|
|
284
|
+
m.hide();
|
|
285
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
286
|
+
if ('timeout' === why) throw new Stopped('timeout', `"${step.item}" was not picked in time.`);
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
await caps.selectItem(step.item);
|
|
290
|
+
if (caps.getValue && !has()) throw new Stopped('failed', `"${step.target}" did not take "${step.item}".`);
|
|
291
|
+
},
|
|
292
|
+
press: async (step, index)=>{
|
|
293
|
+
var _info_risk;
|
|
294
|
+
var _info_label, _info_capabilities, _info_capabilities_activate, _info_capabilities1;
|
|
295
|
+
const anchor = await anchorFor(step.target);
|
|
296
|
+
const info = anchor.info();
|
|
297
|
+
const risk = null != (_info_risk = info.risk) ? _info_risk : 'none';
|
|
298
|
+
const authority = authorityOf(step, 'press', risk);
|
|
299
|
+
const label = text(step.text) || (null == (_info_label = info.label) ? void 0 : _info_label.call(info)) || step.target;
|
|
300
|
+
const byPerson = 'user' === step.by || 'user' === authority || !(null == (_info_capabilities = info.capabilities) ? void 0 : _info_capabilities.activate);
|
|
301
|
+
if (byPerson) {
|
|
302
|
+
var _ref;
|
|
303
|
+
if ('engine' === step.by) set({
|
|
304
|
+
downgraded: [
|
|
305
|
+
...state.downgraded,
|
|
306
|
+
index
|
|
307
|
+
]
|
|
308
|
+
});
|
|
309
|
+
const before = null != (_ref = null == router ? void 0 : router.where().revision) ? _ref : -1;
|
|
310
|
+
const m = point(step.target, label);
|
|
311
|
+
const why = await until(()=>(router ? router.where().revision !== before : false) || !anchors.find(step.target), personTimeout, m);
|
|
312
|
+
m.hide();
|
|
313
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
314
|
+
if ('timeout' === why) throw new Stopped('timeout', `"${label}" was not pressed in time.`);
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
if ('engine-confirm' === authority && 'none' !== risk) {
|
|
318
|
+
var _ref1, _ref2;
|
|
319
|
+
var _info_changes;
|
|
320
|
+
const changes = null != (_ref1 = null != (_ref2 = null == (_info_changes = info.changes) ? void 0 : _info_changes.call(info)) ? _ref2 : lastPlaceChanges(router)) ? _ref1 : [];
|
|
321
|
+
const seconds = confirmSeconds(source, risk, changes.length > 0, guide.settings.confirm);
|
|
322
|
+
const hl = show({
|
|
323
|
+
target: step.target,
|
|
324
|
+
effects: [
|
|
325
|
+
{
|
|
326
|
+
type: 'highlight',
|
|
327
|
+
pulse: true
|
|
328
|
+
}
|
|
329
|
+
],
|
|
330
|
+
reveal: false
|
|
331
|
+
});
|
|
332
|
+
let ok = false;
|
|
333
|
+
try {
|
|
334
|
+
ok = await guide.confirm({
|
|
335
|
+
title: label,
|
|
336
|
+
source,
|
|
337
|
+
changes,
|
|
338
|
+
seconds,
|
|
339
|
+
destructive: 'destructive' === risk
|
|
340
|
+
});
|
|
341
|
+
} finally{
|
|
342
|
+
hl.hide();
|
|
343
|
+
}
|
|
344
|
+
if (!ok) throw new Stopped('declined', 'The person did not confirm.');
|
|
345
|
+
}
|
|
346
|
+
check();
|
|
347
|
+
show({
|
|
348
|
+
target: step.target,
|
|
349
|
+
effects: [
|
|
350
|
+
{
|
|
351
|
+
type: 'ripple'
|
|
352
|
+
}
|
|
353
|
+
],
|
|
354
|
+
timeoutMs: 600,
|
|
355
|
+
reveal: false
|
|
356
|
+
});
|
|
357
|
+
await (null == (_info_capabilities1 = info.capabilities) ? void 0 : null == (_info_capabilities_activate = _info_capabilities1.activate) ? void 0 : _info_capabilities_activate.call(_info_capabilities1));
|
|
358
|
+
},
|
|
359
|
+
wait: async (step)=>{
|
|
360
|
+
var _step_timeoutMs;
|
|
361
|
+
var _anchors_find_info_capabilities_getValue, _anchors_find_info_capabilities, _anchors_find;
|
|
362
|
+
const f = step.for;
|
|
363
|
+
const conditions = [];
|
|
364
|
+
if (f.route) conditions.push(routeMet(f.route));
|
|
365
|
+
if (f.anchor) {
|
|
366
|
+
const id = f.anchor;
|
|
367
|
+
conditions.push(()=>!!anchors.find(id));
|
|
368
|
+
}
|
|
369
|
+
if (f.value) conditions.push(valueMet(f.value.target, f.value.equals, null == (_anchors_find = anchors.find(f.value.target)) ? void 0 : null == (_anchors_find_info_capabilities = _anchors_find.info().capabilities) ? void 0 : null == (_anchors_find_info_capabilities_getValue = _anchors_find_info_capabilities.getValue) ? void 0 : _anchors_find_info_capabilities_getValue.call(_anchors_find_info_capabilities)));
|
|
370
|
+
if (void 0 !== f.ms && 0 === conditions.length) return void await sleep(f.ms);
|
|
371
|
+
const why = await until(()=>conditions.some((c)=>c()), null != (_step_timeoutMs = step.timeoutMs) ? _step_timeoutMs : 30000, null);
|
|
372
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
373
|
+
if ('timeout' === why) throw new Stopped('timeout', 'What the journey waited for did not happen.');
|
|
374
|
+
},
|
|
375
|
+
back: async ()=>{
|
|
376
|
+
if (!router || !origin) throw new Stopped('no-router', 'There is nowhere to come back to.');
|
|
377
|
+
const r = await router.restore(origin);
|
|
378
|
+
if (!r.ok) throw new Stopped(r.reason, r.message);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
let origin = null;
|
|
382
|
+
const result = (async ()=>{
|
|
383
|
+
try {
|
|
384
|
+
if (router && journey.steps.some((s)=>'back' === s.do)) origin = await router.snapshotWithScroll();
|
|
385
|
+
for(let i = 0; i < journey.steps.length; i++){
|
|
386
|
+
check();
|
|
387
|
+
set({
|
|
388
|
+
index: i,
|
|
389
|
+
status: 'running'
|
|
390
|
+
});
|
|
391
|
+
const step = journey.steps[i];
|
|
392
|
+
await steps[step.do](step, i);
|
|
393
|
+
if ('manual' === journey.pace && i < journey.steps.length - 1) {
|
|
394
|
+
set({
|
|
395
|
+
status: 'waiting'
|
|
396
|
+
});
|
|
397
|
+
const why = await until(null, personTimeout, null);
|
|
398
|
+
if ('cancelled' === why) throw new Stopped('cancelled', 'cancelled');
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
set({
|
|
402
|
+
status: 'done'
|
|
403
|
+
});
|
|
404
|
+
return {
|
|
405
|
+
ok: true
|
|
406
|
+
};
|
|
407
|
+
} catch (error) {
|
|
408
|
+
var _ref;
|
|
409
|
+
const stopped = error instanceof Stopped ? error : new Stopped('failed', String(null != (_ref = null == error ? void 0 : error.message) ? _ref : error));
|
|
410
|
+
set({
|
|
411
|
+
status: 'cancelled' === stopped.reason ? 'cancelled' : 'failed'
|
|
412
|
+
});
|
|
413
|
+
return {
|
|
414
|
+
ok: false,
|
|
415
|
+
failedAt: state.index,
|
|
416
|
+
reason: stopped.reason,
|
|
417
|
+
message: stopped.message
|
|
418
|
+
};
|
|
419
|
+
} finally{
|
|
420
|
+
for (const m of Array.from(marks))m.hide();
|
|
421
|
+
}
|
|
422
|
+
})();
|
|
423
|
+
return {
|
|
424
|
+
journey,
|
|
425
|
+
state: {
|
|
426
|
+
get: ()=>state,
|
|
427
|
+
subscribe (l) {
|
|
428
|
+
listeners.add(l);
|
|
429
|
+
return ()=>{
|
|
430
|
+
listeners.delete(l);
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
},
|
|
434
|
+
next () {
|
|
435
|
+
null == nextWaiter || nextWaiter();
|
|
436
|
+
},
|
|
437
|
+
cancel () {
|
|
438
|
+
cancelled = true;
|
|
439
|
+
for (const h of Array.from(cancelHooks))h();
|
|
440
|
+
for (const m of Array.from(marks))m.hide();
|
|
441
|
+
},
|
|
442
|
+
result
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function safeMatch(address, pattern) {
|
|
446
|
+
try {
|
|
447
|
+
return matchesAddress(address, pattern);
|
|
448
|
+
} catch {
|
|
449
|
+
return false;
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
function lastPlaceChanges(router) {
|
|
453
|
+
if (!router) return null;
|
|
454
|
+
const n = router.where().segments.length;
|
|
455
|
+
for(let i = n - 1; i >= 0; i--){
|
|
456
|
+
var _router_placeAt_describeChanges, _router_placeAt;
|
|
457
|
+
const d = null == (_router_placeAt = router.placeAt(i)) ? void 0 : null == (_router_placeAt_describeChanges = _router_placeAt.describeChanges) ? void 0 : _router_placeAt_describeChanges.call(_router_placeAt);
|
|
458
|
+
if (d && d.length > 0) return d;
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
export { runJourney };
|
|
463
|
+
|
|
464
|
+
//# sourceMappingURL=journey.jsx.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guide/journey.jsx","sources":["../../src/guide/journey.ts"],"sourcesContent":["import {\n confirmSeconds,\n type G9AnchorRisk,\n type G9GuideEffectSpec,\n type G9Journey,\n type G9JourneySource,\n type G9JourneyStep,\n type G9Snapshot,\n type G9StepAuthority,\n type G9Until,\n type G9WaitFor,\n g9RuntimeTimers,\n journeyAuthority,\n matchesAddress,\n textIn,\n tryParseAddress,\n} from '@g9tm/lynxcontrols-foundation';\nimport { windowRect } from '../anchor/measure';\nimport type { G9AnchorEntry } from '../anchor/registry';\nimport { revealAnchor } from '../anchor/scroll';\nimport type { G9Router } from '../route/router';\nimport type { G9GuideHandle, G9GuideOutcome, G9GuideService, G9GuideSpec } from './service';\n\n// Runs a journey on screen. Who may do what is the SOURCE policy (foundation `journeyAuthority`), read with the CALLER's\n// source — a journey cannot raise its own rights: navigation, showing and filling a form are the engine's; pressing a\n// control that saves or deletes waits for the person's confirmation behind a countdown, with every change listed; a\n// step the policy keeps from the engine falls to the person (the finger points, the guide waits). Every step ends with\n// a result; a failure stops the journey with its reason (no retries, no loops). Back ends the journey.\n\n/** What a journey runs with: the trusted source, the language, the guide and the router. */\nexport interface G9JourneyRunOptions {\n /** Who started it (trusted: the app decides, never the journey). */\n readonly source: G9JourneySource;\n readonly language: 'fa' | 'en';\n readonly guide: G9GuideService;\n readonly router?: G9Router | null;\n /** Make the policy stricter for a step (an app may never make it looser). */\n readonly authority?: (step: G9JourneyStep, risk: G9AnchorRisk) => G9StepAuthority | null;\n /** How long a person's step may take before the journey stops (ms). Default 120000. */\n readonly personTimeoutMs?: number;\n}\n\n/** The phase of a running journey. */\nexport type G9JourneyStatus = 'running' | 'waiting' | 'done' | 'failed' | 'cancelled';\n\n/** Where a running journey is. */\nexport interface G9JourneyState {\n readonly index: number;\n readonly status: G9JourneyStatus;\n /** Steps the policy gave to the person instead of the engine. */\n readonly downgraded: readonly number[];\n}\n\n/** How a journey ended: `ok`, or the step it stopped at and why. */\nexport interface G9JourneyResult {\n readonly ok: boolean;\n readonly failedAt?: number;\n readonly reason?: string;\n readonly message?: string;\n}\n\n/** A running journey: its state, «next» for a manual pace, cancel, and its result. */\nexport interface G9JourneyRun {\n readonly journey: G9Journey;\n readonly state: { get(): G9JourneyState; subscribe(l: () => void): () => void };\n /** The «next» of a manual journey (or of the bubble). */\n next(): void;\n cancel(): void;\n readonly result: Promise<G9JourneyResult>;\n}\n\nclass Stopped extends Error {\n constructor(\n readonly reason: string,\n message: string,\n ) {\n super(message);\n }\n}\n\nconst sleep = (ms: number) => new Promise<void>((r) => g9RuntimeTimers.setTimeout(r, ms));\nconst RANK: Readonly<Record<G9StepAuthority, number>> = { engine: 0, 'engine-confirm': 1, user: 2 };\n\n/** Starts a journey (validate untrusted JSON with `validateJourney` first). */\nexport function runJourney(journey: G9Journey, options: G9JourneyRunOptions): G9JourneyRun {\n const { guide, router, language, source } = options;\n const anchors = guide.anchors;\n const personTimeout = options.personTimeoutMs ?? 120000;\n let state: G9JourneyState = { index: 0, status: 'running', downgraded: [] };\n const listeners = new Set<() => void>();\n const set = (patch: Partial<G9JourneyState>) => {\n state = { ...state, ...patch };\n for (const l of Array.from(listeners)) l();\n };\n let cancelled = false;\n let nextWaiter: (() => void) | null = null;\n const marks = new Set<G9GuideHandle>();\n const cancelHooks = new Set<() => void>();\n\n const show = (spec: G9GuideSpec): G9GuideHandle => {\n const h = guide.show({ language, ...spec });\n marks.add(h);\n void h.result.then(() => marks.delete(h));\n return h;\n };\n const text = (t: Parameters<typeof textIn>[0] | undefined) => (t === undefined ? '' : textIn(t, language));\n const check = () => {\n if (cancelled) throw new Stopped('cancelled', 'cancelled');\n };\n\n /** Resolves on the first of: a condition met (polled), the run's «next», a cancel, a timeout. */\n const until = (\n condition: (() => boolean | Promise<boolean>) | null,\n timeoutMs: number,\n mark: G9GuideHandle | null,\n ): Promise<'met' | 'next' | 'timeout' | 'cancelled' | G9GuideOutcome> =>\n new Promise((resolve) => {\n let done = false;\n let poll: unknown = null;\n const finish = (why: 'met' | 'next' | 'timeout' | 'cancelled' | G9GuideOutcome) => {\n if (done) return;\n done = true;\n g9RuntimeTimers.clearTimeout(timer);\n if (poll !== null) g9RuntimeTimers.clearTimeout(poll);\n cancelHooks.delete(onCancel);\n if (nextWaiter === onNext) nextWaiter = null;\n resolve(why);\n };\n const onCancel = () => finish('cancelled');\n const onNext = () => finish('next');\n cancelHooks.add(onCancel);\n nextWaiter = onNext;\n const timer = g9RuntimeTimers.setTimeout(() => finish('timeout'), timeoutMs);\n void mark?.result.then((o) =>\n o === 'next' || o === 'done' || o === 'skip' || o === 'tapped'\n ? finish('next')\n : o === 'target-lost'\n ? finish('target-lost')\n : // Hidden by someone else (Android back ends the guide), or the host went away: the journey stops.\n o === 'hidden' || o === 'unmount'\n ? finish('cancelled')\n : undefined,\n );\n if (condition) {\n const tick = async () => {\n poll = null;\n if (done) return;\n let met = false;\n try {\n met = await condition();\n } catch {\n met = false;\n }\n if (met) finish('met');\n else if (!done) poll = g9RuntimeTimers.setTimeout(() => void tick(), 250);\n };\n void tick();\n }\n });\n\n const anchorFor = async (id: string): Promise<G9AnchorEntry> => {\n const r = await revealAnchor(anchors, id, { smooth: true });\n if (!r.anchor) throw new Stopped('not-found', `The control \"${id}\" is not on screen.`);\n return r.anchor;\n };\n\n const routeMet = (pattern: string) => () => {\n const here = router?.where().unique ?? '';\n return here === pattern || (tryParseAddress(here).ok && safeMatch(here, pattern));\n };\n\n const valueMet = (target: string, equals: string | undefined, start: string | null | undefined) => () => {\n const v = anchors.find(target)?.info().capabilities?.getValue?.();\n return equals === undefined ? v !== start : v === equals;\n };\n\n const untilOf = async (u: G9Until | undefined, mark: G9GuideHandle | null, fallbackNext: boolean) => {\n if (u === undefined || u === 'next' || u === 'tap') return until(null, personTimeout, mark);\n if ('ms' in u) {\n await sleep(u.ms);\n return 'met';\n }\n if ('route' in u) return until(routeMet(u.route), personTimeout, fallbackNext ? mark : null);\n const start = anchors.find(u.value.target)?.info().capabilities?.getValue?.();\n return until(valueMet(u.value.target, u.value.equals, start), personTimeout, fallbackNext ? mark : null);\n };\n\n const authorityOf = (\n step: G9JourneyStep,\n action: 'navigate' | 'fill' | 'press',\n risk: G9AnchorRisk,\n ): G9StepAuthority => {\n const base = journeyAuthority(source, action, risk);\n const app = options.authority?.(step, risk) ?? null;\n return app && RANK[app] > RANK[base] ? app : base;\n };\n\n const point = (target: string, words: string, gesture: 'tap' | 'longPress' = 'tap') =>\n show({\n target,\n effects: [\n { type: 'spotlight' },\n { type: 'highlight', pulse: true, opacity: 0.08 },\n { type: 'pointer', gesture },\n ...(words ? [{ type: 'caption' as const, text: words }] : []),\n ],\n buttons: ['next'],\n });\n\n const steps: Record<G9JourneyStep['do'], (step: never, index: number) => Promise<void>> = {\n go: async (step: Extract<G9JourneyStep, { do: 'go' }>) => {\n if (!router) throw new Stopped('no-router', 'There is no router to go with.');\n const by = step.by ?? 'jump';\n const r =\n by === 'jump'\n ? await router.go(step.to, {\n source: source === 'link' ? 'link' : source === 'assistant' ? 'assistant' : 'user',\n })\n : await router.walk(step.to, { by, presenter: guide.presenter() }).result;\n if (!r.ok) throw new Stopped(r.reason, r.message);\n },\n show: async (step: Extract<G9JourneyStep, { do: 'show' }>) => {\n const effects: G9GuideEffectSpec[] = step.effects\n ? step.effects.slice()\n : [{ type: 'spotlight' }, { type: 'highlight', pulse: true, opacity: 0.08 }];\n if (step.text && !effects.some((e) => e.type === 'caption')) effects.push({ type: 'caption', text: step.text });\n const m = show({ target: step.target, effects, buttons: ['next'] });\n const why = await untilOf(step.until, m, true);\n m.hide();\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout' || why === 'target-lost')\n throw new Stopped(\n why,\n `\"${step.target}\" ${why === 'timeout' ? 'was not reached in time' : 'left the screen'}.`,\n );\n },\n say: async (step: Extract<G9JourneyStep, { do: 'say' }>) => {\n const w = windowRect();\n const m = show({\n target: { x: w.width / 2 - 1, y: w.height * 0.42, width: 2, height: 2 },\n effects: [{ type: 'caption', text: step.text, placement: 'below' }],\n buttons: ['next'],\n reveal: false,\n });\n const why = await untilOf(step.until, m, true);\n m.hide();\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout') throw new Stopped('timeout', 'No answer in time.');\n },\n fill: async (step: Extract<G9JourneyStep, { do: 'fill' }>, index: number) => {\n const anchor = await anchorFor(step.target);\n const caps = anchor.info().capabilities;\n if (step.by === 'user' || !caps?.setValue) {\n if (step.by !== 'user') set({ downgraded: [...state.downgraded, index] });\n const m = point(step.target, step.value);\n const why = await until(valueMet(step.target, step.value, null), personTimeout, m);\n m.hide();\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout') throw new Stopped('timeout', `\"${step.target}\" was not filled in time.`);\n return;\n }\n const m = show({ target: step.target, effects: [{ type: 'highlight', pulse: true }], reveal: false });\n try {\n await caps.focus?.();\n const chars = Array.from(step.value);\n const per = Math.min(guide.settings.typeMsPerChar, chars.length > 0 ? 1200 / chars.length : 0);\n if (per > 0) {\n for (let i = 1; i < chars.length; i++) {\n check();\n await caps.setValue(chars.slice(0, i).join(''));\n await sleep(per);\n }\n }\n check();\n await caps.setValue(step.value);\n } finally {\n m.hide();\n }\n const read = caps.getValue?.();\n if (read !== undefined && read !== null && read !== step.value)\n throw new Stopped('failed', `\"${step.target}\" holds \"${read}\", not the value given.`);\n },\n select: async (step: Extract<G9JourneyStep, { do: 'select' }>, index: number) => {\n const anchor = await anchorFor(step.target);\n const caps = anchor.info().capabilities;\n const has = () => (caps?.getValue?.() ?? '').split(',').indexOf(step.item) >= 0;\n if (step.by === 'user' || !caps?.selectItem) {\n if (step.by !== 'user') set({ downgraded: [...state.downgraded, index] });\n const m = point(step.target, '');\n const why = await until(has, personTimeout, m);\n m.hide();\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout') throw new Stopped('timeout', `\"${step.item}\" was not picked in time.`);\n return;\n }\n await caps.selectItem(step.item);\n if (caps.getValue && !has()) throw new Stopped('failed', `\"${step.target}\" did not take \"${step.item}\".`);\n },\n press: async (step: Extract<G9JourneyStep, { do: 'press' }>, index: number) => {\n const anchor = await anchorFor(step.target);\n const info = anchor.info();\n const risk = info.risk ?? 'none';\n const authority = authorityOf(step, 'press', risk);\n const label = text(step.text) || info.label?.() || step.target;\n const byPerson = step.by === 'user' || authority === 'user' || !info.capabilities?.activate;\n if (byPerson) {\n if (step.by === 'engine') set({ downgraded: [...state.downgraded, index] });\n const before = router?.where().revision ?? -1;\n const m = point(step.target, label);\n const why = await until(\n () => (router ? router.where().revision !== before : false) || !anchors.find(step.target),\n personTimeout,\n m,\n );\n m.hide();\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout') throw new Stopped('timeout', `\"${label}\" was not pressed in time.`);\n return;\n }\n if (authority === 'engine-confirm' && risk !== 'none') {\n const changes = info.changes?.() ?? lastPlaceChanges(router) ?? [];\n const seconds = confirmSeconds(source, risk, changes.length > 0, guide.settings.confirm);\n const hl = show({ target: step.target, effects: [{ type: 'highlight', pulse: true }], reveal: false });\n let ok = false;\n try {\n ok = await guide.confirm({ title: label, source, changes, seconds, destructive: risk === 'destructive' });\n } finally {\n hl.hide();\n }\n if (!ok) throw new Stopped('declined', 'The person did not confirm.');\n }\n check();\n show({ target: step.target, effects: [{ type: 'ripple' }], timeoutMs: 600, reveal: false });\n await info.capabilities?.activate?.();\n },\n wait: async (step: Extract<G9JourneyStep, { do: 'wait' }>) => {\n const f: G9WaitFor = step.for;\n const conditions: Array<() => boolean> = [];\n if (f.route) conditions.push(routeMet(f.route));\n if (f.anchor) {\n const id = f.anchor;\n conditions.push(() => !!anchors.find(id));\n }\n if (f.value)\n conditions.push(\n valueMet(f.value.target, f.value.equals, anchors.find(f.value.target)?.info().capabilities?.getValue?.()),\n );\n if (f.ms !== undefined && conditions.length === 0) {\n await sleep(f.ms);\n return;\n }\n const why = await until(() => conditions.some((c) => c()), step.timeoutMs ?? 30000, null);\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n if (why === 'timeout') throw new Stopped('timeout', 'What the journey waited for did not happen.');\n },\n back: async () => {\n if (!router || !origin) throw new Stopped('no-router', 'There is nowhere to come back to.');\n const r = await router.restore(origin);\n if (!r.ok) throw new Stopped(r.reason, r.message);\n },\n };\n\n let origin: G9Snapshot | null = null;\n const result = (async (): Promise<G9JourneyResult> => {\n try {\n if (router && journey.steps.some((s) => s.do === 'back')) origin = await router.snapshotWithScroll();\n for (let i = 0; i < journey.steps.length; i++) {\n check();\n set({ index: i, status: 'running' });\n const step = journey.steps[i] as G9JourneyStep;\n await (steps[step.do] as (s: G9JourneyStep, i: number) => Promise<void>)(step, i);\n if (journey.pace === 'manual' && i < journey.steps.length - 1) {\n set({ status: 'waiting' });\n const why = await until(null, personTimeout, null);\n if (why === 'cancelled') throw new Stopped('cancelled', 'cancelled');\n }\n }\n set({ status: 'done' });\n return { ok: true };\n } catch (error) {\n const stopped =\n error instanceof Stopped ? error : new Stopped('failed', String((error as Error)?.message ?? error));\n set({ status: stopped.reason === 'cancelled' ? 'cancelled' : 'failed' });\n return { ok: false, failedAt: state.index, reason: stopped.reason, message: stopped.message };\n } finally {\n for (const m of Array.from(marks)) m.hide();\n }\n })();\n\n return {\n journey,\n state: {\n get: () => state,\n subscribe(l) {\n listeners.add(l);\n return () => {\n listeners.delete(l);\n };\n },\n },\n next() {\n nextWaiter?.();\n },\n cancel() {\n cancelled = true;\n for (const h of Array.from(cancelHooks)) h();\n for (const m of Array.from(marks)) m.hide();\n },\n result,\n };\n}\n\nfunction safeMatch(address: string, pattern: string): boolean {\n try {\n return matchesAddress(address, pattern);\n } catch {\n return false;\n }\n}\n\nfunction lastPlaceChanges(router: G9Router | null | undefined) {\n if (!router) return null;\n const n = router.where().segments.length;\n for (let i = n - 1; i >= 0; i--) {\n const d = router.placeAt(i)?.describeChanges?.();\n if (d && d.length > 0) return d;\n }\n return null;\n}\n"],"names":["Stopped","Error","reason","message","sleep","ms","Promise","r","g9RuntimeTimers","RANK","runJourney","journey","options","_options_personTimeoutMs","guide","router","language","source","anchors","personTimeout","state","listeners","Set","set","patch","l","Array","cancelled","nextWaiter","marks","cancelHooks","show","spec","h","text","t","undefined","textIn","check","until","condition","timeoutMs","mark","resolve","done","poll","finish","why","timer","onCancel","onNext","o","tick","met","anchorFor","id","revealAnchor","routeMet","pattern","here","tryParseAddress","safeMatch","valueMet","target","equals","start","_anchors_find_info_capabilities","v","untilOf","u","fallbackNext","authorityOf","step","action","risk","base","journeyAuthority","app","point","words","gesture","steps","_step_by","by","effects","e","m","w","windowRect","index","caps","anchor","chars","per","Math","i","read","has","_info_risk","info","_info_capabilities","_info_capabilities1","authority","label","byPerson","before","_ref1","changes","lastPlaceChanges","seconds","confirmSeconds","hl","ok","_step_timeoutMs","f","conditions","c","origin","result","s","error","stopped","String","address","matchesAddress","n","_router_placeAt","d"],"mappings":";;;;;;;;;;;;;AAuEA,MAAMA,gBAAgBC;IACpB,YACWC,MAAc,EACvBC,OAAe,CACf;QACA,KAAK,CAACA,UAAAA,iBAAAA,IAAAA,EAAAA,UAAAA,KAAAA,IAAAA,IAAAA,CAHGD,MAAM,GAANA;IAIX;AACF;AAEA,MAAME,QAAQ,CAACC,KAAe,IAAIC,QAAc,CAACC,IAAMC,gBAAgB,UAAU,CAACD,GAAGF;AACrF,MAAMI,OAAkD;IAAE,QAAQ;IAAG,kBAAkB;IAAG,MAAM;AAAE;AAG3F,SAASC,WAAWC,OAAkB,EAAEC,OAA4B;QAGnDC;IAFtB,MAAM,EAAEC,KAAK,EAAEC,MAAM,EAAEC,QAAQ,EAAEC,MAAM,EAAE,GAAGL;IAC5C,MAAMM,UAAUJ,MAAM,OAAO;IAC7B,MAAMK,gBAAgB,QAAAN,CAAAA,2BAAAA,QAAQ,eAAe,AAAD,IAAtBA,2BAA2B;IACjD,IAAIO,QAAwB;QAAE,OAAO;QAAG,QAAQ;QAAW,YAAY,EAAE;IAAC;IAC1E,MAAMC,YAAY,IAAIC;IACtB,MAAMC,MAAM,CAACC;QACXJ,QAAQ;YAAE,GA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,CAAC;gBACTJ,UAAU,GAAG,CAACI;gBACd,OAAO;oBACLJ,UAAU,MAAM,CAACI;gBACnB;YACF;QACF;QACA;YACEG,QAAAA,cAAAA;QACF;QACA;YACED,YAAY;YACZ,KAAK,MAAMM,KAAKP,MAAM,IAAI,CAACI,aAAcG;YACzC,KAAK,MAAMqD,KAAK5D,MAAM,IAAI,CAACG,OAAQyD,EAAE,IAAI;QAC3C;QACAgC;IACF;AACF;AAEA,SAASzD,UAAU8D,OAAe,EAAEjE,OAAe;IACjD,IAAI;QACF,OAAOkE,eAAeD,SAASjE;IACjC,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA,SAASkD,iBAAiB7F,MAAmC;IAC3D,IAAI,CAACA,QAAQ,OAAO;IACpB,MAAM8G,IAAI9G,OAAO,KAAK,GAAG,QAAQ,CAAC,MAAM;IACxC,IAAK,IAAIgF,IAAI8B,IAAI,GAAG9B,KAAK,GAAGA,IAAK;YACrB+B,iCAAAA;QAAV,MAAMC,IAAI,QAAAD,CAAAA,kBAAAA,OAAO,OAAO,CAAC/B,EAAC,IAAhB+B,KAAAA,IAAAA,QAAAA,CAAAA,kCAAAA,gBAAmB,eAAe,AAAD,IAAjCA,KAAAA,IAAAA,gCAAAA,IAAAA,CAAAA;QACV,IAAIC,KAAKA,EAAE,MAAM,GAAG,GAAG,OAAOA;IAChC;IACA,OAAO;AACT"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { G9AnchorRect } from '../anchor/registry.js';
|
|
2
|
+
/** Which side of the target a bubble sits on (`over` when none fits). */
|
|
3
|
+
export type G9BubbleSide = 'below' | 'above' | 'end' | 'start' | 'over';
|
|
4
|
+
/** Where a guide bubble goes and where its arrow points. */
|
|
5
|
+
export interface G9BubblePlacement {
|
|
6
|
+
readonly x: number;
|
|
7
|
+
readonly y: number;
|
|
8
|
+
readonly side: G9BubbleSide;
|
|
9
|
+
/** The arrow's offset along the bubble edge that faces the target (px from the bubble's left or top). */
|
|
10
|
+
readonly arrow: number;
|
|
11
|
+
}
|
|
12
|
+
/** The target, the bubble size and the free area a bubble is placed in. */
|
|
13
|
+
export interface G9BubbleRequest {
|
|
14
|
+
readonly target: G9AnchorRect;
|
|
15
|
+
readonly bubble: {
|
|
16
|
+
readonly width: number;
|
|
17
|
+
readonly height: number;
|
|
18
|
+
};
|
|
19
|
+
/** The free area. */
|
|
20
|
+
readonly view: G9AnchorRect;
|
|
21
|
+
/** Gap between target and bubble. Default 12. */
|
|
22
|
+
readonly gap?: number;
|
|
23
|
+
/** Margin from the free area's edges. Default 12. */
|
|
24
|
+
readonly margin?: number;
|
|
25
|
+
readonly prefer?: 'auto' | 'above' | 'below' | 'start' | 'end';
|
|
26
|
+
readonly rtl?: boolean;
|
|
27
|
+
/** Corner radius the arrow stays clear of. Default 14. */
|
|
28
|
+
readonly radius?: number;
|
|
29
|
+
}
|
|
30
|
+
/** The bubble's place. */
|
|
31
|
+
export declare function placeBubble(r: G9BubbleRequest): G9BubblePlacement;
|
|
32
|
+
/**
|
|
33
|
+
* Where the pointing finger goes: the fingertip of the glyph (at 11.5 / 6 of its 24-unit box) on the target's centre,
|
|
34
|
+
* the hand hanging below it — so it never hides the label of a button above it.
|
|
35
|
+
*/
|
|
36
|
+
export declare function placePointer(target: G9AnchorRect, size?: number): {
|
|
37
|
+
readonly x: number;
|
|
38
|
+
readonly y: number;
|
|
39
|
+
};
|
|
40
|
+
/** The four rects of a scrim around a hole (top, bottom, start, end bands), none negative. */
|
|
41
|
+
export declare function scrimBands(hole: G9AnchorRect, view: G9AnchorRect): readonly G9AnchorRect[];
|
|
42
|
+
/** A rect grown by `pad` on every side. */
|
|
43
|
+
export declare function inflate(r: G9AnchorRect, pad: number): G9AnchorRect;
|
|
44
|
+
//# sourceMappingURL=placement.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/guide/placement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EA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