mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2025-12-06 02:30:47 -08:00
refactor: from @tiddlygit/tiddlywiki to tiddlywiki , because there is no prerelease feature that I need now
This commit is contained in:
parent
fe3a29eff1
commit
0bef181d59
12 changed files with 23 additions and 27 deletions
|
|
@ -63,7 +63,7 @@ For example: `tiddlywiki`
|
||||||
|
|
||||||
1. `npm i tiddlywiki`
|
1. `npm i tiddlywiki`
|
||||||
1. Add `ExternalsPlugin` in webpack.plugins.js (maybe optional for some deps, tiddlywiki needs this because its custom `require` can't require things that is bundled by webpack. `dugite` don't need this step)
|
1. Add `ExternalsPlugin` in webpack.plugins.js (maybe optional for some deps, tiddlywiki needs this because its custom `require` can't require things that is bundled by webpack. `dugite` don't need this step)
|
||||||
1. Add a `await fs.copy(path.join(projectRoot, 'node_modules/@tiddlygit/tiddlywiki')` in `scripts/afterPack.js` , to copy things to resource folder, that is outside of asar, so it can be used by the worker_thread in electron
|
1. Add a `await fs.copy(path.join(projectRoot, 'node_modules/tiddlywiki')` in `scripts/afterPack.js` , to copy things to resource folder, that is outside of asar, so it can be used by the worker_thread in electron
|
||||||
|
|
||||||
## How to add plugin that only execute inside TidGi
|
## How to add plugin that only execute inside TidGi
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "pnpm run clean && pnpm run init:git-submodule && pnpm run start:without-clean",
|
"start": "pnpm run clean && pnpm run init:git-submodule && pnpm run start:without-clean",
|
||||||
"start:without-clean": "pnpm run build:plugin && cross-env NODE_ENV=development electron-forge start",
|
"start:without-clean": "pnpm run build:plugin && cross-env NODE_ENV=development electron-forge start",
|
||||||
"clean": "rimraf -- ./out ./userData-dev ./node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo && cross-env NODE_ENV=development npx ts-node scripts/developmentMkdir.ts",
|
"clean": "rimraf -- ./out ./userData-dev ./node_modules/tiddlywiki/plugins/linonetwo && cross-env NODE_ENV=development npx ts-node scripts/developmentMkdir.ts",
|
||||||
"clean:cache": "rimraf -- ./.webpack ./node_modules/.cache",
|
"clean:cache": "rimraf -- ./.webpack ./node_modules/.cache",
|
||||||
"start:without-clean:debug-worker": "pnpm run build:plugin && cross-env NODE_ENV=development DEBUG_WORKER=true electron-forge start",
|
"start:without-clean:debug-worker": "pnpm run build:plugin && cross-env NODE_ENV=development DEBUG_WORKER=true electron-forge start",
|
||||||
"start:without-clean:debug-main": "pnpm run build:plugin && cross-env NODE_ENV=development DEBUG_MAIN=true electron-forge start",
|
"start:without-clean:debug-main": "pnpm run build:plugin && cross-env NODE_ENV=development DEBUG_MAIN=true electron-forge start",
|
||||||
|
|
@ -31,7 +31,7 @@
|
||||||
"author": "Lin Onetwo <linonetwo012@gmail.com>, Quang Lam <quang.lam2807@gmail.com>",
|
"author": "Lin Onetwo <linonetwo012@gmail.com>, Quang Lam <quang.lam2807@gmail.com>",
|
||||||
"main": ".webpack/main",
|
"main": ".webpack/main",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tiddlygit/tiddlywiki": "5.3.5",
|
"tiddlywiki": "5.3.6",
|
||||||
"ansi-to-html": "^0.7.2",
|
"ansi-to-html": "^0.7.2",
|
||||||
"app-path": "^4.0.0",
|
"app-path": "^4.0.0",
|
||||||
"best-effort-json-parser": "1.1.2",
|
"best-effort-json-parser": "1.1.2",
|
||||||
|
|
|
||||||
|
|
@ -83,13 +83,14 @@ exports.default = async (
|
||||||
// shell,
|
// shell,
|
||||||
// });
|
// });
|
||||||
const packagePathsToCopyDereferenced = [
|
const packagePathsToCopyDereferenced = [
|
||||||
['@tiddlygit', 'tiddlywiki', 'package.json'],
|
['tiddlywiki', 'package.json'],
|
||||||
['@tiddlygit', 'tiddlywiki', 'boot'],
|
['tiddlywiki', 'boot'],
|
||||||
['@tiddlygit', 'tiddlywiki', 'core'],
|
['tiddlywiki', 'core'],
|
||||||
['@tiddlygit', 'tiddlywiki', 'plugins'],
|
// only copy plugins that is used in src/services/wiki/wikiWorker/startNodeJSWiki.ts , other plugins can be installed via JSON from online plugin library
|
||||||
['@tiddlygit', 'tiddlywiki', 'themes'],
|
['tiddlywiki', 'plugins', 'linonetwo'],
|
||||||
['@tiddlygit', 'tiddlywiki', 'languages'],
|
['tiddlywiki', 'plugins', 'tiddlywiki', 'filesystem'],
|
||||||
['@tiddlygit', 'tiddlywiki', 'tiddlywiki.js'],
|
['tiddlywiki', 'plugins', 'tiddlywiki', 'tiddlyweb'],
|
||||||
|
['tiddlywiki', 'tiddlywiki.js'],
|
||||||
// we only need its `main` binary, no need its dependency and code, because we already copy it to src/services/native/externalApp
|
// we only need its `main` binary, no need its dependency and code, because we already copy it to src/services/native/externalApp
|
||||||
['app-path', 'main'],
|
['app-path', 'main'],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,10 @@
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||||
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
||||||
import esbuild from 'esbuild';
|
import esbuild from 'esbuild';
|
||||||
import { rimraf } from 'rimraf'
|
import { rimraf } from 'rimraf';
|
||||||
|
|
||||||
// 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)
|
// 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 tidgiIpcSyncadaptorOutDir = path.join(__dirname, '../node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor');
|
const tidgiIpcSyncadaptorOutDir = path.join(__dirname, '../node_modules/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor');
|
||||||
// delete if exist
|
// delete if exist
|
||||||
await rimraf(tidgiIpcSyncadaptorOutDir);
|
await rimraf(tidgiIpcSyncadaptorOutDir);
|
||||||
await fs.mkdirp(tidgiIpcSyncadaptorOutDir);
|
await fs.mkdirp(tidgiIpcSyncadaptorOutDir);
|
||||||
|
|
@ -44,7 +44,7 @@ const filterFunc = (src) => {
|
||||||
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorSourceFolder), tidgiIpcSyncadaptorOutDir, { filter: filterFunc });
|
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorSourceFolder), tidgiIpcSyncadaptorOutDir, { filter: filterFunc });
|
||||||
|
|
||||||
const tidgiIpcSyncadaptorUISourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptorUI';
|
const tidgiIpcSyncadaptorUISourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptorUI';
|
||||||
const tidgiIpcSyncadaptorUIOutDir = path.join(__dirname, '../node_modules/@tiddlygit/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor-ui');
|
const tidgiIpcSyncadaptorUIOutDir = path.join(__dirname, '../node_modules/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor-ui');
|
||||||
// delete if exist
|
// delete if exist
|
||||||
await rimraf(tidgiIpcSyncadaptorUIOutDir);
|
await rimraf(tidgiIpcSyncadaptorUIOutDir);
|
||||||
await fs.mkdirp(tidgiIpcSyncadaptorUIOutDir);
|
await fs.mkdirp(tidgiIpcSyncadaptorUIOutDir);
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ export const PACKAGE_PATH_BASE = isDevelopmentOrTest
|
||||||
? path.resolve(__dirname, '..', '..', 'node_modules')
|
? path.resolve(__dirname, '..', '..', 'node_modules')
|
||||||
: path.resolve(process.resourcesPath, 'node_modules');
|
: path.resolve(process.resourcesPath, 'node_modules');
|
||||||
export const ZX_FOLDER = path.resolve(PACKAGE_PATH_BASE, 'zx', 'build', 'cli.js');
|
export const ZX_FOLDER = path.resolve(PACKAGE_PATH_BASE, 'zx', 'build', 'cli.js');
|
||||||
export const TIDDLYWIKI_PACKAGE_FOLDER = path.resolve(PACKAGE_PATH_BASE, '@tiddlygit', 'tiddlywiki', 'boot');
|
export const TIDDLYWIKI_PACKAGE_FOLDER = path.resolve(PACKAGE_PATH_BASE, 'tiddlywiki', 'boot');
|
||||||
|
|
||||||
export const LOCALIZATION_FOLDER = isDevelopmentOrTest
|
export const LOCALIZATION_FOLDER = isDevelopmentOrTest
|
||||||
? path.resolve(sourcePath, '..', localizationFolderName)
|
? path.resolve(sourcePath, '..', localizationFolderName)
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* Can't use logger in this file, because it runs in the worker.
|
* Can't use logger in this file, because it runs in the worker.
|
||||||
*/
|
*/
|
||||||
import type { ITiddlyWiki } from '@tiddlygit/tiddlywiki';
|
import AnsiToHtml from 'ansi-to-html';
|
||||||
import { fork } from 'child_process';
|
import { fork } from 'child_process';
|
||||||
import { writeFile } from 'fs-extra';
|
import { writeFile } from 'fs-extra';
|
||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import type { Subscriber } from 'rxjs';
|
import type { Subscriber } from 'rxjs';
|
||||||
|
import type { ITiddlyWiki } from 'tiddlywiki';
|
||||||
import vm, { Context } from 'vm';
|
import vm, { Context } from 'vm';
|
||||||
import AnsiToHtml from 'ansi-to-html';
|
|
||||||
import { IZxWorkerMessage, ZxWorkerControlActions } from '../../interface';
|
import { IZxWorkerMessage, ZxWorkerControlActions } from '../../interface';
|
||||||
import { fixZxPath } from './fixZxPath';
|
import { fixZxPath } from './fixZxPath';
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { isHtmlWiki } from '@/constants/fileNames';
|
import { isHtmlWiki } from '@/constants/fileNames';
|
||||||
import { TiddlyWiki } from '@tiddlygit/tiddlywiki';
|
|
||||||
import { remove } from 'fs-extra';
|
import { remove } from 'fs-extra';
|
||||||
|
import { TiddlyWiki } from 'tiddlywiki';
|
||||||
|
|
||||||
export async function extractWikiHTML(htmlWikiPath: string, saveWikiFolderPath: string, constants: { TIDDLYWIKI_PACKAGE_FOLDER: string }): Promise<void> {
|
export async function extractWikiHTML(htmlWikiPath: string, saveWikiFolderPath: string, constants: { TIDDLYWIKI_PACKAGE_FOLDER: string }): Promise<void> {
|
||||||
// tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder
|
// tiddlywiki --load ./mywiki.html --savewikifolder ./mywikifolder
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,6 @@
|
||||||
* Worker environment is not part of electron environment, so don't import "@/constants/paths" here, as its process.resourcesPath will become undefined and throw Errors.
|
* Worker environment is not part of electron environment, so don't import "@/constants/paths" here, as its process.resourcesPath will become undefined and throw Errors.
|
||||||
*
|
*
|
||||||
* Don't use i18n and logger in worker thread. For example, 12b93020, will throw error "Electron failed to install correctly, please delete node_modules/electron and try installing again ...worker.js..."
|
* Don't use i18n and logger in worker thread. For example, 12b93020, will throw error "Electron failed to install correctly, please delete node_modules/electron and try installing again ...worker.js..."
|
||||||
*
|
|
||||||
* Import tw related things and typing from `@tiddlygit/tiddlywiki` instead of `tiddlywiki`, otherwise you will get `Unhandled Error ReferenceError: self is not defined at $:/boot/bootprefix.js:40749:36` because tiddlywiki
|
|
||||||
*/
|
*/
|
||||||
import { uninstall } from '@/helpers/installV8Cache';
|
import { uninstall } from '@/helpers/installV8Cache';
|
||||||
import './preload';
|
import './preload';
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,11 @@
|
||||||
import { getTidGiAuthHeaderWithToken } from '@/constants/auth';
|
import { getTidGiAuthHeaderWithToken } from '@/constants/auth';
|
||||||
import { defaultServerIP } from '@/constants/urls';
|
import { defaultServerIP } from '@/constants/urls';
|
||||||
import { TiddlyWiki } from '@tiddlygit/tiddlywiki';
|
|
||||||
import intercept from 'intercept-stdout';
|
import intercept from 'intercept-stdout';
|
||||||
import { nanoid } from 'nanoid';
|
import { nanoid } from 'nanoid';
|
||||||
import inspector from 'node:inspector';
|
import inspector from 'node:inspector';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { TiddlyWiki } from 'tiddlywiki';
|
||||||
import { IWikiMessage, WikiControlActions } from '../interface';
|
import { IWikiMessage, WikiControlActions } from '../interface';
|
||||||
import { wikiOperationsInWikiWorker } from '../wikiOperations/executor/wikiOperationInServer';
|
import { wikiOperationsInWikiWorker } from '../wikiOperations/executor/wikiOperationInServer';
|
||||||
import { IStartNodeJSWikiConfigs } from '.';
|
import { IStartNodeJSWikiConfigs } from '.';
|
||||||
|
|
|
||||||
4
src/type.d.ts
vendored
4
src/type.d.ts
vendored
|
|
@ -5,10 +5,6 @@ declare module 'errio' {
|
||||||
export function register(error: ErrorConstructor): void;
|
export function register(error: ErrorConstructor): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
declare module '@tiddlygit/tiddlywiki' {
|
|
||||||
export * from 'tiddlywiki';
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module 'espree' {
|
declare module 'espree' {
|
||||||
// https://github.com/eslint/espree#options
|
// https://github.com/eslint/espree#options
|
||||||
export interface Options {
|
export interface Options {
|
||||||
|
|
|
||||||
|
|
@ -50,10 +50,10 @@ module.exports = {
|
||||||
externals: [
|
externals: [
|
||||||
// simply external all things will make require can't find things. Only exclude what we copied in scripts/afterPack.js
|
// simply external all things will make require can't find things. Only exclude what we copied in scripts/afterPack.js
|
||||||
// nodeExternals({
|
// nodeExternals({
|
||||||
// additionalModuleDirs: ['@tiddlygit/tiddlywiki'],
|
// additionalModuleDirs: ['tiddlywiki'],
|
||||||
// allowlist: [/(threads-plugin)/],
|
// allowlist: [/(threads-plugin)/],
|
||||||
// }),
|
// }),
|
||||||
'@tiddlygit/tiddlywiki',
|
'tiddlywiki',
|
||||||
'dugite',
|
'dugite',
|
||||||
'zx',
|
'zx',
|
||||||
...(process.platform === 'win32' ? [] : ['registry-js']),
|
...(process.platform === 'win32' ? [] : ['registry-js']),
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,8 @@ exports.main = _.compact([
|
||||||
new ExternalsPlugin({
|
new ExternalsPlugin({
|
||||||
type: 'commonjs',
|
type: 'commonjs',
|
||||||
// use regex works.
|
// use regex works.
|
||||||
include: /@tiddlygit\+tiddlywiki@(.+)|dugite(.+)/,
|
// include: /@tiddlygit\+tiddlywiki@(.+)|dugite(.+)/,
|
||||||
|
include: /tiddlywiki(.+)|dugite(.+)/,
|
||||||
// when using npm, we can use this. But with pnpm, this won't work ↓
|
// when using npm, we can use this. But with pnpm, this won't work ↓
|
||||||
// include: path.join(__dirname, 'node_modules', '.pnpm', '@tiddlygit', 'tiddlywiki'),
|
// include: path.join(__dirname, 'node_modules', '.pnpm', '@tiddlygit', 'tiddlywiki'),
|
||||||
}),
|
}),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue