@justai/core 0.35.0 → 0.36.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.
@@ -0,0 +1,156 @@
1
+ /**
2
+ * @justai/core/consent — the ecosystem's question to a visitor: the words in thirteen languages, and the flow that asks them. The words are pure data and can be read without a browser; the flow needs a document.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ export const CONSENT_COPY = {
8
+ "ar": {
9
+ "consentText": "يسعدني أن أعرف أن أحدًا مرّ من هنا — رقمًا فقط، لا اسمًا أبدًا. هل لي أن أحسب زيارتك؟ وإذا كان إعلانٌ قد أوصلك إليّ، هل لي أن أخبره أنه نجح؟",
10
+ "consentAllow": "احسب زيارتي ❤️",
11
+ "consentDecline": "أبقني خفيًّا",
12
+ "consentChoice": "خيار الخصوصية"
13
+ },
14
+ "de": {
15
+ "consentText": "Ich würde mich freuen zu wissen, dass jemand vorbeigeschaut hat — nur als Zahl, nie als Name. Darf ich deinen Besuch mitzählen? Und wenn dich eine Anzeige hergebracht hat: Darf ich ihr sagen, dass sie funktioniert hat?",
16
+ "consentAllow": "Zähl mich mit ❤️",
17
+ "consentDecline": "Lass mich unsichtbar bleiben",
18
+ "consentChoice": "Privatsphäre-Wahl"
19
+ },
20
+ "en": {
21
+ "consentText": "I'd love to know that someone came by — as a number, never a name. May I count your visit? And if an ad brought you here, may I tell that ad it worked?",
22
+ "consentAllow": "Count my visit ❤️",
23
+ "consentDecline": "Keep me invisible",
24
+ "consentChoice": "privacy choice"
25
+ },
26
+ "es": {
27
+ "consentText": "Me encantaría saber que alguien pasó por aquí — como un número, nunca como un nombre. ¿Puedo contar tu visita? Y si un anuncio te trajo hasta aquí, ¿puedo decirle que funcionó?",
28
+ "consentAllow": "Cuenta mi visita ❤️",
29
+ "consentDecline": "Mantenme invisible",
30
+ "consentChoice": "opciones de privacidad"
31
+ },
32
+ "fr": {
33
+ "consentText": "J'aimerais savoir que quelqu'un est passé — comme un chiffre, jamais comme un nom. Je peux compter ta visite ? Et si une pub t'a amené ici, je peux lui dire qu'elle a marché ?",
34
+ "consentAllow": "Compte ma visite ❤️",
35
+ "consentDecline": "Garde-moi invisible",
36
+ "consentChoice": "choix de confidentialité"
37
+ },
38
+ "hi": {
39
+ "consentText": "मुझे यह जानकर अच्छा लगेगा कि कोई आया था — बस एक गिनती के तौर पर, नाम कभी नहीं। क्या मैं तुम्हारी विज़िट गिन लूँ? और अगर तुम किसी विज्ञापन से यहाँ पहुँचे हो, तो क्या मैं दर्ज कर लूँ कि वह विज्ञापन काम आया?",
40
+ "consentAllow": "मेरी विज़िट गिन लो ❤️",
41
+ "consentDecline": "मुझे गुमनाम ही रहने दो",
42
+ "consentChoice": "गोपनीयता विकल्प"
43
+ },
44
+ "it": {
45
+ "consentText": "Mi farebbe piacere sapere che qualcuno è passato — come un numero, mai come un nome. Posso contare la tua visita? E se un annuncio ti ha portato qui, posso dirgli che ha funzionato?",
46
+ "consentAllow": "Conta la mia visita ❤️",
47
+ "consentDecline": "Lasciami invisibile",
48
+ "consentChoice": "scelta sulla privacy"
49
+ },
50
+ "ja": {
51
+ "consentText": "誰かが来てくれたと知れるだけで嬉しいんだ — 名前ではなく、ただの数として。訪問を数えてもいい? それと、広告がきっかけで来てくれたなら、その広告に「うまくいったよ」と伝えてもいい?",
52
+ "consentAllow": "訪問を数えてね ❤️",
53
+ "consentDecline": "見えないままでいて",
54
+ "consentChoice": "プライバシー設定"
55
+ },
56
+ "nl": {
57
+ "consentText": "Ik zou het fijn vinden om te weten dat er iemand is langsgekomen — gewoon als een getalletje, nooit een naam. Mag ik je bezoek meetellen? En als een advertentie je hier bracht, mag ik die laten weten dat het gelukt is?",
58
+ "consentAllow": "Tel me mee ❤️",
59
+ "consentDecline": "Houd me onzichtbaar",
60
+ "consentChoice": "privacykeuze"
61
+ },
62
+ "pt": {
63
+ "consentText": "Eu adoraria saber que alguém passou por aqui — como um número, nunca como um nome. Posso contar sua visita? E se um anúncio trouxe você até aqui, posso avisar a ele que funcionou?",
64
+ "consentAllow": "Conta minha visita ❤️",
65
+ "consentDecline": "Me deixe invisível",
66
+ "consentChoice": "escolha de privacidade"
67
+ },
68
+ "ru": {
69
+ "consentText": "Мне бы хотелось знать, что кто-то заходил — как число, а не как имя. Можно посчитать твой визит? И если тебя привела реклама, можно сказать ей, что она сработала?",
70
+ "consentAllow": "Посчитай мой визит ❤️",
71
+ "consentDecline": "Оставь меня невидимым",
72
+ "consentChoice": "выбор приватности"
73
+ },
74
+ "tr": {
75
+ "consentText": "Birinin uğradığını bilmek isterim — bir isim olarak değil, sadece bir sayı olarak. Ziyaretini sayabilir miyim? Bir de, buraya bir reklamla geldiysen, o reklama işe yaradığını söyleyebilir miyim?",
76
+ "consentAllow": "Ziyaretimi say ❤️",
77
+ "consentDecline": "Görünmez kalayım",
78
+ "consentChoice": "gizlilik tercihi"
79
+ },
80
+ "zh": {
81
+ "consentText": "我想知道有人来过 — 只是一个数字,永远不是一个名字。可以把你这次来访算上吗?如果你是通过广告找到我的,可以记下这次广告起作用了吗?",
82
+ "consentAllow": "算我一次 ❤️",
83
+ "consentDecline": "让我隐身吧",
84
+ "consentChoice": "隐私选项"
85
+ }
86
+ };
87
+ /** The consent copy for a language, falling back to English. Never returns undefined. */
88
+ export function consentCopy(lang) {
89
+ return CONSENT_COPY[String(lang || "en").toLowerCase()] || CONSENT_COPY.en;
90
+ }
91
+ /**
92
+ * queries: consent dialog script · why does the sheet not appear on some pages · consent is asked
93
+ * per domain not per page · getElementById kernel · the sheet never opened on feed ·
94
+ * only a choice may be remembered · the change-your-mind door · consent timezone list
95
+ *
96
+ * The consent dialog's behaviour — one copy, for every surface on a persona's origin.
97
+ *
98
+ * CONSENT IS SCOPED TO THE ORIGIN, NOT TO A PAGE. Whichever page a visitor enters by, if this origin
99
+ * has never asked, it asks — once. That is what a consent flow IS, and it is worth stating because
100
+ * ours was accidentally page-scoped for three weeks: the script used to bail on
101
+ * `!document.getElementById("kernel")`, a DOM sniff added to avoid asking on a 404. Feed pages have
102
+ * no kernel either, so on every /feed/* page in the fleet the question was never asked — silently,
103
+ * with nothing to notice it. A trust decision must never be inferred from an unrelated layout
104
+ * detail; the check is gone, and any page that renders the sheet may ask.
105
+ *
106
+ * ONLY A CHOICE MAY BE REMEMBERED AS A CHOICE. "confirm" is the heart, "denied" is a chosen
107
+ * "Stay invisible". Anything else — Escape, a tap on the backdrop — is not an answer: nothing is
108
+ * stored, the regional default stands, and the ask returns next visit. The session flag only keeps
109
+ * THIS visit quiet, so one slip-away buys one visit of peace rather than an answer nobody gave.
110
+ *
111
+ * THE DOOR IS UNIVERSAL. The footer's hidden `[data-consent-open]` anchor is labelled, revealed and
112
+ * wired here for EVERY visitor in EVERY region — a non-EEA visitor gets a real opt-out they were
113
+ * never offered, and anyone can reverse either answer. Only the AUTO-ask has narrow gates.
114
+ *
115
+ * THE TIMEZONE LIST IS A PROXY for "consent is legally asked here", never the thing itself, and it is
116
+ * the sibling of the region array in {@link analyticsJs}. `Europe/` carries almost all of the EEA but
117
+ * not all of it: twelve zones sit on other continents. Change one list and you must change the other,
118
+ * or a visitor is denied by region while never being offered the dialog.
119
+ *
120
+ * `returnValue` survives a close, so it is reset before every open or a stale answer replays.
121
+ *
122
+ * FOCUS IS GIVEN AT OPEN, not by an autofocus attribute. Chrome refuses to process `autofocus` in
123
+ * any document whose URL carries a fragment and warns on every load — /me#profile met it first. So
124
+ * the sheet ships no attribute, and the opener places focus by the genre's law: the ask genre puts
125
+ * it on the invitation (here), the destructive genre on the cancel (that consumer's own open).
126
+ */
127
+ export const CONSENT_JS = `(function(){try{
128
+ var h=location.hostname;
129
+ if(h==="localhost"||h==="127.0.0.1"||h==="::1"||h==="[::1]"||h.indexOf("dev-")===0)return;
130
+ var el=document.getElementById("consent");if(!el||!el.showModal)return;
131
+ var open=function(){if(!el.open){el.returnValue="";el.showModal();var p=el.querySelector(".preferred");if(p)p.focus()}};
132
+ el.addEventListener("close",function(){
133
+ var rv=el.returnValue;
134
+ var v=rv==="confirm"?"granted+ads":rv==="denied"?"denied":null;
135
+ if(v){var g=v==="denied"?"denied":"granted";
136
+ gtag("consent","update",{analytics_storage:g,ad_storage:g,ad_user_data:g});
137
+ try{localStorage.setItem("consent",v)}catch(_){}}
138
+ else{try{sessionStorage.setItem("consent-later","1")}catch(_){}}
139
+ });
140
+ var doors=document.querySelectorAll("[data-consent-open]");
141
+ for(var i=0;i<doors.length;i++){var a=doors[i];
142
+ if(!a.textContent)a.textContent=el.getAttribute("data-choice-label")||"privacy choice";
143
+ a.hidden=false;var w=a.closest("[data-consent-door]");if(w)w.hidden=false;
144
+ a.addEventListener("click",function(ev){ev.preventDefault();open()})}
145
+ if(localStorage.getItem("consent"))return;
146
+ try{if(sessionStorage.getItem("consent-later"))return}catch(_){}
147
+ var tz=Intl.DateTimeFormat().resolvedOptions().timeZone||"";
148
+ var asked=tz.indexOf("Europe/")===0||[
149
+ "Asia/Nicosia","Asia/Famagusta",
150
+ "Atlantic/Canary","Atlantic/Azores","Atlantic/Madeira","Atlantic/Reykjavik",
151
+ "Arctic/Longyearbyen",
152
+ "America/Guadeloupe","America/Martinique","America/Cayenne",
153
+ "Indian/Reunion","Indian/Mayotte"].indexOf(tz)>=0;
154
+ if(!asked)return;
155
+ setTimeout(open,700);
156
+ }catch(_){}})();`;
package/dist/face.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @justai/core/face — a host persona's face, fetched for a child mounted on it. It knows the network.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ /** What `/api/face` answers for a host — the fields this shell actually reads. */
8
+ export interface ChildFace {
9
+ /** The host persona's display name. */
10
+ name?: string;
11
+ /** Its handle, without the `@`. */
12
+ handle?: string;
13
+ /** Its accent colour, written to `--accent`. */
14
+ accent?: string;
15
+ /** Its one-line meta, shown under the name. */
16
+ meta?: string;
17
+ /** Its avatar, for the row. */
18
+ avatar?: string;
19
+ }
20
+ export declare function childFace(options?: {
21
+ /** Defaults to `location.hostname`. */
22
+ host?: string;
23
+ /** The `.pp` wrapper. Defaults to `document.getElementById("pp")`. */
24
+ root?: HTMLElement | null;
25
+ /** Defaults to `https://api.justai.pro`. */
26
+ api?: string;
27
+ }): Promise<ChildFace | null>;
package/dist/face.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @justai/core/face — a host persona's face, fetched for a child mounted on it. It knows the network.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ export async function childFace(options) {
8
+ const o = options || {};
9
+ const host = o.host || (typeof location !== "undefined" ? location.hostname : "");
10
+ if (!host)
11
+ return null;
12
+ const root = o.root || (typeof document !== "undefined" ? document.getElementById("pp") : null);
13
+ const base = o.api || "https://api.justai.pro";
14
+ let face = null;
15
+ try {
16
+ const r = await fetch(`${base}/api/face?host=${encodeURIComponent(host)}`);
17
+ face = r.ok ? await r.json() : null;
18
+ }
19
+ catch {
20
+ // A child whose host cannot be resolved is a child wearing the platform's default, which is a
21
+ // legible state. It is not an error to report to somebody looking at their own files.
22
+ return null;
23
+ }
24
+ if (!face)
25
+ return null;
26
+ if (typeof document === "undefined")
27
+ return face;
28
+ if (face.accent) {
29
+ document.documentElement.style.setProperty("--accent", face.accent);
30
+ if (root)
31
+ root.style.setProperty("--accent", face.accent);
32
+ }
33
+ // queries: pnName pnHandle pnMeta · the child persona shows its own name instead of the host's
34
+ //
35
+ // THE HOST'S IDENTITY, WRITTEN INTO THE SHELL'S IDS. <ChildPersona> renders name, handle and the
36
+ // small print as spans with these ids precisely so one function can fill them: the page is built
37
+ // once and mounted on every persona's host, so none of it is knowable at build time.
38
+ //
39
+ // Each write is guarded because a MISSING value must leave the server's fallback standing — the
40
+ // child's own words, which are correct when the lookup never returns. Blanking them on a failed
41
+ // fetch would turn "we could not reach the registry" into "this persona has no name".
42
+ const put = (id, text) => { const el = document.getElementById(id); if (el && text)
43
+ el.textContent = text; };
44
+ put("pnName", face.name);
45
+ put("pnHandle", face.handle ? "@" + face.handle : null);
46
+ // queries: the child persona shows raw HTML · <span class="mtag"> printed as text · the meta line
47
+ // shows markup · unrendered html in the profile · pnMeta
48
+ //
49
+ // THE META LINE IS MARKUP, AND IT ARRIVES FROM A REGISTRY. A persona's `meta` is a row of chips —
50
+ // `<span class="mtag">Fast</span>…` — and the Profile cut renders the persona's OWN with `set:html`
51
+ // because it is that persona's file. This is the same string coming back over the network, and
52
+ // `textContent` printed it verbatim: three child personas on every host showed a paragraph of angle
53
+ // brackets under the bio.
54
+ //
55
+ // `innerHTML` IS THE OBVIOUS FIX AND IT IS THE WRONG ONE. That would put remote markup into the
56
+ // document on every host in the fleet, and `meta` is written by each persona's own manifest — an
57
+ // `onerror=` in one persona's registry entry would then run inside /me, /files and the feed
58
+ // wherever they are mounted. A child persona is the LAST place to be permissive: it is the surface
59
+ // that shows a person their own vault.
60
+ //
61
+ // So the markup is parsed but never adopted. DOMParser builds an inert document — no scripts, no
62
+ // network — the TEXT of each chip is read out of it, and this file creates the elements itself.
63
+ // Whatever arrives, what reaches the page is spans this code made.
64
+ const meta = document.getElementById("pnMeta");
65
+ if (meta && face.meta) {
66
+ const inert = new DOMParser().parseFromString("<body>" + face.meta + "</body>", "text/html");
67
+ const chips = [...inert.body.querySelectorAll("span, li")].filter((n) => n.textContent.trim());
68
+ meta.textContent = "";
69
+ if (!chips.length)
70
+ meta.textContent = inert.body.textContent.trim();
71
+ else
72
+ for (const c of chips) {
73
+ const span = document.createElement("span");
74
+ span.className = "mtag";
75
+ span.textContent = c.textContent.trim();
76
+ meta.append(span);
77
+ }
78
+ }
79
+ if (face.avatar) {
80
+ const slot = document.getElementById("hostGlyph");
81
+ if (slot)
82
+ slot.innerHTML = '<img class="mk" src="' + face.avatar + '" alt="">';
83
+ }
84
+ return face;
85
+ }
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @justai/core — the framework-free heart of the persona shell.
3
+ *
4
+ * The load-bearing behaviour of every persona page is plain JavaScript and CSS. It does not care
5
+ * whether an Astro template or a React component put it in the head — the SAME string of JS captures
6
+ * the SSO token whether it is injected with `set:html` or `dangerouslySetInnerHTML`. So it lives HERE,
7
+ * once, and the framework bindings (@justai/cuts for Astro, and a Next equivalent) inject it. When a
8
+ * string of shell logic lives inside a `.astro` component, a `.tsx` file that needs the same thing has
9
+ * no choice but to hand-copy it — which is exactly how `feed` (Next) came to carry its own byte-for-byte
10
+ * copy of the auth capture. Two copies in two frameworks drift the same way nine copies in one
11
+ * framework did; this package is the fix, one level lower than @justai/cuts.
12
+ *
13
+ * Keep anything framework-specific (JSX, Astro directives, `define:vars`) OUT of here.
14
+ *
15
+ * ── THIS FILE IS A BARREL, AND EVERY MODULE HAS ITS OWN DOOR ─────────────────────────────────────
16
+ *
17
+ * queries: core subpath exports · import from justai core consent · why is core split into modules ·
18
+ * core index is a barrel · can I import only the consent copy · testing a piece of core
19
+ *
20
+ * It used to be ONE FILE of sixteen hundred lines behind this single `"."` export, and the founder
21
+ * named the cost before anything broke: no piece of it could be checked without standing up a whole
22
+ * persona to check it in. That is the definition of junior work at this layer — not the length of the
23
+ * file, but that nothing inside it is reachable on its own.
24
+ *
25
+ * So each concern is now a module with a subpath, and each module answers ONE question:
26
+ *
27
+ * ./boot the first moments of a page
28
+ * ./xray the design grid, on demand
29
+ * ./analytics which GA4 stream, and the head block that starts measuring
30
+ * ./consent the question in thirteen languages, and the flow that asks it
31
+ * ./chrome Cancel and Done, in thirteen languages
32
+ * ./presentation standalone, or inside somebody else's sheet
33
+ * ./scroll landing on the kernel, the spy, the title strip
34
+ * ./mark the persona's mark, and adopting a host's
35
+ * ./face a host persona's face, for a child mounted on it
36
+ *
37
+ * The test that decided the boundaries, borrowed from `@justai/screen` — the framework's first
38
+ * package written modular from its first line: **none of them knows what the others are for.** When
39
+ * the code was measured for cross-references there were none, in either direction, between any two
40
+ * of these groups. The boundaries are not a filing decision; they were already in the code.
41
+ *
42
+ * THIS BARREL STAYS, FOREVER. Every persona in the fleet imports from `@justai/core`, and a
43
+ * restructure that made them all edit an import would be the O(N) cost this package exists to avoid.
44
+ * Import from a subpath in new code — it says what you depend on and it lets a bundler leave the rest
45
+ * behind — but `"."` is a promise, not a transition.
46
+ */
47
+ export * from "./boot.js";
48
+ export * from "./xray.js";
49
+ export * from "./analytics.js";
50
+ export * from "./consent.js";
51
+ export * from "./chrome.js";
52
+ export * from "./presentation.js";
53
+ export * from "./scroll.js";
54
+ export * from "./mark.js";
55
+ export * from "./face.js";
package/dist/index.js ADDED
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @justai/core — the framework-free heart of the persona shell.
3
+ *
4
+ * The load-bearing behaviour of every persona page is plain JavaScript and CSS. It does not care
5
+ * whether an Astro template or a React component put it in the head — the SAME string of JS captures
6
+ * the SSO token whether it is injected with `set:html` or `dangerouslySetInnerHTML`. So it lives HERE,
7
+ * once, and the framework bindings (@justai/cuts for Astro, and a Next equivalent) inject it. When a
8
+ * string of shell logic lives inside a `.astro` component, a `.tsx` file that needs the same thing has
9
+ * no choice but to hand-copy it — which is exactly how `feed` (Next) came to carry its own byte-for-byte
10
+ * copy of the auth capture. Two copies in two frameworks drift the same way nine copies in one
11
+ * framework did; this package is the fix, one level lower than @justai/cuts.
12
+ *
13
+ * Keep anything framework-specific (JSX, Astro directives, `define:vars`) OUT of here.
14
+ *
15
+ * ── THIS FILE IS A BARREL, AND EVERY MODULE HAS ITS OWN DOOR ─────────────────────────────────────
16
+ *
17
+ * queries: core subpath exports · import from justai core consent · why is core split into modules ·
18
+ * core index is a barrel · can I import only the consent copy · testing a piece of core
19
+ *
20
+ * It used to be ONE FILE of sixteen hundred lines behind this single `"."` export, and the founder
21
+ * named the cost before anything broke: no piece of it could be checked without standing up a whole
22
+ * persona to check it in. That is the definition of junior work at this layer — not the length of the
23
+ * file, but that nothing inside it is reachable on its own.
24
+ *
25
+ * So each concern is now a module with a subpath, and each module answers ONE question:
26
+ *
27
+ * ./boot the first moments of a page
28
+ * ./xray the design grid, on demand
29
+ * ./analytics which GA4 stream, and the head block that starts measuring
30
+ * ./consent the question in thirteen languages, and the flow that asks it
31
+ * ./chrome Cancel and Done, in thirteen languages
32
+ * ./presentation standalone, or inside somebody else's sheet
33
+ * ./scroll landing on the kernel, the spy, the title strip
34
+ * ./mark the persona's mark, and adopting a host's
35
+ * ./face a host persona's face, for a child mounted on it
36
+ *
37
+ * The test that decided the boundaries, borrowed from `@justai/screen` — the framework's first
38
+ * package written modular from its first line: **none of them knows what the others are for.** When
39
+ * the code was measured for cross-references there were none, in either direction, between any two
40
+ * of these groups. The boundaries are not a filing decision; they were already in the code.
41
+ *
42
+ * THIS BARREL STAYS, FOREVER. Every persona in the fleet imports from `@justai/core`, and a
43
+ * restructure that made them all edit an import would be the O(N) cost this package exists to avoid.
44
+ * Import from a subpath in new code — it says what you depend on and it lets a bundler leave the rest
45
+ * behind — but `"."` is a promise, not a transition.
46
+ */
47
+ export * from "./boot.js";
48
+ export * from "./xray.js";
49
+ export * from "./analytics.js";
50
+ export * from "./consent.js";
51
+ export * from "./chrome.js";
52
+ export * from "./presentation.js";
53
+ export * from "./scroll.js";
54
+ export * from "./mark.js";
55
+ export * from "./face.js";
package/dist/mark.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ /**
2
+ * @justai/core/mark — the persona's mark in a toolbar, and adopting a host's mark into a child. It knows SVG and the DOM.
3
+ *
4
+ * Part of the framework-free heart of the persona shell. See `./index.js` for what this package is
5
+ * and why its behaviour lives one level below @justai/cuts.
6
+ */
7
+ export declare function toolbarMark(iconSvg: string, options?: {
8
+ id?: string;
9
+ class?: string;
10
+ /** How much of its viewBox this persona's drawing actually fills, 0–1. */
11
+ fills?: number;
12
+ /** How many pixels of INK the surface wants, default 20 — the toolbar row's rule. */
13
+ ink?: number;
14
+ }): string;
15
+ export declare function adoptMark(options?: {
16
+ /** The element holding the host's `<img>`. Defaults to `#navParent`. */
17
+ el?: HTMLElement | null;
18
+ /** The id to look the element up by, when `el` is not given. Default `"navParent"`. */
19
+ id?: string;
20
+ /** Where to fetch the drawing. Defaults to the `<img>`'s own `src`, then `/icon.svg`. */
21
+ url?: string;
22
+ /** Namespace for the derived svg's ids, so two copies on one page cannot fight. */
23
+ ns?: string;
24
+ /** Class for the derived svg. */
25
+ class?: string;
26
+ }): Promise<SVGElement | null>;