File tree Expand file tree Collapse file tree 4 files changed +8
-1
lines changed Expand file tree Collapse file tree 4 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 66 * Copyright (C) 2025 Posit Software, PBC
77 */
88
9+ // This is used to create new interfaces that extend the Cloneable interface
10+ // to make the object having a clone method for specific cloning behavior in safeCloneDeep.
911export interface Cloneable < T > {
1012 clone ( ) : T ;
1113}
Original file line number Diff line number Diff line change @@ -275,6 +275,7 @@ export async function projectContext(
275275 } ) ;
276276 const fileInformationCache = new FileInformationCacheMap ( ) ;
277277 const result : ProjectContext = {
278+ clone : ( ) => result ,
278279 resolveBrand : async ( fileName ?: string ) =>
279280 projectResolveBrand ( result , fileName ) ,
280281 resolveFullMarkdownForFile : (
@@ -371,6 +372,7 @@ export async function projectContext(
371372 } ) ;
372373 const fileInformationCache = new FileInformationCacheMap ( ) ;
373374 const result : ProjectContext = {
375+ clone : ( ) => result ,
374376 resolveBrand : async ( fileName ?: string ) =>
375377 projectResolveBrand ( result , fileName ) ,
376378 resolveFullMarkdownForFile : (
@@ -446,6 +448,7 @@ export async function projectContext(
446448 } ) ;
447449 const fileInformationCache = new FileInformationCacheMap ( ) ;
448450 const context : ProjectContext = {
451+ clone : ( ) => context ,
449452 resolveBrand : async ( fileName ?: string ) =>
450453 projectResolveBrand ( context , fileName ) ,
451454 resolveFullMarkdownForFile : (
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
2222import { ProjectEnvironment } from "./project-environment-types.ts" ;
2323import { ProjectCache } from "../core/cache/cache-types.ts" ;
2424import { TempContext } from "../core/temp-types.ts" ;
25+ import { Cloneable } from "../core/safe-clone-deep.ts" ;
2526
2627export {
2728 type NavigationItem as NavItem ,
@@ -58,7 +59,7 @@ export type FileInformation = {
5859 brand ?: LightDarkBrand ;
5960} ;
6061
61- export interface ProjectContext {
62+ export interface ProjectContext extends Cloneable < ProjectContext > {
6263 dir : string ;
6364 engines : string [ ] ;
6465 files : ProjectFiles ;
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export async function singleFileProjectContext(
4141 const projectCacheBaseDir = temp . createDir ( ) ;
4242
4343 const result : ProjectContext = {
44+ clone : ( ) => result ,
4445 resolveBrand : ( fileName ?: string ) => projectResolveBrand ( result , fileName ) ,
4546 dir : normalizePath ( dirname ( source ) ) ,
4647 engines : [ ] ,
You can’t perform that action at this time.
0 commit comments