@signal4/s4 2.6.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +60 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +407 -196
- package/dist/cli.js.map +1 -1
- package/dist/cli_args.d.ts +24 -0
- package/dist/cli_args.d.ts.map +1 -0
- package/dist/cli_args.js +130 -0
- package/dist/cli_args.js.map +1 -0
- package/dist/client.d.ts +103 -3
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +195 -23
- package/dist/client.js.map +1 -1
- package/dist/format.d.ts +103 -4
- package/dist/format.d.ts.map +1 -1
- package/dist/format.js +299 -64
- package/dist/format.js.map +1 -1
- package/dist/handler_types.d.ts +10 -0
- package/dist/handler_types.d.ts.map +1 -1
- package/dist/handler_types.js +25 -0
- package/dist/handler_types.js.map +1 -1
- package/dist/handlers/ads.js +4 -4
- package/dist/handlers/ads.js.map +1 -1
- package/dist/handlers/analyze.d.ts.map +1 -1
- package/dist/handlers/analyze.js +22 -6
- package/dist/handlers/analyze.js.map +1 -1
- package/dist/handlers/bookmarks.js +2 -2
- package/dist/handlers/bookmarks.js.map +1 -1
- package/dist/handlers/claim_detail.d.ts.map +1 -1
- package/dist/handlers/claim_detail.js +18 -10
- package/dist/handlers/claim_detail.js.map +1 -1
- package/dist/handlers/claims.d.ts.map +1 -1
- package/dist/handlers/claims.js +72 -27
- package/dist/handlers/claims.js.map +1 -1
- package/dist/handlers/count.d.ts +14 -0
- package/dist/handlers/count.d.ts.map +1 -0
- package/dist/handlers/count.js +158 -0
- package/dist/handlers/count.js.map +1 -0
- package/dist/handlers/explore.d.ts.map +1 -1
- package/dist/handlers/explore.js +56 -14
- package/dist/handlers/explore.js.map +1 -1
- package/dist/handlers/registry.d.ts.map +1 -1
- package/dist/handlers/registry.js +5 -1
- package/dist/handlers/registry.js.map +1 -1
- package/dist/handlers/reports.d.ts +6 -0
- package/dist/handlers/reports.d.ts.map +1 -1
- package/dist/handlers/reports.js +140 -26
- package/dist/handlers/reports.js.map +1 -1
- package/dist/handlers/search.d.ts.map +1 -1
- package/dist/handlers/search.js +80 -23
- package/dist/handlers/search.js.map +1 -1
- package/dist/handlers/timeline.d.ts.map +1 -1
- package/dist/handlers/timeline.js +14 -8
- package/dist/handlers/timeline.js.map +1 -1
- package/dist/http.js +25 -3
- package/dist/http.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/provenance.d.ts +29 -2
- package/dist/provenance.d.ts.map +1 -1
- package/dist/provenance.js +63 -4
- package/dist/provenance.js.map +1 -1
- package/dist/server_core.d.ts +8 -1
- package/dist/server_core.d.ts.map +1 -1
- package/dist/server_core.js +90 -8
- package/dist/server_core.js.map +1 -1
- package/dist/speed.d.ts +40 -0
- package/dist/speed.d.ts.map +1 -0
- package/dist/speed.js +214 -0
- package/dist/speed.js.map +1 -0
- package/dist/surface.d.ts +7 -0
- package/dist/surface.d.ts.map +1 -0
- package/dist/surface.js +19 -0
- package/dist/surface.js.map +1 -0
- package/dist/types.d.ts +249 -15
- package/dist/types.d.ts.map +1 -1
- package/package.json +3 -2
package/dist/speed.js
ADDED
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/** How long a call should take — one source for tool descriptions, CLI help, the
|
|
2
|
+
* progress notice a slow call sends before it starts, and the "took Ns" footer.
|
|
3
|
+
*
|
|
4
|
+
* Tiers, by the typical time (geometric mean of the range):
|
|
5
|
+
* instant < 0.5s fast 0.5–2.5s slow > 2.5s
|
|
6
|
+
*
|
|
7
|
+
* Every number is measured, not guessed: the 100-plan replay against the live API
|
|
8
|
+
* (2026-10-15/16, ~/logs/search_eval/replay-2026-10-15.jsonl — per-tool p50/p90) and the
|
|
9
|
+
* VPS before/after runs for the counting engine (signal4#292, #296). Semantic tools pay
|
|
10
|
+
* ~1s for the query embedding before they scan; a scan costs roughly 0.15–0.35s per
|
|
11
|
+
* month of window over the whole corpus. Update the table when a tool gets faster. */
|
|
12
|
+
const INSTANT_MAX = 0.5;
|
|
13
|
+
const FAST_MAX = 2.5;
|
|
14
|
+
/** Responses that took longer than this say how long. */
|
|
15
|
+
export const REPORT_ELAPSED_OVER_S = 2.5;
|
|
16
|
+
const EMBED_S = 1.0;
|
|
17
|
+
export function tierOf(lo, hi) {
|
|
18
|
+
const typical = Math.sqrt(Math.max(lo, 0.01) * Math.max(hi, 0.01));
|
|
19
|
+
if (typical < INSTANT_MAX)
|
|
20
|
+
return "instant";
|
|
21
|
+
if (typical <= FAST_MAX)
|
|
22
|
+
return "fast";
|
|
23
|
+
return "slow";
|
|
24
|
+
}
|
|
25
|
+
function est(lo, hi, why) {
|
|
26
|
+
return { tier: tierOf(lo, hi), lo, hi, why };
|
|
27
|
+
}
|
|
28
|
+
/** Fixed-cost tools: [lo, hi] seconds from the replay (p50-ish, p90). */
|
|
29
|
+
const BASE = {
|
|
30
|
+
get_segment: [0.1, 0.2],
|
|
31
|
+
get_segment_sentences: [0.1, 0.3],
|
|
32
|
+
get_thread: [0.1, 0.4],
|
|
33
|
+
get_claim: [0.1, 0.4],
|
|
34
|
+
list_collections: [0.1, 0.3],
|
|
35
|
+
manage_bookmarks: [0.1, 0.4],
|
|
36
|
+
find_speakers: [0.2, 0.8],
|
|
37
|
+
get_platform_stats: [0.2, 1],
|
|
38
|
+
get_collection_stats: [0.2, 1],
|
|
39
|
+
get_project_stats: [0.2, 1],
|
|
40
|
+
get_speaker: [0.2, 2.5],
|
|
41
|
+
claim_graph: [0.3, 1.6],
|
|
42
|
+
get_channel: [0.3, 1.2],
|
|
43
|
+
get_episode: [0.5, 2],
|
|
44
|
+
channel_dossier: [0.5, 1.6],
|
|
45
|
+
compare_channels: [0.7, 1.5],
|
|
46
|
+
get_top_channels: [0.5, 2.5],
|
|
47
|
+
analyze_claims: [0.8, 2.3],
|
|
48
|
+
contradict_claims: [0.8, 4.4],
|
|
49
|
+
compare_claims: [0.8, 4],
|
|
50
|
+
check_channel_contradictions: [0.8, 4],
|
|
51
|
+
find_entities: [0.1, 1.2],
|
|
52
|
+
trend_claims: [1, 3.5],
|
|
53
|
+
get_top_speakers: [1.5, 3.5],
|
|
54
|
+
get_speaker_network: [1, 5],
|
|
55
|
+
get_ad_analytics: [0.5, 3],
|
|
56
|
+
// Warm 0.2–2.8s; the largest entities (Donald Trump, Ukraine) up to ~6s cold (signal4#317).
|
|
57
|
+
entity_claims: [0.3, 6],
|
|
58
|
+
top_claims: [2, 8],
|
|
59
|
+
get_topics: [3, 19],
|
|
60
|
+
// Paid LLM pipelines (their own descriptions carry these ranges).
|
|
61
|
+
get_briefing: [2, 10],
|
|
62
|
+
analyze_topic: [15, 45],
|
|
63
|
+
compare_speakers: [15, 45],
|
|
64
|
+
build_dossier: [15, 45],
|
|
65
|
+
check_contradictions: [15, 45],
|
|
66
|
+
compare_frames: [30, 60],
|
|
67
|
+
};
|
|
68
|
+
/** Window length in months from days / start_date / end_date (YYYY, YYYY-MM, YYYY-MM-DD). */
|
|
69
|
+
export function windowMonths(params, defaultDays = 30) {
|
|
70
|
+
const today = Date.now();
|
|
71
|
+
const parse = (v, edge) => {
|
|
72
|
+
if (typeof v !== "string" || !v)
|
|
73
|
+
return undefined;
|
|
74
|
+
const m = /^(\d{4})(?:-(\d{2}))?(?:-(\d{2}))?$/.exec(v.trim());
|
|
75
|
+
if (!m)
|
|
76
|
+
return undefined;
|
|
77
|
+
const y = Number(m[1]);
|
|
78
|
+
const mo = m[2] ? Number(m[2]) - 1 : edge === "start" ? 0 : 11;
|
|
79
|
+
const d = m[3] ? Number(m[3]) : edge === "start" ? 1 : 28;
|
|
80
|
+
return Date.UTC(y, mo, d);
|
|
81
|
+
};
|
|
82
|
+
const start = parse(params.start_date, "start");
|
|
83
|
+
const end = parse(params.end_date, "end") ?? today;
|
|
84
|
+
const days = start != null
|
|
85
|
+
? (end - start) / 86400000
|
|
86
|
+
: Number(params.days ?? params.baseline_days ?? defaultDays) || defaultDays;
|
|
87
|
+
return Math.max(days / 30.4, 0.25);
|
|
88
|
+
}
|
|
89
|
+
/** Whole-corpus semantic scan cost for a window: ~0.2–0.35s per month up to two years,
|
|
90
|
+
* thin before that. Measured on the VPS: 1 month 0.2–0.7s, 12 months 2.4–3.6s, all time 5–8s. */
|
|
91
|
+
function scanCost(months) {
|
|
92
|
+
const recent = Math.min(months, 24);
|
|
93
|
+
const older = Math.max(months - 24, 0);
|
|
94
|
+
const lo = 0.2 + 0.15 * recent;
|
|
95
|
+
// All time measured 4.7s warm, 7–8.5s just after cache churn (signal4#238).
|
|
96
|
+
const hi = Math.min(0.8 + 0.35 * recent + 0.02 * older, 9);
|
|
97
|
+
return [lo, hi];
|
|
98
|
+
}
|
|
99
|
+
function monthsLabel(months) {
|
|
100
|
+
if (months >= 120)
|
|
101
|
+
return "all time";
|
|
102
|
+
if (months >= 23)
|
|
103
|
+
return `${Math.round(months / 12)} years`;
|
|
104
|
+
if (months >= 1.5)
|
|
105
|
+
return `${Math.round(months)} months`;
|
|
106
|
+
return `${Math.max(1, Math.round(months * 30.4))} days`;
|
|
107
|
+
}
|
|
108
|
+
/** The estimate for one call. Unknown tools are "fast" with a wide range. */
|
|
109
|
+
export function estimate(tool, params = {}) {
|
|
110
|
+
const speaker = params.speaker ?? params.speaker_name ?? params.speaker_id;
|
|
111
|
+
const keyword = params.mode === "keyword" || typeof params.keyword === "string";
|
|
112
|
+
switch (tool) {
|
|
113
|
+
case "search_quotes": {
|
|
114
|
+
if (params.full_history)
|
|
115
|
+
return est(2, 15, "exact scan of a speaker's whole history");
|
|
116
|
+
const m = windowMonths(params);
|
|
117
|
+
if (keyword) {
|
|
118
|
+
return est(0.3, speaker ? 4 : 1.5, `keyword search, newest first, ${monthsLabel(m)}`);
|
|
119
|
+
}
|
|
120
|
+
if (!params.topic)
|
|
121
|
+
return est(0.2, 2, "listing by speaker or channel");
|
|
122
|
+
const [lo, hi] = scanCost(m);
|
|
123
|
+
// Deep pages rerank more candidates: rank 1,000 ~+1s, rank 2,000 ~+3s (signal4#329).
|
|
124
|
+
const deep = Math.min(Number(params.offset ?? 0), 2000) / 2000 * 3;
|
|
125
|
+
return est(EMBED_S + lo + deep / 2, EMBED_S + hi + 0.5 + deep + (speaker ? 4 : 0), `semantic search over ${monthsLabel(m)}${speaker ? " for one speaker" : ""}${deep ? ", deep page" : ""}`);
|
|
126
|
+
}
|
|
127
|
+
case "count_mentions": {
|
|
128
|
+
if (params.group_by === "speaker") {
|
|
129
|
+
// Folding speaker rows onto people reads `speakers`: 0.1–3s warm, up to ~7s cold (signal4#318).
|
|
130
|
+
const base = estimate("count_mentions", { ...params, group_by: "none" });
|
|
131
|
+
return est(base.lo + 0.2, base.hi + 5, `${base.why}, ranked by speaker`);
|
|
132
|
+
}
|
|
133
|
+
const m = windowMonths(params);
|
|
134
|
+
if (keyword) {
|
|
135
|
+
const hi = m <= 3 ? 2 : m <= 12 ? 6 : 15;
|
|
136
|
+
return est(0.3, hi + (speaker ? 6 : 0), `exact keyword count over ${monthsLabel(m)} (very common words take longest)`);
|
|
137
|
+
}
|
|
138
|
+
if (!params.topic && !params.topics)
|
|
139
|
+
return est(0.3, m <= 3 ? 2 : 8, `count of everything in scope over ${monthsLabel(m)}`);
|
|
140
|
+
const [lo, hi] = scanCost(m);
|
|
141
|
+
return est(EMBED_S + lo, EMBED_S + hi + (speaker ? 10 : 0), `semantic count over ${monthsLabel(m)}${speaker ? " for one speaker" : ""}`);
|
|
142
|
+
}
|
|
143
|
+
case "get_timeline":
|
|
144
|
+
case "detect_trend": {
|
|
145
|
+
const m = windowMonths(params, tool === "detect_trend" ? Number(params.baseline_days ?? 30) || 30 : 30);
|
|
146
|
+
const [lo, hi] = scanCost(m);
|
|
147
|
+
return est(EMBED_S + lo, EMBED_S + hi + (speaker ? 10 : 0), `semantic count over ${monthsLabel(m)}`);
|
|
148
|
+
}
|
|
149
|
+
case "get_top_channels":
|
|
150
|
+
if (params.topic)
|
|
151
|
+
return est(1, 8, "which channels say the most about the topic, from the transcripts");
|
|
152
|
+
return est(BASE.get_top_channels[0], BASE.get_top_channels[1]);
|
|
153
|
+
case "get_top_speakers":
|
|
154
|
+
if (params.topic)
|
|
155
|
+
return est(1, 8, "who talks most about the topic, from the transcripts");
|
|
156
|
+
return est(BASE.get_top_speakers[0], BASE.get_top_speakers[1]);
|
|
157
|
+
case "get_claim":
|
|
158
|
+
return params.include_related ? est(0.3, 1.5, "claim detail plus related claims") : est(0.1, 0.4);
|
|
159
|
+
case "search_claims": {
|
|
160
|
+
if (params.entity)
|
|
161
|
+
return est(1, 5, "claims search filtered by entity");
|
|
162
|
+
if (keyword)
|
|
163
|
+
return est(0.3, 2, "claims keyword search");
|
|
164
|
+
return est(1.5, 10, "semantic claims search");
|
|
165
|
+
}
|
|
166
|
+
default: {
|
|
167
|
+
const b = BASE[tool];
|
|
168
|
+
return b ? est(b[0], b[1]) : est(0.5, 5);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/** 0.1–0.9 to one decimal, 1–10 to the half second, then whole seconds. */
|
|
173
|
+
function secs(n) {
|
|
174
|
+
if (n < 1)
|
|
175
|
+
return Math.max(n, 0.1).toFixed(1);
|
|
176
|
+
return n < 10 ? String(Math.round(n * 2) / 2) : String(Math.round(n));
|
|
177
|
+
}
|
|
178
|
+
/** "instant" · "fast ~1–2s" · "slow ~3–8s". */
|
|
179
|
+
export function label(e) {
|
|
180
|
+
if (e.tier === "instant")
|
|
181
|
+
return "instant";
|
|
182
|
+
return `${e.tier} ~${secs(e.lo)}–${secs(e.hi)}s`;
|
|
183
|
+
}
|
|
184
|
+
/** The speed line a tool description starts with, e.g. "[slow ~15–45s · paid LLM]".
|
|
185
|
+
* Tools whose time depends on the window carry a short scale ("…; 12 months ~3–6s"). */
|
|
186
|
+
export function descriptionTag(tool, paid = false) {
|
|
187
|
+
const windowed = ["search_quotes", "count_mentions", "get_timeline", "detect_trend"].includes(tool);
|
|
188
|
+
// The usual call: a topic, default (30-day) window, semantic.
|
|
189
|
+
const base = estimate(tool, windowed ? { topic: "x" } : {});
|
|
190
|
+
let scale = "";
|
|
191
|
+
if (windowed) {
|
|
192
|
+
const year = estimate(tool, { days: 365, topic: "x" });
|
|
193
|
+
const all = estimate(tool, { start_date: "2010", topic: "x" });
|
|
194
|
+
scale = `; 12 months ${label(year).replace(/^\w+ /, "")}, all time ${label(all).replace(/^\w+ /, "")}`;
|
|
195
|
+
}
|
|
196
|
+
return `[${label(base)}${scale}${paid ? " · paid LLM" : ""}]`;
|
|
197
|
+
}
|
|
198
|
+
/** Replace the speed/price bracket a backend description starts with by ours,
|
|
199
|
+
* keeping the paid marker. */
|
|
200
|
+
export function decorateDescription(tool, description) {
|
|
201
|
+
const m = /^\[([^\]]*)\]\s*/.exec(description);
|
|
202
|
+
const paid = m ? /paid/i.test(m[1]) : false;
|
|
203
|
+
const rest = m ? description.slice(m[0].length) : description;
|
|
204
|
+
return `${descriptionTag(tool, paid)} ${rest}`;
|
|
205
|
+
}
|
|
206
|
+
/** The notice a slow call sends before it starts (MCP progress, CLI stderr). */
|
|
207
|
+
export function startNotice(e) {
|
|
208
|
+
return `Estimated ${secs(e.lo)}–${secs(e.hi)}s${e.why ? `: ${e.why}` : ""}.`;
|
|
209
|
+
}
|
|
210
|
+
/** Footer for a response that took longer than REPORT_ELAPSED_OVER_S. */
|
|
211
|
+
export function elapsedFooter(ms) {
|
|
212
|
+
return ms / 1000 > REPORT_ELAPSED_OVER_S ? `\n_Took ${(ms / 1000).toFixed(1)}s._` : "";
|
|
213
|
+
}
|
|
214
|
+
//# sourceMappingURL=speed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speed.js","sourceRoot":"","sources":["../src/speed.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;sFAUsF;AAatF,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,QAAQ,GAAG,GAAG,CAAC;AACrB,yDAAyD;AACzD,MAAM,CAAC,MAAM,qBAAqB,GAA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AAC,CAAC;IAC/C,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;IAC5C,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;IAC9D,OAAO,GAAG,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,EAAE,CAAC;AACjD,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,WAAW,CAAC,CAAW;IACrC,OAAO,aAAa,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;AAC/E,CAAC;AAED,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,EAAU;IACtC,OAAO,EAAE,GAAG,IAAI,GAAG,qBAAqB,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AACzF,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Which front end is rendering: next-step hints use CLI or MCP call syntax. */
|
|
2
|
+
export type Surface = "cli" | "mcp";
|
|
3
|
+
export declare function setSurface(s: Surface): void;
|
|
4
|
+
export declare function getSurface(): Surface;
|
|
5
|
+
/** Rewrite an MCP-style call hint (`get_segment seg:42`, `offset:20`) to CLI syntax when running as the CLI. */
|
|
6
|
+
export declare function hint(mcp: string): string;
|
|
7
|
+
//# sourceMappingURL=surface.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.d.ts","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAEhF,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC;AAIpC,wBAAgB,UAAU,CAAC,CAAC,EAAE,OAAO,GAAG,IAAI,CAAiB;AAC7D,wBAAgB,UAAU,IAAI,OAAO,CAAoB;AAEzD,gHAAgH;AAChH,wBAAgB,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAWxC"}
|
package/dist/surface.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Which front end is rendering: next-step hints use CLI or MCP call syntax. */
|
|
2
|
+
let current = "mcp";
|
|
3
|
+
export function setSurface(s) { current = s; }
|
|
4
|
+
export function getSurface() { return current; }
|
|
5
|
+
/** Rewrite an MCP-style call hint (`get_segment seg:42`, `offset:20`) to CLI syntax when running as the CLI. */
|
|
6
|
+
export function hint(mcp) {
|
|
7
|
+
if (current !== "cli")
|
|
8
|
+
return mcp;
|
|
9
|
+
return mcp
|
|
10
|
+
.replace(/get_segment seg:(\d+)/g, "s4 segment $1")
|
|
11
|
+
.replace(/get_speaker speaker_id:(\d+)/g, "s4 speaker $1")
|
|
12
|
+
.replace(/get_claim claim:(\d+)( include_observations:true)?/g, (_m, id, o) => `s4 claim ${id}${o ? " --observations" : ""}`)
|
|
13
|
+
.replace(/get_thread segment_id:(\d+)( max_chars:0)?/g, "s4 thread $1")
|
|
14
|
+
.replace(/get_episode content_id:(\S+?)( include_transcript:true)?(?=$|[\s·\]])/g, (_m, id, t) => `s4 episode ${id}${t ? " --transcript" : ""}`)
|
|
15
|
+
.replace(/search_quotes topic:("[^"]*") start_date:(\S+)/g, "s4 search $1 --since $2")
|
|
16
|
+
.replace(/\bobservations_offset:(\d+)/g, "--obs-offset $1")
|
|
17
|
+
.replace(/\boffset:(\d+)/g, "--offset $1");
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=surface.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"surface.js","sourceRoot":"","sources":["../src/surface.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAIhF,IAAI,OAAO,GAAY,KAAK,CAAC;AAE7B,MAAM,UAAU,UAAU,CAAC,CAAU,IAAU,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC;AAC7D,MAAM,UAAU,UAAU,KAAc,OAAO,OAAO,CAAC,CAAC,CAAC;AAEzD,gHAAgH;AAChH,MAAM,UAAU,IAAI,CAAC,GAAW;IAC9B,IAAI,OAAO,KAAK,KAAK;QAAE,OAAO,GAAG,CAAC;IAClC,OAAO,GAAG;SACP,OAAO,CAAC,wBAAwB,EAAE,eAAe,CAAC;SAClD,OAAO,CAAC,+BAA+B,EAAE,eAAe,CAAC;SACzD,OAAO,CAAC,qDAAqD,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SAC5H,OAAO,CAAC,6CAA6C,EAAE,cAAc,CAAC;SACtE,OAAO,CAAC,wEAAwE,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,cAAc,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;SAC/I,OAAO,CAAC,iDAAiD,EAAE,yBAAyB,CAAC;SACrF,OAAO,CAAC,8BAA8B,EAAE,iBAAiB,CAAC;SAC1D,OAAO,CAAC,iBAAiB,EAAE,aAAa,CAAC,CAAC;AAC/C,CAAC"}
|