@vue-skuilder/db 0.2.25 → 0.2.27

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 (40) hide show
  1. package/dist/{SyncStrategy-CCU1H81I.d.cts → SyncStrategy-BXliog1m.d.cts} +14 -1
  2. package/dist/{SyncStrategy-CCU1H81I.d.ts → SyncStrategy-BXliog1m.d.ts} +14 -1
  3. package/dist/{contentSource-CrRnbjBx.d.cts → contentSource-D3c1fMAk.d.cts} +11 -0
  4. package/dist/{contentSource-kD35o65m.d.ts → contentSource-LPf044hY.d.ts} +11 -0
  5. package/dist/core/index.d.cts +3 -3
  6. package/dist/core/index.d.ts +3 -3
  7. package/dist/core/index.js +55 -13
  8. package/dist/core/index.js.map +1 -1
  9. package/dist/core/index.mjs +55 -13
  10. package/dist/core/index.mjs.map +1 -1
  11. package/dist/{dataLayerProvider-IecbidDO.d.cts → dataLayerProvider-CeLiFbHv.d.cts} +1 -1
  12. package/dist/{dataLayerProvider-CtzddVdy.d.ts → dataLayerProvider-DaAootVV.d.ts} +1 -1
  13. package/dist/impl/couch/index.d.cts +4 -3
  14. package/dist/impl/couch/index.d.ts +4 -3
  15. package/dist/impl/couch/index.js +71 -13
  16. package/dist/impl/couch/index.js.map +1 -1
  17. package/dist/impl/couch/index.mjs +71 -13
  18. package/dist/impl/couch/index.mjs.map +1 -1
  19. package/dist/impl/static/index.d.cts +3 -3
  20. package/dist/impl/static/index.d.ts +3 -3
  21. package/dist/impl/static/index.js +55 -13
  22. package/dist/impl/static/index.js.map +1 -1
  23. package/dist/impl/static/index.mjs +55 -13
  24. package/dist/impl/static/index.mjs.map +1 -1
  25. package/dist/index.d.cts +3 -3
  26. package/dist/index.d.ts +3 -3
  27. package/dist/index.js +72 -14
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +72 -14
  30. package/dist/index.mjs.map +1 -1
  31. package/package.json +3 -3
  32. package/src/core/interfaces/userDB.ts +10 -0
  33. package/src/core/navigators/generators/prescribed.ts +43 -14
  34. package/src/impl/common/BaseUserDB.ts +40 -0
  35. package/src/impl/common/SyncStrategy.ts +11 -1
  36. package/src/impl/common/index.ts +1 -0
  37. package/src/impl/common/types.ts +5 -0
  38. package/src/impl/couch/CouchDBSyncStrategy.ts +25 -1
  39. package/src/study/SessionController.ts +6 -2
  40. package/tests/core/navigators/prescribedIntroExposure.test.ts +29 -0
@@ -18,6 +18,10 @@ interface AuthenticationResult {
18
18
  ok: boolean;
19
19
  error?: string;
20
20
  }
21
+ interface AdoptSessionResult extends AuthenticationResult {
22
+ /** The adopted session's user, when ok. */
23
+ username?: string;
24
+ }
21
25
 
22
26
  /**
23
27
  * Strategy interface for handling user data synchronization
@@ -93,6 +97,15 @@ interface SyncStrategy {
93
97
  * Log out the current user (if supported)
94
98
  */
95
99
  logout?(): Promise<AuthenticationResult>;
100
+ /**
101
+ * Adopt a remote session established outside this client (e.g. a server that
102
+ * verified a third-party sign-in and set the session cookie), optionally
103
+ * migrating a guest account's local data into it (if supported).
104
+ * @param migrateFromGuest Guest username whose local data should be carried
105
+ * over. The caller must capture it BEFORE the session switched, since the
106
+ * remote now reports the adopted user.
107
+ */
108
+ adoptSession?(migrateFromGuest?: string): Promise<AdoptSessionResult>;
96
109
  /**
97
110
  * Get the current logged-in username
98
111
  * Returns the username if logged in, or a default guest username
@@ -100,4 +113,4 @@ interface SyncStrategy {
100
113
  getCurrentUsername(): Promise<string>;
101
114
  }
102
115
 
103
- export type { AccountCreationResult as A, SyncStrategy as S, AuthenticationResult as a };
116
+ export type { AccountCreationResult as A, SyncStrategy as S, AuthenticationResult as a, AdoptSessionResult as b };
@@ -18,6 +18,10 @@ interface AuthenticationResult {
18
18
  ok: boolean;
19
19
  error?: string;
20
20
  }
21
+ interface AdoptSessionResult extends AuthenticationResult {
22
+ /** The adopted session's user, when ok. */
23
+ username?: string;
24
+ }
21
25
 
