Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Commit 923bf83

Browse files
Fixing stuff
2 parents 7f118a4 + 62f5238 commit 923bf83

294 files changed

Lines changed: 43445 additions & 1853 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Gruntfile.js

Lines changed: 153 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2541,6 +2541,156 @@ module.exports = function (grunt) {
25412541
'nuget-time',
25422542
'nuget-virtualtime'
25432543
]);
2544+
2545+
2546+
2547+
grunt.registerTask('rebuild-ts', 'Rebuild typescript declarations', function() {
2548+
var path = require('path');
2549+
var fs = require('fs');
2550+
2551+
var cache = {};
2552+
var dependencies = {};
2553+
var concatItems = grunt.config.get('concat');
2554+
2555+
function loadFile(tsFile) {
2556+
if (cache[tsFile]) {
2557+
return;
2558+
}
2559+
var dependencyRegex = /\/\/\/ <reference path\=\"(.*?)\" \/>/g;
2560+
var c; //, count = 0;
2561+
var source = grunt.file.read(tsFile);
2562+
2563+
// source with tests
2564+
var s = source.match(/module Rx \{([\s\S]*)\}[\s\S]*\(function/);
2565+
if (s && s[1]) {
2566+
c = cache[tsFile] = s[1];
2567+
}
2568+
if (!s) {
2569+
// source without tests
2570+
s = source.match(/module Rx \{([\s\S]*)\}/);
2571+
if (s && s[1]) {
2572+
c = cache[tsFile] = s[1];
2573+
}
2574+
}
2575+
2576+
var deps = dependencies[tsFile] = [];
2577+
var result;
2578+
while (result = dependencyRegex.exec(source)) {
2579+
var dep = path.resolve(__dirname, path.dirname(tsFile), result[1])
2580+
.substr(__dirname.length + 1)
2581+
.replace(/\\/g, '/');
2582+
2583+
deps.push(dep);
2584+
loadFile(dep);
2585+
}
2586+
2587+
return c;
2588+
}
2589+
2590+
function addLoadedFile(tsFile) {
2591+
if (loadedFiles[tsFile]) {
2592+
return;
2593+
}
2594+
2595+
if (!(tsFile.match(/\/toset\.ts$/) || tsFile.match(/\/tomap\.ts$/))) {
2596+
output.push(cache[tsFile]);
2597+
}
2598+
es6Output.push(cache[tsFile]);
2599+
loadedFiles[tsFile] = true;
2600+
}
2601+
2602+
function addFileContent(tsFile) {
2603+
if (loadedFiles[tsFile]) {
2604+
return;
2605+
}
2606+
2607+
var deps = dependencies[tsFile];
2608+
for (var k = 0; k < deps.length; k++) {
2609+
addLoadedFile(deps[k]);
2610+
addFileContent(deps[k]);
2611+
}
2612+
2613+
addLoadedFile(tsFile);
2614+
}
2615+
2616+
loadFile('ts/core/es5.ts');
2617+
loadFile('ts/core/es6.ts');
2618+
2619+
for (var key in concatItems) {
2620+
var loadedFiles = {};
2621+
var output = [];
2622+
var es6Output = [];
2623+
var value = concatItems[key];
2624+
var src = value.src;
2625+
var dest = value.dest;
2626+
2627+
var dist = false;
2628+
2629+
if (key.indexOf('-compat') > -1) {
2630+
continue;
2631+
}
2632+
2633+
if (dest.indexOf('dist/') === 0) {
2634+
dist = dest.match(/dist\/(.*?)\.js/)[1];
2635+
dest = dest.replace(/dist\/(.*?)\.js/, 'ts/$1.d.ts');
2636+
} else if (dest.indexOf('modules/') === 0) {
2637+
continue;
2638+
} else {
2639+
throw new Error("not sure how to handle " + dest);
2640+
}
2641+
2642+
for (var i = 0; i < src.length; i++) {
2643+
var file = src[i];
2644+
var tsFile = file
2645+
.replace(/src\/(.*?).js/, 'ts/$1.ts')
2646+
// Is this right 100% of the time?
2647+
.replace('perf/operators', 'linq/observable');
2648+
2649+
if (cache[tsFile] || fs.existsSync(tsFile)) {
2650+
if (!cache[tsFile]) {
2651+
loadFile(tsFile);
2652+
}
2653+
2654+
if (tsFile.indexOf('/es5') === -1 || tsFile.indexOf('/es6') === -1) {
2655+
addFileContent(tsFile);
2656+
}
2657+
} else {
2658+
var valid = ['/headers/', '/longstacktraces/', '/internal/', '/autodetachobserver', '/subjects/innersubscription', '/perf/observablebase', 'linq/enumerable/while', '.compat.', 'linq/observable/_', '/linq/observable/fromarrayobservable', '/joins/', '/linq/observable/flatmapbase', '/disposables/scheduleddisposable', '/concurrency/catchscheduler', '/core/observeonobserver', '/testing/mockpromise', '/testing/hotobservable', '/testing/coldobservable'];
2659+
var validResult = false;
2660+
for (var z = 0; z < valid.length; z++) {
2661+
if (tsFile.indexOf(valid[z]) !== -1) {
2662+
validResult = true;
2663+
break;
2664+
}
2665+
}
2666+
2667+
if (!validResult) {
2668+
console.log('missing file: ' + tsFile);
2669+
}
2670+
}
2671+
}
2672+
2673+
output.unshift(cache['ts/core/es5.ts']);
2674+
es6Output.unshift(cache['ts/core/es6.ts']);
2675+
2676+
var outputString = 'declare module Rx {\n' + output.join('') + '\n}\n';
2677+
outputString += '\ndeclare module "rx" { export = Rx; }\n';
2678+
if (dist) {
2679+
outputString += 'declare module "'+dist+'" { export = Rx; }';
2680+
}
2681+
grunt.file.write(dest, outputString);
2682+
2683+
outputString = 'declare module Rx {\n' + es6Output.join('') + '\n}\n';
2684+
outputString += '\ndeclare module "rx" { export = Rx; }\n';
2685+
if (dist) {
2686+
outputString += '\ndeclare module "'+dist+'" { export = Rx; }\n';
2687+
}
2688+
grunt.file.write(dest.replace(/^ts\//, 'ts/es6/'), outputString);
2689+
}
2690+
2691+
grunt.file.write('ts/es6/es6-iterable.d.ts', grunt.file.read('ts/core/es6-iterable.d.ts'));
2692+
grunt.file.write('ts/es6/es6-promise.d.ts', grunt.file.read('ts/core/es6-promise.d.ts'));
2693+
});
25442694

25452695
grunt.registerTask('concat-min', [
25462696
'concat:core',
@@ -2633,7 +2783,7 @@ module.exports = function (grunt) {
26332783
'copy:lite-extras-compat',
26342784
'copy:core',
26352785
'copy:core-binding',
2636-
'copy:core-testing',
2786+
'copy:core-testing'
26372787
]);
26382788

26392789
// Default task
@@ -2730,6 +2880,7 @@ module.exports = function (grunt) {
27302880
'copy:core-binding',
27312881
'copy:core-testing',
27322882

2733-
'qunit'
2883+
'qunit',
2884+
'rebuild-ts'
27342885
]);
27352886
};

dist/rx.all.compat.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6289,7 +6289,16 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
62896289
}, source);
62906290
};
62916291

