Skip to content

Commit

Permalink
chore: 1.nothing important
Browse files Browse the repository at this point in the history
  • Loading branch information
JuckZ committed Feb 19, 2023
1 parent 456ee92 commit 4eb95af
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 59 deletions.
10 changes: 0 additions & 10 deletions src/__mocks__/chalk.ts
Original file line number Diff line number Diff line change
@@ -1,10 +0,0 @@
'use strict';
const chalk = jest.genMockFromModule<any>('chalk');

chalk.red = jest.fn();
chalk.green = jest.fn();
chalk.blue = {
bold: jest.fn(),
};

module.exports = chalk;
14 changes: 0 additions & 14 deletions src/__mocks__/jsonfile.ts
Original file line number Diff line number Diff line change
@@ -1,14 +0,0 @@
'use strict';
const jsonfile = jest.genMockFromModule<any>('jsonfile');

let error;

const setup = createError => (error = createError);

const writeFile = jest.fn((fileName, order, cb) => {
error ? cb('Something went wrong') : cb();
});
jsonfile.setup = setup;
jsonfile.writeFile = writeFile;

module.exports = jsonfile;
17 changes: 4 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
debounce,
setIcon,
} from 'obsidian';
import { ref, Ref } from 'vue';
import { ref } from 'vue';
import moment from 'moment';
import { EditDetector, OneDay, Tag, UndoHistoryInstance } from './types';
import { getAllDailyNotes, getDailyNote, getDailyNoteSettings } from 'obsidian-daily-notes-interface';
Expand Down Expand Up @@ -57,12 +57,6 @@ import {
updateDBConditionally,
} from './utils/db/db';
import { insertAfterHandler, setBanner } from './utils/content';
import {
changeToolbarPopover,
getEditorPositionFromIndex,
loadCustomViewContainer,
unloadCustomViewContainer,
} from './utils/editor';
import { getLocalRandom, searchPicture } from './utils/genBanner';
import { loadSQL } from './utils/db/sqljs';
import { PomodoroStatus, initiateDB } from './utils/promotodo';
Expand All @@ -76,7 +70,8 @@ import type { ExtApp, ExtTFile } from './types';
import { DocumentDirectionSettings } from './render/DocumentDirection';
import { emojiListPlugin } from './render/EmojiList';
import { onCodeMirrorChange, toggleBlast, toggleShake } from './render/Blast';
import { Pomodoro, pomodoroSchema } from './schemas/spaces';
import { pomodoroSchema } from './schemas/spaces';
import type { Pomodoro } from './schemas/spaces';
import t from './i18n';
import './main.scss';

Expand Down Expand Up @@ -1111,7 +1106,6 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
);
menu.showAtMouseEvent(event);
});
loadCustomViewContainer(this);
}

