pax_global_header 0000666 0000000 0000000 00000000064 13560354627 0014525 g ustar 00root root 0000000 0000000 52 comment=aad712123b2a9f5373d2eeb71cd63227fe5c7bd8
knockout-3.5.1/ 0000775 0000000 0000000 00000000000 13560354627 0013370 5 ustar 00root root 0000000 0000000 knockout-3.5.1/.gitignore 0000664 0000000 0000000 00000000240 13560354627 0015354 0 ustar 00root root 0000000 0000000 *.suo
*.swp
*.csproj.user
bin
obj
*.pdb
_ReSharper*
*.ReSharper.user
*.ReSharper
desktop.ini
.eprj
perf/*
*.orig
*.bak
.DS_Store
npm-debug.log
node_modules
dist knockout-3.5.1/.npmignore 0000664 0000000 0000000 00000000317 13560354627 0015370 0 ustar 00root root 0000000 0000000 # Only package the build output for npm. Developers who want sources/tests can get them from the KO repo.
*
!build/output/knockout-latest.js
!build/output/knockout-latest.debug.js
!build/types/knockout.d.ts
knockout-3.5.1/.travis.yml 0000664 0000000 0000000 00000000126 13560354627 0015500 0 ustar 00root root 0000000 0000000 language: node_js
node_js:
- "node"
before_install:
- npm install -g typescript
knockout-3.5.1/Gruntfile.js 0000664 0000000 0000000 00000015712 13560354627 0015673 0 ustar 00root root 0000000 0000000 /*global module:false*/
module.exports = function(grunt) {
var _ = grunt.util._;
// Project configuration
grunt.initConfig({
// Metadata
pkg: grunt.file.readJSON('package.json'),
fragments: './build/fragments/',
banner: '/*!\n' +
' * Knockout JavaScript library v<%= pkg.version %>\n' +
' * (c) The Knockout.js team - <%= pkg.homepage %>\n' +
' * License: <%= pkg.licenses[0].type %> (<%= pkg.licenses[0].url %>)\n' +
' */\n\n',
checktrailingspaces: {
main: {
src: [
"**/*.{js,html,css,bat,ps1,sh}",
"!build/output/**",
"!node_modules/**"
],
filter: 'isFile'
}
},
build: {
debug: './build/output/knockout-latest.debug.js',
min: './build/output/knockout-latest.js'
},
dist: {
debug: './dist/knockout.debug.js',
min: './dist/knockout.js'
},
test: {
phantomjs: 'spec/runner.phantom.js',
node: 'spec/runner.node.js'
},
testtypes: {
global: "spec/types/global",
module: "spec/types/module"
}
});
grunt.registerTask('clean', 'Clean up output files.', function (target) {
var output = grunt.config('build');
var files = [ output.debug, output.min ];
var options = { force: (target == 'force') };
_.forEach(files, function (file) {
if (grunt.file.exists(file))
grunt.file.delete(file, options);
});
return !this.errorCount;
});
var trailingSpaceRegex = /[ ]$/;
grunt.registerMultiTask('checktrailingspaces', 'checktrailingspaces', function() {
var matches = [];
this.files[0].src.forEach(function(filepath) {
var content = grunt.file.read(filepath),
lines = content.split(/\r*\n/);
lines.forEach(function(line, index) {
if (trailingSpaceRegex.test(line)) {
matches.push([filepath, (index+1), line].join(':'));
}
});
});
if (matches.length) {
grunt.log.error("The following files have trailing spaces that need to be cleaned up:");
grunt.log.writeln(matches.join('\n'));
return false;
}
});
function getReferencedSources(sourceReferencesFilename) {
// Returns the array of filenames referenced by a file like source-references.js
var result;
global.knockoutDebugCallback = function(sources) { result = sources; };
eval(grunt.file.read(sourceReferencesFilename));
return result;
}
function getCombinedSources() {
var fragments = grunt.config('fragments'),
sourceFilenames = [
fragments + 'extern-pre.js',
fragments + 'amd-pre.js',
getReferencedSources(fragments + 'source-references.js'),
fragments + 'amd-post.js',
fragments + 'extern-post.js'
],
flattenedSourceFilenames = Array.prototype.concat.apply([], sourceFilenames),
combinedSources = flattenedSourceFilenames.map(function(filename) {
return grunt.file.read('./' + filename);
}).join('');
return combinedSources.replace('##VERSION##', grunt.config('pkg.version'));
}
function buildDebug(output) {
var source = [];
source.push(grunt.config('banner'));
source.push('(function(){\n');
source.push('var DEBUG=true;\n');
source.push(getCombinedSources());
source.push('})();\n');
grunt.file.write(output, source.join('').replace(/\r\n/g, '\n'));
}
function buildMin(output, done) {
var cc = require('closure-compiler');
var options = {
compilation_level: 'ADVANCED_OPTIMIZATIONS',
output_wrapper: '(function() {%output%})();'
};
grunt.log.write('Compiling...');
cc.compile('/**@const*/var DEBUG=false;' + getCombinedSources(), options, function (err, stdout, stderr) {
if (err) {
grunt.log.error(err);
done(false);
} else {
grunt.log.ok();
grunt.file.write(output, (grunt.config('banner') + stdout).replace(/\r\n/g, '\n'));
done(true);
}
});
}
grunt.registerMultiTask('build', 'Build', function() {
if (!this.errorCount) {
var output = this.data;
if (this.target === 'debug') {
buildDebug(output);
} else if (this.target === 'min') {
buildMin(output, this.async());
}
}
return !this.errorCount;
});
grunt.registerMultiTask('test', 'Run tests', function () {
var done = this.async();
grunt.util.spawn({ cmd: this.target, args: [this.data] },
function (error, result, code) {
if (code === 127 /*not found*/) {
grunt.verbose.error(result.stderr);
// ignore this error
done(true);
} else {
grunt.log.writeln(result.stdout);
if (error)
grunt.log.error(result.stderr);
done(!error);
}
}
);
});
grunt.registerMultiTask('testtypes', 'Run types tests', function () {
var done = this.async(),
target = this.target;
grunt.util.spawn({ cmd: "tsc", args: ["-p", this.data] },
function (error, result, code) {
grunt.log.writeln(result.stdout);
if (error)
grunt.log.error(result.stderr);
else
grunt.log.ok("Knockout TypeScript " + target + " types validated!");
done(!error);
}
);
});
grunt.registerTask('dist', function() {
var version = grunt.config('pkg.version'),
buildConfig = grunt.config('build'),
distConfig = grunt.config('dist');
grunt.file.copy(buildConfig.debug, distConfig.debug);
grunt.file.copy(buildConfig.min, distConfig.min);
console.log('To publish, run:');
console.log(' git add bower.json');
console.log(' git add -f ' + distConfig.debug);
console.log(' git add -f ' + distConfig.min);
console.log(' git checkout head');
console.log(' git commit -m \'Version ' + version + ' for distribution\'');
console.log(' git tag -a v' + version + ' -m \'Add tag v' + version + '\'');
console.log(' git checkout master');
console.log(' git push origin --tags');
});
// Default task.
grunt.registerTask('default', ['clean', 'checktrailingspaces', 'build', 'test', 'testtypes']);
};
knockout-3.5.1/LICENSE 0000664 0000000 0000000 00000002265 13560354627 0014402 0 ustar 00root root 0000000 0000000 The MIT License (MIT) - http://www.opensource.org/licenses/mit-license.php
Copyright (c) 2010 Steven Sanderson, the Knockout.js team, and other contributors
http://knockoutjs.com/
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
knockout-3.5.1/README.md 0000664 0000000 0000000 00000005110 13560354627 0014644 0 ustar 00root root 0000000 0000000 # Knockout
**Knockout** is a JavaScript [MVVM](http://en.wikipedia.org/wiki/Model_View_ViewModel) (a modern variant of MVC) library that makes it easier to create rich, desktop-like user interfaces with JavaScript and HTML. It uses *observers* to make your UI automatically stay in sync with an underlying data model, along with a powerful and extensible set of *declarative bindings* to enable productive development.
## Getting started
[](https://gitter.im/knockout/knockout?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
**Totally new to Knockout?** The most fun place to start is the [online interactive tutorials](http://learn.knockoutjs.com/).
For more details, see
* Documentation on [the project's website](http://knockoutjs.com/documentation/introduction.html)
* Online examples at [http://knockoutjs.com/examples/](http://knockoutjs.com/examples/)
## Downloading Knockout
You can [download released versions of Knockout](http://knockoutjs.com/downloads/) from the project's website.
For Node.js developers, Knockout is also available from [npm](https://npmjs.org/) - just run `npm install knockout`.
## Building Knockout from sources
If you prefer to build the library yourself:
1. **Clone the repo from GitHub**
```sh
git clone https://github.com/knockout/knockout.git
cd knockout
```
2. **Acquire build dependencies.**
Make sure you have [Node.js](http://nodejs.org/) installed on your workstation. This is only needed to _build_ Knockout from sources. Knockout itself has no dependency on Node.js once it is built (it works with any server technology or none). Now run:
```sh
npm install -g grunt-cli
npm install
```
The first `npm` command sets up the popular [Grunt](http://gruntjs.com/) build tool. You might need to run this command with `sudo` if you're on Linux or Mac OS X, or in an Administrator command prompt on Windows. The second `npm` command fetches the remaining build dependencies.
3. **Run the build tool**
```sh
grunt
```
Now you'll find the built files in `build/output/`.
## Running the tests
If you have [phantomjs](http://phantomjs.org/download.html) installed, then the `grunt` script will automatically run the specification suite and report its results.
Or, if you want to run the specs in a browser (e.g., for debugging), simply open `spec/runner.html` in your browser.
## License
MIT license - [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php)
knockout-3.5.1/bower.json 0000664 0000000 0000000 00000000674 13560354627 0015410 0 ustar 00root root 0000000 0000000 {
"name": "knockout",
"homepage": "http://knockoutjs.com/",
"description": "Knockout makes it easier to create rich, responsive UIs with JavaScript",
"main": "dist/knockout.js",
"moduleType": [
"amd",
"globals",
"node"
],
"keywords": [
"knockout",
"mvvm",
"mvc",
"spa"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"spec",
"build/output"
]
}
knockout-3.5.1/build/ 0000775 0000000 0000000 00000000000 13560354627 0014467 5 ustar 00root root 0000000 0000000 knockout-3.5.1/build/fragments/ 0000775 0000000 0000000 00000000000 13560354627 0016455 5 ustar 00root root 0000000 0000000 knockout-3.5.1/build/fragments/amd-post.js 0000664 0000000 0000000 00000000005 13560354627 0020532 0 ustar 00root root 0000000 0000000 }));
knockout-3.5.1/build/fragments/amd-pre.js 0000664 0000000 0000000 00000001100 13560354627 0020330 0 ustar 00root root 0000000 0000000 (function(factory) {
// Support three module loading scenarios
if (typeof define === 'function' && define['amd']) {
// [1] AMD anonymous module
define(['exports', 'require'], factory);
} else if (typeof exports === 'object' && typeof module === 'object') {
// [2] CommonJS/Node.js
factory(module['exports'] || exports); // module.exports is for Node.js
} else {
// [3] No module loader (plain ");
};
var buildFolderPath = getPathToScriptTagSrc(debugFileName);
window.knockoutDebugCallback = function (scriptUrls) {
for (var i = 0; i < scriptUrls.length; i++)
referenceScript(buildFolderPath + scriptUrls[i]);
};
referenceScript(buildFolderPath + sourcesReferenceFile);
})();
knockout-3.5.1/build/output/ 0000775 0000000 0000000 00000000000 13560354627 0016027 5 ustar 00root root 0000000 0000000 knockout-3.5.1/build/output/.gitignore 0000664 0000000 0000000 00000000054 13560354627 0020016 0 ustar 00root root 0000000 0000000 knockout-latest.js
knockout-latest.debug.js
knockout-3.5.1/build/output/.npmignore 0000664 0000000 0000000 00000000143 13560354627 0020024 0 ustar 00root root 0000000 0000000 # This file is needed, because otherwise the .gitignore causes npm not to package the build output
knockout-3.5.1/build/types/ 0000775 0000000 0000000 00000000000 13560354627 0015633 5 ustar 00root root 0000000 0000000 knockout-3.5.1/build/types/knockout.d.ts 0000664 0000000 0000000 00000112562 13560354627 0020271 0 ustar 00root root 0000000 0000000 // Type definitions for Knockout v3.5.0
// Project: http://knockoutjs.com
// Definitions by: Maxime LUCE , Michael Best
export as namespace ko;
//#region subscribables/subscribable.js
export type SubscriptionCallback = (this: TTarget, val: T) => void;
export type MaybeSubscribable = T | Subscribable;
export interface Subscription {
dispose(): void;
disposeWhenNodeIsRemoved(node: Node): void;
}
type Flatten = T extends Array ? U : T;
export interface SubscribableFunctions extends Function {
init>(instance: S): void;
notifySubscribers(valueToWrite?: T, event?: string): void;
subscribe(callback: SubscriptionCallback>, TTarget>, callbackTarget: TTarget, event: "arrayChange"): Subscription;
subscribe(callback: SubscriptionCallback, callbackTarget: TTarget, event: "beforeChange" | "spectate" | "awake"): Subscription;
subscribe(callback: SubscriptionCallback, callbackTarget: TTarget, event: "asleep"): Subscription;
subscribe(callback: SubscriptionCallback, callbackTarget?: TTarget, event?: "change"): Subscription;
subscribe(callback: SubscriptionCallback, callbackTarget: TTarget, event: string): Subscription;
extend(requestedExtenders: ObservableExtenderOptions): this;
extend>(requestedExtenders: ObservableExtenderOptions): S;
getSubscriptionsCount(event?: string): number;
}
export interface Subscribable extends SubscribableFunctions { }
export const subscribable: {
new (): Subscribable;
fn: SubscribableFunctions;
};
export function isSubscribable(instance: any): instance is Subscribable;
//#endregion
//#region subscribables/observable.js
export type MaybeObservable = T | Observable;
export interface ObservableFunctions extends Subscribable {
equalityComparer(a: T, b: T): boolean;
peek(): T;
valueHasMutated(): void;
valueWillMutate(): void;
}
export interface Observable extends ObservableFunctions {
(): T;
(value: T): any;
}
export function observable(value: T): Observable;
export function observable(value: null): Observable
/** No initial value provided, so implicitly includes `undefined` as a possible value */
export function observable(): Observable
export module observable {
export const fn: ObservableFunctions;
}
export function isObservable(instance: any): instance is Observable;
export function isWriteableObservable(instance: any): instance is Observable;
export function isWritableObservable(instance: any): instance is Observable;
//#endregion
//#region subscribables/observableArray.js
export type MaybeObservableArray = T[] | ObservableArray;
export interface ObservableArrayFunctions extends ObservableFunctions {
//#region observableArray/generalFunctions
/**
* Returns the index of the first occurrence of a value in an array.
* @param searchElement The value to locate in the array.
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
*/
indexOf(searchElement: T, fromIndex?: number): number;
/**
* Returns a section of an array.
* @param start The beginning of the specified portion of the array.
* @param end The end of the specified portion of the array. If omitted, all items after start are included
*/
slice(start: number, end?: number): T[];
/**
* Removes elements from an array and, if necessary, inserts new elements in their place, returning the deleted elements.
* @param start The zero-based location in the array from which to start removing elements.
* @param deleteCount The number of elements to remove. Defaults to removing everything after `start`
* @param items Elements to insert into the array in place of the deleted elements.
*/
splice(start: number, deleteCount?: number, ...items: T[]): T[];
/**
* Removes the last value from the array and returns it.
*/
pop(): T;
/**
* Adds a new item to the end of array.
* @param items Items to be added
*/
push(...items: T[]): number;
/**
* Removes the first value from the array and returns it.
*/
shift(): T;
/**
* Inserts a new item at the beginning of the array.
* @param items Items to be added
*/
unshift(...items: T[]): number;
/**
* Reverses the order of the array and returns the observableArray.
* Modifies the underlying array.
*/
reverse(): this;
/**
* Sorts the array contents and returns the observableArray.
* Modifies the underlying array.
*/
sort(compareFunction?: (left: T, right: T) => number): this;
//#endregion
//#region observableArray/koSpecificFunctions
/**
* Returns a reversed copy of the array.
* Does not modify the underlying array.
*/
reversed(): T[];
/**
* Returns a reversed copy of the array.
* Does not modify the underlying array.
*/
sorted(compareFunction?: (left: T, right: T) => number): T[];
/**
* Replaces the first value that equals oldItem with newItem
* @param oldItem Item to be replaced
* @param newItem Replacing item
*/
replace(oldItem: T, newItem: T): void;
/**
* Removes all values that equal item and returns them as an array.
* @param item The item to be removed
*/
remove(item: T): T[];
/**
* Removes all values and returns them as an array.
* @param removeFunction A function used to determine true if item should be removed and fasle otherwise
*/
remove(removeFunction: (item: T) => boolean): T[];
/**
* Removes all values and returns them as an array.
*/
removeAll(): T[];
/**
* Removes all values that equal any of the supplied items
* @param items Items to be removed
*/
removeAll(items: T[]): T[];
// Ko specific Usually relevant to Ruby on Rails developers only
/**
* Finds any objects in the array that equal someItem and gives them a special property called _destroy with value true.
* Usually only relevant to Ruby on Rails development
* @param item Items to be marked with the property.
*/
destroy(item: T): void;
/**
* Finds any objects in the array filtered by a function and gives them a special property called _destroy with value true.
* Usually only relevant to Ruby on Rails development
* @param destroyFunction A function used to determine which items should be marked with the property.
*/
destroy(destroyFunction: (item: T) => boolean): void;
/**
* Gives a special property called _destroy with value true to all objects in the array.
* Usually only relevant to Ruby on Rails development
*/
destroyAll(): void;
/**
* Finds any objects in the array that equal supplied items and gives them a special property called _destroy with value true.
* Usually only relevant to Ruby on Rails development
* @param items
*/
destroyAll(items: T[]): void;
//#endregion
}
export interface ObservableArray extends Observable, ObservableArrayFunctions {
(value: T[] | null | undefined): this;
}
export function observableArray(): ObservableArray;
export function observableArray(initialValue: T[]): ObservableArray;
export module observableArray {
export const fn: ObservableArrayFunctions;
}
export function isObservableArray(instance: any): instance is ObservableArray;
//#endregion
//#region subscribables/dependendObservable.js
export type ComputedReadFunction = Subscribable | Observable | Computed | ((this: TTarget) => T);
export type ComputedWriteFunction = (this: TTarget, val: T) => void;
export type MaybeComputed = T | Computed;
export interface ComputedFunctions extends Subscribable {
// It's possible for a to be undefined, since the equalityComparer is run on the initial
// computation with undefined as the first argument. This is user-relevant for deferred computeds.
equalityComparer(a: T | undefined, b: T): boolean;
peek(): T;
dispose(): void;
isActive(): boolean;
getDependenciesCount(): number;
getDependencies(): Subscribable[];
}
export interface Computed extends ComputedFunctions {
(): T;
(value: T): this;
}
export interface PureComputed extends Computed { }
export interface ComputedOptions {
read?: ComputedReadFunction;
write?: ComputedWriteFunction;
owner?: TTarget;
pure?: boolean;
deferEvaluation?: boolean;
disposeWhenNodeIsRemoved?: Node;
disposeWhen?: () => boolean;
}
export function computed(options: ComputedOptions): Computed;
export function computed(evaluator: ComputedReadFunction): Computed;
export function computed(evaluator: ComputedReadFunction, evaluatorTarget: TTarget): Computed;
export function computed(evaluator: ComputedReadFunction, evaluatorTarget: TTarget, options: ComputedOptions): Computed;
export module computed {
export const fn: ComputedFunctions;
}
export function pureComputed(options: ComputedOptions): PureComputed;
export function pureComputed(evaluator: ComputedReadFunction): PureComputed;
export function pureComputed(evaluator: ComputedReadFunction, evaluatorTarget: TTarget): PureComputed;
export function isComputed(instance: any): instance is Computed;
export function isPureComputed(instance: any): instance is PureComputed;
//#endregion
//#region subscribables/dependencyDetection.js
export interface ComputedContext {
getDependenciesCount(): number;
getDependencies(): Subscribable[];
isInitial(): boolean;
registerDependency(subscribable: Subscribable): void;
}
export const computedContext: ComputedContext;
/**
* Executes a function and returns the result, while disabling depdendency tracking
* @param callback - the function to execute without dependency tracking
* @param callbackTarget - the `this` binding for `callback`
* @param callbackArgs - the args to provide to `callback`
*/
export function ignoreDependencies(
callback: (this: Target, ...args: Args) => Return,
callbackTarget?: Target,
callbackArgs?: Args
): Return;
//#endregion
//#region subscribables/extenders.js
export type RateLimitMethod = (callback: () => void, timeout: number, options: any) => (() => void);
export interface RateLimitOptions {
timeout: number;
method?: "notifyAtFixedRate" | "notifyWhenChangesStop" | RateLimitMethod;
[option: string]: any;
}
export interface ExtendersOptions {
trackArrayChanges: true | utils.CompareArraysOptions;
throttle: number;
rateLimit: number | RateLimitOptions;
deferred: true;
notify: "always" | any;
}
export interface Extender {
(target: T, options: O): T;
}
type AsExtenders = { [P in keyof T]: Extender }
export interface Extenders extends AsExtenders> {
[name: string]: Extender;
}
export interface ObservableExtenderOptions extends Partial> { }
export const extenders: Extenders;
//#endregion
//#region subscribables/mappingHelpers.js
type Unwrapped = T extends ko.Subscribable ? R :
T extends Record ? { [P in keyof T]: Unwrapped } : T;
export function toJS(rootObject: T): Unwrapped;
export function toJSON(rootObject: any, replacer?: Function, space?: number): string;
//#endregion
//#region subscribables/observableUtils.js
export function when(predicate: ComputedReadFunction, callback: SubscriptionCallback, context?: TTarget): Subscription;
export function when(predicate: ComputedReadFunction): Promise;
//#endregion
//#region binding/bindingAttributeSyntax.js
export type BindingAccessors = { [name: string]: Function; };
export interface AllBindings {
(): any;
get(name: string): any;
get(name: string): T;
has(name: string): boolean;
}
export type BindingHandlerControlsDescendant = { controlsDescendantBindings: boolean; }
export type BindingHandlerAddBinding = (name: string, value: any) => void;
export interface BindingHandler {
after?: string[];
init?: (element: any, valueAccessor: () => T, allBindings: AllBindings, viewModel: any, bindingContext: BindingContext) => void | BindingHandlerControlsDescendant;
update?: (element: any, valueAccessor: () => T, allBindings: AllBindings, viewModel: any, bindingContext: BindingContext) => void;
options?: any;
preprocess?: (value: string | undefined, name: string, addBinding: BindingHandlerAddBinding) => string | undefined | void;
}
export interface BindingHandlers {
[name: string]: BindingHandler;
}
export interface BindingContext {
ko: any; // typeof ko;
[name: string]: any;
$parent?: any;
$parents: any[];
$root: any;
$data: T;
$rawData: T | Observable;
$index?: Observable;
$parentContext?: BindingContext;
$component?: any;
extend(properties: object): BindingContext;
extend(properties: (self: BindingContext) => object): BindingContext;
createChildContext(dataItem: T | Observable, dataItemAlias?: string, extendCallback?: BindingContextExtendCallback): BindingContext;
createChildContext(accessor: () => T | Observable, dataItemAlias?: string, extendCallback?: BindingContextExtendCallback): BindingContext;
createChildContext(dataItem: T | Observable, options: BindingChildContextOptions): BindingContext;
createChildContext(accessor: () => T | Observable, options: BindingChildContextOptions): BindingContext;
}
export interface BindingChildContextOptions {
as?: string;
extend?: BindingContextExtendCallback;
noChildContext?: boolean;
}
export function applyBindings(bindingContext: T | BindingContext): void;
export function applyBindings(bindingContext: T | BindingContext, rootNode: Node | null, extendCallback?: BindingContextExtendCallback): void;
export function applyBindingsToDescendants(bindingContext: T | BindingContext, rootNode?: Node): void;
export function applyBindingsToNode(node: Node, bindings: object | (() => object), viewModel: T | BindingContext): void;
export function applyBindingAccessorsToNode(node: Node, bindings: BindingAccessors | (() => BindingAccessors), viewModel: T | BindingContext): void;
export function dataFor(node: Node): T;
export function contextFor(node: Node): BindingContext;
export const bindingHandlers: BindingHandlers;
export function getBindingHandler(handler: string): BindingHandler;
export type BindingContextExtendCallback = (self: BindingContext, parentContext: BindingContext | null, dataItem: T) => void;
export module bindingEvent {
export function subscribe(node: Node, event: "childrenComplete" | "descendantsComplete", callback: (node: Node) => void, callbackContext?: any): Subscription;
export function startPossiblyAsyncContentBinding(node: Element, bindingContext: BindingContext): BindingContext;
}
//#endregion
//#region binding/bindingProvider.js
export interface BindingOptions {
valueAccessors?: boolean;
bindingParams?: boolean;
}
export interface IBindingProvider {
nodeHasBindings(node: Node): boolean;
getBindings?(node: Node, bindingContext: BindingContext): object;
getBindingAccessors(node: Node, bindingContext: BindingContext): BindingAccessors;
preprocessNode?(node: Node): Node[] | undefined;
}
export class bindingProvider implements IBindingProvider {
nodeHasBindings(node: Node): boolean;
getBindings(node: Node, bindingContext: BindingContext): object;
getBindingAccessors(node: Node, bindingContext: BindingContext): BindingAccessors;
getBindingsString(node: Node, bindingContext?: BindingContext): string;
parseBindingsString(bindingsString: string, bindingContext: BindingContext, node: Node): object;
parseBindingsString(bindingsString: string, bindingContext: BindingContext, node: Node, options: BindingOptions): object | BindingAccessors;
static instance: IBindingProvider;
}
//#endregion
//#region binding/expressionRewriting.js
export module expressionRewriting {
export interface KeyValue {
key?: string;
value?: string;
unknown?: string;
}
export interface TwoWayBindings {
[name: string]: boolean | string;
}
export const bindingRewriteValidators: any[];
export function parseObjectLiteral(objectLiteralString: string): KeyValue[];
export function preProcessBindings(bindingsString: string, bindingOptions?: BindingOptions): string;
export function preProcessBindings(keyValueArray: KeyValue[], bindingOptions?: BindingOptions): string;
export const _twoWayBindings: TwoWayBindings;
}
//#endregion
//#region binding/selectExtensions.js
export module selectExtensions {
export function readValue(element: HTMLElement): any;
export function writeValue(element: HTMLElement, value?: any, allowUnset?: boolean): void;
}
//#endregion
//#region binding/defaultBindings/
export interface BindingHandlers {
// Controlling text and appearance
visible: {
update(element: HTMLElement, valueAccessor: () => MaybeSubscribable): void;
};
hidden: {
update(element: HTMLElement, valueAccessor: () => MaybeSubscribable): void;
};
text: {
init(): BindingHandlerControlsDescendant;
update(element: Node, valueAccessor: () => MaybeSubscribable): void;
};
html: {
init(): BindingHandlerControlsDescendant;
update(element: Node, valueAccessor: () => MaybeSubscribable): void;
};
class: {
update(element: HTMLElement, valueAccessor: () => MaybeSubscribable): void;
};
css: {
update(element: HTMLElement, valueAccessor: () => MaybeSubscribable): void;
};
style: {
update(element: HTMLElement, valueAccessor: () => MaybeSubscribable