Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Sequence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export class Sequence extends ManifestResource {
getViewingDirection(): ViewingDirection | null {
if (this.getProperty("viewingDirection")) {
return this.getProperty("viewingDirection");
// @ts-ignore
} else if ((<Manifest>this.options.resource).getViewingDirection) {
return (<Manifest>this.options.resource).getViewingDirection();
}
Expand Down
39 changes: 33 additions & 6 deletions src/Utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,20 @@ export class Utils {
parentResource: JSONLDResource,
id: string
): JSONLDResource {
return <JSONLDResource>(
Utils.traverseAndFind(parentResource.__jsonld, "@id", id)
const presentation2Resource = Utils.traverseAndFind(
parentResource.__jsonld,
"@id",
id
);
if (presentation2Resource) {
return presentation2Resource as JSONLDResource;
}

return Utils.traverseAndFind(
parentResource.__jsonld,
"id",
id
) as JSONLDResource;
}

/**
Expand Down Expand Up @@ -1073,6 +1084,7 @@ export class Utils {
}

static getServices(resource: any): Service[] {

let service: any;

// if passing a manifesto-parsed object, use the __jsonld.service property,
Expand All @@ -1084,26 +1096,41 @@ export class Utils {
}

const services: Service[] = [];
if (!service) return services;

// coerce to array
if (!Array.isArray(service)) {
service = [service];
}

if (resource.__jsonld && resource.__jsonld.services) {
service.push(...resource.__jsonld.services);
}

if (service.length === 0) {
return services;
}

for (let i = 0; i < service.length; i++) {
const s: any = service[i];

if (typeof s === "string") {
if (!s) {
continue;
}

const id = typeof s === "string" ? s : s.id || s["@id"];

if (id) {
const r: JSONLDResource = this.getResourceById(
resource.options.resource,
s
id
);

if (r) {
services.push(new Service(r.__jsonld || r, resource.options));
continue;
}
} else {
}
if (typeof s !== "string") {
services.push(new Service(s, resource.options));
}
}
Expand Down
Loading