From f076cc16665cd791183972073847879b20182b4b Mon Sep 17 00:00:00 2001 From: Angelo Ashmore Date: Fri, 8 Apr 2016 17:03:09 -1000 Subject: [PATCH] Remove format-date dependency, add documentation, fix dist (#16) --- .babelrc | 7 +- .eslintrc.json | 31 - .gitignore | 1 + .npmignore | 2 + README.md | 33 +- dist/ics-js.js | 2093 +---------------- esdoc.json | 13 + package.json | 42 +- src/Component.js | 247 +- src/ICS.js | 16 - src/Property.js | 89 +- src/components/VALARM.js | 14 +- src/components/VCALENDAR.js | 17 +- src/components/VEVENT.js | 21 +- src/components/VTODO.js | 17 +- src/components/validators/index.js | 1 - src/components/validators/required.js | 20 - src/components/validators/singleton.js | 21 +- src/components/validators/unique.js | 22 +- src/constants.js | 6 + src/errors/InvalidComponentError.js | 8 +- src/errors/InvalidProvidedComponentError.js | 9 +- src/errors/InvalidProvidedPropError.js | 9 +- src/errors/ValidationError.js | 8 +- src/helpers/formatDate.js | 27 + src/helpers/index.js | 1 + src/index.js | 3 + src/properties/CATEGORIES.js | 21 +- src/properties/CREATED.js | 5 + src/properties/DTEND.js | 5 + src/properties/DTSTAMP.js | 34 +- src/properties/DTSTART.js | 5 + src/properties/DUE.js | 5 + src/properties/EXDATE.js | 39 +- src/properties/GEO.js | 21 +- src/properties/LAST_MODIFIED.js | 5 + src/properties/RDATE.js | 5 + src/properties/TRANSP.js | 22 +- src/properties/UID.js | 21 +- src/properties/VERSION.js | 21 +- src/properties/_default.js | 7 - src/properties/base.js | 14 + src/properties/index.js | 2 +- test/helpers/propertyTest.js | 14 +- test/integration/ics-js.js | 16 +- test/unit/Component.js | 152 +- test/unit/ICS.js | 24 - test/unit/Property.js | 67 +- test/unit/properties/DTSTAMP.js | 2 +- test/unit/properties/EXDATE.js | 2 +- test/unit/properties/TRANSP.js | 7 +- test/unit/properties/UID.js | 7 +- test/unit/properties/{_default.js => base.js} | 14 +- webpack.config.js | 48 +- 54 files changed, 852 insertions(+), 2511 deletions(-) delete mode 100644 .eslintrc.json create mode 100644 .npmignore create mode 100644 esdoc.json delete mode 100644 src/ICS.js delete mode 100644 src/components/validators/required.js create mode 100644 src/constants.js create mode 100644 src/helpers/formatDate.js create mode 100644 src/helpers/index.js create mode 100644 src/index.js delete mode 100644 src/properties/_default.js create mode 100644 src/properties/base.js delete mode 100644 test/unit/ICS.js rename test/unit/properties/{_default.js => base.js} (58%) diff --git a/.babelrc b/.babelrc index 5e09db1..d55ba80 100644 --- a/.babelrc +++ b/.babelrc @@ -1,7 +1,6 @@ { - "presets": ["es2015"], - "plugins": [ - "transform-class-properties", - "transform-export-extensions" + "presets": [ + "es2015", + "stage-0" ] } diff --git a/.eslintrc.json b/.eslintrc.json deleted file mode 100644 index d7302a6..0000000 --- a/.eslintrc.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "env": { - "node": true, - "browser": true, - "es6": true, - "mocha": true - }, - "extends": "eslint:recommended", - "parserOptions": { - "sourceType": "module" - }, - "parser": "babel-eslint", - "rules": { - "indent": [ - 2, - 2 - ], - "linebreak-style": [ - 2, - "unix" - ], - "quotes": [ - 2, - "single" - ], - "semi": [ - 2, - "always" - ] - } -} diff --git a/.gitignore b/.gitignore index 07e6e47..8b715c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /node_modules +/esdoc diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..bee8070 --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +/src +/esdoc \ No newline at end of file diff --git a/README.md b/README.md index 3c1aaa2..29abd9c 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,26 @@ # ics-js -Create ICS files in ES6. + +Create ICS files in ES6. Works in Node.js or in the browser. ## Status [![npm version](https://badge.fury.io/js/ics-js.svg)](http://badge.fury.io/js/ics-js) [![Build Status](https://secure.travis-ci.org/angeloashmore/ics-js.svg?branch=master)](http://travis-ci.org/angeloashmore/ics-js?branch=master) +[![Canonical Code Style](https://img.shields.io/badge/code%20style-canonical-blue.svg?style=flat)](https://github.com/gajus/canonical) ## Installation -`npm install ics-js` +```shell +npm install --save ics-js +``` + +## Documentation + +[![Documentation](https://doc.esdoc.org/github.com/angeloashmore/ics-js/badge.svg)](https://doc.esdoc.org/github.com/angeloashmore/ics-js/) -## Usage +[View documentation on ESDoc](https://doc.esdoc.org/github.com/angeloashmore/ics-js/). + +## Quick Guide Import the module: @@ -34,11 +44,14 @@ The following components are implenented: ### Add properties to a component ```js -// Component#addProp(name, value, props) -// -// name: Name of the property -// value: Value of the property -// props: Object with properties for the property +/** + * Component#addProp(name, value, props = {}, skipTransformer = false) + * + * @param {string} name - Name of the property (e.g. DTSTAMP). + * @param {*} [value] - Value of the property. + * @param {Object} [props={}] - Object of properties for the property. Object keys and values are directly injected. + * @param {boolean} [skipTransformer=false] - Explicitly determine if the property's value is transformed. + */ cal.addProp('VERSION', 2) // Number(2) is converted to '2.0' cal.addProp('PRODID', 'XYZ Corp'); @@ -87,7 +100,3 @@ cal.toString(); // Returns a string cal.toBlob(); // Returns a Blob cal.toBase64(); // Returns a Promise with a base64 string as the resolved value ``` - -## Acknowledgements - -Inspired by [nwcell/ics.js](https://github.com/nwcell/ics.js) diff --git a/dist/ics-js.js b/dist/ics-js.js index 37e09cc..7305a54 100644 --- a/dist/ics-js.js +++ b/dist/ics-js.js @@ -1,2091 +1,2 @@ -(function webpackUniversalModuleDefinition(root, factory) { - if(typeof exports === 'object' && typeof module === 'object') - module.exports = factory(); - else if(typeof define === 'function' && define.amd) - define([], factory); - else { - var a = factory(); - for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i]; - } -})(this, function() { -return /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; - -/******/ // The require function -/******/ function __webpack_require__(moduleId) { - -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) -/******/ return installedModules[moduleId].exports; - -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ exports: {}, -/******/ id: moduleId, -/******/ loaded: false -/******/ }; - -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); - -/******/ // Flag the module as loaded -/******/ module.loaded = true; - -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } - - -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; - -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; - -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = "/dist/"; - -/******/ // Load entry module and return exports -/******/ return __webpack_require__(0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ function(module, exports, __webpack_require__) { - - module.exports = __webpack_require__(4); - - -/***/ }, -/* 1 */ -/***/ function(module, exports) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Property = function () { - function Property(value, props) { - var skipTransformer = arguments.length <= 2 || arguments[2] === undefined ? false : arguments[2]; - - _classCallCheck(this, Property); - - this.value = value; - this.props = props || {}; - this.skipTransformer = skipTransformer; - } - - _createClass(Property, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return true; - } - }, { - key: 'transformer', - value: function transformer() { - return this.value; - } - }, { - key: 'transformedValue', - value: function transformedValue() { - if (this.skipTransformer || this.shortTransformer()) return this.value; - return this.transformer(); - } - }, { - key: 'transformedProps', - value: function transformedProps() { - var props = []; - for (var key in this.props) { - props.push(key + '=' + this.props[key]); - }return props.join(';'); - } - }, { - key: 'toString', - value: function toString() { - var hasProps = Object.keys(this.props).length > 0; - var key = this.constructor.propName + (hasProps ? ';' + this.transformedProps() : ''); - var value = this.transformedValue(); - var keyValuePair = key + ':' + value; - return keyValuePair.match(/.{1,75}/g).join('\r\n '); - } - }]); - - return Property; - }(); - - Property.keyRegex = /^[A-Z]([A-Z]|-)*[A-Z]$/; - Property.propName = 'Property'; - exports.default = Property; - -/***/ }, -/* 2 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _ICS = __webpack_require__(4); - - var _ICS2 = _interopRequireDefault(_ICS); - - var _properties = __webpack_require__(34); - - var properties = _interopRequireWildcard(_properties); - - var _errors = __webpack_require__(6); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var Component = function () { - function Component() { - _classCallCheck(this, Component); - - this.prefix = 'BEGIN:' + this.constructor.componentName; - this.suffix = 'END:' + this.constructor.componentName; - - this._props = []; - this._components = []; - } - - _createClass(Component, [{ - key: 'props', - value: function props() { - return Object.freeze(this._props.slice(0)); - } - }, { - key: 'propNames', - value: function propNames() { - return Object.freeze(this.props().map(function (prop) { - return prop.constructor.propName; - })); - } - - // Set props to null or {} if not needed - - }, { - key: 'addProp', - value: function addProp(name, value, props, skipTransformer) { - var _this = this; - - var validProps = this.constructor.validProps; - - if (!validProps[name]) throw new _errors.InvalidProvidedPropError(); - - var PropClass = properties[name] || properties._default(name); - var prop = new PropClass(value, props, skipTransformer); - validProps[name].forEach(function (validator) { - return validator(_this, prop); - }); - - this._props.push(prop); - - return prop; - } - }, { - key: 'components', - value: function components() { - return Object.freeze(this._components.slice(0)); - } - }, { - key: 'componentNames', - value: function componentNames() { - return Object.freeze(this.components().map(function (prop) { - return prop.constructor.componentName; - })); - } - }, { - key: 'addComponent', - value: function addComponent(component) { - var _this2 = this; - - var validComponents = this.constructor.validComponents; - var componentName = component.constructor.componentName; - - - if (!(component instanceof Component)) throw new TypeError('Expected `component` to be an instance of Component.'); - if (!validComponents[componentName]) throw new _errors.InvalidProvidedComponentError(); - - validComponents[componentName].forEach(function (validator) { - return validator(_this2, component); - }); - - this._components.push(component); - return component; - } - }, { - key: 'reset', - value: function reset() { - this._props = this._components = []; - } - }, { - key: 'validateRequired', - value: function validateRequired() { - var requiredProps = this.constructor.requiredProps; - - - var intersection = Component._intersect(requiredProps, this.propNames()); - - if (intersection.length > 0) throw new _errors.InvalidComponentError(); - - return true; - } - }, { - key: 'toString', - value: function toString() { - this.validateRequired(); - - var props = this._props.map(function (prop) { - return prop.toString(); - }); - var components = this._components.map(function (component) { - return component.toString(); - }); - - return [this.prefix].concat(_toConsumableArray(props), _toConsumableArray(components), [this.suffix]).join(this.constructor.separator); - } - }, { - key: 'toBlob', - value: function toBlob() { - return new Blob([this.toString()], { type: _ICS2.default.MIME_TYPE }); - } - }, { - key: 'toBase64', - value: function toBase64() { - var blob = this.toBlob(); - var reader = new window.FileReader(); - - return new Promise(function (resolve, reject) { - reader.readAsDataURL(blob); - reader.onloadend = function () { - return resolve(reader.result); - }; - reader.onerror = function () { - return reject(reader.error); - }; - reader.onabort = function () { - return reject(); - }; - }); - } - }], [{ - key: '_intersect', - value: function _intersect(a, b) { - var b_ = new Set(b); - return a.filter(function (item) { - return !b_.has(item); - }); - } - }]); - - return Component; - }(); - - Component.separator = '\r\n'; - Component.requiredProps = []; - Component.validProps = {}; - Component.validComponents = {}; - exports.default = Component; - -/***/ }, -/* 3 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _formatoid = __webpack_require__(8); - - var _formatoid2 = _interopRequireDefault(_formatoid); - - var _ICS = __webpack_require__(4); - - var _ICS2 = _interopRequireDefault(_ICS); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var DTSTAMP = function (_Property) { - _inherits(DTSTAMP, _Property); - - function DTSTAMP() { - _classCallCheck(this, DTSTAMP); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(DTSTAMP).apply(this, arguments)); - } - - _createClass(DTSTAMP, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return !(this.value instanceof Date); - } - }, { - key: 'transformer', - value: function transformer() { - var valueIsDate = this.props.VALUE == 'DATE'; - - if (valueIsDate) { - // Remove timezone offset - var offset = this.value.getTimezoneOffset() * 60000; - this.value = new Date(this.value.getTime() + offset); - } - - var format = valueIsDate ? _ICS2.default.DateFormat : _ICS2.default.DateTimeFormat; - return (0, _formatoid2.default)(this.value, format); - } - }]); - - return DTSTAMP; - }(_Property3.default); - - DTSTAMP.propName = 'DTSTAMP'; - exports.default = DTSTAMP; - -/***/ }, -/* 4 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Property = __webpack_require__(1); - - var _Property2 = _interopRequireDefault(_Property); - - var _Component = __webpack_require__(2); - - var _Component2 = _interopRequireDefault(_Component); - - var _components = __webpack_require__(13); - - var components = _interopRequireWildcard(_components); - - function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - var ICS = function ICS() { - _classCallCheck(this, ICS); - }; - - ICS.Property = _Property2.default; - ICS.Component = _Component2.default; - ICS.MIME_TYPE = 'text/calendar'; - ICS.DateFormat = 'YYYYMMDD'; - ICS.DateTimeFormat = 'YYYYMMDDTHHmmss'; - exports.default = ICS; - - - for (var componentName in components) { - ICS[componentName] = components[componentName]; - } - -/***/ }, -/* 5 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.unique = exports.singleton = exports.required = undefined; - - var _required2 = __webpack_require__(14); - - var _required3 = _interopRequireDefault(_required2); - - var _singleton2 = __webpack_require__(15); - - var _singleton3 = _interopRequireDefault(_singleton2); - - var _unique2 = __webpack_require__(16); - - var _unique3 = _interopRequireDefault(_unique2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.required = _required3.default; - exports.singleton = _singleton3.default; - exports.unique = _unique3.default; - -/***/ }, -/* 6 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.ValidationError = exports.InvalidProvidedPropError = exports.InvalidProvidedComponentError = exports.InvalidComponentError = undefined; - - var _InvalidComponentError2 = __webpack_require__(17); - - var _InvalidComponentError3 = _interopRequireDefault(_InvalidComponentError2); - - var _InvalidProvidedComponentError2 = __webpack_require__(18); - - var _InvalidProvidedComponentError3 = _interopRequireDefault(_InvalidProvidedComponentError2); - - var _InvalidProvidedPropError2 = __webpack_require__(19); - - var _InvalidProvidedPropError3 = _interopRequireDefault(_InvalidProvidedPropError2); - - var _ValidationError2 = __webpack_require__(20); - - var _ValidationError3 = _interopRequireDefault(_ValidationError2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.InvalidComponentError = _InvalidComponentError3.default; - exports.InvalidProvidedComponentError = _InvalidProvidedComponentError3.default; - exports.InvalidProvidedPropError = _InvalidProvidedPropError3.default; - exports.ValidationError = _ValidationError3.default; - -/***/ }, -/* 7 */ -/***/ function(module, exports) { - - "use strict"; - - var _createClass = (function () { function defineProperties(target, props) { for (var key in props) { var prop = props[key]; prop.configurable = true; if (prop.value) prop.writable = true; } Object.defineProperties(target, props); } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); - - var _get = function get(object, property, receiver) { var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc && desc.writable) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } }; - - var _inherits = function (subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) subClass.__proto__ = superClass; }; - - var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }; - - var ExtendableError = (function (_Error) { - function ExtendableError(message) { - _classCallCheck(this, ExtendableError); - - Error.captureStackTrace(this, this.constructor); - this.message = message; - _get(Object.getPrototypeOf(ExtendableError.prototype), "constructor", this).call(this, message); - } - - _inherits(ExtendableError, _Error); - - _createClass(ExtendableError, { - name: { - get: function () { - return this.constructor.name; - } - } - }); - - return ExtendableError; - })(Error); - - module.exports = ExtendableError; - -/***/ }, -/* 8 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - - const months = __webpack_require__(37) - , days = __webpack_require__(35) - , fillo = __webpack_require__(36) - , ParseIt = __webpack_require__(38).Parser - ; - - const parser = new ParseIt({ - // Years - /// 2015 - "YYYY": function (i) { return i.getFullYear(); } - - // 15 - , "YY": function (i) { return i.getFullYear() % 100; } - - // Months - // January - , "MMMM": function (i) { return months[i.getMonth()]; } - - // Jan - , "MMM": function (i) { return months.abbr[i.getMonth()]; } - - // 01 - , "MM": function (i) { return fillo(i.getMonth() + 1); } - - // 1 - , "M": function (i) { return i.getMonth() + 1; } - - // Days - // Sunday - , "dddd": function (i) { return days[i.getDay()]; } - // Sun - , "ddd": function (i) { return days.abbr[i.getDay()]; } - // Su - , "dd": function (i) { return days.short[i.getDay()]; } - // 0 - , "d": function (i) { return i.getDay(); } - - // Dates - // 06 Day in month - , "DD": function (i) { return fillo(i.getDate()); } - // 6 Day in month - , "D": function (i) { return i.getDate(); } - - // AM/PM - // AM/PM - , "A": function (i) { return i.getHours() >= 12 ? "PM" : "AM"; } - // am/pm - , "a": function (i) { return i.getHours() >= 12 ? "pm" : "am"; } - - // Hours - // 08 Hour - , "hh": function (i) { return fillo(i.getHours() % 12 || 12); } - // 8 Hour - , "h": function (i) { return i.getHours() % 12 || 12; } - // (alias) - , "HH": function (i) { return fillo(i.getHours()); } - // (alias) - , "H": function (i) { return i.getHours(); } - - // Minutes - // 09 Minute - , "mm": function (i) { return fillo(i.getMinutes()); } - // 9 Minute - , "m": function (i) { return i.getMinutes(); } - - // Seconds - // 09 Seconds - , "ss": function (i) { return fillo(i.getSeconds()); } - - // 9 Seconds - , "s": function (i) { return i.getSeconds(); } - }); - - /** - * formatoid - * Formats the date into a given format. - * - * Usable format fields: - * - * - **Years** - * - `YYYY` (e.g. `"2015"`) - * - `YY` (e.g. `"15"`) - * - **Months** - * - `MMMM` (e.g. `"January"`) - * - `MMM` (e.g. `"Jan"`) - * - `MM` (e.g. `"01"`) - * - `M` (e.g. `"1"`) - * - **Days** - * - `dddd` (e.g. `"Sunday"`) - * - `ddd` (e.g. `"Sun"`) - * - `dd` (e.g. `"Su"`) - * - `d` (e.g. `"Su"`) - * - **Dates** - * - `DD` (e.g. `"07"`) - * - `D` (e.g. `"7"`) - * - **AM/PM** - * - `A` (e.g. `"AM"`) - * - `a` (e.g. `"pm"`) - * - **Hours** - * - `hh` (e.g. `"07"`)–12 hour format - * - `h` (e.g. `"7"`) - * - `HH` (e.g. `"07"`)–24 hour format - * - `H` (e.g. `"7"`) - * - **Minutes** - * - `mm` (e.g. `"07"`) - * - `m` (e.g. `"7"`) - * - **Seconds** - * - `ss` (e.g. `"07"`) - * - `s` (e.g. `"7"`) - * - * @name formatoid - * @function - * @param {Date} i The date object. - * @param {String} f The date format. - * @return {String} The formatted date (as string). - */ - module.exports = function formatoid (i, f) { - return parser.run(f, [i]); - }; - - -/***/ }, -/* 9 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Component2 = __webpack_require__(2); - - var _Component3 = _interopRequireDefault(_Component2); - - var _validators = __webpack_require__(5); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var VALARM = function (_Component) { - _inherits(VALARM, _Component); - - function VALARM() { - _classCallCheck(this, VALARM); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(VALARM).apply(this, arguments)); - } - - return VALARM; - }(_Component3.default); - - VALARM.componentName = 'VALARM'; - VALARM.requiredProps = ['ACTION', 'TRIGGER']; - VALARM.validProps = { - ACTION: [(0, _validators.singleton)()], - TRIGGER: [(0, _validators.singleton)()], - - DURATION: [(0, _validators.singleton)()], - REPEAT: [(0, _validators.singleton)()], - - DESCRIPTION: [(0, _validators.singleton)()], - SUMMARY: [(0, _validators.singleton)()], - ATTACH: [(0, _validators.singleton)()], - - ATTENDEE: [] - }; - exports.default = VALARM; - -/***/ }, -/* 10 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Component2 = __webpack_require__(2); - - var _Component3 = _interopRequireDefault(_Component2); - - var _validators = __webpack_require__(5); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var VCALENDAR = function (_Component) { - _inherits(VCALENDAR, _Component); - - function VCALENDAR() { - _classCallCheck(this, VCALENDAR); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(VCALENDAR).apply(this, arguments)); - } - - return VCALENDAR; - }(_Component3.default); - - VCALENDAR.componentName = 'VCALENDAR'; - VCALENDAR.requiredProps = ['PRODID', 'VERSION']; - VCALENDAR.validProps = { - PRODID: [(0, _validators.singleton)()], - VERSION: [(0, _validators.singleton)()], - - CALSCALE: [(0, _validators.singleton)()], - METHOD: [(0, _validators.singleton)()] - }; - VCALENDAR.validComponents = { - VEVENT: [], - VTODO: [], - VJOURNAL: [], - VFREEBUSY: [], - VTIMEZONE: [] - }; - exports.default = VCALENDAR; - -/***/ }, -/* 11 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Component2 = __webpack_require__(2); - - var _Component3 = _interopRequireDefault(_Component2); - - var _validators = __webpack_require__(5); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var VEVENT = function (_Component) { - _inherits(VEVENT, _Component); - - function VEVENT() { - _classCallCheck(this, VEVENT); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(VEVENT).apply(this, arguments)); - } - - return VEVENT; - }(_Component3.default); - - VEVENT.componentName = 'VEVENT'; - VEVENT.requiredProps = ['DTSTAMP', 'UID']; - VEVENT.validProps = { - DTSTAMP: [(0, _validators.singleton)()], - UID: [(0, _validators.singleton)()], - - DTSTART: [(0, _validators.singleton)()], - CLASS: [(0, _validators.singleton)()], - CREATED: [(0, _validators.singleton)()], - DESCRIPTION: [(0, _validators.singleton)()], - GEO: [(0, _validators.singleton)()], - 'LAST-MOD': [(0, _validators.singleton)()], - LOCATION: [(0, _validators.singleton)()], - ORGANIZER: [(0, _validators.singleton)()], - PRIORITY: [(0, _validators.singleton)()], - SEQUENCE: [(0, _validators.singleton)()], - STATUS: [(0, _validators.singleton)()], - SUMMARY: [(0, _validators.singleton)()], - TRANSP: [(0, _validators.singleton)()], - URL: [(0, _validators.singleton)()], - 'RECURRENCE-ID': [(0, _validators.singleton)()], - RRULE: [(0, _validators.singleton)()], - - DTEND: [(0, _validators.singleton)(), (0, _validators.unique)(['DURATION'])], - DURATION: [(0, _validators.singleton)(), (0, _validators.unique)(['DTEND'])], - - ATTACH: [], - ATTENDEE: [], - CATEGORIES: [], - COMMENT: [], - CONTACT: [], - EXDATE: [], - 'REQUEST-STATUS': [], - RELATED: [], - RESOURCES: [], - RDATE: [] - }; - VEVENT.validComponents = { - VALARM: [] - }; - exports.default = VEVENT; - -/***/ }, -/* 12 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _Component2 = __webpack_require__(2); - - var _Component3 = _interopRequireDefault(_Component2); - - var _validators = __webpack_require__(5); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var VTODO = function (_Component) { - _inherits(VTODO, _Component); - - function VTODO() { - _classCallCheck(this, VTODO); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(VTODO).apply(this, arguments)); - } - - return VTODO; - }(_Component3.default); - - VTODO.componentName = 'VTODO'; - VTODO.requiredProps = ['DTSTAMP', 'UID']; - VTODO.validProps = { - DTSTAMP: [(0, _validators.singleton)()], - UID: [(0, _validators.singleton)()], - - CLASS: [(0, _validators.singleton)()], - COMPLETED: [(0, _validators.singleton)()], - CREATED: [(0, _validators.singleton)()], - DESCRIPTION: [(0, _validators.singleton)()], - DTSTART: [(0, _validators.singleton)()], - GEO: [(0, _validators.singleton)()], - 'LAST-MOD': [(0, _validators.singleton)()], - LOCATION: [(0, _validators.singleton)()], - ORGANIZER: [(0, _validators.singleton)()], - PERCENT: [(0, _validators.singleton)()], - PRIORITY: [(0, _validators.singleton)()], - 'RECURRENCE-ID': [(0, _validators.singleton)()], - SEQUENCE: [(0, _validators.singleton)()], - STATUS: [(0, _validators.singleton)()], - SUMMARY: [(0, _validators.singleton)()], - URL: [(0, _validators.singleton)()], - RRULE: [(0, _validators.singleton)()], - - DUE: [(0, _validators.singleton)(), (0, _validators.unique)(['DURATION'])], - DURATION: [(0, _validators.singleton)(), (0, _validators.unique)(['DUE'])], - - ATTACH: [], - ATTENDEE: [], - CATEGORIES: [], - COMMENT: [], - CONTACT: [], - EXDATE: [], - 'REQUEST-STATUS': [], - RELATED: [], - RESOURCES: [], - RDATE: [] - }; - VTODO.validComponents = { - VALARM: [] - }; - exports.default = VTODO; - -/***/ }, -/* 13 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.VTODO = exports.VEVENT = exports.VCALENDAR = exports.VALARM = undefined; - - var _VALARM2 = __webpack_require__(9); - - var _VALARM3 = _interopRequireDefault(_VALARM2); - - var _VCALENDAR2 = __webpack_require__(10); - - var _VCALENDAR3 = _interopRequireDefault(_VCALENDAR2); - - var _VEVENT2 = __webpack_require__(11); - - var _VEVENT3 = _interopRequireDefault(_VEVENT2); - - var _VTODO2 = __webpack_require__(12); - - var _VTODO3 = _interopRequireDefault(_VTODO2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports.VALARM = _VALARM3.default; - exports.VCALENDAR = _VCALENDAR3.default; - exports.VEVENT = _VEVENT3.default; - exports.VTODO = _VTODO3.default; - -/***/ }, -/* 14 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = required; - - var _Property = __webpack_require__(1); - - var _Property2 = _interopRequireDefault(_Property); - - var _Component = __webpack_require__(2); - - var _Component2 = _interopRequireDefault(_Component); - - var _errors = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function required() { - return function (component, subject) { - var subjectName = void 0; - var names = void 0; - - if (subject instanceof _Property2.default) { - subjectName = subject.constructor.propName; - names = component.propNames(); - } else if (subject instanceof _Component2.default) { - subjectName = subject.constructor.componentName; - names = component.componentNames(); - } - - if (!names.includes(subjectName)) throw new _errors.ValidationError(); - }; - } - -/***/ }, -/* 15 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = singleton; - - var _Property = __webpack_require__(1); - - var _Property2 = _interopRequireDefault(_Property); - - var _Component = __webpack_require__(2); - - var _Component2 = _interopRequireDefault(_Component); - - var _errors = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function singleton() { - return function (component, subject) { - var subjectName = void 0; - var names = void 0; - - if (subject instanceof _Property2.default) { - subjectName = subject.constructor.propName; - names = component.propNames(); - } else if (subject instanceof _Component2.default) { - subjectName = subject.constructor.componentName; - names = component.componentNames(); - } - - var filtered = names.filter(function (name) { - return name === subjectName; - }); - if (filtered.length >= 1) throw new _errors.ValidationError(); - }; - } - -/***/ }, -/* 16 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.default = unique; - - var _Property = __webpack_require__(1); - - var _Property2 = _interopRequireDefault(_Property); - - var _Component = __webpack_require__(2); - - var _Component2 = _interopRequireDefault(_Component); - - var _errors = __webpack_require__(6); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } - - function unique(uniqueNames) { - return function (component, subject) { - var subjectName = void 0; - var names = void 0; - - if (subject instanceof _Property2.default) { - subjectName = subject.constructor.propName; - names = component.propNames(); - } else if (subject instanceof _Component2.default) { - subjectName = subject.constructor.componentName; - names = component.componentNames(); - } - - var a = new Set(names); - var b = new Set([subjectName].concat(_toConsumableArray(uniqueNames))); - var difference = new Set([].concat(_toConsumableArray(a)).filter(function (x) { - return !b.has(x); - })); - - if (difference > 1) throw new _errors.ValidationError(); - }; - } - -/***/ }, -/* 17 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _es6Error = __webpack_require__(7); - - var _es6Error2 = _interopRequireDefault(_es6Error); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var InvalidComponentError = function (_ExtendableError) { - _inherits(InvalidComponentError, _ExtendableError); - - function InvalidComponentError() { - var message = arguments.length <= 0 || arguments[0] === undefined ? 'Component does not contain all required properties.' : arguments[0]; - - _classCallCheck(this, InvalidComponentError); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(InvalidComponentError).call(this, message)); - } - - return InvalidComponentError; - }(_es6Error2.default); - - exports.default = InvalidComponentError; - -/***/ }, -/* 18 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _es6Error = __webpack_require__(7); - - var _es6Error2 = _interopRequireDefault(_es6Error); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var InvalidProvidedComponentError = function (_ExtendableError) { - _inherits(InvalidProvidedComponentError, _ExtendableError); - - function InvalidProvidedComponentError() { - var message = arguments.length <= 0 || arguments[0] === undefined ? 'Provided component\'s type is not listed in validComponents.' : arguments[0]; - - _classCallCheck(this, InvalidProvidedComponentError); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(InvalidProvidedComponentError).call(this, message)); - } - - return InvalidProvidedComponentError; - }(_es6Error2.default); - - exports.default = InvalidProvidedComponentError; - -/***/ }, -/* 19 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _es6Error = __webpack_require__(7); - - var _es6Error2 = _interopRequireDefault(_es6Error); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var InvalidProvidedPropError = function (_ExtendableError) { - _inherits(InvalidProvidedPropError, _ExtendableError); - - function InvalidProvidedPropError() { - var message = arguments.length <= 0 || arguments[0] === undefined ? 'Provided property\'s type is not listed in validProps.' : arguments[0]; - - _classCallCheck(this, InvalidProvidedPropError); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(InvalidProvidedPropError).call(this, message)); - } - - return InvalidProvidedPropError; - }(_es6Error2.default); - - exports.default = InvalidProvidedPropError; - -/***/ }, -/* 20 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _es6Error = __webpack_require__(7); - - var _es6Error2 = _interopRequireDefault(_es6Error); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var ValidationError = function (_ExtendableError) { - _inherits(ValidationError, _ExtendableError); - - function ValidationError() { - var message = arguments.length <= 0 || arguments[0] === undefined ? 'Provided object was invalid for the recieving component.' : arguments[0]; - - _classCallCheck(this, ValidationError); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(ValidationError).call(this, message)); - } - - return ValidationError; - }(_es6Error2.default); - - exports.default = ValidationError; - -/***/ }, -/* 21 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var CATEGORIES = function (_Property) { - _inherits(CATEGORIES, _Property); - - function CATEGORIES() { - _classCallCheck(this, CATEGORIES); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(CATEGORIES).apply(this, arguments)); - } - - _createClass(CATEGORIES, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return typeof this.value === 'string'; - } - }, { - key: 'transformer', - value: function transformer() { - return this.value.join(','); - } - }]); - - return CATEGORIES; - }(_Property3.default); - - CATEGORIES.propName = 'CATEGORIES'; - exports.default = CATEGORIES; - -/***/ }, -/* 22 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var CREATED = function (_DTSTAMP) { - _inherits(CREATED, _DTSTAMP); - - function CREATED() { - _classCallCheck(this, CREATED); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(CREATED).apply(this, arguments)); - } - - return CREATED; - }(_DTSTAMP3.default); - - CREATED.propName = 'CREATED'; - exports.default = CREATED; - -/***/ }, -/* 23 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var DTEND = function (_DTSTAMP) { - _inherits(DTEND, _DTSTAMP); - - function DTEND() { - _classCallCheck(this, DTEND); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(DTEND).apply(this, arguments)); - } - - return DTEND; - }(_DTSTAMP3.default); - - DTEND.propName = 'DTEND'; - exports.default = DTEND; - -/***/ }, -/* 24 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var DTSTART = function (_DTSTAMP) { - _inherits(DTSTART, _DTSTAMP); - - function DTSTART() { - _classCallCheck(this, DTSTART); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(DTSTART).apply(this, arguments)); - } - - return DTSTART; - }(_DTSTAMP3.default); - - DTSTART.propName = 'DTSTART'; - exports.default = DTSTART; - -/***/ }, -/* 25 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var DUE = function (_DTSTAMP) { - _inherits(DUE, _DTSTAMP); - - function DUE() { - _classCallCheck(this, DUE); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(DUE).apply(this, arguments)); - } - - return DUE; - }(_DTSTAMP3.default); - - DUE.propName = 'DUE'; - exports.default = DUE; - -/***/ }, -/* 26 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _formatoid = __webpack_require__(8); - - var _formatoid2 = _interopRequireDefault(_formatoid); - - var _ICS = __webpack_require__(4); - - var _ICS2 = _interopRequireDefault(_ICS); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var EXDATE = function (_Property) { - _inherits(EXDATE, _Property); - - function EXDATE() { - _classCallCheck(this, EXDATE); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(EXDATE).apply(this, arguments)); - } - - _createClass(EXDATE, [{ - key: 'shortTransformer', - value: function shortTransformer() { - if (Array.isArray(this.value)) { - return !this.value.every(function (value) { - return value instanceof Date; - }); - } else { - return true; - } - } - }, { - key: 'transformer', - value: function transformer() { - var valueIsDate = this.props.VALUE == 'DATE'; - var format = valueIsDate ? _ICS2.default.DateFormat : _ICS2.default.DateTimeFormat; - - return this.value.map(function (value) { - if (valueIsDate) { - // Remove timezone offset - var offset = value.getTimezoneOffset() * 60000; - value = new Date(value.getTime() + offset); - } - - return (0, _formatoid2.default)(value, format); - }).join(); - } - }]); - - return EXDATE; - }(_Property3.default); - - EXDATE.propName = 'EXDATE'; - exports.default = EXDATE; - -/***/ }, -/* 27 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var GEO = function (_Property) { - _inherits(GEO, _Property); - - function GEO() { - _classCallCheck(this, GEO); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(GEO).apply(this, arguments)); - } - - _createClass(GEO, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return typeof this.value === 'string'; - } - }, { - key: 'transformer', - value: function transformer() { - return this.value.join(';'); - } - }]); - - return GEO; - }(_Property3.default); - - GEO.propName = 'GEO'; - exports.default = GEO; - -/***/ }, -/* 28 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var LAST_MODIFIED = function (_DTSTAMP) { - _inherits(LAST_MODIFIED, _DTSTAMP); - - function LAST_MODIFIED() { - _classCallCheck(this, LAST_MODIFIED); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(LAST_MODIFIED).apply(this, arguments)); - } - - return LAST_MODIFIED; - }(_DTSTAMP3.default); - - LAST_MODIFIED.propName = 'LAST-MODIFIED'; - exports.default = LAST_MODIFIED; - -/***/ }, -/* 29 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var RDATE = function (_DTSTAMP) { - _inherits(RDATE, _DTSTAMP); - - function RDATE() { - _classCallCheck(this, RDATE); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(RDATE).apply(this, arguments)); - } - - return RDATE; - }(_DTSTAMP3.default); - - RDATE.propName = 'RDATE'; - exports.default = RDATE; - -/***/ }, -/* 30 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var TRANSP = function (_Property) { - _inherits(TRANSP, _Property); - - function TRANSP() { - _classCallCheck(this, TRANSP); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(TRANSP).apply(this, arguments)); - } - - _createClass(TRANSP, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return typeof this.value === 'string'; - } - }, { - key: 'transformer', - value: function transformer() { - return this.value ? 'TRANSPARENT' : 'OPAQUE'; - } - }]); - - return TRANSP; - }(_Property3.default); - - TRANSP.propName = 'TRANSP'; - exports.default = TRANSP; - -/***/ }, -/* 31 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _simpleGuid = __webpack_require__(40); - - var _simpleGuid2 = _interopRequireDefault(_simpleGuid); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var UID = function (_Property) { - _inherits(UID, _Property); - - function UID() { - _classCallCheck(this, UID); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(UID).apply(this, arguments)); - } - - _createClass(UID, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return !!this.value; - } - }, { - key: 'transformer', - value: function transformer() { - return (0, _simpleGuid2.default)(); - } - }]); - - return UID; - }(_Property3.default); - - UID.propName = 'UID'; - exports.default = UID; - -/***/ }, -/* 32 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - - var VERSION = function (_Property) { - _inherits(VERSION, _Property); - - function VERSION() { - _classCallCheck(this, VERSION); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(VERSION).apply(this, arguments)); - } - - _createClass(VERSION, [{ - key: 'shortTransformer', - value: function shortTransformer() { - return (/[0-9].[0-9]/.test(this.value) - ); - } - }, { - key: 'transformer', - value: function transformer() { - return parseFloat(this.value).toFixed(1); - } - }]); - - return VERSION; - }(_Property3.default); - - VERSION.propName = 'VERSION'; - exports.default = VERSION; - -/***/ }, -/* 33 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - - exports.default = function (name) { - var _class, _temp; - - return _temp = _class = function (_Property) { - _inherits(_default, _Property); - - function _default() { - _classCallCheck(this, _default); - - return _possibleConstructorReturn(this, Object.getPrototypeOf(_default).apply(this, arguments)); - } - - return _default; - }(_Property3.default), _class.propName = name, _temp; - }; - - var _Property2 = __webpack_require__(1); - - var _Property3 = _interopRequireDefault(_Property2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } - - function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } - - function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } - -/***/ }, -/* 34 */ -/***/ function(module, exports, __webpack_require__) { - - 'use strict'; - - Object.defineProperty(exports, "__esModule", { - value: true - }); - exports.VERSION = exports.UID = exports.TRANSP = exports.RDATE = exports.LAST_MODIFIED = exports.GEO = exports.EXDATE = exports.DUE = exports.DTSTART = exports.DTSTAMP = exports.DTEND = exports.CREATED = exports.CATEGORIES = exports._default = undefined; - - var _default2 = __webpack_require__(33); - - var _default3 = _interopRequireDefault(_default2); - - var _CATEGORIES2 = __webpack_require__(21); - - var _CATEGORIES3 = _interopRequireDefault(_CATEGORIES2); - - var _CREATED2 = __webpack_require__(22); - - var _CREATED3 = _interopRequireDefault(_CREATED2); - - var _DTEND2 = __webpack_require__(23); - - var _DTEND3 = _interopRequireDefault(_DTEND2); - - var _DTSTAMP2 = __webpack_require__(3); - - var _DTSTAMP3 = _interopRequireDefault(_DTSTAMP2); - - var _DTSTART2 = __webpack_require__(24); - - var _DTSTART3 = _interopRequireDefault(_DTSTART2); - - var _DUE2 = __webpack_require__(25); - - var _DUE3 = _interopRequireDefault(_DUE2); - - var _EXDATE2 = __webpack_require__(26); - - var _EXDATE3 = _interopRequireDefault(_EXDATE2); - - var _GEO2 = __webpack_require__(27); - - var _GEO3 = _interopRequireDefault(_GEO2); - - var _LAST_MODIFIED2 = __webpack_require__(28); - - var _LAST_MODIFIED3 = _interopRequireDefault(_LAST_MODIFIED2); - - var _RDATE2 = __webpack_require__(29); - - var _RDATE3 = _interopRequireDefault(_RDATE2); - - var _TRANSP2 = __webpack_require__(30); - - var _TRANSP3 = _interopRequireDefault(_TRANSP2); - - var _UID2 = __webpack_require__(31); - - var _UID3 = _interopRequireDefault(_UID2); - - var _VERSION2 = __webpack_require__(32); - - var _VERSION3 = _interopRequireDefault(_VERSION2); - - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - - exports._default = _default3.default; - exports.CATEGORIES = _CATEGORIES3.default; - exports.CREATED = _CREATED3.default; - exports.DTEND = _DTEND3.default; - exports.DTSTAMP = _DTSTAMP3.default; - exports.DTSTART = _DTSTART3.default; - exports.DUE = _DUE3.default; - exports.EXDATE = _EXDATE3.default; - exports.GEO = _GEO3.default; - exports.LAST_MODIFIED = _LAST_MODIFIED3.default; - exports.RDATE = _RDATE3.default; - exports.TRANSP = _TRANSP3.default; - exports.UID = _UID3.default; - exports.VERSION = _VERSION3.default; - -/***/ }, -/* 35 */ -/***/ function(module, exports) { - - /*! - * days - * - * Copyright (c) 2014 Jon Schlinkert, contributors. - * Licensed under the MIT license. - */ - - module.exports = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']; - module.exports.abbr = ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat']; - module.exports.short = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']; - - -/***/ }, -/* 36 */ -/***/ function(module, exports) { - - /** - * fillo - * Fill additional characters at the beginning of the string. - * - * @name fillo - * @function - * @param {String|Number} what The input snippet (number, string or anything that can be stringified). - * @param {Number} size The width of the final string (default: `2`). - * @param {String} ch The character to repeat (default: `"0"`). - * @return {String} The input value with filled characters. - */ - module.exports = function fillo (what, size, ch) { - size = size || 2; - ch = ch || "0"; - what = what.toString(); - return ch.repeat(size - what.length) + what; - }; - - -/***/ }, -/* 37 */ -/***/ function(module, exports) { - - /*! - * months - * - * Copyright (c) 2014 Jon Schlinkert, contributors. - * Licensed under the MIT license. - */ - - module.exports = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; - - module.exports.abbr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; - - -/***/ }, -/* 38 */ -/***/ function(module, exports, __webpack_require__) { - - "use strict"; - - const regexEscape = __webpack_require__(39); - - class ParseIt { - /** - * ParseIt - * The `ParseIt` class. It can be used to use the same data object but with different formats/arguments. - * - * @name ParseIt - * @function - * @param {Object} obj An object containing the fields to replace. - */ - constructor (obj) { - this.obj = obj || {}; - this.re = new RegExp("^(" + Object.keys(obj).map(regexEscape).join("|") + ")"); - } - - /** - * run - * Replaces the fields in the format string with data coming from the data object. - * - * - * @name parseIt - * @function - * @param {String} format The format input. - * @param {Array} args An array of arguments to be passed to the replace function (stored in the `obj` object). - * @return {String} The result as string. - */ - run (format, args) { - var result = ""; - args = args || []; - do { - let arr = format.match(this.re) - , field = arr && arr[1] - , c = field || format.charAt(0) - ; - - if (field) { - let value = this.obj[field]; - if (typeof value === "function") { - value = value.apply(this, args); - } - result += value; - } else { - result += c; - } - format = format.substring(c.length); - } while (format); - return result; - } - } - - /** - * parseIt - * A wrapper around the `ParseIt` class. The `ParseIt` constructor is accessible using `parseIt.Parser`. - * - * @name parseIt - * @function - * @param {String} format The format input. - * @param {Object} obj An object containing the fields to replace. - * @param {Array} args An array of arguments to be passed to the replace function (stored in the `obj` object). - * @return {String} The result as string. - */ - function parseIt(format, obj, args) { - return new ParseIt(obj).run(format, args); - } - - parseIt.Parser = ParseIt; - - module.exports = parseIt; - - -/***/ }, -/* 39 */ -/***/ function(module, exports) { - - /** - * RegexEscape - * Escapes a string for using it in a regular expression. - * - * @name RegexEscape - * @function - * @param {String} input The string that must be escaped. - * @return {String} The escaped string. - */ - function RegexEscape(input) { - return input.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); - } - - /** - * proto - * Adds the `RegexEscape` function to `RegExp` class. - * - * @name proto - * @function - * @return {Function} The `RegexEscape` function. - */ - RegexEscape.proto = function () { - RegExp.escape = RegexEscape; - return RegexEscape; - }; - - module.exports = RegexEscape; - - -/***/ }, -/* 40 */ -/***/ function(module, exports) { - - - var guid = function() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) { - var r = Math.random()*16|0, v = c === 'x' ? r : (r&0x3|0x8); - return v.toString(16); - }).toUpperCase(); - } - - module.exports = guid; - - -/***/ } -/******/ ]) -}); -; \ No newline at end of file +!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function r(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t["default"]=e,t}Object.defineProperty(t,"__esModule",{value:!0});var o=n(25),u=r(o);t["default"]=u},function(e,t){"use strict";function n(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){for(var n=0;n0,t=this.constructor.propName+(e?";"+this.transformedProps():""),n=this.transformedValue(),r=t+":"+n;return r.match(/.{1,75}/g).join("\r\n ")}}]),e}();o.propName="Property",t["default"]=o},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n0)throw new y.InvalidComponentError;return!0}},{key:"toString",value:function(){this.validateRequired();var e=this.internalProps.map(function(e){return e.toString()}),t=this.internalComponents.map(function(e){return e.toString()});return[this.prefix].concat(u(e),u(t),[this.suffix]).join(this.constructor.separator)}},{key:"toBlob",value:function(){return new Blob([this.toString()],{type:s.MIME_TYPE})}},{key:"toBase64",value:function(){var e=this.toBlob(),t=new window.FileReader;return new Promise(function(n,r){t.readAsDataURL(e),t.onloadend=function(){n(t.result)},t.onerror=function(){r(t.error)},t.onabort=function(){r()}})}}]),e}();h.componentName="Component",h.separator="\r\n",h.requiredProps=[],h.validProps={},h.validComponents={},t["default"]=h},function(e,t){function n(e){var t=typeof e;return"number"==t||"boolean"==t||"string"==t&&"__proto__"!=e||null==e}e.exports=n},function(e,t,n){var r=n(15),o=n(17),u=r(o,"Map");e.exports=u},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.unique=t.singleton=void 0;var o=n(26),u=r(o),i=n(27),a=r(i);t.singleton=u["default"],t.unique=a["default"]},function(e,t){"use strict";var n=function(){function e(e,t){for(var n in t){var r=t[n];r.configurable=!0,r.value&&(r.writable=!0)}Object.defineProperties(e,t)}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),r=function a(e,t,n){var r=Object.getOwnPropertyDescriptor(e,t);if(void 0===r){var o=Object.getPrototypeOf(e);return null===o?void 0:a(o,t,n)}if("value"in r&&r.writable)return r.value;var u=r.get;if(void 0!==u)return u.call(n)},o=function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(e.__proto__=t)},u=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},i=function(e){function t(e){u(this,t),Error.captureStackTrace(this,this.constructor),this.message=e,r(Object.getPrototypeOf(t.prototype),"constructor",this).call(this,e)}return o(t,e),n(t,{name:{get:function(){return this.constructor.name}}}),t}(Error);e.exports=i},function(e,t,n){function r(e,t){for(var n=e.length;n--;)if(o(e[n][0],t))return n;return-1}var o=n(82);e.exports=r},function(e,t,n){var r=n(15),o=r(Object,"create");e.exports=o},function(e,t,n){function r(e){var t=o(e)?f.call(e):"";return t==u||t==i}var o=n(13),u="[object Function]",i="[object GeneratorFunction]",a=Object.prototype,f=a.toString;e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.ValidationError=t.InvalidProvidedPropError=t.InvalidProvidedComponentError=t.InvalidComponentError=void 0;var o=n(29),u=r(o),i=n(30),a=r(i),f=n(31),c=r(f),s=n(32),l=r(s);t.InvalidComponentError=u["default"],t.InvalidProvidedComponentError=a["default"],t.InvalidProvidedPropError=c["default"],t.ValidationError=l["default"]},function(e,t,n){function r(e){return u(e)&&o(e)}var o=n(85),u=n(19);e.exports=r},function(e,t){function n(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}e.exports=n},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.formatDate=void 0;var o=n(33),u=r(o);t.formatDate=u["default"]},function(e,t,n){function r(e,t){var n=e[t];return o(n)?n:void 0}var o=n(87);e.exports=r},function(e,t,n){function r(e,t){return o?void 0!==e[t]:i.call(e,t)}var o=n(9),u=Object.prototype,i=u.hasOwnProperty;e.exports=r},function(e,t,n){(function(e){var r=n(69),o={"function":!0,object:!0},u=o[typeof t]&&t&&!t.nodeType?t:void 0,i=o[typeof e]&&e&&!e.nodeType?e:void 0,a=r(u&&i&&"object"==typeof global&&global),f=r(o[typeof self]&&self),c=r(o[typeof window]&&window),s=r(o[typeof this]&&this),l=a||c!==(s&&s.window)&&c||f||s||Function("return this")();e.exports=l}).call(t,n(93)(e))},function(e,t,n){var r=n(62),o=n(63),u=n(12),i=n(88),a=i(function(e,t){return u(e)?r(e,o(t,1,!0)):[]});e.exports=a},function(e,t){function n(e){return!!e&&"object"==typeof e}e.exports=n},function(e,t,n){function r(e){return"symbol"==typeof e||o(e)&&a.call(e)==u}var o=n(19),u="[object Symbol]",i=Object.prototype,a=i.toString;e.exports=r},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(3),f=r(a),c=n(6),s=function(e){function t(){return o(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(f["default"]);s.componentName="VALARM",s.requiredProps=["ACTION","TRIGGER"],s.validProps={ACTION:[(0,c.singleton)()],TRIGGER:[(0,c.singleton)()],ATTACH:[(0,c.singleton)()],DESCRIPTION:[(0,c.singleton)()],DURATION:[(0,c.singleton)()],REPEAT:[(0,c.singleton)()],SUMMARY:[(0,c.singleton)()],ATTENDEE:[]},t["default"]=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(3),f=r(a),c=n(6),s=function(e){function t(){return o(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(f["default"]);s.componentName="VCALENDAR",s.requiredProps=["PRODID","VERSION"],s.validProps={PRODID:[(0,c.singleton)()],VERSION:[(0,c.singleton)()],CALSCALE:[(0,c.singleton)()],METHOD:[(0,c.singleton)()]},s.validComponents={VEVENT:[],VFREEBUSY:[],VJOURNAL:[],VTIMEZONE:[],VTODO:[]},t["default"]=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(3),f=r(a),c=n(6),s=function(e){function t(){return o(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(f["default"]);s.componentName="VEVENT",s.requiredProps=["DTSTAMP","UID"],s.validProps={DTSTAMP:[(0,c.singleton)()],UID:[(0,c.singleton)()],CLASS:[(0,c.singleton)()],CREATED:[(0,c.singleton)()],DESCRIPTION:[(0,c.singleton)()],DTSTART:[(0,c.singleton)()],GEO:[(0,c.singleton)()],"LAST-MOD":[(0,c.singleton)()],LOCATION:[(0,c.singleton)()],ORGANIZER:[(0,c.singleton)()],PRIORITY:[(0,c.singleton)()],"RECURRENCE-ID":[(0,c.singleton)()],RRULE:[(0,c.singleton)()],SEQUENCE:[(0,c.singleton)()],STATUS:[(0,c.singleton)()],SUMMARY:[(0,c.singleton)()],TRANSP:[(0,c.singleton)()],URL:[(0,c.singleton)()],DTEND:[(0,c.singleton)(),(0,c.unique)(["DURATION"])],DURATION:[(0,c.singleton)(),(0,c.unique)(["DTEND"])],ATTACH:[],ATTENDEE:[],CATEGORIES:[],COMMENT:[],CONTACT:[],EXDATE:[],RDATE:[],RELATED:[],"REQUEST-STATUS":[],RESOURCES:[]},s.validComponents={VALARM:[]},t["default"]=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(3),f=r(a),c=n(6),s=function(e){function t(){return o(this,t),u(this,Object.getPrototypeOf(t).apply(this,arguments))}return i(t,e),t}(f["default"]);s.componentName="VTODO",s.requiredProps=["DTSTAMP","UID"],s.validProps={DTSTAMP:[(0,c.singleton)()],UID:[(0,c.singleton)()],CLASS:[(0,c.singleton)()],COMPLETED:[(0,c.singleton)()],CREATED:[(0,c.singleton)()],DESCRIPTION:[(0,c.singleton)()],DTSTART:[(0,c.singleton)()],GEO:[(0,c.singleton)()],"LAST-MOD":[(0,c.singleton)()],LOCATION:[(0,c.singleton)()],ORGANIZER:[(0,c.singleton)()],PERCENT:[(0,c.singleton)()],PRIORITY:[(0,c.singleton)()],"RECURRENCE-ID":[(0,c.singleton)()],RRULE:[(0,c.singleton)()],SEQUENCE:[(0,c.singleton)()],STATUS:[(0,c.singleton)()],SUMMARY:[(0,c.singleton)()],URL:[(0,c.singleton)()],DUE:[(0,c.singleton)(),(0,c.unique)(["DURATION"])],DURATION:[(0,c.singleton)(),(0,c.unique)(["DUE"])],ATTACH:[],ATTENDEE:[],CATEGORIES:[],COMMENT:[],CONTACT:[],EXDATE:[],RDATE:[],RELATED:[],"REQUEST-STATUS":[],RESOURCES:[]},s.validComponents={VALARM:[]},t["default"]=s},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0}),t.VTODO=t.VEVENT=t.VCALENDAR=t.VALARM=void 0;var o=n(21),u=r(o),i=n(22),a=r(i),f=n(23),c=r(f),s=n(24),l=r(s);t.VALARM=u["default"],t.VCALENDAR=a["default"],t.VEVENT=c["default"],t.VTODO=l["default"]},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(1),u=r(o),i=n(3),a=r(i),f=n(11);t["default"]=function(){return function(e,t){var n=void 0,r=void 0;t instanceof u["default"]?(n=t.constructor.propName,r=e.propNames()):t instanceof a["default"]&&(n=t.constructor.componentName,r=e.componentNames());var o=r.filter(function(e){return e===n});if(o.length>=1)throw new f.ValidationError}}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t1)throw new l.ValidationError}}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.MIME_TYPE="text/calendar"},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),f=r(a),c=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"Component does not contain all required properties.":arguments[0];return o(this,t),u(this,Object.getPrototypeOf(t).call(this,e))}return i(t,e),t}(f["default"]);t["default"]=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),f=r(a),c=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"Provided component's type is not listed in validComponents.":arguments[0];return o(this,t),u(this,Object.getPrototypeOf(t).call(this,e))}return i(t,e),t}(f["default"]);t["default"]=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),f=r(a),c=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"Provided property's type is not listed in validProps.":arguments[0];return o(this,t),u(this,Object.getPrototypeOf(t).call(this,e))}return i(t,e),t}(f["default"]);t["default"]=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=n(7),f=r(a),c=function(e){function t(){var e=arguments.length<=0||void 0===arguments[0]?"Provided object was invalid for the recieving component.":arguments[0];return o(this,t),u(this,Object.getPrototypeOf(t).call(this,e))}return i(t,e),t}(f["default"]);t["default"]=c},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}Object.defineProperty(t,"__esModule",{value:!0});var o=n(48),u=r(o);t["default"]=function(e){var t=arguments.length<=1||void 0===arguments[1]?!0:arguments[1],n=void 0;return n=e.getFullYear()+(0,u["default"])(e.getMonth()+1,2,0)+(0,u["default"])(e.getDate(),2,0),t&&(n+="T"+(0,u["default"])(e.getHours(),2,0)+(0,u["default"])(e.getMinutes(),2,0)+(0,u["default"])(e.getSeconds(),2,0)),n}},function(e,t,n){"use strict";function r(e){return e&&e.__esModule?e:{"default":e}}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}Object.defineProperty(t,"__esModule",{value:!0});var a=function(){function e(e,t){for(var n=0;n-1}var o=n(64);e.exports=r},function(e,t){function n(e,t,n){for(var r=-1,o=e.length;++rn)return!1;var r=e.length-1;return n==r?e.pop():i.call(e,n,1),!0}var o=n(8),u=Array.prototype,i=u.splice;e.exports=r},function(e,t,n){function r(e,t){var n=o(e,t);return 0>n?void 0:e[n][1]}var o=n(8);e.exports=r},function(e,t,n){function r(e,t){return o(e,t)>-1}var o=n(8);e.exports=r},function(e,t,n){function r(e,t,n){var r=o(e,t);0>r?e.push([t,n]):e[r][1]=n}var o=n(8);e.exports=r},function(e,t,n){function r(e,t,n,r){var l=-1,p=u,y=!0,h=e.length,d=[],b=t.length;if(!h)return d;n&&(t=a(t,f(n))),r?(p=i,y=!1):t.length>=s&&(p=c,y=!1,t=new o(t));e:for(;++l0&&a(l)&&(n||i(l)||u(l))?t>1?r(l,t-1,n,f):o(f,l):n||(f[f.length]=l)}return f}var o=n(57),u=n(83),i=n(84),a=n(12);e.exports=r},function(e,t,n){function r(e,t,n){if(t!==t)return o(e,n);for(var r=n-1,u=e.length;++r-1&&e%1==0&&r>=e}var r=9007199254740991;e.exports=n},function(e,t,n){function r(e){if(!i(e))return!1;var t=o(e)||u(e)?y:c;return t.test(a(e))}var o=n(10),u=n(75),i=n(13),a=n(81),f=/[\\^$.*+?()[\]{}|]/g,c=/^\[object .+?Constructor\]$/,s=Object.prototype,l=Function.prototype.toString,p=s.hasOwnProperty,y=RegExp("^"+l.call(p).replace(f,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=r},function(e,t,n){function r(e,t){if("function"!=typeof e)throw new TypeError(i);return t=a(void 0===t?e.length-1:u(t),0),function(){for(var n=arguments,r=-1,u=a(n.length-t,0),i=Array(u);++re?-1:1;return t*i}var n=e%1;return e===e?n?e-n:e:0}var o=n(90),u=1/0,i=1.7976931348623157e308;e.exports=r},function(e,t,n){function r(e){if("number"==typeof e)return e;if(i(e))return a;if(u(e)){var t=o(e.valueOf)?e.valueOf():e;e=u(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(f,"");var n=s.test(e);return n||l.test(e)?p(e.slice(2),n?2:8):c.test(e)?a:+e}var o=n(10),u=n(13),i=n(20),a=NaN,f=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,l=/^0o[0-7]+$/i,p=parseInt;e.exports=r},function(e,t,n){function r(e){if("string"==typeof e)return e;if(null==e)return"";if(u(e))return f?f.call(e):"";var t=e+"";return"0"==t&&1/e==-i?"-0":t}var o=n(52),u=n(20),i=1/0,a=o?o.prototype:void 0,f=a?a.toString:void 0;e.exports=r},function(e,t){var n=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,n="x"===e?t:3&t|8;return n.toString(16)}).toUpperCase()};e.exports=n},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children=[],e.webpackPolyfill=1),e}}])}); \ No newline at end of file diff --git a/esdoc.json b/esdoc.json new file mode 100644 index 0000000..efaab1f --- /dev/null +++ b/esdoc.json @@ -0,0 +1,13 @@ +{ + "source": "./src", + "destination": "./esdoc", + "plugins": [ + { + "name": "esdoc-es7-plugin" + } + ], + "test": { + "type": "mocha", + "source": "./test" + } +} diff --git a/package.json b/package.json index be5b649..eec8a8d 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "scripts": { "lint": "eslint src test", "test": "mocha", - "build": "webpack" + "build": "webpack --progress --colors", + "doc": "esdoc -c esdoc.json" }, "repository": { "type": "git", @@ -24,23 +25,36 @@ }, "homepage": "https://github.com/angeloashmore/ics-js#readme", "devDependencies": { - "babel": "^6.5.2", - "babel-core": "^6.5.2", - "babel-eslint": "^6.0.0-beta.6", - "babel-loader": "^6.2.3", - "babel-plugin-transform-class-properties": "^6.5.2", - "babel-plugin-transform-export-extensions": "^6.5.0", - "babel-preset-es2015": "^6.5.0", - "eslint": "^2.5.0", - "eslint-config-airbnb": "^6.0.2", - "eslint-plugin-react": "^4.0.0", - "mocha": "^2.2.5", - "node-libs-browser": "^0.5.2", + "babel-core": "^6.7.4", + "babel-eslint": "^6.0.2", + "babel-loader": "^6.2.4", + "babel-preset-es2015": "^6.6.0", + "babel-preset-stage-0": "^6.5.0", + "esdoc": "^0.4.6", + "esdoc-es7-plugin": "0.0.3", + "eslint": "^2.7.0", + "eslint-config-canonical": "^1.6.15", + "eslint-config-canonical-jsdoc": "^1.2.21", + "left-pad": "^1.0.1", + "mocha": "^2.4.5", "webpack": "^1.12.14" }, "dependencies": { "es6-error": "^1.0.0", - "formatoid": "^1.0.1", + "lodash": "^4.8.2", "simple-guid": "0.0.1" + }, + "eslintConfig": { + "parser": "babel-eslint", + "extends": [ + "eslint-config-canonical", + "eslint-config-canonical-jsdoc" + ], + "rules": { + "indent": [ + 2, + 2 + ] + } } } diff --git a/src/Component.js b/src/Component.js index f815a52..c62cc62 100644 --- a/src/Component.js +++ b/src/Component.js @@ -1,4 +1,5 @@ -import ICS from './ICS'; +import difference from 'lodash/difference'; +import {MIME_TYPE} from './constants'; import * as properties from './properties'; import { InvalidComponentError, @@ -6,86 +7,221 @@ import { InvalidProvidedPropError } from './errors'; +/** + * Base class for components. + */ export default class Component { + /** + * Name of the component + * + * @abstract + * @type {string} + */ static componentName = 'Component'; + /** + * String used to separate lines when returning the component as a string. + * + * @type {string} + */ static separator = '\r\n'; + /** + * Array of required properties. + * + * @abstract + * @type {string[]} + */ static requiredProps = []; + /** + * Valid properties with appropriate validators. + * + * @abstract + * @type {Object} + */ static validProps = {}; + + /** + * Valid components with appropriate validators. + * + * @abstract + * @type {Object} + */ static validComponents = {}; - constructor() { - this.prefix = `BEGIN:${this.constructor.componentName}`; - this.suffix = `END:${this.constructor.componentName}`; + /** + * Create a new component. + */ + constructor () { + /** + * Prefix used when returning the component as a string. + * + * @private + * @type {string} + */ + this.prefix = 'BEGIN:' + this.constructor.componentName; + + /** + * Suffix used when returning the component as a string. + * + * @private + * @type {string} + */ + this.suffix = 'END:' + this.constructor.componentName; - this._props = []; - this._components = []; + /** + * Array to store the component's properties. + * + * @private + * @type {Property[]} + */ + this.internalProps = []; + + /** + * Array to store the component's components. + * + * @private + * @type {Component[]} + */ + this.internalComponents = []; } - props() { - return Object.freeze(this._props.slice(0)); + /** + * Get a frozen array of the component's properties. + * + * @returns {Property[]} Frozen array of the component's properties. + */ + props () { + return Object.freeze(this.internalProps.slice(0)); } - propNames() { - return Object.freeze(this.props().map(prop => prop.constructor.propName)); + /** + * Get a frozen array of the component's properties' names. + * + * @returns {string[]} Frozen array of the component's properties' names. + */ + propNames () { + return Object.freeze(this.internalProps.map((prop) => { + return prop.constructor.propName; + })); } - // Set props to null or {} if not needed - addProp(name, value, props, skipTransformer) { - const { validProps } = this.constructor; - if (!validProps[name]) throw new InvalidProvidedPropError(); + /** + * Add a property to the component. + * + * @param {string} name - Name of the property (e.g. DTSTAMP). + * @param {*} [value] - Value of the property. + * @param {Object} [props={}] - Object of properties for the property. Object keys and values are directly injected. + * @param {boolean} [skipTransformer=false] - Explicitly determine if the property's value is transformed. + * @throws {InvalidProvidedPropError} Provided property type is not in the component's list of valid property types. + * @returns {Property} Configured property instance. + */ + addProp (name, value, props = {}, skipTransformer = false) { + const {validProps} = this.constructor; + + if (!validProps[name]) { + throw new InvalidProvidedPropError(); + } - const PropClass = properties[name] || properties._default(name); + const PropClass = properties[name] || properties.base(name); // eslint-disable-line import/namespace const prop = new PropClass(value, props, skipTransformer); - validProps[name].forEach(validator => validator(this, prop)); - this._props.push(prop); + validProps[name].forEach((validator) => { + validator(this, prop); + }); + + this.internalProps.push(prop); return prop; } - components() { - return Object.freeze(this._components.slice(0)); + /** + * Get a frozen array of the component's components. + * + * @returns {Component[]} Frozen array of the component's components. + */ + components () { + return Object.freeze(this.internalComponents.slice(0)); } - componentNames() { - return Object.freeze(this.components().map(prop => prop.constructor.componentName)); + /** + * Get a frozen array of the component's components' names. + * + * @returns {string[]} Frozen array of the component's components' names. + */ + componentNames () { + return Object.freeze(this.internalComponents.map((component) => { + return component.constructor.componentName; + })); } - addComponent(component) { - const { validComponents } = this.constructor; - const { componentName } = component.constructor; + /** + * Add a component to the component. + * + * @param {Component} component - Configured component to add to the component. + * @throws {InvalidProvidedComponentError} Provided component type is not in the component's list of valid component types. + * @returns {Component} Provided component. + */ + addComponent (component) { + const {validComponents} = this.constructor; + const {componentName} = component.constructor; - if (!(component instanceof Component)) throw new TypeError('Expected `component` to be an instance of Component.'); - if (!validComponents[componentName]) throw new InvalidProvidedComponentError(); + if (!(component instanceof Component)) { + throw new TypeError('Expected component to be an instance of Component.'); + } - validComponents[componentName].forEach(validator => validator(this, component)); + if (!validComponents[componentName]) { + throw new InvalidProvidedComponentError(); + } + + validComponents[componentName].forEach((validator) => { + validator(this, component); + }); + + this.internalComponents.push(component); - this._components.push(component); return component; } - reset() { - this._props = this._components = []; + /** + * Reset the components components and properties to the default empty state. + */ + reset () { + this.internalProps = this.internalComponents = []; } - validateRequired() { - const { requiredProps } = this.constructor; - - const intersection = Component._intersect(requiredProps, this.propNames()); + /** + * Validate if all required properties have been added. + * + * @throws {InvalidComponentError} Required properties are missing. + * @returns {boolean} All required properties are present. + */ + validateRequired () { + const {requiredProps} = this.constructor; - if (intersection.length > 0) throw new InvalidComponentError(); + if (difference(requiredProps, this.propNames()).length > 0) { + throw new InvalidComponentError(); + } return true; } - toString() { + /** + * Get a string representation of the component. + * + * @returns {string} String representation of the component. + */ + toString () { this.validateRequired(); - const props = this._props.map(prop => prop.toString()); - const components = this._components.map(component => component.toString()); + const props = this.internalProps.map((prop) => { + return prop.toString(); + }); + + const components = this.internalComponents.map((component) => { + return component.toString(); + }); return [ this.prefix, @@ -95,24 +231,37 @@ export default class Component { ].join(this.constructor.separator); } - toBlob() { - return new Blob([this.toString()], { type: ICS.MIME_TYPE }); + /** + * Get a Blob representation of the component. Uses MIME_TYPE as the MIME + * type. + * + * @returns {Blob} Blob representation of the component. + */ + toBlob () { + return new Blob([this.toString()], {type: MIME_TYPE}); } - toBase64() { + /** + * Get a Base64 encoded string representation of the component. A Promise is + * used to allow the interpreter to process the base64 conversion. + * + * @returns {Promise} Promise that resolves with a Base64 encoded string. + */ + toBase64 () { const blob = this.toBlob(); const reader = new window.FileReader(); return new Promise((resolve, reject) => { reader.readAsDataURL(blob); - reader.onloadend = () => resolve(reader.result); - reader.onerror = () => reject(reader.error); - reader.onabort = () => reject(); + reader.onloadend = () => { + resolve(reader.result); + }; + reader.onerror = () => { + reject(reader.error); + }; + reader.onabort = () => { + reject(); + }; }); } - - static _intersect(a, b) { - const b_ = new Set(b); - return a.filter(item => !b_.has(item)); - } } diff --git a/src/ICS.js b/src/ICS.js deleted file mode 100644 index bd2022e..0000000 --- a/src/ICS.js +++ /dev/null @@ -1,16 +0,0 @@ -import Property from './Property'; -import Component from './Component'; -import * as components from './components'; - -export default class ICS { - static Property = Property; - static Component = Component; - - static MIME_TYPE = 'text/calendar'; - static DateFormat = 'YYYYMMDD' - static DateTimeFormat = 'YYYYMMDDTHHmmss' -} - -for (let componentName in components) { - ICS[componentName] = components[componentName]; -} diff --git a/src/Property.js b/src/Property.js index 1b69dbb..322332a 100644 --- a/src/Property.js +++ b/src/Property.js @@ -1,37 +1,106 @@ +/** + * Base class for properties. + */ export default class Property { - static keyRegex = /^[A-Z]([A-Z]|-)*[A-Z]$/; + /** + * Name of the property. + * + * @abstract + * @type {string} + */ static propName = 'Property'; - constructor(value, props, skipTransformer = false) { + /** + * Create a new property. + * + * @param {*} value - Value of the property. + * @param {Object} [props={}] - Object of properties for the property. Object keys and values are directly injected. + * @param {boolean} [skipTransformer=false] - Explicitly determine if the property's value is transformed. + */ + constructor (value, props, skipTransformer = false) { + /** + * The property's value. + * + * @type {*} + */ this.value = value; + + /** + * Object to store the property's properties. + * + * @private + * @type {Object} + */ this.props = props || {}; + + /** + * Determine if the property's value is transformed. + * + * @type {boolean} + */ this.skipTransformer = skipTransformer; } - shortTransformer() { + /** + * Determine if the property's value is transformed. Returning true causes the + * transformer to be skipped. + * + * @abstract + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { return true; } - transformer() { + /** + * Function that transforms the value. + * + * @abstract + * @returns {*} The property's transformed value. + */ + transformer () { return this.value; } - transformedValue() { - if (this.skipTransformer || this.shortTransformer()) return this.value; + /** + * Get the property's value. The value is transformed if needed. + * + * @returns {*} The property's value (transformed if needed). + */ + transformedValue () { + if (this.skipTransformer || this.shortTransformer()) { + return this.value; + } + return this.transformer(); } - transformedProps() { + /** + * Get the property's properties formatted for string output. + * + * @returns {string} The property's properties formatted for string output. + */ + transformedProps () { const props = []; - for (let key in this.props) props.push(`${key}=${this.props[key]}`); + + Object.keys(this.props).forEach((key) => { + props.push(key + '=' + this.props[key]); + }); + return props.join(';'); } - toString() { + /** + * Get a string representation of the property. + * + * @returns {string} String representation of the property. + */ + toString () { const hasProps = Object.keys(this.props).length > 0; const key = this.constructor.propName + (hasProps ? ';' + this.transformedProps() : ''); const value = this.transformedValue(); - const keyValuePair = `${key}:${value}`; + const keyValuePair = key + ':' + value; + return keyValuePair.match(/.{1,75}/g).join('\r\n '); } } diff --git a/src/components/VALARM.js b/src/components/VALARM.js index d63bb57..8157c34 100644 --- a/src/components/VALARM.js +++ b/src/components/VALARM.js @@ -1,22 +1,28 @@ import Component from '../Component'; -import { singleton } from './validators'; +import {singleton} from './validators'; +/** + * VALARM class. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.6.6 + */ export default class VALARM extends Component { static componentName = 'VALARM'; static requiredProps = ['ACTION', 'TRIGGER']; static validProps = { + /* eslint-disable key-spacing, sorting/sort-object-props */ ACTION: [singleton()], TRIGGER: [singleton()], + ATTACH: [singleton()], + DESCRIPTION: [singleton()], DURATION: [singleton()], REPEAT: [singleton()], - - DESCRIPTION: [singleton()], SUMMARY: [singleton()], - ATTACH: [singleton()], ATTENDEE: [] + /* eslint-enable key-spacing, sorting/sort-object-props */ } } diff --git a/src/components/VCALENDAR.js b/src/components/VCALENDAR.js index b7b7a00..c7161e3 100644 --- a/src/components/VCALENDAR.js +++ b/src/components/VCALENDAR.js @@ -1,24 +1,33 @@ import Component from '../Component'; -import { singleton } from './validators'; +import {singleton} from './validators'; +/** + * VCALENDAR class. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.4 + */ export default class VCALENDAR extends Component { static componentName = 'VCALENDAR'; static requiredProps = ['PRODID', 'VERSION']; static validProps = { + /* eslint-disable key-spacing, sorting/sort-object-props */ PRODID: [singleton()], VERSION: [singleton()], CALSCALE: [singleton()], METHOD: [singleton()] + /* eslint-enable key-spacing, sorting/sort-object-props */ } static validComponents = { + /* eslint-disable key-spacing */ VEVENT: [], - VTODO: [], - VJOURNAL: [], VFREEBUSY: [], - VTIMEZONE: [] + VJOURNAL: [], + VTIMEZONE: [], + VTODO: [] + /* eslint-enable key-spacing */ } } diff --git a/src/components/VEVENT.js b/src/components/VEVENT.js index 5b7c0e6..28a7af5 100644 --- a/src/components/VEVENT.js +++ b/src/components/VEVENT.js @@ -1,31 +1,37 @@ import Component from '../Component'; -import { singleton, unique } from './validators'; +import {singleton, unique} from './validators'; +/** + * VEVENT class. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.6.1 + */ export default class VEVENT extends Component { static componentName = 'VEVENT'; static requiredProps = ['DTSTAMP', 'UID']; static validProps = { + /* eslint-disable key-spacing, sorting/sort-object-props */ DTSTAMP: [singleton()], UID: [singleton()], - DTSTART: [singleton()], CLASS: [singleton()], CREATED: [singleton()], DESCRIPTION: [singleton()], + DTSTART: [singleton()], GEO: [singleton()], 'LAST-MOD': [singleton()], LOCATION: [singleton()], ORGANIZER: [singleton()], PRIORITY: [singleton()], + 'RECURRENCE-ID': [singleton()], + RRULE: [singleton()], SEQUENCE: [singleton()], STATUS: [singleton()], SUMMARY: [singleton()], TRANSP: [singleton()], URL: [singleton()], - 'RECURRENCE-ID': [singleton()], - RRULE: [singleton()], DTEND: [singleton(), unique(['DURATION'])], DURATION: [singleton(), unique(['DTEND'])], @@ -36,10 +42,11 @@ export default class VEVENT extends Component { COMMENT: [], CONTACT: [], EXDATE: [], - 'REQUEST-STATUS': [], + RDATE: [], RELATED: [], - RESOURCES: [], - RDATE: [] + 'REQUEST-STATUS': [], + RESOURCES: [] + /* eslint-enable key-spacing, sorting/sort-object-props */ } static validComponents = { diff --git a/src/components/VTODO.js b/src/components/VTODO.js index e942cbd..8c85eaa 100644 --- a/src/components/VTODO.js +++ b/src/components/VTODO.js @@ -1,12 +1,18 @@ import Component from '../Component'; -import { singleton, unique } from './validators'; +import {singleton, unique} from './validators'; +/** + * VTODO class. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.6.2 + */ export default class VTODO extends Component { static componentName = 'VTODO'; static requiredProps = ['DTSTAMP', 'UID']; static validProps = { + /* eslint-disable key-spacing, sorting/sort-object-props */ DTSTAMP: [singleton()], UID: [singleton()], @@ -22,11 +28,11 @@ export default class VTODO extends Component { PERCENT: [singleton()], PRIORITY: [singleton()], 'RECURRENCE-ID': [singleton()], + RRULE: [singleton()], SEQUENCE: [singleton()], STATUS: [singleton()], SUMMARY: [singleton()], URL: [singleton()], - RRULE: [singleton()], DUE: [singleton(), unique(['DURATION'])], DURATION: [singleton(), unique(['DUE'])], @@ -37,10 +43,11 @@ export default class VTODO extends Component { COMMENT: [], CONTACT: [], EXDATE: [], - 'REQUEST-STATUS': [], + RDATE: [], RELATED: [], - RESOURCES: [], - RDATE: [] + 'REQUEST-STATUS': [], + RESOURCES: [] + /* eslint-disable key-spacing, sorting/sort-object-props */ } static validComponents = { diff --git a/src/components/validators/index.js b/src/components/validators/index.js index c8b35b3..f3a5590 100644 --- a/src/components/validators/index.js +++ b/src/components/validators/index.js @@ -1,3 +1,2 @@ -export required from './required'; export singleton from './singleton'; export unique from './unique'; diff --git a/src/components/validators/required.js b/src/components/validators/required.js deleted file mode 100644 index 442019c..0000000 --- a/src/components/validators/required.js +++ /dev/null @@ -1,20 +0,0 @@ -import Property from '../../Property'; -import Component from '../../Component'; -import { ValidationError } from '../../errors'; - -export default function required() { - return (component, subject) => { - let subjectName; - let names; - - if (subject instanceof Property) { - subjectName = subject.constructor.propName; - names = component.propNames(); - } else if (subject instanceof Component) { - subjectName = subject.constructor.componentName; - names = component.componentNames(); - } - - if (!names.includes(subjectName)) throw new ValidationError(); - }; -} diff --git a/src/components/validators/singleton.js b/src/components/validators/singleton.js index 7ef5f46..44d532e 100644 --- a/src/components/validators/singleton.js +++ b/src/components/validators/singleton.js @@ -1,8 +1,14 @@ import Property from '../../Property'; import Component from '../../Component'; -import { ValidationError } from '../../errors'; +import {ValidationError} from '../../errors'; -export default function singleton() { +/** + * Validator to ensure only one instance of the subject is present in the + * component. + * + * @throws {ValidationError} An instance of the subject is already present in the component. + */ +export default () => { return (component, subject) => { let subjectName; let names; @@ -15,7 +21,12 @@ export default function singleton() { names = component.componentNames(); } - const filtered = names.filter(name => name === subjectName); - if (filtered.length >= 1) throw new ValidationError(); + const filtered = names.filter((name) => { + return name === subjectName; + }); + + if (filtered.length >= 1) { + throw new ValidationError(); + } }; -} +}; diff --git a/src/components/validators/unique.js b/src/components/validators/unique.js index fe16e9a..58827c8 100644 --- a/src/components/validators/unique.js +++ b/src/components/validators/unique.js @@ -1,8 +1,16 @@ +import difference from 'lodash/difference'; import Property from '../../Property'; import Component from '../../Component'; -import { ValidationError } from '../../errors'; +import {ValidationError} from '../../errors'; -export default function unique(uniqueNames) { +/** + * Validator to ensure only one instance of the subject of a subset of types is + * present in the component. + * + * @param {string[]} uniqueNames - Names of the subset of types. + * @throws {ValidationError} An instance of a type in the subset of types is already present in the component. + */ +export default (uniqueNames) => { return (component, subject) => { let subjectName; let names; @@ -15,10 +23,8 @@ export default function unique(uniqueNames) { names = component.componentNames(); } - const a = new Set(names); - const b = new Set([subjectName, ...uniqueNames]); - const difference = new Set([...a].filter(x => !b.has(x))); - - if (difference > 1) throw new ValidationError(); + if (difference(names, [subjectName, ...uniqueNames]) > 1) { + throw new ValidationError(); + } }; -} +}; diff --git a/src/constants.js b/src/constants.js new file mode 100644 index 0000000..971a3eb --- /dev/null +++ b/src/constants.js @@ -0,0 +1,6 @@ +/** + * MIME type of the Blob output. + * + * @type {string} + */ +export const MIME_TYPE = 'text/calendar'; diff --git a/src/errors/InvalidComponentError.js b/src/errors/InvalidComponentError.js index afbdb98..851ef40 100644 --- a/src/errors/InvalidComponentError.js +++ b/src/errors/InvalidComponentError.js @@ -1,7 +1,13 @@ import ExtendableError from 'es6-error'; +/** + * Error thrown when a component does not contain all required properties. + */ export default class InvalidComponentError extends ExtendableError { - constructor(message = 'Component does not contain all required properties.') { + /** + * Create a new InvalidComponentError. + */ + constructor (message = 'Component does not contain all required properties.') { super(message); } } diff --git a/src/errors/InvalidProvidedComponentError.js b/src/errors/InvalidProvidedComponentError.js index aac280c..e184faa 100644 --- a/src/errors/InvalidProvidedComponentError.js +++ b/src/errors/InvalidProvidedComponentError.js @@ -1,7 +1,14 @@ import ExtendableError from 'es6-error'; +/** + * Error thrown when adding a component to a component that is not in the list + * of valid components. + */ export default class InvalidProvidedComponentError extends ExtendableError { - constructor(message = 'Provided component\'s type is not listed in validComponents.') { + /** + * Create a new InvalidProvidedComponentError. + */ + constructor (message = 'Provided component\'s type is not listed in validComponents.') { super(message); } } diff --git a/src/errors/InvalidProvidedPropError.js b/src/errors/InvalidProvidedPropError.js index a8b7ee3..e3f0ac4 100644 --- a/src/errors/InvalidProvidedPropError.js +++ b/src/errors/InvalidProvidedPropError.js @@ -1,7 +1,14 @@ import ExtendableError from 'es6-error'; +/** + * Error thrown when adding a property to a component that is not in the list of + * valid properties. + */ export default class InvalidProvidedPropError extends ExtendableError { - constructor(message = 'Provided property\'s type is not listed in validProps.') { + /** + * Create a new InvalidProvidedPropError. + */ + constructor (message = 'Provided property\'s type is not listed in validProps.') { super(message); } } diff --git a/src/errors/ValidationError.js b/src/errors/ValidationError.js index 2108cb2..b7e3eb1 100644 --- a/src/errors/ValidationError.js +++ b/src/errors/ValidationError.js @@ -1,7 +1,13 @@ import ExtendableError from 'es6-error'; +/** + * Error thrown when a validation fails. + */ export default class ValidationError extends ExtendableError { - constructor(message = 'Provided object was invalid for the recieving component.') { + /** + * Create a new ValidationError. + */ + constructor (message = 'Provided object was invalid for the recieving component.') { super(message); } } diff --git a/src/helpers/formatDate.js b/src/helpers/formatDate.js new file mode 100644 index 0000000..63192b6 --- /dev/null +++ b/src/helpers/formatDate.js @@ -0,0 +1,27 @@ +import leftpad from 'left-pad'; + +/** + * Format a Date object to a valid string. + * + * @private + * @param {Date} date - Date to format. + * @param {boolean} [includeTime=true] - Determine if time is included in the string. + */ +export default (date, includeTime = true) => { + let string; + + string = + date.getFullYear() + + leftpad(date.getMonth() + 1, 2, 0) + + leftpad(date.getDate(), 2, 0); + + if (includeTime) { + string += + 'T' + + leftpad(date.getHours(), 2, 0) + + leftpad(date.getMinutes(), 2, 0) + + leftpad(date.getSeconds(), 2, 0); + } + + return string; +}; diff --git a/src/helpers/index.js b/src/helpers/index.js new file mode 100644 index 0000000..8b1bcd7 --- /dev/null +++ b/src/helpers/index.js @@ -0,0 +1 @@ +export formatDate from './formatDate'; diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000..2f67bc0 --- /dev/null +++ b/src/index.js @@ -0,0 +1,3 @@ +import * as components from './components'; + +export default components; diff --git a/src/properties/CATEGORIES.js b/src/properties/CATEGORIES.js index 335088e..7e254b1 100644 --- a/src/properties/CATEGORIES.js +++ b/src/properties/CATEGORIES.js @@ -1,13 +1,28 @@ import Property from '../Property'; +/** + * CATEGORIES property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.1.2 + */ export default class CATEGORIES extends Property { static propName = 'CATEGORIES'; - shortTransformer() { - return (typeof this.value === 'string' || this.value instanceof String); + /** + * Check if property's value is an array. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { + return !Array.isArray(this.value); } - transformer() { + /** + * Joins the value using commas to separate values. + * + * @returns {string} The property's transformed value. + */ + transformer () { return this.value.join(','); } } diff --git a/src/properties/CREATED.js b/src/properties/CREATED.js index 5d7cf12..716236b 100644 --- a/src/properties/CREATED.js +++ b/src/properties/CREATED.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * CREATED property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.7.1 + */ export default class CREATED extends DTSTAMP { static propName = 'CREATED'; } diff --git a/src/properties/DTEND.js b/src/properties/DTEND.js index 63314c5..1074aca 100644 --- a/src/properties/DTEND.js +++ b/src/properties/DTEND.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * DTEND property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.2 + */ export default class DTEND extends DTSTAMP { static propName = 'DTEND'; } diff --git a/src/properties/DTSTAMP.js b/src/properties/DTSTAMP.js index d27d9a7..6df4246 100644 --- a/src/properties/DTSTAMP.js +++ b/src/properties/DTSTAMP.js @@ -1,24 +1,42 @@ -import formatoid from 'formatoid'; -import ICS from '../ICS'; +import {formatDate} from '../helpers'; import Property from '../Property'; +/** + * DTSTAMP property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.7.2 + */ export default class DTSTAMP extends Property { static propName = 'DTSTAMP'; - shortTransformer() { + /** + * Check if property's value is not an instance of Date. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { return !(this.value instanceof Date); } - transformer() { - const valueIsDate = this.props.VALUE == 'DATE'; + /** + * Format the property's value to a string representation of a date or + * datetime. + * + * @returns {string} The property's transformed value. + */ + transformer () { + let value; + const valueIsDate = this.props.VALUE === 'DATE'; + + value = this.value; if (valueIsDate) { // Remove timezone offset const offset = this.value.getTimezoneOffset() * 60000; - this.value = new Date(this.value.getTime() + offset); + + value = new Date(this.value.getTime() + offset); } - const format = valueIsDate ? ICS.DateFormat : ICS.DateTimeFormat; - return formatoid(this.value, format); + return formatDate(value, !valueIsDate); } } diff --git a/src/properties/DTSTART.js b/src/properties/DTSTART.js index ed59345..bb40cbe 100644 --- a/src/properties/DTSTART.js +++ b/src/properties/DTSTART.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * DTSTART property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.4 + */ export default class DTSTART extends DTSTAMP { static propName = 'DTSTART'; } diff --git a/src/properties/DUE.js b/src/properties/DUE.js index 6b95b63..93b776c 100644 --- a/src/properties/DUE.js +++ b/src/properties/DUE.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * DUE property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.3 + */ export default class DUE extends DTSTAMP { static propName = 'DUE'; } diff --git a/src/properties/EXDATE.js b/src/properties/EXDATE.js index 6d38407..86ce158 100644 --- a/src/properties/EXDATE.js +++ b/src/properties/EXDATE.js @@ -1,30 +1,47 @@ -import formatoid from 'formatoid'; -import ICS from '../ICS'; +import {formatDate} from '../helpers'; import Property from '../Property'; +/** + * EXDATE property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.5.1 + */ export default class EXDATE extends Property { static propName = 'EXDATE'; - shortTransformer() { + /** + * Check if property's value is not an array of Date instances. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { if (Array.isArray(this.value)) { - return !this.value.every(value => value instanceof Date); + return !this.value.every((value) => { + return value instanceof Date; + }); } else { return true; } } - transformer() { - const valueIsDate = this.props.VALUE == 'DATE'; - const format = valueIsDate ? ICS.DateFormat : ICS.DateTimeFormat; + /** + * Format the property's values to string representations of a date or + * datetime. The values are joined using commas to separate values. + * + * @returns {string} The property's transformed value. + */ + transformer () { + const valueIsDate = this.props.VALUE === 'DATE'; - return this.value.map(function(value) { + return this.value.map((value) => { if (valueIsDate) { // Remove timezone offset const offset = value.getTimezoneOffset() * 60000; - value = new Date(value.getTime() + offset); + + return formatDate(new Date(value.getTime() + offset), !valueIsDate); } - return formatoid(value, format); - }).join(); + return formatDate(value, !valueIsDate); + }).join(','); } } diff --git a/src/properties/GEO.js b/src/properties/GEO.js index 0338254..328666a 100644 --- a/src/properties/GEO.js +++ b/src/properties/GEO.js @@ -1,13 +1,28 @@ import Property from '../Property'; +/** + * GEO property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.3 + */ export default class GEO extends Property { static propName = 'GEO'; - shortTransformer() { - return (typeof this.value === 'string' || this.value instanceof String); + /** + * Check if property's value is not an array. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { + return !Array.isArray(this.value); } - transformer() { + /** + * Joins the value using semicolon to separate values. + * + * @returns {string} The property's transformed value. + */ + transformer () { return this.value.join(';'); } } diff --git a/src/properties/LAST_MODIFIED.js b/src/properties/LAST_MODIFIED.js index 961ef96..2ff9615 100644 --- a/src/properties/LAST_MODIFIED.js +++ b/src/properties/LAST_MODIFIED.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * LAST_MODIFIED property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.7.3 + */ export default class LAST_MODIFIED extends DTSTAMP { static propName = 'LAST-MODIFIED'; } diff --git a/src/properties/RDATE.js b/src/properties/RDATE.js index 1d2fc39..e10e916 100644 --- a/src/properties/RDATE.js +++ b/src/properties/RDATE.js @@ -1,5 +1,10 @@ import DTSTAMP from './DTSTAMP'; +/** + * RDATE property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.5.2 + */ export default class RDATE extends DTSTAMP { static propName = 'RDATE'; } diff --git a/src/properties/TRANSP.js b/src/properties/TRANSP.js index 6c114f9..3a9dc3c 100644 --- a/src/properties/TRANSP.js +++ b/src/properties/TRANSP.js @@ -1,13 +1,29 @@ import Property from '../Property'; +/** + * TRANSP property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.2.7 + */ export default class TRANSP extends Property { static propName = 'TRANSP'; - shortTransformer() { - return (typeof this.value === 'string' || this.value instanceof String); + /** + * Check if property's value is not a boolean. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { + return typeof this.value !== 'boolean'; } - transformer() { + /** + * Returns "TRANSPARENT" if the property's value is true, or "OPAQUE" if + * false. + * + * @returns {string} The property's transformed value. + */ + transformer () { return this.value ? 'TRANSPARENT' : 'OPAQUE'; } } diff --git a/src/properties/UID.js b/src/properties/UID.js index 4f74b89..86f81eb 100644 --- a/src/properties/UID.js +++ b/src/properties/UID.js @@ -1,14 +1,29 @@ import guid from 'simple-guid'; import Property from '../Property'; +/** + * UID property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.8.4.7 + */ export default class UID extends Property { static propName = 'UID'; - shortTransformer() { - return !!this.value; + /** + * Check if property has a value. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { + return Boolean(this.value); } - transformer() { + /** + * Generate a random GUID. + * + * @returns {string} The property's transformed value. + */ + transformer () { return guid(); } } diff --git a/src/properties/VERSION.js b/src/properties/VERSION.js index ffe6cf5..5e1c9d7 100644 --- a/src/properties/VERSION.js +++ b/src/properties/VERSION.js @@ -1,13 +1,28 @@ import Property from '../Property'; +/** + * VERSION property. + * + * @see https://tools.ietf.org/html/rfc5545#section-3.7.4 + */ export default class VERSION extends Property { static propName = 'VERSION'; - shortTransformer() { - return /[0-9].[0-9]/.test(this.value); + /** + * Check if property's value is not a number. + * + * @returns {boolean} Whether the property's value is transformed. + */ + shortTransformer () { + return typeof this.value !== 'number'; } - transformer() { + /** + * Parse the property's value and return a float value with one decimal point. + * + * @returns {string} The property's transformed value. + */ + transformer () { return parseFloat(this.value).toFixed(1); } } diff --git a/src/properties/_default.js b/src/properties/_default.js deleted file mode 100644 index 06bb68f..0000000 --- a/src/properties/_default.js +++ /dev/null @@ -1,7 +0,0 @@ -import Property from '../Property'; - -export default function(name) { - return class _default extends Property { - static propName = name; - }; -} diff --git a/src/properties/base.js b/src/properties/base.js new file mode 100644 index 0000000..0cab822 --- /dev/null +++ b/src/properties/base.js @@ -0,0 +1,14 @@ +import Property from '../Property'; + +/** + * Generate a generic class with a given name. Used when the property does not + * require any special transformations. + * + * @param {string} name - Name of the property. + * @returns {Object} Generic property class. + */ +export default (name) => { + return class base extends Property { + static propName = name; + }; +}; diff --git a/src/properties/index.js b/src/properties/index.js index 5ad050e..09a69b7 100644 --- a/src/properties/index.js +++ b/src/properties/index.js @@ -1,4 +1,4 @@ -export _default from './_default'; +export base from './base'; export CATEGORIES from './CATEGORIES'; export CREATED from './CREATED'; diff --git a/test/helpers/propertyTest.js b/test/helpers/propertyTest.js index 3e1893e..4c0e013 100644 --- a/test/helpers/propertyTest.js +++ b/test/helpers/propertyTest.js @@ -1,8 +1,8 @@ import assert from 'assert'; import * as properties from '../../src/properties'; -export default function(name, opts) { - describe(name, function() { +export default (name, opts) => { + describe(name, () => { const { transformableValue, transformableProps, @@ -10,18 +10,18 @@ export default function(name, opts) { shortableProps } = opts; - const PropertyClass = properties[name]; + const PropertyClass = properties[name]; // eslint-disable-line import/namespace const transformedProp = new PropertyClass(transformableValue, transformableProps); const shortedProp = new PropertyClass(transformedValue, shortableProps); - describe('#transformedValue()', function() { - it('should transform a transformable value', function() { + describe('#transformedValue()', () => { + it('should transform a transformable value', () => { assert.equal(transformedProp.transformedValue(), transformedValue); }); - it('should not transform a shorted value', function() { + it('should not transform a shorted value', () => { assert.equal(shortedProp.transformedValue(), transformedValue); }); }); }); -} +}; diff --git a/test/integration/ics-js.js b/test/integration/ics-js.js index 23cade1..ef9969c 100644 --- a/test/integration/ics-js.js +++ b/test/integration/ics-js.js @@ -1,23 +1,27 @@ import assert from 'assert'; -import ICS from '../../src/ICS'; +import ICS from '../../src'; const cal = new ICS.VCALENDAR(); + cal.addProp('VERSION', 2); cal.addProp('PRODID', 'XYZ Corp'); const event = new ICS.VEVENT(); + event.addProp('UID', '1'); -event.addProp('DTSTAMP', new Date('2015-07-18'), { VALUE: 'DATE' }); +event.addProp('DTSTAMP', new Date('2015-07-18'), {VALUE: 'DATE'}); event.addProp('SUMMARY', 'Birthdate'); -event.addProp('DTSTART', new Date('1991-03-07 07:00:00'), { VALUE: 'DATE-TIME' }); +event.addProp('DTSTART', new Date('1991-03-07 07:00:00'), {VALUE: 'DATE-TIME'}); event.addProp('DTEND', new Date('1991-03-07 19:30:00')); const eventAlarm = new ICS.VALARM(); + eventAlarm.addProp('ACTION', 'DISPLAY'); eventAlarm.addProp('TRIGGER', '-PT12H'); eventAlarm.addProp('DESCRIPTION', 'Event reminder'); const todo = new ICS.VTODO(); + todo.addProp('UID', '1'); todo.addProp('DTSTAMP', new Date('2015-07-18 10:00:00')); todo.addProp('DUE', new Date('2015-07-19 10:00:00')); @@ -54,9 +58,9 @@ const icsString = 'BEGIN:VCALENDAR\r\n' + 'END:VTODO\r\n' + 'END:VCALENDAR'; -describe('ics-js', function() { - describe('creating an ICS file', function() { - it('should return an ICS file as a string', function() { +describe('ics-js', () => { + describe('creating an ICS file', () => { + it('should return an ICS file as a string', () => { assert.equal(cal.toString(), icsString); }); }); diff --git a/test/unit/Component.js b/test/unit/Component.js index 5b72150..f41041f 100644 --- a/test/unit/Component.js +++ b/test/unit/Component.js @@ -1,6 +1,9 @@ +/* eslint max-nested-callbacks:0 */ + import assert from 'assert'; -import ICS from '../../src/ICS'; -import { VERSION } from '../../src/properties'; +import ICS from '../../src'; +import Component from '../../src/Component'; +import {VERSION} from '../../src/properties'; import { InvalidComponentError, InvalidProvidedComponentError, @@ -12,159 +15,174 @@ const component = new ICS.VCALENDAR(); const prop = new VERSION(2); const component2 = new ICS.VEVENT(); -describe('Component', function() { - beforeEach(function() { +describe('Component', () => { + beforeEach(() => { component.reset(); }); - describe('#constructor()', function() { - it('should create a new instance of Component', function() { - assert.equal(component instanceof ICS.Component, true); + describe('#constructor()', () => { + it('should create a new instance of Component', () => { + assert.equal(component instanceof Component, true); }); - it('should have an empty `_props` instance property', function() { - assert.deepEqual(component._props, []); + it('should have an empty `internalProps` instance property', () => { + assert.deepEqual(component.internalProps, []); }); - it('should have an empty `_components` instance property', function() { - assert.deepEqual(component._components, []); + it('should have an empty `internalComponents` instance property', () => { + assert.deepEqual(component.internalComponents, []); }); }); - describe('#props()', function() { - it('should not be mutable', function() { - assert.throws(() => component.props().push(prop), TypeError); + describe('#props()', () => { + it('should not be mutable', () => { + assert.throws(() => { + component.props().push(prop); + }, TypeError); }); - describe('with no props', function() { - it('should return an empty array', function() { + describe('with no props', () => { + it('should return an empty array', () => { assert.deepEqual(component.props(), []); }); }); - describe('with some props', function() { - it('should return an array with added Property objects', function() { + describe('with some props', () => { + it('should return an array with added Property objects', () => { component.addProp('VERSION', 2); assert.deepEqual(component.props(), [prop]); }); }); }); - describe('#propNames()', function() { - describe('with no props', function() { - it('should return an empty array', function() { + describe('#propNames()', () => { + describe('with no props', () => { + it('should return an empty array', () => { assert.deepEqual(component.propNames(), []); }); }); - describe('with some props', function() { - it('should return an array with added Property objects\' names', function() { + describe('with some props', () => { + it('should return an array with added Property objects\' names', () => { component.addProp('VERSION', 2); assert.deepEqual(component.propNames(), [prop.constructor.propName]); }); }); }); - describe('#addProp()', function() { - it('should add a Property', function() { + describe('#addProp()', () => { + it('should add a Property', () => { component.addProp('VERSION', 2); - assert.deepEqual(component._props, [prop]); + assert.deepEqual(component.internalProps, [prop]); }); - it('should throw an InvalidProvidedPropError if passed an invalid (for the component) prop', function() { - assert.throws(() => component.addProp('DTSTART', new Date()), InvalidProvidedPropError); + it('should throw an InvalidProvidedPropError if passed an invalid (for the component) prop', () => { + assert.throws(() => { + component.addProp('DTSTART', new Date()); + }, InvalidProvidedPropError); }); - it('should throw an Error if passed a prop against its requirement validations', function() { + it('should throw an Error if passed a prop against its requirement validations', () => { component.addProp('VERSION', 2); - assert.throws(() => component.addProp('VERSION', 2), ValidationError); + assert.throws(() => { + component.addProp('VERSION', 2); + }, ValidationError); }); }); - describe('#components()', function() { - it('should not be mutable', function() { - assert.throws(() => component.components().push(component2), TypeError); + describe('#components()', () => { + it('should not be mutable', () => { + assert.throws(() => { + component.components().push(component2); + }, TypeError); }); - describe('with no components', function() { - it('should return an empty array', function() { + describe('with no components', () => { + it('should return an empty array', () => { assert.deepEqual(component.components(), []); }); }); - describe('with some components', function() { - it('should return an array with added Component objects', function() { + describe('with some components', () => { + it('should return an array with added Component objects', () => { component.addComponent(component2); assert.deepEqual(component.components(), [component2]); }); }); }); - describe('#componentNames()', function() { - describe('with no components', function() { - it('should return an empty array', function() { + describe('#componentNames()', () => { + describe('with no components', () => { + it('should return an empty array', () => { assert.deepEqual(component.componentNames(), []); }); }); - describe('with some components', function() { - it('should return an array with added Component objects\' names', function() { + describe('with some components', () => { + it('should return an array with added Component objects\' names', () => { component.addComponent(component2); assert.deepEqual(component.componentNames(), [component2.constructor.componentName]); }); }); }); - describe('#addComponent()', function() { - it('should add a Component', function() { + describe('#addComponent()', () => { + it('should add a Component', () => { component.addComponent(component2); - assert.deepEqual(component._components, [component2]); + assert.deepEqual(component.internalComponents, [component2]); }); - it('should throw a TypeError if not passed an instance of Component', function() { - assert.throws(() => component.addComponent('component'), TypeError); + it('should throw a TypeError if not passed an instance of Component', () => { + assert.throws(() => { + component.addComponent('component'); + }, TypeError); }); - it('should throw an InvalidProvidedComponentError if passed an invalid (for the component) component', function() { + it('should throw an InvalidProvidedComponentError if passed an invalid (for the component) component', () => { const invalidComponent = new ICS.VCALENDAR(); - assert.throws(() => component.addComponent(invalidComponent), InvalidProvidedComponentError); + + assert.throws(() => { + component.addComponent(invalidComponent); + }, InvalidProvidedComponentError); }); }); - describe('#reset()', function() { - it('should remove all props and components', function() { + describe('#reset()', () => { + it('should remove all props and components', () => { component.addProp('VERSION', 2); component.addComponent(component2); component.reset(); - assert.deepEqual(component._props, []); - assert.deepEqual(component._components, []); + assert.deepEqual(component.internalProps, []); + assert.deepEqual(component.internalComponents, []); }); }); - describe('#validateRequired()', function() { - it('should throw an InvalidComponentError if missing required props', function() { + describe('#validateRequired()', () => { + it('should throw an InvalidComponentError if missing required props', () => { component.addProp('VERSION', 2); - assert.throws(() => component.validateRequired(), InvalidComponentError); + assert.throws(() => { + component.validateRequired(); + }, InvalidComponentError); }); - it('should return true if all required props are present', function() { + it('should return true if all required props are present', () => { component.addProp('VERSION', 2); component.addProp('PRODID', 'XYZ Corp'); assert.equal(component.validateRequired(), true); }); }); - describe('#toString()', function() { - beforeEach(function() { + describe('#toString()', () => { + beforeEach(() => { component.addProp('VERSION', 2); component.addProp('PRODID', 'XYZ Corp'); }); - it('should return a string', function() { + it('should return a string', () => { assert.equal(typeof component.toString(), 'string'); }); - it('should begin and end with prefix and suffix', function() { + it('should begin and end with prefix and suffix', () => { const string = component.toString(); const separator = component.constructor.separator; const splitString = string.split(separator); @@ -176,24 +194,24 @@ describe('Component', function() { // Tests involving Blob skipped since Node/io.js does not support it. - describe.skip('#toBlob()', function() { - beforeEach(function() { + describe.skip('#toBlob()', () => { + beforeEach(() => { component.addProp('VERSION', 2); component.addProp('PRODID', 'XYZ Corp'); }); - it('should return an instance of Blob', function() { + it('should return an instance of Blob', () => { assert.equal(component.toBlob() instanceof Blob, true); }); }); - describe.skip('toBase64()', function() { - beforeEach(function() { + describe.skip('toBase64()', () => { + beforeEach(() => { component.addProp('VERSION', 2); component.addProp('PRODID', 'XYZ Corp'); }); - it('should return a string starting with "data:text/calendar,"', function() { + it('should return a string starting with "data:text/calendar,"', () => { const base64 = component.toBase64(); assert.equal(typeof base64, 'string'); diff --git a/test/unit/ICS.js b/test/unit/ICS.js deleted file mode 100644 index 6915487..0000000 --- a/test/unit/ICS.js +++ /dev/null @@ -1,24 +0,0 @@ -import assert from 'assert'; -import ICS from '../../src/ICS'; -import Property from '../../src/Property'; -import Component from '../../src/Component'; - -describe('ICS', function() { - describe('Property', function() { - it('should return the Property class', function() { - assert.equal(ICS.Property, Property); - }); - }); - - describe('Component', function() { - it('should return the Component class', function() { - assert.equal(ICS.Component, Component); - }); - }); - - describe('::MIME_TYPE', function() { - it('should return "text/calendar"', function() { - assert.equal(ICS.MIME_TYPE, 'text/calendar'); - }); - }); -}); diff --git a/test/unit/Property.js b/test/unit/Property.js index b41c7e7..d1b126b 100644 --- a/test/unit/Property.js +++ b/test/unit/Property.js @@ -1,83 +1,72 @@ +/* eslint max-nested-callbacks:0 */ + import assert from 'assert'; -import ICS from '../../src/ICS'; +import Property from '../../src/Property'; -const validName = 'DSTART'; -const invalidName = '-DStart-'; const value = 'value'; -const prop = new ICS.Property(value); +const prop = new Property(value); const propProps = { KEY1: 'VALUE1', KEY2: 'VALUE2' }; -const propWithProps = new ICS.Property(value, propProps); - -describe('Property', function() { - describe('::keyRegex', function() { - const keyRegex = ICS.Property.keyRegex; - - it('should return false for keys containing invalid characters', function() { - assert.equal(keyRegex.test(invalidName), false); - }); +const propWithProps = new Property(value, propProps); - it('should return true for a valid key', function() { - assert.equal(keyRegex.test(validName), true); - }); - }); - - describe('#constructor()', function() { - it('should create a new instance of ICS.Property', function() { - assert.equal(prop instanceof ICS.Property, true); +describe('Property', () => { + describe('#constructor()', () => { + it('should create a new instance of Property', () => { + assert.equal(prop instanceof Property, true); }); - it('should have defined `value` and `skipTransformer` instance properties', function() { - assert.equal(prop.value != undefined, true); - assert.equal(prop.skipTransformer != undefined, true); + it('should have defined `value` and `skipTransformer` instance properties', () => { + assert.notStrictEqual(typeof prop.value, 'undefined'); + assert.notStrictEqual(typeof prop.skipTransformer, 'undefined'); }); }); - describe('#shortTransformer()', function() { - it('should return true', function() { + describe('#shortTransformer()', () => { + it('should return true', () => { assert.equal(prop.shortTransformer(), true); }); }); - describe('#transformer()', function() { - it('should return value untouched', function() { + describe('#transformer()', () => { + it('should return value untouched', () => { assert.equal(prop.transformer(), value); }); }); - describe('#transformedValue()', function() { - it('should return value untouched', function() { + describe('#transformedValue()', () => { + it('should return value untouched', () => { assert.equal(prop.transformer(), value); }); }); - describe('#transformedProps()', function() { - it('should return a string', function() { + describe('#transformedProps()', () => { + it('should return a string', () => { assert.equal(typeof prop.transformedProps(), 'string'); }); - describe('with no props', function() { - it('should return an empty string', function() { + describe('with no props', () => { + it('should return an empty string', () => { assert.equal(prop.transformedProps(), ''); }); }); - describe('with props', function() { - it('should return a semicolon separated string', function() { + describe('with props', () => { + it('should return a semicolon separated string', () => { assert.equal(propWithProps.transformedProps(), 'KEY1=VALUE1;KEY2=VALUE2'); }); }); }); - describe('toString()', function() { - it('should return a string', function() { + describe('toString()', () => { + it('should return a string', () => { assert.equal(typeof prop.toString(), 'string'); }); - it('should be properly formatted', function() { + it('should be properly formatted', () => { const regex = /.*:{1}.*/; + assert.equal(regex.test(prop.toString()), true); }); }); diff --git a/test/unit/properties/DTSTAMP.js b/test/unit/properties/DTSTAMP.js index 9c2f5c8..75dc7de 100644 --- a/test/unit/properties/DTSTAMP.js +++ b/test/unit/properties/DTSTAMP.js @@ -6,7 +6,7 @@ propertyTest('DTSTAMP', { }); propertyTest('DTSTAMP', { + transformableProps: {VALUE: 'DATE'}, transformableValue: new Date('1991-03-07'), - transformableProps: { VALUE: 'DATE' }, transformedValue: '19910307' }); diff --git a/test/unit/properties/EXDATE.js b/test/unit/properties/EXDATE.js index cd62714..2a40c18 100644 --- a/test/unit/properties/EXDATE.js +++ b/test/unit/properties/EXDATE.js @@ -6,7 +6,7 @@ propertyTest('EXDATE', { }); propertyTest('EXDATE', { + transformableProps: {VALUE: 'DATE'}, transformableValue: [new Date('1991-03-07'), new Date('1991-07-11')], - transformableProps: { VALUE: 'DATE' }, transformedValue: '19910307,19910711' }); diff --git a/test/unit/properties/TRANSP.js b/test/unit/properties/TRANSP.js index 7abec96..5979671 100644 --- a/test/unit/properties/TRANSP.js +++ b/test/unit/properties/TRANSP.js @@ -1,15 +1,16 @@ import assert from 'assert'; import propertyTest from '../../helpers/propertyTest'; -import { TRANSP } from '../../../src/properties'; +import {TRANSP} from '../../../src/properties'; propertyTest('TRANSP', { transformableValue: true, transformedValue: 'TRANSPARENT' }); -describe('UID', function() { - it('should return OPAQUE if false', function() { +describe('TRANSP', () => { + it('should return OPAQUE if false', () => { const prop = new TRANSP(false); + assert.equal(prop.transformedValue(), 'OPAQUE'); }); }); diff --git a/test/unit/properties/UID.js b/test/unit/properties/UID.js index d970847..9ba6344 100644 --- a/test/unit/properties/UID.js +++ b/test/unit/properties/UID.js @@ -1,15 +1,16 @@ import assert from 'assert'; import propertyTest from '../../helpers/propertyTest'; -import { UID } from '../../../src/properties'; +import {UID} from '../../../src/properties'; propertyTest('UID', { transformableValue: '123', transformedValue: '123' }); -describe('UID', function() { - it('should generate a GUID if no value is provided', function() { +describe('UID', () => { + it('should generate a GUID if no value is provided', () => { const prop = new UID(); + assert.equal(prop.transformedValue().length, 36); }); }); diff --git a/test/unit/properties/_default.js b/test/unit/properties/base.js similarity index 58% rename from test/unit/properties/_default.js rename to test/unit/properties/base.js index 507a592..951ceb9 100644 --- a/test/unit/properties/_default.js +++ b/test/unit/properties/base.js @@ -1,22 +1,22 @@ import assert from 'assert'; import Property from '../../../src/Property'; -import { _default } from '../../../src/properties'; +import {base} from '../../../src/properties'; -describe('_default', function() { +describe('base', () => { const name = 'NAME'; const value = 'value'; - const PropClass = _default(name); + const PropClass = base(name); const prop = new PropClass(value); - describe('_default()', function() { - it('should return an extension of Property with the name as the propName', function() { + describe('base()', () => { + it('should return an extension of Property with the name as the propName', () => { assert.equal(new PropClass() instanceof Property, true); assert.equal(PropClass.propName, name); }); }); - describe('#transformedValue()', function() { - it('should pass the value without transformations', function() { + describe('#transformedValue()', () => { + it('should pass the value without transformations', () => { assert.equal(prop.transformedValue(), value); }); }); diff --git a/webpack.config.js b/webpack.config.js index 99afaf2..d4a585f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,46 +1,42 @@ -'use strict'; - -var path = require('path'); var webpack = require('webpack'); module.exports = { - entry: [path.resolve(__dirname, 'src/ICS.js')], + entry: './src/index.js', output: { - path: path.resolve(__dirname, 'dist'), + path: 'dist', filename: 'ics-js.js', - publicPath: '/dist/', - pathinfo: false, - libraryTarget: 'umd', + libraryTarget: 'umd' }, module: { loaders: [ - { test: /\.js$/, exclude: /node_modules/, loader: 'babel' } - ], - }, - - target: 'node', - devtool: false, - debug: false, - cache: false, - - stats: { - colors: true, - reasons: false, + { + test: /\.js$/, + exclude: /node_modules/, + loader: 'babel' + } + ] }, resolve: { - root: path.join(__dirname, 'src'), - extensions: ['', '.js'], + modulesDirectories: ['node_modules'], + extensions: ['', '.js'] }, - resolveLoader: { - root: path.join(__dirname, 'node_modules'), - }, + target: 'node', plugins: [ new webpack.NoErrorsPlugin(), new webpack.optimize.OccurenceOrderPlugin(), - ], + new webpack.optimize.UglifyJsPlugin({ + compress: { + warnings: false + }, + mangle: true, + output: { + comments: false + } + }) + ] };