@dereekb/dbx-web 13.40.0 → 13.42.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.
- package/eslint/package.json +4 -4
- package/fesm2022/dereekb-dbx-web-mapbox.mjs +69 -4
- package/fesm2022/dereekb-dbx-web-mapbox.mjs.map +1 -1
- package/fesm2022/dereekb-dbx-web-style-demo.mjs +5 -5
- package/fesm2022/dereekb-dbx-web-style-demo.mjs.map +1 -1
- package/fesm2022/dereekb-dbx-web.mjs +8 -8
- package/fesm2022/dereekb-dbx-web.mjs.map +1 -1
- package/mapbox/README.md +49 -0
- package/package.json +7 -7
- package/types/dereekb-dbx-web-mapbox.d.ts +84 -2
package/mapbox/README.md
CHANGED
|
@@ -3,4 +3,53 @@
|
|
|
3
3
|
|
|
4
4
|
The sources for this package are in the main [@dereekb/dbx-components](https://github.com/dereekb/dbx-components) repo. Please file issues and pull requests against that repo.
|
|
5
5
|
|
|
6
|
+
## Required build asset: the mapbox-gl web worker
|
|
7
|
+
|
|
8
|
+
Apps using `provideDbxMapbox()` must copy mapbox-gl's prebuilt CSP web worker into their
|
|
9
|
+
assets. Add this entry to the `assets` array of the app's `build` target in `project.json`:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"input": "node_modules/mapbox-gl/dist",
|
|
14
|
+
"glob": "mapbox-gl-csp-worker.js",
|
|
15
|
+
"output": "assets/mapbox-gl"
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
`provideDbxMapbox()` registers an app initializer that points `mapboxgl.workerUrl` at
|
|
20
|
+
`assets/mapbox-gl/mapbox-gl-csp-worker.js` before any map is created, and logs an error
|
|
21
|
+
naming this snippet if the asset is not reachable.
|
|
22
|
+
|
|
23
|
+
### Why
|
|
24
|
+
|
|
25
|
+
mapbox-gl builds its web worker by stringifying two of its own functions into a `Blob`.
|
|
26
|
+
Only those function *bodies* are serialized, so anything the bundler hoists to module scope
|
|
27
|
+
is missing inside the worker. `@angular/build` unconditionally disables esbuild's
|
|
28
|
+
`object-rest-spread` support (a V8 performance workaround, still present in Angular 22), which
|
|
29
|
+
rewrites every object spread into exactly such a hoisted helper. From mapbox-gl **3.26.0** on
|
|
30
|
+
there are object spreads in the serialized worker code, so the worker dies while loading tiles:
|
|
31
|
+
|
|
32
|
+
```
|
|
33
|
+
ReferenceError: __spreadValues is not defined at Ie.loadTile
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
(In a production build the helper name is minified, so the same failure reads as
|
|
37
|
+
`ReferenceError: <mangled> is not defined`.)
|
|
38
|
+
|
|
39
|
+
Loading the worker from a real file instead of the generated blob — mapbox's own documented
|
|
40
|
+
`workerUrl` escape hatch — avoids the problem entirely at any mapbox-gl version. Copying the
|
|
41
|
+
asset out of the app's own `node_modules` keeps the worker in version lockstep with the
|
|
42
|
+
`mapbox-gl` the app bundles.
|
|
43
|
+
|
|
44
|
+
### Options
|
|
45
|
+
|
|
46
|
+
`provideDbxMapbox({ worker })` accepts:
|
|
47
|
+
|
|
48
|
+
- `workerUrl` — serve the asset from somewhere other than the default path.
|
|
49
|
+
- `enabled: false` — restore mapbox-gl's stock blob worker. Only safe below mapbox-gl 3.26.0.
|
|
50
|
+
|
|
51
|
+
Note the CSP worker does not support the dynamically loaded RTL text plugin
|
|
52
|
+
(`setRTLTextPlugin`) or `addTileProvider` modules, which rely on a hook the blob worker
|
|
53
|
+
provides. Apps needing those must set `enabled: false` and stay below mapbox-gl 3.26.0.
|
|
54
|
+
|
|
6
55
|
License: MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dereekb/dbx-web",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.42.0",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"*.scss",
|
|
6
6
|
"*.css"
|
|
@@ -13,12 +13,12 @@
|
|
|
13
13
|
"@angular/material": "^21.2.9",
|
|
14
14
|
"@angular/platform-browser": "21.2.11",
|
|
15
15
|
"@cantoo/pdf-lib": "^2.6.5",
|
|
16
|
-
"@dereekb/browser": "13.
|
|
17
|
-
"@dereekb/date": "13.
|
|
18
|
-
"@dereekb/dbx-core": "13.
|
|
19
|
-
"@dereekb/rxjs": "13.
|
|
20
|
-
"@dereekb/util": "13.
|
|
21
|
-
"@dereekb/vitest": "13.
|
|
16
|
+
"@dereekb/browser": "13.42.0",
|
|
17
|
+
"@dereekb/date": "13.42.0",
|
|
18
|
+
"@dereekb/dbx-core": "13.42.0",
|
|
19
|
+
"@dereekb/rxjs": "13.42.0",
|
|
20
|
+
"@dereekb/util": "13.42.0",
|
|
21
|
+
"@dereekb/vitest": "13.42.0",
|
|
22
22
|
"@ngbracket/ngx-layout": "^21.0.0",
|
|
23
23
|
"@ngrx/component-store": "^21.1.0",
|
|
24
24
|
"@ngrx/effects": "^21.1.0",
|
|
@@ -759,16 +759,98 @@ declare class DbxMapboxModule {
|
|
|
759
759
|
static ɵinj: i0.ɵɵInjectorDeclaration<DbxMapboxModule>;
|
|
760
760
|
}
|
|
761
761
|
|
|
762
|
+
/**
|
|
763
|
+
* Relative url the mapbox-gl CSP web worker asset is expected to be served from.
|
|
764
|
+
*
|
|
765
|
+
* The asset itself is copied out of `node_modules/mapbox-gl/dist/mapbox-gl-csp-worker.js`
|
|
766
|
+
* by the consuming app's build configuration, which keeps it in version lockstep with the
|
|
767
|
+
* `mapbox-gl` the app actually bundles.
|
|
768
|
+
*/
|
|
769
|
+
declare const DEFAULT_DBX_MAPBOX_WORKER_URL = "assets/mapbox-gl/mapbox-gl-csp-worker.js";
|
|
770
|
+
/**
|
|
771
|
+
* Configuration for {@link configureDbxMapboxWorker}.
|
|
772
|
+
*/
|
|
773
|
+
interface DbxMapboxWorkerConfig {
|
|
774
|
+
/**
|
|
775
|
+
* Whether or not to load mapbox-gl's web worker from a self-hosted asset instead of the
|
|
776
|
+
* default blob url.
|
|
777
|
+
*
|
|
778
|
+
* True by default. Set to false only to restore mapbox-gl's stock blob worker, which is
|
|
779
|
+
* broken in Angular/esbuild apps on mapbox-gl 3.26.0 and up.
|
|
780
|
+
*/
|
|
781
|
+
readonly enabled?: Maybe<boolean>;
|
|
782
|
+
/**
|
|
783
|
+
* Url the mapbox-gl CSP web worker asset is served from.
|
|
784
|
+
*
|
|
785
|
+
* Defaults to {@link DEFAULT_DBX_MAPBOX_WORKER_URL}.
|
|
786
|
+
*/
|
|
787
|
+
readonly workerUrl?: Maybe<string>;
|
|
788
|
+
}
|
|
789
|
+
/**
|
|
790
|
+
* Result of {@link configureDbxMapboxWorker}.
|
|
791
|
+
*/
|
|
792
|
+
interface DbxMapboxWorkerConfigurationResult {
|
|
793
|
+
/**
|
|
794
|
+
* Whether or not the self-hosted worker was configured on mapbox-gl.
|
|
795
|
+
*/
|
|
796
|
+
readonly configured: boolean;
|
|
797
|
+
/**
|
|
798
|
+
* Url that was configured, if any.
|
|
799
|
+
*/
|
|
800
|
+
readonly workerUrl: Maybe<string>;
|
|
801
|
+
/**
|
|
802
|
+
* Whether or not the configured worker asset could be retrieved.
|
|
803
|
+
*
|
|
804
|
+
* Null when no check was performed.
|
|
805
|
+
*/
|
|
806
|
+
readonly available: Maybe<boolean>;
|
|
807
|
+
}
|
|
808
|
+
/**
|
|
809
|
+
* Checks whether the mapbox-gl web worker asset is actually served from the given url.
|
|
810
|
+
*
|
|
811
|
+
* @param workerUrl - Url the worker asset is expected at.
|
|
812
|
+
* @returns True when the asset responds successfully.
|
|
813
|
+
*/
|
|
814
|
+
declare function isDbxMapboxWorkerAssetAvailable(workerUrl: string): Promise<boolean>;
|
|
815
|
+
/**
|
|
816
|
+
* Configures mapbox-gl to load its web worker from a self-hosted copy of mapbox's prebuilt
|
|
817
|
+
* CSP worker rather than from the blob url it generates itself.
|
|
818
|
+
*
|
|
819
|
+
* mapbox-gl's default worker is built by stringifying two of its own functions into a blob.
|
|
820
|
+
* Only those function bodies are serialized, so any helper the bundler hoists to module
|
|
821
|
+
* scope is missing at runtime. `@angular/build` unconditionally disables esbuild's
|
|
822
|
+
* `object-rest-spread` support, which rewrites every object spread in mapbox-gl 3.26.0+ into
|
|
823
|
+
* exactly such a hoisted helper, and the worker then dies with a `ReferenceError` while
|
|
824
|
+
* loading tiles. Pointing `workerUrl` at a real file — mapbox's own documented CSP escape
|
|
825
|
+
* hatch — sidesteps the bug entirely, at any mapbox-gl version.
|
|
826
|
+
*
|
|
827
|
+
* Must be applied before the first `Map` is constructed.
|
|
828
|
+
*
|
|
829
|
+
* @param inputConfig - Configuration. Optional.
|
|
830
|
+
* @returns The applied configuration.
|
|
831
|
+
*/
|
|
832
|
+
declare function configureDbxMapboxWorker(inputConfig?: Maybe<DbxMapboxWorkerConfig>): Promise<DbxMapboxWorkerConfigurationResult>;
|
|
833
|
+
|
|
762
834
|
/**
|
|
763
835
|
* Configuration for provideDbxMapbox().
|
|
764
836
|
*/
|
|
765
837
|
interface ProvideDbxMapboxConfig {
|
|
766
838
|
readonly dbxMapboxConfig: DbxMapboxConfig;
|
|
767
839
|
readonly ngxMapboxGLModuleConfig: Parameters<typeof provideMapboxGL>[0];
|
|
840
|
+
/**
|
|
841
|
+
* Configuration for the self-hosted mapbox-gl web worker.
|
|
842
|
+
*
|
|
843
|
+
* Enabled by default. See {@link configureDbxMapboxWorker} for why it is needed and
|
|
844
|
+
* which build asset the app must copy.
|
|
845
|
+
*/
|
|
846
|
+
readonly worker?: Maybe<DbxMapboxWorkerConfig>;
|
|
768
847
|
}
|
|
769
848
|
/**
|
|
770
849
|
* Creates EnvironmentProviders for providing DbxMapboxConfig and configuring the NgxMapboxGLModule.
|
|
771
850
|
*
|
|
851
|
+
* Also registers an app initializer that points mapbox-gl at the self-hosted CSP web worker
|
|
852
|
+
* asset before any map is created.
|
|
853
|
+
*
|
|
772
854
|
* @param config - Configuration.
|
|
773
855
|
* @returns EnvironmentProviders.
|
|
774
856
|
*/
|
|
@@ -785,5 +867,5 @@ interface DbxMapboxEnvironmentOptions extends DbxMapboxConfig {
|
|
|
785
867
|
*/
|
|
786
868
|
type DbxMapboxOptions = DbxMapboxEnvironmentOptions;
|
|
787
869
|
|
|
788
|
-
export { DEFAULT_MAPBOX_CENTER, DEFAULT_MAPBOX_LAYOUT_DRAWER_WIDTH, DEFAULT_MAPBOX_MAP_STORE_TIMER_REFRESH_PERIOD, DEFAULT_MAPBOX_STYLE, DEFAULT_MAPBOX_ZOOM, DbxMapboxChangeService, DbxMapboxConfig, DbxMapboxInjectionComponent, DbxMapboxInjectionStore, DbxMapboxInjectionStoreInjectionBlockDirective, DbxMapboxInjectionStoreProviderBlock, DbxMapboxLayoutComponent, DbxMapboxLayoutDrawerComponent, DbxMapboxLayoutVirtualResizeSyncComponent, DbxMapboxMapDirective, DbxMapboxMapStore, DbxMapboxMapStoreInjectionBlockDirective, DbxMapboxMapStoreProviderBlock, DbxMapboxMarkerComponent, DbxMapboxMarkersComponent, DbxMapboxMenuComponent, DbxMapboxModule, DbxMapboxService, KNOWN_MAPBOX_STYLES, MAPBOX_MAX_ZOOM_LEVEL, MAPBOX_MIN_ZOOM_LEVEL, dbxMapboxColoredDotStyle, filterByMapboxViewportBound, mapboxViewportBoundFunction, mapboxZoomLevel, provideDbxMapbox, provideMapboxInjectionStoreIfParentIsUnavailable, provideMapboxStoreIfParentIsUnavailable, updateDbxMapboxMapInjectionStoreStateWithInjectionConfig, updateDbxMapboxMapInjectionStoreStateWithRemovedKey };
|
|
789
|
-
export type { DbxMapboxClickEvent, DbxMapboxEnvironmentOptions, DbxMapboxInjectionConfig, DbxMapboxInjectionKey, DbxMapboxLayoutMode, DbxMapboxLayoutSide, DbxMapboxMapInjectionStoreState, DbxMapboxMarginCalculationSizing, DbxMapboxMarker, DbxMapboxMarkerDisplayConfig, DbxMapboxMarkerFactory, DbxMapboxMarkerPresentation, DbxMapboxMarkerSize, DbxMapboxOptions, DbxMapboxStoreBoundRefreshSettings, DbxMapboxStoreBoundRefreshType, DbxMapboxStoreState, FilterMapboxBoundConfig, FilterMapboxBoundReadItemValueFunction, KnownMapboxStyle, MapboxBearing, MapboxEaseTo, MapboxEaseToOptions, MapboxEaseToPositionOptions, MapboxEventData, MapboxFitBounds, MapboxFitBoundsOptions, MapboxFitPositions, MapboxFlyTo, MapboxFlyToOptions, MapboxFlyToPositionOptions, MapboxJumpTo, MapboxJumpToPositionOptions, MapboxMapLifecycleState, MapboxMapMoveState, MapboxMapRotateState, MapboxMapZoomState, MapboxPitch, MapboxResetNorth, MapboxResetNorthPitch, MapboxRotateTo, MapboxSetStyleOptions, MapboxSnapToNorth, MapboxStyleConfig, MapboxTileSize, MapboxViewportBoundFunction, MapboxViewportBoundFunctionConfig, MapboxViewportBoundFunctionInput, MapboxViewportBoundFunctionItem, MapboxViewportBoundFunctionItemValue, MapboxZoomLevel, MapboxZoomLevelRange, ProvideDbxMapboxConfig, StringMapboxListenerPair, TypedMapboxListenerPair };
|
|
870
|
+
export { DEFAULT_DBX_MAPBOX_WORKER_URL, DEFAULT_MAPBOX_CENTER, DEFAULT_MAPBOX_LAYOUT_DRAWER_WIDTH, DEFAULT_MAPBOX_MAP_STORE_TIMER_REFRESH_PERIOD, DEFAULT_MAPBOX_STYLE, DEFAULT_MAPBOX_ZOOM, DbxMapboxChangeService, DbxMapboxConfig, DbxMapboxInjectionComponent, DbxMapboxInjectionStore, DbxMapboxInjectionStoreInjectionBlockDirective, DbxMapboxInjectionStoreProviderBlock, DbxMapboxLayoutComponent, DbxMapboxLayoutDrawerComponent, DbxMapboxLayoutVirtualResizeSyncComponent, DbxMapboxMapDirective, DbxMapboxMapStore, DbxMapboxMapStoreInjectionBlockDirective, DbxMapboxMapStoreProviderBlock, DbxMapboxMarkerComponent, DbxMapboxMarkersComponent, DbxMapboxMenuComponent, DbxMapboxModule, DbxMapboxService, KNOWN_MAPBOX_STYLES, MAPBOX_MAX_ZOOM_LEVEL, MAPBOX_MIN_ZOOM_LEVEL, configureDbxMapboxWorker, dbxMapboxColoredDotStyle, filterByMapboxViewportBound, isDbxMapboxWorkerAssetAvailable, mapboxViewportBoundFunction, mapboxZoomLevel, provideDbxMapbox, provideMapboxInjectionStoreIfParentIsUnavailable, provideMapboxStoreIfParentIsUnavailable, updateDbxMapboxMapInjectionStoreStateWithInjectionConfig, updateDbxMapboxMapInjectionStoreStateWithRemovedKey };
|
|
871
|
+
export type { DbxMapboxClickEvent, DbxMapboxEnvironmentOptions, DbxMapboxInjectionConfig, DbxMapboxInjectionKey, DbxMapboxLayoutMode, DbxMapboxLayoutSide, DbxMapboxMapInjectionStoreState, DbxMapboxMarginCalculationSizing, DbxMapboxMarker, DbxMapboxMarkerDisplayConfig, DbxMapboxMarkerFactory, DbxMapboxMarkerPresentation, DbxMapboxMarkerSize, DbxMapboxOptions, DbxMapboxStoreBoundRefreshSettings, DbxMapboxStoreBoundRefreshType, DbxMapboxStoreState, DbxMapboxWorkerConfig, DbxMapboxWorkerConfigurationResult, FilterMapboxBoundConfig, FilterMapboxBoundReadItemValueFunction, KnownMapboxStyle, MapboxBearing, MapboxEaseTo, MapboxEaseToOptions, MapboxEaseToPositionOptions, MapboxEventData, MapboxFitBounds, MapboxFitBoundsOptions, MapboxFitPositions, MapboxFlyTo, MapboxFlyToOptions, MapboxFlyToPositionOptions, MapboxJumpTo, MapboxJumpToPositionOptions, MapboxMapLifecycleState, MapboxMapMoveState, MapboxMapRotateState, MapboxMapZoomState, MapboxPitch, MapboxResetNorth, MapboxResetNorthPitch, MapboxRotateTo, MapboxSetStyleOptions, MapboxSnapToNorth, MapboxStyleConfig, MapboxTileSize, MapboxViewportBoundFunction, MapboxViewportBoundFunctionConfig, MapboxViewportBoundFunctionInput, MapboxViewportBoundFunctionItem, MapboxViewportBoundFunctionItemValue, MapboxZoomLevel, MapboxZoomLevelRange, ProvideDbxMapboxConfig, StringMapboxListenerPair, TypedMapboxListenerPair };
|