@g9tm/lynxcontrols-pilot 0.0.0-stage → 2.4.1
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/README.md +159 -2
- package/catalog/cards/G9PilotHost.md +16 -0
- package/catalog/cards/G9PilotMask.md +10 -0
- package/catalog/cards/G9PilotPanel.md +10 -0
- package/catalog/catalog.json +420 -0
- package/catalog/index.md +7 -0
- package/check/cli.mjs +5 -0
- package/check/index.mjs +137 -0
- package/check/index.test.mjs +180 -0
- package/config/cli.mjs +31 -0
- package/config/index.d.ts +62 -0
- package/config/index.mjs +380 -0
- package/config/index.test.mjs +406 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/anchors.d.ts +39 -0
- package/dist/anchors.d.ts.map +1 -0
- package/dist/anchors.jsx +103 -0
- package/dist/bridge.d.ts +4 -0
- package/dist/bridge.d.ts.map +1 -0
- package/dist/bridge.jsx +143 -0
- package/dist/busy.d.ts +4 -0
- package/dist/busy.d.ts.map +1 -0
- package/dist/busy.jsx +43 -0
- package/dist/commands.d.ts +24 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.jsx +286 -0
- package/dist/consent.d.ts +51 -0
- package/dist/consent.d.ts.map +1 -0
- package/dist/consent.jsx +131 -0
- package/dist/explore.d.ts +36 -0
- package/dist/explore.d.ts.map +1 -0
- package/dist/explore.jsx +133 -0
- package/dist/flags.d.ts +69 -0
- package/dist/flags.d.ts.map +1 -0
- package/dist/flags.jsx +81 -0
- package/dist/host-core.d.ts +36 -0
- package/dist/host-core.d.ts.map +1 -0
- package/dist/host-core.jsx +90 -0
- package/dist/host-sink.d.ts +43 -0
- package/dist/host-sink.d.ts.map +1 -0
- package/dist/host-sink.jsx +87 -0
- package/dist/index-marks.d.ts +33 -0
- package/dist/index-marks.d.ts.map +1 -0
- package/dist/index-marks.jsx +40 -0
- package/dist/index-observe.d.ts +17 -0
- package/dist/index-observe.d.ts.map +1 -0
- package/dist/index-observe.jsx +14 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.jsx +11 -0
- package/dist/info.d.ts +10 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/info.jsx +9 -0
- package/dist/kit.d.ts +67 -0
- package/dist/kit.d.ts.map +1 -0
- package/dist/kit.jsx +1 -0
- package/dist/layer.d.ts +4 -0
- package/dist/layer.d.ts.map +1 -0
- package/dist/layer.jsx +10 -0
- package/dist/layers.d.ts +4 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/layers.jsx +146 -0
- package/dist/mask.d.ts +20 -0
- package/dist/mask.d.ts.map +1 -0
- package/dist/mask.jsx +35 -0
- package/dist/net.d.ts +17 -0
- package/dist/net.d.ts.map +1 -0
- package/dist/net.jsx +60 -0
- package/dist/observe.d.ts +99 -0
- package/dist/observe.d.ts.map +1 -0
- package/dist/observe.jsx +194 -0
- package/dist/off.d.ts +45 -0
- package/dist/off.d.ts.map +1 -0
- package/dist/off.jsx +81 -0
- package/dist/otlp.d.ts +61 -0
- package/dist/otlp.d.ts.map +1 -0
- package/dist/otlp.jsx +141 -0
- package/dist/panel.d.ts +13 -0
- package/dist/panel.d.ts.map +1 -0
- package/dist/panel.jsx +182 -0
- package/dist/session.d.ts +42 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.jsx +115 -0
- package/dist/types.d.ts +47 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.jsx +1 -0
- package/dist/watch.d.ts +17 -0
- package/dist/watch.d.ts.map +1 -0
- package/dist/watch.jsx +165 -0
- package/doctor/cli.mjs +5 -0
- package/doctor/index.mjs +214 -0
- package/doctor/index.test.mjs +174 -0
- package/gradle/g9pilot.app.gradle +55 -0
- package/gradle/g9pilot.settings.gradle +27 -0
- package/ios/g9pilot.rb +47 -0
- package/package.json +66 -4
- package/rspeedy/index.d.ts +40 -0
- package/rspeedy/index.mjs +100 -0
- package/rspeedy/index.test.mjs +192 -0
package/dist/anchors.jsx
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { registerTestTarget } from "@g9tm/app-pilot-lynx";
|
|
2
|
+
const TYPES = {
|
|
3
|
+
button: 'Button',
|
|
4
|
+
entry: 'Entry',
|
|
5
|
+
toggle: 'Switch',
|
|
6
|
+
picker: 'Picker',
|
|
7
|
+
tab: 'TabItem',
|
|
8
|
+
list: 'List',
|
|
9
|
+
item: 'Tile',
|
|
10
|
+
card: 'Card',
|
|
11
|
+
label: 'Label',
|
|
12
|
+
image: 'Image',
|
|
13
|
+
map: 'Map'
|
|
14
|
+
};
|
|
15
|
+
function anchorTarget(entry) {
|
|
16
|
+
var _first_capabilities, _TYPES_first_kind;
|
|
17
|
+
const info = ()=>entry.info();
|
|
18
|
+
const caps = ()=>{
|
|
19
|
+
var _info_capabilities;
|
|
20
|
+
return null != (_info_capabilities = info().capabilities) ? _info_capabilities : {};
|
|
21
|
+
};
|
|
22
|
+
const first = info();
|
|
23
|
+
const c = null != (_first_capabilities = first.capabilities) ? _first_capabilities : {};
|
|
24
|
+
return {
|
|
25
|
+
type: null != (_TYPES_first_kind = TYPES[first.kind]) ? _TYPES_first_kind : 'View',
|
|
26
|
+
text: ()=>{
|
|
27
|
+
var _ref;
|
|
28
|
+
var _info_label, _info;
|
|
29
|
+
return null != (_ref = null == (_info_label = (_info = info()).label) ? void 0 : _info_label.call(_info)) ? _ref : null;
|
|
30
|
+
},
|
|
31
|
+
enabled: ()=>{
|
|
32
|
+
var _ref;
|
|
33
|
+
var _info_enabled, _info;
|
|
34
|
+
return null != (_ref = null == (_info_enabled = (_info = info()).enabled) ? void 0 : _info_enabled.call(_info)) ? _ref : true;
|
|
35
|
+
},
|
|
36
|
+
layer: entry.binding.layer,
|
|
37
|
+
...first.secret ? {
|
|
38
|
+
secret: true
|
|
39
|
+
} : {},
|
|
40
|
+
...void 0 !== entry.binding.sheetId ? {
|
|
41
|
+
sheetId: entry.binding.sheetId
|
|
42
|
+
} : {},
|
|
43
|
+
node: ()=>entry.binding.node(),
|
|
44
|
+
...c.getValue ? {
|
|
45
|
+
value: ()=>{
|
|
46
|
+
var _ref;
|
|
47
|
+
var _caps_getValue, _caps;
|
|
48
|
+
return null != (_ref = null == (_caps_getValue = (_caps = caps()).getValue) ? void 0 : _caps_getValue.call(_caps)) ? _ref : null;
|
|
49
|
+
}
|
|
50
|
+
} : {},
|
|
51
|
+
...c.setValue ? {
|
|
52
|
+
setValue: async (value)=>{
|
|
53
|
+
var _ref;
|
|
54
|
+
var _caps_setValue, _caps, _caps_getValue, _caps1;
|
|
55
|
+
const applied = await (null == (_caps_setValue = (_caps = caps()).setValue) ? void 0 : _caps_setValue.call(_caps, value));
|
|
56
|
+
return 'string' == typeof applied ? applied : null != (_ref = null == (_caps_getValue = (_caps1 = caps()).getValue) ? void 0 : _caps_getValue.call(_caps1)) ? _ref : void 0;
|
|
57
|
+
}
|
|
58
|
+
} : {},
|
|
59
|
+
...c.activate ? {
|
|
60
|
+
activate: ()=>{
|
|
61
|
+
var _caps_activate, _caps;
|
|
62
|
+
return null == (_caps_activate = (_caps = caps()).activate) ? void 0 : _caps_activate.call(_caps);
|
|
63
|
+
}
|
|
64
|
+
} : {},
|
|
65
|
+
...c.itemKeys ? {
|
|
66
|
+
items: ()=>{
|
|
67
|
+
var _ref;
|
|
68
|
+
var _caps_itemKeys, _caps;
|
|
69
|
+
return (null != (_ref = null == (_caps_itemKeys = (_caps = caps()).itemKeys) ? void 0 : _caps_itemKeys.call(_caps)) ? _ref : []).map((key)=>({
|
|
70
|
+
key,
|
|
71
|
+
text: key
|
|
72
|
+
}));
|
|
73
|
+
},
|
|
74
|
+
selectItem: (item)=>{
|
|
75
|
+
var _ref, _item_key;
|
|
76
|
+
var _caps_selectItem, _caps;
|
|
77
|
+
return null == (_caps_selectItem = (_caps = caps()).selectItem) ? void 0 : _caps_selectItem.call(_caps, String(null != (_ref = null != (_item_key = item.key) ? _item_key : item.text) ? _ref : ''));
|
|
78
|
+
}
|
|
79
|
+
} : {}
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function mirrorAnchors(registry) {
|
|
83
|
+
const live = new Map();
|
|
84
|
+
const sync = ()=>{
|
|
85
|
+
const now = new Set(registry.all().filter((a)=>{
|
|
86
|
+
var _a_binding_shown, _a_binding;
|
|
87
|
+
return !a.virtual && (null == (_a_binding_shown = (_a_binding = a.binding).shown) ? void 0 : _a_binding_shown.call(_a_binding)) !== false;
|
|
88
|
+
}));
|
|
89
|
+
for (const [entry, off] of live)if (!now.has(entry)) {
|
|
90
|
+
off();
|
|
91
|
+
live.delete(entry);
|
|
92
|
+
}
|
|
93
|
+
for (const entry of now)if (!live.has(entry)) live.set(entry, registerTestTarget(entry.id, anchorTarget(entry)));
|
|
94
|
+
};
|
|
95
|
+
sync();
|
|
96
|
+
const unsubscribe = registry.subscribe(sync);
|
|
97
|
+
return ()=>{
|
|
98
|
+
unsubscribe();
|
|
99
|
+
for (const off of live.values())off();
|
|
100
|
+
live.clear();
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
export { anchorTarget, mirrorAnchors };
|
package/dist/bridge.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../src/bridge.tsx"],"names":[],"mappings":"AAsDA,OAAO,EAA2B,KAAK,YAAY,EAAW,MAAM,aAAa,CAAC;AA+HlF,sHAAsH;AACtH,eAAO,MAAM,WAAW,EAAE,YAAqE,CAAC"}
|
package/dist/bridge.jsx
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { PilotError, addGate, emit, installDesign, installLease, installPilotConfig, installStage, onPilotFlag, recordLog, recordNet, registerCommand, registerRecorderCommands, registerStore, registerTraceSection } from "@g9tm/app-pilot";
|
|
2
|
+
import { registerDevtoolCommands } from "@g9tm/app-pilot-devtool";
|
|
3
|
+
import { PilotAnnotations, PilotBadge, PilotInspector, pilotNative, registerInspectorCommands, selfCall, startPilot, startSelfDrive, stopSelfDrive } from "@g9tm/app-pilot-lynx";
|
|
4
|
+
import { g9Popups } from "@g9tm/lynxcontrols/popup";
|
|
5
|
+
import { setG9MotionScale } from "@g9tm/lynxcontrols-foundation/services";
|
|
6
|
+
import { createDesignRegistry } from "@g9tm/lynxcontrols-foundation/theme";
|
|
7
|
+
import { registerG9Commands } from "./commands.jsx";
|
|
8
|
+
import { CONSENT_REQUEST, installConsent } from "./consent.jsx";
|
|
9
|
+
import { ANNOTATE, BADGE, DESIGN, DEVTOOL, EXPLORE, INSPECTOR, LEASE, PERF, RECORDER, SCREEN, SELF_DRIVE, SETTINGS, STAGE, UI } from "./flags.jsx";
|
|
10
|
+
import { textFor } from "./host-core.jsx";
|
|
11
|
+
import { installMasking } from "./mask.jsx";
|
|
12
|
+
import { aroundRequest } from "./net.jsx";
|
|
13
|
+
import { installSession } from "./session.jsx";
|
|
14
|
+
import { installScreen, installWatch } from "./watch.jsx";
|
|
15
|
+
function install(ctx) {
|
|
16
|
+
var _ctx_props_commands, _ctx_props;
|
|
17
|
+
const offs = [
|
|
18
|
+
installWatch(ctx)
|
|
19
|
+
];
|
|
20
|
+
if (UI && !SCREEN) offs.push(installScreen(ctx));
|
|
21
|
+
if ('none' !== SETTINGS.consent) {
|
|
22
|
+
var _ctx_props_askConsent;
|
|
23
|
+
const ask = null != (_ctx_props_askConsent = ctx.props().askConsent) ? _ctx_props_askConsent : ({ kid: id, reading, reason })=>{
|
|
24
|
+
const lang = ctx.language();
|
|
25
|
+
const kid = id || textFor(lang, 'کنترلکنندهٔ بینام', 'an unnamed controller');
|
|
26
|
+
const ask = reading ? textFor(lang, `«${kid}» میخواهد صفحهٔ شما را ببیند.`, `"${kid}" asks to see your screen.`) : textFor(lang, `«${kid}» میخواهد برنامه را برای شما هدایت کند.`, `"${kid}" asks to operate the app for you.`);
|
|
27
|
+
const words = reason ? textFor(lang, `\nبه گفتهٔ خودش: «${reason}»`, `\nIn its words: "${reason}"`) : '';
|
|
28
|
+
return g9Popups().showConfirm(ask + words, {
|
|
29
|
+
title: textFor(lang, 'کمک از راه دور', 'Remote help'),
|
|
30
|
+
okText: textFor(lang, 'اجازه میدهم', 'Allow'),
|
|
31
|
+
cancelText: textFor(lang, 'نه', 'Deny')
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const consent = installConsent({
|
|
35
|
+
mode: SETTINGS.consent,
|
|
36
|
+
ask,
|
|
37
|
+
maxMinutes: SETTINGS.session.maxMinutes,
|
|
38
|
+
onChange: (mode, kids)=>{
|
|
39
|
+
var _pilotNative_admit, _pilotNative;
|
|
40
|
+
return null == (_pilotNative = pilotNative()) ? void 0 : null == (_pilotNative_admit = _pilotNative.admit) ? void 0 : _pilotNative_admit.call(_pilotNative, JSON.stringify({
|
|
41
|
+
mode,
|
|
42
|
+
kids
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
offs.push(consent.remove);
|
|
47
|
+
offs.push(registerCommand('g9.consent', ()=>({
|
|
48
|
+
mode: SETTINGS.consent,
|
|
49
|
+
granted: consent.granted()
|
|
50
|
+
}), {
|
|
51
|
+
scope: 'observe',
|
|
52
|
+
description: 'The consent mode and which controllers the person on the device accepted, and since when.'
|
|
53
|
+
}));
|
|
54
|
+
offs.push(registerCommand(CONSENT_REQUEST, async (args, c)=>{
|
|
55
|
+
var _c_kid;
|
|
56
|
+
return consent.request(null != (_c_kid = c.kid) ? _c_kid : '', {
|
|
57
|
+
reading: true === args.reading,
|
|
58
|
+
...'string' == typeof args.reason ? {
|
|
59
|
+
reason: args.reason
|
|
60
|
+
} : {},
|
|
61
|
+
waitMs: Math.min('number' == typeof args.waitMs ? args.waitMs : 60000, c.timeoutMs - 500)
|
|
62
|
+
});
|
|
63
|
+
}, {
|
|
64
|
+
scope: 'observe',
|
|
65
|
+
mutating: false,
|
|
66
|
+
description: 'Asks the person on the device to accept this controller before its first change (args: reason, reading, waitMs). Answers {granted, pending}.',
|
|
67
|
+
example: {
|
|
68
|
+
reason: 'To reproduce the checkout problem you reported',
|
|
69
|
+
waitMs: 30000
|
|
70
|
+
}
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
offs.push(installSession());
|
|
74
|
+
offs.push(installPilotConfig({
|
|
75
|
+
badge: {
|
|
76
|
+
mode: SETTINGS.badge
|
|
77
|
+
}
|
|
78
|
+
}));
|
|
79
|
+
if ('secret' === SETTINGS.mask) offs.push(installMasking());
|
|
80
|
+
if (LEASE) offs.push(installLease());
|
|
81
|
+
if (RECORDER) offs.push(registerRecorderCommands());
|
|
82
|
+
if (STAGE) {
|
|
83
|
+
offs.push(installStage());
|
|
84
|
+
offs.push(onPilotFlag('reduceMotion', (on)=>setG9MotionScale(on ? 0 : 1)));
|
|
85
|
+
}
|
|
86
|
+
if (DESIGN) offs.push(installDesign(createDesignRegistry({
|
|
87
|
+
theme: ctx.core.themeStore,
|
|
88
|
+
shape: ctx.core.shape
|
|
89
|
+
})));
|
|
90
|
+
if (INSPECTOR) offs.push(registerInspectorCommands());
|
|
91
|
+
if (DEVTOOL) offs.push(registerDevtoolCommands());
|
|
92
|
+
offs.push(registerG9Commands({
|
|
93
|
+
core: ctx.core,
|
|
94
|
+
router: ctx.router,
|
|
95
|
+
language: ctx.language,
|
|
96
|
+
element: (id)=>{
|
|
97
|
+
var _ref;
|
|
98
|
+
var _lynx_getElementById, _lynx;
|
|
99
|
+
return "u" < typeof lynx ? null : null != (_ref = null == (_lynx_getElementById = (_lynx = lynx).getElementById) ? void 0 : _lynx_getElementById.call(_lynx, id)) ? _ref : null;
|
|
100
|
+
}
|
|
101
|
+
}, {
|
|
102
|
+
perf: PERF,
|
|
103
|
+
explore: EXPLORE
|
|
104
|
+
}));
|
|
105
|
+
const own = null == (_ctx_props_commands = (_ctx_props = ctx.props()).commands) ? void 0 : _ctx_props_commands.call(_ctx_props, {
|
|
106
|
+
registerCommand: registerCommand,
|
|
107
|
+
emit: emit,
|
|
108
|
+
PilotError: PilotError,
|
|
109
|
+
addGate: addGate,
|
|
110
|
+
onPilotFlag: onPilotFlag,
|
|
111
|
+
recordLog: recordLog,
|
|
112
|
+
recordNet: recordNet,
|
|
113
|
+
registerStore: registerStore,
|
|
114
|
+
registerTraceSection: registerTraceSection,
|
|
115
|
+
aroundRequest: aroundRequest,
|
|
116
|
+
selfDrive: SELF_DRIVE ? {
|
|
117
|
+
start: startSelfDrive,
|
|
118
|
+
call: selfCall,
|
|
119
|
+
stop: stopSelfDrive
|
|
120
|
+
} : null
|
|
121
|
+
});
|
|
122
|
+
if (own) offs.push(own);
|
|
123
|
+
startPilot();
|
|
124
|
+
return ()=>{
|
|
125
|
+
for (const off of offs.reverse())off();
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
function overlays(props, language) {
|
|
129
|
+
var _props_badgeLabel;
|
|
130
|
+
return <>
|
|
131
|
+
{ANNOTATE ? <PilotAnnotations/> : null}
|
|
132
|
+
{INSPECTOR ? <PilotInspector/> : null}
|
|
133
|
+
{BADGE ? <PilotBadge label={null != (_props_badgeLabel = props.badgeLabel) ? _props_badgeLabel : textFor(language, '● کنترل خودکار', '● Automated')}/> : null}
|
|
134
|
+
</>;
|
|
135
|
+
}
|
|
136
|
+
const bridgeLevel = {
|
|
137
|
+
install,
|
|
138
|
+
overlays,
|
|
139
|
+
testIds: {
|
|
140
|
+
confirmTouches: UI
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
export { bridgeLevel };
|
package/dist/busy.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { LynxControlsKit } from './kit.js';
|
|
2
|
+
/** The hook for [kit] (made once, at module level: `export const useHostBusyTracking = lynxControlsBusyHook(kit)`). */
|
|
3
|
+
export declare function lynxControlsBusyHook(kit: LynxControlsKit): () => void;
|
|
4
|
+
//# sourceMappingURL=busy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"busy.d.ts","sourceRoot":"","sources":["../src/busy.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE7C,uHAAuH;AACvH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,eAAe,GAAG,MAAM,IAAI,CAsCrE"}
|
package/dist/busy.jsx
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { beginBusy } from "@g9tm/app-pilot";
|
|
2
|
+
import { useEffect } from "@lynx-js/react";
|
|
3
|
+
function lynxControlsBusyHook(kit) {
|
|
4
|
+
return function() {
|
|
5
|
+
const sheets = kit.sheet.useG9Sheets();
|
|
6
|
+
const popups = kit.popup.useG9Popups();
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
let endSheet = null;
|
|
9
|
+
let endPopup = null;
|
|
10
|
+
const syncSheets = ()=>{
|
|
11
|
+
const moving = sheets.stack.getSnapshot().find((e)=>'opening' === e.status || 'closing' === e.status || 'queued' === e.status);
|
|
12
|
+
if (moving && !endSheet) endSheet = beginBusy('closing' === moving.status ? 'ui:sheet:close' : 'ui:sheet:open');
|
|
13
|
+
if (!moving && endSheet) {
|
|
14
|
+
endSheet();
|
|
15
|
+
endSheet = null;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const syncPopups = ()=>{
|
|
19
|
+
const entry = popups.queue.getSnapshot();
|
|
20
|
+
const moving = entry && ('opening' === entry.phase || 'closing' === entry.phase || 'queued' === entry.phase);
|
|
21
|
+
if (moving && !endPopup) endPopup = beginBusy('ui:popup');
|
|
22
|
+
if (!moving && endPopup) {
|
|
23
|
+
endPopup();
|
|
24
|
+
endPopup = null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const offSheets = sheets.stack.subscribe(syncSheets);
|
|
28
|
+
const offPopups = popups.queue.subscribe(syncPopups);
|
|
29
|
+
syncSheets();
|
|
30
|
+
syncPopups();
|
|
31
|
+
return ()=>{
|
|
32
|
+
offSheets();
|
|
33
|
+
offPopups();
|
|
34
|
+
null == endSheet || endSheet();
|
|
35
|
+
null == endPopup || endPopup();
|
|
36
|
+
};
|
|
37
|
+
}, [
|
|
38
|
+
sheets,
|
|
39
|
+
popups
|
|
40
|
+
]);
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export { lynxControlsBusyHook };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { G9ProviderCore } from '@g9tm/lynxcontrols/provider';
|
|
2
|
+
import type { G9Router } from '@g9tm/lynxcontrols/route';
|
|
3
|
+
/** What the commands read; the host component hands it over (and tests hand fakes). */
|
|
4
|
+
export interface G9PilotCommandContext {
|
|
5
|
+
readonly core: Pick<G9ProviderCore, 'themeStore' | 'rootId'> & Partial<Pick<G9ProviderCore, 'anchors'>>;
|
|
6
|
+
/** The culture's language (the sample a field is filled with). */
|
|
7
|
+
readonly language?: () => string;
|
|
8
|
+
router(): G9Router | null;
|
|
9
|
+
/** The page's element API (`lynx.getElementById`), for the variable profile. */
|
|
10
|
+
readonly element?: (id: string) => {
|
|
11
|
+
setProperty(v: Record<string, string>): void;
|
|
12
|
+
} | null;
|
|
13
|
+
/** The next frame (tests pass an immediate one). */
|
|
14
|
+
readonly frame?: () => Promise<void>;
|
|
15
|
+
readonly now?: () => number;
|
|
16
|
+
}
|
|
17
|
+
/** The singleton kinds a router can open by itself, with their made-up ancestors: what g9.explore visits. */
|
|
18
|
+
export declare function explorablePlaces(router: G9Router): readonly string[];
|
|
19
|
+
/** Registers the g9.* commands; returns the uninstaller. `perf` and `explore` follow the build's modules. */
|
|
20
|
+
export declare function registerG9Commands(ctx: G9PilotCommandContext, modules: {
|
|
21
|
+
readonly perf: boolean;
|
|
22
|
+
readonly explore: boolean;
|
|
23
|
+
}): () => void;
|
|
24
|
+
//# sourceMappingURL=commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"commands.d.ts","sourceRoot":"","sources":["../src/commands.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAOzD,uFAAuF;AACvF,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,cAAc,EAAE,YAAY,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,CAAC;IACxG,kEAAkE;IAClE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,MAAM,CAAC;IACjC,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC;IAC1B,gFAAgF;IAChF,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK;QAAE,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IAC3F,oDAAoD;IACpD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC7B;AAmBD,6GAA6G;AAC7G,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,MAAM,EAAE,CAWpE;AAKD,6GAA6G;AAC7G,wBAAgB,kBAAkB,CAChC,GAAG,EAAE,qBAAqB,EAC1B,OAAO,EAAE;IAAE,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GAC7D,MAAM,IAAI,CAgOZ"}
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { PilotError, dispatch, optionalInt, optionalString, registerCommand, requireString, waitIdle } from "@g9tm/app-pilot";
|
|
2
|
+
import { formatAddress, parseAddress } from "@g9tm/lynxcontrols-foundation/route";
|
|
3
|
+
import { toCssVariables } from "@g9tm/lynxcontrols-foundation/tokens";
|
|
4
|
+
import { options } from "@lynx-js/react/internal";
|
|
5
|
+
import { controlsOnScreen, safeActions } from "./explore.jsx";
|
|
6
|
+
import { PROFILE, SETTINGS, pilotModules } from "./flags.jsx";
|
|
7
|
+
const defaultFrame = ()=>new Promise((r)=>'function' == typeof requestAnimationFrame ? requestAnimationFrame(()=>r()) : setTimeout(r, 16));
|
|
8
|
+
const defaultNow = ()=>"u" > typeof performance && performance.now ? performance.now() : Date.now();
|
|
9
|
+
function needRouter(ctx) {
|
|
10
|
+
const router = ctx.router();
|
|
11
|
+
if (!router) throw new PilotError('This app has no G9 router (G9Provider without `router`).', {
|
|
12
|
+
code: 'UNSUPPORTED',
|
|
13
|
+
category: 'automation',
|
|
14
|
+
hint: 'Give G9Provider a router (createG9Router) to use g9.where / g9.go / g9.explore.'
|
|
15
|
+
});
|
|
16
|
+
return router;
|
|
17
|
+
}
|
|
18
|
+
function explorablePlaces(router) {
|
|
19
|
+
const cat = router.catalogue;
|
|
20
|
+
const out = [];
|
|
21
|
+
for (const kind of cat.kinds()){
|
|
22
|
+
const def = cat.def(kind);
|
|
23
|
+
if (!def || def.id || def.variants || !def.open) continue;
|
|
24
|
+
const ancestors = cat.defaultAncestors(kind);
|
|
25
|
+
if (ancestors) out.push(formatAddress([
|
|
26
|
+
...ancestors,
|
|
27
|
+
{
|
|
28
|
+
kind
|
|
29
|
+
}
|
|
30
|
+
]));
|
|
31
|
+
}
|
|
32
|
+
return out;
|
|
33
|
+
}
|
|
34
|
+
const local = (command, args = {})=>dispatch({
|
|
35
|
+
id: `g9.${command}.${Date.now()}`,
|
|
36
|
+
command,
|
|
37
|
+
args,
|
|
38
|
+
kid: 'self-g9.explore',
|
|
39
|
+
scopes: [
|
|
40
|
+
'*'
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
function registerG9Commands(ctx, modules) {
|
|
44
|
+
var _ctx_frame, _ctx_now;
|
|
45
|
+
const frame = null != (_ctx_frame = ctx.frame) ? _ctx_frame : defaultFrame;
|
|
46
|
+
const now = null != (_ctx_now = ctx.now) ? _ctx_now : defaultNow;
|
|
47
|
+
const offs = [
|
|
48
|
+
registerCommand('g9.pilot', ()=>({
|
|
49
|
+
profile: PROFILE,
|
|
50
|
+
modules: pilotModules(),
|
|
51
|
+
settings: SETTINGS
|
|
52
|
+
}), {
|
|
53
|
+
scope: 'observe',
|
|
54
|
+
description: 'What this build carries of G9AppPilot: profile, modules and settings.'
|
|
55
|
+
}),
|
|
56
|
+
registerCommand('g9.where', ()=>needRouter(ctx).where(), {
|
|
57
|
+
scope: 'observe',
|
|
58
|
+
description: "Where the app is: the G9 router's unique and general address, breadcrumbs, open places."
|
|
59
|
+
}),
|
|
60
|
+
registerCommand('g9.go', async (args)=>{
|
|
61
|
+
const address = requireString(args, 'address');
|
|
62
|
+
const result = await needRouter(ctx).go(parseAddress(address));
|
|
63
|
+
return result;
|
|
64
|
+
}, {
|
|
65
|
+
scope: 'drive',
|
|
66
|
+
description: 'Opens an address the way the UI does (the G9 router), waiting for every place to declare itself.',
|
|
67
|
+
example: {
|
|
68
|
+
address: '/settings'
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
registerCommand('g9.places', ()=>{
|
|
72
|
+
const router = needRouter(ctx);
|
|
73
|
+
const cat = router.catalogue;
|
|
74
|
+
const reachable = new Set(explorablePlaces(router));
|
|
75
|
+
return cat.kinds().map((kind)=>{
|
|
76
|
+
var _ref;
|
|
77
|
+
const def = cat.def(kind);
|
|
78
|
+
const ancestors = cat.defaultAncestors(kind);
|
|
79
|
+
const address = ancestors ? formatAddress([
|
|
80
|
+
...ancestors,
|
|
81
|
+
{
|
|
82
|
+
kind
|
|
83
|
+
}
|
|
84
|
+
]) : null;
|
|
85
|
+
return {
|
|
86
|
+
kind,
|
|
87
|
+
describe: null != (_ref = null == def ? void 0 : def.describe) ? _ref : null,
|
|
88
|
+
needsId: !!(null == def ? void 0 : def.id),
|
|
89
|
+
opensByItself: null !== address && reachable.has(address),
|
|
90
|
+
address
|
|
91
|
+
};
|
|
92
|
+
});
|
|
93
|
+
}, {
|
|
94
|
+
scope: 'observe',
|
|
95
|
+
description: "The router's catalogue: every kind, what it is, whether g9.explore can open it."
|
|
96
|
+
})
|
|
97
|
+
];
|
|
98
|
+
if (modules.explore) offs.push(registerCommand('g9.explore', async (args)=>{
|
|
99
|
+
var _optionalString, _ctx_core_anchors, _before_result_last, _after_result_violations;
|
|
100
|
+
const router = needRouter(ctx);
|
|
101
|
+
const only = null != (_optionalString = optionalString(args, 'prefix')) ? _optionalString : '';
|
|
102
|
+
const max = optionalInt(args, 'maxPlaces', 40);
|
|
103
|
+
const settleMs = optionalInt(args, 'settleMs', 4000);
|
|
104
|
+
const safe = 'safe' === optionalString(args, 'actions');
|
|
105
|
+
const anchors = null != (_ctx_core_anchors = ctx.core.anchors) ? _ctx_core_anchors : null;
|
|
106
|
+
const start = router.where().unique;
|
|
107
|
+
const places = explorablePlaces(router).filter((a)=>a.startsWith(only)).slice(0, max);
|
|
108
|
+
const before = await local('oracle.list');
|
|
109
|
+
const seenBefore = before.ok ? null != (_before_result_last = before.result.last) ? _before_result_last : 0 : 0;
|
|
110
|
+
const visits = [];
|
|
111
|
+
for (const address of places){
|
|
112
|
+
var _ref, _snap_result_count;
|
|
113
|
+
var _ctx_language;
|
|
114
|
+
const t0 = now();
|
|
115
|
+
const gone = await router.go(parseAddress(address)).catch((e)=>({
|
|
116
|
+
ok: false,
|
|
117
|
+
error: String(e)
|
|
118
|
+
}));
|
|
119
|
+
await waitIdle(300, settleMs).catch(()=>void 0);
|
|
120
|
+
const check = await local('oracle.check');
|
|
121
|
+
const snap = await local('ui.snapshot', {
|
|
122
|
+
maxNodes: 400
|
|
123
|
+
});
|
|
124
|
+
const opened = false !== gone.ok;
|
|
125
|
+
const flow = [
|
|
126
|
+
{
|
|
127
|
+
command: 'g9.go',
|
|
128
|
+
args: {
|
|
129
|
+
address
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
];
|
|
133
|
+
const acted = safe && opened && anchors ? await safeActions(anchors, {
|
|
134
|
+
language: null != (_ref = null == (_ctx_language = ctx.language) ? void 0 : _ctx_language.call(ctx)) ? _ref : 'en',
|
|
135
|
+
check: async ()=>{
|
|
136
|
+
await waitIdle(100, settleMs).catch(()=>void 0);
|
|
137
|
+
await local('oracle.check');
|
|
138
|
+
}
|
|
139
|
+
}) : null;
|
|
140
|
+
if (acted) flow.push(...acted.flow);
|
|
141
|
+
visits.push({
|
|
142
|
+
address,
|
|
143
|
+
opened,
|
|
144
|
+
ms: Math.round(now() - t0),
|
|
145
|
+
controls: snap.ok ? null != (_snap_result_count = snap.result.count) ? _snap_result_count : null : null,
|
|
146
|
+
checked: check.ok,
|
|
147
|
+
...anchors ? {
|
|
148
|
+
list: controlsOnScreen(anchors)
|
|
149
|
+
} : {},
|
|
150
|
+
...acted ? {
|
|
151
|
+
actions: acted.actions
|
|
152
|
+
} : {},
|
|
153
|
+
flow
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
await router.go(parseAddress(start)).catch(()=>void 0);
|
|
157
|
+
const after = await local('oracle.list', {
|
|
158
|
+
since: seenBefore
|
|
159
|
+
});
|
|
160
|
+
return {
|
|
161
|
+
visited: visits.length,
|
|
162
|
+
visits,
|
|
163
|
+
findings: after.ok ? null != (_after_result_violations = after.result.violations) ? _after_result_violations : [] : [],
|
|
164
|
+
back: start
|
|
165
|
+
};
|
|
166
|
+
}, {
|
|
167
|
+
scope: 'drive',
|
|
168
|
+
description: 'Opens every place that opens by itself (no id) in turn, lets it settle, runs the oracles on it, lists its controls and comes back. With actions: "safe" it also opens each tab and expander and fills each field with a sample (then restores it) — never a button, a toggle, a secret or a risky control. Each visit carries a replayable flow.',
|
|
169
|
+
example: {
|
|
170
|
+
prefix: '',
|
|
171
|
+
maxPlaces: 40,
|
|
172
|
+
actions: 'safe'
|
|
173
|
+
}
|
|
174
|
+
}));
|
|
175
|
+
if (modules.perf) offs.push(registerCommand('g9.renders', async (args)=>{
|
|
176
|
+
var _optionalString;
|
|
177
|
+
const what = null != (_optionalString = optionalString(args, 'action')) ? _optionalString : 'mode';
|
|
178
|
+
const counts = new Map();
|
|
179
|
+
const hooks = options;
|
|
180
|
+
const prev = hooks.diffed;
|
|
181
|
+
await frame();
|
|
182
|
+
hooks.diffed = (vnode)=>{
|
|
183
|
+
const type = vnode.type;
|
|
184
|
+
if ('string' != typeof type) {
|
|
185
|
+
var _counts_get;
|
|
186
|
+
const name = type.displayName || type.name || 'anonymous';
|
|
187
|
+
counts.set(name, (null != (_counts_get = counts.get(name)) ? _counts_get : 0) + 1);
|
|
188
|
+
}
|
|
189
|
+
null == prev || prev(vnode);
|
|
190
|
+
};
|
|
191
|
+
try {
|
|
192
|
+
const theme = ctx.core.themeStore;
|
|
193
|
+
if ('mode' === what) theme.setMode('dark' === theme.getSnapshot().scheme ? 'light' : 'dark');
|
|
194
|
+
else if ('wait' === what) await new Promise((r)=>setTimeout(r, optionalInt(args, 'ms', 3000)));
|
|
195
|
+
else throw new PilotError(`Unknown action "${what}".`, {
|
|
196
|
+
code: 'BAD_ARGS',
|
|
197
|
+
hint: 'action: mode | wait'
|
|
198
|
+
});
|
|
199
|
+
await frame();
|
|
200
|
+
await frame();
|
|
201
|
+
} finally{
|
|
202
|
+
hooks.diffed = prev;
|
|
203
|
+
}
|
|
204
|
+
const top = [
|
|
205
|
+
...counts.entries()
|
|
206
|
+
].sort((a, b)=>b[1] - a[1]).slice(0, 30);
|
|
207
|
+
return {
|
|
208
|
+
total: [
|
|
209
|
+
...counts.values()
|
|
210
|
+
].reduce((a, b)=>a + b, 0),
|
|
211
|
+
top
|
|
212
|
+
};
|
|
213
|
+
}, {
|
|
214
|
+
scope: 'observe',
|
|
215
|
+
mutating: true,
|
|
216
|
+
description: 'Which components render (counted by name) for one action: mode = a light/dark switch, wait = whatever happens meanwhile.',
|
|
217
|
+
example: {
|
|
218
|
+
action: 'mode'
|
|
219
|
+
}
|
|
220
|
+
}), registerCommand('g9.profileTheme', async ()=>{
|
|
221
|
+
const theme = ctx.core.themeStore;
|
|
222
|
+
const start = theme.getSnapshot().scheme;
|
|
223
|
+
const runs = [];
|
|
224
|
+
for(let i = 0; i < 4; i++){
|
|
225
|
+
await frame();
|
|
226
|
+
const s0 = now();
|
|
227
|
+
theme.setMode(i % 2 ? 'light' : 'dark');
|
|
228
|
+
const sync = now() - s0;
|
|
229
|
+
await frame();
|
|
230
|
+
await frame();
|
|
231
|
+
runs.push([
|
|
232
|
+
Math.round(sync),
|
|
233
|
+
Math.round(now() - s0)
|
|
234
|
+
]);
|
|
235
|
+
}
|
|
236
|
+
theme.setMode('dark' === start ? 'dark' : 'light');
|
|
237
|
+
return {
|
|
238
|
+
modeSyncAndFrame: runs
|
|
239
|
+
};
|
|
240
|
+
}, {
|
|
241
|
+
scope: 'observe',
|
|
242
|
+
mutating: true,
|
|
243
|
+
description: 'A light/dark switch four times: [synchronous ms, ms to the second frame] each.'
|
|
244
|
+
}), registerCommand('g9.profileVars', async ()=>{
|
|
245
|
+
var _ref;
|
|
246
|
+
var _ctx_element;
|
|
247
|
+
const root = null != (_ref = null == (_ctx_element = ctx.element) ? void 0 : _ctx_element.call(ctx, ctx.core.rootId)) ? _ref : null;
|
|
248
|
+
if (!root) throw new PilotError('No element API for the provider root.', {
|
|
249
|
+
code: 'UNSUPPORTED',
|
|
250
|
+
category: 'automation'
|
|
251
|
+
});
|
|
252
|
+
const names = Object.keys(toCssVariables(ctx.core.themeStore.getSnapshot())).filter((k)=>k.startsWith('--g9-'));
|
|
253
|
+
const out = {};
|
|
254
|
+
for (const n of [
|
|
255
|
+
1,
|
|
256
|
+
10,
|
|
257
|
+
names.length
|
|
258
|
+
]){
|
|
259
|
+
const runs = [];
|
|
260
|
+
for(let i = 0; i < 3; i++){
|
|
261
|
+
const v = {};
|
|
262
|
+
for (const k of names.slice(0, n))v[k] = i % 2 ? '#123456' : '#654321';
|
|
263
|
+
await frame();
|
|
264
|
+
const s0 = now();
|
|
265
|
+
root.setProperty(v);
|
|
266
|
+
await frame();
|
|
267
|
+
await frame();
|
|
268
|
+
runs.push(Math.round(now() - s0));
|
|
269
|
+
}
|
|
270
|
+
out[String(n)] = runs;
|
|
271
|
+
}
|
|
272
|
+
root.setProperty(toCssVariables(ctx.core.themeStore.getSnapshot()));
|
|
273
|
+
return {
|
|
274
|
+
variables: names.length,
|
|
275
|
+
ms: out
|
|
276
|
+
};
|
|
277
|
+
}, {
|
|
278
|
+
scope: 'observe',
|
|
279
|
+
mutating: true,
|
|
280
|
+
description: "The engine's cost of changing 1, 10 or every colour variable on the provider root, to the next frame."
|
|
281
|
+
}));
|
|
282
|
+
return ()=>{
|
|
283
|
+
for (const off of offs)off();
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
export { explorablePlaces, registerG9Commands };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/** How the person is asked (the host shows a G9 confirm). Resolves whether they accepted. */
|
|
2
|
+
export type G9ConsentAsk = (request: {
|
|
3
|
+
readonly kid: string;
|
|
4
|
+
readonly reading: boolean;
|
|
5
|
+
/** The controller's own words, when it asked up front (g9.consent.request): shown quoted, at most 120 characters. */
|
|
6
|
+
readonly reason?: string;
|
|
7
|
+
}) => Promise<boolean>;
|
|
8
|
+
/** The command a controller sends to ask before its first change; the gate always admits it. */
|
|
9
|
+
export declare const CONSENT_REQUEST = "g9.consent.request";
|
|
10
|
+
export interface G9ConsentOptions {
|
|
11
|
+
readonly mode: 'none' | 'session' | 'escalation';
|
|
12
|
+
readonly ask: G9ConsentAsk;
|
|
13
|
+
readonly maxMinutes?: number;
|
|
14
|
+
readonly now?: () => number;
|
|
15
|
+
/**
|
|
16
|
+
* Told the accepted controllers whenever they change (and once at install): the native bridge's own commands do not
|
|
17
|
+
* pass the page's gates, so the host hands the same decision down to them (`G9Pilot.admit`).
|
|
18
|
+
*/
|
|
19
|
+
readonly onChange?: (mode: G9ConsentOptions['mode'], kids: readonly string[]) => void;
|
|
20
|
+
}
|
|
21
|
+
/** The consent state of this page: the gate, and what the person granted (for `g9.pilot` and tests). */
|
|
22
|
+
export interface G9ConsentGate {
|
|
23
|
+
granted(): ReadonlyArray<{
|
|
24
|
+
readonly kid: string;
|
|
25
|
+
readonly at: number;
|
|
26
|
+
}>;
|
|
27
|
+
/** Forget every grant (the person pressed «stop sharing»). */
|
|
28
|
+
revoke(): void;
|
|
29
|
+
/** The build's mode. */
|
|
30
|
+
readonly mode: G9ConsentOptions['mode'];
|
|
31
|
+
/** Told whenever a grant comes or goes (the panel's list). */
|
|
32
|
+
subscribe(listener: () => void): () => void;
|
|
33
|
+
/**
|
|
34
|
+
* Asks the person for `kid` now (g9.consent.request): resolves `granted` when they accepted (at once when they already
|
|
35
|
+
* had), `pending` when they did not decide within `waitMs` (the prompt stays; the controller asks again later).
|
|
36
|
+
*/
|
|
37
|
+
request(kid: string, options: {
|
|
38
|
+
readonly reading?: boolean;
|
|
39
|
+
readonly reason?: string;
|
|
40
|
+
readonly waitMs: number;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
readonly granted: boolean;
|
|
43
|
+
readonly pending: boolean;
|
|
44
|
+
}>;
|
|
45
|
+
remove(): void;
|
|
46
|
+
}
|
|
47
|
+
/** The consent gate the bridge installed (null: consent `none`, or no bridge): the panel's «stop sharing». */
|
|
48
|
+
export declare function g9PilotConsent(): G9ConsentGate | null;
|
|
49
|
+
/** Installs the consent gate (a no-op gate for `none`). */
|
|
50
|
+
export declare function installConsent(options: G9ConsentOptions): G9ConsentGate;
|
|
51
|
+
//# sourceMappingURL=consent.d.ts.map
|