@@ -72,7 +72,9 @@ export const getLocalApplicationTransporter = (
7272 return ;
7373 }
7474
75- const content = await readFile ( filePath , { encoding : "utf-8" } ) ;
75+ const content = await readFile ( filePath , {
76+ encoding : isAssetOrFont ( document ) ? "base64" : "utf-8" ,
77+ } ) ;
7678
7779 return {
7880 ...document ,
@@ -212,14 +214,20 @@ export const localStoreAsset = async (
212214 fileData : string | Buffer ,
213215 font ?: {
214216 fontFamily ?: string ;
215- weight ?: number ;
217+ fontWeight ?: number ;
216218 fontStyle ?: string ;
217219 fontType ?: string ;
218220 } ,
219- options ?: { existingAppMetadata ?: ApplicationLocalMeta } ,
221+ options ?: {
222+ existingAppMetadata ?: ApplicationLocalMeta ;
223+ } ,
220224) : Promise < { relativePath : string ; assetDocument : EnsembleDocument } > => {
221225 const appsMetadata = await getGlobalMetadata ( ) ;
222- const appMetadata = appsMetadata [ appId ] || options ?. existingAppMetadata ;
226+ const existingAppMetadata = appsMetadata [ appId ] ;
227+ const appMetadata =
228+ options ?. existingAppMetadata ||
229+ ( existingAppMetadata &&
230+ ( await getAppManifest ( existingAppMetadata . projectPath ) ) ) ;
223231 if ( ! appMetadata ) {
224232 throw new Error ( `App ${ appId } not found in local metadata` ) ;
225233 }
@@ -253,6 +261,7 @@ export const localStoreAsset = async (
253261 const { relativePath } = await saveArtifact ( assetDocument , appMetadata , {
254262 relativePath : fileName ,
255263 } ) ;
264+
256265 return { relativePath, assetDocument } ;
257266} ;
258267
@@ -368,27 +377,29 @@ const setGlobalMetadata = async (
368377 await writeJsonData ( filePath , metadata ) ;
369378} ;
370379
371- const getAppManifest = async ( projectPath : string ) : Promise < HasManifest > => {
380+ const getAppManifest = async (
381+ projectPath : string ,
382+ ) : Promise < ApplicationLocalMeta > => {
372383 const filePath = join ( projectPath , APP_MANIFEST_FILE ) ;
373384
374385 // Check if the file exists
375386 if ( ! existsSync ( filePath ) ) {
376- return { } ;
387+ return { } as ApplicationLocalMeta ;
377388 }
378389
379390 const manifest = readJsonFile < ApplicationLocalMeta > ( filePath ) ;
380391 return manifest ;
381392} ;
382393
383394const setAppManifest = async (
384- manifest : HasManifest ,
395+ appMetadata : ApplicationLocalMeta ,
385396 projectPath : string ,
386397) : Promise < void > => {
387398 ensureDir ( projectPath ) ;
388399
389400 const filePath = join ( projectPath , APP_MANIFEST_FILE ) ;
390401
391- await writeJsonData ( filePath , manifest , true ) ;
402+ await writeJsonData ( filePath , appMetadata , true ) ;
392403} ;
393404
394405const readJsonFile = async < T > ( filePath : string ) : Promise < T > => {
@@ -416,7 +427,7 @@ const ensureDir = (path: string): void => {
416427 if ( ! existsSync ( path ) ) mkdirSync ( path , { recursive : true } ) ;
417428} ;
418429
419- const isAssetOrFont = ( document : EnsembleDocument ) : boolean => {
430+ const isAssetOrFont = ( document : Partial < EnsembleDocument > ) : boolean => {
420431 return (
421432 document . type === EnsembleDocumentType . Asset ||
422433 document . type === EnsembleDocumentType . Font
@@ -432,7 +443,7 @@ const fetchFileData = async (url: string): Promise<Buffer> => {
432443const extractFontData = ( fontDoc : FontDTO ) : object => {
433444 return {
434445 fontFamily : fontDoc . fontFamily ,
435- weight : fontDoc . fontWeight ,
446+ fontWeight : fontDoc . fontWeight ,
436447 fontStyle : fontDoc . fontStyle ,
437448 fontType : fontDoc . fontType ,
438449 } ;
0 commit comments