@g9tm/lynxcontrols-pilot 0.0.0-stage → 2.4.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/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
|
@@ -0,0 +1 @@
|
|
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AE;QAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;KAAE,GACzF,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC,CAAC;IACrE,MAAM,IAAI,IAAI,CAAC;CAChB;AAID,8GAA8G;AAC9G,wBAAgB,cAAc,IAAI,aAAa,GAAG,IAAI,CAErD;AAED,2DAA2D;AAC3D,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,aAAa,CA8FvE"}
|
package/dist/consent.jsx
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { addGate, isPureRead } from "@g9tm/app-pilot";
|
|
2
|
+
const CONSENT_REQUEST = 'g9.consent.request';
|
|
3
|
+
const refusal = (message, hint)=>({
|
|
4
|
+
ok: false,
|
|
5
|
+
error: message,
|
|
6
|
+
code: 'CONSENT',
|
|
7
|
+
category: 'automation',
|
|
8
|
+
hint
|
|
9
|
+
});
|
|
10
|
+
let current = null;
|
|
11
|
+
function g9PilotConsent() {
|
|
12
|
+
return current;
|
|
13
|
+
}
|
|
14
|
+
function installConsent(options) {
|
|
15
|
+
var _options_now, _options_maxMinutes;
|
|
16
|
+
const now = null != (_options_now = options.now) ? _options_now : Date.now;
|
|
17
|
+
const grants = new Map();
|
|
18
|
+
const asking = new Map();
|
|
19
|
+
const ttl = (null != (_options_maxMinutes = options.maxMinutes) ? _options_maxMinutes : 0) * 60000;
|
|
20
|
+
const listeners = new Set();
|
|
21
|
+
const changed = ()=>{
|
|
22
|
+
var _options_onChange;
|
|
23
|
+
null == (_options_onChange = options.onChange) || _options_onChange.call(options, options.mode, [
|
|
24
|
+
...grants.keys()
|
|
25
|
+
]);
|
|
26
|
+
for (const l of [
|
|
27
|
+
...listeners
|
|
28
|
+
])l();
|
|
29
|
+
};
|
|
30
|
+
const live = (kid)=>{
|
|
31
|
+
const g = grants.get(kid);
|
|
32
|
+
if (!g) return null;
|
|
33
|
+
if (ttl > 0 && now() - g.at > ttl) {
|
|
34
|
+
grants.delete(kid);
|
|
35
|
+
changed();
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
return g;
|
|
39
|
+
};
|
|
40
|
+
const askOnce = (kid, reading, reason)=>{
|
|
41
|
+
let pending = asking.get(kid);
|
|
42
|
+
if (!pending) {
|
|
43
|
+
const words = null == reason ? void 0 : reason.trim().slice(0, 120);
|
|
44
|
+
pending = options.ask(words ? {
|
|
45
|
+
kid,
|
|
46
|
+
reading,
|
|
47
|
+
reason: words
|
|
48
|
+
} : {
|
|
49
|
+
kid,
|
|
50
|
+
reading
|
|
51
|
+
}).catch(()=>false).then((yes)=>{
|
|
52
|
+
asking.delete(kid);
|
|
53
|
+
if (yes) {
|
|
54
|
+
grants.set(kid, {
|
|
55
|
+
at: now()
|
|
56
|
+
});
|
|
57
|
+
changed();
|
|
58
|
+
}
|
|
59
|
+
return yes;
|
|
60
|
+
});
|
|
61
|
+
asking.set(kid, pending);
|
|
62
|
+
}
|
|
63
|
+
return pending;
|
|
64
|
+
};
|
|
65
|
+
const gate = (request)=>{
|
|
66
|
+
var _request_kid;
|
|
67
|
+
if ('none' === options.mode) return null;
|
|
68
|
+
const kid = null != (_request_kid = request.kid) ? _request_kid : '';
|
|
69
|
+
if (kid.startsWith('self-') || request.command === CONSENT_REQUEST) return null;
|
|
70
|
+
const reading = isPureRead(request.command);
|
|
71
|
+
if ('escalation' === options.mode && reading) return null;
|
|
72
|
+
if (live(kid)) return null;
|
|
73
|
+
askOnce(kid, reading);
|
|
74
|
+
return refusal(`The person on this device has not accepted remote ${reading ? 'viewing' : 'control'} by "${kid}" yet.`, 'A consent prompt is on the screen: repeat the command once the person accepted (g9.pilot shows the grants).');
|
|
75
|
+
};
|
|
76
|
+
const removeGate = addGate((request)=>gate(request));
|
|
77
|
+
changed();
|
|
78
|
+
const handle = {
|
|
79
|
+
mode: options.mode,
|
|
80
|
+
subscribe (listener) {
|
|
81
|
+
listeners.add(listener);
|
|
82
|
+
return ()=>listeners.delete(listener);
|
|
83
|
+
},
|
|
84
|
+
granted: ()=>[
|
|
85
|
+
...grants.entries()
|
|
86
|
+
].filter(([kid])=>live(kid)).map(([kid, g])=>({
|
|
87
|
+
kid,
|
|
88
|
+
at: g.at
|
|
89
|
+
})),
|
|
90
|
+
revoke () {
|
|
91
|
+
grants.clear();
|
|
92
|
+
changed();
|
|
93
|
+
},
|
|
94
|
+
async request (kid, { reading = false, reason, waitMs }) {
|
|
95
|
+
if ('none' === options.mode || kid.startsWith('self-') || live(kid)) return {
|
|
96
|
+
granted: true,
|
|
97
|
+
pending: false
|
|
98
|
+
};
|
|
99
|
+
if ('escalation' === options.mode && reading) return {
|
|
100
|
+
granted: true,
|
|
101
|
+
pending: false
|
|
102
|
+
};
|
|
103
|
+
let timer;
|
|
104
|
+
const late = new Promise((res)=>{
|
|
105
|
+
timer = setTimeout(()=>res('late'), Math.max(0, waitMs));
|
|
106
|
+
});
|
|
107
|
+
const answer = await Promise.race([
|
|
108
|
+
askOnce(kid, reading, reason),
|
|
109
|
+
late
|
|
110
|
+
]);
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
return 'late' === answer ? {
|
|
113
|
+
granted: false,
|
|
114
|
+
pending: true
|
|
115
|
+
} : {
|
|
116
|
+
granted: answer,
|
|
117
|
+
pending: false
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
remove () {
|
|
121
|
+
var _options_onChange;
|
|
122
|
+
removeGate();
|
|
123
|
+
listeners.clear();
|
|
124
|
+
if (current === handle) current = null;
|
|
125
|
+
null == (_options_onChange = options.onChange) || _options_onChange.call(options, options.mode, []);
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
current = handle;
|
|
129
|
+
return handle;
|
|
130
|
+
}
|
|
131
|
+
export { CONSENT_REQUEST, g9PilotConsent, installConsent };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { G9AnchorRegistry } from '@g9tm/lynxcontrols/anchor';
|
|
2
|
+
/** One control of a place, as g9.explore lists it. */
|
|
3
|
+
export interface G9ExploredControl {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
readonly risk: string;
|
|
7
|
+
}
|
|
8
|
+
/** One safe action g9.explore took. */
|
|
9
|
+
export interface G9ExploreAction {
|
|
10
|
+
readonly id: string;
|
|
11
|
+
readonly action: 'tab' | 'expand' | 'fill';
|
|
12
|
+
readonly ok: boolean;
|
|
13
|
+
readonly error?: string;
|
|
14
|
+
}
|
|
15
|
+
/** One replayable step (a runner sends these as commands). */
|
|
16
|
+
export interface G9FlowStep {
|
|
17
|
+
readonly command: string;
|
|
18
|
+
readonly args: Readonly<Record<string, unknown>>;
|
|
19
|
+
}
|
|
20
|
+
/** The controls on screen now (shown, not virtual), newest id once: what a place holds. */
|
|
21
|
+
export declare function controlsOnScreen(anchors: Pick<G9AnchorRegistry, 'all'>, limit?: number): G9ExploredControl[];
|
|
22
|
+
/** A sample a field accepts, in the culture's language (fields keep ASCII digits and draw the culture's). */
|
|
23
|
+
export declare const sampleFor: (language: string) => string;
|
|
24
|
+
/**
|
|
25
|
+
* The safe actions on the controls on screen, each followed by `check` (the oracles); → what it did and the flow that
|
|
26
|
+
* replays it. `max` bounds the actions per place.
|
|
27
|
+
*/
|
|
28
|
+
export declare function safeActions(anchors: Pick<G9AnchorRegistry, 'all'>, options: {
|
|
29
|
+
readonly language: string;
|
|
30
|
+
readonly check: () => Promise<unknown>;
|
|
31
|
+
readonly max?: number;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
actions: G9ExploreAction[];
|
|
34
|
+
flow: G9FlowStep[];
|
|
35
|
+
}>;
|
|
36
|
+
//# sourceMappingURL=explore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"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AO,CAAC;IAAE,OAAO,EAAE,eAAe,EAAE,CAAC;IAAC,IAAI,EAAE,UAAU,EAAE,CAAA;CAAE,CAAC,CA+C7D"}
|
package/dist/explore.jsx
ADDED
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const shown = (a)=>{
|
|
2
|
+
var _a_binding_shown, _a_binding;
|
|
3
|
+
return (null == (_a_binding_shown = (_a_binding = a.binding).shown) ? void 0 : _a_binding_shown.call(_a_binding)) !== false && !a.virtual;
|
|
4
|
+
};
|
|
5
|
+
const enabled = (a)=>{
|
|
6
|
+
try {
|
|
7
|
+
var _a_info_enabled, _a_info;
|
|
8
|
+
return (null == (_a_info_enabled = (_a_info = a.info()).enabled) ? void 0 : _a_info_enabled.call(_a_info)) !== false;
|
|
9
|
+
} catch {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
function controlsOnScreen(anchors, limit = 80) {
|
|
14
|
+
const seen = new Set();
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const a of [
|
|
17
|
+
...anchors.all()
|
|
18
|
+
].reverse()){
|
|
19
|
+
var _info_risk;
|
|
20
|
+
if (!shown(a) || seen.has(a.id)) continue;
|
|
21
|
+
seen.add(a.id);
|
|
22
|
+
const info = a.info();
|
|
23
|
+
out.push({
|
|
24
|
+
id: a.id,
|
|
25
|
+
kind: info.kind,
|
|
26
|
+
risk: null != (_info_risk = info.risk) ? _info_risk : 'none'
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return out.reverse().slice(0, limit);
|
|
30
|
+
}
|
|
31
|
+
const sampleFor = (language)=>'fa' === language ? 'نمونه 12' : 'Sample 12';
|
|
32
|
+
async function safeActions(anchors, options) {
|
|
33
|
+
var _options_max;
|
|
34
|
+
const actions = [];
|
|
35
|
+
const flow = [];
|
|
36
|
+
const max = null != (_options_max = options.max) ? _options_max : 30;
|
|
37
|
+
const candidates = [
|
|
38
|
+
...anchors.all()
|
|
39
|
+
].filter((a)=>{
|
|
40
|
+
var _a_info_risk;
|
|
41
|
+
return shown(a) && enabled(a) && (null != (_a_info_risk = a.info().risk) ? _a_info_risk : 'none') === 'none';
|
|
42
|
+
});
|
|
43
|
+
const done = new Set();
|
|
44
|
+
for (const a of candidates){
|
|
45
|
+
var _info_capabilities;
|
|
46
|
+
if (actions.length >= max) break;
|
|
47
|
+
if (done.has(a.id)) continue;
|
|
48
|
+
done.add(a.id);
|
|
49
|
+
const info = a.info();
|
|
50
|
+
const caps = null != (_info_capabilities = info.capabilities) ? _info_capabilities : {};
|
|
51
|
+
const act = async (action, run, steps)=>{
|
|
52
|
+
try {
|
|
53
|
+
await run();
|
|
54
|
+
await options.check();
|
|
55
|
+
actions.push({
|
|
56
|
+
id: a.id,
|
|
57
|
+
action,
|
|
58
|
+
ok: true
|
|
59
|
+
});
|
|
60
|
+
flow.push(...steps);
|
|
61
|
+
} catch (e) {
|
|
62
|
+
actions.push({
|
|
63
|
+
id: a.id,
|
|
64
|
+
action,
|
|
65
|
+
ok: false,
|
|
66
|
+
error: e instanceof Error ? e.message : String(e)
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
if ('tab' === info.kind && caps.activate) await act('tab', ()=>{
|
|
71
|
+
var _caps_activate;
|
|
72
|
+
return null == (_caps_activate = caps.activate) ? void 0 : _caps_activate.call(caps);
|
|
73
|
+
}, [
|
|
74
|
+
{
|
|
75
|
+
command: 'ui.tap',
|
|
76
|
+
args: {
|
|
77
|
+
automationId: a.id
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
]);
|
|
81
|
+
else if (caps.expand) await act('expand', async ()=>{
|
|
82
|
+
var _caps_expand, _caps_expand1;
|
|
83
|
+
await (null == (_caps_expand = caps.expand) ? void 0 : _caps_expand.call(caps, true));
|
|
84
|
+
await options.check();
|
|
85
|
+
await (null == (_caps_expand1 = caps.expand) ? void 0 : _caps_expand1.call(caps, false));
|
|
86
|
+
}, [
|
|
87
|
+
{
|
|
88
|
+
command: 'ui.tap',
|
|
89
|
+
args: {
|
|
90
|
+
automationId: a.id
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
command: 'ui.tap',
|
|
95
|
+
args: {
|
|
96
|
+
automationId: a.id
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
]);
|
|
100
|
+
else if ('entry' === info.kind && caps.setValue && !info.secret) {
|
|
101
|
+
var _ref;
|
|
102
|
+
var _caps_getValue;
|
|
103
|
+
const before = null != (_ref = null == (_caps_getValue = caps.getValue) ? void 0 : _caps_getValue.call(caps)) ? _ref : '';
|
|
104
|
+
const sample = sampleFor(options.language);
|
|
105
|
+
await act('fill', async ()=>{
|
|
106
|
+
var _caps_setValue, _caps_setValue1;
|
|
107
|
+
await (null == (_caps_setValue = caps.setValue) ? void 0 : _caps_setValue.call(caps, sample));
|
|
108
|
+
await options.check();
|
|
109
|
+
await (null == (_caps_setValue1 = caps.setValue) ? void 0 : _caps_setValue1.call(caps, before));
|
|
110
|
+
}, [
|
|
111
|
+
{
|
|
112
|
+
command: 'ui.setValue',
|
|
113
|
+
args: {
|
|
114
|
+
automationId: a.id,
|
|
115
|
+
value: sample
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
command: 'ui.setValue',
|
|
120
|
+
args: {
|
|
121
|
+
automationId: a.id,
|
|
122
|
+
value: before
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
actions,
|
|
130
|
+
flow
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
export { controlsOnScreen, safeActions, sampleFor };
|
package/dist/flags.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** The profiles, from nothing to everything (`g9pilot.config.json`). */
|
|
2
|
+
export type G9PilotProfile = 'off' | 'marks' | 'observe' | 'support' | 'full';
|
|
3
|
+
/** What the page needs to know of its build's configuration (the keys stay with the native gate). */
|
|
4
|
+
export interface G9PilotSettings {
|
|
5
|
+
readonly environment: string | null;
|
|
6
|
+
readonly profile: G9PilotProfile;
|
|
7
|
+
readonly distribution: 'store' | 'test';
|
|
8
|
+
readonly badge: 'off' | 'remote' | 'realDeviceOrRemote' | 'always';
|
|
9
|
+
/** none: commands run at once · session: the person accepts once per controller · escalation: watching is free, driving asks. */
|
|
10
|
+
readonly consent: 'none' | 'session' | 'escalation';
|
|
11
|
+
/** secret: the native screenshot blacks out every secret target (password fields, <G9PilotMask>). */
|
|
12
|
+
readonly mask: 'off' | 'secret';
|
|
13
|
+
/** maxMinutes: how long the person's consent lasts (0: until the app stops). */
|
|
14
|
+
readonly session: {
|
|
15
|
+
readonly maxMinutes: number;
|
|
16
|
+
};
|
|
17
|
+
readonly selfDrive: {
|
|
18
|
+
readonly maxSeconds: number;
|
|
19
|
+
};
|
|
20
|
+
readonly observe: {
|
|
21
|
+
readonly rules: Readonly<Record<string, 'off' | 'warn' | 'finding' | 'auto'>>;
|
|
22
|
+
readonly sampling: {
|
|
23
|
+
readonly errors: number;
|
|
24
|
+
readonly vitals: number;
|
|
25
|
+
readonly traces: number;
|
|
26
|
+
};
|
|
27
|
+
readonly buffer: {
|
|
28
|
+
readonly maxFindings: number;
|
|
29
|
+
readonly persist: boolean;
|
|
30
|
+
};
|
|
31
|
+
readonly report: {
|
|
32
|
+
readonly via: 'local' | 'diagnostic' | 'hub' | 'otlp';
|
|
33
|
+
readonly consent: 'build' | 'user' | 'never';
|
|
34
|
+
/** via otlp: the collector's URL (…/v1/logs). */
|
|
35
|
+
readonly endpoint?: string | null;
|
|
36
|
+
/** via otlp: the resource's service.name (default: g9-lynx-app). */
|
|
37
|
+
readonly service?: string | null;
|
|
38
|
+
/** Seconds between automatic reports on a new finding (0: only on request). */
|
|
39
|
+
readonly auto?: number;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
readonly maxScopes: readonly string[];
|
|
43
|
+
}
|
|
44
|
+
/** Every module a profile can carry. */
|
|
45
|
+
export type G9PilotModule = 'marks' | 'oracles' | 'vitals' | 'blackbox' | 'screen' | 'bridge' | 'ui' | 'lease' | 'recorder' | 'stage' | 'design' | 'inspector' | 'annotate' | 'badge' | 'devtool' | 'selfDrive' | 'perf' | 'explore';
|
|
46
|
+
export declare const DEFAULT_SETTINGS: G9PilotSettings;
|
|
47
|
+
export declare const PROFILE: G9PilotProfile;
|
|
48
|
+
export declare const SETTINGS: G9PilotSettings;
|
|
49
|
+
export declare const MARKS: boolean;
|
|
50
|
+
export declare const ORACLES: boolean;
|
|
51
|
+
export declare const VITALS: boolean;
|
|
52
|
+
export declare const BLACKBOX: boolean;
|
|
53
|
+
export declare const SCREEN: boolean;
|
|
54
|
+
export declare const BRIDGE: boolean;
|
|
55
|
+
export declare const UI: boolean;
|
|
56
|
+
export declare const LEASE: boolean;
|
|
57
|
+
export declare const RECORDER: boolean;
|
|
58
|
+
export declare const STAGE: boolean;
|
|
59
|
+
export declare const DESIGN: boolean;
|
|
60
|
+
export declare const INSPECTOR: boolean;
|
|
61
|
+
export declare const ANNOTATE: boolean;
|
|
62
|
+
export declare const BADGE: boolean;
|
|
63
|
+
export declare const DEVTOOL: boolean;
|
|
64
|
+
export declare const SELF_DRIVE: boolean;
|
|
65
|
+
export declare const PERF: boolean;
|
|
66
|
+
export declare const EXPLORE: boolean;
|
|
67
|
+
/** The modules this build carries, by name (diagnostics: `g9.pilot`). */
|
|
68
|
+
export declare function pilotModules(): readonly G9PilotModule[];
|
|
69
|
+
//# sourceMappingURL=flags.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flags.d.ts","sourceRoot":"","sources":["../src/flags.ts"],"names":[],"mappings":"AA0BA,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE9E,qGAAqG;AACrG,MAAM,WAAW,eAAe;IAC9B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6E,CAAC;AAClG,eAAO,MAAM,UAAU,SAAmF,CAAC;AAC3G,eAAO,MAAM,IAAI,SAAuE,CAAC;AACzF,eAAO,MAAM,OAAO,SAA6E,CAAC;AAElG,yEAAyE;AACzE,wBAAgB,YAAY,IAAI,SAAS,aAAa,EAAE,CAsBvD"}
|
package/dist/flags.jsx
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const DEFAULT_SETTINGS = Object.freeze({
|
|
2
|
+
environment: null,
|
|
3
|
+
profile: 'off',
|
|
4
|
+
distribution: 'store',
|
|
5
|
+
badge: 'off',
|
|
6
|
+
consent: 'none',
|
|
7
|
+
mask: 'off',
|
|
8
|
+
session: {
|
|
9
|
+
maxMinutes: 0
|
|
10
|
+
},
|
|
11
|
+
selfDrive: {
|
|
12
|
+
maxSeconds: 0
|
|
13
|
+
},
|
|
14
|
+
observe: {
|
|
15
|
+
rules: {},
|
|
16
|
+
sampling: {
|
|
17
|
+
errors: 1,
|
|
18
|
+
vitals: 1,
|
|
19
|
+
traces: 1
|
|
20
|
+
},
|
|
21
|
+
buffer: {
|
|
22
|
+
maxFindings: 200,
|
|
23
|
+
persist: true
|
|
24
|
+
},
|
|
25
|
+
report: {
|
|
26
|
+
via: 'local',
|
|
27
|
+
consent: 'build',
|
|
28
|
+
endpoint: null,
|
|
29
|
+
service: null,
|
|
30
|
+
auto: 0
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
maxScopes: []
|
|
34
|
+
});
|
|
35
|
+
const PROFILE = "u" < typeof __G9_PILOT_PROFILE__ ? 'off' : __G9_PILOT_PROFILE__;
|
|
36
|
+
const SETTINGS = "u" < typeof __G9_PILOT_SETTINGS__ ? DEFAULT_SETTINGS : {
|
|
37
|
+
...DEFAULT_SETTINGS,
|
|
38
|
+
...__G9_PILOT_SETTINGS__
|
|
39
|
+
};
|
|
40
|
+
const MARKS = "u" < typeof __G9_PILOT_MARKS__ ? false : __G9_PILOT_MARKS__;
|
|
41
|
+
const ORACLES = "u" < typeof __G9_PILOT_ORACLES__ ? false : __G9_PILOT_ORACLES__;
|
|
42
|
+
const VITALS = "u" < typeof __G9_PILOT_VITALS__ ? false : __G9_PILOT_VITALS__;
|
|
43
|
+
const BLACKBOX = "u" < typeof __G9_PILOT_BLACKBOX__ ? false : __G9_PILOT_BLACKBOX__;
|
|
44
|
+
const SCREEN = "u" < typeof __G9_PILOT_SCREEN__ ? false : __G9_PILOT_SCREEN__;
|
|
45
|
+
const BRIDGE = "u" < typeof __G9_PILOT_BRIDGE__ ? false : __G9_PILOT_BRIDGE__;
|
|
46
|
+
const UI = "u" < typeof __G9_PILOT_UI__ ? false : __G9_PILOT_UI__;
|
|
47
|
+
const LEASE = "u" < typeof __G9_PILOT_LEASE__ ? false : __G9_PILOT_LEASE__;
|
|
48
|
+
const RECORDER = "u" < typeof __G9_PILOT_RECORDER__ ? false : __G9_PILOT_RECORDER__;
|
|
49
|
+
const STAGE = "u" < typeof __G9_PILOT_STAGE__ ? false : __G9_PILOT_STAGE__;
|
|
50
|
+
const DESIGN = "u" < typeof __G9_PILOT_DESIGN__ ? false : __G9_PILOT_DESIGN__;
|
|
51
|
+
const INSPECTOR = "u" < typeof __G9_PILOT_INSPECTOR__ ? false : __G9_PILOT_INSPECTOR__;
|
|
52
|
+
const ANNOTATE = "u" < typeof __G9_PILOT_ANNOTATE__ ? false : __G9_PILOT_ANNOTATE__;
|
|
53
|
+
const BADGE = "u" < typeof __G9_PILOT_BADGE__ ? false : __G9_PILOT_BADGE__;
|
|
54
|
+
const DEVTOOL = "u" < typeof __G9_PILOT_DEVTOOL__ ? false : __G9_PILOT_DEVTOOL__;
|
|
55
|
+
const SELF_DRIVE = "u" < typeof __G9_PILOT_SELF_DRIVE__ ? false : __G9_PILOT_SELF_DRIVE__;
|
|
56
|
+
const PERF = "u" < typeof __G9_PILOT_PERF__ ? false : __G9_PILOT_PERF__;
|
|
57
|
+
const EXPLORE = "u" < typeof __G9_PILOT_EXPLORE__ ? false : __G9_PILOT_EXPLORE__;
|
|
58
|
+
function pilotModules() {
|
|
59
|
+
const all = {
|
|
60
|
+
marks: MARKS,
|
|
61
|
+
oracles: ORACLES,
|
|
62
|
+
vitals: VITALS,
|
|
63
|
+
blackbox: BLACKBOX,
|
|
64
|
+
screen: SCREEN,
|
|
65
|
+
bridge: BRIDGE,
|
|
66
|
+
ui: UI,
|
|
67
|
+
lease: LEASE,
|
|
68
|
+
recorder: RECORDER,
|
|
69
|
+
stage: STAGE,
|
|
70
|
+
design: DESIGN,
|
|
71
|
+
inspector: INSPECTOR,
|
|
72
|
+
annotate: ANNOTATE,
|
|
73
|
+
badge: BADGE,
|
|
74
|
+
devtool: DEVTOOL,
|
|
75
|
+
selfDrive: SELF_DRIVE,
|
|
76
|
+
perf: PERF,
|
|
77
|
+
explore: EXPLORE
|
|
78
|
+
};
|
|
79
|
+
return Object.keys(all).filter((m)=>all[m]);
|
|
80
|
+
}
|
|
81
|
+
export { ANNOTATE, BADGE, BLACKBOX, BRIDGE, DEFAULT_SETTINGS, DESIGN, DEVTOOL, EXPLORE, INSPECTOR, LEASE, MARKS, ORACLES, PERF, PROFILE, RECORDER, SCREEN, SELF_DRIVE, SETTINGS, STAGE, UI, VITALS, pilotModules };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { G9ProviderCore } from '@g9tm/lynxcontrols/provider';
|
|
2
|
+
import { type G9Router } from '@g9tm/lynxcontrols/route';
|
|
3
|
+
import type { G9CultureStore } from '@g9tm/lynxcontrols-foundation/culture';
|
|
4
|
+
import { type ReactNode } from '@lynx-js/react';
|
|
5
|
+
import type { LynxControlsKit } from './kit.js';
|
|
6
|
+
import type { G9PilotHostProps } from './types.js';
|
|
7
|
+
/** The kit's live modules: the same copies the app renders (the adapter never resolves a second one). */
|
|
8
|
+
export declare const kit: LynxControlsKit;
|
|
9
|
+
/** What a level's install reads (always the latest render's values). */
|
|
10
|
+
export interface G9PilotHostContext {
|
|
11
|
+
readonly core: G9ProviderCore;
|
|
12
|
+
readonly culture: G9CultureStore;
|
|
13
|
+
props(): G9PilotHostProps;
|
|
14
|
+
router(): G9Router | null;
|
|
15
|
+
language(): string;
|
|
16
|
+
}
|
|
17
|
+
export interface G9PilotLevel {
|
|
18
|
+
/** What the level adds to the test ids' configuration (the bridge: confirmTouches). */
|
|
19
|
+
readonly testIds?: {
|
|
20
|
+
readonly confirmTouches?: boolean;
|
|
21
|
+
};
|
|
22
|
+
/** Installs the level once per app; returns the uninstaller. */
|
|
23
|
+
install(ctx: G9PilotHostContext): () => void;
|
|
24
|
+
/** What the level draws over the page (the bridge's badge, inspector, annotations). */
|
|
25
|
+
overlays?(props: G9PilotHostProps, language: string): ReactNode;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Told when the host installs or removes its level: a panel rendered inside <G9PilotHost> mounts before the host's own
|
|
29
|
+
* effect runs, so it reads the consent, the session and the findings again then.
|
|
30
|
+
*/
|
|
31
|
+
export declare function onPilotHostChange(listener: () => void): () => void;
|
|
32
|
+
/** A <G9PilotHost> for one level. */
|
|
33
|
+
export declare function makePilotHost(level: G9PilotLevel): (props: G9PilotHostProps) => ReactNode;
|
|
34
|
+
/** The language-picked text (fa / en). */
|
|
35
|
+
export declare const textFor: (language: string, fa: string, en: string) => string;
|
|
36
|
+
//# sourceMappingURL=host-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"host-core.d.ts","sourceRoot":"","sources":["../src/host-core.tsx"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAElE,OAAO,EAAE,KAAK,QAAQ,EAAe,MAAM,0BAA0B,CAAC;AAEtE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,gBAAgB,CAAC;AAGnE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEhD,yGAAyG;AACzG,eAAO,MAAM,GAAG,EAAE,eAIjB,CAAC;AAEF,wEAAwE;AACxE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,cAAc,CAAC;IACjC,KAAK,IAAI,gBAAgB,CAAC;IAC1B,MAAM,IAAI,QAAQ,GAAG,IAAI,CAAC;IAC1B,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,uFAAuF;IACvF,QAAQ,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,cAAc,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACzD,gEAAgE;IAChE,OAAO,CAAC,GAAG,EAAE,kBAAkB,GAAG,MAAM,IAAI,CAAC;IAC7C,uFAAuF;IACvF,QAAQ,CAAC,CAAC,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;CACjE;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAGlE;AAED,qCAAqC;AACrC,wBAAgB,aAAa,CAAC,KAAK,EAAE,YAAY,GAAG,CAAC,KAAK,EAAE,gBAAgB,KAAK,SAAS,CA0CzF;AAED,0CAA0C;AAC1C,eAAO,MAAM,OAAO,GAAI,UAAU,MAAM,EAAE,IAAI,MAAM,EAAE,IAAI,MAAM,KAAG,MAAuC,CAAC"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { configureTestIds } from "@g9tm/app-pilot-lynx";
|
|
2
|
+
import { g9Popovers } from "@g9tm/lynxcontrols/popover";
|
|
3
|
+
import { g9Popups, useG9Popups } from "@g9tm/lynxcontrols/popup";
|
|
4
|
+
import { useG9Core, useG9CultureStore } from "@g9tm/lynxcontrols/provider";
|
|
5
|
+
import { useG9Router } from "@g9tm/lynxcontrols/route";
|
|
6
|
+
import { g9SheetShowThrottleMs, g9Sheets, useG9SheetContext, useG9Sheets } from "@g9tm/lynxcontrols/sheet";
|
|
7
|
+
import { useEffect, useRef } from "@lynx-js/react";
|
|
8
|
+
import { mirrorAnchors } from "./anchors.jsx";
|
|
9
|
+
import { lynxControlsBusyHook } from "./busy.jsx";
|
|
10
|
+
import { lynxControlsLayerHook } from "./layer.jsx";
|
|
11
|
+
const kit = {
|
|
12
|
+
sheet: {
|
|
13
|
+
g9Sheets: g9Sheets,
|
|
14
|
+
useG9Sheets: useG9Sheets,
|
|
15
|
+
useG9SheetContext: useG9SheetContext,
|
|
16
|
+
g9SheetShowThrottleMs: g9SheetShowThrottleMs
|
|
17
|
+
},
|
|
18
|
+
popup: {
|
|
19
|
+
g9Popups: g9Popups,
|
|
20
|
+
useG9Popups: useG9Popups
|
|
21
|
+
},
|
|
22
|
+
popover: {
|
|
23
|
+
g9Popovers: g9Popovers
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const useHostBusyTracking = lynxControlsBusyHook(kit);
|
|
27
|
+
let configured = false;
|
|
28
|
+
let installed = 0;
|
|
29
|
+
const changeListeners = new Set();
|
|
30
|
+
const changed = ()=>{
|
|
31
|
+
for (const l of [
|
|
32
|
+
...changeListeners
|
|
33
|
+
])l();
|
|
34
|
+
};
|
|
35
|
+
function onPilotHostChange(listener) {
|
|
36
|
+
changeListeners.add(listener);
|
|
37
|
+
return ()=>changeListeners.delete(listener);
|
|
38
|
+
}
|
|
39
|
+
function makePilotHost(level) {
|
|
40
|
+
return function(props) {
|
|
41
|
+
var _ref;
|
|
42
|
+
var _level_overlays;
|
|
43
|
+
if (!configured) {
|
|
44
|
+
configured = true;
|
|
45
|
+
configureTestIds({
|
|
46
|
+
useHostLayer: lynxControlsLayerHook(kit),
|
|
47
|
+
...level.testIds
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
useHostBusyTracking();
|
|
51
|
+
const core = useG9Core();
|
|
52
|
+
const culture = useG9CultureStore();
|
|
53
|
+
const router = useG9Router();
|
|
54
|
+
const latest = useRef({
|
|
55
|
+
props,
|
|
56
|
+
router
|
|
57
|
+
});
|
|
58
|
+
latest.current = {
|
|
59
|
+
props,
|
|
60
|
+
router
|
|
61
|
+
};
|
|
62
|
+
useEffect(()=>{
|
|
63
|
+
installed++;
|
|
64
|
+
if (installed > 1) return ()=>{
|
|
65
|
+
installed--;
|
|
66
|
+
};
|
|
67
|
+
const offAnchors = mirrorAnchors(core.anchors);
|
|
68
|
+
const offLevel = level.install({
|
|
69
|
+
core,
|
|
70
|
+
culture,
|
|
71
|
+
props: ()=>latest.current.props,
|
|
72
|
+
router: ()=>latest.current.router,
|
|
73
|
+
language: ()=>culture.getSnapshot().language
|
|
74
|
+
});
|
|
75
|
+
changed();
|
|
76
|
+
return ()=>{
|
|
77
|
+
installed--;
|
|
78
|
+
offLevel();
|
|
79
|
+
offAnchors();
|
|
80
|
+
changed();
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
return <>
|
|
84
|
+
{props.children}
|
|
85
|
+
{null != (_ref = null == (_level_overlays = level.overlays) ? void 0 : _level_overlays.call(level, props, culture.getSnapshot().language)) ? _ref : null}
|
|
86
|
+
</>;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
const textFor = (language, fa, en)=>'fa' === language ? fa : en;
|
|
90
|
+
export { kit, makePilotHost, onPilotHostChange, textFor };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { G9FindingsBuffer, G9PilotFinding } from './observe.js';
|
|
2
|
+
interface HostModule {
|
|
3
|
+
pilotFindings?: (payload: string) => void;
|
|
4
|
+
}
|
|
5
|
+
interface GlobalEventEmitter {
|
|
6
|
+
addListener(name: string, listener: (...args: never[]) => void): void;
|
|
7
|
+
removeListener(name: string, listener: (...args: never[]) => void): void;
|
|
8
|
+
}
|
|
9
|
+
/** What the watch sends the host: the findings, and what this host cannot measure (the hello of a bridgeless host). */
|
|
10
|
+
export interface G9HostFindings {
|
|
11
|
+
readonly findings: readonly G9PilotFinding[];
|
|
12
|
+
/** Rules (or parts of one) that need a native host this one is not. */
|
|
13
|
+
readonly unsupported: readonly {
|
|
14
|
+
readonly rule: string;
|
|
15
|
+
readonly reason: string;
|
|
16
|
+
}[];
|
|
17
|
+
/** How many screen checks ran (the host waits for the next one after asking). */
|
|
18
|
+
readonly checks: number;
|
|
19
|
+
}
|
|
20
|
+
/** What a host without the native pilot module cannot give the watch. */
|
|
21
|
+
export declare const BRIDGELESS_UNSUPPORTED: G9HostFindings['unsupported'];
|
|
22
|
+
/** A command the watch runs on itself (G9AppPilot's `dispatch`, under its own kid). */
|
|
23
|
+
export interface G9SelfRequest {
|
|
24
|
+
readonly id: string;
|
|
25
|
+
readonly command: string;
|
|
26
|
+
readonly args: Record<string, unknown>;
|
|
27
|
+
readonly kid: string;
|
|
28
|
+
readonly scopes: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
/** Options of {@link installHostSink}. */
|
|
31
|
+
export interface G9HostSinkOptions {
|
|
32
|
+
/** Runs a command of this build: `oracle.check` (the screen rules now), `pilot.lynxError` (an error the runtime caught). */
|
|
33
|
+
readonly dispatch: (request: G9SelfRequest) => Promise<unknown>;
|
|
34
|
+
/** What this host cannot give (default {@link BRIDGELESS_UNSUPPORTED}). */
|
|
35
|
+
readonly unsupported?: G9HostFindings['unsupported'];
|
|
36
|
+
/** The host module and the event emitter (tests pass fakes). */
|
|
37
|
+
readonly host?: HostModule | null;
|
|
38
|
+
readonly events?: GlobalEventEmitter | null;
|
|
39
|
+
}
|
|
40
|
+
/** Sends `buffer` to a host that takes findings, and listens for its check and error events. Returns the uninstaller. */
|
|
41
|
+
export declare function installHostSink(buffer: G9FindingsBuffer, options: G9HostSinkOptions): () => void;
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=host-sink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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