diff --git a/packages/legacy/package.json b/packages/legacy/package.json deleted file mode 100644 index 679d42d7..00000000 --- a/packages/legacy/package.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "name": "@hyperion-framework/legacy", - "version": "0.1.0", - "private": true, - "main": "dist/hyperion-framework.js", - "umd:main": "dist/hyperion-framework.umd.js", - "module": "dist/hyperion-framework.mjs", - "source": "src/index.ts", - "types": "dist/index.d.ts", - "author": "Stephen Fraser ", - "license": "MIT", - "scripts": { - "build": "microbundle src/index.ts -o dist/hyperion-framework.js", - "start": "microbundle watch" - }, - "devDependencies": { - "microbundle": "^0.9.0", - "prettier": "^1.15.3", - "tslib": "^1.9.3", - "tslint": "^5.12.0", - "tslint-config-prettier": "^1.17.0", - "tslint-plugin-prettier": "^2.0.1" - }, - "dependencies": { - "@hyperion-framework/types": "^0.1.0", - "@types/object-hash": "^1.2.0", - "@types/traverse": "^0.6.32", - "normalizr": "^3.3.0", - "object-hash": "^1.3.1", - "traverse": "^0.6.6", - "typesafe-actions": "^3.0.0" - } -} diff --git a/packages/legacy/src/index.ts b/packages/legacy/src/index.ts deleted file mode 100644 index cd67447c..00000000 --- a/packages/legacy/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './utility/cast'; diff --git a/packages/legacy/src/utility/annotations.ts b/packages/legacy/src/utility/annotations.ts deleted file mode 100644 index 57996621..00000000 --- a/packages/legacy/src/utility/annotations.ts +++ /dev/null @@ -1,28 +0,0 @@ -type AnnotationSelector = { - unit: 'percent' | 'pixel'; - x: number; - y: number; - width: number; - height: number; - id: string; -}; - -export function parseSelectorTarget(toParse: string): AnnotationSelector | string { - if (!toParse) { - return toParse; - } - const W3C_SELECTOR = /[#&?](xywh=)?(pixel:|percent:)?([0-9]+(\.[0-9]+)?),([0-9]+(\.[0-9]+)?),([0-9]+(\.[0-9]+)?),([0-9]+(\.[0-9]+)?)/; - const match = W3C_SELECTOR.exec(toParse); - - if (match) { - return { - unit: match[2] === 'percent:' ? 'percent' : 'pixel', - x: parseFloat(match[3]), - y: parseFloat(match[5]), - width: parseFloat(match[7]), - height: parseFloat(match[9]), - id: toParse.split('#')[0], - }; - } - return toParse; -} diff --git a/packages/legacy/src/utility/cast.ts b/packages/legacy/src/utility/cast.ts deleted file mode 100644 index 8a01e0d7..00000000 --- a/packages/legacy/src/utility/cast.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { Annotation, AnnotationPage, Canvas, Collection, Manifest } from '@hyperion-framework/types'; - -export function castTo(jsonLd: unknown): T { - return jsonLd as T; -} - -export const cast = { - toManifest: (jsonLd: unknown) => castTo(jsonLd), - toCollection: (jsonLd: unknown) => castTo(jsonLd), - toCanvas: (jsonLd: unknown) => castTo(jsonLd), - toAnnotationPage: (jsonLd: unknown) => castTo(jsonLd), - toAnnotation: (jsonLd: unknown) => castTo(jsonLd), -}; diff --git a/packages/legacy/src/utility/compatibility.ts b/packages/legacy/src/utility/compatibility.ts deleted file mode 100644 index 1e6658db..00000000 --- a/packages/legacy/src/utility/compatibility.ts +++ /dev/null @@ -1,36 +0,0 @@ -import traverse from 'traverse'; -import hash from 'object-hash'; - -type Process = (obj: any) => void; - -export function buildProcess(processes: Process[]) { - return (jsonLd: any): any => { - traverse(jsonLd).forEach(function(obj: any) { - // tslint:disable-next-line:no-invalid-this - processes.forEach(process => process.call(this, [obj])); - }); - return jsonLd; - }; -} - -export function addMissingIds(obj: any): void { - // Presentation 3 has only one optional. - // But then again, some common missing ids... - if ( - (obj.type === 'AnnotationPage' || - obj.type === 'Annotation' || - obj.type === 'Application' || - obj.type === 'Dataset' || - obj.type === 'Image' || - obj.type === 'Sound' || - obj.type === 'Text' || - obj.type === 'Video' || - obj.type === 'TextualBody' || - obj.profile) && - !obj.id - ) { - // @ts-ignore - // tslint:disable-next-line:no-invalid-this - this.update({ ...obj, id: `https://hyperion/${hash(obj)}` }); - } -} diff --git a/packages/legacy/src/wrappers/Canvas.ts b/packages/legacy/src/wrappers/Canvas.ts deleted file mode 100644 index 5fb31843..00000000 --- a/packages/legacy/src/wrappers/Canvas.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { - AnnotationPage, - Canvas, - ContentResource, - InternationalString, - Manifest, - MetadataItem, - ResourceType, - Service, - ViewingDirection, -} from '@hyperion-framework/types'; - -class CanvasWrapper implements Canvas { - behaviour: string[] = []; - homepage: ContentResource[] = []; - id: string; - logo: ContentResource[] = []; - motivation: string = ''; - partOf: Manifest[] = []; - rendering: ContentResource[] = []; - seeAlso: ContentResource[] = []; - service: Service[] = []; - start: Canvas[] = []; - readonly type: ResourceType = 'Canvas'; - viewingDirection: ViewingDirection = 'left-to-right'; - label: InternationalString; - items: AnnotationPage[] = []; - duration: number = 0; - height: number; - metadata: MetadataItem[] = []; - navDate: string | null = null; - posterCanvas: any; - requiredStatement: MetadataItem | null = null; - rights: string | null = null; - summary: InternationalString | null = null; - thumbnail: any; - width: number; - - constructor(id: string, label: InternationalString, width: number, height: number) { - this.id = id; - this.label = label; - this.width = width; - this.height = height; - } -} - -export default CanvasWrapper; diff --git a/packages/legacy/src/wrappers/Collection.ts b/packages/legacy/src/wrappers/Collection.ts deleted file mode 100644 index 485d7b1f..00000000 --- a/packages/legacy/src/wrappers/Collection.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { - AnnotationCollection, - Canvas, - Collection, - ContentResource, InternationalString, - Manifest, ResourceType, Service, ViewingDirection -} from '@hyperion-framework/types'; - -class CollectionWrapper implements Collection { - id: string; - behaviour = []; - homepage: ContentResource[] = []; - logo: ContentResource[] = []; - motivation: string = ''; - partOf: Array = []; - rendering: ContentResource[] = []; - seeAlso: ContentResource[] = []; - service: Service[] = []; - type: ResourceType = 'Collection'; - viewingDirection: ViewingDirection = 'left-to-right'; - label: InternationalString; - items: Array = []; - - constructor(id: string, label: InternationalString) { - this.id = id; - this.label = label; - } -} - -export default CollectionWrapper; diff --git a/packages/legacy/src/wrappers/Manifest.ts b/packages/legacy/src/wrappers/Manifest.ts deleted file mode 100644 index eaf7914a..00000000 --- a/packages/legacy/src/wrappers/Manifest.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { - Manifest, - InternationalString, - ContentResource, - Canvas, - Service, - Collection, - ResourceType, - ViewingDirection, -} from '@hyperion-framework/types'; - -class ManifestWrapper implements Manifest { - behaviour: string[] = []; - homepage: ContentResource[] = []; - id: string; - logo: ContentResource[] = []; - motivation: string = ''; - partOf: Collection[] = []; - rendering: ContentResource[] = []; - seeAlso: ContentResource[] = []; - service: Service[] = []; - start: Canvas[] = []; - readonly type: ResourceType = 'Manifest'; - viewingDirection: ViewingDirection = 'left-to-right'; - label: InternationalString; - items: Canvas[] = []; - - constructor(id: string, label: InternationalString) { - this.id = id; - this.label = label; - } -} - -export default ManifestWrapper; diff --git a/packages/legacy/tsconfig.json b/packages/legacy/tsconfig.json deleted file mode 100644 index 4130f9fb..00000000 --- a/packages/legacy/tsconfig.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "extends": "../../tsconfig.json", - "compilerOptions": { - "rootDir": "src", - "outDir": "dist/" - } -}