@vue-skuilder/standalone-ui 0.2.19 → 0.2.21

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.
@@ -29632,18 +29632,23 @@ ${t.stack}` : JSON.stringify(t);
29632
29632
  return t === GuestUsername || t.startsWith(GuestUsername) ? getLocalUserDB(t) : this.getUserDB(t);
29633
29633
  }
29634
29634
  async hydrate(t, c) {
29635
- let u = pouchdb_setup_default.replicate(c, t, {});
29636
- this.hydrationHandle = u;
29635
+ let u = (await t.info()).doc_count === 0, d = pouchdb_setup_default.replicate(c, t, u ? { selector: { _deleted: { $exists: !1 } } } : {});
29636
+ this.hydrationHandle = d;
29637
29637
  try {
29638
- return { docsWritten: (await u).docs_written };
29638
+ let t = await d;
29639
+ return {
29640
+ docsWritten: t.docs_written,
29641
+ lastSeq: u ? t.last_seq : void 0
29642
+ };
29639
29643
  } finally {
29640
29644
  this.hydrationHandle = void 0;
29641
29645
  }
29642
29646
  }
29643
- startSync(t, c) {
29647
+ startSync(t, c, u) {
29644
29648
  t.name !== c.name && (this.syncHandle = pouchdb_setup_default.sync(t, c, {
29645
29649
  live: !0,
29646
- retry: !0
29650
+ retry: !0,
29651
+ ...u === void 0 ? {} : { pull: { since: u } }
29647
29652
  }));
29648
29653
  }
29649
29654
  stopSync() {
@@ -30072,7 +30077,7 @@ Currently logged-in as ${this._username}.`);
30072
30077
  }) : (_BaseUser._instance = new _BaseUser(await t.getCurrentUsername(), t), await _BaseUser._instance.init(), _BaseUser._instance);
30073
30078
  }
30074
30079
  constructor(t, c) {
30075
- _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _defineProperty$2(this, "_hydration", { state: "not-required" }), _defineProperty$2(this, "_hydrationPromise", null), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
30080
+ _defineProperty$2(this, "_username", void 0), _defineProperty$2(this, "syncStrategy", void 0), _defineProperty$2(this, "localDB", void 0), _defineProperty$2(this, "remoteDB", void 0), _defineProperty$2(this, "writeDB", void 0), _defineProperty$2(this, "updateQueue", void 0), _defineProperty$2(this, "_hydration", { state: "not-required" }), _defineProperty$2(this, "_hydrationPromise", null), _defineProperty$2(this, "_hydratedSeq", void 0), _BaseUser._initialized = !1, this._username = t, this.syncStrategy = c, this.setDBandQ();
30076
30081
  }
30077
30082
  setDBandQ() {
30078
30083
  this.localDB = getLocalUserDB(this._username), this.remoteDB = this.syncStrategy.setupRemoteDB(this._username), this.writeDB = this.syncStrategy.getWriteDB ? this.syncStrategy.getWriteDB(this._username) : this.localDB, this.updateQueue = new UpdateQueue(this.localDB, this.writeDB);
@@ -30082,14 +30087,14 @@ Currently logged-in as ${this._username}.`);
30082
30087
  _BaseUser._initialized = !0;
30083
30088
  return;
30084
30089
  }
30085
- this.syncStrategy.stopSync?.(), this.setDBandQ(), this._hydrationPromise = this.hydrateLocalMirror(), await this._hydrationPromise, this.syncStrategy.startSync(this.localDB, this.remoteDB), this.applyDesignDocs().catch((t) => {
30090
+ this.syncStrategy.stopSync?.(), this.setDBandQ(), this._hydrationPromise = this.hydrateLocalMirror(), await this._hydrationPromise, this.syncStrategy.startSync(this.localDB, this.remoteDB, this._hydratedSeq), this.applyDesignDocs().catch((t) => {
30086
30091
  log4(`Error in applyDesignDocs background task: ${t}`), t && typeof t == "object" && log4(`Full error details in applyDesignDocs: ${JSON.stringify(t)}`);
30087
30092
  }), this.deduplicateReviews().catch((t) => {
30088
30093
  log4(`Error in deduplicateReviews background task: ${t}`), t && typeof t == "object" && log4(`Full error details in background task: ${JSON.stringify(t)}`);
30089
30094
  }), _BaseUser._initialized = !0;
30090
30095
  }
30091
30096
  async hydrateLocalMirror() {
30092
- if (this.localDB.name === this.remoteDB.name || !this.syncStrategy.hydrate) {
30097
+ if (this._hydratedSeq = void 0, this.localDB.name === this.remoteDB.name || !this.syncStrategy.hydrate) {
30093
30098
  this._hydration = { state: "not-required" };
30094
30099
  return;
30095
30100
  }
@@ -30100,8 +30105,8 @@ Currently logged-in as ${this._username}.`);
30100
30105
  this._hydration = { state: "hydrating" };
