# Webext-Bridge Messaging System

## Tong quan

AutoShopee Kit su dung **webext-bridge** lam he thong messaging chinh de giao tiep giua cac thanh phan cua browser extension: Background, Content Script, Popup va Options Page.

### Kien truc messaging

```
                        webext-bridge (v2)
  +-----------+                                    +------------+
  |  Popup /  |  --- sendMessage (EVENT_*) --->    | Background |
  |  Options  |  <-- response (Promise) --------   |  Service   |
  +-----------+                                    |  Worker    |
                                                   +-----+------+
  +-----------+                                          |
  |  Content  |  --- sendMessage (EVENT_*) --->          |
  |  Script   |  <-- response (Promise) --------        |
  +-----------+                                          |
       ^                                                 |
       |            sendMessage (tabId) ----------------+
       +------------------------------------------------+
```

### Co che hoat dong

1. **webext-bridge**: Su dung `sendMessage` / `onMessage` voi cac event name duoc dinh nghia tai `src/app/bridge/config/event.js`
2. **PostMessage API**: Giao tiep giua content script va page script (injected script) qua `window.postMessage`
3. **Chrome runtime messaging (v1)**: He thong cu (`src/app/bridge/content/v1.js`) su dung `chrome.runtime.sendMessage` truc tiep, van duoc giu lai cho tuong thich nguoc

### Cac context

| Context | Module webext-bridge | Mo ta |
|---------|---------------------|-------|
| `background` | `webext-bridge/background` | Background service worker |
| `content-script` | `webext-bridge/content-script` | Content script inject vao trang web |
| `popup` | `webext-bridge/popup` | Popup UI |
| `options` | `webext-bridge/options` | Options page |

Viec phat hien context tu dong duoc xu ly trong `src/app/bridge/config/api.js` thong qua ham `getBridgeApi()`.

## Cau hinh Event

Tat ca event name duoc dinh nghia tap trung tai:

**File**: `src/app/bridge/config/event.js`

```
EVENT_GET_USER_INFO
EVENT_GET_AFFILIATE_PLATFORM
EVENT_GET_LOCAL_SETTING
EVENT_GET_SCRIPT_URL
EVENT_OPEN_POPUP
EVENT_SHOPEE_LISTEN_FETCH
EVENT_SHOPEE_SAVE_PRODUCT
EVENT_SHOPEE_GET_PRODUCT
EVENT_SHOPEE_GET_AFFILIATE_CHAT
EVENT_SHOPEE_GET_HEADER_SHOPEE
EVENT_SHOPEE_PRODUCT_SELECT_VARIANT
EVENT_TAB_ON_CHANGE
EVENT_TAB_FETCH_URL
EVENT_TAB_GET_WEBCONTENT_HTML
EVENT_TAB_CREATE_BLOB_URL
EVENT_FETCH_API_AUTOSHOPEE
```

## Background Handlers

Background lang nghe va xu ly cac message tu Content Script, Popup va Options. Duoc dang ky trong `src/background/bridge/global.js` (webext-bridge) va `src/background/bridge/event.js` (chrome runtime v1).

### EVENT_GET_USER_INFO

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script / Popup --> Background |
| **Handler** | `onBridgeGetUserInfo` |
| **Payload gui** | Khong co |
| **Response** | `BridgeGetUserData` |

**Muc dich**: Lay thong tin nguoi dung dang dang nhap, bao gom trang thai xac thuc, goi cuoc (free/VIP), token, username.

**Cau truc response** (`BridgeGetUserData`):
- `isAuthed` (boolean) - Da dang nhap chua
- `isPaidPlan` (boolean) - Co phai goi tra phi
- `isVipPlus` (boolean) - Co phai VIP+
- `extensionPlan` (UserExtensionPlan) - Goi cuoc extension
- `userPlan` (UserDataPlan) - Goi cuoc user
- `token` (string) - Access token
- `id` (string) - User ID
- `username` (string) - Ten dang nhap
- `password` (string) - Mat khau
- `userData` (UserData) - Du lieu user day du

---

