@@ -123,41 +123,52 @@ export function setShowError(value: boolean) {
123
123
124
124
export class ZippedAssetPackage extends BaseNative < com . carto . utils . ZippedAssetPackage , ZippedAssetPackageOptions > {
125
125
mInterface : com . akylas . carto . additions . AKAssetPackage . Interface ;
126
+ mBaseAssetPackage : com . akylas . carto . additions . AKAssetPackage ;
127
+ mAssetPackage : com . akylas . carto . additions . AKAssetPackage ;
128
+ mVectorTileStyleSetData : com . carto . core . BinaryData ;
126
129
constructor ( options ) {
127
130
super ( options ) ;
128
- for ( const property of [ 'mInterface' ] ) {
129
- const descriptor = Object . getOwnPropertyDescriptor ( DirAssetPackage . prototype , property ) ;
130
- if ( descriptor ) {
131
- descriptor . enumerable = false ;
132
- }
133
- }
131
+ // Object.defineProperty(this, 'mInterface', { enumerable: false });
132
+ // Object.defineProperty(this, 'mBaseAssetPackage', { enumerable: false });
133
+ // Object.defineProperty(this, 'mAssetPackage', { enumerable: false });
134
+ // Object.defineProperty(this, 'mVectorTileStyleSetData', { enumerable: false });
135
+ // for (const property of ['mInterface']) {
136
+ // const descriptor = Object.getOwnPropertyDescriptor(DirAssetPackage.prototype, property);
137
+ // if (descriptor) {
138
+ // descriptor.enumerable = false;
139
+ // }
140
+ // }
141
+ }
142
+ dispose ( ) : void {
143
+ super . dispose ( ) ;
144
+ this . mInterface = null ;
145
+ this . mBaseAssetPackage = null ;
146
+ this . mAssetPackage = null ;
147
+ this . mVectorTileStyleSetData = null ;
134
148
}
135
149
createNative ( options : ZippedAssetPackageOptions ) {
136
150
// if (File.exists(options.zipPath)) {
137
- let vectorTileStyleSetData : com . carto . core . BinaryData ;
138
151
if ( options . liveReload === true ) {
139
152
const data = File . fromPath ( getFileName ( options . zipPath ) ) . readSync ( ) ;
140
- vectorTileStyleSetData = new com . carto . core . BinaryData ( data ) ;
153
+ this . mVectorTileStyleSetData = new com . carto . core . BinaryData ( data ) ;
141
154
} else {
142
155
const zipPath = getRelativePathToApp ( options . zipPath ) ;
143
- console . log ( 'zipPath' , zipPath ) ;
144
- vectorTileStyleSetData = com . carto . utils . AssetUtils . loadAsset ( zipPath ) ;
156
+ this . mVectorTileStyleSetData = com . carto . utils . AssetUtils . loadAsset ( zipPath ) ;
145
157
}
146
- let assetPackage : com . akylas . carto . additions . AKAssetPackage ;
147
158
if ( options . basePack ) {
148
- assetPackage = options . basePack . getNative ( ) ;
159
+ this . mBaseAssetPackage = options . basePack . getNative ( ) ;
149
160
}
150
161
if ( options . loadAsset && options . getAssetNames ) {
151
162
this . mInterface = new com . akylas . carto . additions . AKAssetPackage . Interface ( {
152
163
getAssetNames : options . getAssetNames ,
153
164
loadAsset : options . loadAsset
154
165
} ) ;
155
- assetPackage = new com . akylas . carto . additions . AKAssetPackage ( this . mInterface , assetPackage ) ;
166
+ this . mAssetPackage = new com . akylas . carto . additions . AKAssetPackage ( this . mInterface , this . mBaseAssetPackage ) ;
156
167
}
157
- if ( assetPackage ) {
158
- return new com . carto . utils . ZippedAssetPackage ( vectorTileStyleSetData , assetPackage ) ;
168
+ if ( this . mBaseAssetPackage || this . mAssetPackage ) {
169
+ return new com . carto . utils . ZippedAssetPackage ( this . mVectorTileStyleSetData , this . mAssetPackage || this . mBaseAssetPackage ) ;
159
170
} else {
160
- return new com . carto . utils . ZippedAssetPackage ( vectorTileStyleSetData ) ;
171
+ return new com . carto . utils . ZippedAssetPackage ( this . mVectorTileStyleSetData ) ;
161
172
}
162
173
// } else {
163
174
// console.error(`could not find zip file: ${options.zipPath}`);
@@ -182,20 +193,28 @@ function walkDir(dirPath: string, cb: (str: string) => void, currentSubDir?: str
182
193
} ) ;
183
194
}
184
195
export class DirAssetPackage extends BaseNative < com . akylas . carto . additions . AKAssetPackage , DirAssetPackageOptions > {
185
- assetNames : com . carto . core . StringVector ;
196
+ mAssetNames : com . carto . core . StringVector ;
186
197
mDirPath : string ;
187
198
mCartoDirPath : string ;
188
199
loadUsingNS = false ;
189
200
mInterface : com . akylas . carto . additions . AKAssetPackage . Interface ;
190
201
constructor ( options ) {
191
202
super ( options ) ;
203
+
204
+ // Object.defineProperty(this, 'mInterface', { enumerable: false });
205
+ // Object.defineProperty(this, 'mAssetNames', { enumerable: false });
192
206
for ( const property of [ 'mInterface' ] ) {
193
207
const descriptor = Object . getOwnPropertyDescriptor ( DirAssetPackage . prototype , property ) ;
194
208
if ( descriptor ) {
195
209
descriptor . enumerable = false ;
196
210
}
197
211
}
198
212
}
213
+ dispose ( ) : void {
214
+ this . mInterface = null ;
215
+ this . mAssetNames = null ;
216
+ super . dispose ( ) ;
217
+ }
199
218
createNative ( options : DirAssetPackageOptions ) {
200
219
if ( Folder . exists ( getFileName ( options . dirPath ) ) ) {
201
220
const dirPath = options . dirPath ;
@@ -227,15 +246,15 @@ export class DirAssetPackage extends BaseNative<com.akylas.carto.additions.AKAss
227
246
return result ;
228
247
}
229
248
public getAssetNames ( ) {
230
- if ( ! this . assetNames ) {
249
+ if ( ! this . mAssetNames ) {
231
250
try {
232
- this . assetNames = new com . carto . core . StringVector ( ) ;
251
+ this . mAssetNames = new com . carto . core . StringVector ( ) ;
233
252
walkDir ( this . mDirPath , ( fileRelPath : string ) => {
234
- this . assetNames . add ( fileRelPath ) ;
253
+ this . mAssetNames . add ( fileRelPath ) ;
235
254
} ) ;
236
255
} catch ( e ) { }
237
256
}
238
- return this . assetNames ;
257
+ return this . mAssetNames ;
239
258
}
240
259
}
241
260
0 commit comments