1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-01-22 06:56:52 +00:00

feat: make $tw.wiki globally available

This commit is contained in:
linonetwo 2024-09-10 16:13:59 +08:00
parent ac308e0f89
commit b6f219aa82
6 changed files with 21 additions and 5 deletions

1
.gitignore vendored
View File

@ -9,3 +9,4 @@ node_modules/
/playwright-report/ /playwright-report/
/playwright/.cache/ /playwright/.cache/
$__StoryList.tid $__StoryList.tid
types/generated/

1
core/globals.d.ts vendored
View File

@ -1 +0,0 @@
declare var $tw: any;

View File

@ -22,6 +22,13 @@ Adds the following properties to the wiki object:
/*global $tw: false */ /*global $tw: false */
"use strict"; "use strict";
/**
* @typedef {import('$:/core/modules/widgets/widget.js').widget} Widget
*/
/**
* @type {Widget}
*/
var widget = require("$:/core/modules/widgets/widget.js"); var widget = require("$:/core/modules/widgets/widget.js");
var USER_NAME_TITLE = "$:/status/UserName", var USER_NAME_TITLE = "$:/status/UserName",

View File

@ -13,6 +13,7 @@
"bin": { "bin": {
"tiddlywiki": "./tiddlywiki.js" "tiddlywiki": "./tiddlywiki.js"
}, },
"types": "./types",
"main": "./boot/boot.js", "main": "./boot/boot.js",
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -11,15 +11,16 @@
"allowSyntheticDefaultImports": true, "allowSyntheticDefaultImports": true,
"checkJs": true, "checkJs": true,
"declaration": true, "declaration": true,
"declarationDir": "types", "declarationDir": "types/generated",
"declarationMap": true, "declarationMap": true,
"emitDeclarationOnly": true, "emitDeclarationOnly": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"], "lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "Node16", "module": "Node16",
"outDir": "types", "outDir": "types/generated",
"rootDir": "core", "rootDir": ".",
"skipLibCheck": true, "skipLibCheck": true,
"target": "ESNext" "target": "ESNext"
}, },
"include": ["./core/**/*.js", "**/*.d.ts"] "include": ["./core/**/*.js", "./core/**/*.d.ts", "types/tw.d.ts"],
"exclude": ["types/generated"]
} }

7
types/tw.d.ts vendored Normal file
View File

@ -0,0 +1,7 @@
import * as Wiki from '../core/modules/wiki';
declare global {
var $tw: {
wiki: typeof Wiki;
};
}