diff --git a/Gruntfile.js b/Gruntfile.js index 0c8efc3..84f4e00 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,7 @@ module.exports = function(grunt) { var banner = [ "<%= pkg.name %> v<%= pkg.version %>", "The MIT License (MIT)", - "Copyright (c) 2015 <%= pkg.author %>" + "Copyright (c) 2016 <%= pkg.author %>" ].join("\n * ").trim(); grunt.initConfig({ diff --git a/dist/ko-reactor.js b/dist/ko-reactor.js index afd8be4..02c49d8 100644 --- a/dist/ko-reactor.js +++ b/dist/ko-reactor.js @@ -1,8 +1,19 @@ // Deep observer plugin for Knockout http://knockoutjs.com/ // (c) Ziad Jeeroburkhan // License: MIT (http://www.opensource.org/licenses/mit-license.php) -// Version 1.3.6 - +// Version 1.3.7 +; (function (factory) { + // CommonJS + if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') { + factory(require('knockout')); + // AMD + } else if (typeof define === 'function' && define.amd) { + define(['knockout'], factory); + // Normal script tag + } else { + factory(window.ko); + } +}(function (ko) { ko.subscribable.fn['watch'] = function (targetOrCallback, options, evaluatorCallback, context) { /// /// Track and manage changes within the chained observable down to any given level. @@ -290,3 +301,5 @@ ko['watch'] = function (target, options, evaluatorCallback, context) { } }; }; + +})); \ No newline at end of file diff --git a/dist/ko-reactor.min.js b/dist/ko-reactor.min.js index 109a6d2..50908c5 100644 --- a/dist/ko-reactor.min.js +++ b/dist/ko-reactor.min.js @@ -1 +1 @@ -ko.subscribable.fn.watch=function(a,b,c,d){var e=typeof a;return"boolean"===e||"undefined"===e?ko.watch(this,{enabled:a!==!1}):"function"!==e||ko.isSubscribable(a)?ko.watch(a,b,c,d||this):ko.watch(this,b||{},a,d||this),this},ko.watch=function(a,b,c,d){function e(h,i,j,k,l,m){if(h&&0!==b.depth&&(-1===b.depth||j.length<(b.depth||1))){if(b.watchedOnly&&!h.watchable&&h!=a)return;if((b.enabled===!1||b.enabled===!0)&&(h.watchable=b.enabled),h.watchable===!1)return;b.seal===!0&&(h.watchable=!1);var n=typeof h;if("object"===n||"function"===n){if(h._watcher===d)return;if(b.hide&&ko.utils.arrayIndexOf(b.hide,h)>-1)return;var o=[].concat(j,i&&i!==a?i:[]);if("function"!==n){if("[object Object]"===Object.prototype.toString.call(h))ko.utils.objectForEach(h,function(a,c){if(c=b.getter?b.getter.call(d,o,h,a):c){if(b.wrap){var f=Object.prototype.toString.call(c);"[object Function]"!==f&&"[object Object]"!==f&&(b.beforeWrap&&b.beforeWrap.call(d,o,h,c)===!1||(c=h[a]="[object Array]"===f?ko.observableArray(c):ko.observable(c)))}b.unloop&&(c._watcher=k?void 0:d);var g=e(c,l?null:h,o,k,null,a);b.tagFields&&void 0===c._fieldName&&(g||"parentsOnly"!==b.tagFields&&"function"==typeof c||"object"==typeof c)&&(c._fieldName=a)}});else if(b.hideArrays!==!0)for(var p=0;p=0;e--)c.change[e]._watcher===d&&c.change[e].dispose();if(c.beforeChange&&(b.mutable||b.oldValues>0))for(var e=c.beforeChange.length-1;e>=0;e--)c.beforeChange[e]._watcher===d&&c.beforeChange[e].dispose();if(c.arrayChange)for(var e=c.arrayChange.length-1;e>=0;e--)c.arrayChange[e]._watcher===d&&c.arrayChange[e].dispose()}function g(a,f,g,h){f?a.subscribe(function(b){ko.utils.arrayForEach(b,function(b){var f=c.call(d,g,a,b);void 0!==f&&d(f),b.moved||setTimeout(function(){e(b.value,h?null:a,g,"deleted"===b.status)},0)})},void 0,"arrayChange")._watcher=d:(a.subscribe(function(){if(a.watchable!==!1){var f=c.call(d,g,a);void 0!==f&&d(f),b.mutable&&"object"==typeof a()&&e(a(),h?null:a,g)}},null,"change")._watcher=d,(b.oldValues>0||b.mutable)&&(a.subscribe(function(c){if(b.oldValues>0){var d=a.oldValues?a.oldValues:a.oldValues=[];for(d.unshift(c);d.length>b.oldValues;)d.pop()}b.mutable&&"object"==typeof c&&e(c,h?null:a,g,!1,!0)},null,"beforeChange")._watcher=d))}"function"==typeof b&&(d=d||c,c=b,b={}),d=d||this;var h;switch(ko.DEBUG||ko.version){case!0:h="_subscriptions";break;case"3.0.0":h="F";break;case"3.1.0":h="H";break;case"3.2.0":h="M";break;case"3.3.0":h="G";break;case"3.4.0":h="K";break;default:throw"Unsupported Knockout version. Only v3.0.0 to v3.4.0 are supported when minified. Current version is "+ko.version}return"function"!=typeof a||ko.isSubscribable(a)?(e(a,null,[]),{dispose:function(){e(a,null,[],!0)}}):ko.computed(a,c,b)};window.foo = "1.3.6"; +!function(a){"function"==typeof require&&"object"==typeof exports&&"object"==typeof module?a(require("knockout")):"function"==typeof define&&define.amd?define(["knockout"],a):a(window.ko)}(function(a){a.subscribable.fn.watch=function(b,c,d,e){var f=typeof b;return"boolean"===f||"undefined"===f?a.watch(this,{enabled:b!==!1}):"function"!==f||a.isSubscribable(b)?a.watch(b,c,d,e||this):a.watch(this,c||{},b,e||this),this},a.watch=function(b,c,d,e){function f(i,j,k,l,m,n){if(i&&0!==c.depth&&(-1===c.depth||k.length<(c.depth||1))){if(c.watchedOnly&&!i.watchable&&i!=b)return;if((c.enabled===!1||c.enabled===!0)&&(i.watchable=c.enabled),i.watchable===!1)return;c.seal===!0&&(i.watchable=!1);var o=typeof i;if("object"===o||"function"===o){if(i._watcher===e)return;if(c.hide&&a.utils.arrayIndexOf(c.hide,i)>-1)return;var p=[].concat(k,j&&j!==b?j:[]);if("function"!==o){if("[object Object]"===Object.prototype.toString.call(i))a.utils.objectForEach(i,function(b,d){if(d=c.getter?c.getter.call(e,p,i,b):d){if(c.wrap){var g=Object.prototype.toString.call(d);"[object Function]"!==g&&"[object Object]"!==g&&(c.beforeWrap&&c.beforeWrap.call(e,p,i,d)===!1||(d=i[b]="[object Array]"===g?a.observableArray(d):a.observable(d)))}c.unloop&&(d._watcher=l?void 0:e);var h=f(d,m?null:i,p,l,null,b);c.tagFields&&void 0===d._fieldName&&(h||"parentsOnly"!==c.tagFields&&"function"==typeof d||"object"==typeof d)&&(d._fieldName=b)}});else if(c.hideArrays!==!0)for(var q=0;q=0;d--)b.change[d]._watcher===e&&b.change[d].dispose();if(b.beforeChange&&(c.mutable||c.oldValues>0))for(var d=b.beforeChange.length-1;d>=0;d--)b.beforeChange[d]._watcher===e&&b.beforeChange[d].dispose();if(b.arrayChange)for(var d=b.arrayChange.length-1;d>=0;d--)b.arrayChange[d]._watcher===e&&b.arrayChange[d].dispose()}function h(b,g,h,i){g?b.subscribe(function(c){a.utils.arrayForEach(c,function(a){var c=d.call(e,h,b,a);void 0!==c&&e(c),a.moved||setTimeout(function(){f(a.value,i?null:b,h,"deleted"===a.status)},0)})},void 0,"arrayChange")._watcher=e:(b.subscribe(function(){if(b.watchable!==!1){var a=d.call(e,h,b);void 0!==a&&e(a),c.mutable&&"object"==typeof b()&&f(b(),i?null:b,h)}},null,"change")._watcher=e,(c.oldValues>0||c.mutable)&&(b.subscribe(function(a){if(c.oldValues>0){var d=b.oldValues?b.oldValues:b.oldValues=[];for(d.unshift(a);d.length>c.oldValues;)d.pop()}c.mutable&&"object"==typeof a&&f(a,i?null:b,h,!1,!0)},null,"beforeChange")._watcher=e))}"function"==typeof c&&(e=e||d,d=c,c={}),e=e||this;var i;switch(a.DEBUG||a.version){case!0:i="_subscriptions";break;case"3.0.0":i="F";break;case"3.1.0":i="H";break;case"3.2.0":i="M";break;case"3.3.0":i="G";break;case"3.4.0":i="K";break;default:throw"Unsupported Knockout version. Only v3.0.0 to v3.4.0 are supported when minified. Current version is "+a.version}return"function"!=typeof b||a.isSubscribable(b)?(f(b,null,[]),{dispose:function(){f(b,null,[],!0)}}):a.computed(b,d,c)}});window.foo = "1.3.7"; \ No newline at end of file diff --git a/package.json b/package.json index dc678a8..5aa805d 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "ko-reactor", "author": "Ziad Jeeroburkhan", - "version": "1.3.6", + "version": "1.3.7", "repository": { "type": "git", "url": "https://github.com/ZiadJ/knockoutjs-reactor.git" diff --git a/src/knockout.reactor.js b/src/knockout.reactor.js index 7316419..02c49d8 100644 --- a/src/knockout.reactor.js +++ b/src/knockout.reactor.js @@ -1,7 +1,7 @@ // Deep observer plugin for Knockout http://knockoutjs.com/ // (c) Ziad Jeeroburkhan // License: MIT (http://www.opensource.org/licenses/mit-license.php) -// Version 1.3.6 +// Version 1.3.7 ; (function (factory) { // CommonJS if (typeof require === 'function' && typeof exports === 'object' && typeof module === 'object') {