kenobi-js 0.1.43 → 0.1.44

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/browser/dist.js CHANGED
@@ -1333,8 +1333,6 @@ var KenobiLib = (() => {
1333
1333
  .backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0); backdrop-filter: blur(0); -webkit-backdrop-filter: blur(0); transition: all 0.5s ease; z-index: 0; pointer-events: none; }
1334
1334
  .backdrop.active { background: rgba(0,0,0,0.1); backdrop-filter: blur(var(--kb-focus-blur)); -webkit-backdrop-filter: blur(var(--kb-focus-blur)); }
1335
1335
  .launcher { position: absolute; pointer-events: auto; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); box-shadow: var(--kb-shadow-container); backdrop-filter: blur(var(--kb-backdrop-blur)); -webkit-backdrop-filter: blur(var(--kb-backdrop-blur)); border-radius: 9999px; padding: 0.5rem 1rem; display: flex; align-items: center; gap: 0.75rem; cursor: pointer; transition: transform 0.2s, opacity 0.3s; opacity: 0; z-index: 1; color: var(--kb-text-title); font-weight: 500; font-size: 0.875rem; font-family: var(--kb-font-family); }
1336
- .launcher .kbd-hint .kbd { background: var(--kb-kbd-bg); border: 1px solid var(--kb-kbd-border); color: var(--kb-kbd-text); }
1337
- .launcher .kbd-hint .kbd-text { color: var(--kb-kbd-text); }
1338
1336
  .launcher:hover { transform: scale(1.02); background-color: var(--kb-bg-container); }
1339
1337
  .kb-chip-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
1340
1338
  .kb-chip { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.8rem; border-radius: 9999px; border: 1px solid rgba(255,255,255,0.85); background: linear-gradient(135deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)); color: var(--kb-text-title); font-size: 0.8rem; font-weight: 600; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 8px 18px rgba(0,0,0,0.4), inset 0 0 0 1px rgba(255,255,255,0.45); }
