diff --git a/package.json b/package.json index 201ae8df2..4b5fe6ac4 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,6 @@ "gulp-util": "3.0.8", "gulp-zip": "5.0.1", "jquery": "^3.5.1", - "knockout": "3.4.2", "knockout-sortable": "1.2.0", "moment": "2.24.0", "node-fs": "0.1.7", diff --git a/tasks/config.js b/tasks/config.js index c15c30181..ee3220873 100644 --- a/tasks/config.js +++ b/tasks/config.js @@ -87,7 +87,7 @@ config.paths.js = { 'vendors/keymaster/keymaster.js', // custom (modified) 'vendors/qr.js/qr.min.js', // fixed (license) 'vendors/bootstrap/js/bootstrap.native.min.js', // fixed - 'node_modules/knockout/build/output/knockout-latest.js', + 'vendors/knockout/build/output/knockout-latest.js', 'node_modules/knockout-sortable/build/knockout-sortable.min.js ', 'node_modules/simplestatemanager/dist/ssm.min.js', 'vendors/lightgallery/dist/js/lightgallery.min.js', // license diff --git a/vendors/knockout/Gruntfile.js b/vendors/knockout/Gruntfile.js new file mode 100644 index 000000000..19e7b561a --- /dev/null +++ b/vendors/knockout/Gruntfile.js @@ -0,0 +1,196 @@ +/*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']); +}; diff --git a/vendors/knockout/LICENSE b/vendors/knockout/LICENSE new file mode 100644 index 000000000..5e71cca12 --- /dev/null +++ b/vendors/knockout/LICENSE @@ -0,0 +1,22 @@ +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. diff --git a/vendors/knockout/README.md b/vendors/knockout/README.md new file mode 100644 index 000000000..137c17846 --- /dev/null +++ b/vendors/knockout/README.md @@ -0,0 +1,59 @@ +# 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 + +[![Join the chat at https://gitter.im/knockout/knockout](https://badges.gitter.im/Join%20Chat.svg)](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) diff --git a/vendors/knockout/build/fragments/source-references.js b/vendors/knockout/build/fragments/source-references.js new file mode 100644 index 000000000..481422c3e --- /dev/null +++ b/vendors/knockout/build/fragments/source-references.js @@ -0,0 +1,60 @@ +knockoutDebugCallback([ + 'src/namespace.js', + 'src/google-closure-compiler-utils.js', + 'src/version.js', + 'src/options.js', + 'src/utils.js', + 'src/utils.domData.js', + 'src/utils.domNodeDisposal.js', + 'src/utils.domManipulation.js', + 'src/memoization.js', + 'src/tasks.js', + 'src/subscribables/extenders.js', + 'src/subscribables/subscribable.js', + 'src/subscribables/dependencyDetection.js', + 'src/subscribables/observable.js', + 'src/subscribables/observableArray.js', + 'src/subscribables/observableArray.changeTracking.js', + 'src/subscribables/dependentObservable.js', + 'src/subscribables/mappingHelpers.js', + 'src/subscribables/observableUtils.js', + 'src/binding/selectExtensions.js', + 'src/binding/expressionRewriting.js', + 'src/virtualElements.js', + 'src/binding/bindingProvider.js', + 'src/binding/bindingAttributeSyntax.js', + 'src/components/loaderRegistry.js', + 'src/components/defaultLoader.js', + 'src/components/customElements.js', + 'src/components/componentBinding.js', + 'src/binding/defaultBindings/attr.js', + 'src/binding/defaultBindings/checked.js', + 'src/binding/defaultBindings/css.js', + 'src/binding/defaultBindings/enableDisable.js', + 'src/binding/defaultBindings/event.js', + 'src/binding/defaultBindings/foreach.js', + 'src/binding/defaultBindings/hasfocus.js', + 'src/binding/defaultBindings/html.js', + 'src/binding/defaultBindings/ifIfnotWith.js', + 'src/binding/defaultBindings/let.js', + 'src/binding/defaultBindings/options.js', + 'src/binding/defaultBindings/selectedOptions.js', + 'src/binding/defaultBindings/style.js', + 'src/binding/defaultBindings/submit.js', + 'src/binding/defaultBindings/text.js', + 'src/binding/defaultBindings/textInput.js', + 'src/binding/defaultBindings/uniqueName.js', + 'src/binding/defaultBindings/using.js', + 'src/binding/defaultBindings/value.js', + 'src/binding/defaultBindings/visibleHidden.js', + // click depends on event - The order matters for specs, which includes each file individually + 'src/binding/defaultBindings/click.js', + 'src/templating/templateEngine.js', + 'src/templating/templateRewriting.js', + 'src/templating/templateSources.js', + 'src/templating/templating.js', + 'src/binding/editDetection/compareArrays.js', + 'src/binding/editDetection/arrayToDomNodeChildren.js', + 'src/templating/native/nativeTemplateEngine.js', + 'src/templating/jquery.tmpl/jqueryTmplTemplateEngine.js' +]); diff --git a/vendors/knockout/package.json b/vendors/knockout/package.json new file mode 100644 index 000000000..761e105d6 --- /dev/null +++ b/vendors/knockout/package.json @@ -0,0 +1,40 @@ +{ + "name": "knockout", + "description": "Knockout makes it easier to create rich, responsive UIs with JavaScript", + "homepage": "http://knockoutjs.com/", + "version": "3.5.1-pre", + "license": "MIT", + "author": "The Knockout.js team", + "main": "build/output/knockout-latest.js", + "types": "build/types/knockout.d.ts", + "scripts": { + "prepublish": "grunt", + "test": "node spec/runner.node.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/knockout/knockout.git" + }, + "bugs": "https://github.com/knockout/knockout/issues", + "testling": { + "preprocess": "build/build.sh", + "html": "spec/runner.html?src=build/output/knockout-latest.js&testling=true", + "browsers": [ + "ie/6..latest", + "chrome/20..latest", + "firefox/3..latest", + "safari/5.0.5..latest", + "opera/11.0..latest", + "iphone/6..latest", + "ipad/6..latest" + ] + }, + "licenses": [ + { "type": "MIT", "url": "http://www.opensource.org/licenses/mit-license.php" } + ], + "devDependencies": { + "grunt": "~0.4.1", + "grunt-cli": "~0.1.0", + "closure-compiler": "~0.2.1" + } +} diff --git a/vendors/knockout/src/binding/bindingAttributeSyntax.js b/vendors/knockout/src/binding/bindingAttributeSyntax.js new file mode 100755 index 000000000..b3effebf2 --- /dev/null +++ b/vendors/knockout/src/binding/bindingAttributeSyntax.js @@ -0,0 +1,608 @@ +(function () { + // Hide or don't minify context properties, see https://github.com/knockout/knockout/issues/2294 + var contextSubscribable = ko.utils.createSymbolOrString('_subscribable'); + var contextAncestorBindingInfo = ko.utils.createSymbolOrString('_ancestorBindingInfo'); + var contextDataDependency = ko.utils.createSymbolOrString('_dataDependency'); + + ko.bindingHandlers = {}; + + // The following element types will not be recursed into during binding. + var bindingDoesNotRecurseIntoElementTypes = { + // Don't want bindings that operate on text nodes to mutate