@opengeospatial/jsonld-ui-utils 0.4.12 → 0.5.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
@@ -93,10 +93,15 @@ The generated elements carry CSS classes you can style:
93
93
  | `.object-property` | Property name cells |
94
94
  | `.object-value` | Property value cells |
95
95
  | `.literal-value` | Scalar (non-object) values |
96
- | `.array-entry` | Entries within an array value |
96
+ | `.array-table` | `<table>` elements holding array values, one row per entry |
97
+ | `.array-value`, `.array-entry` | Cells of an array table |
98
+ | `.literal-language`, `.literal-datatype` | Language tag or datatype of a JSON-LD value object |
99
+ | `.truncated-value` | Summary shown instead of content beyond `maxDepth` / `maxElements` |
97
100
 
98
101
  Include `dist/jsonld-ui-utils.css` (or the CDN link above) for default styling of these classes.
99
102
 
103
+ JSON-LD keywords get special treatment: `@context` entries are hidden, value objects (`@value`) are shown as a single literal, and `@list` / `@set` as plain arrays. `augment()` also understands keyword aliases, links `@id` and `@type` values, and applies type-scoped and property-scoped contexts. An object whose only keys are `@graph` and optionally `@context` is shown as the contents of `@graph`; otherwise (e.g. a named graph) `@graph` is shown as a property. `@context` entries embedded in the data are applied to their object and its descendants; relative references in them are resolved against `baseUrl`, and one that fails to load is skipped with a warning. With `propertiesField` set, only those at or below that field are seen.
104
+
100
105
  #### 3. Augment with semantic metadata
101
106
 
102
107
  ```javascript
@@ -123,16 +128,22 @@ During and after augmentation, elements receive additional CSS classes:
123
128
  | Option | Type | Default | Description |
124
129
  |---|---|---|---|
125
130
  | `propertiesField` | `string` or `null` | `'properties'` | Property on `feature` to use as the root object. Set to `null` to use the entire feature. |
131
+ | `maxDepth` | `number` | `15` | Maximum nesting levels (objects and arrays). Deeper content is not generated, only summarized. |
132
+ | `maxElements` | `number` | `100` | Maximum entries rendered per array or object. `@id`, `@type`, `id` and `type` are always shown. |
126
133
 
127
134
  #### `augment(rootElem, context, options?)`
128
135
 
129
136
  | Option | Type | Default | Description |
130
137
  |---|---|---|---|
131
138
  | `replaceElements` | `boolean` | `true` | Replace element text with the resolved label. |
139
+ | `baseUrl` | `string` | — | Base for relative identifiers, unless the context sets `@base`. |
132
140
  | `labelPredicates` | `string[]` | SKOS prefLabel, DCT/DC title, SDO/FOAF name, RDFS label | RDF predicates checked when extracting a label. |
133
141
  | `descriptionPredicates` | `string[]` | SKOS definition, DCT/DC description, RDFS comment | RDF predicates checked when extracting a description. |
134
142
  | `fallbackRainbowInstances` | `string` or `string[]` | — | One or more RAINBOW proxy base URLs tried in order when a direct fetch returns no label. |
135
- | `fallbackSparqlEndpoints` | `string` or `string[]` | — | One or more SPARQL endpoint URLs tried in order as a last resort (`DESCRIBE <uri>`). |
143
+ | `fallbackSparqlEndpoints` | `string` or `string[]` | — | One or more SPARQL endpoint URLs tried in order as a last resort (`DESCRIBE`, several URIs per query). |
144
+ | `maxConcurrentRequests` | `number` | `6` | Maximum simultaneous HTTP requests. |
145
+ | `sparqlBatchSize` | `number` | `50` | Maximum URIs per SPARQL query. A smaller batch is sent once no other lookup is pending, or after 500 ms. |
146
+ | `requestTimeout` | `number` | `10000` | Milliseconds after which a request is abandoned. |
136
147
 
137
148
  ### Lower-level API
138
149
 
@@ -155,9 +166,9 @@ const data = await fetchResource('https://example.org/vocab/MyTerm', {
155
166
  console.log(data.label); // e.g. "My Term"
156
167
  ```
157
168
 
158
- #### `loadContext(context)`
169
+ #### `loadContext(context, options?)`
159
170
 
160
- Load and merge one or more JSON-LD contexts. Accepts a context object, a URL string, or an array of either:
171
+ Load and merge one or more JSON-LD contexts. `options.baseUrl` is used to resolve relative context references; references inside a remote context resolve against that context's URL. `options.requestTimeout` (default 10000 ms) limits each remote request. Accepts a context object, a URL string, or an array of either:
161
172
 
162
173
  ```javascript
163
174
  const merged = await loadContext([
@@ -260,6 +271,8 @@ Per the JSON-FG scoping rules, a `coordRefSys` on an individual feature override
260
271
  | `ldContext` | `string`, `object`, or `array` | — | JSON-LD context (URL, object, or array) used to resolve property URIs. |
261
272
  | `popupOptions` | `object` | `{ maxWidth: 400 }` | Options passed to Leaflet's `bindPopup`. |
262
273
  | `augmentOptions` | `object` | `{}` | Options passed to `augment()` (see above). |
274
+ | `baseUrl` | `string` | — | Base for relative context references and identifiers. |
275
+ | `maxDepth`, `maxElements` | `number` | `15`, `100` | Popup table limits (see `createPropertiesTable`). |
263
276
  | `onEachFeature` | `function` | — | Called for every feature before the plugin's own logic, matching Leaflet's `onEachFeature` signature. |
264
277
  | `coordRefSys` | `string` | — | Override CRS detection with an explicit URI (e.g. `"EPSG:5514"`). |
265
278
  | `proj4` | `object` | — | Inject a specific proj4 instance instead of using the auto-resolved one. |
package/dist/augment.d.ts CHANGED
@@ -2,6 +2,8 @@ import { CreatePropertiesTableOptions, FetchResourceOptions } from "./resource";
2
2
  import { ContextDefinition } from "jsonld";
3
3
  export interface AugmentOptions extends FetchResourceOptions {
4
4
  replaceElements: boolean;
5
+ /** Base URL for resolving relative identifiers (overridden by @base in the context) */
6
+ baseUrl?: string;
5
7
  }
6
8
  export declare function createPropertiesTable(feature: {
7
9
  [index: string]: any;
@@ -0,0 +1,21 @@
1
+ import { ContextDefinition } from "jsonld";
2
+ export type ContextStack = ContextDefinition[];
3
+ export interface TermDefinition {
4
+ '@id'?: string | null;
5
+ '@reverse'?: string;
6
+ '@type'?: string;
7
+ '@context'?: any;
8
+ }
9
+ export interface ExpandOptions {
10
+ /** Resolve as a vocabulary term (property names, types): term definitions and @vocab apply */
11
+ vocab?: boolean;
12
+ /** Resolve as a document-relative reference (@id values): @base / baseUrl apply */
13
+ base?: boolean;
14
+ baseUrl?: string;
15
+ }
16
+ export declare function pushContext(stack: ContextStack, context: any): ContextStack;
17
+ /** Term definition in object form; null if the term is explicitly unmapped, undefined if unknown */
18
+ export declare function findTerm(term: string, stack: ContextStack): TermDefinition | null | undefined;
19
+ /** The keyword (`@id`, `@type`...) that a key stands for, either directly or through an alias */
20
+ export declare function asKeyword(key: string, stack: ContextStack): string | null;
21
+ export declare function expandIri(value: string, stack: ContextStack, options: ExpandOptions, seen?: Set<string>): string | null;