Commit eebb9918 authored by Boris Kocherov's avatar Boris Kocherov

add sdk_async_loader

parent c2a3beca
......@@ -356,9 +356,33 @@ DocsAPI.DocEditor.version = function() {
'Common.Controllers.Comments',
'Common.Controllers.Plugins'
];
define("sdk_files", [], function () {
return [
"../common/browser.js",
"../common/commonDefines.js",
"../common/docscoapicommon.js",
"../common/docscoapi.js",
"../common/apiCommon.js",
"../common/SerializeCommonWordExcel.js",
"../common/editorscommon.js",
"../common/HistoryCommon.js",
"../common/TableId.js",
"../common/TableIdChanges.js",
"../common/AdvancedOptions.js",
"../cell/apiDefines.js",
"../cell/utils/utils.js",
"../cell/view/HandlerList.js",
"../cell/model/CollaborativeEditing.js",
"../common/apiBase.js",
"../common/Private/license.js",
"../word/apiCommon.js",
"../cell/api.js",
"../common/Local/license.js",
"../common/Local/jio.js"
];
});
styles = [
// sdk changed to sdk/Excel/sdk-all
'css!sdk/../css/main.css',
'css!../sdkjs/cell/css/main.css',
'css!spreadsheeteditor/main/resources/css/app.css'
];
break;
......@@ -382,6 +406,33 @@ DocsAPI.DocEditor.version = function() {
'Common.Controllers.ExternalMergeEditor',
'Common.Controllers.ReviewChanges'
];
define("sdk_files", [], function () {
return [
"../common/browser.js",
"../common/commonDefines.js",
"../common/docscoapicommon.js",
"../common/docscoapi.js",
"../common/spellcheckapi.js",
"../common/spellCheckLanguage.js",
"../common/spellCheckLanguagesAll.js",
"../common/apiCommon.js",
"../common/SerializeCommonWordExcel.js",
"../common/editorscommon.js",
"../common/HistoryCommon.js",
"../common/TableId.js",
"../common/TableIdChanges.js",
"../common/AdvancedOptions.js",
"../word/apiDefines.js",
"../common/CollaborativeEditingBase.js",
"../word/Editor/CollaborativeEditing.js",
"../common/apiBase.js",
"../common/Private/license.js",
"../word/apiCommon.js",
"../word/api.js",
"../common/Local/license.js",
"../common/Local/jio.js"
];
});
styles = [
'css!documenteditor/main/resources/css/app.css'
];
......@@ -402,6 +453,31 @@ DocsAPI.DocEditor.version = function() {
'Common.Controllers.Comments',
'Common.Controllers.ExternalDiagramEditor'
];
define("sdk_files", [], function () {
return [
"../common/browser.js",
"../common/commonDefines.js",
"../common/docscoapicommon.js",
"../common/docscoapi.js",
"../common/apiCommon.js",
"../common/SerializeCommonWordExcel.js",
"../common/editorscommon.js",
"../common/HistoryCommon.js",
"../common/TableId.js",
"../common/TableIdChanges.js",
"../common/AdvancedOptions.js",
"../slide/apiDefines.js",
"../common/CollaborativeEditingBase.js",
"../slide/Editor/CollaborativeEditing.js",
"../common/apiBase.js",
"../common/Private/license.js",
"../word/apiCommon.js",
"../slide/api.js",
"../common/Local/license.js",
"../common/Local/empty_slide.js",
"../common/Local/jio.js"
];
});
styles = [
'css!presentationeditor/main/resources/css/app.css'
];
......@@ -409,6 +485,10 @@ DocsAPI.DocEditor.version = function() {
}
Common.Gateway = g;
define("sdk", [
"promise!sdk_async_loader"
], function () {
});
require.config({
baseUrl: "apps/",
waitSeconds: 360,
......@@ -418,6 +498,7 @@ DocsAPI.DocEditor.version = function() {
backbone: '../vendor/backbone/backbone',
bootstrap: '../vendor/bootstrap/dist/js/bootstrap',
text: '../vendor/requirejs-text/text',
promise: '../vendor/requirejs-promise/requirejs-promise',
perfectscrollbar: 'common/main/lib/mods/perfect-scrollbar',
jmousewheel: '../vendor/perfect-scrollbar/src/jquery.mousewheel',
xregexp: '../vendor/xregexp/xregexp-all-min',
......@@ -425,7 +506,6 @@ DocsAPI.DocEditor.version = function() {
jsziputils: '../vendor/jszip-utils/jszip-utils.min',
jsrsasign: '../vendor/jsrsasign/jsrsasign-latest-all-min',
allfonts: '../fonts/AllFonts',
sdk: '../sdkjs/' + sdkPath + '/sdk-all-min',
api: 'api/documents/api',
core: 'common/main/lib/core/application',
notification: 'common/main/lib/core/NotificationCenter',
......@@ -468,17 +548,6 @@ DocsAPI.DocEditor.version = function() {
'notification',
'irregularstack'
]
},
sdk: {
deps: [
'jquery',
'underscore',
'allfonts',
'xregexp',
'sockjs',
'jsziputils',
'jsrsasign'
]
}
}
});
......
/*global window, rJS, RSVP, DocsAPI, console, document,
Common, require, jIO, URL, FileReader, atob, ArrayBuffer,
Uint8Array, XMLHttpRequest, Blob, Rusha*/
"use strict";
define([
'sdk_files',
'jquery',
'underscore',
'allfonts',
'xregexp',
'sockjs',
'jsziputils',
'jsrsasign'
], function (urls) {
var script_src = "",
queue = new RSVP.Queue();
function loadScript(src) {
return new RSVP.Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
urls.forEach(function (url) {
url = url.replace('../', './sdkjs/');
queue
.push(function () {
return jIO.util.ajax({
type: "GET",
url: url
});
})
.push(function (result) {
script_src += "\n" + result.target.response;
});
});
queue.push(function () {
var url = URL.createObjectURL(new Blob([script_src], {type: "text/javascript"}));
return loadScript(url);
}).push(undefined, function (error) {
console.log(error);
});
return queue;
});
......@@ -10,6 +10,7 @@
"prefix": "onlyoffice/",
"paths": [
"apps/css.js",
"apps/sdk_async_loader.js",
"apps/common/Analytics.js",
"apps/common/IrregularStack.js",
"apps/common/locale.js",
......@@ -31,7 +32,8 @@
"vendor/sockjs/sockjs.min.js",
"vendor/underscore/underscore.js",
"vendor/xregexp/xregexp-all-min.js",
"vendor/xmla4js/Xmla.js"
"vendor/xmla4js/Xmla.js",
"vendor/requirejs-promise/requirejs-promise.js"
]
},
{
......
/*! see LICENCE for Simplified BSD Licence */
/*jslint browser:true, indent:2*/
/*global define, require*/ // Require.JS
/*global Promise*/ // ES6 native Promise
define(function () {
'use strict';
var isPromise;
isPromise = function (obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
if (window.Promise && obj instanceof Promise) {
return true;
}
return typeof obj.then === 'function';
};
return {
/**
* @param {String} name This is the name of the desired resource module.
* @param {Function} req Provides a "require" to load other modules.
* @param {Function} load Pass the module's result to this function.
* @param {Object} config Provides the optimizer's configuration.
*/
load: function (name, req, load) { // , config
// TODO: check config.isBuild\
// TODO: call load.fromText() if necessary to eval JavaScript text
req([name], function (result) {
var onReject, onResolve, complete;
onReject = function () {
load.error.apply(null, arguments);
};
onResolve = function () {
load.apply(null, arguments);
};
if (isPromise(result)) {
// If the promise supports "done" (not all do), we want to use that to
// terminate the promise chain and expose any exceptions.
complete = result.done || result.then;
if (typeof result.fail === 'function') {
complete.call(result, onResolve);
result.fail(onReject);
} else {
// native Promises don't have `fail` (thanks @nfeldman)
complete.call(result, onResolve, onReject);
}
} else {
load(result);
}
});
}/*,
write: function () {
// TODO: what needs to be done for write() ??
}, */
/* pluginBuilder: function () {
// TODO: what needs to be done for pluginBuilder() ??
} */
/*
* Note: we explicitly do NOT implement normalize(), as the simpler
* default implementation is sufficient for current use cases.
*/
};
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment