From 19f5a30497bdbe76f5df3f4ca221e8122c02454d Mon Sep 17 00:00:00 2001 From: Arsalan Cheema Date: Fri, 23 Dec 2022 01:52:33 +0800 Subject: [PATCH] Update for publishing to package (#70) * update bounds and add .cabal * update readme * update version * update description * update cabal version --- .gitignore | 3 +- README.md | 10 +- cdp.cabal | 322 +++++++++++++++++++++++++++++++++++++++++++++++++++ package.yaml | 58 +++++----- 4 files changed, 359 insertions(+), 34 deletions(-) create mode 100644 cdp.cabal diff --git a/.gitignore b/.gitignore index 6f2ad1b..7601bce 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,6 @@ result result-* # haskell -*.cabal dist dist-newstyle cabal-dev @@ -26,4 +25,4 @@ cabal.sandbox.config .stack-work/ cabal.project.local .HTF/ -.ghc.environment.* \ No newline at end of file +.ghc.environment.* diff --git a/README.md b/README.md index 4a814a8..cf42487 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ whileTrue f act = do else pure [a] ``` +More examples can be found in `examples`. + ## Generating the CDP library ``` @@ -75,13 +77,9 @@ cabal run cdp-gen [Project board](https://github.com/users/arsalan0c/projects/1) Commands and events for all non-deprecated domains are supported. -The following session functionalities are supported: -- creating a session: obtain a session id by using the `pTargetAttachToTarget` function to send a `Target.attachToTarget` command, passing `True` for the flatten argument -- send a command for a particular session: use the `sendCommandForSession` function with a session id -- subscribe to events for a particular session: - 1. register a handler with a session id - 2. send the command to enable events for the domain, with the same session id +Sessions can also be created with a target (such as a tab), which can be used to restrict the scope of commands and events for the target. +See `examples/sessions.hs` for example usage. ## Contributing PRs are welcome! If you would like to discuss changes or have any feedback, feel free to open an [issue](https://github.com/arsalan0c/cdp-hs/issues). diff --git a/cdp.cabal b/cdp.cabal new file mode 100644 index 0000000..e1e3882 --- /dev/null +++ b/cdp.cabal @@ -0,0 +1,322 @@ +cabal-version: 3.0 + +-- This file has been generated from package.yaml by hpack version 0.34.6. +-- +-- see: https://github.com/sol/hpack + +name: cdp +version: 0.0.1.1 +synopsis: A library for the Chrome Devtools Protocol +description: A library for the Chrome Devtools Protocol (CDP). It provides access to Chrome, enabling tasks such as printing a page or opening a tab. + + Chrome Devtools Protocol: + + README: + + Examples: +category: Package.Category +homepage: https://github.com/arsalan0c/cdp-hs#readme +bug-reports: https://github.com/arsalan0c/cdp-hs/issues +author: Arsalan Cheema +maintainer: Arsalan Cheema +license: BSD-3-Clause +build-type: Simple +extra-doc-files: + README.md + +source-repository head + type: git + location: https://github.com/arsalan0c/cdp-hs + +library + exposed-modules: + CDP + CDP.Domains + CDP.Domains.Accessibility + CDP.Domains.Animation + CDP.Domains.Audits + CDP.Domains.BackgroundService + CDP.Domains.BrowserTarget + CDP.Domains.CacheStorage + CDP.Domains.Cast + CDP.Domains.CSS + CDP.Domains.Database + CDP.Domains.Debugger + CDP.Domains.DeviceOrientation + CDP.Domains.DOMDebugger + CDP.Domains.DOMPageNetworkEmulationSecurity + CDP.Domains.DOMSnapshot + CDP.Domains.DOMStorage + CDP.Domains.EventBreakpoints + CDP.Domains.Fetch + CDP.Domains.HeadlessExperimental + CDP.Domains.HeapProfiler + CDP.Domains.IndexedDB + CDP.Domains.Input + CDP.Domains.Inspector + CDP.Domains.IO + CDP.Domains.LayerTree + CDP.Domains.Log + CDP.Domains.Media + CDP.Domains.Memory + CDP.Domains.Overlay + CDP.Domains.Performance + CDP.Domains.PerformanceTimeline + CDP.Domains.Profiler + CDP.Domains.Runtime + CDP.Domains.ServiceWorker + CDP.Domains.Storage + CDP.Domains.SystemInfo + CDP.Domains.Tethering + CDP.Domains.Tracing + CDP.Domains.WebAudio + CDP.Domains.WebAuthn + CDP.Endpoints + CDP.Internal.Utils + CDP.Runtime + CDP.Definition + CDP.Gen.Deprecated + CDP.Gen.Program + CDP.Gen.Snippets + Main + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + src + gen + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-example-endpoints + main-is: endpoints.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + examples + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , blaze-html >=0.9.1 && <0.10 + , blaze-markup >=0.8.2 && <0.9 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , utf8-string >=1.0.2 && <1.1 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-example-open-twitter + main-is: open-twitter.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + examples + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-example-print-page + main-is: print-page.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + examples + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , base64-bytestring >=1.1.0 && <1.2 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-example-sessions + main-is: sessions.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + examples + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-example-subscribe + main-is: subscribe.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + examples + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +executable cdp-gen + main-is: Main.hs + other-modules: + CDP.Definition + CDP.Gen.Deprecated + CDP.Gen.Program + CDP.Gen.Snippets + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + gen + default-extensions: + Strict + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 + +test-suite cdp-test + type: exitcode-stdio-1.0 + main-is: Main.hs + other-modules: + Paths_cdp + autogen-modules: + Paths_cdp + hs-source-dirs: + test + ghc-options: -Wall -threaded + build-depends: + aeson >=1.5.6 && <1.6 + , base >=4.14.3 && <4.15 + , bytestring >=0.10.12 && <0.11 + , cdp + , containers >=0.6.5 && <0.7 + , data-default >=0.7.1 && <0.8 + , directory >=1.3.6 && <1.4 + , extra >=1.7.9 && <1.8 + , filepath >=1.4.2 && <1.5 + , hspec + , http-conduit >=2.3.8 && <2.4 + , monad-loops >=0.4.3 && <0.5 + , mtl >=2.2.2 && <2.3 + , network-uri >=2.6.4 && <2.7 + , process >=1.6.13 && <1.7 + , random >=1.2.0 && <1.3 + , text >=1.2.4 && <1.3 + , vector >=0.12.3 && <0.13 + , websockets >=0.12.7 && <0.13 + default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index e75fd41..71cdc37 100644 --- a/package.yaml +++ b/package.yaml @@ -1,11 +1,17 @@ name: cdp -version: 0.0.1.0 -synopsis: A library for the Chrome Devtools Protocol (CDP) +version: 0.0.1.1 +synopsis: A library for the Chrome Devtools Protocol description: " - Chrome Devtools Protocol: https://chromedevtools.github.io/devtools-protocol/ + A library for the Chrome Devtools Protocol (CDP). + It provides access to Chrome, enabling tasks such as printing a page or opening a tab. + + Chrome Devtools Protocol: + + README: + Examples: " @@ -14,6 +20,8 @@ maintainer: Arsalan Cheema github: arsalan0c/cdp-hs category: Package.Category license: BSD-3-Clause +verbatim: + cabal-version: 3.0 extra-doc-files: - README.md @@ -24,25 +32,23 @@ library: - gen dependencies: - - base ==4.14.3.0 - - aeson ==1.5.6.0 - - text ==1.2.4.1 - - bytestring ==0.10.12.0 - - containers ==0.6.5.1 - - data-default ==0.7.1.1 - - http-conduit ==2.3.8 - - mtl ==2.2.2 - - network-uri ==2.6.4.1 - - extra ==1.7.9 - - text ==1.2.4.1 - - vector ==0.12.3.1 - - websockets ==0.12.7.3 - - random ==1.2.0 - - monad-loops ==0.4.3 - - data-default ==0.7.1.1 - - process ==1.6.13.2 - - filepath ==1.4.2.1 - - directory ==1.3.6.0 +- aeson >= 1.5.6 && < 1.6 +- base >= 4.14.3 && < 4.15 +- bytestring >= 0.10.12 && < 0.11 +- containers >= 0.6.5 && < 0.7 +- text >= 1.2.4 && < 1.3 +- random >= 1.2.0 && < 1.3 +- mtl >= 2.2.2 && < 2.3 +- vector >= 0.12.3 && < 0.13 +- data-default >= 0.7.1 && < 0.8 +- directory >= 1.3.6 && < 1.4 +- filepath >= 1.4.2 && < 1.5 +- extra >= 1.7.9 && < 1.8 +- process >= 1.6.13 && < 1.7 +- http-conduit >= 2.3.8 && < 2.4 +- network-uri >= 2.6.4 && < 2.7 +- monad-loops >= 0.4.3 && < 0.5 +- websockets >= 0.12.7 && < 0.13 executables: cdp-gen: @@ -56,7 +62,7 @@ executables: main: print-page.hs dependencies: - cdp - - base64-bytestring + - base64-bytestring >= 1.1.0 && < 1.2 cdp-example-subscribe: source-dirs: examples @@ -75,9 +81,9 @@ executables: main: endpoints.hs dependencies: - cdp - - blaze-html - - blaze-markup - - utf8-string + - blaze-html >= 0.9.1 && < 0.10 + - blaze-markup >= 0.8.2 && < 0.9 + - utf8-string >= 1.0.2 && < 1.1 cdp-example-sessions: source-dirs: examples