@tapflowio/relay 0.23.0 → 0.24.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/RelayServer.d.ts.map +1 -1
- package/dist/RelayServer.js +18 -8
- package/dist/RelayServer.js.map +1 -1
- package/dist/api/auth.d.ts +1 -1
- package/dist/api/auth.d.ts.map +1 -1
- package/dist/api/auth.js +11 -3
- package/dist/api/auth.js.map +1 -1
- package/dist/api/builds.d.ts +1 -1
- package/dist/api/builds.d.ts.map +1 -1
- package/dist/api/builds.js +8 -2
- package/dist/api/builds.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/buildFiles.d.ts +23 -0
- package/dist/lib/buildFiles.d.ts.map +1 -0
- package/dist/lib/buildFiles.js +39 -0
- package/dist/lib/buildFiles.js.map +1 -0
- package/dist/lib/config.d.ts +26 -1
- package/dist/lib/config.d.ts.map +1 -1
- package/dist/lib/config.js +81 -17
- package/dist/lib/config.js.map +1 -1
- package/dist/lib/dataDir.d.ts +48 -1
- package/dist/lib/dataDir.d.ts.map +1 -1
- package/dist/lib/dataDir.js +108 -12
- package/dist/lib/dataDir.js.map +1 -1
- package/dist/middleware/auth.js +3 -3
- package/dist/middleware/auth.js.map +1 -1
- package/dist/server.js +2 -1
- package/dist/server.js.map +1 -1
- package/package.json +4 -4
- package/public/assets/AppCenter-BHz6vh5p.js +26 -0
- package/public/assets/AppCenter-BHz6vh5p.js.br +0 -0
- package/public/assets/AppCenter-BHz6vh5p.js.gz +0 -0
- package/public/assets/Default-bCqU0Qz9.js +1 -0
- package/public/assets/Default-bCqU0Qz9.js.br +0 -0
- package/public/assets/Default-bCqU0Qz9.js.gz +0 -0
- package/public/assets/Invite-EVMTsuNz.js +1 -0
- package/public/assets/Invite-EVMTsuNz.js.br +0 -0
- package/public/assets/Invite-EVMTsuNz.js.gz +0 -0
- package/public/assets/MacResources-fCn40Tf5.js +1 -0
- package/public/assets/MacResources-fCn40Tf5.js.br +0 -0
- package/public/assets/MacResources-fCn40Tf5.js.gz +0 -0
- package/public/assets/NotFound-wHOnT2Fl.js +1 -0
- package/public/assets/NotFound-wHOnT2Fl.js.br +0 -0
- package/public/assets/NotFound-wHOnT2Fl.js.gz +0 -0
- package/public/assets/QASession-CL-eyFxG.js +150 -0
- package/public/assets/QASession-CL-eyFxG.js.br +0 -0
- package/public/assets/QASession-CL-eyFxG.js.gz +0 -0
- package/public/assets/ResetPassword-D-SFg4ap.js +1 -0
- package/public/assets/ResetPassword-D-SFg4ap.js.br +0 -0
- package/public/assets/ResetPassword-D-SFg4ap.js.gz +0 -0
- package/public/assets/Setup-ULjvIfAi.js +1 -0
- package/public/assets/Setup-ULjvIfAi.js.br +0 -0
- package/public/assets/Setup-ULjvIfAi.js.gz +0 -0
- package/public/assets/Team-DH91GD4w.js +6 -0
- package/public/assets/Team-DH91GD4w.js.br +0 -0
- package/public/assets/Team-DH91GD4w.js.gz +0 -0
- package/public/assets/Tokens-DImLpOVZ.js +1 -0
- package/public/assets/Tokens-DImLpOVZ.js.br +0 -0
- package/public/assets/Tokens-DImLpOVZ.js.gz +0 -0
- package/public/assets/alert-dialog-CwcUyDZQ.js +1 -0
- package/public/assets/alert-dialog-CwcUyDZQ.js.br +0 -0
- package/public/assets/alert-dialog-CwcUyDZQ.js.gz +0 -0
- package/public/assets/badge-B4QAWrzA.js +1 -0
- package/public/assets/badge-B4QAWrzA.js.br +0 -0
- package/public/assets/badge-B4QAWrzA.js.gz +0 -0
- package/public/assets/build-format-CtmRXihN.js +11 -0
- package/public/assets/build-format-CtmRXihN.js.br +0 -0
- package/public/assets/build-format-CtmRXihN.js.gz +0 -0
- package/public/assets/dialog-BAFN_ONP.js +11 -0
- package/public/assets/dialog-BAFN_ONP.js.br +0 -0
- package/public/assets/dialog-BAFN_ONP.js.gz +0 -0
- package/public/assets/index-COOWQXpW.js +218 -0
- package/public/assets/index-COOWQXpW.js.br +0 -0
- package/public/assets/index-COOWQXpW.js.gz +0 -0
- package/public/assets/index-ozCdBYxk.css +1 -0
- package/public/assets/index-ozCdBYxk.css.br +0 -0
- package/public/assets/index-ozCdBYxk.css.gz +0 -0
- package/public/assets/list-view-Rrqp8TkG.js +1 -0
- package/public/assets/list-view-Rrqp8TkG.js.br +0 -0
- package/public/assets/list-view-Rrqp8TkG.js.gz +0 -0
- package/public/assets/{pencil-CPaoEKFm.js → pencil-CAHyK7Qf.js} +2 -2
- package/public/assets/pencil-CAHyK7Qf.js.br +0 -0
- package/public/assets/pencil-CAHyK7Qf.js.gz +0 -0
- package/public/assets/resource-health-BRpSwarg.js +1 -0
- package/public/assets/resource-health-BRpSwarg.js.br +0 -0
- package/public/assets/resource-health-BRpSwarg.js.gz +0 -0
- package/public/assets/{trash-CD9Y9G-i.js → trash-CkO-5TRA.js} +3 -3
- package/public/assets/trash-CkO-5TRA.js.br +0 -0
- package/public/assets/trash-CkO-5TRA.js.gz +0 -0
- package/public/assets/useFocusAfterSwap-BY3N9f9v.js +1 -0
- package/public/assets/useFocusAfterSwap-BY3N9f9v.js.br +0 -0
- package/public/assets/useFocusAfterSwap-BY3N9f9v.js.gz +0 -0
- package/public/assets/{vendor-charts-YPhPkjLw.js → vendor-charts-BykzUV2D.js} +1 -1
- package/public/assets/vendor-charts-BykzUV2D.js.br +0 -0
- package/public/assets/vendor-charts-BykzUV2D.js.gz +0 -0
- package/public/assets/{vendor-react-C5H_1fOn.js → vendor-react-BlPSzrEe.js} +18 -10
- package/public/assets/vendor-react-BlPSzrEe.js.br +0 -0
- package/public/assets/vendor-react-BlPSzrEe.js.gz +0 -0
- package/public/assets/{vendor-router-CnmrRwJF.js → vendor-router-B_lVHrKl.js} +3 -3
- package/public/assets/vendor-router-B_lVHrKl.js.br +0 -0
- package/public/assets/vendor-router-B_lVHrKl.js.gz +0 -0
- package/public/index.html +4 -4
- package/public/index.html.br +0 -0
- package/public/index.html.gz +0 -0
- package/public/assets/AppCenter-OTDuqwSf.js +0 -21
- package/public/assets/AppCenter-OTDuqwSf.js.br +0 -0
- package/public/assets/AppCenter-OTDuqwSf.js.gz +0 -0
- package/public/assets/Default-D9GLpWlN.js +0 -1
- package/public/assets/Default-D9GLpWlN.js.br +0 -0
- package/public/assets/Default-D9GLpWlN.js.gz +0 -0
- package/public/assets/Invite-Bhiam8En.js +0 -1
- package/public/assets/Invite-Bhiam8En.js.br +0 -0
- package/public/assets/Invite-Bhiam8En.js.gz +0 -0
- package/public/assets/MacResources-DObzVJxQ.js +0 -3
- package/public/assets/MacResources-DObzVJxQ.js.br +0 -0
- package/public/assets/MacResources-DObzVJxQ.js.gz +0 -0
- package/public/assets/NotFound-Dz_k_Mzf.js +0 -1
- package/public/assets/NotFound-Dz_k_Mzf.js.br +0 -0
- package/public/assets/NotFound-Dz_k_Mzf.js.gz +0 -0
- package/public/assets/QASession-2crubOLY.js +0 -150
- package/public/assets/QASession-2crubOLY.js.br +0 -0
- package/public/assets/QASession-2crubOLY.js.gz +0 -0
- package/public/assets/ResetPassword-EUm12ojo.js +0 -1
- package/public/assets/ResetPassword-EUm12ojo.js.br +0 -0
- package/public/assets/ResetPassword-EUm12ojo.js.gz +0 -0
- package/public/assets/Setup-Fc_0RW0a.js +0 -1
- package/public/assets/Setup-Fc_0RW0a.js.br +0 -0
- package/public/assets/Setup-Fc_0RW0a.js.gz +0 -0
- package/public/assets/Team-Ac5aOGgx.js +0 -6
- package/public/assets/Team-Ac5aOGgx.js.br +0 -0
- package/public/assets/Team-Ac5aOGgx.js.gz +0 -0
- package/public/assets/Tokens-pEnCy-7l.js +0 -1
- package/public/assets/Tokens-pEnCy-7l.js.br +0 -0
- package/public/assets/Tokens-pEnCy-7l.js.gz +0 -0
- package/public/assets/alert-dialog-DhOTocMh.js +0 -1
- package/public/assets/alert-dialog-DhOTocMh.js.br +0 -0
- package/public/assets/alert-dialog-DhOTocMh.js.gz +0 -0
- package/public/assets/badge-B4gbViMs.js +0 -1
- package/public/assets/badge-B4gbViMs.js.br +0 -0
- package/public/assets/badge-B4gbViMs.js.gz +0 -0
- package/public/assets/build-format-DKGajT96.js +0 -11
- package/public/assets/build-format-DKGajT96.js.br +0 -0
- package/public/assets/build-format-DKGajT96.js.gz +0 -0
- package/public/assets/dialog-DEL1xxKJ.js +0 -11
- package/public/assets/dialog-DEL1xxKJ.js.br +0 -0
- package/public/assets/dialog-DEL1xxKJ.js.gz +0 -0
- package/public/assets/index-Bxs7CdEi.css +0 -1
- package/public/assets/index-Bxs7CdEi.css.br +0 -0
- package/public/assets/index-Bxs7CdEi.css.gz +0 -0
- package/public/assets/index-COIlCLCW.js +0 -218
- package/public/assets/index-COIlCLCW.js.br +0 -0
- package/public/assets/index-COIlCLCW.js.gz +0 -0
- package/public/assets/pencil-CPaoEKFm.js.br +0 -0
- package/public/assets/pencil-CPaoEKFm.js.gz +0 -0
- package/public/assets/resource-health-Ca4-5Rde.js +0 -1
- package/public/assets/resource-health-Ca4-5Rde.js.br +0 -0
- package/public/assets/resource-health-Ca4-5Rde.js.gz +0 -0
- package/public/assets/table-CSeGVnii.js +0 -1
- package/public/assets/table-CSeGVnii.js.br +0 -0
- package/public/assets/table-CSeGVnii.js.gz +0 -0
- package/public/assets/trash-CD9Y9G-i.js.br +0 -0
- package/public/assets/trash-CD9Y9G-i.js.gz +0 -0
- package/public/assets/vendor-charts-YPhPkjLw.js.br +0 -0
- package/public/assets/vendor-charts-YPhPkjLw.js.gz +0 -0
- package/public/assets/vendor-react-C5H_1fOn.js.br +0 -0
- package/public/assets/vendor-react-C5H_1fOn.js.gz +0 -0
- package/public/assets/vendor-router-CnmrRwJF.js.br +0 -0
- package/public/assets/vendor-router-CnmrRwJF.js.gz +0 -0
package/dist/lib/dataDir.js
CHANGED
|
@@ -1,18 +1,114 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
+
import os from 'os';
|
|
2
3
|
import path from 'path';
|
|
3
4
|
export const LEGACY_DATA_DIR = '.tapflow-data';
|
|
4
5
|
export const UNIFIED_DATA_DIR = path.join('.tapflow', 'data');
|
|
5
|
-
//
|
|
6
|
-
// `
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
// The layout of an install dir tapflow owns: config and data side by side, nothing wrapped.
|
|
7
|
+
// `.tapflow/data` wraps because it dates from when tapflow lived inside the user's own folder.
|
|
8
|
+
export const OWN_DATA_DIR = 'data';
|
|
9
|
+
export const CONFIG_FILE = 'tapflow.config.json';
|
|
10
|
+
export const DEFAULT_INSTALL_DIR_NAME = '.tapflow';
|
|
11
|
+
/**
|
|
12
|
+
* Whether `dir` holds an install's data. An empty dir counts — the Docker image and the systemd
|
|
13
|
+
* docs create one before the relay first starts. A dir whose only entry is `jwt-secret` does not:
|
|
14
|
+
* every CLI command up to this change wrote one wherever it ran, because the relay config created
|
|
15
|
+
* it at import, and the relay itself always creates `tapflow.db` on boot. So a dir holding the
|
|
16
|
+
* secret alone is one no relay ever ran in, and treating it as an install made an app repo that
|
|
17
|
+
* had once run `tapflow flow run` look like one.
|
|
18
|
+
*/
|
|
19
|
+
export function holdsInstallData(dir) {
|
|
20
|
+
let entries;
|
|
21
|
+
try {
|
|
22
|
+
entries = fs.readdirSync(dir);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const real = entries.filter((e) => e !== '.DS_Store');
|
|
28
|
+
return !(real.length === 1 && real[0] === 'jwt-secret');
|
|
29
|
+
}
|
|
30
|
+
// Read-only resolution of an install's data dir when nothing names one. The relay never MOVES
|
|
31
|
+
// anything — that is the job of `tapflow migrate data-dir`. Existing layouts come first, so an
|
|
32
|
+
// install that has data keeps it: `.tapflow/data`, then the legacy `.tapflow-data`, and only then
|
|
33
|
+
// `fallback`. The existing ones win over a new-layout `data/` because an install living inside an
|
|
34
|
+
// app repo can have an unrelated `data/` of the app's own. The caller warns when usingLegacy is true.
|
|
35
|
+
export function resolveDefaultDataDir(installDir, fallback = UNIFIED_DATA_DIR) {
|
|
36
|
+
const unified = path.join(installDir, UNIFIED_DATA_DIR);
|
|
37
|
+
if (holdsInstallData(unified))
|
|
38
|
+
return { dataDir: unified, usingLegacy: false, existing: true };
|
|
39
|
+
const legacy = path.join(installDir, LEGACY_DATA_DIR);
|
|
40
|
+
if (holdsInstallData(legacy))
|
|
41
|
+
return { dataDir: legacy, usingLegacy: true, existing: true };
|
|
42
|
+
return { dataDir: path.join(installDir, fallback), usingLegacy: false, existing: false };
|
|
43
|
+
}
|
|
44
|
+
function realpathOr(p) {
|
|
45
|
+
try {
|
|
46
|
+
return fs.realpathSync(p);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return path.resolve(p);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* **Which directory is this machine's tapflow install.** Every command asks this and none takes a
|
|
54
|
+
* path, so `init` writes where `start` reads:
|
|
55
|
+
*
|
|
56
|
+
* 1. `TAPFLOW_HOME`, when set and non-empty (relative values resolve against the cwd).
|
|
57
|
+
* 2. The current directory, when it already is an install — it holds `tapflow.config.json`, or a
|
|
58
|
+
* `.tapflow/data` / `.tapflow-data` with install data in it. This is how installs from before the
|
|
59
|
+
* home existed keep running where they are, and how `pnpm dev` keeps its own.
|
|
60
|
+
* 3. `~/.tapflow`.
|
|
61
|
+
*
|
|
62
|
+
* A permanent rule, like npm's project `.npmrc` before the user one — not a migration path.
|
|
63
|
+
*
|
|
64
|
+
* Two cases around the home directory, both found in design review:
|
|
65
|
+
* - At `~`, `~/.tapflow/data` is the default install's own data, so it is not a signal there. And
|
|
66
|
+
* once `~/.tapflow/tapflow.config.json` exists, `~` is never an install: an older install at `~`
|
|
67
|
+
* would otherwise serve the new install's data under the old config.
|
|
68
|
+
* - An install at `~/.tapflow` with no config of its own reads `~/tapflow.config.json`, which is
|
|
69
|
+
* where `tapflow init` run from a new terminal used to write it. Without that, starting it from
|
|
70
|
+
* anywhere but `~` served the same database and secret with its TLS, tunnel and SMTP gone.
|
|
71
|
+
*/
|
|
72
|
+
export function resolveInstallDir({ env = process.env, cwd = process.cwd(), home = os.homedir() } = {}) {
|
|
73
|
+
const defaultDir = path.join(home, DEFAULT_INSTALL_DIR_NAME);
|
|
74
|
+
let reason = 'default';
|
|
75
|
+
let shadowed = [];
|
|
76
|
+
if (env.TAPFLOW_HOME) {
|
|
77
|
+
const dir = path.resolve(cwd, env.TAPFLOW_HOME);
|
|
78
|
+
if (realpathOr(dir) !== realpathOr(defaultDir)) {
|
|
79
|
+
return {
|
|
80
|
+
dir, reason: 'TAPFLOW_HOME', configPath: path.join(dir, CONFIG_FILE),
|
|
81
|
+
defaultDataLayout: OWN_DATA_DIR, missing: !fs.existsSync(dir), shadowed,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
reason = 'TAPFLOW_HOME';
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
const atHome = realpathOr(cwd) === realpathOr(home);
|
|
88
|
+
const homeInstallConfigured = atHome && fs.existsSync(path.join(defaultDir, CONFIG_FILE));
|
|
89
|
+
if (homeInstallConfigured) {
|
|
90
|
+
shadowed = [path.join(home, CONFIG_FILE)].filter((p) => fs.existsSync(p));
|
|
91
|
+
if (holdsInstallData(path.join(home, LEGACY_DATA_DIR)))
|
|
92
|
+
shadowed.push(path.join(home, LEGACY_DATA_DIR));
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
const inCwd = (why) => ({
|
|
96
|
+
dir: cwd, reason: why, configPath: path.join(cwd, CONFIG_FILE),
|
|
97
|
+
// An install in its own folder from before the home existed: keep its layout.
|
|
98
|
+
defaultDataLayout: UNIFIED_DATA_DIR, missing: false, shadowed: [],
|
|
99
|
+
});
|
|
100
|
+
if (fs.existsSync(path.join(cwd, CONFIG_FILE)))
|
|
101
|
+
return inCwd('config in the current directory');
|
|
102
|
+
if (!atHome && holdsInstallData(path.join(cwd, UNIFIED_DATA_DIR)))
|
|
103
|
+
return inCwd('data in the current directory');
|
|
104
|
+
if (holdsInstallData(path.join(cwd, LEGACY_DATA_DIR)))
|
|
105
|
+
return inCwd('data in the current directory');
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
let configPath = path.join(defaultDir, CONFIG_FILE);
|
|
109
|
+
const homeConfig = path.join(home, CONFIG_FILE);
|
|
110
|
+
if (!fs.existsSync(configPath) && fs.existsSync(homeConfig))
|
|
111
|
+
configPath = homeConfig;
|
|
112
|
+
return { dir: defaultDir, reason, configPath, defaultDataLayout: OWN_DATA_DIR, missing: false, shadowed };
|
|
17
113
|
}
|
|
18
114
|
//# sourceMappingURL=dataDir.js.map
|
package/dist/lib/dataDir.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataDir.js","sourceRoot":"","sources":["../../src/lib/dataDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"dataDir.js","sourceRoot":"","sources":["../../src/lib/dataDir.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAA;AAC9C,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAA;AAC7D,4FAA4F;AAC5F,+FAA+F;AAC/F,MAAM,CAAC,MAAM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AAC;IACH,CAAC;IAED,IAAI,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAA;IACnD,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;IAC/C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QAAE,UAAU,GAAG,UAAU,CAAA;IACpF,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AAC3G,CAAC"}
|
package/dist/middleware/auth.js
CHANGED
|
@@ -2,14 +2,14 @@ import crypto from 'crypto';
|
|
|
2
2
|
import jwt from 'jsonwebtoken';
|
|
3
3
|
import { AuthError } from '@tapflowio/agent-core';
|
|
4
4
|
import { getDb } from '../db.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getJwtSecret } from '../lib/config.js';
|
|
6
6
|
const JWT_EXPIRES = '7d';
|
|
7
7
|
export function signJwt(payload) {
|
|
8
|
-
return jwt.sign(payload,
|
|
8
|
+
return jwt.sign(payload, getJwtSecret(), { expiresIn: JWT_EXPIRES });
|
|
9
9
|
}
|
|
10
10
|
export function verifyJwtOrThrow(token) {
|
|
11
11
|
try {
|
|
12
|
-
return jwt.verify(token,
|
|
12
|
+
return jwt.verify(token, getJwtSecret());
|
|
13
13
|
}
|
|
14
14
|
catch (cause) {
|
|
15
15
|
throw new AuthError('Invalid or expired auth token', { cause });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/middleware/auth.ts"],"names":[],"mappings":"AACA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,GAAG,MAAM,cAAc,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,C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,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC,CAAC,CAAA;YACxD,OAAO,IAAI,CAAA;QACb,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,CAAA;IAC/B,CAAC;IACD,MAAM,IAAI,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,CAAC,CAAA;IAClC,IAAI,CAAC,IAAI;QAAE,OAAO,IAAI,CAAA;IACtB,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAA;AAChC,CAAC"}
|
package/dist/server.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
import { initDb } from './db.js';
|
|
3
3
|
import { RelayServer } from './RelayServer.js';
|
|
4
|
-
import { config, loadedEnvPath } from './lib/config.js';
|
|
4
|
+
import { config, loadedEnvPath, assertInstallDir } from './lib/config.js';
|
|
5
5
|
import { buildCorsOrigins, containerWithoutPublicUrlWarning, proxyWithoutPublicUrlWarning } from './lib/proxyConfig.js';
|
|
6
6
|
import { runningInContainer } from './lib/lanAddress.js';
|
|
7
7
|
import { bootstrapAdminFromEnv, AdminBootstrapError } from './lib/adminBootstrap.js';
|
|
@@ -9,6 +9,7 @@ import { createCertProvider, resolveRelayDisplayHost } from './lib/cert/index.js
|
|
|
9
9
|
import { startTlsBackgroundTasks } from './lib/tlsTasks.js';
|
|
10
10
|
import { createLogger } from '@tapflowio/agent-core';
|
|
11
11
|
const logger = createLogger('relay');
|
|
12
|
+
assertInstallDir();
|
|
12
13
|
const { port, dataDir } = config.local;
|
|
13
14
|
// config loaded <dataDir>/.env before reading any secret (JWT/SMTP/DNS tokens); just report it here.
|
|
14
15
|
if (loadedEnvPath)
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,IAA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AAC,IAAI,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;IAChD,CAAC,CAAA;IACD,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AAChC,CAAC;AAED,KAAK,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACxB,MAAM,CAAC,KAAK,CAAC,0BAA0B,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IACrD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tapflowio/relay",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "WebSocket relay server for tapflow — NAT traversal, session routing, JWT auth, bundled dashboard",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tapflow",
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"nodemailer": "^9.1.1",
|
|
53
53
|
"ws": "^8.21.3",
|
|
54
54
|
"zod": "^4.6.5",
|
|
55
|
-
"@tapflowio/agent-core": "0.
|
|
56
|
-
"@tapflowio/protocol": "0.
|
|
55
|
+
"@tapflowio/agent-core": "0.24.0",
|
|
56
|
+
"@tapflowio/protocol": "0.24.0"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"@types/better-sqlite3": "^7.6.13",
|
|
60
60
|
"@types/busboy": "^1.5.4",
|
|
61
61
|
"@types/jsonwebtoken": "^9.0.10",
|
|
62
|
-
"@types/node": "^22.20.
|
|
62
|
+
"@types/node": "^22.20.4",
|
|
63
63
|
"@types/nodemailer": "^8.0.1",
|
|
64
64
|
"@types/ws": "^8.0.0",
|
|
65
65
|
"typescript": "^5.0.0",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
var Ue=a=>{throw TypeError(a)};var Fe=(a,e,s)=>e.has(a)||Ue("Cannot "+s);var N=(a,e,s)=>(Fe(a,e,"read from private field"),s?s.call(a):e.get(a)),ye=(a,e,s)=>e.has(a)?Ue("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(a):e.set(a,s),ve=(a,e,s,l)=>(Fe(a,e,"write to private field"),l?l.call(a,s):e.set(a,s),s),ge=(a,e,s)=>(Fe(a,e,"access private method"),s);import{k as c,f as Se,j as t}from"./vendor-react-BlPSzrEe.js";import{y as ft,aq as mt,ai as Ve,aa as pt,am as Ze,aH as et,al as xt,ar as gt,a0 as ke,at as oe,B as pe,L as Ce,O as bt,I as He,F as jt,W as yt,S as vt,G as St,z as Nt,E as wt,T as Dt,f as Ct,aG as Je,ah as kt,N as _t,ap as At,av as It,a5 as Ot,ak as Et,a8 as Rt}from"./index-COOWQXpW.js";import{f as Tt,d as Pe,S as Ft,P as $t,b as Mt,e as Pt}from"./build-format-CtmRXihN.js";import{f as tt,d as st,e as lt,i as Oe,j as Ee,g as Re,h as E,S as Te,a as at,D as nt,C as Bt}from"./dialog-BAFN_ONP.js";import{P as zt,T as Lt}from"./trash-CkO-5TRA.js";import{B as $e}from"./badge-B4QAWrzA.js";import{f as qt,g as Kt,d as Qt,b as Ut,c as Vt,e as Ht,a as Jt,A as Gt}from"./alert-dialog-CwcUyDZQ.js";import{u as Wt}from"./useFocusAfterSwap-BY3N9f9v.js";import{b as Xt,c as Yt}from"./vendor-router-B_lVHrKl.js";var ce,me,$,de,le,De,Be,Ye,Zt=(Ye=class extends ft{constructor(e,s){super();ye(this,le);ye(this,ce);ye(this,me);ye(this,$);ye(this,de);ve(this,ce,e),this.setOptions(s),this.bindMethods(),ge(this,le,De).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){var l;const s=this.options;this.options=N(this,ce).defaultMutationOptions(e),mt(this.options,s)||N(this,ce).getMutationCache().notify({type:"observerOptionsUpdated",mutation:N(this,$),observer:this}),s!=null&&s.mutationKey&&this.options.mutationKey&&Ve(s.mutationKey)!==Ve(this.options.mutationKey)?this.reset():((l=N(this,$))==null?void 0:l.state.status)==="pending"&&N(this,$).setOptions(this.options)}onSubscribe(){this.listeners.size===1&&N(this,$)&&(N(this,$).addObserver(this),ge(this,le,De).call(this))}onUnsubscribe(){var e;this.hasListeners()||(e=N(this,$))==null||e.removeObserver(this)}onMutationUpdate(e){ge(this,le,De).call(this),ge(this,le,Be).call(this,e)}getCurrentResult(){return N(this,me)}reset(){var e;(e=N(this,$))==null||e.removeObserver(this),ve(this,$,void 0),ge(this,le,De).call(this),ge(this,le,Be).call(this)}mutate(e,s){var l;return ve(this,de,s),(l=N(this,$))==null||l.removeObserver(this),ve(this,$,N(this,ce).getMutationCache().build(N(this,ce),this.options)),N(this,$).addObserver(this),N(this,$).execute(e)}},ce=new WeakMap,me=new WeakMap,$=new WeakMap,de=new WeakMap,le=new WeakSet,De=function(){var s;const e=((s=N(this,$))==null?void 0:s.state)??pt();ve(this,me,{...e,isPending:e.status==="pending",isSuccess:e.status==="success",isError:e.status==="error",isIdle:e.status==="idle",mutate:this.mutate,reset:this.reset})},Be=function(e){Ze.batch(()=>{var s,l,i,g,o,y,d,j;if(N(this,de)&&this.hasListeners()){const x=N(this,me).variables,r=N(this,me).context,p={client:N(this,ce),meta:this.options.meta,mutationKey:this.options.mutationKey};if((e==null?void 0:e.type)==="success"){try{(l=(s=N(this,de)).onSuccess)==null||l.call(s,e.data,x,r,p)}catch(b){Promise.reject(b)}try{(g=(i=N(this,de)).onSettled)==null||g.call(i,e.data,null,x,r,p)}catch(b){Promise.reject(b)}}else if((e==null?void 0:e.type)==="error"){try{(y=(o=N(this,de)).onError)==null||y.call(o,e.error,x,r,p)}catch(b){Promise.reject(b)}try{(j=(d=N(this,de)).onSettled)==null||j.call(d,void 0,e.error,x,r,p)}catch(b){Promise.reject(b)}}}this.listeners.forEach(x=>{x(N(this,me))})})},Ye);function Me(a,e){const s=et(),[l]=c.useState(()=>new Zt(s,a));c.useEffect(()=>{l.setOptions(a)},[l,a]);const i=c.useSyncExternalStore(c.useCallback(o=>l.subscribe(Ze.batchCalls(o)),[l]),()=>l.getCurrentResult(),()=>l.getCurrentResult()),g=c.useCallback((...o)=>{l.mutate(o[0],o[1]).catch(xt)},[l]);if(i.error&>(l.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:g,mutateAsync:i.mutate}}/**
|
|
2
|
+
* @license lucide-react v1.47.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const it={name:"ban",size:24,node:[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]]};it.node;const es=ke(it);/**
|
|
7
|
+
* @license lucide-react v1.47.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const rt={name:"layers",size:24,node:[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],aliases:["layers-3"]};rt.node;const ts=ke(rt);/**
|
|
12
|
+
* @license lucide-react v1.47.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const ot={name:"package",size:24,node:[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]};ot.node;const ss=ke(ot);/**
|
|
17
|
+
* @license lucide-react v1.47.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ct={name:"timer-off",size:24,node:[["path",{d:"M10 2h4",key:"n1abiw"}],["path",{d:"M4.6 11a8 8 0 0 0 1.7 8.7 8 8 0 0 0 8.7 1.7",key:"10he05"}],["path",{d:"M7.4 7.4a8 8 0 0 1 10.3 1 8 8 0 0 1 .9 10.2",key:"15f7sh"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M12 12v-2",key:"fwoke6"}]]};ct.node;const ls=ke(ct);/**
|
|
22
|
+
* @license lucide-react v1.47.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const dt={name:"upload",size:24,node:[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]};dt.node;const as=ke(dt);function ns(a){const e=Se.c(36),{onSuccess:s,appId:l}=a,[i,g]=c.useState(!1),[o,y]=c.useState(null),[d,j]=c.useState("none"),x=c.useRef(null);let r;e[0]!==l||e[1]!==o||e[2]!==s||e[3]!==d?(r=function(D){if(D.preventDefault(),!o)return;const q=new FormData;q.append("file",o),d!=="none"&&q.append("status",d),l&&q.append("app_id",String(l));const ae=fetch("/api/v1/builds",{method:"POST",credentials:"include",body:q}).then(async ue=>{if(!ue.ok){const ee=await ue.json().catch(os);throw new Error(ee.error??"Upload failed. Check the file format.")}s()});oe.promise(ae,{loading:"Uploading build…",success:"Build uploaded",error:rs}),g(!1),y(null),j("none")},e[0]=l,e[1]=o,e[2]=s,e[3]=d,e[4]=r):r=e[4];const p=r;let b;e[5]===Symbol.for("react.memo_cache_sentinel")?(b=function(D){g(D),D||(y(null),j("none"))},e[5]=b):b=e[5];const h=b;let v;e[6]===Symbol.for("react.memo_cache_sentinel")?(v=t.jsx(tt,{asChild:!0,children:t.jsxs(pe,{size:"sm",children:[t.jsx(as,{className:"mr-2 h-4 w-4"}),"Upload build"]})}),e[6]=v):v=e[6];let C;e[7]===Symbol.for("react.memo_cache_sentinel")?(C=t.jsx(st,{children:t.jsx(lt,{children:"Upload build"})}),e[7]=C):C=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=t.jsx(Ce,{children:"File"}),e[8]=f):f=e[8];let k;e[9]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{var w;return(w=x.current)==null?void 0:w.click()},e[9]=k):k=e[9];let O;e[10]===Symbol.for("react.memo_cache_sentinel")?(O=w=>{w.preventDefault();const D=w.dataTransfer.files[0];D&&y(D)},e[10]=O):O=e[10];const M=o?o.name:"Click or drag to upload";let R;e[11]!==M?(R=t.jsx("div",{className:"flex h-24 cursor-pointer items-center justify-center rounded-md border-2 border-dashed text-sm text-muted-foreground hover:border-primary",onClick:k,onDragOver:is,onDrop:O,children:M}),e[11]=M,e[12]=R):R=e[12];let T;e[13]===Symbol.for("react.memo_cache_sentinel")?(T=t.jsx("input",{ref:x,type:"file",accept:".zip,.apk,.tgz,.tar.gz,application/gzip,application/x-gzip",className:"hidden",onChange:w=>{var D;return y(((D=w.target.files)==null?void 0:D[0])??null)}}),e[13]=T):T=e[13];let z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=t.jsx("code",{children:".app.zip"}),e[14]=z):z=e[14];let Y;e[15]===Symbol.for("react.memo_cache_sentinel")?(Y=t.jsx("code",{children:".tar.gz"}),e[15]=Y):Y=e[15];let K;e[16]===Symbol.for("react.memo_cache_sentinel")?(K=t.jsx("code",{children:".tgz"}),e[16]=K):K=e[16];let G;e[17]===Symbol.for("react.memo_cache_sentinel")?(G=t.jsxs("p",{className:"text-xs text-muted-foreground",children:["iOS: ",z," or ",Y," / ",K," (e.g. an EAS simulator build) · Android: ",t.jsx("code",{children:".apk"})]}),e[17]=G):G=e[17];let V;e[18]!==R?(V=t.jsxs("div",{className:"grid gap-2",children:[f,R,T,G]}),e[18]=R,e[19]=V):V=e[19];let L;e[20]===Symbol.for("react.memo_cache_sentinel")?(L=t.jsxs(Ce,{children:["Status ",t.jsx("span",{className:"text-muted-foreground",children:"(optional)"})]}),e[20]=L):L=e[20];let Z;e[21]===Symbol.for("react.memo_cache_sentinel")?(Z=t.jsx(Oe,{children:t.jsx(Ee,{})}),e[21]=Z):Z=e[21];let Q;e[22]===Symbol.for("react.memo_cache_sentinel")?(Q=t.jsxs(Re,{children:[t.jsx(E,{value:"none",children:"None"}),t.jsx(E,{value:"Backlog",children:"Backlog"}),t.jsx(E,{value:"In Progress",children:"In Progress"}),t.jsx(E,{value:"Done",children:"Done"}),t.jsx(E,{value:"Rejected",children:"Rejected"})]}),e[22]=Q):Q=e[22];let P;e[23]!==d?(P=t.jsxs("div",{className:"grid gap-2",children:[L,t.jsxs(Te,{value:d,onValueChange:j,children:[Z,Q]})]}),e[23]=d,e[24]=P):P=e[24];let U;e[25]===Symbol.for("react.memo_cache_sentinel")?(U=t.jsx(pe,{type:"button",variant:"outline",className:"w-24",onClick:()=>g(!1),children:"Cancel"}),e[25]=U):U=e[25];const A=!o;let B;e[26]!==A?(B=t.jsxs("div",{className:"flex justify-end gap-2",children:[U,t.jsx(pe,{type:"submit",className:"w-24",disabled:A,children:"Upload"})]}),e[26]=A,e[27]=B):B=e[27];let I;e[28]!==p||e[29]!==V||e[30]!==P||e[31]!==B?(I=t.jsxs(at,{className:"sm:max-w-md",children:[C,t.jsxs("form",{onSubmit:p,className:"flex flex-col gap-4 pt-2",children:[V,P,B]})]}),e[28]=p,e[29]=V,e[30]=P,e[31]=B,e[32]=I):I=e[32];let F;return e[33]!==i||e[34]!==I?(F=t.jsxs(nt,{open:i,onOpenChange:h,children:[v,I]}),e[33]=i,e[34]=I,e[35]=F):F=e[35],F}function is(a){return a.preventDefault()}function rs(a){return a instanceof Error?a.message:"Failed to upload build"}function os(){return{}}function Ie(a){const e=Se.c(8);let s,l;e[0]!==a?({className:s,...l}=a,e[0]=a,e[1]=s,e[2]=l):(s=e[1],l=e[2]);let i;e[3]!==s?(i=bt("font-mono text-xs tabular-nums tracking-tight",s),e[3]=s,e[4]=i):i=e[4];let g;return e[5]!==l||e[6]!==i?(g=t.jsx("span",{className:i,...l}),e[5]=l,e[6]=i,e[7]=g):g=e[7],g}function cs({onSuccess:a}){const[e,s]=c.useState(!1),[l,i]=c.useState(""),[g,o]=c.useState(""),[y,d]=c.useState("ios"),[j,x]=c.useState(""),[r,p]=c.useState(!1);async function b(h){h.preventDefault(),x(""),p(!0);try{const v=await yt({name:l.trim(),bundle_id_key:g.trim(),platform:y});if(!v){x("Failed to create app");return}if("error"in v){x(v.error);return}s(!1),i(""),o(""),d("ios"),oe.success("App created"),a()}catch{x("Failed to create app — check your network"),oe.error("Failed to create app — check your network")}finally{p(!1)}}return t.jsxs(nt,{open:e,onOpenChange:s,children:[t.jsx(tt,{asChild:!0,children:t.jsxs("button",{className:"flex w-full items-center gap-1.5 rounded-md px-2 py-1.5 text-left text-sm text-muted-foreground hover:bg-accent hover:text-foreground transition-colors",children:[t.jsx(zt,{className:"size-3.5 shrink-0"}),t.jsx("span",{children:"Add App"})]})}),t.jsxs(at,{className:"sm:max-w-sm",children:[t.jsx(st,{children:t.jsx(lt,{children:"Add App"})}),t.jsxs("form",{onSubmit:b,className:"flex flex-col gap-4 pt-2",children:[t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(Ce,{htmlFor:"app-name",children:"Name"}),t.jsx(He,{id:"app-name",value:l,onChange:h=>i(h.target.value),placeholder:"My App",required:!0})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(Ce,{htmlFor:"bundle-id",children:"Bundle ID"}),t.jsx(He,{id:"bundle-id",value:g,onChange:h=>o(h.target.value),placeholder:"com.example.myapp",required:!0})]}),t.jsxs("div",{className:"flex flex-col gap-1.5",children:[t.jsx(Ce,{htmlFor:"platform",children:"Platform"}),t.jsxs(Te,{value:y,onValueChange:h=>d(h),children:[t.jsx(Oe,{id:"platform",children:t.jsx(Ee,{})}),t.jsxs(Re,{children:[t.jsx(E,{value:"ios",children:"iOS"}),t.jsx(E,{value:"android",children:"Android"}),t.jsx(E,{value:"both",children:"Both"})]})]})]}),t.jsx(jt,{assertive:!0,id:"add-app-error",message:j||void 0}),t.jsx(pe,{type:"submit",disabled:r,className:"w-full",children:r?"Creating…":"Create App"})]})]})]})}function ds(a){const e=Se.c(16),{apps:s,selectedAppId:l,onSelect:i,onAdd:g}=a;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=t.jsx("span",{className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Apps"}),e[0]=o):o=e[0];let y;e[1]!==s.length?(y=s.length===0&&t.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:"No apps yet"}),e[1]=s.length,e[2]=y):y=e[2];let d;if(e[3]!==s||e[4]!==i||e[5]!==l){let r;e[7]!==i||e[8]!==l?(r=p=>t.jsxs("button",{onClick:()=>i(p.id),className:["flex flex-col gap-0.5 rounded-md px-2 py-2 text-left text-sm hover:bg-accent overflow-hidden",p.id===l?"bg-accent font-medium":""].join(" "),children:[t.jsx("span",{className:"truncate",children:p.name}),t.jsx(Ie,{className:"text-muted-foreground truncate",children:p.bundle_id_key})]},p.id),e[7]=i,e[8]=l,e[9]=r):r=e[9],d=s.map(r),e[3]=s,e[4]=i,e[5]=l,e[6]=d}else d=e[6];let j;e[10]!==g?(j=t.jsx("div",{className:"mt-1 border-t pt-1",children:t.jsx(cs,{onSuccess:g})}),e[10]=g,e[11]=j):j=e[11];let x;return e[12]!==y||e[13]!==d||e[14]!==j?(x=t.jsxs("aside",{className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[o,y,d,j]}),e[12]=y,e[13]=d,e[14]=j,e[15]=x):x=e[15],x}function us(a){const e=Se.c(82),{build:s,isLast:l,onNavigate:i,onStatusChange:g,onScheduleDeletion:o,onCancelDeletion:y,statusDescribedBy:d}=a,[j,x]=c.useState(!1),r=c.useRef(null),p=s.status_label==="Done";let b;e[0]!==s.delete_after?(b=s.delete_after?Tt(s.delete_after):null,e[0]=s.delete_after,e[1]=b):b=e[1];const h=b;let v;e[2]!==s?(v=Pe(s),e[2]=s,e[3]=v):v=e[3];const C=v;let f;e[4]!==s.id||e[5]!==g?(f=function(fe){g(s.id,fe==="none"?null:fe)},e[4]=s.id,e[5]=g,e[6]=f):f=e[6];const k=f;let O;e[7]===Symbol.for("react.memo_cache_sentinel")?(O=we=>{var fe;we.preventDefault(),(fe=r.current)==null||fe.focus()},e[7]=O):O=e[7];let M;e[8]===Symbol.for("react.memo_cache_sentinel")?(M=t.jsxs(qt,{children:[t.jsx(Kt,{children:"Schedule deletion?"}),t.jsx(Qt,{children:"Build files will be deleted after 7 days. You can cancel the scheduled deletion anytime before then."})]}),e[8]=M):M=e[8];let R;e[9]===Symbol.for("react.memo_cache_sentinel")?(R=t.jsx(Ut,{children:"Cancel"}),e[9]=R):R=e[9];let T;e[10]!==s.id||e[11]!==o?(T=t.jsxs(Vt,{onCloseAutoFocus:O,children:[M,t.jsxs(Ht,{children:[R,t.jsx(Jt,{onClick:()=>{o(s.id),x(!1)},children:"Schedule deletion"})]})]}),e[10]=s.id,e[11]=o,e[12]=T):T=e[12];let z;e[13]!==j||e[14]!==T?(z=t.jsx(Gt,{open:j,onOpenChange:x,children:T}),e[13]=j,e[14]=T,e[15]=z):z=e[15];const Y=l?"":"border-b";let K;e[16]!==Y?(K=["flex items-center gap-3 px-4 py-3",Y],e[16]=Y,e[17]=K):K=e[17];const G=K.join(" "),V=s.build_number??"—";let L;e[18]!==V?(L=t.jsxs("span",{className:"text-sm font-medium",children:["build ",t.jsx(Ie,{children:V})]}),e[18]=V,e[19]=L):L=e[19];const Z=s.platform==="ios"?"ios":"android";let Q;e[20]!==s.platform||e[21]!==Z?(Q=t.jsx($e,{tone:Z,className:"text-xs capitalize",children:s.platform}),e[20]=s.platform,e[21]=Z,e[22]=Q):Q=e[22];let P;e[23]!==s.status_label?(P=s.status_label&&t.jsx($e,{tone:Ft[s.status_label],className:"text-xs",children:s.status_label}),e[23]=s.status_label,e[24]=P):P=e[24];let U;e[25]!==h?(U=h&&t.jsx($e,{tone:h.urgent?"rejected":"backlog",className:"text-xs",children:h.label}),e[25]=h,e[26]=U):U=e[26];let A;e[27]!==L||e[28]!==Q||e[29]!==P||e[30]!==U?(A=t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[L,Q,P,U]}),e[27]=L,e[28]=Q,e[29]=P,e[30]=U,e[31]=A):A=e[31];let B;e[32]===Symbol.for("react.memo_cache_sentinel")?(B={display:"flex",flexDirection:"row",gap:"14px",marginTop:"0.7rem",alignItems:"center"},e[32]=B):B=e[32];let I;e[33]!==s.uploader?(I=s.uploader&&t.jsxs(t.Fragment,{children:[t.jsx("span",{children:s.uploader}),t.jsx(vt,{orientation:"vertical",className:"h-3"})]}),e[33]=s.uploader,e[34]=I):I=e[34];let F;e[35]!==s.uploaded_at?(F=new Date(s.uploaded_at).toLocaleDateString(),e[35]=s.uploaded_at,e[36]=F):F=e[36];let w;e[37]!==F?(w=t.jsx(Ie,{children:F}),e[37]=F,e[38]=w):w=e[38];let D;e[39]!==I||e[40]!==w?(D=t.jsxs("div",{style:B,className:"text-xs text-muted-foreground",children:[I,w]}),e[39]=I,e[40]=w,e[41]=D):D=e[41];let q;e[42]!==A||e[43]!==D?(q=t.jsxs("div",{className:"flex-1 min-w-0",children:[A,D]}),e[42]=A,e[43]=D,e[44]=q):q=e[44];const ae=s.status_label??"none",ue=`Status for ${C}`;let ee;e[45]===Symbol.for("react.memo_cache_sentinel")?(ee=t.jsx(Ee,{}),e[45]=ee):ee=e[45];let he;e[46]!==s.id||e[47]!==d||e[48]!==ue?(he=t.jsx(Oe,{className:"h-9 w-32 text-xs","aria-label":ue,"aria-describedby":d,"data-status-trigger":s.id,children:ee}),e[46]=s.id,e[47]=d,e[48]=ue,e[49]=he):he=e[49];let xe;e[50]===Symbol.for("react.memo_cache_sentinel")?(xe=t.jsxs(Re,{children:[t.jsx(E,{value:"none",children:t.jsx("span",{className:"text-muted-foreground",children:"—"})}),t.jsx(E,{value:"Backlog",children:"Backlog"}),t.jsx(E,{value:"In Progress",children:"In Progress"}),t.jsx(E,{value:"Done",children:"Done"}),t.jsx(E,{value:"Rejected",children:"Rejected"})]}),e[50]=xe):xe=e[50];let H;e[51]!==k||e[52]!==ae||e[53]!==he?(H=t.jsxs(Te,{value:ae,onValueChange:k,children:[he,xe]}),e[51]=k,e[52]=ae,e[53]=he,e[54]=H):H=e[54];let ne;e[55]!==s.id||e[56]!==h||e[57]!==y||e[58]!==C?(ne=t.jsx(St,{asChild:!0,children:h?t.jsx(pe,{ref:r,size:"icon-sm",variant:"outline",onClick:()=>y(s.id),"aria-label":`Cancel scheduled deletion of ${C}`,children:t.jsx(ls,{className:"h-3.5 w-3.5","aria-hidden":!0})}):t.jsx(pe,{ref:r,size:"icon-sm",variant:"destructive",onClick:()=>x(!0),"aria-label":`Schedule deletion of ${C}`,children:t.jsx(Lt,{className:"h-3.5 w-3.5","aria-hidden":!0})})}),e[55]=s.id,e[56]=h,e[57]=y,e[58]=C,e[59]=ne):ne=e[59];const be=h?"Cancel scheduled deletion":"Schedule deletion";let J;e[60]!==be?(J=t.jsx(Nt,{children:be}),e[60]=be,e[61]=J):J=e[61];let te;e[62]!==ne||e[63]!==J?(te=t.jsx(wt,{delayDuration:400,children:t.jsxs(Dt,{children:[ne,J]})}),e[62]=ne,e[63]=J,e[64]=te):te=e[64];let ie;e[65]!==s.id||e[66]!==i?(ie=()=>i(s.id),e[65]=s.id,e[66]=i,e[67]=ie):ie=e[67];const Ne=`Start QA on ${C}`;let se;e[68]===Symbol.for("react.memo_cache_sentinel")?(se=t.jsx($t,{className:"mr-1.5 h-3.5 w-3.5"}),e[68]=se):se=e[68];let W;e[69]!==p||e[70]!==ie||e[71]!==Ne?(W=t.jsxs(pe,{size:"sm",onClick:ie,disabled:p,"aria-label":Ne,children:[se,"Start QA"]}),e[69]=p,e[70]=ie,e[71]=Ne,e[72]=W):W=e[72];let re;e[73]!==G||e[74]!==q||e[75]!==H||e[76]!==te||e[77]!==W?(re=t.jsxs("div",{className:G,children:[q,H,te,W]}),e[73]=G,e[74]=q,e[75]=H,e[76]=te,e[77]=W,e[78]=re):re=e[78];let je;return e[79]!==re||e[80]!==z?(je=t.jsxs(t.Fragment,{children:[z,re]}),e[79]=re,e[80]=z,e[81]=je):je=e[81],je}function hs(a){const e=Se.c(28),{versionName:s,builds:l,isOpen:i,onToggle:g,onNavigate:o,onStatusChange:y,onScheduleDeletion:d,onCancelDeletion:j,describedBy:x,rowNote:r}=a,p=c.useId(),b=i?p:void 0;let h;e[0]!==i?(h=i?t.jsx(Bt,{className:"h-4 w-4 shrink-0 text-muted-foreground"}):t.jsx(Ct,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),e[0]=i,e[1]=h):h=e[1];let v;e[2]!==s?(v=t.jsx(Ie,{className:"font-medium text-sm text-foreground",children:s}),e[2]=s,e[3]=v):v=e[3];const C=l.length>1?"s":"";let f;e[4]!==l.length||e[5]!==C?(f=t.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",l.length," build",C,")"]}),e[4]=l.length,e[5]=C,e[6]=f):f=e[6];let k;e[7]!==x||e[8]!==i||e[9]!==g||e[10]!==b||e[11]!==h||e[12]!==v||e[13]!==f||e[14]!==s?(k=t.jsx("h2",{children:t.jsxs("button",{className:"flex w-full items-center gap-2 px-4 py-3 text-left hover:bg-accent/50 bg-card focus-visible:outline-none focus-visible:outline-offset-[-2px] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",onClick:g,"aria-expanded":i,"aria-controls":b,"aria-describedby":x,"data-release-header":s,children:[h,v,f]})}),e[7]=x,e[8]=i,e[9]=g,e[10]=b,e[11]=h,e[12]=v,e[13]=f,e[14]=s,e[15]=k):k=e[15];let O;e[16]!==l||e[17]!==i||e[18]!==j||e[19]!==o||e[20]!==d||e[21]!==y||e[22]!==p||e[23]!==r?(O=i&&t.jsx("div",{id:p,className:"border-t bg-card",children:l.map((R,T)=>t.jsx(us,{build:R,isLast:T===l.length-1,onNavigate:o,onStatusChange:y,onScheduleDeletion:d,onCancelDeletion:j,statusDescribedBy:(r==null?void 0:r.buildId)===R.id?r.id:void 0},R.id))}),e[16]=l,e[17]=i,e[18]=j,e[19]=o,e[20]=d,e[21]=y,e[22]=p,e[23]=r,e[24]=O):O=e[24];let M;return e[25]!==k||e[26]!==O?(M=t.jsxs("div",{className:"rounded-lg shadow-card-2 overflow-hidden",children:[k,O]}),e[25]=k,e[26]=O,e[27]=M):M=e[27],M}const ut="tapflow-app-center-releases:";function fs(a){try{const e=JSON.parse(localStorage.getItem(ut+a)??"[]");return Array.isArray(e)?e.filter(s=>Array.isArray(s)&&s.length===2&&typeof s[0]=="string"&&typeof s[1]=="boolean"):[]}catch{return[]}}function ms(a,e){try{localStorage.setItem(ut+a,JSON.stringify(e))}catch{}}function ps(a,e){const s=Se.c(13),[l,i]=c.useState(xs);let g;s[0]!==a||s[1]!==l?(g=a===null?[]:l.get(a)??fs(a),s[0]=a,s[1]=l,s[2]=g):g=s[2];const o=g,y=e[0];let d;s[3]!==y||s[4]!==o?(d=b=>{var h;return((h=o.find(v=>{const[C]=v;return C===b}))==null?void 0:h[1])??b===y},s[3]=y,s[4]=o,s[5]=d):d=s[5];const j=d;let x;s[6]!==a||s[7]!==j||s[8]!==o?(x=b=>{if(a===null)return;const h=[...o.filter(v=>{const[C]=v;return C!==b}),[b,!j(b)]].slice(-200);ms(a,h),i(v=>new Map(v).set(a,h))},s[6]=a,s[7]=j,s[8]=o,s[9]=x):x=s[9];const r=x;let p;return s[10]!==j||s[11]!==r?(p={isOpen:j,toggle:r},s[10]=j,s[11]=r,s[12]=p):p=s[12],p}function xs(){return new Map}const _e=a=>`row:${a}`,Ae=a=>`release:${a}`;function Ge(a){return a instanceof HTMLElement?a.dataset.statusTrigger!==void 0?_e(Number(a.dataset.statusTrigger)):a.dataset.releaseHeader!==void 0?Ae(a.dataset.releaseHeader):null:null}function We(a,e){const s=new Set(JSON.parse(e));return a.find(l=>s.has(l))??null}function Xe(a,e){return a.map((s,l)=>({item:s,d:l>e?2*(l-e)-1:2*(e-l)})).filter(({d:s})=>s>0).sort((s,l)=>s.d-l.d).map(({item:s})=>s)}function ks(){var Ke;const a=Xt(),[e,s]=Yt(),l=et(),[i,g]=c.useState(""),[o,y]=c.useState(""),[d,j]=c.useState("all");c.useEffect(()=>{const n=setTimeout(()=>y(i),250);return()=>clearTimeout(n)},[i]);const x=e.get("appId"),r=x!==null&&/^[1-9][0-9]*$/.test(x)?Number(x):null,p=Je({queryKey:["apps"],queryFn:Ot}),b=p.data??[],h=b.find(n=>n.id===r)??null,v=["builds",r,o,d],C=JSON.stringify(v),f=Je({queryKey:v,queryFn:()=>Rt({appId:r,search:o,statusFilter:d}),enabled:r!==null,placeholderData:Et}),k=f.data??[];c.useEffect(()=>{!p.data||e.get("appId")||p.data.length===0||s({appId:String(p.data[0].id)},{replace:!0})},[p.data,e,s]);const[O,M]=c.useState(null),[R,T]=c.useState(!1);c.useEffect(()=>{f.isRefetchError&&oe.error("Couldn't refresh builds — showing the last list",{id:"builds:refresh"})},[f.isRefetchError]);const z=c.useRef(null);c.useEffect(()=>{r===null||f.isPlaceholderData||!f.data||z.current!==r&&(z.current=r,M(r))},[r,f.isPlaceholderData,f.data]);function Y(n){s({appId:String(n)})}function K(n,m){return{onMutate:async u=>{const S=v;await l.cancelQueries({queryKey:S});const _=l.getQueryData(S);return l.setQueryData(S,X=>X&&n(X,u)),{previous:_,key:S}},onError:(u,S,_)=>{_!=null&&_.previous&&l.setQueryData(_.key,_.previous),oe.error(m)},onSettled:()=>{l.invalidateQueries({queryKey:["builds"]})}}}const G=K((n,m)=>n.map(u=>u.id===m.buildId?{...u,status_label:m.status}:u),"Failed to update status"),V=Me({mutationFn:({buildId:n,status:m})=>It(n,m),...G,onError:(n,m,u)=>{var S;G.onError(n,m,u),((S=I.current)==null?void 0:S.leaving)===m.buildId&&(I.current=null,D(null))}}),L=(n,m)=>{var S;const u=(S=l.getQueryData(n))==null?void 0:S.find(_=>_.id===m);return u?Pe(u):"the build"},Z=Me({mutationFn:n=>At(n),...K((n,m)=>n.map(u=>u.id===m?{...u,delete_after:new Date().toISOString()}:u),"Failed to schedule deletion"),onSuccess:(n,m,u)=>{u&&(l.setQueryData(u.key,S=>S==null?void 0:S.map(_=>_.id===m?{..._,delete_after:n}:_)),oe.success(`Deletion scheduled for ${L(u.key,m)} — it will be deleted ${Pt(n)}`))}}),Q=Me({mutationFn:n=>_t(n),...K((n,m)=>n.map(u=>u.id===m?{...u,delete_after:null}:u),"Failed to cancel scheduled deletion"),onSuccess:(n,m,u)=>{oe.success(`Scheduled deletion cancelled for ${u?L(u.key,m):"the build"}`)}}),P=n=>Z.mutate(n),U=n=>Q.mutate(n),A=kt(k),B=ps(((Ke=k[0])==null?void 0:Ke.app_id)??null,A.map(n=>n.versionName)),I=c.useRef(null),F=c.useRef(null),[w,D]=c.useState(null),q=c.useRef(null),ae=c.useId();function ue(n){const m=A.findIndex(S=>S.builds.some(_=>_.id===n));if(m<0)return[];const u=A[m].builds;return[...Xe(u,u.findIndex(S=>S.id===n)).map(S=>_e(S.id)),...Xe(A,m).map(S=>Ae(S.versionName))]}const ee=JSON.stringify(A.flatMap(n=>[Ae(n.versionName),...B.isOpen(n.versionName)?n.builds.map(m=>_e(m.id)):[]])),he=(n,m)=>{const u=k.find(X=>X.id===n),_=d!=="all"&&m!==d?ue(n):[];if(u&&_.length>0){const X=`${Pe(u)} was set to ${m??"no status"}, so the ${d} filter no longer shows it.`,Qe={leaving:n,candidates:_,text:X,key:C};I.current=Qe,F.current=null,D(Qe)}V.mutate({buildId:n,status:m})},xe=w!==null&&!k.some(n=>n.id===w.leaving),H=xe?We(w.candidates,ee):null,ne=f.data,be=f.isRefetchError;c.useLayoutEffect(()=>{var _;const n=I.current;if(!n)return;if(n.key!==C||be){I.current=null,D(null);return}if((ne??[]).some(X=>X.id===n.leaving))return;I.current=null;const m=We(n.candidates,ee);if(!m||document.activeElement!==null&&document.activeElement!==document.body){oe.success(n.text),D(null);return}const u=((_=q.current)==null?void 0:_.querySelectorAll("[data-status-trigger], [data-release-header]"))??[],S=Array.from(u).find(X=>Ge(X)===m);S instanceof HTMLElement?(F.current=m,S.focus()):(oe.success(n.text),D(null))},[C,be,ne,ee]),c.useEffect(()=>{if(!w)return;const n=m=>{const u=Ge(m.target);if(F.current!==null){u!==F.current&&D(null);return}u!==_e(w.leaving)&&(u===null||!w.candidates.includes(u))&&D(null)};return document.addEventListener("focusin",n),()=>document.removeEventListener("focusin",n)},[w]);const J=(h==null?void 0:h.name)??"this app",te=o!==""||d!=="all",ie=f.isPlaceholderData&&O!==r,Ne=f.isFetchedAfterMount&&(f.isPlaceholderData||f.isLoading),se=R||Ne,W=f.isLoadingError||se?"error":f.isLoading||A.length===0&&ie?"loading":A.length===0?"empty":"list",re=c.useRef(null),je=Wt(W,re),we=c.useId(),fe=c.useId(),ze=c.useId(),Le=c.useId(),qe=c.useId(),ht=r===null?"":f.isLoadingError?`Couldn't load builds for ${J}`:f.isLoading||ie||se?`Loading builds for ${J}`:A.length>0?`Showing ${k.length} build${k.length===1?"":"s"} for ${J}`:te?`No builds match the current filters for ${J}`:`No builds for ${J}`;return t.jsxs("div",{className:"flex h-full gap-0",children:[t.jsx(ds,{apps:b,selectedAppId:r,onSelect:Y,onAdd:()=>l.invalidateQueries({queryKey:["apps"]})}),t.jsxs("div",{className:"flex-1 flex flex-col gap-4 p-4 overflow-y-auto min-w-0",children:[t.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[t.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:h?h.name:"App Center"}),t.jsx(ns,{onSuccess:()=>{l.invalidateQueries({queryKey:["apps"]}),l.invalidateQueries({queryKey:["builds"]})},appId:r})]}),t.jsx("p",{id:qe,role:"status",className:"sr-only",children:ht}),r===null?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(ts,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{className:"text-sm font-medium",children:"No app selected"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:"Choose an app from the sidebar to view its builds."})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-wrap gap-2",children:[t.jsx(Mt,{ref:re,"aria-describedby":`${Le} ${ze}`,"aria-label":"Search versions",placeholder:"Search version…",value:i,onChange:g}),t.jsxs(Te,{value:d,onValueChange:j,children:[t.jsx(Oe,{className:"h-8 w-36","aria-label":"Filter by status",children:t.jsx(Ee,{placeholder:"Status"})}),t.jsxs(Re,{children:[t.jsx(E,{value:"all",children:"All statuses"}),t.jsx(E,{value:"Backlog",children:"Backlog"}),t.jsx(E,{value:"In Progress",children:"In Progress"}),t.jsx(E,{value:"Done",children:"Done"}),t.jsx(E,{value:"Rejected",children:"Rejected"})]})]}),f.isRefetchError&&t.jsx("p",{className:"text-sm text-muted-foreground self-center",children:"Showing the last list — refresh failed."})]}),t.jsx("div",{...je,className:"contents",children:W==="error"?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(es,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{id:we,className:"text-sm font-medium",children:"Couldn't load builds"}),t.jsx("p",{id:fe,className:"text-sm text-muted-foreground",children:"Check that the relay is reachable."}),t.jsx(pe,{variant:"outline",size:"sm",className:"mt-1 aria-disabled:opacity-50","aria-describedby":`${we} ${fe}`,"aria-disabled":se,onClick:()=>{se||(T(!0),f.refetch().finally(()=>T(!1)))},children:se?"Trying…":"Try again"})]}):W==="loading"?t.jsx("p",{id:Le,className:"text-sm text-muted-foreground",children:"Loading…"}):W==="empty"?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-2 text-center",children:[t.jsx(ss,{className:"w-8 h-8 text-muted-foreground/40"}),t.jsx("p",{id:ze,className:"text-sm font-medium",children:te?"No matching builds":"No builds yet"}),t.jsx("p",{className:"text-sm text-muted-foreground",children:te?"No build matches the search and status filters.":"Upload the first build to get started."})]}):t.jsxs("div",{ref:q,className:"flex flex-col gap-2","aria-busy":f.isPlaceholderData,children:[xe&&t.jsx("p",{id:ae,hidden:!0,children:w.text}),A.map(({versionName:n,builds:m},u)=>t.jsx(hs,{describedBy:[u===0&&!f.isPlaceholderData?qe:null,H===Ae(n)?ae:null].filter(Boolean).join(" ")||void 0,rowNote:H!=null&&H.startsWith("row:")?{buildId:Number(H.slice(4)),id:ae}:void 0,versionName:n,builds:m,isOpen:B.isOpen(n),onToggle:()=>B.toggle(n),onNavigate:S=>a(`/app-center/build?id=${S}`),onStatusChange:he,onScheduleDeletion:P,onCancelDeletion:U},n))]})})]})]})]})}export{ks as AppCenter};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as m,j as e}from"./vendor-react-BlPSzrEe.js";import{aM as ce,aw as me,aH as ue,aG as J,aD as A,au as k,aJ as pe,C as y,c as b,d as N,a as S,L as c,I as u,F as p,S as G,h as Y,at as i,B as f,H as ge,O as fe,K as he,ao as g,an as F,_ as Z,as as h,ae as xe,a5 as je}from"./index-COOWQXpW.js";import{B as ve}from"./badge-B4QAWrzA.js";import{A as we,h as ye,c as be,f as Ne,g as Se,d as Pe,e as Ce,b as Ae,a as ke}from"./alert-dialog-CwcUyDZQ.js";import{P as X}from"./pencil-CAHyK7Qf.js";import"./vendor-router-B_lVHrKl.js";const Fe=F({teamName:h().min(1,"Team name is required"),logo:Z(File).nullable().optional()}),De=F({displayName:h().min(1,"Display name is required"),avatar:Z(File).nullable().optional()}),qe=F({currentPassword:h().min(1,"Enter your current password"),newPassword:h().min(8,"Password must be at least 8 characters"),confirmPassword:h()}).refine(x=>x.newPassword===x.confirmPassword,{message:"Passwords do not match",path:["confirmPassword"]});function Be(){var O,U,H,M,V,W,$;const{resolvedTheme:x}=ce(),I=x==="dark"?"/logo-dark.svg":"/logo.svg",{user:o}=me(),D=(o==null?void 0:o.role)==="Admin",q=(o==null?void 0:o.role)==="Admin"||(o==null?void 0:o.role)==="Developer",j=ue(),P=J({queryKey:g.settings,queryFn:xe,enabled:D}),[ee,se]=m.useState(null),re=ee??((O=P.data)==null?void 0:O.logo_url)??null,T=m.useRef(null),d=A({resolver:k(Fe),defaultValues:{teamName:"",logo:null},values:P.data?{teamName:P.data.team_name,logo:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ae(s){const r=new FormData;r.append("team_name",s.teamName),s.logo&&r.append("logo",s.logo);try{if(!(await fetch("/api/v1/settings",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update workspace");return}i.success("Workspace updated"),j.invalidateQueries({queryKey:g.settings})}catch{i.error("Failed to update workspace")}}const[te,oe]=m.useState(null),E=te??(o==null?void 0:o.avatarUrl)??null,L=m.useRef(null),l=A({resolver:k(De),defaultValues:{displayName:"",avatar:null},values:o?{displayName:o.displayName??"",avatar:null}:void 0,resetOptions:{keepDirtyValues:!0}});async function ie(s){const r=new FormData;r.append("display_name",s.displayName),s.avatar&&r.append("avatar",s.avatar);try{if(!(await fetch("/api/v1/profile",{method:"PATCH",credentials:"include",body:r})).ok){i.error("Failed to update profile");return}i.success("Profile updated"),j.invalidateQueries({queryKey:g.me})}catch{i.error("Failed to update profile")}}const t=A({resolver:k(qe)});async function ne(s){try{const r=await fetch("/api/v1/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({currentPassword:s.currentPassword,newPassword:s.newPassword})});if(!r.ok){const a=await r.json();t.setError("root",{message:a.error??"Failed to change password"});return}t.reset(),i.success("Password changed")}catch{t.setError("root",{message:"Network error"})}}const C=J({queryKey:g.apps,queryFn:je,enabled:q}).data??[],[Q,_]=m.useState({}),[z,R]=m.useState({}),[B,K]=m.useState({});async function le(s){K(r=>({...r,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"DELETE",credentials:"include"})).ok){i.error("Failed to delete app");return}j.invalidateQueries({queryKey:g.apps}),i.success("App deleted")}catch{i.error("Failed to delete app")}finally{K(r=>({...r,[s]:!1}))}}async function de(s){var r;R(a=>({...a,[s]:!0}));try{if(!(await fetch(`/api/v1/apps/${s}`,{method:"PATCH",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:Q[s]??((r=C.find(n=>n.id===s))==null?void 0:r.name)})})).ok){i.error("Failed to update app");return}i.success("App updated"),_(({[s]:n,...w})=>w),j.invalidateQueries({queryKey:g.apps})}catch{i.error("Failed to update app")}finally{R(a=>({...a,[s]:!1}))}}const v=pe({control:l.control,name:"displayName"});return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsx("h1",{className:"text-xl font-semibold tracking-display-sm",children:"Settings"}),D&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Workspace"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:d.handleSubmit(ae),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"team-name",children:"Team name"}),e.jsx(u,{id:"team-name",placeholder:"My QA Team","aria-required":"true","aria-invalid":!!d.formState.errors.teamName,"aria-describedby":d.formState.errors.teamName?"teamName-error":void 0,...d.register("teamName")}),e.jsx(p,{id:"teamName-error",message:(U=d.formState.errors.teamName)==null?void 0:U.message})]}),e.jsx(G,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Logo ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"logo",control:d.control,render:({field:s})=>e.jsxs("div",{className:"relative w-16 h-16",children:[e.jsx("img",{src:re??I,alt:"Workspace logo",className:"w-16 h-16 rounded-lg object-contain"}),e.jsx("button",{type:"button","aria-label":"Change logo",onClick:()=>{var r;return(r=T.current)==null?void 0:r.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:T,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:r=>{var n;const a=(n=r.target.files)==null?void 0:n[0];if(a&&a.size>2*1024*1024){i.error("Image must be 2MB or less");return}a&&(s.onChange(a),se(URL.createObjectURL(a)))}})]})})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:d.formState.isSubmitting,children:d.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Profile"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:l.handleSubmit(ie),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"display-name",children:"Nickname"}),e.jsx(u,{id:"display-name",placeholder:"Your name","aria-required":"true","aria-invalid":!!l.formState.errors.displayName,"aria-describedby":l.formState.errors.displayName?"displayName-error":void 0,...l.register("displayName")}),e.jsx(p,{id:"displayName-error",message:(H=l.formState.errors.displayName)==null?void 0:H.message})]}),e.jsx(G,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(c,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"avatar",control:l.control,render:({field:s})=>{var r;return e.jsxs("div",{className:"relative w-14 h-14",children:[E?e.jsx("img",{src:E,alt:"Profile avatar",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const a=ge(v||(o==null?void 0:o.email)||"");return{backgroundColor:a.bg,color:a.fg}})(),children:((r=v==null?void 0:v[0])==null?void 0:r.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":"Change avatar",onClick:()=>{var a;return(a=L.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(X,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:L,type:"file",accept:".png,.jpg,.jpeg",className:"hidden",onChange:a=>{var w;const n=(w=a.target.files)==null?void 0:w[0];if(n&&n.size>2*1024*1024){i.error("Image must be 2MB or less");return}n&&(s.onChange(n),oe(URL.createObjectURL(n)))}})]})}})]}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:l.formState.isSubmitting,children:l.formState.isSubmitting?"Saving…":"Save changes"})})]})})]}),e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Password"})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:t.handleSubmit(ne),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"current-password",children:"Current password"}),e.jsx(u,{id:"current-password",type:"password","aria-required":"true",autoComplete:"current-password","aria-invalid":!!t.formState.errors.currentPassword,"aria-describedby":t.formState.errors.currentPassword?"currentPassword-error":void 0,...t.register("currentPassword")}),e.jsx(p,{id:"currentPassword-error",message:(M=t.formState.errors.currentPassword)==null?void 0:M.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"new-password",children:"New password"}),e.jsx(u,{id:"new-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.newPassword,"aria-describedby":t.formState.errors.newPassword?"newPassword-error":void 0,...t.register("newPassword")}),e.jsx(p,{id:"newPassword-error",message:(V=t.formState.errors.newPassword)==null?void 0:V.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(c,{htmlFor:"confirm-password",children:"Confirm new password"}),e.jsx(u,{id:"confirm-password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!t.formState.errors.confirmPassword,"aria-describedby":t.formState.errors.confirmPassword?"confirmPassword-error":void 0,...t.register("confirmPassword")}),e.jsx(p,{id:"confirmPassword-error",message:(W=t.formState.errors.confirmPassword)==null?void 0:W.message})]}),e.jsx(p,{assertive:!0,id:"default-error",message:($=t.formState.errors.root)==null?void 0:$.message}),e.jsx("div",{className:"flex justify-end",children:e.jsx(f,{type:"submit",size:"sm",disabled:t.formState.isSubmitting,children:t.formState.isSubmitting?"Saving…":"Change password"})})]})})]}),q&&C.length>0&&e.jsxs(y,{children:[e.jsx(b,{children:e.jsx(N,{children:"Apps"})}),e.jsx(S,{children:e.jsx("div",{className:"flex flex-col divide-y divide-border",children:C.map(s=>e.jsxs("div",{className:"flex flex-col gap-2 py-4 first:pt-0 last:pb-0",children:[e.jsx(c,{htmlFor:`app-${s.id}`,children:"App Name"}),e.jsx(u,{id:`app-${s.id}`,value:Q[s.id]??s.name,onChange:r=>_(a=>({...a,[s.id]:r.target.value}))}),e.jsxs("div",{className:"flex flex-col gap-1.5 mt-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground font-mono",children:s.bundle_id_key}),e.jsx(ve,{tone:s.platform==="ios"?"ios":s.platform==="android"?"android":void 0,variant:s.platform==="both"?"secondary":void 0,className:"capitalize",children:s.platform})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(f,{size:"sm",variant:"outline",disabled:z[s.id],onClick:()=>de(s.id),children:z[s.id]?"Saving…":"Save"}),e.jsxs(we,{children:[e.jsx(ye,{asChild:!0,children:e.jsx(f,{size:"sm",variant:"destructive",disabled:B[s.id],children:B[s.id]?"Deleting…":"Delete"})}),e.jsxs(be,{children:[e.jsxs(Ne,{children:[e.jsx(Se,{children:"Delete app?"}),e.jsxs(Pe,{children:["This will permanently delete ",e.jsx("strong",{children:s.name})," and all its builds. This action cannot be undone."]})]}),e.jsxs(Ce,{children:[e.jsx(Ae,{className:"w-24",children:"Cancel"}),e.jsx(ke,{className:fe(he({variant:"destructive"}),"w-24"),onClick:()=>le(s.id),children:"Delete"})]})]})]})]})]})]},s.id))})})]})]})}export{Be as DefaultSettings};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as S,j as e}from"./vendor-react-BlPSzrEe.js";import{aD as H,au as M,aJ as Q,aH as U,aG as _,C as F,c as q,d as I,b as R,a as O,L as d,I as v,h as Y,H as z,F as c,S as G,B as J,ao as T,an as V,as as h,_ as W,aK as X}from"./index-COOWQXpW.js";import{b as Z,c as $}from"./vendor-router-B_lVHrKl.js";import{P as ee}from"./pencil-CAHyK7Qf.js";const ae=V({displayName:h().optional(),avatar:W(File).nullable().optional(),password:h().min(8,"Password must be at least 8 characters"),confirm:h()}).refine(o=>o.password===o.confirm,{message:"Passwords do not match",path:["confirm"]});function ne(){var y,b,N,C,k;const o=Z(),[E]=$(),t=E.get("token")??"",[f,A]=S.useState(null),x=S.useRef(null),{register:m,handleSubmit:B,control:g,setError:u,formState:{errors:s,isSubmitting:j}}=H({resolver:M(ae),defaultValues:{displayName:"",avatar:null}}),l=Q({control:g,name:"displayName"})??"",K=U(),p=_({queryKey:T.inviteToken(t),queryFn:()=>X(t),enabled:t!=="",staleTime:1/0}),w=!t||p.isError?"invalid":p.isPending?"loading":"valid",L=((y=p.data)==null?void 0:y.role)??"";async function D(r){var i;try{const a=new FormData;if(a.append("token",t),a.append("password",r.password),(i=r.displayName)!=null&&i.trim()&&a.append("display_name",r.displayName.trim()),r.avatar&&a.append("avatar",r.avatar),!(await fetch("/api/v1/invitations/accept",{method:"POST",body:a})).ok){u("root",{message:"Failed to accept invitation"});return}K.removeQueries({queryKey:T.inviteToken(t)}),o("/app-center",{replace:!0})}catch{u("root",{message:"Network error. Please try again."})}}return w==="loading"?e.jsx("div",{className:"flex min-h-svh items-center justify-center"}):w==="invalid"?e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsx(F,{level:4,className:"w-full max-w-sm text-center",children:e.jsxs(q,{children:[e.jsx(I,{children:"Invitation expired"}),e.jsx(R,{children:"This invite link is invalid or has expired. Ask your admin for a new one."})]})})}):e.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs(F,{level:4,className:"w-full max-w-sm",children:[e.jsxs(q,{className:"text-center",children:[e.jsx(I,{children:"Set up your account"}),e.jsxs(R,{children:["You're joining as ",e.jsx("strong",{children:L})]})]}),e.jsx(O,{children:e.jsxs("form",{onSubmit:B(D),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{htmlFor:"display-name",children:["Nickname ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional)"})]}),e.jsx(v,{id:"display-name",placeholder:"Your name",...m("displayName")})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsxs(d,{children:["Avatar ",e.jsx("span",{className:"text-muted-foreground text-xs",children:"(optional, png · jpg, max 2MB)"})]}),e.jsx(Y,{name:"avatar",control:g,render:({field:r})=>{var i;return e.jsxs("div",{className:"relative w-14 h-14",children:[f?e.jsx("img",{src:f,alt:"Avatar preview",className:"w-14 h-14 rounded-full object-cover border"}):e.jsx("div",{className:"w-14 h-14 rounded-full flex items-center justify-center text-lg font-medium",style:(()=>{const a=z(l);return{backgroundColor:a.bg,color:a.fg}})(),children:((i=l==null?void 0:l[0])==null?void 0:i.toUpperCase())??"?"}),e.jsx("button",{type:"button","aria-label":s.avatar?"Change avatar — the file was rejected":"Change avatar","aria-describedby":s.avatar?"avatar-error":void 0,onClick:()=>{var a;return(a=x.current)==null?void 0:a.click()},className:"absolute bottom-0 right-0 w-6 h-6 rounded-full bg-background border border-border shadow-sm flex items-center justify-center hover:bg-accent transition-colors",children:e.jsx(ee,{className:"w-3 h-3","aria-hidden":"true"})}),e.jsx("input",{ref:x,type:"file",accept:"image/png,image/jpeg",className:"hidden",onChange:a=>{var P;const n=(P=a.target.files)==null?void 0:P[0];if(n){if(n.size>2*1024*1024){u("avatar",{message:"Max 2MB for avatar"});return}r.onChange(n),A(URL.createObjectURL(n))}}})]})}}),e.jsx(c,{assertive:!0,id:"avatar-error",message:(b=s.avatar)==null?void 0:b.message})]}),e.jsx(G,{}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"password",children:"Password"}),e.jsx(v,{id:"password",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.password,"aria-describedby":s.password?"password-error":void 0,...m("password")}),e.jsx(c,{id:"password-error",message:(N=s.password)==null?void 0:N.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(d,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(v,{id:"confirm",type:"password","aria-required":"true",autoComplete:"new-password","aria-invalid":!!s.confirm,"aria-describedby":s.confirm?"confirm-error":void 0,...m("confirm")}),e.jsx(c,{id:"confirm-error",message:(C=s.confirm)==null?void 0:C.message})]}),e.jsx(c,{assertive:!0,id:"invite-error",message:(k=s.root)==null?void 0:k.message}),e.jsx(J,{type:"submit",disabled:j,className:"w-full",children:j?"Creating account…":"Create account"})]})})]})})}export{ne as Invite};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as N,f as Xe,j as s}from"./vendor-react-BlPSzrEe.js";import{ax as Lt,aG as bt,aH as Et,M as Tt,ab as Rt,ao as Qe,ad as Ot}from"./index-COOWQXpW.js";import{R as Ct,u as Dt,T as It,b as Pt,c as Kt}from"./resource-health-BRpSwarg.js";import{t as Ft,i as jt,j as Ht,h as Ut,g as Bt,f as _t,l as Gt,P as qt,e as Qt,G as Wt,A as Xt,m as wt,d as Vt,a as zt,b as Yt,L as Jt,B as Zt,c as es}from"./vendor-charts-BykzUV2D.js";import"./vendor-router-B_lVHrKl.js";const ts=t=>(document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t));function ss(){return N.useSyncExternalStore(ts,ls,ns)}function ns(){return!0}function ls(){return document.visibilityState!=="hidden"}function os(t,e){const o=Xe.c(4),[m,y]=N.useState(as);let i,n;return o[0]!==e||o[1]!==t?(i=()=>{if(!e)return;y(Date.now());const h=setInterval(()=>y(Date.now()),t);return()=>clearInterval(h)},n=[t,e],o[0]=e,o[1]=t,o[2]=i,o[3]=n):(i=o[2],n=o[3]),N.useEffect(i,n),m}function as(){return Date.now()}const xt={"1h":36e5,"6h":216e5,"24h":864e5,"7d":6048e5},rs={"1h":Ht.every(10),"6h":jt,"24h":jt.every(3),"7d":Ft};function is(t,e,o){return rs[o].range(new Date(t),new Date(e+1))}function cs(t,e){const o=new Date(t);return e==="7d"?`${o.getMonth()+1}/${o.getDate()}`:`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}`}const ds=2e3;function us(t){return Math.min(1e4,Math.max(1e3,xt[t]/ds))}const fs={"1h":6e4,"6h":6e4,"24h":3e5,"7d":9e5},pt=t=>Math.round(t*10)/10;function ms(t,e,o){let m;for(const i of t){const n=i.agentName===e?i.resources:void 0;n&&(!m||n.reportedAt>m.reportedAt)&&(m=n)}if(!m||o-m.reportedAt>Ct)return null;const y=i=>Number.isFinite(i)?pt(i):null;return{cpu:y(m.cpuPercent),mem:y(m.memUsedMB/m.memTotalMB*100)}}const $t={cpu:{label:"CPU",color:"#60a5fa"},mem:{label:"RAM",color:"#a78bfa"}},At={"1h":"1h","6h":"6h","24h":"24h","7d":"7d"};function Ls(){const t=Xe.c(65);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[o,m]=N.useState(e),[y,i]=N.useState(null),[n,h]=N.useState("24h"),O=ss();let k;t[1]!==n?(k=us(n),t[1]=n,t[2]=k):k=t[2];const x=os(k,O),{setNode:b}=Lt();let p,j;t[3]!==b?(p=()=>(b(s.jsx("span",{className:"text-sm font-medium",children:"Mac Resources"})),()=>b(null)),j=[b],t[3]=b,t[4]=p,t[5]=j):(p=t[4],j=t[5]),N.useEffect(p,j);let C;t[6]===Symbol.for("react.memo_cache_sentinel")?(C=u=>{u.type==="agents:listed"&&m(u.sessions??[])},t[6]=C):C=t[6];const Q=C,{send:E,connected:T}=Dt(Q);let ie,ce;t[7]!==T||t[8]!==E?(ie=()=>{if(!T)return;E({type:"agents:list"});const u=setInterval(()=>E({type:"agents:list"}),1e4);return()=>clearInterval(u)},ce=[T,E],t[7]=T,t[8]=E,t[9]=ie,t[10]=ce):(ie=t[9],ce=t[10]),N.useEffect(ie,ce);let le;t[11]===Symbol.for("react.memo_cache_sentinel")?(le={queryKey:Qe.agents,queryFn:Rt,refetchOnWindowFocus:!1},t[11]=le):le=t[11];const W=bt(le);let c,d,F,oe;t[12]!==W.data||t[13]!==o?(F=W.data??[],d=o.map(ps).filter(Boolean),c=[...new Set([...d,...F])],oe=new Set(d),t[12]=W.data,t[13]=o,t[14]=c,t[15]=d,t[16]=F,t[17]=oe):(c=t[14],d=t[15],F=t[16],oe=t[17]);const w=oe,l=y??(W.isPending?null:F[0]??d[0]??null),H=Et();let Z;t[18]!==n||t[19]!==l?(Z=l?Qe.resourceHistory(l,n):null,t[18]=n,t[19]=l,t[20]=Z):Z=t[20];const ee=Z;let D;t[21]!==ee||t[22]!==n?(D=ee??Qe.resourceHistory("",n),t[21]=ee,t[22]=n,t[23]=D):D=t[23];let U;t[24]!==n||t[25]!==l?(U=u=>{const{signal:L}=u;return Ot(l,n,L)},t[24]=n,t[25]=l,t[26]=U):U=t[26];let X;t[27]!==D||t[28]!==U?(X={queryKey:D,queryFn:U,enabled:!1},t[27]=D,t[28]=U,t[29]=X):X=t[29];const I=bt(X),B=I.refetch;let P,V;t[30]!==H||t[31]!==n||t[32]!==B||t[33]!==l||t[34]!==O?(P=()=>{if(!l||!O)return;const u=Qe.resourceHistory(l,n),L=fs[n],q=()=>{const ne=H.getQueryState(u);(ne==null?void 0:ne.fetchStatus)==="fetching"&&ne.data===void 0?H.cancelQueries({queryKey:u,exact:!0}).then(()=>B()):B({cancelRefetch:!0})},g=H.getQueryState(u),ae=Math.max((g==null?void 0:g.dataUpdatedAt)??0,(g==null?void 0:g.errorUpdatedAt)??0),se=(g==null?void 0:g.data)!==void 0&&ae>0?Math.max(0,L-(Date.now()-ae)):0;let de;const re=()=>{q(),de=setInterval(q,L)},Ve=se>0?setTimeout(re,se):void 0;return se===0&&re(),()=>{clearTimeout(Ve),clearInterval(de),H.cancelQueries({queryKey:u,exact:!0})}},V=[l,n,O,B,H],t[30]=H,t[31]=n,t[32]=B,t[33]=l,t[34]=O,t[35]=P,t[36]=V):(P=t[35],V=t[36]),N.useEffect(P,V);const S=I.data!==void 0||I.isError,te=ee!==null&&!S;let r;t[37]!==I.data?(r=I.data??[],t[37]=I.data,t[38]=r):r=t[38];let z;t[39]!==r?(z=r.map(xs),t[39]=r,t[40]=z):z=t[40];const G=z;let Y;t[41]!==x||t[42]!==l||t[43]!==o?(Y=l?ms(o,l,x):null,t[41]=x,t[42]=l,t[43]=o,t[44]=Y):Y=t[44];const f=Y;let _;t[45]===Symbol.for("react.memo_cache_sentinel")?(_=s.jsx("h1",{className:"sr-only",children:"Mac Resources"}),t[45]=_):_=t[45];let v;t[46]===Symbol.for("react.memo_cache_sentinel")?(v=s.jsx("h2",{id:"macs-heading",className:"px-2 pb-1 font-mono text-xs font-medium text-muted-foreground uppercase tracking-wider",children:"Macs"}),t[46]=v):v=t[46];let M;t[47]!==c||t[48]!==T||t[49]!==w||t[50]!==l?(M=c.length===0?s.jsx("span",{className:"px-2 text-sm text-muted-foreground",children:T?"No agents yet.":"Connecting…"}):c.map(u=>{const L=w.has(u),q=l===u;return s.jsxs("button",{onClick:()=>i(u),"aria-current":q?"true":void 0,className:["flex items-center gap-2 rounded-md px-2 py-2 text-left text-sm hover:bg-accent transition-colors",q?"bg-accent font-medium":""].join(" "),children:[s.jsx("span",{className:`inline-block h-1.5 w-1.5 shrink-0 rounded-full ${L?"bg-emerald-400":"bg-muted-foreground/40"}`,"aria-hidden":"true"}),s.jsx("span",{className:"truncate min-w-0",children:u}),s.jsx("span",{className:"sr-only",children:L?"Online":"Offline"})]},u)}),t[47]=c,t[48]=T,t[49]=w,t[50]=l,t[51]=M):M=t[51];let $;t[52]!==M?($=s.jsxs("aside",{"aria-labelledby":"macs-heading",className:"w-64 shrink-0 border-r flex flex-col gap-1 p-3 overflow-y-auto",children:[v,M]}),t[52]=M,t[53]=$):$=t[53];let A;t[54]!==G||t[55]!==(f==null?void 0:f.cpu)||t[56]!==(f==null?void 0:f.mem)||t[57]!==te||t[58]!==x||t[59]!==n||t[60]!==l?(A=s.jsx("div",{className:"flex-1 min-w-0 overflow-auto",children:l?s.jsxs("div",{className:"flex flex-col gap-6 p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("h2",{className:"text-base font-semibold",children:l}),s.jsx(It,{value:n,onValueChange:u=>h(u),children:s.jsx(Pt,{children:Object.keys(At).map(hs)})})]}),te?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"Loading…"}):G.length===0?s.jsx("div",{className:"flex h-40 items-center justify-center text-sm text-muted-foreground",children:"No data yet for this range. Data is collected every minute while the agent is connected."}):s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(Nt,{title:"CPU %",color:"cpu",data:G,dataKey:"cpu",range:n,now:x,live:(f==null?void 0:f.cpu)??null}),s.jsx(Nt,{title:"RAM %",color:"mem",data:G,dataKey:"mem",range:n,now:x,live:(f==null?void 0:f.mem)??null})]})]}):s.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-muted-foreground",children:[s.jsx(Tt,{className:"h-8 w-8"}),s.jsx("p",{className:"text-sm",children:"Select a Mac to view resource history."})]})}),t[54]=G,t[55]=f==null?void 0:f.cpu,t[56]=f==null?void 0:f.mem,t[57]=te,t[58]=x,t[59]=n,t[60]=l,t[61]=A):A=t[61];let J;return t[62]!==$||t[63]!==A?(J=s.jsxs("div",{className:"flex h-full min-h-0",children:[_,$,A]}),t[62]=$,t[63]=A,t[64]=J):J=t[64],J}function hs(t){return s.jsx(Kt,{value:t,children:At[t]},t)}function xs(t){return{time:t.recorded_at,cpu:pt(t.cpu_percent),mem:pt(t.mem_percent)}}function ps(t){return t.agentName}const gt=t=>new Date(t.time).getTime(),St=t=>new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}),We=t=>`${Math.round(t*10)/10}%`,gs=_t(gt).left,ys=_t(t=>t.t).left,K={top:8,right:24,bottom:24,left:40},kt=16,Mt=6,vs=20,bs=40;function Nt(t){const e=Xe.c(18),{title:o,color:m,data:y,dataKey:i,range:n,now:h,live:O}=t,k=$t[m].color;let x;e[0]!==k?(x=s.jsx("span",{className:"inline-block h-2.5 w-2.5 rounded-full",style:{background:k}}),e[0]=k,e[1]=x):x=e[1];let b;e[2]!==o?(b=s.jsx("h2",{className:"text-sm font-medium",children:o}),e[2]=o,e[3]=b):b=e[3];let p;e[4]!==x||e[5]!==b?(p=s.jsxs("div",{className:"flex items-center gap-2",children:[x,b]}),e[4]=x,e[5]=b,e[6]=p):p=e[6];let j;e[7]!==y||e[8]!==i||e[9]!==k||e[10]!==O||e[11]!==h||e[12]!==n||e[13]!==o?(j=s.jsx("div",{className:"relative h-[220px] w-full",children:s.jsx(qt,{children:Q=>{const{width:E,height:T}=Q;return E>0&&T>0?s.jsx(js,{width:E,height:T,data:y,dataKey:i,hex:k,range:n,now:h,live:O,label:o}):null}})}),e[7]=y,e[8]=i,e[9]=k,e[10]=O,e[11]=h,e[12]=n,e[13]=o,e[14]=j):j=e[14];let C;return e[15]!==p||e[16]!==j?(C=s.jsxs("div",{className:"rounded-lg border p-4 flex flex-col gap-3",children:[p,j]}),e[15]=p,e[16]=j,e[17]=C):C=e[17],C}function js(t){const e=Xe.c(139),{width:o,height:m,data:y,dataKey:i,hex:n,range:h,now:O,live:k,label:x}=t,b=k===void 0?null:k,p=`chart-hint-${i}`,[j,C]=N.useState(null),[Q,E]=N.useState(!1),[T,ie]=N.useState(null),[ce,le]=N.useState(!1),W=ce?T:null,c=o-K.left-K.right,d=m-K.top-K.bottom,F=O,oe=F-xt[h],w=Ut({domain:[oe,F],range:[0,Math.max(0,c)]}),l=Bt({domain:[0,100],range:[d,kt]}),H=c>0?vs/c*xt[h]:0,Z=oe-H,ee=F+H;let D;e[0]!==h||e[1]!==Z||e[2]!==ee?(D=is(Z,ee,h),e[0]=h,e[1]=Z,e[2]=ee,e[3]=D):D=e[3];const U=D,X=c>0?Math.min(.5,bs/c):0,I=`fill-${i}`,B=`plot-${i}`,P=`axis-fade-${i}`,V=y[y.length-1],S=b!==null&&V?{t:Math.max(F,gt(V)+1),v:b,live:!0}:null;let te;e[4]!==i?(te=a=>({t:gt(a),v:a[i]}),e[4]=i,e[5]=te):te=e[5];const r=y.map(te);S&&r.push(S);const z=a=>Math.min(w(a),c),G=S?z(S.t):0,Y=S?l(S.v):0,f=Math.max(0,y.length-1),_=j===null?Math.max(0,r.length-1):j==="live"?S?r.length-1:f:Math.min(gs(y,j),f),v=Q?r[_]:void 0,M=v?z(v.t):0,$=v?l(v.v):0,A=$t[i].label;let J;e[6]!==A?(J=a=>`${A}, ${St(a.t)}, ${a.live?"latest, ":""}${We(a.v)}`,e[6]=A,e[7]=J):J=e[7];const u=J,L=a=>{const R=r[a];R&&(C(R.live?"live":R.t),E(!0),ie({now:a,text:u(R)}))};let q;e[8]===Symbol.for("react.memo_cache_sentinel")?(q=()=>E(!1),e[8]=q):q=e[8];const g=q;let ae,se;e[9]!==Q?(ae=()=>{if(!Q)return;const a=R=>{R.key==="Escape"&&E(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},se=[Q],e[9]=Q,e[10]=ae,e[11]=se):(ae=e[10],se=e[11]),N.useEffect(ae,se);const de=a=>{if(r.length===0)return;const R=_,Fe=a.key==="ArrowLeft"||a.key==="ArrowDown"?Math.max(0,R-1):a.key==="ArrowRight"||a.key==="ArrowUp"?Math.min(r.length-1,R+1):a.key==="Home"?0:a.key==="End"?r.length-1:null;Fe!==null&&(a.preventDefault(),L(Fe))},re=a=>{const R=Gt(a);if(!R)return;const Fe=R.x-K.left,yt=ys(r,w.invert(Fe).getTime()),vt=[r[yt-1],r[yt],S].reduce((mt,ht)=>ht&&(!mt||Math.abs(z(ht.t)-Fe)<=Math.abs(z(mt.t)-Fe))?ht:mt,void 0);vt&&L(r.indexOf(vt))},Ve="group",ne=S?`${x}, last ${h}. Now ${We(S.v)}.`:V?`${x}, last ${h}. Latest ${We(V[i])}.`:`${x}, last ${h}. No samples.`;let ue;e[12]!==I||e[13]!==n?(ue=s.jsx(Qt,{id:I,from:n,to:n,fromOpacity:.3,toOpacity:0,fromOffset:"5%",toOffset:"95%"}),e[12]=I,e[13]=n,e[14]=ue):ue=e[14];const ze=Math.max(0,c),Ye=Math.max(0,d);let fe;e[15]!==ze||e[16]!==Ye?(fe=s.jsx("rect",{x:0,y:0,width:ze,height:Ye}),e[15]=ze,e[16]=Ye,e[17]=fe):fe=e[17];let me;e[18]!==B||e[19]!==fe?(me=s.jsx("clipPath",{id:B,children:fe}),e[18]=B,e[19]=fe,e[20]=me):me=e[20];const Je=`${P}-grad`,Ze=Math.max(0,c);let He;e[21]===Symbol.for("react.memo_cache_sentinel")?(He=s.jsx("stop",{offset:0,stopColor:"white",stopOpacity:0}),e[21]=He):He=e[21];let he;e[22]!==X?(he=s.jsx("stop",{offset:X,stopColor:"white",stopOpacity:1}),e[22]=X,e[23]=he):he=e[23];const et=1-X;let xe;e[24]!==et?(xe=s.jsx("stop",{offset:et,stopColor:"white",stopOpacity:1}),e[24]=et,e[25]=xe):xe=e[25];let Ue;e[26]===Symbol.for("react.memo_cache_sentinel")?(Ue=s.jsx("stop",{offset:1,stopColor:"white",stopOpacity:0}),e[26]=Ue):Ue=e[26];let pe;e[27]!==Je||e[28]!==Ze||e[29]!==he||e[30]!==xe?(pe=s.jsxs("linearGradient",{id:Je,gradientUnits:"userSpaceOnUse",x1:0,y1:0,x2:Ze,y2:0,children:[He,he,xe,Ue]}),e[27]=Je,e[28]=Ze,e[29]=he,e[30]=xe,e[31]=pe):pe=e[31];const tt=Math.max(0,c),st=Math.max(0,c),nt=`url(#${P}-grad)`;let ge;e[32]!==d||e[33]!==st||e[34]!==nt?(ge=s.jsx("rect",{x:0,y:d,width:st,height:K.bottom*2,fill:nt}),e[32]=d,e[33]=st,e[34]=nt,e[35]=ge):ge=e[35];let ye;e[36]!==P||e[37]!==d||e[38]!==tt||e[39]!==ge?(ye=s.jsx("mask",{id:P,maskUnits:"userSpaceOnUse",maskContentUnits:"userSpaceOnUse",x:0,y:d,width:tt,height:K.bottom*2,children:ge}),e[36]=P,e[37]=d,e[38]=tt,e[39]=ge,e[40]=ye):ye=e[40];let Be;e[41]===Symbol.for("react.memo_cache_sentinel")?(Be=[0,25,50,75,100],e[41]=Be):Be=e[41];let ve;e[42]!==c||e[43]!==l?(ve=s.jsx(Wt,{scale:l,width:c,tickValues:Be,strokeDasharray:"3 3",stroke:"hsl(var(--border))"}),e[42]=c,e[43]=l,e[44]=ve):ve=e[44];const lt=`url(#${B})`;let be;e[45]!==w?(be=a=>w(a.t),e[45]=w,e[46]=be):be=e[46];let je;e[47]!==l?(je=a=>l(a.v),e[47]=l,e[48]=je):je=e[48];const ot=`url(#${I})`;let we;e[49]!==r||e[50]!==be||e[51]!==je||e[52]!==ot||e[53]!==l?(we=s.jsx(Xt,{data:r,x:be,y:je,yScale:l,curve:wt,fill:ot}),e[49]=r,e[50]=be,e[51]=je,e[52]=ot,e[53]=l,e[54]=we):we=e[54];let Se;e[55]!==w?(Se=a=>w(a.t),e[55]=w,e[56]=Se):Se=e[56];let ke;e[57]!==l?(ke=a=>l(a.v),e[57]=l,e[58]=ke):ke=e[58];let Me;e[59]!==n||e[60]!==r||e[61]!==Se||e[62]!==ke?(Me=s.jsx(Vt,{data:r,x:Se,y:ke,curve:wt,stroke:n,strokeWidth:1.5}),e[59]=n,e[60]=r,e[61]=Se,e[62]=ke,e[63]=Me):Me=e[63];let Ne;e[64]!==lt||e[65]!==we||e[66]!==Me?(Ne=s.jsxs("g",{clipPath:lt,children:[we,Me]}),e[64]=lt,e[65]=we,e[66]=Me,e[67]=Ne):Ne=e[67];const at=`url(#${P})`;let _e;e[68]!==h?(_e=a=>cs(+a,h),e[68]=h,e[69]=_e):_e=e[69];let $e;e[70]!==d||e[71]!==_e||e[72]!==U||e[73]!==w?($e=s.jsx(zt,{top:d,scale:w,tickValues:U,tickFormat:_e,hideAxisLine:!0,hideTicks:!0,tickLength:0,tickLabelProps:ks}),e[70]=d,e[71]=_e,e[72]=U,e[73]=w,e[74]=$e):$e=e[74];let Ae;e[75]!==at||e[76]!==$e?(Ae=s.jsx("g",{mask:at,children:$e}),e[75]=at,e[76]=$e,e[77]=Ae):Ae=e[77];let Ge;e[78]===Symbol.for("react.memo_cache_sentinel")?(Ge=[0,25,50,75,100],e[78]=Ge):Ge=e[78];let Le;e[79]!==l?(Le=s.jsx(Yt,{scale:l,tickValues:Ge,tickFormat:Ss,hideAxisLine:!0,hideTicks:!0,tickLabelProps:ws}),e[79]=l,e[80]=Le):Le=e[80];let Ee;e[81]!==G||e[82]!==Y||e[83]!==n||e[84]!==S?(Ee=S&&s.jsxs("g",{className:"live-head","aria-hidden":"true",pointerEvents:"none",children:[s.jsx("circle",{cx:G,cy:Y,r:Mt,fill:n,fillOpacity:.2}),s.jsx("circle",{cx:G,cy:Y,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5})]}),e[81]=G,e[82]=Y,e[83]=n,e[84]=S,e[85]=Ee):Ee=e[85];let Te;e[86]!==n||e[87]!==d||e[88]!==v||e[89]!==M||e[90]!==$?(Te=v&&s.jsxs("g",{style:{transition:"transform 0.25s ease-out",transform:`translateX(${M}px)`},pointerEvents:"none",children:[s.jsx(Jt,{from:{x:0,y:kt},to:{x:0,y:d},stroke:"hsl(var(--border))",strokeWidth:1}),s.jsx("circle",{cx:0,cy:0,r:3,fill:n,stroke:"hsl(var(--background))",strokeWidth:1.5,style:{transition:"transform 0.25s ease-out",transform:`translateY(${$}px)`}})]}),e[86]=n,e[87]=d,e[88]=v,e[89]=M,e[90]=$,e[91]=Te):Te=e[91];const rt=Math.max(0,c)+Mt,it=Math.max(0,d),ct=`${x} samples`,dt=Math.max(0,r.length-1),ut=W?Math.min(W.now,Math.max(0,r.length-1)):_,ft=W?W.text:r[_]?u(r[_]):void 0;let Re;e[92]!==_||e[93]!==L?(Re=()=>{le(!0),L(_)},e[92]=_,e[93]=L,e[94]=Re):Re=e[94];let Oe;e[95]!==g?(Oe=()=>{g(),le(!1)},e[95]=g,e[96]=Oe):Oe=e[96];let Ce;e[97]!==de||e[98]!==re||e[99]!==g||e[100]!==p||e[101]!==rt||e[102]!==it||e[103]!==ct||e[104]!==dt||e[105]!==ut||e[106]!==ft||e[107]!==Re||e[108]!==Oe?(Ce=s.jsx(Zt,{x:0,y:0,width:rt,height:it,fill:"transparent",tabIndex:0,role:"slider","aria-label":ct,"aria-valuemin":0,"aria-valuemax":dt,"aria-valuenow":ut,"aria-valuetext":ft,"aria-describedby":p,className:"outline-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring",onFocus:Re,onBlur:Oe,onKeyDown:de,onMouseMove:re,onMouseLeave:g,onTouchMove:re,onTouchEnd:g,onTouchCancel:g}),e[97]=de,e[98]=re,e[99]=g,e[100]=p,e[101]=rt,e[102]=it,e[103]=ct,e[104]=dt,e[105]=ut,e[106]=ft,e[107]=Re,e[108]=Oe,e[109]=Ce):Ce=e[109];let De;e[110]!==ve||e[111]!==Ne||e[112]!==Ae||e[113]!==Le||e[114]!==Ee||e[115]!==Te||e[116]!==Ce?(De=s.jsxs(es,{left:K.left,top:K.top,children:[ve,Ne,Ae,Le,Ee,Te,Ce]}),e[110]=ve,e[111]=Ne,e[112]=Ae,e[113]=Le,e[114]=Ee,e[115]=Te,e[116]=Ce,e[117]=De):De=e[117];let Ie;e[118]!==m||e[119]!==ne||e[120]!==ue||e[121]!==me||e[122]!==pe||e[123]!==ye||e[124]!==De||e[125]!==o?(Ie=s.jsxs("svg",{width:o,height:m,role:Ve,"aria-label":ne,children:[ue,me,pe,ye,De]}),e[118]=m,e[119]=ne,e[120]=ue,e[121]=me,e[122]=pe,e[123]=ye,e[124]=De,e[125]=o,e[126]=Ie):Ie=e[126];let Pe;e[127]!==p?(Pe=s.jsx("p",{id:p,className:"sr-only",children:"Use the arrow keys to read individual samples, and End for the latest value. Escape hides the reading."}),e[127]=p,e[128]=Pe):Pe=e[128];let Ke;e[129]!==c||e[130]!==A||e[131]!==v||e[132]!==M||e[133]!==$?(Ke=v&&s.jsxs("div",{"aria-hidden":"true",className:"pointer-events-none absolute top-0 left-0 whitespace-nowrap rounded-lg border bg-background px-3 py-2 text-xs text-foreground shadow-md",style:{transform:`translate(${M+K.left}px, ${$+K.top}px) translate(${M>c*.6?"calc(-100% - 12px)":"12px"}, -50%)`,transition:"transform 0.25s ease-out"},children:[s.jsxs("p",{className:"mb-1",children:["Date: ",St(v.t)]}),s.jsxs("p",{children:[A,": ",We(v.v)]})]}),e[129]=c,e[130]=A,e[131]=v,e[132]=M,e[133]=$,e[134]=Ke):Ke=e[134];let qe;return e[135]!==Ie||e[136]!==Pe||e[137]!==Ke?(qe=s.jsxs(s.Fragment,{children:[Ie,Pe,Ke]}),e[135]=Ie,e[136]=Pe,e[137]=Ke,e[138]=qe):qe=e[138],qe}function ws(){return{fontSize:11,fill:"currentColor",textAnchor:"end",dx:-4,dy:3,className:"fill-muted-foreground"}}function Ss(t){return`${t}%`}function ks(){return{fontSize:11,fill:"currentColor",textAnchor:"middle",dy:6,className:"fill-muted-foreground"}}export{js as AreaChartInner,Ls as MacResources};
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{f as l,j as n}from"./vendor-react-BlPSzrEe.js";function m(r){const e=l.c(8),{code:a,message:i}=r;let t;e[0]!==a?(t=n.jsx("span",{className:"text-lg font-semibold tracking-tight text-foreground",children:a}),e[0]=a,e[1]=t):t=e[1];let o;e[2]===Symbol.for("react.memo_cache_sentinel")?(o=n.jsx("span",{className:"h-6 w-px bg-border","aria-hidden":"true"}),e[2]=o):o=e[2];let s;e[3]!==i?(s=n.jsx("span",{className:"text-sm text-muted-foreground",children:i}),e[3]=i,e[4]=s):s=e[4];let c;return e[5]!==t||e[6]!==s?(c=n.jsx("div",{className:"flex min-h-svh items-center justify-center bg-background p-4",children:n.jsxs("div",{className:"flex items-center gap-4",children:[t,o,s]})}),e[5]=t,e[6]=s,e[7]=c):c=e[7],c}function f(){const r=l.c(1);let e;return r[0]===Symbol.for("react.memo_cache_sentinel")?(e=n.jsx(m,{code:404,message:"page not found"}),r[0]=e):e=r[0],e}export{f as NotFound};
|
|
Binary file
|
|
Binary file
|