mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
Move definitions and test in separate folders
This enables each definition to have a readme if necessary. Also a .json metadata file to help with package managers. And last, to have different versions of the definitions.
This commit is contained in:
97
unity-webapi/unity-webapi-1.0.d.ts
vendored
Normal file
97
unity-webapi/unity-webapi-1.0.d.ts
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
// Type definitions for Ubuntu Unity Web API 1.0
|
||||
// Project: https://launchpad.net/libunity-webapps
|
||||
// Definitions by: John Vrbanac <john.vrbanac@linux.com> | https://github.com/jmvrbanac
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
declare class UnitySettings {
|
||||
public name:String;
|
||||
public iconUrl:String;
|
||||
public onInit:Function;
|
||||
}
|
||||
|
||||
enum UnityPlaybackState {
|
||||
Playing,
|
||||
Paused
|
||||
}
|
||||
|
||||
declare class UnityTrackMetadata {
|
||||
title:String;
|
||||
|
||||
// Optionals
|
||||
album:String;
|
||||
artist:String;
|
||||
artLocation:String;
|
||||
}
|
||||
|
||||
interface UnityMediaPlayer {
|
||||
setTrack(trackMetadata:UnityTrackMetadata);
|
||||
|
||||
onPrevious(onPreviousCallback:Function);
|
||||
onNext(onNextCallback:Function);
|
||||
onPlayPause(onPlayPauseCallback:Function);
|
||||
|
||||
getPlaybackstate(response:Function);
|
||||
setPlaybackstate(state:UnityPlaybackState);
|
||||
|
||||
setCanGoNext(cangonext:Boolean);
|
||||
setCanGoPrev(cangoprev:Boolean);
|
||||
setCanPlay(canplay:Boolean);
|
||||
setCanPause(canpause:Boolean);
|
||||
}
|
||||
|
||||
interface UnityNotification {
|
||||
showNotification (summary:String, body:String, iconUrl?:String);
|
||||
}
|
||||
|
||||
declare class UnityIndicatorProperties {
|
||||
public count:Number;
|
||||
public time:Date;
|
||||
public iconURI:String;
|
||||
public onIndicatorActivated:Function;
|
||||
}
|
||||
|
||||
interface UnityMessagingIndicator {
|
||||
showIndicator(name:String, indicatorProperties:UnityIndicatorProperties);
|
||||
clearIndicator(name:String);
|
||||
clearIndicators();
|
||||
|
||||
addAction(name:String, onActionInvoked:Function);
|
||||
removeAction(name:String);
|
||||
removeActions();
|
||||
onPresenceChanged(onPresenceChanged:Function);
|
||||
|
||||
// This is suppose to be readonly, but i'm not sure how to do this
|
||||
// in a definition file.
|
||||
presence:String;
|
||||
}
|
||||
|
||||
interface UnityLauncher {
|
||||
setCount(count:number);
|
||||
clearCount();
|
||||
|
||||
setProgress(progress:number);
|
||||
clearProgress();
|
||||
|
||||
setUrgent(urgent:Boolean);
|
||||
|
||||
addAction(name:String, onActionInvoked:Function);
|
||||
removeAction(name:String);
|
||||
removeActions();
|
||||
}
|
||||
|
||||
interface Unity {
|
||||
init(settings:UnitySettings);
|
||||
addAction(name:String, callback:Function);
|
||||
removeAction(actionName:String);
|
||||
removeActions();
|
||||
|
||||
Notification:UnityNotification;
|
||||
MediaPlayer:UnityMediaPlayer;
|
||||
MessagingIndicator:UnityMessagingIndicator;
|
||||
Launcher:UnityLauncher;
|
||||
}
|
||||
|
||||
interface BrowserPublic {
|
||||
getUnityObject(version:number):Unity;
|
||||
}
|
||||
|
||||
58
unity-webapi/unity-webapi-tests.ts
Normal file
58
unity-webapi/unity-webapi-tests.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
/// <reference path="../Definitions/unity-webapi-1.0.d.ts" />
|
||||
|
||||
var Unity = external.getUnityObject(1.0);
|
||||
var settings = new UnitySettings();
|
||||
Unity.init(settings);
|
||||
|
||||
// Actions
|
||||
Unity.addAction("boom", function() {});
|
||||
Unity.removeAction("boom");
|
||||
Unity.removeActions();
|
||||
|
||||
// Notification
|
||||
Unity.Notification.showNotification("sum", "body");
|
||||
Unity.Notification.showNotification("sum", "body", "optional");
|
||||
|
||||
// Messaging
|
||||
var props = new UnityIndicatorProperties();
|
||||
props.count = 0;
|
||||
props.time = new Date();
|
||||
|
||||
Unity.MessagingIndicator.showIndicator("boom", props);
|
||||
Unity.MessagingIndicator.clearIndicator("boom");
|
||||
Unity.MessagingIndicator.clearIndicators();
|
||||
|
||||
Unity.MessagingIndicator.addAction("boom", function() {});
|
||||
Unity.MessagingIndicator.removeAction("boom");
|
||||
Unity.MessagingIndicator.removeActions();
|
||||
Unity.MessagingIndicator.onPresenceChanged(function() {});
|
||||
|
||||
// Launcher
|
||||
Unity.Launcher.setCount(1);
|
||||
Unity.Launcher.clearCount();
|
||||
|
||||
Unity.Launcher.setProgress(100);
|
||||
Unity.Launcher.clearProgress();
|
||||
|
||||
Unity.Launcher.setUrgent(true);
|
||||
|
||||
Unity.Launcher.addAction("boom", function(){});
|
||||
Unity.Launcher.removeAction("boom");
|
||||
Unity.Launcher.removeActions();
|
||||
|
||||
|
||||
// MediaPlayer
|
||||
var metadata = new UnityTrackMetadata();
|
||||
Unity.MediaPlayer.setTrack(metadata);
|
||||
|
||||
Unity.MediaPlayer.onPrevious(function(){});
|
||||
Unity.MediaPlayer.onNext(function(){});
|
||||
Unity.MediaPlayer.onPlayPause(function(){});
|
||||
|
||||
Unity.MediaPlayer.getPlaybackstate(function(){});
|
||||
Unity.MediaPlayer.setPlaybackstate(UnityPlaybackState.Playing);
|
||||
|
||||
Unity.MediaPlayer.setCanGoNext(true);
|
||||
Unity.MediaPlayer.setCanGoPrev(true);
|
||||
Unity.MediaPlayer.setCanPlay(true);
|
||||
Unity.MediaPlayer.setCanPause(true);
|
||||
Reference in New Issue
Block a user