Skip to content

Commit

Permalink
feat: add bundle des for web
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhouYixun committed Oct 16, 2022
1 parent ccc82cd commit 77bc54a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
7 changes: 7 additions & 0 deletions src/entity/wirMessage.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,10 @@ type UrlItem struct {
WebSocketDebuggerUrl string `json:"webSocketDebuggerUrl"`
DevtoolsFrontendUrl string `json:"devtoolsFrontendUrl"`
}

type BundleItem struct {
PID string `json:"pid,omitempty"`
BundleId string `json:"bundleId,omitempty"`
Name string `json:"name,omitempty"`
Pages []UrlItem `json:"pages,omitempty"`
}
21 changes: 17 additions & 4 deletions src/webinspector/webkitDebugService.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,17 @@ func (w *WebkitDebugService) FindPagesByID(pageId string) (application *entity.W
return nil, nil, fmt.Errorf("not find page")
}

func (w *WebkitDebugService) GetOpenPages(port int) ([]entity.UrlItem, error) {
func (w *WebkitDebugService) GetOpenPages(port int) ([]entity.BundleItem, error) {
var wg = sync.WaitGroup{}
for key, _ := range w.connectedApplication {
var result []entity.BundleItem
for key, app := range w.connectedApplication {
wg.Add(1)
var bundleItem = &entity.BundleItem{
BundleId: *app.ApplicationBundle,
Name: *app.ApplicationName,
PID: *app.ApplicationID,
}
result = append(result, *bundleItem)
go func(key string) {
err := w.rpcService.SendForwardGetListing(&w.connectID, &key)
if err != nil {
Expand All @@ -185,8 +192,8 @@ func (w *WebkitDebugService) GetOpenPages(port int) ([]entity.UrlItem, error) {
}(key)
}
wg.Wait()
var pages []entity.UrlItem
for appID, _ := range w.applicationPages {
var pages []entity.UrlItem
for pageID, page := range w.applicationPages[appID] {
//if page.PageType != entity.WEB && page.PageType != entity.WEB_PAGE {
// continue
Expand All @@ -202,8 +209,14 @@ func (w *WebkitDebugService) GetOpenPages(port int) ([]entity.UrlItem, error) {
}
pages = append(pages, *pageItem)
}
for k, v := range result {
if v.PID == appID {
result[k].Pages = pages
break
}
}
}
return pages, nil
return result, nil
}

func (w *WebkitDebugService) sendWebkitProtocolCommand(applicationID *string, pageID *int, message []byte) {
Expand Down

0 comments on commit 77bc54a

Please sign in to comment.