Skip to content

Commit c22dc0b

Browse files
klntskyf-f
andauthored
Updates for v0.14 (#46)
Co-authored-by: Fabrizio Ferrai <[email protected]>
1 parent 58ce738 commit c22dc0b

26 files changed

+227
-487
lines changed

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
"scripts": {
1818
"test": "spago docs --no-search && ./dist/purescript-docs-search build-index && spago test && npm run check-version",
1919
"bundle-app": "spago bundle-app --no-build --no-install -m Docs.Search.App --to dist/docs-search-app.js",
20-
"parcel-app": "parcel build --no-source-maps --target browser --out-file dist/docs-search-app.js dist/docs-search-app.js",
21-
"build-app": "npm run bundle-app && npm run parcel-app",
20+
"esbuild-app": "esbuild dist/docs-search-app.js --target=es2016 --bundle --minify --outfile=dist/docs-search-app.min.js && mv dist/docs-search-app.min.js dist/docs-search-app.js",
21+
"build-app": "npm run bundle-app && npm run esbuild-app",
2222
"bundle-main": "spago bundle-app --no-build --no-install -m Docs.Search.Main --to dist/main.js",
23-
"parcel-main": "parcel build --no-source-maps --target node --bundle-node-modules --out-file dist/main.js dist/main.js",
23+
"esbuild-main": "esbuild dist/main.js --platform=node --bundle --minify --outfile=dist/main.min.js && mv dist/main.min.js dist/main.js",
2424
"add-shebang": "echo \"#!/usr/bin/env node\" > dist/purescript-docs-search && cat dist/main.js >> dist/purescript-docs-search",
2525
"chmod-main": "chmod +x dist/purescript-docs-search",
26-
"build-main": "npm run bundle-main && npm run parcel-main && npm run add-shebang && rm dist/main.js && npm run chmod-main",
26+
"build-main": "npm run bundle-main && npm run esbuild-main && npm run add-shebang && rm dist/main.js && npm run chmod-main",
2727
"build": "spago build && npm run build-app && npm run build-main",
28-
"build-dev": "spago build && npm run build-app && npm run bundle-main && npm run add-shebang && rm dist/main.js && npm run chmod-main",
2928
"clean": "rm -rf dist",
3029
"check-version": "[ \"$(./dist/purescript-docs-search version)\" = \"$npm_package_version\" ]"
3130
},
@@ -44,10 +43,10 @@
4443
"homepage": "https://github.com/spacchetti/purescript-docs-search#readme",
4544
"dependencies": {},
4645
"devDependencies": {
46+
"esbuild": "^0.11.10",
4747
"glob": "^7.1.6",
48-
"markdown-it": "^11.0.0",
49-
"parcel": "^1.12.4",
50-
"puppeteer": "^5.2.1",
51-
"spago": "^0.15.3"
48+
"markdown-it": "^12.0.4",
49+
"puppeteer": "^8.0.0",
50+
"spago": "^0.20.0"
5251
}
5352
}

packages.dhall

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ let mkPackage =
22
https://raw.githubusercontent.com/purescript/package-sets/psc-0.13.2-20190725/src/mkPackage.dhall sha256:0b197efa1d397ace6eb46b243ff2d73a3da5638d8d0ac8473e8e4a8fc528cf57
33

44
let upstream =
5-
https://github.com/purescript/package-sets/releases/download/psc-0.13.8-20200724/packages.dhall sha256:bb941d30820a49345a0e88937094d2b9983d939c9fd3a46969b85ce44953d7d9
5+
https://github.com/purescript/package-sets/releases/download/psc-0.14.0-20210409/packages.dhall sha256:e81c2f2ce790c0e0d79869d22f7a37d16caeb5bd81cfda71d46c58f6199fd33f
66

77
let overrides = {=}
88

