@readium/shared 2.1.1 → 2.1.3

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.1",
3
+ "version": "2.1.3",
4
4
  "type": "module",
5
5
  "description": "Shared models to be used across other Readium projects and implementations in Typescript",
6
6
  "author": "readium",
@@ -58,18 +58,18 @@
58
58
  }
59
59
  ],
60
60
  "devDependencies": {
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",
61
+ "@babel/core": "^7.28.6",
62
+ "@babel/preset-env": "^7.28.6",
63
+ "@babel/preset-typescript": "^7.28.5",
64
+ "@size-limit/file": "^12.0.0",
65
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",
66
+ "babel-jest": "^30.2.0",
67
+ "css-selector-generator": "^3.8.0",
68
+ "jest": "^30.2.0",
69
+ "size-limit": "^12.0.0",
70
+ "ts-jest": "^29.4.6",
71
71
  "tslib": "^2.8.1",
72
- "typescript": "^5.9.2",
73
- "vite": "^7.1.5"
72
+ "typescript": "^5.9.3",
73
+ "vite": "^7.3.1"
74
74
  }
75
75
  }
@@ -21,7 +21,7 @@ export class Contributor {
21
21
  public readonly name: LocalizedString;
22
22
 
23
23
  /** The string used to sort the name of the contributor. */
24
- public readonly sortAs?: string;
24
+ public readonly sortAs?: LocalizedString;
25
25
 
26
26
  /** An unambiguous reference to this contributor. */
27
27
  public readonly identifier?: string;
@@ -43,7 +43,7 @@ export class Contributor {
43
43
  */
44
44
  constructor(values: {
45
45
  name: LocalizedString;
46
- sortAs?: string;
46
+ sortAs?: LocalizedString;
47
47
  identifier?: string;
48
48
  altIdentifiers?: Set<AltIdentifier>;
49
49
  roles?: Set<string>;
@@ -74,7 +74,7 @@ export class Contributor {
74
74
  if (!json.name) return;
75
75
  return new Contributor({
76
76
  name: LocalizedString.deserialize(json.name) as LocalizedString,
77
- sortAs: json.sortAs,
77
+ sortAs: LocalizedString.deserialize(json.sortAs),
78
78
  identifier: json.identifier,
79
79
  altIdentifiers: json.altIdentifier
80
80
  ? (Array.isArray(json.altIdentifier)
@@ -98,7 +98,7 @@ export class Contributor {
98
98
  */
99
99
  public serialize(): any {
100
100
  const json: any = { name: this.name.serialize() };
101
- if (this.sortAs !== undefined) json.sortAs = this.sortAs;
101
+ if (this.sortAs !== undefined) json.sortAs = this.sortAs.serialize();
102
102
  if (this.identifier !== undefined) json.identifier = this.identifier;
103
103
  if (this.altIdentifiers) json.altIdentifier = setToArray(this.altIdentifiers).map(altId => altId.serialize());
104
104
  if (this.roles) json.role = setToArray(this.roles);
@@ -9,7 +9,7 @@
9
9
  export class LocalizedString {
10
10
  public readonly translations: { [key: string]: string };
11
11
 
12
- public static readonly UNDEFINED_LANGUAGE = 'undefined';
12
+ public static readonly UNDEFINED_LANGUAGE = 'und';
13
13
  public static readonly LANGUAGE_EN = 'en';
14
14
 
15
15
  /**
@@ -14,7 +14,7 @@ export class Subject {
14
14
  public readonly name: LocalizedString;
15
15
 
16
16
  /** Provides a string that a machine can sort. */
17
- public readonly sortAs?: string;
17
+ public readonly sortAs?: LocalizedString;
18
18
 
19
19
  /** EPUB 3.1 opf:term. */
20
20
  public readonly code?: string;
@@ -28,7 +28,7 @@ export class Subject {
28
28
  /** Creates a [Subject]. */
29
29
  constructor(values: {
30
30
  name: LocalizedString;
31
- sortAs?: string;
31
+ sortAs?: LocalizedString;
32
32
  code?: string;
33
33
  scheme?: string;
34
34
  links?: Links;
@@ -56,7 +56,7 @@ export class Subject {
56
56
  if (!json.name) return;
57
57
  return new Subject({
58
58
  name: LocalizedString.deserialize(json.name) as LocalizedString,
59
- sortAs: json.sortAs,
59
+ sortAs: json.sortAs ? LocalizedString.deserialize(json.sortAs) : undefined,
60
60
  code: json.code,
61
61
  scheme: json.scheme,
62
62
  links: Links.deserialize(json.links),
@@ -69,7 +69,7 @@ export class Subject {
69
69
  */
70
70
  public serialize(): any {
71
71
  const json: any = { name: this.name.serialize() };
72
- if (this.sortAs !== undefined) json.sortAs = this.sortAs;
72
+ if (this.sortAs !== undefined) json.sortAs = this.sortAs.serialize();
73
73
  if (this.code !== undefined) json.code = this.code;
74
74
  if (this.scheme !== undefined) json.scheme = this.scheme;
75
75
  if (this.links) json.links = this.links.serialize();
@@ -9,7 +9,7 @@ export declare class Contributor {
9
9
  /** The name of the contributor. */
10
10
  readonly name: LocalizedString;
11
11
  /** The string used to sort the name of the contributor. */
12
- readonly sortAs?: string;
12
+ readonly sortAs?: LocalizedString;
13
13
  /** An unambiguous reference to this contributor. */
14
14
  readonly identifier?: string;
15
15
  /** Alternate identifiers for this contributor. */
@@ -25,7 +25,7 @@ export declare class Contributor {
25
25
  */
26
26
  constructor(values: {
27
27
  name: LocalizedString;
28
- sortAs?: string;
28
+ sortAs?: LocalizedString;
29
29
  identifier?: string;
30
30
  altIdentifiers?: Set<AltIdentifier>;
31
31
  roles?: Set<string>;
@@ -5,7 +5,7 @@ export declare class LocalizedString {
5
5
  readonly translations: {
6
6
  [key: string]: string;
7
7
  };
8
- static readonly UNDEFINED_LANGUAGE = "undefined";
8
+ static readonly UNDEFINED_LANGUAGE = "und";
9
9
  static readonly LANGUAGE_EN = "en";
10
10
  /**
11
11
  * translations can be a string or a collection of language/translation pairs,
@@ -7,7 +7,7 @@ export declare class Subject {
7
7
  /** Subject name. */
8
8
  readonly name: LocalizedString;
9
9
  /** Provides a string that a machine can sort. */
10
- readonly sortAs?: string;
10
+ readonly sortAs?: LocalizedString;
11
11
  /** EPUB 3.1 opf:term. */
12
12
  readonly code?: string;
13
13
  /** EPUB 3.1 opf:authority. */
@@ -17,7 +17,7 @@ export declare class Subject {
17
17
  /** Creates a [Subject]. */
18
18
  constructor(values: {
19
19
  name: LocalizedString;
20
- sortAs?: string;
20
+ sortAs?: LocalizedString;
21
21
  code?: string;
22
22
  scheme?: string;
23
23
  links?: Links;