hyperbook 0.84.0 → 0.84.1
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/dist/assets/client.js +0 -22
- package/dist/assets/cloud.js +86 -79
- package/dist/assets/shell.css +2 -1
- package/dist/assets/store.js +0 -5
- package/dist/index.js +5 -5
- package/package.json +4 -4
package/dist/assets/client.js
CHANGED
|
@@ -488,25 +488,6 @@ var hyperbook = Object.assign(window.hyperbook || {}, (function () {
|
|
|
488
488
|
|
|
489
489
|
observer.observe(document.body, { childList: true, subtree: true });
|
|
490
490
|
|
|
491
|
-
// User authentication functions (delegate to cloud.js IIFE)
|
|
492
|
-
const userToggle = () => {
|
|
493
|
-
if (window.hyperbook.cloud) {
|
|
494
|
-
window.hyperbook.cloud.userToggle();
|
|
495
|
-
}
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
const doLogin = async () => {
|
|
499
|
-
if (window.hyperbook.cloud) {
|
|
500
|
-
await window.hyperbook.cloud.doLogin();
|
|
501
|
-
}
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
const doLogout = () => {
|
|
505
|
-
if (window.hyperbook.cloud) {
|
|
506
|
-
window.hyperbook.cloud.doLogout();
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
|
|
510
491
|
return {
|
|
511
492
|
toggleLightbox,
|
|
512
493
|
toggleBookmark,
|
|
@@ -520,9 +501,6 @@ var hyperbook = Object.assign(window.hyperbook || {}, (function () {
|
|
|
520
501
|
shareClose,
|
|
521
502
|
shareUpdatePreview,
|
|
522
503
|
shareCopyUrl,
|
|
523
|
-
userToggle,
|
|
524
|
-
doLogin,
|
|
525
|
-
doLogout,
|
|
526
504
|
init,
|
|
527
505
|
};
|
|
528
506
|
})());
|
package/dist/assets/cloud.js
CHANGED
|
@@ -4,6 +4,7 @@ window.hyperbook.cloud = (function () {
|
|
|
4
4
|
const AUTH_TOKEN_KEY = "hyperbook_auth_token";
|
|
5
5
|
const AUTH_USER_KEY = "hyperbook_auth_user";
|
|
6
6
|
let isLoadingFromCloud = false;
|
|
7
|
+
let syncManager = null;
|
|
7
8
|
|
|
8
9
|
// ===== Simple Mutex =====
|
|
9
10
|
class Mutex {
|
|
@@ -557,7 +558,7 @@ window.hyperbook.cloud = (function () {
|
|
|
557
558
|
/**
|
|
558
559
|
* Initialize cloud integration
|
|
559
560
|
*/
|
|
560
|
-
async function
|
|
561
|
+
async function init() {
|
|
561
562
|
// Load from cloud if authenticated
|
|
562
563
|
if (HYPERBOOK_CLOUD && getAuthToken()) {
|
|
563
564
|
try {
|
|
@@ -578,8 +579,6 @@ window.hyperbook.cloud = (function () {
|
|
|
578
579
|
}
|
|
579
580
|
}
|
|
580
581
|
|
|
581
|
-
// Initialize SyncManager for cloud syncing
|
|
582
|
-
let syncManager = null;
|
|
583
582
|
if (HYPERBOOK_CLOUD && getAuthToken() && !isReadOnlyMode()) {
|
|
584
583
|
syncManager = new SyncManager({
|
|
585
584
|
debounceDelay: 2000,
|
|
@@ -599,119 +598,130 @@ window.hyperbook.cloud = (function () {
|
|
|
599
598
|
|
|
600
599
|
// Start polling external DBs for changes
|
|
601
600
|
syncManager.startPolling();
|
|
602
|
-
|
|
603
|
-
window.hyperbookManualSave = () => syncManager.manualSave();
|
|
604
601
|
}
|
|
605
602
|
}
|
|
606
603
|
|
|
607
604
|
// ===== Cloud UI Functions =====
|
|
608
605
|
const updateUserIconState = (state) => {
|
|
609
|
-
const icon = document.querySelector(
|
|
606
|
+
const icon = document.querySelector(".user-icon");
|
|
610
607
|
if (!icon) return;
|
|
611
|
-
icon.setAttribute(
|
|
608
|
+
icon.setAttribute("data-state", state);
|
|
612
609
|
};
|
|
613
610
|
|
|
614
611
|
const updateUserUI = (user) => {
|
|
615
|
-
const loginForm = document.getElementById(
|
|
616
|
-
const userInfo = document.getElementById(
|
|
612
|
+
const loginForm = document.getElementById("user-login-form");
|
|
613
|
+
const userInfo = document.getElementById("user-info");
|
|
617
614
|
|
|
618
615
|
if (!loginForm || !userInfo) return;
|
|
619
616
|
|
|
620
617
|
if (user) {
|
|
621
|
-
loginForm.classList.add(
|
|
622
|
-
userInfo.classList.remove(
|
|
623
|
-
document.getElementById(
|
|
624
|
-
updateUserIconState(
|
|
618
|
+
loginForm.classList.add("hidden");
|
|
619
|
+
userInfo.classList.remove("hidden");
|
|
620
|
+
document.getElementById("user-display-name").textContent = user.username;
|
|
621
|
+
updateUserIconState("logged-in");
|
|
625
622
|
} else {
|
|
626
|
-
loginForm.classList.remove(
|
|
627
|
-
userInfo.classList.add(
|
|
628
|
-
const passwordField = document.getElementById(
|
|
629
|
-
if (passwordField) passwordField.value =
|
|
630
|
-
updateUserIconState(
|
|
623
|
+
loginForm.classList.remove("hidden");
|
|
624
|
+
userInfo.classList.add("hidden");
|
|
625
|
+
const passwordField = document.getElementById("user-password");
|
|
626
|
+
if (passwordField) passwordField.value = "";
|
|
627
|
+
updateUserIconState("not-logged-in");
|
|
631
628
|
}
|
|
632
629
|
};
|
|
633
630
|
|
|
634
631
|
const updateSaveStatus = (status, metadata = {}) => {
|
|
635
|
-
const statusEl = document.getElementById(
|
|
632
|
+
const statusEl = document.getElementById("user-save-status");
|
|
636
633
|
if (!statusEl) return;
|
|
637
634
|
|
|
638
635
|
statusEl.className = status;
|
|
639
636
|
|
|
640
|
-
if (status ===
|
|
641
|
-
statusEl.textContent = i18n.get(
|
|
642
|
-
updateUserIconState(
|
|
643
|
-
} else if (status ===
|
|
644
|
-
statusEl.textContent = i18n.get(
|
|
645
|
-
updateUserIconState(
|
|
646
|
-
} else if (status ===
|
|
647
|
-
statusEl.textContent = i18n.get(
|
|
648
|
-
updateUserIconState(
|
|
649
|
-
} else if (status ===
|
|
650
|
-
statusEl.textContent = i18n.get(
|
|
651
|
-
updateUserIconState(
|
|
652
|
-
} else if (status ===
|
|
653
|
-
statusEl.textContent = i18n.get(
|
|
654
|
-
updateUserIconState(
|
|
655
|
-
} else if (status ===
|
|
656
|
-
statusEl.textContent = i18n.get(
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
updateUserIconState(
|
|
637
|
+
if (status === "unsaved") {
|
|
638
|
+
statusEl.textContent = i18n.get("user-unsaved", {}, "Unsaved changes");
|
|
639
|
+
updateUserIconState("logged-in");
|
|
640
|
+
} else if (status === "saving") {
|
|
641
|
+
statusEl.textContent = i18n.get("user-saving", {}, "Saving...");
|
|
642
|
+
updateUserIconState("syncing");
|
|
643
|
+
} else if (status === "saved") {
|
|
644
|
+
statusEl.textContent = i18n.get("user-saved", {}, "Saved");
|
|
645
|
+
updateUserIconState("synced");
|
|
646
|
+
} else if (status === "error") {
|
|
647
|
+
statusEl.textContent = i18n.get("user-save-error", {}, "Save Error");
|
|
648
|
+
updateUserIconState("unsynced");
|
|
649
|
+
} else if (status === "offline") {
|
|
650
|
+
statusEl.textContent = i18n.get("user-offline", {}, "Offline");
|
|
651
|
+
updateUserIconState("unsynced");
|
|
652
|
+
} else if (status === "offline-queued") {
|
|
653
|
+
statusEl.textContent = i18n.get(
|
|
654
|
+
"user-offline-queued",
|
|
655
|
+
{},
|
|
656
|
+
"Saved locally",
|
|
657
|
+
);
|
|
658
|
+
updateUserIconState("logged-in");
|
|
659
|
+
} else if (status === "readonly") {
|
|
660
|
+
statusEl.textContent = i18n.get("user-readonly", {}, "Read-Only Mode");
|
|
661
|
+
statusEl.className = "readonly";
|
|
662
|
+
updateUserIconState("synced");
|
|
662
663
|
}
|
|
663
664
|
};
|
|
664
665
|
|
|
665
666
|
const showLogin = () => {
|
|
666
|
-
const drawer = document.getElementById(
|
|
667
|
-
if (drawer && !drawer.hasAttribute(
|
|
668
|
-
drawer.setAttribute(
|
|
667
|
+
const drawer = document.getElementById("user-drawer");
|
|
668
|
+
if (drawer && !drawer.hasAttribute("open")) {
|
|
669
|
+
drawer.setAttribute("open", "");
|
|
669
670
|
updateUserUI(null);
|
|
670
671
|
}
|
|
671
672
|
};
|
|
672
673
|
|
|
673
674
|
const userToggle = () => {
|
|
674
|
-
const drawer = document.getElementById(
|
|
675
|
+
const drawer = document.getElementById("user-drawer");
|
|
675
676
|
if (drawer) {
|
|
676
|
-
drawer.toggleAttribute(
|
|
677
|
+
drawer.toggleAttribute("open");
|
|
677
678
|
const user = getAuthUser();
|
|
678
679
|
updateUserUI(user);
|
|
679
680
|
}
|
|
680
681
|
};
|
|
681
682
|
|
|
682
|
-
const
|
|
683
|
-
const username = document.getElementById(
|
|
684
|
-
const password = document.getElementById(
|
|
685
|
-
const errorEl = document.getElementById(
|
|
683
|
+
const login = async () => {
|
|
684
|
+
const username = document.getElementById("user-username").value;
|
|
685
|
+
const password = document.getElementById("user-password").value;
|
|
686
|
+
const errorEl = document.getElementById("user-login-error");
|
|
686
687
|
|
|
687
688
|
if (!username || !password) {
|
|
688
|
-
errorEl.textContent = i18n.get(
|
|
689
|
+
errorEl.textContent = i18n.get(
|
|
690
|
+
"user-login-required",
|
|
691
|
+
{},
|
|
692
|
+
"Username and password required",
|
|
693
|
+
);
|
|
689
694
|
return;
|
|
690
695
|
}
|
|
691
696
|
|
|
692
697
|
try {
|
|
693
698
|
const user = await hyperbookLogin(username, password);
|
|
694
699
|
updateUserUI(user);
|
|
695
|
-
errorEl.textContent =
|
|
700
|
+
errorEl.textContent = "";
|
|
696
701
|
} catch (error) {
|
|
697
|
-
errorEl.textContent =
|
|
702
|
+
errorEl.textContent =
|
|
703
|
+
error.message || i18n.get("user-login-failed", {}, "Login failed");
|
|
698
704
|
}
|
|
699
705
|
};
|
|
700
706
|
|
|
701
|
-
const
|
|
702
|
-
if (
|
|
707
|
+
const logout = () => {
|
|
708
|
+
if (
|
|
709
|
+
confirm(
|
|
710
|
+
i18n.get("user-logout-confirm", {}, "Are you sure you want to logout?"),
|
|
711
|
+
)
|
|
712
|
+
) {
|
|
703
713
|
hyperbookLogout();
|
|
704
714
|
updateUserUI(null);
|
|
705
715
|
|
|
706
|
-
const drawer = document.getElementById(
|
|
716
|
+
const drawer = document.getElementById("user-drawer");
|
|
707
717
|
if (drawer) {
|
|
708
|
-
drawer.removeAttribute(
|
|
718
|
+
drawer.removeAttribute("open");
|
|
709
719
|
}
|
|
710
720
|
}
|
|
711
721
|
};
|
|
712
722
|
|
|
713
723
|
// Initialize user UI on load
|
|
714
|
-
document.addEventListener(
|
|
724
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
715
725
|
const user = getAuthUser();
|
|
716
726
|
if (user) {
|
|
717
727
|
updateUserUI(user);
|
|
@@ -719,34 +729,31 @@ window.hyperbook.cloud = (function () {
|
|
|
719
729
|
|
|
720
730
|
// Show impersonation banner if in readonly mode
|
|
721
731
|
if (isReadOnlyMode()) {
|
|
722
|
-
const banner = document.createElement(
|
|
723
|
-
banner.id =
|
|
732
|
+
const banner = document.createElement("div");
|
|
733
|
+
banner.id = "impersonation-banner";
|
|
724
734
|
banner.innerHTML = `
|
|
725
|
-
<span>${i18n.get(
|
|
726
|
-
<a href="#" id="exit-impersonation">${i18n.get(
|
|
735
|
+
<span>${i18n.get("user-impersonating", {}, "Impersonating")}: <strong>${user ? user.username : ""}</strong> — ${i18n.get("user-readonly", {}, "Read-Only Mode")}</span>
|
|
736
|
+
<a href="#" id="exit-impersonation">${i18n.get("user-exit-impersonation", {}, "Exit Impersonation")}</a>
|
|
727
737
|
`;
|
|
728
738
|
document.body.prepend(banner);
|
|
729
739
|
|
|
730
|
-
document
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
740
|
+
document
|
|
741
|
+
.getElementById("exit-impersonation")
|
|
742
|
+
.addEventListener("click", (e) => {
|
|
743
|
+
e.preventDefault();
|
|
744
|
+
hyperbookLogout();
|
|
745
|
+
window.close();
|
|
746
|
+
window.location.reload();
|
|
747
|
+
});
|
|
736
748
|
}
|
|
737
749
|
});
|
|
738
750
|
|
|
751
|
+
init();
|
|
752
|
+
|
|
739
753
|
return {
|
|
740
|
-
|
|
741
|
-
logout: hyperbookLogout,
|
|
742
|
-
getAuthUser,
|
|
743
|
-
isReadOnlyMode,
|
|
744
|
-
initCloudIntegration,
|
|
745
|
-
updateUserUI,
|
|
746
|
-
updateSaveStatus,
|
|
747
|
-
showLogin,
|
|
754
|
+
save: () => syncManager?.manualSave(),
|
|
748
755
|
userToggle,
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
}
|
|
756
|
+
login,
|
|
757
|
+
logout,
|
|
758
|
+
};
|
|
752
759
|
})();
|
package/dist/assets/shell.css
CHANGED
|
@@ -1096,6 +1096,7 @@ nav.toc li.level-3 {
|
|
|
1096
1096
|
}
|
|
1097
1097
|
|
|
1098
1098
|
#impersonation-banner {
|
|
1099
|
+
font-family: hyperbook-body, sans-serif;
|
|
1099
1100
|
position: fixed;
|
|
1100
1101
|
top: 0;
|
|
1101
1102
|
left: 0;
|
|
@@ -1108,7 +1109,7 @@ nav.toc li.level-3 {
|
|
|
1108
1109
|
justify-content: center;
|
|
1109
1110
|
align-items: center;
|
|
1110
1111
|
gap: 16px;
|
|
1111
|
-
font-size:
|
|
1112
|
+
font-size: 1rem;
|
|
1112
1113
|
}
|
|
1113
1114
|
|
|
1114
1115
|
#impersonation-banner a {
|
package/dist/assets/store.js
CHANGED
|
@@ -194,11 +194,6 @@ const initStore = async () => {
|
|
|
194
194
|
windowHeight: window.innerHeight,
|
|
195
195
|
});
|
|
196
196
|
});
|
|
197
|
-
|
|
198
|
-
// Initialize cloud integration if configured
|
|
199
|
-
if (window.hyperbook.cloud) {
|
|
200
|
-
await window.hyperbook.cloud.initializeStore(store);
|
|
201
|
-
}
|
|
202
197
|
};
|
|
203
198
|
|
|
204
199
|
initStore();
|
package/dist/index.js
CHANGED
|
@@ -181451,7 +181451,7 @@ var makeHeaderElements = (ctx) => {
|
|
|
181451
181451
|
id: "user-toggle",
|
|
181452
181452
|
class: "icon-button",
|
|
181453
181453
|
title: "User",
|
|
181454
|
-
onclick: "hyperbook.userToggle()"
|
|
181454
|
+
onclick: "hyperbook.cloud.userToggle()"
|
|
181455
181455
|
},
|
|
181456
181456
|
children: [
|
|
181457
181457
|
{
|
|
@@ -181522,7 +181522,7 @@ var makeHeaderElements = (ctx) => {
|
|
|
181522
181522
|
type: "element",
|
|
181523
181523
|
tagName: "button",
|
|
181524
181524
|
properties: {
|
|
181525
|
-
onclick: "hyperbook.
|
|
181525
|
+
onclick: "hyperbook.cloud.login()"
|
|
181526
181526
|
},
|
|
181527
181527
|
children: [
|
|
181528
181528
|
{
|
|
@@ -181622,7 +181622,7 @@ var makeHeaderElements = (ctx) => {
|
|
|
181622
181622
|
type: "element",
|
|
181623
181623
|
tagName: "button",
|
|
181624
181624
|
properties: {
|
|
181625
|
-
onclick: "
|
|
181625
|
+
onclick: "hyperbook.cloud.save()"
|
|
181626
181626
|
},
|
|
181627
181627
|
children: [
|
|
181628
181628
|
{
|
|
@@ -181635,7 +181635,7 @@ var makeHeaderElements = (ctx) => {
|
|
|
181635
181635
|
type: "element",
|
|
181636
181636
|
tagName: "button",
|
|
181637
181637
|
properties: {
|
|
181638
|
-
onclick: "hyperbook.
|
|
181638
|
+
onclick: "hyperbook.cloud.logout()",
|
|
181639
181639
|
class: "logout-btn"
|
|
181640
181640
|
},
|
|
181641
181641
|
children: [
|
|
@@ -202823,7 +202823,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
|
|
|
202823
202823
|
/***/ ((module) => {
|
|
202824
202824
|
|
|
202825
202825
|
"use strict";
|
|
202826
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.84.
|
|
202826
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.84.1","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=18"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
|
|
202827
202827
|
|
|
202828
202828
|
/***/ })
|
|
202829
202829
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hyperbook",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.1",
|
|
4
4
|
"author": "Mike Barkmin",
|
|
5
5
|
"homepage": "https://github.com/openpatch/hyperbook#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"update-check": "1.5.4",
|
|
58
58
|
"ws": "^8.18.0",
|
|
59
59
|
"create-hyperbook": "0.3.4",
|
|
60
|
-
"@hyperbook/
|
|
61
|
-
"@hyperbook/
|
|
62
|
-
"@hyperbook/
|
|
60
|
+
"@hyperbook/markdown": "0.55.1",
|
|
61
|
+
"@hyperbook/types": "0.22.0",
|
|
62
|
+
"@hyperbook/fs": "0.24.2"
|
|
63
63
|
},
|
|
64
64
|
"scripts": {
|
|
65
65
|
"version": "pnpm build",
|