@digitalculture/ochre-sdk 0.4.9 → 0.4.11

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/index.cjs CHANGED
@@ -226,7 +226,7 @@ function parseFakeString(string) {
226
226
  } else if (typeof string === "boolean") {
227
227
  returnString = string ? "Yes" : "No";
228
228
  }
229
- return returnString.replaceAll("'", "'");
229
+ return returnString.replaceAll("'", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
230
230
  }
231
231
  function parseStringItem(item) {
232
232
  let returnString = "";
@@ -243,12 +243,16 @@ function parseStringItem(item) {
243
243
  case "object": {
244
244
  const stringItems = Array.isArray(item.string) ? item.string : [item.string];
245
245
  for (const stringItem of stringItems) {
246
- const renderedText = stringItem.rend != null ? parseRenderOptions(
247
- parseFakeString(stringItem.content),
248
- stringItem.rend
249
- ) : parseFakeString(stringItem.content);
250
- const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
251
- returnString += whitespacedText;
246
+ if (typeof stringItem === "string" || typeof stringItem === "number" || typeof stringItem === "boolean") {
247
+ returnString += parseFakeString(stringItem);
248
+ } else {
249
+ const renderedText = stringItem.rend != null ? parseRenderOptions(
250
+ parseFakeString(stringItem.content),
251
+ stringItem.rend
252
+ ) : parseFakeString(stringItem.content);
253
+ const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
254
+ returnString += whitespacedText;
255
+ }
252
256
  }
253
257
  break;
254
258
  }
@@ -257,7 +261,7 @@ function parseStringItem(item) {
257
261
  break;
258
262
  }
259
263
  }
260
- return returnString;
264
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
261
265
  }
262
266
  function parseStringDocumentItem(item, footnotes) {
263
267
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
@@ -364,7 +368,7 @@ function parseStringDocumentItem(item, footnotes) {
364
368
  item.whitespace
365
369
  );
366
370
  }
367
- return returnString.replaceAll("'", "'");
371
+ return returnString.replaceAll("'", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
368
372
  } else {
369
373
  returnString = parseFakeString(item.content);
370
374
  if (item.rend != null) {
@@ -380,7 +384,7 @@ function parseStringDocumentItem(item, footnotes) {
380
384
  );
381
385
  }
382
386
  }
383
- return returnString;
387
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
384
388
  }
385
389
  function parseStringContent(content, language = "eng") {
386
390
  switch (typeof content.content) {
@@ -411,7 +415,7 @@ ${JSON.stringify(
411
415
  }
412
416
  }
413
417
  default: {
414
- return String(content.content);
418
+ return String(content.content).replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
415
419
  }
416
420
  }
417
421
  }
@@ -1372,7 +1376,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1372
1376
  const links = elementResource.links ? parseLinks(
1373
1377
  Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
1374
1378
  ) : [];
1375
- const imageLinks = links.filter((link) => link.type === "image");
1379
+ const imageLinks = links.filter(
1380
+ (link) => link.type === "image" || link.type === "IIIF"
1381
+ );
1376
1382
  let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
