1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-26 19:47:20 +00:00

Split module loading into a separate startup task

Still a work in progress.
This commit is contained in:
Jermolene 2014-05-03 17:10:55 +01:00
parent 1c82348edb
commit 749582ede0
5 changed files with 43 additions and 27 deletions

View File

@ -1773,10 +1773,10 @@ $tw.boot.executeNextStartupTask = function() {
};
$tw.boot.isStartupTaskEligible = function(taskModule) {
var dependencies = taskModule.dependencies;
if(dependencies) {
for(var t=0; t<dependencies.length; t++) {
if(!$tw.boot.executedStartupModules[dependencies[t]]) {
var after = taskModule.after;
if(after) {
for(var t=0; t<after.length; t++) {
if(!$tw.boot.executedStartupModules[after[t]]) {
return false;
}
}

View File

@ -14,6 +14,7 @@ This is the main application logic for both the client and server
// Export name and synchronous status
exports.name = "startup";
exports.after = ["load-modules"];
exports.synchronous = true;
// Set to `true` to enable performance instrumentation
@ -36,28 +37,12 @@ var widget = require("$:/core/modules/widgets/widget.js");
exports.startup = function() {
var modules,n,m,f,commander;
// Load modules
$tw.modules.applyMethods("utils",$tw.utils);
if($tw.node) {
$tw.modules.applyMethods("utils-node",$tw.utils);
}
$tw.modules.applyMethods("global",$tw);
$tw.modules.applyMethods("config",$tw.config);
if($tw.browser) {
$tw.utils.getBrowserInfo($tw.browser);
$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));
}
$tw.version = $tw.utils.extractVersionInfo();
$tw.Tiddler.fieldModules = $tw.modules.getModulesByTypeAsHashmap("tiddlerfield");
$tw.modules.applyMethods("tiddlermethod",$tw.Tiddler.prototype);
$tw.modules.applyMethods("wikimethod",$tw.Wiki.prototype);
$tw.modules.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerModules);
$tw.macros = $tw.modules.getModulesByTypeAsHashmap("macro");
// Set up the performance framework
$tw.perf = new $tw.Performance(PERFORMANCE_INSTRUMENTATION);
// Set up the parsers
$tw.wiki.initParsers();
// Set up the command modules
$tw.Commander.initCommands();
// Kick off the language manager and switcher
$tw.language = new $tw.Language();
$tw.languageSwitcher = new $tw.PluginSwitcher({

View File

@ -0,0 +1,36 @@
/*\
title: $:/core/modules/startup/load-modules.js
type: application/javascript
module-type: startup
Load core modules
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
// Export name and synchronous status
exports.name = "load-modules";
exports.synchronous = true;
exports.startup = function() {
// Load modules
$tw.modules.applyMethods("utils",$tw.utils);
if($tw.node) {
$tw.modules.applyMethods("utils-node",$tw.utils);
}
$tw.modules.applyMethods("global",$tw);
$tw.modules.applyMethods("config",$tw.config);
$tw.Tiddler.fieldModules = $tw.modules.getModulesByTypeAsHashmap("tiddlerfield");
$tw.modules.applyMethods("tiddlermethod",$tw.Tiddler.prototype);
$tw.modules.applyMethods("wikimethod",$tw.Wiki.prototype);
$tw.modules.applyMethods("tiddlerdeserializer",$tw.Wiki.tiddlerDeserializerModules);
$tw.macros = $tw.modules.getModulesByTypeAsHashmap("macro");
$tw.wiki.initParsers();
$tw.Commander.initCommands();
};
})();

View File

@ -130,9 +130,4 @@ exports.convertEventName = function(eventName) {
return newEventName;
};
// Setup constants for the current browser
exports.getBrowserInfo = function(info) {
info.isIE = (/msie|trident/i.test(navigator.userAgent));
};
})();

View File

@ -13,7 +13,7 @@ Modules with their ''module-type'' field set to `startup`:
* Must expose a `startup` function
** For synchronous startup modules the startup function is called as `startup()`, asynchronous modules are passed a callback they must invoke on completion: `startup(callback)`
* May expose a `name` property that is used to identify the task
* May expose a `dependencies` property containing an array of names of dependent tasks that must be run before this one
* May expose a `after` property containing an array of names of dependent tasks that must be run before this one
! Startup Processing