@readium/shared 2.1.0 → 2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@readium/shared",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "type": "module",
5
5
  "description": "Shared models to be used across other Readium projects and implementations in Typescript",
6
6
  "author": "readium",
@@ -31,9 +31,9 @@
31
31
  "types": "./types/src/index.d.ts",
32
32
  "exports": {
33
33
  ".": {
34
+ "types": "./types/src/index.d.ts",
34
35
  "import": "./dist/index.js",
35
- "require": "./dist/index.umd.cjs",
36
- "types": "./types/src/index.d.ts"
36
+ "require": "./dist/index.umd.cjs"
37
37
  }
38
38
  },
39
39
  "files": [
@@ -48,7 +48,6 @@
48
48
  "dev": "vite",
49
49
  "build": "tsc && vite build",
50
50
  "update-accessibility-locales": "node update-accessibility-locales.mjs",
51
- "postinstall": "npm run update-accessibility-locales",
52
51
  "test": "jest",
53
52
  "size": "size-limit"
54
53
  },
@@ -59,18 +58,18 @@
59
58
  }
60
59
  ],
61
60
  "devDependencies": {
62
- "@babel/core": "^7.25.2",
63
- "@babel/preset-env": "^7.25.4",
64
- "@babel/preset-typescript": "^7.22.5",
65
- "@size-limit/file": "^11.1.4",
66
- "@types/jest": "^29.5.10",
67
- "babel-jest": "^29.0.0",
68
- "css-selector-generator": "^3.6.4",
69
- "jest": "^29.7.0",
70
- "size-limit": "^11.1.4",
71
- "ts-jest": "^29.1.1",
72
- "tslib": "^2.6.2",
73
- "typescript": "^5.4.5",
74
- "vite": "^4.5.5"
61
+ "@babel/core": "^7.28.3",
62
+ "@babel/preset-env": "^7.28.3",
63
+ "@babel/preset-typescript": "^7.27.1",
64
+ "@size-limit/file": "^11.2.0",
65
+ "@types/jest": "^30.0.0",
66
+ "babel-jest": "^30.1.1",
67
+ "css-selector-generator": "^3.6.9",
68
+ "jest": "^30.1.1",
69
+ "size-limit": "^11.2.0",
70
+ "ts-jest": "^29.4.1",
71
+ "tslib": "^2.8.1",
72
+ "typescript": "^5.9.2",
73
+ "vite": "^7.1.5"
75
74
  }
76
75
  }
@@ -35,7 +35,7 @@ export class Acquisition {
35
35
  }
36
36
 
