Skip to content

Commit

Permalink
chore(wakatime): 重新添加附属仓库 wakatime | Re-add sub-repository wakatime.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zuoqiu-Yingyi committed Apr 2, 2024
1 parent 84f62f5 commit ddad458
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:

env:
PACKAGE_NAME: wakatime
PACKAGE_VERSION: 0.3.5
PACKAGE_VERSION: 0.3.6

jobs:
release-please:
Expand Down
13 changes: 1 addition & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "wakatime",
"private": true,
"version": "0.3.5",
"version": "0.3.6",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -12,17 +12,6 @@
"preview": "vite preview",
"check": "svelte-check --tsconfig ./tsconfig.json"
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.4.6",
"@tsconfig/svelte": "^5.0.2",
"less": "^4.2.0",
"svelte": "^4.2.2",
"svelte-check": "^3.5.2",
"svelte-preprocess-less": "^0.4.0",
"tslib": "^2.6.2",
"typescript": "^5.2.2",
"vite": "^4.5.0"
},
"dependencies": {
"@workspace/components": "workspace:^",
"@workspace/types": "workspace:^",
Expand Down
2 changes: 1 addition & 1 deletion public/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "wakatime",
"author": "Zuoqiu Yingyi",
"url": "https://github.com/Zuoqiu-Yingyi/siyuan-plugin-wakatime",
"version": "0.3.5",
"version": "0.3.6",
"minAppVersion": "2.10.13",
"keywords": [
"分析",
Expand Down
3 changes: 2 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,15 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export default {
OFFLINE_CACHE_PATH: "temp/.wakatime/cache", // 缓存文件目录路径
WAKATIME_DEFAULT_API_URL: "https://wakatime.com/api/v1", // 默认 API 地址
WAKATIME_STATUS_BAR_PATHNAME: "users/current/statusbar/today", // 状态栏数据 API 地址
WAKATIME_HEARTBEATS_PATHNAME: "users/current/heartbeats", // 心跳数据 API 路径地址
WAKATIME_HEARTBEATS_BULK: 25, // 每次提交数量限制
WAKATIME_CLIENT_NAME: "wakatime", // 客户端名称
WAKATIME_CLIENT_VERSION: "1.86.0", // 客户端名称
WAKATIME_CLIENT_VERSION: "1.90.0", // 客户端版本
WAKATIME_EDITOR_NAME: "siyuan", // 编辑器名称
WAKATIME_PLUGIN_NAME: "siyuan-wakatime", // 插件名称
WAKATIME_DEFAULT_LANGUAGE: "Siyuan", // 默认语言名称
Expand Down
35 changes: 23 additions & 12 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ export default class WakaTimePlugin extends siyuan.Plugin {
.finally(async () => {
/* 初始化 channel */
this.initBridge();
const runing = await this.isWorkerRunning();
const running = await this.isWorkerRunning();

if (!runing) { // worker 未正常运行
if (!running) { // worker 未正常运行
/* 初始化 worker */
this.initWorker();

Expand Down Expand Up @@ -253,18 +253,29 @@ export default class WakaTimePlugin extends siyuan.Plugin {
/* 获取所有更改的块 ID */
transactions?.forEach(transaction => {
transaction.doOperations?.forEach(operation => {
// this.logger.debug(operation);
switch (operation.action) {
case "delete": // 忽略删除操作
return;
default:
case "create":
case "update":
case "insert":
case "move":
case "append":
case "appendInsert":
case "prependInsert":
case "foldHeading":
case "unfoldHeading":
case "setAttrs":
case "doUpdateUpdated":
if (operation.id) {
this.bridge?.call<THandlers["addEditEvent"]>(
"addEditEvent",
operation.id,
);
}
break;
case "delete": // 忽略删除操作 (避免无法查询块信息)
default: // 忽略其他操作 (闪卡, 属性视图等)
break;
}

if (operation.id) {
this.bridge?.call<THandlers["addEditEvent"]>(
"addEditEvent",
operation.id,
);
}
});
// transaction.undoOperations?.forEach(operation => {
Expand Down
6 changes: 6 additions & 0 deletions src/types/wakatime.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,12 @@ export namespace Heartbeats {
// <integer: total number of lines in the entity (when entity type is file)>,
lines?: number;

// <integer: number of lines added since last heartbeat in the current file (optional)>,
line_additions?: number;

// <integer: number of lines removed since last heartbeat in the current file (optional)>,
line_deletions?: number;

// <integer: current line row number of cursor with the first line starting at 1 (optional)>,
lineno?: number;

Expand Down
4 changes: 4 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
"extends": "@tsconfig/svelte/tsconfig.json",
"compilerOptions": {
"target": "ESNext",
"lib": [
"ESNext",
"DOM"
],
"useDefineForClassFields": true,
"module": "ESNext",
"resolveJsonModule": true,
Expand Down

0 comments on commit ddad458

Please sign in to comment.