@justai/core 0.21.0 → 0.22.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 +12 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justai/core",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "The framework-free heart of the persona shell \u2014 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
@@ -71,6 +71,17 @@ export const JS_CLASS_JS = `document.documentElement.classList.add("js")`;
71
71
  */
72
72
  export const XRAY_JS = `(() => {
73
73
  if (!new URLSearchParams(location.search).has("xray")) return;
74
+ // IT RUNS IN <head>, SO IT WAITS. The shell mounts this beside its other inline scripts, which is
75
+ // the right place — before first paint, so the overlay does not appear a beat late. But #kernel
76
+ // does not exist yet at that moment, and the first version simply returned: the flag was read, the
77
+ // element was absent, and nothing happened with nothing said. Deferring is one line; finding out
78
+ // why an instrument silently does not work is not.
79
+ if (document.readyState === "loading") {
80
+ return void document.addEventListener("DOMContentLoaded", () => start(), { once: true });
81
+ }
82
+ start();
83
+
84
+ function start() {
74
85
  var K = () => document.getElementById("kernel");
75
86
  if (!K()) return;
76
87
 
@@ -175,6 +186,7 @@ export const XRAY_JS = `(() => {
175
186
  addEventListener("resize", schedule, { passive: true });
176
187
  addEventListener("scroll", schedule, { passive: true });
177
188
  if (document.fonts && document.fonts.ready) document.fonts.ready.then(draw);
189
+ }
178
190
  })()`;
179
191
 
180
192
  /**