22
26
  /**
23
27
  * Strategy interface for handling user data synchronization
@@ -93,6 +97,15 @@ interface SyncStrategy {
93
97
  * Log out the current user (if supported)
94
98
  */
95
99
  logout?(): Promise<AuthenticationResult>;
100
+ /**
101
+ * Adopt a remote session established outside this client (e.g. a server that
102
+ * verified a third-party sign-in and set the session cookie), optionally
103
+ * migrating a guest account's local data into it (if supported).
104
+ * @param migrateFromGuest Guest username whose local data should be carried
105
+ * over. The caller must capture it BEFORE the session switched, since the
106
+ * remote now reports the adopted user.
107
+ */
108
+ adoptSession?(migrateFromGuest?: string): Promise<AdoptSessionResult>;
96
109
  /**
97
110
  * Get the current logged-in username
98
111
  * Returns the username if logged in, or a default guest username
@@ -100,4 +113,4 @@ interface SyncStrategy {
100
113
  getCurrentUsername(): Promise<string>;
101
114
  }
102
115
 
103
- export type { AccountCreationResult as A, SyncStrategy as S, AuthenticationResult as a };
116
+ export type { AccountCreationResult as A, SyncStrategy as S, AuthenticationResult as a, AdoptSessionResult as b };
@@ -1213,6 +1213,17 @@ interface UserDBAuthenticator {
1213
1213
  logout(): Promise<{
1214
1214
  ok: boolean;
1215
1215
  }>;
1216
+ /**
1217
+ * Adopt a session established outside this client (e.g. third-party
1218
+ * sign-in completed server-side), optionally migrating guest data.
1219
+ */
1220
+ adoptSession(opts: {
1221
+ migrateGuestData: boolean;
1222
+ }): Promise<{
1223
+ ok: boolean;
1224
+ error?: string;
1225
+ username?: string;
1226
+ }>;
1216
1227
  }
1217
1228
  /**
1218
1229
  * Complete user database interface - combines all user operations
@@ -1213,6 +1213,17 @@ interface UserDBAuthenticator {
1213
1213
  logout(): Promise<{
1214
1214
  ok: boolean;
1215
1215
  }>;
1216
+ /**
1217
+ * Adopt a session established outside this client (e.g. third-party
1218
+ * sign-in completed server-side), optionally migrating guest data.
1219
+ */
1220
+ adoptSession(opts: {
1221
+ migrateGuestData: boolean;
1222
+ }): Promise<{
1223
+ ok: boolean;
1224
+ error?: string;
1225
+ username?: string;
1226
+ }>;
1216
1227
  }
