mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-09-30 07:50:47 +00:00
Make rawmarkup code dynamically load dependencies
empty.html with the plugin is now 4.1MB
This commit is contained in:
parent
0546a14201
commit
146a22b894
@ -8,7 +8,35 @@ Startup code injected as raw markup at the bottom of the body section
|
||||
|
||||
(function() {
|
||||
|
||||
// Get the main tiddler store
|
||||
var storeEl = document.querySelector("script.tiddlywiki-tiddler-store");
|
||||
var tiddlerStore = JSON.parse(storeEl.textContent);
|
||||
|
||||
function getTiddler(title) {
|
||||
for(var t=0; t<tiddlerStore.length; t++) {
|
||||
var tiddler = tiddlerStore[t];
|
||||
if(tiddler.title === title) {
|
||||
return tiddler;
|
||||
}
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var thisPlugin = getTiddler("$:/plugins/tiddlywiki/sqlite3store");
|
||||
|
||||
var thisPluginTiddlers = JSON.parse(thisPlugin.text).tiddlers;
|
||||
|
||||
// Execute the sqlite3 module
|
||||
var sqlite3js = thisPluginTiddlers["$:/plugins/tiddlywiki/sqlite3store/sqlite3.js"].text;
|
||||
|
||||
var context = {
|
||||
exports: {}
|
||||
};
|
||||
|
||||
$tw.utils.evalSandboxed(sqlite3js,context,"$:/plugins/tiddlywiki/sqlite3store/sqlite3.js",true);
|
||||
|
||||
// Create a Blob URL for our wasm data
|
||||
var sqlite3wasm = thisPluginTiddlers["$:/plugins/tiddlywiki/sqlite3store/sqlite3.wasm"].text;
|
||||
var decodedData = window.atob(sqlite3wasm),
|
||||
uInt8Array = new Uint8Array(decodedData.length);
|
||||
for (var i = 0; i < decodedData.length; ++i) {
|
||||
|
@ -2,7 +2,5 @@ title: $:/plugins/tiddlywiki/sqlite3store/rawmarkup/bottombody
|
||||
tags: $:/tags/RawMarkupWikified/BottomBody
|
||||
|
||||
`<script>`
|
||||
{{$:/plugins/tiddlywiki/sqlite3store/sqlite3.js}}
|
||||
`var sqlite3wasm = "`<$text text={{$:/plugins/tiddlywiki/sqlite3store/sqlite3.wasm}}/>`";`
|
||||
{{$:/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js}}
|
||||
`</script>`
|
||||
|
Loading…
Reference in New Issue
Block a user