brane 0.0.2 → 0.3.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/AGENTS.md +362 -0
- package/CHANGELOG.md +33 -0
- package/CONTRIBUTING.md +91 -0
- package/DESIGN.md +402 -0
- package/Dockerfile +61 -0
- package/LICENSE +656 -17
- package/README.md +174 -2
- package/SECURITY.md +205 -0
- package/dist/absorb/brane-id.js +11 -0
- package/dist/absorb/chatgpt.js +161 -0
- package/dist/absorb/claude-code.js +504 -0
- package/dist/absorb/index.js +543 -0
- package/dist/absorb/organelle.js +345 -0
- package/dist/absorb/run.js +520 -0
- package/dist/absorb/sources.js +168 -0
- package/dist/absorb/types.js +3 -0
- package/dist/agent-env.js +45 -0
- package/dist/agents.js +1168 -0
- package/dist/claude-live-session.js +124 -0
- package/dist/cli.js +50 -0
- package/dist/codex-tool-log.js +144 -0
- package/dist/commands/absorb.js +291 -0
- package/dist/commands/attach.js +31 -0
- package/dist/commands/certify.js +62 -0
- package/dist/commands/config.js +116 -0
- package/dist/commands/cost.js +126 -0
- package/dist/commands/daemon.js +350 -0
- package/dist/commands/doctor.js +262 -0
- package/dist/commands/fold.js +95 -0
- package/dist/commands/list.js +89 -0
- package/dist/commands/mcp.js +84 -0
- package/dist/commands/meld.js +332 -0
- package/dist/commands/memory.js +215 -0
- package/dist/commands/revive.js +74 -0
- package/dist/commands/run.js +85 -0
- package/dist/commands/spawn.js +1094 -0
- package/dist/commands/token.js +153 -0
- package/dist/copilot-tool-log.js +145 -0
- package/dist/cost/pricing.js +116 -0
- package/dist/cost/reprice.js +136 -0
- package/dist/crush-tool-log.js +293 -0
- package/dist/daemon/agent-scope.js +116 -0
- package/dist/daemon/awaiting.js +54 -0
- package/dist/daemon/cert-manager.js +349 -0
- package/dist/daemon/client.js +262 -0
- package/dist/daemon/gated-routes.js +112 -0
- package/dist/daemon/keep-awake.js +103 -0
- package/dist/daemon/local-socket.js +145 -0
- package/dist/daemon/presence-gate.js +206 -0
- package/dist/daemon/server.js +6349 -0
- package/dist/daemon/signal-source.js +35 -0
- package/dist/daemon/tailscale-rebind.js +58 -0
- package/dist/daemon/token-ring.js +263 -0
- package/dist/daemon/token-routes.js +190 -0
- package/dist/db/events.js +152 -0
- package/dist/db/mentions.js +179 -0
- package/dist/db/schema.js +633 -0
- package/dist/db/tokens.js +583 -0
- package/dist/db/tool-uses.js +647 -0
- package/dist/diagram/index.js +85 -0
- package/dist/diagram/label.js +455 -0
- package/dist/diagram/layout.js +476 -0
- package/dist/diagram/links.js +50 -0
- package/dist/diagram/metrics.js +152 -0
- package/dist/diagram/parse.js +487 -0
- package/dist/diagram/svg.js +389 -0
- package/dist/diagram/types.js +9 -0
- package/dist/export.js +629 -0
- package/dist/files/archive-types.js +2 -0
- package/dist/files/archive.js +182 -0
- package/dist/files/browse.js +327 -0
- package/dist/files/bytes.js +162 -0
- package/dist/files/codecs.js +33 -0
- package/dist/files/find.js +212 -0
- package/dist/files/tar.js +223 -0
- package/dist/files/zip.js +209 -0
- package/dist/folds.js +72 -0
- package/dist/grammars/ebnf.js +92 -0
- package/dist/highlight.js +250 -0
- package/dist/ids.js +24 -0
- package/dist/markdown-diagnostics.js +233 -0
- package/dist/math.js +168 -0
- package/dist/mcp/server.js +886 -0
- package/dist/memory/embedder.js +145 -0
- package/dist/memory/embedding-worker.js +71 -0
- package/dist/memory/embeddings.js +91 -0
- package/dist/memory/index.js +232 -0
- package/dist/memory/storage.js +587 -0
- package/dist/memory/wiki.js +688 -0
- package/dist/memory/wordpiece.js +247 -0
- package/dist/mentions-scan.js +40 -0
- package/dist/presence.js +259 -0
- package/dist/session-affinity.js +185 -0
- package/dist/shared/api-request.js +124 -0
- package/dist/shared/block-glyphs.js +114 -0
- package/dist/shared/diagram-css.js +17 -0
- package/dist/shared/export-selection.js +101 -0
- package/dist/shared/find-in-text.js +110 -0
- package/dist/shared/glow-hues.js +225 -0
- package/dist/shared/hex-dump.js +62 -0
- package/dist/shared/hex-pages.js +52 -0
- package/dist/shared/hit-drum.js +79 -0
- package/dist/shared/known-nids.js +58 -0
- package/dist/shared/list-scroll-keys.js +56 -0
- package/dist/shared/markdown-lists.js +72 -0
- package/dist/shared/markdown-math.js +485 -0
- package/dist/shared/markdown-mentions.js +79 -0
- package/dist/shared/markdown-nids.js +41 -0
- package/dist/shared/markdown-protocols.js +53 -0
- package/dist/shared/markdown-refs.js +123 -0
- package/dist/shared/membrane-invasion.js +342 -0
- package/dist/shared/membrane-motion.js +83 -0
- package/dist/shared/membrane-palette.js +253 -0
- package/dist/shared/membrane-terrain.js +212 -0
- package/dist/shared/message-selection.js +123 -0
- package/dist/shared/mo-glyph.js +57 -0
- package/dist/shared/narrative-format.js +237 -0
- package/dist/shared/narrative-menu.js +82 -0
- package/dist/shared/narrative-sort.js +47 -0
- package/dist/shared/narrative-status.js +52 -0
- package/dist/shared/no-pan.js +85 -0
- package/dist/shared/pane-layout.js +50 -0
- package/dist/shared/payload-inline.js +83 -0
- package/dist/shared/speaker-color.js +61 -0
- package/dist/shared/token-rotation.js +14 -0
- package/dist/shared/view-url.js +197 -0
- package/dist/shared/wiki-links.js +70 -0
- package/dist/shared/wiki-window.js +4 -0
- package/dist/tailscale.js +55 -0
- package/dist/test/absorb-claude.test.js +892 -0
- package/dist/test/agent-scope.test.js +193 -0
- package/dist/test/agents.test.js +55 -0
- package/dist/test/api-request.test.js +122 -0
- package/dist/test/awaiting-glow.test.js +54 -0
- package/dist/test/awaiting.test.js +122 -0
- package/dist/test/bind-token.test.js +88 -0
- package/dist/test/block-glyphs.test.js +68 -0
- package/dist/test/cert-manager.test.js +262 -0
- package/dist/test/claude-live-session.test.js +110 -0
- package/dist/test/codex-tool-log.test.js +568 -0
- package/dist/test/config.test.js +71 -0
- package/dist/test/copilot-tool-log.test.js +93 -0
- package/dist/test/cors-preflight.test.js +49 -0
- package/dist/test/cost-linger.test.js +31 -0
- package/dist/test/cost-pricing.test.js +72 -0
- package/dist/test/cost-reprice.test.js +139 -0
- package/dist/test/cost-sessions.test.js +301 -0
- package/dist/test/crush-tool-log.test.js +289 -0
- package/dist/test/daemon-client.test.js +109 -0
- package/dist/test/daemon-socket.test.js +293 -0
- package/dist/test/diagram-arrows.test.js +205 -0
- package/dist/test/diagram-export.test.js +210 -0
- package/dist/test/diagram-labels.test.js +313 -0
- package/dist/test/diagram-parse.test.js +191 -0
- package/dist/test/diagram-render.test.js +175 -0
- package/dist/test/diagram-review.test.js +288 -0
- package/dist/test/diagram-self-loop-labels.test.js +303 -0
- package/dist/test/embedder.test.js +84 -0
- package/dist/test/events.test.js +123 -0
- package/dist/test/export-selection.test.js +102 -0
- package/dist/test/export.test.js +505 -0
- package/dist/test/files-browse.test.js +393 -0
- package/dist/test/files-find.test.js +272 -0
- package/dist/test/find-in-text.test.js +86 -0
- package/dist/test/first-paint-viewport.test.js +59 -0
- package/dist/test/fixtures/embedding-golden.js +23 -0
- package/dist/test/fixtures/wordpiece-golden.js +167 -0
- package/dist/test/glow-hues.test.js +202 -0
- package/dist/test/harness-cost.test.js +423 -0
- package/dist/test/helpers.js +21 -0
- package/dist/test/hex-pages.test.js +68 -0
- package/dist/test/highlight.test.js +69 -0
- package/dist/test/hit-drum.test.js +71 -0
- package/dist/test/hook-config.test.js +262 -0
- package/dist/test/json-gzip.test.js +70 -0
- package/dist/test/key-routing.test.js +58 -0
- package/dist/test/known-nids.test.js +106 -0
- package/dist/test/link-preview.test.js +67 -0
- package/dist/test/list-scroll-keys.test.js +66 -0
- package/dist/test/listen-own-words.test.js +147 -0
- package/dist/test/listen-timeout.test.js +33 -0
- package/dist/test/markdown-diagnostics.test.js +121 -0
- package/dist/test/markdown-lists.test.js +182 -0
- package/dist/test/markdown-math.test.js +256 -0
- package/dist/test/markdown-nids.test.js +146 -0
- package/dist/test/markdown-protocols.test.js +139 -0
- package/dist/test/mcp-bridge-cancel.test.js +98 -0
- package/dist/test/mcp-bridge-reconnect.test.js +121 -0
- package/dist/test/mcp-narrative.test.js +193 -0
- package/dist/test/mcp.test.js +548 -0
- package/dist/test/meld.test.js +85 -0
- package/dist/test/membrane-invasion.test.js +482 -0
- package/dist/test/membrane-motion.test.js +101 -0
- package/dist/test/membrane-palette.test.js +166 -0
- package/dist/test/membrane-terrain.test.js +170 -0
- package/dist/test/memory-log.test.js +202 -0
- package/dist/test/mentions-e2e.test.js +261 -0
- package/dist/test/mentions-ledger.test.js +265 -0
- package/dist/test/mentions-listen.test.js +265 -0
- package/dist/test/mentions.test.js +238 -0
- package/dist/test/message-selection.test.js +114 -0
- package/dist/test/mo-glyph.test.js +22 -0
- package/dist/test/model-resolution.test.js +166 -0
- package/dist/test/narrate-validate.test.js +77 -0
- package/dist/test/narrate-wait.test.js +160 -0
- package/dist/test/narrative-format.test.js +219 -0
- package/dist/test/narrative-menu.test.js +137 -0
- package/dist/test/narrative-sort.test.js +75 -0
- package/dist/test/no-pan.test.js +60 -0
- package/dist/test/pane-layout.test.js +153 -0
- package/dist/test/paths.test.js +37 -0
- package/dist/test/payload-inline.test.js +91 -0
- package/dist/test/precache-fonts.test.js +72 -0
- package/dist/test/presence-gate.test.js +440 -0
- package/dist/test/presence.test.js +160 -0
- package/dist/test/read-events.test.js +220 -0
- package/dist/test/remote-meld.test.js +115 -0
- package/dist/test/revive-cli.test.js +93 -0
- package/dist/test/search-floor.test.js +206 -0
- package/dist/test/search-fusion.test.js +168 -0
- package/dist/test/search.test.js +205 -0
- package/dist/test/security.test.js +48 -0
- package/dist/test/selection-wiring.test.js +61 -0
- package/dist/test/session-affinity.test.js +295 -0
- package/dist/test/signal-source.test.js +32 -0
- package/dist/test/socket-account.test.js +268 -0
- package/dist/test/spawn-toml.test.js +72 -0
- package/dist/test/speaker-color.test.js +90 -0
- package/dist/test/tailscale-rebind.test.js +79 -0
- package/dist/test/terminal-cursor.test.js +61 -0
- package/dist/test/terminal-resync.test.js +23 -0
- package/dist/test/thin-cli.test.js +382 -0
- package/dist/test/token-bootstrap.test.js +272 -0
- package/dist/test/token-devices.test.js +587 -0
- package/dist/test/token-lapse.test.js +94 -0
- package/dist/test/token-ring.test.js +188 -0
- package/dist/test/token-rotate-cli.test.js +58 -0
- package/dist/test/token-routes.test.js +95 -0
- package/dist/test/tool-uses.test.js +1006 -0
- package/dist/test/usage-ledger.test.js +126 -0
- package/dist/test/view-url.test.js +581 -0
- package/dist/test/wiki-links.test.js +57 -0
- package/dist/test/wiki-sources.test.js +85 -0
- package/dist/test/wiki-window.test.js +31 -0
- package/dist/test/wiki.test.js +399 -0
- package/dist/test/wordpiece.test.js +68 -0
- package/dist/tls.js +148 -0
- package/dist/tmux.js +202 -0
- package/dist/user-agent.js +46 -0
- package/docker-entrypoint.sh +141 -0
- package/docs/README.md +3 -0
- package/docs/absorb.md +231 -0
- package/docs/cost-ledger.md +125 -0
- package/docs/daemon-api.md +189 -0
- package/docs/diagrams.md +163 -0
- package/docs/doctor.md +36 -0
- package/docs/export-scope.md +69 -0
- package/docs/files-view.md +133 -0
- package/docs/link-previews.md +38 -0
- package/docs/math.md +32 -0
- package/docs/mcp.md +69 -0
- package/docs/memory-search.md +75 -0
- package/docs/mentions.md +101 -0
- package/docs/multi-brane.md +14 -0
- package/docs/passkeys.md +165 -0
- package/docs/presence.md +202 -0
- package/docs/releasing.md +53 -0
- package/docs/rendering-warnings.md +22 -0
- package/docs/request-layer.md +72 -0
- package/docs/selection-store.md +50 -0
- package/docs/session-affinity.md +61 -0
- package/docs/terminal-mirroring.md +211 -0
- package/docs/token-rotation.md +413 -0
- package/docs/view-urls.md +114 -0
- package/docs/web-app.md +23 -0
- package/docs/wiki.md +43 -0
- package/expo/dist/_expo/static/js/web/entry-e56efc1291dca7258ea00b8108b033a4.js +1097 -0
- package/expo/dist/apple-touch-icon.png +0 -0
- package/expo/dist/favicon.svg +3 -0
- package/expo/dist/index.html +177 -0
- package/expo/dist/katex/fonts/KaTeX_AMS-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Caligraphic-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Caligraphic-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Fraktur-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Fraktur-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-BoldItalic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Main-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Math-BoldItalic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Math-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Bold.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Italic.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_SansSerif-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Script-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size1-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size2-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size3-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Size4-Regular.woff2 +0 -0
- package/expo/dist/katex/fonts/KaTeX_Typewriter-Regular.woff2 +0 -0
- package/expo/dist/katex/katex.min.css +1 -0
- package/expo/dist/manifest.json +16 -0
- package/expo/dist/metadata.json +1 -0
- package/expo/dist/og/membrane.v1.png +0 -0
- package/expo/dist/pdf.min.mjs +28 -0
- package/expo/dist/pdf.worker.min.mjs +28 -0
- package/expo/dist/sw.js +154 -0
- package/package.json +81 -23
- package/protocols/LIVE_loop.md +407 -0
- package/protocols/bebrief.md +41 -0
- package/protocols/digest.md +231 -0
- package/protocols/fly.md +266 -0
- package/protocols/idle.md +81 -0
- package/protocols/keeper.md +829 -0
- package/protocols/markdown.md +80 -0
- package/protocols/memory.md +419 -0
- package/protocols/mentions.md +93 -0
- package/protocols/payloads.md +53 -0
- package/protocols/prelude.md +91 -0
- package/protocols/ramify.md +105 -0
- package/protocols/review.md +356 -0
- package/protocols/rrr.md +232 -0
- package/protocols/scribe.md +429 -0
- package/protocols/summarize.md +203 -0
- package/protocols/twin.md +174 -0
- package/protocols/wiki.md +438 -0
- package/protocols/worker.md +38 -0
- package/wiki/shared/append-only-event-log.md +148 -0
- package/wiki/shared/index.md +48 -0
- package/wiki/shared/owning-your-narratives.md +161 -0
- package/wiki/shared/premature-ontologies.md +435 -0
- package/wiki/shared/sedimentary-superintelligence.md +128 -0
- package/wiki/shared/sequestering-the-narrative.md +143 -0
- package/wiki/shared/why-wikis-work.md +216 -0
- package/.npmignore +0 -2
- package/.travis.yml +0 -5
- package/index.js +0 -8
- package/index.js~ +0 -12
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { findMatches, firstAtOrAfter, isCaseSensitive, locateSpan, parseLineJump, stepMatch, } from "../shared/find-in-text.js";
|
|
4
|
+
describe("find-in-text", () => {
|
|
5
|
+
it("is smart-case", () => {
|
|
6
|
+
assert.equal(isCaseSensitive("usememo"), false);
|
|
7
|
+
assert.equal(isCaseSensitive("useMemo"), true);
|
|
8
|
+
assert.deepEqual(findMatches("useMemo usememo USEMEMO", "usememo").matches.length, 3);
|
|
9
|
+
assert.deepEqual(findMatches("useMemo usememo USEMEMO", "useMemo").matches, [{ start: 0, end: 7 }]);
|
|
10
|
+
});
|
|
11
|
+
it("finds non-overlapping literal hits, untrimmed", () => {
|
|
12
|
+
assert.deepEqual(findMatches("aaaa", "aa").matches, [{ start: 0, end: 2 }, { start: 2, end: 4 }]);
|
|
13
|
+
// Regex metacharacters are just characters.
|
|
14
|
+
assert.deepEqual(findMatches("a.b a*b", ".").matches, [{ start: 1, end: 2 }]);
|
|
15
|
+
// A trailing space asks for the word, not the prefix.
|
|
16
|
+
assert.deepEqual(findMatches("use user use", "use ").matches, [{ start: 0, end: 4 }]);
|
|
17
|
+
assert.deepEqual(findMatches("abc", "").matches, []);
|
|
18
|
+
});
|
|
19
|
+
it("caps the hit count and says so", () => {
|
|
20
|
+
const r = findMatches("x".repeat(10), "x", 4);
|
|
21
|
+
assert.equal(r.matches.length, 4);
|
|
22
|
+
assert.equal(r.capped, true);
|
|
23
|
+
assert.equal(findMatches("xxxx", "x", 4).capped, false);
|
|
24
|
+
});
|
|
25
|
+
it("falls back to exact case when lowercasing would shift offsets", () => {
|
|
26
|
+
// "İ".toLowerCase() is two code units; a case-folded search would put
|
|
27
|
+
// every later hit one character to the left of where it is.
|
|
28
|
+
const text = "İ foo";
|
|
29
|
+
assert.notEqual(text.toLowerCase().length, text.length);
|
|
30
|
+
assert.deepEqual(findMatches(text, "foo").matches, [{ start: 2, end: 5 }]);
|
|
31
|
+
});
|
|
32
|
+
it("parses :N as a line jump and nothing else", () => {
|
|
33
|
+
assert.equal(parseLineJump(":120"), 120);
|
|
34
|
+
assert.equal(parseLineJump(" :7 "), 7);
|
|
35
|
+
for (const q of [":", ":0", ": 12", "12", ":12a", "a:12"])
|
|
36
|
+
assert.equal(parseLineJump(q), null, q);
|
|
37
|
+
});
|
|
38
|
+
it("keeps the current hit moving forward while the query grows", () => {
|
|
39
|
+
const m = [{ start: 3, end: 5 }, { start: 10, end: 12 }, { start: 20, end: 22 }];
|
|
40
|
+
assert.equal(firstAtOrAfter(m, 0), 0);
|
|
41
|
+
assert.equal(firstAtOrAfter(m, 10), 1);
|
|
42
|
+
assert.equal(firstAtOrAfter(m, 11), 2);
|
|
43
|
+
assert.equal(firstAtOrAfter(m, 21), 0, "wraps past the last hit");
|
|
44
|
+
assert.equal(firstAtOrAfter([], 5), -1);
|
|
45
|
+
});
|
|
46
|
+
it("steps with wraparound", () => {
|
|
47
|
+
assert.equal(stepMatch(0, 3, 1), 1);
|
|
48
|
+
assert.equal(stepMatch(2, 3, 1), 0);
|
|
49
|
+
assert.equal(stepMatch(0, 3, -1), 2);
|
|
50
|
+
assert.equal(stepMatch(-1, 3, 1), 0);
|
|
51
|
+
assert.equal(stepMatch(-1, 3, -1), 2);
|
|
52
|
+
assert.equal(stepMatch(0, 0, 1), -1);
|
|
53
|
+
});
|
|
54
|
+
describe("locateSpan", () => {
|
|
55
|
+
// "use" "Memo" | sep | "(x)" — a Shiki-style token split, then a line break.
|
|
56
|
+
const slots = [
|
|
57
|
+
{ start: 0, length: 3 },
|
|
58
|
+
{ start: 3, length: 4 },
|
|
59
|
+
{ start: 8, length: 3 },
|
|
60
|
+
];
|
|
61
|
+
it("maps a hit that crosses token spans", () => {
|
|
62
|
+
assert.deepEqual(locateSpan(slots, { start: 0, end: 7 }), {
|
|
63
|
+
start: { node: 0, offset: 0 },
|
|
64
|
+
end: { node: 1, offset: 4 },
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
it("starts a hit on a boundary in the later node and ends it in the earlier", () => {
|
|
68
|
+
assert.deepEqual(locateSpan(slots, { start: 3, end: 7 }), {
|
|
69
|
+
start: { node: 1, offset: 0 },
|
|
70
|
+
end: { node: 1, offset: 4 },
|
|
71
|
+
});
|
|
72
|
+
assert.deepEqual(locateSpan(slots, { start: 1, end: 3 }), {
|
|
73
|
+
start: { node: 0, offset: 1 },
|
|
74
|
+
end: { node: 0, offset: 3 },
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
it("refuses an end that lands in a separator", () => {
|
|
78
|
+
assert.equal(locateSpan(slots, { start: 7, end: 8 }), null);
|
|
79
|
+
assert.deepEqual(locateSpan(slots, { start: 8, end: 11 }), {
|
|
80
|
+
start: { node: 2, offset: 0 },
|
|
81
|
+
end: { node: 2, offset: 3 },
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
//# sourceMappingURL=find-in-text.test.js.map
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { test, describe } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
import { dirname, join } from "node:path";
|
|
6
|
+
// With `output: "single"`, expo/public/index.html is the HTML that ships and
|
|
7
|
+
// the runtime <Head> in app/_layout.tsx lands only after the bundle executes.
|
|
8
|
+
// When the two disagreed about the viewport, a link opened on iOS was laid out
|
|
9
|
+
// twice, mid-load, and could stick with the header behind the address bar
|
|
10
|
+
// until a reload. The other half of that bug was #root: `height: 100%` plus
|
|
11
|
+
// safe-area padding under `content-box` made it taller than the page, which
|
|
12
|
+
// gave <body> something to scroll. Neither is visible on a desktop browser or
|
|
13
|
+
// with zero insets, so the source is what gets checked.
|
|
14
|
+
const repoRoot = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
15
|
+
const read = (rel) => readFileSync(join(repoRoot, rel), "utf8");
|
|
16
|
+
// Source the tarball doesn't ship; skip from an install (`brane doctor`).
|
|
17
|
+
const sourceMissing = !existsSync(join(repoRoot, "expo", "public", "index.html"));
|
|
18
|
+
const skip = sourceMissing ? "expo source not shipped" : false;
|
|
19
|
+
const viewportOf = (src, file) => {
|
|
20
|
+
const m = src.match(/<meta\s+name="viewport"\s+content="([^"]+)"/);
|
|
21
|
+
assert.ok(m, `${file} should declare a viewport`);
|
|
22
|
+
return m[1];
|
|
23
|
+
};
|
|
24
|
+
// Every `#root { … }` block that sets safe-area padding must also be border-box.
|
|
25
|
+
const paddedRootRules = (src) => [...src.matchAll(/#root\s*\{([^}]*)\}/g)].map((m) => m[1]).filter((body) => body.includes("safe-area-inset"));
|
|
26
|
+
describe("the first paint is laid out under the viewport the app keeps", () => {
|
|
27
|
+
test("public/index.html and the runtime <Head> declare the same viewport", { skip }, () => {
|
|
28
|
+
const served = viewportOf(read("expo/public/index.html"), "public/index.html");
|
|
29
|
+
const runtime = viewportOf(read("expo/app/_layout.tsx"), "app/_layout.tsx");
|
|
30
|
+
assert.equal(served, runtime);
|
|
31
|
+
assert.match(served, /viewport-fit=cover/);
|
|
32
|
+
});
|
|
33
|
+
for (const file of ["expo/public/index.html", "expo/app/_layout.tsx"]) {
|
|
34
|
+
test(`${file}: a safe-area-padded #root is border-box`, { skip }, () => {
|
|
35
|
+
const rules = paddedRootRules(read(file));
|
|
36
|
+
assert.ok(rules.length > 0, `${file} should pad #root by the safe-area insets`);
|
|
37
|
+
for (const body of rules)
|
|
38
|
+
assert.match(body, /box-sizing:\s*border-box/);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
// #root's height is the visible area (expo/lib/noPan.ts sets --brane-vvh), so
|
|
43
|
+
// a bottom bar rides the keyboard. The runtime <Head> copy lands after the
|
|
44
|
+
// served one and wins, so a copy still saying `height: 100%` silently undid it
|
|
45
|
+
// (claude-3j4583pl:149).
|
|
46
|
+
describe("#root height follows the visible area", () => {
|
|
47
|
+
for (const file of ["expo/public/index.html", "expo/app/_layout.tsx"]) {
|
|
48
|
+
test(`${file}: every #root height is var(--brane-vvh, …)`, { skip }, () => {
|
|
49
|
+
const heights = [...read(file).matchAll(/#root\s*\{([^}]*)\}/g)]
|
|
50
|
+
.map((m) => /(?:^|;|\s)height:\s*([^;]+)/.exec(m[1])?.[1]?.trim())
|
|
51
|
+
.filter((h) => !!h);
|
|
52
|
+
const own = file.endsWith("_layout.tsx") ? heights : heights.slice(1); // index.html's first block is Expo's reset
|
|
53
|
+
assert.ok(own.length > 0, `${file} should size #root`);
|
|
54
|
+
for (const h of own)
|
|
55
|
+
assert.match(h, /^var\(--brane-vvh/, `${file}: #root height is ${h}`);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=first-paint-viewport.test.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const EMBEDDING_GOLDEN = [
|
|
2
|
+
{
|
|
3
|
+
text: "hello world",
|
|
4
|
+
vector: [-0.00245436444, -0.0129989870, 0.0149002094, -0.0738997161, 0.00534359738, -0.00997238420, -0.0416909605, 0.0404783525, 0.0432351157, -0.00593416719, -0.0221801102, -0.0589328893, 0.0333780348, 0.0596568137, 0.00653898995, -0.0289768316, -0.00132407038, -0.0341950357, -0.119818904, -0.0119996751, 0.142366111, 0.0134158889, 0.0196011979, -0.0473625474, -0.0357149951, 0.00901771430, 0.0137780458, 0.0192253441, 0.0382964984, -0.142097741, -0.0295767169, -0.0279541705, 0.0716555193, -0.00135934749, 0.0637778118, 0.00916544255, -0.0168551896, 0.0350361429, -0.0217793416, 0.0239365008, 0.0157807358, -0.0394562818, 0.00788052846, -0.0183216818, 0.0257347208, -0.0751736984, -0.0199071914, 0.0601452291, 0.0113241440, 0.00891754124, -0.0790685341, -0.0563974194, -0.0203910898, -0.0106415655, 0.0113192601, 0.102710813, 0.0450210460, 0.00204645260, 0.0235985499, 0.0196756236, 0.0520907231, 0.0362943746, -0.178213641, 0.0536948964, 0.0521556251, -0.0173290297, 0.0319242440, 0.0375742242, 0.0241909269, 0.0105087245, 0.00956737809, 0.00526615325, 0.0431160927, 0.0756055489, -0.0105945859, -0.0154242804, 0.0248426814, -0.0580298975, -0.0152014345, -0.0268163141, -0.0202958174, 0.0594267100, 0.00874671340, -0.0301109254, -0.0239031333, -0.0360884778, -0.0311430562, -0.00431904756, -0.0170685723, 0.00932173617, -0.0266511310, -0.0245792791, -0.00601271167, 0.0131407641, -0.0481447019, -0.00128209719, -0.0000658171193, 0.00961623434, -0.00782500487, 0.186913654, -0.0905606598, -0.0148849469, 0.0390316956, -0.0752000883, 0.0531540662, 0.00169400894, -0.0139218392, -0.0220574662, -0.0119482279, 0.00292902417, 0.0196739994, -0.0618381463, 0.0101607731, -0.0143332332, 0.000692490372, -0.0251597874, 0.0483529232, 0.000720523298, 0.0707693994, -0.0428998694, 0.00937373936, 0.0148897721, -0.0460926183, -0.00481216330, 0.0461842790, -0.0260804743, 0.0652212054, 0.0620387085, 0.0231321044, 0.0777998418, -0.00545215188, 0.0502017960, -0.0227270238, -0.0150601044, 0.0219924673, -0.0142349014, -0.00848909561, -0.0192535482, 0.0543998778, -0.0627273694, 0.00478660828, -0.0868108273, -0.0340323709, -0.114201739, -0.00114031055, 0.0427108705, -0.0663357750, 0.0261882674, -0.0215875767, -0.0339069664, -0.0311837848, 0.0798240900, -0.0167082027, -0.0323668681, 0.0104133468, 0.0610541962, -0.00331839966, 0.101287715, 0.0123368856, 0.0306126736, 0.000958173478, -0.0130756227, -0.00245804130, 0.0173991136, -0.00745328702, -0.154980704, 0.00638489937, 0.00787700154, -0.0180089977, -0.00292243483, 0.00445943931, 0.0148226479, -0.0389932804, 0.0250238422, 0.144107834, 0.00658017956, -0.00870995130, 0.0666404665, -0.0424207896, 0.0123504363, 0.0540609621, -0.0526088215, -0.0441357605, 0.0172721371, 0.0111634368, -0.0337260738, -0.0177449472, -0.0397806242, 0.0630501881, 0.0826375559, -0.0283821151, 0.0149782179, -0.0338265002, -0.0414432660, -0.0690756589, -0.00792234112, 0.0298017580, -0.0788613185, 0.0199452732, -0.0248389337, 0.160488978, 0.0746995211, 0.00763878459, 0.0346065424, 0.0182992779, 0.00853278674, 0.0429713428, 0.00413733255, 0.0584557801, -0.00262242183, -0.0289339609, -0.000478891801, 0.0353063121, -0.0247692633, 0.0355739482, -0.0401699021, -0.0158850998, 0.0800552741, 0.0270925239, 0.0345209762, -0.0370234288, -0.00219969428, -0.0403973982, -0.222714052, 0.0214438625, 0.0170847401, -0.0199245159, -0.0362617038, 0.0146217961, 0.0481822081, -0.0481649861, 0.121995434, -0.0169114955, 0.117019184, -0.0659279898, -0.000352799427, -0.0479761399, 0.0212420076, 0.0137502691, 0.000899085833, 0.0238043908, -0.0151338289, -0.00980342086, 0.0243597459, 0.0242228322, 0.0571415126, -0.0721388459, 0.0490803905, -0.0489893705, 0.122545213, 0.111872151, -0.00107568514, 0.00996189937, 0.0391830578, -0.0203747377, 0.0110125607, -0.132668659, -0.0216600616, 0.0785138682, -0.0316758379, -0.0581378378, -0.107571289, -0.0313527249, 0.0130516961, 0.0168819949, -0.0323830619, -0.0234339293, -0.0217065420, -0.0735159665, -0.0713667646, -0.0269483402, -0.0727013573, 0.00302131497, -0.00736342976, 0.0293899700, 0.0486111566, 0.0516229160, -0.00279254862, -0.0595245771, -0.0107589522, -0.0120263472, -0.0252619833, 0.0523895994, -0.0117200147, -0.0181731582, 0.0352057926, -0.0378369018, 0.0166473854, 0.0321619697, -0.0631059185, -0.0243176930, 0.0649029985, -0.00660904450, -0.0207798053, -0.0419770516, 0.0159811899, -0.0326670781, 0.0451429226, 0.0116226422, -0.0168449394, -0.0152272973, -0.0410178155, -0.0268217064, -0.00654949713, 0.0187144354, 0.0829617977, 0.0220961496, 0.0404932834, 0.0599460006, 0.0583448745, 0.00111501454, 0.0337723345, -0.0293870196, -0.0152364252, 0.0369386934, -0.0161930900, -0.0679092854, -0.00303483731, 0.0106949797, -0.275881022, 0.0360424034, -0.00181260624, 0.0187490322, 0.0224856716, 0.0274712406, 0.0576059967, 0.00342703261, -0.0892149583, 0.0123303914, -0.0742089376, 0.0276620723, 0.0233904459, -0.0592837967, -0.00171115040, 0.00342877535, -0.00337162684, -0.0317333639, 0.00977037754, -0.00980538130, -0.00123865402, 0.0281310529, 0.229619220, -0.0195783284, 0.0646211207, 0.0631967112, -0.0119546512, 0.0000545281073, 0.0648293272, 0.0189339481, -0.0888860896, 0.0118578579, 0.0640416369, -0.0108865611, 0.0368695185, -0.0110558309, -0.0720273778, -0.00294012856, 0.0215934757, -0.0596429147, -0.0406512842, 0.0184087548, -0.0380289368, 0.0643603429, 0.0434721261, -0.0950609371, -0.0326721780, -0.0369423814, 0.0160533991, 0.0523707047, -0.0231324509, -0.0757129788, -0.0102855638, 0.0250704624, -0.0336854421, 0.0259293243, 0.0116664525, -0.0247312281, 0.00976551045, -0.0580153428, 0.0285255760, -0.00743085053, 0.0613490492, 0.0238706041, 0.0441078283],
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
text: "The quick brown fox jumps over the lazy dog.",
|
|
8
|
+
vector: [-0.0825213715, 0.00505315652, 0.0127157215, 0.0929174274, 0.00671320967, 0.0179988574, 0.00659189885, 0.0514962301, 0.00941371825, 0.00813019089, -0.0275379494, -0.0787416548, 0.0463570841, 0.0543530099, -0.0277414490, 0.0448732562, -0.0134765916, -0.00797980931, -0.0835263059, 0.0113408063, 0.0000618455160, -0.0993144289, -0.0477987081, -0.00873522833, 0.0201858748, 0.00940392260, 0.00222531566, 0.0109269079, -0.0264734738, -0.123767436, 0.0687087700, -0.0592248514, -0.0162750892, -0.0677363649, -0.0167077500, -0.00123255537, -0.0270064529, 0.0162890349, 0.00132292381, 0.0165223647, 0.0308447424, 0.0104845464, -0.0417639241, -0.0509454422, 0.0180499963, 0.00463405252, -0.0740139186, -0.0409960262, 0.0496644489, -0.0225682408, -0.0617914312, -0.000547081756, 0.0399322249, -0.0833332166, 0.0398763306, -0.0294388290, 0.0229869206, 0.0233420338, -0.0117622279, 0.00436465861, 0.00867835805, 0.0390914343, -0.0417807363, 0.0550398976, 0.0250631943, -0.00178476365, -0.0349304900, -0.0268726908, 0.00450354954, 0.00584676210, 0.0536151119, 0.0665373504, -0.00271632941, 0.0367026478, 0.0697201118, 0.0275690425, -0.00422192644, 0.0384425484, -0.0253853276, -0.00131976185, -0.00313204527, -0.0297110341, -0.0372669101, -0.0128935995, 0.0259667337, -0.0326144807, 0.0142258732, -0.0698487908, 0.0624483302, 0.0967653617, -0.00919593498, -0.00970079470, -0.0313629396, -0.0120453816, 0.00946081523, -0.0305530801, 0.0351160429, -0.00320527819, -0.0607548393, 0.112297937, -0.0609368384, 0.0575051121, 0.124640867, -0.0456646644, 0.0353983939, 0.0246143565, 0.0132071832, 0.0379179530, -0.0139496950, -0.00839891564, 0.0602189079, 0.0119716423, 0.00378893944, 0.0578893311, 0.0454794317, -0.000854641141, -0.0220924038, 0.0618992820, 0.0474139936, -0.0176622011, 0.0596081614, -0.0250211097, 0.0738977939, -0.0162872858, 0.0278565716, -0.0895332769, 0.0359792300, 0.0549046881, 0.0541378558, 0.0384585969, 0.0334429070, -0.115192063, 0.0455185696, -0.0726352856, -0.00301123504, 0.0247486252, -0.0439807065, 0.0107719377, 0.0270268954, -0.0226975530, 0.00397763308, -0.129528105, -0.0232264809, -0.0667292401, -0.0160298049, -0.0122278528, -0.00934705883, -0.00946237333, -0.0495795272, 0.00149772828, 0.0191818867, 0.0145214982, -0.0258228239, -0.00659944490, -0.0462281629, -0.0408938378, -0.0553220734, 0.105501801, 0.0155143831, -0.0276108179, -0.0407469496, 0.0457120277, -0.0255357213, -0.0582935363, 0.0579574332, 0.0179280844, -0.0165438894, -0.00768757286, -0.0247243159, -0.00591371581, 0.00848211627, 0.0321118087, -0.129551813, 0.0261080973, 0.00409141742, -0.0485550426, -0.128927201, 0.0153801013, -0.0149797527, -0.0820268244, 0.0641126707, -0.0970904604, -0.0642321482, 0.0540805310, 0.0544565879, 0.00557761220, -0.0375531502, 0.0321240462, -0.0245540012, 0.000538429187, -0.0393111408, 0.0359548628, -0.00241829222, -0.0977910906, -0.0632577091, 0.0283199083, -0.0340567902, -0.0224386211, 0.0120183518, 0.0170708783, 0.0697279498, -0.0762579665, 0.0511447191, -0.0234302375, 0.0811530724, -0.0251618754, 0.0339337438, -0.0155682536, 0.0406764448, -0.0516670644, 0.0145296929, -0.0440414809, 0.0549825802, -0.0147817628, 0.00138168852, 0.0211382117, -0.0722944587, 0.0134928524, 0.0378925018, 0.00431254134, 0.0964344740, -0.00212349114, 0.0395180434, -0.109683633, 0.0992987901, -0.0336583517, -0.0186348800, -0.0242690332, 0.00997663476, 0.0253825001, -0.0908756182, 0.0573440865, 0.0506584309, 0.0328653492, -0.0537519678, -0.0346693136, -0.0507481545, -0.00606755959, 0.0910851583, 0.00830776431, 0.0666295812, 0.0475434028, 0.00714682322, 0.0175251048, 0.0147855785, 0.0595919602, -0.0335725471, 0.0515501350, -0.0348428413, 0.175059855, 0.126105607, 0.0671086013, 0.0113362921, -0.0300918873, 0.0366074182, -0.100147538, -0.0402238369, 0.103131086, 0.0798010305, 0.110451654, -0.0462286957, -0.0274362564, -0.0125796162, -0.0715310201, 0.0305003840, 0.0212838873, -0.121704198, 0.00429035071, 0.000385454914, -0.0634740442, -0.0315629877, -0.00981921144, 0.0160699431, 0.0840928480, 0.00286099454, 0.0559363104, 0.0249074530, 0.00712303491, 0.0262416694, -0.0386892557, 0.0160427578, 0.0205668658, 0.00524931308, -0.0176469758, -0.0764335468, 0.00195578462, -0.00363900443, 0.0139110740, -0.00255121128, -0.00800117478, -0.0574578382, -0.00988423638, 0.0821173638, 0.0274945609, 0.0512282737, 0.0619360581, 0.0475476868, -0.00785395596, 0.00251529831, 0.0403846949, 0.0579260327, 0.0563164651, 0.00192195340, 0.0386679545, -0.0533698574, 0.00362820248, -0.0177399740, 0.00418638811, -0.126614645, 0.0928835869, -0.0629705489, 0.0256962571, -0.113816246, -0.0176727492, 0.0673814714, -0.0385258794, -0.0387734883, -0.0408945903, -0.0181579571, -0.217504993, -0.0188728161, 0.00228816178, -0.0227436125, 0.0260163322, 0.00276495423, 0.00741388788, -0.00613124901, -0.0212998986, -0.00879594311, -0.0542727076, 0.0246832147, 0.0386441275, 0.00681757182, -0.0203467943, -0.0270362161, -0.0298460480, 0.0862395614, -0.0298914611, -0.0759180337, 0.0178312156, -0.0489471629, 0.144333690, -0.0700383782, 0.0459588654, 0.0174823366, -0.0118119614, 0.0462346859, 0.106713429, -0.00540990010, 0.0577299260, -0.0384423509, 0.0363225900, -0.109569281, -0.0383361466, 0.0542514920, -0.0185849816, 0.0187013131, -0.00523566455, -0.0533918589, 0.0372413248, 0.0519343577, 0.0754283667, -0.0399183892, 0.0375040770, -0.0605196916, -0.0782435611, -0.0324705094, -0.0433741920, 0.0958380401, -0.00441872235, -0.00914044492, -0.0668986365, -0.00311309937, 0.0106366463, -0.0131569384, -0.00554829696, 0.00642954651, -0.0526778735, -0.0474820398, -0.00877701305, -0.0176669788, 0.0615311153, 0.0574758612, 0.162334964],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
text: "café naïve résumé",
|
|
12
|
+
vector: [-0.0393463485, -0.0129487682, 0.00590293016, 0.00577539206, 0.0100508230, -0.0249193534, -0.0422781333, -0.00959741324, -0.0214779489, -0.0375980698, -0.0188898258, -0.0318899937, 0.0244491789, -0.0129124103, 0.0802299604, 0.0242850576, 0.0473876446, 0.0231711473, 0.0296522938, -0.0218989830, -0.0352286659, -0.0393191427, -0.0401456617, 0.00902896933, 0.0246039145, 0.0110326409, -0.0301342532, -0.00833343063, -0.0734047070, -0.110185519, 0.0604967363, -0.0199930705, 0.0908756480, -0.0342640355, 0.0388708264, 0.0275251996, -0.0293712653, 0.0509783514, 0.0207330789, 0.00506208325, 0.0259451754, 0.00115358003, -0.0385591760, -0.0189860035, -0.0357911848, -0.0949510485, -0.0292759854, -0.0656812042, -0.0544624180, -0.0155891618, -0.00995025225, -0.0528468750, -0.0194747932, -0.0195894390, -0.0170559827, 0.0519622900, 0.0896088406, 0.0230128430, 0.0398294255, 0.0305424035, 0.00817913935, -0.0449950472, -0.189137682, 0.0531350486, 0.0487091877, 0.0181647837, -0.00234767282, -0.0726937726, -0.00188881310, 0.0137680592, -0.0627094135, 0.0653333068, -0.0141554475, 0.0861747861, -0.0207506064, 0.000772417057, 0.0384950005, -0.0424727127, -0.0123789161, 0.0412391312, -0.0263869185, 0.0378992185, 0.000198556692, 0.0817866027, -0.0523285717, -0.0230086278, 0.0305755548, 0.00943222549, 0.0864416286, -0.000441509299, 0.00892420206, -0.0126227112, 0.0228940602, -0.00332642836, -0.0342508070, -0.0625092089, 0.0771637559, 0.00377207878, -0.0191635843, 0.109683834, -0.0541510694, 0.0138544207, 0.0525354967, -0.00904915109, 0.0812502950, -0.0700414702, 0.0424891487, 0.00171464169, 0.0267791152, -0.00660598185, -0.0297516882, 0.0158112291, 0.0633444116, 0.00162646628, 0.0684971064, 0.0138150146, 0.00236388599, 0.0316349342, 0.0175801329, 0.0546412989, 0.000453600020, 0.0308623463, -0.00985062588, -0.0493314117, -0.0246688463, -0.0103535829, -0.0260440800, 0.0382795855, 0.0252172034, 0.0863360390, 0.0313377827, -0.0209126957, 0.0678832233, 0.00213213591, 0.0320752859, 0.00271276454, -0.00933666248, 0.0109621072, 0.0169025976, 0.0637764782, -0.0205807425, -0.0470691137, -0.0451210812, -0.0460806452, 0.0322395824, 0.100923471, -0.0246948674, 0.110387810, -0.00246294658, -0.00973404199, -0.0397255830, 0.0180930067, 0.0284038857, 0.0288469605, -0.00750312628, -0.0153932376, 0.0748682767, 0.120280594, -0.0417363830, 0.0724594221, 0.0103459172, -0.0442289710, -0.0288593974, 0.0269280076, 0.00364664569, -0.156791434, -0.00434603216, 0.0519155376, -0.0592115298, 0.0317972265, 0.0518839583, -0.00691824080, 0.0415951386, 0.000496757857, 0.0700965002, 0.00430006254, -0.00232220790, 0.0421089157, 0.0469341092, 0.0624327473, 0.00414561061, -0.0573571771, -0.0883742273, 0.00743872160, -0.0342341624, 0.00455699675, -0.0618500710, -0.0134663200, 0.0163958985, 0.0331193358, -0.0774137974, -0.0283728559, -0.0265588760, -0.00286342436, -0.00360915856, -0.0455901064, 0.0201369207, -0.0247387290, 0.0491835698, -0.0361555144, -0.0161030423, -0.0133646987, -0.0206746273, 0.0123124216, -0.000257431006, 0.00596773485, 0.00480671134, -0.000245230010, 0.100622594, 0.00230101263, -0.0477767549, -0.00584031083, 0.0131988376, -0.00906275213, 0.00330620934, 0.00496352278, 0.0182499830, 0.0440338105, 0.0346775502, 0.0398497358, 0.0304480065, 0.00469745835, -0.0708467886, -0.214830607, 0.0330491997, -0.0390215591, 0.0333539955, -0.0734646097, -0.0225313473, -0.00282943784, 0.0288675353, 0.0353802182, 0.0334187634, 0.0237817839, 0.0167824905, 0.0180104915, 0.0593115278, -0.0429306254, -0.0104523692, 0.0529491603, -0.0278606731, -0.00242171763, -0.0344438069, 0.0588474609, 0.00266516767, -0.0246427022, -0.0825543478, 0.0471335836, 0.0245095361, 0.169175640, 0.0610678494, -0.00822364073, -0.110460669, 0.0124160843, 0.0493236110, 0.0256814919, -0.181288615, 0.0671730265, 0.0124265384, 0.0371365994, -0.0986920670, -0.0521303229, -0.0404379778, 0.00313234632, 0.0220429841, -0.0156323444, -0.0858456567, -0.0607256070, -0.0203059465, -0.0678376108, -0.00938509312, -0.0839325115, 0.0406484082, 0.0202592928, -0.00537572848, -0.0207398850, -0.0155922556, -0.0404420421, -0.0142079042, -0.0237657949, -0.00265506608, -0.00102103874, -0.00864602439, -0.0372452699, -0.0313986205, -0.00770600932, -0.00599587103, 0.0296907052, 0.0581828542, 0.00244959374, -0.0579879060, 0.00312659983, -0.00289216591, -0.0153663708, 0.00257430365, 0.0351111926, -0.0283421166, -0.00139672006, -0.0549632311, -0.00630790414, -0.0275603905, -0.000179314578, -0.00680050580, 0.104056582, -0.0220603067, 0.0518522188, 0.0134923393, 0.0224831346, 0.0998347402, 0.0823432580, -0.0495232344, 0.117122345, -0.0236053988, -0.0297563411, 0.0303709228, -0.0846658573, 0.0240881089, 0.0558116287, 0.0212141480, -0.247538731, 0.0286093969, -0.123163879, -0.0317276567, 0.0596909598, -0.0335778892, 0.0244987570, -0.0438261032, -0.0926168263, 0.0459595583, -0.0116805043, 0.00155167957, 0.0444281884, -0.0683320835, 0.0475872196, 0.0432069339, 0.0859792307, -0.0183036309, 0.0329142772, -0.151372150, -0.0113068027, 0.111086637, 0.187370792, -0.0153256077, -0.0634596646, 0.0290016420, -0.00144001911, -0.0271543507, 0.0576248951, -0.0181232244, 0.00688018650, 0.00512602553, 0.0616172440, -0.0563333370, -0.0349923857, -0.0157236848, -0.0456170589, -0.0158046056, 0.0103073446, -0.0716204196, 0.00247076410, -0.0246021580, 0.0107783303, 0.0300616939, 0.0479662903, -0.0712828860, 0.0243928228, -0.00257914537, -0.0197426397, 0.0149770128, 0.0298025031, -0.0360151306, -0.0269709323, 0.0336668231, 0.0409304462, 0.0434861183, -0.0606994145, 0.0656758398, -0.0472882651, -0.0517551899, -0.0291158091, -0.00959284790, 0.0868594125, 0.0870305449, -0.0246162582],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
text: "",
|
|
16
|
+
vector: [0.0484622046, -0.00129711500, 0.0168782230, -0.0479299165, -0.0228758249, 0.0702052861, 0.00650135009, 0.0452862754, 0.0277771372, -0.00789486337, -0.0274255481, -0.0602678247, -0.0159393735, 0.0457231142, 0.0168959070, -0.0142251914, 0.0140748611, 0.0549120642, -0.0228154529, -0.0377750061, 0.0342021249, -0.0332575217, 0.0114466939, -0.00888355915, 0.00105043768, -0.00443521934, -0.0150755644, -0.0406712443, -0.0729311630, -0.171333909, 0.00412184512, -0.0597924106, 0.0292831883, -0.0186806992, -0.0127332509, -0.0307561439, -0.00575853745, 0.0138227148, 0.00128463691, -0.00676282961, 0.0325579755, 0.0115774395, -0.0633177832, 0.00885580387, -0.0213568471, -0.0252963901, 0.0115528172, -0.0192253496, 0.0887255892, -0.0295257643, 0.0187725555, -0.0649721026, 0.0109691415, 0.0215745401, 0.0138112493, 0.0472296774, -0.00980931427, -0.0283518955, -0.0100792311, 0.0626523942, -0.00818486325, 0.0371127017, -0.224270359, 0.0596597306, -0.00464549894, -0.00659288419, -0.00347570912, 0.0363385379, 0.0331614017, -0.0161323138, -0.0480709709, 0.0182518288, 0.0520801097, 0.0825142860, 0.00901293103, 0.00275042071, 0.0290662050, -0.0285756011, -0.00216498086, -0.00468603754, 0.00619103247, 0.0165443569, 0.0427132882, -0.0147032272, -0.00492400490, -0.0511349030, -0.0501946919, -0.0134032117, 0.0590949357, 0.0316745825, -0.0315838307, -0.0296874419, -0.0507531166, -0.0113796992, -0.0519791692, 0.0197545830, -0.0155374743, -0.0484593324, -0.00109939871, 0.290993065, -0.0569387339, 0.00294769811, 0.0358491242, -0.0311344117, 0.00236454979, -0.0229450371, -0.0185919870, -0.00999693852, -0.0256923903, 0.00459533697, -0.00795689411, -0.00791586377, 0.0161248520, 0.0315452032, -0.0217656214, 0.0585681945, 0.0565179773, 0.0401709862, -0.0186545402, -0.0395344421, -0.00538822915, -0.0201744866, -0.0460982025, -0.0508724451, 0.0138777513, -0.0389558449, 0.0616296828, 0.0796580315, 0.0239981655, 0.0468520038, 0.0248751082, 0.0194345284, -0.0179231986, 0.0334619395, -0.00421463558, -0.0134389820, 0.00798259582, -0.0405471250, -0.0205075741, 0.00260598492, -0.0159887038, -0.0407459773, 0.0171063133, -0.139711544, 0.0127190650, 0.0857255161, -0.000412186026, -0.0442958064, -0.0555412509, -0.0452579819, 0.0116696535, 0.0450412855, 0.0290278979, 0.0341487750, 0.0140218148, -0.00814745575, 0.0195382051, 0.00863729045, -0.0211934373, 0.0155506600, -0.00736809894, -0.0426874273, -0.00567174563, 0.0578102767, -0.0229099579, -0.0366982110, -0.0132710710, 0.00924861897, 0.0334126092, -0.0237194989, 0.00818954315, 0.00817897357, -0.0186426174, 0.0157680977, 0.0739905089, 0.0197401978, -0.0409595631, -0.00114278670, -0.00770530896, -0.0102014616, -0.00556808338, 0.00156612531, -0.0142861083, 0.0196942929, 0.0930176601, -0.0335425250, -0.00606447132, -0.0221373159, -0.00494302716, -0.00504993182, 0.00351236318, 0.0184780024, 0.00606272975, -0.000718217285, -0.0245536081, -0.0518433638, -0.0172214396, -0.0750576183, -0.00227341475, -0.0239540339, 0.133352503, -0.0196675062, -0.0278167874, 0.0724727660, 0.00744018238, -0.00593732996, -0.0356925055, 0.0220705941, 0.0207766946, 0.00368446740, 0.00177877804, 0.0163224563, 0.109579287, 0.0400448292, 0.0283460133, -0.0588114299, 0.0391754247, 0.0403878689, -0.0337970629, -0.0179209337, 0.0402136520, 0.102937102, 0.0504234023, -0.300148070, 0.0560813025, 0.0221606158, 0.0399412252, -0.0361773334, 0.0309022162, -0.0201925021, -0.0106468815, 0.0529731996, 0.0732885525, 0.0891969502, 0.0148510262, -0.0396555699, 0.0694910958, 0.0275572073, 0.0723662302, 0.0518428050, 0.0166826472, 0.0133005269, 0.00348926242, 0.0114952056, 0.0195730682, 0.00474820938, -0.0160637386, 0.0784999877, -0.0149671631, 0.208917677, 0.00776086980, -0.0225143395, 0.0227659196, -0.0130595863, -0.00115054660, -0.00699093798, -0.0634940118, -0.00654665753, 0.0294546783, -0.0498734973, -0.00523392996, -0.0821861550, -0.0291963331, 0.0257281251, 0.0265691355, -0.0141378678, -0.0390935205, 0.0356495753, -0.0431627966, 0.0275548659, 0.0319889635, -0.0225107186, -0.0506508537, 0.0527480245, -0.0110764354, 0.0759383813, -0.00264758663, 0.0216561928, -0.0386365876, 0.0284338426, -0.0244160835, -0.0230707899, 0.0128145758, 0.0555341057, 0.00933228526, -0.0362965278, -0.0449987128, 0.0403882153, -0.0236010309, -0.0360376686, -0.0248340815, 0.0122831529, 0.00998950284, -0.0447303839, -0.0260171350, 0.0551067814, 0.0130052119, 0.0578969009, 0.0303377714, 0.0306604616, -0.0394476168, -0.0393119343, -0.0188601669, 0.0317336246, -0.0122600729, 0.0231971126, -0.0221147742, 0.0634806752, 0.0468672290, 0.0306597389, -0.0237685703, 0.0119876005, -0.0309635662, -0.000827134412, -0.00492035737, 0.00821423065, -0.0955787897, -0.00381166977, -0.00478035538, -0.325355023, -0.0164889432, 0.0211538672, -0.0391425751, -0.0321737789, 0.00582670327, -0.00935310125, -0.00876547210, 0.0164772794, -0.0127284732, -0.0649041459, -0.00131030951, 0.0288485289, -0.0212773737, -0.00920051523, 0.0575730093, 0.116851464, -0.0373430550, 0.0366293192, -0.0772200599, 0.000816913380, 0.0459156409, 0.246232629, -0.0483017489, 0.0771148279, -0.0110976975, -0.0123155750, -0.0418384634, 0.0112301754, 0.0130467210, 0.0384753831, 0.00124366989, 0.0938451365, -0.0392316356, -0.0109620234, 0.0567506365, -0.0442940146, 0.0309541374, -0.0411509238, 0.000577244442, -0.0203697793, -0.0261382721, -0.0786906183, -0.0193060040, 0.0501700342, -0.0771232247, -0.0332011245, -0.0446814969, -0.00524860574, 0.0130757382, 0.0119050816, -0.0240699127, -0.0257623214, 0.0157188177, 0.0251958445, -0.0450123586, 0.0130986338, -0.0524696186, 0.00762723014, -0.0154853547, -0.0158419255, -0.0584208295, -0.0218864009, 0.0380407535, 0.00796798337],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
text: "one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three ",
|
|
20
|
+
vector: [-0.0923419744, 0.00852839649, 0.0150273535, -0.0211134385, 0.00999811757, -0.00122047495, 0.0202662870, 0.00232780329, 0.0494728647, -0.0344091915, 0.0130607560, -0.0148880081, 0.0190665554, -0.0490860417, 0.0573514812, 0.00692725275, -0.00801306311, -0.0414700881, -0.131621197, 0.00288193463, 0.0739181563, -0.0243687350, -0.00791450217, -0.0193428937, 0.00619060267, 0.0521768853, -0.0272688586, -0.0418416224, -0.000721749326, -0.208180785, -0.00770867756, -0.0357185714, 0.0450763926, -0.0368577018, 0.0231436342, -0.0355087891, -0.0309703220, 0.0308242273, -0.0886266828, -0.00839802995, 0.0581445210, -0.00529869320, -0.0723652393, -0.00171531388, -0.0135431811, -0.0507100150, 0.00971546769, -0.0249796398, 0.102992535, -0.0167934690, -0.0406237543, -0.0519057848, 0.0362617932, 0.0452882126, -0.00781324971, 0.0483864546, 0.0114500625, 0.0332192369, 0.0141792567, 0.0210230555, 0.0328483060, 0.0256109051, -0.229146630, -0.0175537542, 0.0646092817, 0.0166094601, 0.0177586321, -0.0202766620, 0.0216687005, 0.0961154103, -0.00176002306, -0.0561012998, 0.0440704040, -0.0354031771, 0.0209957063, -0.0000370925773, -0.00683273561, -0.0292025767, -0.0337333344, -0.0477766208, -0.100147493, -0.000156445123, -0.0314017907, 0.00218815659, -0.0247203615, -0.0104397340, 0.0181152150, -0.0443171896, 0.0222145393, 0.0108119836, 0.00171800423, 0.00862519350, 0.0184368696, 0.0455227569, -0.0628504753, -0.00812943652, 0.0354773887, -0.0155300722, 0.0337256752, 0.136561722, -0.0469753109, 0.0199976768, 0.0178771652, 0.00289140828, 0.00931581110, -0.0521938987, -0.00135611673, -0.0881859809, 0.00623481954, 0.0202798061, 0.0240392499, 0.00757253310, 0.0411483794, -0.0933998749, -0.0342595391, 0.00775228301, 0.0645982474, 0.0402310640, -0.0102281021, -0.0274644680, 0.0304511674, 0.0221493561, 0.0621670894, -0.0167742781, 0.000445577054, 0.00535303866, 0.120773360, 0.0714815632, 0.0835690573, 0.0390734971, 0.0554950945, -0.0418974198, -0.0408914313, -0.00301782670, -0.0363702849, 0.00449551689, 0.0636019558, 0.0184071232, -0.0551088713, -0.0922782570, -0.0227709580, -0.163863331, 0.0347266011, -0.0499979556, 0.0515216067, 0.163200855, -0.0437146910, 0.00808577891, 0.0134341661, 0.00589689473, -0.0162904989, 0.0726683065, 0.000729369291, -0.0439797975, 0.0341057852, -0.0256948564, -0.0569118746, 0.0936523974, -0.0457488410, -0.0119080357, 0.0183922518, -0.0293129366, -0.00769722741, -0.0821128786, 0.0518579781, -0.0274357256, 0.00850715488, 0.00710449973, 0.0317715108, -0.0408857130, 0.0596577600, 0.0562973358, -0.0822730213, -0.00130320445, 0.0948516652, 0.0231580250, -0.0514744222, 0.00638099434, 0.0488803387, 0.0745909587, 0.0135003952, -0.00554535678, -0.0144672357, 0.0259957239, 0.0230295807, 0.0149919651, 0.0268692803, 0.0114806183, 0.0446926765, 0.0546698906, 0.00358645292, -0.0149011910, -0.0423390679, 0.0689898655, -0.0684703887, 0.00763424765, -0.00955456309, -0.0451517366, -0.0450981334, -0.0231387317, 0.0688504279, 0.0591649860, 0.0600145496, -0.0199938435, 0.0185089335, -0.0263721161, 0.0706970841, -0.0333371982, 0.0144210793, 0.0463701934, -0.0184618030, -0.0131851211, 0.00632208539, -0.00111545413, 0.0247383788, -0.0161470845, 0.00682116579, -0.00141419459, 0.0197011344, 0.0588923506, 0.0199761353, -0.0709906667, -0.0249538571, -0.199758232, -0.0257283896, 0.0307502802, -0.00814679544, 0.00998858642, 0.00865254924, -0.0114988117, -0.0374366567, 0.0359414518, 0.0463804714, 0.0391337574, -0.00891535822, 0.00353830936, 0.00577292033, -0.0419788510, 0.0728047118, 0.00123583619, -0.0321730189, -0.0251055975, 0.0216370970, -0.00893373042, 0.0755542740, -0.0550582856, -0.0112944534, -0.0564875826, -0.00177490071, 0.179089248, 0.0227317940, -0.0341240838, 0.0145195220, 0.0391485468, 0.0112940287, 0.0156135270, -0.0764529780, 0.115165830, 0.0754837394, -0.0535063408, -0.111924440, -0.0211193319, -0.0776818097, -0.0185873490, 0.0633817166, 0.0188985094, -0.0676441044, -0.0185909811, -0.0143132927, -0.0120257456, -0.00315317302, -0.0601984113, 0.0230420474, 0.0606938750, 0.0358296074, 0.0766638070, 0.00830295868, 0.0438068695, -0.0223285798, -0.0751000568, -0.00882262643, 0.00633656560, 0.0616576634, 0.0240737833, 0.0455743372, 0.0112198470, -0.0654710755, -0.0346012525, 0.0351908617, -0.00477116555, -0.0142972842, 0.00156989007, 0.0172922183, -0.00413813256, 0.0705197826, -0.0362919383, -0.0537591390, 0.0590415895, 0.0651626438, -0.0192475114, -0.0561501533, 0.0305751972, -0.0256546065, -0.0492470637, -0.00500630168, 0.00520107942, 0.0195633769, 0.00407380890, 0.0221734997, -0.0256479830, 0.0121464655, 0.0122316992, -0.0471445173, -0.0733583942, -0.00376710761, 0.0608851723, -0.0761051103, -0.0206985120, 0.0705956146, -0.206755742, 0.0219660867, 0.00545223197, 0.0157409757, 0.0570367202, 0.0268791616, 0.0417561606, 0.0408714674, -0.0597931519, 0.0140747745, 0.0218675565, 0.0287384521, 0.0848675743, 0.00900184922, -0.0370506421, 0.00687280251, 0.0661108196, -0.0276782867, 0.0296383351, -0.0432523303, 0.0157334805, -0.0216011312, 0.185079500, 0.00611539418, 0.00991434976, -0.0424100757, 0.0216092095, 0.000252076250, 0.0269482639, 0.0116777020, 0.0104064159, -0.0761428624, 0.0246324874, -0.0668708384, 0.00762202358, -0.0655106232, -0.0630417690, -0.0557837151, -0.0103921909, 0.0120075587, -0.0976061597, -0.0140047250, -0.0806322023, -0.00252742507, 0.157121003, -0.0161863975, -0.0120692020, -0.0156130344, 0.00333334878, 0.00658369297, -0.0508803092, -0.0428456888, -0.000562674948, 0.00484452629, 0.00862654485, 0.0215233639, -0.0401783846, 0.0431062952, 0.0101224827, -0.0376386456, 0.0156253371, -0.0296131298, 0.0297321454, 0.114293419, 0.0393411256],
|
|
21
|
+
},
|
|
22
|
+
];
|
|
23
|
+
//# sourceMappingURL=embedding-golden.js.map
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
export const WORDPIECE_GOLDEN = [
|
|
2
|
+
{
|
|
3
|
+
text: "",
|
|
4
|
+
ids: [101, 102],
|
|
5
|
+
},
|
|
6
|
+
{
|
|
7
|
+
text: " ",
|
|
8
|
+
ids: [101, 102],
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
text: "\n\t ",
|
|
12
|
+
ids: [101, 102],
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
text: "a",
|
|
16
|
+
ids: [101, 1037, 102],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
text: "hello world",
|
|
20
|
+
ids: [101, 7592, 2088, 102],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
text: "The quick brown fox jumps over the lazy dog.",
|
|
24
|
+
ids: [101, 1996, 4248, 2829, 4419, 14523, 2058, 1996, 13971, 3899, 1012, 102],
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
text: "Brane is a TypeScript reimagining of the organelle system.",
|
|
28
|
+
ids: [101, 24905, 2063, 2003, 1037, 4127, 23235, 24964, 2863, 11528, 2075, 1997, 1996, 5812, 14774, 2291, 1012, 102],
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
text: "caf\u00e9 na\u00efve r\u00e9sum\u00e9",
|
|
32
|
+
ids: [101, 7668, 15743, 13746, 102],
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
text: "\u00dcn\u00efc\u00f6d\u00e9 \u00e0cc\u00e9nts \u00e9verywhere",
|
|
36
|
+
ids: [101, 27260, 24947, 7249, 102],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
text: "ZALGO Z\u0338\u0327\u034eA\u0334L\u0337G\u0336O\u0335",
|
|
40
|
+
ids: [101, 23564, 2140, 3995, 23564, 2140, 3995, 102],
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
text: "\u4e2d\u6587\u5b57\u7b26\u6d4b\u8bd5",
|
|
44
|
+
ids: [101, 1746, 1861, 100, 100, 100, 100, 102],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
text: "\u65e5\u672c\u8a9e\u306e\u30c6\u30ad\u30b9\u30c8",
|
|
48
|
+
ids: [101, 1864, 1876, 1950, 1671, 30239, 30227, 30233, 30240, 102],
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
text: "\ud55c\uad6d\uc5b4 \ud14d\uc2a4\ud2b8",
|
|
52
|
+
ids: [101, 1469, 30006, 30021, 29991, 30014, 30020, 29999, 30008, 1467, 30009, 30020, 29997, 30017, 30003, 30017, 102],
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
text: "\uff26\uff35\uff2c\uff2c\uff37\uff29\uff24\uff34\uff28 \uff21\uff22\uff23",
|
|
56
|
+
ids: [101, 100, 100, 102],
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
text: "emoji \ud83c\udf89\ud83d\udd25 mixed with text",
|
|
60
|
+
ids: [101, 7861, 29147, 2072, 100, 3816, 2007, 3793, 102],
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
text: "\ud83c\uddfa\ud83c\uddf8 flag sequences \ud83c\uddec\ud83c\udde7",
|
|
64
|
+
ids: [101, 100, 5210, 10071, 100, 102],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
text: "\ufffd replacement char",
|
|
68
|
+
ids: [101, 6110, 25869, 102],
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
text: "soft\u00adhyphen",
|
|
72
|
+
ids: [101, 3730, 10536, 8458, 2368, 102],
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
text: "[CLS] literal [SEP] and [MASK] and [PAD] and [UNK]",
|
|
76
|
+
ids: [101, 101, 18204, 102, 1998, 103, 1998, 0, 1998, 100, 102],
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
text: "snake_case camelCase kebab-case SCREAMING_SNAKE",
|
|
80
|
+
ids: [101, 7488, 1035, 2553, 19130, 18382, 17710, 3676, 2497, 1011, 2553, 7491, 1035, 7488, 102],
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
text: "https://example.com/a?b=c#d&e=f",
|
|
84
|
+
ids: [101, 16770, 1024, 1013, 1013, 2742, 1012, 4012, 1013, 1037, 1029, 1038, 1027, 1039, 1001, 1040, 1004, 1041, 1027, 1042, 102],
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
text: "$1,234.56 \u2014 em-dash \u2026 ellipsis \u00ab guillemets \u00bb",
|
|
88
|
+
ids: [101, 1002, 1015, 1010, 22018, 1012, 5179, 1517, 7861, 1011, 11454, 1529, 3449, 15000, 6190, 1077, 26458, 6216, 11368, 2015, 1090, 102],
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
text: "e.g. i.e. etc. Dr. Smith went to Washington, D.C.",
|
|
92
|
+
ids: [101, 1041, 1012, 1043, 1012, 1045, 1012, 1041, 1012, 4385, 1012, 2852, 1012, 3044, 2253, 2000, 2899, 1010, 1040, 1012, 1039, 1012, 102],
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
text: "```js\nconst x = 1;\n```",
|
|
96
|
+
ids: [101, 1036, 1036, 1036, 1046, 2015, 9530, 3367, 1060, 1027, 1015, 1025, 1036, 1036, 1036, 102],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
text: "tab\there\nnewline\r\ncarriage",
|
|
100
|
+
ids: [101, 21628, 2182, 2047, 4179, 9118, 102],
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
text: "supercalifragilisticexpialidocious antidisestablishmentarianism",
|
|
104
|
+
ids: [101, 3565, 9289, 10128, 29181, 24411, 4588, 10288, 19312, 21273, 10085, 6313, 3424, 10521, 4355, 7875, 13602, 3672, 12199, 2964, 102],
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
text: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
108
|
+
ids: [101, 22038, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 2595, 102],
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
text: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
112
|
+
ids: [101, 22038, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 20348, 102],
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
text: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
|
|
116
|
+
ids: [101, 100, 102],
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
text: "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
120
|
+
ids: [101, 100, 102],
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
text: "SELECT * FROM events WHERE seq > 42 ORDER BY seq ASC;",
|
|
124
|
+
ids: [101, 7276, 1008, 2013, 2824, 2073, 7367, 4160, 1028, 4413, 2344, 2011, 7367, 4160, 2004, 2278, 1025, 102],
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
text: "0x1F 0b1010 1e-9 3.14159 -273.15",
|
|
128
|
+
ids: [101, 1014, 2595, 2487, 2546, 1014, 2497, 10790, 10790, 1015, 2063, 1011, 1023, 1017, 1012, 15471, 28154, 1011, 25371, 1012, 2321, 102],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
text: "he said \"don't\" \u2014 she said 'won't'",
|
|
132
|
+
ids: [101, 2002, 2056, 1000, 2123, 1005, 1056, 1000, 1517, 2016, 2056, 1005, 2180, 1005, 1056, 1005, 102],
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
text: "multiple internal spaces",
|
|
136
|
+
ids: [101, 3674, 4722, 7258, 102],
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
text: " leading and trailing ",
|
|
140
|
+
ids: [101, 2877, 1998, 12542, 102],
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
text: "MixedCASE WoRdS wItH nUmBeRs 123abc abc123",
|
|
144
|
+
ids: [101, 3816, 18382, 2616, 2007, 3616, 13138, 7875, 2278, 5925, 12521, 2509, 102],
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
text: "@mention #hashtag $TICKER %percent ^caret &",
|
|
148
|
+
ids: [101, 1030, 5254, 1001, 23325, 15900, 1002, 16356, 2121, 1003, 3867, 1034, 2729, 2102, 1004, 23713, 102],
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
text: "one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three one two three ",
|
|
152
|
+
ids: [101, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028, 2048, 2093, 2028],
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
text: "narrative claude-51qrhege:34 reference",
|
|
156
|
+
ids: [101, 7984, 8149, 1011, 4868, 4160, 25032, 24746, 1024, 4090, 4431, 102],
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
text: "\ud83e\uddec protein folding: \u03b1-helix and \u03b2-sheet structures",
|
|
160
|
+
ids: [101, 100, 5250, 12745, 1024, 1155, 1011, 25743, 1998, 1156, 1011, 7123, 5090, 102],
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
text: "\u03a9 \u03bc \u03c0 \u2211 \u222b \u221a \u221e \u2248 \u2260 \u2264 \u2265",
|
|
164
|
+
ids: [101, 1179, 1166, 1170, 100, 100, 1600, 1601, 1606, 1027, 1608, 1609, 102],
|
|
165
|
+
},
|
|
166
|
+
];
|
|
167
|
+
//# sourceMappingURL=wordpiece-golden.js.map
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { describe, it } from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { GlowHues, GLOW_HUES_STORAGE_KEY, RECENT_LIMIT, RECENT_MS, gapMidpoints, hueDistance, parseGlowAssignments, MIN_RECOLOR_STEP, RECOLOR_CLEARANCE_MIN, REJECTED_CLEARANCE, REJECTED_LIMIT, REJECTED_MS, recolorHue, takenHues, } from "../shared/glow-hues.js";
|
|
4
|
+
import { speakerHue } from "../shared/speaker-color.js";
|
|
5
|
+
function memoryStore() {
|
|
6
|
+
const data = new Map();
|
|
7
|
+
return { data, getItem: (k) => data.get(k) ?? null, setItem: (k, v) => void data.set(k, v) };
|
|
8
|
+
}
|
|
9
|
+
function clock(start = 1_800_000_000_000) {
|
|
10
|
+
let t = start;
|
|
11
|
+
return { now: () => t, advance: (ms) => { t += ms; } };
|
|
12
|
+
}
|
|
13
|
+
const minGap = (hues) => {
|
|
14
|
+
let m = 360;
|
|
15
|
+
for (let i = 0; i < hues.length; i++) {
|
|
16
|
+
for (let j = i + 1; j < hues.length; j++)
|
|
17
|
+
m = Math.min(m, hueDistance(hues[i], hues[j]));
|
|
18
|
+
}
|
|
19
|
+
return m;
|
|
20
|
+
};
|
|
21
|
+
describe("gapMidpoints", () => {
|
|
22
|
+
it("puts the widest arc first, and its middle is the answer", () => {
|
|
23
|
+
assert.deepEqual(gapMidpoints([0, 90]), [225, 45]);
|
|
24
|
+
assert.deepEqual(gapMidpoints([350, 10]), [180, 0]);
|
|
25
|
+
});
|
|
26
|
+
it("is empty for a free wheel, and opposite a single hue", () => {
|
|
27
|
+
assert.deepEqual(gapMidpoints([]), []);
|
|
28
|
+
assert.deepEqual(gapMidpoints([30]), [210]);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
describe("GlowHues", () => {
|
|
32
|
+
it("spreads narratives that start glowing one after another", () => {
|
|
33
|
+
const c = clock();
|
|
34
|
+
const g = new GlowHues(memoryStore(), c.now);
|
|
35
|
+
const hues = ["claude-a", "claude-b", "claude-c", "claude-d"].map((nid) => {
|
|
36
|
+
c.advance(1000);
|
|
37
|
+
return g.hueFor(nid);
|
|
38
|
+
});
|
|
39
|
+
// Greedy largest-gap: four hues never closer than a quarter turn.
|
|
40
|
+
assert.ok(minGap(hues) >= 90, `min gap ${minGap(hues)} for ${hues}`);
|
|
41
|
+
});
|
|
42
|
+
it("gives the first narrative on a free wheel its speaker hue", () => {
|
|
43
|
+
const g = new GlowHues(memoryStore());
|
|
44
|
+
assert.equal(g.hueFor("claude-4c7289d1"), speakerHue("claude-4c7289d1"));
|
|
45
|
+
});
|
|
46
|
+
it("keeps a hue once chosen, whatever lights up later", () => {
|
|
47
|
+
const c = clock();
|
|
48
|
+
const g = new GlowHues(memoryStore(), c.now);
|
|
49
|
+
const first = g.hueFor("claude-a");
|
|
50
|
+
for (let i = 0; i < 20; i++) {
|
|
51
|
+
c.advance(60_000);
|
|
52
|
+
g.hueFor(`claude-other${i}`);
|
|
53
|
+
assert.equal(g.hueFor("claude-a"), first);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
it("survives a reload through the store", () => {
|
|
57
|
+
const store = memoryStore();
|
|
58
|
+
const hue = new GlowHues(store).hueFor("claude-a");
|
|
59
|
+
assert.equal(new GlowHues(store).hueFor("claude-a"), hue);
|
|
60
|
+
assert.ok(store.data.has(GLOW_HUES_STORAGE_KEY));
|
|
61
|
+
});
|
|
62
|
+
it("Recolor lands clear of the others, and the new hue sticks", () => {
|
|
63
|
+
const store = memoryStore();
|
|
64
|
+
const c = clock();
|
|
65
|
+
const assignments = { "claude-x": { hue: 0, seen: c.now() }, "claude-y": { hue: 100, seen: c.now() }, "claude-me": { hue: 5, seen: c.now() } };
|
|
66
|
+
store.setItem(GLOW_HUES_STORAGE_KEY, JSON.stringify(assignments));
|
|
67
|
+
const g = new GlowHues(store, c.now);
|
|
68
|
+
const hue = g.recolor("claude-me");
|
|
69
|
+
// Widest gap is 100..360, middle 230, clearance 130: at least 65 from both.
|
|
70
|
+
assert.ok(hueDistance(hue, 0) >= 65 && hueDistance(hue, 100) >= 65, `landed on ${hue}`);
|
|
71
|
+
assert.equal(g.hueFor("claude-me"), hue);
|
|
72
|
+
});
|
|
73
|
+
it("Recolor with one other session is not a toggle", () => {
|
|
74
|
+
// The complaint: 180 -> 0-ish -> 180 -> ... Seeded draws must reach many
|
|
75
|
+
// hues, every one well clear of the other session. Not the far half: from
|
|
76
|
+
// 180 a full step leaves it, so the clearance gives way before the step.
|
|
77
|
+
let seed = 1;
|
|
78
|
+
const random = () => ((seed = (seed * 16807) % 2147483647) - 1) / 2147483646;
|
|
79
|
+
const c = clock();
|
|
80
|
+
const store = memoryStore();
|
|
81
|
+
store.setItem(GLOW_HUES_STORAGE_KEY, JSON.stringify({ "claude-other": { hue: 0, seen: c.now() }, "claude-me": { hue: 180, seen: c.now() } }));
|
|
82
|
+
const g = new GlowHues(store, c.now, random);
|
|
83
|
+
const seen = new Set();
|
|
84
|
+
let prev = 180;
|
|
85
|
+
for (let i = 0; i < 12; i++) {
|
|
86
|
+
c.advance(1000);
|
|
87
|
+
const next = g.recolor("claude-me");
|
|
88
|
+
assert.ok(hueDistance(next, 0) >= 45, `press ${i}: ${next} too near the other`);
|
|
89
|
+
assert.ok(hueDistance(next, prev) >= MIN_RECOLOR_STEP, `press ${i}: ${prev} -> ${next}`);
|
|
90
|
+
seen.add(next);
|
|
91
|
+
prev = next;
|
|
92
|
+
}
|
|
93
|
+
assert.ok(seen.size >= 8, `only ${[...seen]}`);
|
|
94
|
+
});
|
|
95
|
+
it("Recolor stays clear of the hues it just left, until they expire", () => {
|
|
96
|
+
const c = clock();
|
|
97
|
+
const store = memoryStore();
|
|
98
|
+
const g = new GlowHues(store, c.now, Math.random);
|
|
99
|
+
const left = [g.hueFor("claude-me")];
|
|
100
|
+
for (let i = 0; i < REJECTED_LIMIT - 1; i++) {
|
|
101
|
+
const next = g.recolor("claude-me");
|
|
102
|
+
// Alone on the wheel, three hues 100° apart can leave nowhere 60° from
|
|
103
|
+
// all of them; the oldest gives way, never the last two.
|
|
104
|
+
for (const h of left.slice(-2))
|
|
105
|
+
assert.ok(hueDistance(next, h) >= REJECTED_CLEARANCE, `press ${i}: ${next} near rejected ${h}`);
|
|
106
|
+
left.push(next);
|
|
107
|
+
}
|
|
108
|
+
const stored = JSON.parse(store.data.get(GLOW_HUES_STORAGE_KEY))["claude-me"];
|
|
109
|
+
assert.equal(stored.rejected.length, REJECTED_LIMIT - 1);
|
|
110
|
+
c.advance(REJECTED_MS + 1);
|
|
111
|
+
g.recolor("claude-me");
|
|
112
|
+
const after = JSON.parse(store.data.get(GLOW_HUES_STORAGE_KEY))["claude-me"];
|
|
113
|
+
assert.equal(after.rejected.length, 1, "expired rejections kept");
|
|
114
|
+
});
|
|
115
|
+
it("a crowded wheel relaxes the rejections before failing to move", () => {
|
|
116
|
+
const taken = Array.from({ length: 12 }, (_, i) => i * 30);
|
|
117
|
+
// Every clear spot is a gap middle (15, 45, ...); reject them all.
|
|
118
|
+
const rejected = taken.map((h) => h + 15);
|
|
119
|
+
const moved = recolorHue(15, taken, { rejected, random: () => 0.5 });
|
|
120
|
+
assert.ok(hueDistance(moved, 15) >= MIN_RECOLOR_STEP, `moved to ${moved}`);
|
|
121
|
+
assert.ok(Math.min(...taken.map((h) => hueDistance(h, moved))) >= 7, `moved to ${moved}`);
|
|
122
|
+
});
|
|
123
|
+
it("Recolor always visibly moves, even when already in the widest gap", () => {
|
|
124
|
+
// One other hue at 0 and this one opposite it: the widest gap *is* here.
|
|
125
|
+
const moved = recolorHue(180, [0]);
|
|
126
|
+
assert.ok(hueDistance(moved, 180) >= 20, `moved to ${moved}`);
|
|
127
|
+
assert.ok(hueDistance(moved, 0) >= 45, `moved to ${moved}`);
|
|
128
|
+
// Alone on the wheel: still a change.
|
|
129
|
+
assert.ok(hueDistance(recolorHue(40, []), 40) >= 20);
|
|
130
|
+
});
|
|
131
|
+
it("repeated Recolors keep landing somewhere distinct", () => {
|
|
132
|
+
const c = clock();
|
|
133
|
+
const g = new GlowHues(memoryStore(), c.now);
|
|
134
|
+
const others = ["claude-a", "claude-b", "claude-c"].map((nid) => g.hueFor(nid));
|
|
135
|
+
let prev = g.hueFor("claude-me");
|
|
136
|
+
for (let i = 0; i < 6; i++) {
|
|
137
|
+
const next = g.recolor("claude-me");
|
|
138
|
+
assert.ok(hueDistance(next, prev) >= MIN_RECOLOR_STEP, `press ${i}: ${prev} -> ${next}`);
|
|
139
|
+
// Four sessions leave 45° of best clearance. The step and the hues just
|
|
140
|
+
// left outrank half of it, never the quarter.
|
|
141
|
+
assert.ok(Math.min(...others.map((h) => hueDistance(h, next))) >= 45 * RECOLOR_CLEARANCE_MIN, `press ${i}: ${next} vs ${others}`);
|
|
142
|
+
prev = next;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
it("every press changes the color, and two presses never come back", () => {
|
|
146
|
+
// The complaint after #536: a 45° minimum let a fifth of presses shade the
|
|
147
|
+
// hue (pink to rose) rather than change it. Over many seeded runs, with
|
|
148
|
+
// zero to three other sessions glowing, each press takes a full step and
|
|
149
|
+
// the second lands clear of where the first started.
|
|
150
|
+
let seed = 7;
|
|
151
|
+
const random = () => ((seed = (seed * 16807) % 2147483647) - 1) / 2147483646;
|
|
152
|
+
for (let run = 0; run < 400; run++) {
|
|
153
|
+
const c = clock();
|
|
154
|
+
const g = new GlowHues(memoryStore(), c.now, random);
|
|
155
|
+
const others = Array.from({ length: run % 4 }, (_, i) => g.hueFor(`claude-o${i}`));
|
|
156
|
+
const start = g.hueFor("claude-me");
|
|
157
|
+
c.advance(1000);
|
|
158
|
+
const first = g.recolor("claude-me");
|
|
159
|
+
c.advance(1000);
|
|
160
|
+
const second = g.recolor("claude-me");
|
|
161
|
+
const where = `run ${run}, others ${others}: ${start} -> ${first} -> ${second}`;
|
|
162
|
+
assert.ok(hueDistance(first, start) >= MIN_RECOLOR_STEP, where);
|
|
163
|
+
assert.ok(hueDistance(second, first) >= MIN_RECOLOR_STEP, where);
|
|
164
|
+
assert.ok(hueDistance(second, start) >= REJECTED_CLEARANCE, where);
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
it("an unreadable store is an empty one, and a failed write still answers", () => {
|
|
168
|
+
const broken = {
|
|
169
|
+
getItem: () => { throw new Error("blocked"); },
|
|
170
|
+
setItem: () => { throw new Error("blocked"); },
|
|
171
|
+
};
|
|
172
|
+
const g = new GlowHues(broken);
|
|
173
|
+
assert.equal(g.hueFor("claude-a"), speakerHue("claude-a"));
|
|
174
|
+
assert.equal(typeof g.recolor("claude-a"), "number");
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
describe("takenHues", () => {
|
|
178
|
+
it("counts only recent glows, most recent first, capped", () => {
|
|
179
|
+
const now = 10 * RECENT_MS;
|
|
180
|
+
const assignments = {
|
|
181
|
+
stale: { hue: 1, seen: now - RECENT_MS - 1 },
|
|
182
|
+
me: { hue: 2, seen: now },
|
|
183
|
+
};
|
|
184
|
+
for (let i = 0; i < RECENT_LIMIT + 5; i++)
|
|
185
|
+
assignments[`n${i}`] = { hue: 10 + i, seen: now - i };
|
|
186
|
+
const taken = takenHues(assignments, "me", now);
|
|
187
|
+
assert.equal(taken.length, RECENT_LIMIT);
|
|
188
|
+
assert.ok(!taken.includes(1), "stale hue counted");
|
|
189
|
+
assert.ok(!taken.includes(2), "own hue counted");
|
|
190
|
+
assert.equal(taken[0], 10);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
describe("parseGlowAssignments", () => {
|
|
194
|
+
it("drops anything malformed", () => {
|
|
195
|
+
assert.deepEqual(parseGlowAssignments(null), {});
|
|
196
|
+
assert.deepEqual(parseGlowAssignments("not json"), {});
|
|
197
|
+
assert.deepEqual(parseGlowAssignments("[1,2]"), {});
|
|
198
|
+
assert.deepEqual(parseGlowAssignments(JSON.stringify({ a: { hue: 400, seen: 5 }, b: { hue: "x", seen: 1 }, c: null })), { a: { hue: 40, seen: 5 } });
|
|
199
|
+
assert.deepEqual(parseGlowAssignments(JSON.stringify({ a: { hue: 1, seen: 5, rejected: [{ hue: 370, at: 2 }, { hue: "x" }, null] } })), { a: { hue: 1, seen: 5, rejected: [{ hue: 10, at: 2 }] } });
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
//# sourceMappingURL=glow-hues.test.js.map
|