mirror of
https://github.com/XFox111/TabsAsideExtension.git
synced 2026-07-02 19:52:47 +03:00
Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c0037cc3a7 | |||
| db30e81765 | |||
| 7e57488896 | |||
| 61d0e54e58 | |||
| a03f2ab442 | |||
| 2f6ed6cbfa | |||
| aac4ac9a7e | |||
| bc2e2489e6 | |||
| 57e87aace0 | |||
| 5f2d18f509 | |||
| 54a1e48672 |
@@ -38,7 +38,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:20
|
||||
container: node:24
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -51,7 +51,14 @@ jobs:
|
||||
echo "WXT_GA4_API_SECRET=${{ secrets.GA4_SECRET }}" >> .env
|
||||
echo "WXT_GA4_MEASUREMENT_ID=${{ secrets.GA4_MEASUREMENT_ID }}" >> .env
|
||||
|
||||
- run: corepack enable
|
||||
- run: yarn install
|
||||
|
||||
# Patch for firefox dnd popup (see https://github.com/clauderic/dnd-kit/issues/1043)
|
||||
- run: grep -v "this.windowListeners.add(EventName.Resize, this.handleCancel);" core.esm.js > core.esm.js.tmp && mv core.esm.js.tmp core.esm.js
|
||||
working-directory: ./node_modules/@dnd-kit/core/dist
|
||||
if: ${{ matrix.target == 'firefox' }}
|
||||
|
||||
- run: yarn zip -b ${{ matrix.target }}
|
||||
|
||||
- name: Drop build artifacts (${{ matrix.target }})
|
||||
@@ -68,7 +75,7 @@ jobs:
|
||||
extension-root: ./.output/firefox-mv3
|
||||
self-hosted: false
|
||||
|
||||
- run: yarn audit
|
||||
- run: yarn npm audit
|
||||
continue-on-error: ${{ github.event_name != 'release' && github.event.inputs.bypass_audit == 'true' }}
|
||||
|
||||
publish-github:
|
||||
|
||||
@@ -30,7 +30,7 @@ on:
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
container: node:23
|
||||
container: node:24
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -43,7 +43,14 @@ jobs:
|
||||
echo "WXT_GA4_API_SECRET=${{ secrets.GA4_SECRET }}" >> .env
|
||||
echo "WXT_GA4_MEASUREMENT_ID=${{ secrets.GA4_MEASUREMENT_ID }}" >> .env
|
||||
|
||||
- run: corepack enable
|
||||
- run: yarn install
|
||||
|
||||
# Patch for firefox dnd popup (see https://github.com/clauderic/dnd-kit/issues/1043)
|
||||
- run: grep -v "this.windowListeners.add(EventName.Resize, this.handleCancel);" core.esm.js > core.esm.js.tmp && mv core.esm.js.tmp core.esm.js
|
||||
working-directory: ./node_modules/@dnd-kit/core/dist
|
||||
if: ${{ matrix.target == 'firefox' }}
|
||||
|
||||
- run: yarn zip -b ${{ matrix.target }}
|
||||
|
||||
- name: Drop artifacts (${{ matrix.target }})
|
||||
@@ -60,4 +67,4 @@ jobs:
|
||||
extension-root: ./.output/firefox-mv3
|
||||
self-hosted: false
|
||||
|
||||
- run: yarn audit
|
||||
- run: yarn npm audit
|
||||
|
||||
@@ -8,6 +8,7 @@ pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
|
||||
node_modules
|
||||
.yarn/
|
||||
.output
|
||||
stats.html
|
||||
stats-*.json
|
||||
|
||||
+117
@@ -0,0 +1,117 @@
|
||||
nodeLinker: node-modules
|
||||
|
||||
packageExtensions:
|
||||
"@wxt-dev/module-react@*":
|
||||
peerDependencies:
|
||||
vite: "*"
|
||||
"@fluentui/react-accordion@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-avatar@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-carousel@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-color-picker@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-combobox@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-dialog@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-field@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-list@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-menu@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-nav@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-overflow@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-popover@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-swatch-picker@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-table@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-tabs@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-tag-picker@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-teaching-popover@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-toolbar@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-tree@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-alert@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-checkbox@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-components@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-drawer@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-infobutton@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-infolabel@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-input@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-persona@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-progress@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-radio@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-select@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-skeleton@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-slider@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-spinbutton@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-switch@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-tags@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-textarea@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
"@fluentui/react-search@*":
|
||||
peerDependencies:
|
||||
scheduler: "0.23.0"
|
||||
@@ -39,16 +39,19 @@ body
|
||||
/* Handle */
|
||||
::-webkit-scrollbar-thumb
|
||||
{
|
||||
/* eslint-disable-next-line css/no-invalid-properties */
|
||||
background-color: var(--colorNeutralStroke1);
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover
|
||||
{
|
||||
/* eslint-disable-next-line css/no-invalid-properties */
|
||||
background-color: var(--colorNeutralStroke1Hover);
|
||||
}
|
||||
|
||||
::-webkit-scrollbar-thumb:hover:active
|
||||
{
|
||||
/* eslint-disable-next-line css/no-invalid-properties */
|
||||
background-color: var(--colorNeutralStroke1Pressed);
|
||||
}
|
||||
|
||||
@@ -99,12 +99,23 @@ export const useStyles_GroupView = makeStyles({
|
||||
display: "flex",
|
||||
columnGap: tokens.spacingHorizontalS,
|
||||
rowGap: tokens.spacingHorizontalSNudge,
|
||||
height: "100%"
|
||||
height: "100%",
|
||||
position: "relative"
|
||||
},
|
||||
verticalList:
|
||||
{
|
||||
flexFlow: "column"
|
||||
},
|
||||
verticalListCollapsed:
|
||||
{
|
||||
maxHeight: "136px",
|
||||
overflow: "clip"
|
||||
},
|
||||
horizontalListCollapsed:
|
||||
{
|
||||
maxWidth: "400px",
|
||||
overflow: "clip"
|
||||
},
|
||||
listContainer:
|
||||
{
|
||||
padding: `${tokens.spacingVerticalS} ${tokens.spacingHorizontalXS}`,
|
||||
|
||||
@@ -88,7 +88,13 @@ export default function GroupView({ group, indices, dragOverlay }: GroupViewProp
|
||||
<Caption1Strong>{ i18n.t("groups.empty") }</Caption1Strong>
|
||||
</div>
|
||||
:
|
||||
<div className={ mergeClasses(cls.list, !tilesView && cls.verticalList) }>
|
||||
<div
|
||||
className={ mergeClasses(
|
||||
cls.list,
|
||||
!tilesView && cls.verticalList,
|
||||
((active?.item.type === "group" && active?.indices[0] === indices[0]) || dragOverlay) && (tilesView ? cls.horizontalListCollapsed : cls.verticalListCollapsed)
|
||||
) }
|
||||
>
|
||||
<SortableContext
|
||||
items={ group.items.map((_, index) => [...indices, index].join("/")) }
|
||||
disabled={ disableSorting }
|
||||
|
||||
@@ -8,6 +8,7 @@ export const useStyles_TabView = makeStyles({
|
||||
|
||||
width: "160px",
|
||||
height: "120px",
|
||||
flexShrink: 0,
|
||||
marginBottom: tokens.spacingVerticalSNudge,
|
||||
|
||||
border: `${tokens.strokeWidthThin} solid ${tokens.colorNeutralStroke3}`,
|
||||
|
||||
@@ -21,6 +21,7 @@ import { collisionDetector } from "../../utils/dnd/collisionDetector";
|
||||
import { useStyles_CollectionListView } from "./CollectionListView.styles";
|
||||
import SearchBar from "./SearchBar";
|
||||
import StorageCapacityIssueMessage from "./messages/StorageCapacityIssueMessage";
|
||||
import { snapHandleToCursor } from "../../utils/dnd/snapHandleToCursor";
|
||||
|
||||
export default function CollectionListView(): ReactElement
|
||||
{
|
||||
@@ -110,6 +111,7 @@ export default function CollectionListView(): ReactElement
|
||||
collisionDetection={ collisionDetector(!tilesView) }
|
||||
onDragStart={ handleDragStart }
|
||||
onDragEnd={ handleDragEnd }
|
||||
modifiers={ [snapHandleToCursor] }
|
||||
>
|
||||
<SortableContext
|
||||
items={ resultList.map((_, index) => index.toString()) }
|
||||
|
||||
@@ -33,9 +33,11 @@ export function collisionDetector(vertical?: boolean): CollisionDetection
|
||||
|
||||
if (activeItem.item.type === "collection")
|
||||
{
|
||||
// If we drag a collection, we should ignore other items, like tabs or groups
|
||||
if (droppableItem.item.type !== "collection")
|
||||
continue;
|
||||
|
||||
// Using distance between centers
|
||||
value = distanceBetween(centerOfRectangle(rect), centerRect);
|
||||
collisions.push({ id, data: { droppableContainer, value } });
|
||||
continue;
|
||||
@@ -44,14 +46,20 @@ export function collisionDetector(vertical?: boolean): CollisionDetection
|
||||
const intersectionRatio: number = getIntersectionRatio(rect, collisionRect);
|
||||
const intersectionCoefficient: number = intersectionRatio / getMaxIntersectionRatio(rect, collisionRect);
|
||||
|
||||
// Dragging a tab or a group over a collection
|
||||
if (droppableItem.item.type === "collection")
|
||||
{
|
||||
// Ignoring collection, if the tab or the group is inside that collection
|
||||
if (activeItem.indices.length === 2 && activeItem.indices[0] === droppableItem.indices[0])
|
||||
continue;
|
||||
|
||||
if (intersectionCoefficient < 0.7 && activeItem.item.type === "tab")
|
||||
// Ignoring collection if we're dragging a tab or a group that doesn't belong to the collection,
|
||||
// but intersection ratio is less than 0.7
|
||||
if (intersectionCoefficient < 0.7)
|
||||
continue;
|
||||
|
||||
// If we're dragging a tab, that's inside a group that belongs to the collection,
|
||||
// we substract the group's intersection from the collection's one
|
||||
if (activeItem.indices.length === 3 && activeItem.indices[0] === droppableItem.indices[0])
|
||||
{
|
||||
const [collectionId, groupId] = activeItem.indices;
|
||||
@@ -62,16 +70,23 @@ export function collisionDetector(vertical?: boolean): CollisionDetection
|
||||
|
||||
value = 1 / (intersectionRatio - getIntersectionRatio(groupRect, collisionRect));
|
||||
}
|
||||
// Otherwise, use intersection ratio
|
||||
// At this point we're dragging either:
|
||||
// - a group, that doesn't belong to the collection
|
||||
// - a tab, that either belongs to the collection's group, or has intersection coefficient >= .7
|
||||
else
|
||||
{
|
||||
value = 1 / intersectionRatio;
|
||||
value = 2 / intersectionRatio;
|
||||
}
|
||||
}
|
||||
// If we're dragging a tab or a group over another group's dropzone
|
||||
else if (droppableItem.item.type === "group" && (id as string).endsWith("_dropzone"))
|
||||
{
|
||||
// Ignore, if we're dragging a group
|
||||
if (activeItem.item.type === "group")
|
||||
continue;
|
||||
|
||||
// Ignore, if we're dragging a tab, that's inside the group
|
||||
if (
|
||||
activeItem.indices.length === 3 &&
|
||||
activeItem.indices[0] === droppableItem.indices[0] &&
|
||||
@@ -79,11 +94,15 @@ export function collisionDetector(vertical?: boolean): CollisionDetection
|
||||
)
|
||||
continue;
|
||||
|
||||
// Ignore, if coefficient is less than .5
|
||||
// (at this point we're dragging a tab, that's outside of the group's dropzone)
|
||||
if (intersectionCoefficient < 0.5)
|
||||
continue;
|
||||
|
||||
// Use intersection between the tab and the group's dropzone
|
||||
value = 1 / intersectionRatio;
|
||||
}
|
||||
// We're dragging a group or a tab over its sibling
|
||||
else if (activeItem.indices.length === droppableItem.indices.length)
|
||||
{
|
||||
if (activeItem.indices[0] !== droppableItem.indices[0])
|
||||
@@ -92,9 +111,22 @@ export function collisionDetector(vertical?: boolean): CollisionDetection
|
||||
if (activeItem.indices.length === 3 && activeItem.indices[1] !== droppableItem.indices[1])
|
||||
continue;
|
||||
|
||||
// Ignore pinned groups
|
||||
if (droppableItem.item.type === "group" && droppableItem.item.pinned === true)
|
||||
continue;
|
||||
|
||||
const collectionRect: ClientRect | undefined = droppableRects.get(activeItem.indices[0].toString());
|
||||
|
||||
if (!collectionRect)
|
||||
continue;
|
||||
|
||||
const collectionIntersectionRatio: number = getIntersectionRatio(collectionRect, collisionRect);
|
||||
const collectionIntersectionCoefficient: number = collectionIntersectionRatio / getMaxIntersectionRatio(collectionRect, collisionRect);
|
||||
|
||||
// Ignore if we are outside of the home collection
|
||||
if (collectionIntersectionCoefficient < 0.7)
|
||||
continue;
|
||||
|
||||
if (activeItem.item.type === "tab" && droppableItem.item.type === "tab")
|
||||
{
|
||||
value = distanceBetween(centerOfRectangle(rect), centerRect);
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Modifier } from "@dnd-kit/core";
|
||||
import { Coordinates, getEventCoordinates } from "@dnd-kit/utilities";
|
||||
import { DndItem } from "../../hooks/useDndItem";
|
||||
|
||||
export const snapHandleToCursor: Modifier = ({
|
||||
activatorEvent,
|
||||
draggingNodeRect,
|
||||
transform,
|
||||
active
|
||||
}) =>
|
||||
{
|
||||
if (draggingNodeRect && activatorEvent)
|
||||
{
|
||||
const activeItem: DndItem | undefined = active?.data.current as DndItem;
|
||||
const activatorCoordinates: Coordinates | null = getEventCoordinates(activatorEvent);
|
||||
|
||||
if (!activatorCoordinates)
|
||||
return transform;
|
||||
|
||||
const initX: number = activatorCoordinates.x - draggingNodeRect.left;
|
||||
const initY: number = activatorCoordinates.y - draggingNodeRect.top;
|
||||
|
||||
const offsetX: number = activeItem?.item.type === "group" ? 24 : draggingNodeRect.height / 2;
|
||||
const offsetY: number = activeItem?.item.type === "group" ? 20 : draggingNodeRect.height / 2;
|
||||
|
||||
return {
|
||||
...transform,
|
||||
x: transform.x + initX - offsetX,
|
||||
y: transform.y + initY - offsetY
|
||||
};
|
||||
}
|
||||
|
||||
return transform;
|
||||
};
|
||||
+4
-4
@@ -149,13 +149,13 @@ collections:
|
||||
title: "Требуется разрешение"
|
||||
message:
|
||||
edge:
|
||||
p1: "Расширению необходимо дополнительное разрешение чтобы открыть вкладки в режиме InPrivate"
|
||||
p1: "Расширению необходимо дополнительное разрешение, чтобы открыть вкладки в режиме InPrivate"
|
||||
p2: "Для этого нажмите \"Настройки\" и затем отметьте опцию \"Разрешить в режиме InPrivate\""
|
||||
firefox:
|
||||
p1: "Расширению необходимо дополнительное разрешение чтобы открыть вкладки в приватном окне"
|
||||
p1: "Расширению необходимо дополнительное разрешение, чтобы открыть вкладки в приватном окне"
|
||||
p2: "Для этого нажмите \"Настройки\", перейдите в \"Подробности\" и разрешите \"Запуск в приватных окнах\""
|
||||
chrome:
|
||||
p1: "Расширению необходимо дополнительное разрешение чтобы открыть вкладки в режиме инкогнито"
|
||||
p1: "Расширению необходимо дополнительное разрешение, чтобы открыть вкладки в режиме инкогнито"
|
||||
p2: "Для этого нажмите \"Настройки\" и отметьте опцию \"Разрешить использование в режиме инкогнито\""
|
||||
action: "Настройки"
|
||||
menu:
|
||||
@@ -246,6 +246,6 @@ parse_error_message:
|
||||
|
||||
merge_conflict_message:
|
||||
title: "В локальном и облачном хранилищах есть конфликтующие изменения."
|
||||
message: "Чтобы это исправить, вы можете сохранить локальную копию в облако, либо принять изменения из облака."
|
||||
message: "Чтобы это исправить, вы можете сохранить локальную копию в облако либо принять изменения из облака."
|
||||
accept_local: "Заменить локальной"
|
||||
accept_cloud: "Принять облачные изменения"
|
||||
|
||||
+1
-1
@@ -246,6 +246,6 @@ parse_error_message:
|
||||
|
||||
merge_conflict_message:
|
||||
title: "В локальному і облачному хранилищах є конфліктуючі зміни."
|
||||
message: "Щоб це виправити, ви можете зберегти локальну копію в хмарі, або прийняти зміни з хмари."
|
||||
message: "Щоб це виправити, ви можете зберегти локальну копію в хмарі або прийняти зміни з хмари."
|
||||
accept_local: "Заменить локальною"
|
||||
accept_cloud: "Прийняти облачні зміни"
|
||||
|
||||
+21
-21
@@ -1,47 +1,47 @@
|
||||
{
|
||||
"name": "tabs-aside",
|
||||
"private": true,
|
||||
"version": "3.0.0-rc7",
|
||||
"version": "3.0.0-rc8",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "wxt",
|
||||
"build": "wxt build --mv3",
|
||||
"zip": "wxt zip --mv3",
|
||||
"build": "yarn lint && wxt build --mv3",
|
||||
"zip": "yarn lint && wxt zip --mv3",
|
||||
"lint": "tsc --noEmit && eslint . -c eslint.config.js",
|
||||
"prebuild": "yarn lint",
|
||||
"prezip": "yarn lint",
|
||||
"postinstall": "wxt prepare"
|
||||
"prepare": "wxt prepare",
|
||||
"postinstall": "yarn prepare"
|
||||
},
|
||||
"dependencies": {
|
||||
"@dnd-kit/core": "^6.3.1",
|
||||
"@dnd-kit/modifiers": "^9.0.0",
|
||||
"@dnd-kit/sortable": "^10.0.0",
|
||||
"@dnd-kit/utilities": "^3.2.2",
|
||||
"@fluentui/react-components": "^9.63.0",
|
||||
"@fluentui/react-icons": "^2.0.298",
|
||||
"@webext-core/messaging": "^2.2.0",
|
||||
"@wxt-dev/analytics": "^0.4.1",
|
||||
"@wxt-dev/i18n": "^0.2.3",
|
||||
"@fluentui/react-components": "^9.67.0",
|
||||
"@fluentui/react-icons": "^2.0.306",
|
||||
"@webext-core/messaging": "^2.3.0",
|
||||
"@wxt-dev/analytics": "0.4.1",
|
||||
"@wxt-dev/i18n": "^0.2.4",
|
||||
"lzutf8": "^0.6.3",
|
||||
"react": "^18.3.1",
|
||||
"react": "18.3.1",
|
||||
"react-dom": "18.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/css": "^0.7.0",
|
||||
"@eslint/js": "^9.26.0",
|
||||
"@eslint/json": "^0.12.0",
|
||||
"@stylistic/eslint-plugin": "^4.2.0",
|
||||
"@eslint/css": "^0.10.0",
|
||||
"@eslint/js": "^9.31.0",
|
||||
"@eslint/json": "^0.13.0",
|
||||
"@stylistic/eslint-plugin": "^5.2.0",
|
||||
"@types/react": "^18.3.1",
|
||||
"@types/react-dom": "^18.3.1",
|
||||
"@types/scheduler": "^0",
|
||||
"@wxt-dev/module-react": "^1.1.3",
|
||||
"eslint": "^9.26.0",
|
||||
"eslint": "^9.31.0",
|
||||
"eslint-plugin-react": "^7.37.5",
|
||||
"globals": "^16.0.0",
|
||||
"globals": "^16.3.0",
|
||||
"scheduler": "0.23.0",
|
||||
"typescript": "^5.8.3",
|
||||
"typescript-eslint": "^8.31.1",
|
||||
"vite": "^6.3.4",
|
||||
"typescript-eslint": "^8.37.0",
|
||||
"vite": "^6.3.5",
|
||||
"wxt": "~0.19.29"
|
||||
},
|
||||
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
|
||||
"packageManager": "yarn@4.9.2"
|
||||
}
|
||||
|
||||
+8
-4
@@ -1,6 +1,6 @@
|
||||
import { trackError } from "@/features/analytics";
|
||||
import { GraphicsStorage } from "@/models/CollectionModels";
|
||||
import { defineExtensionMessaging, ExtensionMessagingConfig, ExtensionMessenger } from "@webext-core/messaging";
|
||||
import { defineExtensionMessaging, ExtensionMessagingConfig, ExtensionMessenger, ExtensionSendMessageArgs, GetDataType, GetReturnType } from "@webext-core/messaging";
|
||||
|
||||
type ProtocolMap =
|
||||
{
|
||||
@@ -11,16 +11,20 @@ type ProtocolMap =
|
||||
|
||||
function defineMessaging(config?: ExtensionMessagingConfig): ExtensionMessenger<ProtocolMap>
|
||||
{
|
||||
const { onMessage, sendMessage, removeAllListeners } = defineExtensionMessaging<ProtocolMap>(config);
|
||||
const { onMessage, sendMessage, removeAllListeners }: ExtensionMessenger<ProtocolMap> = defineExtensionMessaging<ProtocolMap>(config);
|
||||
|
||||
return {
|
||||
onMessage,
|
||||
removeAllListeners,
|
||||
sendMessage: async (type, data, args): Promise<any> =>
|
||||
async sendMessage<TType extends keyof ProtocolMap>(
|
||||
type: TType,
|
||||
data: GetDataType<ProtocolMap[TType]>,
|
||||
...args: ExtensionSendMessageArgs
|
||||
): Promise<GetReturnType<ProtocolMap[TType]>>
|
||||
{
|
||||
try
|
||||
{
|
||||
return await sendMessage(type, data, args);
|
||||
return await sendMessage(type, data, ...args);
|
||||
}
|
||||
catch (ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user