mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-04-27 15:50:57 -07:00
fix: prevent adaptor wikitext overwrite by tiddlyweb plugin
Try to workaround https://github.com/Jermolene/TiddlyWiki5/issues/7553
This commit is contained in:
parent
926b0c29c0
commit
bd69eefa1a
34 changed files with 80 additions and 52 deletions
|
|
@ -7,31 +7,35 @@
|
|||
import esbuild from 'esbuild';
|
||||
|
||||
// put it here, so it can be loaded via `'+plugins/linonetwo/tidgi'` in cli, and get copied in scripts/afterPack.js when copying tiddlywiki (no need to copy this plugin again)
|
||||
const outDir = path.join(__dirname, '../node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo/tidgi');
|
||||
await fs.mkdirp(outDir);
|
||||
const tidgiIpcSyncadaptorOutDir = path.join(__dirname, '../node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor');
|
||||
await fs.mkdirp(tidgiIpcSyncadaptorOutDir);
|
||||
const tsconfigPath = path.join(__dirname, '../tsconfig.json');
|
||||
const sourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptor';
|
||||
const tidgiIpcSyncadaptorSourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptor';
|
||||
const sharedConfig = {
|
||||
logLevel: 'info',
|
||||
bundle: true,
|
||||
// use node so we have `exports`, otherwise `module.adaptorClass` in $:/core/modules/startup.js will be undefined
|
||||
platform: 'node',
|
||||
minify: true,
|
||||
outdir: outDir,
|
||||
outdir: tidgiIpcSyncadaptorOutDir,
|
||||
tsconfig: tsconfigPath,
|
||||
target: 'ESNEXT',
|
||||
};
|
||||
await Promise.all([
|
||||
esbuild.build({
|
||||
...sharedConfig,
|
||||
entryPoints: [path.join(__dirname, sourceFolder, 'ipc-syncadaptor.ts')],
|
||||
entryPoints: [path.join(__dirname, tidgiIpcSyncadaptorSourceFolder, 'ipc-syncadaptor.ts')],
|
||||
}),
|
||||
esbuild.build({
|
||||
...sharedConfig,
|
||||
entryPoints: [path.join(__dirname, sourceFolder, 'electron-ipc-cat.ts')],
|
||||
entryPoints: [path.join(__dirname, tidgiIpcSyncadaptorSourceFolder, 'electron-ipc-cat.ts')],
|
||||
}),
|
||||
]);
|
||||
const filterFunc = (src) => {
|
||||
return !src.endsWith('.ts');
|
||||
};
|
||||
await fs.copy(path.join(__dirname, sourceFolder), outDir, { filter: filterFunc });
|
||||
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorSourceFolder), tidgiIpcSyncadaptorOutDir, { filter: filterFunc });
|
||||
|
||||
const tidgiIpcSyncadaptorUISourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptorUI';
|
||||
const tidgiIpcSyncadaptorUIOutDir = path.join(__dirname, '../node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor-ui');
|
||||
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorUISourceFolder), tidgiIpcSyncadaptorUIOutDir, { filter: filterFunc });
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ exports.after = ['startup'];
|
|||
exports.synchronous = true;
|
||||
exports.startup = function() {
|
||||
if ('service' in window && 'descriptors' in window.service && window.service.descriptors !== undefined) {
|
||||
require('$:/plugins/linonetwo/tidgi/Startup/electron-ipc-cat.js');
|
||||
require('$:/plugins/linonetwo/tidgi-ipc-syncadaptor/Startup/electron-ipc-cat.js');
|
||||
// call setupSSE in `src/services/wiki/plugin/ipcSyncAdaptor/ipc-syncadaptor.ts` of TidGi-Desktop
|
||||
if (typeof $tw !== 'undefined') {
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
creator: LinOnetwo
|
||||
title: $:/plugins/linonetwo/tidgi/Startup/install-electron-ipc-cat.js
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor/Startup/install-electron-ipc-cat.js
|
||||
type: application/javascript
|
||||
module-type: startup
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
creator: LinOnetwo
|
||||
title: $:/plugins/linonetwo/tidgi/Startup/electron-ipc-cat.js
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor/Startup/electron-ipc-cat.js
|
||||
type: application/javascript
|
||||
module-type: library
|
||||
|
|
@ -1,2 +1,2 @@
|
|||
import 'electron-ipc-cat/fixContextIsolation';
|
||||
console.log('electron-ipc-cat/fixContextIsolation in $:/plugins/linonetwo/tidgi');
|
||||
console.log('electron-ipc-cat/fixContextIsolation in $:/plugins/linonetwo/tidgi-ipc-syncadaptor');
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
title: $:/plugins/linonetwo/tidgi/ipc-syncadaptor.js
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor/ipc-syncadaptor.js
|
||||
type: application/javascript
|
||||
module-type: syncadaptor
|
||||
|
|
@ -48,7 +48,7 @@ class TidGiIPCSyncAdaptor {
|
|||
}
|
||||
|
||||
/**
|
||||
* This should be called after install-electron-ipc-cat, so this is called in `$:/plugins/linonetwo/tidgi/Startup/install-electron-ipc-cat.js`
|
||||
* This should be called after install-electron-ipc-cat, so this is called in `$:/plugins/linonetwo/tidgi-ipc-syncadaptor/Startup/install-electron-ipc-cat.js`
|
||||
*/
|
||||
setupSSE() {
|
||||
if (window.observables?.wiki?.getWikiChangeObserver$ === undefined) {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
{
|
||||
"title": "$:/plugins/linonetwo/tidgi",
|
||||
"title": "$:/plugins/linonetwo/tidgi-ipc-syncadaptor",
|
||||
"name": "TidGi",
|
||||
"description": "Plugin that make TidGi works",
|
||||
"description": "Save/load data to tidgi's main process",
|
||||
"author": "LinOnetwo",
|
||||
"core-version": ">=5.1.22",
|
||||
"plugin-type": "plugin",
|
||||
"version": "0.1.0",
|
||||
"dependents": ["$:/plugins/tiddlywiki/tiddlyweb"],
|
||||
"dependents": [],
|
||||
"list": "readme tree",
|
||||
"plugin-priority-comment": "lower than $:/plugins/tiddlywiki/tiddlyweb's 10, so we load before it, so our syncadaptor load first in core/modules/server/server.js",
|
||||
"plugin-priority-comment": "lower than $:/plugins/tiddlywiki/tiddlyweb's 10, so the js load before it to register",
|
||||
"plugin-priority": 9
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi/readme
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor/readme
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
!! SyncAdaptor
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi/tree
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor/tree
|
||||
caption: {{$:/language/SideBar/Explorer/Caption}}
|
||||
|
||||
<<tree "$:/plugins/linonetwo/tidgi/">>
|
||||
<<tree "$:/plugins/linonetwo/tidgi-ipc-syncadaptor/">>
|
||||
|
|
|
|||
|
|
@ -1,3 +0,0 @@
|
|||
title: $:/config/SaveWikiButton/Template
|
||||
|
||||
$:/plugins/linonetwo/tidgi/save/offline
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
title: $:/plugins/linonetwo/tidgi/syncer-actions/copy-logs
|
||||
tags: $:/tags/SyncerDropdown
|
||||
|
||||
<$button message="tm-copy-syncer-logs-to-clipboard" class="tc-btn-invisible">
|
||||
{{$:/core/images/copy-clipboard}} Copy syncer logs to clipboard
|
||||
</$button>
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
title: $:/plugins/linonetwo/tidgi/syncer-actions/refresh
|
||||
tags: $:/tags/SyncerDropdown
|
||||
|
||||
<$reveal state="$:/status/IsLoggedIn" type="match" text="yes">
|
||||
<$button tooltip="Get latest changes from the server" aria-label="Refresh from server" class="tc-btn-invisible">
|
||||
<$action-sendmessage $message="tm-server-refresh"/>
|
||||
{{$:/core/images/refresh-button}}<span class="tc-btn-text"><$text text="Get latest changes from the server"/></span>
|
||||
</$button>
|
||||
</$reveal>
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
title: $:/tags/SyncerDropdown
|
||||
list: $:/plugins/linonetwo/tidgi/syncer-actions/refresh $:/plugins/linonetwo/tidgi/syncer-actions/save-snapshot $:/plugins/linonetwo/tidgi/syncer-actions/copy-logs
|
||||
13
src/services/wiki/plugin/ipcSyncAdaptorUI/plugin.info
Normal file
13
src/services/wiki/plugin/ipcSyncAdaptorUI/plugin.info
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"title": "$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui",
|
||||
"name": "TidGi",
|
||||
"description": "UI for $:/plugins/linonetwo/tidgi-ipc-syncadaptor",
|
||||
"author": "LinOnetwo",
|
||||
"core-version": ">=5.1.22",
|
||||
"plugin-type": "plugin",
|
||||
"version": "0.1.0",
|
||||
"dependents": ["$:/plugins/linonetwo/tidgi-ipc-syncadaptor"],
|
||||
"list": "readme tree",
|
||||
"plugin-priority-comment": "higher than $:/plugins/tiddlywiki/tiddlyweb's 10, so we load after it to overwrite it",
|
||||
"plugin-priority": 11
|
||||
}
|
||||
6
src/services/wiki/plugin/ipcSyncAdaptorUI/readme.tid
Normal file
6
src/services/wiki/plugin/ipcSyncAdaptorUI/readme.tid
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/readme
|
||||
type: text/vnd.tiddlywiki
|
||||
|
||||
!! UI
|
||||
|
||||
To fix [[https://github.com/Jermolene/TiddlyWiki5/issues/7553]]
|
||||
4
src/services/wiki/plugin/ipcSyncAdaptorUI/tree.tid
Normal file
4
src/services/wiki/plugin/ipcSyncAdaptorUI/tree.tid
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/tree
|
||||
caption: {{$:/language/SideBar/Explorer/Caption}}
|
||||
|
||||
<<tree "$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/">>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
title: $:/config/SaveWikiButton/Template
|
||||
|
||||
$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/save/offline
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi/icon/cloud
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/icon/cloud
|
||||
tags: $:/tags/Image
|
||||
|
||||
<svg class="tc-image-cloud tc-image-button" width="22pt" height="22pt" viewBox="0 0 128 128"><g><path d="M24 103C10.745 103 0 92.255 0 79c0-9.697 5.75-18.05 14.027-21.836A24.787 24.787 0 0114 56c0-13.255 10.745-24 24-24 1.373 0 2.718.115 4.028.337C48.628 24.2 58.707 19 70 19c19.882 0 36 16.118 36 36v.082c12.319 1.016 22 11.336 22 23.918 0 12.239-9.16 22.337-20.999 23.814L107 103H24z"/><path class="tc-image-cloud-idle" d="M57.929 84.698a6 6 0 01-8.485 0L35.302 70.556a6 6 0 118.485-8.485l9.9 9.9L81.97 43.686a6 6 0 018.485 8.486L57.929 84.698z"/><path class="tc-image-cloud-progress tc-animate-rotate-slow" d="M44.8 40a3.6 3.6 0 100 7.2h2.06A23.922 23.922 0 0040 64c0 13.122 10.531 23.785 23.603 23.997L64 88l.001-7.2c-9.171 0-16.626-7.348-16.798-16.477L47.2 64c0-5.165 2.331-9.786 5.999-12.868L53.2 55.6a3.6 3.6 0 107.2 0v-12a3.6 3.6 0 00-3.6-3.6h-12zM64 40v7.2c9.278 0 16.8 7.522 16.8 16.8 0 5.166-2.332 9.787-6 12.869V72.4a3.6 3.6 0 10-7.2 0v12a3.6 3.6 0 003.6 3.6h12a3.6 3.6 0 100-7.2l-2.062.001A23.922 23.922 0 0088 64c0-13.255-10.745-24-24-24z"/></g></svg>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi/readonly
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/readonly
|
||||
tags: [[$:/tags/Stylesheet]]
|
||||
|
||||
\define button-selector(title)
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
title: $:/plugins/linonetwo/tidgi/save/offline
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/save/offline
|
||||
|
||||
\import [subfilter{$:/core/config/GlobalImportFilter}]
|
||||
\define saveTiddlerFilter()
|
||||
[is[tiddler]] -[[$:/boot/boot.css]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/linonetwo/tidgi]] -[prefix[$:/temp/]] +[sort[title]] $(publishFilter)$
|
||||
[is[tiddler]] -[[$:/boot/boot.css]] -[prefix[$:/HistoryList]] -[status[pending]plugin-type[import]] -[type[application/javascript]library[yes]] -[[$:/boot/boot.js]] -[[$:/boot/bootprefix.js]] -[[$:/plugins/tiddlywiki/filesystem]] -[[$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui]] -[prefix[$:/temp/]] +[sort[title]] $(publishFilter)$
|
||||
\end
|
||||
{{$:/core/templates/tiddlywiki5.html}}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
title: $:/core/ui/Buttons/save-wiki
|
||||
tags: $:/tags/PageControls
|
||||
caption: {{$:/plugins/linonetwo/tidgi/icon/cloud}} Server status
|
||||
description: Status of synchronisation with server
|
||||
caption: {{$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/icon/cloud}} TidGi status
|
||||
description: Status of synchronisation with TidGi
|
||||
|
||||
\whitespace trim
|
||||
\define config-title()
|
||||
|
|
@ -10,7 +10,7 @@ $:/config/PageControlButtons/Visibility/$(listItem)$
|
|||
<$button popup=<<qualify "$:/state/popup/save-wiki">> tooltip="Status of synchronisation with server" aria-label="Server status" class=<<tv-config-toolbar-class>> selectedClass="tc-selected">
|
||||
<span class="tc-dirty-indicator">
|
||||
<$list filter="[<tv-config-toolbar-icons>match[yes]]">
|
||||
{{$:/plugins/linonetwo/tidgi/icon/cloud}}
|
||||
{{$:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/icon/cloud}}
|
||||
</$list>
|
||||
<$list filter="[<tv-config-toolbar-text>match[yes]]">
|
||||
<span class="tc-btn-text"><$text text="Server status"/></span>
|
||||
|
|
@ -19,7 +19,7 @@ $:/config/PageControlButtons/Visibility/$(listItem)$
|
|||
</$button>
|
||||
<$reveal state=<<qualify "$:/state/popup/save-wiki">> type="popup" position="belowleft" animate="yes">
|
||||
<div class="tc-drop-down">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/SyncerDropdown]!has[draft.of]]" variable="listItem">
|
||||
<$list filter="[all[shadows+tiddlers]tag[$:/tags/TidgiSyncadaptorDropdown]!has[draft.of]]" variable="listItem">
|
||||
<$transclude tiddler=<<listItem>>/>
|
||||
</$list>
|
||||
</div>
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
title: $:/plugins/linonetwo/tidgi/styles
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/styles
|
||||
tags: [[$:/tags/Stylesheet]]
|
||||
|
||||
\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline macrocallblock
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/copy-logs
|
||||
tags: $:/tags/TidgiSyncadaptorDropdown
|
||||
|
||||
<$button message="tm-copy-syncer-logs-to-clipboard" class="tc-btn-invisible">
|
||||
{{$:/core/images/copy-clipboard}} Copy TidGi syncer logs to clipboard
|
||||
</$button>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/refresh
|
||||
tags: $:/tags/TidgiSyncadaptorDropdown
|
||||
|
||||
<$reveal state="$:/status/IsLoggedIn" type="match" text="yes">
|
||||
<$button tooltip="Sync from TidGi main process" aria-label="Refresh from server" class="tc-btn-invisible">
|
||||
<$action-sendmessage $message="tm-server-refresh"/>
|
||||
{{$:/core/images/refresh-button}}<span class="tc-btn-text"><$text text="Sync from TidGi main process"/></span>
|
||||
</$button>
|
||||
</$reveal>
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
title: $:/plugins/linonetwo/tidgi/syncer-actions/save-snapshot
|
||||
tags: $:/tags/SyncerDropdown
|
||||
title: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/save-snapshot
|
||||
tags: $:/tags/TidgiSyncadaptorDropdown
|
||||
|
||||
<$button class="tc-btn-invisible">
|
||||
<$wikify name="site-title" text={{$:/config/SaveWikiButton/Filename}}>
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
title: $:/tags/TidgiSyncadaptorDropdown
|
||||
list: $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/refresh $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/save-snapshot $:/plugins/linonetwo/tidgi-ipc-syncadaptor-ui/syncer-actions/copy-logs
|
||||
|
|
@ -65,7 +65,8 @@ export function startNodeJSWiki({
|
|||
* Install $:/plugins/linonetwo/tidgi instead of +plugins/tiddlywiki/tiddlyweb to speedup (without JSON.parse) and fix http errors when network change.
|
||||
* See scripts/compilePlugins.mjs for how it is built.
|
||||
*/
|
||||
'plugins/linonetwo/tidgi',
|
||||
'plugins/linonetwo/tidgi-ipc-syncadaptor',
|
||||
'plugins/linonetwo/tidgi-ipc-syncadaptor-ui',
|
||||
enableHTTPAPI ? 'plugins/tiddlywiki/tiddlyweb' : undefined, // we use $:/plugins/linonetwo/tidgi instead
|
||||
// 'plugins/linonetwo/watch-fs',
|
||||
].filter(Boolean) as string[];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue