@vectoriahq/quac 0.20.0 → 0.22.0-next.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.
@@ -58,6 +58,11 @@ export declare const QUAC_ICON_FIELD = "quac:icon";
58
58
  * it: text that may hold HTML markup.
59
59
  */
60
60
  export declare const QUAC_ADDED_MESSAGE_FIELD = "quac:added_message";
61
+ /**
62
+ * The key a Collection takes for its map tip: HTML holding QGIS expressions
63
+ * between `[%` and `%]`, which a reader fills in for a feature.
64
+ */
65
+ export declare const QUAC_MAP_TIP_FIELD = "quac:map_tip";
61
66
  /**
62
67
  * The key a Collection takes for the area and distance units its source gives
63
68
  * `$area`, `$length` and `$perimeter` in: `{ area_unit, distance_unit }`, each
@@ -217,6 +222,8 @@ export interface NormalizedLayer {
217
222
  icon?: string | null;
218
223
  /** Emitted as `quac:added_message`: the message shown once a feature is added, as the source wrote it. */
219
224
  addedMessage?: string | null;
225
+ /** Emitted as `quac:map_tip`: the template of the layer's map tip, as the source wrote it. */
226
+ mapTip?: string | null;
220
227
  /** Emitted as `quac:locks` where it locks an edit. */
221
228
  locks?: LayerLocks;
222
229
  /** Emitted as `quac:filters` where the source sets one up. */