@@ -1409,19 +1407,17 @@ var KenobiLib = (() => {
1409
1407
  .popover-watermark { position: absolute; top: 100%; left: 0; right: 0; text-align: center; font-size: 0.625rem; color: var(--kb-watermark-text); opacity: 0.6; font-weight: 500; letter-spacing: 0.025em; padding-top: 0.5rem; }
1410
1408
  .popover-watermark a { color: inherit; text-decoration: none; cursor: pointer; }
1411
1409
  .popover-watermark a:hover { text-decoration: underline; opacity: 1; }
1412
- /* Launcher hint positioning */
1413
- .launcher .kbd-hint { position: static; transform: none; opacity: 0.6; transition: opacity 0.2s; }
1414
- .launcher:hover .kbd-hint { opacity: 1; }
1415
- .pos-top-right.launcher .kbd-hint { left: auto; right: auto; }
1410
+ /* Launcher helper hint (below launcher) */
1411
+ .launcher-hint { position: absolute; top: calc(100% + 0.4rem); left: 50%; transform: translateX(-50%); pointer-events: none; white-space: nowrap; }
1412
+ .launcher-hint.visible { opacity: 0.65; }
1416
1413
  /* Launcher dismiss button */
1417
1414
  .launcher .btn-dismiss.launcher-dismiss { top: -0.375rem; left: -0.375rem; width: 1.25rem; height: 1.25rem; opacity: 0; transition: opacity 0.2s ease-out, background-color 0.3s ease-out, color 0.3s ease-out; }
1418
1415
  .launcher:hover .btn-dismiss.launcher-dismiss { opacity: 1; }
1419
1416
  /* Launcher logo */
1420
1417
  .launcher-logo { width: 20px; height: 20px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
1421
1418
  .launcher-logo svg { width: 20px; height: 20px; }
1422
- /* Mobile: hide keyboard hints, show dismiss button */
1419
+ /* Mobile: show dismiss button */
1423
1420
  @media (max-width: 768px) {
1424
- .launcher .kbd-hint { display: none; }
1425
1421
  .launcher .btn-dismiss.launcher-dismiss { opacity: 1; }
1426
1422
  }
1427
1423
  /* Toggle personalization button */
@@ -1431,6 +1427,11 @@ var KenobiLib = (() => {
1431
1427
  /* Custom tooltip for toggle button */
1432
1428
  .btn-toggle-personalization .toggle-tooltip { position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%); white-space: nowrap; background-color: var(--kb-bg-container); border: 1px solid var(--kb-border-container); color: var(--kb-text-title); font-size: 0.7rem; font-weight: 500; padding: 0.25rem 0.5rem; border-radius: 4px; opacity: 0; visibility: hidden; transition: opacity 0.15s ease-out, visibility 0.15s ease-out; pointer-events: none; z-index: 100; box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
1433
1429
  .btn-toggle-personalization:hover .toggle-tooltip { opacity: 1; visibility: visible; }
1430
+ .btn-toggle-personalization.loading { cursor: default; opacity: 0.7; }
1431
+ .btn-toggle-personalization.loading:hover { transform: none; }
1432
+ .btn-toggle-personalization:disabled { cursor: default; }
1433
+ .launcher-domain { text-decoration: underline; text-underline-offset: 2px; }
1434
+ .launcher-actions { display: flex; align-items: center; gap: 0.25rem; }
1434
1435
  `;
1435
1436
  var useEnterExitAnimation = /* @__PURE__ */ __name((ref, isVisible, config) => {
1436
1437
  const hasEnteredRef = A2(false);
@@ -1769,19 +1770,35 @@ var KenobiLib = (() => {
1769
1770
  config.onDismiss,
1770
1771
  isPopoverEnabled
1771
1772
  ]);
1773
+ const [isMobile, setIsMobile] = d2(false);
1772
1774
  const isMac = typeof navigator !== "undefined" && /Mac/.test(navigator.userAgent);
1773
- const shortcutDisplay = (() => {
1775
+ y2(() => {
1776
+ if (typeof window === "undefined") return;
1777
+ const media = window.matchMedia("(max-width: 768px)");
1778
+ const update = /* @__PURE__ */ __name(() => setIsMobile(media.matches), "update");
1779
+ update();
1780
+ if ("addEventListener" in media) {
1781
+ media.addEventListener("change", update);
1782
+ return () => media.removeEventListener("change", update);
1783
+ }
1784
+ window.addEventListener("resize", update);
1785
+ return () => window.removeEventListener("resize", update);
1786
+ }, []);
1787
+ const launcherHint = (() => {
1788
+ if (isMobile) {
1789
+ return { keys: [], label: "tap to launch" };
1790
+ }
1774
1791
  if (config.keyboardShortcut) {
1775
1792
  const mods = config.keyboardShortcut.modifiers || [];
1776
1793
  const keys = [];
1777
- if (mods.includes("meta")) keys.push(isMac ? "\u2318" : "Win");
1794
+ if (mods.includes("meta")) keys.push(isMac ? "\u2318" : "Ctrl");
1778
1795
  if (mods.includes("ctrl")) keys.push("Ctrl");
1779
1796
  if (mods.includes("alt")) keys.push(isMac ? "Opt" : "Alt");
1780
1797
  if (mods.includes("shift")) keys.push("Shift");
1781
1798
  keys.push(config.keyboardShortcut.key.toUpperCase());
1782
- return keys;
1799
+ return { keys, label: "to launch" };
1783
1800
  }
1784
- return [isMac ? "\u2318" : "Ctrl", "P"];
1801
+ return { keys: [isMac ? "\u2318" : "Ctrl", "P"], label: "to launch" };
1785
1802
  })();
1786
1803
  const [logoFailed, setLogoFailed] = d2(false);
1787
1804
  const [logoAttempt, setLogoAttempt] = d2(
@@ -2057,6 +2074,7 @@ var KenobiLib = (() => {
2057
2074
  const isContainerVisible = !!config.isVisible && mode === "card" && !isDismissed;
2058
2075
  const isLauncherVisible = !!config.isVisible && mode === "launcher" && !isDismissed;
2059
2076
  const isAnythingVisible = isContainerVisible || isLauncherVisible;
2077
+ const showLauncherHint = !!config.showKeyboardHints && isLauncherVisible;
2060
2078
  return /* @__PURE__ */ u3(k, { children: [
2061
2079
  /* @__PURE__ */ u3(
2062
2080
  "div",
@@ -2254,25 +2272,55 @@ var KenobiLib = (() => {
2254
2272
  ),
2255
2273
  config.showLauncherLogo !== false && /* @__PURE__ */ u3("div", { class: "launcher-logo", children: /* @__PURE__ */ u3(LogoIcon, {}) }),
2256
2274
  /* @__PURE__ */ u3("div", { class: "launcher-label", children: [
2257
- /* @__PURE__ */ u3("span", { children: launcherLabelText }),
2275
+ /* @__PURE__ */ u3("span", { children: (() => {
2276
+ const forMatch = launcherLabelText.match(/^(For\s+)(.+)$/i);
2277
+ if (forMatch) {
2278
+ return /* @__PURE__ */ u3(k, { children: [
2279
+ forMatch[1],
2280
+ /* @__PURE__ */ u3("span", { class: "launcher-domain", children: forMatch[2] })
2281
+ ] });
2282
+ }
2283
+ return launcherLabelText;
2284
+ })() }),
2258
2285
  isDeanonymized && renderDeanonymizedChip("launcher")
2259
2286
  ] }),
2260
- config.enableUndoToggle && hasHadSuccess && /* @__PURE__ */ u3(
2261
- "button",
2262
- {
2263
- class: "btn-toggle-personalization",
2264
- "aria-label": config.isPersonalized ? "Show original" : "Show personalized",
2265
- onClick: (e3) => {
2266
- e3.stopPropagation();
2267
- config.onTogglePersonalization?.();
2268
- },
2269
- children: [
2270
- /* @__PURE__ */ u3(ArrowPathIcon, {}),
2271
- /* @__PURE__ */ u3("span", { class: "toggle-tooltip", children: config.isPersonalized ? "Show original" : "Show personalized" })
2272
- ]
2273
- }
2274
- ),
2275
- config.showKeyboardHints && /* @__PURE__ */ u3("div", { class: "kbd-hint visible", children: /* @__PURE__ */ u3("div", { class: "kbd-group", children: shortcutDisplay.map((k3, i3) => /* @__PURE__ */ u3("div", { class: "kbd", children: k3 }, i3)) }) })
2287
+ /* @__PURE__ */ u3("div", { class: "launcher-actions", children: [
2288
+ config.enableUndoToggle && hasHadSuccess && /* @__PURE__ */ u3(
2289
+ "button",
2290
+ {
2291
+ class: "btn-toggle-personalization",
2292
+ "aria-label": config.isPersonalized ? "Show original" : "Show personalized",
2293
+ onClick: (e3) => {
2294
+ e3.stopPropagation();
2295
+ config.onTogglePersonalization?.();
2296
+ },
2297
+ children: [
2298
+ /* @__PURE__ */ u3(ArrowPathIcon, {}),
2299
+ /* @__PURE__ */ u3("span", { class: "toggle-tooltip", children: config.isPersonalized ? "Show original" : "Show personalized" })
2300
+ ]
2301
+ }
2302
+ ),
2303
+ config.launcherAction && config.launcherAction.status !== "idle" && hasHadSuccess && /* @__PURE__ */ u3(
2304
+ "button",
2305
+ {
2306
+ class: `btn-toggle-personalization${config.launcherAction.status === "loading" ? " loading" : ""}`,
2307
+ "aria-label": config.launcherAction.tooltip || "Action",
2308
+ onClick: (e3) => {
2309
+ e3.stopPropagation();
2310
+ config.launcherAction?.onClick?.();
2311
+ },
2312
+ disabled: config.launcherAction.status === "loading",
2313
+ children: [
2314
+ config.launcherAction.status === "loading" ? /* @__PURE__ */ u3(LoaderIcon, {}) : /* @__PURE__ */ u3(ArrowRightIcon, {}),
2315
+ config.launcherAction.tooltip && /* @__PURE__ */ u3("span", { class: "toggle-tooltip", children: config.launcherAction.tooltip })
2316
+ ]
2317
+ }
2318
+ )
2319
+ ] }),
2320
+ showLauncherHint && /* @__PURE__ */ u3("div", { class: "kbd-hint visible launcher-hint", "aria-hidden": "true", children: [
2321
+ launcherHint.keys.length > 0 && /* @__PURE__ */ u3("div", { class: "kbd-group", children: launcherHint.keys.map((key, index) => /* @__PURE__ */ u3("div", { class: "kbd", children: key }, index)) }),
2322
+ /* @__PURE__ */ u3("span", { class: "kbd-text", children: launcherHint.label })
2323
+ ] })
2276
2324
  ]
2277
2325
  }
2278
2326
  )
@@ -3965,7 +4013,7 @@ var KenobiLib = (() => {
3965
4013
  __publicField(this, "personalize", /* @__PURE__ */ __name(async (input) => {
3966
4014
  if (!this.config.publicKey) {
3967
4015
  this.log("error", "Cannot personalize: publicKey not configured");
3968
- return;
4016
+ return null;
3969
4017
  }
3970
4018
  const startTime = /* @__PURE__ */ new Date();
3971
4019
  this.log("debug", "Starting personalization with input:", input);
@@ -4013,6 +4061,7 @@ var KenobiLib = (() => {
4013
4061
  source: prepared ? "prefetch" : "api",
4014
4062
  deanonymized: isDeanonymizedInput
4015
4063
  });
4064
+ return result;
4016
4065
  } catch (error) {
4017
4066
  this.log("error", "Personalization failed:", error);
4018
4067
  if (this.cueCardInstance) {
@@ -4025,6 +4074,7 @@ var KenobiLib = (() => {
4025
4074
  deanonymized: isDeanonymizedInput
4026
4075
  });
4027
4076
  }
4077
+ return null;
4028
4078
  }, "personalize"));
4029
4079
  /**
4030
4080
  * Returns the CueCard instance if one was auto-mounted.