-
-
-
-
diff --git a/src/index.ts b/src/index.ts
index 431ebfef14..6be00c3f3b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -8,10 +8,6 @@ export * from './gestures/slide-edge-gesture';
export * from './gestures/slide-gesture';
export * from './gestures/gesture-controller';
-export * from './storage/storage';
-export * from './storage/sql';
-export * from './storage/local-storage';
-
export * from './util/click-block';
export * from './util/events';
export * from './util/keyboard';
diff --git a/src/storage/local-storage.ts b/src/storage/local-storage.ts
deleted file mode 100644
index 96d4fbe97b..0000000000
--- a/src/storage/local-storage.ts
+++ /dev/null
@@ -1,101 +0,0 @@
-import { StorageEngine } from './storage';
-
-
-/**
- * @name LocalStorage
- * @description
- * The LocalStorage storage engine uses the browser's local storage system for
- * storing key/value pairs.
- *
- * Note: LocalStorage should ONLY be used for temporary data that you can afford to lose.
- * Given disk space constraints on a mobile device, local storage might be "cleaned up"
- * by the operating system (iOS).
- *
- * For guaranteed, long-term storage, use the SqlStorage engine which stores data in a file.
- *
- * @usage
- * ```ts
- * import { Component } from '@angular/core';
- * import { Storage, LocalStorage } from 'ionic-angular';
- * @Component({
- * template: ``
- * });
- * export class MyClass{
- * constructor(){
- * this.local = new Storage(LocalStorage);
- * this.local.set('didTutorial', 'true');
- * }
- *}
- *```
- * @demo /docs/v2/demos/src/local-storage/
- * @see {@link /docs/v2/platform/storage/ Storage Platform Docs}
- */
-export class LocalStorage extends StorageEngine {
- constructor(options = {}) {
- super();
- }
-
- /**
- * Get the value of a key in LocalStorage
- * @param {string} key the key you want to lookup in LocalStorage
- * @returns {Promise} Returns a promise which is resolved when the value has been retrieved
- */
- get(key: string): Promise {
- return new Promise((resolve, reject) => {
- try {
- let value = window.localStorage.getItem(key);
- resolve(value);
- } catch (e) {
- reject(e);
- }
- });
- }
-
- /**
- * Set a key value pair and save it to LocalStorage
- * @param {string} key the key you want to save to LocalStorage
- * @param {string} value the value of the key you're saving
- * @returns {Promise} Returns a promise which is resolved when the key value pair have been set
- */
- set(key: string, value: string): Promise {
- return new Promise((resolve, reject) => {
- try {
- window.localStorage.setItem(key, value);
- resolve();
- } catch (e) {
- reject(e);
- }
- });
- }
-
- /**
- * Remove a key from LocalStorage
- * @param {string} key the key you want to remove from LocalStorage
- * @returns {Promise} Returns a promise which is resolved when the key has been removed
- */
- remove(key: string): Promise {
- return new Promise((resolve, reject) => {
- try {
- window.localStorage.removeItem(key);
- resolve();
- } catch (e) {
- reject(e);
- }
- });
- }
-
- /**
- * Clear data stored in LocalStorage
- * @returns {Promise} Returns a promise which is resolved when the data have been cleared
- */
- clear(): Promise {
- return new Promise((resolve, reject) => {
- try {
- window.localStorage.clear();
- resolve();
- } catch (e) {
- reject(e);
- }
- });
- }
-}
diff --git a/src/storage/sql.ts b/src/storage/sql.ts
deleted file mode 100644
index 05b5177c09..0000000000
--- a/src/storage/sql.ts
+++ /dev/null
@@ -1,155 +0,0 @@
-import { StorageEngine } from './storage';
-
-import { defaults, assign } from '../util/util';
-
-const DB_NAME: string = '__ionicstorage';
-const win: any = window;
-
-/**
- * SqlStorage is a wrapper that uses SQLite when running natively (if available)
- * to store data in a persistent SQL store on the filesystem
- * or uses WebSQL when serving the app to the browser.
- *
- * This is the preferred storage engine, as data will be stored in appropriate
- * app storage, unlike Local Storage which is treated differently by the OS.
- *
- * For convenience, the engine supports key/value storage for simple get/set and blob
- * storage. The full SQL engine is exposed underneath through the `query` method.
- *
- * @usage
- ```js
- * let storage = new Storage(SqlStorage, options);
- * storage.set('name', 'Max');
- * storage.get('name').then((name) => {
- * });
- *
- * // Sql storage also exposes the full engine underneath
- * storage.query('insert into projects(name, data) values("Cool Project", "blah")');
- * storage.query('select * from projects').then((resp) => {})
- * ```
- *
- * The `SqlStorage` service supports these options:
- * {
- * name: the name of the database (__ionicstorage by default)
- * backupFlag: // where to store the file, default is BACKUP_LOCAL which DOES NOT store to iCloud. Other options: BACKUP_LIBRARY, BACKUP_DOCUMENTS
- * existingDatabase: whether to load this as an existing database (default is false)
- * }
- *
- */
-export class SqlStorage extends StorageEngine {
- static BACKUP_LOCAL = 2;
- static BACKUP_LIBRARY = 1;
- static BACKUP_DOCUMENTS = 0;
-
- private _db: any;
-
- constructor(options = {}) {
- super();
-
- let dbOptions = defaults(options, {
- name: DB_NAME,
- backupFlag: SqlStorage.BACKUP_LOCAL,
- existingDatabase: false
- });
-
- if (win.sqlitePlugin) {
- let location = this._getBackupLocation(dbOptions.backupFlag);
-
- this._db = win.sqlitePlugin.openDatabase(assign({
- name: dbOptions.name,
- location: location,
- createFromLocation: dbOptions.existingDatabase ? 1 : 0
- }, dbOptions));
-
- } else {
- console.warn('Storage: SQLite plugin not installed, falling back to WebSQL. Make sure to install cordova-sqlite-storage in production!');
-
- this._db = win.openDatabase(dbOptions.name, '1.0', 'database', 5 * 1024 * 1024);
- }
- this._tryInit();
- }
-
- _getBackupLocation(dbFlag: number): number {
- switch (dbFlag) {
- case SqlStorage.BACKUP_LOCAL:
- return 2;
- case SqlStorage.BACKUP_LIBRARY:
- return 1;
- case SqlStorage.BACKUP_DOCUMENTS:
- return 0;
- default:
- throw Error('Invalid backup flag: ' + dbFlag);
- }
- }
-
- // Initialize the DB with our required tables
- _tryInit() {
- this.query('CREATE TABLE IF NOT EXISTS kv (key text primary key, value text)').catch(err => {
- console.error('Storage: Unable to create initial storage tables', err.tx, err.err);
- });
- }
-
- /**
- * Perform an arbitrary SQL operation on the database. Use this method
- * to have full control over the underlying database through SQL operations
- * like SELECT, INSERT, and UPDATE.
- *
- * @param {string} query the query to run
- * @param {array} params the additional params to use for query placeholders
- * @return {Promise} that resolves or rejects with an object of the form { tx: Transaction, res: Result (or err)}
- */
- query(query: string, params: any[] = []): Promise {
- return new Promise((resolve, reject) => {
- try {
- this._db.transaction((tx: any) => {
- tx.executeSql(query, params,
- (tx: any, res: any) => resolve({ tx: tx, res: res }),
- (tx: any, err: any) => reject({ tx: tx, err: err }));
- },
- (err: any) => reject({ err: err }));
- } catch (err) {
- reject({ err: err });
- }
- });
- }
-
- /**
- * Get the value in the database identified by the given key.
- * @param {string} key the key
- * @return {Promise} that resolves or rejects with an object of the form { tx: Transaction, res: Result (or err)}
- */
- get(key: string): Promise {
- return this.query('select key, value from kv where key = ? limit 1', [key]).then(data => {
- if (data.res.rows.length > 0) {
- return data.res.rows.item(0).value;
- }
- });
- }
-
- /**
- * Set the value in the database for the given key. Existing values will be overwritten.
- * @param {string} key the key
- * @param {string} value The value (as a string)
- * @return {Promise} that resolves or rejects with an object of the form { tx: Transaction, res: Result (or err)}
- */
- set(key: string, value: string): Promise {
- return this.query('insert or replace into kv(key, value) values (?, ?)', [key, value]);
- }
-
- /**
- * Remove the value in the database for the given key.
- * @param {string} key the key
- * @return {Promise} that resolves or rejects with an object of the form { tx: Transaction, res: Result (or err)}
- */
- remove(key: string): Promise {
- return this.query('delete from kv where key = ?', [key]);
- }
-
- /**
- * Clear all keys/values of your database.
- * @return {Promise} that resolves or rejects with an object of the form { tx: Transaction, res: Result (or err)}
- */
- clear(): Promise {
- return this.query('delete from kv');
- }
-}
diff --git a/src/storage/storage.ts b/src/storage/storage.ts
deleted file mode 100644
index a907166a56..0000000000
--- a/src/storage/storage.ts
+++ /dev/null
@@ -1,85 +0,0 @@
-/**
- * Storage is an easy way to store key/value pairs and other complicated
- * data in a way that uses a variety of storage engines underneath.
- *
- * For most cases, we recommend the SqlStorage system as it will store
- * data in a file in the app's sandbox. LocalStorage should ONLY be used
- * for temporary data as it may be 'cleaned up' by the operation system
- * during low disk space situations.
- */
-/**
- * @private
-*/
-export class Storage {
- private _strategy: StorageEngine;
-
- constructor(strategyCls: IStorageEngine, options?: any) {
- this._strategy = new strategyCls(options);
- }
-
- get(key: string): Promise {
- return this._strategy.get(key);
- }
-
- getJson(key: string): Promise {
- return this.get(key).then(value => {
- try {
- return JSON.parse(value);
- } catch (e) {
- console.warn('Storage getJson(): unable to parse value for key', key, ' as JSON');
- throw e; // rethrowing exception so it can be handled with .catch()
- }
- });
- }
-
- setJson(key: string, value: any): Promise {
- try {
- return this.set(key, JSON.stringify(value));
- } catch (e) {
- return Promise.reject(e);
- }
- }
-
- set(key: string, value: any) {
- return this._strategy.set(key, value);
- }
-
- remove(key: string) {
- return this._strategy.remove(key);
- }
-
- query(query: string, params?: any) {
- return this._strategy.query(query, params);
- }
-
- clear() {
- return this._strategy.clear();
- }
-}
-
-export interface IStorageEngine {
- new (options: any): StorageEngine;
-}
-
-/**
- * @private
-*/
-export class StorageEngine {
- constructor(options = {}) { }
-
- get(key: string): Promise {
- throw Error('get() not implemented for this storage engine');
- }
- set(key: string, value: any): Promise {
- throw Error('set() not implemented for this storage engine');
- }
- remove(key: string): Promise {
- throw Error('remove() not implemented for this storage engine');
- }
- query(query: string, params?: any): Promise {
- throw Error('query() not implemented for this storage engine');
- }
- clear(): Promise {
- throw Error('clear() not implemented for this storage engine');
- }
-}