@@ -374,6 +381,13 @@ export declare function readCollectionIcon(collection: StacCollection | null | u
374
381
  * judges safe.
375
382
  */
376
383
  export declare function readCollectionAddedMessage(collection: StacCollection | null | undefined): string | null;
384
+ /**
385
+ * The template of a Collection's map tip (`quac:map_tip`), as the source wrote
386
+ * it, or null where it gives none. It is HTML holding QGIS expressions between
387
+ * `[%` and `%]`, which the application fills in for a feature and shows only as
388
+ * far as it judges safe.
389
+ */
390
+ export declare function readCollectionMapTip(collection: StacCollection | null | undefined): string | null;
377
391
  /**
378
392
  * Reads `quac:locks` back off a Collection: the edits it locks, each `true` or
379
393
  * `{ expression }`. A member that is neither, or an expression that is blank,
@@ -63,6 +63,11 @@ export const QUAC_ICON_FIELD = 'quac:icon';
63
63
  * it: text that may hold HTML markup.
64
64
  */
65
65
  export const QUAC_ADDED_MESSAGE_FIELD = 'quac:added_message';
66
+ /**
67
+ * The key a Collection takes for its map tip: HTML holding QGIS expressions
68
+ * between `[%` and `%]`, which a reader fills in for a feature.
69
+ */
70
+ export const QUAC_MAP_TIP_FIELD = 'quac:map_tip';
66
71
  /**
67
72
  * The key a Collection takes for the area and distance units its source gives
68
73
  * `$area`, `$length` and `$perimeter` in: `{ area_unit, distance_unit }`, each
@@ -275,6 +280,8 @@ function buildCollection(layer, defaultProviders, folder) {
275
280
  collection[QUAC_ICON_FIELD] = layer.icon;
276
281
  if (layer.addedMessage)
277
282
  collection[QUAC_ADDED_MESSAGE_FIELD] = layer.addedMessage;
283
+ if (layer.mapTip)
284
+ collection[QUAC_MAP_TIP_FIELD] = layer.mapTip;
278
285
  if (layer.formOrder)
279
286
  collection[QUAC_FORM_ORDER_FIELD] = layer.formOrder;
280
287
  // Source-declaring vendor fields (`quac:wfs_*`), copied verbatim so a consumer reads the source structurally rather than by
@@ -566,6 +573,16 @@ export function readCollectionAddedMessage(collection) {
566
573
  const message = collection?.[QUAC_ADDED_MESSAGE_FIELD];
567
574
  return typeof message === 'string' && message.trim() !== '' ? message : null;
568
575
  }
576
+ /**
577
+ * The template of a Collection's map tip (`quac:map_tip`), as the source wrote
578
+ * it, or null where it gives none. It is HTML holding QGIS expressions between
579
+ * `[%` and `%]`, which the application fills in for a feature and shows only as
580
+ * far as it judges safe.
581
+ */
582
+ export function readCollectionMapTip(collection) {
583
+ const template = collection?.[QUAC_MAP_TIP_FIELD];
584
+ return typeof template === 'string' && template.trim() !== '' ? template : null;
585
+ }
569
586
  const LOCKED_EDITS = ['add', 'attributes', 'geometry', 'delete'];
570
587
  /**
571
588
  * Reads `quac:locks` back off a Collection: the edits it locks, each `true` or
@@ -429,6 +429,7 @@ function qgsLayerToNormalized(layer, context, geometryFilter = geometryFilterOf(
429
429
  legendImage: layer.legendImage,
430
430
  icon: layer.icon,
431
431
  addedMessage: layer.addedMessage,
432
+ mapTip: layer.mapTip,
432
433
  locks: combineLocks(layer.locks ?? {}, wfsTransactionLocks(layer.id, context.wfsTransactionLayers)),
433
434
  filters: context.filtersByCollectionId.get(layer.id),
434
435
  vendorFields: buildVendorFields(layer, context.measurement),
package/dist/index.d.ts CHANGED
@@ -36,7 +36,7 @@ export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionR
36
36
  export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from './model/stacPmtiles.ts';
37
37
  export type { StacPmtilesSource } from './model/stacPmtiles.ts';
38
38
  export type { StacCompanionData } from './generate/stacCatalogue.ts';
39
- export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
39
+ export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from './generate/normalizedProject.ts';
40
40
  export type { CollectionFilter, CollectionFormLayout, CollectionRelation, CollectionRelationField } from './generate/normalizedProject.ts';
41
41
  export { generateStacCatalogueFromWfsCapabilities } from './generate/wfsStacCatalogue.ts';
42
42
  export type { WfsStacCatalogueOptions } from './generate/wfsStacCatalogue.ts';
package/dist/index.js CHANGED
@@ -24,7 +24,7 @@ export { DATA_ROLE, findAssetByRole, readDataAsset } from "./model/stacAssetRole
24
24
  export { THUMBNAIL_ROLE, readCollectionAttribution, readCollectionDeprecation, readCollectionSelfHref, readCollectionThumbnail } from "./model/stacCollectionNotes.js";
25
25
  export { FILE_EXTENSION, FILE_SIZE_FIELD, TABLE_ROW_COUNT_FIELD, readCollectionRowCount, readDataAssetFileSize } from "./model/stacSizeAndCount.js";
26
26
  export { PMTILES_MEDIA_TYPE, VISUAL_ROLE, readCollectionPmtiles } from "./model/stacPmtiles.js";
27
- export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
27
+ export { QUAC_ACTIVE_COLLECTION_FIELD, QUAC_FILTERS_FIELD, QUAC_FORM_ORDER_FIELD, QUAC_LOCKS_FIELD, QUAC_MUTUALLY_EXCLUSIVE_FIELD, QUAC_PRIVATE_FIELD, readCatalogueActiveCollection, readCatalogueInitialView, readCataloguePrintLayouts, readCollectionDisplayField, readCollectionEditable, readCollectionFieldAliases, readCollectionFieldComments, readCollectionFieldAttachments, readCollectionFieldEditRules, readCollectionFieldNames, readCollectionFieldTypes, readCollectionFieldValueRelations, readCollectionFieldValues, readCollectionFormLayout, readCollectionGeometryType, readCollectionIdentifiable, readCollectionMeasurement, readCollectionOpacity, readCollectionIcon, readCollectionAddedMessage, readCollectionMapTip, readCollectionLegendImage, readCollectionFilters, readCollectionLocks, readCollectionPrivate, readCollectionRelatedTo, readCollectionScaleRange, readCollectionVisibility, statedOpacity } from "./generate/normalizedProject.js";
28
28
  export { generateStacCatalogueFromWfsCapabilities } from "./generate/wfsStacCatalogue.js";
29
29
  export { generateStacCatalogueFromFolder } from "./generate/folderStacCatalogue.js";
30
30
  export { generateCollectionForDroppedFile, generateCollectionForLinkedFile } from "./generate/fileLayerCollection.js";
@@ -306,6 +306,11 @@ export interface LayerEntry {
306
306
  * none.
307
307
  */
308
308
  addedMessage?: string | null;
309
+ /**
310
+ * The layer's HTML map tip, from `<mapTip>`, as written and unfilled. Null
311
+ * or absent where Enable Map Tips is off or the template is blank.
312
+ */
313
+ mapTip?: string | null;
309
314
  /**
310
315
  * The address of each field's icon, from the layer's `quac_icon_<field>`
311
316
  * variables. Fields with none are absent.
@@ -44,6 +44,8 @@ export interface StacStyle {
44
44
  * Either holds the values to merge over the style document it is listed on.
45
45
  */
46
46
  export type StyleOverrideReference = string | Record<string, unknown>;
47
+ /** The key a style asset stores its style overrides under. */
48
+ export declare const QUAC_STYLE_OVERRIDES = "quac:style_overrides";
47
49
  /**
48
50
  * The role marking the asset a Collection nominates as its default style.
49
51
  *
@@ -1,7 +1,7 @@
1
1
  /** The key a style asset stores its categorised field under. */
2
2
  const QUAC_CATEGORISED_FIELD = 'quac:categorised_field';
3
3
  /** The key a style asset stores its style overrides under. */
4
- const QUAC_STYLE_OVERRIDES = 'quac:style_overrides';
4
+ export const QUAC_STYLE_OVERRIDES = 'quac:style_overrides';
5
5
  function readStyleOverrides(value) {
6
6
  if (!Array.isArray(value))
7
7
  return [];
@@ -125,6 +125,7 @@ function parseMapLayer(maplayer, notes, photoSettings) {
125
125
  fieldEditRules: parseFieldEditRules(maplayer, note),
126
126
  icon: parseLayerIcon(maplayer),
127
127
  addedMessage: parseAddedMessage(maplayer),
128
+ mapTip: parseMapTip(maplayer),
128
129
  fieldIcons: parseFieldIcons(maplayer),
129
130
  fieldControls: parseFieldControls(maplayer),
130
131
  formLayout: parseFormLayout(maplayer),
@@ -1042,6 +1043,26 @@ function parseAddedMessage(maplayer) {
1042
1043
  const value = readLayerVariable(maplayer, ADDED_MESSAGE_VARIABLE);
1043
1044
  return value === null || value.trim() === '' ? null : value;
1044
1045
  }
1046
+ /**
1047
+ * Reads a vector layer's HTML Map Tip (Layer Properties › Display) from
1048
+ * `<mapTip>`, as written: HTML holding QGIS expressions between `[%` and
1049
+ * `%]`, left unfilled. Null where Enable Map Tips is off, which QGIS saves as
1050
+ * an `enabled` other than `1`, where the template is blank, and for a layer
1051
+ * that is not a vector layer. A missing `enabled` is on, as
1052
+ * `QgsVectorLayer::readSymbology` reads it (`src/core/vector/qgsvectorlayer.cpp`,
1053
+ * `qgis/QGIS@master`, read 2026-11-30). This is the map tip of the layer's
1054
+ * current style; another named style's own is not read.
1055
+ */
1056
+ function parseMapTip(maplayer) {
1057
+ if (maplayer.getAttribute('type') !== 'vector')
1058
+ return null;
1059
+ const node = directChild(maplayer, 'mapTip');
1060
+ const template = node?.textContent ?? '';
1061
+ if (!node || template.trim() === '')
1062
+ return null;
1063
+ const enabled = node.getAttribute('enabled');
1064
+ return enabled === null || enabled.trim() === '1' ? template : null;
1065
+ }
1045
1066
  /** The start of the name of a layer variable that chooses a field's control: `quac_control_condition`. */
1046
1067
  const FIELD_CONTROL_VARIABLE_PREFIX = 'quac_control_';
1047
1068
  /**
@@ -12,7 +12,10 @@ import type { StacCatalog, StacCollection } from '../model/Stac.ts';
12
12
  export declare function collectAllCollections(root: StacCatalog): StacCollection[];
13
13
  /**
14
14
  * Rewrites a fetched document's asset and link hrefs to absolute addresses,
15
- * against the URL the document itself came from.
15
+ * against the URL the document itself came from, and with them each address a
16
+ * style asset's `quac:style_overrides` lists: an override written by address
17
+ * is a file beside the catalogue as much as an asset is. An override written in
18
+ * place, as an object, is kept as it is.
16
19
  *
17
20
  * A published catalogue gives each Collection its own document and addresses
18
21
  * that Collection's files relative to it — `./roads.parquet` beside
@@ -1,3 +1,4 @@
1
+ import { QUAC_STYLE_OVERRIDES } from "../model/stacStyles.js";
1
2
  /**
2
3
  * Pure helpers over a fetched STAC document, used by `StacEndpointAdapter` as
3
4
  * it reads and inlines a catalogue. None of them makes a request.
@@ -18,7 +19,10 @@ export function collectAllCollections(root) {
18
19
  }
19
20
  /**
20
21
  * Rewrites a fetched document's asset and link hrefs to absolute addresses,
21
- * against the URL the document itself came from.
22
+ * against the URL the document itself came from, and with them each address a
23
+ * style asset's `quac:style_overrides` lists: an override written by address
24
+ * is a file beside the catalogue as much as an asset is. An override written in
25
+ * place, as an object, is kept as it is.
22
26
  *
23
27
  * A published catalogue gives each Collection its own document and addresses
24
28
  * that Collection's files relative to it — `./roads.parquet` beside
@@ -56,7 +60,16 @@ export function resolveDocumentHrefs(document, url) {
56
60
  ...(document.links ? { links: document.links.map((link) => ({ ...link, href: absolute(link.href) })) } : {}),
57
61
  ...(assets
58
62
  ? {
59
- assets: Object.fromEntries(Object.entries(assets).map(([key, asset]) => [key, { ...asset, href: absolute(asset.href) }]))
63
+ assets: Object.fromEntries(Object.entries(assets).map(([key, asset]) => {
64
+ const overrides = asset[QUAC_STYLE_OVERRIDES];
65
+ return [key, {
66
+ ...asset,
67
+ href: absolute(asset.href),
68
+ ...(Array.isArray(overrides)
69
+ ? { [QUAC_STYLE_OVERRIDES]: overrides.map((entry) => (typeof entry === 'string' ? absolute(entry) : entry)) }
70
+ : {})
71
+ }];
72
+ }))
60
73
  }
61
74
  : {}),
62
75
  // A document that inlines its children addresses their files relative to
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vectoriahq/quac",
3
- "version": "0.20.0",
3
+ "version": "0.22.0-next.1",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "description": "Writes and reads QUAC, which adds map layer settings to STAC catalogues.",
@@ -296,6 +296,11 @@
296
296
  "type": "string",
297
297
  "minLength": 1
298
298
  },
299
+ "quac:map_tip": {
300
+ "description": "The template of the card shown for a feature on the map: HTML holding QGIS expressions between [% and %], which a reader fills in for the feature. Written from a QGIS vector layer's HTML Map Tip while Enable Map Tips is ticked.",
301
+ "type": "string",
302
+ "minLength": 1
303
+ },
299
304
  "quac:primary_key": {
300
305
  "description": "The names of the fields whose values identify a feature in the layer's data, its primary key. Written from QGIS, which gives a layer's primary key, where every field of the key is among the columns.",
301
306
  "type": "array",