nish-ui 1.8.0 → 2.0.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 +223 -61
- package/dist/base-tailwind.css +1757 -0
- package/dist/base.css +1590 -1445
- package/dist/chart.d.ts +4 -1
- package/dist/chart.js +122 -49
- package/dist/elements-all.d.ts +8 -0
- package/dist/elements-all.js +178 -0
- package/dist/elements-charts.d.ts +124 -2
- package/dist/elements-charts.js +131 -1
- package/dist/elements-data.d.ts +166 -2
- package/dist/elements-data.js +46 -1
- package/dist/elements-forms.d.ts +71 -0
- package/dist/elements-forms.js +24 -25
- package/dist/elements.d.ts +71 -0
- package/dist/elements.js +4 -5
- package/dist/esm/chart-values.js +58 -0
- package/dist/esm/chart.js +10 -0
- package/dist/esm/cn.js +19 -0
- package/dist/esm/combobox-filter.js +13 -0
- package/dist/esm/components/accordion.js +166 -0
- package/dist/esm/components/app-shell.js +198 -0
- package/dist/esm/components/avatar-classes.js +28 -0
- package/dist/esm/components/avatar.js +113 -0
- package/dist/esm/components/breadcrumbs.js +154 -0
- package/dist/esm/components/canvas/follow-caption.js +32 -0
- package/dist/esm/components/canvas/follow.js +119 -0
- package/dist/esm/components/canvas/icons.js +70 -0
- package/dist/esm/components/canvas/index.js +10 -0
- package/dist/esm/components/canvas/layout.js +258 -0
- package/dist/esm/components/canvas/legend.js +93 -0
- package/dist/esm/components/canvas/minimap.js +127 -0
- package/dist/esm/components/canvas/node.js +87 -0
- package/dist/esm/components/canvas/route.js +262 -0
- package/dist/esm/components/canvas/system-canvas.js +837 -0
- package/dist/esm/components/canvas/types.js +10 -0
- package/dist/esm/components/canvas/view.js +47 -0
- package/dist/esm/components/chart-hooks.js +19 -0
- package/dist/esm/components/charts.js +467 -0
- package/dist/esm/components/client.js +24 -0
- package/dist/esm/components/combobox.js +343 -0
- package/dist/esm/components/command.js +403 -0
- package/dist/esm/components/data-classes.js +159 -0
- package/dist/esm/components/data.js +517 -0
- package/dist/esm/components/display-classes.js +130 -0
- package/dist/esm/components/display.js +755 -0
- package/dist/esm/components/error-boundary.js +64 -0
- package/dist/esm/components/feedback.js +136 -0
- package/dist/esm/components/file-dropzone.js +184 -0
- package/dist/esm/components/filters.js +108 -0
- package/dist/esm/components/flow.js +746 -0
- package/dist/esm/components/forms-classes.js +43 -0
- package/dist/esm/components/forms.js +581 -0
- package/dist/esm/components/hooks-classes.js +9 -0
- package/dist/esm/components/hooks.js +236 -0
- package/dist/esm/components/icons.js +96 -0
- package/dist/esm/components/inbox-classes.js +29 -0
- package/dist/esm/components/inbox.js +257 -0
- package/dist/esm/components/latest.js +13 -0
- package/dist/esm/components/layout-vars.js +96 -0
- package/dist/esm/components/layout.js +272 -0
- package/dist/esm/components/media.js +143 -0
- package/dist/esm/components/nav.js +614 -0
- package/dist/esm/components/overlay-classes.js +66 -0
- package/dist/esm/components/overlay.js +1447 -0
- package/dist/esm/components/pagination-classes.js +29 -0
- package/dist/esm/components/pagination.js +154 -0
- package/dist/esm/components/portal.js +16 -0
- package/dist/esm/components/primitives-classes.js +198 -0
- package/dist/esm/components/primitives.js +268 -0
- package/dist/esm/components/progress.js +77 -0
- package/dist/esm/components/provider.js +32 -0
- package/dist/esm/components/radio-group.js +186 -0
- package/dist/esm/components/resource-classes.js +133 -0
- package/dist/esm/components/resource.js +209 -0
- package/dist/esm/components/segmented.js +178 -0
- package/dist/esm/components/separator.js +38 -0
- package/dist/esm/components/service-tokens.js +221 -0
- package/dist/esm/components/settings.js +301 -0
- package/dist/esm/components/slider.js +262 -0
- package/dist/esm/components/split-classes.js +8 -0
- package/dist/esm/components/split.js +411 -0
- package/dist/esm/components/strings.js +119 -0
- package/dist/esm/components/table.js +144 -0
- package/dist/esm/components/tabs-classes.js +21 -0
- package/dist/esm/components/tabs.js +201 -0
- package/dist/esm/components/tag-input.js +257 -0
- package/dist/esm/components/theme-toggle.js +177 -0
- package/dist/esm/components/toast.js +361 -0
- package/dist/esm/components/url-state.js +118 -0
- package/dist/esm/components/visually-hidden.js +20 -0
- package/dist/esm/format.js +320 -0
- package/dist/esm/inbox-client.js +2 -0
- package/dist/esm/inbox-types.js +2 -0
- package/dist/esm/index.js +320 -0
- package/dist/esm/runtime.js +37 -0
- package/dist/esm/server/inbox/client.js +297 -0
- package/dist/esm/server/inbox/types.js +24 -0
- package/dist/esm/sparkline-path.js +59 -0
- package/dist/esm/split-layout.js +419 -0
- package/dist/esm/system-canvas.js +2 -0
- package/dist/esm/theme.js +804 -0
- package/dist/esm/tokens.mjs +425 -0
- package/dist/esm/url.js +20 -0
- package/dist/files.json +5 -1
- package/dist/fonts/LICENSE-Inter.txt +93 -0
- package/dist/format.d.ts +32 -18
- package/dist/format.js +227 -82
- package/dist/inbox-client.js +3 -1
- package/dist/index.d.ts +1689 -667
- package/dist/nish-components.css +4701 -3169
- package/dist/nish-components.min.css +1 -0
- package/dist/nish.css +1603 -1450
- package/dist/nish.min.css +1 -0
- package/dist/node/eslint.js +29 -14
- package/dist/node/th-check.js +29 -14
- package/dist/node/vite.d.ts +12 -0
- package/dist/node/vite.js +12 -2
- package/dist/server/hono.d.ts +15 -6
- package/dist/server/hono.js +30 -25
- package/dist/server/index.d.ts +3 -10
- package/dist/server/index.js +71 -38
- package/dist/{spa-DuVB5O7S.d.ts → spa-BLlMc0eI.d.ts} +38 -5
- package/dist/system-canvas-BLuWd69H.d.ts +183 -0
- package/dist/system-canvas.d.ts +2 -168
- package/dist/tailwind-core.css +114 -0
- package/dist/tailwind.css +3 -7
- package/dist/theme-init.js +23 -9
- package/dist/theme-init.sha256 +1 -0
- package/dist/theme.d.ts +246 -4
- package/dist/theme.global.js +357 -90
- package/dist/theme.js +338 -68
- package/dist/tokens.css +14 -6
- package/dist/tokens.dtcg.json +1513 -0
- package/dist/tokens.js +29 -14
- package/dist/tokens.json +512 -0
- package/package.json +51 -13
- package/dist/chart.js.map +0 -1
- package/dist/elements-charts.js.map +0 -1
- package/dist/elements-data.js.map +0 -1
- package/dist/elements-forms.js.map +0 -1
- package/dist/elements.js.map +0 -1
- package/dist/format.js.map +0 -1
- package/dist/inbox-client.js.map +0 -1
- package/dist/index.js +0 -10260
- package/dist/index.js.map +0 -1
- package/dist/server/hono.js.map +0 -1
- package/dist/server/index.js.map +0 -1
- package/dist/split-layout.js.map +0 -1
- package/dist/system-canvas.js +0 -2204
- package/dist/system-canvas.js.map +0 -1
- package/dist/theme.global.js.map +0 -1
- package/dist/theme.js.map +0 -1
package/dist/server/index.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
// src/server/session.ts
|
|
2
2
|
import { createHmac, createHash, randomBytes, timingSafeEqual } from "crypto";
|
|
3
3
|
var SESSION_DAYS = 30;
|
|
4
|
+
var MIN_SECRET_BYTES = 32;
|
|
4
5
|
var COOKIE_NAME_RE = /^[A-Za-z0-9_-]+$/;
|
|
5
6
|
var NONCE_RE = /^[0-9a-f]{24}$/;
|
|
6
7
|
var HEX_RE = /^[0-9a-f]+$/;
|
|
8
|
+
function assertSecretLength(secret) {
|
|
9
|
+
if (Buffer.byteLength(secret) < MIN_SECRET_BYTES) {
|
|
10
|
+
throw new Error(
|
|
11
|
+
`session secret is too short: ${Buffer.byteLength(secret)} bytes, need at least ${MIN_SECRET_BYTES}. Generate one with: node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"`
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
7
15
|
function equalStrings(a, b) {
|
|
8
16
|
const x = Buffer.from(a);
|
|
9
17
|
const y = Buffer.from(b);
|
|
@@ -11,6 +19,7 @@ function equalStrings(a, b) {
|
|
|
11
19
|
}
|
|
12
20
|
function createSessionToken(secret, now = Date.now(), days = SESSION_DAYS) {
|
|
13
21
|
if (secret === "") throw new Error("session secret is empty");
|
|
22
|
+
assertSecretLength(secret);
|
|
14
23
|
const expires = Math.floor(now / 1e3) + Math.round(days * 86400);
|
|
15
24
|
const body = `v1.${expires}.${randomBytes(12).toString("hex")}`;
|
|
16
25
|
const sig = createHmac("sha256", secret).update(body).digest("base64url");
|
|
@@ -42,7 +51,7 @@ function verifySessionToken(secret, token, opts = {}) {
|
|
|
42
51
|
}
|
|
43
52
|
function passwordMatches(expected, provided, opts = {}) {
|
|
44
53
|
if (typeof expected !== "string" || typeof provided !== "string" || expected === "") return false;
|
|
45
|
-
const fold = opts.caseInsensitive ??
|
|
54
|
+
const fold = opts.caseInsensitive ?? false;
|
|
46
55
|
const a = fold ? expected.trim().toLowerCase() : expected;
|
|
47
56
|
const b = fold ? provided.trim().toLowerCase() : provided;
|
|
48
57
|
const ha = createHash("sha256").update(a).digest();
|
|
@@ -67,6 +76,7 @@ function readCookie(header, name) {
|
|
|
67
76
|
}
|
|
68
77
|
function createSessionAuth(o) {
|
|
69
78
|
if (!COOKIE_NAME_RE.test(o.cookieName)) throw new Error(`invalid cookie name: ${o.cookieName}`);
|
|
79
|
+
if (typeof o.secret === "string") assertSecretLength(o.secret);
|
|
70
80
|
const days = o.days ?? SESSION_DAYS;
|
|
71
81
|
const secret = () => typeof o.secret === "function" ? o.secret() : o.secret;
|
|
72
82
|
const auth = {
|
|
@@ -87,18 +97,20 @@ function isLoopback(address) {
|
|
|
87
97
|
const a = address.trim().toLowerCase();
|
|
88
98
|
return a === "::1" || /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a) || a.startsWith("::ffff:127.");
|
|
89
99
|
}
|
|
90
|
-
function clientIp(get, remoteAddress) {
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
function clientIp(get, remoteAddress, opts = {}) {
|
|
101
|
+
const trust = opts.trust ?? "none";
|
|
102
|
+
if (trust === "cloudflare") {
|
|
103
|
+
const cf = get("cf-connecting-ip")?.trim();
|
|
104
|
+
if (cf && cf.length <= 64 && !cf.includes(",")) return cf;
|
|
105
|
+
}
|
|
106
|
+
if (trust === "cloudflare" || trust === "proxy") {
|
|
107
|
+
const xff = get("x-forwarded-for");
|
|
108
|
+
if (xff) {
|
|
109
|
+
const hop = xff.split(",").pop()?.trim();
|
|
110
|
+
if (hop) return hop;
|
|
98
111
|
}
|
|
99
112
|
}
|
|
100
|
-
|
|
101
|
-
return "local";
|
|
113
|
+
return remoteAddress ? remoteAddress : null;
|
|
102
114
|
}
|
|
103
115
|
|
|
104
116
|
// src/server/limiter.ts
|
|
@@ -107,27 +119,39 @@ function createLimiter(o = {}) {
|
|
|
107
119
|
const windowMs = o.windowMs ?? 6e4;
|
|
108
120
|
const cap = o.cap ?? 1e4;
|
|
109
121
|
const entries = /* @__PURE__ */ new Map();
|
|
122
|
+
const makeRoom = (now) => {
|
|
123
|
+
if (entries.size < cap) return true;
|
|
124
|
+
for (const [k, v] of entries) if (v.reset <= now) entries.delete(k);
|
|
125
|
+
for (const [k, v] of entries) {
|
|
126
|
+
if (entries.size < cap) break;
|
|
127
|
+
if (v.count < max) entries.delete(k);
|
|
128
|
+
}
|
|
129
|
+
return entries.size < cap;
|
|
130
|
+
};
|
|
131
|
+
const touch = (key, now) => {
|
|
132
|
+
const e = entries.get(key);
|
|
133
|
+
if (e && e.reset > now) return e;
|
|
134
|
+
entries.delete(key);
|
|
135
|
+
if (!makeRoom(now)) return null;
|
|
136
|
+
const fresh = { count: 0, reset: now + windowMs };
|
|
137
|
+
entries.set(key, fresh);
|
|
138
|
+
return fresh;
|
|
139
|
+
};
|
|
110
140
|
return {
|
|
141
|
+
hit(key, now = Date.now()) {
|
|
142
|
+
const e = touch(key, now);
|
|
143
|
+
if (!e) return false;
|
|
144
|
+
e.count += 1;
|
|
145
|
+
return e.count <= max;
|
|
146
|
+
},
|
|
111
147
|
allowed(key, now = Date.now()) {
|
|
112
148
|
const e = entries.get(key);
|
|
113
149
|
if (!e || e.reset <= now) return true;
|
|
114
150
|
return e.count < max;
|
|
115
151
|
},
|
|
116
152
|
fail(key, now = Date.now()) {
|
|
117
|
-
const e =
|
|
118
|
-
if (
|
|
119
|
-
entries.delete(key);
|
|
120
|
-
entries.set(key, { count: 1, reset: now + windowMs });
|
|
121
|
-
} else {
|
|
122
|
-
e.count += 1;
|
|
123
|
-
}
|
|
124
|
-
if (entries.size > cap) {
|
|
125
|
-
for (const [k, v] of entries) if (v.reset <= now) entries.delete(k);
|
|
126
|
-
for (const k of entries.keys()) {
|
|
127
|
-
if (entries.size <= cap) break;
|
|
128
|
-
entries.delete(k);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
153
|
+
const e = touch(key, now);
|
|
154
|
+
if (e) e.count += 1;
|
|
131
155
|
},
|
|
132
156
|
reset(key) {
|
|
133
157
|
entries.delete(key);
|
|
@@ -224,6 +248,10 @@ function errorResponse(err, req, log = (line) => console.error(line)) {
|
|
|
224
248
|
// src/server/spa.ts
|
|
225
249
|
import { readFile, stat } from "fs/promises";
|
|
226
250
|
import { resolve as resolve2, sep } from "path";
|
|
251
|
+
var SECURITY_HEADERS = {
|
|
252
|
+
"X-Content-Type-Options": "nosniff",
|
|
253
|
+
"Referrer-Policy": "strict-origin-when-cross-origin"
|
|
254
|
+
};
|
|
227
255
|
var TYPES = {
|
|
228
256
|
html: "text/html; charset=utf-8",
|
|
229
257
|
js: "text/javascript; charset=utf-8",
|
|
@@ -255,7 +283,6 @@ async function isFile(path) {
|
|
|
255
283
|
return false;
|
|
256
284
|
}
|
|
257
285
|
}
|
|
258
|
-
var text = (body, status) => new Response(body, { status, headers: { "Content-Type": "text/plain; charset=utf-8" } });
|
|
259
286
|
function createSpaHandler(o) {
|
|
260
287
|
const dir = resolve2(o.dir);
|
|
261
288
|
const indexName = o.index ?? "index.html";
|
|
@@ -263,9 +290,12 @@ function createSpaHandler(o) {
|
|
|
263
290
|
const maxAge = o.maxAge ?? 3600;
|
|
264
291
|
const notBuilt = o.notBuilt ?? "UI not built: run npm run build";
|
|
265
292
|
const indexPath = resolve2(dir, indexName);
|
|
293
|
+
const safety = { ...SECURITY_HEADERS };
|
|
294
|
+
if (o.frameOptions !== false) safety["X-Frame-Options"] = "SAMEORIGIN";
|
|
295
|
+
const text = (body, status) => new Response(body, { status, headers: { "Content-Type": "text/plain; charset=utf-8", ...safety } });
|
|
266
296
|
const send = async (file, cache, head) => {
|
|
267
297
|
const body = head ? null : await readFile(file);
|
|
268
|
-
return new Response(body, { status: 200, headers: { "Content-Type": contentType(file), "Cache-Control": cache } });
|
|
298
|
+
return new Response(body, { status: 200, headers: { "Content-Type": contentType(file), "Cache-Control": cache, ...safety } });
|
|
269
299
|
};
|
|
270
300
|
return async (req) => {
|
|
271
301
|
const head = req.method === "HEAD";
|
|
@@ -320,9 +350,9 @@ var ISO_RE = /^\d{4}-\d{2}-\d{2}([T ]\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:?\
|
|
|
320
350
|
var SEVERITIES = ["info", "normal", "urgent"];
|
|
321
351
|
var ACTION_ID_RE = /^[a-z0-9][a-z0-9-]{0,31}$/;
|
|
322
352
|
var ACTIONS_MAX = 3;
|
|
323
|
-
function cut(
|
|
324
|
-
const chars = [...
|
|
325
|
-
return chars.length > max ? chars.slice(0, max - 1).join("") + "\u2026" :
|
|
353
|
+
function cut(text, max) {
|
|
354
|
+
const chars = [...text];
|
|
355
|
+
return chars.length > max ? chars.slice(0, max - 1).join("") + "\u2026" : text;
|
|
326
356
|
}
|
|
327
357
|
function isPlainObject(v) {
|
|
328
358
|
return typeof v === "object" && v !== null && !Array.isArray(v);
|
|
@@ -447,7 +477,9 @@ function createInboxClient(options) {
|
|
|
447
477
|
const devOff = options.url === void 0 && !envUrl && !!env?.npm_lifecycle_event && env?.NODE_ENV !== "production";
|
|
448
478
|
const baseUrl = (options.url ?? (envUrl || DEFAULT_URL)).trim();
|
|
449
479
|
const disabled = baseUrl === "off" || devOff;
|
|
450
|
-
|
|
480
|
+
let trimmed = baseUrl;
|
|
481
|
+
while (trimmed.endsWith("/")) trimmed = trimmed.slice(0, -1);
|
|
482
|
+
const endpoint = `${trimmed}/ingest/events`;
|
|
451
483
|
const timeoutMs = options.timeoutMs ?? 3e3;
|
|
452
484
|
const log = options.log ?? ((message) => console.warn(`[inbox] ${message}`));
|
|
453
485
|
if (devOff) log("off outside production; set INBOX_URL to send");
|
|
@@ -704,15 +736,15 @@ function parseEntries(raw, where) {
|
|
|
704
736
|
function readSeed(o) {
|
|
705
737
|
const out = [];
|
|
706
738
|
if (o.file) {
|
|
707
|
-
let
|
|
739
|
+
let text = null;
|
|
708
740
|
try {
|
|
709
|
-
|
|
741
|
+
text = readFileSync2(o.file, "utf8");
|
|
710
742
|
} catch (err) {
|
|
711
743
|
if (err.code !== "ENOENT") console.warn(`[service-tokens] ${o.file}: ${err.message}`);
|
|
712
744
|
}
|
|
713
|
-
if (
|
|
745
|
+
if (text !== null) {
|
|
714
746
|
try {
|
|
715
|
-
for (const entry of parseEntries(JSON.parse(
|
|
747
|
+
for (const entry of parseEntries(JSON.parse(text), o.file)) out.push({ entry, source: "file" });
|
|
716
748
|
} catch {
|
|
717
749
|
console.warn(`[service-tokens] ${o.file}: not valid JSON, ignored`);
|
|
718
750
|
}
|
|
@@ -740,9 +772,9 @@ function jsonRevocationStore(file) {
|
|
|
740
772
|
};
|
|
741
773
|
return {
|
|
742
774
|
load() {
|
|
743
|
-
let
|
|
775
|
+
let text;
|
|
744
776
|
try {
|
|
745
|
-
|
|
777
|
+
text = readFileSync2(file, "utf8");
|
|
746
778
|
} catch (err) {
|
|
747
779
|
if (err.code === "ENOENT") return [];
|
|
748
780
|
throw err;
|
|
@@ -754,7 +786,7 @@ function jsonRevocationStore(file) {
|
|
|
754
786
|
};
|
|
755
787
|
let raw;
|
|
756
788
|
try {
|
|
757
|
-
raw = JSON.parse(
|
|
789
|
+
raw = JSON.parse(text);
|
|
758
790
|
} catch {
|
|
759
791
|
return setAside("not valid JSON");
|
|
760
792
|
}
|
|
@@ -881,6 +913,7 @@ export {
|
|
|
881
913
|
INBOX_ACTION_TIMEOUT_MS,
|
|
882
914
|
INBOX_DEFAULT_SETTINGS,
|
|
883
915
|
INBOX_SOURCE_LABELS,
|
|
916
|
+
MIN_SECRET_BYTES,
|
|
884
917
|
SESSION_DAYS,
|
|
885
918
|
actionTokenMatches,
|
|
886
919
|
appRoot,
|
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
/** 127.0.0.0/8, ::1 and ::ffff:127.x. */
|
|
2
|
+
declare function isLoopback(address: string | null | undefined): boolean;
|
|
3
|
+
/** Which forwarding headers `clientIp` believes.
|
|
4
|
+
* - 'none' (default): none. The socket address is the client. Right when the app is reached directly.
|
|
5
|
+
* - 'proxy': the rightmost `X-Forwarded-For` hop, which the nearest proxy appended itself. Use it
|
|
6
|
+
* when exactly one proxy you control sits in front of the app and no client can reach the app
|
|
7
|
+
* except through it.
|
|
8
|
+
* - 'cloudflare': `cf-connecting-ip`, then as 'proxy'. Use it only when every request really comes
|
|
9
|
+
* through Cloudflare (the origin refuses other traffic), or the header can be forged. */
|
|
10
|
+
type TrustProxy = 'none' | 'proxy' | 'cloudflare';
|
|
11
|
+
interface ClientIpOptions {
|
|
12
|
+
trust?: TrustProxy;
|
|
13
|
+
}
|
|
14
|
+
/** The address a limiter should key on, or null when the request has none (no trusted header and
|
|
15
|
+
* no socket address). Callers that rate limit must still count a null request: the session
|
|
16
|
+
* routes in hono.ts put every address-less request into one shared bucket.
|
|
17
|
+
* 'none' returns the socket address as is (a loopback peer too: behind a local proxy, set
|
|
18
|
+
* `trust`). 'proxy' returns the rightmost X-Forwarded-For hop, else the socket address.
|
|
19
|
+
* 'cloudflare' returns cf-connecting-ip (trimmed, at most 64 chars, no comma), else as 'proxy'. */
|
|
20
|
+
declare function clientIp(get: (name: string) => string | null | undefined, remoteAddress?: string | null, opts?: ClientIpOptions): string | null;
|
|
21
|
+
|
|
1
22
|
interface CrossSiteOptions {
|
|
2
23
|
/** Origins besides the request's own that may send writes, like 'https://start.nish.software'. */
|
|
3
24
|
allowedOrigins?: Iterable<string>;
|
|
@@ -186,6 +207,11 @@ interface InboxListResponse {
|
|
|
186
207
|
}
|
|
187
208
|
|
|
188
209
|
interface Limiter {
|
|
210
|
+
/** Counts one attempt for key and says whether it may go ahead: true for the first `max`
|
|
211
|
+
* attempts inside the current window, false after. Synchronous, so check it before any
|
|
212
|
+
* `await` and parallel requests cannot all pass. A new key when the limiter is full of locked
|
|
213
|
+
* keys gets false. */
|
|
214
|
+
hit(key: string, now?: number): boolean;
|
|
189
215
|
/** False once `max` failures happened inside the current window for key. */
|
|
190
216
|
allowed(key: string, now?: number): boolean;
|
|
191
217
|
/** Records a failure. A missing or expired entry restarts at 1 with reset = now + windowMs. */
|
|
@@ -289,7 +315,10 @@ declare function checkServiceRequest(get: (name: string) => string | undefined,
|
|
|
289
315
|
} | null;
|
|
290
316
|
|
|
291
317
|
declare const SESSION_DAYS = 30;
|
|
292
|
-
/**
|
|
318
|
+
/** The shortest session secret accepted, in bytes. */
|
|
319
|
+
declare const MIN_SECRET_BYTES = 32;
|
|
320
|
+
/** Throws when the secret is empty or shorter than 32 bytes.
|
|
321
|
+
* `v1.<expires s>.<24 hex nonce>.<base64url hmac-sha256 of the first three parts>` */
|
|
293
322
|
declare function createSessionToken(secret: string, now?: number, days?: number): string;
|
|
294
323
|
interface VerifyOptions {
|
|
295
324
|
now?: number;
|
|
@@ -300,8 +329,8 @@ interface VerifyOptions {
|
|
|
300
329
|
* False for: empty secret, missing token, wrong part count or prefix, non-finite or past expiry,
|
|
301
330
|
* signature length mismatch. Constant-time compare (timingSafeEqual on equal-length buffers). */
|
|
302
331
|
declare function verifySessionToken(secret: string, token: string | null | undefined, opts?: VerifyOptions): boolean;
|
|
303
|
-
/** sha256 both sides, timingSafeEqual.
|
|
304
|
-
* Always false when expected is ''. */
|
|
332
|
+
/** sha256 both sides, timingSafeEqual. An exact match by default: no trimming, case matters.
|
|
333
|
+
* caseInsensitive: true trims and lowercases both sides first. Always false when expected is ''. */
|
|
305
334
|
declare function passwordMatches(expected: string, provided: string, opts?: {
|
|
306
335
|
caseInsensitive?: boolean;
|
|
307
336
|
}): boolean;
|
|
@@ -321,6 +350,8 @@ interface SessionAuth {
|
|
|
321
350
|
/** `<name>=; Max-Age=0; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT; HttpOnly; SameSite=Lax` */
|
|
322
351
|
clearCookie(): string;
|
|
323
352
|
}
|
|
353
|
+
/** Throws at setup for a bad cookie name or, when `secret` is a string, one shorter than 32 bytes.
|
|
354
|
+
* A function secret is checked each time a token is issued. */
|
|
324
355
|
declare function createSessionAuth(o: {
|
|
325
356
|
cookieName: string;
|
|
326
357
|
secret: string | (() => string);
|
|
@@ -334,8 +365,10 @@ interface SpaOptions {
|
|
|
334
365
|
immutable?: string[];
|
|
335
366
|
maxAge?: number;
|
|
336
367
|
notBuilt?: string;
|
|
368
|
+
/** Sends `X-Frame-Options: SAMEORIGIN` unless false (for an app that is meant to be framed). */
|
|
369
|
+
frameOptions?: false;
|
|
337
370
|
}
|
|
338
371
|
declare function createSpaHandler(o: SpaOptions): (req: Request) => Promise<Response>;
|
|
339
372
|
|
|
340
|
-
export {
|
|
341
|
-
export type { CrossSiteOptions as C, InboxActionCall as I, Limiter as L, ManagedServiceTokens as M, RevocationStore as R, SessionAuth as S, VerifyOptions as V, InboxData as a, SpaOptions as b, InboxEventInput as c, InboxIngestAction as d, InboxEvent as e, InboxAction as f, InboxActionResult as
|
|
373
|
+
export { createLimiter as A, createServiceTokens as B, createSessionAuth as D, createSessionToken as E, createSpaHandler as F, hashServiceToken as G, isCrossSiteWrite as H, isDirectLoopback as J, isLoopback as K, jsonRevocationStore as N, loadManagedServiceTokens as O, loadServiceTokens as P, mintServiceToken as Q, passwordMatches as U, readCookie as W, verifySessionToken as X, INBOX_ACTION_HEADER as h, INBOX_ACTION_TIMEOUT_MS as i, INBOX_DEFAULT_SETTINGS as j, INBOX_SOURCE_LABELS as k, MIN_SECRET_BYTES as r, SESSION_DAYS as t, checkServiceRequest as y, clientIp as z };
|
|
374
|
+
export type { CrossSiteOptions as C, InboxActionCall as I, Limiter as L, ManagedServiceTokens as M, RevocationStore as R, SessionAuth as S, TrustProxy as T, VerifyOptions as V, InboxData as a, SpaOptions as b, InboxEventInput as c, InboxIngestAction as d, InboxEvent as e, InboxAction as f, ClientIpOptions as g, InboxActionResult as l, InboxItem as m, InboxListResponse as n, InboxSettings as o, InboxSeverity as p, InboxView as q, RevokedToken as s, ServiceTokenEntry as u, ServiceTokenView as v, ServiceTokens as w, VerifyResult as x };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode, ComponentPropsWithoutRef, Ref } from 'react';
|
|
3
|
+
|
|
4
|
+
type CanvasHue = 'indigo' | 'emerald' | 'amber' | 'lime' | 'rose' | 'sky' | 'violet' | 'teal';
|
|
5
|
+
type CanvasNodeKind = 'ui' | 'service' | 'worker' | 'library' | 'infra' | 'data' | 'tool' | 'docs';
|
|
6
|
+
interface CanvasNode {
|
|
7
|
+
id: string;
|
|
8
|
+
label: string;
|
|
9
|
+
kind?: CanvasNodeKind;
|
|
10
|
+
detail?: string;
|
|
11
|
+
/** 0..1 afterglow */
|
|
12
|
+
heat?: number;
|
|
13
|
+
/** live work here now */
|
|
14
|
+
active?: boolean;
|
|
15
|
+
/** When the newest activity here happened, ms. Follow mode visits the newest first. */
|
|
16
|
+
activeAt?: number;
|
|
17
|
+
/** shown under an active node, max ~48 chars */
|
|
18
|
+
note?: string;
|
|
19
|
+
/** sessions/agents here */
|
|
20
|
+
count?: number;
|
|
21
|
+
}
|
|
22
|
+
interface CanvasGroup {
|
|
23
|
+
id: string;
|
|
24
|
+
title: string;
|
|
25
|
+
subtitle?: string;
|
|
26
|
+
hue?: CanvasHue;
|
|
27
|
+
/** Left-to-right layer in the "columns" layout; also orders groups inside a band. */
|
|
28
|
+
column: number;
|
|
29
|
+
/** Top-to-bottom band in the "bands" layout. Default: `column`. */
|
|
30
|
+
band?: number;
|
|
31
|
+
badge?: ReactNode;
|
|
32
|
+
nodes: CanvasNode[];
|
|
33
|
+
}
|
|
34
|
+
interface CanvasEdge {
|
|
35
|
+
id: string;
|
|
36
|
+
/** node or group id */
|
|
37
|
+
from: string;
|
|
38
|
+
/** node or group id */
|
|
39
|
+
to: string;
|
|
40
|
+
/** Overrides the kind's line style with a dashed line. */
|
|
41
|
+
dashed?: boolean;
|
|
42
|
+
label?: string;
|
|
43
|
+
/** A `CanvasEdgeKind` id: sets the line style and which legend toggle shows or hides it. */
|
|
44
|
+
kind?: string;
|
|
45
|
+
}
|
|
46
|
+
/** One entry of the line legend. */
|
|
47
|
+
interface CanvasEdgeKind {
|
|
48
|
+
id: string;
|
|
49
|
+
/** Legend text ("Traffic", "Deploys"). */
|
|
50
|
+
label: string;
|
|
51
|
+
/** Default "solid". */
|
|
52
|
+
line?: 'solid' | 'dashed' | 'dotted';
|
|
53
|
+
/** Hidden until the viewer turns it on in the legend. */
|
|
54
|
+
hidden?: boolean;
|
|
55
|
+
}
|
|
56
|
+
/** "columns": layers left to right. "bands": bands top to bottom, each wrapping its groups into
|
|
57
|
+
* rows. "auto": whichever shows the map biggest in the current viewport. */
|
|
58
|
+
type CanvasLayoutMode = 'columns' | 'bands' | 'auto';
|
|
59
|
+
/** Text of the canvas that has no key in `NishStrings`. Each one wins over its English default. */
|
|
60
|
+
interface CanvasLabels {
|
|
61
|
+
/** Added to the "Lines" button when kinds are hidden: "· 2 hidden". */
|
|
62
|
+
hidden: (count: number) => string;
|
|
63
|
+
/** Follow caption when nothing is active. */
|
|
64
|
+
followIdle: string;
|
|
65
|
+
/** Follow caption for one node. */
|
|
66
|
+
followOne: (group: string, label: string) => string;
|
|
67
|
+
/** Follow caption for several nodes. */
|
|
68
|
+
followMany: (count: number) => string;
|
|
69
|
+
}
|
|
70
|
+
declare const DEFAULT_CANVAS_LABELS: CanvasLabels;
|
|
71
|
+
interface SystemCanvasProps extends Omit<ComponentPropsWithoutRef<'div'>, 'onSelect' | 'children' | 'aria-label'> {
|
|
72
|
+
ref?: Ref<HTMLDivElement>;
|
|
73
|
+
groups: CanvasGroup[];
|
|
74
|
+
edges: CanvasEdge[];
|
|
75
|
+
/** Faint titles above each column ("Edge", "Infra", "Apps", ...), by column index. */
|
|
76
|
+
columns?: string[];
|
|
77
|
+
/** Titles of the bands in the "bands" layout, by band index. Falls back to `columns`. */
|
|
78
|
+
bands?: string[];
|
|
79
|
+
/** Default "auto". */
|
|
80
|
+
layout?: CanvasLayoutMode;
|
|
81
|
+
/** The line legend. Edges whose kind is hidden are left out of the layout and routing. */
|
|
82
|
+
edgeKinds?: CanvasEdgeKind[];
|
|
83
|
+
/** Follow mode: the view flies to where work is happening. Controlled when set. */
|
|
84
|
+
follow?: boolean;
|
|
85
|
+
onFollowChange?: (on: boolean) => void;
|
|
86
|
+
/** Overview map in a corner on viewports 600 px wide or more. Default true. */
|
|
87
|
+
minimap?: boolean;
|
|
88
|
+
selected?: string | null;
|
|
89
|
+
onSelect?: (id: string, type: 'node' | 'group') => void;
|
|
90
|
+
/** CSS height of the viewport. Default "100%". */
|
|
91
|
+
height?: string;
|
|
92
|
+
/** aria-label. Default: the `systemMap` string ("System map"). */
|
|
93
|
+
label?: string;
|
|
94
|
+
/** Text without a key in the provider's strings (follow caption, hidden-lines count). */
|
|
95
|
+
labels?: Partial<CanvasLabels>;
|
|
96
|
+
className?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** A pannable, zoomable graph-paper canvas of grouped nodes joined by edges. Nodes with
|
|
100
|
+
* `active` pulse in their group's hue, edges into them flow, and `heat` leaves a fading
|
|
101
|
+
* glow behind. Drag or scroll to pan, ctrl+scroll or pinch to zoom, arrow keys, `+`, `-`
|
|
102
|
+
* and `0` from the keyboard. */
|
|
103
|
+
declare function SystemCanvas({ groups, edges, columns, bands, layout: layoutMode, edgeKinds, follow, onFollowChange, minimap, selected, onSelect, height, label: labelProp, labels: labelOverrides, className, style, ref: forwardedRef, ...rest }: SystemCanvasProps): react.JSX.Element;
|
|
104
|
+
|
|
105
|
+
interface CanvasLayout {
|
|
106
|
+
mode: "columns" | "bands";
|
|
107
|
+
width: number;
|
|
108
|
+
height: number;
|
|
109
|
+
/** World px above y = 0 taken by the headers: 36 in "columns" (titles sit above the cards), 0 in "bands" (titles sit inside). */
|
|
110
|
+
titleRoom: number;
|
|
111
|
+
/** Top-left of each column's ("columns") or band's ("bands") title, world px; `index` is the column or band value. */
|
|
112
|
+
headers: {
|
|
113
|
+
index: number;
|
|
114
|
+
x: number;
|
|
115
|
+
y: number;
|
|
116
|
+
}[];
|
|
117
|
+
groups: Record<string, {
|
|
118
|
+
x: number;
|
|
119
|
+
y: number;
|
|
120
|
+
w: number;
|
|
121
|
+
h: number;
|
|
122
|
+
}>;
|
|
123
|
+
nodes: Record<string, {
|
|
124
|
+
x: number;
|
|
125
|
+
y: number;
|
|
126
|
+
w: number;
|
|
127
|
+
h: number;
|
|
128
|
+
}>;
|
|
129
|
+
}
|
|
130
|
+
/** Where every group and node sits, in world units (px at zoom 1). Pure and deterministic.
|
|
131
|
+
*
|
|
132
|
+
* "columns" (default): columns are the distinct `column` values in ascending order, groups
|
|
133
|
+
* stack in the order given, nodes sit in a 2-column grid inside their group (1 column for a
|
|
134
|
+
* group of one), and each column is centered against the tallest. The first sub-column starts
|
|
135
|
+
* 60 px in and `width` includes 60 px after the last, which is room for the edge lanes
|
|
136
|
+
* outside the cards.
|
|
137
|
+
*
|
|
138
|
+
* "bands": bands are the distinct `band ?? column` values in ascending order, stacked top to
|
|
139
|
+
* bottom; each band wraps its groups (by `column`, then input order) into rows no wider than
|
|
140
|
+
* `width`. The gaps between rows grow with the number of edge ends that need lanes there. */
|
|
141
|
+
interface LayoutOptions {
|
|
142
|
+
/** Default "columns". */
|
|
143
|
+
mode?: "columns" | "bands";
|
|
144
|
+
/** "bands" only: the widest a row of groups may get, world px (at least one group per row). */
|
|
145
|
+
width?: number;
|
|
146
|
+
/** "bands" only: used to size the gaps between rows for the edge lanes. */
|
|
147
|
+
edges?: CanvasEdge[];
|
|
148
|
+
columnGap?: number;
|
|
149
|
+
rowGap?: number;
|
|
150
|
+
}
|
|
151
|
+
declare function layoutSystem(groups: CanvasGroup[], o?: LayoutOptions): CanvasLayout;
|
|
152
|
+
/** The layout to show in a viewport of `viewport` px. "columns" and "bands" use that mode;
|
|
153
|
+
* "auto" picks whichever candidate shows the map biggest. Pure and deterministic. */
|
|
154
|
+
declare function pickLayout(groups: CanvasGroup[], edges: CanvasEdge[], viewport: {
|
|
155
|
+
w: number;
|
|
156
|
+
h: number;
|
|
157
|
+
}, mode?: CanvasLayoutMode): CanvasLayout;
|
|
158
|
+
|
|
159
|
+
interface RoutedEdge {
|
|
160
|
+
id: string;
|
|
161
|
+
/** The corners of the line, source port first. Every segment is horizontal or vertical. */
|
|
162
|
+
points: [number, number][];
|
|
163
|
+
/** The same line as an SVG path with rounded corners; also valid for CSS `offset-path`. */
|
|
164
|
+
d: string;
|
|
165
|
+
/** Direction of travel of the last segment: "right" in "columns", "down" in "bands". */
|
|
166
|
+
dir: 'right' | 'down';
|
|
167
|
+
}
|
|
168
|
+
/** Routes every edge as an orthogonal line (horizontal and vertical segments, rounded corners)
|
|
169
|
+
* from the right border of its source card to the left border of its target card. A node
|
|
170
|
+
* attaches at its own center height, a group at its card's middle. Group boxes are clustered
|
|
171
|
+
* into sub-columns by x; the gaps between them (and 60 px outside the first and last) are
|
|
172
|
+
* channels, where vertical lanes run: one lane per source port (edges from a port share a
|
|
173
|
+
* trunk) and one per target port (edges into a port merge). An edge to a sub-column further
|
|
174
|
+
* right than the next travels along a horizontal corridor free of cards; backward edges and
|
|
175
|
+
* edges inside one sub-column do the same, mirrored. Two edges share a line only at a shared
|
|
176
|
+
* source or target port. Pure and deterministic; the result is keyed by edge id and skips
|
|
177
|
+
* edges with an unknown end. In a "bands" layout the same router runs on the transposed layout
|
|
178
|
+
* (x and y swapped) and the points are swapped back: lines leave the bottom border of the
|
|
179
|
+
* source card and enter the top border of the target card, and `dir` is "down". */
|
|
180
|
+
declare function routeEdges(layout: CanvasLayout, groups: CanvasGroup[], edges: CanvasEdge[]): Record<string, RoutedEdge>;
|
|
181
|
+
|
|
182
|
+
export { DEFAULT_CANVAS_LABELS as D, SystemCanvas as S, layoutSystem as l, pickLayout as p, routeEdges as r };
|
|
183
|
+
export type { CanvasEdge as C, LayoutOptions as L, RoutedEdge as R, CanvasEdgeKind as a, CanvasGroup as b, CanvasHue as c, CanvasLabels as d, CanvasLayout as e, CanvasLayoutMode as f, CanvasNode as g, CanvasNodeKind as h, SystemCanvasProps as i };
|
package/dist/system-canvas.d.ts
CHANGED
|
@@ -1,168 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
type CanvasHue = 'indigo' | 'emerald' | 'amber' | 'lime' | 'rose' | 'sky' | 'violet' | 'teal';
|
|
5
|
-
type CanvasNodeKind = 'ui' | 'service' | 'worker' | 'library' | 'infra' | 'data' | 'tool' | 'docs';
|
|
6
|
-
interface CanvasNode {
|
|
7
|
-
id: string;
|
|
8
|
-
label: string;
|
|
9
|
-
kind?: CanvasNodeKind;
|
|
10
|
-
detail?: string;
|
|
11
|
-
/** 0..1 afterglow */
|
|
12
|
-
heat?: number;
|
|
13
|
-
/** live work here now */
|
|
14
|
-
active?: boolean;
|
|
15
|
-
/** When the newest activity here happened, ms. Follow mode visits the newest first. */
|
|
16
|
-
activeAt?: number;
|
|
17
|
-
/** shown under an active node, max ~48 chars */
|
|
18
|
-
note?: string;
|
|
19
|
-
/** sessions/agents here */
|
|
20
|
-
count?: number;
|
|
21
|
-
}
|
|
22
|
-
interface CanvasGroup {
|
|
23
|
-
id: string;
|
|
24
|
-
title: string;
|
|
25
|
-
subtitle?: string;
|
|
26
|
-
hue?: CanvasHue;
|
|
27
|
-
/** Left-to-right layer in the "columns" layout; also orders groups inside a band. */
|
|
28
|
-
column: number;
|
|
29
|
-
/** Top-to-bottom band in the "bands" layout. Default: `column`. */
|
|
30
|
-
band?: number;
|
|
31
|
-
badge?: ReactNode;
|
|
32
|
-
nodes: CanvasNode[];
|
|
33
|
-
}
|
|
34
|
-
interface CanvasEdge {
|
|
35
|
-
id: string;
|
|
36
|
-
/** node or group id */
|
|
37
|
-
from: string;
|
|
38
|
-
/** node or group id */
|
|
39
|
-
to: string;
|
|
40
|
-
/** Overrides the kind's line style with a dashed line. */
|
|
41
|
-
dashed?: boolean;
|
|
42
|
-
label?: string;
|
|
43
|
-
/** A `CanvasEdgeKind` id: sets the line style and which legend toggle shows or hides it. */
|
|
44
|
-
kind?: string;
|
|
45
|
-
}
|
|
46
|
-
/** One entry of the line legend. */
|
|
47
|
-
interface CanvasEdgeKind {
|
|
48
|
-
id: string;
|
|
49
|
-
/** Legend text ("Traffic", "Deploys"). */
|
|
50
|
-
label: string;
|
|
51
|
-
/** Default "solid". */
|
|
52
|
-
line?: 'solid' | 'dashed' | 'dotted';
|
|
53
|
-
/** Hidden until the viewer turns it on in the legend. */
|
|
54
|
-
hidden?: boolean;
|
|
55
|
-
}
|
|
56
|
-
/** "columns": layers left to right. "bands": bands top to bottom, each wrapping its groups into
|
|
57
|
-
* rows. "auto": whichever shows the map biggest in the current viewport. */
|
|
58
|
-
type CanvasLayoutMode = 'columns' | 'bands' | 'auto';
|
|
59
|
-
interface SystemCanvasProps {
|
|
60
|
-
groups: CanvasGroup[];
|
|
61
|
-
edges: CanvasEdge[];
|
|
62
|
-
/** Faint titles above each column ("Edge", "Infra", "Apps", ...), by column index. */
|
|
63
|
-
columns?: string[];
|
|
64
|
-
/** Titles of the bands in the "bands" layout, by band index. Falls back to `columns`. */
|
|
65
|
-
bands?: string[];
|
|
66
|
-
/** Default "auto". */
|
|
67
|
-
layout?: CanvasLayoutMode;
|
|
68
|
-
/** The line legend. Edges whose kind is hidden are left out of the layout and routing. */
|
|
69
|
-
edgeKinds?: CanvasEdgeKind[];
|
|
70
|
-
/** Follow mode: the view flies to where work is happening. Controlled when set. */
|
|
71
|
-
follow?: boolean;
|
|
72
|
-
onFollowChange?: (on: boolean) => void;
|
|
73
|
-
/** Overview map in a corner on viewports 600 px wide or more. Default true. */
|
|
74
|
-
minimap?: boolean;
|
|
75
|
-
selected?: string | null;
|
|
76
|
-
onSelect?: (id: string, type: 'node' | 'group') => void;
|
|
77
|
-
/** CSS height of the viewport. Default "100%". */
|
|
78
|
-
height?: string;
|
|
79
|
-
/** aria-label. Default "System map". */
|
|
80
|
-
label?: string;
|
|
81
|
-
className?: string;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/** A pannable, zoomable graph-paper canvas of grouped nodes joined by edges. Nodes with
|
|
85
|
-
* `active` pulse in their group's hue, edges into them flow, and `heat` leaves a fading
|
|
86
|
-
* glow behind. Drag or scroll to pan, ctrl+scroll or pinch to zoom, arrow keys, `+`, `-`
|
|
87
|
-
* and `0` from the keyboard. */
|
|
88
|
-
declare function SystemCanvas({ groups, edges, columns, bands, layout: layoutMode, edgeKinds, follow, onFollowChange, minimap, selected, onSelect, height, label, className, }: SystemCanvasProps): react.JSX.Element;
|
|
89
|
-
|
|
90
|
-
interface CanvasLayout {
|
|
91
|
-
mode: "columns" | "bands";
|
|
92
|
-
width: number;
|
|
93
|
-
height: number;
|
|
94
|
-
/** World px above y = 0 taken by the headers: 36 in "columns" (titles sit above the cards), 0 in "bands" (titles sit inside). */
|
|
95
|
-
titleRoom: number;
|
|
96
|
-
/** Top-left of each column's ("columns") or band's ("bands") title, world px; `index` is the column or band value. */
|
|
97
|
-
headers: {
|
|
98
|
-
index: number;
|
|
99
|
-
x: number;
|
|
100
|
-
y: number;
|
|
101
|
-
}[];
|
|
102
|
-
groups: Record<string, {
|
|
103
|
-
x: number;
|
|
104
|
-
y: number;
|
|
105
|
-
w: number;
|
|
106
|
-
h: number;
|
|
107
|
-
}>;
|
|
108
|
-
nodes: Record<string, {
|
|
109
|
-
x: number;
|
|
110
|
-
y: number;
|
|
111
|
-
w: number;
|
|
112
|
-
h: number;
|
|
113
|
-
}>;
|
|
114
|
-
}
|
|
115
|
-
/** Where every group and node sits, in world units (px at zoom 1). Pure and deterministic.
|
|
116
|
-
*
|
|
117
|
-
* "columns" (default): columns are the distinct `column` values in ascending order, groups
|
|
118
|
-
* stack in the order given, nodes sit in a 2-column grid inside their group (1 column for a
|
|
119
|
-
* group of one), and each column is centered against the tallest. The first sub-column starts
|
|
120
|
-
* 60 px in and `width` includes 60 px after the last, which is room for the edge lanes
|
|
121
|
-
* outside the cards.
|
|
122
|
-
*
|
|
123
|
-
* "bands": bands are the distinct `band ?? column` values in ascending order, stacked top to
|
|
124
|
-
* bottom; each band wraps its groups (by `column`, then input order) into rows no wider than
|
|
125
|
-
* `width`. The gaps between rows grow with the number of edge ends that need lanes there. */
|
|
126
|
-
interface LayoutOptions {
|
|
127
|
-
/** Default "columns". */
|
|
128
|
-
mode?: "columns" | "bands";
|
|
129
|
-
/** "bands" only: the widest a row of groups may get, world px (at least one group per row). */
|
|
130
|
-
width?: number;
|
|
131
|
-
/** "bands" only: used to size the gaps between rows for the edge lanes. */
|
|
132
|
-
edges?: CanvasEdge[];
|
|
133
|
-
columnGap?: number;
|
|
134
|
-
rowGap?: number;
|
|
135
|
-
}
|
|
136
|
-
declare function layoutSystem(groups: CanvasGroup[], o?: LayoutOptions): CanvasLayout;
|
|
137
|
-
/** The layout to show in a viewport of `viewport` px. "columns" and "bands" use that mode;
|
|
138
|
-
* "auto" picks whichever candidate shows the map biggest. Pure and deterministic. */
|
|
139
|
-
declare function pickLayout(groups: CanvasGroup[], edges: CanvasEdge[], viewport: {
|
|
140
|
-
w: number;
|
|
141
|
-
h: number;
|
|
142
|
-
}, mode?: CanvasLayoutMode): CanvasLayout;
|
|
143
|
-
|
|
144
|
-
interface RoutedEdge {
|
|
145
|
-
id: string;
|
|
146
|
-
/** The corners of the line, source port first. Every segment is horizontal or vertical. */
|
|
147
|
-
points: [number, number][];
|
|
148
|
-
/** The same line as an SVG path with rounded corners; also valid for CSS `offset-path`. */
|
|
149
|
-
d: string;
|
|
150
|
-
/** Direction of travel of the last segment: "right" in "columns", "down" in "bands". */
|
|
151
|
-
dir: 'right' | 'down';
|
|
152
|
-
}
|
|
153
|
-
/** Routes every edge as an orthogonal line (horizontal and vertical segments, rounded corners)
|
|
154
|
-
* from the right border of its source card to the left border of its target card. A node
|
|
155
|
-
* attaches at its own center height, a group at its card's middle. Group boxes are clustered
|
|
156
|
-
* into sub-columns by x; the gaps between them (and 60 px outside the first and last) are
|
|
157
|
-
* channels, where vertical lanes run: one lane per source port (edges from a port share a
|
|
158
|
-
* trunk) and one per target port (edges into a port merge). An edge to a sub-column further
|
|
159
|
-
* right than the next travels along a horizontal corridor free of cards; backward edges and
|
|
160
|
-
* edges inside one sub-column do the same, mirrored. Two edges share a line only at a shared
|
|
161
|
-
* source or target port. Pure and deterministic; the result is keyed by edge id and skips
|
|
162
|
-
* edges with an unknown end. In a "bands" layout the same router runs on the transposed layout
|
|
163
|
-
* (x and y swapped) and the points are swapped back: lines leave the bottom border of the
|
|
164
|
-
* source card and enter the top border of the target card, and `dir` is "down". */
|
|
165
|
-
declare function routeEdges(layout: CanvasLayout, groups: CanvasGroup[], edges: CanvasEdge[]): Record<string, RoutedEdge>;
|
|
166
|
-
|
|
167
|
-
export { SystemCanvas, layoutSystem, pickLayout, routeEdges };
|
|
168
|
-
export type { CanvasEdge, CanvasEdgeKind, CanvasGroup, CanvasHue, CanvasLayout, CanvasLayoutMode, CanvasNode, CanvasNodeKind, LayoutOptions, RoutedEdge, SystemCanvasProps };
|
|
1
|
+
export { C as CanvasEdge, a as CanvasEdgeKind, b as CanvasGroup, c as CanvasHue, d as CanvasLabels, e as CanvasLayout, f as CanvasLayoutMode, g as CanvasNode, h as CanvasNodeKind, L as LayoutOptions, R as RoutedEdge, S as SystemCanvas, i as SystemCanvasProps, l as layoutSystem, p as pickLayout, r as routeEdges } from './system-canvas-BLuWd69H.js';
|
|
2
|
+
import 'react';
|