From a463783283179db449a6d2950aea736e1ca1493c Mon Sep 17 00:00:00 2001 From: lin onetwo Date: Sun, 26 May 2024 09:56:25 -0500 Subject: [PATCH] Fix/sjcl variable (#8099) * refactor: use files to add prefix * fix: always use $tw.sjcl * refactor: move sjcl to lib/sjcl * fix: require sjcl in lib/ * refactor: move sjcl.js back into /boot --- boot/sjcl.js.meta | 3 --- boot/tiddlywiki.files | 35 +++++++++++++++++++++++++++++++++++ core/modules/utils/utils.js | 2 +- 3 files changed, 36 insertions(+), 4 deletions(-) delete mode 100644 boot/sjcl.js.meta create mode 100644 boot/tiddlywiki.files diff --git a/boot/sjcl.js.meta b/boot/sjcl.js.meta deleted file mode 100644 index f32b4df93a7..00000000000 --- a/boot/sjcl.js.meta +++ /dev/null @@ -1,3 +0,0 @@ -title: $:/library/sjcl.js -type: application/javascript -library: yes diff --git a/boot/tiddlywiki.files b/boot/tiddlywiki.files new file mode 100644 index 00000000000..5e9c3d393b9 --- /dev/null +++ b/boot/tiddlywiki.files @@ -0,0 +1,35 @@ +{ + "tiddlers": [ + { + "file": "sjcl.js", + "fields": { + "title": "$:/library/sjcl.js", + "type": "application/javascript", + "library": "yes" + }, + "prefix": "(function(define) {\n", + "suffix": "\n})(function (_,defined){window.sjcl = defined()})\n" + }, + { + "file": "boot.js", + "fields": { + "title": "$:/boot/boot.js", + "type": "application/javascript" + } + }, + { + "file": "bootprefix.js", + "fields": { + "title": "$:/boot/bootprefix.js", + "type": "application/javascript" + } + }, + { + "file": "boot.css.tid", + "fields": { + "title": "$:/boot/boot.css", + "type": "text/css" + } + } + ] +} \ No newline at end of file diff --git a/core/modules/utils/utils.js b/core/modules/utils/utils.js index 42b3bd05c39..878f83fbb39 100644 --- a/core/modules/utils/utils.js +++ b/core/modules/utils/utils.js @@ -825,7 +825,7 @@ options.length .. number of characters returned defaults to 64 */ exports.sha256 = function(str, options) { options = options || {} - return sjcl.codec.hex.fromBits(sjcl.hash.sha256.hash(str)).substr(0,options.length || 64); + return $tw.sjcl.codec.hex.fromBits($tw.sjcl.hash.sha256.hash(str)).substr(0,options.length || 64); } /*