Skip to content

Commit

Permalink
fix(ios): resource loading fix
Browse files Browse the repository at this point in the history
  • Loading branch information
farfromrefug committed Mar 8, 2024
1 parent cd278a3 commit da24a4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/ui-carto/utils/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export function setShowError(value: boolean);

export interface ZippedAssetPackageOptions {
zipPath: string;
basePack?
}

export class ZippedAssetPackage extends BaseNative<any, ZippedAssetPackageOptions> {
Expand Down
28 changes: 21 additions & 7 deletions src/ui-carto/utils/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,27 @@ const currentAppFolder = knownFolders.currentApp();

export class ZippedAssetPackage extends BaseNative<NTZippedAssetPackage, ZippedAssetPackageOptions> {
createNative(options: ZippedAssetPackageOptions) {
const zipPath = getRelativePathToApp(options.zipPath);
if (File.exists(zipPath)) {
const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath);
return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData);
} else {
console.error(`could not find zip file: ${options.zipPath}`);
return null;
let zipPath;
try {
const fullZipPath = getFileName(options.zipPath);
zipPath = getRelativePathToApp(options.zipPath);
if (File.exists(fullZipPath)) {
let assetPackage: NTAssetPackage;
if (options.basePack) {
assetPackage = options.basePack.getNative();
}
const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath);
if (assetPackage) {
return NTZippedAssetPackage.alloc().initWithZipDataBaseAssetPackage(vectorTileStyleSetData, assetPackage);
} else {
return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData);
}
} else {
throw new Error(`could not find zip file: ${options.zipPath}(${zipPath})`)
}
} catch (error) {
console.error(`ZippedAssetPackage(${zipPath}, ${options.zipPath}): ${error}`);
throw error;
}
}
getAssetNames() {
Expand Down

0 comments on commit da24a4d

Please sign in to comment.