@@ -13,12 +13,13 @@ let additions =
1313
, "avar"
1414
, "console"
1515
, "const"
16-
, "coroutines"
1716
, "dom-indexed"
17+
, "effect"
1818
, "foreign"
1919
, "fork"
2020
, "free"
2121
, "freeap"
22+
, "halogen-subscriptions"
2223
, "halogen-vdom"
2324
, "media-types"
2425
, "nullable"
@@ -28,15 +29,29 @@ let additions =
2829
, "transformers"
2930
, "unsafe-coerce"
3031
, "unsafe-reference"
32+
, "web-file"
3133
, "web-uievents"
3234
]
33-
"https://github.com/slamdata/purescript-halogen.git"
34-
"v5.0.0-rc.6"
35+
"https://github.com/purescript-halogen/purescript-halogen.git"
36+
"v6.1.0"
3537
, halogen-css =
3638
mkPackage
37-
[ "css", "halogen" ]
39+
[ "halogen" ]
3840
"https://github.com/slamdata/purescript-halogen-css.git"
3941
"v8.0.0"
42+
, memoize =
43+
mkPackage
44+
[ "prelude"
45+
, "lazy"
46+
, "either"
47+
, "maybe"
48+
, "tuples"
49+
, "integers"
50+
, "lists"
51+
, "strings"
52+
]
53+
"https://github.com/paf31/purescript-memoize.git"
54+
"9960694e82adc212fd89f8ed8778cf55fcb72aeb"
4055
, optparse =
4156
mkPackage
4257
[ "prelude"
@@ -46,14 +61,14 @@ let additions =
4661
, "ordered-collections"
4762
, "arrays"
4863
, "console"
49-
, "memoize"
5064
, "transformers"
5165
, "exists"
5266
, "node-process"
5367
, "free"
68+
, "memoize"
5469
]
55-
"https://github.com/f-o-a-m/purescript-optparse.git"
56-
"v3.0.1"
70+
"https://github.com/srghma/purescript-optparse.git"
71+
"d49b03fcd35f5be167e9c5c44ab1c17ca0956fb1"
5772
, exitcodes =
5873
mkPackage
5974
[ "enums" ]
@@ -66,9 +81,9 @@ let additions =
6681
"v0.4.0"
6782
, html-parser-halogen =
6883
mkPackage
69-
[ "string-parsers", "generics-rep", "halogen" ]
84+
[ "string-parsers", "halogen" ]
7085
"https://github.com/rnons/purescript-html-parser-halogen.git"
71-
"890da763cdd2a1049ab8837e477c5ba1fcf6d4ce"
86+
"458e492e441fcf69a66911b7b64beea5849e0dad"
7287
, markdown-it-halogen =
7388
mkPackage
7489
[ "markdown-it", "html-parser-halogen" ]
@@ -86,6 +101,32 @@ let additions =
86101
]
87102
"https://github.com/justinwoo/purescript-toppokki.git"
88103
"v2.4.0"
104+
, search-trie =
105+
mkPackage
106+
[ "prelude"
107+
, "arrays"
108+
, "ordered-collections"
109+
, "lists"
110+
, "foldable-traversable"
111+
, "bifunctors"
112+
]
113+
"https://github.com/klntsky/purescript-search-trie.git"
114+
"e7f7f22486a1dba22171ec885dbc2149dc815119"
115+
, css =
116+
mkPackage
117+
[ "colors"
118+
, "console"
119+
, "effect"
120+
, "exceptions"
121+
, "nonempty"
122+
, "profunctor"
123+
, "psci-support"
124+
, "strings"
125+
, "these"
126+
, "transformers"
127+
]
128+
"https://github.com/purescript-contrib/purescript-css.git"
129+
"5c1a44ee95c259352a2b4570b060de14130540bc"
89130
}
90131

91132
in upstream // overrides // additions

spago.dhall

