Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lint-staged
37 changes: 37 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"$schema": "https://biomejs.dev/schemas/2.1.2/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"includes": ["**", "!**/generated/**"]
},
"formatter": {
"enabled": true,
"indentStyle": "space",
"indentWidth": 2
},
"linter": {
"enabled": true,
"rules": {
"recommended": true
}
},
"javascript": {
"formatter": {
"quoteStyle": "single",
"trailingCommas": "es5"
}
},
"assist": {
"enabled": true,
"actions": {
"source": {
"organizeImports": "on"
}
}
}
}
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ node {
}

tasks.register('buildFrontend', PnpmTask) {
args = ['build:packages']
args = ['build']
dependsOn('installDepsForUI')
}

Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"license": "GPL-3.0",
"author": {
"name": "Halo OSS Team",
"name": "Halo",
"url": "https://github.com/halo-dev"
},
"contributors": [
Expand All @@ -12,20 +12,23 @@
}
],
"scripts": {
"build:packages": "pnpm --filter \"./packages/**\" build",
"example:dev": "pnpm --filter \"./packages/example\" dev",
"release:packages": "pnpm --filter \"./packages/**\" release"
"build": "pnpm -r run build",
"check": "biome check --write",
"example:dev": "pnpm -C packages/example dev",
"prepare": "husky",
"release": "pnpm -r run release"
},
"lint-staged": {
"*": [
"biome check --no-errors-on-unmatched --files-ignore-unknown=true"
]
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.7.2",
"@biomejs/biome": "^2.1.2",
"@tsconfig/node18": "^18.2.2",
"@types/node": "^18.19.18",
"@typescript-eslint/eslint-plugin": "^6.21.0",
"@typescript-eslint/parser": "^6.21.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"prettier": "^3.2.5",
"husky": "^9.1.7",
"lint-staged": "^16.1.2",
"typescript": "~5.3.3",
"vite": "^5.1.4"
},
Expand Down
33 changes: 0 additions & 33 deletions packages/comment-widget/.eslintrc.json

This file was deleted.

24 changes: 0 additions & 24 deletions packages/comment-widget/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions packages/comment-widget/.prettierrc.json

This file was deleted.

8 changes: 2 additions & 6 deletions packages/comment-widget/lit-localize.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
{
"$schema": "https://raw.githubusercontent.com/lit/lit/main/packages/localize-tools/config.schema.json",
"sourceLocale": "en",
"targetLocales": [
"es",
"zh-CN",
"zh-TW"
],
"targetLocales": ["es", "zh-CN", "zh-TW"],
"tsConfig": "./tsconfig.json",
"output": {
"mode": "runtime",
Expand All @@ -16,4 +12,4 @@
"format": "xliff",
"xliffDir": "./xliff/"
}
}
}
9 changes: 3 additions & 6 deletions packages/comment-widget/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
],
"scripts": {
"build": "tsc",
"dev": "tsc -w",
"lint": "lit-analyzer && eslint 'src/**/*.ts'",
"prettier": "prettier \"**/*.{cjs,html,js,json,md,ts}\" --ignore-path ./.gitignore --write"
"dev": "tsc -w"
},
"dependencies": {
"@emoji-mart/data": "^1.1.2",
Expand All @@ -39,13 +37,12 @@
"@lit/localize": "^0.12.2",
"dayjs": "^1.11.10",
"emoji-mart": "^5.5.2",
"es-toolkit": "^1.39.7",
"javascript-time-ago": "^2.5.9",
"lit": "^3.1.2",
"lodash-es": "^4.17.21"
"lit": "^3.1.2"
},
"devDependencies": {
"@lit/localize-tools": "^0.8.0",
"@types/lodash-es": "^4.17.12",
"lit-analyzer": "^2.0.3"
}
}
30 changes: 22 additions & 8 deletions packages/comment-widget/src/avatar/avatar-policy.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { CommentVo, ReplyVo } from '@halo-dev/api-client';
import type { CommentVo, ReplyVo } from '@halo-dev/api-client';
import { getAvatarProvider } from './providers';

