UNPKG

@neodx/vfs

Version:

Simple virtual file system - working dir context, lazy changes, different modes, integrations and moreover

1 lines 32.7 kB
{"version":3,"file":"index.cjs","sources":["../../src/backend/create-node-fs-backend.ts","../../src/core/context.ts","../../src/backend/shared.ts","../../src/core/scopes.ts","../../src/core/create-base-vfs.ts","../../src/create-vfs.ts","../../src/backend/create-readonly-backend.ts"],"sourcesContent":["import { readdir } from 'fs/promises';\nimport { ensureFile, exists, isDirectory, isFile, readFile, rm, writeFile } from '@neodx/fs';\nimport type { VfsBackend } from './shared';\n\nexport function createNodeFsBackend() {\n return {\n async read(path) {\n try {\n return await readFile(path);\n } catch {\n return null;\n }\n },\n async write(path, content) {\n await ensureFile(path);\n return await writeFile(path, content);\n },\n async delete(path) {\n return await rm(path, {\n force: true,\n recursive: true\n });\n },\n\n async exists(path) {\n return await exists(path);\n },\n async readDir(path) {\n try {\n const dirents = await readdir(path, {\n withFileTypes: true\n });\n\n return dirents;\n } catch {\n return [];\n }\n },\n\n async isDir(path) {\n return await isDirectory(path);\n },\n async isFile(path) {\n return await isFile(path);\n },\n __: {\n kind: 'node-fs'\n }\n } satisfies VfsBackend;\n}\n","import type { Logger } from '@neodx/log';\nimport { createLogger } from '@neodx/log/node';\nimport { isNull, mapValues, uniqBy } from '@neodx/std';\nimport { normalize, relative, resolve } from 'pathe';\nimport type { VfsBackend } from '../backend';\nimport type { VfsPlugin } from '../create-vfs-plugin';\nimport type { BaseVfs, VfsContentLike, VfsFileMeta, VfsLogger, VfsLogMethod } from './types';\n\nexport interface CreateVfsContextParams {\n log?: VfsLogger;\n logLevel?: VfsLogMethod;\n path: string;\n backend: VfsBackend;\n parent?: VfsContext;\n}\n\nexport const createVfsContext = ({\n parent,\n logLevel,\n log = logLevel ? defaultLogger.fork({ level: logLevel }) : defaultLogger,\n ...params\n}: CreateVfsContextParams): VfsContext => {\n const store = new Map();\n const ctx: VfsContext = {\n log,\n ...params,\n\n catch(message: string, originalError: unknown) {\n // TODO Implement generic error handling\n const error = new Error(`${message} (${originalError})`);\n\n (error as any).path = ctx.path;\n error.name = 'VfsError';\n error.cause = originalError;\n ctx.log.error(error);\n return error;\n },\n\n get(path: string) {\n const resolved = ctx.resolve(path);\n\n return ctx.getAllChanges().find(meta => meta.path === resolved) ?? null;\n },\n getAllChanges() {\n return getAndMergeChanges(ctx.__.getAll());\n },\n getAllDirectChanges() {\n return getAndMergeChanges(ctx.__.getScoped());\n },\n getRelativeChanges(path: string) {\n const resolved = trailingSlash(ctx.resolve(path));\n\n return uniqBy(\n ctx.__.getAll()\n .flatMap(ctx => Array.from(ctx.__.getStore().values()))\n .filter(meta => meta.path.startsWith(resolved)),\n meta => meta.path\n );\n },\n writePathContent(path: string, content: VfsContentLike) {\n const resolved = ctx.resolve(path);\n const currentMeta = ctx.get(resolved);\n\n ctx.__.register(resolved, {\n deleted: false,\n content,\n updatedAfterDelete: currentMeta?.deleted\n });\n },\n deletePath(path: string) {\n ctx.__.register(ctx.resolve(path), { content: null, deleted: true });\n },\n unregister(path: string) {\n ctx.__.unregister(ctx.resolve(path));\n },\n resolve(...to: string[]) {\n return resolve(ctx.path, ...to);\n },\n relative(path: string): string {\n const normalized = normalize(path);\n\n // TODO Remove this hack after https://github.com/unjs/pathe/issues/126\n return ctx.path === '/' && normalized.startsWith('/')\n ? normalized.slice(1)\n : relative(ctx.path, resolve(ctx.path, normalized));\n },\n\n backend: mapValues(params.backend, (fn, key) =>\n key === '__'\n ? (fn as any)\n : async (path: string, ...args: any[]) => await (fn as any)(ctx.resolve(path), ...args)\n ),\n __: {\n kind,\n parent,\n plugins: [],\n children: [],\n\n getStore: () => store,\n getAll: () => [...ctx.__.getAncestors(), ctx, ...ctx.__.getDescendants()],\n getScoped: () => [ctx, ...ctx.__.getDescendants()],\n getAncestors: () => getAncestors(ctx),\n getDescendants: () => getDescendants(ctx),\n\n register: (path, overrides) => {\n const currentMeta = ctx.get(path);\n const meta: VfsChangeMeta = {\n ...currentMeta,\n ...overrides,\n path,\n content: isNull(overrides.content) ? overrides.content : Buffer.from(overrides.content),\n relativePath: ctx.relative(path)\n };\n\n ctx.__.getAll().forEach(ctx => ctx.__.getStore().set(path, meta));\n },\n unregister: (path: string) => {\n ctx.__.getAll().forEach(ctx => ctx.__.getStore().delete(path));\n }\n }\n };\n\n if (parent) {\n parent.__.children.push(ctx);\n }\n return ctx;\n};\n\n/**\n * End users should not use context, it's for internal use only.\n * Contains all changes, API for working with them, FS backend, and other useful stuff.\n */\nexport interface VfsContext {\n // path\n\n path: string;\n resolve(...to: string[]): string;\n relative(path: string): string;\n\n // operations\n\n get(path: string): VfsChangeMeta | null;\n\n /**\n * We will sync ALL changes from the current context AND all descendants.\n * Changes from ancestors will be ignored.\n */\n getAllDirectChanges(): VfsChangeMeta[];\n /**\n * We will sync ALL changes from the current context AND all descendants AND all ancestors.\n */\n getAllChanges(): VfsChangeMeta[];\n getRelativeChanges(path: string): VfsChangeMeta[];\n /** Remove file from context. */\n unregister(path: string): void;\n /** Set associated file temporal content. */\n writePathContent(path: string, content: VfsContentLike): void;\n /** Mark path as deleted. */\n deletePath(path: string, deleted: boolean): void;\n /** Handles any vfs errors. */\n catch(message: string, error: unknown): Error;\n\n // meta\n\n readonly log: Logger<VfsLogMethod>;\n readonly backend: VfsBackend;\n\n /** @internal */\n __: {\n vfs?: BaseVfs;\n kind: typeof kind;\n parent?: VfsContext;\n plugins: VfsPlugin<any>[];\n children: VfsContext[];\n\n getAll: () => VfsContext[];\n getStore: () => Map<string, VfsChangeMeta>;\n getScoped: () => VfsContext[];\n getAncestors: () => VfsContext[];\n getDescendants: () => VfsContext[];\n\n register: (path: string, meta: RegisteredMeta) => void;\n unregister: (path: string) => void;\n };\n}\n\ninterface RegisteredMeta extends Omit<VfsChangeMeta, 'path' | 'relativePath' | 'content'> {\n content: VfsContentLike | null;\n}\n\nexport interface VfsChangeMeta extends VfsFileMeta {\n content: Buffer | null;\n deleted?: boolean;\n /**\n * Indicates that the file or directory was updated after deletion.\n * It could be used to ensure the correct order of operations.\n */\n updatedAfterDelete?: boolean;\n}\n\nexport const isVfsContext = (ctx: any): ctx is VfsContext => ctx?.__?.kind === kind;\n\nconst kind = Symbol('VfsContext');\nconst getAncestors = (ctx: VfsContext): VfsContext[] =>\n ctx.__.parent ? [ctx.__.parent, ...getAncestors(ctx.__.parent)] : [];\nconst getDescendants = (ctx: VfsContext): VfsContext[] =>\n ctx.__.children.flatMap(child => [child, ...getDescendants(child)]);\nconst getAndMergeChanges = (contexts: VfsContext[]): VfsChangeMeta[] =>\n uniqBy(\n contexts.flatMap(ctx => Array.from(ctx.__.getStore().values())),\n meta => meta.path\n );\nconst trailingSlash = (path: string) => (path.endsWith('/') ? path : `${path}/`);\nconst defaultLogger = createLogger({ name: 'vfs', level: 'info' });\n","import type { Asyncable, VfsContentLike } from '../core/types';\n\n/**\n * Implementations for critical base VFS operations.\n * All methods accept absolute paths.\n */\nexport interface VfsBackend {\n /** Read file content or return `null` if file does not exist. */\n read: (path: string) => Asyncable<Buffer | null>;\n /** Write file content. */\n write: (path: string, content: VfsContentLike) => Asyncable<void>;\n /** Check if an entry exists. */\n exists: (path: string) => Asyncable<boolean>;\n /** Delete an entry (recursively if directory). */\n delete: (path: string) => Asyncable<void>;\n /** Read directory entries (non-recursive). */\n readDir: (path: string) => Asyncable<VfsDirent[]>;\n /** Check if an entry is a directory. */\n isDir: (path: string) => Asyncable<boolean>;\n /** Check if an entry is a file. */\n isFile: (path: string) => Asyncable<boolean>;\n\n __?: unknown;\n}\n\n/**\n * A `node:fs.Dirent` compatible interface.\n */\nexport interface VfsDirent {\n isFile(): boolean;\n isDirectory(): boolean;\n isSymbolicLink(): boolean;\n name: string;\n}\n\nexport const getVfsBackendKind = (backend: VfsBackend) =>\n (backend.__ as { kind?: string } | undefined)?.kind ?? 'unknown';\n","import { asyncReduce, fromKeys } from '@neodx/std';\nimport type { VfsPlugin } from '../create-vfs-plugin';\nimport type { VfsContext } from './context';\nimport { createVfsContext } from './context';\nimport { createBaseVfs } from './create-base-vfs';\nimport type { Asyncable, BaseVfs, Pipe, VfsFileAction } from './types';\n\n// Public API\n\nexport type PublicVfs<Vfs extends BaseVfs> = Vfs & PublicVfsApi<Vfs>;\nexport type NonPublicVfs<Vfs extends BaseVfs> = Omit<Vfs, keyof PublicVfsApi<Vfs>>;\nexport interface PublicVfsApi<Vfs extends BaseVfs> {\n /**\n * Creates a new vfs instance under the specified path.\n * All plugins will be inherited.\n * All changes are two-way synced.\n */\n child: (path: string) => PublicVfs<Vfs>;\n /**\n * Immutable extension of the current vfs instance with the specified plugins.\n * You can use it in any order and any number of times.\n * @example\n * const vfs = createHeadlessVfs('/root/path');\n * const enhanced = vfs.pipe(glob(), json());\n * const superEnhanced = vfs.pipe(json()).pipe(glob()).pipe(prettier(), eslint());\n */\n pipe: Pipe<Vfs>;\n}\n\n// Private API\n\nexport type PrivateVfs<Vfs extends BaseVfs> = NonPublicVfs<Vfs> & {\n __: PrivateVfsApi<NonPublicVfs<Vfs>>;\n};\nexport interface PrivateVfsApi<Vfs extends BaseVfs> extends PrivateVfsHookApi<Vfs> {\n context: VfsContext;\n}\nexport interface PrivateVfsHooks<Vfs extends BaseVfs> {\n beforeApplyFile: (action: VfsFileAction, vfs: Vfs) => Asyncable<void>;\n beforeApply: (actions: VfsFileAction[], vfs: Vfs) => Asyncable<void>;\n /**\n * Hook will be called after marking file and all nested files as deleted\n */\n afterDelete: (path: string, vfs: Vfs) => Asyncable<void>;\n}\nexport type PrivateVfsHookName = keyof PrivateVfsHooks<BaseVfs>;\nexport type PrivateVfsHookApi<Vfs extends BaseVfs> = {\n [K in keyof PrivateVfsHooks<Vfs>]: (handler: PrivateVfsHooks<Vfs>[K]) => void;\n};\nexport type PrivateVfsHookRegistry<Vfs extends BaseVfs> = ReturnType<\n typeof createHookRegistry<Vfs>\n>;\n\nexport const createHookRegistry = <Vfs extends BaseVfs>() => {\n const hooks = new Map<PrivateVfsHookName, PrivateVfsHooks<Vfs>[PrivateVfsHookName][]>();\n\n return {\n scope<K extends PrivateVfsHookName>(name: K) {\n const hook = hooks.get(name) ?? [];\n\n hooks.set(name, hook);\n return (handler: PrivateVfsHooks<Vfs>[K]) => hook.push(handler);\n },\n get<K extends PrivateVfsHookName>(name: K) {\n return (hooks.get(name) as PrivateVfsHooks<Vfs>[K][] | null) ?? [];\n },\n async run<K extends PrivateVfsHookName>(\n name: K,\n ...args: Parameters<PrivateVfsHooks<Vfs>[K]>\n ): Promise<void> {\n return asyncReduce(\n this.get(name),\n async (_, handler) => await (handler as any)(...args),\n undefined\n );\n }\n };\n};\n\nexport const toPublicScope = <Vfs extends BaseVfs>(\n vfs: Vfs,\n ctx: VfsContext,\n hooks: PrivateVfsHookRegistry<Vfs>\n): PublicVfs<Vfs> => {\n const privateApi: PrivateVfsApi<Vfs> = {\n context: ctx,\n ...fromKeys(['beforeApply', 'beforeApplyFile', 'afterDelete'], hooks.scope)\n };\n\n return {\n ...vfs,\n __: privateApi,\n child(path: string) {\n const { log, backend } = ctx;\n const childCtx = createVfsContext({\n backend,\n parent: ctx,\n path: ctx.resolve(path),\n log\n });\n\n return pipe(\n createBaseVfs(childCtx),\n childCtx,\n createHookRegistry(),\n ...ctx.__.plugins\n ) as any;\n },\n pipe(...plugins: VfsPlugin<any>[]) {\n return pipe(vfs, ctx, hooks, ...plugins) as any;\n }\n };\n};\n\nconst pipe = <Vfs extends BaseVfs>(\n vfs: Vfs,\n ctx: VfsContext,\n hooks: PrivateVfsHookRegistry<Vfs>,\n ...plugins: VfsPlugin<any>[]\n) => {\n const next = plugins.reduce(\n (next, plugin) =>\n plugin(next, {\n context: ctx,\n ...fromKeys(['beforeApply', 'beforeApplyFile', 'afterDelete'], hooks.scope)\n }),\n vfs\n );\n\n ctx.__.plugins.push(...plugins);\n ctx.__.vfs = next;\n return toPublicScope(next, ctx, hooks);\n};\n","import { colors } from '@neodx/colors';\nimport { concurrently, quickPluralize } from '@neodx/std';\nimport { dirname } from 'pathe';\nimport { getVfsBackendKind } from '../backend/shared';\nimport type { VfsContext } from './context';\nimport {\n deleteVfsPath,\n existsVfsPath,\n getVfsActions,\n isVfsDir,\n isVfsFile,\n readVfsDir,\n readVfsFile,\n renameVfs,\n tryReadVfsFile,\n writeVfsFile\n} from './operations';\nimport { createHookRegistry, toPublicScope } from './scopes';\nimport type { BaseVfs, VfsFileAction } from './types';\n\nexport function createBaseVfs(ctx: VfsContext) {\n const hooks = createHookRegistry();\n const backendKind = getVfsBackendKind(ctx.backend);\n\n const applyFile = async (action: VfsFileAction) => {\n ctx.log.info('%s %s', labels[action.type], action.relativePath);\n\n await hooks.run('beforeApplyFile', action, getCurrentVfs());\n // TODO Deletion is required only for write after directory deletion, probably we can optimize it\n if (action.type === 'delete' || action.updatedAfterDelete) {\n await ctx.backend.delete(action.path);\n }\n if (action.type !== 'delete') {\n await ctx.backend.write(action.path, action.content);\n }\n if (action.type === 'delete') {\n await hooks.run('afterDelete', action.path, getCurrentVfs());\n }\n ctx.unregister(action.path);\n };\n\n const baseVfs: BaseVfs = {\n // @ts-expect-error internal\n [contextSymbol]: ctx,\n\n get log() {\n return ctx.log;\n },\n get path() {\n return ctx.path;\n },\n get dirname() {\n return dirname(ctx.path);\n },\n get virtual() {\n return backendKind === 'in-memory';\n },\n get readonly() {\n return backendKind === 'readonly';\n },\n\n async apply() {\n try {\n const changes = await getVfsActions(ctx);\n\n ctx.log.info(\n 'Applying %d %s...',\n changes.length,\n quickPluralize(changes.length, 'change', 'changes')\n );\n await hooks.run('beforeApply', changes, getCurrentVfs());\n await concurrently(await getVfsActions(ctx), applyFile);\n } catch (originalError) {\n throw ctx.catch('Failed to apply changes', originalError);\n }\n },\n\n resolve: ctx.resolve,\n relative: ctx.relative,\n\n isDir: path => isVfsDir(ctx, path),\n isFile: path => isVfsFile(ctx, path),\n exists: path => existsVfsPath(ctx, path),\n\n readDir: (async (pathOrParams, params) => {\n const [path, { withFileTypes } = {} as any] =\n typeof pathOrParams === 'string' ? [pathOrParams, params] : [undefined, pathOrParams];\n const entries = await readVfsDir(ctx, path);\n\n return withFileTypes ? entries : entries.map(dirent => dirent.name);\n }) as BaseVfs['readDir'],\n\n read: ((path, encoding) => readVfsFile(ctx, path, encoding)) as BaseVfs['read'],\n write: (path, content) => writeVfsFile(ctx, path, content),\n rename: (from, ...to) => renameVfs(ctx, from, ...to),\n delete: path => deleteVfsPath(ctx, path),\n tryRead: ((path, encoding) => tryReadVfsFile(ctx, path, encoding)) as BaseVfs['tryRead']\n };\n const getCurrentVfs = () => ctx.__.vfs ?? baseVfs;\n\n return toPublicScope(baseVfs, ctx, hooks);\n}\n\nexport const getVfsContext = (vfs: BaseVfs) => (vfs as any)[contextSymbol] as VfsContext;\n\nconst labels = {\n delete: colors.red('delete'),\n create: colors.green('create'),\n update: colors.yellow('update')\n};\nconst contextSymbol = Symbol('context');\n","import { createAutoLogger } from '@neodx/log/node';\nimport { isTypeOfBoolean } from '@neodx/std';\nimport type { VfsBackend, VirtualInitializer } from './backend';\nimport { createInMemoryBackend, createNodeFsBackend } from './backend';\nimport { createReadonlyBackend } from './backend/create-readonly-backend';\nimport { createVfsContext } from './core/context';\nimport { createBaseVfs } from './core/create-base-vfs';\nimport type { VfsLogger, VfsLogMethod } from './core/types';\nimport { eslint, type EsLintPluginParams } from './plugins/eslint';\nimport { glob } from './plugins/glob.ts';\nimport { json } from './plugins/json.ts';\nimport { packageJson } from './plugins/package-json.ts';\nimport type { PrettierPluginParams } from './plugins/prettier.ts';\nimport { prettier } from './plugins/prettier.ts';\nimport { scan } from './plugins/scan.ts';\n\nexport interface CreateVfsParams extends CreateHeadlessVfsParams {\n /**\n * Params for the `prettier` plugin.\n * Pass `false` or `{ auto: false }` to disable auto formatting.\n * @default true\n */\n prettier?: boolean | PrettierPluginParams;\n /**\n * Params for the `eslint` plugin.\n * Pass `false` or `{ auto: false }` to disable auto fixing.\n * @default true\n */\n eslint?: boolean | EsLintPluginParams;\n}\n\nexport interface CreateHeadlessVfsParams extends CreateDefaultVfsBackendParams {\n /** @see @neodx/log */\n log?: VfsLogger | VfsLogMethod | 'silent';\n /** Pass your own vfs backend. */\n backend?: VfsBackend;\n}\n\nexport interface CreateDefaultVfsBackendParams {\n /** If not specified, will use `node:fs` backend. */\n virtual?: boolean | VirtualInitializer;\n /** If true, all operations will be read-only (if you didn't pass your own backend). */\n readonly?: boolean;\n}\n\nexport type Vfs = ReturnType<typeof createVfs>;\n\nexport function createVfs(\n path: string,\n { eslint: eslintParams = true, prettier: prettierParams = true, ...params }: CreateVfsParams = {}\n) {\n return createHeadlessVfs(path, params).pipe(\n json(),\n scan(),\n glob(),\n eslint(isTypeOfBoolean(eslintParams) ? { auto: eslintParams } : eslintParams),\n prettier(isTypeOfBoolean(prettierParams) ? { auto: prettierParams } : prettierParams),\n packageJson()\n );\n}\n\nexport function createHeadlessVfs(\n path: string,\n {\n log = 'error',\n virtual,\n readonly,\n backend = createDefaultVfsBackend(path, { virtual, readonly })\n }: CreateHeadlessVfsParams = {}\n) {\n const context = createVfsContext({\n path,\n log: createAutoLogger(log, { name: 'vfs' }),\n backend\n });\n\n return createBaseVfs(context);\n}\n\nexport function createDefaultVfsBackend(\n path: string,\n { virtual, readonly }: CreateDefaultVfsBackendParams\n) {\n const originalBackend = virtual\n ? createInMemoryBackend(path, virtual === true ? {} : virtual)\n : createNodeFsBackend();\n\n return readonly ? createReadonlyBackend(originalBackend) : originalBackend;\n}\n","import { uniqBy } from '@neodx/std';\nimport { resolve } from 'pathe';\nimport { createInMemoryBackend, pathStartsWith } from './create-in-memory-backend';\nimport type { VfsBackend } from './shared';\n\nexport function createReadonlyBackend(backend: VfsBackend) {\n const inMemory = createInMemoryBackend();\n const deleted = (path: string) => {\n const paths = Array.from(inMemory.__.getDeleted());\n\n return (\n paths.includes(path) ||\n paths.some(expectedParentPath => pathStartsWith(path, expectedParentPath))\n );\n };\n\n return {\n read: path => (deleted(path) ? null : inMemory.read(path) ?? backend.read(path)),\n exists: path => !deleted(path) && (inMemory.exists(path) || backend.exists(path)),\n isFile: path => !deleted(path) && (inMemory.isFile(path) || backend.isFile(path)),\n isDir: path => !deleted(path) && (inMemory.isDir(path) || backend.isDir(path)),\n write: inMemory.write,\n delete: inMemory.delete,\n async readDir(path) {\n if (deleted(path)) return [];\n const actual = await backend.readDir(path);\n\n return uniqBy(\n actual.filter(entry => !deleted(resolve(path, entry.name))).concat(inMemory.readDir(path)),\n entry => entry.name\n );\n },\n __: {\n kind: 'readonly'\n }\n } satisfies VfsBackend;\n}\n"],"names":["createNodeFsBackend","read","path","readFile","write","content","ensureFile","writeFile","delete","rm","force","recursive","exists","readDir","readdir","withFileTypes","isDir","isDirectory","isFile","__","kind","createVfsContext","parent","logLevel","log","defaultLogger","fork","level","params","store","Map","ctx","catch","message","originalError","error","Error","name","cause","get","resolved","resolve","getAllChanges","find","meta","getAndMergeChanges","getAll","getAllDirectChanges","getScoped","getRelativeChanges","trailingSlash","uniqBy","flatMap","Array","from","getStore","values","filter","startsWith","writePathContent","currentMeta","register","deleted","updatedAfterDelete","deletePath","unregister","to","relative","normalized","normalize","slice","backend","mapValues","fn","key","args","plugins","children","getAncestors","getDescendants","overrides","isNull","Buffer","relativePath","forEach","set","push","Symbol","child","contexts","endsWith","createLogger","getVfsBackendKind","createHookRegistry","hooks","scope","hook","handler","run","asyncReduce","_","undefined","toPublicScope","vfs","privateApi","context","fromKeys","childCtx","pipe","createBaseVfs","next","reduce","plugin","backendKind","applyFile","action","info","labels","type","getCurrentVfs","baseVfs","contextSymbol","dirname","virtual","readonly","apply","changes","getVfsActions","length","quickPluralize","concurrently","isVfsDir","isVfsFile","existsVfsPath","pathOrParams","entries","readVfsDir","map","dirent","encoding","readVfsFile","writeVfsFile","rename","renameVfs","deleteVfsPath","tryRead","tryReadVfsFile","colors","red","create","green","update","yellow","createHeadlessVfs","createDefaultVfsBackend","createAutoLogger","originalBackend","createInMemoryBackend","createReadonlyBackend","inMemory","paths","getDeleted","includes","some","expectedParentPath","pathStartsWith","actual","entry","concat","eslint","eslintParams","prettier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