1377
1383
  if (document === null) {
1378
1384
  const documentLink = links.find((link) => link.type === "internalDocument");
package/dist/index.d.cts CHANGED
@@ -715,7 +715,10 @@ type OchreStringItemContent = {
715
715
  * Raw string item with language metadata
716
716
  */
717
717
  type OchreStringItem = {
718
- string: FakeString | OchreStringItemContent | Array<OchreStringItemContent>;
718
+ string:
719
+ | FakeString
720
+ | OchreStringItemContent
721
+ | Array<FakeString | OchreStringItemContent>;
719
722
  lang?: Language["iso6393"]; // 3 character code (zxx = "a.k.a.")
720
723
  languages?: string; // 3 character codes, semicolon separated
721
724
  };
package/dist/index.d.ts CHANGED
@@ -715,7 +715,10 @@ type OchreStringItemContent = {
715
715
  * Raw string item with language metadata
716
716
  */
717
717
  type OchreStringItem = {
718
- string: FakeString | OchreStringItemContent | Array<OchreStringItemContent>;
718
+ string:
719
+ | FakeString
720
+ | OchreStringItemContent
721
+ | Array<FakeString | OchreStringItemContent>;
719
722
  lang?: Language["iso6393"]; // 3 character code (zxx = "a.k.a.")
720
723
  languages?: string; // 3 character codes, semicolon separated
721
724
  };
package/dist/index.js CHANGED
@@ -149,7 +149,7 @@ function parseFakeString(string) {
149
149
  } else if (typeof string === "boolean") {
150
150
  returnString = string ? "Yes" : "No";
151
151
  }
152
- return returnString.replaceAll("&#39;", "'");
152
+ return returnString.replaceAll("&#39;", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
153
153
  }
154
154
  function parseStringItem(item) {
155
155
  let returnString = "";
@@ -166,12 +166,16 @@ function parseStringItem(item) {
166
166
  case "object": {
167
167
  const stringItems = Array.isArray(item.string) ? item.string : [item.string];
168
168
  for (const stringItem of stringItems) {
169
- const renderedText = stringItem.rend != null ? parseRenderOptions(
170
- parseFakeString(stringItem.content),
171
- stringItem.rend
172
- ) : parseFakeString(stringItem.content);
173
- const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
174
- returnString += whitespacedText;
169
+ if (typeof stringItem === "string" || typeof stringItem === "number" || typeof stringItem === "boolean") {
170
+ returnString += parseFakeString(stringItem);
171
+ } else {
172
+ const renderedText = stringItem.rend != null ? parseRenderOptions(
173
+ parseFakeString(stringItem.content),
174
+ stringItem.rend
175
+ ) : parseFakeString(stringItem.content);
176
+ const whitespacedText = stringItem.whitespace != null ? parseWhitespace(renderedText, stringItem.whitespace) : renderedText;
177
+ returnString += whitespacedText;
178
+ }
175
179
  }
176
180
  break;
177
181
  }
@@ -180,7 +184,7 @@ function parseStringItem(item) {
180
184
  break;
181
185
  }
182
186
  }
183
- return returnString;
187
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
184
188
  }
185
189
  function parseStringDocumentItem(item, footnotes) {
186
190
  if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
@@ -287,7 +291,7 @@ function parseStringDocumentItem(item, footnotes) {
287
291
  item.whitespace
288
292
  );
289
293
  }
290
- return returnString.replaceAll("&#39;", "'");
294
+ return returnString.replaceAll("&#39;", "'").replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
291
295
  } else {
292
296
  returnString = parseFakeString(item.content);
293
297
  if (item.rend != null) {
@@ -303,7 +307,7 @@ function parseStringDocumentItem(item, footnotes) {
303
307
  );
304
308
  }
305
309
  }
306
- return returnString;
310
+ return returnString.replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
307
311
  }
308
312
  function parseStringContent(content, language = "eng") {
309
313
  switch (typeof content.content) {
@@ -334,7 +338,7 @@ ${JSON.stringify(
334
338
  }
335
339
  }
336
340
  default: {
337
- return String(content.content);
341
+ return String(content.content).replaceAll(/^(\d+)\./gm, String.raw`$1\.`);
338
342
  }
339
343
  }
340
344
  }
@@ -1295,7 +1299,9 @@ async function parseWebElementProperties(componentProperty, elementResource) {
1295
1299
  const links = elementResource.links ? parseLinks(
1296
1300
  Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
1297
1301
  ) : [];
1298
- const imageLinks = links.filter((link) => link.type === "image");
1302
+ const imageLinks = links.filter(
1303
+ (link) => link.type === "image" || link.type === "IIIF"
1304
+ );
1299
1305
  let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
1300
1306
  if (document === null) {
1301
1307
  const documentLink = links.find((link) => link.type === "internalDocument");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@digitalculture/ochre-sdk",
3
- "version": "0.4.9",
3
+ "version": "0.4.11",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Node.js library for working with OCHRE (Online Cultural and Historical Research Environment) data",