mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-27 03:57:21 +00:00
Split module loading into a separate startup task
Still a work in progress.
This commit is contained in:
parent
1c82348edb
commit
749582ede0
@ -1773,10 +1773,10 @@ $tw.boot.executeNextStartupTask = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
$tw.boot.isStartupTaskEligible = function(taskModule) {
|
$tw.boot.isStartupTaskEligible = function(taskModule) {
|
||||||
var dependencies = taskModule.dependencies;
|
var after = taskModule.after;
|
||||||
if(dependencies) {
|
if(after) {
|
||||||
for(var t=0; t<dependencies.length; t++) {
|
for(var t=0; t<after.length; t++) {
|
||||||
if(!$tw.boot.executedStartupModules[dependencies[t]]) {
|
if(!$tw.boot.executedStartupModules[after[t]]) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ This is the main application logic for both the client and server
|
|||||||
|
|
||||||
// Export name and synchronous status
|
// Export name and synchronous status
|
||||||
exports.name = "startup";
|
exports.name = "startup";
|
||||||
|
exports.after = ["load-modules"];
|
||||||
exports.synchronous = true;
|
exports.synchronous = true;
|
||||||
|
|
||||||
// Set to `true` to enable performance instrumentation
|
// Set to `true` to enable performance instrumentation
|
||||||
@ -36,28 +37,12 @@ var widget = require("$:/core/modules/widgets/widget.js");
|
|||||||
|
|
||||||
exports.startup = function() {
|
exports.startup = function() {
|
||||||
var modules,n,m,f,commander;
|
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) {
|
if($tw.browser) {
|
||||||
$tw.utils.getBrowserInfo($tw.browser);
|
$tw.browser.isIE = (/msie|trident/i.test(navigator.userAgent));
|
||||||
}
|
}
|
||||||
$tw.version = $tw.utils.extractVersionInfo();
|
$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
|
// Set up the performance framework
|
||||||
$tw.perf = new $tw.Performance(PERFORMANCE_INSTRUMENTATION);
|
$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
|
// Kick off the language manager and switcher
|
||||||
$tw.language = new $tw.Language();
|
$tw.language = new $tw.Language();
|
||||||
$tw.languageSwitcher = new $tw.PluginSwitcher({
|
$tw.languageSwitcher = new $tw.PluginSwitcher({
|
||||||
|
36
core/modules/startup/load-modules.js
Normal file
36
core/modules/startup/load-modules.js
Normal 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();
|
||||||
|
};
|
||||||
|
|
||||||
|
})();
|
@ -130,9 +130,4 @@ exports.convertEventName = function(eventName) {
|
|||||||
return newEventName;
|
return newEventName;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Setup constants for the current browser
|
|
||||||
exports.getBrowserInfo = function(info) {
|
|
||||||
info.isIE = (/msie|trident/i.test(navigator.userAgent));
|
|
||||||
};
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -13,7 +13,7 @@ Modules with their ''module-type'' field set to `startup`:
|
|||||||
* Must expose a `startup` function
|
* 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)`
|
** 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 `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
|
! Startup Processing
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user