Skip to content

Commit da24a4d

Browse files
committed
fix(ios): resource loading fix
1 parent cd278a3 commit da24a4d

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/ui-carto/utils/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export function setShowError(value: boolean);
1414

1515
export interface ZippedAssetPackageOptions {
1616
zipPath: string;
17+
basePack?
1718
}
1819

1920
export class ZippedAssetPackage extends BaseNative<any, ZippedAssetPackageOptions> {

src/ui-carto/utils/index.ios.ts

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,27 @@ const currentAppFolder = knownFolders.currentApp();
6767

6868
export class ZippedAssetPackage extends BaseNative<NTZippedAssetPackage, ZippedAssetPackageOptions> {
6969
createNative(options: ZippedAssetPackageOptions) {
70-
const zipPath = getRelativePathToApp(options.zipPath);
71-
if (File.exists(zipPath)) {
72-
const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath);
73-
return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData);
74-
} else {
75-
console.error(`could not find zip file: ${options.zipPath}`);
76-
return null;
70+
let zipPath;
71+
try {
72+
const fullZipPath = getFileName(options.zipPath);
73+
zipPath = getRelativePathToApp(options.zipPath);
74+
if (File.exists(fullZipPath)) {
75+
let assetPackage: NTAssetPackage;
76+
if (options.basePack) {
77+
assetPackage = options.basePack.getNative();
78+
}
79+
const vectorTileStyleSetData = NTAssetUtils.loadAsset(zipPath);
80+
if (assetPackage) {
81+
return NTZippedAssetPackage.alloc().initWithZipDataBaseAssetPackage(vectorTileStyleSetData, assetPackage);
82+
} else {
83+
return NTZippedAssetPackage.alloc().initWithZipData(vectorTileStyleSetData);
84+
}
85+
} else {
86+
throw new Error(`could not find zip file: ${options.zipPath}(${zipPath})`)
87+
}
88+
} catch (error) {
89+
console.error(`ZippedAssetPackage(${zipPath}, ${options.zipPath}): ${error}`);
90+
throw error;
7791
}
7892
}
7993
getAssetNames() {

0 commit comments

Comments
 (0)