Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
Updating to M101 deployment.
Browse files Browse the repository at this point in the history
  • Loading branch information
serkan-inci committed Jun 27, 2016
1 parent f4301b6 commit 2e3bde8
Show file tree
Hide file tree
Showing 6 changed files with 1,983 additions and 4,241 deletions.
94 changes: 86 additions & 8 deletions lib/VSS.SDK.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
//----------------------------------------------------------
// Copyright (C) Microsoft Corporation. All rights reserved.
//----------------------------------------------------------
///<reference path='../References/VSS-Common.d.ts' />
///<reference path='../References/VSS.SDK.Interfaces.d.ts' />
///<reference path='../References/SDK.Interfaces.d.ts' />
Expand Down Expand Up @@ -678,8 +681,16 @@ var VSS;
var isReady = false;
var readyCallbacks;
var parentChannel = XDM.XDMChannelManager.get().addChannel(window.parent);
var shimmedLocalStorage;
var hostReadyForShimUpdates = false;
var Storage = (function () {
function Storage() {
var changeCallback;
function invokeChangeCallback() {
if (changeCallback) {
changeCallback.call(this);
}
}
function Storage(changeCallback) {
}
Object.defineProperties(Storage.prototype, {
getItem: {
Expand All @@ -693,23 +704,37 @@ var VSS;
setItem: {
get: function () {
return function (key, value) {
this["" + key] = "" + value;
key = "" + key;
var existingValue = this[key];
var newValue = "" + value;
if (existingValue !== newValue) {
this[key] = newValue;
invokeChangeCallback();
}
};
}
},
removeItem: {
get: function () {
return function (key) {
delete this["" + key];
key = "" + key;
if (typeof this[key] !== "undefined") {
delete this[key];
invokeChangeCallback();
}
};
}
},
clear: {
get: function () {
return function () {
for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
var key = _a[_i];
delete this[key];
var keys = Object.keys(this);
if (keys.length > 0) {
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
var key = keys_1[_i];
delete this[key];
}
invokeChangeCallback();
}
};
}
Expand All @@ -720,11 +745,26 @@ var VSS;
return Object.keys(this)[index];
};
}
},
length: {
get: function () {
return Object.keys(this).length;
}
}
});
return Storage;
}());
function shimSandboxedProperties() {
var updateSettingsTimeout;
function updateShimmedStorageCallback() {
// Talk to the host frame on a 50 ms delay in order to batch storage/cookie updates
if (!updateSettingsTimeout) {
updateSettingsTimeout = setTimeout(function () {
updateSettingsTimeout = 0;
updateHostSandboxedStorage();
}, 50);
}
}
// Override document.cookie if it is not available
var hasCookieSupport = false;
try {
Expand All @@ -750,7 +790,8 @@ var VSS;
}
if (!hasLocalStorage) {
delete window.localStorage;
Object.defineProperty(window, "localStorage", { value: new Storage() });
shimmedLocalStorage = new Storage(updateShimmedStorageCallback);
Object.defineProperty(window, "localStorage", { value: shimmedLocalStorage });
delete window.sessionStorage;
Object.defineProperty(window, "sessionStorage", { value: new Storage() });
}
Expand Down Expand Up @@ -808,6 +849,37 @@ var VSS;
initialConfiguration = handshakeData.initialConfig || {};
initialContribution = handshakeData.contribution;
extensionContext = handshakeData.extensionContext;
if (handshakeData.sandboxedStorage) {
var updateNeeded = false;
if (shimmedLocalStorage) {
if (handshakeData.sandboxedStorage.localStorage) {
// Merge host data in with any values already set.
var newData = handshakeData.sandboxedStorage.localStorage;
// Check for any properties written prior to the initial handshake
for (var _i = 0, _a = Object.keys(shimmedLocalStorage); _i < _a.length; _i++) {
var key = _a[_i];
var value = shimmedLocalStorage.getItem(key);
if (value !== newData[key]) {
newData[key] = value;
updateNeeded = true;
}
}
// Update the stored values
for (var _b = 0, _c = Object.keys(newData); _b < _c.length; _b++) {
var key = _c[_b];
shimmedLocalStorage.setItem(key, newData[key]);
}
}
else if (shimmedLocalStorage.length > 0) {
updateNeeded = true;
}
}
hostReadyForShimUpdates = true;
if (updateNeeded) {
// Talk to host frame to issue update
updateHostSandboxedStorage();
}
}
if (usingPlatformScripts || usingPlatformStyles) {
setupAmdLoader();
}
Expand All @@ -818,6 +890,12 @@ var VSS;
}, 0);
}
VSS.init = init;
function updateHostSandboxedStorage() {
var storage = {
localStorage: JSON.stringify(shimmedLocalStorage || {})
};
parentChannel.invokeRemoteMethod("updateSandboxedStorage", "VSS.HostControl", [storage]);
}
/**
* Ensures that the AMD loader from the host is configured and fetches a script (AMD) module
* (and its dependencies). If no callback is supplied, this will still perform an asynchronous
Expand Down Expand Up @@ -1300,4 +1378,4 @@ var VSS;
}
}
})(VSS || (VSS = {}));
//# sourceMappingURL=VSS.SDK.js.map
//dependencies=
Loading

0 comments on commit 2e3bde8

Please sign in to comment.