### EVENT_GET_SCRIPT_URL

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeGetScriptUrl` |
| **Payload gui** | `{ scriptPath: string }` |
| **Response** | `{ scriptUrl: string }` |

**Muc dich**: Chuyen doi duong dan tuong doi cua script thanh URL tuyet doi cua extension (su dung `chrome.runtime.getURL`). Dung de inject script vao trang web.

---

### EVENT_OPEN_POPUP

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeOpenPopup` |
| **Payload gui** | `BridgeOpenPopup` |
| **Response** | `true` |

**Muc dich**: Mo popup extension tai mot path cu the voi query string.

**Cau truc payload** (`BridgeOpenPopup`):
- `path` (string) - Duong dan trong popup (vd: `/shopee/product`)
- `qs` (object) - Query string parameters

---

### EVENT_GET_LOCAL_SETTING

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeGetLocalSetting` |
| **Payload gui** | `{ key: string }` |
| **Response** | Gia tri cua setting tuong ung |

**Muc dich**: Doc mot cai dat local tu `allSetting` theo key. Content script khong truy cap truc tiep duoc localStorage cua extension nen can gui qua background.

**Luu y**: Ham `bridgeGetSetting` (content side) se validate key truoc khi gui, nem loi `SETTING_KEY_NOT_FOUND` neu key khong ton tai.

---

### EVENT_GET_AFFILIATE_PLATFORM

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeGetAffiliatePlatform` |
| **Payload gui** | `{ platform: ShopPlatform }` |
| **Response** | URL affiliate cua platform |

**Muc dich**: Lay URL affiliate tuong ung voi tung nen tang (Shopee, Lazada, TikTok).

---

### EVENT_SHOPEE_SAVE_PRODUCT

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeShopeeSaveProduct` |
| **Payload gui** | `ShopeeProductData` |
| **Response** | `true` |

**Muc dich**: Luu thong tin san pham Shopee vao cache (CacheShopeeProduct) voi key la `{shop_id}-{item_id}`.

---

### EVENT_SHOPEE_GET_PRODUCT

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script / Options --> Background |
| **Handler** | `onBridgeShopeeGetProduct` |
| **Payload gui** | `BridgeShopeeGetProduct` |
| **Response** | `ShopeeProductData | null` |

**Muc dich**: Lay du lieu san pham Shopee da cache tu background.

**Cau truc payload** (`BridgeShopeeGetProduct`):
- `productId` (string) - Ma san pham
- `shopId` (string) - Ma shop

---

### EVENT_SHOPEE_GET_HEADER_SHOPEE

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script (v1) --> Background |
| **Handler** | `onBridgeShopeeGetHeaderShopee` |
| **Payload gui** | `{ by: BridgeShopeeGetHeader }` |
| **Response** | `Array` - Danh sach request payload |

**Muc dich**: Lay danh sach HTTP request headers da thu thap duoc tu Shopee. Co 2 loai:
- `by: "product"` - Headers tu cac request lien quan san pham (`RequestProductPayload`)
- `by: "search"` - Headers tu cac request tim kiem (`RequestSearchPayload`)

---

### EVENT_SHOPEE_LISTEN_FETCH

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeShopeeListenFetch` |
| **Payload gui** | `BridgeShopeeListenerFetch` |
| **Response** | `true` |

**Muc dich**: Content script gui cac fetch request ma no bat duoc tu trang Shopee len background de xu ly. Background se:
1. Loc URL (bo qua cac URL trong `listUrlBucketIgnore`)
2. Luu vao `FetchListenerBucketShopee`
3. Neu URL chua `pdp/cart_panel/select_variation_pc` hoac `pdp/get_pc_vsku`, xu ly them logic luu stock cua variant san pham

**Cau truc payload** (`BridgeShopeeListenerFetch`):
- `url` (string) - URL cua request da bat
- `json` (object) - Response JSON cua request do

---

### EVENT_SHOPEE_GET_AFFILIATE_CHAT

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script --> Background |
| **Handler** | `onBridgeShopeeGetAffiliateChat` |
| **Payload gui** | `BridgeShopeeAffiliateChatMesage` |
| **Response** | `string` - Noi dung chat da render, hoac `"ERROR"` |

**Muc dich**: Tao noi dung tin nhan chat affiliate tu template.

**Cau truc payload** (`BridgeShopeeAffiliateChatMesage`):
- `id` (string) - ID cua doi tuong
- `name` (string) - Ten doi tuong

---

### EVENT_FETCH_API_AUTOSHOPEE

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Content Script / Options --> Background |
| **Handler** | `handleFetchApiEvent` (BackgroundBridgeEvent class) |
| **Payload gui** | `BridgeFetchApiPayload` |
| **Response** | `object` - Response data tu API |

**Muc dich**: Thuc hien HTTP request den AutoShopee API tu background. Content script va Options page khong the goi API truc tiep do gioi han CORS, nen uy quyen cho background thuc hien.

**Cau truc payload** (`BridgeFetchApiPayload`):
- `url` (string) - URL API
- `method` (RequestMethod) - Phuong thuc HTTP (GET, POST, ...)
- `body` (object) - Body cua request
- `header` (object) - Custom headers

**Luu y**: Handler nay duoc dang ky ca trong he thong webext-bridge moi (`global.js`) va he thong chrome runtime cu (`event.js`).

## Content Script Handlers

Content script lang nghe cac message tu Background va Popup/Options.

### EVENT_TAB_FETCH_URL

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Background --> Content Script (theo tabId) |
| **Handler** | Trong `src/content/service/event.js` |
| **Payload gui** | `{ url: string, method: RequestMethod, body?: object }` |
| **Response** | JSON response tu fetch, hoac `null` |

**Muc dich**: Yeu cau content script thuc hien fetch request den Shopee API trong context cua trang web hien tai. Content script se dung `PostMessageFetchUrl` de chuyen request den page script (injected script) de thuc hien fetch voi cookie va session cua nguoi dung.

**Luong xu ly**:
1. Background goi `bridgeTabFetchShopeeUrl(tabId, payload)`
2. Content script nhan va chuyen tiep qua `PostMessageFetchUrl.sendMessage(data)`
3. Page script (inject vao trang) thuc hien fetch thuc su
4. Ket qua tra nguoc ve Background

---

### EVENT_TAB_ON_CHANGE

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Background --> Content Script (theo tabId) |
| **Handler** | Trong `src/content/service/util.js` (`onChangeTab`) |
| **Payload gui** | `object` - Du lieu tab (tabData) |
| **Response** | Khong co (callback) |

**Muc dich**: Thong bao cho content script khi co su thay doi tab (navigation, URL change). Content script se reload lai cac loader tuong ung.

**Luu y**: Background tu dong gui message nay khi `tabOnUpdate` event xay ra.

---

### EVENT_TAB_GET_WEBCONTENT_HTML

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Options --> Content Script (theo tabId) |
| **Handler** | Trong `src/content/all/listener.js` |
| **Payload gui** | `null` |
| **Response** | `string` - `document.documentElement.outerHTML` |

**Muc dich**: Lay toan bo HTML cua trang web hien tai tu content script. Dung cho cac tinh nang can phan tich noi dung trang.

---

### EVENT_TAB_CREATE_BLOB_URL

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Options --> Content Script (theo tabId) |
| **Handler** | Trong `src/content/all/listener.js` |
| **Payload gui** | `{ base64: string, type: string }` |
| **Response** | `string` - Blob URL |

**Muc dich**: Tao blob URL tu du lieu base64 trong context cua trang web. Can thiet vi blob URL chi hoat dong trong cung origin.

---

### EVENT_SHOPEE_PRODUCT_SELECT_VARIANT

| Thuoc tinh | Gia tri |
|------------|---------|
| **Huong** | Popup (Vuex store) --> Content Script (theo tabId) |
| **Handler** | Trong `src/content/shopee/client/loader.js` |
| **Payload gui** | `{ productId, shopId, requestId, listSelect }` |
| **Response** | Khong co (fire-and-forget) |

**Muc dich**: Dieu khien content script click chon cac variant san pham tren trang Shopee de thu thap thong tin stock. Popup gui danh sach variant can chon, content script tu dong tuong tac voi DOM de click.

**Cau truc payload**:
- `productId` (number) - Ma san pham
- `shopId` (number) - Ma shop
- `requestId` (string) - ID request de theo doi
- `listSelect` (Array) - Danh sach variant can click
  - `titer` (Array) - Tier index cua variant
  - `modelId` (number) - Model ID

