@justai/core 0.16.0 → 0.18.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +60 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.16.0",
3
+ "version": "0.18.0",
4
4
  "description": "The framework-free heart of the persona shell — the load-bearing behaviour (auth capture, reveal, ready) as plain strings, so Astro and Next inject the SAME logic instead of each re-writing it.",
5
5
  "license": "UNLICENSED",
6
6
  "repository": {
package/src/index.js CHANGED
@@ -894,7 +894,38 @@ export async function childFace(options) {
894
894
  const put = (id, text) => { const el = document.getElementById(id); if (el && text) el.textContent = text; };
895
895
  put("pnName", face.name);
896
896
  put("pnHandle", face.handle ? "@" + face.handle : null);
897
- put("pnMeta", face.meta);
897
+
898
+ // queries: the child persona shows raw HTML · <span class="mtag"> printed as text · the meta line
899
+ // shows markup · unrendered html in the profile · pnMeta
900
+ //
901
+ // THE META LINE IS MARKUP, AND IT ARRIVES FROM A REGISTRY. A persona's `meta` is a row of chips —
902
+ // `<span class="mtag">Fast</span>…` — and the Profile cut renders the persona's OWN with `set:html`
903
+ // because it is that persona's file. This is the same string coming back over the network, and
904
+ // `textContent` printed it verbatim: three child personas on every host showed a paragraph of angle
905
+ // brackets under the bio.
906
+ //
907
+ // `innerHTML` IS THE OBVIOUS FIX AND IT IS THE WRONG ONE. That would put remote markup into the
908
+ // document on every host in the fleet, and `meta` is written by each persona's own manifest — an
909
+ // `onerror=` in one persona's registry entry would then run inside /me, /files and the feed
910
+ // wherever they are mounted. A child persona is the LAST place to be permissive: it is the surface
911
+ // that shows a person their own vault.
912
+ //
913
+ // So the markup is parsed but never adopted. DOMParser builds an inert document — no scripts, no
914
+ // network — the TEXT of each chip is read out of it, and this file creates the elements itself.
915
+ // Whatever arrives, what reaches the page is spans this code made.
916
+ const meta = document.getElementById("pnMeta");
917
+ if (meta && face.meta) {
918
+ const inert = new DOMParser().parseFromString("<body>" + face.meta + "</body>", "text/html");
919
+ const chips = [...inert.body.querySelectorAll("span, li")].filter((n) => n.textContent.trim());
920
+ meta.textContent = "";
921
+ if (!chips.length) meta.textContent = inert.body.textContent.trim();
922
+ else for (const c of chips) {
923
+ const span = document.createElement("span");
924
+ span.className = "mtag";
925
+ span.textContent = c.textContent.trim();
926
+ meta.append(span);
927
+ }
928
+ }
898
929
  if (face.avatar) {
899
930
  const slot = document.getElementById("hostGlyph");
900
931
  if (slot) slot.innerHTML = '<img class="mk" src="' + face.avatar + '" alt="">';
@@ -1049,10 +1080,37 @@ export async function adoptMark(options) {
1049
1080
  if (!svg) return null;
1050
1081
  if (img) img.remove();
1051
1082
 
1083
+ // queries: the parent icon still has a background · app.zone mark has a black tile in the child
1084
+ // toolbar · the ground was not removed · a path ground · squircle path
1085
+ //
1086
+ // THE GROUND IS WHATEVER IS BEHIND EVERYTHING, AND HERE IT CAN BE MEASURED.
1087
+ //
1088
+ // `toolbarMark` finds a ground by matching a `<rect>` against the viewBox, because at build time a
1089
+ // string is all it has. Fourteen personas draw exactly that rect. The fifteenth is app.zone, whose
1090
+ // mark comes out of a design tool as a 1024 viewBox with the squircle as a hand-drawn `<path>` —
1091
+ // so its tile survived, and /me and /files on app.zone showed a black card in a row of inks while
1092
+ // every other host was correct.
1093
+ //
1094
+ // Chasing that with another string rule would be chasing the sixteenth drawing next. In the
1095
+ // browser the question is geometric and answerable: a ground is the BACKMOST painted shape that
1096
+ // covers the whole viewBox. Measure it and remove it, whatever it was drawn as.
1097
+ //
1098
+ // Only the first shape, and only a shape — a `<g>` may legitimately wrap the entire mark, and
1099
+ // removing that would remove the drawing rather than what is behind it.
1100
+ const vb = (svg.getAttribute("viewBox") || "").split(/[\s,]+/).map(Number);
1101
+ if (vb.length === 4 && vb[2] > 0 && vb[3] > 0) {
1102
+ const back = [...svg.children].find((n) => /^(path|rect|circle|ellipse|polygon|polyline)$/i.test(n.tagName));
1103
+ try {
1104
+ if (back) {
1105
+ const bb = back.getBBox();
1106
+ if (bb.width >= vb[2] * 0.97 && bb.height >= vb[3] * 0.97) back.remove();
1107
+ }
1108
+ } catch { /* not rendered — leave the drawing whole */ }
1109
+ }
1110
+
1052
1111
  // the measurement `fills` would have carried, taken from the drawing itself
1053
1112
  let box = 20;
1054
1113
  try {
1055
- const vb = (svg.getAttribute("viewBox") || "").split(/[\s,]+/).map(Number);
1056
1114
  const bb = svg.getBBox();
1057
1115
  if (vb.length === 4 && vb[2] > 0 && vb[3] > 0 && bb.width > 0) {
1058
1116
  const fills = Math.max(bb.width / vb[2], bb.height / vb[3]);