@loaders.gl/core 4.4.0-alpha.9 → 4.4.0

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.
@@ -8,13 +8,15 @@ import {
8
8
  registerJSModules,
9
9
  isPureObject,
10
10
  isObject,
11
- StrictLoaderOptions
11
+ StrictLoaderOptions,
12
+ path
12
13
  } from '@loaders.gl/loader-utils';
13
14
  import {probeLog, NullLog} from './loggers';
14
15
  import {DEFAULT_LOADER_OPTIONS, REMOVED_LOADER_OPTIONS} from './option-defaults';
16
+ import {stripQueryString} from '../utils/url-utils';
15
17
 
16
18
  const CORE_LOADER_OPTION_KEYS = [
17
- 'baseUri',
19
+ 'baseUrl',
18
20
  'fetch',
19
21
  'mimeType',
20
22
  'fallbackMimeType',
@@ -91,7 +93,7 @@ export function setGlobalOptions(options: LoaderOptions): void {
91
93
  }
92
94
 
93
95
  /**
94
- * Merges options with global opts and loader defaults, also injects baseUri
96
+ * Merges options with global opts and loader defaults, also injects baseUrl
95
97
  * @param options
96
98
  * @param loader
97
99
  * @param loaders
@@ -175,14 +177,18 @@ function validateOptionsObject(
175
177
  if (!(key in defaultOptions) && !isBaseUriOption && !isWorkerUrlOption) {
176
178
  // Issue deprecation warnings
177
179
  if (key in deprecatedOptions) {
178
- probeLog.warn(
179
- `${loaderName} loader option \'${prefix}${key}\' no longer supported, use \'${deprecatedOptions[key]}\'`
180
- )();
180
+ if (probeLog.level > 0) {
181
+ probeLog.warn(
182
+ `${loaderName} loader option \'${prefix}${key}\' no longer supported, use \'${deprecatedOptions[key]}\'`
183
+ )();
184
+ }
181
185
  } else if (!isSubOptions) {
182
- const suggestion = findSimilarOption(key, loaders);
183
- probeLog.warn(
184
- `${loaderName} loader option \'${prefix}${key}\' not recognized. ${suggestion}`
185
- )();
186
+ if (probeLog.level > 0) {
187
+ const suggestion = findSimilarOption(key, loaders);
188
+ probeLog.warn(
189
+ `${loaderName} loader option \'${prefix}${key}\' not recognized. ${suggestion}`
190
+ )();
191
+ }
186
192
  }
187
193
  }
188
194
  }
@@ -258,8 +264,7 @@ function mergeNestedFields(mergedOptions: LoaderOptions, options: LoaderOptions)
258
264
 
259
265
  /**
260
266
  * Harvest information from the url
261
- * @deprecated This is mainly there to support a hack in the GLTFLoader
262
- * TODO - baseUri should be a directory, i.e. remove file component from baseUri
267
+ * @deprecated This is mainly there to support loaders that still resolve from options
263
268
  * TODO - extract extension?
264
269
  * TODO - extract query parameters?
265
270
  * TODO - should these be injected on context instead of options?
@@ -268,11 +273,10 @@ function addUrlOptions(options: LoaderOptions, url?: string): void {
268
273
  if (!url) {
269
274
  return;
270
275
  }
271
- const hasTopLevelBaseUri = options.baseUri !== undefined;
272
- const hasCoreBaseUri = options.core?.baseUri !== undefined;
273
- if (!hasTopLevelBaseUri && !hasCoreBaseUri) {
276
+ const hasCoreBaseUrl = options.core?.baseUrl !== undefined;
277
+ if (!hasCoreBaseUrl) {
274
278
  options.core ||= {};
275
- options.core.baseUri = url;
279
+ options.core.baseUrl = path.dirname(stripQueryString(url));
276
280
  }
277
281
  }
278
282
 
@@ -285,6 +289,13 @@ function cloneLoaderOptions(options: LoaderOptions): LoaderOptions {
285
289
  }
286
290
 
287
291
  function moveDeprecatedTopLevelOptionsToCore(options: LoaderOptions): void {
292
+ if (options.baseUri !== undefined) {
293
+ options.core ||= {};
294
+ if (options.core.baseUrl === undefined) {
295
+ options.core.baseUrl = options.baseUri;
296
+ }
297
+ }
298
+
288
299
  for (const key of CORE_LOADER_OPTION_KEYS) {
289
300
  if ((options as Record<string, unknown>)[key] !== undefined) {
290
301
  const coreOptions = (options.core = options.core || {});