abstract class AvatarPolicy {
abstract applyCommentPolicy(comment: CommentVo | undefined): string | undefined;
abstract applyCommentPolicy(
comment: CommentVo | undefined
): string | undefined;
abstract applyReplyPolicy(reply: ReplyVo | undefined): string | undefined;
}

Expand All @@ -15,15 +17,19 @@ class AnonymousUserPolicy extends AvatarPolicy {
const avatarProvider = getAvatarProvider();
const isAnonymous = comment?.owner.kind === emailKind;
if (isAnonymous) {
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
comment?.spec.owner.annotations?.[emailHash]
);
}
return comment?.owner.avatar;
}
applyReplyPolicy(reply: ReplyVo | undefined): string | undefined {
const avatarProvider = getAvatarProvider();
const isAnonymous = reply?.owner.kind === emailKind;
if (isAnonymous) {
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
reply?.spec.owner.annotations?.[emailHash]
);
}
return reply?.owner.avatar;
}
Expand All @@ -32,11 +38,15 @@ class AnonymousUserPolicy extends AvatarPolicy {
class AllUserPolicy extends AvatarPolicy {
applyCommentPolicy(comment: CommentVo | undefined): string | undefined {
const avatarProvider = getAvatarProvider();
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
comment?.spec.owner.annotations?.[emailHash]
);
}
applyReplyPolicy(reply: ReplyVo | undefined): string | undefined {
const avatarProvider = getAvatarProvider();
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
reply?.spec.owner.annotations?.[emailHash]
);
}
}

Expand All @@ -46,7 +56,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
const isAnonymous = comment?.owner.kind === emailKind;
const avatar = comment?.owner.avatar;
if (isAnonymous || !avatar) {
return avatarProvider?.getAvatarSrc(comment?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
comment?.spec.owner.annotations?.[emailHash]
);
}
return avatar;
}
Expand All @@ -55,7 +67,9 @@ class NoAvatarUserPolicy extends AvatarPolicy {
const isAnonymous = reply?.owner.kind === emailKind;
const avatar = reply?.owner.avatar;
if (isAnonymous || !avatar) {
return avatarProvider?.getAvatarSrc(reply?.spec.owner.annotations?.[emailHash]);
return avatarProvider?.getAvatarSrc(
reply?.spec.owner.annotations?.[emailHash]
);
}
return avatar;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/comment-widget/src/avatar/providers/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type AvatarProvider from './avatar-provider';
import Gravatar from './gravatar';
import AvatarProvider from './avatar-provider';

let avatarProvider: AvatarProvider | undefined;

Expand Down
2 changes: 1 addition & 1 deletion packages/comment-widget/src/base-comment-item-action.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LitElement, css, html } from 'lit';
import { css, html, LitElement } from 'lit';
import { property } from 'lit/decorators.js';

export class BaseCommentItemAction extends LitElement {
Expand Down
14 changes: 8 additions & 6 deletions packages/comment-widget/src/base-comment-item.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import './user-avatar';
import { LitElement, css, html } from 'lit';
import { msg } from '@lit/localize';
import { css, html, LitElement } from 'lit';
import { property } from 'lit/decorators.js';
import { formatDate, timeAgo } from './utils/date';
import baseStyles from './styles/base';
import varStyles from './styles/var';
import { msg } from '@lit/localize';
import { formatDate, timeAgo } from './utils/date';

export class BaseCommentItem extends LitElement {
@property({ type: String })
Expand Down Expand Up @@ -38,11 +38,13 @@ export class BaseCommentItem extends LitElement {
</div>
<div class="item__main">
<div class="item__meta">
${this.userWebsite
? html`<a class="item__author" target="_blank" href=${this.userWebsite}>
${
this.userWebsite
? html`<a class="item__author" target="_blank" href=${this.userWebsite}>
${this.userDisplayName}
</a>`
: html`<div class="item__author">${this.userDisplayName}</div>`}
: html`<div class="item__author">${this.userDisplayName}</div>`
}
<div class="item__meta-info" title=${formatDate(this.creationTime)}>
${timeAgo(this.creationTime)}
</div>
Expand Down
Loading