From 9b38ee837ad23415736175d8f42a3689430120de Mon Sep 17 00:00:00 2001 From: Peli de Halleux Date: Thu, 10 Dec 2015 17:53:29 -0800 Subject: [PATCH] removing webappbooster support --- Jakefile | 10 - README.md | 1 - ast/api.ts | 7 +- ast/json.ts | 1 - ast/jsonInterfaces.ts | 1 - browser/browser.ts | 20 +- editor/default.ts | 5 +- editor/editor.ts | 21 +- editor/refs.ts | 1 - editor/scriptList.ts | 9 +- lib/AdManager.ts | 9 - lib/App.ts | 2 +- lib/Sound.ts | 12 - lib/refs.ts | 1 - libwab/AdManager.ts | 24 - libwab/ArtCache.ts | 11 - libwab/Bazaar.ts | 23 - libwab/BluetoothDevice.ts | 113 ---- libwab/DeviceMotion.ts | 37 -- libwab/DeviceOrientation.ts | 54 -- libwab/Languages.ts | 43 -- libwab/Media.ts | 285 --------- libwab/Player.ts | 157 ----- libwab/Radio.ts | 53 -- libwab/ScreenshotManager.ts | 22 - libwab/Senses.ts | 62 -- libwab/ShareManager.ts | 42 -- libwab/Social.ts | 146 ----- libwab/Sound.ts | 51 -- libwab/Tags.ts | 57 -- libwab/Tiles.ts | 29 - libwab/Web.ts | 100 --- libwab/refs.ts | 22 - libwab/runtime.ts | 1185 ----------------------------------- rt/RTValue.ts | 2 - rt/html.ts | 2 - rt/rt.ts | 2 +- rt/sizemgr.ts | 2 - rt/ticker.ts | 5 - runner/main.ts | 6 +- runner/refs.ts | 1 - storage/wall.ts | 29 +- tools/genmeta.ts | 2 +- vsrefs.ts | 1 - 44 files changed, 26 insertions(+), 2642 deletions(-) delete mode 100644 lib/AdManager.ts delete mode 100644 libwab/AdManager.ts delete mode 100644 libwab/ArtCache.ts delete mode 100644 libwab/Bazaar.ts delete mode 100644 libwab/BluetoothDevice.ts delete mode 100644 libwab/DeviceMotion.ts delete mode 100644 libwab/DeviceOrientation.ts delete mode 100644 libwab/Languages.ts delete mode 100644 libwab/Media.ts delete mode 100644 libwab/Player.ts delete mode 100644 libwab/Radio.ts delete mode 100644 libwab/ScreenshotManager.ts delete mode 100644 libwab/Senses.ts delete mode 100644 libwab/ShareManager.ts delete mode 100644 libwab/Social.ts delete mode 100644 libwab/Sound.ts delete mode 100644 libwab/Tags.ts delete mode 100644 libwab/Tiles.ts delete mode 100644 libwab/Web.ts delete mode 100644 libwab/refs.ts delete mode 100644 libwab/runtime.ts diff --git a/Jakefile b/Jakefile index 4655b8d4..27f1ee14 100644 --- a/Jakefile +++ b/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", diff --git a/README.md b/README.md index d7481c39..c2c363d6 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/ast/api.ts b/ast/api.ts index c47771f6..0c899d4d 100644 --- a/ast/api.ts +++ b/ast/api.ts @@ -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 ((TDev.RT).Wab) - _cap |= AST.App.fromCapabilityList((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]) } diff --git a/ast/json.ts b/ast/json.ts index f5c493fb..0f4620f3 100644 --- a/ast/json.ts +++ b/ast/json.ts @@ -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()), diff --git a/ast/jsonInterfaces.ts b/ast/jsonInterfaces.ts index 6035498c..4f87b4d9 100644 --- a/ast/jsonInterfaces.ts +++ b/ast/jsonInterfaces.ts @@ -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[]; diff --git a/browser/browser.ts b/browser/browser.ts index b462ea86..213925a0 100644 --- a/browser/browser.ts +++ b/browser/browser.ts @@ -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("

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.

