@@ -44,9 +44,9 @@ outputOpt = "output"
44
44
45
45
outputKey = outputOpt
46
46
47
- browserNamespaceOpt = " browser- namespace"
47
+ namespaceOpt = " namespace"
48
48
49
- browserNamespaceKey = camelcaseFn browserNamespaceOpt
49
+ namespaceKey = namespaceOpt
50
50
51
51
commentsOpt = " comments"
52
52
@@ -98,7 +98,7 @@ newtype PscBundle
98
98
, output :: NullOrUndefined String
99
99
, "module" :: NullOrUndefined (Either String (Array String ))
100
100
, main :: NullOrUndefined (Either Boolean String )
101
- , browserNamespace :: NullOrUndefined String
101
+ , namespace :: NullOrUndefined String
102
102
}
103
103
104
104
newtype PscDocs
@@ -118,10 +118,6 @@ newtype PathArray = PathArray (Array String)
118
118
119
119
data Format = Markdown | ETags | CTags
120
120
121
- instance isForeignEither :: (IsForeign a , IsForeign b ) => IsForeign (Either a b ) where
122
- read a = (Left <$> read a :: F a ) <|>
123
- (Right <$> read a :: F b )
124
-
125
121
instance isForeignPsc :: IsForeign Psc where
126
122
read obj =
127
123
Psc <$> ({ src: _
@@ -134,8 +130,8 @@ instance isForeignPsc :: IsForeign Psc where
134
130
, comments: _
135
131
, noPrefix: _
136
132
, requirePath: _
137
- } <$> readProp srcKey obj
138
- <*> readProp ffiKey obj
133
+ } <$> ( readProp srcKey obj >>= readEither)
134
+ <*> ( readProp ffiKey obj >>= readEitherNU)
139
135
<*> readProp outputKey obj
140
136
<*> readProp noTcoKey obj
141
137
<*> readProp noMagicDoKey obj
@@ -151,28 +147,28 @@ instance isForeignPscBundle :: IsForeign PscBundle where
151
147
, output: _
152
148
, " module" : _
153
149
, main: _
154
- , browserNamespace : _
155
- } <$> readProp srcKey obj
150
+ , namespace : _
151
+ } <$> ( readProp srcKey obj >>= readEither)
156
152
<*> readProp outputKey obj
157
- <*> readProp moduleKey obj
158
- <*> readProp mainKey obj
159
- <*> readProp browserNamespaceKey obj)
153
+ <*> ( readProp moduleKey obj >>= readEitherNU)
154
+ <*> ( readProp mainKey obj >>= readEitherNU)
155
+ <*> readProp namespaceKey obj)
160
156
161
157
instance isForeignPscDocs :: IsForeign PscDocs where
162
158
read obj =
163
159
PscDocs <$> ({ src: _
164
160
, format: _
165
161
, docgen: _
166
- } <$> readProp srcKey obj
162
+ } <$> ( readProp srcKey obj >>= readEither)
167
163
<*> readProp formatKey obj
168
164
<*> readProp docgenOpt obj)
169
165
170
166
instance isForeignPsci :: IsForeign Psci where
171
167
read obj =
172
168
Psci <$> ({ src: _
173
169
, ffi: _
174
- } <$> readProp srcKey obj
175
- <*> readProp ffiKey obj)
170
+ } <$> ( readProp srcKey obj >>= readEither)
171
+ <*> ( readProp ffiKey obj >>= readEitherNU) )
176
172
177
173
instance isForeignPathArray :: IsForeign PathArray where
178
174
read val = PathArray <$> read val
@@ -257,7 +253,7 @@ pscBundleOptions opts = fold <$> parsed
257
253
opt outputOpt a.output <>
258
254
opt moduleOpt a." module" <>
259
255
opt mainOpt a.main <>
260
- opt browserNamespaceOpt a.browserNamespace
256
+ opt namespaceOpt a.namespace
261
257
262
258
pscDocsOptions :: Foreign -> Either ForeignError (Array String )
263
259
pscDocsOptions opts = fold <$> parsed
@@ -266,6 +262,13 @@ pscDocsOptions opts = fold <$> parsed
266
262
opt formatOpt a.format <>
267
263
opt docgenOpt a.docgen
268
264
265
+ readEither :: forall left right . (IsForeign left , IsForeign right ) => Foreign -> F (Either left right )
266
+ readEither a = (Left <$> read a) <|> (Right <$> read a)
267
+
268
+ readEitherNU :: forall left right . (IsForeign left , IsForeign right ) => NullOrUndefined Foreign -> F (NullOrUndefined (Either left right ))
269
+ readEitherNU a @ (NullOrUndefined Nothing ) = pure (NullOrUndefined Nothing )
270
+ readEitherNU (NullOrUndefined (Just a)) = (NullOrUndefined <<< Just ) <$> readEither a
271
+
269
272
foreign import expandGlob :: String -> (Array String )
270
273
271
274
foreign import camelcaseFn :: String -> String
0 commit comments