/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * */ // @lexical/y/migrate: EXPERIMENTAL layout migrations of stored documents // (DECISIONS D102, y.md "Changing the layout and migrating"). // // A frozen step per layout (`@lexical/y/migrate/1to2`, ...) moves a root // from layout N to N + 1 in place. The runner here runs a chain of them on // an observer-free copy, each in one transaction under a client id hashed // from every input, recording the new layout (`lexical-y:`) and the // epoch (`lexical-y-epoch`); it checks every result before anything is // stored or applied. Only an authority migrates a shared document (a server // or relay that owns its storage, with every session evicted, or a reseed // tool). The binding never imports this entry or a step. import {MIN_LAYOUT} from './internal/constants'; import {type YMigrationEpoch} from './internal/Layouts'; import {type YPendingMaterial} from './internal/Pending'; import { getYLayoutInfo, loadStepsWith, migrateYState, type YLayoutInfo, type YLayoutMigration, type YMigrateOptions, type YMigrateStateOptions, YMigrationError, type YMigrationErrorCode, type YMigrationLoaders, type YMigrationReceipt, type YMigrationResult, type YMigrationRootReceipt, type YMigrationStepInput, type YMigrationStepReceipt, } from './internal/Runner'; import {STEP_LOADERS} from './internal/StepLoaders'; /** @experimental Options of loadYMigrationSteps (a later version may add some). */ export interface YLoadYMigrationStepsOptions { /** One loader per layout (`() => import(...)`); default: the published steps. */ readonly loaders?: YMigrationLoaders; } /** * @experimental Load the steps a root at layout `from` needs to reach `to` * (default MIN_LAYOUT), only those, in parallel: by default the published * steps (`@lexical/y/migrate/to`, each its own chunk), or * `loaders` (one per layout, `() => import(...)`). Rejects with a * 'missing-step' YMigrationError when a link has no loader, 'invalid-steps' * when a loader gives something else than the step from that layout. */ export function loadYMigrationSteps( from: number, to: number = MIN_LAYOUT, {loaders = STEP_LOADERS}: YLoadYMigrationStepsOptions = {}, ): Promise { return loadStepsWith(loaders, from, to); } export type { YLayoutInfo, YLayoutMigration, YMigrateOptions, YMigrateStateOptions, YMigrationEpoch, YMigrationErrorCode, YMigrationLoaders, YMigrationReceipt, YMigrationResult, YMigrationRootReceipt, YMigrationStepInput, YMigrationStepReceipt, YPendingMaterial, }; export {getYLayoutInfo, migrateYState, YMigrationError};