@@ -44,9 +44,9 @@ outputOpt = "output"
4444
4545outputKey = outputOpt
4646
47- browserNamespaceOpt = " browser- namespace"
47+ namespaceOpt = " namespace"
4848
49- browserNamespaceKey = camelcaseFn browserNamespaceOpt
49+ namespaceKey = namespaceOpt
5050
5151commentsOpt = " comments"
5252
@@ -98,7 +98,7 @@ newtype PscBundle
9898 , output :: NullOrUndefined String
9999 , "module" :: NullOrUndefined (Either String (Array String ))
100100 , main :: NullOrUndefined (Either Boolean String )
101- , browserNamespace :: NullOrUndefined String
101+ , namespace :: NullOrUndefined String
102102 }
103103
104104newtype PscDocs
@@ -118,10 +118,6 @@ newtype PathArray = PathArray (Array String)
118118
119119data Format = Markdown | ETags | CTags
120120
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-
125121instance isForeignPsc :: IsForeign Psc where
126122 read obj =
127123 Psc <$> ({ src: _
@@ -134,8 +130,8 @@ instance isForeignPsc :: IsForeign Psc where
134130 , comments: _
135131 , noPrefix: _
136132 , requirePath: _
137- } <$> readProp srcKey obj
138- <*> readProp ffiKey obj
133+ } <$> ( readProp srcKey obj >>= readEither)
134+ <*> ( readProp ffiKey obj >>= readEitherNU)
139135 <*> readProp outputKey obj
140136 <*> readProp noTcoKey obj
141137 <*> readProp noMagicDoKey obj
@@ -151,28 +147,28 @@ instance isForeignPscBundle :: IsForeign PscBundle where
151147 , output: _
152148 , " module" : _
153149 , main: _
154- , browserNamespace : _
155- } <$> readProp srcKey obj
150+ , namespace : _
151+ } <$> ( readProp srcKey obj >>= readEither)
156152 <*> 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)
160156
161157instance isForeignPscDocs :: IsForeign PscDocs where
162158 read obj =
163159 PscDocs <$> ({ src: _
164160 , format: _
165161 , docgen: _
166- } <$> readProp srcKey obj
162+ } <$> ( readProp srcKey obj >>= readEither)
167163 <*> readProp formatKey obj
168164 <*> readProp docgenOpt obj)
169165
170166instance isForeignPsci :: IsForeign Psci where
171167 read obj =
172168 Psci <$> ({ src: _
173169 , ffi: _
174- } <$> readProp srcKey obj
175- <*> readProp ffiKey obj)
170+ } <$> ( readProp srcKey obj >>= readEither)
171+ <*> ( readProp ffiKey obj >>= readEitherNU) )
176172
177173instance isForeignPathArray :: IsForeign PathArray where
178174 read val = PathArray <$> read val
@@ -257,7 +253,7 @@ pscBundleOptions opts = fold <$> parsed
257253 opt outputOpt a.output <>
258254 opt moduleOpt a." module" <>
259255 opt mainOpt a.main <>
260- opt browserNamespaceOpt a.browserNamespace
256+ opt namespaceOpt a.namespace
261257
262258pscDocsOptions :: Foreign -> Either ForeignError (Array String )
263259pscDocsOptions opts = fold <$> parsed
@@ -266,6 +262,13 @@ pscDocsOptions opts = fold <$> parsed
266262 opt formatOpt a.format <>
267263 opt docgenOpt a.docgen
268264
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+
269272foreign import expandGlob :: String -> (Array String )
270273
271274foreign import camelcaseFn :: String -> String
0 commit comments