30101
30106
  let t = Date.now();
30102
30107
  try {
30103
- let { docsWritten: c } = await withTimeout(this.syncStrategy.hydrate(this.localDB, this.remoteDB), HYDRATION_TIMEOUT_MS, `Hydration of local mirror for ${this._username}`);
30104
- await this.writeHydrationMarker(), this._hydration = {
30108
+ let { docsWritten: c, lastSeq: u } = await withTimeout(this.syncStrategy.hydrate(this.localDB, this.remoteDB), HYDRATION_TIMEOUT_MS, `Hydration of local mirror for ${this._username}`);
30109
+ this._hydratedSeq = u, await this.writeHydrationMarker(), this._hydration = {
30105
30110
  state: "hydrated",
30106
30111
  docsWritten: c,
30107
30112
  durationMs: Date.now() - t
@@ -40472,6 +40477,7 @@ var import_vuedraggable_umd, B$1, N$2, R$1, q$2, M$2, F$2, z$1, H$1, J$2, y, W$2
40472
40477
  piniaPlugin: () => oe$3,
40473
40478
  requestPasswordReset: () => requestPasswordReset,
40474
40479
  resetPassword: () => resetPassword,
40480
+ resolveLoginIdentifier: () => resolveLoginIdentifier,
40475
40481
  sendVerificationEmail: () => sendVerificationEmail,
40476
40482
  splitByDelimiters: () => splitByDelimiters,
40477
40483
  splitParagraphToken: () => splitParagraphToken,
@@ -40820,10 +40826,46 @@ async function verifyEmail(t) {
40820
40826
  credentials: "include",
40821
40827
  body: JSON.stringify({ token: t })
40822
40828
  });
40823
- return c.ok ? await c.json() : {
40829
+ if (!c.ok) {
40830
+ let t;
40831
+ try {
40832
+ t = (await c.json())?.error;
40833
+ } catch {}
40834
+ return {
40835
+ ok: !1,
40836
+ error: t || `HTTP ${c.status}: ${c.statusText}`
40837
+ };
40838
+ }
40839
+ return await c.json();
40840
+ } catch (t) {
40841
+ return {
40824
40842
  ok: !1,
40825
- error: `HTTP ${c.status}: ${c.statusText}`
40843
+ error: t instanceof Error ? t.message : "Network error"
40826
40844
  };
40845
+ }
40846
+ }
40847
+ async function resolveLoginIdentifier(t, c) {
40848
+ try {
40849
+ let u = await fetch(`${getApiBase()}/auth/resolve-login`, {
40850
+ method: "POST",
40851
+ headers: { "Content-Type": "application/json" },
40852
+ credentials: "include",
40853
+ body: JSON.stringify({
40854
+ identifier: t,
40855
+ password: c
40856
+ })
40857
+ });
40858
+ if (!u.ok) {
40859
+ let t;
40860
+ try {
40861
+ t = (await u.json())?.error;
40862
+ } catch {}
40863
+ return {
40864
+ ok: !1,
40865
+ error: t || `HTTP ${u.status}: ${u.statusText}`
40866
+ };
40867
+ }
40868
+ return await u.json();
40827
40869
  } catch (t) {
40828
40870
  return {
40829
40871
  ok: !1,
@@ -44352,9 +44394,19 @@ var Ee$1, De$1, Oe$1, ke$1, Ae$1, je$1, Me$1, Ne$1, Pe$1, Fe$1, Ie$1, Le$1, Z$2,
44352
44394
  D.value = !1;
44353
44395
  }, O.value);
44354
44396
  }, login = async () => {
44355
- E.value = !0, log$2("Starting login attempt"), log$2(`Login attempt for username: ${C.value}`);
44397
+ E.value = !0, log$2("Starting login attempt"), log$2(`Login attempt for identifier: ${C.value}`);
44356
44398
  try {
44357
- log$2("Attempting to get User instance"), yr.value = await getCurrentUser(), log$2("Got User instance, attempting login"), await yr.value.login(C.value, w.value), log$2("Login successful"), log$2("Initializing user config"), S.init(), log$2("User config initialized"), log$2("Setting authentication state"), b.loginAndRegistration.loggedIn = !0, log$2(`Authentication state set, redirecting to: ${u.redirectTo}`), d("loginSuccess", u.redirectTo), m.push(u.redirectTo), log$2("Login and redirect complete");
44399
+ log$2("Attempting to get User instance"), yr.value = await getCurrentUser(), log$2("Got User instance, attempting login");
44400
+ let t = C.value;
44401
+ if (C.value.includes("@")) {
44402
+ let c = await resolveLoginIdentifier(C.value, w.value);
44403
+ if (!c.ok || !c.username) {
44404
+ log$2("Email identifier did not resolve (bad credentials)"), initBadLogin(), E.value = !1;
44405
+ return;
44406
+ }
44407
+ t = c.username;
44408
+ }
44409
+ await yr.value.login(t, w.value), log$2("Login successful"), log$2("Initializing user config"), S.init(), log$2("User config initialized"), log$2("Setting authentication state"), b.loginAndRegistration.loggedIn = !0, log$2(`Authentication state set, redirecting to: ${u.redirectTo}`), d("loginSuccess", u.redirectTo), m.push(u.redirectTo), log$2("Login and redirect complete");
44358
44410
  } catch (t) {
44359
44411
  log$2("Login attempt failed"), log$2(`Login error details: ${JSON.stringify(t)}`), console.log(`login error: ${JSON.stringify(t)}`), log$2("Initiating bad login feedback"), initBadLogin();
44360
44412
  }
@@ -44385,7 +44437,7 @@ var Ee$1, De$1, Oe$1, ke$1, Ae$1, je$1, Me$1, Ne$1, Pe$1, Fe$1, Ie$1, Le$1, Z$2,
44385
44437
  "onUpdate:modelValue": c[0] || (c[0] = (t) => C.value = t),
44386
44438
  autofocus: "",
44387
44439
  name: "username",
44388
- label: "Username",
44440
+ label: "Username or email",
44389
44441
  "prepend-icon": "mdi-account-circle"
44390
44442
  }, null, 8, ["modelValue"]),