## Popup / Options Handlers

Popup va Options page chi gui message, khong dang ky handler. Cac ham gui message duoc dinh nghia tai:

### Tu Content Script gui len Background

**File**: `src/app/bridge/content/background.js`

| Ham | Event | Payload | Response |
|-----|-------|---------|----------|
| `bridgeGetUserInfo()` | `EVENT_GET_USER_INFO` | Khong co | `BridgeGetUserData` |
| `bridgeGetScriptUrl(scriptPath)` | `EVENT_GET_SCRIPT_URL` | `{ scriptPath }` | `{ scriptUrl }` |
| `bridgeOpenPopupUrl(payload)` | `EVENT_OPEN_POPUP` | `BridgeOpenPopup` | `true` |
| `bridgeGetSetting(keySetting)` | `EVENT_GET_LOCAL_SETTING` | `{ key }` | Gia tri setting |
| `bridgeGetAffiliateUrl(platform)` | `EVENT_GET_AFFILIATE_PLATFORM` | `{ platform }` | URL |
| `bridgeShopeeSaveProductId(product)` | `EVENT_SHOPEE_SAVE_PRODUCT` | `ShopeeProductData` | `true` |
| `bridgeShopeeGetAffiliateChatMesage(payload)` | `EVENT_SHOPEE_GET_AFFILIATE_CHAT` | `BridgeShopeeAffiliateChatMesage` | `string` |
| `bridgeShopeeListenFetch(payload)` | `EVENT_SHOPEE_LISTEN_FETCH` | `BridgeShopeeListenerFetch` | `true` |
| `bridgeShopeeGetProduct(payload)` | `EVENT_SHOPEE_GET_PRODUCT` | `BridgeShopeeGetProduct` | `ShopeeProductData` |

### Tu Content Script gui len Background (v1 - chrome runtime)

**File**: `src/app/bridge/content/v1.js`

| Ham | Event | Payload | Response |
|-----|-------|---------|----------|
| `bridgeShopeeGetHeaderProduct(by)` | `EVENT_SHOPEE_GET_HEADER_SHOPEE` | `{ by }` | `Array` |
| `bridgeGetScriptUrl(scriptPath)` | `EVENT_GET_SCRIPT_URL` | `{ scriptPath }` | `{ scriptUrl }` |
| `bridgeFetchApiAutoshopee(payload)` | `EVENT_FETCH_API_AUTOSHOPEE` | `BridgeFetchApiPayload` | `object` |

### Tu Background gui den Content Script

**File**: `src/app/bridge/background/content.js`

| Ham | Event | Payload | Response |
|-----|-------|---------|----------|
| `bridgeTabFetchShopeeUrl(tabId, payload)` | `EVENT_TAB_FETCH_URL` | `{ url, method, body? }` | JSON response |
| `bridgeTabOnChange(tabId, payload)` | `EVENT_TAB_ON_CHANGE` | Tab data object | Tab ID |

### Tu Options Page gui den Background / Content Script

**File**: `src/app/bridge/options/background.js`

| Ham | Event | Huong | Payload | Response |
|-----|-------|-------|---------|----------|
| `bridgeGetWebcontentTabId(tabId)` | `EVENT_TAB_GET_WEBCONTENT_HTML` | Options --> Content Script | `null` | HTML string |
| `bridgeCreateBlobUrlTabId(payload, tabId)` | `EVENT_TAB_CREATE_BLOB_URL` | Options --> Content Script | `{ base64, type }` | Blob URL |
| `bridgeCreateBlobUrlTabCurrent(payload)` | `EVENT_TAB_CREATE_BLOB_URL` | Options --> Content Script (tab hien tai) | `{ base64, type }` | Blob URL |
| `bridgeGetWebcontentTabCurrent()` | `EVENT_TAB_GET_WEBCONTENT_HTML` | Options --> Content Script (tab hien tai) | `null` | HTML string |
| `bridgeShopeeGetProduct(payload)` | `EVENT_SHOPEE_GET_PRODUCT` | Options --> Background | `BridgeShopeeGetProduct` | `ShopeeProductData` |

