Skip to content

Commit

Permalink
fix: ensure the assistant runs on the client-side and release @peterc…
Browse files Browse the repository at this point in the history
  • Loading branch information
RaoHai authored Sep 23, 2024
2 parents a2b7ad4 + 55f5cb5 commit c4e28b1
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 13 deletions.
2 changes: 1 addition & 1 deletion assistant/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@petercatai/assistant",
"version": "1.0.6",
"version": "1.0.7",
"description": "Peter Cat Assistant Application",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions assistant/src/Assistant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const Assistant = (props: AssistantProps) => {
};

const startDrag = (e: { clientY: any; preventDefault: () => void }) => {
if (typeof document === 'undefined') {
return;
}
const startY = e.clientY;
const initBottom = position.bottom;

Expand Down
37 changes: 30 additions & 7 deletions assistant/src/utils/popcenter.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,32 @@
export const popupCenter = ({ url, title, w, h }: { url: string; title: string, w: number; h: number; }) => {
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
export const popupCenter = ({
url,
title,
w,
h,
}: {
url: string;
title: string;
w: number;
h: number;
}) => {
if (typeof window === 'undefined') {
return;
}
const dualScreenLeft =
window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop =
window.screenTop !== undefined ? window.screenTop : window.screenY;

const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
const width = window.innerWidth
? window.innerWidth
: document.documentElement.clientWidth
? document.documentElement.clientWidth
: screen.width;
const height = window.innerHeight
? window.innerHeight
: document.documentElement.clientHeight
? document.documentElement.clientHeight
: screen.height;

const systemZoom = width / window.screen.availWidth;

Expand All @@ -20,11 +43,11 @@ export const popupCenter = ({ url, title, w, h }: { url: string; title: string,
height=${h / systemZoom},
top=${top},
left=${left}
`
`,
);
if (newWindow && newWindow.focus) {
newWindow.focus();
}

return newWindow;
}
};
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@fullpage/react-fullpage": "^0.1.42",
"@next/bundle-analyzer": "^13.4.19",
"@nextui-org/react": "^2.2.9",
"@petercatai/assistant": "^1.0.6",
"@petercatai/assistant": "^1.0.7",
"@sentry/nextjs": "^8.28.0",
"@supabase/supabase-js": "^2.32.0",
"@tanstack/react-query": "^5.17.19",
Expand Down
11 changes: 7 additions & 4 deletions client/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2927,10 +2927,10 @@
resolved "https://registry.npmjs.org/@panva/hkdf/-/hkdf-1.2.1.tgz#cb0d111ef700136f4580349ff0226bf25c853f23"
integrity sha512-6oclG6Y3PiDFcoyk8srjLfVKyMfVCKJ27JwNPViuXziFpmdz+MZnZN/aKY0JGXgYuO/VghU0jcOAZgWXZ1Dmrw==

"@petercatai/assistant@^1.0.3":
version "1.0.5"
resolved "https://registry.npmjs.org/@petercatai/assistant/-/assistant-1.0.5.tgz#dd58d7c4e27431e3924ce0db65ab46d572d52f4a"
integrity sha512-INLpdoNw0urY5ny1D9O6H4JSdfyY3LsoeB/EKFNJo0W3ELzHKhNm3ha5B/iD1CR7QAfwwTk09Q7SLKreVleEZw==
"@petercatai/assistant@^1.0.7":
version "1.0.7"
resolved "https://registry.npmjs.org/@petercatai/assistant/-/assistant-1.0.7.tgz#d3f55048c2dbae901ac7ba0f59f2eb6594a081e6"
integrity sha512-FE/i8ZxakbD9pl2K12KBE1G2PeUhj7HnxB0S8r8GfWwDzq7GZgjwOvnIP6/ooW17e6xhm5J/AWPAldBVjk6RMQ==
dependencies:
"@ant-design/icons" "^5.3.5"
"@ant-design/pro-chat" "^1.9.0"
Expand Down Expand Up @@ -11326,6 +11326,7 @@ string-convert@^0.2.0:
integrity sha512-u/1tdPl4yQnPBjnVrmdLo9gtuLvELKsAoRapekWggdiQNvvvum+jYF329d84NAa660KQw7pB2n36KrIKVoXa3A==

"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
name string-width-cjs
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -11434,6 +11435,7 @@ stringify-entities@^4.0.0:
character-entities-legacy "^3.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
name strip-ansi-cjs
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -12347,6 +12349,7 @@ word-wrap@^1.2.5:
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
name wrap-ansi-cjs
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down

0 comments on commit c4e28b1

Please sign in to comment.