@datarails-ai/dr-appspace-cli 0.12.58 → 0.12.60
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 +38 -1
- package/dist/cli.js +1738 -558
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { fileURLToPath as fileURLToPath6 } from "url";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "@datarails-ai/dr-appspace-cli",
|
|
16
|
-
version: "0.12.
|
|
16
|
+
version: "0.12.60",
|
|
17
17
|
description: "Datarails App Space CLI \u2014 build, try, push and publish App Space apps",
|
|
18
18
|
type: "module",
|
|
19
19
|
engines: {
|
|
@@ -57,7 +57,7 @@ var package_default = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
// src/buildInfo.ts
|
|
60
|
-
var BUILD_TIME = "2026-11-
|
|
60
|
+
var BUILD_TIME = "2026-11-01T16:43:32.463Z";
|
|
61
61
|
function formatBuildTime(iso) {
|
|
62
62
|
if (iso === "") return "";
|
|
63
63
|
const d = new Date(iso);
|
|
@@ -754,13 +754,13 @@ async function requestDeviceCode(host, options) {
|
|
|
754
754
|
body: body.toString(),
|
|
755
755
|
signal: options?.signal
|
|
756
756
|
});
|
|
757
|
-
const
|
|
757
|
+
const text4 = await res.text();
|
|
758
758
|
if (!res.ok) {
|
|
759
|
-
throw new Error(`device/code failed: ${res.status} ${
|
|
759
|
+
throw new Error(`device/code failed: ${res.status} ${text4.trim()}`);
|
|
760
760
|
}
|
|
761
761
|
let raw;
|
|
762
762
|
try {
|
|
763
|
-
raw = JSON.parse(
|
|
763
|
+
raw = JSON.parse(text4);
|
|
764
764
|
} catch (err) {
|
|
765
765
|
const msg = err instanceof Error ? err.message : String(err);
|
|
766
766
|
throw new Error(`device/code parse: ${msg}`);
|
|
@@ -791,10 +791,10 @@ var defaultSleep = (ms, signal) => new Promise((resolve17, reject) => {
|
|
|
791
791
|
{ once: true }
|
|
792
792
|
);
|
|
793
793
|
});
|
|
794
|
-
function parseTokenResponse(
|
|
794
|
+
function parseTokenResponse(text4) {
|
|
795
795
|
let raw;
|
|
796
796
|
try {
|
|
797
|
-
raw = JSON.parse(
|
|
797
|
+
raw = JSON.parse(text4);
|
|
798
798
|
} catch (err) {
|
|
799
799
|
const msg = err instanceof Error ? err.message : String(err);
|
|
800
800
|
throw new Error(`token parse: ${msg}`);
|
|
@@ -812,10 +812,10 @@ function parseTokenResponse(text3) {
|
|
|
812
812
|
}
|
|
813
813
|
return tok;
|
|
814
814
|
}
|
|
815
|
-
function tryParseErrorCode(
|
|
815
|
+
function tryParseErrorCode(text4) {
|
|
816
816
|
let raw;
|
|
817
817
|
try {
|
|
818
|
-
raw = JSON.parse(
|
|
818
|
+
raw = JSON.parse(text4);
|
|
819
819
|
} catch {
|
|
820
820
|
return "";
|
|
821
821
|
}
|
|
@@ -849,15 +849,15 @@ async function pollForToken(host, deviceCode, options = {}) {
|
|
|
849
849
|
body: body.toString(),
|
|
850
850
|
signal
|
|
851
851
|
});
|
|
852
|
-
const
|
|
852
|
+
const text4 = await res.text();
|
|
853
853
|
if (res.ok) {
|
|
854
|
-
const tok = parseTokenResponse(
|
|
854
|
+
const tok = parseTokenResponse(text4);
|
|
855
855
|
if (!tok.sessionId || !tok.csrfToken) {
|
|
856
856
|
throw new Error("token response missing session_id or csrf_token");
|
|
857
857
|
}
|
|
858
858
|
return tok;
|
|
859
859
|
}
|
|
860
|
-
const errCode = tryParseErrorCode(
|
|
860
|
+
const errCode = tryParseErrorCode(text4);
|
|
861
861
|
if (errCode === "authorization_pending" || errCode === "slow_down") {
|
|
862
862
|
await sleep3(interval, signal);
|
|
863
863
|
continue;
|
|
@@ -865,7 +865,7 @@ async function pollForToken(host, deviceCode, options = {}) {
|
|
|
865
865
|
if (errCode) {
|
|
866
866
|
throw new Error(`token error: ${errCode}`);
|
|
867
867
|
}
|
|
868
|
-
throw new Error(`token HTTP ${res.status}: ${
|
|
868
|
+
throw new Error(`token HTTP ${res.status}: ${text4.trim()}`);
|
|
869
869
|
}
|
|
870
870
|
}
|
|
871
871
|
|
|
@@ -965,10 +965,10 @@ function decodeJwtExpiration(token) {
|
|
|
965
965
|
}
|
|
966
966
|
return new Date(exp * 1e3);
|
|
967
967
|
}
|
|
968
|
-
function parseTokenBody(
|
|
968
|
+
function parseTokenBody(text4, label) {
|
|
969
969
|
let raw;
|
|
970
970
|
try {
|
|
971
|
-
raw = JSON.parse(
|
|
971
|
+
raw = JSON.parse(text4);
|
|
972
972
|
} catch (err) {
|
|
973
973
|
throw new Error(`jwt ${label} parse: ${msgOf3(err)}`);
|
|
974
974
|
}
|
|
@@ -994,11 +994,11 @@ async function mintJwt(host, sessionId, csrfToken, options) {
|
|
|
994
994
|
body: "{}",
|
|
995
995
|
signal: options?.signal
|
|
996
996
|
});
|
|
997
|
-
const
|
|
997
|
+
const text4 = await res.text();
|
|
998
998
|
if (!res.ok) {
|
|
999
|
-
throw new Error(`jwt mint: HTTP ${res.status}: ${truncate(
|
|
999
|
+
throw new Error(`jwt mint: HTTP ${res.status}: ${truncate(text4, TRUNCATE)}`);
|
|
1000
1000
|
}
|
|
1001
|
-
const out = parseTokenBody(
|
|
1001
|
+
const out = parseTokenBody(text4, "mint");
|
|
1002
1002
|
if (out.access === "") {
|
|
1003
1003
|
throw new Error("jwt mint: empty access token");
|
|
1004
1004
|
}
|
|
@@ -1021,11 +1021,11 @@ async function refreshJwt(host, refreshToken, options) {
|
|
|
1021
1021
|
body: JSON.stringify({ refresh: refreshToken }),
|
|
1022
1022
|
signal: options?.signal
|
|
1023
1023
|
});
|
|
1024
|
-
const
|
|
1024
|
+
const text4 = await res.text();
|
|
1025
1025
|
if (!res.ok) {
|
|
1026
|
-
throw new Error(`jwt refresh: HTTP ${res.status}: ${truncate(
|
|
1026
|
+
throw new Error(`jwt refresh: HTTP ${res.status}: ${truncate(text4, TRUNCATE)}`);
|
|
1027
1027
|
}
|
|
1028
|
-
const out = parseTokenBody(
|
|
1028
|
+
const out = parseTokenBody(text4, "refresh");
|
|
1029
1029
|
if (out.access === "") {
|
|
1030
1030
|
throw new Error("jwt refresh: empty access token");
|
|
1031
1031
|
}
|
|
@@ -1045,11 +1045,11 @@ async function refreshExternalJwt(host, refreshToken, options) {
|
|
|
1045
1045
|
body: JSON.stringify({ refresh: refreshToken }),
|
|
1046
1046
|
signal: options?.signal
|
|
1047
1047
|
});
|
|
1048
|
-
const
|
|
1048
|
+
const text4 = await res.text();
|
|
1049
1049
|
if (!res.ok) {
|
|
1050
|
-
throw new Error(`jwt external refresh: HTTP ${res.status}: ${truncate(
|
|
1050
|
+
throw new Error(`jwt external refresh: HTTP ${res.status}: ${truncate(text4, TRUNCATE)}`);
|
|
1051
1051
|
}
|
|
1052
|
-
const out = parseTokenBody(
|
|
1052
|
+
const out = parseTokenBody(text4, "refresh");
|
|
1053
1053
|
if (out.access === "") {
|
|
1054
1054
|
throw new Error("jwt external refresh: empty access token");
|
|
1055
1055
|
}
|
|
@@ -1076,12 +1076,12 @@ async function loginAs(host, operatorAccessToken, userId, options) {
|
|
|
1076
1076
|
body: JSON.stringify(body),
|
|
1077
1077
|
signal: options?.signal
|
|
1078
1078
|
});
|
|
1079
|
-
const
|
|
1079
|
+
const text4 = await res.text();
|
|
1080
1080
|
if (!res.ok) {
|
|
1081
1081
|
let code;
|
|
1082
1082
|
let detail;
|
|
1083
1083
|
try {
|
|
1084
|
-
const parsed2 = JSON.parse(
|
|
1084
|
+
const parsed2 = JSON.parse(text4);
|
|
1085
1085
|
if (typeof parsed2["code"] === "string") code = parsed2["code"];
|
|
1086
1086
|
if (typeof parsed2["detail"] === "string") detail = parsed2["detail"];
|
|
1087
1087
|
} catch {
|
|
@@ -1089,12 +1089,12 @@ async function loginAs(host, operatorAccessToken, userId, options) {
|
|
|
1089
1089
|
throw new LoginAsError(res.status, {
|
|
1090
1090
|
code,
|
|
1091
1091
|
detail,
|
|
1092
|
-
body: truncate(
|
|
1092
|
+
body: truncate(text4, TRUNCATE)
|
|
1093
1093
|
});
|
|
1094
1094
|
}
|
|
1095
1095
|
let raw;
|
|
1096
1096
|
try {
|
|
1097
|
-
raw = JSON.parse(
|
|
1097
|
+
raw = JSON.parse(text4);
|
|
1098
1098
|
} catch (err) {
|
|
1099
1099
|
throw new Error(`jwt loginas parse: ${msgOf3(err)}`);
|
|
1100
1100
|
}
|
|
@@ -1137,11 +1137,11 @@ async function exchangeApiKey(host, apiKey, options) {
|
|
|
1137
1137
|
headers: { Authorization: `Bearer ${key}`, Accept: "application/json" },
|
|
1138
1138
|
signal: options?.signal
|
|
1139
1139
|
});
|
|
1140
|
-
const
|
|
1140
|
+
const text4 = await res.text();
|
|
1141
1141
|
if (!res.ok) {
|
|
1142
1142
|
let code;
|
|
1143
1143
|
try {
|
|
1144
|
-
const value = JSON.parse(
|
|
1144
|
+
const value = JSON.parse(text4)["error"];
|
|
1145
1145
|
if (value === "invalid_key" || value === "exchange_unavailable") code = value;
|
|
1146
1146
|
} catch {
|
|
1147
1147
|
}
|
|
@@ -1151,7 +1151,7 @@ async function exchangeApiKey(host, apiKey, options) {
|
|
|
1151
1151
|
}
|
|
1152
1152
|
let raw;
|
|
1153
1153
|
try {
|
|
1154
|
-
raw = JSON.parse(
|
|
1154
|
+
raw = JSON.parse(text4);
|
|
1155
1155
|
} catch {
|
|
1156
1156
|
throw new Error("api-key exchange parse: the response is not JSON");
|
|
1157
1157
|
}
|
|
@@ -1801,16 +1801,16 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1801
1801
|
body: fd,
|
|
1802
1802
|
signal: options?.signal
|
|
1803
1803
|
});
|
|
1804
|
-
const
|
|
1804
|
+
const text4 = await res.text();
|
|
1805
1805
|
if (res.status === 401 || res.status === 403) {
|
|
1806
1806
|
throw new SessionExpiredError(`POST ${path3} (HTTP ${res.status})`);
|
|
1807
1807
|
}
|
|
1808
1808
|
if (res.status < 200 || res.status >= 300) {
|
|
1809
|
-
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(
|
|
1809
|
+
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(text4, 200)}`);
|
|
1810
1810
|
}
|
|
1811
|
-
if (
|
|
1811
|
+
if (text4 === "" || text4 === '""') return null;
|
|
1812
1812
|
try {
|
|
1813
|
-
return JSON.parse(
|
|
1813
|
+
return JSON.parse(text4);
|
|
1814
1814
|
} catch (err) {
|
|
1815
1815
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1816
1816
|
throw new Error(`POST ${path3}: decode: ${msg}`);
|
|
@@ -1851,16 +1851,16 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1851
1851
|
body: fd,
|
|
1852
1852
|
signal: options?.signal
|
|
1853
1853
|
});
|
|
1854
|
-
const
|
|
1854
|
+
const text4 = await res.text();
|
|
1855
1855
|
if (res.status === 401 || res.status === 403) {
|
|
1856
1856
|
throw new SessionExpiredError(`POST ${path3} (HTTP ${res.status})`);
|
|
1857
1857
|
}
|
|
1858
1858
|
if (res.status < 200 || res.status >= 300) {
|
|
1859
|
-
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(
|
|
1859
|
+
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(text4, 200)}`);
|
|
1860
1860
|
}
|
|
1861
|
-
if (
|
|
1861
|
+
if (text4 === "" || text4 === '""') return null;
|
|
1862
1862
|
try {
|
|
1863
|
-
return JSON.parse(
|
|
1863
|
+
return JSON.parse(text4);
|
|
1864
1864
|
} catch (err) {
|
|
1865
1865
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1866
1866
|
throw new Error(`POST ${path3}: decode: ${msg}`);
|
|
@@ -1909,16 +1909,16 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1909
1909
|
body: fd,
|
|
1910
1910
|
signal: options?.signal
|
|
1911
1911
|
});
|
|
1912
|
-
const
|
|
1912
|
+
const text4 = await res.text();
|
|
1913
1913
|
if (res.status === 401 || res.status === 403) {
|
|
1914
1914
|
throw new SessionExpiredError(`POST ${path3} (HTTP ${res.status})`);
|
|
1915
1915
|
}
|
|
1916
1916
|
if (res.status < 200 || res.status >= 300) {
|
|
1917
|
-
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(
|
|
1917
|
+
throw new Error(`POST ${path3}: HTTP ${res.status}: ${truncate2(text4, 200)}`);
|
|
1918
1918
|
}
|
|
1919
|
-
if (
|
|
1919
|
+
if (text4 === "" || text4 === '""') return null;
|
|
1920
1920
|
try {
|
|
1921
|
-
return JSON.parse(
|
|
1921
|
+
return JSON.parse(text4);
|
|
1922
1922
|
} catch (err) {
|
|
1923
1923
|
const msg = err instanceof Error ? err.message : String(err);
|
|
1924
1924
|
throw new Error(`POST ${path3}: decode: ${msg}`);
|
|
@@ -1978,11 +1978,11 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1978
1978
|
}
|
|
1979
1979
|
}
|
|
1980
1980
|
if (this.isAuthRejected(res)) {
|
|
1981
|
-
const
|
|
1981
|
+
const text5 = await res.text();
|
|
1982
1982
|
if (refreshed || triedSessionOnly) {
|
|
1983
1983
|
const attempted = refreshed ? "session-only retry and JWT refresh" : "session-only retry";
|
|
1984
1984
|
throw new Error(
|
|
1985
|
-
`${method} ${path3}: HTTP ${res.status} after ${attempted} (authenticated, but endpoint rejected \u2014 check permissions, tenant/org context, or body): ${truncate2(
|
|
1985
|
+
`${method} ${path3}: HTTP ${res.status} after ${attempted} (authenticated, but endpoint rejected \u2014 check permissions, tenant/org context, or body): ${truncate2(text5, 200)}`
|
|
1986
1986
|
);
|
|
1987
1987
|
}
|
|
1988
1988
|
if (refreshErr !== void 0) {
|
|
@@ -1991,17 +1991,17 @@ var AuthorizedClient = class _AuthorizedClient {
|
|
|
1991
1991
|
}
|
|
1992
1992
|
throw new SessionExpiredError(`${method} ${path3} (HTTP ${res.status})`);
|
|
1993
1993
|
}
|
|
1994
|
-
const
|
|
1994
|
+
const text4 = await res.text();
|
|
1995
1995
|
if (res.status < 200 || res.status >= 300) {
|
|
1996
|
-
throw new Error(`${method} ${path3}: HTTP ${res.status}: ${truncate2(
|
|
1996
|
+
throw new Error(`${method} ${path3}: HTTP ${res.status}: ${truncate2(text4, 200)}`);
|
|
1997
1997
|
}
|
|
1998
1998
|
try {
|
|
1999
1999
|
await this._store.touch(this._serverKey, this._email);
|
|
2000
2000
|
} catch {
|
|
2001
2001
|
}
|
|
2002
|
-
if (
|
|
2002
|
+
if (text4 === "" || text4 === '""') return null;
|
|
2003
2003
|
try {
|
|
2004
|
-
return JSON.parse(
|
|
2004
|
+
return JSON.parse(text4);
|
|
2005
2005
|
} catch (err) {
|
|
2006
2006
|
const msg = err instanceof Error ? err.message : String(err);
|
|
2007
2007
|
throw new Error(`${method} ${path3}: decode: ${msg}`);
|
|
@@ -3011,8 +3011,8 @@ async function connect(opts) {
|
|
|
3011
3011
|
signal,
|
|
3012
3012
|
...init?.headers === void 0 ? {} : { headers: init.headers }
|
|
3013
3013
|
});
|
|
3014
|
-
const
|
|
3015
|
-
const lead =
|
|
3014
|
+
const text4 = await res.text();
|
|
3015
|
+
const lead = text4.trimStart().toLowerCase();
|
|
3016
3016
|
if (lead.startsWith("<!doctype html") || lead.startsWith("<html")) {
|
|
3017
3017
|
throw new Error(
|
|
3018
3018
|
`the request was intercepted before reaching App Space (HTTP ${res.status}, HTML page returned \u2014 likely the Cloudflare WAF). The CLI gzips UI bundles to avoid this; if you are calling the API yourself, send frontend_bundle_gz.`
|
|
@@ -3020,9 +3020,9 @@ async function connect(opts) {
|
|
|
3020
3020
|
}
|
|
3021
3021
|
let parsed2 = void 0;
|
|
3022
3022
|
try {
|
|
3023
|
-
parsed2 =
|
|
3023
|
+
parsed2 = text4 === "" ? void 0 : JSON.parse(text4);
|
|
3024
3024
|
} catch {
|
|
3025
|
-
parsed2 =
|
|
3025
|
+
parsed2 = text4;
|
|
3026
3026
|
}
|
|
3027
3027
|
if (!res.ok) {
|
|
3028
3028
|
throw new AppSpaceHttpError(describeFailure(res.status, method, path3, parsed2), res.status, parsed2);
|
|
@@ -3593,8 +3593,8 @@ function describe(node, ctx) {
|
|
|
3593
3593
|
const description = node["description"];
|
|
3594
3594
|
return ctx.inBranch && typeof description === "string" ? ` \u2014 ${firstSentence(description)}` : "";
|
|
3595
3595
|
}
|
|
3596
|
-
function firstSentence(
|
|
3597
|
-
let out =
|
|
3596
|
+
function firstSentence(text4) {
|
|
3597
|
+
let out = text4;
|
|
3598
3598
|
let start = 0;
|
|
3599
3599
|
for (; ; ) {
|
|
3600
3600
|
const end = out.indexOf(". ", start);
|
|
@@ -3608,9 +3608,9 @@ function firstSentence(text3) {
|
|
|
3608
3608
|
}
|
|
3609
3609
|
return truncate3(out);
|
|
3610
3610
|
}
|
|
3611
|
-
function truncate3(
|
|
3612
|
-
const chars = [...
|
|
3613
|
-
if (chars.length <= MAX_HINT) return
|
|
3611
|
+
function truncate3(text4) {
|
|
3612
|
+
const chars = [...text4];
|
|
3613
|
+
if (chars.length <= MAX_HINT) return text4;
|
|
3614
3614
|
let cut3 = chars.slice(0, MAX_HINT - 1);
|
|
3615
3615
|
const space = cut3.lastIndexOf(" ");
|
|
3616
3616
|
if (space > Math.floor(MAX_HINT / 2)) cut3 = cut3.slice(0, space);
|
|
@@ -3793,9 +3793,9 @@ function walkFrom(base, clean) {
|
|
|
3793
3793
|
}
|
|
3794
3794
|
return resolved;
|
|
3795
3795
|
}
|
|
3796
|
-
function lineAt(
|
|
3796
|
+
function lineAt(text4, index) {
|
|
3797
3797
|
let line2 = 1;
|
|
3798
|
-
for (let i = 0; i < index && i <
|
|
3798
|
+
for (let i = 0; i < index && i < text4.length; i++) if (text4.charCodeAt(i) === 10) line2++;
|
|
3799
3799
|
return line2;
|
|
3800
3800
|
}
|
|
3801
3801
|
|
|
@@ -3926,8 +3926,8 @@ function parseAttrs(raw) {
|
|
|
3926
3926
|
}
|
|
3927
3927
|
return attrs;
|
|
3928
3928
|
}
|
|
3929
|
-
function loadsModule(pagePath,
|
|
3930
|
-
const { elements } = parseHtml(
|
|
3929
|
+
function loadsModule(pagePath, text4, pattern) {
|
|
3930
|
+
const { elements } = parseHtml(text4);
|
|
3931
3931
|
return elements.some((el) => {
|
|
3932
3932
|
if (el.tag !== "script" || el.attrs.src === void 0) return false;
|
|
3933
3933
|
const target = resolveFromPlatformRoot(pagePath, el.attrs.src);
|
|
@@ -4103,11 +4103,11 @@ function parseDeclares(raw) {
|
|
|
4103
4103
|
}
|
|
4104
4104
|
var PAIR = /(["'])data-dr-([a-z][a-z-]*)\1\s*:\s*(["'])([^"'\\]*)\3/g;
|
|
4105
4105
|
var REGEX_AFTER = /* @__PURE__ */ new Set(["", "(", ",", "=", ":", "[", "!", "&", "|", "?", ";", "+", "-", "*", "%", "~", "^", "<", ">"]);
|
|
4106
|
-
function scanBundle(
|
|
4106
|
+
function scanBundle(text4, { file, page }) {
|
|
4107
4107
|
const pairs = /* @__PURE__ */ new Map();
|
|
4108
|
-
for (const match of
|
|
4108
|
+
for (const match of text4.matchAll(PAIR)) pairs.set(match.index, { attr: match[2], value: match[4] });
|
|
4109
4109
|
if (pairs.size === 0) return [];
|
|
4110
|
-
const objects = groupByObject(
|
|
4110
|
+
const objects = groupByObject(text4, pairs);
|
|
4111
4111
|
const elements = [];
|
|
4112
4112
|
for (const found of objects) {
|
|
4113
4113
|
const attrs = {};
|
|
@@ -4148,21 +4148,21 @@ function scanBundle(text3, { file, page }) {
|
|
|
4148
4148
|
}
|
|
4149
4149
|
return elements;
|
|
4150
4150
|
}
|
|
4151
|
-
function groupByObject(
|
|
4151
|
+
function groupByObject(text4, pairs) {
|
|
4152
4152
|
const byObject = /* @__PURE__ */ new Map();
|
|
4153
4153
|
const stack = [];
|
|
4154
4154
|
let previous = "";
|
|
4155
4155
|
let i = 0;
|
|
4156
|
-
while (i <
|
|
4157
|
-
const ch =
|
|
4158
|
-
if (ch === "/" &&
|
|
4159
|
-
const end =
|
|
4160
|
-
i = end === -1 ?
|
|
4156
|
+
while (i < text4.length) {
|
|
4157
|
+
const ch = text4[i];
|
|
4158
|
+
if (ch === "/" && text4[i + 1] === "/") {
|
|
4159
|
+
const end = text4.indexOf("\n", i);
|
|
4160
|
+
i = end === -1 ? text4.length : end + 1;
|
|
4161
4161
|
continue;
|
|
4162
4162
|
}
|
|
4163
|
-
if (ch === "/" &&
|
|
4164
|
-
const end =
|
|
4165
|
-
i = end === -1 ?
|
|
4163
|
+
if (ch === "/" && text4[i + 1] === "*") {
|
|
4164
|
+
const end = text4.indexOf("*/", i + 2);
|
|
4165
|
+
i = end === -1 ? text4.length : end + 2;
|
|
4166
4166
|
continue;
|
|
4167
4167
|
}
|
|
4168
4168
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
@@ -4172,12 +4172,12 @@ function groupByObject(text3, pairs) {
|
|
|
4172
4172
|
if (!byObject.has(open2)) byObject.set(open2, []);
|
|
4173
4173
|
byObject.get(open2).push(pair);
|
|
4174
4174
|
}
|
|
4175
|
-
i = endOfString(
|
|
4175
|
+
i = endOfString(text4, i);
|
|
4176
4176
|
previous = '"';
|
|
4177
4177
|
continue;
|
|
4178
4178
|
}
|
|
4179
4179
|
if (ch === "/" && REGEX_AFTER.has(previous)) {
|
|
4180
|
-
i = endOfRegex(
|
|
4180
|
+
i = endOfRegex(text4, i);
|
|
4181
4181
|
previous = "/";
|
|
4182
4182
|
continue;
|
|
4183
4183
|
}
|
|
@@ -4188,25 +4188,25 @@ function groupByObject(text3, pairs) {
|
|
|
4188
4188
|
}
|
|
4189
4189
|
return [...byObject.entries()].sort((a, b) => a[0] - b[0]).map(([, found]) => found);
|
|
4190
4190
|
}
|
|
4191
|
-
function endOfString(
|
|
4192
|
-
const quote =
|
|
4193
|
-
for (let i = start + 1; i <
|
|
4194
|
-
if (
|
|
4195
|
-
else if (
|
|
4191
|
+
function endOfString(text4, start) {
|
|
4192
|
+
const quote = text4[start];
|
|
4193
|
+
for (let i = start + 1; i < text4.length; i += 1) {
|
|
4194
|
+
if (text4[i] === "\\") i += 1;
|
|
4195
|
+
else if (text4[i] === quote) return i + 1;
|
|
4196
4196
|
}
|
|
4197
|
-
return
|
|
4197
|
+
return text4.length;
|
|
4198
4198
|
}
|
|
4199
|
-
function endOfRegex(
|
|
4199
|
+
function endOfRegex(text4, start) {
|
|
4200
4200
|
let inClass = false;
|
|
4201
|
-
for (let i = start + 1; i <
|
|
4202
|
-
const ch =
|
|
4201
|
+
for (let i = start + 1; i < text4.length; i += 1) {
|
|
4202
|
+
const ch = text4[i];
|
|
4203
4203
|
if (ch === "\\") i += 1;
|
|
4204
4204
|
else if (ch === "\n") return i;
|
|
4205
4205
|
else if (ch === "[") inClass = true;
|
|
4206
4206
|
else if (ch === "]") inClass = false;
|
|
4207
4207
|
else if (ch === "/" && !inClass) return i + 1;
|
|
4208
4208
|
}
|
|
4209
|
-
return
|
|
4209
|
+
return text4.length;
|
|
4210
4210
|
}
|
|
4211
4211
|
|
|
4212
4212
|
// ../flows/insights-builder/kit/contract/pySpec.mjs
|
|
@@ -4326,8 +4326,8 @@ function tokenize(src, d) {
|
|
|
4326
4326
|
}
|
|
4327
4327
|
const number = /^(?:0[xXbBoO][0-9a-fA-F_]+|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?)/.exec(src.slice(i, i + 40));
|
|
4328
4328
|
if (number && /\d/.test(number[0])) {
|
|
4329
|
-
const
|
|
4330
|
-
push("number", Number(
|
|
4329
|
+
const text4 = number[0].replace(/_/g, "");
|
|
4330
|
+
push("number", Number(text4), i, i + number[0].length);
|
|
4331
4331
|
i += number[0].length;
|
|
4332
4332
|
continue;
|
|
4333
4333
|
}
|
|
@@ -4420,8 +4420,8 @@ function unescape(body) {
|
|
|
4420
4420
|
}
|
|
4421
4421
|
return out;
|
|
4422
4422
|
}
|
|
4423
|
-
function cut(
|
|
4424
|
-
const flat = String(
|
|
4423
|
+
function cut(text4, max = MAX_TEXT) {
|
|
4424
|
+
const flat = String(text4).replace(/\s+/g, " ").trim();
|
|
4425
4425
|
return flat.length > max ? flat.slice(0, max) : flat;
|
|
4426
4426
|
}
|
|
4427
4427
|
var Literals = class {
|
|
@@ -4558,7 +4558,7 @@ var Literals = class {
|
|
|
4558
4558
|
return this.d.bare === "callable" ? { $callable: value } : { $unresolved: cut(value) };
|
|
4559
4559
|
}
|
|
4560
4560
|
parseString(index) {
|
|
4561
|
-
let
|
|
4561
|
+
let text4 = "";
|
|
4562
4562
|
let i = index;
|
|
4563
4563
|
while (this.tokens[i]?.type === "string" || this.depth > 0 && this.tokens[i]?.type === "newline") {
|
|
4564
4564
|
const token = this.tokens[i];
|
|
@@ -4569,10 +4569,10 @@ var Literals = class {
|
|
|
4569
4569
|
}
|
|
4570
4570
|
const piece = token.prefix.includes("f") ? this.interpolate(token) : token.value;
|
|
4571
4571
|
if (piece === null) return null;
|
|
4572
|
-
|
|
4572
|
+
text4 += piece;
|
|
4573
4573
|
i += 1;
|
|
4574
4574
|
}
|
|
4575
|
-
return i === index ? null : { value:
|
|
4575
|
+
return i === index ? null : { value: text4, next: i };
|
|
4576
4576
|
}
|
|
4577
4577
|
/**
|
|
4578
4578
|
* An f-string whose fields are all plain constant names, substituted. A
|
|
@@ -4911,28 +4911,28 @@ var ALLOWED_CONTEXT = [
|
|
|
4911
4911
|
var NUMBER = /^-?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/;
|
|
4912
4912
|
var LITERAL_CONTEXT = new RegExp(`\\b(${ALLOWED_CONTEXT.join("|")})\\b["']?\\s*[:=(]?\\s*$`, "i");
|
|
4913
4913
|
var CONTEXT = LITERAL_CONTEXT;
|
|
4914
|
-
function findDataLiterals(
|
|
4914
|
+
function findDataLiterals(text4) {
|
|
4915
4915
|
const found = [];
|
|
4916
|
-
for (let i = 0; i <
|
|
4917
|
-
const open2 =
|
|
4916
|
+
for (let i = 0; i < text4.length; i++) {
|
|
4917
|
+
const open2 = text4[i];
|
|
4918
4918
|
if (open2 !== "[" && open2 !== "{") continue;
|
|
4919
|
-
const close = closingIndex(
|
|
4919
|
+
const close = closingIndex(text4, i);
|
|
4920
4920
|
if (close === -1) continue;
|
|
4921
|
-
const body =
|
|
4921
|
+
const body = text4.slice(i + 1, close);
|
|
4922
4922
|
const numbers = countNumbers(body);
|
|
4923
|
-
if (numbers >= MIN_NUMBERS && !CONTEXT.test(
|
|
4924
|
-
found.push({ line: lineAt(
|
|
4923
|
+
if (numbers >= MIN_NUMBERS && !CONTEXT.test(text4.slice(Math.max(0, i - 60), i))) {
|
|
4924
|
+
found.push({ line: lineAt(text4, i), numbers, sample: text4.slice(i, Math.min(close + 1, i + 60)) });
|
|
4925
4925
|
i = close;
|
|
4926
4926
|
}
|
|
4927
4927
|
}
|
|
4928
4928
|
return found;
|
|
4929
4929
|
}
|
|
4930
|
-
function closingIndex(
|
|
4930
|
+
function closingIndex(text4, start) {
|
|
4931
4931
|
const pairs = { "[": "]", "{": "}" };
|
|
4932
|
-
const stack = [pairs[
|
|
4932
|
+
const stack = [pairs[text4[start]]];
|
|
4933
4933
|
let quote = null;
|
|
4934
|
-
for (let i = start + 1; i <
|
|
4935
|
-
const ch =
|
|
4934
|
+
for (let i = start + 1; i < text4.length && i < start + 2e4; i++) {
|
|
4935
|
+
const ch = text4[i];
|
|
4936
4936
|
if (quote) {
|
|
4937
4937
|
if (ch === "\\") i++;
|
|
4938
4938
|
else if (ch === quote) quote = null;
|
|
@@ -5008,9 +5008,9 @@ function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH
|
|
|
5008
5008
|
const constants = /* @__PURE__ */ new Map();
|
|
5009
5009
|
const hoisted = hoist(table, [], constants, null);
|
|
5010
5010
|
const callables = /* @__PURE__ */ new Set();
|
|
5011
|
-
let
|
|
5011
|
+
let text4 = null;
|
|
5012
5012
|
try {
|
|
5013
|
-
|
|
5013
|
+
text4 = `${name} = ${renderAssignment(hoisted, name, width, callables)}
|
|
5014
5014
|
`;
|
|
5015
5015
|
} catch (error) {
|
|
5016
5016
|
if (!(error instanceof WriteError)) throw error;
|
|
@@ -5033,7 +5033,7 @@ function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH
|
|
|
5033
5033
|
text: `${constant} = ${pyLiteral(held, { indent: 0, width, callables, pointer: `/${constant}` })}`
|
|
5034
5034
|
}));
|
|
5035
5035
|
const imports = callables.size === 0 ? [] : [`from ${library?.module ?? DEFAULT_LIBRARY_MODULE} import ${[...callables].sort().join(", ")}`];
|
|
5036
|
-
const written = [...rows2.map((row) => row.text),
|
|
5036
|
+
const written = [...rows2.map((row) => row.text), text4].join("\n");
|
|
5037
5037
|
for (const literal of findDataLiterals(written)) {
|
|
5038
5038
|
problems.push({
|
|
5039
5039
|
code: "data_literal",
|
|
@@ -5042,7 +5042,7 @@ function writeSpec(data, { library = null, name = "SPEC", width = DEFAULT_WIDTH
|
|
|
5042
5042
|
});
|
|
5043
5043
|
}
|
|
5044
5044
|
if (problems.length > 0) return { text: null, imports: [], constants: [], problems };
|
|
5045
|
-
return { text:
|
|
5045
|
+
return { text: text4, imports, constants: rows2, problems };
|
|
5046
5046
|
}
|
|
5047
5047
|
function writeModule({ docstring = null, imports = [], constants = [], tables = [], body = null } = {}) {
|
|
5048
5048
|
const blocks = [];
|
|
@@ -5051,12 +5051,12 @@ function writeModule({ docstring = null, imports = [], constants = [], tables =
|
|
|
5051
5051
|
if (constants.length > 0) blocks.push(constants.join("\n"));
|
|
5052
5052
|
for (const table of tables) blocks.push(table.replace(/\n+$/, ""));
|
|
5053
5053
|
if (body !== null) blocks.push(body.replace(/\n+$/, ""));
|
|
5054
|
-
let
|
|
5054
|
+
let text4 = "";
|
|
5055
5055
|
for (const [index, block] of blocks.entries()) {
|
|
5056
|
-
if (index > 0)
|
|
5057
|
-
|
|
5056
|
+
if (index > 0) text4 += separator(blocks[index - 1], block);
|
|
5057
|
+
text4 += block;
|
|
5058
5058
|
}
|
|
5059
|
-
return `${
|
|
5059
|
+
return `${text4}
|
|
5060
5060
|
`;
|
|
5061
5061
|
}
|
|
5062
5062
|
function renderAssignment(value, name, width, callables) {
|
|
@@ -5174,10 +5174,10 @@ function pyNumber(value, ctx) {
|
|
|
5174
5174
|
}
|
|
5175
5175
|
return Number.isInteger(value) ? String(value) : String(value);
|
|
5176
5176
|
}
|
|
5177
|
-
function pyString(
|
|
5178
|
-
const quote =
|
|
5177
|
+
function pyString(text4) {
|
|
5178
|
+
const quote = text4.includes('"') && !text4.includes("'") ? "'" : '"';
|
|
5179
5179
|
let out = quote;
|
|
5180
|
-
for (const ch of
|
|
5180
|
+
for (const ch of text4) {
|
|
5181
5181
|
if (ch === "\\") out += "\\\\";
|
|
5182
5182
|
else if (ch === quote) out += `\\${ch}`;
|
|
5183
5183
|
else if (ch === "\n") out += "\\n";
|
|
@@ -5235,8 +5235,8 @@ function constantName(path3, constants) {
|
|
|
5235
5235
|
if (!constants.has(start)) return start;
|
|
5236
5236
|
for (let n = 2; ; n += 1) if (!constants.has(`${start}_${n}`)) return `${start}_${n}`;
|
|
5237
5237
|
}
|
|
5238
|
-
function asDocstring(
|
|
5239
|
-
const body = String(
|
|
5238
|
+
function asDocstring(text4) {
|
|
5239
|
+
const body = String(text4).replace(/\\/g, "\\\\").replace(/"""/g, '\\"\\"\\"').replace(/\s+$/, "");
|
|
5240
5240
|
return body.includes("\n") ? `"""${body}
|
|
5241
5241
|
"""` : `"""${body}"""`;
|
|
5242
5242
|
}
|
|
@@ -5418,8 +5418,8 @@ function transformFileProblems(data, extra) {
|
|
|
5418
5418
|
for (const key of Object.keys(widgets).sort(natural2)) {
|
|
5419
5419
|
const path3 = isPlainObject(widgets[key]) ? widgets[key].transform : void 0;
|
|
5420
5420
|
if (typeof path3 !== "string" || !TRANSFORM_PATH.test(path3)) continue;
|
|
5421
|
-
const
|
|
5422
|
-
if (typeof
|
|
5421
|
+
const text4 = files[path3];
|
|
5422
|
+
if (typeof text4 !== "string") {
|
|
5423
5423
|
problems.push({
|
|
5424
5424
|
code: "transform_missing",
|
|
5425
5425
|
where: `/data/widgets/${key}/transform`,
|
|
@@ -5429,14 +5429,14 @@ function transformFileProblems(data, extra) {
|
|
|
5429
5429
|
}
|
|
5430
5430
|
if (linted.has(path3)) continue;
|
|
5431
5431
|
linted.add(path3);
|
|
5432
|
-
for (const finding of lintTransform(
|
|
5432
|
+
for (const finding of lintTransform(text4)) {
|
|
5433
5433
|
problems.push({ code: "transform_forbidden", where: `${path3}:${finding.line}`, message: finding.message });
|
|
5434
5434
|
}
|
|
5435
5435
|
}
|
|
5436
5436
|
return problems;
|
|
5437
5437
|
}
|
|
5438
|
-
function lintTransform(
|
|
5439
|
-
const tokens = new Literals(String(
|
|
5438
|
+
function lintTransform(text4) {
|
|
5439
|
+
const tokens = new Literals(String(text4 ?? ""), "py").tokens;
|
|
5440
5440
|
const findings = nameFindings(tokens);
|
|
5441
5441
|
let defined = false;
|
|
5442
5442
|
for (let i = 0; i < tokens.length; i += 1) {
|
|
@@ -5531,8 +5531,8 @@ function fieldExpressions(body) {
|
|
|
5531
5531
|
}
|
|
5532
5532
|
return fields;
|
|
5533
5533
|
}
|
|
5534
|
-
function findTransformLiterals(
|
|
5535
|
-
const source = String(
|
|
5534
|
+
function findTransformLiterals(text4) {
|
|
5535
|
+
const source = String(text4 ?? "");
|
|
5536
5536
|
const tokens = new Literals(source, "py").tokens;
|
|
5537
5537
|
const found = [];
|
|
5538
5538
|
const stack = [];
|
|
@@ -5723,8 +5723,8 @@ ${entries.map((entry) => ` ${entry},`).join("\n")}
|
|
|
5723
5723
|
table
|
|
5724
5724
|
].join("\n");
|
|
5725
5725
|
}
|
|
5726
|
-
function pyText(
|
|
5727
|
-
const value = String(
|
|
5726
|
+
function pyText(text4) {
|
|
5727
|
+
const value = String(text4);
|
|
5728
5728
|
let doubles = 0;
|
|
5729
5729
|
let singles = 0;
|
|
5730
5730
|
for (const ch of value) {
|
|
@@ -5749,7 +5749,7 @@ function readTransforms(source) {
|
|
|
5749
5749
|
if (!literals.has(TRANSFORMS_TABLE)) return { found: false, texts: null, span: null, text: null };
|
|
5750
5750
|
const value = literals.constant(TRANSFORMS_TABLE);
|
|
5751
5751
|
const span = literals.constantSpan(TRANSFORMS_TABLE);
|
|
5752
|
-
const readable = isPlainObject(value) && Object.entries(value).every(([path3,
|
|
5752
|
+
const readable = isPlainObject(value) && Object.entries(value).every(([path3, text4]) => TRANSFORM_PATH.test(path3) && typeof text4 === "string");
|
|
5753
5753
|
if (!readable) return { found: true, texts: null, span, text: literals.constantText(TRANSFORMS_TABLE) };
|
|
5754
5754
|
const texts = {};
|
|
5755
5755
|
for (const path3 of Object.keys(value).sort(natural2)) texts[path3] = value[path3];
|
|
@@ -5948,9 +5948,9 @@ function routesOf(manifest) {
|
|
|
5948
5948
|
function themeSection(app) {
|
|
5949
5949
|
const file = app.ui.find((entry) => entry.path === THEME_FILE);
|
|
5950
5950
|
if (!file) return null;
|
|
5951
|
-
const
|
|
5951
|
+
const text4 = file.text.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
5952
5952
|
const tokens = {};
|
|
5953
|
-
for (const block of
|
|
5953
|
+
for (const block of text4.matchAll(/(?::root|body\.dr-app-page)\s*\{([^}]*)\}/g)) {
|
|
5954
5954
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
5955
5955
|
if (hit[1] !== "--dr-app-theme") tokens[hit[1]] = hit[2].trim();
|
|
5956
5956
|
}
|
|
@@ -6133,10 +6133,10 @@ function mountOf(page) {
|
|
|
6133
6133
|
};
|
|
6134
6134
|
}
|
|
6135
6135
|
function embeddedContractOf(page) {
|
|
6136
|
-
const
|
|
6137
|
-
if (
|
|
6136
|
+
const text4 = contractBlockText(page?.text ?? "");
|
|
6137
|
+
if (text4 === null) return null;
|
|
6138
6138
|
try {
|
|
6139
|
-
const embedded = JSON.parse(
|
|
6139
|
+
const embedded = JSON.parse(text4.replace(/<\\\//g, "</"));
|
|
6140
6140
|
return isPlainObject(embedded) ? embedded : null;
|
|
6141
6141
|
} catch {
|
|
6142
6142
|
return null;
|
|
@@ -6168,10 +6168,10 @@ function cardSpecOf(element) {
|
|
|
6168
6168
|
return element?.type === "widget" && typeof card === "string" && card !== "" ? card : null;
|
|
6169
6169
|
}
|
|
6170
6170
|
var RUNTIME_RENDERER = "runtime";
|
|
6171
|
-
function navGates(
|
|
6171
|
+
function navGates(text4, pagePath) {
|
|
6172
6172
|
const out = /* @__PURE__ */ new Map();
|
|
6173
|
-
if (typeof
|
|
6174
|
-
const tree = decodedTree(
|
|
6173
|
+
if (typeof text4 !== "string") return out;
|
|
6174
|
+
const tree = decodedTree(text4);
|
|
6175
6175
|
const base = pagePath.includes("/") ? pagePath.slice(0, pagePath.lastIndexOf("/") + 1) : "";
|
|
6176
6176
|
for (const node of tree.nodes) {
|
|
6177
6177
|
if (node.tag !== "a" || typeof node.attrs.href !== "string" || typeof node.attrs["data-dr-role"] !== "string") continue;
|
|
@@ -6187,8 +6187,8 @@ function navGates(text3, pagePath) {
|
|
|
6187
6187
|
}
|
|
6188
6188
|
return out;
|
|
6189
6189
|
}
|
|
6190
|
-
function isOwnedPage(
|
|
6191
|
-
return typeof
|
|
6190
|
+
function isOwnedPage(text4) {
|
|
6191
|
+
return typeof text4 === "string" && ownedIn(decodedTree(text4));
|
|
6192
6192
|
}
|
|
6193
6193
|
function ownedIn(tree) {
|
|
6194
6194
|
const hasHead = tree.nodes.some((node) => node.tag === "head");
|
|
@@ -6305,7 +6305,7 @@ function numberAttr(node, name) {
|
|
|
6305
6305
|
if (raw === "") return null;
|
|
6306
6306
|
return Number.isFinite(Number(raw)) ? Number(raw) : raw;
|
|
6307
6307
|
}
|
|
6308
|
-
function propsOf(node,
|
|
6308
|
+
function propsOf(node, text4, tree) {
|
|
6309
6309
|
const props = {};
|
|
6310
6310
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
6311
6311
|
if (!name.startsWith(WIDGET_PREFIX)) continue;
|
|
@@ -6317,13 +6317,13 @@ function propsOf(node, text3, tree) {
|
|
|
6317
6317
|
props.param = node.attrs[CONTROL_ATTR];
|
|
6318
6318
|
props.control_kind = node.attrs[`${CONTROL_ATTR}-kind`] ?? null;
|
|
6319
6319
|
for (const name of CONTROL_PROPS) if (name in node.attrs) props[name] = node.attrs[name];
|
|
6320
|
-
const label = labelFor(node,
|
|
6320
|
+
const label = labelFor(node, text4, tree);
|
|
6321
6321
|
if (label !== null) props.label = label;
|
|
6322
6322
|
}
|
|
6323
6323
|
if (node.tag === "a" && "href" in node.attrs) {
|
|
6324
6324
|
props.href = node.attrs.href;
|
|
6325
6325
|
props.current = node.attrs["aria-current"] === "page";
|
|
6326
|
-
const label = textOf(
|
|
6326
|
+
const label = textOf(text4, node);
|
|
6327
6327
|
if (label) props.label = label;
|
|
6328
6328
|
}
|
|
6329
6329
|
if (COMPONENT_ATTR in node.attrs || FIELD_ATTR in node.attrs) {
|
|
@@ -6337,9 +6337,9 @@ function propsOf(node, text3, tree) {
|
|
|
6337
6337
|
const inputType = inputTypeOf(node);
|
|
6338
6338
|
if (inputType !== null) props.input_type = inputType;
|
|
6339
6339
|
if ("required" in node.attrs) props.required = true;
|
|
6340
|
-
if (node.tag === "select") props.options = optionsOf(node,
|
|
6340
|
+
if (node.tag === "select") props.options = optionsOf(node, text4, tree);
|
|
6341
6341
|
if (props.label === void 0) {
|
|
6342
|
-
const label = labelFor(node,
|
|
6342
|
+
const label = labelFor(node, text4, tree);
|
|
6343
6343
|
if (label !== null) props.label = label;
|
|
6344
6344
|
}
|
|
6345
6345
|
}
|
|
@@ -6353,13 +6353,13 @@ function inputTypeOf(node) {
|
|
|
6353
6353
|
if (node.tag === "input") return node.attrs.type ?? "text";
|
|
6354
6354
|
return null;
|
|
6355
6355
|
}
|
|
6356
|
-
function optionsOf(node,
|
|
6356
|
+
function optionsOf(node, text4, tree) {
|
|
6357
6357
|
const options = [];
|
|
6358
6358
|
const walk5 = (index) => {
|
|
6359
6359
|
for (const child of tree.nodes[index].children) {
|
|
6360
6360
|
const candidate = tree.nodes[child];
|
|
6361
6361
|
if (candidate.tag === "option") {
|
|
6362
|
-
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf(
|
|
6362
|
+
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf(text4, candidate));
|
|
6363
6363
|
} else walk5(child);
|
|
6364
6364
|
}
|
|
6365
6365
|
};
|
|
@@ -6369,15 +6369,15 @@ function optionsOf(node, text3, tree) {
|
|
|
6369
6369
|
function splitList(value) {
|
|
6370
6370
|
return String(value).split(/[\s,]+/).filter(Boolean);
|
|
6371
6371
|
}
|
|
6372
|
-
function labelFor(node,
|
|
6372
|
+
function labelFor(node, text4, tree) {
|
|
6373
6373
|
const id = node.attrs.id;
|
|
6374
6374
|
if (!id) return node.attrs["aria-label"] ?? null;
|
|
6375
6375
|
const label = tree.nodes.find((candidate) => candidate.tag === "label" && candidate.attrs.for === id);
|
|
6376
|
-
return label ? textOf(
|
|
6376
|
+
return label ? textOf(text4, label) : node.attrs["aria-label"] ?? null;
|
|
6377
6377
|
}
|
|
6378
|
-
function textOf(
|
|
6379
|
-
const next =
|
|
6380
|
-
return decodeEntities(
|
|
6378
|
+
function textOf(text4, node) {
|
|
6379
|
+
const next = text4.indexOf("<", node.end);
|
|
6380
|
+
return decodeEntities(text4.slice(node.end, next === -1 ? void 0 : next).replace(/\s+/g, " ").trim());
|
|
6381
6381
|
}
|
|
6382
6382
|
function slotsOf(node, tree) {
|
|
6383
6383
|
if (!(WIDGET_ATTR in node.attrs)) return {};
|
|
@@ -6402,23 +6402,23 @@ function bindingOf(entry, node, spec) {
|
|
|
6402
6402
|
if (entry.type === "control") return node.attrs[CONTROL_ATTR] || null;
|
|
6403
6403
|
return null;
|
|
6404
6404
|
}
|
|
6405
|
-
function titleOf(tree,
|
|
6405
|
+
function titleOf(tree, text4) {
|
|
6406
6406
|
const title = tree.nodes.find((node) => node.tag === "title");
|
|
6407
|
-
return title ? textOf(
|
|
6407
|
+
return title ? textOf(text4, title) : null;
|
|
6408
6408
|
}
|
|
6409
|
-
function headerOf(tree,
|
|
6409
|
+
function headerOf(tree, text4) {
|
|
6410
6410
|
const withClass = (name) => tree.nodes.find((node) => classesOf(node).includes(name));
|
|
6411
6411
|
const title = withClass("dr-appbar__title");
|
|
6412
6412
|
if (title) {
|
|
6413
6413
|
const summary2 = withClass("dr-appbar__summary");
|
|
6414
|
-
return { title: textOf(
|
|
6414
|
+
return { title: textOf(text4, title), summary: summary2 ? textOf(text4, summary2) || null : null };
|
|
6415
6415
|
}
|
|
6416
6416
|
const region = tree.nodes.find((node) => node.attrs[KIT_ATTR] === "header");
|
|
6417
6417
|
if (!region) return null;
|
|
6418
6418
|
const heading = firstTag(tree, region, "h1", true);
|
|
6419
6419
|
if (!heading) return null;
|
|
6420
6420
|
const summary = firstTag(tree, region, "p", true);
|
|
6421
|
-
const out = { title: textOf(
|
|
6421
|
+
const out = { title: textOf(text4, heading), summary: summary ? textOf(text4, summary) || null : null };
|
|
6422
6422
|
const actions = parseJsonAttr(region.attrs[HEADER_ACTIONS_ATTR]);
|
|
6423
6423
|
if (Array.isArray(actions)) out.actions = actions;
|
|
6424
6424
|
const from = region.attrs[TITLE_FROM_ATTR];
|
|
@@ -6452,16 +6452,16 @@ function navOf(tree, main2) {
|
|
|
6452
6452
|
const source = nav?.attrs[NAV_COUNTS_ATTR] ?? main2?.attrs[NAV_COUNTS_ATTR];
|
|
6453
6453
|
return source === void 0 || source === "" ? {} : { nav: { counts: { source } } };
|
|
6454
6454
|
}
|
|
6455
|
-
function sectionOf(node,
|
|
6456
|
-
const title = textOf(
|
|
6455
|
+
function sectionOf(node, text4, index) {
|
|
6456
|
+
const title = textOf(text4, node);
|
|
6457
6457
|
return { id: node.attrs.id ?? slug(title) ?? `section_${index + 1}`, title };
|
|
6458
6458
|
}
|
|
6459
|
-
function wrappedSectionOf(tree, node,
|
|
6459
|
+
function wrappedSectionOf(tree, node, text4, index) {
|
|
6460
6460
|
const heading = firstTag(tree, node, "h2");
|
|
6461
6461
|
const id = node.attrs[SECTION_ATTR];
|
|
6462
|
-
const out = { id: id === void 0 || id === "" ? `section_${index + 1}` : id, title: heading ? textOf(
|
|
6462
|
+
const out = { id: id === void 0 || id === "" ? `section_${index + 1}` : id, title: heading ? textOf(text4, heading) : "" };
|
|
6463
6463
|
const subtitle = node.children.map((child) => tree.nodes[child]).find((child) => child.tag === "p");
|
|
6464
|
-
if (subtitle) out.subtitle = textOf(
|
|
6464
|
+
if (subtitle) out.subtitle = textOf(text4, subtitle);
|
|
6465
6465
|
for (const key of BAND_LOOK) {
|
|
6466
6466
|
const value = node.attrs[`data-dr-${key}`];
|
|
6467
6467
|
if (value !== void 0 && value !== "") out[key] = value;
|
|
@@ -6469,8 +6469,8 @@ function wrappedSectionOf(tree, node, text3, index) {
|
|
|
6469
6469
|
return out;
|
|
6470
6470
|
}
|
|
6471
6471
|
var BAND_LOOK = ["layout", "surface", "aside"];
|
|
6472
|
-
function slug(
|
|
6473
|
-
const clean = String(
|
|
6472
|
+
function slug(text4) {
|
|
6473
|
+
const clean = String(text4 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
6474
6474
|
return clean === "" ? null : clean;
|
|
6475
6475
|
}
|
|
6476
6476
|
function routeOf(manifest, path3) {
|
|
@@ -6823,9 +6823,9 @@ function readSources(handlers) {
|
|
|
6823
6823
|
}
|
|
6824
6824
|
const carried = literals.constant("TRANSFORMS");
|
|
6825
6825
|
if (!isPlainObject(carried)) continue;
|
|
6826
|
-
for (const [name,
|
|
6826
|
+
for (const [name, text4] of Object.entries(carried)) {
|
|
6827
6827
|
const path3 = table[name]?.transform;
|
|
6828
|
-
if (typeof path3 === "string" && typeof
|
|
6828
|
+
if (typeof path3 === "string" && typeof text4 === "string" && !texts.has(path3)) texts.set(path3, text4);
|
|
6829
6829
|
}
|
|
6830
6830
|
}
|
|
6831
6831
|
const owned = [...texts.keys()].sort(natural3).map((path3) => ({ path: path3, text: texts.get(path3) }));
|
|
@@ -6850,9 +6850,9 @@ function specTransforms(handlers, spec, problems) {
|
|
|
6850
6850
|
continue;
|
|
6851
6851
|
}
|
|
6852
6852
|
carried ??= /* @__PURE__ */ new Set();
|
|
6853
|
-
for (const [path3,
|
|
6853
|
+
for (const [path3, text4] of Object.entries(table.texts)) {
|
|
6854
6854
|
carried.add(path3);
|
|
6855
|
-
out.push({ path: path3, text:
|
|
6855
|
+
out.push({ path: path3, text: text4 });
|
|
6856
6856
|
}
|
|
6857
6857
|
}
|
|
6858
6858
|
const unreadable = problems.some((problem6) => problem6.code === "transform_unreadable");
|
|
@@ -6991,8 +6991,8 @@ function backendSection(app, manifest, pages, elements) {
|
|
|
6991
6991
|
};
|
|
6992
6992
|
}
|
|
6993
6993
|
function handlerVerbs(source) {
|
|
6994
|
-
const
|
|
6995
|
-
return DATA_VERBS.filter((verb) => TABLE_ONLY_VERBS.has(verb) ? callsOnTable(
|
|
6994
|
+
const text4 = typeof source === "string" ? source : "";
|
|
6995
|
+
return DATA_VERBS.filter((verb) => TABLE_ONLY_VERBS.has(verb) ? callsOnTable(text4, verb) : new RegExp(`\\.\\s*${verb}\\s*\\(`).test(text4));
|
|
6996
6996
|
}
|
|
6997
6997
|
function callsOnTable(source, verb) {
|
|
6998
6998
|
const holders = [TABLE_INLINE];
|
|
@@ -7015,9 +7015,9 @@ function signatureOk(source) {
|
|
|
7015
7015
|
}
|
|
7016
7016
|
return count >= 2;
|
|
7017
7017
|
}
|
|
7018
|
-
function isReferenced(name,
|
|
7018
|
+
function isReferenced(name, text4) {
|
|
7019
7019
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
7020
|
-
return new RegExp(`\\bcall\\(\\s*(['"\`])${escaped}\\1|/${escaped}(['"\`]|\\b)|(['"\`])${escaped}\\3`).test(
|
|
7020
|
+
return new RegExp(`\\bcall\\(\\s*(['"\`])${escaped}\\1|/${escaped}(['"\`]|\\b)|(['"\`])${escaped}\\3`).test(text4);
|
|
7021
7021
|
}
|
|
7022
7022
|
function rolesOf(manifest) {
|
|
7023
7023
|
const roles = Array.isArray(manifest.roles) ? manifest.roles : [];
|
|
@@ -7152,9 +7152,9 @@ function natural3(a, b) {
|
|
|
7152
7152
|
var NAMED_ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
7153
7153
|
var ENTITY = /&(#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z][a-zA-Z0-9]{1,31});/g;
|
|
7154
7154
|
function decodeEntities(value) {
|
|
7155
|
-
const
|
|
7156
|
-
if (!
|
|
7157
|
-
return
|
|
7155
|
+
const text4 = String(value);
|
|
7156
|
+
if (!text4.includes("&")) return text4;
|
|
7157
|
+
return text4.replace(ENTITY, (whole, body) => {
|
|
7158
7158
|
if (body[0] !== "#") return Object.prototype.hasOwnProperty.call(NAMED_ENTITIES, body) ? NAMED_ENTITIES[body] : whole;
|
|
7159
7159
|
const code = body[1] === "x" || body[1] === "X" ? Number.parseInt(body.slice(2), 16) : Number.parseInt(body.slice(1), 10);
|
|
7160
7160
|
if (!Number.isInteger(code) || code < 1 || code > 1114111 || code >= 55296 && code <= 57343) return whole;
|
|
@@ -8354,7 +8354,7 @@ function pyCode(source) {
|
|
|
8354
8354
|
}
|
|
8355
8355
|
return out;
|
|
8356
8356
|
}
|
|
8357
|
-
var reEscape = (
|
|
8357
|
+
var reEscape = (text4) => text4.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
8358
8358
|
function pyPayloadReads(source) {
|
|
8359
8359
|
const code = pyCode(String(source ?? ""));
|
|
8360
8360
|
const signature = /^[ \t]*(?:async[ \t]+)?def[ \t]+handle[ \t]*\([ \t]*\w+[ \t]*,[ \t]*(\w+)/m.exec(code);
|
|
@@ -8424,24 +8424,24 @@ function jsCode(source) {
|
|
|
8424
8424
|
}
|
|
8425
8425
|
return out;
|
|
8426
8426
|
}
|
|
8427
|
-
function stringEnd(
|
|
8428
|
-
const quote =
|
|
8427
|
+
function stringEnd(text4, i) {
|
|
8428
|
+
const quote = text4[i];
|
|
8429
8429
|
let j = i + 1;
|
|
8430
|
-
while (j <
|
|
8431
|
-
if (
|
|
8432
|
-
else if (quote !== "`" &&
|
|
8430
|
+
while (j < text4.length && text4[j] !== quote) {
|
|
8431
|
+
if (text4[j] === "\\") j++;
|
|
8432
|
+
else if (quote !== "`" && text4[j] === "\n") break;
|
|
8433
8433
|
j++;
|
|
8434
8434
|
}
|
|
8435
|
-
return Math.min(j + 1,
|
|
8435
|
+
return Math.min(j + 1, text4.length);
|
|
8436
8436
|
}
|
|
8437
|
-
function closeOf(
|
|
8438
|
-
const open2 =
|
|
8437
|
+
function closeOf(text4, i) {
|
|
8438
|
+
const open2 = text4[i];
|
|
8439
8439
|
const close = { "{": "}", "(": ")", "[": "]" }[open2];
|
|
8440
8440
|
let depth = 0;
|
|
8441
|
-
for (let j = i; j <
|
|
8442
|
-
const ch =
|
|
8441
|
+
for (let j = i; j < text4.length; j++) {
|
|
8442
|
+
const ch = text4[j];
|
|
8443
8443
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
8444
|
-
j = stringEnd(
|
|
8444
|
+
j = stringEnd(text4, j) - 1;
|
|
8445
8445
|
continue;
|
|
8446
8446
|
}
|
|
8447
8447
|
if (ch === "{" || ch === "(" || ch === "[") depth++;
|
|
@@ -8452,12 +8452,12 @@ function closeOf(text3, i) {
|
|
|
8452
8452
|
}
|
|
8453
8453
|
return -1;
|
|
8454
8454
|
}
|
|
8455
|
-
function literalAt(
|
|
8456
|
-
const quote =
|
|
8455
|
+
function literalAt(text4, i) {
|
|
8456
|
+
const quote = text4[i];
|
|
8457
8457
|
if (quote !== '"' && quote !== "'" && quote !== "`") return null;
|
|
8458
|
-
const end = stringEnd(
|
|
8459
|
-
const body =
|
|
8460
|
-
if (
|
|
8458
|
+
const end = stringEnd(text4, i);
|
|
8459
|
+
const body = text4.slice(i + 1, end - 1);
|
|
8460
|
+
if (text4[end - 1] !== quote || quote === "`" && body.includes("${") || body.includes("\\")) return null;
|
|
8461
8461
|
return { value: body, end };
|
|
8462
8462
|
}
|
|
8463
8463
|
function objectKeys(body) {
|
|
@@ -8571,8 +8571,8 @@ function fieldOf(element) {
|
|
|
8571
8571
|
if (INPUT_PARTS.has(element?.type) && named2(element.props?.props?.field)) return element.props.props.field;
|
|
8572
8572
|
return null;
|
|
8573
8573
|
}
|
|
8574
|
-
function mentions(
|
|
8575
|
-
return new RegExp(`(^|[^A-Za-z0-9_])${reEscape(name)}([^A-Za-z0-9_]|$)`).test(
|
|
8574
|
+
function mentions(text4, name) {
|
|
8575
|
+
return new RegExp(`(^|[^A-Za-z0-9_])${reEscape(name)}([^A-Za-z0-9_]|$)`).test(text4);
|
|
8576
8576
|
}
|
|
8577
8577
|
function payloadProducers(contract, { moduleSource = () => void 0, pageSource = () => void 0 } = {}) {
|
|
8578
8578
|
const elements = isPlainObject2(contract?.elements) ? contract.elements : {};
|
|
@@ -8697,13 +8697,13 @@ function payloadProducers(contract, { moduleSource = () => void 0, pageSource =
|
|
|
8697
8697
|
}
|
|
8698
8698
|
for (const page of Array.isArray(contract?.pages) ? contract.pages : []) {
|
|
8699
8699
|
if (!named2(page?.path)) continue;
|
|
8700
|
-
const
|
|
8700
|
+
const text4 = pageSource(page.path);
|
|
8701
8701
|
const unknown = { page: page.path, uid: null, what: "script", keys: null };
|
|
8702
|
-
if (typeof
|
|
8702
|
+
if (typeof text4 !== "string") {
|
|
8703
8703
|
if (page.owned === true) add("*", unknown);
|
|
8704
8704
|
continue;
|
|
8705
8705
|
}
|
|
8706
|
-
const code = page.owned === true ? [
|
|
8706
|
+
const code = page.owned === true ? [text4] : pageCode(text4, page.path, modules, pageSource);
|
|
8707
8707
|
if (code === null) {
|
|
8708
8708
|
add("*", unknown);
|
|
8709
8709
|
continue;
|
|
@@ -8938,23 +8938,23 @@ function problem2(at, why, kind = "other") {
|
|
|
8938
8938
|
function describe2(node, ctx) {
|
|
8939
8939
|
return ctx.inBranch && isObject3(node) && typeof node.description === "string" ? ` \u2014 ${firstSentence2(node.description)}` : "";
|
|
8940
8940
|
}
|
|
8941
|
-
function firstSentence2(
|
|
8941
|
+
function firstSentence2(text4) {
|
|
8942
8942
|
let start = 0;
|
|
8943
8943
|
for (; ; ) {
|
|
8944
|
-
const end =
|
|
8944
|
+
const end = text4.indexOf(". ", start);
|
|
8945
8945
|
if (end === -1) break;
|
|
8946
|
-
const before =
|
|
8946
|
+
const before = text4.slice(0, end);
|
|
8947
8947
|
if (!before.endsWith("e.g") && !before.endsWith("i.e")) {
|
|
8948
|
-
|
|
8948
|
+
text4 = text4.slice(0, end + 1);
|
|
8949
8949
|
break;
|
|
8950
8950
|
}
|
|
8951
8951
|
start = end + 2;
|
|
8952
8952
|
}
|
|
8953
|
-
return truncate4(
|
|
8953
|
+
return truncate4(text4);
|
|
8954
8954
|
}
|
|
8955
|
-
function truncate4(
|
|
8956
|
-
const chars = [...
|
|
8957
|
-
if (chars.length <= MAX_HINT2) return
|
|
8955
|
+
function truncate4(text4) {
|
|
8956
|
+
const chars = [...text4];
|
|
8957
|
+
if (chars.length <= MAX_HINT2) return text4;
|
|
8958
8958
|
let cut3 = chars.slice(0, MAX_HINT2 - 1);
|
|
8959
8959
|
const space = cut3.lastIndexOf(" ");
|
|
8960
8960
|
if (space > Math.floor(MAX_HINT2 / 2)) cut3 = cut3.slice(0, space);
|
|
@@ -9220,14 +9220,14 @@ function targetOf(href) {
|
|
|
9220
9220
|
return `ui/${file}`;
|
|
9221
9221
|
}
|
|
9222
9222
|
function navLinks(html, { owned = false } = {}) {
|
|
9223
|
-
const
|
|
9223
|
+
const text4 = String(html ?? "");
|
|
9224
9224
|
const regions = [];
|
|
9225
|
-
if (owned) regions.push(
|
|
9225
|
+
if (owned) regions.push(text4);
|
|
9226
9226
|
else {
|
|
9227
|
-
for (const open2 of
|
|
9227
|
+
for (const open2 of text4.matchAll(NAV_OPEN)) {
|
|
9228
9228
|
const start = open2.index + open2[0].length;
|
|
9229
|
-
const end =
|
|
9230
|
-
regions.push(
|
|
9229
|
+
const end = text4.indexOf("</nav>", start);
|
|
9230
|
+
regions.push(text4.slice(start, end === -1 ? text4.length : end));
|
|
9231
9231
|
}
|
|
9232
9232
|
}
|
|
9233
9233
|
const out = [];
|
|
@@ -9239,7 +9239,7 @@ function navLinks(html, { owned = false } = {}) {
|
|
|
9239
9239
|
}
|
|
9240
9240
|
}
|
|
9241
9241
|
if (owned) {
|
|
9242
|
-
for (const link of moduleLinks(
|
|
9242
|
+
for (const link of moduleLinks(text4)) if (!out.some((one) => one.target === link.target && one.gate.length === 0)) out.push(link);
|
|
9243
9243
|
}
|
|
9244
9244
|
return out;
|
|
9245
9245
|
}
|
|
@@ -9514,7 +9514,7 @@ var REASON_KEYS = Object.freeze([
|
|
|
9514
9514
|
]);
|
|
9515
9515
|
var REJECTS = /(?:==|!=|\bin\b)[^\n]*(['"])(?:reject|rejected|decline|declined|deny|denied)\1/i;
|
|
9516
9516
|
function pyLines(source) {
|
|
9517
|
-
const
|
|
9517
|
+
const text4 = String(source ?? "").replace(/("""|''')[\s\S]*?\1/g, (block) => block.replace(/[^\n]/g, " ")).split("\n").map((line2) => {
|
|
9518
9518
|
let quote = null;
|
|
9519
9519
|
for (let i = 0; i < line2.length; i++) {
|
|
9520
9520
|
const ch = line2[i];
|
|
@@ -9526,7 +9526,7 @@ function pyLines(source) {
|
|
|
9526
9526
|
}
|
|
9527
9527
|
return line2;
|
|
9528
9528
|
});
|
|
9529
|
-
return
|
|
9529
|
+
return text4;
|
|
9530
9530
|
}
|
|
9531
9531
|
var indentOf = (line2) => /^[ \t]*/.exec(line2)[0].replace(/\t/g, " ").length;
|
|
9532
9532
|
var blank = (line2) => line2.trim() === "";
|
|
@@ -9599,7 +9599,7 @@ function unliftableRefusals(contract, { handlerSource = () => void 0 } = {}) {
|
|
|
9599
9599
|
for (const key of REASON_KEYS) {
|
|
9600
9600
|
if (!reads.optional.includes(key) && !reads.required.includes(key)) continue;
|
|
9601
9601
|
const vars = reasonVars(lines, key);
|
|
9602
|
-
const mentions3 = (
|
|
9602
|
+
const mentions3 = (text4) => new RegExp(`(['"])${key}\\1`).test(text4) || [...vars].some((v) => new RegExp(`\\b${v}\\b`).test(text4));
|
|
9603
9603
|
const gates = lines.map((line2, i) => [line2, i]).filter(([line2]) => /^\s*if\b/.test(line2) && [...vars].some((v) => new RegExp(`\\bnot[ \\t]+\\(?[ \\t]*${v}\\b`).test(line2)));
|
|
9604
9604
|
for (const [gate, gi] of gates) {
|
|
9605
9605
|
const depth = indentOf(gate);
|
|
@@ -11787,40 +11787,40 @@ var FORMULA_NUMBERS_ALONE = "its figure can be a number it states rather than an
|
|
|
11787
11787
|
var COMPARISONS = ["<=", ">=", "==", "!=", "<", ">"];
|
|
11788
11788
|
var FormulaSyntax = class extends Error {
|
|
11789
11789
|
};
|
|
11790
|
-
function tokenize2(
|
|
11790
|
+
function tokenize2(text4) {
|
|
11791
11791
|
const tokens = [];
|
|
11792
11792
|
let at = 0;
|
|
11793
11793
|
const isDigit = (c) => c >= "0" && c <= "9";
|
|
11794
11794
|
const isStart = (c) => /[\p{L}_]/u.test(c);
|
|
11795
11795
|
const isPart5 = (c) => /[\p{L}\p{N}_]/u.test(c);
|
|
11796
|
-
while (at <
|
|
11797
|
-
const c =
|
|
11796
|
+
while (at < text4.length) {
|
|
11797
|
+
const c = text4[at];
|
|
11798
11798
|
if (/\s/.test(c)) {
|
|
11799
11799
|
at += 1;
|
|
11800
|
-
} else if (COMPARISONS.slice(0, 4).includes(
|
|
11801
|
-
tokens.push(["op",
|
|
11800
|
+
} else if (COMPARISONS.slice(0, 4).includes(text4.slice(at, at + 2))) {
|
|
11801
|
+
tokens.push(["op", text4.slice(at, at + 2)]);
|
|
11802
11802
|
at += 2;
|
|
11803
11803
|
} else if ("+-*/(),<>".includes(c)) {
|
|
11804
11804
|
tokens.push(["op", c]);
|
|
11805
11805
|
at += 1;
|
|
11806
11806
|
} else if (isDigit(c) || c === ".") {
|
|
11807
11807
|
const start = at;
|
|
11808
|
-
while (at <
|
|
11809
|
-
const spelled =
|
|
11808
|
+
while (at < text4.length && (isDigit(text4[at]) || text4[at] === ".")) at += 1;
|
|
11809
|
+
const spelled = text4.slice(start, at);
|
|
11810
11810
|
if ((spelled.match(/\./g) ?? []).length > 1 || spelled === ".") throw new FormulaSyntax();
|
|
11811
11811
|
tokens.push(["num", Number(spelled)]);
|
|
11812
11812
|
} else if (isStart(c)) {
|
|
11813
11813
|
const start = at;
|
|
11814
|
-
while (at <
|
|
11815
|
-
tokens.push(["name",
|
|
11814
|
+
while (at < text4.length && isPart5(text4[at])) at += 1;
|
|
11815
|
+
tokens.push(["name", text4.slice(start, at)]);
|
|
11816
11816
|
} else {
|
|
11817
11817
|
throw new FormulaSyntax();
|
|
11818
11818
|
}
|
|
11819
11819
|
}
|
|
11820
11820
|
return tokens;
|
|
11821
11821
|
}
|
|
11822
|
-
function parseFormula(
|
|
11823
|
-
const tokens = tokenize2(String(
|
|
11822
|
+
function parseFormula(text4) {
|
|
11823
|
+
const tokens = tokenize2(String(text4));
|
|
11824
11824
|
if (tokens.length === 0) throw new FormulaSyntax();
|
|
11825
11825
|
const is = (at, op) => at < tokens.length && tokens[at][0] === "op" && tokens[at][1] === op;
|
|
11826
11826
|
const isComparison = (at) => at < tokens.length && tokens[at][0] === "op" && COMPARISONS.includes(tokens[at][1]);
|
|
@@ -11916,10 +11916,10 @@ function takesAnOperand(node) {
|
|
|
11916
11916
|
if (kind === "bin") return takesAnOperand(node[2]) || takesAnOperand(node[3]);
|
|
11917
11917
|
if (kind === "fn") {
|
|
11918
11918
|
const [, name, args] = node;
|
|
11919
|
-
let
|
|
11920
|
-
if (name === "if")
|
|
11921
|
-
else if (name === "abs" || name === "round")
|
|
11922
|
-
return
|
|
11919
|
+
let figures2 = args;
|
|
11920
|
+
if (name === "if") figures2 = args.slice(1);
|
|
11921
|
+
else if (name === "abs" || name === "round") figures2 = args.slice(0, 1);
|
|
11922
|
+
return figures2.length > 0 && figures2.every(takesAnOperand);
|
|
11923
11923
|
}
|
|
11924
11924
|
return false;
|
|
11925
11925
|
}
|
|
@@ -11968,11 +11968,11 @@ function callProblems(name, args, note) {
|
|
|
11968
11968
|
}
|
|
11969
11969
|
}
|
|
11970
11970
|
}
|
|
11971
|
-
function formulaProblems(
|
|
11972
|
-
if (typeof
|
|
11971
|
+
function formulaProblems(text4, operands) {
|
|
11972
|
+
if (typeof text4 !== "string") return { tree: null, problems: ["the formula is not text"] };
|
|
11973
11973
|
let tree;
|
|
11974
11974
|
try {
|
|
11975
|
-
tree = parseFormula(
|
|
11975
|
+
tree = parseFormula(text4);
|
|
11976
11976
|
} catch (error) {
|
|
11977
11977
|
if (!(error instanceof FormulaSyntax)) throw error;
|
|
11978
11978
|
return {
|
|
@@ -12662,9 +12662,9 @@ function ownedReaders(pages, extra) {
|
|
|
12662
12662
|
const known = /* @__PURE__ */ new Set();
|
|
12663
12663
|
for (const page of Array.isArray(pages) ? pages : []) {
|
|
12664
12664
|
if (page?.owned !== true || !named5(page.path)) continue;
|
|
12665
|
-
const
|
|
12666
|
-
if (typeof
|
|
12667
|
-
const embedded = embeddedContractOf({ text:
|
|
12665
|
+
const text4 = extra?.[page.path];
|
|
12666
|
+
if (typeof text4 !== "string" || !isOwnedPage(text4)) continue;
|
|
12667
|
+
const embedded = embeddedContractOf({ text: text4 });
|
|
12668
12668
|
if (embedded === null) continue;
|
|
12669
12669
|
known.add(page.path);
|
|
12670
12670
|
const elements = isPlainObject8(embedded.elements) ? embedded.elements : {};
|
|
@@ -13291,7 +13291,7 @@ function appIdProblems(app) {
|
|
|
13291
13291
|
return appIdLengthProblems(id, isPlainObject8(app.data_model.tables) ? Object.keys(app.data_model.tables) : []);
|
|
13292
13292
|
}
|
|
13293
13293
|
function appIdLengthProblems(id, tables) {
|
|
13294
|
-
const bytes = (
|
|
13294
|
+
const bytes = (text4) => new TextEncoder().encode(text4).length;
|
|
13295
13295
|
const names = [...tables].sort();
|
|
13296
13296
|
if (names.length === 0) return [];
|
|
13297
13297
|
let longest = names[0];
|
|
@@ -13512,8 +13512,8 @@ function paramProblems(contract, sources) {
|
|
|
13512
13512
|
return problems;
|
|
13513
13513
|
}
|
|
13514
13514
|
function numberFix(value, integer = false) {
|
|
13515
|
-
const
|
|
13516
|
-
const parsed2 =
|
|
13515
|
+
const text4 = typeof value === "string" ? value.trim() : null;
|
|
13516
|
+
const parsed2 = text4 !== null && text4 !== "" ? Number(text4) : NaN;
|
|
13517
13517
|
if (Number.isFinite(parsed2) && (!integer || Number.isInteger(parsed2))) return `write it as the number ${parsed2}, unquoted`;
|
|
13518
13518
|
return `write ${integer ? "a whole number" : "a number"}, or leave the key out`;
|
|
13519
13519
|
}
|
|
@@ -13860,7 +13860,7 @@ function compileApp(contract, { kit = null, runtime = RUNTIME, extra = {} } = {}
|
|
|
13860
13860
|
for (const page of compiled) files[page.path] = pageHtml2(whole, page, elements, tree, model, pageOpts);
|
|
13861
13861
|
}
|
|
13862
13862
|
if (typeof extra["seed.json"] === "string") files["seed.json"] = extra["seed.json"];
|
|
13863
|
-
files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served));
|
|
13863
|
+
files["tests.json"] = typeof extra["tests.json"] === "string" ? extra["tests.json"] : json(testsOf(handlers, names, sources, served, model));
|
|
13864
13864
|
return { files, problems, contract: whole, order: order2, warnings };
|
|
13865
13865
|
}
|
|
13866
13866
|
function refreshPins(contract, compiled, files) {
|
|
@@ -17302,20 +17302,59 @@ contract, not this file.`,
|
|
|
17302
17302
|
].join("\n")
|
|
17303
17303
|
}
|
|
17304
17304
|
};
|
|
17305
|
-
function testsOf(handlers, names, sources = {}, served = []) {
|
|
17305
|
+
function testsOf(handlers, names, sources = {}, served = [], model = { tables: {} }) {
|
|
17306
17306
|
const cases = {};
|
|
17307
17307
|
for (const name of names) {
|
|
17308
17308
|
const row = handlers[name] ?? {};
|
|
17309
|
-
const one = testCase(name, row);
|
|
17309
|
+
const one = testCase(name, row, model);
|
|
17310
17310
|
if (one !== null) cases[name] = [one];
|
|
17311
17311
|
}
|
|
17312
17312
|
for (const name of served) {
|
|
17313
17313
|
const shape = sources[name]?.shape;
|
|
17314
|
-
cases[name] =
|
|
17314
|
+
cases[name] = readsDeclaredMetric(sources[name]) ? (
|
|
17315
|
+
// Bound or not, the card names where its figure comes from
|
|
17316
|
+
// (`meta.source.kind: "metric"`): the one fact a dry run, which binds
|
|
17317
|
+
// nothing, shares with a pushed version. `app-space ship` binds the
|
|
17318
|
+
// metric and checks the source against the draft after its push.
|
|
17319
|
+
[{ name: `${name} names the declared metric it reads`, payload: {}, shape: { meta: { source: { kind: "string" } } } }]
|
|
17320
|
+
) : shape === void 0 || shape === "rows" ? [{ name: `${name} answers with rows`, payload: {}, shape: { rows: [] } }] : [{ name: `${name} answers a ${shape} payload`, payload: {}, shape: { kind: "string" } }];
|
|
17315
17321
|
}
|
|
17316
17322
|
return { handlers: Object.fromEntries(Object.keys(cases).sort(natural3).map((name) => [name, cases[name]])), ui: { entry: "index.html" } };
|
|
17317
17323
|
}
|
|
17318
|
-
function
|
|
17324
|
+
function readsDeclaredMetric(source) {
|
|
17325
|
+
const metric = source?.from?.financeos?.metric;
|
|
17326
|
+
return typeof metric === "string" && metric.startsWith("@");
|
|
17327
|
+
}
|
|
17328
|
+
var SAMPLE_MARK = "app-space test";
|
|
17329
|
+
function sampleValue(column) {
|
|
17330
|
+
if (column.ref !== null || column.type === "file") return void 0;
|
|
17331
|
+
if (Array.isArray(column.enum) && column.enum.length > 0) return column.enum[0];
|
|
17332
|
+
if (column.type === "bool") return true;
|
|
17333
|
+
if (column.type === "int" || column.type === "bigint" || /^decimal\(/.test(column.type)) return 1;
|
|
17334
|
+
if (column.type === "date") return "2000-01-01";
|
|
17335
|
+
if (column.type === "timestamptz") return "2000-01-01T00:00:00Z";
|
|
17336
|
+
if (column.type === "jsonb") return {};
|
|
17337
|
+
if (column.type === "uuid") return "00000000-0000-4000-8000-000000000000";
|
|
17338
|
+
return `${SAMPLE_MARK} ${column.name}`;
|
|
17339
|
+
}
|
|
17340
|
+
function insertPayload(row, model) {
|
|
17341
|
+
const table = model?.tables?.[row.table];
|
|
17342
|
+
if (table === void 0) return {};
|
|
17343
|
+
const fields = new Set(Array.isArray(row.fields) ? row.fields : []);
|
|
17344
|
+
const fixed = isPlainObject8(row.fixed) ? row.fixed : {};
|
|
17345
|
+
const defaults = isPlainObject8(table.defaults) ? table.defaults : {};
|
|
17346
|
+
const payload = {};
|
|
17347
|
+
for (const column of Object.values(table.columns)) {
|
|
17348
|
+
if (column.pk || column.nullable || column.default !== null || column.computed !== null) continue;
|
|
17349
|
+
if (Object.prototype.hasOwnProperty.call(fixed, column.name) || Object.prototype.hasOwnProperty.call(defaults, column.name)) continue;
|
|
17350
|
+
if (!fields.has(column.name)) return null;
|
|
17351
|
+
const value = sampleValue(column);
|
|
17352
|
+
if (value === void 0) return null;
|
|
17353
|
+
payload[column.name] = value;
|
|
17354
|
+
}
|
|
17355
|
+
return payload;
|
|
17356
|
+
}
|
|
17357
|
+
function testCase(name, row, model = { tables: {} }) {
|
|
17319
17358
|
switch (row.role) {
|
|
17320
17359
|
case "list":
|
|
17321
17360
|
case "inbox":
|
|
@@ -17340,7 +17379,10 @@ function testCase(name, row) {
|
|
|
17340
17379
|
if (required.length === 0 && row.role === "submit" && named5(row.by)) {
|
|
17341
17380
|
return { name: `${name} refuses a row with no ${row.by}`, payload: {}, expect: { error: `${row.by} is required` } };
|
|
17342
17381
|
}
|
|
17343
|
-
if (required.length === 0)
|
|
17382
|
+
if (required.length === 0) {
|
|
17383
|
+
const payload = insertPayload(row, model);
|
|
17384
|
+
return payload === null ? null : { name: `${name} writes the row it is given`, payload, shape: { row: {} } };
|
|
17385
|
+
}
|
|
17344
17386
|
return { name: `${name} refuses a row with nothing in it`, payload: {}, expect: { error: `${required[0]} is required` } };
|
|
17345
17387
|
}
|
|
17346
17388
|
case "remove":
|
|
@@ -19871,8 +19913,8 @@ function planPages(skeleton) {
|
|
|
19871
19913
|
};
|
|
19872
19914
|
});
|
|
19873
19915
|
}
|
|
19874
|
-
function slug2(
|
|
19875
|
-
return
|
|
19916
|
+
function slug2(text4) {
|
|
19917
|
+
return text4.trim().toLowerCase().replace(/^\/+|\/+$/g, "").replace(/\.html$/, "").replace(/[^a-z0-9_-]+/g, "-").replace(/-{2,}/g, "-").replace(/^-+|-+$/g, "");
|
|
19876
19918
|
}
|
|
19877
19919
|
function widgetIdFor(cardId, path3, planned, boundElsewhere, taken) {
|
|
19878
19920
|
const candidate = planned.get(cardId) ?? cardId;
|
|
@@ -19976,12 +20018,12 @@ function readDraft(named13, problems) {
|
|
|
19976
20018
|
problems.push(problem3("assemble-draft", at("transforms"), '"transforms" is not an object.', `Write it as {"transforms/<name>.py": "<the file's text>"}.`));
|
|
19977
20019
|
} else {
|
|
19978
20020
|
draft.transforms = {};
|
|
19979
|
-
for (const [path3,
|
|
20021
|
+
for (const [path3, text4] of Object.entries(transforms)) {
|
|
19980
20022
|
if (!TRANSFORM_PATH3.test(path3)) {
|
|
19981
20023
|
problems.push(problem3("assemble-draft", at("transforms", path3), `${JSON.stringify(path3)} is not a transform file name.`, "Name it transforms/<name>.py \u2014 lowercase letters, digits and underscores, at most 64 of them, with the worker prefix (transforms/w3_revenue_ma.py)."));
|
|
19982
|
-
} else if (typeof
|
|
20024
|
+
} else if (typeof text4 !== "string" || text4.trim() === "") {
|
|
19983
20025
|
problems.push(problem3("assemble-draft", at("transforms", path3), `${path3} holds no text.`, 'Give the whole file as one string: "def transform(rows, ctx, params):\\n ...".'));
|
|
19984
|
-
} else draft.transforms[path3] =
|
|
20026
|
+
} else draft.transforms[path3] = text4;
|
|
19985
20027
|
}
|
|
19986
20028
|
}
|
|
19987
20029
|
}
|
|
@@ -20302,10 +20344,10 @@ function mergeTransforms(drafts, widgets, widgetIds, baseTexts, problems, did) {
|
|
|
20302
20344
|
const out = {};
|
|
20303
20345
|
const carriedBy = /* @__PURE__ */ new Map();
|
|
20304
20346
|
for (const draft of drafts) {
|
|
20305
|
-
for (const [path3,
|
|
20347
|
+
for (const [path3, text4] of Object.entries(draft.transforms ?? {})) {
|
|
20306
20348
|
const earlier = carriedBy.get(path3);
|
|
20307
20349
|
if (earlier !== void 0) {
|
|
20308
|
-
if (out[path3] !==
|
|
20350
|
+
if (out[path3] !== text4) {
|
|
20309
20351
|
problems.push(
|
|
20310
20352
|
problem3(
|
|
20311
20353
|
"assemble-conflict",
|
|
@@ -20317,7 +20359,7 @@ function mergeTransforms(drafts, widgets, widgetIds, baseTexts, problems, did) {
|
|
|
20317
20359
|
}
|
|
20318
20360
|
continue;
|
|
20319
20361
|
}
|
|
20320
|
-
out[path3] =
|
|
20362
|
+
out[path3] = text4;
|
|
20321
20363
|
carriedBy.set(path3, draft.name);
|
|
20322
20364
|
}
|
|
20323
20365
|
}
|
|
@@ -20336,7 +20378,7 @@ function mergeTransforms(drafts, widgets, widgetIds, baseTexts, problems, did) {
|
|
|
20336
20378
|
}
|
|
20337
20379
|
}
|
|
20338
20380
|
const mine = new Set(Object.values(widgetIds).flat());
|
|
20339
|
-
for (const [path3,
|
|
20381
|
+
for (const [path3, text4] of Object.entries(out)) {
|
|
20340
20382
|
const name = carriedBy.get(path3) ?? "a draft";
|
|
20341
20383
|
const readers = Object.entries(widgets).filter(([, row]) => isObj(row) && row["transform"] === path3).map(([id]) => id);
|
|
20342
20384
|
if (readers.length === 0) {
|
|
@@ -20351,7 +20393,7 @@ function mergeTransforms(drafts, widgets, widgetIds, baseTexts, problems, did) {
|
|
|
20351
20393
|
continue;
|
|
20352
20394
|
}
|
|
20353
20395
|
const held = baseTexts[path3];
|
|
20354
|
-
if (held ===
|
|
20396
|
+
if (held === text4) continue;
|
|
20355
20397
|
if (held === void 0) {
|
|
20356
20398
|
did.push(`${name}: ${path3}, for ${readers.join(", ")}`);
|
|
20357
20399
|
continue;
|
|
@@ -20377,14 +20419,14 @@ function ownedTextsOf(doc) {
|
|
|
20377
20419
|
const out = {};
|
|
20378
20420
|
for (const entry of Array.isArray(owned) ? owned : []) {
|
|
20379
20421
|
if (!isObj(entry)) continue;
|
|
20380
|
-
const { path: path3, text:
|
|
20381
|
-
if (typeof path3 === "string" && TRANSFORM_PATH3.test(path3) && typeof
|
|
20422
|
+
const { path: path3, text: text4 } = entry;
|
|
20423
|
+
if (typeof path3 === "string" && TRANSFORM_PATH3.test(path3) && typeof text4 === "string") out[path3] = text4;
|
|
20382
20424
|
}
|
|
20383
20425
|
return out;
|
|
20384
20426
|
}
|
|
20385
20427
|
function transformFilesOf(files) {
|
|
20386
20428
|
const out = {};
|
|
20387
|
-
for (const [path3,
|
|
20429
|
+
for (const [path3, text4] of Object.entries(files ?? {})) if (TRANSFORM_PATH3.test(path3) && typeof text4 === "string") out[path3] = text4;
|
|
20388
20430
|
return out;
|
|
20389
20431
|
}
|
|
20390
20432
|
function controlElement(path3, control) {
|
|
@@ -20588,7 +20630,7 @@ function controlOfPart(element, page, path3) {
|
|
|
20588
20630
|
if (name === null || !Array.isArray(page["params"])) return null;
|
|
20589
20631
|
const param = page["params"].find((one) => isObj(one) && one["name"] === name);
|
|
20590
20632
|
if (param === void 0) return null;
|
|
20591
|
-
const
|
|
20633
|
+
const text4 = (value) => typeof value === "number" && Number.isFinite(value) ? String(value) : void 0;
|
|
20592
20634
|
const props = { param: name };
|
|
20593
20635
|
if (type === "toggle") {
|
|
20594
20636
|
props["type"] = "checkbox";
|
|
@@ -20603,7 +20645,7 @@ function controlOfPart(element, page, path3) {
|
|
|
20603
20645
|
["step", "step"],
|
|
20604
20646
|
["value", "default"]
|
|
20605
20647
|
]) {
|
|
20606
|
-
const value =
|
|
20648
|
+
const value = text4(param[from]);
|
|
20607
20649
|
if (value !== void 0) props[key] = value;
|
|
20608
20650
|
}
|
|
20609
20651
|
}
|
|
@@ -21307,8 +21349,8 @@ function formatFigure(value, unit) {
|
|
|
21307
21349
|
}
|
|
21308
21350
|
function figure(value, unit) {
|
|
21309
21351
|
if (typeof value !== "number" || !Number.isFinite(value)) return String(value);
|
|
21310
|
-
const
|
|
21311
|
-
return unit === "%" ? `${
|
|
21352
|
+
const text4 = Number.isInteger(value) ? value.toLocaleString("en-US") : value.toLocaleString("en-US", { maximumFractionDigits: 2 });
|
|
21353
|
+
return unit === "%" ? `${text4} %` : unit === "days" ? `${text4} days` : text4;
|
|
21312
21354
|
}
|
|
21313
21355
|
function summarise2(payload) {
|
|
21314
21356
|
if (typeof payload["error"] === "string") return `ERROR ${payload["error"]}`;
|
|
@@ -21417,13 +21459,13 @@ var HARNESS = [
|
|
|
21417
21459
|
" except BaseException as exc:",
|
|
21418
21460
|
' answer({"ok": False, "type": type(exc).__name__, "message": str(exc)[:2000], "traceback": traceback.format_exc()[-20000:]})'
|
|
21419
21461
|
].join("\n");
|
|
21420
|
-
function runTransformLocally(
|
|
21462
|
+
function runTransformLocally(text4, path3, rows2, params, {
|
|
21421
21463
|
python = "python3",
|
|
21422
21464
|
timeoutMs = TRANSFORM_TIMEOUT_MS,
|
|
21423
21465
|
answerBytes = ANSWER_BYTES
|
|
21424
21466
|
} = {}) {
|
|
21425
21467
|
const result = spawnSync(python, ["-I", "-c", HARNESS], {
|
|
21426
|
-
input: JSON.stringify({ text:
|
|
21468
|
+
input: JSON.stringify({ text: text4, path: path3, rows: rows2, params, calls: [...FORBIDDEN_CALLS2] }),
|
|
21427
21469
|
// Not a boundary (see WHAT RUNS HERE), but nothing to hand over either:
|
|
21428
21470
|
// no token or secret this process was started with, no project folder.
|
|
21429
21471
|
env: runEnv(),
|
|
@@ -21493,8 +21535,8 @@ function printedLines(path3, printed) {
|
|
|
21493
21535
|
function bounded(traceback) {
|
|
21494
21536
|
const lines = traceback.replace(/\s+$/, "").split("\n").filter((line2) => !line2.startsWith(' File "<string>"'));
|
|
21495
21537
|
const kept = lines.length > TRACEBACK_LINES ? [" \u2026", ...lines.slice(-TRACEBACK_LINES)] : lines;
|
|
21496
|
-
const
|
|
21497
|
-
return
|
|
21538
|
+
const text4 = kept.join("\n");
|
|
21539
|
+
return text4.length > TRACEBACK_CHARS ? `\u2026${text4.slice(-TRACEBACK_CHARS)}` : text4;
|
|
21498
21540
|
}
|
|
21499
21541
|
function transformTextsFor(document, spec, shared = {}) {
|
|
21500
21542
|
const carried = { ...shared, ...isObj2(document) && isObj2(document["transforms"]) ? document["transforms"] : {} };
|
|
@@ -21502,8 +21544,8 @@ function transformTextsFor(document, spec, shared = {}) {
|
|
|
21502
21544
|
for (const row of Object.values(spec)) {
|
|
21503
21545
|
const path3 = isObj2(row) ? row["transform"] : void 0;
|
|
21504
21546
|
if (typeof path3 !== "string" || !TRANSFORM_PATH4.test(path3) || Object.hasOwn(out, path3)) continue;
|
|
21505
|
-
const
|
|
21506
|
-
if (typeof
|
|
21547
|
+
const text4 = Object.hasOwn(carried, path3) ? carried[path3] : void 0;
|
|
21548
|
+
if (typeof text4 === "string") out[path3] = text4;
|
|
21507
21549
|
}
|
|
21508
21550
|
return out;
|
|
21509
21551
|
}
|
|
@@ -21524,15 +21566,15 @@ function planTransforms(spec, answers, texts) {
|
|
|
21524
21566
|
};
|
|
21525
21567
|
continue;
|
|
21526
21568
|
}
|
|
21527
|
-
const
|
|
21528
|
-
if (
|
|
21569
|
+
const text4 = texts[path3];
|
|
21570
|
+
if (text4 === void 0) {
|
|
21529
21571
|
plan.failed[id] = {
|
|
21530
21572
|
sentence: `${path3} was not run: preview runs only a transform the draft carries under "transforms", never a file from the folder, which may hold someone else's`,
|
|
21531
21573
|
detail: [`to preview it, carry ${path3}'s text in a SPEC draft's "transforms"; or ship, and read the card after the push`]
|
|
21532
21574
|
};
|
|
21533
21575
|
continue;
|
|
21534
21576
|
}
|
|
21535
|
-
const lint = lintTransform2(
|
|
21577
|
+
const lint = lintTransform2(text4);
|
|
21536
21578
|
if (lint.length > 0) {
|
|
21537
21579
|
plan.failed[id] = {
|
|
21538
21580
|
sentence: `${path3} was not run: compile would refuse it (transform_forbidden)`,
|
|
@@ -21542,7 +21584,7 @@ function planTransforms(spec, answers, texts) {
|
|
|
21542
21584
|
}
|
|
21543
21585
|
const params = isObj2(meta["params_applied"]) ? meta["params_applied"] : defaultsOf(row["params"]);
|
|
21544
21586
|
const input = Array.isArray(answer["rows"]) ? answer["rows"] : [];
|
|
21545
|
-
const run = runTransformLocally(
|
|
21587
|
+
const run = runTransformLocally(text4, path3, input, params);
|
|
21546
21588
|
if (!run.ok) {
|
|
21547
21589
|
plan.failed[id] = {
|
|
21548
21590
|
sentence: run.failure ?? `${path3} failed`,
|
|
@@ -21585,12 +21627,12 @@ function registerPreviewCommand(parent) {
|
|
|
21585
21627
|
).option("--payload <json>", 'The request to serve (default: {"op": "load"}).')
|
|
21586
21628
|
)
|
|
21587
21629
|
).action(async (file, opts) => {
|
|
21588
|
-
const
|
|
21630
|
+
const text4 = await readFile6(file, "utf8").catch(() => {
|
|
21589
21631
|
throw new Error(`cannot read ${file}`);
|
|
21590
21632
|
});
|
|
21591
21633
|
let document;
|
|
21592
21634
|
try {
|
|
21593
|
-
document = JSON.parse(
|
|
21635
|
+
document = JSON.parse(text4);
|
|
21594
21636
|
} catch {
|
|
21595
21637
|
throw new Error(`${file} is not valid JSON`);
|
|
21596
21638
|
}
|
|
@@ -21807,10 +21849,10 @@ function metricsTransport(client) {
|
|
|
21807
21849
|
headers,
|
|
21808
21850
|
...body === void 0 ? {} : { body: JSON.stringify(body) }
|
|
21809
21851
|
});
|
|
21810
|
-
const
|
|
21811
|
-
let parsed2 =
|
|
21852
|
+
const text4 = res.body.toString("utf8");
|
|
21853
|
+
let parsed2 = text4 === "" ? null : text4;
|
|
21812
21854
|
try {
|
|
21813
|
-
parsed2 =
|
|
21855
|
+
parsed2 = text4 === "" ? null : JSON.parse(text4);
|
|
21814
21856
|
} catch {
|
|
21815
21857
|
}
|
|
21816
21858
|
return { status: res.status, body: parsed2 };
|
|
@@ -22941,7 +22983,7 @@ function sentUi(body) {
|
|
|
22941
22983
|
const out = {};
|
|
22942
22984
|
const plain = body["frontend_bundle"];
|
|
22943
22985
|
if (typeof plain === "object" && plain !== null) {
|
|
22944
|
-
for (const [path3,
|
|
22986
|
+
for (const [path3, text4] of Object.entries(plain)) out[path3] = text4;
|
|
22945
22987
|
}
|
|
22946
22988
|
const gz = body["frontend_bundle_gz"];
|
|
22947
22989
|
if (typeof gz === "object" && gz !== null) {
|
|
@@ -23105,13 +23147,13 @@ async function pushBody(dir, opts) {
|
|
|
23105
23147
|
return { appId, body, handlers };
|
|
23106
23148
|
}
|
|
23107
23149
|
function chartsWithoutEcharts(files) {
|
|
23108
|
-
const
|
|
23150
|
+
const text4 = new Map(files.map((file) => [file.path, file.bytes.toString("utf8")]));
|
|
23109
23151
|
const out = [];
|
|
23110
|
-
for (const [path3, html] of
|
|
23152
|
+
for (const [path3, html] of text4) {
|
|
23111
23153
|
if (!path3.endsWith(".html") || html.includes('echarts.min.js"></script>')) continue;
|
|
23112
23154
|
const modules = new Set([...html.matchAll(/data-dr-module="([^"]+)"/g)].map((match) => match[1]));
|
|
23113
23155
|
for (const module of [...modules].sort()) {
|
|
23114
|
-
const source =
|
|
23156
|
+
const source = text4.get(module);
|
|
23115
23157
|
if (source !== void 0 && CHARTING_RE.test(source)) {
|
|
23116
23158
|
out.push(`ui/${path3} loads no echarts, but ui/${module} names a chart; run \`app-space compile\` again so the page loads it`);
|
|
23117
23159
|
}
|
|
@@ -23119,8 +23161,41 @@ function chartsWithoutEcharts(files) {
|
|
|
23119
23161
|
}
|
|
23120
23162
|
return out;
|
|
23121
23163
|
}
|
|
23164
|
+
async function staleTransforms(dir, handlers) {
|
|
23165
|
+
const stale = /* @__PURE__ */ new Map();
|
|
23166
|
+
const onDisk = /* @__PURE__ */ new Map();
|
|
23167
|
+
for (const name of Object.keys(handlers).sort()) {
|
|
23168
|
+
const code = handlers[name]?.code ?? "";
|
|
23169
|
+
if (!code.includes("TRANSFORMS")) continue;
|
|
23170
|
+
const carried = [
|
|
23171
|
+
...readSources([{ source: code }]).owned
|
|
23172
|
+
];
|
|
23173
|
+
const table = readTransforms(code);
|
|
23174
|
+
for (const [path3, text4] of Object.entries(table.texts ?? {})) carried.push({ path: path3, text: text4 });
|
|
23175
|
+
for (const { path: path3, text: text4 } of carried) {
|
|
23176
|
+
if (!onDisk.has(path3)) onDisk.set(path3, await readIfPresent(join8(dir, path3)));
|
|
23177
|
+
const current = onDisk.get(path3);
|
|
23178
|
+
if (current === void 0 || current === text4) continue;
|
|
23179
|
+
if (!stale.has(path3)) stale.set(path3, /* @__PURE__ */ new Set());
|
|
23180
|
+
stale.get(path3)?.add(`handlers/${name}.py`);
|
|
23181
|
+
}
|
|
23182
|
+
}
|
|
23183
|
+
return [...stale.keys()].sort().map((path3) => ({ path: path3, handlers: [...stale.get(path3) ?? []].sort() }));
|
|
23184
|
+
}
|
|
23185
|
+
function staleTransformsMessage(stale) {
|
|
23186
|
+
const lines = stale.map((one) => {
|
|
23187
|
+
const shown2 = one.handlers.slice(0, 3).join(", ");
|
|
23188
|
+
const more = one.handlers.length > 3 ? ` and ${String(one.handlers.length - 3)} more` : "";
|
|
23189
|
+
return ` ${one.path} \u2014 ${shown2}${more} still carry the text of the last compile`;
|
|
23190
|
+
});
|
|
23191
|
+
return `nothing was pushed: ${stale.length === 1 ? "a transform has" : "transforms have"} changed since the handlers were compiled, and push sends the handlers (which carry each transform as text), not transforms/ \u2014 so it would upload the old code:
|
|
23192
|
+
${lines.join("\n")}
|
|
23193
|
+
Run \`app-space compile --push\` (or \`app-space compile\`, then push) so the handlers carry what transforms/ holds.`;
|
|
23194
|
+
}
|
|
23122
23195
|
async function pushFolder(dir, opts) {
|
|
23123
23196
|
const { appId, body, handlers } = await pushBody(dir, opts);
|
|
23197
|
+
const stale = await staleTransforms(dir, handlers);
|
|
23198
|
+
if (stale.length > 0) throw new Error(staleTransformsMessage(stale));
|
|
23124
23199
|
const client = await connect(opts);
|
|
23125
23200
|
try {
|
|
23126
23201
|
if (opts.metricBindings === void 0 && Object.keys(declaredMetrics(body["contract"])).length > 0) {
|
|
@@ -23262,8 +23337,8 @@ async function recordedRenderer(dir) {
|
|
|
23262
23337
|
return null;
|
|
23263
23338
|
}
|
|
23264
23339
|
}
|
|
23265
|
-
function digestOf(
|
|
23266
|
-
return createHash3("sha256").update(
|
|
23340
|
+
function digestOf(text4) {
|
|
23341
|
+
return createHash3("sha256").update(text4, "utf8").digest("hex");
|
|
23267
23342
|
}
|
|
23268
23343
|
async function recordedDigests(dir) {
|
|
23269
23344
|
try {
|
|
@@ -23424,17 +23499,17 @@ async function writeOwnedFiles(dir, document, { force = false } = {}) {
|
|
|
23424
23499
|
if (typeof raw !== "object" || raw === null || Array.isArray(raw)) continue;
|
|
23425
23500
|
const entry = raw;
|
|
23426
23501
|
const path3 = entry["path"];
|
|
23427
|
-
const
|
|
23428
|
-
if (typeof path3 !== "string" || typeof
|
|
23502
|
+
const text4 = entry["text"];
|
|
23503
|
+
if (typeof path3 !== "string" || typeof text4 !== "string" || !OWNED_TEXT_PATH.test(path3)) continue;
|
|
23429
23504
|
const full = join10(dir, path3);
|
|
23430
23505
|
const existing = await readIfPresent(full);
|
|
23431
|
-
if (existing ===
|
|
23506
|
+
if (existing === text4) continue;
|
|
23432
23507
|
if (existing !== void 0 && !force) {
|
|
23433
23508
|
kept.push(path3);
|
|
23434
23509
|
continue;
|
|
23435
23510
|
}
|
|
23436
23511
|
await mkdir4(dirname3(full), { recursive: true });
|
|
23437
|
-
await writeFile5(full,
|
|
23512
|
+
await writeFile5(full, text4);
|
|
23438
23513
|
wrote.push(path3);
|
|
23439
23514
|
}
|
|
23440
23515
|
return { wrote: wrote.sort(), kept: kept.sort() };
|
|
@@ -23692,8 +23767,8 @@ function unchecked2(status, detail) {
|
|
|
23692
23767
|
skipped: []
|
|
23693
23768
|
};
|
|
23694
23769
|
}
|
|
23695
|
-
function firstLineOf(
|
|
23696
|
-
const line2 =
|
|
23770
|
+
function firstLineOf(text4) {
|
|
23771
|
+
const line2 = text4.split("\n")[0] ?? "";
|
|
23697
23772
|
return line2.length > 300 ? `${line2.slice(0, 299)}\u2026` : line2;
|
|
23698
23773
|
}
|
|
23699
23774
|
function fromRefusal(status, detail, contract) {
|
|
@@ -23772,13 +23847,13 @@ async function stage(dir, scratch, files) {
|
|
|
23772
23847
|
filter: (source) => !/[\\/](node_modules|\.git)$/.test(source)
|
|
23773
23848
|
});
|
|
23774
23849
|
const root = resolve5(scratch);
|
|
23775
|
-
for (const [path3,
|
|
23850
|
+
for (const [path3, text4] of Object.entries(files)) {
|
|
23776
23851
|
const full = resolve5(root, path3);
|
|
23777
23852
|
if (!full.startsWith(root + sep2)) {
|
|
23778
23853
|
return `the package names a path outside its folder (${JSON.stringify(path3)})`;
|
|
23779
23854
|
}
|
|
23780
23855
|
await mkdir5(dirname4(full), { recursive: true });
|
|
23781
|
-
await writeFile6(full,
|
|
23856
|
+
await writeFile6(full, text4);
|
|
23782
23857
|
}
|
|
23783
23858
|
return null;
|
|
23784
23859
|
}
|
|
@@ -23797,19 +23872,19 @@ function skip(why) {
|
|
|
23797
23872
|
return { problems: [], skipped: [{ what: WHAT, why }] };
|
|
23798
23873
|
}
|
|
23799
23874
|
function parse(bytes) {
|
|
23800
|
-
const
|
|
23801
|
-
if (
|
|
23875
|
+
const text4 = bytes.toString("utf8");
|
|
23876
|
+
if (text4 === "") return void 0;
|
|
23802
23877
|
try {
|
|
23803
|
-
return JSON.parse(
|
|
23878
|
+
return JSON.parse(text4);
|
|
23804
23879
|
} catch {
|
|
23805
|
-
return
|
|
23880
|
+
return text4;
|
|
23806
23881
|
}
|
|
23807
23882
|
}
|
|
23808
23883
|
function detailOf(body) {
|
|
23809
23884
|
return isObj4(body) ? body["detail"] : void 0;
|
|
23810
23885
|
}
|
|
23811
|
-
function sentence(
|
|
23812
|
-
return
|
|
23886
|
+
function sentence(text4) {
|
|
23887
|
+
return text4.endsWith(".") ? text4 : `${text4}.`;
|
|
23813
23888
|
}
|
|
23814
23889
|
function firstLine2(err) {
|
|
23815
23890
|
return (err instanceof Error ? err.message : String(err)).split("\n")[0] ?? "";
|
|
@@ -24167,7 +24242,7 @@ function libraryOrderProblems(page, files = []) {
|
|
|
24167
24242
|
const indexOf = (module) => elements.findIndex((el) => el.tag === "script" && el.attrs.src !== void 0 && RUNTIME_LIBRARIES.find((one) => one.module === module).pattern.test(resolveFromPlatformRoot(page.path, el.attrs.src) ?? ""));
|
|
24168
24243
|
const inline = elements.filter((el) => el.tag === "script" && !("src" in el.attrs));
|
|
24169
24244
|
const textOf3 = (el) => "src" in el.attrs ? files.find((file) => file.path === resolveInBundle(page.path, el.attrs.src))?.text : scripts[inline.indexOf(el)]?.text;
|
|
24170
|
-
const calls = (
|
|
24245
|
+
const calls = (text4) => typeof text4 === "string" && MOUNT_CALL.test(withoutRegexLiterals(executableText(text4)));
|
|
24171
24246
|
const runs = (el) => runsInPlace(el) || (el.attrs.type ?? "").trim().toLowerCase() === "module";
|
|
24172
24247
|
const mounts = elements.filter((el) => el.tag === "script" && runs(el) && calls(textOf3(el)));
|
|
24173
24248
|
const mountScript = mounts.find((el) => !runsAfterParsing(el));
|
|
@@ -24811,19 +24886,19 @@ function collectScripts(app, page, runtime = null) {
|
|
|
24811
24886
|
}
|
|
24812
24887
|
return scripts;
|
|
24813
24888
|
}
|
|
24814
|
-
function handlerDerivedNames(
|
|
24889
|
+
function handlerDerivedNames(text4) {
|
|
24815
24890
|
const names = /* @__PURE__ */ new Set();
|
|
24816
24891
|
const assigned = /(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*await\s+(?:call\(|[\w.$]*fetch\(|[\w.$]+\.json\()/g;
|
|
24817
24892
|
const thenParam = /\.then\(\s*(?:async\s*)?\(?\s*([A-Za-z_$][\w$]*)/g;
|
|
24818
24893
|
for (const re of [assigned, thenParam]) {
|
|
24819
24894
|
let match;
|
|
24820
|
-
while ((match = re.exec(
|
|
24895
|
+
while ((match = re.exec(text4)) !== null) names.add(match[1]);
|
|
24821
24896
|
}
|
|
24822
24897
|
return names;
|
|
24823
24898
|
}
|
|
24824
|
-
function lineOffset(
|
|
24899
|
+
function lineOffset(text4, index) {
|
|
24825
24900
|
let lines = 0;
|
|
24826
|
-
for (let i = 0; i < index; i++) if (
|
|
24901
|
+
for (let i = 0; i < index; i++) if (text4.charCodeAt(i) === 10) lines++;
|
|
24827
24902
|
return lines;
|
|
24828
24903
|
}
|
|
24829
24904
|
function checkControl(el, boxes, where2) {
|
|
@@ -24839,25 +24914,25 @@ function checkControl(el, boxes, where2) {
|
|
|
24839
24914
|
}
|
|
24840
24915
|
return [];
|
|
24841
24916
|
}
|
|
24842
|
-
function controlBoxes(
|
|
24917
|
+
function controlBoxes(text4) {
|
|
24843
24918
|
const boxes = [];
|
|
24844
24919
|
const open2 = new RegExp(`<([a-zA-Z][\\w-]*)([^>]*\\b${KIT_MARK}\\s*=\\s*["'](?:${[...CONTROL_BOXES].join("|")})["'][^>]*)>`, "g");
|
|
24845
24920
|
let match;
|
|
24846
|
-
while ((match = open2.exec(
|
|
24847
|
-
boxes.push([lineAt(
|
|
24921
|
+
while ((match = open2.exec(text4)) !== null) {
|
|
24922
|
+
boxes.push([lineAt(text4, match.index), lineAt(text4, closingTag(text4, match[1].toLowerCase(), open2.lastIndex))]);
|
|
24848
24923
|
}
|
|
24849
24924
|
return boxes;
|
|
24850
24925
|
}
|
|
24851
|
-
function closingTag(
|
|
24926
|
+
function closingTag(text4, tag, from) {
|
|
24852
24927
|
const re = new RegExp(`<(/?)${tag}\\b`, "gi");
|
|
24853
24928
|
re.lastIndex = from;
|
|
24854
24929
|
let depth = 1;
|
|
24855
24930
|
let match;
|
|
24856
|
-
while ((match = re.exec(
|
|
24931
|
+
while ((match = re.exec(text4)) !== null) {
|
|
24857
24932
|
depth += match[1] ? -1 : 1;
|
|
24858
24933
|
if (depth === 0) return match.index;
|
|
24859
24934
|
}
|
|
24860
|
-
return
|
|
24935
|
+
return text4.length;
|
|
24861
24936
|
}
|
|
24862
24937
|
function checkControls(page, controls, scriptText, handlerText) {
|
|
24863
24938
|
const violations = [];
|
|
@@ -24934,8 +25009,8 @@ function checkHandlers(app, frontendText, cardHandlers = /* @__PURE__ */ new Set
|
|
|
24934
25009
|
for (const literal of findDataLiterals(carried.texts === null ? handler.source : blanked(handler.source, carried.span))) {
|
|
24935
25010
|
violations.push({ rule: "R1.3", where: `${where2}:${literal.line}`, message: `numeric data literal (${literal.numbers} numbers): ${literal.sample}` });
|
|
24936
25011
|
}
|
|
24937
|
-
for (const [path3,
|
|
24938
|
-
for (const literal of findTransformLiterals(
|
|
25012
|
+
for (const [path3, text4] of Object.entries(carried.texts ?? {})) {
|
|
25013
|
+
for (const literal of findTransformLiterals(text4)) {
|
|
24939
25014
|
violations.push({
|
|
24940
25015
|
rule: "R1.3",
|
|
24941
25016
|
where: `${path3}:${literal.line}`,
|
|
@@ -25326,17 +25401,17 @@ function resolve6(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
|
25326
25401
|
}
|
|
25327
25402
|
function rootTokens(css) {
|
|
25328
25403
|
const out = /* @__PURE__ */ new Map();
|
|
25329
|
-
const
|
|
25330
|
-
for (const block of
|
|
25404
|
+
const text4 = css.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
25405
|
+
for (const block of text4.matchAll(/:root\s*\{([^}]*)\}/g)) {
|
|
25331
25406
|
const offset = block.index + block[0].indexOf("{");
|
|
25332
25407
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
25333
|
-
out.set(hit[1], { value: hit[2].trim(), line: lineOf(
|
|
25408
|
+
out.set(hit[1], { value: hit[2].trim(), line: lineOf(text4, offset + hit.index) });
|
|
25334
25409
|
}
|
|
25335
25410
|
}
|
|
25336
25411
|
return out;
|
|
25337
25412
|
}
|
|
25338
|
-
function lineOf(
|
|
25339
|
-
return
|
|
25413
|
+
function lineOf(text4, index) {
|
|
25414
|
+
return text4.slice(0, index).split("\n").length;
|
|
25340
25415
|
}
|
|
25341
25416
|
function dedupe2(violations) {
|
|
25342
25417
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -25348,17 +25423,17 @@ function dedupe2(violations) {
|
|
|
25348
25423
|
});
|
|
25349
25424
|
}
|
|
25350
25425
|
function rgbOf2(value, over) {
|
|
25351
|
-
const
|
|
25426
|
+
const text4 = String(value || "").trim();
|
|
25352
25427
|
let parts = null;
|
|
25353
25428
|
let alpha = 1;
|
|
25354
|
-
if (
|
|
25355
|
-
let hex =
|
|
25429
|
+
if (text4.startsWith("#")) {
|
|
25430
|
+
let hex = text4.slice(1);
|
|
25356
25431
|
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
25357
25432
|
if (/^[0-9a-f]{6,8}$/i.test(hex)) {
|
|
25358
25433
|
parts = [parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16)];
|
|
25359
25434
|
}
|
|
25360
25435
|
} else {
|
|
25361
|
-
const hit = /rgba?\(([^)]+)\)/.exec(
|
|
25436
|
+
const hit = /rgba?\(([^)]+)\)/.exec(text4);
|
|
25362
25437
|
if (hit) {
|
|
25363
25438
|
const bits = hit[1].split(/[,/]/).map((bit) => parseFloat(bit));
|
|
25364
25439
|
parts = [bits[0], bits[1], bits[2]];
|
|
@@ -25417,7 +25492,7 @@ function verify({ app: appRef, catalog, agent, describe: describe7, load }, { ex
|
|
|
25417
25492
|
const liveness2 = checkLiveness(contract, load, {
|
|
25418
25493
|
handlerWhere: app.handlers[0]?.file || app.handlersSource
|
|
25419
25494
|
});
|
|
25420
|
-
const
|
|
25495
|
+
const figures2 = checkFigures(contract, {
|
|
25421
25496
|
handlerWhere: app.handlers[0]?.file || app.handlersSource
|
|
25422
25497
|
});
|
|
25423
25498
|
const violations = [
|
|
@@ -25439,7 +25514,7 @@ function verify({ app: appRef, catalog, agent, describe: describe7, load }, { ex
|
|
|
25439
25514
|
return {
|
|
25440
25515
|
ok: violations.length === 0,
|
|
25441
25516
|
violations,
|
|
25442
|
-
warnings:
|
|
25517
|
+
warnings: figures2.warnings.sort(byRuleThenWhere),
|
|
25443
25518
|
skipped,
|
|
25444
25519
|
app: { id: appRef.id ?? app.manifest.id, version: appRef.version ?? null },
|
|
25445
25520
|
kit: KIT.name,
|
|
@@ -25602,9 +25677,9 @@ function walkFrom2(base, clean) {
|
|
|
25602
25677
|
}
|
|
25603
25678
|
return resolved;
|
|
25604
25679
|
}
|
|
25605
|
-
function lineAt2(
|
|
25680
|
+
function lineAt2(text4, index) {
|
|
25606
25681
|
let line2 = 1;
|
|
25607
|
-
for (let i = 0; i < index && i <
|
|
25682
|
+
for (let i = 0; i < index && i < text4.length; i++) if (text4.charCodeAt(i) === 10) line2++;
|
|
25608
25683
|
return line2;
|
|
25609
25684
|
}
|
|
25610
25685
|
|
|
@@ -25836,11 +25911,11 @@ function parseDeclares2(raw) {
|
|
|
25836
25911
|
}
|
|
25837
25912
|
var PAIR2 = /(["'])data-dr-([a-z][a-z-]*)\1\s*:\s*(["'])([^"'\\]*)\3/g;
|
|
25838
25913
|
var REGEX_AFTER2 = /* @__PURE__ */ new Set(["", "(", ",", "=", ":", "[", "!", "&", "|", "?", ";", "+", "-", "*", "%", "~", "^", "<", ">"]);
|
|
25839
|
-
function scanBundle2(
|
|
25914
|
+
function scanBundle2(text4, { file, page }) {
|
|
25840
25915
|
const pairs = /* @__PURE__ */ new Map();
|
|
25841
|
-
for (const match of
|
|
25916
|
+
for (const match of text4.matchAll(PAIR2)) pairs.set(match.index, { attr: match[2], value: match[4] });
|
|
25842
25917
|
if (pairs.size === 0) return [];
|
|
25843
|
-
const objects = groupByObject2(
|
|
25918
|
+
const objects = groupByObject2(text4, pairs);
|
|
25844
25919
|
const elements = [];
|
|
25845
25920
|
for (const found of objects) {
|
|
25846
25921
|
const attrs = {};
|
|
@@ -25881,21 +25956,21 @@ function scanBundle2(text3, { file, page }) {
|
|
|
25881
25956
|
}
|
|
25882
25957
|
return elements;
|
|
25883
25958
|
}
|
|
25884
|
-
function groupByObject2(
|
|
25959
|
+
function groupByObject2(text4, pairs) {
|
|
25885
25960
|
const byObject = /* @__PURE__ */ new Map();
|
|
25886
25961
|
const stack = [];
|
|
25887
25962
|
let previous = "";
|
|
25888
25963
|
let i = 0;
|
|
25889
|
-
while (i <
|
|
25890
|
-
const ch =
|
|
25891
|
-
if (ch === "/" &&
|
|
25892
|
-
const end =
|
|
25893
|
-
i = end === -1 ?
|
|
25964
|
+
while (i < text4.length) {
|
|
25965
|
+
const ch = text4[i];
|
|
25966
|
+
if (ch === "/" && text4[i + 1] === "/") {
|
|
25967
|
+
const end = text4.indexOf("\n", i);
|
|
25968
|
+
i = end === -1 ? text4.length : end + 1;
|
|
25894
25969
|
continue;
|
|
25895
25970
|
}
|
|
25896
|
-
if (ch === "/" &&
|
|
25897
|
-
const end =
|
|
25898
|
-
i = end === -1 ?
|
|
25971
|
+
if (ch === "/" && text4[i + 1] === "*") {
|
|
25972
|
+
const end = text4.indexOf("*/", i + 2);
|
|
25973
|
+
i = end === -1 ? text4.length : end + 2;
|
|
25899
25974
|
continue;
|
|
25900
25975
|
}
|
|
25901
25976
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
@@ -25905,12 +25980,12 @@ function groupByObject2(text3, pairs) {
|
|
|
25905
25980
|
if (!byObject.has(open2)) byObject.set(open2, []);
|
|
25906
25981
|
byObject.get(open2).push(pair);
|
|
25907
25982
|
}
|
|
25908
|
-
i = endOfString2(
|
|
25983
|
+
i = endOfString2(text4, i);
|
|
25909
25984
|
previous = '"';
|
|
25910
25985
|
continue;
|
|
25911
25986
|
}
|
|
25912
25987
|
if (ch === "/" && REGEX_AFTER2.has(previous)) {
|
|
25913
|
-
i = endOfRegex2(
|
|
25988
|
+
i = endOfRegex2(text4, i);
|
|
25914
25989
|
previous = "/";
|
|
25915
25990
|
continue;
|
|
25916
25991
|
}
|
|
@@ -25921,25 +25996,25 @@ function groupByObject2(text3, pairs) {
|
|
|
25921
25996
|
}
|
|
25922
25997
|
return [...byObject.entries()].sort((a, b) => a[0] - b[0]).map(([, found]) => found);
|
|
25923
25998
|
}
|
|
25924
|
-
function endOfString2(
|
|
25925
|
-
const quote =
|
|
25926
|
-
for (let i = start + 1; i <
|
|
25927
|
-
if (
|
|
25928
|
-
else if (
|
|
25999
|
+
function endOfString2(text4, start) {
|
|
26000
|
+
const quote = text4[start];
|
|
26001
|
+
for (let i = start + 1; i < text4.length; i += 1) {
|
|
26002
|
+
if (text4[i] === "\\") i += 1;
|
|
26003
|
+
else if (text4[i] === quote) return i + 1;
|
|
25929
26004
|
}
|
|
25930
|
-
return
|
|
26005
|
+
return text4.length;
|
|
25931
26006
|
}
|
|
25932
|
-
function endOfRegex2(
|
|
26007
|
+
function endOfRegex2(text4, start) {
|
|
25933
26008
|
let inClass = false;
|
|
25934
|
-
for (let i = start + 1; i <
|
|
25935
|
-
const ch =
|
|
26009
|
+
for (let i = start + 1; i < text4.length; i += 1) {
|
|
26010
|
+
const ch = text4[i];
|
|
25936
26011
|
if (ch === "\\") i += 1;
|
|
25937
26012
|
else if (ch === "\n") return i;
|
|
25938
26013
|
else if (ch === "[") inClass = true;
|
|
25939
26014
|
else if (ch === "]") inClass = false;
|
|
25940
26015
|
else if (ch === "/" && !inClass) return i + 1;
|
|
25941
26016
|
}
|
|
25942
|
-
return
|
|
26017
|
+
return text4.length;
|
|
25943
26018
|
}
|
|
25944
26019
|
|
|
25945
26020
|
// ../flows/appspace-builder/kit/contract/pySpec.mjs
|
|
@@ -26031,8 +26106,8 @@ function tokenize3(src, d) {
|
|
|
26031
26106
|
}
|
|
26032
26107
|
const number = /^(?:0[xXbBoO][0-9a-fA-F_]+|(?:\d[\d_]*\.?[\d_]*|\.\d[\d_]*)(?:[eE][+-]?\d+)?)/.exec(src.slice(i, i + 40));
|
|
26033
26108
|
if (number && /\d/.test(number[0])) {
|
|
26034
|
-
const
|
|
26035
|
-
push("number", Number(
|
|
26109
|
+
const text4 = number[0].replace(/_/g, "");
|
|
26110
|
+
push("number", Number(text4), i, i + number[0].length);
|
|
26036
26111
|
i += number[0].length;
|
|
26037
26112
|
continue;
|
|
26038
26113
|
}
|
|
@@ -26125,8 +26200,8 @@ function unescape2(body) {
|
|
|
26125
26200
|
}
|
|
26126
26201
|
return out;
|
|
26127
26202
|
}
|
|
26128
|
-
function cut2(
|
|
26129
|
-
const flat = String(
|
|
26203
|
+
function cut2(text4, max = MAX_TEXT2) {
|
|
26204
|
+
const flat = String(text4).replace(/\s+/g, " ").trim();
|
|
26130
26205
|
return flat.length > max ? flat.slice(0, max) : flat;
|
|
26131
26206
|
}
|
|
26132
26207
|
var Literals2 = class {
|
|
@@ -26263,7 +26338,7 @@ var Literals2 = class {
|
|
|
26263
26338
|
return this.d.bare === "callable" ? { $callable: value } : { $unresolved: cut2(value) };
|
|
26264
26339
|
}
|
|
26265
26340
|
parseString(index) {
|
|
26266
|
-
let
|
|
26341
|
+
let text4 = "";
|
|
26267
26342
|
let i = index;
|
|
26268
26343
|
while (this.tokens[i]?.type === "string" || this.depth > 0 && this.tokens[i]?.type === "newline") {
|
|
26269
26344
|
const token = this.tokens[i];
|
|
@@ -26274,10 +26349,10 @@ var Literals2 = class {
|
|
|
26274
26349
|
}
|
|
26275
26350
|
const piece = token.prefix.includes("f") ? this.interpolate(token) : token.value;
|
|
26276
26351
|
if (piece === null) return null;
|
|
26277
|
-
|
|
26352
|
+
text4 += piece;
|
|
26278
26353
|
i += 1;
|
|
26279
26354
|
}
|
|
26280
|
-
return i === index ? null : { value:
|
|
26355
|
+
return i === index ? null : { value: text4, next: i };
|
|
26281
26356
|
}
|
|
26282
26357
|
/**
|
|
26283
26358
|
* An f-string whose fields are all plain constant names, substituted. A
|
|
@@ -26622,7 +26697,7 @@ function readTransforms2(source) {
|
|
|
26622
26697
|
if (!literals.has(TRANSFORMS_TABLE2)) return { found: false, texts: null, span: null, text: null };
|
|
26623
26698
|
const value = literals.constant(TRANSFORMS_TABLE2);
|
|
26624
26699
|
const span = literals.constantSpan(TRANSFORMS_TABLE2);
|
|
26625
|
-
const readable = isPlainObject12(value) && Object.entries(value).every(([path3,
|
|
26700
|
+
const readable = isPlainObject12(value) && Object.entries(value).every(([path3, text4]) => TRANSFORM_PATH5.test(path3) && typeof text4 === "string");
|
|
26626
26701
|
if (!readable) return { found: true, texts: null, span, text: literals.constantText(TRANSFORMS_TABLE2) };
|
|
26627
26702
|
const texts = {};
|
|
26628
26703
|
for (const path3 of Object.keys(value).sort(natural4)) texts[path3] = value[path3];
|
|
@@ -26818,9 +26893,9 @@ function routesOf3(manifest) {
|
|
|
26818
26893
|
function themeSection2(app) {
|
|
26819
26894
|
const file = app.ui.find((entry) => entry.path === THEME_FILE6);
|
|
26820
26895
|
if (!file) return null;
|
|
26821
|
-
const
|
|
26896
|
+
const text4 = file.text.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
26822
26897
|
const tokens = {};
|
|
26823
|
-
for (const block of
|
|
26898
|
+
for (const block of text4.matchAll(/(?::root|body\.dr-app-page)\s*\{([^}]*)\}/g)) {
|
|
26824
26899
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
26825
26900
|
if (hit[1] !== "--dr-app-theme") tokens[hit[1]] = hit[2].trim();
|
|
26826
26901
|
}
|
|
@@ -27003,10 +27078,10 @@ function mountOf2(page) {
|
|
|
27003
27078
|
};
|
|
27004
27079
|
}
|
|
27005
27080
|
function embeddedContractOf2(page) {
|
|
27006
|
-
const
|
|
27007
|
-
if (
|
|
27081
|
+
const text4 = contractBlockText2(page?.text ?? "");
|
|
27082
|
+
if (text4 === null) return null;
|
|
27008
27083
|
try {
|
|
27009
|
-
const embedded = JSON.parse(
|
|
27084
|
+
const embedded = JSON.parse(text4.replace(/<\\\//g, "</"));
|
|
27010
27085
|
return isPlainObject12(embedded) ? embedded : null;
|
|
27011
27086
|
} catch {
|
|
27012
27087
|
return null;
|
|
@@ -27038,10 +27113,10 @@ function cardSpecOf2(element) {
|
|
|
27038
27113
|
return element?.type === "widget" && typeof card === "string" && card !== "" ? card : null;
|
|
27039
27114
|
}
|
|
27040
27115
|
var RUNTIME_RENDERER4 = "runtime";
|
|
27041
|
-
function navGates2(
|
|
27116
|
+
function navGates2(text4, pagePath) {
|
|
27042
27117
|
const out = /* @__PURE__ */ new Map();
|
|
27043
|
-
if (typeof
|
|
27044
|
-
const tree = decodedTree2(
|
|
27118
|
+
if (typeof text4 !== "string") return out;
|
|
27119
|
+
const tree = decodedTree2(text4);
|
|
27045
27120
|
const base = pagePath.includes("/") ? pagePath.slice(0, pagePath.lastIndexOf("/") + 1) : "";
|
|
27046
27121
|
for (const node of tree.nodes) {
|
|
27047
27122
|
if (node.tag !== "a" || typeof node.attrs.href !== "string" || typeof node.attrs["data-dr-role"] !== "string") continue;
|
|
@@ -27172,7 +27247,7 @@ function numberAttr2(node, name) {
|
|
|
27172
27247
|
if (raw === "") return null;
|
|
27173
27248
|
return Number.isFinite(Number(raw)) ? Number(raw) : raw;
|
|
27174
27249
|
}
|
|
27175
|
-
function propsOf2(node,
|
|
27250
|
+
function propsOf2(node, text4, tree) {
|
|
27176
27251
|
const props = {};
|
|
27177
27252
|
for (const [name, value] of Object.entries(node.attrs)) {
|
|
27178
27253
|
if (!name.startsWith(WIDGET_PREFIX2)) continue;
|
|
@@ -27184,13 +27259,13 @@ function propsOf2(node, text3, tree) {
|
|
|
27184
27259
|
props.param = node.attrs[CONTROL_ATTR2];
|
|
27185
27260
|
props.control_kind = node.attrs[`${CONTROL_ATTR2}-kind`] ?? null;
|
|
27186
27261
|
for (const name of CONTROL_PROPS2) if (name in node.attrs) props[name] = node.attrs[name];
|
|
27187
|
-
const label = labelFor2(node,
|
|
27262
|
+
const label = labelFor2(node, text4, tree);
|
|
27188
27263
|
if (label !== null) props.label = label;
|
|
27189
27264
|
}
|
|
27190
27265
|
if (node.tag === "a" && "href" in node.attrs) {
|
|
27191
27266
|
props.href = node.attrs.href;
|
|
27192
27267
|
props.current = node.attrs["aria-current"] === "page";
|
|
27193
|
-
const label = textOf2(
|
|
27268
|
+
const label = textOf2(text4, node);
|
|
27194
27269
|
if (label) props.label = label;
|
|
27195
27270
|
}
|
|
27196
27271
|
if (COMPONENT_ATTR3 in node.attrs || FIELD_ATTR2 in node.attrs) {
|
|
@@ -27204,9 +27279,9 @@ function propsOf2(node, text3, tree) {
|
|
|
27204
27279
|
const inputType = inputTypeOf2(node);
|
|
27205
27280
|
if (inputType !== null) props.input_type = inputType;
|
|
27206
27281
|
if ("required" in node.attrs) props.required = true;
|
|
27207
|
-
if (node.tag === "select") props.options = optionsOf2(node,
|
|
27282
|
+
if (node.tag === "select") props.options = optionsOf2(node, text4, tree);
|
|
27208
27283
|
if (props.label === void 0) {
|
|
27209
|
-
const label = labelFor2(node,
|
|
27284
|
+
const label = labelFor2(node, text4, tree);
|
|
27210
27285
|
if (label !== null) props.label = label;
|
|
27211
27286
|
}
|
|
27212
27287
|
}
|
|
@@ -27220,13 +27295,13 @@ function inputTypeOf2(node) {
|
|
|
27220
27295
|
if (node.tag === "input") return node.attrs.type ?? "text";
|
|
27221
27296
|
return null;
|
|
27222
27297
|
}
|
|
27223
|
-
function optionsOf2(node,
|
|
27298
|
+
function optionsOf2(node, text4, tree) {
|
|
27224
27299
|
const options = [];
|
|
27225
27300
|
const walk5 = (index) => {
|
|
27226
27301
|
for (const child of tree.nodes[index].children) {
|
|
27227
27302
|
const candidate = tree.nodes[child];
|
|
27228
27303
|
if (candidate.tag === "option") {
|
|
27229
|
-
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf2(
|
|
27304
|
+
if (!("disabled" in candidate.attrs)) options.push(candidate.attrs.value ?? textOf2(text4, candidate));
|
|
27230
27305
|
} else walk5(child);
|
|
27231
27306
|
}
|
|
27232
27307
|
};
|
|
@@ -27236,15 +27311,15 @@ function optionsOf2(node, text3, tree) {
|
|
|
27236
27311
|
function splitList2(value) {
|
|
27237
27312
|
return String(value).split(/[\s,]+/).filter(Boolean);
|
|
27238
27313
|
}
|
|
27239
|
-
function labelFor2(node,
|
|
27314
|
+
function labelFor2(node, text4, tree) {
|
|
27240
27315
|
const id = node.attrs.id;
|
|
27241
27316
|
if (!id) return node.attrs["aria-label"] ?? null;
|
|
27242
27317
|
const label = tree.nodes.find((candidate) => candidate.tag === "label" && candidate.attrs.for === id);
|
|
27243
|
-
return label ? textOf2(
|
|
27318
|
+
return label ? textOf2(text4, label) : node.attrs["aria-label"] ?? null;
|
|
27244
27319
|
}
|
|
27245
|
-
function textOf2(
|
|
27246
|
-
const next =
|
|
27247
|
-
return decodeEntities3(
|
|
27320
|
+
function textOf2(text4, node) {
|
|
27321
|
+
const next = text4.indexOf("<", node.end);
|
|
27322
|
+
return decodeEntities3(text4.slice(node.end, next === -1 ? void 0 : next).replace(/\s+/g, " ").trim());
|
|
27248
27323
|
}
|
|
27249
27324
|
function slotsOf2(node, tree) {
|
|
27250
27325
|
if (!(WIDGET_ATTR2 in node.attrs)) return {};
|
|
@@ -27269,23 +27344,23 @@ function bindingOf2(entry, node, spec) {
|
|
|
27269
27344
|
if (entry.type === "control") return node.attrs[CONTROL_ATTR2] || null;
|
|
27270
27345
|
return null;
|
|
27271
27346
|
}
|
|
27272
|
-
function titleOf2(tree,
|
|
27347
|
+
function titleOf2(tree, text4) {
|
|
27273
27348
|
const title = tree.nodes.find((node) => node.tag === "title");
|
|
27274
|
-
return title ? textOf2(
|
|
27349
|
+
return title ? textOf2(text4, title) : null;
|
|
27275
27350
|
}
|
|
27276
|
-
function headerOf2(tree,
|
|
27351
|
+
function headerOf2(tree, text4) {
|
|
27277
27352
|
const withClass = (name) => tree.nodes.find((node) => classesOf3(node).includes(name));
|
|
27278
27353
|
const title = withClass("dr-appbar__title");
|
|
27279
27354
|
if (title) {
|
|
27280
27355
|
const summary2 = withClass("dr-appbar__summary");
|
|
27281
|
-
return { title: textOf2(
|
|
27356
|
+
return { title: textOf2(text4, title), summary: summary2 ? textOf2(text4, summary2) || null : null };
|
|
27282
27357
|
}
|
|
27283
27358
|
const region = tree.nodes.find((node) => node.attrs[KIT_ATTR2] === "header");
|
|
27284
27359
|
if (!region) return null;
|
|
27285
27360
|
const heading = firstTag2(tree, region, "h1", true);
|
|
27286
27361
|
if (!heading) return null;
|
|
27287
27362
|
const summary = firstTag2(tree, region, "p", true);
|
|
27288
|
-
const out = { title: textOf2(
|
|
27363
|
+
const out = { title: textOf2(text4, heading), summary: summary ? textOf2(text4, summary) || null : null };
|
|
27289
27364
|
const actions = parseJsonAttr2(region.attrs[HEADER_ACTIONS_ATTR2]);
|
|
27290
27365
|
if (Array.isArray(actions)) out.actions = actions;
|
|
27291
27366
|
const from = region.attrs[TITLE_FROM_ATTR2];
|
|
@@ -27319,16 +27394,16 @@ function navOf2(tree, main2) {
|
|
|
27319
27394
|
const source = nav?.attrs[NAV_COUNTS_ATTR2] ?? main2?.attrs[NAV_COUNTS_ATTR2];
|
|
27320
27395
|
return source === void 0 || source === "" ? {} : { nav: { counts: { source } } };
|
|
27321
27396
|
}
|
|
27322
|
-
function sectionOf2(node,
|
|
27323
|
-
const title = textOf2(
|
|
27397
|
+
function sectionOf2(node, text4, index) {
|
|
27398
|
+
const title = textOf2(text4, node);
|
|
27324
27399
|
return { id: node.attrs.id ?? slug3(title) ?? `section_${index + 1}`, title };
|
|
27325
27400
|
}
|
|
27326
|
-
function wrappedSectionOf2(tree, node,
|
|
27401
|
+
function wrappedSectionOf2(tree, node, text4, index) {
|
|
27327
27402
|
const heading = firstTag2(tree, node, "h2");
|
|
27328
27403
|
const id = node.attrs[SECTION_ATTR2];
|
|
27329
|
-
const out = { id: id === void 0 || id === "" ? `section_${index + 1}` : id, title: heading ? textOf2(
|
|
27404
|
+
const out = { id: id === void 0 || id === "" ? `section_${index + 1}` : id, title: heading ? textOf2(text4, heading) : "" };
|
|
27330
27405
|
const subtitle = node.children.map((child) => tree.nodes[child]).find((child) => child.tag === "p");
|
|
27331
|
-
if (subtitle) out.subtitle = textOf2(
|
|
27406
|
+
if (subtitle) out.subtitle = textOf2(text4, subtitle);
|
|
27332
27407
|
for (const key of BAND_LOOK4) {
|
|
27333
27408
|
const value = node.attrs[`data-dr-${key}`];
|
|
27334
27409
|
if (value !== void 0 && value !== "") out[key] = value;
|
|
@@ -27336,8 +27411,8 @@ function wrappedSectionOf2(tree, node, text3, index) {
|
|
|
27336
27411
|
return out;
|
|
27337
27412
|
}
|
|
27338
27413
|
var BAND_LOOK4 = ["layout", "surface", "aside"];
|
|
27339
|
-
function slug3(
|
|
27340
|
-
const clean = String(
|
|
27414
|
+
function slug3(text4) {
|
|
27415
|
+
const clean = String(text4 ?? "").toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
27341
27416
|
return clean === "" ? null : clean;
|
|
27342
27417
|
}
|
|
27343
27418
|
function routeOf4(manifest, path3) {
|
|
@@ -27679,9 +27754,9 @@ function readSources2(handlers) {
|
|
|
27679
27754
|
}
|
|
27680
27755
|
const carried = literals.constant("TRANSFORMS");
|
|
27681
27756
|
if (!isPlainObject12(carried)) continue;
|
|
27682
|
-
for (const [name,
|
|
27757
|
+
for (const [name, text4] of Object.entries(carried)) {
|
|
27683
27758
|
const path3 = table[name]?.transform;
|
|
27684
|
-
if (typeof path3 === "string" && typeof
|
|
27759
|
+
if (typeof path3 === "string" && typeof text4 === "string" && !texts.has(path3)) texts.set(path3, text4);
|
|
27685
27760
|
}
|
|
27686
27761
|
}
|
|
27687
27762
|
const owned = [...texts.keys()].sort(natural5).map((path3) => ({ path: path3, text: texts.get(path3) }));
|
|
@@ -27706,9 +27781,9 @@ function specTransforms2(handlers, spec, problems) {
|
|
|
27706
27781
|
continue;
|
|
27707
27782
|
}
|
|
27708
27783
|
carried ??= /* @__PURE__ */ new Set();
|
|
27709
|
-
for (const [path3,
|
|
27784
|
+
for (const [path3, text4] of Object.entries(table.texts)) {
|
|
27710
27785
|
carried.add(path3);
|
|
27711
|
-
out.push({ path: path3, text:
|
|
27786
|
+
out.push({ path: path3, text: text4 });
|
|
27712
27787
|
}
|
|
27713
27788
|
}
|
|
27714
27789
|
const unreadable = problems.some((problem6) => problem6.code === "transform_unreadable");
|
|
@@ -27847,8 +27922,8 @@ function backendSection2(app, manifest, pages, elements) {
|
|
|
27847
27922
|
};
|
|
27848
27923
|
}
|
|
27849
27924
|
function handlerVerbs2(source) {
|
|
27850
|
-
const
|
|
27851
|
-
return DATA_VERBS2.filter((verb) => TABLE_ONLY_VERBS2.has(verb) ? callsOnTable2(
|
|
27925
|
+
const text4 = typeof source === "string" ? source : "";
|
|
27926
|
+
return DATA_VERBS2.filter((verb) => TABLE_ONLY_VERBS2.has(verb) ? callsOnTable2(text4, verb) : new RegExp(`\\.\\s*${verb}\\s*\\(`).test(text4));
|
|
27852
27927
|
}
|
|
27853
27928
|
function callsOnTable2(source, verb) {
|
|
27854
27929
|
const holders = [TABLE_INLINE2];
|
|
@@ -27871,9 +27946,9 @@ function signatureOk2(source) {
|
|
|
27871
27946
|
}
|
|
27872
27947
|
return count >= 2;
|
|
27873
27948
|
}
|
|
27874
|
-
function isReferenced3(name,
|
|
27949
|
+
function isReferenced3(name, text4) {
|
|
27875
27950
|
const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
27876
|
-
return new RegExp(`\\bcall\\(\\s*(['"\`])${escaped}\\1|/${escaped}(['"\`]|\\b)|(['"\`])${escaped}\\3`).test(
|
|
27951
|
+
return new RegExp(`\\bcall\\(\\s*(['"\`])${escaped}\\1|/${escaped}(['"\`]|\\b)|(['"\`])${escaped}\\3`).test(text4);
|
|
27877
27952
|
}
|
|
27878
27953
|
function rolesOf3(manifest) {
|
|
27879
27954
|
const roles = Array.isArray(manifest.roles) ? manifest.roles : [];
|
|
@@ -28008,9 +28083,9 @@ function natural5(a, b) {
|
|
|
28008
28083
|
var NAMED_ENTITIES2 = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'" };
|
|
28009
28084
|
var ENTITY2 = /&(#[0-9]{1,7}|#[xX][0-9a-fA-F]{1,6}|[a-zA-Z][a-zA-Z0-9]{1,31});/g;
|
|
28010
28085
|
function decodeEntities3(value) {
|
|
28011
|
-
const
|
|
28012
|
-
if (!
|
|
28013
|
-
return
|
|
28086
|
+
const text4 = String(value);
|
|
28087
|
+
if (!text4.includes("&")) return text4;
|
|
28088
|
+
return text4.replace(ENTITY2, (whole, body) => {
|
|
28014
28089
|
if (body[0] !== "#") return Object.prototype.hasOwnProperty.call(NAMED_ENTITIES2, body) ? NAMED_ENTITIES2[body] : whole;
|
|
28015
28090
|
const code = body[1] === "x" || body[1] === "X" ? Number.parseInt(body.slice(2), 16) : Number.parseInt(body.slice(1), 10);
|
|
28016
28091
|
if (!Number.isInteger(code) || code < 1 || code > 1114111 || code >= 55296 && code <= 57343) return whole;
|
|
@@ -28065,23 +28140,23 @@ function problem5(at, why, kind = "other") {
|
|
|
28065
28140
|
function describe4(node, ctx) {
|
|
28066
28141
|
return ctx.inBranch && isObject6(node) && typeof node.description === "string" ? ` \u2014 ${firstSentence3(node.description)}` : "";
|
|
28067
28142
|
}
|
|
28068
|
-
function firstSentence3(
|
|
28143
|
+
function firstSentence3(text4) {
|
|
28069
28144
|
let start = 0;
|
|
28070
28145
|
for (; ; ) {
|
|
28071
|
-
const end =
|
|
28146
|
+
const end = text4.indexOf(". ", start);
|
|
28072
28147
|
if (end === -1) break;
|
|
28073
|
-
const before =
|
|
28148
|
+
const before = text4.slice(0, end);
|
|
28074
28149
|
if (!before.endsWith("e.g") && !before.endsWith("i.e")) {
|
|
28075
|
-
|
|
28150
|
+
text4 = text4.slice(0, end + 1);
|
|
28076
28151
|
break;
|
|
28077
28152
|
}
|
|
28078
28153
|
start = end + 2;
|
|
28079
28154
|
}
|
|
28080
|
-
return truncate5(
|
|
28155
|
+
return truncate5(text4);
|
|
28081
28156
|
}
|
|
28082
|
-
function truncate5(
|
|
28083
|
-
const chars = [...
|
|
28084
|
-
if (chars.length <= MAX_HINT3) return
|
|
28157
|
+
function truncate5(text4) {
|
|
28158
|
+
const chars = [...text4];
|
|
28159
|
+
if (chars.length <= MAX_HINT3) return text4;
|
|
28085
28160
|
let cut3 = chars.slice(0, MAX_HINT3 - 1);
|
|
28086
28161
|
const space = cut3.lastIndexOf(" ");
|
|
28087
28162
|
if (space > Math.floor(MAX_HINT3 / 2)) cut3 = cut3.slice(0, space);
|
|
@@ -28309,7 +28384,7 @@ function pyCode2(source) {
|
|
|
28309
28384
|
}
|
|
28310
28385
|
return out;
|
|
28311
28386
|
}
|
|
28312
|
-
var reEscape2 = (
|
|
28387
|
+
var reEscape2 = (text4) => text4.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28313
28388
|
function pyPayloadReads2(source) {
|
|
28314
28389
|
const code = pyCode2(String(source ?? ""));
|
|
28315
28390
|
const signature = /^[ \t]*(?:async[ \t]+)?def[ \t]+handle[ \t]*\([ \t]*\w+[ \t]*,[ \t]*(\w+)/m.exec(code);
|
|
@@ -28379,24 +28454,24 @@ function jsCode2(source) {
|
|
|
28379
28454
|
}
|
|
28380
28455
|
return out;
|
|
28381
28456
|
}
|
|
28382
|
-
function stringEnd2(
|
|
28383
|
-
const quote =
|
|
28457
|
+
function stringEnd2(text4, i) {
|
|
28458
|
+
const quote = text4[i];
|
|
28384
28459
|
let j = i + 1;
|
|
28385
|
-
while (j <
|
|
28386
|
-
if (
|
|
28387
|
-
else if (quote !== "`" &&
|
|
28460
|
+
while (j < text4.length && text4[j] !== quote) {
|
|
28461
|
+
if (text4[j] === "\\") j++;
|
|
28462
|
+
else if (quote !== "`" && text4[j] === "\n") break;
|
|
28388
28463
|
j++;
|
|
28389
28464
|
}
|
|
28390
|
-
return Math.min(j + 1,
|
|
28465
|
+
return Math.min(j + 1, text4.length);
|
|
28391
28466
|
}
|
|
28392
|
-
function closeOf2(
|
|
28393
|
-
const open2 =
|
|
28467
|
+
function closeOf2(text4, i) {
|
|
28468
|
+
const open2 = text4[i];
|
|
28394
28469
|
const close = { "{": "}", "(": ")", "[": "]" }[open2];
|
|
28395
28470
|
let depth = 0;
|
|
28396
|
-
for (let j = i; j <
|
|
28397
|
-
const ch =
|
|
28471
|
+
for (let j = i; j < text4.length; j++) {
|
|
28472
|
+
const ch = text4[j];
|
|
28398
28473
|
if (ch === '"' || ch === "'" || ch === "`") {
|
|
28399
|
-
j = stringEnd2(
|
|
28474
|
+
j = stringEnd2(text4, j) - 1;
|
|
28400
28475
|
continue;
|
|
28401
28476
|
}
|
|
28402
28477
|
if (ch === "{" || ch === "(" || ch === "[") depth++;
|
|
@@ -28407,12 +28482,12 @@ function closeOf2(text3, i) {
|
|
|
28407
28482
|
}
|
|
28408
28483
|
return -1;
|
|
28409
28484
|
}
|
|
28410
|
-
function literalAt2(
|
|
28411
|
-
const quote =
|
|
28485
|
+
function literalAt2(text4, i) {
|
|
28486
|
+
const quote = text4[i];
|
|
28412
28487
|
if (quote !== '"' && quote !== "'" && quote !== "`") return null;
|
|
28413
|
-
const end = stringEnd2(
|
|
28414
|
-
const body =
|
|
28415
|
-
if (
|
|
28488
|
+
const end = stringEnd2(text4, i);
|
|
28489
|
+
const body = text4.slice(i + 1, end - 1);
|
|
28490
|
+
if (text4[end - 1] !== quote || quote === "`" && body.includes("${") || body.includes("\\")) return null;
|
|
28416
28491
|
return { value: body, end };
|
|
28417
28492
|
}
|
|
28418
28493
|
function objectKeys2(body) {
|
|
@@ -28526,8 +28601,8 @@ function fieldOf2(element) {
|
|
|
28526
28601
|
if (INPUT_PARTS2.has(element?.type) && named8(element.props?.props?.field)) return element.props.props.field;
|
|
28527
28602
|
return null;
|
|
28528
28603
|
}
|
|
28529
|
-
function mentions2(
|
|
28530
|
-
return new RegExp(`(^|[^A-Za-z0-9_])${reEscape2(name)}([^A-Za-z0-9_]|$)`).test(
|
|
28604
|
+
function mentions2(text4, name) {
|
|
28605
|
+
return new RegExp(`(^|[^A-Za-z0-9_])${reEscape2(name)}([^A-Za-z0-9_]|$)`).test(text4);
|
|
28531
28606
|
}
|
|
28532
28607
|
function payloadProducers2(contract, { moduleSource = () => void 0, pageSource = () => void 0 } = {}) {
|
|
28533
28608
|
const elements = isPlainObject13(contract?.elements) ? contract.elements : {};
|
|
@@ -28652,13 +28727,13 @@ function payloadProducers2(contract, { moduleSource = () => void 0, pageSource =
|
|
|
28652
28727
|
}
|
|
28653
28728
|
for (const page of Array.isArray(contract?.pages) ? contract.pages : []) {
|
|
28654
28729
|
if (!named8(page?.path)) continue;
|
|
28655
|
-
const
|
|
28730
|
+
const text4 = pageSource(page.path);
|
|
28656
28731
|
const unknown = { page: page.path, uid: null, what: "script", keys: null };
|
|
28657
|
-
if (typeof
|
|
28732
|
+
if (typeof text4 !== "string") {
|
|
28658
28733
|
if (page.owned === true) add("*", unknown);
|
|
28659
28734
|
continue;
|
|
28660
28735
|
}
|
|
28661
|
-
const code = page.owned === true ? [
|
|
28736
|
+
const code = page.owned === true ? [text4] : pageCode2(text4, page.path, modules, pageSource);
|
|
28662
28737
|
if (code === null) {
|
|
28663
28738
|
add("*", unknown);
|
|
28664
28739
|
continue;
|
|
@@ -29490,18 +29565,18 @@ function unreadParams(contract, { moduleSource = () => void 0, handlerSource = (
|
|
|
29490
29565
|
} else if (handlers[one]?.role === "custom" && !custom.includes(one)) custom.push(one);
|
|
29491
29566
|
}
|
|
29492
29567
|
if (element?.type === "custom" && named9(props.module)) {
|
|
29493
|
-
const
|
|
29494
|
-
if (typeof
|
|
29568
|
+
const text4 = moduleSource(props.module);
|
|
29569
|
+
if (typeof text4 === "string") modules.push(text4);
|
|
29495
29570
|
else unknown = true;
|
|
29496
29571
|
}
|
|
29497
29572
|
}
|
|
29498
29573
|
if (unknown) continue;
|
|
29499
29574
|
for (const name of namesOf(page)) {
|
|
29500
29575
|
if (read.has(name)) continue;
|
|
29501
|
-
if (modules.some((
|
|
29576
|
+
if (modules.some((text4) => readsUiParam2(text4, name))) continue;
|
|
29502
29577
|
if (custom.some((handler) => {
|
|
29503
|
-
const
|
|
29504
|
-
return typeof
|
|
29578
|
+
const text4 = handlerSource(handler);
|
|
29579
|
+
return typeof text4 !== "string" || text4.includes(`"${name}"`) || text4.includes(`'${name}'`);
|
|
29505
29580
|
})) {
|
|
29506
29581
|
continue;
|
|
29507
29582
|
}
|
|
@@ -30167,17 +30242,17 @@ function resolve11(token, overrides, seen = /* @__PURE__ */ new Set()) {
|
|
|
30167
30242
|
}
|
|
30168
30243
|
function rootTokens2(css) {
|
|
30169
30244
|
const out = /* @__PURE__ */ new Map();
|
|
30170
|
-
const
|
|
30171
|
-
for (const block of
|
|
30245
|
+
const text4 = css.replace(/\/\*[\s\S]*?\*\//g, (hit) => hit.replace(/[^\n]/g, " "));
|
|
30246
|
+
for (const block of text4.matchAll(/:root\s*\{([^}]*)\}/g)) {
|
|
30172
30247
|
const offset = block.index + block[0].indexOf("{");
|
|
30173
30248
|
for (const hit of block[1].matchAll(/(--dr-[a-z0-9-]+)\s*:\s*([^;]+);/g)) {
|
|
30174
|
-
out.set(hit[1], { value: hit[2].trim(), line: lineOf2(
|
|
30249
|
+
out.set(hit[1], { value: hit[2].trim(), line: lineOf2(text4, offset + hit.index) });
|
|
30175
30250
|
}
|
|
30176
30251
|
}
|
|
30177
30252
|
return out;
|
|
30178
30253
|
}
|
|
30179
|
-
function lineOf2(
|
|
30180
|
-
return
|
|
30254
|
+
function lineOf2(text4, index) {
|
|
30255
|
+
return text4.slice(0, index).split("\n").length;
|
|
30181
30256
|
}
|
|
30182
30257
|
function dedupe3(violations) {
|
|
30183
30258
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -30189,17 +30264,17 @@ function dedupe3(violations) {
|
|
|
30189
30264
|
});
|
|
30190
30265
|
}
|
|
30191
30266
|
function rgbOf3(value, over) {
|
|
30192
|
-
const
|
|
30267
|
+
const text4 = String(value || "").trim();
|
|
30193
30268
|
let parts = null;
|
|
30194
30269
|
let alpha = 1;
|
|
30195
|
-
if (
|
|
30196
|
-
let hex =
|
|
30270
|
+
if (text4.startsWith("#")) {
|
|
30271
|
+
let hex = text4.slice(1);
|
|
30197
30272
|
if (hex.length === 3) hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];
|
|
30198
30273
|
if (/^[0-9a-f]{6,8}$/i.test(hex)) {
|
|
30199
30274
|
parts = [parseInt(hex.slice(0, 2), 16), parseInt(hex.slice(2, 4), 16), parseInt(hex.slice(4, 6), 16)];
|
|
30200
30275
|
}
|
|
30201
30276
|
} else {
|
|
30202
|
-
const hit = /rgba?\(([^)]+)\)/.exec(
|
|
30277
|
+
const hit = /rgba?\(([^)]+)\)/.exec(text4);
|
|
30203
30278
|
if (hit) {
|
|
30204
30279
|
const bits = hit[1].split(/[,/]/).map((bit) => parseFloat(bit));
|
|
30205
30280
|
parts = [bits[0], bits[1], bits[2]];
|
|
@@ -30609,14 +30684,14 @@ function targetOf2(href) {
|
|
|
30609
30684
|
return `ui/${file}`;
|
|
30610
30685
|
}
|
|
30611
30686
|
function navLinks2(html, { owned = false } = {}) {
|
|
30612
|
-
const
|
|
30687
|
+
const text4 = String(html ?? "");
|
|
30613
30688
|
const regions = [];
|
|
30614
|
-
if (owned) regions.push(
|
|
30689
|
+
if (owned) regions.push(text4);
|
|
30615
30690
|
else {
|
|
30616
|
-
for (const open2 of
|
|
30691
|
+
for (const open2 of text4.matchAll(NAV_OPEN2)) {
|
|
30617
30692
|
const start = open2.index + open2[0].length;
|
|
30618
|
-
const end =
|
|
30619
|
-
regions.push(
|
|
30693
|
+
const end = text4.indexOf("</nav>", start);
|
|
30694
|
+
regions.push(text4.slice(start, end === -1 ? text4.length : end));
|
|
30620
30695
|
}
|
|
30621
30696
|
}
|
|
30622
30697
|
const out = [];
|
|
@@ -30628,7 +30703,7 @@ function navLinks2(html, { owned = false } = {}) {
|
|
|
30628
30703
|
}
|
|
30629
30704
|
}
|
|
30630
30705
|
if (owned) {
|
|
30631
|
-
for (const link of moduleLinks2(
|
|
30706
|
+
for (const link of moduleLinks2(text4)) if (!out.some((one) => one.target === link.target && one.gate.length === 0)) out.push(link);
|
|
30632
30707
|
}
|
|
30633
30708
|
return out;
|
|
30634
30709
|
}
|
|
@@ -30903,7 +30978,7 @@ var REASON_KEYS2 = Object.freeze([
|
|
|
30903
30978
|
]);
|
|
30904
30979
|
var REJECTS2 = /(?:==|!=|\bin\b)[^\n]*(['"])(?:reject|rejected|decline|declined|deny|denied)\1/i;
|
|
30905
30980
|
function pyLines2(source) {
|
|
30906
|
-
const
|
|
30981
|
+
const text4 = String(source ?? "").replace(/("""|''')[\s\S]*?\1/g, (block) => block.replace(/[^\n]/g, " ")).split("\n").map((line2) => {
|
|
30907
30982
|
let quote = null;
|
|
30908
30983
|
for (let i = 0; i < line2.length; i++) {
|
|
30909
30984
|
const ch = line2[i];
|
|
@@ -30915,7 +30990,7 @@ function pyLines2(source) {
|
|
|
30915
30990
|
}
|
|
30916
30991
|
return line2;
|
|
30917
30992
|
});
|
|
30918
|
-
return
|
|
30993
|
+
return text4;
|
|
30919
30994
|
}
|
|
30920
30995
|
var indentOf2 = (line2) => /^[ \t]*/.exec(line2)[0].replace(/\t/g, " ").length;
|
|
30921
30996
|
var blank3 = (line2) => line2.trim() === "";
|
|
@@ -30988,7 +31063,7 @@ function unliftableRefusals2(contract, { handlerSource = () => void 0 } = {}) {
|
|
|
30988
31063
|
for (const key of REASON_KEYS2) {
|
|
30989
31064
|
if (!reads.optional.includes(key) && !reads.required.includes(key)) continue;
|
|
30990
31065
|
const vars = reasonVars2(lines, key);
|
|
30991
|
-
const mentions3 = (
|
|
31066
|
+
const mentions3 = (text4) => new RegExp(`(['"])${key}\\1`).test(text4) || [...vars].some((v) => new RegExp(`\\b${v}\\b`).test(text4));
|
|
30992
31067
|
const gates = lines.map((line2, i) => [line2, i]).filter(([line2]) => /^\s*if\b/.test(line2) && [...vars].some((v) => new RegExp(`\\bnot[ \\t]+\\(?[ \\t]*${v}\\b`).test(line2)));
|
|
30993
31068
|
for (const [gate, gi] of gates) {
|
|
30994
31069
|
const depth = indentOf2(gate);
|
|
@@ -31839,7 +31914,8 @@ async function writePlan(dir, kind, contract, files, paths, force) {
|
|
|
31839
31914
|
}
|
|
31840
31915
|
const existing = await readIfPresent(join15(dir, path3));
|
|
31841
31916
|
if (existing === files[path3]) {
|
|
31842
|
-
|
|
31917
|
+
const ours = owned.has(path3) && (!AUTHOR_FILES.has(path3) || existing !== void 0 && digests[path3] === digestOf(existing));
|
|
31918
|
+
if (!ours && AUTHOR_FILES.has(path3)) plan.inputs.push(path3);
|
|
31843
31919
|
else plan.owned.push(path3);
|
|
31844
31920
|
continue;
|
|
31845
31921
|
}
|
|
@@ -32197,8 +32273,8 @@ function sameScalar(want, got) {
|
|
|
32197
32273
|
}
|
|
32198
32274
|
function describeValue(value) {
|
|
32199
32275
|
if (value === void 0) return "nothing";
|
|
32200
|
-
const
|
|
32201
|
-
return
|
|
32276
|
+
const text4 = JSON.stringify(value) ?? "nothing";
|
|
32277
|
+
return text4.length > 80 ? `${text4.slice(0, 77)}\u2026` : text4;
|
|
32202
32278
|
}
|
|
32203
32279
|
function isPlain(value) {
|
|
32204
32280
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
@@ -32264,14 +32340,14 @@ async function loadContract(dir, opts) {
|
|
|
32264
32340
|
record2.name = typeof app["name"] === "string" ? app["name"] : null;
|
|
32265
32341
|
const headline = resolveExpectations(opts.expect, assembled.contract, assembled.widgetIds);
|
|
32266
32342
|
const overlay = {};
|
|
32267
|
-
for (const [path3,
|
|
32343
|
+
for (const [path3, text4] of Object.entries(assembled.transforms)) {
|
|
32268
32344
|
if (!insideFolder(dir, path3)) throw new Error(`refusing to write the transform ${JSON.stringify(path3)} outside ${dir}.`);
|
|
32269
32345
|
if (opts.check === true) {
|
|
32270
|
-
overlay[path3] =
|
|
32346
|
+
overlay[path3] = text4;
|
|
32271
32347
|
continue;
|
|
32272
32348
|
}
|
|
32273
32349
|
await mkdir6(dirname7(join15(dir, path3)), { recursive: true });
|
|
32274
|
-
await writeFile7(join15(dir, path3),
|
|
32350
|
+
await writeFile7(join15(dir, path3), text4);
|
|
32275
32351
|
(record2.transforms ??= []).push(path3);
|
|
32276
32352
|
}
|
|
32277
32353
|
if (opts.check !== true) {
|
|
@@ -32363,8 +32439,8 @@ async function compileFolder(dir, kind, contract, kit, overlay = {}) {
|
|
|
32363
32439
|
const built = kind === "dashboard" && rendererOf2(contract) !== "runtime" ? compile(contract, { kit, extra }) : compileApp(contract, { kit, extra });
|
|
32364
32440
|
if (Object.keys(built.files).length > 0) {
|
|
32365
32441
|
for (const path3 of ownedPaths(contract)) {
|
|
32366
|
-
const
|
|
32367
|
-
if (built.files[path3] === void 0 && typeof
|
|
32442
|
+
const text4 = extra[path3];
|
|
32443
|
+
if (built.files[path3] === void 0 && typeof text4 === "string") built.files[path3] = text4;
|
|
32368
32444
|
}
|
|
32369
32445
|
}
|
|
32370
32446
|
return built;
|
|
@@ -32420,32 +32496,40 @@ async function recordPulled(dir, contractWritten) {
|
|
|
32420
32496
|
async function folderFiles(dir) {
|
|
32421
32497
|
const out = {};
|
|
32422
32498
|
for (const name of ["seed.json", "tests.json"]) {
|
|
32423
|
-
const
|
|
32424
|
-
if (
|
|
32499
|
+
const text4 = await readIfPresent(join15(dir, name));
|
|
32500
|
+
if (text4 !== void 0) out[name] = text4;
|
|
32501
|
+
}
|
|
32502
|
+
if (out["tests.json"] !== void 0 && await generatedUnedited(dir, "tests.json", out["tests.json"])) {
|
|
32503
|
+
delete out["tests.json"];
|
|
32425
32504
|
}
|
|
32426
32505
|
for (const file of await readDirIfPresent(join15(dir, "handlers"))) {
|
|
32427
32506
|
if (!file.endsWith(".py")) continue;
|
|
32428
|
-
const
|
|
32429
|
-
if (
|
|
32507
|
+
const text4 = await readIfPresent(join15(dir, "handlers", file));
|
|
32508
|
+
if (text4 !== void 0) out[`handlers/${file}`] = text4;
|
|
32430
32509
|
}
|
|
32431
32510
|
for (const file of await readDirIfPresent(join15(dir, "ui"))) {
|
|
32432
32511
|
if (!file.endsWith(".html")) continue;
|
|
32433
|
-
const
|
|
32434
|
-
if (
|
|
32512
|
+
const text4 = await readIfPresent(join15(dir, "ui", file));
|
|
32513
|
+
if (text4 !== void 0) out[`ui/${file}`] = text4;
|
|
32435
32514
|
}
|
|
32436
32515
|
for (const file of await readDirIfPresent(join15(dir, "ui", "components"))) {
|
|
32437
32516
|
if (!file.endsWith(".js")) continue;
|
|
32438
|
-
const
|
|
32439
|
-
if (
|
|
32517
|
+
const text4 = await readIfPresent(join15(dir, "ui", "components", file));
|
|
32518
|
+
if (text4 !== void 0) out[`ui/components/${file}`] = text4;
|
|
32440
32519
|
}
|
|
32441
32520
|
return { ...out, ...await transformFiles(dir) };
|
|
32442
32521
|
}
|
|
32522
|
+
async function generatedUnedited(dir, path3, text4) {
|
|
32523
|
+
if (!(await ownedFiles(dir)).has(path3)) return false;
|
|
32524
|
+
const recorded = (await recordedDigests(dir))[path3];
|
|
32525
|
+
return recorded !== void 0 && recorded === digestOf(text4);
|
|
32526
|
+
}
|
|
32443
32527
|
async function transformFiles(dir) {
|
|
32444
32528
|
const out = {};
|
|
32445
32529
|
for (const file of await readDirIfPresent(join15(dir, "transforms"))) {
|
|
32446
32530
|
if (!file.endsWith(".py")) continue;
|
|
32447
|
-
const
|
|
32448
|
-
if (
|
|
32531
|
+
const text4 = await readIfPresent(join15(dir, "transforms", file));
|
|
32532
|
+
if (text4 !== void 0) out[`transforms/${file}`] = text4;
|
|
32449
32533
|
}
|
|
32450
32534
|
return out;
|
|
32451
32535
|
}
|
|
@@ -32973,11 +33057,11 @@ var EJECTED_DOCSTRING = 'Ejected with app-space eject: this file is yours now, a
|
|
|
32973
33057
|
function authorsDocstring(body) {
|
|
32974
33058
|
return body.replace(/Generated by [^\n]*compile[\s\S]*?not this file\./, EJECTED_DOCSTRING);
|
|
32975
33059
|
}
|
|
32976
|
-
function literalEnd2(
|
|
33060
|
+
function literalEnd2(text4, open2) {
|
|
32977
33061
|
let depth = 0;
|
|
32978
33062
|
let quote = null;
|
|
32979
|
-
for (let i = open2; i <
|
|
32980
|
-
const c =
|
|
33063
|
+
for (let i = open2; i < text4.length; i++) {
|
|
33064
|
+
const c = text4[i];
|
|
32981
33065
|
if (quote !== null) {
|
|
32982
33066
|
if (c === "\\") i++;
|
|
32983
33067
|
else if (c === quote) quote = null;
|
|
@@ -33095,9 +33179,9 @@ function unservedAfter(path3, lost) {
|
|
|
33095
33179
|
}
|
|
33096
33180
|
function navGateOf(files, path3) {
|
|
33097
33181
|
const gates = navGates;
|
|
33098
|
-
for (const [file,
|
|
33182
|
+
for (const [file, text4] of Object.entries(files)) {
|
|
33099
33183
|
if (file === path3 || !file.startsWith("ui/") || !file.endsWith(".html")) continue;
|
|
33100
|
-
const role = gates(
|
|
33184
|
+
const role = gates(text4, file).get(path3);
|
|
33101
33185
|
if (role !== void 0) return role;
|
|
33102
33186
|
}
|
|
33103
33187
|
return null;
|
|
@@ -33133,8 +33217,8 @@ async function ejectElement(dir, contract, uid) {
|
|
|
33133
33217
|
const module = `components/${name}.js`;
|
|
33134
33218
|
const path3 = `ui/${module}`;
|
|
33135
33219
|
if (!insideFolder(dir, path3)) throw new Refused(`${JSON.stringify(path3)} is not a path inside ${dir}.`);
|
|
33136
|
-
const
|
|
33137
|
-
await mayPlace(dir, path3,
|
|
33220
|
+
const text4 = templateFor(type, module, typeof props["id"] === "string" ? props["id"] : name);
|
|
33221
|
+
await mayPlace(dir, path3, text4, []);
|
|
33138
33222
|
const args = {};
|
|
33139
33223
|
const kept = {};
|
|
33140
33224
|
for (const [key, value] of Object.entries(props)) {
|
|
@@ -33145,7 +33229,7 @@ async function ejectElement(dir, contract, uid) {
|
|
|
33145
33229
|
if (Object.keys(args).length > 0) kept["args"] = args;
|
|
33146
33230
|
element["type"] = "custom";
|
|
33147
33231
|
element["props"] = kept;
|
|
33148
|
-
const wrote = await commit(dir, contract, path3,
|
|
33232
|
+
const wrote = await commit(dir, contract, path3, text4);
|
|
33149
33233
|
return { target: `element:${uid}`, wrote, said: `${type} ${uid} is yours now: a custom element drawn by ${path3}.` };
|
|
33150
33234
|
}
|
|
33151
33235
|
function moduleName(id, type, uid) {
|
|
@@ -33213,9 +33297,9 @@ function refusedLines(built) {
|
|
|
33213
33297
|
if (Object.keys(built.files).length > 0 && refused.length === 0) return null;
|
|
33214
33298
|
return (refused.length > 0 ? refused : built.problems).map((problem6) => ` [${problem6.code}] ${problem6.message}`).join("\n");
|
|
33215
33299
|
}
|
|
33216
|
-
async function mayPlace(dir, path3,
|
|
33300
|
+
async function mayPlace(dir, path3, text4, same5) {
|
|
33217
33301
|
const existing = await readIfPresent(join16(dir, path3));
|
|
33218
|
-
if (existing === void 0 || existing ===
|
|
33302
|
+
if (existing === void 0 || existing === text4 || same5.includes(existing)) return;
|
|
33219
33303
|
if ((await ownedFiles(dir)).has(path3)) {
|
|
33220
33304
|
const recorded = (await recordedDigests(dir))[path3];
|
|
33221
33305
|
if (recorded === void 0 || recorded === digestOf(existing)) return;
|
|
@@ -33224,7 +33308,7 @@ async function mayPlace(dir, path3, text3, same5) {
|
|
|
33224
33308
|
`${path3} already holds something other than what eject would write there. It is yours: move it aside first, or keep it and edit contract.json by hand.`
|
|
33225
33309
|
);
|
|
33226
33310
|
}
|
|
33227
|
-
async function commit(dir, contract, path3,
|
|
33311
|
+
async function commit(dir, contract, path3, text4, check5) {
|
|
33228
33312
|
const invalid = validateContract(contract, NO_CATALOG).problems;
|
|
33229
33313
|
if (invalid.length > 0) {
|
|
33230
33314
|
throw new Refused(`after this eject contract.json would not validate, so eject leaves the folder as it was:
|
|
@@ -33232,7 +33316,7 @@ ${formatProblems(invalid)}`);
|
|
|
33232
33316
|
}
|
|
33233
33317
|
let built;
|
|
33234
33318
|
try {
|
|
33235
|
-
built = await compileFolder(dir, "app", contract, kit_default2, { [path3]:
|
|
33319
|
+
built = await compileFolder(dir, "app", contract, kit_default2, { [path3]: text4 });
|
|
33236
33320
|
} catch (err) {
|
|
33237
33321
|
throw new Refused(`after this eject contract.json would not compile (${err instanceof Error ? err.message : String(err)}).`);
|
|
33238
33322
|
}
|
|
@@ -33244,10 +33328,10 @@ ${lines}
|
|
|
33244
33328
|
}
|
|
33245
33329
|
check5?.(built.files);
|
|
33246
33330
|
const full = join16(dir, path3);
|
|
33247
|
-
const wrote = await readIfPresent(full) ===
|
|
33331
|
+
const wrote = await readIfPresent(full) === text4 ? [] : [path3];
|
|
33248
33332
|
if (wrote.length > 0) {
|
|
33249
33333
|
await mkdir7(dirname8(full), { recursive: true });
|
|
33250
|
-
await writeFile8(full,
|
|
33334
|
+
await writeFile8(full, text4);
|
|
33251
33335
|
}
|
|
33252
33336
|
await writeFile8(join16(dir, "contract.json"), JSON.stringify(contract, null, 2) + "\n");
|
|
33253
33337
|
await recordAsInput(dir, path3);
|
|
@@ -33371,11 +33455,11 @@ import { readFile as readFile11, realpath } from "fs/promises";
|
|
|
33371
33455
|
import { basename as basename2, extname, resolve as resolve14, sep as sep5 } from "path";
|
|
33372
33456
|
|
|
33373
33457
|
// src/commands/appspace/_samplePdf.ts
|
|
33374
|
-
function pdfString(
|
|
33375
|
-
if (!/^[\x20-\x7e]*$/.test(
|
|
33376
|
-
throw new Error(`buildPdf takes printable ASCII only, and ${JSON.stringify(
|
|
33458
|
+
function pdfString(text4) {
|
|
33459
|
+
if (!/^[\x20-\x7e]*$/.test(text4)) {
|
|
33460
|
+
throw new Error(`buildPdf takes printable ASCII only, and ${JSON.stringify(text4)} is not`);
|
|
33377
33461
|
}
|
|
33378
|
-
return `(${
|
|
33462
|
+
return `(${text4.replace(/[\\()]/g, (c) => `\\${c}`)})`;
|
|
33379
33463
|
}
|
|
33380
33464
|
function buildPdf(lines) {
|
|
33381
33465
|
const body = lines.map((line2, i) => `${i === 0 ? "" : "T* "}${pdfString(line2)} Tj`).join("\n");
|
|
@@ -33879,14 +33963,14 @@ function fileFor(field) {
|
|
|
33879
33963
|
}
|
|
33880
33964
|
var FORM_CONTROL_TAGS = /* @__PURE__ */ new Set(["input", "select", "textarea"]);
|
|
33881
33965
|
function labelOf2(component) {
|
|
33882
|
-
const cut3 = (
|
|
33966
|
+
const cut3 = (text5) => text5.length <= 40 ? text5 : `${text5.slice(0, 39)}\u2026`;
|
|
33883
33967
|
if (component.type === "form") {
|
|
33884
33968
|
if (component.props.id !== void 0) return `the ${component.props.id} form`;
|
|
33885
33969
|
if (component.props.entity !== void 0) return `the ${component.props.entity} form`;
|
|
33886
33970
|
return `form #${String(component.n)}`;
|
|
33887
33971
|
}
|
|
33888
|
-
const
|
|
33889
|
-
if (
|
|
33972
|
+
const text4 = (component.text ?? "").trim();
|
|
33973
|
+
if (text4 !== "") return cut3(text4);
|
|
33890
33974
|
return component.props.id ?? `${component.type} #${String(component.n)}`;
|
|
33891
33975
|
}
|
|
33892
33976
|
function controlFor(column) {
|
|
@@ -34412,9 +34496,9 @@ function installChartCapture(window, charts) {
|
|
|
34412
34496
|
function numberOf(value) {
|
|
34413
34497
|
if (typeof value === "number") return Number.isFinite(value) ? value : null;
|
|
34414
34498
|
if (typeof value !== "string") return null;
|
|
34415
|
-
const
|
|
34416
|
-
if (
|
|
34417
|
-
const n = Number(
|
|
34499
|
+
const text4 = value.replace(/[,\s$]/g, "");
|
|
34500
|
+
if (text4 === "" || /^[-+]?0[xob]/i.test(text4)) return null;
|
|
34501
|
+
const n = Number(text4);
|
|
34418
34502
|
return Number.isFinite(n) ? n : null;
|
|
34419
34503
|
}
|
|
34420
34504
|
var MONTH_NAME = "january|jan|february|feb|march|mar|april|apr|may|june|jun|july|jul|august|aug|september|sept|sep|october|oct|november|nov|december|dec";
|
|
@@ -34435,8 +34519,8 @@ var DATE_LIKE = new RegExp(
|
|
|
34435
34519
|
].join("|"),
|
|
34436
34520
|
"gi"
|
|
34437
34521
|
);
|
|
34438
|
-
function figuresIn(
|
|
34439
|
-
const undated =
|
|
34522
|
+
function figuresIn(text4) {
|
|
34523
|
+
const undated = text4.replace(DATE_LIKE, " ");
|
|
34440
34524
|
return (undated.match(/[-+]?\d[\d,]*(?:\.\d+)?/g) ?? []).map((one) => Number(one.replace(/,/g, "")));
|
|
34441
34525
|
}
|
|
34442
34526
|
function seriesNumbers(data) {
|
|
@@ -34488,8 +34572,8 @@ function drawnSnapshot(document, harvest, charts) {
|
|
|
34488
34572
|
for (const component of harvest.components) {
|
|
34489
34573
|
if (component.type !== "stat" || component.text === void 0) continue;
|
|
34490
34574
|
if (out.has(component.n)) continue;
|
|
34491
|
-
const
|
|
34492
|
-
if (
|
|
34575
|
+
const figures2 = figuresIn(component.text);
|
|
34576
|
+
if (figures2.length > 0) add(component.n, [null, `figures=${JSON.stringify(figures2)}`, figures2]);
|
|
34493
34577
|
}
|
|
34494
34578
|
for (const [node, chart] of charts) {
|
|
34495
34579
|
if (node.isConnected === false) continue;
|
|
@@ -34500,10 +34584,10 @@ function drawnSnapshot(document, harvest, charts) {
|
|
|
34500
34584
|
}
|
|
34501
34585
|
function movedBetween(before, after, param, echoes = []) {
|
|
34502
34586
|
const echoed = new Set(echoes.map(numberOf).filter((n) => n !== null));
|
|
34503
|
-
const keep = (list3) => (list3 ?? []).flatMap(([field, what,
|
|
34587
|
+
const keep = (list3) => (list3 ?? []).flatMap(([field, what, figures2]) => {
|
|
34504
34588
|
if (field === param) return [];
|
|
34505
|
-
if (
|
|
34506
|
-
const answered =
|
|
34589
|
+
if (figures2 === void 0 || echoed.size === 0) return [what];
|
|
34590
|
+
const answered = figures2.filter((n) => !echoed.has(n));
|
|
34507
34591
|
return answered.length === 0 ? [] : [`figures=${JSON.stringify(answered)}`];
|
|
34508
34592
|
});
|
|
34509
34593
|
const moved = [];
|
|
@@ -34536,8 +34620,8 @@ function nullTexts(document) {
|
|
|
34536
34620
|
}
|
|
34537
34621
|
return true;
|
|
34538
34622
|
};
|
|
34539
|
-
const look = (
|
|
34540
|
-
for (const match of
|
|
34623
|
+
const look = (text4, context) => {
|
|
34624
|
+
for (const match of text4.matchAll(NULL_LITERAL)) {
|
|
34541
34625
|
if (out.length >= NULL_TEXT_LIMIT) return;
|
|
34542
34626
|
const near = maskToken(context.replace(/\s+/g, " ").trim());
|
|
34543
34627
|
out.push({ literal: match[0], near: near.length <= NULL_TEXT_CONTEXT ? near : `${near.slice(0, NULL_TEXT_CONTEXT - 1)}\u2026` });
|
|
@@ -34554,12 +34638,12 @@ function nullTexts(document) {
|
|
|
34554
34638
|
if (parent === null) continue;
|
|
34555
34639
|
own2.set(parent, (own2.get(parent) ?? "") + (node.nodeValue ?? ""));
|
|
34556
34640
|
}
|
|
34557
|
-
for (const [parent,
|
|
34641
|
+
for (const [parent, text4] of own2) {
|
|
34558
34642
|
NULL_LITERAL.lastIndex = 0;
|
|
34559
|
-
if (!NULL_LITERAL.test(
|
|
34643
|
+
if (!NULL_LITERAL.test(text4)) continue;
|
|
34560
34644
|
NULL_LITERAL.lastIndex = 0;
|
|
34561
34645
|
if (!shown2(parent)) continue;
|
|
34562
|
-
look(
|
|
34646
|
+
look(text4, parent.textContent ?? text4);
|
|
34563
34647
|
}
|
|
34564
34648
|
for (const input of Array.from(body.querySelectorAll("input, textarea"))) {
|
|
34565
34649
|
const control = input;
|
|
@@ -34659,9 +34743,9 @@ var COLUMN_NAME = /^[A-Za-z_][\w -]{0,63}$/;
|
|
|
34659
34743
|
function numberLike(value) {
|
|
34660
34744
|
if (typeof value === "number") return Number.isFinite(value);
|
|
34661
34745
|
if (typeof value !== "string") return false;
|
|
34662
|
-
const
|
|
34663
|
-
if (
|
|
34664
|
-
return Number.isFinite(Number(
|
|
34746
|
+
const text4 = value.replace(/[,\s$]/g, "");
|
|
34747
|
+
if (text4 === "" || /^[-+]?0[xob]/i.test(text4)) return false;
|
|
34748
|
+
return Number.isFinite(Number(text4));
|
|
34665
34749
|
}
|
|
34666
34750
|
function rowKeys(rows2) {
|
|
34667
34751
|
const keys2 = [];
|
|
@@ -34707,16 +34791,16 @@ function answerOf(res) {
|
|
|
34707
34791
|
if (numeric.length > 0) out.numeric = numeric;
|
|
34708
34792
|
}
|
|
34709
34793
|
if (typeof error === "string" && error.trim() !== "") {
|
|
34710
|
-
const
|
|
34711
|
-
out.error =
|
|
34794
|
+
const text4 = error.trim();
|
|
34795
|
+
out.error = text4.length <= ERROR_TEXT_LIMIT ? text4 : `${text4.slice(0, ERROR_TEXT_LIMIT - 1)}\u2026`;
|
|
34712
34796
|
}
|
|
34713
34797
|
return out;
|
|
34714
34798
|
}
|
|
34715
34799
|
var TEXT_LIMIT = 80;
|
|
34716
34800
|
function harvestText(el) {
|
|
34717
|
-
const
|
|
34718
|
-
if (
|
|
34719
|
-
return
|
|
34801
|
+
const text4 = maskToken((el.textContent ?? "").replace(/\s+/g, " ").trim());
|
|
34802
|
+
if (text4 === "") return void 0;
|
|
34803
|
+
return text4.length <= TEXT_LIMIT ? text4 : `${text4.slice(0, TEXT_LIMIT - 1)}\u2026`;
|
|
34720
34804
|
}
|
|
34721
34805
|
function harvestAlert(el, index) {
|
|
34722
34806
|
const candidates = [
|
|
@@ -34727,9 +34811,9 @@ function harvestAlert(el, index) {
|
|
|
34727
34811
|
let owner = alert;
|
|
34728
34812
|
while (owner !== null && owner !== el && !index.has(owner)) owner = owner.parentElement;
|
|
34729
34813
|
if (owner !== el) continue;
|
|
34730
|
-
const
|
|
34731
|
-
if (
|
|
34732
|
-
return
|
|
34814
|
+
const text4 = maskToken((alert.textContent ?? "").replace(/\s+/g, " ").trim());
|
|
34815
|
+
if (text4 === "") continue;
|
|
34816
|
+
return text4.length <= ERROR_TEXT_LIMIT ? text4 : `${text4.slice(0, ERROR_TEXT_LIMIT - 1)}\u2026`;
|
|
34733
34817
|
}
|
|
34734
34818
|
return void 0;
|
|
34735
34819
|
}
|
|
@@ -34798,8 +34882,8 @@ function harvestNodes(document) {
|
|
|
34798
34882
|
tag: el.tagName.toLowerCase(),
|
|
34799
34883
|
parent
|
|
34800
34884
|
};
|
|
34801
|
-
const
|
|
34802
|
-
if (
|
|
34885
|
+
const text4 = harvestText(el);
|
|
34886
|
+
if (text4 !== void 0) out.text = text4;
|
|
34803
34887
|
const alert = harvestAlert(el, index);
|
|
34804
34888
|
if (alert !== void 0) out.alert = alert;
|
|
34805
34889
|
if (gatedByRole(el)) out.role_visible = drawn(el);
|
|
@@ -34903,8 +34987,8 @@ async function encodeMultipart(form, readBlob = defaultBlobReader) {
|
|
|
34903
34987
|
unsupported: `the attached part (${name}) could not be read by this smoke check (${err instanceof Error ? err.message : String(err)}) \u2014 the request was not made.`
|
|
34904
34988
|
};
|
|
34905
34989
|
}
|
|
34906
|
-
const
|
|
34907
|
-
if (!Buffer.from(
|
|
34990
|
+
const text5 = bytes.toString("utf8");
|
|
34991
|
+
if (!Buffer.from(text5, "utf8").equals(bytes)) {
|
|
34908
34992
|
return {
|
|
34909
34993
|
unsupported: `the page attached a part (${name}) whose bytes are not text, and this smoke check carries a multipart body as text \u2014 the request was not made. Exercise that upload from the app itself.`
|
|
34910
34994
|
};
|
|
@@ -34916,7 +35000,7 @@ async function encodeMultipart(form, readBlob = defaultBlobReader) {
|
|
|
34916
35000
|
Content-Disposition: form-data; name="${escapeDispositionValue(name)}"; filename="${escapeDispositionValue(filename)}"\r
|
|
34917
35001
|
Content-Type: ${mime.replace(/[\r\n]/g, "")}\r
|
|
34918
35002
|
\r
|
|
34919
|
-
${
|
|
35003
|
+
${text5}\r
|
|
34920
35004
|
`
|
|
34921
35005
|
);
|
|
34922
35006
|
continue;
|
|
@@ -34929,7 +35013,7 @@ ${String(value)}\r
|
|
|
34929
35013
|
`
|
|
34930
35014
|
);
|
|
34931
35015
|
}
|
|
34932
|
-
const
|
|
35016
|
+
const text4 = `${parts.join("")}--${MULTIPART_BOUNDARY}--\r
|
|
34933
35017
|
`;
|
|
34934
35018
|
if (parts.some((part) => part.slice(part.indexOf("\r\n\r\n")).includes(MULTIPART_BOUNDARY))) {
|
|
34935
35019
|
return {
|
|
@@ -34937,7 +35021,7 @@ ${String(value)}\r
|
|
|
34937
35021
|
};
|
|
34938
35022
|
}
|
|
34939
35023
|
return {
|
|
34940
|
-
text:
|
|
35024
|
+
text: text4,
|
|
34941
35025
|
contentType: `multipart/form-data; boundary=${MULTIPART_BOUNDARY}`
|
|
34942
35026
|
};
|
|
34943
35027
|
}
|
|
@@ -35673,6 +35757,996 @@ import { mkdir as mkdir8, mkdtemp as mkdtemp4, readFile as readFile12, readdir a
|
|
|
35673
35757
|
import { createServer } from "http";
|
|
35674
35758
|
import { tmpdir as tmpdir5 } from "os";
|
|
35675
35759
|
import { delimiter, extname as extname2, join as join17, relative as relative3, resolve as resolve15, sep as sep6 } from "path";
|
|
35760
|
+
|
|
35761
|
+
// ../tests/vendor/fixtures/widgets/kpi.json
|
|
35762
|
+
var kpi_default = {
|
|
35763
|
+
kind: "kpi",
|
|
35764
|
+
label: "Revenue YTD",
|
|
35765
|
+
value: -1022e4,
|
|
35766
|
+
unit: "currency",
|
|
35767
|
+
account_type: "revenue",
|
|
35768
|
+
delta: {
|
|
35769
|
+
value: 2.7,
|
|
35770
|
+
direction: "up",
|
|
35771
|
+
unit: "%",
|
|
35772
|
+
against: "prior month"
|
|
35773
|
+
},
|
|
35774
|
+
spark: [
|
|
35775
|
+
-98e4,
|
|
35776
|
+
-101e4,
|
|
35777
|
+
-112e4,
|
|
35778
|
+
-99e4,
|
|
35779
|
+
-1105e3,
|
|
35780
|
+
-124e4,
|
|
35781
|
+
-119e4,
|
|
35782
|
+
-131e4,
|
|
35783
|
+
-1275e3
|
|
35784
|
+
],
|
|
35785
|
+
meta: {
|
|
35786
|
+
v: 1,
|
|
35787
|
+
source: {
|
|
35788
|
+
kind: "metric",
|
|
35789
|
+
metric_id: 42,
|
|
35790
|
+
metric_name: "Revenue",
|
|
35791
|
+
url: null,
|
|
35792
|
+
read: "points",
|
|
35793
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
35794
|
+
query: {
|
|
35795
|
+
call: "metric_series",
|
|
35796
|
+
metric_id: 42,
|
|
35797
|
+
scenarios: [
|
|
35798
|
+
"Actuals"
|
|
35799
|
+
],
|
|
35800
|
+
scenario: null,
|
|
35801
|
+
date_start: "2026-01-01",
|
|
35802
|
+
date_end: "2026-09-16",
|
|
35803
|
+
aggregation_period: "month",
|
|
35804
|
+
aggregation_type: null,
|
|
35805
|
+
dimension_filters: {
|
|
35806
|
+
Entity: [
|
|
35807
|
+
"NCM-US"
|
|
35808
|
+
]
|
|
35809
|
+
}
|
|
35810
|
+
}
|
|
35811
|
+
},
|
|
35812
|
+
account_type: "revenue",
|
|
35813
|
+
unit: "currency",
|
|
35814
|
+
filters_applied: {
|
|
35815
|
+
period: {
|
|
35816
|
+
start: "2026-01-01",
|
|
35817
|
+
end: "2026-09-16",
|
|
35818
|
+
grain: "month"
|
|
35819
|
+
},
|
|
35820
|
+
scenario: [
|
|
35821
|
+
"Actuals"
|
|
35822
|
+
],
|
|
35823
|
+
dimensions: {
|
|
35824
|
+
Entity: [
|
|
35825
|
+
"NCM-US"
|
|
35826
|
+
]
|
|
35827
|
+
}
|
|
35828
|
+
},
|
|
35829
|
+
filters_ignored: [],
|
|
35830
|
+
params_applied: {},
|
|
35831
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
35832
|
+
row_count: 9,
|
|
35833
|
+
reads: 1
|
|
35834
|
+
}
|
|
35835
|
+
};
|
|
35836
|
+
|
|
35837
|
+
// ../tests/vendor/fixtures/widgets/series.json
|
|
35838
|
+
var series_default = {
|
|
35839
|
+
kind: "series",
|
|
35840
|
+
x: {
|
|
35841
|
+
type: "period",
|
|
35842
|
+
grain: "month",
|
|
35843
|
+
values: [
|
|
35844
|
+
"2026-01",
|
|
35845
|
+
"2026-02",
|
|
35846
|
+
"2026-03",
|
|
35847
|
+
"2026-04",
|
|
35848
|
+
"2026-05",
|
|
35849
|
+
"2026-06",
|
|
35850
|
+
"2026-07",
|
|
35851
|
+
"2026-08",
|
|
35852
|
+
"2026-09"
|
|
35853
|
+
]
|
|
35854
|
+
},
|
|
35855
|
+
series: [
|
|
35856
|
+
{
|
|
35857
|
+
id: "actuals",
|
|
35858
|
+
label: "Actuals",
|
|
35859
|
+
scenario: "Actuals",
|
|
35860
|
+
values: [
|
|
35861
|
+
-98e4,
|
|
35862
|
+
-101e4,
|
|
35863
|
+
-112e4,
|
|
35864
|
+
-99e4,
|
|
35865
|
+
null,
|
|
35866
|
+
-124e4,
|
|
35867
|
+
-119e4,
|
|
35868
|
+
-131e4,
|
|
35869
|
+
-1275e3
|
|
35870
|
+
],
|
|
35871
|
+
account_type: "revenue",
|
|
35872
|
+
style: {
|
|
35873
|
+
stack: null
|
|
35874
|
+
}
|
|
35875
|
+
},
|
|
35876
|
+
{
|
|
35877
|
+
id: "budget",
|
|
35878
|
+
label: "Budget",
|
|
35879
|
+
scenario: "Budget",
|
|
35880
|
+
values: [
|
|
35881
|
+
-1e6,
|
|
35882
|
+
-1e6,
|
|
35883
|
+
-1e6,
|
|
35884
|
+
-1e6,
|
|
35885
|
+
-1e6,
|
|
35886
|
+
-1e6,
|
|
35887
|
+
-1e6,
|
|
35888
|
+
-1e6,
|
|
35889
|
+
-1e6
|
|
35890
|
+
],
|
|
35891
|
+
account_type: "revenue",
|
|
35892
|
+
style: {
|
|
35893
|
+
stack: null
|
|
35894
|
+
}
|
|
35895
|
+
}
|
|
35896
|
+
],
|
|
35897
|
+
meta: {
|
|
35898
|
+
v: 1,
|
|
35899
|
+
source: {
|
|
35900
|
+
kind: "metric",
|
|
35901
|
+
metric_id: 42,
|
|
35902
|
+
metric_name: "Revenue",
|
|
35903
|
+
url: null,
|
|
35904
|
+
read: "points",
|
|
35905
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
35906
|
+
query: {
|
|
35907
|
+
call: "metric_series",
|
|
35908
|
+
metric_id: 42,
|
|
35909
|
+
scenarios: [
|
|
35910
|
+
"Actuals",
|
|
35911
|
+
"Budget"
|
|
35912
|
+
],
|
|
35913
|
+
scenario: null,
|
|
35914
|
+
date_start: "2026-01-01",
|
|
35915
|
+
date_end: "2026-09-16",
|
|
35916
|
+
aggregation_period: "month",
|
|
35917
|
+
aggregation_type: null,
|
|
35918
|
+
dimension_filters: {
|
|
35919
|
+
Entity: [
|
|
35920
|
+
"NCM-US"
|
|
35921
|
+
]
|
|
35922
|
+
}
|
|
35923
|
+
}
|
|
35924
|
+
},
|
|
35925
|
+
account_type: "revenue",
|
|
35926
|
+
unit: "currency",
|
|
35927
|
+
filters_applied: {
|
|
35928
|
+
period: {
|
|
35929
|
+
start: "2026-01-01",
|
|
35930
|
+
end: "2026-09-16",
|
|
35931
|
+
grain: "month"
|
|
35932
|
+
},
|
|
35933
|
+
scenario: [
|
|
35934
|
+
"Actuals",
|
|
35935
|
+
"Budget"
|
|
35936
|
+
],
|
|
35937
|
+
dimensions: {
|
|
35938
|
+
Entity: [
|
|
35939
|
+
"NCM-US"
|
|
35940
|
+
]
|
|
35941
|
+
}
|
|
35942
|
+
},
|
|
35943
|
+
filters_ignored: [],
|
|
35944
|
+
params_applied: {},
|
|
35945
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
35946
|
+
row_count: 9,
|
|
35947
|
+
reads: 1,
|
|
35948
|
+
drill: {
|
|
35949
|
+
dimensions: [
|
|
35950
|
+
"Entity",
|
|
35951
|
+
"Account"
|
|
35952
|
+
],
|
|
35953
|
+
op: "drill",
|
|
35954
|
+
widget: "rev"
|
|
35955
|
+
}
|
|
35956
|
+
}
|
|
35957
|
+
};
|
|
35958
|
+
|
|
35959
|
+
// ../tests/vendor/fixtures/widgets/breakdown.json
|
|
35960
|
+
var breakdown_default = {
|
|
35961
|
+
kind: "breakdown",
|
|
35962
|
+
dimension: "Entity",
|
|
35963
|
+
items: [
|
|
35964
|
+
{
|
|
35965
|
+
label: "NCM-US",
|
|
35966
|
+
value: -12e5,
|
|
35967
|
+
share: 0.57
|
|
35968
|
+
},
|
|
35969
|
+
{
|
|
35970
|
+
label: "NCM-UK",
|
|
35971
|
+
value: -51e4,
|
|
35972
|
+
share: 0.24
|
|
35973
|
+
},
|
|
35974
|
+
{
|
|
35975
|
+
label: "NCM-IL",
|
|
35976
|
+
value: -225e3,
|
|
35977
|
+
share: 0.11
|
|
35978
|
+
}
|
|
35979
|
+
],
|
|
35980
|
+
total: -2115e3,
|
|
35981
|
+
other_count: 3,
|
|
35982
|
+
other_value: -18e4,
|
|
35983
|
+
meta: {
|
|
35984
|
+
v: 1,
|
|
35985
|
+
source: {
|
|
35986
|
+
kind: "metric",
|
|
35987
|
+
metric_id: 42,
|
|
35988
|
+
metric_name: "Revenue",
|
|
35989
|
+
url: null,
|
|
35990
|
+
read: "rows",
|
|
35991
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
35992
|
+
query: {
|
|
35993
|
+
call: "drill_down_business_metric",
|
|
35994
|
+
metric_ids: [
|
|
35995
|
+
42
|
|
35996
|
+
],
|
|
35997
|
+
date_start: "2026-01-01",
|
|
35998
|
+
date_end: "2026-09-16",
|
|
35999
|
+
dimension_filters: {
|
|
36000
|
+
Entity: [
|
|
36001
|
+
"NCM-US"
|
|
36002
|
+
]
|
|
36003
|
+
}
|
|
36004
|
+
}
|
|
36005
|
+
},
|
|
36006
|
+
account_type: "revenue",
|
|
36007
|
+
unit: "currency",
|
|
36008
|
+
filters_applied: {
|
|
36009
|
+
period: {
|
|
36010
|
+
start: "2026-01-01",
|
|
36011
|
+
end: "2026-09-16",
|
|
36012
|
+
grain: "month"
|
|
36013
|
+
},
|
|
36014
|
+
scenario: [
|
|
36015
|
+
"Actuals"
|
|
36016
|
+
],
|
|
36017
|
+
dimensions: {
|
|
36018
|
+
Entity: [
|
|
36019
|
+
"NCM-US"
|
|
36020
|
+
]
|
|
36021
|
+
}
|
|
36022
|
+
},
|
|
36023
|
+
filters_ignored: [],
|
|
36024
|
+
params_applied: {},
|
|
36025
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36026
|
+
row_count: 6,
|
|
36027
|
+
reads: 1,
|
|
36028
|
+
drill: {
|
|
36029
|
+
dimensions: [
|
|
36030
|
+
"Entity",
|
|
36031
|
+
"Account"
|
|
36032
|
+
],
|
|
36033
|
+
op: "drill",
|
|
36034
|
+
widget: "rev"
|
|
36035
|
+
}
|
|
36036
|
+
}
|
|
36037
|
+
};
|
|
36038
|
+
|
|
36039
|
+
// ../tests/vendor/fixtures/widgets/table.json
|
|
36040
|
+
var table_default = {
|
|
36041
|
+
kind: "table",
|
|
36042
|
+
columns: [
|
|
36043
|
+
{
|
|
36044
|
+
key: "period",
|
|
36045
|
+
label: "Month",
|
|
36046
|
+
align: "left"
|
|
36047
|
+
},
|
|
36048
|
+
{
|
|
36049
|
+
key: "actual",
|
|
36050
|
+
label: "Actual",
|
|
36051
|
+
account_type: "revenue",
|
|
36052
|
+
format: {
|
|
36053
|
+
fn: "currency",
|
|
36054
|
+
opts: {
|
|
36055
|
+
compact: true
|
|
36056
|
+
}
|
|
36057
|
+
}
|
|
36058
|
+
},
|
|
36059
|
+
{
|
|
36060
|
+
key: "budget",
|
|
36061
|
+
label: "Budget",
|
|
36062
|
+
account_type: "revenue",
|
|
36063
|
+
format: {
|
|
36064
|
+
fn: "currency",
|
|
36065
|
+
opts: {
|
|
36066
|
+
compact: true
|
|
36067
|
+
}
|
|
36068
|
+
}
|
|
36069
|
+
}
|
|
36070
|
+
],
|
|
36071
|
+
rows: [
|
|
36072
|
+
{
|
|
36073
|
+
period: "2026-01",
|
|
36074
|
+
actual: -98e4,
|
|
36075
|
+
budget: -1e6
|
|
36076
|
+
},
|
|
36077
|
+
{
|
|
36078
|
+
period: "2026-02",
|
|
36079
|
+
actual: -101e4,
|
|
36080
|
+
budget: -1e6
|
|
36081
|
+
},
|
|
36082
|
+
{
|
|
36083
|
+
period: "2026-03",
|
|
36084
|
+
actual: -112e4,
|
|
36085
|
+
budget: -1e6
|
|
36086
|
+
}
|
|
36087
|
+
],
|
|
36088
|
+
totals: {
|
|
36089
|
+
period: "Total",
|
|
36090
|
+
actual: -311e4,
|
|
36091
|
+
budget: -3e6
|
|
36092
|
+
},
|
|
36093
|
+
page: {
|
|
36094
|
+
offset: 0,
|
|
36095
|
+
limit: 200,
|
|
36096
|
+
total: 3
|
|
36097
|
+
},
|
|
36098
|
+
meta: {
|
|
36099
|
+
v: 1,
|
|
36100
|
+
source: {
|
|
36101
|
+
kind: "table",
|
|
36102
|
+
table_id: "7",
|
|
36103
|
+
table_alias: "gl",
|
|
36104
|
+
table_name: "GL",
|
|
36105
|
+
measure: {
|
|
36106
|
+
field: "net_balance_usd",
|
|
36107
|
+
agg: "SUM"
|
|
36108
|
+
},
|
|
36109
|
+
url: null,
|
|
36110
|
+
read: "aggregate",
|
|
36111
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36112
|
+
query: {
|
|
36113
|
+
call: "get_aliased_aggregated_data_with_polling",
|
|
36114
|
+
table_alias: "gl",
|
|
36115
|
+
dimensions: [
|
|
36116
|
+
"period",
|
|
36117
|
+
"scenario"
|
|
36118
|
+
],
|
|
36119
|
+
metrics: [
|
|
36120
|
+
{
|
|
36121
|
+
field: "net_balance_usd",
|
|
36122
|
+
agg: "SUM"
|
|
36123
|
+
}
|
|
36124
|
+
],
|
|
36125
|
+
filters: [
|
|
36126
|
+
{
|
|
36127
|
+
name: "type",
|
|
36128
|
+
values: [
|
|
36129
|
+
"Revenue"
|
|
36130
|
+
]
|
|
36131
|
+
},
|
|
36132
|
+
{
|
|
36133
|
+
name: "Entity",
|
|
36134
|
+
values: [
|
|
36135
|
+
"NCM-US"
|
|
36136
|
+
]
|
|
36137
|
+
}
|
|
36138
|
+
],
|
|
36139
|
+
period_field: "period",
|
|
36140
|
+
period_is_date: false,
|
|
36141
|
+
select: null,
|
|
36142
|
+
limit: null,
|
|
36143
|
+
offset: null
|
|
36144
|
+
}
|
|
36145
|
+
},
|
|
36146
|
+
account_type: "revenue",
|
|
36147
|
+
unit: "currency",
|
|
36148
|
+
filters_applied: {
|
|
36149
|
+
period: {
|
|
36150
|
+
start: "2026-01-01",
|
|
36151
|
+
end: "2026-09-16",
|
|
36152
|
+
grain: "month"
|
|
36153
|
+
},
|
|
36154
|
+
scenario: [
|
|
36155
|
+
"Actuals"
|
|
36156
|
+
],
|
|
36157
|
+
dimensions: {
|
|
36158
|
+
Entity: [
|
|
36159
|
+
"NCM-US"
|
|
36160
|
+
]
|
|
36161
|
+
}
|
|
36162
|
+
},
|
|
36163
|
+
filters_ignored: [],
|
|
36164
|
+
params_applied: {},
|
|
36165
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36166
|
+
row_count: 9,
|
|
36167
|
+
reads: 1,
|
|
36168
|
+
drill: {
|
|
36169
|
+
dimensions: [
|
|
36170
|
+
"entity"
|
|
36171
|
+
],
|
|
36172
|
+
op: "drill",
|
|
36173
|
+
widget: "ledger"
|
|
36174
|
+
}
|
|
36175
|
+
}
|
|
36176
|
+
};
|
|
36177
|
+
|
|
36178
|
+
// ../tests/vendor/fixtures/widgets/narrative.json
|
|
36179
|
+
var narrative_default = {
|
|
36180
|
+
kind: "narrative",
|
|
36181
|
+
mode: "computed",
|
|
36182
|
+
tag: "watch",
|
|
36183
|
+
headline: "Revenue is 12.5% below last month",
|
|
36184
|
+
sections: [
|
|
36185
|
+
{
|
|
36186
|
+
label: "What happened",
|
|
36187
|
+
text: "Revenue fell to",
|
|
36188
|
+
cites: [
|
|
36189
|
+
{
|
|
36190
|
+
widget: "rev",
|
|
36191
|
+
period: "2026-08 \u2192 2026-09",
|
|
36192
|
+
value: null
|
|
36193
|
+
}
|
|
36194
|
+
]
|
|
36195
|
+
},
|
|
36196
|
+
{
|
|
36197
|
+
label: "Figure",
|
|
36198
|
+
text: -1275e3,
|
|
36199
|
+
figure: {
|
|
36200
|
+
widget: "rev",
|
|
36201
|
+
period: "2026-09",
|
|
36202
|
+
dimension: null,
|
|
36203
|
+
of: null,
|
|
36204
|
+
value: -1275e3
|
|
36205
|
+
}
|
|
36206
|
+
},
|
|
36207
|
+
{
|
|
36208
|
+
label: "Why it matters",
|
|
36209
|
+
text: "The drop is concentrated in NCM-US."
|
|
36210
|
+
},
|
|
36211
|
+
{
|
|
36212
|
+
label: "Investigate",
|
|
36213
|
+
text: "Drill Entity \u2192 Account for August."
|
|
36214
|
+
}
|
|
36215
|
+
],
|
|
36216
|
+
about: [
|
|
36217
|
+
"rev",
|
|
36218
|
+
"rev_ytd"
|
|
36219
|
+
],
|
|
36220
|
+
prompt: null,
|
|
36221
|
+
meta: {
|
|
36222
|
+
v: 1,
|
|
36223
|
+
source: {
|
|
36224
|
+
kind: "metric",
|
|
36225
|
+
metric_id: 42,
|
|
36226
|
+
metric_name: "Revenue",
|
|
36227
|
+
url: null,
|
|
36228
|
+
read: "points",
|
|
36229
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36230
|
+
query: {
|
|
36231
|
+
call: "metric_series",
|
|
36232
|
+
metric_id: 42,
|
|
36233
|
+
scenarios: [
|
|
36234
|
+
"Actuals"
|
|
36235
|
+
],
|
|
36236
|
+
scenario: null,
|
|
36237
|
+
date_start: "2026-01-01",
|
|
36238
|
+
date_end: "2026-09-16",
|
|
36239
|
+
aggregation_period: "month",
|
|
36240
|
+
aggregation_type: null,
|
|
36241
|
+
dimension_filters: {
|
|
36242
|
+
Entity: [
|
|
36243
|
+
"NCM-US"
|
|
36244
|
+
]
|
|
36245
|
+
}
|
|
36246
|
+
}
|
|
36247
|
+
},
|
|
36248
|
+
account_type: "revenue",
|
|
36249
|
+
unit: "currency",
|
|
36250
|
+
filters_applied: {
|
|
36251
|
+
period: {
|
|
36252
|
+
start: "2026-01-01",
|
|
36253
|
+
end: "2026-09-16",
|
|
36254
|
+
grain: "month"
|
|
36255
|
+
},
|
|
36256
|
+
scenario: [
|
|
36257
|
+
"Actuals"
|
|
36258
|
+
],
|
|
36259
|
+
dimensions: {
|
|
36260
|
+
Entity: [
|
|
36261
|
+
"NCM-US"
|
|
36262
|
+
]
|
|
36263
|
+
}
|
|
36264
|
+
},
|
|
36265
|
+
filters_ignored: [],
|
|
36266
|
+
params_applied: {},
|
|
36267
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36268
|
+
row_count: 9,
|
|
36269
|
+
reads: 1,
|
|
36270
|
+
builders: {
|
|
36271
|
+
narrate: "_narrate"
|
|
36272
|
+
}
|
|
36273
|
+
}
|
|
36274
|
+
};
|
|
36275
|
+
|
|
36276
|
+
// ../tests/vendor/fixtures/widgets/narrative-agent.json
|
|
36277
|
+
var narrative_agent_default = {
|
|
36278
|
+
kind: "narrative",
|
|
36279
|
+
mode: "agent",
|
|
36280
|
+
tag: null,
|
|
36281
|
+
headline: null,
|
|
36282
|
+
sections: [],
|
|
36283
|
+
about: [
|
|
36284
|
+
"rev",
|
|
36285
|
+
"rev_ytd"
|
|
36286
|
+
],
|
|
36287
|
+
prompt: "Summarise revenue against budget for the selected period, in three sentences.",
|
|
36288
|
+
meta: {
|
|
36289
|
+
v: 1,
|
|
36290
|
+
source: {
|
|
36291
|
+
kind: "metric",
|
|
36292
|
+
metric_id: 42,
|
|
36293
|
+
metric_name: "Revenue",
|
|
36294
|
+
url: null,
|
|
36295
|
+
read: null,
|
|
36296
|
+
fetched_at: null,
|
|
36297
|
+
query: null
|
|
36298
|
+
},
|
|
36299
|
+
account_type: "revenue",
|
|
36300
|
+
unit: "currency",
|
|
36301
|
+
filters_applied: {
|
|
36302
|
+
period: {
|
|
36303
|
+
start: "2026-01-01",
|
|
36304
|
+
end: "2026-09-16",
|
|
36305
|
+
grain: "month"
|
|
36306
|
+
},
|
|
36307
|
+
scenario: [
|
|
36308
|
+
"Actuals"
|
|
36309
|
+
],
|
|
36310
|
+
dimensions: {
|
|
36311
|
+
Entity: [
|
|
36312
|
+
"NCM-US"
|
|
36313
|
+
]
|
|
36314
|
+
}
|
|
36315
|
+
},
|
|
36316
|
+
filters_ignored: [],
|
|
36317
|
+
params_applied: {},
|
|
36318
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36319
|
+
row_count: 0,
|
|
36320
|
+
reads: 0
|
|
36321
|
+
}
|
|
36322
|
+
};
|
|
36323
|
+
|
|
36324
|
+
// ../tests/vendor/fixtures/widgets/ohlc.json
|
|
36325
|
+
var ohlc_default = {
|
|
36326
|
+
kind: "ohlc",
|
|
36327
|
+
x: {
|
|
36328
|
+
type: "period",
|
|
36329
|
+
grain: "month",
|
|
36330
|
+
values: [
|
|
36331
|
+
"2026-01",
|
|
36332
|
+
"2026-02",
|
|
36333
|
+
"2026-03",
|
|
36334
|
+
"2026-04"
|
|
36335
|
+
]
|
|
36336
|
+
},
|
|
36337
|
+
candles: [
|
|
36338
|
+
[
|
|
36339
|
+
100,
|
|
36340
|
+
104.5,
|
|
36341
|
+
98.2,
|
|
36342
|
+
106
|
|
36343
|
+
],
|
|
36344
|
+
[
|
|
36345
|
+
104.5,
|
|
36346
|
+
101,
|
|
36347
|
+
99.5,
|
|
36348
|
+
107.2
|
|
36349
|
+
],
|
|
36350
|
+
[
|
|
36351
|
+
101,
|
|
36352
|
+
108.3,
|
|
36353
|
+
100.4,
|
|
36354
|
+
109
|
|
36355
|
+
],
|
|
36356
|
+
[
|
|
36357
|
+
108.3,
|
|
36358
|
+
107.1,
|
|
36359
|
+
103,
|
|
36360
|
+
110.5
|
|
36361
|
+
]
|
|
36362
|
+
],
|
|
36363
|
+
volume: [
|
|
36364
|
+
1200,
|
|
36365
|
+
980,
|
|
36366
|
+
1430,
|
|
36367
|
+
1110
|
|
36368
|
+
],
|
|
36369
|
+
meta: {
|
|
36370
|
+
v: 1,
|
|
36371
|
+
source: {
|
|
36372
|
+
kind: "table",
|
|
36373
|
+
table_id: "12",
|
|
36374
|
+
table_alias: "fx_rates",
|
|
36375
|
+
table_name: "FX Rates",
|
|
36376
|
+
measure: {
|
|
36377
|
+
field: "rate",
|
|
36378
|
+
agg: "OHLC"
|
|
36379
|
+
},
|
|
36380
|
+
url: null,
|
|
36381
|
+
read: "raw",
|
|
36382
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36383
|
+
query: {
|
|
36384
|
+
call: "get_aliased_table_data",
|
|
36385
|
+
table_alias: "fx_rates",
|
|
36386
|
+
dimensions: null,
|
|
36387
|
+
metrics: null,
|
|
36388
|
+
filters: [
|
|
36389
|
+
{
|
|
36390
|
+
name: "Entity",
|
|
36391
|
+
values: [
|
|
36392
|
+
"NCM-US"
|
|
36393
|
+
]
|
|
36394
|
+
}
|
|
36395
|
+
],
|
|
36396
|
+
period_field: "period",
|
|
36397
|
+
period_is_date: false,
|
|
36398
|
+
select: [
|
|
36399
|
+
"period",
|
|
36400
|
+
"rate_open",
|
|
36401
|
+
"rate_close",
|
|
36402
|
+
"rate_low",
|
|
36403
|
+
"rate_high",
|
|
36404
|
+
"volume"
|
|
36405
|
+
],
|
|
36406
|
+
limit: 200,
|
|
36407
|
+
offset: 0
|
|
36408
|
+
}
|
|
36409
|
+
},
|
|
36410
|
+
account_type: null,
|
|
36411
|
+
unit: null,
|
|
36412
|
+
filters_applied: {
|
|
36413
|
+
period: {
|
|
36414
|
+
start: "2026-01-01",
|
|
36415
|
+
end: "2026-09-16",
|
|
36416
|
+
grain: "month"
|
|
36417
|
+
},
|
|
36418
|
+
scenario: [
|
|
36419
|
+
"Actuals"
|
|
36420
|
+
],
|
|
36421
|
+
dimensions: {
|
|
36422
|
+
Entity: [
|
|
36423
|
+
"NCM-US"
|
|
36424
|
+
]
|
|
36425
|
+
}
|
|
36426
|
+
},
|
|
36427
|
+
filters_ignored: [],
|
|
36428
|
+
params_applied: {},
|
|
36429
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36430
|
+
row_count: 9,
|
|
36431
|
+
reads: 1
|
|
36432
|
+
}
|
|
36433
|
+
};
|
|
36434
|
+
|
|
36435
|
+
// ../tests/vendor/fixtures/widgets/scatter.json
|
|
36436
|
+
var scatter_default = {
|
|
36437
|
+
kind: "scatter",
|
|
36438
|
+
axes: {
|
|
36439
|
+
x: {
|
|
36440
|
+
label: "Spend",
|
|
36441
|
+
unit: "currency"
|
|
36442
|
+
},
|
|
36443
|
+
y: {
|
|
36444
|
+
label: "Revenue",
|
|
36445
|
+
unit: "currency"
|
|
36446
|
+
},
|
|
36447
|
+
size: {
|
|
36448
|
+
label: "Headcount",
|
|
36449
|
+
unit: "count"
|
|
36450
|
+
}
|
|
36451
|
+
},
|
|
36452
|
+
points: [
|
|
36453
|
+
{
|
|
36454
|
+
label: "NCM-US",
|
|
36455
|
+
x: 42e4,
|
|
36456
|
+
y: -12e5,
|
|
36457
|
+
size: 48,
|
|
36458
|
+
group: "Americas"
|
|
36459
|
+
},
|
|
36460
|
+
{
|
|
36461
|
+
label: "NCM-UK",
|
|
36462
|
+
x: 19e4,
|
|
36463
|
+
y: -51e4,
|
|
36464
|
+
size: 21,
|
|
36465
|
+
group: "EMEA"
|
|
36466
|
+
},
|
|
36467
|
+
{
|
|
36468
|
+
label: "NCM-IL",
|
|
36469
|
+
x: 95e3,
|
|
36470
|
+
y: -225e3,
|
|
36471
|
+
size: 12,
|
|
36472
|
+
group: "EMEA"
|
|
36473
|
+
}
|
|
36474
|
+
],
|
|
36475
|
+
meta: {
|
|
36476
|
+
v: 1,
|
|
36477
|
+
source: {
|
|
36478
|
+
kind: "metric",
|
|
36479
|
+
metric_id: 42,
|
|
36480
|
+
metric_name: "Revenue",
|
|
36481
|
+
url: null,
|
|
36482
|
+
read: "rows",
|
|
36483
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36484
|
+
query: {
|
|
36485
|
+
call: "drill_down_business_metric",
|
|
36486
|
+
metric_ids: [
|
|
36487
|
+
42
|
|
36488
|
+
],
|
|
36489
|
+
date_start: "2026-01-01",
|
|
36490
|
+
date_end: "2026-09-16",
|
|
36491
|
+
dimension_filters: {
|
|
36492
|
+
Entity: [
|
|
36493
|
+
"NCM-US"
|
|
36494
|
+
]
|
|
36495
|
+
}
|
|
36496
|
+
}
|
|
36497
|
+
},
|
|
36498
|
+
account_type: "revenue",
|
|
36499
|
+
unit: "currency",
|
|
36500
|
+
filters_applied: {
|
|
36501
|
+
period: {
|
|
36502
|
+
start: "2026-01-01",
|
|
36503
|
+
end: "2026-09-16",
|
|
36504
|
+
grain: "month"
|
|
36505
|
+
},
|
|
36506
|
+
scenario: [
|
|
36507
|
+
"Actuals"
|
|
36508
|
+
],
|
|
36509
|
+
dimensions: {
|
|
36510
|
+
Entity: [
|
|
36511
|
+
"NCM-US"
|
|
36512
|
+
]
|
|
36513
|
+
}
|
|
36514
|
+
},
|
|
36515
|
+
filters_ignored: [],
|
|
36516
|
+
params_applied: {},
|
|
36517
|
+
fetched_at: "2026-09-16T14:02:11Z",
|
|
36518
|
+
row_count: 3,
|
|
36519
|
+
reads: 1,
|
|
36520
|
+
drill: {
|
|
36521
|
+
dimensions: [
|
|
36522
|
+
"Entity"
|
|
36523
|
+
],
|
|
36524
|
+
op: "drill",
|
|
36525
|
+
widget: "spend_vs_rev"
|
|
36526
|
+
}
|
|
36527
|
+
}
|
|
36528
|
+
};
|
|
36529
|
+
|
|
36530
|
+
// ../tests/vendor/fixtures/widgets/catalog-response.json
|
|
36531
|
+
var catalog_response_default = {
|
|
36532
|
+
v: 1,
|
|
36533
|
+
dimensions: [
|
|
36534
|
+
{
|
|
36535
|
+
name: "Entity",
|
|
36536
|
+
values: [
|
|
36537
|
+
"NCM-US",
|
|
36538
|
+
"NCM-UK",
|
|
36539
|
+
"NCM-IL"
|
|
36540
|
+
],
|
|
36541
|
+
truncated: false
|
|
36542
|
+
},
|
|
36543
|
+
{
|
|
36544
|
+
name: "Account",
|
|
36545
|
+
values: [
|
|
36546
|
+
"4000 Sales",
|
|
36547
|
+
"4100 Services"
|
|
36548
|
+
],
|
|
36549
|
+
truncated: false
|
|
36550
|
+
}
|
|
36551
|
+
],
|
|
36552
|
+
scenarios: [
|
|
36553
|
+
"Actuals",
|
|
36554
|
+
"Budget"
|
|
36555
|
+
],
|
|
36556
|
+
period: {
|
|
36557
|
+
min: "2024-01",
|
|
36558
|
+
max: "2026-09"
|
|
36559
|
+
}
|
|
36560
|
+
};
|
|
36561
|
+
|
|
36562
|
+
// src/commands/appspace/_samples.ts
|
|
36563
|
+
var TEMPLATES = {
|
|
36564
|
+
series: series_default,
|
|
36565
|
+
breakdown: breakdown_default,
|
|
36566
|
+
kpi: kpi_default,
|
|
36567
|
+
table: table_default,
|
|
36568
|
+
ohlc: ohlc_default,
|
|
36569
|
+
scatter: scatter_default,
|
|
36570
|
+
narrative: narrative_default
|
|
36571
|
+
};
|
|
36572
|
+
var KIND_READS5 = {
|
|
36573
|
+
line: "series",
|
|
36574
|
+
area: "series",
|
|
36575
|
+
bar: "series",
|
|
36576
|
+
stacked: "series",
|
|
36577
|
+
// dr-app-widgets' finance kinds (`src/kinds/index.ts` VARIANTS), first read;
|
|
36578
|
+
// a walkthrough is the bridge month by month, which a series draws.
|
|
36579
|
+
waterfall: "breakdown",
|
|
36580
|
+
"waterfall-breakdown": "breakdown",
|
|
36581
|
+
"waterfall-walkthrough": "series",
|
|
36582
|
+
heatmap: "series",
|
|
36583
|
+
combo: "series",
|
|
36584
|
+
"stacked-percent": "series",
|
|
36585
|
+
gauge: "kpi",
|
|
36586
|
+
pie: "breakdown",
|
|
36587
|
+
donut: "breakdown",
|
|
36588
|
+
hbar: "breakdown",
|
|
36589
|
+
kpi: "kpi",
|
|
36590
|
+
candle: "ohlc",
|
|
36591
|
+
bubble: "scatter",
|
|
36592
|
+
table: "table",
|
|
36593
|
+
narrative: "narrative"
|
|
36594
|
+
};
|
|
36595
|
+
function payloadKindOf(kind) {
|
|
36596
|
+
if (typeof kind !== "string" || kind === "") return null;
|
|
36597
|
+
if (Object.prototype.hasOwnProperty.call(TEMPLATES, kind)) return kind;
|
|
36598
|
+
return KIND_READS5[kind] ?? KIND_READS5[kind.split("-")[0]] ?? null;
|
|
36599
|
+
}
|
|
36600
|
+
var isObject8 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
36601
|
+
var text3 = (value) => typeof value === "string" && value.trim() !== "" ? value : null;
|
|
36602
|
+
function samplePlan(contract) {
|
|
36603
|
+
const plan = { dashboards: /* @__PURE__ */ new Map(), widgets: /* @__PURE__ */ new Map(), scenarios: [] };
|
|
36604
|
+
if (!isObject8(contract)) return plan;
|
|
36605
|
+
const data = isObject8(contract.data) ? contract.data : {};
|
|
36606
|
+
const declared = isObject8(data.widgets) ? data.widgets : {};
|
|
36607
|
+
const page = isObject8(data.page) ? data.page : {};
|
|
36608
|
+
plan.scenarios = Array.isArray(page.scenarios) ? page.scenarios.filter((s) => typeof s === "string") : [];
|
|
36609
|
+
const mounts = /* @__PURE__ */ new Set();
|
|
36610
|
+
for (const p of Array.isArray(contract.pages) ? contract.pages : []) {
|
|
36611
|
+
const handler = isObject8(p) && isObject8(p.mount) ? text3(p.mount.handler) : null;
|
|
36612
|
+
if (handler !== null) mounts.add(handler);
|
|
36613
|
+
}
|
|
36614
|
+
const elements = isObject8(contract.elements) ? contract.elements : {};
|
|
36615
|
+
const titles = /* @__PURE__ */ new Map();
|
|
36616
|
+
for (const el of Object.values(elements)) {
|
|
36617
|
+
if (!isObject8(el) || el.type !== "widget" || !isObject8(el.props)) continue;
|
|
36618
|
+
const frame2 = isObject8(el.card) ? el.card : {};
|
|
36619
|
+
const title = text3(frame2.title) ?? text3(el.props.title) ?? text3(el.props.label);
|
|
36620
|
+
const id = text3(el.props.card) ?? text3(el.props.id) ?? text3(el.id);
|
|
36621
|
+
if (title !== null && id !== null && !titles.has(id)) titles.set(id, title);
|
|
36622
|
+
}
|
|
36623
|
+
for (const handler of mounts) {
|
|
36624
|
+
const cards = /* @__PURE__ */ new Map();
|
|
36625
|
+
for (const [id, spec] of Object.entries(declared)) {
|
|
36626
|
+
if (!isObject8(spec)) continue;
|
|
36627
|
+
const kind = payloadKindOf(spec.kind);
|
|
36628
|
+
if (kind === null) continue;
|
|
36629
|
+
cards.set(id, { kind, title: titles.get(id) ?? null, accountType: text3(spec.account_type), agent: spec.mode === "agent" });
|
|
36630
|
+
}
|
|
36631
|
+
if (cards.size > 0) plan.dashboards.set(handler, cards);
|
|
36632
|
+
}
|
|
36633
|
+
for (const el of Object.values(elements)) {
|
|
36634
|
+
if (!isObject8(el) || el.type !== "widget" || !isObject8(el.props)) continue;
|
|
36635
|
+
const props = el.props;
|
|
36636
|
+
const source = text3(props.source);
|
|
36637
|
+
if (source === null || mounts.has(source) || plan.widgets.has(source)) continue;
|
|
36638
|
+
const kind = payloadKindOf(props.kind);
|
|
36639
|
+
if (kind === null) continue;
|
|
36640
|
+
const frame2 = isObject8(el.card) ? el.card : {};
|
|
36641
|
+
const title = text3(frame2.title) ?? text3(props.title) ?? text3(props.label);
|
|
36642
|
+
plan.widgets.set(source, { kind, title, accountType: text3(props.account_type), agent: false });
|
|
36643
|
+
}
|
|
36644
|
+
return plan;
|
|
36645
|
+
}
|
|
36646
|
+
function markupPlan(files) {
|
|
36647
|
+
const plan = { dashboards: /* @__PURE__ */ new Map(), widgets: /* @__PURE__ */ new Map(), scenarios: [] };
|
|
36648
|
+
let handler = null;
|
|
36649
|
+
const cards = /* @__PURE__ */ new Map();
|
|
36650
|
+
for (const [path3, body] of Object.entries(files)) {
|
|
36651
|
+
const source = body.toString();
|
|
36652
|
+
if (/\.m?js$/i.test(path3) || /\.html?$/i.test(path3)) {
|
|
36653
|
+
if (handler === null && /drWidgets\.mount\(/.test(source)) {
|
|
36654
|
+
const named13 = /\bhandler:\s*['"]([\w-]+)['"]/.exec(source);
|
|
36655
|
+
const constant = /\bhandler:\s*([A-Z_][A-Z0-9_]*)/.exec(source);
|
|
36656
|
+
const value = constant === null ? null : new RegExp(`\\b${constant[1]}\\s*=\\s*['"]([\\w-]+)['"]`).exec(source);
|
|
36657
|
+
handler = named13?.[1] ?? value?.[1] ?? null;
|
|
36658
|
+
}
|
|
36659
|
+
}
|
|
36660
|
+
if (!/\.html?$/i.test(path3)) continue;
|
|
36661
|
+
for (const tag of source.match(/<[a-z][^>]*\bdata-dr-widget="[^"]+"[^>]*>/gi) ?? []) {
|
|
36662
|
+
const attr3 = (name) => new RegExp(`\\b${name}="([^"]*)"`).exec(tag)?.[1] ?? null;
|
|
36663
|
+
const id = attr3("data-dr-widget");
|
|
36664
|
+
const kind = payloadKindOf(attr3("data-dr-widget-kind"));
|
|
36665
|
+
if (id === null || kind === null || cards.has(id)) continue;
|
|
36666
|
+
cards.set(id, { kind, title: attr3("data-dr-widget-title"), accountType: null, agent: false });
|
|
36667
|
+
}
|
|
36668
|
+
}
|
|
36669
|
+
if (handler !== null && cards.size > 0) plan.dashboards.set(handler, cards);
|
|
36670
|
+
return plan;
|
|
36671
|
+
}
|
|
36672
|
+
function scaleOf(seed) {
|
|
36673
|
+
let hash = 2166136261;
|
|
36674
|
+
for (let i = 0; i < seed.length; i++) {
|
|
36675
|
+
hash ^= seed.charCodeAt(i);
|
|
36676
|
+
hash = Math.imul(hash, 16777619) >>> 0;
|
|
36677
|
+
}
|
|
36678
|
+
return 0.6 + hash % 1e3 / 1e3;
|
|
36679
|
+
}
|
|
36680
|
+
var CREDIT = /* @__PURE__ */ new Set(["revenue", "income", "liability", "equity"]);
|
|
36681
|
+
var SIGNED = /^(value|values|spark|total|other_value|actual|budget|forecast|variance|text)$/;
|
|
36682
|
+
var UNSIGNED = /^(candles|volume|x|y|size)$/;
|
|
36683
|
+
function figures(value, factor, sign, key = "") {
|
|
36684
|
+
if (typeof value === "number") {
|
|
36685
|
+
if (UNSIGNED.test(key)) return Math.round(value * factor);
|
|
36686
|
+
if (!SIGNED.test(key)) return value;
|
|
36687
|
+
const scaled = Math.round(value * factor);
|
|
36688
|
+
return sign === null ? scaled : sign * Math.abs(scaled);
|
|
36689
|
+
}
|
|
36690
|
+
if (Array.isArray(value)) {
|
|
36691
|
+
const filled = value.map((item, i) => {
|
|
36692
|
+
if (item !== null || !/^(values|spark)$/.test(key)) return item;
|
|
36693
|
+
const near = [value[i - 1], value[i + 1]].filter((n) => typeof n === "number");
|
|
36694
|
+
return near.length === 0 ? item : near.reduce((a, b) => a + b, 0) / near.length;
|
|
36695
|
+
});
|
|
36696
|
+
return filled.map((item) => figures(item, factor, sign, key));
|
|
36697
|
+
}
|
|
36698
|
+
if (isObject8(value)) {
|
|
36699
|
+
return Object.fromEntries(
|
|
36700
|
+
Object.entries(value).map(([k, v]) => [k, k === "meta" || k === "delta" || k === "share" ? v : figures(v, factor, sign, k)])
|
|
36701
|
+
);
|
|
36702
|
+
}
|
|
36703
|
+
return value;
|
|
36704
|
+
}
|
|
36705
|
+
function samplePayload(id, card) {
|
|
36706
|
+
const template = card.kind === "narrative" && card.agent ? narrative_agent_default : TEMPLATES[card.kind];
|
|
36707
|
+
const copy = JSON.parse(JSON.stringify(template));
|
|
36708
|
+
const sign = card.accountType === null ? null : CREDIT.has(card.accountType) ? -1 : 1;
|
|
36709
|
+
const out = figures(copy, scaleOf(id), sign);
|
|
36710
|
+
if (card.accountType !== null) {
|
|
36711
|
+
if ("account_type" in out) out.account_type = card.accountType;
|
|
36712
|
+
if (isObject8(out.meta) && "account_type" in out.meta) out.meta = { ...out.meta, account_type: card.accountType };
|
|
36713
|
+
for (const series of Array.isArray(out.series) ? out.series : []) {
|
|
36714
|
+
if (isObject8(series) && "account_type" in series) series.account_type = card.accountType;
|
|
36715
|
+
}
|
|
36716
|
+
for (const column of Array.isArray(out.columns) ? out.columns : []) {
|
|
36717
|
+
if (isObject8(column) && "account_type" in column) column.account_type = card.accountType;
|
|
36718
|
+
}
|
|
36719
|
+
}
|
|
36720
|
+
if (card.kind === "kpi" && card.title !== null) out.label = card.title;
|
|
36721
|
+
if (isObject8(out.meta)) {
|
|
36722
|
+
out.meta = { ...out.meta, filters_ignored: [] };
|
|
36723
|
+
}
|
|
36724
|
+
return out;
|
|
36725
|
+
}
|
|
36726
|
+
function sampleCatalog(plan) {
|
|
36727
|
+
const catalog = JSON.parse(JSON.stringify(catalog_response_default));
|
|
36728
|
+
if (plan.scenarios.length > 0) catalog.scenarios = [...plan.scenarios];
|
|
36729
|
+
return catalog;
|
|
36730
|
+
}
|
|
36731
|
+
function sampleAnswer(plan, handler, body) {
|
|
36732
|
+
const cards = plan.dashboards.get(handler);
|
|
36733
|
+
if (cards !== void 0) {
|
|
36734
|
+
const op = isObject8(body) ? body.op : void 0;
|
|
36735
|
+
if (op === "catalog") return sampleCatalog(plan);
|
|
36736
|
+
if (op !== "load" || !isObject8(body)) return void 0;
|
|
36737
|
+
const asked = Array.isArray(body.widgets) ? body.widgets.filter((w) => typeof w === "string") : [];
|
|
36738
|
+
const widgets = {};
|
|
36739
|
+
for (const id of asked) {
|
|
36740
|
+
const card2 = cards.get(id);
|
|
36741
|
+
if (card2 !== void 0) widgets[id] = samplePayload(id, card2);
|
|
36742
|
+
}
|
|
36743
|
+
return { v: 1, widgets, filters_applied: isObject8(body.filters) ? body.filters : {}, fetched_at: "2026-09-30T09:00:00Z" };
|
|
36744
|
+
}
|
|
36745
|
+
const card = plan.widgets.get(handler);
|
|
36746
|
+
return card === void 0 ? void 0 : samplePayload(handler, card);
|
|
36747
|
+
}
|
|
36748
|
+
|
|
36749
|
+
// src/commands/appspace/_screenshot.ts
|
|
35676
36750
|
var SHOT_TIMEOUT_MS = 6e4;
|
|
35677
36751
|
var SHOT_BUDGET_MS = 18e4;
|
|
35678
36752
|
var SHOT_CONCURRENCY = 4;
|
|
@@ -35690,7 +36764,10 @@ var CHROME_APP_PATHS = [
|
|
|
35690
36764
|
"/usr/bin/google-chrome",
|
|
35691
36765
|
"/usr/bin/google-chrome-stable",
|
|
35692
36766
|
"/usr/bin/chromium",
|
|
35693
|
-
"/usr/bin/chromium-browser"
|
|
36767
|
+
"/usr/bin/chromium-browser",
|
|
36768
|
+
// The managed build sandbox (DEV-1, checked 2026-10-29): Playwright's
|
|
36769
|
+
// Chromium, linked here, with nothing on PATH.
|
|
36770
|
+
"/opt/google/chrome/chrome"
|
|
35694
36771
|
];
|
|
35695
36772
|
var CHROME_NAMES = ["google-chrome", "chromium", "chrome"];
|
|
35696
36773
|
function isFile(path3) {
|
|
@@ -35834,6 +36911,19 @@ function fixtureAnswers(cases) {
|
|
|
35834
36911
|
}
|
|
35835
36912
|
return out;
|
|
35836
36913
|
}
|
|
36914
|
+
function pageContract(files, pages) {
|
|
36915
|
+
for (const entry of [...pages, ...Object.keys(files).filter((path3) => !pages.includes(path3))]) {
|
|
36916
|
+
const body = files[entry];
|
|
36917
|
+
if (body === void 0 || !/\.html?$/i.test(entry)) continue;
|
|
36918
|
+
const block = contractBlockText(body.toString());
|
|
36919
|
+
if (block === null) continue;
|
|
36920
|
+
try {
|
|
36921
|
+
return JSON.parse(block);
|
|
36922
|
+
} catch {
|
|
36923
|
+
}
|
|
36924
|
+
}
|
|
36925
|
+
return null;
|
|
36926
|
+
}
|
|
35837
36927
|
var TYPES = {
|
|
35838
36928
|
".html": "text/html; charset=utf-8",
|
|
35839
36929
|
".htm": "text/html; charset=utf-8",
|
|
@@ -35912,7 +37002,7 @@ var Shelf = class {
|
|
|
35912
37002
|
}
|
|
35913
37003
|
};
|
|
35914
37004
|
var MEASURE_BODY = 'var d=document.documentElement,b=document.body||d,extra=0;document.querySelectorAll("*").forEach(function(e){var s=getComputedStyle(e).overflowY;if((s==="auto"||s==="scroll")&&e.scrollHeight>e.clientHeight)extra=Math.max(extra,e.scrollHeight-e.clientHeight)});var h=Math.max(d.scrollHeight,b.scrollHeight,innerHeight+extra);var m=document.createElement("meta");m.id="dr-shot-height";m.content=String(h);document.head.appendChild(m);';
|
|
35915
|
-
var LOOK_BODY = 'var R=[],vw=innerWidth,D=document.documentElement,N={};function nth(k){N[k]=(N[k]||0)+1;return N[k]}function tx(e){return (e.innerText||e.textContent||"").trim().replace(/\\s+/g," ").slice(0,80)}function vis(e){var r=e.getBoundingClientRect(),s=getComputedStyle(e);return r.width>0&&r.height>0&&s.visibility!=="hidden"&&s.display!=="none"}function own(e){return [].some.call(e.childNodes,function(n){return n.nodeType===3&&n.textContent.trim()!==""})}function ownW(e){var r=e.getBoundingClientRect(),x=r.left+e.clientLeft,m=0;[].forEach.call(e.childNodes,function(n){if(n.nodeType!==3||n.textContent.trim()==="")return;var g=document.createRange();g.selectNodeContents(n);m=Math.max(m,g.getBoundingClientRect().right-x)});return Math.ceil(m)}function rgb(c){var m=/rgba?\\(([^)]+)\\)/.exec(c);if(!m)return null;var p=m[1].split(/[\\s,\\/]+/).filter(Boolean).map(Number);return p.length>=3&&p.slice(0,3).every(isFinite)?[p[0],p[1],p[2],p.length>3&&isFinite(p[3])?p[3]:1]:null}function lum(c){return [c[0],c[1],c[2]].map(function(v){v/=255;return v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4)}).reduce(function(a,v,i){return a+v*[.2126,.7152,.0722][i]},0)}function bgOf(e){for(var p=e;p&&p.nodeType===1;p=p.parentElement){var s=getComputedStyle(p);if(s.backgroundImage!=="none")return null;var c=rgb(s.backgroundColor);if(c&&c[3]>=1)return c}return [255,255,255,1]}var all=[].filter.call(document.querySelectorAll("body *"),vis),pairs={};all.forEach(function(e){if(!own(e))return;var s=getComputedStyle(e);if(e.clientWidth>2&&e.clientHeight>2){var need=e.children.length===0?e.scrollWidth:ownW(e);if(need>e.clientWidth+1&&(s.textOverflow==="ellipsis"||s.overflowX==="hidden"||s.overflowX==="clip"))R.push({rule:"text-clipped",text:tx(e),n:nth("c|"+tx(e)),shown:e.clientWidth,needs:need});else if(s.webkitLineClamp&&s.webkitLineClamp!=="none"&&e.scrollHeight>e.clientHeight+1)R.push({rule:"text-clipped",text:tx(e),n:nth("c|"+tx(e)),shown:e.clientHeight,needs:e.scrollHeight,lines:true})}var f=rgb(s.color),b=bgOf(e);if(!f||!b)return;var a=f[3],fc=[f[0]*a+b[0]*(1-a),f[1]*a+b[1]*(1-a),f[2]*a+b[2]*(1-a)],L1=lum(fc),L2=lum(b),cr=(Math.max(L1,L2)+.05)/(Math.min(L1,L2)+.05),px=parseFloat(s.fontSize),big=px>=24||(px>=18.66&&Number(s.fontWeight)>=700);if(cr<(big?3:4.5)){var k=s.color+"|"+b.join(",");if(pairs[k])pairs[k].count++;else{pairs[k]={rule:"low-contrast",text:tx(e),ratio:Math.round(cr*100)/100,color:s.color,background:"rgb("+b.slice(0,3).join(", ")+")",count:1};R.push(pairs[k])}}});if(D.scrollWidth>vw+1)R.push({rule:"page-overflow",text:"",right:D.scrollWidth,viewport:vw});var off=0;all.forEach(function(e){if(off>=5)return;var r=e.getBoundingClientRect(),s=getComputedStyle(e);if(r.right<=vw+1||s.position==="fixed")return;var p=e.parentElement;if(p&&p!==document.body&&p!==D&&p.getBoundingClientRect().right>vw+1)return;for(var q=p;q&&q!==document.body&&q!==D;q=q.parentElement){if(getComputedStyle(q).overflowX!=="visible")return}off++;R.push({rule:"page-overflow",text:tx(e),n:nth("o|"+tx(e)),right:Math.round(r.right),viewport:vw})});document.querySelectorAll(".dr-app-band").forEach(function(b){if(!vis(b))return;var cs=[].filter.call(b.querySelectorAll(".dr-app-cell"),function(c){return vis(c)&&c.closest(".dr-app-band")===b});var hd=b.querySelector(".dr-app-band-head"),name=hd?tx(hd):"";if(cs.length===0){if(hd)R.push({rule:"empty-band",band:name});return}if(cs.length<2)return;if((b.getAttribute("data-dr-layout")||"grid")==="grid"&&cs.reduce(function(a,c){return a+(Number(c.getAttribute("data-dr-span"))||12)},0)<12*' + String(BAND_FILL_MIN) + ")return;var top=cs[0].getBoundingClientRect().top;if(!cs.every(function(c){return Math.abs(c.getBoundingClientRect().top-top)<2}))return;var w=cs.reduce(function(a,c){return a+c.getBoundingClientRect().width},0),bw=b.getBoundingClientRect().width;if(bw>0&&w<bw*" + String(BAND_FILL_MIN) + ')R.push({rule:"band-underfilled",band:name,filled:Math.round(100*w/bw),tiles:cs.length,tileWidth:Math.round(cs[0].getBoundingClientRect().width),bandWidth:Math.round(bw)})});var lv=all.filter(function(e){return e.children.length===0&&own(e)}).slice(0,400);for(var i=0;i<lv.length;i++)for(var j=i+1;j<lv.length;j++){var x=lv[i].getBoundingClientRect(),y=lv[j].getBoundingClientRect();if(Math.min(x.right,y.right)-Math.max(x.left,y.left)>4&&Math.min(x.bottom,y.bottom)-Math.max(x.top,y.top)>4)R.push({rule:"text-overlap",a:tx(lv[i]),b:tx(lv[j])})}var lm=document.createElement("meta");lm.id="dr-shot-look";lm.content=encodeURIComponent(JSON.stringify(R));document.head.appendChild(lm);';
|
|
37005
|
+
var LOOK_BODY = 'var R=[],vw=innerWidth,D=document.documentElement,N={};function nth(k){N[k]=(N[k]||0)+1;return N[k]}function tx(e){return (e.innerText||e.textContent||"").trim().replace(/\\s+/g," ").slice(0,80)}function shown(e){for(var p=e;p&&p.nodeType===1;p=p.parentElement){if(getComputedStyle(p).opacity==="0")return false}return true}function vis(e){var r=e.getBoundingClientRect(),s=getComputedStyle(e);return r.width>0&&r.height>0&&s.visibility!=="hidden"&&s.display!=="none"&&shown(e)}function own(e){return [].some.call(e.childNodes,function(n){return n.nodeType===3&&n.textContent.trim()!==""})}function ownW(e){var r=e.getBoundingClientRect(),x=r.left+e.clientLeft,m=0;[].forEach.call(e.childNodes,function(n){if(n.nodeType!==3||n.textContent.trim()==="")return;var g=document.createRange();g.selectNodeContents(n);m=Math.max(m,g.getBoundingClientRect().right-x)});return Math.ceil(m)}function rgb(c){var m=/rgba?\\(([^)]+)\\)/.exec(c);if(!m)return null;var p=m[1].split(/[\\s,\\/]+/).filter(Boolean).map(Number);return p.length>=3&&p.slice(0,3).every(isFinite)?[p[0],p[1],p[2],p.length>3&&isFinite(p[3])?p[3]:1]:null}function lum(c){return [c[0],c[1],c[2]].map(function(v){v/=255;return v<=.03928?v/12.92:Math.pow((v+.055)/1.055,2.4)}).reduce(function(a,v,i){return a+v*[.2126,.7152,.0722][i]},0)}function bgOf(e){for(var p=e;p&&p.nodeType===1;p=p.parentElement){var s=getComputedStyle(p);if(s.backgroundImage!=="none")return null;var c=rgb(s.backgroundColor);if(c&&c[3]>=1)return c}return [255,255,255,1]}var all=[].filter.call(document.querySelectorAll("body *"),vis),pairs={};all.forEach(function(e){if(!own(e))return;var s=getComputedStyle(e);if(e.clientWidth>2&&e.clientHeight>2){var need=e.children.length===0?e.scrollWidth:ownW(e);if(need>e.clientWidth+1&&(s.textOverflow==="ellipsis"||s.overflowX==="hidden"||s.overflowX==="clip"))R.push({rule:"text-clipped",text:tx(e),n:nth("c|"+tx(e)),shown:e.clientWidth,needs:need});else if(s.webkitLineClamp&&s.webkitLineClamp!=="none"&&e.scrollHeight>e.clientHeight+1)R.push({rule:"text-clipped",text:tx(e),n:nth("c|"+tx(e)),shown:e.clientHeight,needs:e.scrollHeight,lines:true})}var f=rgb(s.color),b=bgOf(e);if(!f||!b)return;var a=f[3],fc=[f[0]*a+b[0]*(1-a),f[1]*a+b[1]*(1-a),f[2]*a+b[2]*(1-a)],L1=lum(fc),L2=lum(b),cr=(Math.max(L1,L2)+.05)/(Math.min(L1,L2)+.05),px=parseFloat(s.fontSize),big=px>=24||(px>=18.66&&Number(s.fontWeight)>=700);if(cr<(big?3:4.5)){var k=s.color+"|"+b.join(",");if(pairs[k])pairs[k].count++;else{pairs[k]={rule:"low-contrast",text:tx(e),ratio:Math.round(cr*100)/100,color:s.color,background:"rgb("+b.slice(0,3).join(", ")+")",count:1};R.push(pairs[k])}}});if(D.scrollWidth>vw+1)R.push({rule:"page-overflow",text:"",right:D.scrollWidth,viewport:vw});var off=0;all.forEach(function(e){if(off>=5)return;var r=e.getBoundingClientRect(),s=getComputedStyle(e);if(r.right<=vw+1||s.position==="fixed")return;var p=e.parentElement;if(p&&p!==document.body&&p!==D&&p.getBoundingClientRect().right>vw+1)return;for(var q=p;q&&q!==document.body&&q!==D;q=q.parentElement){if(getComputedStyle(q).overflowX!=="visible")return}off++;R.push({rule:"page-overflow",text:tx(e),n:nth("o|"+tx(e)),right:Math.round(r.right),viewport:vw})});document.querySelectorAll(".dr-app-band").forEach(function(b){if(!vis(b))return;var cs=[].filter.call(b.querySelectorAll(".dr-app-cell"),function(c){return vis(c)&&c.closest(".dr-app-band")===b});var hd=b.querySelector(".dr-app-band-head"),name=hd?tx(hd):"";if(cs.length===0){if(hd)R.push({rule:"empty-band",band:name});return}if(cs.length<2)return;if((b.getAttribute("data-dr-layout")||"grid")==="grid"&&cs.reduce(function(a,c){return a+(Number(c.getAttribute("data-dr-span"))||12)},0)<12*' + String(BAND_FILL_MIN) + ")return;var top=cs[0].getBoundingClientRect().top;if(!cs.every(function(c){return Math.abs(c.getBoundingClientRect().top-top)<2}))return;var w=cs.reduce(function(a,c){return a+c.getBoundingClientRect().width},0),bw=b.getBoundingClientRect().width;if(bw>0&&w<bw*" + String(BAND_FILL_MIN) + ')R.push({rule:"band-underfilled",band:name,filled:Math.round(100*w/bw),tiles:cs.length,tileWidth:Math.round(cs[0].getBoundingClientRect().width),bandWidth:Math.round(bw)})});var lv=all.filter(function(e){return e.children.length===0&&own(e)}).slice(0,400);for(var i=0;i<lv.length;i++)for(var j=i+1;j<lv.length;j++){var x=lv[i].getBoundingClientRect(),y=lv[j].getBoundingClientRect();if(Math.min(x.right,y.right)-Math.max(x.left,y.left)>4&&Math.min(x.bottom,y.bottom)-Math.max(x.top,y.top)>4)R.push({rule:"text-overlap",a:tx(lv[i]),b:tx(lv[j])})}var lm=document.createElement("meta");lm.id="dr-shot-look";lm.content=encodeURIComponent(JSON.stringify(R));document.head.appendChild(lm);';
|
|
35916
37006
|
function probeScript(shot) {
|
|
35917
37007
|
const body = (shot.measure === true ? MEASURE_BODY : "") + (shot.look === true ? LOOK_BODY : "");
|
|
35918
37008
|
return `<script>addEventListener("load",function(){setTimeout(function(){${body}},3000)})</script>`;
|
|
@@ -35945,6 +37035,26 @@ function send(res, status, type, body) {
|
|
|
35945
37035
|
function sendJson(res, status, value) {
|
|
35946
37036
|
send(res, status, "application/json", JSON.stringify(value));
|
|
35947
37037
|
}
|
|
37038
|
+
var BODY_MAX = 256 * 1024;
|
|
37039
|
+
function readBody(req) {
|
|
37040
|
+
return new Promise((done) => {
|
|
37041
|
+
const chunks = [];
|
|
37042
|
+
let size2 = 0;
|
|
37043
|
+
req.on("data", (chunk) => {
|
|
37044
|
+
size2 += chunk.length;
|
|
37045
|
+
if (size2 <= BODY_MAX) chunks.push(chunk);
|
|
37046
|
+
});
|
|
37047
|
+
req.on("end", () => {
|
|
37048
|
+
if (size2 > BODY_MAX) return done(null);
|
|
37049
|
+
try {
|
|
37050
|
+
done(JSON.parse(Buffer.concat(chunks).toString("utf8")));
|
|
37051
|
+
} catch {
|
|
37052
|
+
done(null);
|
|
37053
|
+
}
|
|
37054
|
+
});
|
|
37055
|
+
req.on("error", () => done(null));
|
|
37056
|
+
});
|
|
37057
|
+
}
|
|
35948
37058
|
function drain(req) {
|
|
35949
37059
|
return new Promise((done) => {
|
|
35950
37060
|
req.on("data", () => void 0);
|
|
@@ -35958,7 +37068,7 @@ async function startStubServer(opts) {
|
|
|
35958
37068
|
const logOf = (id) => {
|
|
35959
37069
|
let log = logs.get(id);
|
|
35960
37070
|
if (log === void 0) {
|
|
35961
|
-
log = { called: [], answered: [], noFixture: [], refused: [] };
|
|
37071
|
+
log = { called: [], answered: [], noFixture: [], sampled: [], refused: [] };
|
|
35962
37072
|
logs.set(id, log);
|
|
35963
37073
|
}
|
|
35964
37074
|
return log;
|
|
@@ -36007,8 +37117,11 @@ async function startStubServer(opts) {
|
|
|
36007
37117
|
return send(res, 200, type, body);
|
|
36008
37118
|
}
|
|
36009
37119
|
if (req.method === "POST" && /^[^/]+$/.test(inApp)) {
|
|
36010
|
-
|
|
36011
|
-
|
|
37120
|
+
if (inApp === "uploads") {
|
|
37121
|
+
await drain(req);
|
|
37122
|
+
return sendJson(res, 200, { upload: "screenshot-stub" });
|
|
37123
|
+
}
|
|
37124
|
+
const body = await readBody(req);
|
|
36012
37125
|
const log = logOf(id);
|
|
36013
37126
|
note(log.called, inApp);
|
|
36014
37127
|
const access = accessFor(opts.manifest, shot.role, opts.allowedByRole?.[shot.role], opts.sources ?? []);
|
|
@@ -36017,6 +37130,15 @@ async function startStubServer(opts) {
|
|
|
36017
37130
|
return sendJson(res, 403, { detail: `role ${shot.role} may not call ${inApp}` });
|
|
36018
37131
|
}
|
|
36019
37132
|
const answer = opts.answers.get(inApp);
|
|
37133
|
+
if (answer?.from === "expect") {
|
|
37134
|
+
note(log.answered, inApp);
|
|
37135
|
+
return sendJson(res, 200, answer.body);
|
|
37136
|
+
}
|
|
37137
|
+
const sample = opts.samples === void 0 ? void 0 : sampleAnswer(opts.samples, inApp, body);
|
|
37138
|
+
if (sample !== void 0) {
|
|
37139
|
+
note(log.sampled, inApp);
|
|
37140
|
+
return sendJson(res, 200, sample);
|
|
37141
|
+
}
|
|
36020
37142
|
if (answer === void 0) {
|
|
36021
37143
|
note(log.noFixture, inApp);
|
|
36022
37144
|
return sendJson(res, 200, []);
|
|
@@ -36046,7 +37168,13 @@ async function startStubServer(opts) {
|
|
|
36046
37168
|
},
|
|
36047
37169
|
calls: (id) => {
|
|
36048
37170
|
const log = logOf(id);
|
|
36049
|
-
return {
|
|
37171
|
+
return {
|
|
37172
|
+
called: [...log.called],
|
|
37173
|
+
answered: [...log.answered],
|
|
37174
|
+
noFixture: [...log.noFixture],
|
|
37175
|
+
sampled: [...log.sampled],
|
|
37176
|
+
refused: [...log.refused]
|
|
37177
|
+
};
|
|
36050
37178
|
},
|
|
36051
37179
|
close: () => new Promise((done) => {
|
|
36052
37180
|
server.closeAllConnections?.();
|
|
@@ -36066,9 +37194,15 @@ function killGroup(child) {
|
|
|
36066
37194
|
}
|
|
36067
37195
|
}
|
|
36068
37196
|
var sleep2 = (ms) => new Promise((done) => setTimeout(done, ms));
|
|
37197
|
+
function asRoot(getuid = process.getuid?.bind(process) ?? null) {
|
|
37198
|
+
return getuid !== null && getuid() === 0;
|
|
37199
|
+
}
|
|
36069
37200
|
async function runChrome(run) {
|
|
36070
37201
|
const profile = await mkdtemp4(join17(tmpdir5(), "dr-appspace-shot-"));
|
|
36071
37202
|
const args = [
|
|
37203
|
+
// Chrome will not start as root without it, and a container's shell is
|
|
37204
|
+
// root (the managed build sandbox). Elsewhere its own sandbox stays on.
|
|
37205
|
+
...asRoot() ? ["--no-sandbox"] : [],
|
|
36072
37206
|
"--headless=new",
|
|
36073
37207
|
"--disable-gpu",
|
|
36074
37208
|
"--hide-scrollbars",
|
|
@@ -36156,6 +37290,9 @@ async function runScreenshots(opts) {
|
|
|
36156
37290
|
const look = opts.look !== false;
|
|
36157
37291
|
await mkdir8(opts.outDir, { recursive: true });
|
|
36158
37292
|
const answers = fixtureAnswers(opts.cases);
|
|
37293
|
+
const sample = opts.sample !== false;
|
|
37294
|
+
const contract = sample ? pageContract(opts.files, opts.pages) : null;
|
|
37295
|
+
const samples = !sample ? void 0 : contract === null ? markupPlan(opts.files) : samplePlan(contract);
|
|
36159
37296
|
const shelf2 = new Shelf(opts.shelf, opts.fetchImpl);
|
|
36160
37297
|
const stub = await startStubServer({
|
|
36161
37298
|
appId: opts.appId,
|
|
@@ -36164,6 +37301,7 @@ async function runScreenshots(opts) {
|
|
|
36164
37301
|
...opts.allowedByRole === void 0 ? {} : { allowedByRole: opts.allowedByRole },
|
|
36165
37302
|
...opts.sources === void 0 ? {} : { sources: opts.sources },
|
|
36166
37303
|
answers,
|
|
37304
|
+
...samples === void 0 ? {} : { samples },
|
|
36167
37305
|
shelf: shelf2
|
|
36168
37306
|
});
|
|
36169
37307
|
const plan = [];
|
|
@@ -36271,6 +37409,7 @@ async function runScreenshots(opts) {
|
|
|
36271
37409
|
ms: now() - t0,
|
|
36272
37410
|
handlersStubbed: calls.answered,
|
|
36273
37411
|
handlersWithoutFixture: calls.noFixture,
|
|
37412
|
+
...sample ? { handlersSampled: calls.sampled } : {},
|
|
36274
37413
|
handlersRefused: calls.refused
|
|
36275
37414
|
};
|
|
36276
37415
|
if (!result.ok) {
|
|
@@ -36318,6 +37457,7 @@ async function runScreenshots(opts) {
|
|
|
36318
37457
|
createdAt: new Date(started).toISOString(),
|
|
36319
37458
|
ms: now() - started,
|
|
36320
37459
|
look,
|
|
37460
|
+
sample,
|
|
36321
37461
|
shots
|
|
36322
37462
|
};
|
|
36323
37463
|
await writeFile9(join17(opts.outDir, "index.json"), JSON.stringify(index, null, 2) + "\n");
|
|
@@ -36363,6 +37503,11 @@ screenshots \u2192 ${outDir} (${String(written)} of ${String(index.shots.length
|
|
|
36363
37503
|
out += line2(head);
|
|
36364
37504
|
for (const row of rows2) out += line2(row);
|
|
36365
37505
|
const noFixture = [...new Set(index.shots.flatMap((shot) => shot.handlersWithoutFixture))].sort();
|
|
37506
|
+
const sampled = [...new Set(index.shots.flatMap((shot) => shot.handlersSampled ?? []))].sort();
|
|
37507
|
+
if (sampled.length > 0) {
|
|
37508
|
+
out += ` sample data (not the tenant's figures): ${sampled.join(", ")}
|
|
37509
|
+
`;
|
|
37510
|
+
}
|
|
36366
37511
|
if (noFixture.length > 0) {
|
|
36367
37512
|
out += ` no tests.json fixture (answered []): ${noFixture.join(", ")}
|
|
36368
37513
|
`;
|
|
@@ -36784,18 +37929,18 @@ function unreadParams2(contract, { moduleSource = () => void 0, handlerSource =
|
|
|
36784
37929
|
} else if (handlers[one]?.role === "custom" && !custom.includes(one)) custom.push(one);
|
|
36785
37930
|
}
|
|
36786
37931
|
if (element?.type === "custom" && named12(props.module)) {
|
|
36787
|
-
const
|
|
36788
|
-
if (typeof
|
|
37932
|
+
const text4 = moduleSource(props.module);
|
|
37933
|
+
if (typeof text4 === "string") modules.push(text4);
|
|
36789
37934
|
else unknown = true;
|
|
36790
37935
|
}
|
|
36791
37936
|
}
|
|
36792
37937
|
if (unknown) continue;
|
|
36793
37938
|
for (const name of namesOf2(page)) {
|
|
36794
37939
|
if (read.has(name)) continue;
|
|
36795
|
-
if (modules.some((
|
|
37940
|
+
if (modules.some((text4) => readsUiParam(text4, name))) continue;
|
|
36796
37941
|
if (custom.some((handler) => {
|
|
36797
|
-
const
|
|
36798
|
-
return typeof
|
|
37942
|
+
const text4 = handlerSource(handler);
|
|
37943
|
+
return typeof text4 !== "string" || text4.includes(`"${name}"`) || text4.includes(`'${name}'`);
|
|
36799
37944
|
})) {
|
|
36800
37945
|
continue;
|
|
36801
37946
|
}
|
|
@@ -37243,6 +38388,7 @@ function unreachedFindings(declared, cases, contract, runs) {
|
|
|
37243
38388
|
function builderOwns(name, handlers) {
|
|
37244
38389
|
if (handlers === null) return true;
|
|
37245
38390
|
const declared = handlers[name];
|
|
38391
|
+
if (declared?.role === "source") return typeof declared.transform === "string" && declared.transform !== "";
|
|
37246
38392
|
return declared === void 0 || declared.role === "custom";
|
|
37247
38393
|
}
|
|
37248
38394
|
function neverRan(outcome) {
|
|
@@ -37250,13 +38396,26 @@ function neverRan(outcome) {
|
|
|
37250
38396
|
return first.startsWith("not run:") || first.startsWith("could not run it:");
|
|
37251
38397
|
}
|
|
37252
38398
|
function builderTestFindings(outcomes, handlers) {
|
|
37253
|
-
return outcomes.filter((outcome) => !outcome.ok && !neverRan(outcome) && builderOwns(outcome.handler, handlers)).map((outcome) =>
|
|
37254
|
-
|
|
37255
|
-
|
|
37256
|
-
|
|
37257
|
-
|
|
37258
|
-
|
|
37259
|
-
|
|
38399
|
+
return outcomes.filter((outcome) => !outcome.ok && !neverRan(outcome) && builderOwns(outcome.handler, handlers)).map((outcome) => {
|
|
38400
|
+
const message = `the case "${outcome.name}" fails: ${(outcome.problems[0] ?? "it failed").replace(/\s+/g, " ").trim()}`;
|
|
38401
|
+
const transform = handlers?.[outcome.handler]?.role === "source" ? handlers[outcome.handler]?.transform : void 0;
|
|
38402
|
+
if (transform !== void 0) {
|
|
38403
|
+
return {
|
|
38404
|
+
code: "builder-test-failure",
|
|
38405
|
+
where: transform,
|
|
38406
|
+
message,
|
|
38407
|
+
fix: `fix ${transform} (the transform source "${outcome.handler}" runs: yours, carried into the compiled handler), or its row in contract.json data.sources, or the case in tests.json if the case is what is wrong; compile again after.`,
|
|
38408
|
+
see: SEE.handlers
|
|
38409
|
+
};
|
|
38410
|
+
}
|
|
38411
|
+
return {
|
|
38412
|
+
code: "builder-test-failure",
|
|
38413
|
+
where: `handlers/${outcome.handler}.py`,
|
|
38414
|
+
message,
|
|
38415
|
+
fix: `fix handlers/${outcome.handler}.py (a custom handler: yours, and the compiler never rewrites it), or the case in tests.json if the case is what is wrong.`,
|
|
38416
|
+
see: SEE.handlers
|
|
38417
|
+
};
|
|
38418
|
+
});
|
|
37260
38419
|
}
|
|
37261
38420
|
function customFindings(runs) {
|
|
37262
38421
|
const out = [];
|
|
@@ -37379,9 +38538,9 @@ function partFindings(runs) {
|
|
|
37379
38538
|
return true;
|
|
37380
38539
|
};
|
|
37381
38540
|
const alert = component.alert ?? "";
|
|
37382
|
-
const
|
|
38541
|
+
const text4 = component.text ?? "";
|
|
37383
38542
|
const failedPrefix = `${type} failed:`;
|
|
37384
|
-
const failed = alert.startsWith(failedPrefix) ? alert :
|
|
38543
|
+
const failed = alert.startsWith(failedPrefix) ? alert : text4.startsWith(failedPrefix) ? text4 : null;
|
|
37385
38544
|
if (failed !== null) {
|
|
37386
38545
|
if (once("part-failed")) {
|
|
37387
38546
|
const error = failed.slice(failedPrefix.length).trim() || "it threw";
|
|
@@ -37395,7 +38554,7 @@ function partFindings(runs) {
|
|
|
37395
38554
|
}
|
|
37396
38555
|
continue;
|
|
37397
38556
|
}
|
|
37398
|
-
const undefinedSentence = [NO_COMPONENTS, NO_PART(type)].find((sentence3) => alert.startsWith(sentence3) ||
|
|
38557
|
+
const undefinedSentence = [NO_COMPONENTS, NO_PART(type)].find((sentence3) => alert.startsWith(sentence3) || text4.startsWith(sentence3));
|
|
37399
38558
|
if (undefinedSentence !== void 0) {
|
|
37400
38559
|
if (once("part-undefined")) {
|
|
37401
38560
|
out.push({
|
|
@@ -37437,7 +38596,7 @@ function partFindings(runs) {
|
|
|
37437
38596
|
if (entry?.reads?.as !== "rows" || typeof source !== "string" || source === "") continue;
|
|
37438
38597
|
const typed = component.props.props ?? {};
|
|
37439
38598
|
const sentence2 = typeof typed["empty_text"] === "string" && typed["empty_text"] !== "" ? String(typed["empty_text"]) : entry.empty ?? "Nothing to show.";
|
|
37440
|
-
if (!
|
|
38599
|
+
if (!text4.includes(sentence2)) continue;
|
|
37441
38600
|
const answered = loadAnswers(run, source).map((call) => call.rows).find((rows2) => rows2 !== void 0 && rows2 > 0);
|
|
37442
38601
|
if (answered === void 0) continue;
|
|
37443
38602
|
if (!once("part-empty")) continue;
|
|
@@ -37451,12 +38610,12 @@ function partFindings(runs) {
|
|
|
37451
38610
|
}
|
|
37452
38611
|
return out;
|
|
37453
38612
|
}
|
|
37454
|
-
function linesOf(
|
|
37455
|
-
if (typeof
|
|
37456
|
-
return
|
|
38613
|
+
function linesOf(text4) {
|
|
38614
|
+
if (typeof text4 !== "string" || text4 === "") return 0;
|
|
38615
|
+
return text4.replace(/\n$/, "").split("\n").length;
|
|
37457
38616
|
}
|
|
37458
|
-
function nonBlankLinesOf(
|
|
37459
|
-
return
|
|
38617
|
+
function nonBlankLinesOf(text4) {
|
|
38618
|
+
return text4.split("\n").filter((line2) => line2.trim() !== "").length;
|
|
37460
38619
|
}
|
|
37461
38620
|
var PY_ESCAPES = { n: "\n", r: "\r", t: " ", "\\": "\\", "'": "'", '"': '"', "0": "\0" };
|
|
37462
38621
|
function pyStringAt(code, at) {
|
|
@@ -37529,8 +38688,8 @@ function transformFiles2(contract, handlerCode) {
|
|
|
37529
38688
|
for (const name of Object.keys(sources).sort()) {
|
|
37530
38689
|
const path3 = sources[name]?.transform;
|
|
37531
38690
|
if (typeof path3 !== "string" || path3 === "") continue;
|
|
37532
|
-
const
|
|
37533
|
-
if (files.get(path3) === void 0) files.set(path3,
|
|
38691
|
+
const text4 = Object.prototype.hasOwnProperty.call(bySource, name) ? bySource[name] : void 0;
|
|
38692
|
+
if (files.get(path3) === void 0) files.set(path3, text4);
|
|
37534
38693
|
}
|
|
37535
38694
|
return files;
|
|
37536
38695
|
}
|
|
@@ -37571,7 +38730,7 @@ function partsSummary(contract, bundle, handlerCode) {
|
|
|
37571
38730
|
if (isAppContract3(contract)) {
|
|
37572
38731
|
const files = transformFiles2(contract, handlerCode);
|
|
37573
38732
|
let lines = 0;
|
|
37574
|
-
for (const
|
|
38733
|
+
for (const text4 of files.values()) if (text4 !== void 0) lines += nonBlankLinesOf(text4);
|
|
37575
38734
|
summary.transforms = { count: files.size, lines };
|
|
37576
38735
|
}
|
|
37577
38736
|
return summary;
|
|
@@ -37956,9 +39115,14 @@ function formatFindings(findings) {
|
|
|
37956
39115
|
const n = findings.length;
|
|
37957
39116
|
const warnings = findings.filter((finding) => finding.severity === "warning").length;
|
|
37958
39117
|
const handlers = findings.some(
|
|
37959
|
-
(finding) => finding.code === "builder-test-failure" || finding.code === "payload-key-unproduced"
|
|
39118
|
+
(finding) => finding.code === "builder-test-failure" && !finding.where.startsWith("transforms/") || finding.code === "payload-key-unproduced"
|
|
37960
39119
|
);
|
|
37961
|
-
const
|
|
39120
|
+
const transforms = findings.some((finding) => finding.code === "builder-test-failure" && finding.where.startsWith("transforms/"));
|
|
39121
|
+
const yours = [
|
|
39122
|
+
...handlers ? ["custom handlers: the handlers/*.py named"] : [],
|
|
39123
|
+
...transforms ? ["transforms: the transforms/*.py named"] : []
|
|
39124
|
+
];
|
|
39125
|
+
const where2 = yours.length > 0 ? `contract.json (${yours.join("; ")})` : "contract.json";
|
|
37962
39126
|
const counted = warnings === 0 ? "" : ` (${String(warnings)} of them ${warnings === 1 ? "a warning" : "warnings"}, which --strict does not count)`;
|
|
37963
39127
|
out += n === 1 ? `1 finding${counted}: fix it in ${where2} and push again.
|
|
37964
39128
|
` : `${String(n)} findings${counted}: fix them in ${where2} and push again.
|
|
@@ -38755,12 +39919,24 @@ async function readSeed(dir) {
|
|
|
38755
39919
|
async function handlerOwnership(dir, pushed) {
|
|
38756
39920
|
try {
|
|
38757
39921
|
const local = JSON.parse(await readFile13(join18(dir, "contract.json"), "utf8"));
|
|
38758
|
-
const
|
|
38759
|
-
if (
|
|
39922
|
+
const owned = ownershipOf(local);
|
|
39923
|
+
if (owned !== null) return owned;
|
|
38760
39924
|
} catch {
|
|
38761
39925
|
}
|
|
38762
|
-
|
|
38763
|
-
|
|
39926
|
+
return pushed === null ? null : ownershipOf(pushed);
|
|
39927
|
+
}
|
|
39928
|
+
function ownershipOf(contract) {
|
|
39929
|
+
const handlers = contract.data?.app?.handlers;
|
|
39930
|
+
const sources = contract.data?.sources;
|
|
39931
|
+
const hasHandlers = typeof handlers === "object" && handlers !== null;
|
|
39932
|
+
const hasSources = typeof sources === "object" && sources !== null;
|
|
39933
|
+
if (!hasHandlers && !hasSources) return null;
|
|
39934
|
+
const out = {};
|
|
39935
|
+
for (const [name, row] of Object.entries(hasSources ? sources : {})) {
|
|
39936
|
+
const transform = row?.transform;
|
|
39937
|
+
out[name] = typeof transform === "string" && transform !== "" ? { role: "source", transform } : { role: "source" };
|
|
39938
|
+
}
|
|
39939
|
+
return { ...out, ...hasHandlers ? handlers : {} };
|
|
38764
39940
|
}
|
|
38765
39941
|
function findingsNotChecked(factsRead, contract) {
|
|
38766
39942
|
if (!factsRead) {
|
|
@@ -38880,6 +40056,9 @@ function registerTestCommand(parent) {
|
|
|
38880
40056
|
).option("--width <px>", "With --screenshot: the window width.", "1400").option("--height <px>", "With --screenshot: the window height.", "900").option("--full", "With --screenshot: grow the window to the page\u2019s full height (one extra load per picture).").option(
|
|
38881
40057
|
"--no-look",
|
|
38882
40058
|
"With --screenshot: skip the look load (one more load per picture that reports text cut short, an underfilled band and content past the window edge as look-* warnings)."
|
|
40059
|
+
).option(
|
|
40060
|
+
"--no-sample",
|
|
40061
|
+
"With --screenshot: answer data cards with tests.json or [] only, not with sample payloads of their kind (a dashboard\u2019s cards, an app\u2019s widget elements)."
|
|
38883
40062
|
).option(
|
|
38884
40063
|
"--shelf <path>",
|
|
38885
40064
|
"With --screenshot: serve vendor/ and ui-kit/ from this dr-app-space checkout instead of the server the app is pushed to (for offline use)."
|
|
@@ -39085,6 +40264,7 @@ function registerTestCommand(parent) {
|
|
|
39085
40264
|
height: shotSize.height,
|
|
39086
40265
|
full: opts.full === true,
|
|
39087
40266
|
look: opts.look !== false,
|
|
40267
|
+
sample: opts.sample !== false,
|
|
39088
40268
|
budgetMs: shotSize.budget
|
|
39089
40269
|
});
|
|
39090
40270
|
shots = { index, outDir };
|
|
@@ -39194,14 +40374,14 @@ async function readPayloadOption(raw, read = (path3) => readFile14(path3, "utf8"
|
|
|
39194
40374
|
if (raw.startsWith("@")) {
|
|
39195
40375
|
const path3 = raw.slice(1);
|
|
39196
40376
|
if (path3 === "") throw new Error("--payload @ names no file; write --payload @./payload.json.");
|
|
39197
|
-
let
|
|
40377
|
+
let text4;
|
|
39198
40378
|
try {
|
|
39199
|
-
|
|
40379
|
+
text4 = await read(path3);
|
|
39200
40380
|
} catch {
|
|
39201
40381
|
throw new Error(`--payload @${path3}: no such file.`);
|
|
39202
40382
|
}
|
|
39203
40383
|
try {
|
|
39204
|
-
return JSON.parse(
|
|
40384
|
+
return JSON.parse(text4);
|
|
39205
40385
|
} catch {
|
|
39206
40386
|
throw new Error(`--payload @${path3}: the file is not valid JSON.`);
|
|
39207
40387
|
}
|