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:
Boris Yankov
2012-11-18 22:28:44 +02:00
parent b2e85b459f
commit c91c45f9ae
92 changed files with 1354 additions and 1354 deletions

View File

@@ -1,294 +1,294 @@
// Type definitions for Knockout 2.2
// Project: http://knockoutjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface KnockoutSubscribableFunctions {
extend(source);
dispose(): void;
peek(): any;
valueHasMutated(): void;
valueWillMutate(): void;
}
interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
getDependenciesCount(): number;
hasWriteFunction(): bool;
}
interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
}
interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
// General Array functions
indexOf(searchElement, fromIndex?: number): number;
slice(start: number, end?: number): any[];
splice(start: number): any[];
splice(start: number, deleteCount: number, ...items: any[]): any[];
pop();
push(...items: any[]): void;
shift();
unshift(...items: any[]): number;
reverse(): any[];
sort(): void;
sort(compareFunction): void;
// Ko specific
remove(item): any[];
removeAll(items: any[]): any[];
removeAll(): any[];
destroy(item): void;
destroyAll(items: any[]): void;
destroyAll(): void;
}
interface KnockoutSubscribableStatic {
fn: KnockoutSubscribableFunctions;
new (): KnockoutSubscription;
}
interface KnockoutSubscription extends KnockoutSubscribableFunctions {
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutComputedStatic {
fn: KnockoutComputedFunctions;
(): KnockoutComputed;
(func: Function, context?: any): KnockoutComputed;
(def: KnockoutComputedDefine): KnockoutComputed;
(options?: any): KnockoutComputed;
}
interface KnockoutComputed extends KnockoutComputedFunctions {
(): any;
(value: any): void;
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutObservableArrayStatic {
fn: KnockoutObservableArrayFunctions;
(): KnockoutObservableArray;
(value: any[]): KnockoutObservableArray;
}
interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
(): any[];
(value: any[]): void;
subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: any[], topic?: string);
}
interface KnockoutObservableStatic {
fn: KnockoutObservableFunctions;
(value: string): KnockoutObservableString;
(value: Date): KnockoutObservableDate;
(value: number): KnockoutObservableNumber;
(value: bool): KnockoutObservableBool;
(value?: any): KnockoutObservableAny;
}
interface KnockoutObservableBase extends KnockoutObservableFunctions {
}
interface KnockoutObservableAny extends KnockoutObservableBase {
(): any;
(value): void;
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutObservableString extends KnockoutObservableBase {
(): string;
(value: string): void;
subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: string, topic?: string);
}
interface KnockoutObservableNumber extends KnockoutObservableBase {
(): number;
(value: number): void;
subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: number, topic?: string);
}
interface KnockoutObservableBool extends KnockoutObservableBase {
(): bool;
(value: bool): void;
subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: bool, topic?: string);
}
interface KnockoutObservableDate extends KnockoutObservableBase {
(): Date;
(value: Date): void;
subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: Date, topic?: string);
}
interface KnockoutComputedDefine {
read(): any;
write(any);
}
interface KnockoutBindingContext {
$parent: any;
$parents: any[];
$root: any;
$data: any;
$index?: number;
$parentContext?: KnockoutBindingContext;
extend(any): any;
createChildContext(any): any;
}
interface KnockoutBindingHandler {
init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
options?: any;
}
interface KnockoutBindingHandlers {
// Controlling text and appearance
visible: KnockoutBindingHandler;
text: KnockoutBindingHandler;
html: KnockoutBindingHandler;
css: KnockoutBindingHandler;
style: KnockoutBindingHandler;
attr: KnockoutBindingHandler;
// Control Flow
foreach: KnockoutBindingHandler;
if: KnockoutBindingHandler;
ifnot: KnockoutBindingHandler;
with: KnockoutBindingHandler;
// Working with form fields
click: KnockoutBindingHandler;
event: KnockoutBindingHandler;
submit: KnockoutBindingHandler;
enable: KnockoutBindingHandler;
disable: KnockoutBindingHandler;
value: KnockoutBindingHandler;
hasfocus: KnockoutBindingHandler;
checked: KnockoutBindingHandler;
options: KnockoutBindingHandler;
selectedOptions: KnockoutBindingHandler;
uniqueName: KnockoutBindingHandler;
// Rendering templates
template: KnockoutBindingHandler;
}
interface KnockoutMemoization {
memoize(callback);
unmemoize(memoId, callbackParams);
unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
parseMemoText(memoText);
}
interface KnockoutVirtualElements {
allowedBindings;
emptyNode;
firstChild;
insertAfter;
nextSibling;
prepend;
setDomNodeChildren;
}
interface KnockoutExtenders {
throttle(target: any, timeout: number): KnockoutComputed;
notify(target: any, notifyWhen: string): any;
}
interface KnockoutUtils {
fieldsIncludedWithJsonPost: any[];
arrayForEach(array: any[], action: (any) => void ): void;
arrayIndexOf(array: any[], item: any): number;
arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
arrayRemoveItem(array: any[], itemToRemove: any): void;
arrayGetDistinctValues(array: any[]): any[];
arrayMap(array: any[], mapping: (item) => any): any[];
arrayFilter(array: any[], predicate: (item) => bool): any[];
arrayPushAll(array: any[], valuesToPush: any[]): any[];
extend(target, source);
emptyDomNode(domNode): void;
moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
setDomNodeChildren(domNode: any, childNodes: any[]): void;
replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
stringTrim(str: string): string;
stringTokenize(str: string, delimiter: string): string;
stringStartsWith(str: string, startsWith: string): string;
domNodeIsContainedBy(node: any, containedByNode: any): bool;
domNodeIsAttachedToDocument(node: any): bool;
tagNameLower(element: any): string;
registerEventHandler(element: any, eventType: any, handler: Function): void;
triggerEvent(element: any, eventType: any): void;
unwrapObservable(value: any): any;
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
setTextContent(element: any, textContent: string): void;
setElementName(element: any, name: string): void;
ensureSelectElementIsRenderedCorrectly(selectElement);
forceRefresh(node: any): void;
ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
range(min: any, max: any): any;
makeArray(arrayLikeObject: any): any[];
getFormFields(form: any, fieldName: string): any[];
parseJson(jsonString: string): any;
stringifyJson(data: any, replacer: Function, space: string): string;
postJson(urlOrForm: any, data: any, options: any): void;
domNodeDisposal;
}
interface KnockoutStatic {
utils: KnockoutUtils;
memoization: KnockoutMemoization;
bindingHandlers: KnockoutBindingHandlers;
virtualElements: KnockoutVirtualElements;
extenders: KnockoutExtenders;
applyBindings(viewModel: any, rootNode?: any): void;
applyBindingsToDescendants(viewModel: any, rootNode: any): void;
subscribable: KnockoutSubscribableStatic;
observable: KnockoutObservableStatic;
computed: KnockoutComputedStatic;
observableArray: KnockoutObservableArrayStatic;
contextFor(node: any): any;
isSubscribable(instance: any): bool;
toJSON(viewModel: any, replacer?: Function, space?: any): string;
toJS(viewModel: any): any;
isObservable(instance: any): bool;
dataFor(node: any): any;
removeNode(node: Element);
}
// Type definitions for Knockout 2.2
// Project: http://knockoutjs.com
// Definitions by: Boris Yankov <https://github.com/borisyankov/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
interface KnockoutSubscribableFunctions {
extend(source);
dispose(): void;
peek(): any;
valueHasMutated(): void;
valueWillMutate(): void;
}
interface KnockoutComputedFunctions extends KnockoutSubscribableFunctions {
getDependenciesCount(): number;
hasWriteFunction(): bool;
}
interface KnockoutObservableFunctions extends KnockoutSubscribableFunctions {
}
interface KnockoutObservableArrayFunctions extends KnockoutObservableFunctions {
// General Array functions
indexOf(searchElement, fromIndex?: number): number;
slice(start: number, end?: number): any[];
splice(start: number): any[];
splice(start: number, deleteCount: number, ...items: any[]): any[];
pop();
push(...items: any[]): void;
shift();
unshift(...items: any[]): number;
reverse(): any[];
sort(): void;
sort(compareFunction): void;
// Ko specific
remove(item): any[];
removeAll(items: any[]): any[];
removeAll(): any[];
destroy(item): void;
destroyAll(items: any[]): void;
destroyAll(): void;
}
interface KnockoutSubscribableStatic {
fn: KnockoutSubscribableFunctions;
new (): KnockoutSubscription;
}
interface KnockoutSubscription extends KnockoutSubscribableFunctions {
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutComputedStatic {
fn: KnockoutComputedFunctions;
(): KnockoutComputed;
(func: Function, context?: any): KnockoutComputed;
(def: KnockoutComputedDefine): KnockoutComputed;
(options?: any): KnockoutComputed;
}
interface KnockoutComputed extends KnockoutComputedFunctions {
(): any;
(value: any): void;
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutObservableArrayStatic {
fn: KnockoutObservableArrayFunctions;
(): KnockoutObservableArray;
(value: any[]): KnockoutObservableArray;
}
interface KnockoutObservableArray extends KnockoutObservableArrayFunctions {
(): any[];
(value: any[]): void;
subscribe(callback: (newValue: any[]) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: any[], topic?: string);
}
interface KnockoutObservableStatic {
fn: KnockoutObservableFunctions;
(value: string): KnockoutObservableString;
(value: Date): KnockoutObservableDate;
(value: number): KnockoutObservableNumber;
(value: bool): KnockoutObservableBool;
(value?: any): KnockoutObservableAny;
}
interface KnockoutObservableBase extends KnockoutObservableFunctions {
}
interface KnockoutObservableAny extends KnockoutObservableBase {
(): any;
(value): void;
subscribe(callback: (newValue: any) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite, topic?: string);
}
interface KnockoutObservableString extends KnockoutObservableBase {
(): string;
(value: string): void;
subscribe(callback: (newValue: string) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: string, topic?: string);
}
interface KnockoutObservableNumber extends KnockoutObservableBase {
(): number;
(value: number): void;
subscribe(callback: (newValue: number) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: number, topic?: string);
}
interface KnockoutObservableBool extends KnockoutObservableBase {
(): bool;
(value: bool): void;
subscribe(callback: (newValue: bool) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: bool, topic?: string);
}
interface KnockoutObservableDate extends KnockoutObservableBase {
(): Date;
(value: Date): void;
subscribe(callback: (newValue: Date) => void, target?:any, topic?: string): KnockoutSubscription;
notifySubscribers(valueToWrite: Date, topic?: string);
}
interface KnockoutComputedDefine {
read(): any;
write(any);
}
interface KnockoutBindingContext {
$parent: any;
$parents: any[];
$root: any;
$data: any;
$index?: number;
$parentContext?: KnockoutBindingContext;
extend(any): any;
createChildContext(any): any;
}
interface KnockoutBindingHandler {
init?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
update?(element: any, valueAccessor: () => any, allBindingsAccessor: () => any, viewModel: any, bindingContext: KnockoutBindingContext): void;
options?: any;
}
interface KnockoutBindingHandlers {
// Controlling text and appearance
visible: KnockoutBindingHandler;
text: KnockoutBindingHandler;
html: KnockoutBindingHandler;
css: KnockoutBindingHandler;
style: KnockoutBindingHandler;
attr: KnockoutBindingHandler;
// Control Flow
foreach: KnockoutBindingHandler;
if: KnockoutBindingHandler;
ifnot: KnockoutBindingHandler;
with: KnockoutBindingHandler;
// Working with form fields
click: KnockoutBindingHandler;
event: KnockoutBindingHandler;
submit: KnockoutBindingHandler;
enable: KnockoutBindingHandler;
disable: KnockoutBindingHandler;
value: KnockoutBindingHandler;
hasfocus: KnockoutBindingHandler;
checked: KnockoutBindingHandler;
options: KnockoutBindingHandler;
selectedOptions: KnockoutBindingHandler;
uniqueName: KnockoutBindingHandler;
// Rendering templates
template: KnockoutBindingHandler;
}
interface KnockoutMemoization {
memoize(callback);
unmemoize(memoId, callbackParams);
unmemoizeDomNodeAndDescendants(domNode, extraCallbackParamsArray);
parseMemoText(memoText);
}
interface KnockoutVirtualElements {
allowedBindings;
emptyNode;
firstChild;
insertAfter;
nextSibling;
prepend;
setDomNodeChildren;
}
interface KnockoutExtenders {
throttle(target: any, timeout: number): KnockoutComputed;
notify(target: any, notifyWhen: string): any;
}
interface KnockoutUtils {
fieldsIncludedWithJsonPost: any[];
arrayForEach(array: any[], action: (any) => void ): void;
arrayIndexOf(array: any[], item: any): number;
arrayFirst(array: any[], predicate: (item) => bool, predicateOwner?: any): any;
arrayRemoveItem(array: any[], itemToRemove: any): void;
arrayGetDistinctValues(array: any[]): any[];
arrayMap(array: any[], mapping: (item) => any): any[];
arrayFilter(array: any[], predicate: (item) => bool): any[];
arrayPushAll(array: any[], valuesToPush: any[]): any[];
extend(target, source);
emptyDomNode(domNode): void;
moveCleanedNodesToContainerElement(nodes: any[]): HTMLElement;
cloneNodes(nodesArray: any[], shouldCleanNodes: bool): any[];
setDomNodeChildren(domNode: any, childNodes: any[]): void;
replaceDomNodes(nodeToReplaceOrNodeArray: any, newNodesArray: any[]): void;
setOptionNodeSelectionState(optionNode: any, isSelected: bool): void;
stringTrim(str: string): string;
stringTokenize(str: string, delimiter: string): string;
stringStartsWith(str: string, startsWith: string): string;
domNodeIsContainedBy(node: any, containedByNode: any): bool;
domNodeIsAttachedToDocument(node: any): bool;
tagNameLower(element: any): string;
registerEventHandler(element: any, eventType: any, handler: Function): void;
triggerEvent(element: any, eventType: any): void;
unwrapObservable(value: any): any;
toggleDomNodeCssClass(node: any, className: string, shouldHaveClass: bool): void;
setTextContent(element: any, textContent: string): void;
setElementName(element: any, name: string): void;
ensureSelectElementIsRenderedCorrectly(selectElement);
forceRefresh(node: any): void;
ensureSelectElementIsRenderedCorrectly(selectElement: any): void;
range(min: any, max: any): any;
makeArray(arrayLikeObject: any): any[];
getFormFields(form: any, fieldName: string): any[];
parseJson(jsonString: string): any;
stringifyJson(data: any, replacer: Function, space: string): string;
postJson(urlOrForm: any, data: any, options: any): void;
domNodeDisposal;
}
interface KnockoutStatic {
utils: KnockoutUtils;
memoization: KnockoutMemoization;
bindingHandlers: KnockoutBindingHandlers;
virtualElements: KnockoutVirtualElements;
extenders: KnockoutExtenders;
applyBindings(viewModel: any, rootNode?: any): void;
applyBindingsToDescendants(viewModel: any, rootNode: any): void;
subscribable: KnockoutSubscribableStatic;
observable: KnockoutObservableStatic;
computed: KnockoutComputedStatic;
observableArray: KnockoutObservableArrayStatic;
contextFor(node: any): any;
isSubscribable(instance: any): bool;
toJSON(viewModel: any, replacer?: Function, space?: any): string;
toJS(viewModel: any): any;
isObservable(instance: any): bool;
dataFor(node: any): any;
removeNode(node: Element);
}
declare var ko: KnockoutStatic;

File diff suppressed because it is too large Load Diff

View File

@@ -1,197 +1,197 @@
// require-2.1.1.d.ts
// (c) 2012 Josh Baldwin
// require.d.ts may be freely distributed under the MIT license.
// For all details and documentation:
// https://github.com/jbaldwin/require.d.ts
interface RequireShim {
// List of dependencies.
deps?: string[];
// Name the module will be exported as.
exports?: string;
// Initialize function with all dependcies passed in,
// if the function returns a value then that value is used
// as the module export value instead of the object
// found via the 'exports' string.
init?: (...dependencies: any[]) => any;
}
interface RequireConfig {
// The root path to use for all module lookups.
baseUrl?: string;
// Path mappings for module names not found directly under
// baseUrl.
paths?: { [key: string]: string; };
// Dictionary of Shim's.
// does not cover case of key->string[]
shim?: { [key: string]: RequireShim; };
/**
* For the given module prefix, instead of loading the
* module with the given ID, substitude a different
* module ID.
*
* @example
* requirejs.config({
* map: {
* 'some/newmodule': {
* 'foo': 'foo1.2'
* },
* 'some/oldmodule': {
* 'foo': 'foo1.0'
* }
* }
* });
**/
map?: {
[id: string]: {
[id: string]: string;
};
};
// AMD configurations, use module.config() to access in
// define() functions
config?: { [id: string]: { }; };
// Configures loading modules from CommonJS packages.
packages?: { };
// The number of seconds to wait before giving up on loading
// a script. The default is 7 seconds.
waitSeconds?: number;
// A name to give to a loading context. This allows require.js
// to load multiple versions of modules in a page, as long as
// each top-level require call specifies a unique context string.
context?: string;
// An array of dependencies to load.
deps?: string[];
// A function to pass to require that should be require after
// deps have been loaded.
callback?: (...modules: any[]) => void;
// If set to true, an error will be thrown if a script loads
// that does not call define() or have shim exports string
// value that can be checked.
enforceDefine?: bool;
// If set to true, document.createElementNS() will be used
// to create script elements.
xhtml?: bool;
/**
* Extra query string arguments appended to URLs that RequireJS
* uses to fetch resources. Most useful to cachce bust when
* the browser or server is not configured correcty.
*
* @example
* urlArgs: "bust= + (new Date()).getTime()
**/
urlArgs?: string;
/**
* Specify the value for the type="" attribute used for script
* tags inserted into the document by RequireJS. Default is
* "text/javascript". To use Firefox's JavasScript 1.8
* features, use "text/javascript;version=1.8".
**/
scriptType?: string;
}
// not sure what to do with this guy
interface RequireModule {
config(): { };
}
interface RequireMap {
prefix: string;
name: string;
parentMap: RequireMap;
url: string;
originalName: string;
fullName: string;
}
interface Require {
// Configure require.js
config(config: RequireConfig): void;
// Start the main app logic.
// Callback is optional.
// Can alternatively use deps and callback.
(modules: string[]): void;
(modules: string[], ready: (...modules: any[]) => void): void;
// Generate URLs from require module
toUrl(module: string): string;
// On Error override
onError(): void;
// Undefine a module
undef(module: string): void;
// Semi-private function, overload in special instance of undef()
onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
}
interface RequireDefine {
/**
* Define Simple Name/Value Pairs
* @config Dictionary of Named/Value pairs for the config.
**/
(config: { [key: string]: any; }): void;
/**
* Define function.
* @func: The function module.
**/
(func: () => any): void;
/**
* Define function with dependencies.
* @deps List of dependencies module IDs.
* @ready Callback function when the dependencies are loaded.
* @deps module dependencies
* @return module definition
**/
(deps: string[], ready: (...deps: any[]) => any): void;
/**
* Define module with simplified CommonJS wrapper.
* @ready
* @require requirejs instance
* @exports exports object
* @module module
* @return module definition
**/
(ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
/**
* Define a module with a name and dependencies.
* @name The name of the module.
* @deps List of dependencies module IDs.
* @ready Callback function when the dependencies are loaded.
* @deps module dependencies
* @return module definition
**/
(name: string, deps: string[], ready: (...deps: any[]) => any): void;
}
// Ambient declarations for 'require' and 'define'
var require: Require;
// require-2.1.1.d.ts
// (c) 2012 Josh Baldwin
// require.d.ts may be freely distributed under the MIT license.
// For all details and documentation:
// https://github.com/jbaldwin/require.d.ts
interface RequireShim {
// List of dependencies.
deps?: string[];
// Name the module will be exported as.
exports?: string;
// Initialize function with all dependcies passed in,
// if the function returns a value then that value is used
// as the module export value instead of the object
// found via the 'exports' string.
init?: (...dependencies: any[]) => any;
}
interface RequireConfig {
// The root path to use for all module lookups.
baseUrl?: string;
// Path mappings for module names not found directly under
// baseUrl.
paths?: { [key: string]: string; };
// Dictionary of Shim's.
// does not cover case of key->string[]
shim?: { [key: string]: RequireShim; };
/**
* For the given module prefix, instead of loading the
* module with the given ID, substitude a different
* module ID.
*
* @example
* requirejs.config({
* map: {
* 'some/newmodule': {
* 'foo': 'foo1.2'
* },
* 'some/oldmodule': {
* 'foo': 'foo1.0'
* }
* }
* });
**/
map?: {
[id: string]: {
[id: string]: string;
};
};
// AMD configurations, use module.config() to access in
// define() functions
config?: { [id: string]: { }; };
// Configures loading modules from CommonJS packages.
packages?: { };
// The number of seconds to wait before giving up on loading
// a script. The default is 7 seconds.
waitSeconds?: number;
// A name to give to a loading context. This allows require.js
// to load multiple versions of modules in a page, as long as
// each top-level require call specifies a unique context string.
context?: string;
// An array of dependencies to load.
deps?: string[];
// A function to pass to require that should be require after
// deps have been loaded.
callback?: (...modules: any[]) => void;
// If set to true, an error will be thrown if a script loads
// that does not call define() or have shim exports string
// value that can be checked.
enforceDefine?: bool;
// If set to true, document.createElementNS() will be used
// to create script elements.
xhtml?: bool;
/**
* Extra query string arguments appended to URLs that RequireJS
* uses to fetch resources. Most useful to cachce bust when
* the browser or server is not configured correcty.
*
* @example
* urlArgs: "bust= + (new Date()).getTime()
**/
urlArgs?: string;
/**
* Specify the value for the type="" attribute used for script
* tags inserted into the document by RequireJS. Default is
* "text/javascript". To use Firefox's JavasScript 1.8
* features, use "text/javascript;version=1.8".
**/
scriptType?: string;
}
// not sure what to do with this guy
interface RequireModule {
config(): { };
}
interface RequireMap {
prefix: string;
name: string;
parentMap: RequireMap;
url: string;
originalName: string;
fullName: string;
}
interface Require {
// Configure require.js
config(config: RequireConfig): void;
// Start the main app logic.
// Callback is optional.
// Can alternatively use deps and callback.
(modules: string[]): void;
(modules: string[], ready: (...modules: any[]) => void): void;
// Generate URLs from require module
toUrl(module: string): string;
// On Error override
onError(): void;
// Undefine a module
undef(module: string): void;
// Semi-private function, overload in special instance of undef()
onResourceLoad(context: Object, map: RequireMap, depArray: RequireMap[]): void;
}
interface RequireDefine {
/**
* Define Simple Name/Value Pairs
* @config Dictionary of Named/Value pairs for the config.
**/
(config: { [key: string]: any; }): void;
/**
* Define function.
* @func: The function module.
**/
(func: () => any): void;
/**
* Define function with dependencies.
* @deps List of dependencies module IDs.
* @ready Callback function when the dependencies are loaded.
* @deps module dependencies
* @return module definition
**/
(deps: string[], ready: (...deps: any[]) => any): void;
/**
* Define module with simplified CommonJS wrapper.
* @ready
* @require requirejs instance
* @exports exports object
* @module module
* @return module definition
**/
(ready: (require: Require, exports: { [key: string]: any; }, module: RequireModule) => any): void;
/**
* Define a module with a name and dependencies.
* @name The name of the module.
* @deps List of dependencies module IDs.
* @ready Callback function when the dependencies are loaded.
* @deps module dependencies
* @return module definition
**/
(name: string, deps: string[], ready: (...deps: any[]) => any): void;
}
// Ambient declarations for 'require' and 'define'
var require: Require;
var define: RequireDefine;

View File

@@ -1,39 +1,39 @@
/// <reference path="../Definitions/require-2.1.d.ts" />
// this test does not actually reference amd module 'main.ts', create one yourself.
require.config({
baseUrl: '../Definitions',
// Requires versions afaik
paths: {
'jquery': '../Definitions/jquery',
'underscore': '../Definitions/underscore',
'backbone': '../Definitions/backbone'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
}
}
});
// load AMD module main.ts (compiled to main.js)
// and include shims $, _, Backbone
require(['main'], (main, $, _, Backbone) => {
var app = main.AppMain();
app.run();
/// <reference path="../Definitions/require-2.1.d.ts" />
// this test does not actually reference amd module 'main.ts', create one yourself.
require.config({
baseUrl: '../Definitions',
// Requires versions afaik
paths: {
'jquery': '../Definitions/jquery',
'underscore': '../Definitions/underscore',
'backbone': '../Definitions/backbone'
},
shim: {
jquery: {
exports: '$'
},
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
}
}
});
// load AMD module main.ts (compiled to main.js)
// and include shims $, _, Backbone
require(['main'], (main, $, _, Backbone) => {
var app = main.AppMain();
app.run();
});

View File

@@ -1,98 +1,98 @@
// Type definitions for tween.js r7
// Project: https://github.com/sole/tween.js/
// Definitions by: https://github.com/sunetos
// Definitions: https://github.com/borisyankov/DefinitelyTyped
module TWEEN {
export var REVISION: string;
export function getAll(): Tween[];
export function removeAll(): void;
export function add(tween:Tween): void;
export function remove(tween:Tween): void;
export function update(time:number): bool;
export class Tween {
constructor(object?:any);
to(properties:any, duration:number): Tween;
start(time?:number): Tween;
stop(): Tween;
delay(amount:number): Tween;
easing(easing): Tween;
interpolation(interpolation:Function): Tween;
chain(...tweens:Tween[]): Tween;
onStart(callback:Function): Tween;
onUpdate(callback:Function): Tween;
onComplete(callback:Function): Tween;
update(time:number): bool;
};
export var Easing: TweenEasing;
export var Interpolation: TweenInterpolation;
}
interface TweenEasing {
Linear: {
None(k:number): number;
};
Quadratic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Cubic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Quartic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Quintic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Sinusoidal: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Exponential: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Circular: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Elastic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Back: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Bounce: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
}
interface TweenInterpolation {
Linear(v:number[], k:number): number;
Bezier(v:number[], k:number): number;
CatmullRom(v:number[], k:number): number;
Utils: {
Linear(p0:number, p1:number, t:number): number;
Bernstein(n:number, i:number): number;
Factorial(n): number;
};
}
// Type definitions for tween.js r7
// Project: https://github.com/sole/tween.js/
// Definitions by: https://github.com/sunetos
// Definitions: https://github.com/borisyankov/DefinitelyTyped
module TWEEN {
export var REVISION: string;
export function getAll(): Tween[];
export function removeAll(): void;
export function add(tween:Tween): void;
export function remove(tween:Tween): void;
export function update(time:number): bool;
export class Tween {
constructor(object?:any);
to(properties:any, duration:number): Tween;
start(time?:number): Tween;
stop(): Tween;
delay(amount:number): Tween;
easing(easing): Tween;
interpolation(interpolation:Function): Tween;
chain(...tweens:Tween[]): Tween;
onStart(callback:Function): Tween;
onUpdate(callback:Function): Tween;
onComplete(callback:Function): Tween;
update(time:number): bool;
};
export var Easing: TweenEasing;
export var Interpolation: TweenInterpolation;
}
interface TweenEasing {
Linear: {
None(k:number): number;
};
Quadratic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Cubic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Quartic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Quintic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Sinusoidal: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Exponential: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Circular: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Elastic: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Back: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
Bounce: {
In(k:number): number;
Out(k:number): number;
InOut(k:number): number;
};
}
interface TweenInterpolation {
Linear(v:number[], k:number): number;
Bezier(v:number[], k:number): number;
CatmullRom(v:number[], k:number): number;
Utils: {
Linear(p0:number, p1:number, t:number): number;
Bernstein(n:number, i:number): number;
Factorial(n): number;
};
}

View File

@@ -1,97 +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;
}
// 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;
}

View File

@@ -1,58 +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);
/// <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);