removing webappbooster support
This commit is contained in:
Родитель
74b3e3561c
Коммит
9b38ee837a
10
Jakefile
10
Jakefile
|
@ -172,12 +172,6 @@ mkSimpleTask('build/ast.js', [
|
|||
'build/rt.d.ts',
|
||||
'ast'
|
||||
], "ast/refs.ts");
|
||||
mkSimpleTask('build/libwab.js', [
|
||||
'build/rt.d.ts',
|
||||
'rt/typings.d.ts',
|
||||
'build/browser.d.ts',
|
||||
'libwab'
|
||||
], "libwab/refs.ts");
|
||||
mkSimpleTask('build/libnode.js', [
|
||||
'build/rt.d.ts',
|
||||
'rt/typings.d.ts',
|
||||
|
@ -195,7 +189,6 @@ mkSimpleTask('build/editor.js', [
|
|||
'build/rt.d.ts',
|
||||
'build/ast.d.ts',
|
||||
'build/storage.d.ts',
|
||||
'build/libwab.d.ts',
|
||||
'build/libcordova.d.ts',
|
||||
'build/embedded.d.ts',
|
||||
'intellitrain',
|
||||
|
@ -226,7 +219,6 @@ mkSimpleTask('build/runner.js', [
|
|||
'rt/typings.d.ts',
|
||||
'build/rt.d.ts',
|
||||
'build/storage.d.ts',
|
||||
'build/libwab.d.ts',
|
||||
'build/libnode.d.ts',
|
||||
'build/libcordova.d.ts',
|
||||
'runner'
|
||||
|
@ -292,7 +284,6 @@ var concatMap = {
|
|||
"build/runtime.js": [
|
||||
"build/rt",
|
||||
"build/storage",
|
||||
"build/libwab",
|
||||
"build/libnode",
|
||||
"build/libcordova",
|
||||
"build/runner",
|
||||
|
@ -303,7 +294,6 @@ var concatMap = {
|
|||
"build/api.js",
|
||||
"generated/langs.js",
|
||||
"build/storage",
|
||||
"build/libwab",
|
||||
"build/libcordova",
|
||||
"build/pkgshell.js",
|
||||
"build/embedded",
|
||||
|
|
|
@ -177,7 +177,6 @@ The `client.js` is built by default.
|
|||
* `lib`: the libraries exposed to Touch Develop scripts, written in TypeScript
|
||||
* `libcordova`: Apache Cordova specific implementations
|
||||
* `libnode`: Node.JS specific implementations
|
||||
* `libwab`: WebAppBooster implementations, used by the Windows Phone client
|
||||
* `libwinRT`: (deprecated) WinRT specific implementations
|
||||
* `mc`: Minecraft bindings
|
||||
* `noderunner`: runs in the cloud, and parses Touch Develop scripts / compiles
|
||||
|
|
|
@ -513,11 +513,8 @@ module TDev {
|
|||
if (TDev.RT.UserMediaManager.isSupported()) _cap |= PlatformCapability.Camera;
|
||||
if (TDev.RT.Languages.isSpeechSupported()) _cap |= PlatformCapability.Speech;
|
||||
if (TDev.RT.AudioContextManager.isMicrophoneSupported()) _cap |= PlatformCapability.Microphone;
|
||||
if (Browser.isWP8app) _cap |= PlatformCapability.Phone;
|
||||
if (Browser.isNodeJS) _cap |= PlatformCapability.Npm;
|
||||
if (Browser.localProxy) _cap |= PlatformCapability.Shell;
|
||||
if ((<any>TDev.RT).Wab)
|
||||
_cap |= AST.App.fromCapabilityList((<any>TDev.RT).Wab.getSupportedCapabilities());
|
||||
}
|
||||
return _cap;
|
||||
}
|
||||
|
@ -531,8 +528,7 @@ module TDev {
|
|||
UsesStackFrame = 0x00000002,
|
||||
|
||||
Web = 0x00000010,
|
||||
Wab = 0x00000040,
|
||||
WebAll = ImplementationStatus.Web | ImplementationStatus.Wab
|
||||
WebAll = ImplementationStatus.Web
|
||||
}
|
||||
|
||||
|
||||
|
@ -1502,7 +1498,6 @@ module TDev {
|
|||
this._implStatus = this._implStatus & ~ImplementationStatus.WebAll;
|
||||
for (var i = 0; i < platforms.length; ++i)
|
||||
switch (platforms[i]) {
|
||||
case "wab": this._implStatus |= ImplementationStatus.Wab; break;
|
||||
case "": break;
|
||||
default: this.md_oops("unknown platform for stub " + platforms[i])
|
||||
}
|
||||
|
|
|
@ -333,7 +333,6 @@ module TDev.AST.Json
|
|||
pausesInterpreter: optBool(p._implStatus & ImplementationStatus.Pauses),
|
||||
usesStackFrame: optBool(p._implStatus & ImplementationStatus.UsesStackFrame),
|
||||
missingWeb: optBool(!(p._implStatus & ImplementationStatus.Web)),
|
||||
missingWab: optBool(!(p._implStatus & ImplementationStatus.Wab)),
|
||||
capabilities: App.capabilityString(p.getCapability()) || undefined,
|
||||
|
||||
result: doParam(p.getResult()),
|
||||
|
|
|
@ -444,7 +444,6 @@ module TDev.AST.Json
|
|||
pausesInterpreter?: boolean; // is this a potentially-async operation
|
||||
usesStackFrame?: boolean; // is the implementation passed IStackFrame object
|
||||
missingWeb?: boolean; // is the implementation missing from the general web version
|
||||
missingWab?: boolean; // .... from web version running with WebAppBooster
|
||||
capabilities?: string; // comma-separated list of required platform capabilities (if any)
|
||||
result: JPropertyParameter;
|
||||
parameters: JPropertyParameter[];
|
||||
|
|
|
@ -40,7 +40,6 @@ module TDev {
|
|||
export var isWindows8plus = false;
|
||||
export var isRaspberryPiDebian = false;
|
||||
export var isCompiledApp = false;
|
||||
export var isWP8app = false;
|
||||
export var isHosted = false;
|
||||
export var browser = BrowserSoftware.unknown;
|
||||
export var browserVersion = 0;
|
||||
|
@ -60,7 +59,6 @@ module TDev {
|
|||
export var touchStart = false;
|
||||
export var webRunner = false;
|
||||
export var webAppImplicit = false;
|
||||
export var webAppBooster = false;
|
||||
export var inCordova = false;
|
||||
export var inEditor = false;
|
||||
export var builtinTouchToPan = false;
|
||||
|
@ -248,12 +246,6 @@ module TDev {
|
|||
browser = BrowserSoftware.nodeJS;
|
||||
useConsoleLog = true;
|
||||
}
|
||||
if (isTrident && !inCordova) {
|
||||
if (/^x-wmapp/.test(document.URL)) {
|
||||
isWP8app = true;
|
||||
addCap("wp8app");
|
||||
}
|
||||
}
|
||||
|
||||
if (inCordova)
|
||||
addCap("cordova")
|
||||
|
@ -339,8 +331,7 @@ module TDev {
|
|||
}
|
||||
|
||||
browserShortName = browserName(browser);
|
||||
if (isWP8app) browserShortName += ".wp8app";
|
||||
else if (isCellphone) browserShortName += ".phone";
|
||||
if (isCellphone) browserShortName += ".phone";
|
||||
else if (isTablet) browserShortName += ".tablet";
|
||||
else browserShortName += ".desktop";
|
||||
if (inCordova) browserShortName += ".cordova";
|
||||
|
@ -358,7 +349,6 @@ module TDev {
|
|||
if (/Windows NT 5.1/.test(userAgent)) { addCap("win"); addCap("winXP"); }
|
||||
if (/Windows NT 6.0/.test(userAgent)) { addCap("win"); addCap("winVista"); }
|
||||
if (/Windows NT 6.1/.test(userAgent)) { addCap("win"); addCap("win7"); }
|
||||
if (webAppBooster) { addCap("webAppBooster"); }
|
||||
if (isMobileSafari || (isMobile && (browser == BrowserSoftware.ie10 || browser == BrowserSoftware.ie11))) { audioDataUrls = false; }
|
||||
|
||||
if (mobileWebkit)
|
||||
|
@ -377,12 +367,6 @@ module TDev {
|
|||
}
|
||||
} catch (e) { } // observed to fail in "Private Browsing" of (mobile) Safari
|
||||
|
||||
if (isWP8app) {
|
||||
audioDataUrls = true; // through wab
|
||||
screenshots = true; // through wab
|
||||
audioWav = true;
|
||||
}
|
||||
|
||||
dragAndDrop = !isNodeJS && !Browser.isMobile && document && document.createElement && 'draggable' in document.createElement('span');
|
||||
// compiler policies from cloud performance benchmarks
|
||||
/*switch (browser) {
|
||||
|
@ -518,7 +502,7 @@ module TDev {
|
|||
|
||||
// note that on WP8, if Internet Explorer is configured to disallow "storing files", then IndexedDB is not available --- however, this does not actually matter for the Windows Phone app, as it uses its own database backend
|
||||
// in some configrations, we will use an in-memory database instead
|
||||
if (!canWebSql && !canIndexedDB && !isWP8app && !canMemoryTable) {
|
||||
if (!canWebSql && !canIndexedDB && !canMemoryTable) {
|
||||
if (browser == BrowserSoftware.ie10 || browser == BrowserSoftware.ie11)
|
||||
return genericMessage("<p>You are running Internet Explorer in the InPrivate mode. " + what + " does not support this mode, as " + what + " needs to maintain a database of installed scripts, but the InPrivate mode does not allow the use of databases.</p>",
|
||||
"a regular Internet Explorer window");
|
||||
|
|
|
@ -211,10 +211,7 @@ module TDev
|
|||
|
||||
if ((<any>window.navigator).standalone) Util.log("standalone");
|
||||
statusMsg("page loaded, initializing");
|
||||
if (RT.Wab)
|
||||
return RT.Wab.initAsync().then(() => init2Async());
|
||||
else
|
||||
return init2Async();
|
||||
return init2Async();
|
||||
}
|
||||
|
||||
function init2Async(): Promise {
|
||||
|
|
|
@ -4344,27 +4344,21 @@ module TDev
|
|||
|
||||
betaDiv = div("wall-dialog-body",
|
||||
Editor.mkHelpLink("beta"),
|
||||
Browser.isWP8app ? div(null, lf("Using cloud services ") + relId)
|
||||
: HTML.mkCheckBox(
|
||||
HTML.mkCheckBox(
|
||||
lf("always use beta version of TouchDevelop"),
|
||||
Editor.setAlwaysBeta, Editor.isAlwaysBeta()),
|
||||
div("clear"));
|
||||
if (World.switchToChannel) {
|
||||
if ((<any>window).betaFriendlyId) {
|
||||
betaDiv.appendChild(HTML.mkButton(
|
||||
Browser.isWP8app ?
|
||||
lf("stop cloud services beta testing") :
|
||||
lf("stop beta testing"),
|
||||
lf("stop beta testing"),
|
||||
() => {
|
||||
Editor.setAlwaysBeta(false);
|
||||
World.switchToChannel("current");
|
||||
m.dismiss();
|
||||
}))
|
||||
} else {
|
||||
betaDiv.appendChild(HTML.mkButton(
|
||||
Browser.isWP8app ?
|
||||
lf("start cloud services beta testing") :
|
||||
lf("start beta testing"),
|
||||
betaDiv.appendChild(HTML.mkButton(lf("start beta testing"),
|
||||
() => {
|
||||
World.switchToChannel("beta");
|
||||
m.dismiss();
|
||||
|
@ -4614,13 +4608,8 @@ module TDev
|
|||
|
||||
this.setupTopButtons();
|
||||
|
||||
if (Browser.webAppBooster) {
|
||||
api.core.currentPlatform = PlatformCapabilityManager.current(); // based on supported features
|
||||
api.core.currentPlatformImpl = ImplementationStatus.Wab;
|
||||
} else {
|
||||
api.core.currentPlatform = PlatformCapabilityManager.current();
|
||||
api.core.currentPlatformImpl = ImplementationStatus.Web;
|
||||
}
|
||||
api.core.currentPlatform = PlatformCapabilityManager.current();
|
||||
api.core.currentPlatformImpl = ImplementationStatus.Web;
|
||||
|
||||
if (Cloud.lite) {
|
||||
var incoming = false;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
///<reference path='../build/rt.d.ts'/>
|
||||
///<reference path='../build/ast.d.ts'/>
|
||||
///<reference path='../build/storage.d.ts'/>
|
||||
///<reference path='../build/libwab.d.ts'/>
|
||||
///<reference path='../build/libcordova.d.ts'/>
|
||||
///<reference path='../build/embedded.d.ts'/>
|
||||
///<reference path='../typings/ace/ace.d.ts'/>
|
||||
|
|
|
@ -1065,12 +1065,9 @@
|
|||
if (!Editor.isAlwaysBeta()) Editor.setAlwaysBeta(false);
|
||||
m.add([
|
||||
div("wall-dialog-header", lf("Stay at the bleeding edge!")),
|
||||
div("wall-dialog-body",
|
||||
Util.fmt("Run the beta version of Touch Develop {0}.",
|
||||
Browser.isWP8app ? "cloud services" : "web app")),
|
||||
div("wall-dialog-body", lf("Run the beta version of Touch Develop.")),
|
||||
div("wall-dialog-body", lf("See upcoming features first, and help us debug.")),
|
||||
div("wall-dialog-body", lf("You can always go back to the regular version (from 'Settings' in the hub).")),
|
||||
Browser.isWP8app ? null :
|
||||
div("wall-dialog-body", HTML.mkCheckBox(lf("from now on always use beta"), Editor.setAlwaysBeta, Editor.isAlwaysBeta())),
|
||||
div("wall-dialog-buttons",
|
||||
HTML.mkButton(lf("try out beta"), () => {
|
||||
|
@ -6804,9 +6801,7 @@
|
|||
var pinB = null
|
||||
var updateB = null
|
||||
var editB = mkBtn(Ticks.browseEdit, "svg:edit,white", lf("edit"), null, () => { this.edit() });
|
||||
if (TDev.RT.Wab && this.getGuid() && TDev.RT.Wab.isSupportedAction(TDev.RT.Wab.Action.UPDATE_TILE)) {
|
||||
pinB = mkBtn(Ticks.browsePin, "svg:pushpin,white", lf("pin to start"), null, () => { this.pinAsync().done(); });
|
||||
} else if (TDev.RT.App.env().has_host() && this.publicId) {
|
||||
if (TDev.RT.App.env().has_host() && this.publicId) {
|
||||
pinB = mkBtn(Ticks.browsePin, "svg:arrowdownl,white", lf("add to inventory"), null, () => { this.sendScriptIdToAppHost(); });
|
||||
}
|
||||
if (World.updateFor(this.cloudHeader)) {
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT {
|
||||
export module AdManager {
|
||||
export var initialize = (el: HTMLElement) =>
|
||||
{
|
||||
el.setChildren([HTML.mkA('', Cloud.getServiceUrl() + '/help/advertisement', '_blank', 'Learn how to display Ads in your apps!')]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -543,7 +543,7 @@ module TDev.RT {
|
|||
public operating_system() : string
|
||||
{
|
||||
if (Browser.isAndroid) return "android";
|
||||
if (Browser.isWP8app || (Browser.isTrident && Browser.isCellphone)) return "wp";
|
||||
if (Browser.isTrident && Browser.isCellphone) return "wp";
|
||||
if (Browser.isMobileSafari) return "ios";
|
||||
if (Browser.isMacOSX) return "osx";
|
||||
|
||||
|
|
12
lib/Sound.ts
12
lib/Sound.ts
|
@ -102,18 +102,6 @@ module TDev.RT {
|
|||
return streamed();
|
||||
}
|
||||
|
||||
public toWabRequestAsync(): Promise {
|
||||
return this.createUrlAsync()
|
||||
.then(url => {
|
||||
return {
|
||||
uri : url,
|
||||
pan : this._pan,
|
||||
pitch : this._pitch,
|
||||
volume : this._volume
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
public initAsync() : Promise
|
||||
{
|
||||
if (this._buffer || this._audio) return Promise.as(this);
|
||||
|
|
|
@ -89,7 +89,6 @@
|
|||
///<reference path='UserMediaManager.ts'/>
|
||||
///<reference path='CanvasChart.ts'/>
|
||||
///<reference path='ApiManager.ts'/>
|
||||
///<reference path='AdManager.ts'/>
|
||||
///<reference path='Matrix.ts'/>
|
||||
///<reference path='artCache.ts'/>
|
||||
///<reference path='OAuthResponse.ts'/>
|
||||
|
|
|
@ -1,24 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function AdManagerInit()
|
||||
{
|
||||
if (isSupportedAction(Action.SHOW_AD) &&
|
||||
ApiManager.pubCenterApplicationId &&
|
||||
ApiManager.pubCenterAdUnitId) {
|
||||
Util.log('wab: boosting SHOW_AD');
|
||||
AdManager.initialize = AdManagerWab.initialize;
|
||||
}
|
||||
}
|
||||
|
||||
export module AdManagerWab {
|
||||
export function initialize(el: HTMLElement) {
|
||||
Util.log('wab: initialize AdCenter, AdUnitId = ' + ApiManager.pubCenterAdUnitId + ', ApplicationId = ' + ApiManager.pubCenterApplicationId);
|
||||
el.style.display = 'none';
|
||||
sendRequest({
|
||||
action: Action.SHOW_AD,
|
||||
adUnitId:ApiManager.pubCenterAdUnitId,
|
||||
applicationId:ApiManager.pubCenterApplicationId
|
||||
}, (response: Response) => { });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function ArtCacheInit()
|
||||
{
|
||||
ArtCache.getMaxItems = ArtCacheWab.getMaxItems;
|
||||
}
|
||||
|
||||
export module ArtCacheWab {
|
||||
export function getMaxItems() { return 500; }
|
||||
}
|
||||
}
|
|
@ -1,23 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function BazaarInit()
|
||||
{
|
||||
var Bazaar = <any>TDev.RT.Bazaar;
|
||||
if (isSupportedAction(Action.CURRENT_APP_INFO)) {
|
||||
Util.log('wab: boosting CURRENT_APP_INFO');
|
||||
Bazaar.storeidAsync = BazaarWab.storeidAsync;
|
||||
}
|
||||
}
|
||||
|
||||
export module BazaarWab {
|
||||
export function storeidAsync() : Promise {
|
||||
return sendRequestAsync({ action: Action.CURRENT_APP_INFO })
|
||||
.then((response: CurrentAppInfoResponse) => {
|
||||
if (response.status === Status.OK)
|
||||
return <any>response.storeid;
|
||||
else
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,113 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export class WabBluetoothDevice
|
||||
extends BluetoothDevice
|
||||
{
|
||||
private errorHandler: (err:any) => any;
|
||||
|
||||
static isBluetoothError(err:any)
|
||||
{
|
||||
return (typeof err.message === "string" && /HRESULT: 0x/.test(err.message));
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super()
|
||||
// do not put anything here; it will not run
|
||||
}
|
||||
|
||||
public initFrom(j:BluetoothDeviceFriendlyName) {
|
||||
this.errorHandler = (err) => {
|
||||
if (WabBluetoothDevice.isBluetoothError(err)) {
|
||||
this._isConnected = false;
|
||||
return undefined;
|
||||
} else throw err;
|
||||
};
|
||||
this._displayName = j.displayName;
|
||||
this._hostName = j.hostName;
|
||||
this._serviceName = j.serviceName;
|
||||
this._isConnected = false;
|
||||
}
|
||||
|
||||
private mkReq(act:string)
|
||||
{
|
||||
var r:BluetoothConnectRequest = {
|
||||
action: act,
|
||||
hostName: this._hostName,
|
||||
serviceName: this._serviceName,
|
||||
};
|
||||
return r;
|
||||
}
|
||||
|
||||
public connect(r:ResumeCtx)
|
||||
{
|
||||
sendRequestAsync(this.mkReq(Action.BLUETOOTH_CONNECT))
|
||||
.done((response:BluetoothConnectResponse) => {
|
||||
this._isConnected = !!response.connected;
|
||||
r.resume()
|
||||
}, this.errorHandler)
|
||||
}
|
||||
|
||||
public disconnect(r:ResumeCtx)
|
||||
{
|
||||
sendRequestAsync(this.mkReq(Action.BLUETOOTH_DISCONNECT))
|
||||
.done((response:BluetoothConnectResponse) => {
|
||||
this._isConnected = !!response.connected;
|
||||
r.resume()
|
||||
}, this.errorHandler)
|
||||
}
|
||||
|
||||
public readAsync(max_length:number)
|
||||
{
|
||||
if (!this._isConnected) Util.userError(lf("bluetooth device {0}", this.toString()))
|
||||
var req = <BluetoothReadRequest>this.mkReq(Action.BLUETOOTH_READ);
|
||||
req.length = max_length;
|
||||
Util.assert(!!this.errorHandler)
|
||||
return sendRequestAsync(req)
|
||||
.then((response:BluetoothReadResponse) => {
|
||||
this._isConnected = !!response.connected;
|
||||
if (response.connected)
|
||||
return Buffer.fromString(response.data, "base64");
|
||||
else
|
||||
return undefined;
|
||||
}, this.errorHandler)
|
||||
}
|
||||
|
||||
public write_buffer(buffer:Buffer, r:ResumeCtx)
|
||||
{
|
||||
if (!this._isConnected) Util.userError(lf("bluetooth device {0}", this.toString()))
|
||||
var req = <BluetoothWriteRequest>this.mkReq(Action.BLUETOOTH_WRITE);
|
||||
req.data = buffer.to_string("base64");
|
||||
sendRequestAsync(req)
|
||||
.done((response:BluetoothWriteResponse) => {
|
||||
this._isConnected = !!response.connected;
|
||||
r.resume()
|
||||
}, this.errorHandler)
|
||||
}
|
||||
|
||||
static getDevices()
|
||||
{
|
||||
return sendRequestAsync(<BluetoothDevicesRequest>{ action: Action.BLUETOOTH_DEVICES })
|
||||
.then((response: BluetoothDevicesResponse) => {
|
||||
if (response.devices)
|
||||
return response.devices.map(d => {
|
||||
var b = new BluetoothDevice();
|
||||
(<WabBluetoothDevice>b).initFrom(d);
|
||||
return b;
|
||||
});
|
||||
else
|
||||
return undefined;
|
||||
}, (err) => {
|
||||
if (WabBluetoothDevice.isBluetoothError(err)) return undefined;
|
||||
else throw err;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export function BluetoothInit()
|
||||
{
|
||||
if (isSupportedAction(Action.BLUETOOTH_DEVICES)) {
|
||||
Util.log('wab: boosting BLUETOOTH_DEVICES');
|
||||
BluetoothDevice.getDevicesAsync = WabBluetoothDevice.getDevices;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function DeviceMotionInit()
|
||||
{
|
||||
if (isSupportedAction(Action.START_ACCELEROMETER)) {
|
||||
Util.log('wab: boosting START_ACCELEROMETER');
|
||||
DeviceMotion.isSupported = DeviceMotionWab.isSupported;
|
||||
DeviceMotion.isMotionSupported = DeviceMotionWab.isMotionSupported;
|
||||
DeviceMotion.addReadingEvent = DeviceMotionWab.addReadingEvent;
|
||||
DeviceMotion.removeReadingEvent = DeviceMotionWab.removeReadingEvent;
|
||||
}
|
||||
}
|
||||
|
||||
export module DeviceMotionWab
|
||||
{
|
||||
var currId:string;
|
||||
|
||||
export function isSupported() { return true; }
|
||||
export function isMotionSupported() { return true; }
|
||||
|
||||
export function addReadingEvent() {
|
||||
Util.log('wab: starting accelerometer');
|
||||
currId = sendRequest({ action: Action.START_ACCELEROMETER }, (acc:AccelerometerResponse) => {
|
||||
//Util.log('wab: acc ' + acc.x + ', ' + acc.y + ', ' + acc.z);
|
||||
DeviceMotion.setRaw(Vector3.mk(acc.x, acc.y, acc.z), acc.orientation);
|
||||
})
|
||||
}
|
||||
|
||||
export function removeReadingEvent() {
|
||||
Util.log('wab: stopping accelerometer');
|
||||
if (currId) {
|
||||
cancelRequest(currId);
|
||||
currId = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function DeviceOrientationInit()
|
||||
{
|
||||
if (isSupportedAction(Action.START_ORIENTATION)) {
|
||||
Util.log('wab: boosting START_ORIENTATION');
|
||||
DeviceOrientation.isOrientationSupported = DeviceOrientationWab.isHeadingSupported;
|
||||
DeviceOrientation.addOrientationReadingEvent = DeviceOrientationWab.addOrientationReadingEvent;
|
||||
DeviceOrientation.removeOrientationReadingEvent = DeviceOrientationWab.removeOrientationReadingEvent;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.START_COMPASS)) {
|
||||
Util.log('wab: boosting START_COMPASS');
|
||||
DeviceOrientation.isHeadingSupported = DeviceOrientationWab.isHeadingSupported;
|
||||
DeviceOrientation.addHeadingReadingEvent = DeviceOrientationWab.addHeadingReadingEvent;
|
||||
DeviceOrientation.removeHeadingReadingEvent = DeviceOrientationWab.removeHeadingReadingEvent;
|
||||
}
|
||||
}
|
||||
|
||||
export module DeviceOrientationWab
|
||||
{
|
||||
var currOrientationId: string;
|
||||
var currCompassId:string;
|
||||
|
||||
export function isOrientationSupported() { return true; }
|
||||
export function isHeadingSupported() { return true; }
|
||||
|
||||
export function addOrientationReadingEvent() {
|
||||
currOrientationId = sendRequest({ action: Action.START_ORIENTATION }, (r: OrientationResponse) => {
|
||||
DeviceOrientation.setOrientation(r.y, r.p, r.r);
|
||||
})
|
||||
}
|
||||
|
||||
export function addHeadingReadingEvent() {
|
||||
currCompassId = sendRequest({ action: Action.START_COMPASS }, (r:CompassResponse) => {
|
||||
DeviceOrientation.setHeading(r.v);
|
||||
})
|
||||
}
|
||||
|
||||
export function removeOrientationReadingEvent() {
|
||||
if (currOrientationId) {
|
||||
cancelRequest(currOrientationId);
|
||||
currCompassId = "";
|
||||
}
|
||||
}
|
||||
|
||||
export function removeHeadingReadingEvent() {
|
||||
if (currCompassId) {
|
||||
cancelRequest(currCompassId);
|
||||
currCompassId = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function LanguagesInit()
|
||||
{
|
||||
var Languages = <any>TDev.RT.Languages;
|
||||
if (isSupportedAction(Action.DICTATE)) {
|
||||
Util.log('wab: boosting DICTATE');
|
||||
Languages.record_text = LanguagesWab.record_text;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.SPEAK_TEXT)) {
|
||||
Util.log('wab: boosting SPEAK_TEXT');
|
||||
Languages.speak_text = LanguagesWab.speak_text;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.SPEAK_SSML)) {
|
||||
Util.log('wab: boosting SPEAK_SSML');
|
||||
Languages.speak_ssml = LanguagesWab.speak_ssml;
|
||||
}
|
||||
}
|
||||
|
||||
export module LanguagesWab {
|
||||
export function record_text(r: ResumeCtx) {
|
||||
sendRequest({ action: Action.DICTATE },
|
||||
(response: DictateResponse) => {
|
||||
if (response.status === Status.OK)
|
||||
r.resumeVal(response.text);
|
||||
else
|
||||
r.resumeVal('');
|
||||
});
|
||||
}
|
||||
|
||||
export function speak_text(voice_language: string, voice_gender: string, text: string, r: ResumeCtx) {
|
||||
sendRequest(<SpeakTextRequest>{ action: Action.SPEAK_TEXT, language: voice_language, gender: voice_gender, text: text },
|
||||
(response) => r.resume());
|
||||
}
|
||||
|
||||
export function speak_ssml(ssml: XmlObject, r: ResumeCtx) {
|
||||
sendRequest(<SpeakSsmlRequest>{ action: Action.SPEAK_SSML, markup: ssml.toString() },
|
||||
(response) => r.resume());
|
||||
}
|
||||
}
|
||||
}
|
285
libwab/Media.ts
285
libwab/Media.ts
|
@ -1,285 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function MediaInit()
|
||||
{
|
||||
var Media = <any>TDev.RT.Media;
|
||||
if (isSupportedAction(Action.PICK_IMAGE)) {
|
||||
Util.log('wab: boosting PICK_IMAGE');
|
||||
Media.choose_picture = MediaWab.choose_picture;
|
||||
HTML.mkImageInput = HTMLWab.mkImageInput;
|
||||
HTML.mkImageChooser = HTMLWab.mkImageChooser;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.STATUS)) {
|
||||
Util.log('wab: boosting STATUS');
|
||||
HTML.showProgressNotification = HTMLWab.showProgressNotification;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_IMAGE_ALBUMS)) {
|
||||
Util.log('wab: boosting LIST_IMAGE_ALBUMS');
|
||||
Media.pictureAlbumsAsync = MediaWab.pictureAlbumsAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_IMAGES) || isSupportedAction(Action.LIST_IMAGE_ALBUM)) {
|
||||
Util.log('wab: boosting LIST_IMAGES, LIST_IMAGE_ALBUM');
|
||||
Media.picturesAsync = MediaWab.picturesAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.IMAGE)) {
|
||||
Util.log('wab: boosting IMAGE');
|
||||
Media.pictureDataUriAsync = MediaWab.pictureDataUriAsync;
|
||||
Media.pictureUriForMedia = MediaWab.pictureUriForMedia;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_SONGS)) {
|
||||
Util.log('wab: boosting LIST_SONGS');
|
||||
Media.songsAsync = MediaWab.songsAsync;
|
||||
MediaWab.songsAsyncAction = Action.LIST_SONGS;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_SONG_ALBUM)) {
|
||||
Util.log('wab: boosting LIST_SONG_ALBUM');
|
||||
Media.songsAsync = MediaWab.songsAsync;
|
||||
MediaWab.songsAsyncAction = Action.LIST_SONG_ALBUM;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_SONG_ALBUMS)) {
|
||||
Util.log('wab: boosting LIST_SONG_ALBUMS');
|
||||
Media.songAlbumsAsync = MediaWab.songAlbumsAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.SONG_ALBUM)) {
|
||||
Util.log('wab: boosting SONG_ALBUM');
|
||||
Media.initSongAlbumAsync = MediaWab.initSongAlbumAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.SONG_ALBUM_ART)) {
|
||||
Util.log('wab: boosting SONG_ALBUM_ART');
|
||||
Media.loadSongAlbumArtAsync = MediaWab.loadSongAlbumArtAsync;
|
||||
}
|
||||
}
|
||||
|
||||
export module MediaWab {
|
||||
export function choose_picture(r: ResumeCtx) {
|
||||
sendRequestAsync({ action: Action.PICK_IMAGE })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status === Status.OK && response.uri)
|
||||
return Picture.fromUrl(response.uri);
|
||||
else
|
||||
return Promise.as(undefined);
|
||||
}).done(pic => r.resumeVal(pic));
|
||||
}
|
||||
|
||||
export function pictureUriForMedia(uri: string, media: string) {
|
||||
if (!/^wab:/.test(uri))
|
||||
return uri;
|
||||
return uri += "&media=" + encodeURIComponent(media);
|
||||
}
|
||||
|
||||
export function pictureDataUriAsync(uri: string): Promise { // string
|
||||
if (!/^wab:/.test(uri))
|
||||
return Promise.as(undefined);
|
||||
|
||||
Util.log('wab: picture load');
|
||||
return sendRequestAsync(<UriRequest>{ action: Action.IMAGE, uri: uri })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status == Status.OK) {
|
||||
Util.log('wab: picture load success: ' + uri);
|
||||
return response.uri;
|
||||
} else {
|
||||
Util.log('wab: picture load failed: ' + response.status);
|
||||
return undefined;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function picturesAsync(uri: string): Promise {
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
var pics: string[] = [];
|
||||
sendRequest(<UriRequest>{ action: Action.LIST_IMAGES, uri: uri },
|
||||
(response: ListImagesResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
pics.push(response.uri);
|
||||
} else {
|
||||
onSuccess(Pictures.mk(pics));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function pictureAlbumsAsync(uri : string): Promise {
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
var albums: PictureAlbum[] = [];
|
||||
sendRequest({ action: Action.LIST_IMAGE_ALBUMS, uri: uri },
|
||||
(response: ListImageAlbumsResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
albums.push(PictureAlbum.mk(response.name, response.uri));
|
||||
} else {
|
||||
onSuccess(PictureAlbums.mk(albums));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export var songsAsyncAction : string = Action.LIST_SONGS;
|
||||
export function songsAsync(album: string): Promise {
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
Util.log("wab: listing songs: " + album);
|
||||
var songs: Song[] = [];
|
||||
sendRequest({ action: songsAsyncAction, name: album },
|
||||
(response: ListSongsResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
var song = Song.mk(response.uri, undefined, response.title);
|
||||
song.init(response.title, response.album, response.artist, response.duration || -1, "", 0, response.track || -1);
|
||||
songs.push(song);
|
||||
} else {
|
||||
Util.log('wab: found songs: ' + songs.length);
|
||||
onSuccess(Songs.mk(songs));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function songAlbumsAsync(): Promise {
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
Util.log("wab: listing song albums");
|
||||
var albums: SongAlbum[] = [];
|
||||
sendRequest({ action: Action.LIST_SONG_ALBUMS },
|
||||
(response: ListSongAlbumsResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
var album = SongAlbum.mk(response.name, response.artist);
|
||||
albums.push(album);
|
||||
} else {
|
||||
onSuccess(SongAlbums.mk(albums));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function initSongAlbumAsync(album : SongAlbum): Promise { // string
|
||||
Util.log('wab: init song album:' + album.name());
|
||||
var genre: string = '';
|
||||
var duration: number = 0;
|
||||
return sendRequestAsync({ action: Action.SONG_ALBUM, name: album.name() })
|
||||
.then((response: SongAlbumResponse) => {
|
||||
if (response.status == Status.OK && response.thumbnail) {
|
||||
genre = response.genre;
|
||||
duration = response.duration;
|
||||
return Picture.fromUrl(response.thumbnail, true);
|
||||
}
|
||||
else return Promise.as(undefined);
|
||||
}).then(thumbnail => album.init(genre, duration, thumbnail));
|
||||
}
|
||||
|
||||
export function loadSongAlbumArtAsync(albumName: string): Promise { // string
|
||||
Util.log('wab: load song album art:' + albumName);
|
||||
return sendRequestAsync({ action: Action.SONG_ALBUM_ART, name: albumName })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status == Status.OK && response.uri)
|
||||
return Picture.fromUrl(response.uri, true);
|
||||
else return Promise.as(undefined);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export module HTMLWab {
|
||||
export function showProgressNotification(msgText: string, fadeOut: boolean = true, delay: number = 1000, duration: number = 2000) {
|
||||
Util.log('wab: status: ' + msgText + ', ' + duration);
|
||||
sendRequestAsync(<StatusRequest>{ action: Action.STATUS, progress: !fadeOut, message: msgText, duration: duration })
|
||||
.done();
|
||||
}
|
||||
|
||||
export function mkAudioInput(allowEmpty: boolean, maxMb: number): HTML.IInputElement {
|
||||
var dataUri: string = null;
|
||||
var statusDiv = div('', div('validation-error', 'no sound selected'));
|
||||
return <HTML.IInputElement>{
|
||||
element: div("",
|
||||
HTML.mkButton(lf("record sound"), () => {
|
||||
sendRequestAsync({ action: Action.RECORD_MICROPHONE })
|
||||
.done((response: UriResponse) => {
|
||||
if (response.status === Status.OK) {
|
||||
dataUri = response.uri;
|
||||
var previewPlaying = false;
|
||||
var btn = HTML.mkRoundButton("svg:play,white", lf("play"), Ticks.noEvent, () => {
|
||||
Util.log('audio input: preview play');
|
||||
if (!previewPlaying) {
|
||||
previewPlaying = true;
|
||||
Sound.fromArtUrl(dataUri)
|
||||
.then(snd => snd.playAsync())
|
||||
.done(() => {
|
||||
previewPlaying = false;
|
||||
});
|
||||
}
|
||||
});
|
||||
statusDiv.setChildren([btn]);
|
||||
}
|
||||
else {
|
||||
dataUri = null;
|
||||
statusDiv.setChildren([div('validation-error', lf("no sound selected"))]);
|
||||
}
|
||||
})
|
||||
}),
|
||||
statusDiv
|
||||
),
|
||||
validate: function (): string {
|
||||
if (!dataUri)
|
||||
return allowEmpty ? null : lf("Oops, you need to select a sound...");
|
||||
if (dataUri.length > maxMb * 1000000)
|
||||
return lf("Sorry, the sound is too big. The sound must be less than {0} Mb...", maxMb);
|
||||
if (!/^data:audio\/wav/.test(dataUri))
|
||||
return lf("Sorry, you can only upload WAV sounds...");
|
||||
return null;
|
||||
},
|
||||
readAsync: function (): Promise { return Promise.as(dataUri); }
|
||||
};
|
||||
}
|
||||
|
||||
export var mkImageInput = (allowEmpty: boolean, maxMb: number): HTML.IInputElement =>
|
||||
{
|
||||
var dataUri: string = null;
|
||||
var statusDiv = div('', div('validation-error', lf("no picture selected")));
|
||||
return <HTML.IInputElement>{
|
||||
element: div("",
|
||||
HTML.mkButton(lf("choose picture"), () => {
|
||||
sendRequestAsync({ action: Action.PICK_IMAGE })
|
||||
.done((response: UriResponse) => {
|
||||
if (response.status === Status.OK) {
|
||||
dataUri = response.uri;
|
||||
var img = HTML.mkImg(dataUri);
|
||||
img.className = 'upload-preview';
|
||||
statusDiv.setChildren([div('upload-preview', img)]);
|
||||
}
|
||||
else {
|
||||
dataUri = null;
|
||||
statusDiv.setChildren([div('validation-error', lf("no picture selected"))]);
|
||||
}
|
||||
})
|
||||
}),
|
||||
statusDiv
|
||||
),
|
||||
validate: function (): string {
|
||||
if (!dataUri)
|
||||
return allowEmpty ? null : lf("Oops, you need to select a picture...");
|
||||
if (dataUri.length > maxMb * 1000000)
|
||||
return lf("Sorry, the picture is too big. The picture must be less than {0} Mb...", maxMb);
|
||||
if (!/^data:image\/(jpeg|png)/.test(dataUri))
|
||||
return lf("Sorry, you can only upload JPEG and PNG pictures...");
|
||||
return null;
|
||||
},
|
||||
readAsync: function (): Promise { return Promise.as(dataUri); }
|
||||
};
|
||||
}
|
||||
|
||||
export function mkImageChooser(onchanged:(dataUri:string)=>void):HTMLElement
|
||||
{
|
||||
return HTML.mkButton(lf("choose picture"), () => {
|
||||
sendRequestAsync({ action: Action.PICK_IMAGE })
|
||||
.done((response: UriResponse) => {
|
||||
if (response.status === Status.OK) {
|
||||
onchanged(response.uri);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
157
libwab/Player.ts
157
libwab/Player.ts
|
@ -1,157 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function PlayerInit()
|
||||
{
|
||||
var Player = <any>TDev.RT.Player;
|
||||
if (isSupportedAction(Action.PLAYER_COMMAND)) {
|
||||
Util.log('wab: boosting PLAYER_COMMAND');
|
||||
Player.stop = PlayerWab.stop;
|
||||
Player.next = PlayerWab.next;
|
||||
Player.previous = PlayerWab.previous;
|
||||
Player.resume = PlayerWab.resume;
|
||||
Player.pause = PlayerWab.pause;
|
||||
Player.playOne = PlayerWab.playOne;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.PLAYER_STATE)) {
|
||||
Util.log('wab: boosting PLAYER_STATE');
|
||||
Player.is_repeating = PlayerWab.is_repeating;
|
||||
Player.set_repeating = PlayerWab.set_repeating;
|
||||
Player.is_shuffled = PlayerWab.is_shuffled;
|
||||
Player.set_shuffled = PlayerWab.set_shuffled;
|
||||
Player.is_muted = PlayerWab.is_muted;
|
||||
Player.is_stopped = PlayerWab.is_stopped;
|
||||
Player.is_paused = PlayerWab.is_paused;
|
||||
Player.is_playing = PlayerWab.is_playing;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.ACTIVE_SONG)) {
|
||||
Util.log('wab: boosting ACTIVE_SONG');
|
||||
Player.active_song = PlayerWab.active_song;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.START_ACTIVE_SONG_CHANGED)) {
|
||||
Util.log('wab: boosting START_ACTIVE_SONG_CHANGED');
|
||||
Player.addActiveSongChangedEvent = PlayerWab.addActiveSongChangedEvent;
|
||||
Player.removeActiveSongChangedEvent = PlayerWab.removeActiveSongChangedEvent;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.START_PLAYER_STATE_CHANGED)) {
|
||||
Util.log('wab: boosting START_PLAYER_STATE_CHANGED');
|
||||
Player.addPlayerStateChangedEvent = PlayerWab.addPlayerStateChangedEvent;
|
||||
Player.removePlayerStateChangedEvent = PlayerWab.removePlayerStateChangedEvent;
|
||||
}
|
||||
}
|
||||
|
||||
export module PlayerWab {
|
||||
function playerCommand(command: string, uri: string) {
|
||||
Util.log('wab: player ' + command + ' ' + uri);
|
||||
sendRequestAsync(<PlayerCommandRequest>{
|
||||
action: Action.PLAYER_COMMAND,
|
||||
command: command,
|
||||
uri: uri
|
||||
})
|
||||
.done();
|
||||
}
|
||||
export function stop() { playerCommand('stop', null); }
|
||||
export function next() { playerCommand('next', null); }
|
||||
export function previous() { playerCommand('previous', null); }
|
||||
export function resume() { playerCommand('resume', null); }
|
||||
export function pause() { playerCommand('pause', null); }
|
||||
export function playOne(song: Song) {
|
||||
Util.log('wab: play ' + song.url());
|
||||
HTML.showProgressNotification(lf("playing song..."));
|
||||
playerCommand('play', song.url());
|
||||
Util.log('wab: play done');
|
||||
}
|
||||
export function active_song(r: ResumeCtx) {
|
||||
sendRequest({ action: Action.ACTIVE_SONG },
|
||||
(response: ActiveSongResponse) => {
|
||||
if (response.status == Status.OK) {
|
||||
if (!response.uri)
|
||||
r.resumeVal(undefined);
|
||||
else {
|
||||
var song = Song.mk(response.uri, undefined, response.title);
|
||||
song.init(response.title, response.album, response.artist, response.duration || -1, "", 0, response.track || -1);
|
||||
r.resumeVal(song);
|
||||
}
|
||||
} else
|
||||
r.resumeVal(undefined);
|
||||
});
|
||||
}
|
||||
export function is_muted(r: ResumeCtx) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE },
|
||||
(response: PlayerStateResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.muted : false);
|
||||
});
|
||||
}
|
||||
export function is_shuffled(r: ResumeCtx) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE },
|
||||
(response: PlayerStateResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.shuffle : false);
|
||||
});
|
||||
}
|
||||
export function set_shuffled(value : boolean, r: ResumeCtx) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE, shuffle : value },
|
||||
(response: PlayerStateResponse) => r.resume());
|
||||
}
|
||||
export function is_repeating(r: ResumeCtx) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE },
|
||||
(response: PlayerStateResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.repeat : false);
|
||||
});
|
||||
}
|
||||
export function set_repeating(value: boolean, r: ResumeCtx) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE, repeat: value },
|
||||
(response: PlayerStateResponse) => r.resume());
|
||||
}
|
||||
export function is_stopped(r: ResumeCtx) {
|
||||
isPlayerState(r, 'stopped');
|
||||
}
|
||||
export function is_paused(r: ResumeCtx) {
|
||||
isPlayerState(r, 'paused');
|
||||
}
|
||||
export function is_playing(r: ResumeCtx) {
|
||||
isPlayerState(r, 'playing');
|
||||
}
|
||||
function isPlayerState(r : ResumeCtx, state : string) {
|
||||
sendRequest(<PlayerStateRequest>{ action: Action.PLAYER_STATE },
|
||||
(response: PlayerStateResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.state == state : false);
|
||||
});
|
||||
}
|
||||
|
||||
var activeSongChangedId:string;
|
||||
export function addActiveSongChangedEvent(rt: Runtime) {
|
||||
Util.log('wab: starting active song changed');
|
||||
activeSongChangedId = sendRequest({ action: Action.START_ACTIVE_SONG_CHANGED },
|
||||
(response) => {
|
||||
if (response.status == Status.OK)
|
||||
rt.queueEvent("active song changed", null, []);
|
||||
})
|
||||
}
|
||||
export function removeActiveSongChangedEvent() {
|
||||
if (activeSongChangedId) {
|
||||
Util.log('wab: stopping active song changed');
|
||||
cancelRequest(activeSongChangedId);
|
||||
activeSongChangedId = "";
|
||||
}
|
||||
}
|
||||
var playerStateChangedId :string;
|
||||
export function addPlayerStateChangedEvent(rt: Runtime) {
|
||||
Util.log('wab: starting player state changed');
|
||||
playerStateChangedId = sendRequest({ action: Action.START_PLAYER_STATE_CHANGED },
|
||||
(response) => {
|
||||
if (response.status == Status.OK)
|
||||
rt.queueEvent("player state changed", null, []);
|
||||
})
|
||||
}
|
||||
export function removePlayerStateChangedEvent() {
|
||||
if (playerStateChangedId) {
|
||||
Util.log('wab: stopping player state changed');
|
||||
cancelRequest(playerStateChangedId);
|
||||
playerStateChangedId = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function RadioInit()
|
||||
{
|
||||
var Radio = <any>TDev.RT.Radio;
|
||||
if (isSupportedAction(Action.RADIO_COMMAND)) {
|
||||
Util.log('wab: boosting RADIO_COMMAND');
|
||||
Radio.is_playing = RadioWab.is_playing;
|
||||
Radio.start = RadioWab.start;
|
||||
Radio.stop = RadioWab.stop;
|
||||
Radio.signal_strength = RadioWab.signal_strength;
|
||||
Radio.frequency = RadioWab.frequency;
|
||||
Radio.set_frequency = RadioWab.set_frequency;
|
||||
}
|
||||
}
|
||||
|
||||
export module RadioWab {
|
||||
export function start(r: ResumeCtx) {
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND, command:'play' },
|
||||
() => r.resume());
|
||||
}
|
||||
|
||||
export function stop(r: ResumeCtx) {
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND, command:'stop' },
|
||||
() => r.resume());
|
||||
}
|
||||
export function is_playing(r: ResumeCtx) // : boolean
|
||||
{
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND },
|
||||
(response: RadioCommandResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.isPlaying : false);
|
||||
});
|
||||
}
|
||||
export function signal_strength(r: ResumeCtx) // : number
|
||||
{
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND },
|
||||
(response: RadioCommandResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.signal : 0.0);
|
||||
});
|
||||
}
|
||||
export function frequency(r: ResumeCtx) //: number
|
||||
{
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND },
|
||||
(response: RadioCommandResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.frequency : 0.0);
|
||||
});
|
||||
}
|
||||
export function set_frequency(frequency: number, r: ResumeCtx): void {
|
||||
sendRequest(<RadioCommandRequest>{ action: Action.RADIO_COMMAND, frequency : frequency },
|
||||
() => r.resume());
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function ScreenshotManagerInit()
|
||||
{
|
||||
if (isSupportedAction(Action.SCREENSHOT)) {
|
||||
Util.log('wab: boosting screenshot');
|
||||
TDev.RT.ScreenshotManager.toScreenshotURLAsync = ScreenshotManagerWab.toScreenshotURLAsync;
|
||||
}
|
||||
}
|
||||
|
||||
export module ScreenshotManagerWab {
|
||||
export function toScreenshotURLAsync(rt: RuntimeHost, background : boolean): Promise {
|
||||
return sendRequestAsync({ action: Action.SCREENSHOT })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status === Status.OK)
|
||||
return response.uri;
|
||||
else
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function SensesInit()
|
||||
{
|
||||
if (isSupportedAction(Action.POWER_INFORMATION)) {
|
||||
Util.log('wab: boosting POWER_INFORMATION');
|
||||
(<any>Senses).battery_level = SensesWab.battery_level;
|
||||
(<any>Phone).power_source = PhoneWab.power_source;
|
||||
}
|
||||
if (isSupportedAction(Action.RECORD_MICROPHONE)) {
|
||||
Util.log('wab: boosting RECORD_MICROPHONE');
|
||||
(<any>Senses).record_microphone = SensesWab.record_microphone;
|
||||
HTML.mkAudioInput = HTMLWab.mkAudioInput;
|
||||
}
|
||||
if (isSupportedAction(Action.TAKE_PHOTO)) {
|
||||
Util.log('wab: boosting TAKE_PHOTO');
|
||||
(<any>Senses).take_camera_picture = SensesWab.take_camera_picture;
|
||||
}
|
||||
}
|
||||
|
||||
export module PhoneWab {
|
||||
export function power_source(r: ResumeCtx) {
|
||||
sendRequest({ action: Action.POWER_INFORMATION },
|
||||
(response: PowerInformationResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.source : "");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export module SensesWab {
|
||||
export function take_camera_picture(r: ResumeCtx) {
|
||||
sendRequestAsync({ action: Action.TAKE_PHOTO })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status === Status.OK)
|
||||
return Picture.fromUrl(response.uri);
|
||||
else
|
||||
return Promise.as(undefined);
|
||||
}).done(pic => r.resumeVal(pic));
|
||||
}
|
||||
export function battery_level(r: ResumeCtx) {
|
||||
sendRequest({ action: Action.POWER_INFORMATION },
|
||||
(response: PowerInformationResponse) => {
|
||||
r.resumeVal(response.status == Status.OK ? response.level : undefined);
|
||||
});
|
||||
}
|
||||
export function record_microphone(r: ResumeCtx) {
|
||||
Util.log("wab: record microphone");
|
||||
sendRequestAsync({ action: Action.RECORD_MICROPHONE })
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status === Status.OK) {
|
||||
Util.log("wab: record microphone : success");
|
||||
return Sound.fromArtUrl(response.uri)
|
||||
}
|
||||
else {
|
||||
Util.log("wab: record microphone : failed");
|
||||
return Promise.as(undefined);
|
||||
}
|
||||
}).done(snd => r.resumeVal(snd));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,42 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function ShareManagerInit()
|
||||
{
|
||||
if (isSupportedAction(Action.SHARE)) {
|
||||
Util.log('wab: boosting SHARE');
|
||||
ShareManager.shareSocialAsync = ShareManagerWab.shareSocialAsync;
|
||||
ShareManager.sharePictureAsync = ShareManagerWab.sharePictureAsync;
|
||||
// This is no good, it doesn't show the list of choices
|
||||
// ShareManager.shareButtons = ShareManagerWab.shareButtons;
|
||||
}
|
||||
if (isSupportedAction(Action.COPY_TO_CLIPBOARD)) {
|
||||
Util.log('wab: boosting COPY_TO_CLIPBOARD');
|
||||
ShareManager.copyToClipboardAsync = ShareManagerWab.copyToClipboardAsync;
|
||||
}
|
||||
}
|
||||
|
||||
export module ShareManagerWab {
|
||||
function nullToUndefined(x) {
|
||||
return x === null ? undefined : x;
|
||||
}
|
||||
export function copyToClipboardAsync(text: string): Promise {
|
||||
return sendRequestAsync(<CopyToClipboardRequest>{ action: Action.COPY_TO_CLIPBOARD, text: text });
|
||||
}
|
||||
export function shareSocialAsync(network: string, text: string, uri : string) : Promise {
|
||||
return sendRequestAsync(<ShareRequest>{ action: Action.SHARE, text: nullToUndefined(text), provider: network, uri: nullToUndefined(uri) });
|
||||
}
|
||||
export function shareButtons(m:ModalDialog, link: Link, options:ShareManager.ShareOptions)
|
||||
{
|
||||
return [
|
||||
HTML.mkButton(lf("share"), () => {
|
||||
shareSocialAsync("", link.name(), link.address()).done()
|
||||
if (!options.noDismiss) m.dismiss();
|
||||
})
|
||||
]
|
||||
}
|
||||
export function sharePictureAsync(pic: Picture, network: string, text: string) : Promise {
|
||||
var dataUri = pic.getDataUri();
|
||||
return sendRequestAsync(<ShareRequest>{ action: Action.SHARE, photoUri: nullToUndefined(dataUri), text: nullToUndefined(text), provider: network });
|
||||
}
|
||||
}
|
||||
}
|
146
libwab/Social.ts
146
libwab/Social.ts
|
@ -1,146 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function SocialInit()
|
||||
{
|
||||
if (isSupportedAction(Action.SEND_SMS)) {
|
||||
Util.log('wab: boosting SEND_SMS');
|
||||
Social.sendSmsAsync = SocialWab.sendSmsAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.PICK_CONTACT)) {
|
||||
Util.log('wab: boosting PICK_CONTACT');
|
||||
Social.chooseContactAsync = SocialWab.chooseContactAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_CONTACTS)) {
|
||||
Util.log('wab: boosting LIST_CONTACTS');
|
||||
Social.searchContactsAsync = SocialWab.searchContactsAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.LIST_APPOINTMENTS)) {
|
||||
Util.log('wab: boosting LIST_APPOINTMENTS');
|
||||
Social.searchAppointmentsAsync = SocialWab.searchAppointmentsAsync;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.SAVE_TO_GALLERY)) {
|
||||
Util.log('wab: boosting SAVE_TO_GALLERY');
|
||||
Picture.prototype.save_to_library = function (r: ResumeCtx) {
|
||||
var pic: Picture = this;
|
||||
pic.initAsync().done(() => {
|
||||
var url = pic.getDataUri(0.95);
|
||||
sendRequestAsync(<UriRequest>{ action: Action.SAVE_TO_GALLERY, uri: url })
|
||||
.then((response: SaveToGalleryResponse) => {
|
||||
if (response.status === Status.OK) {
|
||||
r.resumeVal(response.name);
|
||||
}
|
||||
else
|
||||
r.resumeVal(undefined);
|
||||
}).done();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.VIBRATE)) {
|
||||
Util.log('wab: boosting VIBRATE');
|
||||
Phone.vibrateCore = function (seconds: number) {
|
||||
var ms = Math.min(5, Math.max(0.02, seconds)) * 1000.0;
|
||||
sendRequestAsync(<VibrateRequest>{ action: Action.VIBRATE, millis: ms })
|
||||
.done(() => { }, (e) => { });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export module SocialWab {
|
||||
export function sendSmsAsync(to: string, body: string) {
|
||||
return sendRequestAsync(<SendSmsRequest>{ action: Action.SEND_SMS, to: to, body: body });
|
||||
}
|
||||
|
||||
export function chooseContactAsync() : Promise { // Contact
|
||||
return sendRequestAsync({ action: Action.PICK_CONTACT })
|
||||
.then((response: ContactResponse) => {
|
||||
if (response.status === Status.OK)
|
||||
return mkContact(response);
|
||||
else return undefined;
|
||||
});
|
||||
}
|
||||
|
||||
export function searchContactsAsync(query: string): Promise { // Collection<Contact>
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
Util.log('wab: search contacts');
|
||||
var aps: Contact[] = [];
|
||||
sendRequest(<SearchContactsRequest>{ action: Action.LIST_CONTACTS, query: query },
|
||||
(response: ListContactsResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
aps.push(mkContact(<ContactResponse>response));
|
||||
} else {
|
||||
Util.log('wab: search contacts: ' + aps.length);
|
||||
onSuccess(Collection.mkAny(Contact, aps));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
export function searchAppointmentsAsync(start: DateTime, end: DateTime): Promise { // Collection<Appointment>
|
||||
return new Promise((onSuccess, onError, onProgress) => {
|
||||
Util.log('wab: search appointments between ' + start + ' and ' + end);
|
||||
var aps: Appointment[] = [];
|
||||
sendRequest(<SearchAppointmentsRequest>{ action: Action.LIST_APPOINTMENTS, start:start.milliseconds_since_epoch(), end:end.milliseconds_since_epoch() },
|
||||
(response: ListAppointmentsResponse) => {
|
||||
if (response.status == Status.OK && !isLastResponse(response)) {
|
||||
aps.push(mkAppointment(response));
|
||||
} else {
|
||||
Util.log('wab: found ' + aps.length + ' appointments');
|
||||
onSuccess(Collection.mkAny(Appointment, aps));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function mkAppointmentContact(r: AppointmentContact): Contact {
|
||||
if (r)
|
||||
return Contact.mk(r.nameDisplay, r.email);
|
||||
else
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function mkAppointmentContacts(r: AppointmentContact[]): Collection<Contact> {
|
||||
if (r)
|
||||
return Collection.mkAny(Contact, r.map(ac => Contact.mk(ac.nameDisplay, ac.email)));
|
||||
else
|
||||
return Collection.mkAny(Contact);
|
||||
}
|
||||
|
||||
function mkAppointment(r: ListAppointmentsResponse): Appointment {
|
||||
return Appointment.mk(r.subject, r.details, r.location, DateTime.mkMs(r.start), DateTime.mkMs(r.end),
|
||||
r.source, mkAppointmentContact(r.organizer), mkAppointmentContacts(r.attendees),
|
||||
r.isPrivate, r.isAllDay, r.onlineStatus);
|
||||
}
|
||||
|
||||
function mkContact(response: ContactResponse): Contact {
|
||||
var c = new Contact();
|
||||
c.set_nick_name(response.name); // legacy
|
||||
c.set_email(response.email); // legacy
|
||||
c.set_phone_number(response.phone); // legacy
|
||||
|
||||
c.set_first_name(response.nameGiven);
|
||||
c.set_middle_name(response.nameMiddle);
|
||||
c.set_last_name(response.nameFamily);
|
||||
|
||||
c.set_home_phone(response.phoneHome);
|
||||
c.set_work_phone(response.phoneWork);
|
||||
c.set_mobile_phone(response.phoneMobile);
|
||||
c.set_phone_number(response.phoneOther);
|
||||
|
||||
c.set_work_email(response.emailWork);
|
||||
c.set_personal_email(response.emailHome);
|
||||
c.set_email(response.emailOther);
|
||||
|
||||
c.set_home_address(response.addressHome || response.addressOther);
|
||||
c.set_work_address(response.addressWork);
|
||||
|
||||
c.setPicture_url(response.photoUri);
|
||||
c.set_source(response.source || "Phone");
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,51 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function SoundInit()
|
||||
{
|
||||
if (isSupportedAction(Action.PLAY_SOUND)) {
|
||||
Util.log('wab: boosting PLAY_SOUND');
|
||||
Sound.prototype.playAsync = function () {
|
||||
var sound: Sound = <Sound>this;
|
||||
return sound.toWabRequestAsync()
|
||||
.then(r => {
|
||||
if (/^data:audio\/wav;base64,/.test(r.uri)) {
|
||||
var soundid = <string>(<any>sound).soundid;
|
||||
return sendRequestAsync(<PlaySoundRequest>{
|
||||
action: Action.PLAY_SOUND,
|
||||
soundid: soundid,
|
||||
uri: soundid ? "" : r.uri,
|
||||
pan: r.pan,
|
||||
pitch: r.pitch,
|
||||
volume: r.volume
|
||||
}).then((e: PlaySoundResponse) => {
|
||||
if (e.cachemiss) {
|
||||
Util.log('wab: play sound: cache-miss');
|
||||
(<any>sound).soundid = undefined;
|
||||
return sendRequestAsync(<PlaySoundRequest>{
|
||||
action: Action.PLAY_SOUND,
|
||||
uri: r.uri,
|
||||
pan: r.pan,
|
||||
pitch: r.pitch,
|
||||
volume: r.volume
|
||||
}).then((cm: PlaySoundResponse) => {
|
||||
if (cm.soundid) {
|
||||
Util.log('wab: play sound: cached after miss ' + cm.soundid);
|
||||
(<any>sound).soundid = cm.soundid;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (e.soundid) {
|
||||
Util.log('wab: play sound: cached ' + e.soundid);
|
||||
(<any>sound).soundid = e.soundid;
|
||||
}
|
||||
return Promise.as(undefined);
|
||||
});
|
||||
}
|
||||
else {
|
||||
return sound.playCoreAsync();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function TagsInit()
|
||||
{
|
||||
if (isSupportedAction(Action.START_SEND_NFC_MESSAGE)) {
|
||||
Util.log('wab: boosting START_SEND_NFC_MESSAGE');
|
||||
Tags.sendNFC = TagsWab.sendNFC;
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.START_RECEIVE_NFC_MESSAGE)) {
|
||||
Util.log('wab: boosting START_RECEIVE_NFC_MESSAGE');
|
||||
Tags.receiveNFC = TagsWab.receiveNFC;
|
||||
}
|
||||
}
|
||||
|
||||
export module TagsWab {
|
||||
export function sendNFC(writeTag: boolean, type: string, value : string, sent : (id : number) => void, transferred : () => void) { // number
|
||||
Util.log("wab: sending nfc tag");
|
||||
var mid: number = 0;
|
||||
sendRequest(<StartSendNfcMessageRequest>{ action: Action.START_SEND_NFC_MESSAGE, value: value, type: type, writeTag:writeTag },
|
||||
(response: SendNfcMessageResponse) => {
|
||||
Util.log("wab: send nfc tag status: " + response.status);
|
||||
if (response.status == Status.OK) {
|
||||
if (response.transferred) {
|
||||
Util.log("wab: send nfc transferred: " + response.id);
|
||||
transferred();
|
||||
}
|
||||
else {
|
||||
mid = response.id;
|
||||
Util.log("wab: send nfc id: " + mid);
|
||||
sent(mid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function receiveNFC(type: string, sent : (id : number) => void, received : (string) => void) { // number
|
||||
Util.log("wab: receiving nfc tag");
|
||||
var mid: number = 0;
|
||||
sendRequest(<StartReceiveNfcMessageRequest>{ action: Action.START_RECEIVE_NFC_MESSAGE, type: type },
|
||||
(response: ReceiveNfcMessageResponse) => {
|
||||
Util.log("wab: receive nfc tag status: " + response.status);
|
||||
if (response.status == Status.OK) {
|
||||
if (response.received) {
|
||||
Util.log("wab: receive nfc received: " + response.id);
|
||||
received(response.value);
|
||||
}
|
||||
else {
|
||||
mid = response.id;
|
||||
Util.log("wab: receive nfc id: " + mid);
|
||||
sent(mid);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function TilesInit()
|
||||
{
|
||||
if (isSupportedAction(Action.UPDATE_TILE)) {
|
||||
Util.log('wab: boosting UPDATE_TILE');
|
||||
Tiles.updateTileAsync = TilesWab.updateTileAsync;
|
||||
}
|
||||
}
|
||||
|
||||
export module TilesWab {
|
||||
export function updateTileAsync(fragment : string, data : ITileData) : Promise {
|
||||
Util.log('wab: update tile');
|
||||
return sendRequestAsync(<UpdateTileRequest>{ action: Action.UPDATE_TILE,
|
||||
uri: fragment,
|
||||
background: data.background,
|
||||
content:data.content,
|
||||
title:data.title,
|
||||
counter: data.counter,
|
||||
icon: data.icon,
|
||||
pictures: data.pictures,
|
||||
template: data.template,
|
||||
pin:data.pin })
|
||||
.then((r : Response) => {
|
||||
Util.log('wab: update tile: ' + r.status);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
100
libwab/Web.ts
100
libwab/Web.ts
|
@ -1,100 +0,0 @@
|
|||
///<reference path='refs.ts'/>
|
||||
module TDev.RT.Wab {
|
||||
export function WebInit()
|
||||
{
|
||||
var w = <any>Web;
|
||||
if (isSupportedAction(Action.NETWORK_INFORMATION)) {
|
||||
Util.log('wab: boosting NETWORK_INFORMATION');
|
||||
w.connection_type = WebWab.connection_type;
|
||||
w.connection_name = WebWab.connection_name;
|
||||
}
|
||||
if (isSupportedAction(Action.BROWSE)) {
|
||||
Util.log('wab: boosting BROWSE');
|
||||
w.browseAsync = WebWab.browseAsync;
|
||||
}
|
||||
|
||||
|
||||
if (Browser.isWP8app) {
|
||||
// no CORS enforced
|
||||
w.proxy = function (url: string) { return url; }
|
||||
w.open_connection_settings = WebWp8.open_connection_settings;
|
||||
|
||||
} else if (isSupportedAction(Action.PROXY)) {
|
||||
Util.log('wab: boosting PROXY');
|
||||
WebRequest.prototype.sendAsync = function () {
|
||||
var request: WebRequest = this;
|
||||
if (!Browser.isWP8app) return request.sendCoreAsync();
|
||||
var json: any = request.serializeForProxy();
|
||||
json.action = Action.PROXY;
|
||||
Time.log(this.toString() + " [WP8 proxy]");
|
||||
return sendRequestAsync(json).then(response => {
|
||||
Util.log(this.toString() + " [WP8 proxy response]");
|
||||
var r = WebResponse.mkProxy(request, response)
|
||||
return r;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (isSupportedAction(Action.OAUTH_AUTHENTICATION)) {
|
||||
Util.log('wab: boosting OAUTH_AUTHENTICATION');
|
||||
w.oauth_v2_dance_async = WebWab.oauth_v2_dance_async;
|
||||
}
|
||||
}
|
||||
|
||||
export module WebWp8 {
|
||||
// wp8 only
|
||||
export function open_connection_settings(page: string, r : ResumeCtx): void {
|
||||
switch (page.toLowerCase()) {
|
||||
case 'airplanemode':
|
||||
case 'bluetooth':
|
||||
case 'cellular':
|
||||
case 'wifi':
|
||||
WebWab.browseAsync('ms-settings-' + page + ':').done(() => r.resume());
|
||||
break;
|
||||
default:
|
||||
r.resume(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export module WebWab {
|
||||
export function oauth_v2_dance_async(url: string, redirect_uri: string, userid: string, stateArg: string) {
|
||||
return sendRequestAsync(<OAuthAuthenticationRequest>{
|
||||
action: Action.OAUTH_AUTHENTICATION,
|
||||
uri: url,
|
||||
redirectUri: redirect_uri,
|
||||
state: stateArg
|
||||
})
|
||||
.then((response: UriResponse) => {
|
||||
if (response.status == Status.OK && response.uri && response.uri.indexOf(stateArg) > -1)
|
||||
return OAuthResponse.parse(response.uri);
|
||||
else
|
||||
return OAuthResponse.mkError('access_denied', '', '');
|
||||
});
|
||||
}
|
||||
|
||||
export function connection_type(r: ResumeCtx) { //: string
|
||||
sendRequest({ action: Action.NETWORK_INFORMATION },
|
||||
(response: NetworkInformationResponse) => {
|
||||
if (response.status == Status.OK)
|
||||
r.resumeVal(response.connectionType || 'none');
|
||||
else
|
||||
r.resumeVal('unknown');
|
||||
});
|
||||
}
|
||||
export function connection_name(r : ResumeCtx) { // : string
|
||||
sendRequest({ action: Action.NETWORK_INFORMATION },
|
||||
(response: NetworkInformationResponse) => {
|
||||
if (response.status == Status.OK)
|
||||
r.resumeVal(response.connectionName || "");
|
||||
else
|
||||
r.resumeVal('');
|
||||
});
|
||||
|
||||
}
|
||||
export function browseAsync(url: string): Promise {
|
||||
Util.log("wab: browse " + url);
|
||||
return sendRequestAsync(<UriRequest>{ action: Action.BROWSE, uri: url });
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
///<reference path='../build/rt.d.ts'/>
|
||||
///<reference path='../rt/typings.d.ts'/>
|
||||
//<reference path='../build/browser.d.ts'/>
|
||||
///<reference path='runtime.ts'/>
|
||||
///<reference path='Social.ts'/>
|
||||
///<reference path='DeviceMotion.ts'/>
|
||||
///<reference path='DeviceOrientation.ts'/>
|
||||
///<reference path='Web.ts'/>
|
||||
///<reference path='Player.ts'/>
|
||||
///<reference path='Senses.ts'/>
|
||||
///<reference path='Languages.ts'/>
|
||||
///<reference path='ShareManager.ts'/>
|
||||
///<reference path='ScreenshotManager.ts'/>
|
||||
///<reference path='Media.ts'/>
|
||||
///<reference path='Sound.ts'/>
|
||||
///<reference path='Tags.ts'/>
|
||||
///<reference path='Tiles.ts' />
|
||||
///<reference path='ArtCache.ts'/>
|
||||
///<reference path='BluetoothDevice.ts'/>
|
||||
///<reference path='Radio.ts'/>
|
||||
///<reference path='AdManager.ts'/>
|
||||
///<reference path='Bazaar.ts' />
|
1185
libwab/runtime.ts
1185
libwab/runtime.ts
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -244,8 +244,6 @@ module TDev.RT {
|
|||
this.copySpecificImpls("Node")
|
||||
else if (Browser.inCordova)
|
||||
this.copySpecificImpls("Cordova")
|
||||
else if (Browser.webAppBooster)
|
||||
this.copySpecificImpls("Wab")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1125,8 +1125,6 @@ module TDev.HTML {
|
|||
|
||||
export function fixWp8Links(...elts:HTMLElement[])
|
||||
{
|
||||
// if (!Browser.isWP8app) return;
|
||||
|
||||
elts.forEach((elt) => {
|
||||
var ch = elt.getElementsByTagName("A");
|
||||
for (var i = 0; i < ch.length; ++i) (() => {
|
||||
|
|
2
rt/rt.ts
2
rt/rt.ts
|
@ -1777,7 +1777,7 @@ module TDev
|
|||
static handleUserError(err: any) {
|
||||
var rt = Runtime.theRuntime
|
||||
if (rt && rt.state != RtState.Stopped && !rt.handlingException) {
|
||||
if (err.isUserError || err.wabStatus) {
|
||||
if (err.isUserError) {
|
||||
rt.handleException(err, rt.current);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -189,8 +189,6 @@ module TDev {
|
|||
rootClass += " rootClass";
|
||||
if (Browser.brokenColumns)
|
||||
rootClass += " brokenColumns";
|
||||
if (Browser.isWP8app)
|
||||
rootClass += " wp8app";
|
||||
elt("root").className = rootClass;
|
||||
|
||||
var rootStyle = elt("root").style;
|
||||
|
|
|
@ -839,11 +839,6 @@ module TDev {
|
|||
if (/^bitvm/.test(ctx))
|
||||
r.exceptionConstructor = "BITVM " + r.exceptionConstructor;
|
||||
|
||||
if (err.wabCrashInfo) {
|
||||
r.stackTrace = err.wabCrashInfo + "\nJavaScript:\n" + r.stackTrace;
|
||||
r.exceptionConstructor = "WAB " + r.exceptionConstructor;
|
||||
}
|
||||
|
||||
if (r.exceptionMessage && /\[object /.test(r.exceptionMessage)) {
|
||||
var msg = r.exceptionMessage;
|
||||
var errorInfo = Util.getErrorInfo(err);
|
||||
|
|
|
@ -87,7 +87,6 @@ module TDev {
|
|||
TDev.RT.ApiManager.bingMapsKey = 'AsnQk63tYReqttLHcIL1RUsc_0h0BwCOib6j0Zvk8QjWs4FQjM9JRM9wEKescphX';
|
||||
TDev.RT.ArtCache.enabled = false; // disable art caching
|
||||
TDev.RT.ApiManager.getKeyAsync = function (url: string): Promise { return Promise.as(undefined); }
|
||||
TDev.RT.AdManager.initialize = (el) => el.style.display = 'none'; // do not show adds
|
||||
//TDev.RT.Web.create_request = function (url: string): TDev.RT.WebRequest { return TDev.RT.WebRequest.mk(url, undefined);};
|
||||
//TDev.RT.Web.proxy = function (url: string): string { return url; }
|
||||
TDev.RT.BingServices.searchAsync = function (
|
||||
|
@ -279,10 +278,7 @@ module TDev {
|
|||
|
||||
function initAsync() : Promise
|
||||
{
|
||||
if (RT.Wab)
|
||||
return RT.Wab.initAsync().then(() => init2Async());
|
||||
else
|
||||
return init2Async();
|
||||
return init2Async();
|
||||
}
|
||||
|
||||
function init2Async() : Promise
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
///<reference path='../rt/typings.d.ts'/>
|
||||
///<reference path='../build/rt.d.ts'/>
|
||||
///<reference path='../build/storage.d.ts'/>
|
||||
///<reference path='../build/libwab.d.ts'/>
|
||||
///<reference path='../build/libnode.d.ts'/>
|
||||
///<reference path='../build/libcordova.d.ts'/>
|
||||
///<reference path='main.ts'/>
|
||||
|
|
|
@ -32,7 +32,6 @@ module TDev {
|
|||
public wallVisible = false;
|
||||
|
||||
public copyrightHeight = 26;
|
||||
public showCopyright = !Browser.isWP8app;
|
||||
private keyState: any = null;
|
||||
public localProxyAsync : (path: string, data: any) => Promise = undefined;
|
||||
|
||||
|
@ -43,7 +42,7 @@ module TDev {
|
|||
|
||||
public fullWallHeight() {
|
||||
this.computeCopyrightHeight()
|
||||
return SizeMgr.windowHeight - (this.showCopyright ? this.copyrightHeight : 0);
|
||||
return SizeMgr.windowHeight - this.copyrightHeight;
|
||||
}
|
||||
|
||||
private computeCopyrightHeight()
|
||||
|
@ -54,7 +53,7 @@ module TDev {
|
|||
public userWallHeight() {
|
||||
if (!this.currentRt.getCurrentPage().chromeVisible) return this.fullWallHeight();
|
||||
this.computeCopyrightHeight()
|
||||
return SizeMgr.windowHeight - 4 * SizeMgr.topFontSize - (this.showCopyright ? this.copyrightHeight : 0);
|
||||
return SizeMgr.windowHeight - 4 * SizeMgr.topFontSize - this.copyrightHeight;
|
||||
}
|
||||
|
||||
public fullWallWidth() {
|
||||
|
@ -430,9 +429,9 @@ module TDev {
|
|||
var wall = elt("wallOverlay");
|
||||
this.titleContainer.setChildren([this.scriptTitleDiv, this.titleDiv, this.subtitleDiv]);
|
||||
this.topBtnRow = divId("wallBtns", "wallBtnRow",
|
||||
this.backBtnDiv, this.titleContainer, this.cloudContainer,
|
||||
this.additionalButtons()
|
||||
);
|
||||
this.backBtnDiv, this.titleContainer, this.cloudContainer,
|
||||
this.additionalButtons()
|
||||
);
|
||||
this.fullScreenBtnRow = divId("wallFullScreenBtns", "", this.additionalFullScreenButtons());
|
||||
this.bottomBtnsDiv = divId("wallBottomBtns", "bottomButtons");
|
||||
var logoDiv: HTMLElement;
|
||||
|
@ -453,18 +452,12 @@ module TDev {
|
|||
legalDiv,
|
||||
logoDiv
|
||||
]);
|
||||
if (this.currentRt.compiled.showAd) {
|
||||
wall.appendChildren([this.adContainer]);
|
||||
TDev.RT.AdManager.initialize(this.adContainer);
|
||||
}
|
||||
if (this.showCopyright) {
|
||||
this.computeCopyrightHeight()
|
||||
this.wallContainer.style.bottom = this.copyrightHeight + "px";
|
||||
var copyright = this.copyrightElement();
|
||||
if (copyright) {
|
||||
// copyright.style.height = this.copyrightHeight + "px";
|
||||
wall.appendChild(copyright);
|
||||
}
|
||||
this.computeCopyrightHeight()
|
||||
this.wallContainer.style.bottom = this.copyrightHeight + "px";
|
||||
var copyright = this.copyrightElement();
|
||||
if (copyright) {
|
||||
// copyright.style.height = this.copyrightHeight + "px";
|
||||
wall.appendChild(copyright);
|
||||
}
|
||||
this.applyWallStyle();
|
||||
wall.style.display = "block";
|
||||
|
|
|
@ -369,7 +369,7 @@ export function genStubs()
|
|||
processFile(path.join(libPath, fn));
|
||||
})
|
||||
|
||||
var srcPaths = ["lib", "rt", "storage", "ast", "editor", "libwab", "libnode"]
|
||||
var srcPaths = ["lib", "rt", "storage", "ast", "editor", "libnode"]
|
||||
srcPaths.forEach(pth => {
|
||||
fs.readdirSync(pth).forEach((fn) => {
|
||||
fileCnt++;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
///<reference path='storage/refs.ts'/>
|
||||
///<reference path='lib/refs.ts'/>
|
||||
///<reference path='rt/refs.ts'/>
|
||||
///<reference path='libwab/refs.ts'/>
|
||||
///<reference path='libcordova/refs.ts'/>
|
||||
///<reference path='libnode/refs.ts'/>
|
||||
///<reference path='runner/refs.ts'/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче