/*! * Copyright (c) Microsoft Corporation and contributors. All rights reserved. * Licensed under the MIT License. */ import { ModelContainerRuntimeFactory, getDataStoreEntryPoint, } from "@fluid-example/example-utils"; import type { IContainer } from "@fluidframework/container-definitions/legacy"; import type { IContainerRuntime } from "@fluidframework/container-runtime-definitions/legacy"; import type { IInventoryList, IInventoryListAppModel } from "../modelInterfaces.js"; import { InventoryListAppModel } from "./appModel.js"; import { LegacyTreeInventoryListFactory } from "./legacyTreeInventoryList.js"; import { NewTreeInventoryListFactory } from "./newTreeInventoryList.js"; export const legacyTreeInventoryListId = "legacy-tree-inventory-list"; export const newTreeInventoryListId = "new-tree-inventory-list"; /** * @internal */ export class InventoryListContainerRuntimeFactory extends ModelContainerRuntimeFactory { public constructor() { super( new Map([ LegacyTreeInventoryListFactory.registryEntry, NewTreeInventoryListFactory.registryEntry, ]), // registryEntries { enableRuntimeIdCompressor: "on" }, ); } protected async containerInitializingFirstTime(runtime: IContainerRuntime): Promise { const legacyTreeInventoryList = await runtime.createDataStore( LegacyTreeInventoryListFactory.type, ); await legacyTreeInventoryList.trySetAlias(legacyTreeInventoryListId); const newTreeInventoryList = await runtime.createDataStore( NewTreeInventoryListFactory.type, ); await newTreeInventoryList.trySetAlias(newTreeInventoryListId); } protected async createModel( runtime: IContainerRuntime, container: IContainer, ): Promise { const legacyTreeInventoryList = await getDataStoreEntryPoint( runtime, legacyTreeInventoryListId, ); const newTreeInventoryList = await getDataStoreEntryPoint( runtime, newTreeInventoryListId, ); return new InventoryListAppModel(legacyTreeInventoryList, newTreeInventoryList); } }