", "a regular Internet Explorer window"); diff --git a/editor/default.ts b/editor/default.ts index 89eb437b..811f2846 100644 --- a/editor/default.ts +++ b/editor/default.ts @@ -211,10 +211,7 @@ module TDev if ((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 { diff --git a/editor/editor.ts b/editor/editor.ts index a9e27d6f..39977af2 100644 --- a/editor/editor.ts +++ b/editor/editor.ts @@ -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 ((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; diff --git a/editor/refs.ts b/editor/refs.ts index 5823d140..c4df4fcb 100644 --- a/editor/refs.ts +++ b/editor/refs.ts @@ -3,7 +3,6 @@ /// /// /// -/// /// /// /// diff --git a/editor/scriptList.ts b/editor/scriptList.ts index 84feaedd..5c51cf02 100644 --- a/editor/scriptList.ts +++ b/editor/scriptList.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)) { diff --git a/lib/AdManager.ts b/lib/AdManager.ts deleted file mode 100644 index f43a1299..00000000 --- a/lib/AdManager.ts +++ /dev/null @@ -1,9 +0,0 @@ -/// -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!')]); - } - } -} diff --git a/lib/App.ts b/lib/App.ts index 6b50d3a8..374a335d 100644 --- a/lib/App.ts +++ b/lib/App.ts @@ -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"; diff --git a/lib/Sound.ts b/lib/Sound.ts index e5b412fa..825922ad 100644 --- a/lib/Sound.ts +++ b/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); diff --git a/lib/refs.ts b/lib/refs.ts index 82845b88..63212a72 100644 --- a/lib/refs.ts +++ b/lib/refs.ts @@ -89,7 +89,6 @@ /// /// /// -/// /// /// /// diff --git a/libwab/AdManager.ts b/libwab/AdManager.ts deleted file mode 100644 index 94f893c3..00000000 --- a/libwab/AdManager.ts +++ /dev/null @@ -1,24 +0,0 @@ -/// -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) => { }); - } - } -} \ No newline at end of file diff --git a/libwab/ArtCache.ts b/libwab/ArtCache.ts deleted file mode 100644 index 469baff0..00000000 --- a/libwab/ArtCache.ts +++ /dev/null @@ -1,11 +0,0 @@ -/// -module TDev.RT.Wab { - export function ArtCacheInit() - { - ArtCache.getMaxItems = ArtCacheWab.getMaxItems; - } - - export module ArtCacheWab { - export function getMaxItems() { return 500; } - } -} diff --git a/libwab/Bazaar.ts b/libwab/Bazaar.ts deleted file mode 100644 index a3499d45..00000000 --- a/libwab/Bazaar.ts +++ /dev/null @@ -1,23 +0,0 @@ -/// -module TDev.RT.Wab { - export function BazaarInit() - { - var Bazaar = 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 response.storeid; - else - return undefined; - }); - } - } -} diff --git a/libwab/BluetoothDevice.ts b/libwab/BluetoothDevice.ts deleted file mode 100644 index 82f9f0fe..00000000 --- a/libwab/BluetoothDevice.ts +++ /dev/null @@ -1,113 +0,0 @@ -/// -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 = 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 = 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({ action: Action.BLUETOOTH_DEVICES }) - .then((response: BluetoothDevicesResponse) => { - if (response.devices) - return response.devices.map(d => { - var b = new BluetoothDevice(); - (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; - } - } -} diff --git a/libwab/DeviceMotion.ts b/libwab/DeviceMotion.ts deleted file mode 100644 index e39e7474..00000000 --- a/libwab/DeviceMotion.ts +++ /dev/null @@ -1,37 +0,0 @@ -/// -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 = ""; - } - } - } -} diff --git a/libwab/DeviceOrientation.ts b/libwab/DeviceOrientation.ts deleted file mode 100644 index df04a627..00000000 --- a/libwab/DeviceOrientation.ts +++ /dev/null @@ -1,54 +0,0 @@ -/// -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 = ""; - } - } - } -} diff --git a/libwab/Languages.ts b/libwab/Languages.ts deleted file mode 100644 index 4677dda8..00000000 --- a/libwab/Languages.ts +++ /dev/null @@ -1,43 +0,0 @@ -/// -module TDev.RT.Wab { - export function LanguagesInit() - { - var Languages = 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({ action: Action.SPEAK_TEXT, language: voice_language, gender: voice_gender, text: text }, - (response) => r.resume()); - } - - export function speak_ssml(ssml: XmlObject, r: ResumeCtx) { - sendRequest({ action: Action.SPEAK_SSML, markup: ssml.toString() }, - (response) => r.resume()); - } - } -} diff --git a/libwab/Media.ts b/libwab/Media.ts deleted file mode 100644 index 0a6a09f7..00000000 --- a/libwab/Media.ts +++ /dev/null @@ -1,285 +0,0 @@ -/// -module TDev.RT.Wab { - export function MediaInit() - { - var Media = 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({ 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({ 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({ 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 { - 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 { - 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); - } - }) - }); - } - } -} diff --git a/libwab/Player.ts b/libwab/Player.ts deleted file mode 100644 index ba9f4fd1..00000000 --- a/libwab/Player.ts +++ /dev/null @@ -1,157 +0,0 @@ -/// -module TDev.RT.Wab { - export function PlayerInit() - { - var Player = 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({ - 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({ action: Action.PLAYER_STATE }, - (response: PlayerStateResponse) => { - r.resumeVal(response.status == Status.OK ? response.muted : false); - }); - } - export function is_shuffled(r: ResumeCtx) { - sendRequest({ action: Action.PLAYER_STATE }, - (response: PlayerStateResponse) => { - r.resumeVal(response.status == Status.OK ? response.shuffle : false); - }); - } - export function set_shuffled(value : boolean, r: ResumeCtx) { - sendRequest({ action: Action.PLAYER_STATE, shuffle : value }, - (response: PlayerStateResponse) => r.resume()); - } - export function is_repeating(r: ResumeCtx) { - sendRequest({ action: Action.PLAYER_STATE }, - (response: PlayerStateResponse) => { - r.resumeVal(response.status == Status.OK ? response.repeat : false); - }); - } - export function set_repeating(value: boolean, r: ResumeCtx) { - sendRequest({ 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({ 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 = ""; - } - } - } -} diff --git a/libwab/Radio.ts b/libwab/Radio.ts deleted file mode 100644 index c2ec487d..00000000 --- a/libwab/Radio.ts +++ /dev/null @@ -1,53 +0,0 @@ -/// -module TDev.RT.Wab { - export function RadioInit() - { - var Radio = 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({ action: Action.RADIO_COMMAND, command:'play' }, - () => r.resume()); - } - - export function stop(r: ResumeCtx) { - sendRequest({ action: Action.RADIO_COMMAND, command:'stop' }, - () => r.resume()); - } - export function is_playing(r: ResumeCtx) // : boolean - { - sendRequest({ action: Action.RADIO_COMMAND }, - (response: RadioCommandResponse) => { - r.resumeVal(response.status == Status.OK ? response.isPlaying : false); - }); - } - export function signal_strength(r: ResumeCtx) // : number - { - sendRequest({ action: Action.RADIO_COMMAND }, - (response: RadioCommandResponse) => { - r.resumeVal(response.status == Status.OK ? response.signal : 0.0); - }); - } - export function frequency(r: ResumeCtx) //: number - { - sendRequest({ 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({ action: Action.RADIO_COMMAND, frequency : frequency }, - () => r.resume()); - } - } -} diff --git a/libwab/ScreenshotManager.ts b/libwab/ScreenshotManager.ts deleted file mode 100644 index e001143c..00000000 --- a/libwab/ScreenshotManager.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// -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; - }); - } - } -} diff --git a/libwab/Senses.ts b/libwab/Senses.ts deleted file mode 100644 index 19af6e37..00000000 --- a/libwab/Senses.ts +++ /dev/null @@ -1,62 +0,0 @@ -/// -module TDev.RT.Wab { - export function SensesInit() - { - if (isSupportedAction(Action.POWER_INFORMATION)) { - Util.log('wab: boosting POWER_INFORMATION'); - (Senses).battery_level = SensesWab.battery_level; - (Phone).power_source = PhoneWab.power_source; - } - if (isSupportedAction(Action.RECORD_MICROPHONE)) { - Util.log('wab: boosting RECORD_MICROPHONE'); - (Senses).record_microphone = SensesWab.record_microphone; - HTML.mkAudioInput = HTMLWab.mkAudioInput; - } - if (isSupportedAction(Action.TAKE_PHOTO)) { - Util.log('wab: boosting TAKE_PHOTO'); - (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)); - } - - } -} diff --git a/libwab/ShareManager.ts b/libwab/ShareManager.ts deleted file mode 100644 index 16684e96..00000000 --- a/libwab/ShareManager.ts +++ /dev/null @@ -1,42 +0,0 @@ -/// -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({ action: Action.COPY_TO_CLIPBOARD, text: text }); - } - export function shareSocialAsync(network: string, text: string, uri : string) : Promise { - return sendRequestAsync({ 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({ action: Action.SHARE, photoUri: nullToUndefined(dataUri), text: nullToUndefined(text), provider: network }); - } - } -} diff --git a/libwab/Social.ts b/libwab/Social.ts deleted file mode 100644 index ce803be6..00000000 --- a/libwab/Social.ts +++ /dev/null @@ -1,146 +0,0 @@ -/// -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({ 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({ action: Action.VIBRATE, millis: ms }) - .done(() => { }, (e) => { }); - } - } - } - - export module SocialWab { - export function sendSmsAsync(to: string, body: string) { - return sendRequestAsync({ 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 - return new Promise((onSuccess, onError, onProgress) => { - Util.log('wab: search contacts'); - var aps: Contact[] = []; - sendRequest({ action: Action.LIST_CONTACTS, query: query }, - (response: ListContactsResponse) => { - if (response.status == Status.OK && !isLastResponse(response)) { - aps.push(mkContact(response)); - } else { - Util.log('wab: search contacts: ' + aps.length); - onSuccess(Collection.mkAny(Contact, aps)); - } - }); - }); - } - - export function searchAppointmentsAsync(start: DateTime, end: DateTime): Promise { // Collection - return new Promise((onSuccess, onError, onProgress) => { - Util.log('wab: search appointments between ' + start + ' and ' + end); - var aps: Appointment[] = []; - sendRequest({ 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 { - 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; - } - } -} diff --git a/libwab/Sound.ts b/libwab/Sound.ts deleted file mode 100644 index 14f93d4d..00000000 --- a/libwab/Sound.ts +++ /dev/null @@ -1,51 +0,0 @@ -/// -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 = this; - return sound.toWabRequestAsync() - .then(r => { - if (/^data:audio\/wav;base64,/.test(r.uri)) { - var soundid = (sound).soundid; - return sendRequestAsync({ - 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'); - (sound).soundid = undefined; - return sendRequestAsync({ - 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); - (sound).soundid = cm.soundid; - } - }); - } - if (e.soundid) { - Util.log('wab: play sound: cached ' + e.soundid); - (sound).soundid = e.soundid; - } - return Promise.as(undefined); - }); - } - else { - return sound.playCoreAsync(); - } - }); - } - } - } -} diff --git a/libwab/Tags.ts b/libwab/Tags.ts deleted file mode 100644 index a770597e..00000000 --- a/libwab/Tags.ts +++ /dev/null @@ -1,57 +0,0 @@ -/// -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({ 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({ 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); - } - } - }); - } - } -} diff --git a/libwab/Tiles.ts b/libwab/Tiles.ts deleted file mode 100644 index c5cde3d0..00000000 --- a/libwab/Tiles.ts +++ /dev/null @@ -1,29 +0,0 @@ -/// -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({ 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); - }); - } - } -} diff --git a/libwab/Web.ts b/libwab/Web.ts deleted file mode 100644 index c2c2ce1d..00000000 --- a/libwab/Web.ts +++ /dev/null @@ -1,100 +0,0 @@ -/// -module TDev.RT.Wab { - export function WebInit() - { - var w = 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({ - 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({ action: Action.BROWSE, uri: url }); - } - } -} diff --git a/libwab/refs.ts b/libwab/refs.ts deleted file mode 100644 index 8e147937..00000000 --- a/libwab/refs.ts +++ /dev/null @@ -1,22 +0,0 @@ -/// -/// -// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// diff --git a/libwab/runtime.ts b/libwab/runtime.ts deleted file mode 100644 index 0fe7aaa9..00000000 --- a/libwab/runtime.ts +++ /dev/null @@ -1,1185 +0,0 @@ -/// - -module TDev.RT.Wab { - var URI = "ws://localhost:8042"; - - export enum Status { - OK = 0, - ERR_PERMISSION_DENIED = -1, - ERR_WEBSOCK_NOT_AVAILABLE = -2, - ERR_WEBSOCK_ACCESS_DENIED = -3, - ERR_WEBSOCK_NOT_CONNECTED = -4, - ERR_AUTHENTICATION_REQUIRED = -5, - ERR_CANCELLED = -6, - ERR_MALFORMED_REQUEST= -7, - ERR_NOT_AVAILABLE = -8, - ERR_NOT_AVAILABLE_WP8 = -43, - ERR_INTERNAL_ERROR= -500, - } - - export module Action { - export var REQUEST_AUTHENTICATION = "REQUEST_AUTHENTICATION"; - export var AUTHENTICATE = "AUTHENTICATE"; - export var REQUEST_PERMISSIONS = "REQUEST_PERMISSIONS"; - export var PICK_CONTACT = "PICK_CONTACT"; - export var START_GYRO = "START_GYRO"; - export var STOP_GYRO = "STOP_GYRO"; - export var START_ACCELEROMETER = "START_ACCELEROMETER"; - export var STOP_ACCELEROMETER = "STOP_ACCELEROMETER"; - export var START_COMPASS = "START_COMPASS"; // new - export var STOP_COMPASS = "STOP_COMPASS"; // new - export var START_ORIENTATION = "START_ORIENTATION"; // new - export var STOP_ORIENTATION = "STOP_ORIENTATION"; // new - export var LOG = "LOG"; - export var PROXY = "PROXY"; - export var NOTIFICATION = "NOTIFICATION"; - export var DB_GET = "DB_GET"; - export var DB_SET = "DB_SET"; - export var DB_KEYS = "DB_KEYS"; - export var DB_DELETE = "DB_DELETE"; - export var VIBRATE = "VIBRATE"; - export var LIST_SONGS = "LIST_SONGS"; - // player commands - export var PLAYER_COMMAND = "PLAYER_COMMAND"; // new - export var PLAYER_STATE = "PLAYER_STATE"; // new - export var ACTIVE_SONG = "ACTIVE_SONG"; // new - export var START_ACTIVE_SONG_CHANGED = "START_ACTIVE_SONG_CHANGED"; // new - export var STOP_ACTIVE_SONG_CHANGED = "STOP_ACTIVE_SONG_CHANGED"; // new - export var START_PLAYER_STATE_CHANGED = "START_PLAYER_STATE_CHANGED"; // new - export var STOP_PLAYER_STATE_CHANGED = "STOP_PLAYER_STATE_CHANGED"; // new - // picture commands - export var SAVE_TO_GALLERY = "SAVE_TO_GALLERY"; - export var LIST_IMAGES = "LIST_IMAGES"; - export var PICK_IMAGE = "PICK_IMAGE"; // new, Request -> UriResponse - export var TAKE_PHOTO = "TAKE_PHOTO"; - export var RECORD_MICROPHONE = "RECORD_MICROPHONE"; // new, Request -> UriResponse - export var SHARE = "SHARE"; // new - export var PLAY_SOUND = "PLAY_SOUND"; // new - export var BROWSE = "BROWSE"; // new - export var DICTATE = "DICTATE"; // speech to text, new - export var OAUTH_AUTHENTICATION = "OAUTH_AUTHENTICATION"; // new - export var NETWORK_INFORMATION = "NETWORK_INFORMATION"; // new - export var LOCK_ORIENTATION = "LOCK_ORIENTATION"; // new - export var POWER_INFORMATION = "POWER_INFORMATION"; // new - export var REVIEW_CURRENT_APP = "REVIEW_CURRENT_APP"; // new - export var LIST_IMAGE_ALBUMS = "LIST_IMAGE_ALBUMS"; // new - export var LIST_IMAGE_ALBUM = "LIST_IMAGE_ALBUM"; // new, UriRequest -> ListAlbumsResponse[] - export var IMAGE = "IMAGE"; // new, UriRequest -> UriResponse - export var LIST_SONG_ALBUMS = "LIST_SONG_ALBUMS"; // new - export var LIST_SONG_ALBUM = "LIST_SONG_ALBUM"; // new - export var SONG_ALBUM = "SONG_ALBUM"; // new - export var SONG_ALBUM_ART = "SONG_ALBUM_ART"; // new - export var LIST_CONTACTS = "LIST_CONTACTS"; // new - export var LIST_APPOINTMENTS = "LIST_APPOINTMENTS"; // new - export var START_SEND_NFC_MESSAGE = "START_SEND_NFC_MESSAGE"; // new - export var STOP_SEND_NFC_MESSAGE = "STOP_SEND_NFC_MESSAGE"; // new - export var START_RECEIVE_NFC_MESSAGE = "START_RECEIVE_NFC_MESSAGE"; // new - export var STOP_RECEIVE_NFC_MESSAGE = "STOP_RECEIVE_NFC_MESSAGE"; // new - export var UPDATE_TILE = "UPDATE_TILE"; // new, UpdateTileRequest - export var SPEAK_TEXT = "SPEAK_TEXT"; // new - export var SPEAK_SSML = "SPEAK_SSML"; // new - export var STATUS = "STATUS"; // new - export var CURRENT_HASH = "CURRENT_HASH"; // new, wp8 specific - export var CHECK_FOR_REFRESH = "CHECK_FOR_REFRESH"; // new, wp8 specific - export var SWITCH_CHANNEL = "SWITCH_CHANNEL"; // new, wp8 specific - export var SEND_SMS = "SEND_SMS"; // new - export var COPY_TO_CLIPBOARD = "COPY_TO_CLIPBOARD"; // new - - export var BLUETOOTH_DEVICES = "BLUETOOTH_DEVICES"; // new - export var BLUETOOTH_CONNECT = "BLUETOOTH_CONNECT"; // new - export var BLUETOOTH_READ = "BLUETOOTH_READ"; // new - export var BLUETOOTH_WRITE = "BLUETOOTH_WRITE"; // new - export var BLUETOOTH_DISCONNECT = "BLUETOOTH_DISCONNECT"; // new - - export var BLUETOOTHLE_DEVICES = "BLUETOOTHLE_DEVICES"; // new - export var BLUETOOTHLE_READ = "BLUETOOTHLE_READ"; // new - export var BLUETOOTHLE_WRITE = "BLUETOOTHLE_WRITE"; // new - - export var SCREENSHOT = "SCREENSHOT"; // new - export var RADIO_COMMAND = "RADIO_COMMAND"; // new - - export var SHOW_AD = "SHOW_AD"; // only supported in exported apps - export var CURRENT_APP_INFO = "CURRENT_APP_INFO"; // only supported in exported apps - } - - export module Permission { - export var READ_CONTACTS = "READ_CONTACTS"; - export var READ_CALENDAR = "READ_CALENDAR"; - export var GYRO = "GYRO"; - export var ACCELEROMETER = "ACCELEROMETER"; - export var AUDIO = "AUDIO"; - export var GALLERY = "GALLERY"; - export var CAMERA = "CAMERA"; - export var VIBRATE = "VIBRATE"; - export var RECORD_AUDIO = "RECORD_AUDIO"; - export var BLUETOOTH = "BLUETOOTH"; - } - - export interface Request { - id?: number; // not really optional; just omitted at request construction time, but always defined by _sendRequest - noResponse?: boolean; - action: string; // one of Action.SOMETHING - } - - export interface Response { - id?: number; - status: number; // Status - } - - export interface CurrentAppInfoResponse extends Response { - storeid : string; - } - - export interface SendSmsRequest extends Request { - to?: string; - body?: string; - } - - export interface ListResponse extends Response { - removeCallbackId?: string; - lastForId?: string; - } - - export function isLastResponse(r:ListResponse) - { - return !!r.lastForId || !!r.removeCallbackId - } - - export interface RequestPermissionsRequest extends Request { - permissions: string[]; // array of Permission.SOMETHING - } - - export interface CurrentHashRequest extends Request - { - hash:string; - isMainScreen:boolean; - } - - export interface OsSettings - { - osVersion:string; - themeBackgroundColor?:string; - themeForegroundColor?:string; - themeSubtleColor?:string; - themeAccentColor?:string; - themeChromeColor?:string; - } - - export interface StatusRequest extends Request { - message: string; - progress: boolean; // show moving dots? - kind?: string; - duration?: number; - } - - export interface RadioCommandRequest extends Request { - command?: string; // play, stop - frequency?: number; // - } - - export interface RadioCommandResponse extends Response { - isPlaying: boolean; - frequency: number; - signal: number; // signalstrengh normalized - } - - export interface RequestPermissionsResponse extends Response - { - version:string; - supportedActions:string[]; // Action.SOMETHING - - osVersion?:string; - wp8AppVersion?:number; - osSettings?:OsSettings; - } - - export interface SpeakTextRequest extends Request { - language: string; - gender: string; - text: string; - } - - export interface SpeakSsmlRequest extends Request { - markup: string; - } - - export interface StartSendNfcMessageRequest extends Request { - value: string; - type: string; // url, text, vcard, picture, mime type - writeTag:boolean; - } - - export interface SendNfcMessageResponse extends Response { - id: number; - transferred?: boolean; // true when message transfered - } - - export interface StopNfcMessageRequest extends Request { - id: number; - } - - export interface StartReceiveNfcMessageRequest extends Request { - type?: string; // url, text, vcard, picture, mime type - } - - export interface ReceiveNfcMessageResponse extends Response { - value: string; - type: string; - id: number; - received?: boolean; // true when message transfered - } - - export interface PowerInformationResponse extends Response { - level: number; // between 0 (discharged) and 1 (charged) - source: string; // battery, external - } - - export interface CompassResponse extends Response { - v: number; // value - a: number; // accuracy - } - - export interface AccelerometerResponse extends Response { - x: number; - y: number; - z: number; - orientation: number; // 0, 90, -90 - } - - export interface GyroResponse extends Response { - x: number; - y: number; - z: number; - orientation: number; - } - - export interface OrientationResponse extends Response { - p: number; // pitch - r: number; // roll - y: number; // yaw - orientation: number; - } - - export interface UpdateTileRequest extends UriRequest { - counter?: number; - content?: string; - title?: string; - background?: string; - pin?: boolean; - pictures?: string[]; - icon?: string; - template?: string; - } - - export interface NetworkInformationResponse extends Response { - connectionName?: string; - connectionType?: string; // unknown, none, ethernet, wifi, mobile - } - - export interface ListImageAlbumsResponse extends ListResponse { - name: string; - uri: string; - } - - export interface ListImagesResponse extends ListResponse { - uri: string; - } - - export interface SongAlbumResponse extends Response { - name: string; - genre?: string; - artist?: string; - duration?: number; - thumbnail?: string; - } - - export interface ListSongAlbumsResponse extends ListResponse { - name: string; - artist: string; - } - - export interface ListSongsResponse extends ListResponse { - uri: string; - data: string; - title: string; - artist: string; - album: string; - duration?: number; - track?: number; - } - - export interface ActiveSongResponse extends Response { - uri: string; - data: string; - title: string; - artist: string; - album: string; - duration?: number; - track?: number; - } - - export interface PlaySoundRequest extends UriRequest { - soundid?: string; - pan?: number; - pitch?: number; - volume?: number; - } - - export interface PlaySoundResponse extends Response { - soundid?: string; - cachemiss?: boolean; - } - - export interface ShareRequest extends Request { - provider?: string; // optional preferred social network - text?: string; - uri?: string; - photoUri?: string; - } - - export interface UriRequest extends Request { - uri: string; - } - - export interface UriResponse extends Response { - uri: string; - } - - export interface DictateRequest extends Request { - title?:string; - caption?: string; - } - - export interface DictateResponse extends Response { - text: string; - } - - export interface SaveToGalleryResponse extends Response { - name: string; - } - - export interface PlayerCommandRequest extends Request { - command: string; // 'play', 'stop', 'resume', 'pause', 'next', 'previous' - uri?: string; // required for play - } - - export interface PlayerStateRequest extends Request { - shuffle?: boolean; - repeat?: boolean;// a single song - } - - export interface PlayerStateResponse extends Response { - state: string; // 'playing', 'paused', 'stopped' - shuffle: boolean; - muted: boolean; - repeat: boolean; - } - - export interface SearchAppointmentsRequest extends Request { - start: number; // DateTime - end: number; // DateTime - } - - export interface AppointmentContact { - nameDisplay: string; - email: string; - } - - export interface CopyToClipboardRequest extends Request { - text: string; - } - - export interface ListAppointmentsResponse extends ListResponse { - subject: string; - location: string; - start: number; // DateTime - end: number; // DateTime - source: string; - details?: string; - isAllDay?: boolean; - isPrivate?: boolean; - onlineStatus?: string; - organizer?: AppointmentContact; // display name of the organizer - attendees?: AppointmentContact[]; - } - - export interface SearchContactsRequest extends Request { - query: string; - } - - export interface ListContactsResponse extends ListResponse { - nameDisplay: string; - email: string; - } - - export interface ContactResponse extends Response { - nameGiven: string; - nameMiddle: string; - nameFamily: string; - nameDisplay: string; - phoneMain: string; - phoneHome: string; - phoneWork: string; - phoneMobile: string; - phoneOther: string; - faxHome: string; - faxWork: string; - emailHome: string; - emailWork: string; - emailOther: string; - addressHome: string; - addressWork: string; - addressOther: string; - photoUri: string; - source?: string; - - phone: string; // legacy - email: string; // legacy - name: string; // legacy - } - - export interface VibrateRequest extends Request { - millis: number; - } - - interface RequestAuthenticationRequest extends Request { - path: string; - } - interface AuthenticateRequest extends Request { - token: string; - } - - interface LogRequest extends Request { - texts: string[]; - } - - interface ProxyCredentials { - name: string; - password: string; - } - - interface ProxyHeader { - name: string; - value: string; - } - - interface ProxyRequest extends Request { - url: string; - method: string; - // content of web request, at most one present - contentText?: string; - content?: string; // base64 encoded - headers?: ProxyHeader[]; - credentials?: ProxyCredentials; - responseType: string; // "base64" or "text" - } - - export interface OAuthAuthenticationRequest extends UriRequest { - redirectUri: string; // registered redirect uri - state: string; // state value to be validated - } - - interface ProxyResponse extends Response { - } - - interface DbGetRequest extends Request { - table: string; - keys: string[]; - } - - interface DbGetResponse extends Response { - values: string[]; - } - - interface DbSetRequest extends Request { - table: string; - keys: string[]; - values: string[]; - } - - interface DbSetResponse extends Response { - } - - interface DbKeysRequest extends Request { - table: string; - } - - interface DbKeysResponse extends Response { - keys: string[]; - } - - interface LockOrientationRequest extends Request { - portraitAllowed: boolean; - landscapeAllowed: boolean; - showClock: boolean; - } - - - export interface BluetoothDeviceName { - hostName: string; - serviceName: string; - } - - export interface BluetoothDeviceFriendlyName extends BluetoothDeviceName { - displayName: string; - } - - export interface BluetoothDevicesRequest extends Request {} - export interface BluetoothConnectRequest extends Request, BluetoothDeviceName {} - export interface BluetoothDisconnectRequest extends Request, BluetoothDeviceName {} - export interface BluetoothWriteRequest extends Request, BluetoothDeviceName { - data: string; - } - export interface BluetoothReadRequest extends Request, BluetoothDeviceName { - length: number; - } - - export interface BluetoothDevicesResponse extends Response { - bluetoothOn: boolean; - devices?: BluetoothDeviceFriendlyName[]; - } - - export interface BluetoothConnectResponse extends Response { - connected: boolean; - } - export interface BluetoothDisconnectResponse extends BluetoothConnectResponse {} - export interface BluetoothWriteResponse extends BluetoothConnectResponse {} - export interface BluetoothReadResponse extends BluetoothConnectResponse { - data: string; - } - - export interface BluetoothLeDeviceName { - deviceId: string; - displayName: string; - services: string[]; - connected?: boolean; - } - export interface BluetoothLeDevicesRequest extends Request { } - export interface BluetoothLeDevicesResponses extends Response { - bluetoothOn: boolean; - devices?: BluetoothLeDeviceName[]; - } - export interface BluetoothLeDeviceRequest extends Request { - deviceId: string; - serviceId: string; - characteristicId: string; - } - export interface BluetoothLeWriteRequest extends BluetoothLeDeviceRequest { - withResponse: boolean; - data: string; - } - export interface BluetoothLeReadRequest extends BluetoothLeDeviceRequest {} - export interface BluetoothLeConnectResponse extends Response { - connected: boolean; - } - export interface BluetoothLeWriteResponse extends BluetoothLeConnectResponse {} - export interface BluetoothLeReadResponse extends BluetoothLeConnectResponse { - data: string[]; - } - - interface NotificationRequest extends Request { - enable: boolean; - } - - class PendingResponse { - constructor(public action: string, public onSuccess: (r: Response) => void , public onError: (any) => void ) { - } - } - - - var _nextId = 0; - var _pendingResponses: any = {}; // TODO: time out stale requests - var _webSocket: WebSocket = undefined; - var isWP8app = false; - var wp8AppVersion = -1; - var supportsAttachments = false; - var confirmedWP8app = false; - - export function isActive() { - return !!_webSocket || isWP8app; - } - - function openWp8Async(): Promise { - var ret = new PromiseInv(); - _webSocket = new WebSocket(URI); - _webSocket.onopen = () => { - var r = ret; - ret = undefined; - Util.log("wp8ws: open"); - if (r) r.success(null); - }; - _webSocket.onmessage = _onmessage; - numAttachments = 0; - _webSocket.onerror = (e) => - { - Util.log("wp8ws: error"); - var r = ret; - ret = undefined; - _webSocket = undefined; - _onerror(e); - if (r) r.error(e); - } - _webSocket.onclose = () => { - Util.log("wp8ws: close"); - _webSocket = undefined; - }; - return ret; - } - - var numAttachments = 0; - var attachments = []; - var finalAttachments = () => { }; - var orphanedReported = false; - - function handleMessage(r: any) { - if (r == undefined) return; - var id = r.id; - if (id == undefined) return; - - var key = id + ""; - var pending: PendingResponse = _pendingResponses[key]; - - if (pending) { - if (!/START_|LIST_/.test(pending.action) || - isLastResponse(r)) { - delete _pendingResponses[key]; - } - if (pending.onSuccess) - Util.setTimeout(0, () => { - try { - pending.onSuccess(r); - } catch (e) { - Util.reportError("wab-onmessage-success", e); - } - }) - } else if (r.status) { - if (!orphanedReported) { - orphanedReported = true; - statusError(r); - } - } - } - - function handleAttachments(r: any): boolean { - var scan = (repl) => { - Object.keys(r).forEach((k) => { - if (!/^attach:/.test(k)) return; - var v = r[k] - if (typeof v == "number") { - if (repl) - v = attachments[v]; - else - maxId = Math.max(maxId, v); - } else if (Array.isArray(v)) { - v.forEach((z, i) => { - if (typeof z == "number") { - if (repl) - v[i] = attachments[z]; - else - maxId = Math.max(maxId, z); - } - }) - } - if (repl) { - delete r[k]; - k = k.slice(7); - r[k] = v; - } - }) - } - - var maxId = -1; - scan(false); - maxId++; - if (maxId > 0) { - numAttachments = maxId; - attachments = []; - finalAttachments = () => { - scan(true); - attachments = []; - handleMessage(r); - }; - return true; - } - - return false; - } - - function _onmessage(ev: MessageEvent): void { - - try { - if (numAttachments > 0) { - numAttachments--; - attachments.push(ev.data); - if (numAttachments == 0) - finalAttachments(); - return; - } - - var r; - try { - r = JSON.parse(ev.data); - } catch (e) { return; } - - if (supportsAttachments && handleAttachments(r)) return; - handleMessage(r); - } catch (e) { - Util.reportError("wab-onmessage", e); - } - } - - function _onerror(ev: ErrorEvent): void { - var prs = _pendingResponses; - _pendingResponses = {}; - Object.keys(prs).forEach(k => { - var h = prs[k].onError; - if (h) h(ev); - }); - // TODO: reopen channel? - } - - var sendingLock = new Lock(); - - function moveToAttachments(request: any): string[] { - var oob = [] - function isLong(v) { - return typeof v == "string" && v.length > 4000; - } - function attach(v) { - if (isLong(v)) { - var r = oob.length; - oob.push(v); - return r; - } else { - return v; - } - } - Object.keys(request).forEach((k) => { - var v = request[k] - if (isLong(v)) { - delete request[k]; - request["attach:" + k] = attach(v); - } else if (Array.isArray(v) && v.some(isLong)) { - delete request[k]; - request["attach:" + k] = v.map(attach); - } - }) - oob.unshift(JSON.stringify(request)); - return oob; - } - - function _sendRequest(request: Request, onSuccess: (r: Response) => void , onError: (any) => void ): string { - if (_webSocket === undefined) { - if (onSuccess) onSuccess({ status: Status.ERR_WEBSOCK_NOT_CONNECTED }); - return; - } - request.id = _nextId++; - if (!(isWP8app && request.noResponse)) - _pendingResponses[request.id + ""] = new PendingResponse(request.action, onSuccess, onError); - - //Util.log("ws send"); - if (supportsAttachments) { - var msgs = moveToAttachments(request); - msgs.forEach((s) => _webSocket.send(s)); - } else { - _webSocket.send(JSON.stringify(request)); - } - - return request.id + ""; - } - - function wrapResponse(response: Response) { - var msg = "" - switch (response.status) { - case Status.ERR_INTERNAL_ERROR: - msg = "TouchDevelop runtime crashed"; break; - case Status.ERR_MALFORMED_REQUEST: - msg = "WebAppBooster reported a malformed request"; break; - case Status.ERR_NOT_AVAILABLE: - case Status.ERR_NOT_AVAILABLE_WP8: - msg = "Not available"; - default: - msg = "Error " + response.status; - } - if ((response).errorMessage) - msg += ": " + (response).errorMessage; - Util.log(msg); - var e:any = new Error(msg); - e.wabStatus = (response).status; - e.wabCrashInfo = (response).crashInfo; - //I don't think we should be really getting these - the command should not be boosted - //if (response.status == Response.ERR_NOT_AVAILABLE) - // response.isUserError = true; - return e; - } - - function requestError(err:any) - { - Util.reportError("wab-request", err); - } - - function statusError(err:any) - { - Util.reportError("wab-status", wrapResponse(err)); - } - - export function statusErrorRaw(err:any):void - { - Util.reportError("wab-status", err); - } - - export function sendRequest(request: Request, onSuccess: (r: Response) => void, onError = statusErrorRaw): string { - return _sendRequest(request, response => { - switch (response.status) { - case Status.OK: - case Status.ERR_CANCELLED: - onSuccess(response); break; - case Status.ERR_PERMISSION_DENIED: requestPermissionsAsync().done(() => { - _sendRequest(request, response => { - if (response.status == Status.OK || response.status == Status.ERR_CANCELLED) - onSuccess(response); - else onError(wrapResponse(response)); - }, requestError); - }, requestError); break; - default: - onError(wrapResponse(response)); - } - }, requestError) - } - - export function cancelRequest(id: string) { - var pending: PendingResponse = _pendingResponses[id]; - if (pending) { - delete _pendingResponses[id]; - if (/^START_/.test(pending.action)) { - _sendRequest({ action: pending.action.replace(/^START_/, "STOP_") }, resp => { }, err => { }); - } - } - } - - export function sendRequestAsync(request: Request): Promise { - return new Promise((onSuccess, onError, onProgress) => { - sendRequest(request, onSuccess, onError); - }); - } - - function boostColors(s:OsSettings) - { - if (!s) return; - Util.log('wab: boosting COLORS'); - function boost(n:string, v:string) - { - if (v) { - var c = Color.fromHtml(v); - Colors[n] = () => c; - } - } - - boost("foreground_os", s.themeForegroundColor); - boost("background_os", s.themeBackgroundColor); - boost("chrome", s.themeChromeColor); - boost("subtle", s.themeSubtleColor); - boost("accent", s.themeAccentColor); - } - - function requestPermissionsAsync(): Promise { - Util.log('wab: requesting permissions'); - return new Promise((onSuccess, onError, onProgress) => { - _sendRequest({ - action: Action.REQUEST_PERMISSIONS, - permissions: [Permission.READ_CONTACTS, Permission.READ_CALENDAR, Permission.GYRO, Permission.ACCELEROMETER, - Permission.AUDIO, Permission.GALLERY, Permission.CAMERA, Permission.VIBRATE, Permission.RECORD_AUDIO, Permission.BLUETOOTH], - }, (response: RequestPermissionsResponse) => { - if (response.status == Status.OK) { - supportedActions = response.supportedActions; - Util.log('wab: permissions: ' + supportedActions.join(', ')); - if (response.wp8AppVersion && wp8AppVersion < 0) { - wp8AppVersion = response.wp8AppVersion; - Browser.platformCaps.push("wp8app-v" + wp8AppVersion) - Browser.platformCaps.push("wp8-v" + response.osVersion) - Util.log(Browser.platformCaps.join(", ")) - boostColors(response.osSettings) - } - onSuccess(response); - } - else { - Util.log('wab: permissions request failed'); - onError(undefined); - } - }, onError); - }); - } - - var pendingMsgs = [] - function flushMsgs() { - if (pendingMsgs.length > 0) { - sendRequestAsync({ action: Action.LOG, noResponse: true, texts: pendingMsgs }).done(); - pendingMsgs = []; - } - Util.setTimeout(500, flushMsgs); - } - - class Wp8Table implements Storage.Table { - constructor(public name: string) { - } - - public getValueAsync(key: string): Promise // of string - { - return this.getItemsAsync([key]).then((items) => items[key]); - } - - public getItemsAsync(keys: string[]): Promise // of Object - { - return sendRequestAsync({ action: Action.DB_GET, table: this.name, keys: keys }) - .then((resp: DbGetResponse) => { - var r = {} - keys.forEach((k, i) => { - r[k] = resp.values[i]; - }) - return r; - }) - } - - public getKeysAsync(): Promise // of string[] - { - return sendRequestAsync({ action: Action.DB_KEYS, table: this.name }) - .then((resp: DbKeysResponse) => resp.keys) - } - - static dbSetLock = new Lock(); - - public setItemsAsync(items: any): Promise // of void - { - var keys = Object.keys(items); - var hasBig = false; - var vals = keys.map((k) => { - var v:string = items[k] - if (v && v.length > 100000) hasBig = true; - if (v === undefined) return null; - return v; - }); - var req: DbSetRequest = { action: Action.DB_SET, table: this.name, keys: keys, values: vals }; - if (hasBig) { - var ret = new PromiseInv(); - Wp8Table.dbSetLock.acquire(() => { - sendRequestAsync(req).done((resp) => { - Wp8Table.dbSetLock.release(); - ret.success(resp); - }); - }); - return ret; - } else - return sendRequestAsync(req); - } - } - - function setWp8UriAsync() { - var r = new PromiseInv(); - (window).tdevWsUri = (uri, legal, appName) => { - Util.log("ws uri: " + uri); - URI = uri; - Runtime.legalNotice = legal || ""; - Runtime.appName = appName; - (window).tdevWsUri = () => { }; - r.success(uri); - }; - Util.log("notifying parent app"); - var wsuriRetry = 5 - function tryNotify() { - try { - (window.external).Notify("WSURI"); - } catch (e) { - if (wsuriRetry-- < 0) throw e; - else Util.setTimeout(500, tryNotify); - } - } - tryNotify(); - Util.log("parent app notified"); - return r; - } - - function setupWp8app(): Promise { - if (!Browser.isWP8app) return null; - if (!window.external) return null; - - isWP8app = true; - supportsAttachments = true; - Browser.deviceMotion = true; - Browser.webAppBooster = true; - Browser.audioWav = true; - Browser.canIndexedDB = false; - Storage.getTableAsync = (name: string) => Promise.as(new Wp8Table(name)); - Storage.clearPreAsync = () => - Promise.join(Storage.tableNames.map((t) => sendRequestAsync({ action: Action.DB_DELETE, table: t }))); - - Util.log("wp8: sending auth app request"); - return setWp8UriAsync().then(() => openWp8Async()).then(() => { - _sendRequest({ action: Action.REQUEST_AUTHENTICATION, path: "app" }, resp => { - if (resp.status == Status.OK) { - Util.externalLog = (msg) => { - pendingMsgs.push(msg); - }; - Util.log("wp8: auth app request OK"); - confirmedWP8app = true; - flushMsgs(); - } else { - Util.log("wp8: auth app request failed: " + JSON.stringify(resp)); - isWP8app = false; - } - }, err => { - Util.log("wp8: auth app request failed (onError): " + err); - isWP8app = false; - }); - }) - } - - var supportedActions: string[] = []; - export function isSupportedAction(name: string) { - return supportedActions.indexOf(name) > -1; - } - - function lockOrientation(p: boolean, l: boolean, clock: boolean) { - SizeMgr.lastOrientationLockTime = Util.now(); - sendRequestAsync({ - action: Action.LOCK_ORIENTATION, - portraitAllowed: p, - landscapeAllowed: l, - showClock: clock - }).done(() => { - SizeMgr.lastOrientationLockTime = Util.now(); - }); - } - - function arrivedAtHash(h:string) { - sendRequestAsync({ - action: Action.CURRENT_HASH, - hash: h, - isMainScreen: h == '#hub' || h == '#', - }).done(); - } - - var lastChannelUri: string; - function refreshNotifications(enable: boolean) { - var request = { - action: Action.NOTIFICATION, - enable: enable - }; - //Util.log("Notification request: " + JSON.stringify(request)); - sendRequestAsync(request).then(response => { - //Util.log("Notification response: " + JSON.stringify(response)); - if (response.channelUri && lastChannelUri != response.channelUri) { - lastChannelUri = response.channelUri; - var webRequest = { subscriptionuri: response.channelUri, versionminor: response.versionMinor, versionmajor: response.versionMajor }; - //Util.log("Notification web request: " + JSON.stringify(webRequest)); - Cloud.postNotificationChannelAsync(webRequest).done(webResponse => - { - //Util.log("Notification web response: " + JSON.stringify(webResponse)); - }, - ex => { }); - } - }).done(); - } - - export function initAsync(): Promise { - var r = setupWp8app(); - if (r) return r.then(() => requestPermissionsAsync()).then(() => { - Util.log('wab: boosting NOTIFICATION'); - Runtime.refreshNotifications = refreshNotifications; - Runtime.lockOrientation = lockOrientation; - if (isSupportedAction(Action.CURRENT_HASH)) - Screen.arrivedAtHash = arrivedAtHash; - lockOrientation(true, false, true); - - function waitForUpdate(id:string) - { - sendRequestAsync({ action: Action.CHECK_FOR_REFRESH }).done(); - (TDev).updateLoop(id, "refreshing runtime"); - return true; - } - - var w = (TDev).World; - if (w) { - if (isSupportedAction(Action.CHECK_FOR_REFRESH)) { - Util.log('wab: boosting CHECK_FOR_REFRESH'); - w.waitForUpdate = waitForUpdate; - } else { - w.waitForUpdate = () => false; - } - - if (isSupportedAction(Action.SWITCH_CHANNEL)) { - Util.log('wab: boosting SWITCH_CHANNEL'); - w.switchToChannel = (ch:string) => { - sendRequestAsync({ - action: Action.SWITCH_CHANNEL, - channel: ch, - }).done(); - ProgressOverlay.lockAndShow("switching to " + ch); - }; - } else { - w.switchToChannel = null; - } - } - - // we use this guy as a ping; it doesn't do much at all on the C# side - if (isSupportedAction(Action.CURRENT_HASH)) - Util.log('wab: boosting CURRENT_HASH'); - Runtime.continueAfter = (ms:number, f:()=>void) => { - sendRequestAsync({ - action: Action.CURRENT_HASH, - hash: undefined, - isMainScreen: false - }).done(f); - }; - }); - - return Promise.as(); - } - - export function getSupportedCapabilities(): string[] { - if (!isActive()) return []; - var caps: string[] = []; - if (isSupportedAction(Action.PICK_CONTACT) || - isSupportedAction(Action.LIST_CONTACTS)) - caps.push("contacts"); - if (isSupportedAction(Action.START_GYRO)) - caps.push("gyroscope"); - if (isSupportedAction(Action.START_ACCELEROMETER)) - caps.push("accelerometer"); - if (isSupportedAction(Action.START_COMPASS)) - caps.push("compass"); - if (isSupportedAction(Action.START_ORIENTATION)) - caps.push("orientation"); - if (isSupportedAction(Action.LIST_APPOINTMENTS)) - caps.push("calendar"); - if (isSupportedAction(Action.UPDATE_TILE)) - caps.push("tiles"); - if (isSupportedAction(Action.SPEAK_TEXT) || - isSupportedAction(Action.SPEAK_SSML) || - isSupportedAction(Action.DICTATE)) - caps.push("speech"); - if (isSupportedAction(Action.LIST_SONGS) - || isSupportedAction(Action.LIST_SONG_ALBUM) - || isSupportedAction(Action.LIST_SONG_ALBUMS) - || isSupportedAction(Action.SONG_ALBUM) - || isSupportedAction(Action.PLAYER_COMMAND) - || isSupportedAction(Action.PLAYER_STATE) - || isSupportedAction(Action.ACTIVE_SONG) - || isSupportedAction(Action.START_ACTIVE_SONG_CHANGED) - || isSupportedAction(Action.START_PLAYER_STATE_CHANGED) - || isSupportedAction(Action.PLAY_SOUND)) - caps.push('musicandsounds'); - if (isSupportedAction(Action.SAVE_TO_GALLERY) - || isSupportedAction(Action.PICK_IMAGE)) - caps.push('media'); - if (isSupportedAction(Action.RECORD_MICROPHONE)) - caps.push('microphone'); - if (isSupportedAction(Action.START_SEND_NFC_MESSAGE) || - isSupportedAction(Action.START_RECEIVE_NFC_MESSAGE)) - caps.push('proximity'); - if (isSupportedAction(Action.BLUETOOTH_DEVICES)) - caps.push('bluetooth'); - if (isSupportedAction(Action.RADIO_COMMAND)) - caps.push('radio'); - return caps; - } -} diff --git a/rt/RTValue.ts b/rt/RTValue.ts index ad570334..a45365df 100644 --- a/rt/RTValue.ts +++ b/rt/RTValue.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") } } diff --git a/rt/html.ts b/rt/html.ts index 626a5120..0b920f6b 100644 --- a/rt/html.ts +++ b/rt/html.ts @@ -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) (() => { diff --git a/rt/rt.ts b/rt/rt.ts index c84e1b84..e7f1abf8 100644 --- a/rt/rt.ts +++ b/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; } diff --git a/rt/sizemgr.ts b/rt/sizemgr.ts index 048f0d2b..15b23439 100644 --- a/rt/sizemgr.ts +++ b/rt/sizemgr.ts @@ -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; diff --git a/rt/ticker.ts b/rt/ticker.ts index b5f3962c..4a5f3b6e 100644 --- a/rt/ticker.ts +++ b/rt/ticker.ts @@ -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); diff --git a/runner/main.ts b/runner/main.ts index b2271a10..a9d53ec2 100644 --- a/runner/main.ts +++ b/runner/main.ts @@ -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 diff --git a/runner/refs.ts b/runner/refs.ts index 93a1a760..441674fc 100644 --- a/runner/refs.ts +++ b/runner/refs.ts @@ -2,7 +2,6 @@ /// /// /// -/// /// /// /// diff --git a/storage/wall.ts b/storage/wall.ts index 7314ed12..13c55fd1 100644 --- a/storage/wall.ts +++ b/storage/wall.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"; diff --git a/tools/genmeta.ts b/tools/genmeta.ts index a36b903e..44bce4b0 100644 --- a/tools/genmeta.ts +++ b/tools/genmeta.ts @@ -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++; diff --git a/vsrefs.ts b/vsrefs.ts index a49dc0c1..1ae7e2a5 100644 --- a/vsrefs.ts +++ b/vsrefs.ts @@ -3,7 +3,6 @@ /// /// /// -/// /// /// ///