@g9tm/lynxcontrols 1.4.11 → 1.6.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/fields/use-text-input.d.ts +1 -1
- package/dist/guide/confirm-sheet.d.ts +26 -0
- package/dist/guide/confirm-sheet.d.ts.map +1 -0
- package/dist/guide/confirm-sheet.jsx +146 -0
- package/dist/guide/confirm-sheet.jsx.map +1 -0
- package/dist/guide/guide.css +428 -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 +462 -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 +95 -0
- package/dist/guide/service.d.ts.map +1 -0
- package/dist/guide/service.jsx +566 -0
- package/dist/guide/service.jsx.map +1 -0
- package/dist/guide/settings.d.ts +68 -0
- package/dist/guide/settings.d.ts.map +1 -0
- package/dist/guide/settings.jsx +66 -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,810 @@
|
|
|
1
|
+
import { formatAddress, g9RuntimeTimers, generalOf, planNavigation, resolvePath, sameSegment, snapshotRefusal, toSegment, tryParseAddress } from "@g9tm/lynxcontrols-foundation";
|
|
2
|
+
import { measureNode } from "../anchor/measure.jsx";
|
|
3
|
+
import { applyScrollMark, readScrollMark, 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
|
+
const DEFAULT_TEXTS = {
|
|
15
|
+
notFound: (t)=>`"${t}" is not on this device.`,
|
|
16
|
+
blocked: (t)=>`"${t}" cannot be closed now.`,
|
|
17
|
+
timeout: (t)=>`"${t}" did not open in time.`,
|
|
18
|
+
notOpened: (t)=>`"${t}" could not be opened.`,
|
|
19
|
+
dirty: (t)=>`"${t}" has unsaved changes.`,
|
|
20
|
+
notAddressable: (t)=>`"${t}" cannot be opened directly.`,
|
|
21
|
+
badAddress: ()=>'This address is not valid.',
|
|
22
|
+
cancelled: ()=>'Cancelled.',
|
|
23
|
+
jumped: (t)=>`Opening "${t}".`
|
|
24
|
+
};
|
|
25
|
+
function isG9Router(sink) {
|
|
26
|
+
return !!sink && 'function' == typeof sink.go && !!sink.current;
|
|
27
|
+
}
|
|
28
|
+
function store(initial) {
|
|
29
|
+
let value = initial;
|
|
30
|
+
const listeners = new Set();
|
|
31
|
+
return {
|
|
32
|
+
get: ()=>value,
|
|
33
|
+
set (v) {
|
|
34
|
+
if (Object.is(v, value)) return;
|
|
35
|
+
value = v;
|
|
36
|
+
for (const l of Array.from(listeners))try {
|
|
37
|
+
l();
|
|
38
|
+
} catch {}
|
|
39
|
+
},
|
|
40
|
+
subscribe (l) {
|
|
41
|
+
listeners.add(l);
|
|
42
|
+
return ()=>{
|
|
43
|
+
listeners.delete(l);
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
class Stop extends Error {
|
|
49
|
+
constructor(reason, at, segment, message){
|
|
50
|
+
super(message), _define_property(this, "reason", void 0), _define_property(this, "at", void 0), _define_property(this, "segment", void 0), this.reason = reason, this.at = at, this.segment = segment;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const sleep = (ms)=>new Promise((r)=>g9RuntimeTimers.setTimeout(r, ms));
|
|
54
|
+
function createG9Router(options) {
|
|
55
|
+
var _options_now, _options_sheetGapMs, _options_closeTimeoutMs, _options_targetTimeoutMs, _options_scrollSettleMs, _options_scrollSettleMaxMs, _options_historySize;
|
|
56
|
+
const catalogue = options.catalogue;
|
|
57
|
+
const now = null != (_options_now = options.now) ? _options_now : ()=>Date.now();
|
|
58
|
+
const texts = {
|
|
59
|
+
...DEFAULT_TEXTS,
|
|
60
|
+
...options.texts
|
|
61
|
+
};
|
|
62
|
+
const sheetGapMs = null != (_options_sheetGapMs = options.sheetGapMs) ? _options_sheetGapMs : 410;
|
|
63
|
+
const closeTimeoutMs = null != (_options_closeTimeoutMs = options.closeTimeoutMs) ? _options_closeTimeoutMs : 3000;
|
|
64
|
+
const targetTimeoutMs = null != (_options_targetTimeoutMs = options.targetTimeoutMs) ? _options_targetTimeoutMs : 3000;
|
|
65
|
+
const scrollSettleMs = null != (_options_scrollSettleMs = options.scrollSettleMs) ? _options_scrollSettleMs : 400;
|
|
66
|
+
const scrollSettleMaxMs = null != (_options_scrollSettleMaxMs = options.scrollSettleMaxMs) ? _options_scrollSettleMaxMs : 3000;
|
|
67
|
+
const historySize = null != (_options_historySize = options.historySize) ? _options_historySize : 50;
|
|
68
|
+
const places = new Map();
|
|
69
|
+
let tokens = 0;
|
|
70
|
+
let revision = 0;
|
|
71
|
+
let lastSheetAt = -1 / 0;
|
|
72
|
+
let cause = 'user';
|
|
73
|
+
let running = null;
|
|
74
|
+
let runs = 0;
|
|
75
|
+
const waiters = new Set();
|
|
76
|
+
const emit = (event)=>{
|
|
77
|
+
try {
|
|
78
|
+
var _options_onEvent;
|
|
79
|
+
null == (_options_onEvent = options.onEvent) || _options_onEvent.call(options, event);
|
|
80
|
+
} catch {}
|
|
81
|
+
};
|
|
82
|
+
const segmentOf = (p)=>{
|
|
83
|
+
try {
|
|
84
|
+
const s = p.declaration.segment;
|
|
85
|
+
return toSegment('function' == typeof s ? s() : s);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
emit({
|
|
88
|
+
kind: 'error',
|
|
89
|
+
where: 'segment',
|
|
90
|
+
error
|
|
91
|
+
});
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const isShown = (p)=>{
|
|
96
|
+
try {
|
|
97
|
+
var _p_declaration_shown, _p_declaration;
|
|
98
|
+
return (null == (_p_declaration_shown = (_p_declaration = p.declaration).shown) ? void 0 : _p_declaration_shown.call(_p_declaration)) !== false;
|
|
99
|
+
} catch (error) {
|
|
100
|
+
emit({
|
|
101
|
+
kind: 'error',
|
|
102
|
+
where: 'shown',
|
|
103
|
+
error
|
|
104
|
+
});
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
const live = ()=>{
|
|
109
|
+
const out = [];
|
|
110
|
+
for (const p of places.values()){
|
|
111
|
+
var _p_declaration_order, _p_declaration_under;
|
|
112
|
+
if (!isShown(p)) continue;
|
|
113
|
+
const segment = segmentOf(p);
|
|
114
|
+
if (segment && catalogue.def(segment.kind)) out.push({
|
|
115
|
+
token: p.token,
|
|
116
|
+
segment,
|
|
117
|
+
layer: p.declaration.layer,
|
|
118
|
+
order: null != (_p_declaration_order = p.declaration.order) ? _p_declaration_order : 0,
|
|
119
|
+
under: null != (_p_declaration_under = p.declaration.under) ? _p_declaration_under : []
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return out;
|
|
123
|
+
};
|
|
124
|
+
const titleOf = (segment, token)=>{
|
|
125
|
+
var _places_get;
|
|
126
|
+
const decl = null !== token ? null == (_places_get = places.get(token)) ? void 0 : _places_get.declaration : void 0;
|
|
127
|
+
let t;
|
|
128
|
+
try {
|
|
129
|
+
var _decl_title;
|
|
130
|
+
t = null == decl ? void 0 : null == (_decl_title = decl.title) ? void 0 : _decl_title.call(decl);
|
|
131
|
+
} catch {
|
|
132
|
+
t = null;
|
|
133
|
+
}
|
|
134
|
+
return (null == t ? void 0 : t.trim()) || catalogue.title(segment, options.context(), options.language());
|
|
135
|
+
};
|
|
136
|
+
const empty = Object.freeze({
|
|
137
|
+
unique: '/',
|
|
138
|
+
general: '/',
|
|
139
|
+
segments: [],
|
|
140
|
+
titles: [],
|
|
141
|
+
incomplete: false,
|
|
142
|
+
others: [],
|
|
143
|
+
facts: {},
|
|
144
|
+
revision: 0
|
|
145
|
+
});
|
|
146
|
+
const current = store(empty);
|
|
147
|
+
const history = store([]);
|
|
148
|
+
const busy = store(false);
|
|
149
|
+
const compute = ()=>{
|
|
150
|
+
const l = live();
|
|
151
|
+
const path = resolvePath(l, catalogue);
|
|
152
|
+
const unique = formatAddress(path.segments);
|
|
153
|
+
const titles = path.segments.map((s, i)=>{
|
|
154
|
+
var _path_tokens_i;
|
|
155
|
+
return titleOf(s, null != (_path_tokens_i = path.tokens[i]) ? _path_tokens_i : null);
|
|
156
|
+
});
|
|
157
|
+
const byToken = new Map(l.map((p)=>[
|
|
158
|
+
p.token,
|
|
159
|
+
p
|
|
160
|
+
]));
|
|
161
|
+
const others = path.others.map((t)=>{
|
|
162
|
+
var _byToken_get;
|
|
163
|
+
return generalOf({
|
|
164
|
+
segments: [
|
|
165
|
+
null == (_byToken_get = byToken.get(t)) ? void 0 : _byToken_get.segment
|
|
166
|
+
]
|
|
167
|
+
}).slice(1);
|
|
168
|
+
});
|
|
169
|
+
const facts = {};
|
|
170
|
+
const ordered = [
|
|
171
|
+
...path.others,
|
|
172
|
+
...path.tokens.filter((t)=>null !== t)
|
|
173
|
+
];
|
|
174
|
+
for (const t of ordered)try {
|
|
175
|
+
var _ref;
|
|
176
|
+
var _places_get_declaration_facts, _places_get, _places_get_declaration;
|
|
177
|
+
Object.assign(facts, null != (_ref = null == (_places_get = places.get(t)) ? void 0 : null == (_places_get_declaration_facts = (_places_get_declaration = _places_get.declaration).facts) ? void 0 : _places_get_declaration_facts.call(_places_get_declaration)) ? _ref : {});
|
|
178
|
+
} catch (error) {
|
|
179
|
+
emit({
|
|
180
|
+
kind: 'error',
|
|
181
|
+
where: 'facts',
|
|
182
|
+
error
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
const prev = current.get();
|
|
186
|
+
const same = prev.unique === unique && prev.incomplete === path.incomplete && prev.titles.join('\u0000') === titles.join('\u0000') && prev.others.join('\u0000') === others.join('\u0000') && JSON.stringify(prev.facts) === JSON.stringify(facts);
|
|
187
|
+
if (!same) {
|
|
188
|
+
revision += 1;
|
|
189
|
+
const next = Object.freeze({
|
|
190
|
+
unique,
|
|
191
|
+
general: generalOf({
|
|
192
|
+
segments: path.segments
|
|
193
|
+
}),
|
|
194
|
+
segments: path.segments,
|
|
195
|
+
titles,
|
|
196
|
+
incomplete: path.incomplete,
|
|
197
|
+
others,
|
|
198
|
+
facts,
|
|
199
|
+
revision
|
|
200
|
+
});
|
|
201
|
+
current.set(next);
|
|
202
|
+
if (prev.unique !== unique) {
|
|
203
|
+
const trail = [
|
|
204
|
+
...history.get(),
|
|
205
|
+
{
|
|
206
|
+
at: now(),
|
|
207
|
+
unique,
|
|
208
|
+
general: next.general,
|
|
209
|
+
cause
|
|
210
|
+
}
|
|
211
|
+
];
|
|
212
|
+
history.set(trail.length > historySize ? trail.slice(trail.length - historySize) : trail);
|
|
213
|
+
}
|
|
214
|
+
emit({
|
|
215
|
+
kind: 'changed',
|
|
216
|
+
location: next,
|
|
217
|
+
cause
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
for (const w of Array.from(waiters))w();
|
|
221
|
+
};
|
|
222
|
+
const waitFor = (predicate, timeoutMs, runId)=>new Promise((resolve)=>{
|
|
223
|
+
if (predicate()) return resolve(true);
|
|
224
|
+
let done = false;
|
|
225
|
+
const finish = (ok)=>{
|
|
226
|
+
if (done) return;
|
|
227
|
+
done = true;
|
|
228
|
+
waiters.delete(check);
|
|
229
|
+
g9RuntimeTimers.clearTimeout(timer);
|
|
230
|
+
resolve(ok);
|
|
231
|
+
};
|
|
232
|
+
const check = ()=>{
|
|
233
|
+
if ((null == running ? void 0 : running.id) !== runId || running.cancelled) finish(false);
|
|
234
|
+
else if (predicate()) finish(true);
|
|
235
|
+
};
|
|
236
|
+
waiters.add(check);
|
|
237
|
+
const timer = g9RuntimeTimers.setTimeout(()=>finish(predicate()), timeoutMs);
|
|
238
|
+
});
|
|
239
|
+
const rowsSettle = (registry, quietMs, maxMs)=>new Promise((resolve)=>{
|
|
240
|
+
let changed = false;
|
|
241
|
+
let done = false;
|
|
242
|
+
let quiet = null;
|
|
243
|
+
const finish = ()=>{
|
|
244
|
+
if (done) return;
|
|
245
|
+
done = true;
|
|
246
|
+
off();
|
|
247
|
+
if (null !== quiet) g9RuntimeTimers.clearTimeout(quiet);
|
|
248
|
+
g9RuntimeTimers.clearTimeout(cap);
|
|
249
|
+
resolve(changed);
|
|
250
|
+
};
|
|
251
|
+
const arm = ()=>{
|
|
252
|
+
if (null !== quiet) g9RuntimeTimers.clearTimeout(quiet);
|
|
253
|
+
quiet = g9RuntimeTimers.setTimeout(finish, quietMs);
|
|
254
|
+
};
|
|
255
|
+
const off = registry.subscribe(()=>{
|
|
256
|
+
changed = true;
|
|
257
|
+
arm();
|
|
258
|
+
});
|
|
259
|
+
const cap = g9RuntimeTimers.setTimeout(finish, maxMs);
|
|
260
|
+
arm();
|
|
261
|
+
});
|
|
262
|
+
const anchorAppears = (registry, id, timeoutMs)=>new Promise((resolve)=>{
|
|
263
|
+
if (registry.find(id)) return resolve(true);
|
|
264
|
+
let done = false;
|
|
265
|
+
const finish = (ok)=>{
|
|
266
|
+
if (done) return;
|
|
267
|
+
done = true;
|
|
268
|
+
off();
|
|
269
|
+
g9RuntimeTimers.clearTimeout(timer);
|
|
270
|
+
resolve(ok);
|
|
271
|
+
};
|
|
272
|
+
const off = registry.subscribe(()=>{
|
|
273
|
+
if (registry.find(id)) finish(true);
|
|
274
|
+
});
|
|
275
|
+
const timer = g9RuntimeTimers.setTimeout(()=>finish(null !== registry.find(id)), timeoutMs);
|
|
276
|
+
});
|
|
277
|
+
const liveWith = (segment)=>{
|
|
278
|
+
var _live_find;
|
|
279
|
+
return null != (_live_find = live().find((p)=>sameSegment(p.segment, segment))) ? _live_find : null;
|
|
280
|
+
};
|
|
281
|
+
const parse = (address)=>{
|
|
282
|
+
if ('string' != typeof address) return address;
|
|
283
|
+
const r = tryParseAddress(address);
|
|
284
|
+
return r.ok ? r.address : null;
|
|
285
|
+
};
|
|
286
|
+
const failure = (reason, at, segment, message)=>({
|
|
287
|
+
ok: false,
|
|
288
|
+
reason,
|
|
289
|
+
at,
|
|
290
|
+
segment,
|
|
291
|
+
message,
|
|
292
|
+
location: current.get()
|
|
293
|
+
});
|
|
294
|
+
async function prepare(address, opts, runId) {
|
|
295
|
+
var _parsed_segments_checked_at;
|
|
296
|
+
const parsed = parse(address);
|
|
297
|
+
if (!parsed) throw new Stop('bad-address', -1, null, texts.badAddress());
|
|
298
|
+
const checked = catalogue.check(parsed);
|
|
299
|
+
if (!checked.ok) throw new Stop(checked.reason, checked.at, null != (_parsed_segments_checked_at = parsed.segments[checked.at]) ? _parsed_segments_checked_at : null, checked.message);
|
|
300
|
+
const target = checked.address;
|
|
301
|
+
const ctx = options.context();
|
|
302
|
+
for(let i = 0; i < target.segments.length; i++){
|
|
303
|
+
var _verdict_message;
|
|
304
|
+
const s = target.segments[i];
|
|
305
|
+
const def = catalogue.def(s.kind);
|
|
306
|
+
if (!(null == def ? void 0 : def.guard)) continue;
|
|
307
|
+
let verdict;
|
|
308
|
+
try {
|
|
309
|
+
verdict = await def.guard(s, target.segments.slice(0, i + 1), ctx);
|
|
310
|
+
} catch (error) {
|
|
311
|
+
var _ref;
|
|
312
|
+
emit({
|
|
313
|
+
kind: 'error',
|
|
314
|
+
where: `guard:${s.kind}`,
|
|
315
|
+
error
|
|
316
|
+
});
|
|
317
|
+
throw new Stop('failed', i, s, String(null != (_ref = null == error ? void 0 : error.message) ? _ref : error));
|
|
318
|
+
}
|
|
319
|
+
if (!verdict.ok) throw new Stop(verdict.reason, i, s, null != (_verdict_message = verdict.message) ? _verdict_message : texts.notFound(catalogue.title(s, ctx, options.language())));
|
|
320
|
+
}
|
|
321
|
+
if ((null == running ? void 0 : running.id) !== runId) throw new Stop('superseded', -1, null, texts.cancelled());
|
|
322
|
+
const l = live();
|
|
323
|
+
const path = resolvePath(l, catalogue);
|
|
324
|
+
const plan = planNavigation(target.segments, path, l);
|
|
325
|
+
for(let i = plan.keep; i < target.segments.length; i++){
|
|
326
|
+
var _catalogue_def;
|
|
327
|
+
const s = target.segments[i];
|
|
328
|
+
if (!(null == (_catalogue_def = catalogue.def(s.kind)) ? void 0 : _catalogue_def.open)) throw new Stop('not-addressable', i, s, texts.notAddressable(catalogue.title(s, ctx, options.language())));
|
|
329
|
+
}
|
|
330
|
+
for (const token of plan.close){
|
|
331
|
+
var _segmentOf, _leave_message;
|
|
332
|
+
const p = places.get(token);
|
|
333
|
+
if (!p) continue;
|
|
334
|
+
let leave = true;
|
|
335
|
+
try {
|
|
336
|
+
var _ref1;
|
|
337
|
+
var _p_declaration_canLeave, _p_declaration;
|
|
338
|
+
leave = null != (_ref1 = null == (_p_declaration_canLeave = (_p_declaration = p.declaration).canLeave) ? void 0 : _p_declaration_canLeave.call(_p_declaration)) ? _ref1 : true;
|
|
339
|
+
} catch {
|
|
340
|
+
leave = true;
|
|
341
|
+
}
|
|
342
|
+
if (true === leave) continue;
|
|
343
|
+
const seg = null != (_segmentOf = segmentOf(p)) ? _segmentOf : toSegment('sheet');
|
|
344
|
+
const title = titleOf(seg, token);
|
|
345
|
+
if (opts.force && 'qa' === opts.source) continue;
|
|
346
|
+
const agreed = options.confirmLeave ? await options.confirmLeave(seg, title, leave.message) : false;
|
|
347
|
+
if (!agreed) throw new Stop('dirty', -1, seg, null != (_leave_message = leave.message) ? _leave_message : texts.dirty(title));
|
|
348
|
+
}
|
|
349
|
+
for (const token of plan.close){
|
|
350
|
+
var _segmentOf1;
|
|
351
|
+
const p = places.get(token);
|
|
352
|
+
if (!p) continue;
|
|
353
|
+
const seg = null != (_segmentOf1 = segmentOf(p)) ? _segmentOf1 : toSegment('sheet');
|
|
354
|
+
if (!p.declaration.close) throw new Stop('blocked', -1, seg, texts.blocked(titleOf(seg, token)));
|
|
355
|
+
try {
|
|
356
|
+
await p.declaration.close();
|
|
357
|
+
} catch (error) {
|
|
358
|
+
emit({
|
|
359
|
+
kind: 'error',
|
|
360
|
+
where: `close:${seg.kind}`,
|
|
361
|
+
error
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
const gone = await waitFor(()=>!places.has(token), closeTimeoutMs, runId);
|
|
365
|
+
if (!gone) {
|
|
366
|
+
var _ref2;
|
|
367
|
+
if ((null == running ? void 0 : running.id) !== runId || (null == running ? void 0 : running.cancelled)) throw new Stop(null != (_ref2 = null == running ? void 0 : running.cancelled) ? _ref2 : 'superseded', -1, null, texts.cancelled());
|
|
368
|
+
throw new Stop('blocked', -1, seg, texts.blocked(titleOf(seg, token)));
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return {
|
|
372
|
+
target,
|
|
373
|
+
open: target.segments.slice(plan.keep),
|
|
374
|
+
keep: plan.keep
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
async function sheetGap() {
|
|
378
|
+
const wait = lastSheetAt + sheetGapMs - now();
|
|
379
|
+
if (wait > 0) await sleep(wait);
|
|
380
|
+
}
|
|
381
|
+
async function openStep(target, index, runId) {
|
|
382
|
+
var _ref, _ref1;
|
|
383
|
+
var _failed_error;
|
|
384
|
+
const s = target.segments[index];
|
|
385
|
+
const def = catalogue.def(s.kind);
|
|
386
|
+
const path = target.segments.slice(0, index + 1);
|
|
387
|
+
await sheetGap();
|
|
388
|
+
let failure = null;
|
|
389
|
+
let refused = false;
|
|
390
|
+
const wake = ()=>{
|
|
391
|
+
for (const w of Array.from(waiters))w();
|
|
392
|
+
};
|
|
393
|
+
Promise.resolve().then(()=>{
|
|
394
|
+
var _def_open;
|
|
395
|
+
return null == def ? void 0 : null == (_def_open = def.open) ? void 0 : _def_open.call(def, s, path, options.context());
|
|
396
|
+
}).then((result)=>{
|
|
397
|
+
if (false === result && !liveWith(s)) {
|
|
398
|
+
refused = true;
|
|
399
|
+
wake();
|
|
400
|
+
}
|
|
401
|
+
}, (error)=>{
|
|
402
|
+
emit({
|
|
403
|
+
kind: 'error',
|
|
404
|
+
where: `open:${s.kind}`,
|
|
405
|
+
error
|
|
406
|
+
});
|
|
407
|
+
if (liveWith(s)) return;
|
|
408
|
+
failure = {
|
|
409
|
+
error
|
|
410
|
+
};
|
|
411
|
+
wake();
|
|
412
|
+
});
|
|
413
|
+
const opened = await waitFor(()=>!!liveWith(s) || null !== failure || refused, null != (_ref = null == def ? void 0 : def.openTimeoutMs) ? _ref : 8000, runId);
|
|
414
|
+
const failed = failure;
|
|
415
|
+
if (failed) throw new Stop('failed', index, s, String(null != (_ref1 = null == (_failed_error = failed.error) ? void 0 : _failed_error.message) ? _ref1 : failed.error));
|
|
416
|
+
if (refused) throw new Stop('failed', index, s, texts.notOpened(catalogue.title(s, options.context(), options.language())));
|
|
417
|
+
if (!opened || !liveWith(s)) {
|
|
418
|
+
var _ref2;
|
|
419
|
+
if ((null == running ? void 0 : running.id) !== runId || (null == running ? void 0 : running.cancelled)) throw new Stop(null != (_ref2 = null == running ? void 0 : running.cancelled) ? _ref2 : 'superseded', index, s, texts.cancelled());
|
|
420
|
+
throw new Stop('timeout', index, s, texts.timeout(catalogue.title(s, options.context(), options.language())));
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
const currentView = (decl)=>{
|
|
424
|
+
try {
|
|
425
|
+
var _ref;
|
|
426
|
+
var _decl_view;
|
|
427
|
+
return null != (_ref = null == (_decl_view = decl.view) ? void 0 : _decl_view.call(decl)) ? _ref : {};
|
|
428
|
+
} catch {
|
|
429
|
+
return {};
|
|
430
|
+
}
|
|
431
|
+
};
|
|
432
|
+
const sameView = (a, b)=>{
|
|
433
|
+
const ka = Object.keys(a);
|
|
434
|
+
return ka.length === Object.keys(b).length && ka.every((k)=>a[k] === b[k]);
|
|
435
|
+
};
|
|
436
|
+
async function applyViews(target, views) {
|
|
437
|
+
var _ref;
|
|
438
|
+
var _options_anchors;
|
|
439
|
+
let worst = 'exact';
|
|
440
|
+
const degrade = (v)=>{
|
|
441
|
+
if ('degraded' === v) worst = 'degraded';
|
|
442
|
+
};
|
|
443
|
+
const l = live();
|
|
444
|
+
for(let i = 0; i < target.segments.length; i++){
|
|
445
|
+
var _s_params, _ref1;
|
|
446
|
+
var _places_get, _views_i;
|
|
447
|
+
const s = target.segments[i];
|
|
448
|
+
const p = l.find((x)=>sameSegment(x.segment, s));
|
|
449
|
+
const decl = p ? null == (_places_get = places.get(p.token)) ? void 0 : _places_get.declaration : void 0;
|
|
450
|
+
const view = {
|
|
451
|
+
...null != (_s_params = s.params) ? _s_params : {},
|
|
452
|
+
...null != (_ref1 = null == views ? void 0 : null == (_views_i = views[i]) ? void 0 : _views_i.view) ? _ref1 : {}
|
|
453
|
+
};
|
|
454
|
+
if ((null == decl ? void 0 : decl.applyView) && !sameView(currentView(decl), view)) try {
|
|
455
|
+
await decl.applyView(view);
|
|
456
|
+
} catch (error) {
|
|
457
|
+
emit({
|
|
458
|
+
kind: 'error',
|
|
459
|
+
where: `applyView:${s.kind}`,
|
|
460
|
+
error
|
|
461
|
+
});
|
|
462
|
+
worst = 'degraded';
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
const registry = null != (_ref = null == (_options_anchors = options.anchors) ? void 0 : _options_anchors.call(options)) ? _ref : null;
|
|
466
|
+
const marks = registry && views ? views.flatMap((v)=>{
|
|
467
|
+
var _v_scroll;
|
|
468
|
+
return Object.entries(null != (_v_scroll = v.scroll) ? _v_scroll : {});
|
|
469
|
+
}) : [];
|
|
470
|
+
if (registry && marks.length > 0) {
|
|
471
|
+
let last = 'exact';
|
|
472
|
+
const pass = async ()=>{
|
|
473
|
+
last = 'exact';
|
|
474
|
+
for (const [id, mark] of marks){
|
|
475
|
+
const spec = registry.scroller(id);
|
|
476
|
+
if (!spec) {
|
|
477
|
+
last = 'degraded';
|
|
478
|
+
continue;
|
|
479
|
+
}
|
|
480
|
+
const applied = await applyScrollMark(registry, spec, mark);
|
|
481
|
+
if ('degraded' === applied) last = 'degraded';
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
await pass();
|
|
485
|
+
if (await rowsSettle(registry, scrollSettleMs, scrollSettleMaxMs)) await pass();
|
|
486
|
+
degrade(last);
|
|
487
|
+
}
|
|
488
|
+
if (target.target && registry) {
|
|
489
|
+
await anchorAppears(registry, target.target, targetTimeoutMs);
|
|
490
|
+
const r = await revealAnchor(registry, target.target);
|
|
491
|
+
if (!r.ok) worst = 'degraded';
|
|
492
|
+
}
|
|
493
|
+
return worst;
|
|
494
|
+
}
|
|
495
|
+
async function run(address, opts, mode, walk, as) {
|
|
496
|
+
if (running) running.cancelled = 'superseded';
|
|
497
|
+
const id = ++runs;
|
|
498
|
+
running = {
|
|
499
|
+
id,
|
|
500
|
+
cancelled: null
|
|
501
|
+
};
|
|
502
|
+
const text = 'string' == typeof address ? address : formatAddress(address);
|
|
503
|
+
busy.set(true);
|
|
504
|
+
const before = cause;
|
|
505
|
+
cause = null != as ? as : walk ? 'walk' : 'restore' === mode ? 'restore' : 'go';
|
|
506
|
+
emit({
|
|
507
|
+
kind: 'go:start',
|
|
508
|
+
address: text,
|
|
509
|
+
mode: walk ? 'walk' : mode
|
|
510
|
+
});
|
|
511
|
+
let result;
|
|
512
|
+
try {
|
|
513
|
+
const { target, open, keep } = await prepare(address, opts, id);
|
|
514
|
+
if (walk) await walk(target, open, keep, id);
|
|
515
|
+
else for(let k = 0; k < open.length; k++){
|
|
516
|
+
await openStep(target, keep + k, id);
|
|
517
|
+
emit({
|
|
518
|
+
kind: 'go:step',
|
|
519
|
+
address: text,
|
|
520
|
+
index: keep + k,
|
|
521
|
+
segment: open[k],
|
|
522
|
+
how: 'opened'
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
const view = await applyViews(target, opts.views);
|
|
526
|
+
result = {
|
|
527
|
+
ok: true,
|
|
528
|
+
location: current.get(),
|
|
529
|
+
view
|
|
530
|
+
};
|
|
531
|
+
} catch (error) {
|
|
532
|
+
if (error instanceof Stop) result = failure(error.reason, error.at, error.segment, error.message);
|
|
533
|
+
else {
|
|
534
|
+
var _ref;
|
|
535
|
+
emit({
|
|
536
|
+
kind: 'error',
|
|
537
|
+
where: 'go',
|
|
538
|
+
error
|
|
539
|
+
});
|
|
540
|
+
result = failure('failed', -1, null, String(null != (_ref = null == error ? void 0 : error.message) ? _ref : error));
|
|
541
|
+
}
|
|
542
|
+
} finally{
|
|
543
|
+
cause = before;
|
|
544
|
+
if ((null == running ? void 0 : running.id) === id) {
|
|
545
|
+
running = null;
|
|
546
|
+
busy.set(false);
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
emit({
|
|
550
|
+
kind: 'go:done',
|
|
551
|
+
address: text,
|
|
552
|
+
result
|
|
553
|
+
});
|
|
554
|
+
return result;
|
|
555
|
+
}
|
|
556
|
+
function snapshot() {
|
|
557
|
+
var _ref;
|
|
558
|
+
const loc = current.get();
|
|
559
|
+
const l = live();
|
|
560
|
+
const views = loc.segments.map((s)=>{
|
|
561
|
+
const p = l.find((x)=>sameSegment(x.segment, s));
|
|
562
|
+
let view;
|
|
563
|
+
try {
|
|
564
|
+
var _places_get_declaration_view, _places_get, _places_get_declaration;
|
|
565
|
+
view = p ? null == (_places_get = places.get(p.token)) ? void 0 : null == (_places_get_declaration_view = (_places_get_declaration = _places_get.declaration).view) ? void 0 : _places_get_declaration_view.call(_places_get_declaration) : void 0;
|
|
566
|
+
} catch {
|
|
567
|
+
view = void 0;
|
|
568
|
+
}
|
|
569
|
+
return view && Object.keys(view).length > 0 ? {
|
|
570
|
+
view
|
|
571
|
+
} : {};
|
|
572
|
+
});
|
|
573
|
+
return {
|
|
574
|
+
v: 1,
|
|
575
|
+
address: loc.unique,
|
|
576
|
+
general: loc.general,
|
|
577
|
+
views,
|
|
578
|
+
facts: loc.facts,
|
|
579
|
+
at: now(),
|
|
580
|
+
app: null != (_ref = 'function' == typeof options.appVersion ? options.appVersion() : options.appVersion) ? _ref : '',
|
|
581
|
+
catalogue: catalogue.hash
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
async function snapshotWithScroll() {
|
|
585
|
+
var _ref;
|
|
586
|
+
var _options_anchors;
|
|
587
|
+
const s = snapshot();
|
|
588
|
+
const registry = null != (_ref = null == (_options_anchors = options.anchors) ? void 0 : _options_anchors.call(options)) ? _ref : null;
|
|
589
|
+
if (!registry || 0 === s.views.length) return s;
|
|
590
|
+
const scroll = {};
|
|
591
|
+
const ids = new Set();
|
|
592
|
+
for (const a of registry.all()){
|
|
593
|
+
const sc = registry.scrollerOf(a);
|
|
594
|
+
if (sc) ids.add(sc.id);
|
|
595
|
+
}
|
|
596
|
+
for (const id of ids){
|
|
597
|
+
const spec = registry.scroller(id);
|
|
598
|
+
if (!spec) continue;
|
|
599
|
+
const box = await measureNode(spec.node());
|
|
600
|
+
if (!box || box.width <= 0 || box.height <= 0) continue;
|
|
601
|
+
const mark = await readScrollMark(registry, spec);
|
|
602
|
+
if ('start' !== mark.by) scroll[id] = mark;
|
|
603
|
+
}
|
|
604
|
+
if (0 === Object.keys(scroll).length) return s;
|
|
605
|
+
const views = s.views.slice();
|
|
606
|
+
const last = views.length - 1;
|
|
607
|
+
views[last] = {
|
|
608
|
+
...views[last],
|
|
609
|
+
scroll
|
|
610
|
+
};
|
|
611
|
+
return {
|
|
612
|
+
...s,
|
|
613
|
+
views
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function restoreAs(s, opts, as) {
|
|
617
|
+
var _opts_maxAgeMs, _opts_source;
|
|
618
|
+
const refusal = snapshotRefusal(s, {
|
|
619
|
+
at: now(),
|
|
620
|
+
catalogue: catalogue.hash,
|
|
621
|
+
maxAgeMs: null != (_opts_maxAgeMs = opts.maxAgeMs) ? _opts_maxAgeMs : 1 / 0
|
|
622
|
+
});
|
|
623
|
+
if (refusal) return Promise.resolve(failure('catalogue' === refusal ? 'bad-address' : 'cancelled', -1, null, `The snapshot is ${'catalogue' === refusal ? 'from another catalogue' : refusal}.`));
|
|
624
|
+
const address = s.target ? `${s.address}#${s.target}` : s.address;
|
|
625
|
+
return run(address, {
|
|
626
|
+
...opts,
|
|
627
|
+
source: null != (_opts_source = opts.source) ? _opts_source : 'restore',
|
|
628
|
+
views: s.views
|
|
629
|
+
}, 'restore', void 0, as);
|
|
630
|
+
}
|
|
631
|
+
const router = {
|
|
632
|
+
catalogue,
|
|
633
|
+
current,
|
|
634
|
+
history,
|
|
635
|
+
busy,
|
|
636
|
+
where: ()=>current.get(),
|
|
637
|
+
declare (declaration) {
|
|
638
|
+
const token = ++tokens;
|
|
639
|
+
places.set(token, {
|
|
640
|
+
token,
|
|
641
|
+
declaration,
|
|
642
|
+
at: now()
|
|
643
|
+
});
|
|
644
|
+
if ('sheet' === declaration.layer) lastSheetAt = now();
|
|
645
|
+
compute();
|
|
646
|
+
return {
|
|
647
|
+
token,
|
|
648
|
+
touch: ()=>{
|
|
649
|
+
if (places.has(token)) compute();
|
|
650
|
+
},
|
|
651
|
+
remove: ()=>{
|
|
652
|
+
if (places.delete(token)) compute();
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
},
|
|
656
|
+
go: (address, opts = {})=>run(address, opts, 'jump'),
|
|
657
|
+
walk (address, opts = {}) {
|
|
658
|
+
var _opts_by;
|
|
659
|
+
const steps = store([]);
|
|
660
|
+
const by = null != (_opts_by = opts.by) ? _opts_by : 'user';
|
|
661
|
+
let cancelledByCaller = false;
|
|
662
|
+
const setStep = (index, state)=>steps.set(steps.get().map((s)=>s.index === index ? {
|
|
663
|
+
...s,
|
|
664
|
+
state
|
|
665
|
+
} : s));
|
|
666
|
+
const result = run(address, opts, 'jump', async (target, open, keep, runId)=>{
|
|
667
|
+
const ctx = options.context();
|
|
668
|
+
steps.set(open.map((segment, k)=>({
|
|
669
|
+
index: keep + k,
|
|
670
|
+
segment,
|
|
671
|
+
title: catalogue.title(segment, ctx, options.language()),
|
|
672
|
+
state: 'pending'
|
|
673
|
+
})));
|
|
674
|
+
for(let k = 0; k < open.length; k++){
|
|
675
|
+
var _ref;
|
|
676
|
+
var _options_anchors;
|
|
677
|
+
const index = keep + k;
|
|
678
|
+
const s = open[k];
|
|
679
|
+
if (cancelledByCaller) throw new Stop('cancelled', index, s, texts.cancelled());
|
|
680
|
+
setStep(index, 'current');
|
|
681
|
+
const def = catalogue.def(s.kind);
|
|
682
|
+
let entry = null;
|
|
683
|
+
try {
|
|
684
|
+
var _ref1;
|
|
685
|
+
var _def_entry;
|
|
686
|
+
entry = null != (_ref1 = await (null == def ? void 0 : null == (_def_entry = def.entry) ? void 0 : _def_entry.call(def, s, target.segments.slice(0, index + 1), ctx))) ? _ref1 : null;
|
|
687
|
+
} catch (error) {
|
|
688
|
+
emit({
|
|
689
|
+
kind: 'error',
|
|
690
|
+
where: `entry:${s.kind}`,
|
|
691
|
+
error
|
|
692
|
+
});
|
|
693
|
+
}
|
|
694
|
+
const registry = null != (_ref = null == (_options_anchors = options.anchors) ? void 0 : _options_anchors.call(options)) ? _ref : null;
|
|
695
|
+
let walked = false;
|
|
696
|
+
if (entry && registry) {
|
|
697
|
+
if (entry.prepare) {
|
|
698
|
+
var _opts_presenter_note, _opts_presenter;
|
|
699
|
+
if (entry.prepareText) null == (_opts_presenter = opts.presenter) || null == (_opts_presenter_note = _opts_presenter.note) || _opts_presenter_note.call(_opts_presenter, entry.prepareText);
|
|
700
|
+
try {
|
|
701
|
+
await entry.prepare();
|
|
702
|
+
} catch (error) {
|
|
703
|
+
emit({
|
|
704
|
+
kind: 'error',
|
|
705
|
+
where: `prepare:${s.kind}`,
|
|
706
|
+
error
|
|
707
|
+
});
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
await sheetGap();
|
|
711
|
+
const shown = await revealAnchor(registry, entry.anchor, {
|
|
712
|
+
smooth: true
|
|
713
|
+
});
|
|
714
|
+
if (shown.ok && shown.anchor) {
|
|
715
|
+
var _entry_gesture;
|
|
716
|
+
var _opts_presenter1;
|
|
717
|
+
const title = catalogue.title(s, ctx, options.language());
|
|
718
|
+
const view = null == (_opts_presenter1 = opts.presenter) ? void 0 : _opts_presenter1.show({
|
|
719
|
+
anchor: entry.anchor,
|
|
720
|
+
text: title,
|
|
721
|
+
gesture: null != (_entry_gesture = entry.gesture) ? _entry_gesture : 'tap',
|
|
722
|
+
index: k,
|
|
723
|
+
count: open.length
|
|
724
|
+
});
|
|
725
|
+
try {
|
|
726
|
+
var _opts_stepTimeoutMs;
|
|
727
|
+
if ('demo' === by) {
|
|
728
|
+
var _opts_demoDelayMs;
|
|
729
|
+
var _shown_anchor_info_capabilities;
|
|
730
|
+
await sleep(null != (_opts_demoDelayMs = opts.demoDelayMs) ? _opts_demoDelayMs : 900);
|
|
731
|
+
const press = null == (_shown_anchor_info_capabilities = shown.anchor.info().capabilities) ? void 0 : _shown_anchor_info_capabilities.activate;
|
|
732
|
+
Promise.resolve().then(()=>null == press ? void 0 : press()).catch((error)=>emit({
|
|
733
|
+
kind: 'error',
|
|
734
|
+
where: `activate:${s.kind}`,
|
|
735
|
+
error
|
|
736
|
+
}));
|
|
737
|
+
}
|
|
738
|
+
walked = await waitFor(()=>!!liveWith(s), null != (_opts_stepTimeoutMs = opts.stepTimeoutMs) ? _opts_stepTimeoutMs : 'demo' === by ? 8000 : 60000, runId);
|
|
739
|
+
} finally{
|
|
740
|
+
null == view || view.hide();
|
|
741
|
+
}
|
|
742
|
+
if (!walked) {
|
|
743
|
+
if (cancelledByCaller || (null == running ? void 0 : running.id) !== runId || (null == running ? void 0 : running.cancelled)) throw new Stop('cancelled', index, s, texts.cancelled());
|
|
744
|
+
setStep(index, 'failed');
|
|
745
|
+
throw new Stop('timeout', index, s, texts.timeout(title));
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
if (walked) setStep(index, 'done');
|
|
750
|
+
else {
|
|
751
|
+
var _opts_presenter_note1, _opts_presenter2;
|
|
752
|
+
null == (_opts_presenter2 = opts.presenter) || null == (_opts_presenter_note1 = _opts_presenter2.note) || _opts_presenter_note1.call(_opts_presenter2, texts.jumped(catalogue.title(s, ctx, options.language())));
|
|
753
|
+
await openStep(target, index, runId);
|
|
754
|
+
setStep(index, 'jumped');
|
|
755
|
+
}
|
|
756
|
+
emit({
|
|
757
|
+
kind: 'go:step',
|
|
758
|
+
address: formatAddress(target),
|
|
759
|
+
index,
|
|
760
|
+
segment: s,
|
|
761
|
+
how: walked ? 'walked' : 'jumped'
|
|
762
|
+
});
|
|
763
|
+
}
|
|
764
|
+
});
|
|
765
|
+
return {
|
|
766
|
+
steps,
|
|
767
|
+
result,
|
|
768
|
+
cancel () {
|
|
769
|
+
cancelledByCaller = true;
|
|
770
|
+
if (running) running.cancelled = 'cancelled';
|
|
771
|
+
for (const w of Array.from(waiters))w();
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
},
|
|
775
|
+
snapshot,
|
|
776
|
+
snapshotWithScroll,
|
|
777
|
+
restore: (s, opts = {})=>restoreAs(s, opts, 'restore'),
|
|
778
|
+
async excursion (address, opts = {}) {
|
|
779
|
+
const origin = await snapshotWithScroll();
|
|
780
|
+
const result = await run(address, opts, 'jump');
|
|
781
|
+
return {
|
|
782
|
+
origin,
|
|
783
|
+
result,
|
|
784
|
+
back: async ()=>{
|
|
785
|
+
var _opts_source;
|
|
786
|
+
return await restoreAs(origin, {
|
|
787
|
+
source: null != (_opts_source = opts.source) ? _opts_source : 'user'
|
|
788
|
+
}, 'back');
|
|
789
|
+
}
|
|
790
|
+
};
|
|
791
|
+
},
|
|
792
|
+
placeAt (index) {
|
|
793
|
+
var _ref;
|
|
794
|
+
var _places_get;
|
|
795
|
+
const l = live();
|
|
796
|
+
const path = resolvePath(l, catalogue);
|
|
797
|
+
const t = path.tokens[index];
|
|
798
|
+
return null == t ? null : null != (_ref = null == (_places_get = places.get(t)) ? void 0 : _places_get.declaration) ? _ref : null;
|
|
799
|
+
},
|
|
800
|
+
reset () {
|
|
801
|
+
if (running) running.cancelled = 'session-ended';
|
|
802
|
+
for (const w of Array.from(waiters))w();
|
|
803
|
+
history.set([]);
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
return router;
|
|
807
|
+
}
|
|
808
|
+
export { createG9Router, isG9Router };
|
|
809
|
+
|
|
810
|
+
//# sourceMappingURL=router.jsx.map
|