@dereekb/rxjs 13.6.9 → 13.6.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs.js +579 -1
- package/index.esm.js +571 -3
- package/package.json +2 -2
- package/src/lib/asset/asset.builder.d.ts +112 -0
- package/src/lib/asset/asset.d.ts +114 -0
- package/src/lib/asset/asset.loader.d.ts +34 -0
- package/src/lib/asset/asset.loader.delegated.d.ts +36 -0
- package/src/lib/asset/asset.loader.fetch.d.ts +33 -0
- package/src/lib/asset/asset.loader.memory.d.ts +21 -0
- package/src/lib/asset/index.d.ts +6 -0
- package/src/lib/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -1,7 +1,575 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var rxjs = require('rxjs');
|
|
4
3
|
var util = require('@dereekb/util');
|
|
4
|
+
var rxjs = require('rxjs');
|
|
5
|
+
|
|
6
|
+
function _class_call_check$9(instance, Constructor) {
|
|
7
|
+
if (!(instance instanceof Constructor)) {
|
|
8
|
+
throw new TypeError("Cannot call a class as a function");
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
// MARK: Abstract Loader
|
|
12
|
+
/**
|
|
13
|
+
* Abstract asset loader that serves as a DI token in both Angular and NestJS.
|
|
14
|
+
*
|
|
15
|
+
* Accepts an {@link AssetPathRef} and returns an {@link AssetLoaderAssetInstance}
|
|
16
|
+
* for lazy Observable-based loading.
|
|
17
|
+
*
|
|
18
|
+
* Follows the same abstract-class-as-DI-token pattern as StorageObject.
|
|
19
|
+
* All concrete implementations are functional (factory functions returning
|
|
20
|
+
* objects satisfying this contract), except Angular's DbxCoreAssetLoader
|
|
21
|
+
* which requires @Injectable().
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* // Angular: inject(AssetLoader)
|
|
26
|
+
* // NestJS: @Inject(AssetLoader)
|
|
27
|
+
* const instance = loader.get(PROJECT_ASSETS.SCHOOL_DISTRICTS);
|
|
28
|
+
* instance.load().subscribe((data) => { ... });
|
|
29
|
+
* ```
|
|
30
|
+
*/ var AssetLoader = function AssetLoader() {
|
|
31
|
+
_class_call_check$9(this, AssetLoader);
|
|
32
|
+
}
|
|
33
|
+
;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Creates a local {@link AssetLocalPathRef}.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const DISTRICTS = localAsset('data/school-districts.json');
|
|
41
|
+
* // { sourceType: 'local', path: 'data/school-districts.json' }
|
|
42
|
+
* ```
|
|
43
|
+
*
|
|
44
|
+
* @param path - Relative path from the environment's base asset directory.
|
|
45
|
+
*/ function localAsset(path) {
|
|
46
|
+
return {
|
|
47
|
+
sourceType: 'local',
|
|
48
|
+
path: path
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a remote {@link AssetRemotePathRef}.
|
|
53
|
+
*
|
|
54
|
+
* Remote assets always use absolute URLs with an http:// or https:// prefix.
|
|
55
|
+
* Throws if the provided URL does not have a valid prefix.
|
|
56
|
+
*
|
|
57
|
+
* @example
|
|
58
|
+
* ```ts
|
|
59
|
+
* const CDN = remoteAsset('https://cdn.example.com/geo.json');
|
|
60
|
+
* // { sourceType: 'remote', url: 'https://cdn.example.com/geo.json' }
|
|
61
|
+
* ```
|
|
62
|
+
*
|
|
63
|
+
* @param url - Absolute URL with http/https prefix to fetch the asset from.
|
|
64
|
+
* @throws Error if the URL does not have a valid http/https prefix.
|
|
65
|
+
*/ function remoteAsset(url) {
|
|
66
|
+
if (!util.isWebsiteUrlWithPrefix(url)) {
|
|
67
|
+
throw new Error('remoteAsset() requires a URL with http:// or https:// prefix, got: "'.concat(url, '"'));
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
sourceType: 'remote',
|
|
71
|
+
url: url
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Creates a fluent builder for creating multiple local asset refs
|
|
76
|
+
* from the same folder.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* const DATA = assetFolder('data');
|
|
81
|
+
*
|
|
82
|
+
* const DISTRICTS = DATA.asset('school-districts.json');
|
|
83
|
+
* // { sourceType: 'local', path: 'data/school-districts.json' }
|
|
84
|
+
*
|
|
85
|
+
* const [A, B] = DATA.assets(['a.txt', 'b.txt']);
|
|
86
|
+
* // [
|
|
87
|
+
* // { sourceType: 'local', path: 'data/a.txt' },
|
|
88
|
+
* // { sourceType: 'local', path: 'data/b.txt' }
|
|
89
|
+
* // ]
|
|
90
|
+
* ```
|
|
91
|
+
*
|
|
92
|
+
* @param folder - Base folder path for the assets.
|
|
93
|
+
*/ function assetFolder(folder) {
|
|
94
|
+
var normalizedFolder = folder.endsWith('/') ? folder : folder + '/';
|
|
95
|
+
var builder = {
|
|
96
|
+
asset: function asset(path) {
|
|
97
|
+
return localAsset("".concat(normalizedFolder).concat(path));
|
|
98
|
+
},
|
|
99
|
+
assets: function assets(paths) {
|
|
100
|
+
return paths.map(function(path) {
|
|
101
|
+
return localAsset("".concat(normalizedFolder).concat(path));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return builder;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Creates a fluent builder for creating multiple remote asset refs
|
|
109
|
+
* from the same base URL.
|
|
110
|
+
*
|
|
111
|
+
* The base URL must be a valid {@link WebsiteUrlWithPrefix}.
|
|
112
|
+
* Each child path is appended to produce a full absolute URL.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```ts
|
|
116
|
+
* const CDN = remoteAssetBaseUrl('https://cdn.example.com/assets');
|
|
117
|
+
*
|
|
118
|
+
* const GEO = CDN.asset('data/geo.json');
|
|
119
|
+
* // { sourceType: 'remote', url: 'https://cdn.example.com/assets/data/geo.json' }
|
|
120
|
+
*
|
|
121
|
+
* const [A, B] = CDN.assets(['a.json', 'b.json']);
|
|
122
|
+
* // [
|
|
123
|
+
* // { sourceType: 'remote', url: 'https://cdn.example.com/assets/a.json' },
|
|
124
|
+
* // { sourceType: 'remote', url: 'https://cdn.example.com/assets/b.json' }
|
|
125
|
+
* // ]
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @param baseUrl - Base URL with http/https prefix.
|
|
129
|
+
* @throws Error if the base URL does not have a valid http/https prefix.
|
|
130
|
+
*/ function remoteAssetBaseUrl(baseUrl) {
|
|
131
|
+
if (!util.isWebsiteUrlWithPrefix(baseUrl)) {
|
|
132
|
+
throw new Error('remoteAssetBaseUrl() requires a URL with http:// or https:// prefix, got: "'.concat(baseUrl, '"'));
|
|
133
|
+
}
|
|
134
|
+
var normalizedBase = baseUrl.endsWith('/') ? baseUrl : baseUrl + '/';
|
|
135
|
+
function resolveChildUrl(path) {
|
|
136
|
+
return new URL(path, normalizedBase).href;
|
|
137
|
+
}
|
|
138
|
+
var builder = {
|
|
139
|
+
asset: function asset(path) {
|
|
140
|
+
return remoteAsset(resolveChildUrl(path));
|
|
141
|
+
},
|
|
142
|
+
assets: function assets(paths) {
|
|
143
|
+
return paths.map(function(path) {
|
|
144
|
+
return remoteAsset(resolveChildUrl(path));
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
return builder;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Creates an {@link AssetLoaderAssetInstance} from a ref and a Promise-based get function.
|
|
153
|
+
*
|
|
154
|
+
* The returned {@link AssetLoaderAssetInstance.load} observable is cold — each subscription
|
|
155
|
+
* invokes the get function anew.
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* ```ts
|
|
159
|
+
* const instance = assetLoaderAssetInstance(ref, (r) => fetch(r.path).then(res => res.arrayBuffer()));
|
|
160
|
+
* instance.load().subscribe((data) => { ... });
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* @param ref - The asset path reference this instance represents.
|
|
164
|
+
* @param getFn - Promise-based function that loads the asset bytes.
|
|
165
|
+
*/ function assetLoaderAssetInstance(ref, getFn) {
|
|
166
|
+
return {
|
|
167
|
+
ref: function ref1() {
|
|
168
|
+
return ref;
|
|
169
|
+
},
|
|
170
|
+
load: function load() {
|
|
171
|
+
return rxjs.defer(function() {
|
|
172
|
+
return rxjs.from(getFn(ref));
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Creates an {@link AssetLoader} from a single {@link AssetLoaderGetFn}.
|
|
179
|
+
*
|
|
180
|
+
* This is the primary helper for building functional AssetLoader implementations
|
|
181
|
+
* from a Promise-based leaf loader.
|
|
182
|
+
*
|
|
183
|
+
* @example
|
|
184
|
+
* ```ts
|
|
185
|
+
* const loader = assetLoaderFromGetFn(async (ref) => {
|
|
186
|
+
* const response = await fetch(resolveUrl(ref));
|
|
187
|
+
* return response.arrayBuffer();
|
|
188
|
+
* });
|
|
189
|
+
* ```
|
|
190
|
+
*
|
|
191
|
+
* @param getFn - Promise-based function that loads any asset's bytes.
|
|
192
|
+
*/ function assetLoaderFromGetFn(getFn) {
|
|
193
|
+
var loader = {
|
|
194
|
+
get: function get(ref) {
|
|
195
|
+
return assetLoaderAssetInstance(ref, getFn);
|
|
196
|
+
}
|
|
197
|
+
};
|
|
198
|
+
return loader;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Creates an {@link AssetLoader} that delegates to source-type-specific loaders.
|
|
203
|
+
*
|
|
204
|
+
* This is the primary composition point: wire a local loader and a remote
|
|
205
|
+
* loader together, and the delegated loader routes each {@link AssetPathRef}
|
|
206
|
+
* to the correct one based on {@link AssetPathRef.sourceType}.
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```ts
|
|
210
|
+
* const loader = delegatedAssetLoader({
|
|
211
|
+
* local: nodeJsLocalAssetLoader({ basePath: './assets' }),
|
|
212
|
+
* remote: fetchAssetLoader({ baseUrl: 'https://api.example.com/assets/' })
|
|
213
|
+
* });
|
|
214
|
+
*
|
|
215
|
+
* loader.get(localAsset('data/districts.json')); // → local loader
|
|
216
|
+
* loader.get(remoteAsset('data/geo.json')); // → remote loader
|
|
217
|
+
* ```
|
|
218
|
+
*
|
|
219
|
+
* @param config - Specifies the local and remote delegate loaders.
|
|
220
|
+
*/ function delegatedAssetLoader(config) {
|
|
221
|
+
var local = config.local, remote = config.remote;
|
|
222
|
+
var loader = {
|
|
223
|
+
get: function get(ref) {
|
|
224
|
+
var delegate = ref.sourceType === 'local' ? local : remote;
|
|
225
|
+
return delegate.get(ref);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
return loader;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, key, arg) {
|
|
232
|
+
try {
|
|
233
|
+
var info = gen[key](arg);
|
|
234
|
+
var value = info.value;
|
|
235
|
+
} catch (error) {
|
|
236
|
+
reject(error);
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (info.done) {
|
|
240
|
+
resolve(value);
|
|
241
|
+
} else {
|
|
242
|
+
Promise.resolve(value).then(_next, _throw);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function _async_to_generator$3(fn) {
|
|
246
|
+
return function() {
|
|
247
|
+
var self = this, args = arguments;
|
|
248
|
+
return new Promise(function(resolve, reject) {
|
|
249
|
+
var gen = fn.apply(self, args);
|
|
250
|
+
function _next(value) {
|
|
251
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "next", value);
|
|
252
|
+
}
|
|
253
|
+
function _throw(err) {
|
|
254
|
+
asyncGeneratorStep$3(gen, resolve, reject, _next, _throw, "throw", err);
|
|
255
|
+
}
|
|
256
|
+
_next(undefined);
|
|
257
|
+
});
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function _ts_generator$3(thisArg, body) {
|
|
261
|
+
var f, y, t, _ = {
|
|
262
|
+
label: 0,
|
|
263
|
+
sent: function() {
|
|
264
|
+
if (t[0] & 1) throw t[1];
|
|
265
|
+
return t[1];
|
|
266
|
+
},
|
|
267
|
+
trys: [],
|
|
268
|
+
ops: []
|
|
269
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
270
|
+
return d(g, "next", {
|
|
271
|
+
value: verb(0)
|
|
272
|
+
}), d(g, "throw", {
|
|
273
|
+
value: verb(1)
|
|
274
|
+
}), d(g, "return", {
|
|
275
|
+
value: verb(2)
|
|
276
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
277
|
+
value: function() {
|
|
278
|
+
return this;
|
|
279
|
+
}
|
|
280
|
+
}), g;
|
|
281
|
+
function verb(n) {
|
|
282
|
+
return function(v) {
|
|
283
|
+
return step([
|
|
284
|
+
n,
|
|
285
|
+
v
|
|
286
|
+
]);
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function step(op) {
|
|
290
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
291
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
292
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
293
|
+
if (y = 0, t) op = [
|
|
294
|
+
op[0] & 2,
|
|
295
|
+
t.value
|
|
296
|
+
];
|
|
297
|
+
switch(op[0]){
|
|
298
|
+
case 0:
|
|
299
|
+
case 1:
|
|
300
|
+
t = op;
|
|
301
|
+
break;
|
|
302
|
+
case 4:
|
|
303
|
+
_.label++;
|
|
304
|
+
return {
|
|
305
|
+
value: op[1],
|
|
306
|
+
done: false
|
|
307
|
+
};
|
|
308
|
+
case 5:
|
|
309
|
+
_.label++;
|
|
310
|
+
y = op[1];
|
|
311
|
+
op = [
|
|
312
|
+
0
|
|
313
|
+
];
|
|
314
|
+
continue;
|
|
315
|
+
case 7:
|
|
316
|
+
op = _.ops.pop();
|
|
317
|
+
_.trys.pop();
|
|
318
|
+
continue;
|
|
319
|
+
default:
|
|
320
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
321
|
+
_ = 0;
|
|
322
|
+
continue;
|
|
323
|
+
}
|
|
324
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
325
|
+
_.label = op[1];
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
329
|
+
_.label = t[1];
|
|
330
|
+
t = op;
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
if (t && _.label < t[2]) {
|
|
334
|
+
_.label = t[2];
|
|
335
|
+
_.ops.push(op);
|
|
336
|
+
break;
|
|
337
|
+
}
|
|
338
|
+
if (t[2]) _.ops.pop();
|
|
339
|
+
_.trys.pop();
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
op = body.call(thisArg, _);
|
|
343
|
+
} catch (e) {
|
|
344
|
+
op = [
|
|
345
|
+
6,
|
|
346
|
+
e
|
|
347
|
+
];
|
|
348
|
+
y = 0;
|
|
349
|
+
} finally{
|
|
350
|
+
f = t = 0;
|
|
351
|
+
}
|
|
352
|
+
if (op[0] & 5) throw op[1];
|
|
353
|
+
return {
|
|
354
|
+
value: op[0] ? op[1] : void 0,
|
|
355
|
+
done: true
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
/**
|
|
360
|
+
* Creates an {@link AssetLoader} that loads remote assets via HTTP fetch.
|
|
361
|
+
* Works in both browser and Node.js (Node 18+) environments.
|
|
362
|
+
*
|
|
363
|
+
* Remote refs always have absolute URLs, so no base URL resolution is needed.
|
|
364
|
+
*
|
|
365
|
+
* @example
|
|
366
|
+
* ```ts
|
|
367
|
+
* const loader = fetchAssetLoader();
|
|
368
|
+
* loader.get(remoteAsset('https://cdn.example.com/geo.json')).load().subscribe((data) => {
|
|
369
|
+
* // loaded from https://cdn.example.com/geo.json
|
|
370
|
+
* });
|
|
371
|
+
*
|
|
372
|
+
* // With a custom fetch function:
|
|
373
|
+
* const loader = fetchAssetLoader({ fetch: myAuthenticatedFetch });
|
|
374
|
+
* ```
|
|
375
|
+
*
|
|
376
|
+
* @param config - Optional fetch configuration with custom fetch function.
|
|
377
|
+
*/ function fetchAssetLoader() {
|
|
378
|
+
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
379
|
+
var _config_fetch;
|
|
380
|
+
var fetchFn = (_config_fetch = config.fetch) !== null && _config_fetch !== void 0 ? _config_fetch : globalThis.fetch;
|
|
381
|
+
var getFn = function getFn(ref) {
|
|
382
|
+
return _async_to_generator$3(function() {
|
|
383
|
+
var remoteRef, url, response;
|
|
384
|
+
return _ts_generator$3(this, function(_state) {
|
|
385
|
+
switch(_state.label){
|
|
386
|
+
case 0:
|
|
387
|
+
remoteRef = ref;
|
|
388
|
+
url = remoteRef.url;
|
|
389
|
+
return [
|
|
390
|
+
4,
|
|
391
|
+
fetchFn(url)
|
|
392
|
+
];
|
|
393
|
+
case 1:
|
|
394
|
+
response = _state.sent();
|
|
395
|
+
if (!response.ok) {
|
|
396
|
+
throw new Error("Failed to fetch asset from ".concat(url, ": ").concat(response.status, " ").concat(response.statusText));
|
|
397
|
+
}
|
|
398
|
+
return [
|
|
399
|
+
2,
|
|
400
|
+
response.arrayBuffer()
|
|
401
|
+
];
|
|
402
|
+
}
|
|
403
|
+
});
|
|
404
|
+
})();
|
|
405
|
+
};
|
|
406
|
+
return assetLoaderFromGetFn(getFn);
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
function asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, key, arg) {
|
|
410
|
+
try {
|
|
411
|
+
var info = gen[key](arg);
|
|
412
|
+
var value = info.value;
|
|
413
|
+
} catch (error) {
|
|
414
|
+
reject(error);
|
|
415
|
+
return;
|
|
416
|
+
}
|
|
417
|
+
if (info.done) {
|
|
418
|
+
resolve(value);
|
|
419
|
+
} else {
|
|
420
|
+
Promise.resolve(value).then(_next, _throw);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
function _async_to_generator$2(fn) {
|
|
424
|
+
return function() {
|
|
425
|
+
var self = this, args = arguments;
|
|
426
|
+
return new Promise(function(resolve, reject) {
|
|
427
|
+
var gen = fn.apply(self, args);
|
|
428
|
+
function _next(value) {
|
|
429
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "next", value);
|
|
430
|
+
}
|
|
431
|
+
function _throw(err) {
|
|
432
|
+
asyncGeneratorStep$2(gen, resolve, reject, _next, _throw, "throw", err);
|
|
433
|
+
}
|
|
434
|
+
_next(undefined);
|
|
435
|
+
});
|
|
436
|
+
};
|
|
437
|
+
}
|
|
438
|
+
function _ts_generator$2(thisArg, body) {
|
|
439
|
+
var f, y, t, _ = {
|
|
440
|
+
label: 0,
|
|
441
|
+
sent: function() {
|
|
442
|
+
if (t[0] & 1) throw t[1];
|
|
443
|
+
return t[1];
|
|
444
|
+
},
|
|
445
|
+
trys: [],
|
|
446
|
+
ops: []
|
|
447
|
+
}, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype), d = Object.defineProperty;
|
|
448
|
+
return d(g, "next", {
|
|
449
|
+
value: verb(0)
|
|
450
|
+
}), d(g, "throw", {
|
|
451
|
+
value: verb(1)
|
|
452
|
+
}), d(g, "return", {
|
|
453
|
+
value: verb(2)
|
|
454
|
+
}), typeof Symbol === "function" && d(g, Symbol.iterator, {
|
|
455
|
+
value: function() {
|
|
456
|
+
return this;
|
|
457
|
+
}
|
|
458
|
+
}), g;
|
|
459
|
+
function verb(n) {
|
|
460
|
+
return function(v) {
|
|
461
|
+
return step([
|
|
462
|
+
n,
|
|
463
|
+
v
|
|
464
|
+
]);
|
|
465
|
+
};
|
|
466
|
+
}
|
|
467
|
+
function step(op) {
|
|
468
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
469
|
+
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
470
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
471
|
+
if (y = 0, t) op = [
|
|
472
|
+
op[0] & 2,
|
|
473
|
+
t.value
|
|
474
|
+
];
|
|
475
|
+
switch(op[0]){
|
|
476
|
+
case 0:
|
|
477
|
+
case 1:
|
|
478
|
+
t = op;
|
|
479
|
+
break;
|
|
480
|
+
case 4:
|
|
481
|
+
_.label++;
|
|
482
|
+
return {
|
|
483
|
+
value: op[1],
|
|
484
|
+
done: false
|
|
485
|
+
};
|
|
486
|
+
case 5:
|
|
487
|
+
_.label++;
|
|
488
|
+
y = op[1];
|
|
489
|
+
op = [
|
|
490
|
+
0
|
|
491
|
+
];
|
|
492
|
+
continue;
|
|
493
|
+
case 7:
|
|
494
|
+
op = _.ops.pop();
|
|
495
|
+
_.trys.pop();
|
|
496
|
+
continue;
|
|
497
|
+
default:
|
|
498
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
499
|
+
_ = 0;
|
|
500
|
+
continue;
|
|
501
|
+
}
|
|
502
|
+
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
503
|
+
_.label = op[1];
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
507
|
+
_.label = t[1];
|
|
508
|
+
t = op;
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
if (t && _.label < t[2]) {
|
|
512
|
+
_.label = t[2];
|
|
513
|
+
_.ops.push(op);
|
|
514
|
+
break;
|
|
515
|
+
}
|
|
516
|
+
if (t[2]) _.ops.pop();
|
|
517
|
+
_.trys.pop();
|
|
518
|
+
continue;
|
|
519
|
+
}
|
|
520
|
+
op = body.call(thisArg, _);
|
|
521
|
+
} catch (e) {
|
|
522
|
+
op = [
|
|
523
|
+
6,
|
|
524
|
+
e
|
|
525
|
+
];
|
|
526
|
+
y = 0;
|
|
527
|
+
} finally{
|
|
528
|
+
f = t = 0;
|
|
529
|
+
}
|
|
530
|
+
if (op[0] & 5) throw op[1];
|
|
531
|
+
return {
|
|
532
|
+
value: op[0] ? op[1] : void 0,
|
|
533
|
+
done: true
|
|
534
|
+
};
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
/**
|
|
538
|
+
* Creates an {@link AssetLoader} backed by an in-memory map.
|
|
539
|
+
* Useful for testing without filesystem or network access.
|
|
540
|
+
*
|
|
541
|
+
* Assets are matched by reference identity — the same {@link AssetPathRef}
|
|
542
|
+
* object used to populate the map must be used to retrieve the data.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```ts
|
|
546
|
+
* const DISTRICTS = localAsset('districts.json');
|
|
547
|
+
* const loader = memoryAssetLoader(new Map([
|
|
548
|
+
* [DISTRICTS, new TextEncoder().encode('[]').buffer]
|
|
549
|
+
* ]));
|
|
550
|
+
*
|
|
551
|
+
* loader.get(DISTRICTS).load().subscribe((data) => { ... });
|
|
552
|
+
* ```
|
|
553
|
+
*
|
|
554
|
+
* @param assets - Map of asset refs to their raw byte data.
|
|
555
|
+
*/ function memoryAssetLoader(assets) {
|
|
556
|
+
var getFn = function getFn(ref) {
|
|
557
|
+
return _async_to_generator$2(function() {
|
|
558
|
+
var data;
|
|
559
|
+
return _ts_generator$2(this, function(_state) {
|
|
560
|
+
data = assets.get(ref);
|
|
561
|
+
if (!data) {
|
|
562
|
+
throw new Error("Asset not found in memory loader: ".concat(JSON.stringify(ref)));
|
|
563
|
+
}
|
|
564
|
+
return [
|
|
565
|
+
2,
|
|
566
|
+
data
|
|
567
|
+
];
|
|
568
|
+
});
|
|
569
|
+
})();
|
|
570
|
+
};
|
|
571
|
+
return assetLoaderFromGetFn(getFn);
|
|
572
|
+
}
|
|
5
573
|
|
|
6
574
|
function asObservable(valueOrObs) {
|
|
7
575
|
if (rxjs.isObservable(valueOrObs)) {
|
|
@@ -6207,6 +6775,7 @@ function _define_property(obj, key, value) {
|
|
|
6207
6775
|
};
|
|
6208
6776
|
}
|
|
6209
6777
|
|
|
6778
|
+
exports.AssetLoader = AssetLoader;
|
|
6210
6779
|
exports.DEFAULT_ASYNC_PUSHER_THROTTLE = DEFAULT_ASYNC_PUSHER_THROTTLE;
|
|
6211
6780
|
exports.DEFAULT_FACTORY_TIMER_INTERVAL = DEFAULT_FACTORY_TIMER_INTERVAL;
|
|
6212
6781
|
exports.DEFAULT_ITEM_PAGE_ITERATOR_MAX = DEFAULT_ITEM_PAGE_ITERATOR_MAX;
|
|
@@ -6232,6 +6801,9 @@ exports.areAllLoadingStatesFinishedLoading = areAllLoadingStatesFinishedLoading;
|
|
|
6232
6801
|
exports.arrayValueFromFinishedLoadingState = arrayValueFromFinishedLoadingState;
|
|
6233
6802
|
exports.asObservable = asObservable;
|
|
6234
6803
|
exports.asObservableFromGetter = asObservableFromGetter;
|
|
6804
|
+
exports.assetFolder = assetFolder;
|
|
6805
|
+
exports.assetLoaderAssetInstance = assetLoaderAssetInstance;
|
|
6806
|
+
exports.assetLoaderFromGetFn = assetLoaderFromGetFn;
|
|
6235
6807
|
exports.asyncPusher = asyncPusher;
|
|
6236
6808
|
exports.asyncPusherCache = asyncPusherCache;
|
|
6237
6809
|
exports.beginLoading = beginLoading;
|
|
@@ -6247,6 +6819,7 @@ exports.combineLatestMapFrom = combineLatestMapFrom;
|
|
|
6247
6819
|
exports.combineLoadingStates = combineLoadingStates;
|
|
6248
6820
|
exports.combineLoadingStatesStatus = combineLoadingStatesStatus;
|
|
6249
6821
|
exports.currentValueFromLoadingState = currentValueFromLoadingState;
|
|
6822
|
+
exports.delegatedAssetLoader = delegatedAssetLoader;
|
|
6250
6823
|
exports.distinctLoadingState = distinctLoadingState;
|
|
6251
6824
|
exports.distinctUntilArrayLengthChanges = distinctUntilArrayLengthChanges;
|
|
6252
6825
|
exports.distinctUntilHasDifferentValues = distinctUntilHasDifferentValues;
|
|
@@ -6265,6 +6838,7 @@ exports.errorOnEmissionsInPeriod = errorOnEmissionsInPeriod;
|
|
|
6265
6838
|
exports.errorPageResult = errorPageResult;
|
|
6266
6839
|
exports.errorResult = errorResult;
|
|
6267
6840
|
exports.factoryTimer = factoryTimer;
|
|
6841
|
+
exports.fetchAssetLoader = fetchAssetLoader;
|
|
6268
6842
|
exports.filterIfObjectValuesUnchanged = filterIfObjectValuesUnchanged;
|
|
6269
6843
|
exports.filterItemsWithObservableDecision = filterItemsWithObservableDecision;
|
|
6270
6844
|
exports.filterMaybe = filterMaybe;
|
|
@@ -6307,6 +6881,7 @@ exports.listLoadingStateContext = listLoadingStateContext;
|
|
|
6307
6881
|
exports.loadingStateContext = loadingStateContext;
|
|
6308
6882
|
exports.loadingStateFromObs = loadingStateFromObs;
|
|
6309
6883
|
exports.loadingStateType = loadingStateType;
|
|
6884
|
+
exports.localAsset = localAsset;
|
|
6310
6885
|
exports.makeCheckIsFunction = makeCheckIsFunction;
|
|
6311
6886
|
exports.makeIsModifiedFunction = makeIsModifiedFunction;
|
|
6312
6887
|
exports.makeIsModifiedFunctionObservable = makeIsModifiedFunctionObservable;
|
|
@@ -6328,6 +6903,7 @@ exports.mapMultipleLoadingStateResults = mapMultipleLoadingStateResults;
|
|
|
6328
6903
|
exports.mappedPageItemIteration = mappedPageItemIteration;
|
|
6329
6904
|
exports.maybeValueFromObservableOrValue = maybeValueFromObservableOrValue;
|
|
6330
6905
|
exports.maybeValueFromObservableOrValueGetter = maybeValueFromObservableOrValueGetter;
|
|
6906
|
+
exports.memoryAssetLoader = memoryAssetLoader;
|
|
6331
6907
|
exports.mergeLoadingStateWithError = mergeLoadingStateWithError;
|
|
6332
6908
|
exports.mergeLoadingStateWithLoading = mergeLoadingStateWithLoading;
|
|
6333
6909
|
exports.mergeLoadingStateWithValue = mergeLoadingStateWithValue;
|
|
@@ -6344,6 +6920,8 @@ exports.preventComplete = preventComplete;
|
|
|
6344
6920
|
exports.promiseFromLoadingState = promiseFromLoadingState;
|
|
6345
6921
|
exports.randomDelay = randomDelay;
|
|
6346
6922
|
exports.randomDelayWithRandomFunction = randomDelayWithRandomFunction;
|
|
6923
|
+
exports.remoteAsset = remoteAsset;
|
|
6924
|
+
exports.remoteAssetBaseUrl = remoteAssetBaseUrl;
|
|
6347
6925
|
exports.returnIfIs = returnIfIs;
|
|
6348
6926
|
exports.scanBuildArray = scanBuildArray;
|
|
6349
6927
|
exports.scanCount = scanCount;
|