**File**: `src/app/bridge/options/send.js` (v1 - chrome runtime)

| Ham | Event | Payload | Response |
|-----|-------|---------|----------|
| `bridgeFetchApiAutoshopee(payload)` | `EVENT_FETCH_API_AUTOSHOPEE` | `BridgeFetchApiPayload` | `object` |
| `bridgeTabCreateBlobUrl(tabId, payload)` | `EVENT_TAB_CREATE_BLOB_URL` | `{ base64, type }` | Blob URL |
| `bridgeGetHtmlTabId(tabId)` | `EVENT_TAB_GET_WEBCONTENT_HTML` | `null` | HTML string |

## PostMessage API

**File**: `src/app/bridge/content/postMessage.js`

He thong giao tiep giua content script va page script (script inject truc tiep vao trang web) su dung `window.postMessage`. Day la lop giao tiep thu 2, can thiet vi content script va page script chay trong cac isolated world khac nhau.

### PostMessageFetchUrl

| Thuoc tinh | Gia tri |
|------------|---------|
| **Channel** | `ATSP_FETCH_URL_REQUEST` / `ATSP_FETCH_URL_REPLY` |
| **Timeout** | 5000ms |
| **Muc dich** | Thuc hien fetch request trong context trang web (co cookie/session) |

### PostMessageFetchListener

| Thuoc tinh | Gia tri |
|------------|---------|
| **Channel** | `ATSP_FETCH_LISTENER_REQUEST` / `ATSP_FETCH_LISTENER_REPLY` |
| **Timeout** | 1000ms |
| **Muc dich** | Lang nghe va bat cac fetch request cua trang Shopee |

**Co che hoat dong**:
1. Moi message duoc gan UUID de khop request/response
2. Gui message qua `window.postMessage(payload, '*')`
3. Listener kiem tra `channelRequest` va `messageId` de xu ly dung message
4. Response gui lai qua `window.postMessage` voi `channelReply`
5. Tu dong timeout va remove listener sau thoi gian quy dinh

## Shopee API Bridge

**File**: `src/app/bridge/shopee/api.js`

Lop tien ich cap cao de thuc hien API call den Shopee thong qua bridge. Tu dong tim hoac tao tab Shopee truoc khi gui request.

| Ham | Mo ta |
|-----|-------|
| `readyFetchUrlShopeeClient(url)` | GET request den Shopee client (shopee.vn) |
| `readyPostUrlShopeeClient(url, payload)` | POST request den Shopee client |
| `readyPostUrlShopeeSeller(url, payload)` | POST request den Shopee seller (banhang.shopee.vn) |
| `getTabIdReadyFetch()` | Tim tab Shopee hop le (khong bi block/captcha) |
| `getTabIsCaptcha()` | Kiem tra co tab nao dang bi captcha khong |

**Luong xu ly**:
1. Tim tab Shopee da mo (su dung `makeTabShopeeClient` / `makeTabShopeeSellerProduct`)
2. Neu chua co tab, tu dong mo tab moi va doi load
3. Gui request qua `bridgeTabFetchShopeeUrl(tabId, payload)`
4. Loc cac tab bi block (`/verify`) hoac captcha (`/verify/captcha`)

## Shopee Tab Manager

**File**: `src/app/bridge/shopee/tab.js`

Quan ly cac tab Shopee dang mo trong trinh duyet.

| Ham | Mo ta |
|-----|-------|
| `getTabShopeeClientAny()` | Tim bat ky tab Shopee client nao |
| `getTabShopeeSellerAny()` | Tim bat ky tab Shopee seller nao |
| `getTabShopeeSellerProduct()` | Tim tab trang quan ly san pham seller |
| `makeTabShopeeSellerProduct()` | Tim hoac tao tab seller product (timeout 50s) |
| `makeTabShopeeClient(loadUrl)` | Tim hoac tao tab Shopee client (timeout 2s) |

## Danh sach tat ca Messages

### Tong hop theo huong giao tiep

#### Content Script --> Background

