@@ -29,12 +29,9 @@ export const useStudio = () => {
2929
3030 // App config (required)
3131 const initialAppConfig = useDefaultAppConfig ( )
32- let initialTokensConfig : object
33-
3432 const storage = useState < Storage | null > ( 'studio-client-db' , ( ) => null )
3533
3634 if ( ! storage . value ) {
37- // @ts -expect-error custom hook
3835 nuxtApp . hook ( 'content:storage' , ( _storage : Storage ) => {
3936 storage . value = _storage
4037 } )
@@ -81,33 +78,6 @@ export const useStudio = () => {
8178 }
8279 }
8380
84- const syncPreviewTokensConfig = ( tokensConfig ?: ParsedContent ) => {
85- // Tokens config (optional; depends on the presence of pinceauTheme provide)
86- // TODO: Improve typings
87- // TODO: Use `inject()` but wrong context seem to be resolved; while $pinceauTheme global property is present in `app` context
88- const themeSheet = nuxtApp ?. vueApp ?. _context ?. config ?. globalProperties ?. $pinceauTheme as Record < string , unknown >
89-
90- // Pinceau might be not present, or not booted yet
91- if ( ! themeSheet || ! themeSheet ?. updateTheme ) return
92-
93- // Set initial tokens config on first call
94- if ( ! initialTokensConfig ) {
95- initialTokensConfig = JSON . parse ( JSON . stringify ( ( themeSheet ?. theme as Record < string , unknown > ) . value || { } ) )
96- }
97-
98- // Call updateTheme with new config
99- callWithNuxt (
100- nuxtApp ,
101- // eslint-disable-next-line @typescript-eslint/no-explicit-any
102- themeSheet . updateTheme as any ,
103- [
104- // Using `defu` to merge with initial tokens
105- // This is important to revert to default values for missing properties
106- defu ( tokensConfig as ParsedContent , initialTokensConfig ) ,
107- ] ,
108- )
109- }
110-
11181 const syncPreview = async ( data : PreviewResponse ) => {
11282 // Preserve db files in case storage is not ready yet (see check below)
11383 dbFiles = data . files = data . files || dbFiles || [ ]
@@ -117,21 +87,18 @@ export const useStudio = () => {
11787 return false
11888 }
11989
120- // Empty dbFiles array once storage is ready
90+ // Empty dbFiles array once storage is ready to clear memory
12191 dbFiles = [ ]
12292
12393 const mergedFiles = mergeDraft ( data . files , data . additions , data . deletions )
12494
12595 // Handle content files
126- const contentFiles = mergedFiles . filter ( item => ! ( [ StudioConfigFiles . appConfig , StudioConfigFiles . nuxtConfig , StudioConfigFiles . tokensConfig ] . includes ( item . path ) ) )
96+ const contentFiles = mergedFiles . filter ( item => ! ( [ StudioConfigFiles . appConfig , StudioConfigFiles . nuxtConfig ] . includes ( item . path ) ) )
12797 await syncPreviewFiles ( storage . value , contentFiles )
12898
12999 const appConfig = mergedFiles . find ( item => item . path === StudioConfigFiles . appConfig )
130100 syncPreviewAppConfig ( appConfig ?. parsed as ParsedContent )
131101
132- const tokensConfig = mergedFiles . find ( item => item . path === StudioConfigFiles . tokensConfig )
133- syncPreviewTokensConfig ( tokensConfig ?. parsed as ParsedContent )
134-
135102 requestRerender ( )
136103
137104 return true
@@ -211,7 +178,6 @@ export const useStudio = () => {
211178
212179 const requestRerender = async ( ) => {
213180 if ( contentConfig ?. documentDriven ) {
214- // @ts -expect-error Update all cached pages
215181 const { pages } = callWithNuxt ( nuxtApp , useContentState )
216182
217183 const contents = await Promise . all ( Object . keys ( pages . value ) . map ( async ( key ) => {
@@ -235,7 +201,6 @@ export const useStudio = () => {
235201
236202 syncPreviewFiles,
237203 syncPreviewAppConfig,
238- syncPreviewTokensConfig,
239204 requestPreviewSynchronization,
240205
241206 findContentWithId,
@@ -334,16 +299,6 @@ export const useStudio = () => {
334299 if ( shouldRemoveAppConfig ) {
335300 syncPreviewAppConfig ( undefined )
336301 }
337-
338- const tokensConfig = additions . find ( item => item . path === StudioConfigFiles . tokensConfig )
339- if ( tokensConfig ) {
340- syncPreviewTokensConfig ( tokensConfig ?. parsed )
341- }
342- const shouldRemoveTokensConfig = deletions . find ( item => item . path === StudioConfigFiles . tokensConfig )
343- if ( shouldRemoveTokensConfig ) {
344- syncPreviewTokensConfig ( undefined )
345- }
346- break
347302 }
348303 }
349304 } )
@@ -361,7 +316,6 @@ export const useStudio = () => {
361316 route . meta . studio_page_contentId = page ?. _id
362317 } )
363318
364- // @ts -expect-error custom hook
365319 nuxtApp . hook ( 'nuxt-studio:preview:ready' , ( ) => {
366320 window . parent . postMessage ( {
367321 type : 'nuxt-studio:preview:ready' ,
0 commit comments