44391
44443
  createVNode(d, {
@@ -44462,7 +44514,7 @@ var Ee$1, De$1, Oe$1, ke$1, Ae$1, je$1, Me$1, Ne$1, Pe$1, Fe$1, Ie$1, Le$1, Z$2,
44462
44514
  });
44463
44515
  };
44464
44516
  }
44465
- }), [["__scopeId", "data-v-563b0048"]]), hn = /* @__PURE__ */ defineComponent({
44517
+ }), [["__scopeId", "data-v-f374a5e9"]]), hn = /* @__PURE__ */ defineComponent({
44466
44518
  name: "UserRegistration",
44467
44519
  props: { onSignupSuccess: {
44468
44520
  type: Function,
@@ -44551,7 +44603,6 @@ Author: ${this.author}
44551
44603
  this.user.createAccount(this.username, this.password).then(async (t) => {
44552
44604
  if (t.status === Status.ok) {
44553
44605
  if (this.authStore.loginAndRegistration.loggedIn = !0, this.authStore.loginAndRegistration.init = !1, this.authStore.loginAndRegistration.init = !0, this.email) try {
44554
- await (await getCurrentUser()).setConfig({ email: this.email });
44555
44606
  let t = typeof window < "u" ? window.location.origin : void 0, c = await sendVerificationEmail(this.username, this.email, t);
44556
44607
  c.ok ? Z$2({
44557
44608
  text: "Account created! Please check your email to verify your account.",