Skip to content

Commit 1d43072

Browse files
author
Jason Ibrahim
committed
export all files from ts
1 parent 4460911 commit 1d43072

File tree

127 files changed

+2297
-131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+2297
-131
lines changed

dist/appworks.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/appworks.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @module
3+
* @description
4+
* Entry point for all public APIs of the appworks package.
5+
*/
6+
"use strict";
7+
function __export(m) {
8+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
9+
}
10+
Object.defineProperty(exports, "__esModule", { value: true });
11+
__export(require("./src/index"));
12+
// This file only reexports content of the `src` folder. Keep it that way.

package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@
4242
""
4343
],
4444
"license": "LICENSE",
45-
"main": "dist/appworks.js",
46-
"main:min": "dist/appworks.min.js",
45+
"main": "src/index.js",
46+
"legacy": "dist/appworks.js",
47+
"legacy:min": "dist/appworks.min.js",
4748
"repository": "https://github.com/opentext/appworks-js",
4849
"scripts": {
49-
"build": "rollup -c && rollup -c --environment BUILD:min",
50+
"ts:export": "tsc index.ts --target es5",
51+
"build": "npm run ts:export && rollup -c && rollup -c --environment BUILD:min",
5052
"lint": "tslint -c tslint.json ./src/**/*.ts",
5153
"prebuild": "npm run test",
5254
"test": "mocha --compilers ts:ts-node/register test/**.spec.ts test/**/*.spec.ts",

rollup.config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@ export default {
1919
};
2020

2121
function dest() {
22-
let pkg = require('./package.json');
23-
if (process.env.BUILD == 'min') {
24-
return pkg['main:min'];
22+
const pkg = require('./package.json');
23+
if (process.env.BUILD === 'min') {
24+
return pkg['legacy:min'];
2525
} else {
26-
return pkg['main'];
26+
return pkg['legacy'];
2727
}
2828
}
2929

3030
function plugins() {
31-
let use = [];
31+
const use = [];
3232
// as we are using a different version of Typescript to the one supplied by rollup we need to require it here
3333
use.push(typescript({
3434
typescript: require('typescript')

src/common/plugin.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var AWPlugin = (function () {
4+
/**
5+
* Base plugin class. Constructor takes in a success function and error function to be executed upon
6+
* return from call to native layer
7+
* @param successHandler - the function to be executed when the native call succeeds. passes an object as arg
8+
* @param errorHandler - the function to be executed when the native call fails. passes an object as arg.
9+
*/
10+
function AWPlugin(successHandler, errorHandler) {
11+
this.successHandler = successHandler;
12+
this.errorHandler = errorHandler;
13+
}
14+
return AWPlugin;
15+
}());
16+
exports.AWPlugin = AWPlugin;
File renamed without changes.

src/common/proxy.js

Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var contacts_1 = require("../../test/mock/contacts");
4+
var accelerometer_1 = require("../../test/mock/accelerometer");
5+
var camera_1 = require("../../test/mock/camera");
6+
var compass_1 = require("../../test/mock/compass");
7+
var geolocation_1 = require("../../test/mock/geolocation");
8+
var media_1 = require("../../test/mock/media");
9+
var capture_1 = require("../../test/mock/capture");
10+
var notifications_1 = require("../../test/mock/notifications");
11+
var connection_1 = require("../../test/mock/connection");
12+
var vibrate_1 = require("../../test/mock/vibrate");
13+
var local_file_system_1 = require("../plugins/file/local-file-system");
14+
var file_transfer_1 = require("../../test/mock/file-transfer");
15+
var util_1 = require("./util");
16+
var storage_1 = require("../plugins/storage/storage");
17+
var on_device_storage_1 = require("../plugins/storage/on-device-storage");
18+
var persistent_storage_1 = require("../../test/mock/persistent-storage");
19+
var desktop_storage_1 = require("../plugins/storage/desktop-storage");
20+
var desktop_webview_1 = require("../plugins/webview/desktop-webview");
21+
var AWProxy = (function () {
22+
function AWProxy() {
23+
}
24+
AWProxy.exec = function (successHandler, errorHandler, name, method, args) {
25+
if (typeof exports.cordova !== 'undefined') {
26+
exports.cordova.exec(successHandler, errorHandler, name, method, args);
27+
}
28+
else if (AWProxy.isDesktopEnv()) {
29+
exports.__aw_plugin_proxy.exec(successHandler, errorHandler, name, method, args);
30+
}
31+
else {
32+
console.error('No proxy objects defined - tried [Cordova, __aw_plugin_proxy]');
33+
if (typeof errorHandler === 'function') {
34+
errorHandler('No proxy objects defined - tried [Cordova, __aw_plugin_proxy]');
35+
}
36+
}
37+
};
38+
AWProxy.accelerometer = function () {
39+
return typeof 'navigator' !== undefined ? exports.navigator.accelerometer : new accelerometer_1.MockAccelerometer();
40+
};
41+
AWProxy.camera = function () {
42+
return typeof exports.navigator !== 'undefined' ? exports.navigator.camera : new camera_1.MockCamera();
43+
};
44+
AWProxy.Camera = function () {
45+
return (typeof exports.Camera !== 'undefined') ? exports.Camera : {
46+
DestinationType: {
47+
DATA_URL: null,
48+
FILE_URI: null,
49+
NATIVE_URI: null,
50+
},
51+
Direction: {
52+
BACK: null,
53+
FRONT: null,
54+
},
55+
EncodingType: {
56+
JPEG: null,
57+
PNG: null,
58+
},
59+
MediaType: {
60+
PICTURE: null,
61+
VIDEO: null,
62+
ALLMEDIA: null,
63+
},
64+
PictureSourceType: {
65+
PHOTOLIBRARY: null,
66+
CAMERA: null,
67+
SAVEDPHOTOALBUM: null,
68+
},
69+
// Used only on iOS
70+
PopoverArrowDirection: {
71+
ARROW_UP: null,
72+
ARROW_DOWN: null,
73+
ARROW_LEFT: null,
74+
ARROW_RIGHT: null,
75+
ARROW_ANY: null
76+
}
77+
};
78+
};
79+
AWProxy.compass = function () {
80+
return typeof exports.navigator !== 'undefined' ? exports.navigator.compass : new compass_1.MockCompass();
81+
};
82+
AWProxy.connection = function () {
83+
return typeof exports.navigator !== 'undefined' ? exports.navigator.connection : new connection_1.MockConnection();
84+
};
85+
AWProxy.Connection = function () {
86+
return (typeof exports.Connection !== 'undefined') ? exports.Connection : {
87+
UNKNOWN: null,
88+
ETHERNET: null,
89+
WIFI: null,
90+
CELL_2G: null,
91+
CELL_3G: null,
92+
CELL_4G: null,
93+
CELL: null,
94+
NONE: null
95+
};
96+
};
97+
AWProxy.contacts = function () {
98+
return typeof exports.navigator !== 'undefined' ? exports.navigator.contacts : new contacts_1.MockContacts();
99+
};
100+
AWProxy.device = function () {
101+
var _device = (typeof exports.device !== 'undefined') ? exports.device : {
102+
cordova: null,
103+
available: true,
104+
model: null,
105+
platform: null,
106+
uuid: null,
107+
version: null,
108+
manufacturer: null,
109+
isVirtual: null,
110+
serial: null,
111+
capture: null
112+
};
113+
if (typeof exports.navigator !== 'undefined' && exports.navigator.device && exports.navigator.device.capture) {
114+
_device.capture = exports.navigator.device.capture;
115+
}
116+
else {
117+
_device.capture = new capture_1.MockCapture();
118+
}
119+
return _device;
120+
};
121+
AWProxy.document = function () {
122+
return (typeof document !== 'undefined') ? document : {
123+
addEventListener: util_1.Util.noop
124+
};
125+
};
126+
AWProxy.file = function () {
127+
if (typeof exports.cordova !== 'undefined') {
128+
return exports.cordova.file;
129+
}
130+
else {
131+
return {
132+
documentsDirectory: ''
133+
};
134+
}
135+
};
136+
AWProxy.filetransfer = function () {
137+
return AWProxy.doGetFileTransfer();
138+
};
139+
// alias name
140+
AWProxy.fileTransfer = function () {
141+
return AWProxy.doGetFileTransfer();
142+
};
143+
AWProxy.doGetFileTransfer = function () {
144+
if (AWProxy.isDesktopEnv()) {
145+
var plugin = AWProxy.getDesktopPlugin('AWFileTransfer');
146+
return (plugin !== null) ? plugin : new file_transfer_1.MockFileTransfer();
147+
}
148+
return (typeof exports.FileTransfer !== 'undefined') ? new exports.FileTransfer() : new file_transfer_1.MockFileTransfer();
149+
};
150+
AWProxy.geolocation = function () {
151+
return (typeof exports.navigator !== 'undefined') ? exports.navigator.geolocation : new geolocation_1.MockGeolocation();
152+
};
153+
AWProxy.localFileSystem = function () {
154+
return local_file_system_1.LocalFileSystem;
155+
};
156+
AWProxy.media = function (src, successHandler, errorHandler, statusChangeHandler) {
157+
if (typeof exports.Media !== 'undefined') {
158+
return new exports.Media(src, successHandler, errorHandler, statusChangeHandler);
159+
}
160+
else {
161+
return new media_1.MockMedia(src, successHandler, errorHandler, statusChangeHandler);
162+
}
163+
};
164+
AWProxy.notification = function () {
165+
return (typeof exports.navigator !== 'undefined') ? exports.navigator.notification : new notifications_1.MockNotification();
166+
};
167+
AWProxy.requestFileSystem = function (type, size, successCallback, errorCallback) {
168+
if (exports.window.requestFileSystem) {
169+
return exports.window.requestFileSystem(type, size, successCallback, errorCallback);
170+
}
171+
};
172+
AWProxy.vibrate = function (time) {
173+
if (typeof exports.navigator !== 'undefined' && exports.navigator.vibrate) {
174+
return exports.navigator.vibrate(time);
175+
}
176+
else {
177+
return new vibrate_1.MockVibrate().vibrate(time);
178+
}
179+
};
180+
AWProxy.webview = function () {
181+
if (typeof exports.cordova !== 'undefined') {
182+
return exports.cordova.InAppBrowser;
183+
}
184+
else {
185+
return new desktop_webview_1.DesktopWebview();
186+
}
187+
};
188+
AWProxy.storage = function () {
189+
return new storage_1.AWStorage();
190+
};
191+
AWProxy.persistentStorage = function () {
192+
var desktopPlugin = AWProxy.getDesktopPlugin('AWStorage');
193+
return desktopPlugin !== null ?
194+
new desktop_storage_1.DesktopStorage(desktopPlugin) : (AWProxy.isMobileEnv()) ?
195+
new on_device_storage_1.OnDeviceStorage() : new persistent_storage_1.PersistentStorageMock();
196+
};
197+
/**
198+
* Are we executing within the AppWorks Desktop context.
199+
*
200+
* @returns {boolean} true if this is a desktop environment, false otherwise
201+
*/
202+
AWProxy.isDesktopEnv = function () {
203+
return typeof exports.__aw_plugin_proxy !== 'undefined';
204+
};
205+
/**
206+
* Are we executing within the AppWorks mobile context.
207+
*
208+
* @return {boolean} true if Cordova is available, false otherwise
209+
*/
210+
AWProxy.isMobileEnv = function () {
211+
return typeof exports.cordova !== 'undefined';
212+
};
213+
/**
214+
* Ask the AppWorks desktop environment to retrieve an instance of a specific plugin.
215+
*
216+
* @param pluginName plugin identifier
217+
* @returns {any} plugin instance or null if no such plugin exists or the method was
218+
* called outside of the desktop client context
219+
*/
220+
AWProxy.getDesktopPlugin = function (pluginName) {
221+
if (!AWProxy.isDesktopEnv())
222+
return null;
223+
// the proxy exposed by desktop has a method to allow retrieval of plugin instances
224+
return exports.__aw_plugin_proxy.getPlugin(pluginName);
225+
};
226+
return AWProxy;
227+
}());
228+
exports.AWProxy = AWProxy;

src/proxy.ts renamed to src/common/proxy.ts

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import {MockContacts} from "../test/mock/contacts";
2-
import {MockAccelerometer} from "../test/mock/accelerometer";
3-
import {MockCamera} from "../test/mock/camera";
4-
import {MockCompass} from "../test/mock/compass";
5-
import {MockGeolocation} from "../test/mock/geolocation";
6-
import {MockMedia} from "../test/mock/media";
7-
import {MockCapture} from "../test/mock/capture";
8-
import {MockNotification} from "../test/mock/notifications";
9-
import {MockConnection} from "../test/mock/connection";
10-
import {MockVibrate} from "../test/mock/vibrate";
11-
import {LocalFileSystem} from "./plugins/file/local-file-system";
12-
import {MockFileTransfer} from "../test/mock/file-transfer";
1+
import {MockContacts} from "../../test/mock/contacts";
2+
import {MockAccelerometer} from "../../test/mock/accelerometer";
3+
import {MockCamera} from "../../test/mock/camera";
4+
import {MockCompass} from "../../test/mock/compass";
5+
import {MockGeolocation} from "../../test/mock/geolocation";
6+
import {MockMedia} from "../../test/mock/media";
7+
import {MockCapture} from "../../test/mock/capture";
8+
import {MockNotification} from "../../test/mock/notifications";
9+
import {MockConnection} from "../../test/mock/connection";
10+
import {MockVibrate} from "../../test/mock/vibrate";
11+
import {LocalFileSystem} from "../plugins/file/local-file-system";
12+
import {MockFileTransfer} from "../../test/mock/file-transfer";
1313
import {Util} from "./util";
14-
import {AWStorage} from "./plugins/storage/storage";
15-
import {OnDeviceStorage} from "./plugins/storage/on-device-storage";
16-
import {PersistentStorageMock} from "../test/mock/persistent-storage";
17-
import {DesktopStorage} from "./plugins/storage/desktop-storage";
18-
import {DesktopWebview} from "./plugins/webview/desktop-webview";
19-
import {CameraInterface} from './plugins/camera/index';
20-
import {Accelerometer} from './plugins/device-motion/index';
21-
import {Compass} from './plugins/device-orientation/index';
22-
import {ConnectionInterface} from './plugins/network-information/index';
23-
import {Contacts} from './plugins/contacts/index';
24-
import {FileTransferInterface} from './plugins/file-transfer/index';
25-
import {MediaInterface} from './plugins/media/index';
26-
import {FileError, FileSystem} from './plugins/file/index';
27-
import {PersistentStorage} from './plugins/storage/index';
28-
import {Device} from './plugins/device/index';
29-
import {Notification} from './plugins/dialogs/index';
14+
import {AWStorage} from "../plugins/storage/storage";
15+
import {OnDeviceStorage} from "../plugins/storage/on-device-storage";
16+
import {PersistentStorageMock} from "../../test/mock/persistent-storage";
17+
import {DesktopStorage} from "../plugins/storage/desktop-storage";
18+
import {DesktopWebview} from "../plugins/webview/desktop-webview";
19+
import {CameraInterface} from '../plugins/camera/index';
20+
import {Accelerometer} from '../plugins/device-motion/index';
21+
import {Compass} from '../plugins/device-orientation/index';
22+
import {ConnectionInterface} from '../plugins/network-information/index';
23+
import {Contacts} from '../plugins/contacts/index';
24+
import {FileTransferInterface} from '../plugins/file-transfer/index';
25+
import {MediaInterface} from '../plugins/media/index';
26+
import {FileError, FileSystem} from '../plugins/file/index';
27+
import {PersistentStorage} from '../plugins/storage/index';
28+
import {Device} from '../plugins/device/index';
29+
import {Notification} from '../plugins/dialogs/index';
3030

3131
export declare const Media: {
3232
new (src: string,

src/common/util.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var Util = (function () {
4+
function Util() {
5+
}
6+
Util.noop = function () {
7+
};
8+
return Util;
9+
}());
10+
exports.Util = Util;
File renamed without changes.

0 commit comments

Comments
 (0)