1217
1228
  /**
1218
1229
  * Complete user database interface - combines all user operations
@@ -1,6 +1,6 @@
1
- import { as as LearnableWeight, O as UserOutcomeRecord, at as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface } from '../contentSource-CrRnbjBx.cjs';
2
- export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, aq as FilterImpact, ag as GeneratorContext, G as GeneratorResult, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, ar as PipelineForecaster, ao as PipelineRunReport, R as ReplanHints, j as ScheduledCard, t as SessionEloEvent, V as SessionStateSnapshot, u as SessionStateSnapshotProvider, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, h as StudyContentSource, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from '../contentSource-CrRnbjBx.cjs';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-IecbidDO.cjs';
1
+ import { as as LearnableWeight, O as UserOutcomeRecord, at as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface } from '../contentSource-D3c1fMAk.cjs';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, aq as FilterImpact, ag as GeneratorContext, G as GeneratorResult, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, ar as PipelineForecaster, ao as PipelineRunReport, R as ReplanHints, j as ScheduledCard, t as SessionEloEvent, V as SessionStateSnapshot, u as SessionStateSnapshotProvider, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, h as StudyContentSource, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from '../contentSource-D3c1fMAk.cjs';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-CeLiFbHv.cjs';
4
4
  import { D as DocType, c as QuestionRecord, i as DocTypePrefixes, C as CardHistory, b as CardRecord } from '../types-legacy-CrwyZIvI.cjs';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from '../types-legacy-CrwyZIvI.cjs';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
@@ -1,6 +1,6 @@
1
- import { as as LearnableWeight, O as UserOutcomeRecord, at as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface } from '../contentSource-kD35o65m.js';
2
- export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, aq as FilterImpact, ag as GeneratorContext, G as GeneratorResult, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, ar as PipelineForecaster, ao as PipelineRunReport, R as ReplanHints, j as ScheduledCard, t as SessionEloEvent, V as SessionStateSnapshot, u as SessionStateSnapshotProvider, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, h as StudyContentSource, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from '../contentSource-kD35o65m.js';
3
- export { D as DataLayerProvider } from '../dataLayerProvider-CtzddVdy.js';
1
+ import { as as LearnableWeight, O as UserOutcomeRecord, at as OrchestrationContext, W as WeightedCard, U as UserDBInterface, C as CourseDBInterface } from '../contentSource-LPf044hY.js';
2
+ export { M as ActivityRecord, A as AdminDBInterface, x as AssignedCard, g as AssignedContent, w as AssignedCourse, v as AssignedTag, af as CardGenerator, ah as CardGeneratorFactory, c as ClassroomDBInterface, I as ClassroomRegistration, H as ClassroomRegistrationDesignation, J as ClassroomRegistrationDoc, e as ContentNavigationStrategyData, f as ContentNavigator, q as ContentSourceID, d as CourseInfo, N as CourseRegistration, s as CourseRegistrationDoc, b as CoursesDBInterface, aq as FilterImpact, ag as GeneratorContext, G as GeneratorResult, ap as GeneratorSummary, $ as HYDRATION_MARKER_ID, a0 as HydrationMarker, a1 as NavigatorConstructor, ab as NavigatorRole, ac as NavigatorRoles, aa as Navigators, ar as PipelineForecaster, ao as PipelineRunReport, R as ReplanHints, j as ScheduledCard, t as SessionEloEvent, V as SessionStateSnapshot, u as SessionStateSnapshotProvider, K as SessionTrackingData, a8 as StrategyContribution, i as StudentClassroomDBInterface, h as StudyContentSource, P as StudySessionDoc, k as StudySessionFailedItem, l as StudySessionFailedNewItem, m as StudySessionFailedReviewItem, S as StudySessionItem, n as StudySessionNewItem, o as StudySessionReviewItem, Q as StudySessionRunSummary, T as TeacherClassroomDBInterface, L as UserConfig, E as UserCourseSetting, B as UserCourseSettings, z as UserDBAuthenticator, a as UserDBReader, y as UserDBWriter, Z as UserHydrationState, _ as UserHydrationStatus, F as UsrCrsDataInterface, au as computeDeviation, aw as computeEffectiveWeight, av as computeSpread, ax as createOrchestrationContext, an as drainCapturedRuns, ak as getActivePipeline, a9 as getCardOrigin, a3 as getRegisteredNavigator, a6 as getRegisteredNavigatorNames, a5 as getRegisteredNavigatorRole, am as getRunsForSession, r as getStudySource, a4 as hasRegisteredNavigator, a7 as initializeNavigatorRegistry, ae as isFilter, ad as isGenerator, p as isReview, X as makeStudySessionId, aj as mountPipelineDebugger, Y as newSessionId, ai as pipelineDebugAPI, a2 as registerNavigator, al as setDebugSessionId } from '../contentSource-LPf044hY.js';
3
+ export { D as DataLayerProvider } from '../dataLayerProvider-DaAootVV.js';
4
4
  import { D as DocType, c as QuestionRecord, i as DocTypePrefixes, C as CardHistory, b as CardRecord } from '../types-legacy-CrwyZIvI.js';
5
5
  export { d as CardData, e as CourseListData, g as DataShapeData, f as DisplayableData, F as Field, G as GuestUsername, Q as QualifiedCardID, h as QuestionData, S as SkuilderCourseData, a as Tag, T as TagStub, l as log } from '../types-legacy-CrwyZIvI.js';
6
6
  import { DataShape, ParsedCard } from '@vue-skuilder/common';
@@ -1889,7 +1889,8 @@ var init_generators = __esm({
1889
1889
  // src/core/navigators/generators/prescribed.ts
1890
1890
  var prescribed_exports = {};
1891
1891
  __export(prescribed_exports, {
1892
- default: () => PrescribedCardsGenerator
1892
+ default: () => PrescribedCardsGenerator,
1893
+ unmetIntroExposeTags: () => unmetIntroExposeTags
1893
1894
  });
1894
1895
  function dedupe(arr) {
1895
1896
  return [...new Set(arr)];
@@ -1929,6 +1930,19 @@ function formatAge(ms) {
1929
1930
  if (hours < 24) return `${hours}h`;
1930
1931
  return `${Math.round(hours / 24)}d`;
1931
1932
  }
1933
+ function unmetIntroExposeTags(tags, userTagElo, minCount) {
1934
+ if (minCount <= 0) return [];
1935
+ const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
1936
+ for (const tag of tags) {
1937
+ if (!tag.startsWith("gpc:intro:")) continue;
1938
+ const suffix = tag.slice("gpc:intro:".length);
1939
+ if (suffix) exposeTags.add(`gpc:expose:${suffix}`);
1940
+ }
1941
+ return [...exposeTags].filter((tag) => {
1942
+ const tagElo = userTagElo[tag];
1943
+ return !tagElo || tagElo.count < minCount;
1944
+ });
1945
+ }
1932
1946
  function pickTopByScore(cards, limit) {
1933
1947
  return [...cards].sort((a, b) => b.score - a.score || a.cardId.localeCompare(b.cardId)).slice(0, limit);
1934
1948
  }
@@ -2227,6 +2241,7 @@ var init_prescribed = __esm({
2227
2241
  freshnessWindowSessions: typeof raw.freshnessWindowSessions === "number" ? raw.freshnessWindowSessions : DEFAULT_FRESHNESS_WINDOW,
2228
2242
  maxDirectTargetsPerRun: typeof raw.maxDirectTargetsPerRun === "number" ? raw.maxDirectTargetsPerRun : DEFAULT_MAX_DIRECT_PER_RUN,
2229
2243
  maxSupportCardsPerRun: typeof raw.maxSupportCardsPerRun === "number" ? raw.maxSupportCardsPerRun : DEFAULT_MAX_SUPPORT_PER_RUN,
2244
+ introExposeMinCount: typeof raw.introExposeMinCount === "number" ? raw.introExposeMinCount : DEFAULT_MIN_COUNT,
2230
2245
  hierarchyWalk: {
2231
2246
  enabled: raw.hierarchyWalk?.enabled !== false,
2232
2247
  maxDepth: typeof raw.hierarchyWalk?.maxDepth === "number" ? raw.hierarchyWalk.maxDepth : DEFAULT_HIERARCHY_DEPTH
@@ -2302,18 +2317,11 @@ var init_prescribed = __esm({
2302
2317
  group.hierarchyWalk?.enabled !== false,
2303
2318
  group.hierarchyWalk?.maxDepth ?? DEFAULT_HIERARCHY_DEPTH
2304
2319
  );
2305
- const introTags = tags.filter((tag) => tag.startsWith("gpc:intro:"));
2306
- const exposeTags = new Set(tags.filter((tag) => tag.startsWith("gpc:expose:")));
2307
- for (const introTag of introTags) {
2308
- const suffix = introTag.slice("gpc:intro:".length);
2309
- if (suffix) {
2310
- exposeTags.add(`gpc:expose:${suffix}`);
2311
- }
2312
- }
2313
- const unmetExposeTags = [...exposeTags].filter((tag) => {
2314
- const tagElo = userTagElo[tag];
2315
- return !tagElo || tagElo.count < DEFAULT_MIN_COUNT;
2316
- });
2320
+ const unmetExposeTags = unmetIntroExposeTags(
2321
+ tags,
2322
+ userTagElo,
2323
+ group.introExposeMinCount ?? DEFAULT_MIN_COUNT
2324
+ );
2317
2325
  if (unmetExposeTags.length > 0) {
2318
2326
  unmetExposeTags.forEach((tag) => supportTags.add(tag));
2319
2327
  }
@@ -9215,6 +9223,40 @@ Currently logged-in as ${this._username}.`
9215
9223
  }
9216
9224
  return loginResult;
9217
9225
  }
9226
+ /**
9227
+ * Adopt a remote session that was established outside this client — e.g. a
9228
+ * backend verified a third-party sign-in (Google) and set the session cookie
9229
+ * on its response. Afterwards the user is logged in exactly as after
9230
+ * login(): username switched, guest pointer cleared, init() re-run.
9231
+ *
9232
+ * @param opts.migrateGuestData Carry the current guest account's local data
9233
+ * into the adopted account. Pass true for a freshly created account (as
9234
+ * createAccount() does), false for an existing one (as login() does).
9235
+ */
9236
+ async adoptSession(opts) {
9237
+ if (!this.syncStrategy.canAuthenticate() || !this.syncStrategy.adoptSession) {
9238
+ throw new Error("Session adoption not supported by current sync strategy");
9239
+ }
9240
+ const guestUsername = this._username.startsWith(GuestUsername) ? this._username : void 0;
9241
+ if (!guestUsername) {
9242
+ throw new Error(`Cannot adopt a session while logged in.
9243
+ Log out of account ${this.getUsername()} first.`);
9244
+ }
9245
+ const result = await this.syncStrategy.adoptSession(
9246
+ opts.migrateGuestData ? guestUsername : void 0
9247
+ );
9248
+ if (result.ok && result.username) {
9249
+ log3(`Adopted session for ${result.username}`);
9250
+ this._username = result.username;
9251
+ try {
9252
+ localStorage.removeItem("sk-guest-uuid");
9253
+ } catch (e) {
9254
+ logger.warn("localStorage not available (Node.js environment):", e);
9255
+ }
9256
+ await this.init();
9257
+ }
9258
+ return result;
9259
+ }
9218
9260
  async resetUserData() {
9219
9261
  if (this.syncStrategy.canAuthenticate()) {
9220
9262
  return {