Lines changed: 54 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,56 @@
1-
{ sources =
2-
[ "src/**/*.purs", "test/**/*.purs" ]
3-
, name =
4-
"docs-search"
1+
{ sources = [ "src/**/*.purs", "test/**/*.purs" ]
2+
, name = "docs-search"
53
, dependencies =
6-
[ "aff-promise"
7-
, "argonaut-codecs"
8-
, "argonaut-core"
9-
, "argonaut-generic"
10-
, "arrays"
11-
, "bower-json"
12-
, "console"
13-
, "control"
14-
, "coroutines"
15-
, "effect"
16-
, "foldable-traversable"
17-
, "generics-rep"
18-
, "halogen"
19-
, "halogen-css"
20-
, "lists"
21-
, "markdown-it"
22-
, "markdown-it-halogen"
23-
, "maybe"
24-
, "newtype"
25-
, "node-buffer"
26-
, "node-fs"
27-
, "node-fs-aff"
28-
, "node-process"
29-
, "node-readline"
30-
, "optparse"
31-
, "profunctor"
32-
, "profunctor-lenses"
33-
, "search-trie"
34-
, "string-parsers"
35-
, "strings"
36-
, "test-unit"
37-
, "web-dom"
38-
, "web-html"
39-
, "toppokki"
40-
, "web-storage"
41-
]
42-
, packages =
43-
./packages.dhall
4+
[ "aff"
5+
, "aff-promise"
6+
, "argonaut-codecs"
7+
, "argonaut-core"
8+
, "argonaut-generic"
9+
, "arrays"
10+
, "bower-json"
11+
, "console"
12+
, "control"
13+
, "css"
14+
, "effect"
15+
, "either"
16+
, "exceptions"
17+
, "foldable-traversable"
18+
, "foreign"
19+
, "foreign-object"
20+
, "halogen"
21+
, "halogen-css"
22+
, "halogen-subscriptions"
23+
, "identity"
24+
, "js-uri"
25+
, "lists"
26+
, "markdown-it"
27+
, "markdown-it-halogen"
28+
, "maybe"
29+
, "newtype"
30+
, "node-buffer"
31+
, "node-fs"
32+
, "node-fs-aff"
33+
, "node-process"
34+
, "node-readline"
35+
, "optparse"
36+
, "ordered-collections"
37+
, "partial"
38+
, "prelude"
39+
, "profunctor"
40+
, "profunctor-lenses"
41+
, "search-trie"
42+
, "string-parsers"
43+
, "strings"
44+
, "test-unit"
45+
, "toppokki"
46+
, "transformers"
47+
, "tuples"
48+
, "unfoldable"
49+
, "web-dom"
50+
, "web-events"
51+
, "web-html"
52+
, "web-storage"
53+
, "web-uievents"
54+
]
55+
, packages = ./packages.dhall
4456
}

src/Docs/Search/App.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@ import Docs.Search.Meta as Meta
1313
import Prelude
1414

1515
import Control.Alt (alt)
16-
import Control.Coroutine as Coroutine
1716
import Data.Maybe (Maybe(..))
1817
import Data.Newtype (wrap)
18+
import Data.Map as Map
1919
import Data.Tuple (Tuple(..))
2020
import Data.Tuple.Nested ((/\))
2121
import Effect (Effect)
2222
import Effect.Aff (launchAff_)
2323
import Halogen as H
2424
import Halogen.Aff as HA
25+
import Halogen.Subscription (subscribe)
2526
import Halogen.VDom.Driver (runUI)
2627
import MarkdownIt as MD
2728
import Web.DOM.ChildNode as ChildNode
@@ -70,11 +71,10 @@ main = do
7071

7172
let initialSearchEngineState = { packageIndex
7273
, moduleIndex
73-
, index: mempty
74-
, typeIndex: mempty
74+
, index: wrap Map.empty
75+
, typeIndex: wrap Map.empty
7576
, scores
7677
}
77-
7878
resultsComponent =
7979
SearchResults.mkComponent
8080
initialSearchEngineState
@@ -85,20 +85,21 @@ main = do
8585
sfio <- runUI SearchField.component unit searchField
8686
srio <- runUI resultsComponent unit searchResults
8787

88-
sfio.subscribe $
89-
Coroutine.consumer (srio.query <<< H.tell <<< SearchResults.MessageFromSearchField)
88+
void $ H.liftEffect $ subscribe sfio.messages $ \sfm -> do
89+
launchAff_ do
90+
srio.query (SearchResults.MessageFromSearchField sfm unit)
9091

9192
-- We need to read the URI hash only when both components are initialized and
9293
-- the search field is subscribed to the main component.
93-
void $ sfio.query $ H.tell SearchField.ReadURIHash
94+
void $ sfio.query $ SearchField.ReadURIHash unit
9495

9596
-- Subscribe to URI hash updates
9697
H.liftEffect do
9798

9899
listener <-
99100
eventListener \event ->
100101
launchAff_ do
101-
sfio.query $ H.tell SearchField.ReadURIHash
102+
sfio.query $ SearchField.ReadURIHash unit
102103

103104
addEventListener hashchange listener true (Window.toEventTarget window)
104105

@@ -112,7 +113,7 @@ main = do
112113
listener <-
113114
eventListener \event ->
114115
launchAff_ do
115-
sbio.query $ H.tell Sidebar.UpdateModuleGrouping
116+
sbio.query $ Sidebar.UpdateModuleGrouping unit
116117

117118
addEventListener focus listener true (Window.toEventTarget window)
118119

src/Docs/Search/App/SearchField.purs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Halogen.HTML as HH
1515
import Halogen.HTML.CSS as HS
1616
import Halogen.HTML.Events as HE
1717
import Halogen.HTML.Properties as HP
18-
import Halogen.Query.EventSource as ES
18+
import Halogen.Query.Event as ES
1919
import Web.DOM.Document as Document
2020
import Web.DOM.ParentNode as ParentNode
2121
import Web.HTML as HTML
@@ -36,6 +36,7 @@ data Action
3636
| FocusChanged Boolean
3737
| InitKeyboardListener
3838
| HandleKey H.SubscriptionId KeyboardEvent
39+
| NoOp
3940

4041
data Query a
4142
= ReadURIHash a
@@ -46,7 +47,7 @@ data SearchFieldMessage
4647
| Focused
4748
| LostFocus
4849

49-
component :: forall i. H.Component HH.HTML Query i SearchFieldMessage Aff
50+
component :: forall i. H.Component Query i SearchFieldMessage Aff
5051
component =
5152
H.mkComponent
5253
{ initialState
@@ -73,12 +74,12 @@ initialState _ = { input: "", focused: false }
7374

7475
handleAction :: Action -> H.HalogenM State Action () SearchFieldMessage Aff Unit
7576
handleAction = case _ of
76-
77+
NoOp -> pure unit
7778
InitKeyboardListener -> do
7879

7980
document <- H.liftEffect $ Window.document =<< HTML.window
8081
H.subscribe' \sid ->
81-
ES.eventListenerEventSource
82+
ES.eventListener
8283
KET.keyup
8384
(HTMLDocument.toEventTarget document)
8485
(map (HandleKey sid) <<< KE.fromEvent)
@@ -159,11 +160,11 @@ render state =
159160
, HP.type_ HP.InputText
160161
, HE.onKeyUp (\event ->
161162
case KeyboardEvent.code event of
162-
"Enter" -> Just EnterPressed
163-
_ -> Nothing)
164-
, HE.onValueInput (Just <<< InputAction)
165-
, HE.onFocusIn $ const $ Just $ FocusChanged true
166-
, HE.onFocusOut $ const $ Just $ FocusChanged false
163+
"Enter" -> EnterPressed
164+
_ -> NoOp)
165+
, HE.onValueInput InputAction
166+
, HE.onFocusIn $ const $ FocusChanged true
167+
, HE.onFocusOut $ const $ FocusChanged false
167168
, HS.style do
168169

169170
let pursuitColor = rgb 0x1d 0x22 0x2d

0 commit comments

Comments
 (0)