@rise-x/apps-sdk 0.15.1 → 0.16.1

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/README.md CHANGED
@@ -761,8 +761,11 @@ Requirements in the app:
761
761
 
762
762
  2. Federated, components render from the shell's copy. The preset's standalone
763
763
  branch aliases `@rise-x/ui` to the SDK's own
764
- compiled bundle (`./ui/standalone`) instead — a self-contained snapshot
765
- with its CSS self-injected, so components render for real with no shell.
764
+ compiled bundle (`./ui/standalone`) instead: a snapshot with its CSS
765
+ self-injected, so components render for real with no shell. `MapView`'s
766
+ libraries (`leaflet`, `maplibre-gl`, and `@maplibre/maplibre-gl-leaflet`)
767
+ aren't in it. They install as dependencies of the SDK, and your app's
768
+ bundler loads each one in its own chunk when a map needs it.
766
769
  It's a snapshot, not the source of truth: verify in a host (or deployed)
767
770
  before release.
768
771
 
@@ -771,7 +774,9 @@ Requirements in the app:
771
774
  The one component with a real library behind it. It renders a Leaflet basemap
772
775
  and nothing else — markers, routes and heat layers are yours to add. Leaflet is
773
776
  fetched in its own chunk on first mount, so apps that never show a map pay
774
- nothing for it.
777
+ nothing for it. The `light` and `dark` presets are OpenFreeMap vector styles
778
+ drawn by MapLibre GL, which arrives in a second chunk only when one of them is
779
+ shown.
775
780
 
776
781
  `onReady` hands back the map **and the Leaflet module it was built from**. Build
777
782
  layers off that `L`: the app then needs no `leaflet` dependency of its own, and
@@ -801,17 +806,36 @@ import { MapView, mapPin } from '@rise-x/apps-sdk/ui';
801
806
  ```
802
807
 
803
808
  `tiles` also takes a preset (`'light'`, `'dark'`, `'streets'`, `'satellite'`), a
804
- custom tile layer, or `null` for no basemap at all.
809
+ custom raster layer (`{ url, ...TileLayerOptions }`), a MapLibre style
810
+ (`{ style }`), or `null` for no basemap at all.
805
811
 
806
- The built-in presets load tile images from third-party hosts, so the host
807
- page's CSP `img-src` must allow `https://*.basemaps.cartocdn.com`,
812
+ OpenStreetMap blocks tile requests that carry no `Referer`, and a host page
813
+ whose `Referrer-Policy` is `same-origin` or `no-referrer` strips it. The
814
+ `streets` preset sets `referrerPolicy: 'strict-origin-when-cross-origin'` for
815
+ this. Pass the same option to any OpenStreetMap layer you add yourself:
816
+
817
+ ```tsx
818
+ L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png', {
819
+ referrerPolicy: 'strict-origin-when-cross-origin',
820
+ attribution: '© OpenStreetMap',
821
+ }).addTo(map);
822
+ ```
823
+
824
+ The built-in presets fetch from third-party hosts, so the host page's CSP must
825
+ allow them: `light` and `dark` need `connect-src https://tiles.openfreemap.org`
826
+ and `worker-src blob:` (MapLibre renders in a web worker); `streets` and
827
+ `satellite` load tile images, so `img-src` must allow
808
828
  `https://tile.openstreetmap.org` and `https://server.arcgisonline.com`. The
809
829
  host page's CSP controls this, so an app can't lift a block from its own
810
- code. The Rise-X shell already allows the built-in preset hosts; for any
811
- other host, ask Rise-X to add it. If no tile loads,
830
+ code. The Rise-X shell's allow-list carries the built-in preset hosts; for
831
+ any other host, ask Rise-X to add it. If no tile of a raster layer loads,
812
832
  `MapView` warns once and removes the layer so Leaflet stops re-requesting
813
833
  blocked tiles on every pan and zoom — use `tiles={null}` or a custom
814
- `MapTileSpec` on a permitted origin instead. `mapPin()` has no `aria-label` of
834
+ `MapTileSpec` on a permitted origin instead. A vector style that fails to
835
+ load is handled the same way: `MapView` warns with the style's origin and
836
+ removes the layer. A vector style also needs WebGL2;
837
+ on a browser without it `MapView` warns and renders as `tiles={null}`, so pick
838
+ a raster preset where that is a possibility. `mapPin()` has no `aria-label` of
815
839
  its own; set one via `marker.getElement()` after `addTo(map)` if the marker
816
840
  needs an accessible name (see the JSDoc on `mapPin`).
817
841
 
@@ -163,6 +163,14 @@ function defineAppConfig({ pkg, port, standalone = false, exposes, define, }) {
163
163
  'react-dom': (0, node_path_1.dirname)(appRequire.resolve('react-dom/package.json')),
164
164
  },
165
165
  },
166
+ tools: {
167
+ ...base.tools,
168
+ rspack: {
169
+ // MapLibre's worker-URL helper trips this on every build, and Rsbuild
170
+ // prints its whole minified line; MapView sets the worker itself.
171
+ ignoreWarnings: [{ module: /[/\\]maplibre-gl[/\\]/, message: /Critical dependency/ }],
172
+ },
173
+ },
166
174
  };
167
175
  }