37
37
  public static deserializeArray(json: any): Array<Acquisition> | undefined {
38
- if (!(json instanceof Array)) return;
38
+ if (!(Array.isArray(json))) return;
39
39
  return json
40
40
  .map<Acquisition>(item => Acquisition.deserialize(item) as Acquisition)
41
41
  .filter(x => x !== undefined);
@@ -25,7 +25,7 @@ export class BelongsTo {
25
25
  * Parses a [BelongsTo] from its RWPM JSON representation.
26
26
  */
27
27
  public static deserialize(json: any): BelongsTo | undefined {
28
- if (!(json && json instanceof Object)) return;
28
+ if (!(json && typeof json === 'object')) return;
29
29
 
30
30
  const items = new Map<string, Collection>();
31
31
  Object.entries(json).forEach(([key, value]) => {
@@ -77,7 +77,7 @@ export class Contributor {
77
77
  sortAs: json.sortAs,
78
78
  identifier: json.identifier,
79
79
  altIdentifiers: json.altIdentifier
80
- ? (json.altIdentifier instanceof Array
80
+ ? (Array.isArray(json.altIdentifier)
81
81
  ? new Set<AltIdentifier>(json.altIdentifier
82
82
  .map((x: string | { value: string; scheme?: string }) => AltIdentifier.deserialize(x))
83
83
  .filter((x: AltIdentifier | undefined): x is AltIdentifier => x !== undefined))
@@ -127,7 +127,7 @@ export class Contributors {
127
127
  */
128
128
  public static deserialize(json: any): Contributors | undefined {
129
129
  if (!json) return;
130
- const items = json instanceof Array ? json : [json];
130
+ const items = Array.isArray(json) ? json : [json];
131
131
  return new Contributors(
132
132
  items
133
133
  .map<Contributor>(item => Contributor.deserialize(item) as Contributor)
@@ -211,7 +211,7 @@ export class GuidedNavigationObject {
211
211
  * Parses a [GuidedNavigationObject] array from its RWPM JSON representation.
212
212
  */
213
213
  public static deserializeArray(json: any): GuidedNavigationObject[] | undefined {
214
- if (!(json instanceof Array)) return undefined;
214
+ if (!(Array.isArray(json))) return undefined;
215
215
  return json
216
216
  .map<GuidedNavigationObject>((item) => GuidedNavigationObject.deserialize(item) as GuidedNavigationObject)
217
217
  .filter((x) => x !== undefined);
@@ -107,7 +107,7 @@ export class Link {
107
107
  type: json.type,
108
108
  title: json.title,
109
109
  rels: json.rel
110
- ? json.rel instanceof Array
110
+ ? Array.isArray(json.rel)
111
111
  ? new Set<string>(json.rel as Array<string>)
112
112
  : new Set<string>([json.rel as string])
113
113
  : undefined,
@@ -226,7 +226,7 @@ export class Links {
226
226
  * Creates a list of [Link] from its RWPM JSON representation.
227
227
  */
228
228
  public static deserialize(json: any): Links | undefined {
229
- if (!(json && json instanceof Array)) return;
229
+ if (!(json && Array.isArray(json))) return;
230
230
  return new Links(
231
231
  json
232
232
  .map<Link>(item => Link.deserialize(item) as Link)
@@ -102,7 +102,7 @@ export class LocatorCollection {
102
102
 
103
103
  let jsonList = json.locators;
104
104
 
105
- if (jsonList && jsonList instanceof Array) {
105
+ if (jsonList && Array.isArray(jsonList)) {
106
106
  locators = jsonList
107
107
  .map<Locator>(x => Locator.deserialize(x) as Locator)
108
108
  .filter(x => x !== undefined);
@@ -39,10 +39,10 @@ export class PublicationCollection {
39
39
  let metadata: Map<string, any> | undefined;
40
40
  let subcollections: Map<string, Array<PublicationCollection>> | undefined;
41
41
 
42
- if (json instanceof Array) {
42
+ if (Array.isArray(json)) {
43
43
  // Parses an array of links.
44
44
  links = Links.deserialize(json);
45
- } else if (json instanceof Object) {
45
+ } else if (typeof json === 'object') {
46
46
  // Parses a sub-collection object.
47
47
  links = Links.deserialize(json.links);
48
48
 
@@ -86,7 +86,7 @@ export class PublicationCollection {
86
86
  const list = new Array<PublicationCollection>();
87
87
  list.push(collection);
88
88
  collections.set(role, list);
89
- } else if (subJSON instanceof Array) {
89
+ } else if (Array.isArray(subJSON)) {
90
90
  // Parses a list of collection objects.
91
91
  const list = subJSON
92
92
  .map<PublicationCollection>(
@@ -98,7 +98,7 @@ export class Subjects {
98
98
  */
99
99
  public static deserialize(json: any): Subjects | undefined {
100
100
  if (!json) return;
101
- const items = json instanceof Array ? json : [json];
101
+ const items = Array.isArray(json) ? json : [json];
102
102
  return new Subjects(
103
103
  items
104
104
  .map<Subject>(item => Subject.deserialize(item) as Subject)
@@ -61,7 +61,7 @@ Properties.prototype.getIndirectAcquisitions = function():
61
61
  | Array<Acquisition>
62
62
  | undefined {
63
63
  const json = this.otherProperties['indirectAcquisition'];
64
- if (!(json && json instanceof Array)) return;
64
+ if (!(json && Array.isArray(json))) return;
65
65
  return json
66
66
  .map<Acquisition>(item => Acquisition.deserialize(item) as Acquisition)
67
67
  .filter(x => x !== undefined);
@@ -1,6 +1,6 @@
1
1
  /** Parses the given array (or undefined it it's not an array) */
2
2
  export function arrayfromJSON(json: any): Array<any> | undefined {
3
- return json && json instanceof Array ? json : undefined;
3
+ return json && Array.isArray(json) ? json : undefined;
4
4
  }
5
5
 
6
6
  export function arrayfromJSONorString(json: any): Array<any> | undefined {