| Event | Muc dich |
|-------|----------|
| `EVENT_GET_USER_INFO` | Lay thong tin nguoi dung |
| `EVENT_GET_SCRIPT_URL` | Lay URL tuyet doi cua script |
| `EVENT_OPEN_POPUP` | Mo popup tai path cu the |
| `EVENT_GET_LOCAL_SETTING` | Doc cai dat local |
| `EVENT_GET_AFFILIATE_PLATFORM` | Lay URL affiliate theo platform |
| `EVENT_SHOPEE_SAVE_PRODUCT` | Luu san pham Shopee vao cache |
| `EVENT_SHOPEE_GET_PRODUCT` | Lay san pham Shopee tu cache |
| `EVENT_SHOPEE_GET_HEADER_SHOPEE` | Lay HTTP headers da thu thap |
| `EVENT_SHOPEE_LISTEN_FETCH` | Gui fetch data da bat duoc |
| `EVENT_SHOPEE_GET_AFFILIATE_CHAT` | Tao noi dung chat affiliate |
| `EVENT_FETCH_API_AUTOSHOPEE` | Goi API AutoShopee qua background |

#### Background --> Content Script

| Event | Muc dich |
|-------|----------|
| `EVENT_TAB_FETCH_URL` | Yeu cau fetch URL trong context trang web |
| `EVENT_TAB_ON_CHANGE` | Thong bao tab da thay doi |

#### Popup --> Content Script

| Event | Muc dich |
|-------|----------|
| `EVENT_SHOPEE_PRODUCT_SELECT_VARIANT` | Click chon variant san pham |

#### Options --> Content Script

| Event | Muc dich |
|-------|----------|
| `EVENT_TAB_GET_WEBCONTENT_HTML` | Lay HTML cua trang web |
| `EVENT_TAB_CREATE_BLOB_URL` | Tao blob URL tu base64 |

#### Options --> Background

| Event | Muc dich |
|-------|----------|
| `EVENT_SHOPEE_GET_PRODUCT` | Lay san pham Shopee tu cache |
| `EVENT_FETCH_API_AUTOSHOPEE` | Goi API AutoShopee qua background |

#### Content Script <--> Page Script (PostMessage)

| Channel | Muc dich |
|---------|----------|
| `ATSP_FETCH_URL` | Thuc hien fetch trong context trang |
| `ATSP_FETCH_LISTENER` | Bat va chuyen tiep fetch cua trang |

### Tong hop theo file

| File | Vai tro |
|------|---------|
| `src/app/bridge/config/event.js` | Dinh nghia tat ca event name |
| `src/app/bridge/config/api.js` | Tu dong phat hien context va khoi tao bridge API |
| `src/app/bridge/background/content.js` | Background gui message den content script |
| `src/app/bridge/content/background.js` | Content script gui message den background (webext-bridge) |
| `src/app/bridge/content/v1.js` | Content script gui message den background (chrome runtime) |
| `src/app/bridge/content/postMessage.js` | Giao tiep content script <--> page script |
| `src/app/bridge/content/tab.js` | Tab service gui message den content script (chrome runtime) |
| `src/app/bridge/options/background.js` | Options page gui message den background/content (webext-bridge) |
| `src/app/bridge/options/send.js` | Options page gui message (chrome runtime) |
| `src/app/bridge/shopee/api.js` | Tien ich fetch Shopee API qua bridge |
| `src/app/bridge/shopee/tab.js` | Quan ly tab Shopee |
| `src/background/bridge/global.js` | Dang ky handlers phia background (webext-bridge) |
| `src/background/bridge/event.js` | Dang ky handlers phia background (chrome runtime) |
| `src/content/service/event.js` | Handler `EVENT_TAB_FETCH_URL` + listener fetch |
| `src/content/service/util.js` | Handler `EVENT_TAB_ON_CHANGE` |
| `src/content/all/listener.js` | Handler `EVENT_TAB_GET_WEBCONTENT_HTML` + `EVENT_TAB_CREATE_BLOB_URL` |
| `src/content/shopee/client/loader.js` | Handler `EVENT_SHOPEE_PRODUCT_SELECT_VARIANT` |
| `src/app/types/Bridge.js` | Type definitions cho bridge payloads |
| `src/app/types/Bridge/Get.js` | Type definition `BridgeGetUserData` |
