epubavocado
Advanced tools
Comparing version 0.2.0 to 0.3.0
export * from './models/package.js'; | ||
export * from './models/container.js'; |
@@ -14,1 +14,2 @@ "use strict"; | ||
__exportStar(require("./models/package.js"), exports); | ||
__exportStar(require("./models/container.js"), exports); |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
}; | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Container = exports.Rootfile = exports.ContainerLink = void 0; | ||
var entity_js_1 = require("../mixins/entity.js"); | ||
var resource_js_1 = require("../mixins/resource.js"); | ||
var util_js_1 = require("../util.js"); | ||
var xpath_js_1 = require("../xpath.js"); | ||
var ContainerLink = /** @class */ (function (_super) { | ||
__extends(ContainerLink, _super); | ||
function ContainerLink() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
Object.defineProperty(ContainerLink.prototype, "__typename", { | ||
get: function () { | ||
return 'ContainerLink'; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
ContainerLink.prototype.rel = function () { | ||
var rel = this._resolve('./@rel'); | ||
if (rel) { | ||
return util_js_1.splitRelAttribute(rel); | ||
} | ||
return []; | ||
}; | ||
return ContainerLink; | ||
}(resource_js_1.Resource(entity_js_1.Entity))); | ||
exports.ContainerLink = ContainerLink; | ||
var Rootfile = /** @class */ (function (_super) { | ||
__extends(Rootfile, _super); | ||
function Rootfile() { | ||
return _super !== null && _super.apply(this, arguments) || this; | ||
} | ||
Object.defineProperty(Rootfile.prototype, "__typename", { | ||
get: function () { | ||
return 'Rootfile'; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Rootfile.prototype.fullPath = function () { | ||
return this._resolve('./@full-path'); | ||
}; | ||
Rootfile.prototype.mediaType = function () { | ||
return this._resolve('./@media-type'); | ||
}; | ||
return Rootfile; | ||
}(entity_js_1.Entity)); | ||
exports.Rootfile = Rootfile; | ||
var Container = /** @class */ (function (_super) { | ||
__extends(Container, _super); | ||
function Container(doc) { | ||
return _super.call(this, xpath_js_1.select('/ocf:container', doc)) || this; | ||
} | ||
Object.defineProperty(Container.prototype, "__typename", { | ||
get: function () { | ||
return 'Container'; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Container.prototype.version = function () { | ||
return this._resolve('./@version'); | ||
}; | ||
Container.prototype.rootfiles = function () { | ||
return this._resolveAll('./ocf:rootfiles/ocf:rootfile', Rootfile); | ||
}; | ||
Container.prototype.links = function () { | ||
return this._resolveAll('./ocf:links/ocf:link', ContainerLink); | ||
}; | ||
Container.prototype.defaultRendition = function () { | ||
return this.rootfiles()[0]; | ||
}; | ||
return Container; | ||
}(entity_js_1.Entity)); | ||
exports.Container = Container; |
@@ -527,4 +527,3 @@ "use strict"; | ||
if (rel) { | ||
// normalize spaces and split space separated words | ||
return rel.replace(/\s+/g, ' ').split(' '); | ||
return util_js_1.splitRelAttribute(rel); | ||
} | ||
@@ -531,0 +530,0 @@ return []; |
export declare const toArray: <T>(valueOrArray: T | T[]) => T[]; | ||
export declare const splitRelAttribute: (rel: string) => string[]; | ||
export declare type Maybe<T> = null | undefined | T; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.toArray = void 0; | ||
exports.splitRelAttribute = exports.toArray = void 0; | ||
var toArray = function (valueOrArray) { | ||
@@ -14,1 +14,6 @@ if (!valueOrArray) { | ||
exports.toArray = toArray; | ||
var splitRelAttribute = function (rel) { | ||
// normalize spaces and split space separated words | ||
return rel.replace(/\s+/g, ' ').split(' '); | ||
}; | ||
exports.splitRelAttribute = splitRelAttribute; |
@@ -7,2 +7,3 @@ import xpath from 'xpath'; | ||
dc: string; | ||
ocf: string; | ||
}; | ||
@@ -9,0 +10,0 @@ export declare const selectAll: xpath.XPathSelect; |
@@ -19,2 +19,3 @@ "use strict"; | ||
dc: 'http://purl.org/dc/elements/1.1/', | ||
ocf: 'urn:oasis:names:tc:opendocument:xmlns:container', | ||
}; | ||
@@ -21,0 +22,0 @@ exports.selectAll = xpath_1.default.useNamespaces(exports.namespaceMap); |
export * from './models/package.js'; | ||
export * from './models/container.js'; |
export * from './models/package.js'; | ||
export * from './models/container.js'; |
@@ -1,1 +0,47 @@ | ||
"use strict"; | ||
import { Entity } from '../mixins/entity.js'; | ||
import { Resource } from '../mixins/resource.js'; | ||
import { splitRelAttribute } from '../util.js'; | ||
import { select } from '../xpath.js'; | ||
export class ContainerLink extends Resource(Entity) { | ||
get __typename() { | ||
return 'ContainerLink'; | ||
} | ||
rel() { | ||
const rel = this._resolve('./@rel'); | ||
if (rel) { | ||
return splitRelAttribute(rel); | ||
} | ||
return []; | ||
} | ||
} | ||
export class Rootfile extends Entity { | ||
get __typename() { | ||
return 'Rootfile'; | ||
} | ||
fullPath() { | ||
return this._resolve('./@full-path'); | ||
} | ||
mediaType() { | ||
return this._resolve('./@media-type'); | ||
} | ||
} | ||
export class Container extends Entity { | ||
get __typename() { | ||
return 'Container'; | ||
} | ||
constructor(doc) { | ||
super(select('/ocf:container', doc)); | ||
} | ||
version() { | ||
return this._resolve('./@version'); | ||
} | ||
rootfiles() { | ||
return this._resolveAll('./ocf:rootfiles/ocf:rootfile', Rootfile); | ||
} | ||
links() { | ||
return this._resolveAll('./ocf:links/ocf:link', ContainerLink); | ||
} | ||
defaultRendition() { | ||
return this.rootfiles()[0]; | ||
} | ||
} |
@@ -10,3 +10,3 @@ import { Entity } from '../mixins/entity.js'; | ||
import { Value } from '../mixins/value.js'; | ||
import { toArray } from '../util.js'; | ||
import { splitRelAttribute, toArray } from '../util.js'; | ||
import { select } from '../xpath.js'; | ||
@@ -264,4 +264,3 @@ // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types | ||
if (rel) { | ||
// normalize spaces and split space separated words | ||
return rel.replace(/\s+/g, ' ').split(' '); | ||
return splitRelAttribute(rel); | ||
} | ||
@@ -268,0 +267,0 @@ return []; |
export declare const toArray: <T>(valueOrArray: T | T[]) => T[]; | ||
export declare const splitRelAttribute: (rel: string) => string[]; | ||
export declare type Maybe<T> = null | undefined | T; |
@@ -10,1 +10,4 @@ export const toArray = (valueOrArray) => { | ||
}; | ||
export const splitRelAttribute = (rel) => | ||
// normalize spaces and split space separated words | ||
rel.replace(/\s+/g, ' ').split(' '); |
@@ -7,2 +7,3 @@ import xpath from 'xpath'; | ||
dc: string; | ||
ocf: string; | ||
}; | ||
@@ -9,0 +10,0 @@ export declare const selectAll: xpath.XPathSelect; |
@@ -6,2 +6,3 @@ import xpath from 'xpath'; | ||
dc: 'http://purl.org/dc/elements/1.1/', | ||
ocf: 'urn:oasis:names:tc:opendocument:xmlns:container', | ||
}; | ||
@@ -8,0 +9,0 @@ export const selectAll = xpath.useNamespaces(namespaceMap); |
{ | ||
"name": "epubavocado", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "I am an EPUB object model aspiring to be standards compliant.", | ||
@@ -5,0 +5,0 @@ "main": "lib/cjs/mod.js", |
@@ -24,3 +24,3 @@ [![npm](https://img.shields.io/npm/v/epubavocado)](https://www.npmjs.com/package/epubavocado) | ||
- [EPUB Open Container Format (OCF) 3.2](https://www.w3.org/publishing/epub32/epub-ocf.html) | ||
- [ ] [3.5.2.1 Container File (`container.xml`)](https://www.w3.org/publishing/epub32/epub-ocf.html#sec-container-metainf-container.xml) | ||
- [x] [3.5.2.1 Container File (`container.xml`)](https://www.w3.org/publishing/epub32/epub-ocf.html#sec-container-metainf-container.xml) | ||
- [EPUB Packages 3.2](https://www.w3.org/publishing/epub32/epub-packages.html) | ||
@@ -55,3 +55,3 @@ - [x] [3.4.1 The `package` Element](https://www.w3.org/publishing/epub32/epub-packages.html#sec-package-elem) | ||
See this [example](https://github.com/jccr/epubavocado/blob/main/test/package.test.ts) from the tests. | ||
See this [example](https://github.com/jccr/epubavocado/blob/main/test/package.spec.ts) from the tests. | ||
@@ -58,0 +58,0 @@ ### GraphQL.js |
export * from './models/package.js' | ||
export * from './models/container.js' |
@@ -11,3 +11,3 @@ import { Constructor } from '../mixins/constructor.js' | ||
import { Value } from '../mixins/value.js' | ||
import { Maybe, toArray } from '../util.js' | ||
import { Maybe, splitRelAttribute, toArray } from '../util.js' | ||
import { select } from '../xpath.js' | ||
@@ -379,4 +379,3 @@ | ||
if (rel) { | ||
// normalize spaces and split space separated words | ||
return rel.replace(/\s+/g, ' ').split(' ') | ||
return splitRelAttribute(rel) | ||
} | ||
@@ -383,0 +382,0 @@ return [] |
@@ -11,2 +11,6 @@ export const toArray = <T>(valueOrArray: T | T[]): T[] => { | ||
export const splitRelAttribute = (rel: string): string[] => | ||
// normalize spaces and split space separated words | ||
rel.replace(/\s+/g, ' ').split(' ') | ||
export type Maybe<T> = null | undefined | T |
@@ -8,2 +8,3 @@ import xpath from 'xpath' | ||
dc: 'http://purl.org/dc/elements/1.1/', | ||
ocf: 'urn:oasis:names:tc:opendocument:xmlns:container', | ||
} | ||
@@ -10,0 +11,0 @@ |
273474
102
5966