okno 1.0.0-alpha.14 → 1.0.0-alpha.16

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.
@@ -715,9 +715,9 @@ l.parseVar = function(e, t, i, s) {
715
715
  l.parseVarId = function(e, t) {
716
716
  e.id = t === "using" || t === "await using" ? this.parseIdent() : this.parseBindingAtom(), this.checkLValPattern(e.id, t === "var" ? Ce : B, !1);
717
717
  };
718
- var X = 1, me = 2, We = 4;
718
+ var X = 1, me = 2, He = 4;
719
719
  l.parseFunction = function(e, t, i, s, r) {
720
- this.initFunction(e), (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !s) && (this.type === a.star && t & me && this.unexpected(), e.generator = this.eat(a.star)), this.options.ecmaVersion >= 8 && (e.async = !!s), t & X && (e.id = t & We && this.type !== a.name ? null : this.parseIdent(), e.id && !(t & me) && this.checkLValSimple(e.id, this.strict || e.generator || e.async ? this.treatFunctionsAsVar ? Ce : B : qe));
720
+ this.initFunction(e), (this.options.ecmaVersion >= 9 || this.options.ecmaVersion >= 6 && !s) && (this.type === a.star && t & me && this.unexpected(), e.generator = this.eat(a.star)), this.options.ecmaVersion >= 8 && (e.async = !!s), t & X && (e.id = t & He && this.type !== a.name ? null : this.parseIdent(), e.id && !(t & me) && this.checkLValSimple(e.id, this.strict || e.generator || e.async ? this.treatFunctionsAsVar ? Ce : B : qe));
721
721
  var n = this.yieldPos, u = this.awaitPos, o = this.awaitIdentPos;
722
722
  return this.yieldPos = 0, this.awaitPos = 0, this.awaitIdentPos = 0, this.enterScope(_e(e.async, e.generator)), t & X || (e.id = this.type === a.name ? this.parseIdent() : null), this.parseFunctionParams(e), this.parseFunctionBody(e, i, !1, r), this.yieldPos = n, this.awaitPos = u, this.awaitIdentPos = o, this.finishNode(e, t & X ? "FunctionDeclaration" : "FunctionExpression");
723
723
  };
@@ -836,7 +836,7 @@ l.parseExportDefaultDeclaration = function() {
836
836
  var e;
837
837
  if (this.type === a._function || (e = this.isAsyncFunction())) {
838
838
  var t = this.startNode();
839
- return this.next(), e && this.next(), this.parseFunction(t, X | We, !1, e);
839
+ return this.next(), e && this.next(), this.parseFunction(t, X | He, !1, e);
840
840
  } else if (this.type === a._class) {
841
841
  var i = this.startNode();
842
842
  return this.parseClass(i, "nullableID");
@@ -1293,7 +1293,7 @@ f.parseMaybeUnary = function(e, t, i, s) {
1293
1293
  u = this.parseAwait(s), t = !0;
1294
1294
  else if (this.type.prefix) {
1295
1295
  var o = this.startNode(), h = this.type === a.incDec;
1296
- o.operator = this.value, o.prefix = !0, this.next(), o.argument = this.parseMaybeUnary(null, !0, h, s), this.checkExpressionErrors(e, !0), h ? this.checkLValSimple(o.argument) : this.strict && o.operator === "delete" && He(o.argument) ? this.raiseRecoverable(o.start, "Deleting local variable in strict mode") : o.operator === "delete" && ve(o.argument) ? this.raiseRecoverable(o.start, "Private fields can not be deleted") : t = !0, u = this.finishNode(o, h ? "UpdateExpression" : "UnaryExpression");
1296
+ o.operator = this.value, o.prefix = !0, this.next(), o.argument = this.parseMaybeUnary(null, !0, h, s), this.checkExpressionErrors(e, !0), h ? this.checkLValSimple(o.argument) : this.strict && o.operator === "delete" && We(o.argument) ? this.raiseRecoverable(o.start, "Deleting local variable in strict mode") : o.operator === "delete" && ve(o.argument) ? this.raiseRecoverable(o.start, "Private fields can not be deleted") : t = !0, u = this.finishNode(o, h ? "UpdateExpression" : "UnaryExpression");
1297
1297
  } else if (!t && this.type === a.privateId)
1298
1298
  (s || this.privateNameStack.length === 0) && this.options.checkPrivateFields && this.unexpected(), u = this.parsePrivateIdent(), this.type !== a._in && this.unexpected();
1299
1299
  else {
@@ -1312,8 +1312,8 @@ f.parseMaybeUnary = function(e, t, i, s) {
1312
1312
  else
1313
1313
  return u;
1314
1314
  };
1315
- function He(e) {
1316
- return e.type === "Identifier" || e.type === "ParenthesizedExpression" && He(e.expression);
1315
+ function We(e) {
1316
+ return e.type === "Identifier" || e.type === "ParenthesizedExpression" && We(e.expression);
1317
1317
  }
1318
1318
  function ve(e) {
1319
1319
  return e.type === "MemberExpression" && e.property.type === "PrivateIdentifier" || e.type === "ChainExpression" && ve(e.expression) || e.type === "ParenthesizedExpression" && ve(e.expression);
@@ -1358,12 +1358,12 @@ f.parseSubscript = function(e, t, i, s, r, n, u) {
1358
1358
  if (r && !h && this.shouldParseAsyncArrow())
1359
1359
  return this.checkPatternErrors(g, !1), this.checkYieldAwaitInDefaultParams(), this.awaitIdentPos > 0 && this.raise(this.awaitIdentPos, "Cannot use 'await' as identifier inside an async function"), this.yieldPos = _, this.awaitPos = Y, this.awaitIdentPos = G, this.parseSubscriptAsyncArrow(t, i, ee, u);
1360
1360
  this.checkExpressionErrors(g, !0), this.yieldPos = _ || this.yieldPos, this.awaitPos = Y || this.awaitPos, this.awaitIdentPos = G || this.awaitIdentPos;
1361
- var W = this.startNodeAt(t, i);
1362
- W.callee = e, W.arguments = ee, o && (W.optional = h), e = this.finishNode(W, "CallExpression");
1361
+ var H = this.startNodeAt(t, i);
1362
+ H.callee = e, H.arguments = ee, o && (H.optional = h), e = this.finishNode(H, "CallExpression");
1363
1363
  } else if (this.type === a.backQuote) {
1364
1364
  (h || n) && this.raise(this.start, "Optional chaining cannot appear in the tag of tagged template expressions");
1365
- var H = this.startNodeAt(t, i);
1366
- H.tag = e, H.quasi = this.parseTemplate({ isTagged: !0 }), e = this.finishNode(H, "TaggedTemplateExpression");
1365
+ var W = this.startNodeAt(t, i);
1366
+ W.tag = e, W.quasi = this.parseTemplate({ isTagged: !0 }), e = this.finishNode(W, "TaggedTemplateExpression");
1367
1367
  }
1368
1368
  return e;
1369
1369
  };
@@ -1473,15 +1473,15 @@ f.parseParenAndDistinguishExpression = function(e, t) {
1473
1473
  break;
1474
1474
  } else
1475
1475
  h.push(this.parseMaybeAssign(!1, g, this.parseParenItem));
1476
- var ee = this.lastTokEnd, W = this.lastTokEndLoc;
1476
+ var ee = this.lastTokEnd, H = this.lastTokEndLoc;
1477
1477
  if (this.expect(a.parenR), e && this.shouldParseArrow(h) && this.eat(a.arrow))
1478
1478
  return this.checkPatternErrors(g, !1), this.checkYieldAwaitInDefaultParams(), this.yieldPos = _, this.awaitPos = Y, this.parseParenArrowList(i, s, h, t);
1479
- (!h.length || d) && this.unexpected(this.lastTokStart), G && this.unexpected(G), this.checkExpressionErrors(g, !0), this.yieldPos = _ || this.yieldPos, this.awaitPos = Y || this.awaitPos, h.length > 1 ? (r = this.startNodeAt(u, o), r.expressions = h, this.finishNodeAt(r, "SequenceExpression", ee, W)) : r = h[0];
1479
+ (!h.length || d) && this.unexpected(this.lastTokStart), G && this.unexpected(G), this.checkExpressionErrors(g, !0), this.yieldPos = _ || this.yieldPos, this.awaitPos = Y || this.awaitPos, h.length > 1 ? (r = this.startNodeAt(u, o), r.expressions = h, this.finishNodeAt(r, "SequenceExpression", ee, H)) : r = h[0];
1480
1480
  } else
1481
1481
  r = this.parseParenExpression();
1482
1482
  if (this.options.preserveParens) {
1483
- var H = this.startNodeAt(i, s);
1484
- return H.expression = r, this.finishNode(H, "ParenthesizedExpression");
1483
+ var W = this.startNodeAt(i, s);
1484
+ return W.expression = r, this.finishNode(W, "ParenthesizedExpression");
1485
1485
  } else
1486
1486
  return r;
1487
1487
  };
@@ -2260,7 +2260,7 @@ c.regexp_eatDecimalEscape = function(e) {
2260
2260
  var nt = 0, O = 1, I = 2;
2261
2261
  c.regexp_eatCharacterClassEscape = function(e) {
2262
2262
  var t = e.current();
2263
- if (Wt(t))
2263
+ if (Ht(t))
2264
2264
  return e.lastIntValue = -1, e.advance(), O;
2265
2265
  var i = !1;
2266
2266
  if (e.switchU && this.options.ecmaVersion >= 9 && ((i = t === 80) || t === 112)) {
@@ -2278,7 +2278,7 @@ c.regexp_eatCharacterClassEscape = function(e) {
2278
2278
  }
2279
2279
  return nt;
2280
2280
  };
2281
- function Wt(e) {
2281
+ function Ht(e) {
2282
2282
  return e === 100 || e === 68 || e === 115 || e === 83 || e === 119 || e === 87;
2283
2283
  }
2284
2284
  c.regexp_eatUnicodePropertyValueExpression = function(e) {
@@ -2320,11 +2320,11 @@ function ut(e) {
2320
2320
  }
2321
2321
  c.regexp_eatUnicodePropertyValue = function(e) {
2322
2322
  var t = 0;
2323
- for (e.lastStringValue = ""; Ht(t = e.current()); )
2323
+ for (e.lastStringValue = ""; Wt(t = e.current()); )
2324
2324
  e.lastStringValue += R(t), e.advance();
2325
2325
  return e.lastStringValue !== "";
2326
2326
  };
2327
- function Ht(e) {
2327
+ function Wt(e) {
2328
2328
  return ut(e) || ce(e);
2329
2329
  }
2330
2330
  c.regexp_eatLoneUnicodePropertyNameOrValue = function(e) {
@@ -3138,25 +3138,6 @@ y.acorn = {
3138
3138
  function Zt(e, t, i) {
3139
3139
  return y.parseExpressionAt(e, t, i);
3140
3140
  }
3141
- function Jt(e, t, i) {
3142
- if (!i || i.length === 0) return e;
3143
- const s = new Map(i.map((u, o) => [u, o])), r = [], n = [];
3144
- for (const u of e) {
3145
- const o = t(u), h = o == null ? void 0 : s.get(o);
3146
- h === void 0 ? n.push(u) : r.push({ item: u, r: h });
3147
- }
3148
- return r.sort((u, o) => u.r - o.r), [...r.map((u) => u.item), ...n];
3149
- }
3150
- function $t(e, t) {
3151
- const i = (e ?? []).filter((s) => s !== t);
3152
- return [t, ...i];
3153
- }
3154
- function ei(e, t) {
3155
- return (e ?? []).filter((i) => i !== t);
3156
- }
3157
3141
  export {
3158
- $t as a,
3159
- ei as b,
3160
- Jt as o,
3161
3142
  Zt as p
3162
3143
  };
package/dist/boot.d.ts CHANGED
@@ -21,18 +21,61 @@ declare const GATE_KEY = "e";
21
21
  declare const g: {
22
22
  document?: Document;
23
23
  location?: Location;
24
+ localStorage?: Storage;
24
25
  __okno_loaded?: boolean;
25
26
  __okno_gate_installed?: boolean;
26
- __okno_autostart?: "key" | "url" | false;
27
+ __okno_autostart?: "key" | "url" | "session" | false;
28
+ __okno_ensure_vt?: () => void;
27
29
  };
28
30
  declare let loading: boolean;
31
+ declare const OPENED_KEY = "okno-win-opened";
32
+ declare const SHELL_ID = "okno-shadow-root";
33
+ declare const VT_STYLE_ID = "okno-vt-style";
34
+ declare const NAV_CLASS = "okno-nav-vt";
35
+ /** The window was last left open → the editor should ride along across navigation. */
36
+ declare function editorActive(): boolean;
37
+ /** Cross-document View Transitions: needs the VT API + the pageswap/pagereveal
38
+ * hooks (Chromium 126+, Safari 18.2+). Elsewhere we degrade to a plain reboot. */
39
+ declare function crossDocVTSupported(): boolean;
40
+ /** Does the HOST page already opt into cross-document View Transitions? Decides
41
+ * how we coexist without interfering (see ensureVTStyle). Read before injecting
42
+ * our own style; cross-origin sheets are skipped (their rules can't be read). */
43
+ declare function hostHasViewTransition(): boolean;
44
+ /** Inject (once) the rules that hold the editor in place across navigation. Two
45
+ * hard constraints: UNIVERSAL (no host-framework assumptions — pure CSS in the
46
+ * always-loaded gate) and NON-INTERFERING with the host's own transitions:
47
+ * • All `okno-shell` / `root` rules are scoped to `html.okno-nav-vt` — a class
48
+ * we set ONLY during a cross-document nav — so they never bleed into okno's
49
+ * own same-document structural View Transitions (which run constantly).
50
+ * • If the host ALREADY uses cross-document VT, we DON'T touch `root`: the page
51
+ * animates exactly as the host intends; we only lift the editor out + hold it.
52
+ * • If the host does NOT, we enable a minimal VT and HARD-CUT the page (suppress
53
+ * the default root crossfade), so a site that never wanted page transitions
54
+ * doesn't suddenly get one — only the editor is held.
55
+ * Public on `window.__okno_ensure_vt` so the editor can opt the current page in
56
+ * the instant it opens (boot ran here before the window was open). */
57
+ declare function ensureVTStyle(): void;
58
+ /** The editor host is normally a 0-size box (its UI is `position:fixed` inside
59
+ * the shadow root), which would snapshot empty and make the browser SKIP the
60
+ * transition. Give it a real viewport box + the group name for the capture —
61
+ * pointer-events:none so it never intercepts clicks. Inline + transient (only
62
+ * during the nav), so it never lingers to fight okno's structural `okno-editor`
63
+ * group. Mirrors the structural-edit code in wrap.ts. */
64
+ declare function pinHostForCapture(host: HTMLElement): void;
65
+ /** Outgoing page: flag the nav + lift the editor into its own snapshot group. */
66
+ declare function onPageSwap(e: Event): void;
67
+ /** Incoming page: flag the nav (so the scoped rules apply), then stand up a
68
+ * placeholder host with the box + name before first render so the new side has a
69
+ * matching `okno-shell` group. `initEditor` reuses it when the bundle loads. The
70
+ * flag is cleared once the transition settles. */
71
+ declare function onPageReveal(e: Event): void;
29
72
  /** The editor sets `window.__okno_loaded` at the top of its entry module, so
30
73
  * this flips true the moment the bundle starts evaluating. */
31
74
  declare function editorPresent(): boolean;
32
75
  /** Don't hijack `e` while the visitor is typing in the host page. Mirrors the
33
76
  * editor's own focus check (modules/keys.svelte.ts), shadow DOM included. */
34
77
  declare function isTyping(): boolean;
35
- declare function bootEditor(reason: "key" | "url"): void;
78
+ declare function bootEditor(reason: "key" | "url" | "session"): void;
36
79
  declare function urlRequestsEditor(): boolean;
37
80
  declare function install(): void;
38
81
  //# sourceMappingURL=boot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,CAAA;AAEtC,QAAA,MAAM,QAAQ,MAAM,CAAA;AAEpB,QAAA,MAAM,CAAC,EAA4B;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,gBAAgB,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,KAAK,CAAA;CACxC,CAAA;AAED,QAAA,IAAI,OAAO,SAAQ,CAAA;AAEnB;+DAC+D;AAC/D,iBAAS,aAAa,IAAI,OAAO,CAEhC;AAED;8EAC8E;AAC9E,iBAAS,QAAQ,IAAI,OAAO,CAO3B;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,IAAI,CAa/C;AAED,iBAAS,iBAAiB,IAAI,OAAO,CASpC;AAED,iBAAS,OAAO,IAAI,IAAI,CAgBvB"}
1
+ {"version":3,"file":"boot.d.ts","sourceRoot":"","sources":["../src/boot.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,CAAC,MAAM,eAAe,EAAE,OAAO,CAAA;AAEtC,QAAA,MAAM,QAAQ,MAAM,CAAA;AAEpB,QAAA,MAAM,CAAC,EAA4B;IAClC,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,QAAQ,CAAC,EAAE,QAAQ,CAAA;IACnB,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,qBAAqB,CAAC,EAAE,OAAO,CAAA;IAC/B,gBAAgB,CAAC,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAA;IACpD,gBAAgB,CAAC,EAAE,MAAM,IAAI,CAAA;CAC7B,CAAA;AAED,QAAA,IAAI,OAAO,SAAQ,CAAA;AAenB,QAAA,MAAM,UAAU,oBAAoB,CAAA;AACpC,QAAA,MAAM,QAAQ,qBAAqB,CAAA;AACnC,QAAA,MAAM,WAAW,kBAAkB,CAAA;AACnC,QAAA,MAAM,SAAS,gBAAgB,CAAA;AAE/B,sFAAsF;AACtF,iBAAS,YAAY,IAAI,OAAO,CAM/B;AAED;mFACmF;AACnF,iBAAS,mBAAmB,IAAI,OAAO,CAOtC;AAED;;kFAEkF;AAClF,iBAAS,qBAAqB,IAAI,OAAO,CAgBxC;AAED;;;;;;;;;;;;uEAYuE;AACvE,iBAAS,aAAa,IAAI,IAAI,CA0B7B;AAED;;;;;0DAK0D;AAC1D,iBAAS,iBAAiB,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI,CAElD;AAED,iFAAiF;AACjF,iBAAS,UAAU,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAKlC;AAED;;;mDAGmD;AACnD,iBAAS,YAAY,CAAC,CAAC,EAAE,KAAK,GAAG,IAAI,CAgBpC;AAED;+DAC+D;AAC/D,iBAAS,aAAa,IAAI,OAAO,CAEhC;AAED;8EAC8E;AAC9E,iBAAS,QAAQ,IAAI,OAAO,CAO3B;AAED,iBAAS,UAAU,CAAC,MAAM,EAAE,KAAK,GAAG,KAAK,GAAG,SAAS,GAAG,IAAI,CAa3D;AAED,iBAAS,iBAAiB,IAAI,OAAO,CASpC;AAED,iBAAS,OAAO,IAAI,IAAI,CAgCvB"}
package/dist/boot.js CHANGED
@@ -1,22 +1,85 @@
1
- const n = globalThis;
2
- let o = !1;
3
- function i() {
4
- return !!n.__okno_loaded;
1
+ const e = globalThis;
2
+ let r = !1;
3
+ const m = "okno-win-opened", l = "okno-shadow-root", c = "okno-vt-style", i = "okno-nav-vt";
4
+ function u() {
5
+ try {
6
+ return e.localStorage?.getItem(m) === "true";
7
+ } catch {
8
+ return !1;
9
+ }
10
+ }
11
+ function h() {
12
+ return !!e.document && typeof e.document.startViewTransition == "function" && typeof window < "u" && "onpageswap" in window;
13
+ }
14
+ function _() {
15
+ if (!e.document) return !1;
16
+ for (const t of Array.from(e.document.styleSheets)) {
17
+ if (t.ownerNode?.id === c) continue;
18
+ let n;
19
+ try {
20
+ n = t.cssRules;
21
+ } catch {
22
+ continue;
23
+ }
24
+ for (const o of Array.from(n))
25
+ if (o.constructor?.name === "CSSViewTransitionRule" || typeof o.cssText == "string" && o.cssText.trimStart().startsWith("@view-transition")) return !0;
26
+ }
27
+ return !1;
28
+ }
29
+ function d() {
30
+ if (!e.document || e.document.getElementById(c) || !h()) return;
31
+ const t = _(), n = e.document.createElement("style");
32
+ n.id = c;
33
+ let o = `
34
+ html.${i}::view-transition-group(okno-shell) { animation-duration: 420ms; }
35
+ html.${i}::view-transition-old(okno-shell) { animation: okno-shell-hold 420ms both; }
36
+ html.${i}::view-transition-new(okno-shell) { animation: none; }
37
+ @keyframes okno-shell-hold { from { opacity: 1 } to { opacity: 1 } }
38
+ `;
39
+ t || (o += `
40
+ @view-transition { navigation: auto; }
41
+ html.${i}::view-transition-group(root),
42
+ html.${i}::view-transition-old(root),
43
+ html.${i}::view-transition-new(root) { animation: none; }
44
+ `), n.textContent = o, e.document.head.appendChild(n);
45
+ }
46
+ function w(t) {
47
+ t.style.cssText += ";position:fixed;inset:0;pointer-events:none;view-transition-name:okno-shell";
48
+ }
49
+ function v(t) {
50
+ if (!u() || !t.viewTransition) return;
51
+ e.document?.documentElement.classList.add(i);
52
+ const n = e.document?.getElementById(l);
53
+ n instanceof HTMLElement && w(n);
54
+ }
55
+ function y(t) {
56
+ const n = t.viewTransition;
57
+ if (!u() || !n || !e.document) return;
58
+ const o = e.document.documentElement;
59
+ o.classList.add(i), n.finished?.then?.(
60
+ () => o.classList.remove(i),
61
+ () => o.classList.remove(i)
62
+ );
63
+ let s = e.document.getElementById(l);
64
+ s || (s = e.document.createElement("div"), s.id = l, e.document.body.appendChild(s)), s instanceof HTMLElement && (s.style.cssText = "position:fixed;inset:0;pointer-events:none;view-transition-name:okno-shell");
65
+ }
66
+ function f() {
67
+ return !!e.__okno_loaded;
5
68
  }
6
- function a() {
7
- let t = n.document?.activeElement;
69
+ function E() {
70
+ let t = e.document?.activeElement;
8
71
  for (; t && t.shadowRoot?.activeElement; )
9
72
  t = t.shadowRoot.activeElement;
10
- const e = t?.tagName;
11
- return e === "INPUT" || e === "TEXTAREA" || t?.isContentEditable === !0;
73
+ const n = t?.tagName;
74
+ return n === "INPUT" || n === "TEXTAREA" || t?.isContentEditable === !0;
12
75
  }
13
- function r(t) {
14
- o || i() || (o = !0, n.__okno_autostart = t, import("okno/editor").catch((e) => {
15
- o = !1, console.error("[okno] failed to load editor bundle", e);
76
+ function a(t) {
77
+ r || f() || (r = !0, e.__okno_autostart = t, import("okno/editor").catch((n) => {
78
+ r = !1, console.error("[okno] failed to load editor bundle", n);
16
79
  }));
17
80
  }
18
- function l() {
19
- const t = n.location;
81
+ function p() {
82
+ const t = e.location;
20
83
  if (!t) return !1;
21
84
  try {
22
85
  if (new URLSearchParams(t.search).has("okno")) return !0;
@@ -24,9 +87,12 @@ function l() {
24
87
  }
25
88
  return typeof t.hash == "string" && /(?:^#|[#&])okno(?:$|[=&])/.test(t.hash);
26
89
  }
27
- function s() {
28
- !n.document || typeof __OKNO_IS_DEV__ < "u" && __OKNO_IS_DEV__ || n.__okno_gate_installed || (n.__okno_gate_installed = !0, n.document.addEventListener("keydown", (e) => {
29
- i() || e.key !== "e" || e.ctrlKey || e.metaKey || e.altKey || a() || r("key");
30
- }), l() && r("url"));
90
+ function g() {
91
+ if (!e.document || (typeof __OKNO_IS_DEV__ < "u" ? __OKNO_IS_DEV__ : !1) || e.__okno_gate_installed) return;
92
+ e.__okno_gate_installed = !0, e.document.addEventListener("keydown", (o) => {
93
+ f() || o.key !== "e" || o.ctrlKey || o.metaKey || o.altKey || E() || a("key");
94
+ }), e.__okno_ensure_vt = d;
95
+ const n = window;
96
+ n.addEventListener("pageswap", v), n.addEventListener("pagereveal", y), u() && (d(), a("session")), p() && a("url");
31
97
  }
32
- s();
98
+ g();
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AA6BA,OAAO,EAAE,CAAA"}
package/dist/cli.js ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+ const [n] = process.argv.slice(2);
3
+ switch (n) {
4
+ case "mcp": {
5
+ const { runMcp: o } = await import("./mcp.js");
6
+ await o();
7
+ break;
8
+ }
9
+ case "help":
10
+ case "--help":
11
+ case "-h": {
12
+ console.log(
13
+ ["", " npx okno Add okno to this project", " npx okno mcp Run the okno MCP server (for your AI client)", ""].join(`
14
+ `)
15
+ );
16
+ break;
17
+ }
18
+ default: {
19
+ const { runInit: o } = await import("./init.js");
20
+ await o();
21
+ }
22
+ }
@@ -0,0 +1,80 @@
1
+ import { p as s } from "./acorn-CZBJD705.js";
2
+ function a(o) {
3
+ const e = o;
4
+ switch (e.type) {
5
+ case "Literal": {
6
+ if (e.regex) throw new Error("regex literals are not allowed");
7
+ return e.value;
8
+ }
9
+ case "TemplateLiteral": {
10
+ if (e.expressions.length > 0) throw new Error("template expressions are not allowed");
11
+ return e.quasis.map((r) => r.value.cooked).join("");
12
+ }
13
+ case "UnaryExpression": {
14
+ if ((e.operator === "-" || e.operator === "+") && e.argument?.type === "Literal" && typeof e.argument.value == "number")
15
+ return e.operator === "-" ? -e.argument.value : +e.argument.value;
16
+ throw new Error(`unary operator ${e.operator} is not allowed`);
17
+ }
18
+ case "Identifier": {
19
+ if (e.name === "undefined") return;
20
+ throw new Error(`identifier ${e.name} is not allowed`);
21
+ }
22
+ case "ArrayExpression":
23
+ return e.elements.map((r) => {
24
+ if (r === null) throw new Error("array holes are not allowed");
25
+ if (r.type === "SpreadElement") throw new Error("spread is not allowed");
26
+ return a(r);
27
+ });
28
+ case "ObjectExpression": {
29
+ const r = {};
30
+ for (const t of e.properties) {
31
+ if (t.type !== "Property") throw new Error("spread is not allowed");
32
+ if (t.computed) throw new Error("computed keys are not allowed");
33
+ if (t.kind !== "init") throw new Error("getters/setters are not allowed");
34
+ if (t.method) throw new Error("methods are not allowed");
35
+ let n;
36
+ if (t.key.type === "Identifier") n = t.key.name;
37
+ else if (t.key.type === "Literal") n = String(t.key.value);
38
+ else throw new Error("unsupported object key");
39
+ r[n] = a(t.value);
40
+ }
41
+ return r;
42
+ }
43
+ default:
44
+ throw new Error(`unsupported node: ${e.type}`);
45
+ }
46
+ }
47
+ function l(o) {
48
+ try {
49
+ let e = o.trim();
50
+ const r = e.match(/export\s+default\s+([\s\S]+)/);
51
+ if (!r)
52
+ return console.warn("Could not find export default"), {};
53
+ e = r[1].trim(), e.endsWith(";") && (e = e.slice(0, -1)), e = e.replace(/\s+satisfies\s+\w+\s*$/, ""), e = e.replace(/\s+as\s+\w+\s*$/, "");
54
+ const t = s(`(${e})`, 0, { ecmaVersion: "latest" });
55
+ return a(t);
56
+ } catch (e) {
57
+ return console.error("Failed to parse TypeScript export:", e), {};
58
+ }
59
+ }
60
+ function p(o, e) {
61
+ const r = { date: e.now, author: e.author }, t = { ...o, created: e.created ?? r, updated: r };
62
+ return `export default ${JSON.stringify(t, null, " ")}
63
+ `;
64
+ }
65
+ function u(o, e = `import type { Schema } from "okno"
66
+
67
+ `) {
68
+ return `${e}export default ${JSON.stringify(o, null, " ")} satisfies Schema
69
+ `;
70
+ }
71
+ function d(o) {
72
+ return `export default ${JSON.stringify(o, null, " ")}
73
+ `;
74
+ }
75
+ export {
76
+ u as a,
77
+ d as b,
78
+ p as e,
79
+ l as p
80
+ };