@mapcreator/sdk 3.0.0 → 3.1.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/Image.d.ts +13 -0
- package/dist/MCMap.d.ts +66 -3
- package/dist/Video.d.ts +3 -9
- package/dist/adornments/categoricalLegend.d.ts +2 -1
- package/dist/adornments/connectedLegend.d.ts +3 -2
- package/dist/adornments/copyright.d.ts +6 -2
- package/dist/adornments/heading.d.ts +2 -1
- package/dist/adornments/manualLegend.d.ts +2 -1
- package/dist/adornments/scalebar.d.ts +2 -1
- package/dist/constants/index.d.ts +1 -0
- package/dist/mapcreator-sdk.bundler.mjs +1742 -1319
- package/dist/mapcreator-sdk.css +1 -1
- package/dist/mapcreator-sdk.mjs +257 -254
- package/dist/models/line.d.ts +2 -1
- package/dist/renderAdornments.d.ts +2 -2
- package/dist/types/index.d.ts +0 -6
- package/dist/utils/fonts.d.ts +47 -3
- package/dist/utils/geoTiff.d.ts +13 -0
- package/dist/utils/helpers.d.ts +4 -2
- package/dist/utils/labelFreeAreas.d.ts +3 -0
- package/dist/utils/pdfFonts.d.ts +22 -0
- package/dist/utils/svg2pdf.d.ts +21 -0
- package/dist/utils/svgHelpers.d.ts +25 -9
- package/package.json +1 -1
package/dist/models/line.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { SvgCache } from '../utils/svgHelpers';
|
|
2
2
|
import { JobObjectLine, JobObjectLineGroup } from '../types/jobObject';
|
|
3
3
|
import { Map } from '@mapcreator/maplibre-gl';
|
|
4
|
+
import { ExportType } from '../types';
|
|
4
5
|
import { Feature } from 'geojson';
|
|
5
|
-
export declare function addLineGroup(map: Map, group: JobObjectLineGroup, beforeId: string, svgCache: SvgCache): void;
|
|
6
|
+
export declare function addLineGroup(map: Map, group: JobObjectLineGroup, beforeId: string, svgCache: SvgCache, exportType: ExportType): void;
|
|
6
7
|
export declare function buildLineFeature(map: Map, group: JobObjectLineGroup, line: JobObjectLine, trimEnd: number, svgCache: SvgCache): Feature;
|
|
@@ -2,5 +2,5 @@ import { Map as MapLibre } from '@mapcreator/maplibre-gl';
|
|
|
2
2
|
import { InitialPositionInfo, ExportType } from './types';
|
|
3
3
|
import { SvgCache } from './utils/svgHelpers';
|
|
4
4
|
import { PositionOffsets, JobObject } from './types/jobObject';
|
|
5
|
-
export declare
|
|
6
|
-
export declare function
|
|
5
|
+
export declare const removeAdornmentContainers: (map: MapLibre) => boolean;
|
|
6
|
+
export declare function useRenderAdornments(jobObject: JobObject, positionOffsets: PositionOffsets, map: MapLibre, svgCache: SvgCache, initialPosition: InitialPositionInfo, cdnUrl: string, exportType: ExportType): Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
package/dist/utils/fonts.d.ts
CHANGED
|
@@ -1,5 +1,49 @@
|
|
|
1
|
-
import { Env
|
|
2
|
-
export
|
|
1
|
+
import { Env } from '../types';
|
|
2
|
+
export type Font = {
|
|
3
|
+
name: string;
|
|
4
|
+
family: string;
|
|
5
|
+
weight: string;
|
|
6
|
+
style: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Registry fields stay raw.
|
|
10
|
+
* Rendering uses this separately serialized CSS value.
|
|
11
|
+
*/
|
|
12
|
+
export type ResolvedFont = Font & {
|
|
13
|
+
cssFamily: string;
|
|
14
|
+
};
|
|
15
|
+
/** Font resources and loaded faces belong to one map's organization. */
|
|
16
|
+
export declare class Fonts {
|
|
17
|
+
private vapiUrl;
|
|
18
|
+
private accessToken;
|
|
19
|
+
private cache;
|
|
20
|
+
private directFonts;
|
|
21
|
+
private registrations;
|
|
22
|
+
readonly fontMap: Map<string, Font>;
|
|
23
|
+
usedFontsCache: Map<string, Font[]>;
|
|
24
|
+
fontInjectedSvgCache: Map<string, string>;
|
|
25
|
+
constructor(fontMap: Map<string, Font>, vapiUrl: string, accessToken: string);
|
|
26
|
+
resolve(name: string, weight?: string): ResolvedFont;
|
|
27
|
+
loadFont(name: string): Promise<string | undefined>;
|
|
28
|
+
loadReference(name: string, weight?: string): Promise<void>;
|
|
29
|
+
getDirectFont(name: string): Font | undefined;
|
|
30
|
+
}
|
|
3
31
|
export declare function loadFontFaces(env: Env, vapiUrl: string, accessToken: string): Promise<Map<string, Font>>;
|
|
32
|
+
/**
|
|
33
|
+
* Serialize one literal family name as a CSS string (not a fallback list).
|
|
34
|
+
*/
|
|
35
|
+
export declare function cssFontFamily(name: string): string;
|
|
36
|
+
/**
|
|
37
|
+
* Quote named families individually, preserving quoted names and generic keywords.
|
|
38
|
+
*/
|
|
39
|
+
export declare function cssFontFamilies(value: string): string;
|
|
40
|
+
/**
|
|
41
|
+
* Decode CSS family-list syntax before resource/API lookup.
|
|
42
|
+
*/
|
|
43
|
+
export declare function parseFontFamilies(value: string): Array<{
|
|
44
|
+
name: string;
|
|
45
|
+
generic: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
export declare function matchFontFace(faces: Iterable<Font>, family: string, weight: string | number, style?: string): Font | undefined;
|
|
48
|
+
export declare function fontAttrs(font: ResolvedFont): string;
|
|
4
49
|
export declare function fontKey(family: string, weight: string, style: string): string;
|
|
5
|
-
export declare function fallbackFont(font: string): string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Map } from '@mapcreator/maplibre-gl';
|
|
2
|
+
export declare function geoTiffMetadata(map: Map, { width, height }: {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
}): {
|
|
6
|
+
width: number;
|
|
7
|
+
height: number;
|
|
8
|
+
GTRasterTypeGeoKey: number;
|
|
9
|
+
PhotometricInterpretation: number;
|
|
10
|
+
ProjectedCSTypeGeoKey: number;
|
|
11
|
+
ModelTiepoint: number[];
|
|
12
|
+
ModelPixelScale: never[];
|
|
13
|
+
};
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { JobObject, JobObjectDataBindings, JobObjectStoredValue } from '../types/jobObject';
|
|
2
1
|
import { Map } from '@mapcreator/maplibre-gl';
|
|
3
2
|
import { LngLat } from '../types/geometry';
|
|
4
3
|
import { ExportType } from '../types';
|
|
4
|
+
import { JobObject, JobObjectDataBindings, JobObjectFormat, JobObjectStoredValue } from '../types/jobObject';
|
|
5
5
|
export declare const numberRe: RegExp;
|
|
6
6
|
export declare function degToRad(angle: number): number;
|
|
7
7
|
export declare function radToDeg(angle: number): number;
|
|
@@ -20,6 +20,8 @@ export declare function bindingToPrimitive(binding: JobObjectStoredValue | undef
|
|
|
20
20
|
export declare function getYoutubeVideoId(url: string): string | undefined;
|
|
21
21
|
type Unit = 'millimeter' | 'centimeter' | 'inch' | 'pixel' | 'pica' | 'kilometer' | 'mile' | 'nauticalMile' | 'foot' | 'meter';
|
|
22
22
|
export declare function unitConvert(from: Unit, to: Unit, value: number): number;
|
|
23
|
+
export declare function toPixels(value: number, unit?: Unit, dpi?: number): number;
|
|
24
|
+
export declare function getMaxCanvasSize(): [number, number];
|
|
23
25
|
export declare function getEvenSize(value: number): number;
|
|
24
26
|
export declare function lerp(value1: number, value2: number, ratio: number): number;
|
|
25
27
|
export declare function unlerp(min: number, max: number, value: number): number;
|
|
@@ -30,7 +32,7 @@ export declare function stripQuotes(s: string): string;
|
|
|
30
32
|
* Fast hash function for non-cryptographic use
|
|
31
33
|
*/
|
|
32
34
|
export declare function fnv32b(str: string): string;
|
|
33
|
-
export declare function calculateScaleCorrection(jobObject: JobObject, container: HTMLElement, exportType: ExportType): number;
|
|
35
|
+
export declare function calculateScaleCorrection(jobObject: JobObject, container: HTMLElement, exportType: ExportType, format: JobObjectFormat): number;
|
|
34
36
|
export declare function almostEqual(a: number, b: number, delta?: number): boolean;
|
|
35
37
|
export declare function pause(ms: number): Promise<void>;
|
|
36
38
|
export declare function visibleOnGlobe(map: Map, lng: number, lat: number): boolean;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type PdfFont = {
|
|
2
|
+
name: string;
|
|
3
|
+
weight: number;
|
|
4
|
+
style: string;
|
|
5
|
+
};
|
|
6
|
+
type FontOptions = {
|
|
7
|
+
fauxBold: boolean;
|
|
8
|
+
fauxItalic: boolean;
|
|
9
|
+
};
|
|
10
|
+
type PdfDocument = {
|
|
11
|
+
registerFont(name: string, data: ArrayBuffer): unknown;
|
|
12
|
+
};
|
|
13
|
+
type FontResolver = {
|
|
14
|
+
registered: (family: string, weight: number, style: string) => PdfFont | undefined;
|
|
15
|
+
search: (family: string, weight: number, style: string) => Promise<string | undefined>;
|
|
16
|
+
load: (name: string) => Promise<ArrayBuffer | undefined>;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Each PDF document will own its resolution and physical-font registration caches.
|
|
20
|
+
*/
|
|
21
|
+
export declare function createPdfFontCallback(resolver: FontResolver): (family: string, requestedWeight: number, requestedStyle: string, doc: PdfDocument, fontOptions?: FontOptions) => Promise<string>;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Fonts } from './fonts';
|
|
2
|
+
import { StyleSpecification } from '@mapcreator/maplibre-gl';
|
|
3
|
+
type CMYK = [number, number, number, number];
|
|
4
|
+
type RGB = [number, number, number];
|
|
5
|
+
type API = {
|
|
6
|
+
vapiUrl: string;
|
|
7
|
+
accessToken: string;
|
|
8
|
+
apiUrl?: string | undefined;
|
|
9
|
+
bearerToken: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function pdfExportOptions(mapstyle: StyleSpecification, fonts: Fonts, api: API): {
|
|
12
|
+
colorCallback: (inValue: [RGB, number] | undefined) => [CMYK, number] | undefined;
|
|
13
|
+
fontCallback: (family: string, requestedWeight: number, requestedStyle: string, doc: {
|
|
14
|
+
registerFont(name: string, data: ArrayBuffer): unknown;
|
|
15
|
+
}, fontOptions?: {
|
|
16
|
+
fauxBold: boolean;
|
|
17
|
+
fauxItalic: boolean;
|
|
18
|
+
}) => Promise<string>;
|
|
19
|
+
assumePt: boolean;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { Fonts, Font, ResolvedFont } from './fonts';
|
|
1
2
|
import { JobObjectDataBindings } from '../types/jobObject';
|
|
2
3
|
import { Map as MapLibre } from '@mapcreator/maplibre-gl';
|
|
3
4
|
import { BBox as BBoxArray } from '../types/geometry';
|
|
4
5
|
import { ColorGenerator } from './choropleth';
|
|
5
|
-
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function
|
|
6
|
+
export declare function escapeXML(str: unknown): string;
|
|
7
|
+
export declare function createImage(svgString: string, width: number, height: number, fonts: Fonts): Promise<HTMLImageElement>;
|
|
8
|
+
export declare function getAdornments(mapContainer: HTMLElement, containerRect?: DOMRect): Array<{
|
|
9
|
+
name: string | undefined;
|
|
10
|
+
svg: string;
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
w: number;
|
|
14
|
+
h: number;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function drawAdornments(ctx2d: OffscreenCanvasRenderingContext2D, svgCache: SvgCache, mapContainer: HTMLElement, containerRect?: DOMRect): Promise<void>;
|
|
8
17
|
export interface SvgColor {
|
|
9
18
|
name: string;
|
|
10
19
|
color: Color | string | undefined;
|
|
@@ -14,8 +23,6 @@ export interface SvgText {
|
|
|
14
23
|
text: string | undefined;
|
|
15
24
|
isMultiline: boolean;
|
|
16
25
|
}
|
|
17
|
-
export declare function collectUsedFonts(svg: string, fontMap: Map<string, Font>): Font[];
|
|
18
|
-
export declare function injectFonts(svg: string, fonts: Font[], fontBuffers: Array<string | undefined>): string;
|
|
19
26
|
export declare function getBBox(svg: string): BBoxArray;
|
|
20
27
|
export declare class SvgHelper {
|
|
21
28
|
private _seen;
|
|
@@ -66,13 +73,17 @@ export declare class SvgHelper {
|
|
|
66
73
|
export declare class SvgCache {
|
|
67
74
|
private map;
|
|
68
75
|
private keyCache;
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
accessToken: string;
|
|
76
|
+
private promises;
|
|
77
|
+
fonts: Fonts;
|
|
72
78
|
constructor(map: MapLibre, fontMap: Map<string, Font>, vapiUrl: string, accessToken: string);
|
|
73
79
|
getMapLibreImageKey(svg: string, pixelRatio: number): string;
|
|
80
|
+
settledImages(): Promise<void>;
|
|
81
|
+
getFillPatterns(pixelRatio: number): {
|
|
82
|
+
name: string;
|
|
83
|
+
string: string;
|
|
84
|
+
}[];
|
|
74
85
|
}
|
|
75
|
-
export declare function measureTextBlock(lines: string[], fontFamily:
|
|
86
|
+
export declare function measureTextBlock(lines: string[], fontFamily: ResolvedFont, fontSize: number): {
|
|
76
87
|
width: number;
|
|
77
88
|
height: number;
|
|
78
89
|
ascent: number;
|
|
@@ -95,4 +106,9 @@ declare class Color {
|
|
|
95
106
|
sameColor(color: Color): boolean;
|
|
96
107
|
toString(): string;
|
|
97
108
|
}
|
|
109
|
+
export declare function splitColor(color: string): {
|
|
110
|
+
color: string;
|
|
111
|
+
opacity: number;
|
|
112
|
+
};
|
|
113
|
+
export declare function colorAttrs(value: string, property?: 'fill' | 'stroke' | 'stop-color'): string;
|
|
98
114
|
export {};
|