Skip to content

Commit 525ddde

Browse files
committed
Added logic to optimize localizer file loading for ABS.
1 parent d374702 commit 525ddde

Some content is hidden

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

57 files changed

+409
-166
lines changed

Node/core/lib/Channel.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
exports.channels = {
34
facebook: 'facebook',
45
skype: 'skype',

Node/core/lib/DefaultLocalizer.js

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
var Library_1 = require("./bots/Library");
24
var logger = require("./logger");
35
var consts = require("./consts");
46
var fs = require("fs");
@@ -19,11 +21,12 @@ var DefaultLocalizer = (function () {
1921
addPaths(child);
2022
});
2123
var path = library.localePath();
22-
if (path) {
24+
if (path && fs.existsSync(path)) {
2325
_that.localePaths.push(path);
2426
}
2527
}
2628
}
29+
libsSeen[Library_1.systemLib.name] = true;
2730
addPaths(root);
2831
}
2932
DefaultLocalizer.prototype.defaultLocale = function (locale) {
@@ -99,20 +102,17 @@ var DefaultLocalizer = (function () {
99102
};
100103
DefaultLocalizer.prototype.loadLocale = function (locale) {
101104
var _this = this;
105+
var asyncEachSeries = Promise.denodeify(async.eachSeries);
102106
if (!this.locales.hasOwnProperty(locale)) {
103107
var entry;
104108
this.locales[locale] = entry = { loaded: null, entries: {} };
105109
entry.loaded = new Promise(function (resolve, reject) {
106-
async.eachSeries(_this.localePaths, function (path, cb) {
107-
_this.loadLocalePath(locale, path).done(function () { return cb(); }, function (err) { return cb(err); });
108-
}, function (err) {
109-
if (err) {
110-
reject(err);
111-
}
112-
else {
113-
resolve(true);
114-
}
115-
});
110+
_this.loadSystemResources(locale)
111+
.then(function () {
112+
return asyncEachSeries(_this.localePaths, function (localePath, cb) {
113+
_this.loadLocalePath(locale, localePath).done(function () { return cb(); }, function (err) { return cb(err); });
114+
});
115+
}).done(function () { return resolve(true); }, function (err) { return reject(err); });
116116
});
117117
}
118118
return this.locales[locale].loaded;
@@ -192,6 +192,29 @@ var DefaultLocalizer = (function () {
192192
});
193193
});
194194
};
195+
DefaultLocalizer.prototype.loadSystemResources = function (locale) {
196+
var _this = this;
197+
return new Promise(function (resolve, reject) {
198+
var access = Promise.denodeify(fs.access);
199+
var dir = path.join(Library_1.systemLib.localePath(), locale);
200+
var filename = Library_1.systemLib.name + '.json';
201+
var filepath = path.join(dir, filename);
202+
access(filepath)
203+
.then(function () {
204+
return _this.parseFile(locale, dir, filename);
205+
})
206+
.done(function (count) { return resolve(count); }, function (err) {
207+
if (err.code === 'ENOENT') {
208+
logger.debug("localizer.loadSystemResources(%s) - Couldn't find file: %s", locale, filepath);
209+
resolve(-1);
210+
}
211+
else {
212+
logger.error('localizer.loadSystemResources(%s) - Error: %s', locale, err.toString());
213+
reject(err);
214+
}
215+
});
216+
});
217+
};
195218
DefaultLocalizer.prototype.createKey = function (ns, msgid) {
196219
var escapedMsgId = this.escapeKey(msgid);
197220
var prepend = "";

Node/core/lib/Message.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var HeroCard_1 = require("./cards/HeroCard");
34
var CardImage_1 = require("./cards/CardImage");
45
var CardAction_1 = require("./cards/CardAction");

Node/core/lib/RemoteSessionLogger.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var SessionLogger_1 = require("./SessionLogger");
814
var RemoteSessionLogger = (function (_super) {
915
__extends(RemoteSessionLogger, _super);

Node/core/lib/Session.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var Dialog_1 = require("./dialogs/Dialog");
814
var Message_1 = require("./Message");
915
var consts = require("./consts");
@@ -402,6 +408,7 @@ var Session = (function (_super) {
402408
var _this = this;
403409
this.logger.log(this.dialogStack(), 'Session.sendBatch() sending ' + this.batch.length + ' message(s)');
404410
if (this.sendingBatch) {
411+
this.batchStarted = true;
405412
return;
406413
}
407414
if (this.batchTimer) {

Node/core/lib/SessionLogger.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var logger = require("./logger");
34
var SessionLogger = (function () {
45
function SessionLogger() {

Node/core/lib/botbuilder.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Session_1 = require("./Session");
34
exports.Session = Session_1.Session;
45
var Message_1 = require("./Message");

Node/core/lib/bots/ChatConnector.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var OpenIdMetadata_1 = require("./OpenIdMetadata");
34
var utils = require("../utils");
45
var logger = require("../logger");

Node/core/lib/bots/ConsoleConnector.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Message_1 = require("../Message");
34
var utils = require("../utils");
45
var readline = require("readline");
@@ -70,6 +71,7 @@ var ConsoleConnector = (function () {
7071
var adr = utils.clone(msg.address);
7172
adr.id = idx.toString();
7273
addresses.push(adr);
74+
cb(null);
7375
}
7476
else {
7577
cb(null);

Node/core/lib/bots/Library.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var WaterfallDialog_1 = require("../dialogs/WaterfallDialog");
814
var ActionSet_1 = require("../dialogs/ActionSet");
915
var IntentRecognizerSet_1 = require("../dialogs/IntentRecognizerSet");

Node/core/lib/bots/OpenIdMetadata.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var logger = require("../logger");
34
var request = require("request");
45
var getPem = require('rsa-pem-from-mod-exp');

Node/core/lib/bots/UniversalBot.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var Library_1 = require("./Library");
814
var Session_1 = require("../Session");
915
var DefaultLocalizer_1 = require("../DefaultLocalizer");

Node/core/lib/cards/AnimationCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var MediaCard_1 = require("./MediaCard");
814
var AnimationCard = (function (_super) {
915
__extends(AnimationCard, _super);

Node/core/lib/cards/AudioCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var MediaCard_1 = require("./MediaCard");
814
var AudioCard = (function (_super) {
915
__extends(AudioCard, _super);

Node/core/lib/cards/CardAction.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Message_1 = require("../Message");
34
var CardAction = (function () {
45
function CardAction(session) {

Node/core/lib/cards/CardImage.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Message_1 = require("../Message");
34
var CardImage = (function () {
45
function CardImage(session) {

Node/core/lib/cards/CardMedia.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var CardMedia = (function () {
34
function CardMedia(session) {
45
this.session = session;

Node/core/lib/cards/HeroCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var ThumbnailCard_1 = require("./ThumbnailCard");
814
var HeroCard = (function (_super) {
915
__extends(HeroCard, _super);

Node/core/lib/cards/Keyboard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Keyboard = (function () {
34
function Keyboard(session) {
45
this.session = session;

Node/core/lib/cards/MediaCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var Message_1 = require("../Message");
814
var Keyboard_1 = require("./Keyboard");
915
var MediaCard = (function (_super) {

Node/core/lib/cards/ReceiptCard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Message_1 = require("../Message");
34
var ReceiptCard = (function () {
45
function ReceiptCard(session) {

Node/core/lib/cards/SigninCard.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var Message_1 = require("../Message");
34
var SigninCard = (function () {
45
function SigninCard(session) {

Node/core/lib/cards/SuggestedActions.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
var SuggestedActions = (function () {
34
function SuggestedActions(session) {
45
this.session = session;

Node/core/lib/cards/ThumbnailCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var Message_1 = require("../Message");
814
var Keyboard_1 = require("./Keyboard");
915
var ThumbnailCard = (function (_super) {

Node/core/lib/cards/VideoCard.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
"use strict";
2-
var __extends = (this && this.__extends) || function (d, b) {
3-
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
4-
function __() { this.constructor = d; }
5-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
6-
};
2+
var __extends = (this && this.__extends) || (function () {
3+
var extendStatics = Object.setPrototypeOf ||
4+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
6+
return function (d, b) {
7+
extendStatics(d, b);
8+
function __() { this.constructor = d; }
9+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
10+
};
11+
})();
12+
Object.defineProperty(exports, "__esModule", { value: true });
713
var Message_1 = require("../Message");
814
var MediaCard_1 = require("./MediaCard");
915
var VideoCard = (function (_super) {

Node/core/lib/consts.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
23
exports.agent = 'botbuilder';
34
exports.messageType = 'message';
45
exports.invokeType = 'invoke';

0 commit comments

Comments
 (0)