@mapcreator/sdk 0.0.0-fonts.0 → 0.0.0-fonts.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/dist/MCMap.d.ts CHANGED
@@ -13,7 +13,7 @@ type VideoEvent = {
13
13
  export declare class MCMap extends Evented {
14
14
  map: MapLibre;
15
15
  private video;
16
- constructor(map: MapLibre, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo);
16
+ constructor(map: MapLibre, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo, backgroundColor: string);
17
17
  on<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): import('@mapcreator/maplibre-gl').Subscription;
18
18
  once<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): Promise<any> | this;
19
19
  off<T extends keyof SdkEventType>(type: T, listener: (e: SdkEventType[T]) => void): this;
package/dist/Video.d.ts CHANGED
@@ -13,9 +13,10 @@ export declare class Video {
13
13
  private mapstyle;
14
14
  private overlays;
15
15
  private layerInfo;
16
+ private backgroundColor;
16
17
  private playhead;
17
18
  private playbackContext;
18
- constructor(mcMap: MCMap, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo);
19
+ constructor(mcMap: MCMap, jobObject: JobObject, svgs: Svgs, svgCache: SvgCache, mapstyle: StyleSpecification, overlays: Map<number, StyleSpecification>, layerInfo: LayerInfo, backgroundColor: string);
19
20
  play(): void;
20
21
  pause(): void;
21
22
  seekTo(time: number): void;
@@ -1,5 +1,5 @@
1
- import { Map } from '@mapcreator/maplibre-gl';
2
1
  import { JobObjectInsetMap } from '../types/jobObject';
2
+ import { Map } from '@mapcreator/maplibre-gl';
3
3
  export declare function useInsetMap(insetMap: JobObjectInsetMap, map: Map, cdnUrl: string, mapScale: number): {
4
4
  element: HTMLElement;
5
5
  ready: Promise<void>;
@@ -33086,7 +33086,7 @@ function zr(e, t) {
33086
33086
  try {
33087
33087
  i.forEach((e) => {
33088
33088
  let r = window.getComputedStyle(e);
33089
- r.fontFamily.split(",").map((e) => M(e)).forEach((e) => {
33089
+ r.fontFamily.split(",").map(M).forEach((e) => {
33090
33090
  let i = t.get(Or(e, r.fontWeight, r.fontStyle));
33091
33091
  i !== void 0 && n.set(i.name, i);
33092
33092
  });
@@ -38099,30 +38099,36 @@ function $c(e, t, n, r) {
38099
38099
  dotOutlineColor: e.dotOutlineColor ?? "#000000",
38100
38100
  mapScale: r,
38101
38101
  globeFallbackActive: !1,
38102
- globeGeoJsonRequested: !1,
38103
38102
  globeGeoJson: void 0
38104
- }, c = fetch(`${n}/data/insetmaps/${e.fileName}`).then((e) => e.json()).then((e) => {
38105
- s.geoJson = ca(e, Object.keys(e.objects)[0]), el(s);
38103
+ }, c = [fetch(`${n}/data/insetmaps/${e.fileName}`).then((e) => e.json()).then((e) => {
38104
+ s.geoJson = ca(e, Object.keys(e.objects)[0]);
38105
+ })];
38106
+ if (!e.isGlobe) {
38107
+ let e = fetch(`${n}/data/insetmaps/world-110m.json`).then((e) => e.json()).then((e) => {
38108
+ s.globeGeoJson = ca(e, Object.keys(e.objects)[0]);
38109
+ });
38110
+ c.push(e);
38111
+ }
38112
+ let l = Promise.all(c).then(() => {
38113
+ el(s);
38106
38114
  });
38107
38115
  return t.on("moveend", () => {
38108
38116
  s.moveEndPosition = t.getCenter(), (s.isGlobe || s.globeFallbackActive) && el(s);
38109
38117
  }), t.on("move", () => {
38110
38118
  if (!s.isGlobe) {
38111
- let [e, r, i, a] = s.boundingBox, o = rl(t), c = uo(Rn([o, In([[
38112
- [e, r],
38113
- [e, a],
38114
- [i, a],
38115
- [i, r],
38116
- [e, r]
38117
- ]])])), l = ea(o), u = (c ? ea(c) : 0) < l * .75;
38118
- s.globeFallbackActive !== u && (s.globeFallbackActive = u, s.moveEndPosition = t.getCenter(), el(s)), s.globeFallbackActive && !s.globeGeoJsonRequested && (s.globeGeoJsonRequested = !0, fetch(`${n}/data/insetmaps/world-110m.json`).then((e) => e.json()).then((e) => {
38119
- s.globeGeoJson = ca(e, Object.keys(e.objects)[0]), s.moveEndPosition = t.getCenter(), el(s);
38120
- }));
38119
+ let [e, n, r, i] = s.boundingBox, a = rl(t), o = uo(Rn([a, In([[
38120
+ [e, n],
38121
+ [e, i],
38122
+ [r, i],
38123
+ [r, n],
38124
+ [e, n]
38125
+ ]])])), c = ea(a), l = (o ? ea(o) : 0) < c * .75;
38126
+ s.globeFallbackActive !== l && (s.globeFallbackActive = l, s.moveEndPosition = t.getCenter(), el(s));
38121
38127
  }
38122
38128
  nl(s);
38123
38129
  }), {
38124
38130
  element: i,
38125
- ready: c
38131
+ ready: l
38126
38132
  };
38127
38133
  }
38128
38134
  function el(e) {
@@ -40216,11 +40222,12 @@ var zu = class {
40216
40222
  mapstyle;
40217
40223
  overlays;
40218
40224
  layerInfo;
40225
+ backgroundColor;
40219
40226
  playhead;
40220
40227
  playbackContext;
40221
- constructor(e, t, n, r, i, a, o) {
40228
+ constructor(e, t, n, r, i, a, o, s) {
40222
40229
  this.mcMap = e, this.playhead = 0, this.playbackContext = void 0;
40223
- let s = (t.video?.keyframes ?? []).map((e) => {
40230
+ let c = (t.video?.keyframes ?? []).map((e) => {
40224
40231
  let { x: t, y: n } = l.MercatorCoordinate.fromLngLat(e.center);
40225
40232
  return {
40226
40233
  ...e,
@@ -40230,7 +40237,7 @@ var zu = class {
40230
40237
  elevation: e.elevation ?? 0
40231
40238
  };
40232
40239
  });
40233
- this.duration = gu(s), this.cameraCurve = new Iu(s), this.jobObject = t, this.svgs = n, this.svgCache = r, this.mapstyle = i, this.overlays = a, this.layerInfo = o;
40240
+ this.duration = gu(c), this.cameraCurve = new Iu(c), this.jobObject = t, this.svgs = n, this.svgCache = r, this.mapstyle = i, this.overlays = a, this.layerInfo = o, this.backgroundColor = s;
40234
40241
  }
40235
40242
  play() {
40236
40243
  this.playbackContext === void 0 && this.duration > 0 && (this.playhead >= this.duration && (this.playhead = 0), this.playbackContext = {
@@ -40261,13 +40268,13 @@ var zu = class {
40261
40268
  e._fadeDuration = 300, e.style.stylesheet.transition = void 0, e.setCenterClampedToGround(!0);
40262
40269
  }
40263
40270
  async captureFrame(e, t, n, r, i, a, o) {
40264
- return this.setCamera(e), await this.mcMap.map.once("idle"), n.fillStyle = this.mcMap.map.getContainer().style.backgroundColor, n.fillRect(0, 0, r, i), n.drawImage(t, 0, 0), await this.drawAdornments(n, a, o), n.getImageData(0, 0, r, i);
40271
+ return this.setCamera(e), await this.mcMap.map.once("idle"), n.fillStyle = this.backgroundColor, n.fillRect(0, 0, r, i), n.drawImage(t, 0, 0), await this.drawAdornments(n, a, o), n.getImageData(0, 0, r, i);
40265
40272
  }
40266
40273
  async drawAdornments(e, t, n) {
40267
40274
  let r = t.querySelectorAll(".adornment-svg"), i = await Promise.all(Array.from(r).map(async (e) => {
40268
- let t = e.outerHTML, r = e.getBoundingClientRect(), i = r.left - n.left, a = r.top - n.top, o = r.width, s = r.height;
40275
+ let t = e.outerHTML, r = e.getBoundingClientRect(), i = r.left - n.left, a = r.top - n.top, o = r.width, s = r.height, { fontMap: c, vapiUrl: l, accessToken: u } = this.svgCache;
40269
40276
  return {
40270
- image: await jr(t, o, s, this.svgCache.fontMap, this.svgCache.vapiUrl, this.svgCache.accessToken),
40277
+ image: await jr(t, o, s, c, l, u),
40271
40278
  x: i,
40272
40279
  y: a
40273
40280
  };
@@ -40411,8 +40418,8 @@ var zu = class {
40411
40418
  }, Bu = class extends l.Evented {
40412
40419
  map;
40413
40420
  video;
40414
- constructor(e, t, n, r, i, a, o) {
40415
- super(), this.map = e, this.video = new zu(this, t, n, r, i, a, o);
40421
+ constructor(e, t, n, r, i, a, o, s) {
40422
+ super(), this.map = e, this.video = new zu(this, t, n, r, i, a, o, s);
40416
40423
  }
40417
40424
  on(e, t) {
40418
40425
  return super.on(e, t);
@@ -40477,11 +40484,13 @@ async function Vu(e) {
40477
40484
  e && (s.boxZoom.disable(), s.doubleClickZoom.disable(), s.dragPan.disable(), s.dragRotate.disable(), s.keyboard.disable(), s.scrollZoom.disable(), s.touchPitch.disable(), s.touchZoomRotate.disable()), d.setParams(t, m(p, f.TWO), e, v);
40478
40485
  }
40479
40486
  let ee = await fetch(`${i}/styles/${o.meta.mapstyleSet}.json?access_token=${t}`).then((e) => e.json());
40480
- s.setStyle(null), s.setStyle(ee), await s.once("style.load"), n === "app" && Ku(s.getStyle().metadata?.customCssFilePath, t), u(p, s);
40487
+ s.setStyle(null), s.setStyle(ee), await s.once("style.load"), n === "app" && qu(s.getStyle().metadata?.customCssFilePath, t), u(p, s);
40481
40488
  let I = await Ol(o.map.overlays ?? [], o.meta.layers ?? [], s, i, t, ee.metadata?.styleOverride), te = (o.map.overlays ?? []).reduce((e, t, n) => e.set(t, I[n]), /* @__PURE__ */ new Map());
40482
- Yu(s, j, O, k, A, i, t), u(p, s), d.setPublication(ee.metadata?.publication), d.setpopupElements(), d.setHighlightManager(), s.setProjection({ type: x === "globe" ? "globe" : "mercator" }), Wu(s, x), S && Gu(s, i, t, C);
40483
- let ne = qu(o.map.layerInfo, ee, I);
40484
- return Ju(s, ne, !y), new Bu(s, o, A, j, ee, te, ne);
40489
+ Xu(s, j, O, k, A, i, t), u(p, s), d.setPublication(ee.metadata?.publication), d.setpopupElements(), d.setHighlightManager(), s.setProjection({ type: x === "globe" ? "globe" : "mercator" });
40490
+ let ne = Wu(s, x);
40491
+ Gu(s, ne), S && Ku(s, i, t, C);
40492
+ let re = Ju(o.map.layerInfo, ee, I);
40493
+ return Yu(s, re, !y), new Bu(s, o, A, j, ee, te, re, ne);
40485
40494
  }
40486
40495
  function Hu(e, t, n) {
40487
40496
  return fetch(`${t}/jobs/${e}.json?access_token=${n}`).then((e) => e.json());
@@ -40496,13 +40505,16 @@ function Uu() {
40496
40505
  }
40497
40506
  function Wu(e, t) {
40498
40507
  let n = e.getStyle().metadata ?? {}, r = n["mc:background-color"] ?? "#f8f8f8", i = n["mc:background-color-globe"] ?? "#000000";
40499
- e.getContainer().style.backgroundColor = t === "globe" ? i : r, e.setSky(e.getStyle().sky ?? h), e.setLight({ position: [
40508
+ return t === "globe" ? i : r;
40509
+ }
40510
+ function Gu(e, t) {
40511
+ e.getContainer().style.backgroundColor = t, e.setSky(e.getStyle().sky ?? h), e.setLight({ position: [
40500
40512
  1.15,
40501
40513
  210,
40502
40514
  45
40503
40515
  ] });
40504
40516
  }
40505
- function Gu(e, t, n, r) {
40517
+ function Ku(e, t, n, r) {
40506
40518
  e.addSource("mc-dem", {
40507
40519
  type: "raster-dem",
40508
40520
  tiles: [`${t}/dataset/jaxa_terrainrgb/{z}/{x}/{y}?access_token=${n}`],
@@ -40514,33 +40526,33 @@ function Gu(e, t, n, r) {
40514
40526
  exaggeration: r
40515
40527
  });
40516
40528
  }
40517
- function Ku(e, t) {
40529
+ function qu(e, t) {
40518
40530
  if (document.getElementById("custom-style")?.remove(), !e) return;
40519
40531
  let n;
40520
40532
  e.startsWith("http") ? (e = `${e}?access_token=${t}`, n = document.createElement("link"), n.setAttribute("rel", "stylesheet"), n.setAttribute("href", e.replace(/https?:/, ""))) : (n = document.createElement("style"), n.appendChild(document.createTextNode(e))), n.setAttribute("id", "custom-style"), n.setAttribute("type", "text/css"), document.head.appendChild(n);
40521
40533
  }
40522
- function qu(e, t, n) {
40534
+ function Ju(e, t, n) {
40523
40535
  let r = e?.reduce((e, t) => (e[t.id] = { visibility: t.visibility }, e), {}) ?? {}, i = {};
40524
40536
  for (let e of t.layers) i[e.id] = r[e.id] ?? { visibility: (e.layout?.visibility ?? "visible") === "visible" };
40525
40537
  for (let e of n) for (let t of e.layers) i[t.id] = r[t.id] ?? { visibility: !1 };
40526
40538
  return i;
40527
40539
  }
40528
- function Ju(e, t, n) {
40540
+ function Yu(e, t, n) {
40529
40541
  for (let r in t) e.getLayer(r) !== void 0 && e.setLayoutProperty(r, "visibility", t[r].visibility && n ? "visible" : "none");
40530
40542
  }
40531
- function Yu(e, t, n, r, i, a, o) {
40543
+ function Xu(e, t, n, r, i, a, o) {
40532
40544
  let { beforeNone: s = [], beforeNames: c = [], beforeBoundaries: l = [], beforeWaters: u = [] } = r;
40533
40545
  s.forEach((r) => {
40534
- Xu(e, t, n, r, i, "mc-before-none", a, o);
40546
+ Zu(e, t, n, r, i, "mc-before-none", a, o);
40535
40547
  }), c.forEach((r) => {
40536
- Xu(e, t, n, r, i, "mc-before-names", a, o);
40548
+ Zu(e, t, n, r, i, "mc-before-names", a, o);
40537
40549
  }), l.forEach((r) => {
40538
- Xu(e, t, n, r, i, "mc-before-boundaries", a, o);
40550
+ Zu(e, t, n, r, i, "mc-before-boundaries", a, o);
40539
40551
  }), u.forEach((r) => {
40540
- Xu(e, t, n, r, i, "mc-before-waters", a, o);
40552
+ Zu(e, t, n, r, i, "mc-before-waters", a, o);
40541
40553
  });
40542
40554
  }
40543
- function Xu(e, t, n, r, i, a, o, s) {
40555
+ function Zu(e, t, n, r, i, a, o, s) {
40544
40556
  if (r.type === "marker") {
40545
40557
  let o = n.marker?.find((e) => e.id === r.groupId);
40546
40558
  o && Tl(e, o, a, i, t);
@@ -40562,5 +40574,5 @@ function Xu(e, t, n, r, i, a, o, s) {
40562
40574
  }
40563
40575
  }
40564
40576
  //#endregion
40565
- var Zu = l.setRTLTextPlugin;
40566
- export { Vu as initMap, Zu as setRTLTextPlugin };
40577
+ var Qu = l.setRTLTextPlugin;
40578
+ export { Vu as initMap, Qu as setRTLTextPlugin };