6292-
var spawn = Observable.spawn = function () {
6292+
var wrap = Observable.wrap = function (fn) {
6293+
createObservable.__generatorFunction__ = fn;
6294+
return createObservable;
6295+
6296+
function createObservable() {
6297+
return Observable.spawn.call(this, fn.apply(this, arguments));
6298+
}
6299+
};
6300+
6301+
var spawn = Observable.spawn = function () {
62936302
var gen = arguments[0], self = this, args = [];
62946303
for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
62956304

@@ -6320,6 +6329,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
63206329
if (ret.done) {
63216330
o.onNext(ret.value);
63226331
o.onCompleted();
6332+
return;
63236333
}
63246334
var value = toObservable.call(self, ret.value);
63256335
if (Observable.isObservable(value)) {
@@ -6346,7 +6356,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
63466356

63476357
function arrayToObservable (obj) {
63486358
return Observable.from(obj)
6349-
.map(toObservable, this)
6359+
.flatMap(toObservable)
63506360
.toArray();
63516361
}
63526362

dist/rx.all.compat.map

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

dist/rx.all.compat.map.orig

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

dist/rx.all.compat.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/rx.all.compat.min.js.orig

Lines changed: 12 additions & 0 deletions
Large diffs are not rendered by default.

dist/rx.all.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6187,7 +6187,16 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
61876187
}, source);
61886188
};
61896189

6190-
var spawn = Observable.spawn = function () {
6190+
var wrap = Observable.wrap = function (fn) {
6191+
createObservable.__generatorFunction__ = fn;
6192+
return createObservable;
6193+
6194+
function createObservable() {
6195+
return Observable.spawn.call(this, fn.apply(this, arguments));
6196+
}
6197+
};
6198+
6199+
var spawn = Observable.spawn = function () {
61916200
var gen = arguments[0], self = this, args = [];
61926201
for (var i = 1, len = arguments.length; i < len; i++) { args.push(arguments[i]); }
61936202

@@ -6218,6 +6227,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
62186227
if (ret.done) {
62196228
o.onNext(ret.value);
62206229
o.onCompleted();
6230+
return;
62216231
}
62226232
var value = toObservable.call(self, ret.value);
62236233
if (Observable.isObservable(value)) {
@@ -6244,7 +6254,7 @@ Rx.Observable.prototype.flatMapLatest = function(selector, resultSelector, thisA
62446254

62456255
function arrayToObservable (obj) {
62466256
return Observable.from(obj)
6247-
.map(toObservable, this)
6257+
.flatMap(toObservable)
62486258
.toArray();
62496259
}
62506260

dist/rx.all.map

Lines changed: 5 additions & 1 deletion
Large diffs are not rendered by default.

dist/rx.all.map.orig

Lines changed: 5 additions & 0 deletions
Large diffs are not rendered by default.

dist/rx.all.min.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)