private watchVault() {
Expand All @@ -1128,9 +1122,7 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
media.addEventListener('change', callback);
// Remove listener when we unload
this.register(() => media.removeEventListener('change', callback));
this.registerDomEvent(activeDocument, 'mouseup', async (e: MouseEvent) => {
changeToolbarPopover(this.app, e);
});

window.addEventListener(eventTypes.pomodoroChange, this.pomodoroChange.bind(this));
window.addEventListener(eventTypes.mdbChange, this.mdbChange.bind(this));
[
Expand All @@ -1150,7 +1142,6 @@ export default class AwesomeBrainManagerPlugin extends Plugin {
}

override async onunload(): Promise<void> {
unloadCustomViewContainer();
toggleBlast('0');
this.app.workspace.detachLeavesOfType(POMODORO_HISTORY_VIEW);
this.style.detach();
Expand Down
3 changes: 2 additions & 1 deletion src/model/content.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { MarkdownDocument, ReminderEdit, modifyReminder, parseReminder } from '../model/format';
import { MarkdownDocument, modifyReminder, parseReminder } from '../model/format';
import type { ReminderEdit } from '../model/format';
import type { Reminder } from '../model/reminder';
import Logger from '../utils/logger';
import type { Todo } from './format/markdown';
Expand Down
3 changes: 2 additions & 1 deletion src/model/format/reminder-default.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DATE_TIME_FORMATTER, DateTime } from '../../model/time';
import type { Todo } from './markdown';
import { ReminderFormatParameterKey, ReminderModel, TodoBasedReminderFormat } from './reminder-base';
import { ReminderFormatParameterKey, TodoBasedReminderFormat } from './reminder-base';
import type { ReminderModel } from './reminder-base';

class DefaultReminderModel implements ReminderModel {
public static readonly regexp = /^(?<title1>.*?)\(@(?<time>.+?)\)(?<title2>.*)$/;
Expand Down
3 changes: 2 additions & 1 deletion src/model/time.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ConstantReference, ReadOnlyReference } from '../model/ref';
import { ConstantReference } from '../model/ref';
import type { ReadOnlyReference } from '../model/ref';
import moment from 'moment';

export class DateTime {
Expand Down
2 changes: 1 addition & 1 deletion src/render/EmojiList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
WidgetType,
} from '@codemirror/view';

import { EditorState, Extension, RangeSetBuilder, StateEffect, StateField, Transaction } from '@codemirror/state';
import { RangeSetBuilder } from '@codemirror/state';

import { syntaxTree } from '@codemirror/language';

Expand Down
2 changes: 1 addition & 1 deletion src/ui/BrowserView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</template>

<script setup lang="ts">
import { Ref, onMounted, onUnmounted, ref, toRefs, onUpdated } from 'vue';
import { onMounted, onUnmounted, toRefs, onUpdated } from 'vue';
import t from '../i18n';
import Title from './Title';
Expand Down
3 changes: 2 additions & 1 deletion src/ui/ClockView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

<script setup lang="ts">
import RadialProgress from 'vue3-radial-progress';
import { Ref, onMounted, onUnmounted, ref, toRefs } from 'vue';
import { onMounted, onUnmounted, ref, toRefs } from 'vue';
import type { Ref } from 'vue';
import { NResult, NSpace } from 'naive-ui';
import moment from 'moment';
import type { Pomodoro } from '../schemas/spaces';
Expand Down
2 changes: 1 addition & 1 deletion src/ui/CustomViewContainer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Ref, onMounted, onUnmounted, watchEffect, ref, toRef, onBeforeUpdate, o
import { NNotificationProvider, NSpace, useNotification } from 'naive-ui';
import t from '../i18n';
import Toolbar from './Toolbar.vue';
import AwesomeBrainManagerPlugin from '../main';
import type AwesomeBrainManagerPlugin from '../main';
import type { EditorState } from '../utils/editor';
defineProps<{
Expand Down
2 changes: 1 addition & 1 deletion src/ui/Toolbar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ import ScanImage from './components/icon/ScanImage.vue';
import type { ServiceName } from '../utils/ThirdPartyService';
import { customTitle, customContent, customAvatar, customDescription } from './CustomContent';
import type { EditorState } from '../utils/editor';
import AwesomeBrainManagerPlugin from '../main';
import type AwesomeBrainManagerPlugin from '../main';
import { eventTypes } from '../types/types';
const props = defineProps<{
Expand Down
5 changes: 3 additions & 2 deletions src/ui/view/BrowserView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HoverPopover, ItemView, WorkspaceLeaf } from 'obsidian';
import { App as VueApp, createApp, Ref } from 'vue';
import { createApp } from 'vue';
import type { App as VueApp, Ref } from 'vue';
import type AwesomeBrainManagerPlugin from 'main';
import BrowserViewComp from '../BrowserView.vue';
import t from '../../i18n';
Expand Down Expand Up @@ -36,7 +37,7 @@ export class BrowserView extends ItemView {
container.createEl('div', {
attr: {
id: 'awesome-brain-manager-browser-view',
style: 'height: 100%; width: 100%'
style: 'height: 100%; width: 100%',
},
});
this.vueapp = createApp(BrowserViewComp, { plugin: this.plugin, url: this.url });
Expand Down
3 changes: 2 additions & 1 deletion src/ui/view/PomodoroHistoryView.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { HoverPopover, ItemView, WorkspaceLeaf } from 'obsidian';
import { App as VueApp, createApp } from 'vue';
import { createApp } from 'vue';
import type { App as VueApp } from 'vue';
import type AwesomeBrainManagerPlugin from 'main';
import PomodoroHistory from '../PomodoroHistory.vue';
import t from '../../i18n';
Expand Down
2 changes: 1 addition & 1 deletion src/utils/ThirdPartyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,5 @@ export const genImageWithChatGPT = async (keyword) => {
n: 1,
});

return completion.data.data[0].url;
return completion.data.data[0].url || '';
};
5 changes: 3 additions & 2 deletions src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { inspect } from 'util';
import chalk from 'chalk';
import { ConstantReference, ReadOnlyReference } from '../model/ref';
import { ConstantReference } from '../model/ref';
import type { ReadOnlyReference } from '../model/ref';

chalk.level = 3;
let debugEnable: ReadOnlyReference<boolean> = new ConstantReference(false);
Expand All @@ -10,7 +11,7 @@ export const initLogger = (debugEnableVal: ReadOnlyReference<boolean>) => {
};

// TODO 单例模式
const printer = (args, chalkify) => {
const printer = (args, chalkify) => {
if (!debugEnable.value) {
return;
}
Expand Down
5 changes: 1 addition & 4 deletions src/utils/promotodo.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import moment from 'moment';
import type { Database } from 'sql.js';
import {
Pomodoro,
Space,
SpaceItem,
VaultItem,
pomodoroSchema,
spaceItemsSchema,
spaceSchema,
vaultSchema,
} from '../schemas/spaces';
import type { Pomodoro } from '../schemas/spaces';
import Logger from '../utils/logger';
import { deleteFromDB, insertIntoDB, replaceDB, selectDB, updateDB } from './db/db';

Expand Down
3 changes: 2 additions & 1 deletion src/utils/request.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import axios, { AxiosInstance, AxiosRequestConfig } from 'axios';
import axios from 'axios';
import type { AxiosInstance, AxiosRequestConfig } from 'axios';
import { Notice } from 'obsidian';
import Logger from './logger';

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@
],
"types": [
"node",
"svelte",
"jest"
"svelte"
]
}
}
5 changes: 4 additions & 1 deletion vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,12 @@ export default defineConfig({
nodeResolve({
// browser: true
}),
nodePolyfills(/* options */),
nodePolyfills({
sourceMap: true,
}),
],
output: {
exports: 'named',
assetFileNames: assetInfo => {
if (assetInfo.name == 'style.css') {
return 'styles.css';
Expand Down

0 comments on commit 4eb95af

Please sign in to comment.