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 6
6
* Copyright (C) 2025 Posit Software, PBC
7
7
*/
8
8
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.
9
11
export interface Cloneable < T > {
10
12
clone ( ) : T ;
11
13
}
Original file line number Diff line number Diff line change @@ -275,6 +275,7 @@ export async function projectContext(
275
275
} ) ;
276
276
const fileInformationCache = new FileInformationCacheMap ( ) ;
277
277
const result : ProjectContext = {
278
+ clone : ( ) => result ,
278
279
resolveBrand : async ( fileName ?: string ) =>
279
280
projectResolveBrand ( result , fileName ) ,
280
281
resolveFullMarkdownForFile : (
@@ -371,6 +372,7 @@ export async function projectContext(
371
372
} ) ;
372
373
const fileInformationCache = new FileInformationCacheMap ( ) ;
373
374
const result : ProjectContext = {
375
+ clone : ( ) => result ,
374
376
resolveBrand : async ( fileName ?: string ) =>
375
377
projectResolveBrand ( result , fileName ) ,
376
378
resolveFullMarkdownForFile : (
@@ -446,6 +448,7 @@ export async function projectContext(
446
448
} ) ;
447
449
const fileInformationCache = new FileInformationCacheMap ( ) ;
448
450
const context : ProjectContext = {
451
+ clone : ( ) => context ,
449
452
resolveBrand : async ( fileName ?: string ) =>
450
453
projectResolveBrand ( context , fileName ) ,
451
454
resolveFullMarkdownForFile : (
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ import {
22
22
import { ProjectEnvironment } from "./project-environment-types.ts" ;
23
23
import { ProjectCache } from "../core/cache/cache-types.ts" ;
24
24
import { TempContext } from "../core/temp-types.ts" ;
25
+ import { Cloneable } from "../core/safe-clone-deep.ts" ;
25
26
26
27
export {
27
28
type NavigationItem as NavItem ,
@@ -58,7 +59,7 @@ export type FileInformation = {
58
59
brand ?: LightDarkBrand ;
59
60
} ;
60
61
61
- export interface ProjectContext {
62
+ export interface ProjectContext extends Cloneable < ProjectContext > {
62
63
dir : string ;
63
64
engines : string [ ] ;
64
65
files : ProjectFiles ;
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export async function singleFileProjectContext(
41
41
const projectCacheBaseDir = temp . createDir ( ) ;
42
42
43
43
const result : ProjectContext = {
44
+ clone : ( ) => result ,
44
45
resolveBrand : ( fileName ?: string ) => projectResolveBrand ( result , fileName ) ,
45
46
dir : normalizePath ( dirname ( source ) ) ,
46
47
engines : [ ] ,
You can’t perform that action at this time.
0 commit comments