168
176
  return {
@@ -1,8 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import type { DivIconOptions, LatLngBoundsExpression, LatLngExpression, Map as LeafletMap, MapOptions, TileLayerOptions } from 'leaflet';
3
3
  type MapTilePreset = 'light' | 'dark' | 'streets' | 'satellite';
4
- type MapTileSpec = TileLayerOptions & {
4
+ type MapTileSpec = (TileLayerOptions & {
5
5
  url: string;
6
+ }) | {
7
+ style: string;
8
+ maxZoom?: number;
6
9
  };
7
10
  declare const MAP_TILES: Record<MapTilePreset, MapTileSpec>;
8
11
  type MapPinTone = 'default' | 'brand' | 'success' | 'warning' | 'error' | 'info';
@@ -11030,21 +11030,7 @@ CSS.
11030
11030
  tabindex="0"
11031
11031
  >
11032
11032
  <div class="leaflet-pane leaflet-map-pane" style="left: 0px; top: 0px">
11033
- <div class="leaflet-pane leaflet-tile-pane">
11034
- <div class="leaflet-layer" style="z-index: 1">
11035
- <div
11036
- class="leaflet-tile-container leaflet-zoom-animated"
11037
- style="z-index: 20; left: 0px; top: 0px"
11038
- >
11039
- <img
11040
- alt=""
11041
- src="https://d.basemaps.cartocdn.com/light_all/9/262/169.png"
11042
- class="leaflet-tile"
11043
- style="width: 256px; height: 256px; left: -94px; top: -76px"
11044
- />
11045
- </div>
11046
- </div>
11047
- </div>
11033
+ <div class="leaflet-pane leaflet-tile-pane"></div>
11048
11034
  <div class="leaflet-pane leaflet-overlay-pane"></div>
11049
11035
  <div class="leaflet-pane leaflet-shadow-pane"></div>
11050
11036
  <div class="leaflet-pane leaflet-marker-pane"></div>
@@ -11094,7 +11080,6 @@ CSS.
11094
11080
  </svg>
11095
11081
  Leaflet</a
11096
11082
  >
11097
- <span aria-hidden="true">|</span> © OpenStreetMap, © CARTO
11098
11083
  </div>
11099
11084
  </div>
11100
11085
  </div>
@@ -11123,21 +11108,7 @@ CSS.
11123
11108
  style="position: relative"
11124
11109
  >
11125
11110
  <div class="leaflet-pane leaflet-map-pane" style="left: 0px; top: 0px">
11126
- <div class="leaflet-pane leaflet-tile-pane">
11127
- <div class="leaflet-layer" style="z-index: 1">
11128
- <div
11129
- class="leaflet-tile-container leaflet-zoom-animated"
11130
- style="z-index: 20; left: 0px; top: 0px"
11131
- >
11132
- <img
11133
- alt=""
11134
- src="https://a.basemaps.cartocdn.com/light_all/12/2098/1354.png"
11135
- class="leaflet-tile"
11136
- style="width: 256px; height: 256px; left: -242px; top: -94px"
11137
- />
11138
- </div>
11139
- </div>
11140
- </div>
11111
+ <div class="leaflet-pane leaflet-tile-pane"></div>
11141
11112
  <div class="leaflet-pane leaflet-overlay-pane"></div>
11142
11113
  <div class="leaflet-pane leaflet-shadow-pane"></div>
11143
11114
  <div class="leaflet-pane leaflet-marker-pane"></div>
@@ -11167,7 +11138,6 @@ CSS.
11167
11138
  </svg>
11168
11139
  Leaflet</a
11169
11140
  >
11170
- <span aria-hidden="true">|</span> © OpenStreetMap, © CARTO
11171
11141
  </div>
11172
11142
  </div>
11173
11143
  </div>
@@ -11195,21 +11165,7 @@ CSS.
11195
11165
  tabindex="0"
11196
11166
  >
11197
11167
  <div class="leaflet-pane leaflet-map-pane" style="left: 0px; top: 0px">
11198
- <div class="leaflet-pane leaflet-tile-pane">
11199
- <div class="leaflet-layer" style="z-index: 1">
11200
- <div
11201
- class="leaflet-tile-container leaflet-zoom-animated"
11202
- style="z-index: 20; left: 0px; top: 0px"
11203
- >
11204
- <img
11205
- alt=""
11206
- src="https://c.basemaps.cartocdn.com/light_all/10/524/338.png"
11207
- class="leaflet-tile"
11208
- style="width: 256px; height: 256px; left: -184px; top: -142px"
11209
- />
11210
- </div>
11211
- </div>
11212
- </div>
11168
+ <div class="leaflet-pane leaflet-tile-pane"></div>
11213
11169
  <div class="leaflet-pane leaflet-overlay-pane"></div>
11214
11170
  <div class="leaflet-pane leaflet-shadow-pane"></div>
11215
11171
  <div class="leaflet-pane leaflet-marker-pane">
@@ -11339,7 +11295,6 @@ CSS.
11339
11295
  </svg>
11340
11296
  Leaflet</a
11341
11297
  >
11342
- <span aria-hidden="true">|</span> © OpenStreetMap, © CARTO
11343
11298
  </div>
11344
11299
  </div>
11345
11300
  </div>