elm-pages 3.0.18 → 3.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/codegen/elm-pages-codegen.cjs +55 -3
- package/generator/src/build.js +1 -2
- package/generator/src/compatibility-key.js +1 -1
- package/generator/template/elm.json +8 -7
- package/generator/template/index.ts +2 -1
- package/generator/template/package.json +6 -6
- package/generator/template/script/elm.json +7 -7
- package/generator/template/script/src/AddRoute.elm +2 -1
- package/package.json +3 -3
- package/src/Pages/Internal/Platform/Cli.elm +8 -3
- package/src/Pages/Internal/Platform.elm +15 -4
- package/src/TerminalText.elm +47 -43
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
- [elm-pages Docs Site](https://elm-pages.com/docs)
|
|
13
13
|
- [elm-pages site showcase](https://elm-pages.com/showcase/)
|
|
14
|
-
- [elm-pages Elm API Docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/10.
|
|
14
|
+
- [elm-pages Elm API Docs](https://package.elm-lang.org/packages/dillonkearns/elm-pages/10.2.0/)
|
|
15
15
|
- [Quick start repo](https://github.com/dillonkearns/elm-pages-starter) [(live site hosted here)](https://elm-pages-starter.netlify.com)
|
|
16
16
|
- [Introducing `elm-pages` blog post](https://elm-pages.com/blog/introducing-elm-pages)
|
|
17
17
|
- [`examples` folder](https://github.com/dillonkearns/elm-pages/blob/master/examples/) (includes https://elm-pages.com site source) Use `git clone --recurse-submodules https://github.com/dillonkearns/elm-pages.git` so that there aren't missing files when you try to build the examples.
|
|
@@ -26079,6 +26079,32 @@ var $author$project$Gen$Pages$Internal$Platform$annotation_ = {
|
|
|
26079
26079
|
]))
|
|
26080
26080
|
])));
|
|
26081
26081
|
}),
|
|
26082
|
+
programConfig: F9(
|
|
26083
|
+
function (programConfigArg0, programConfigArg1, programConfigArg2, programConfigArg3, programConfigArg4, programConfigArg5, programConfigArg6, programConfigArg7, programConfigArg8) {
|
|
26084
|
+
return A4(
|
|
26085
|
+
$mdgriffith$elm_codegen$Elm$Annotation$alias,
|
|
26086
|
+
$author$project$Gen$Pages$Internal$Platform$moduleName_,
|
|
26087
|
+
'ProgramConfig',
|
|
26088
|
+
_List_fromArray(
|
|
26089
|
+
[programConfigArg0, programConfigArg1, programConfigArg2, programConfigArg3, programConfigArg4, programConfigArg5, programConfigArg6, programConfigArg7, programConfigArg8]),
|
|
26090
|
+
A3(
|
|
26091
|
+
$mdgriffith$elm_codegen$Elm$Annotation$namedWith,
|
|
26092
|
+
_List_fromArray(
|
|
26093
|
+
['Pages', 'ProgramConfig']),
|
|
26094
|
+
'ProgramConfig',
|
|
26095
|
+
_List_fromArray(
|
|
26096
|
+
[
|
|
26097
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('userMsg'),
|
|
26098
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('userModel'),
|
|
26099
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('route'),
|
|
26100
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('pageData'),
|
|
26101
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('actionData'),
|
|
26102
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('sharedData'),
|
|
26103
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('effect'),
|
|
26104
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('mappedMsg'),
|
|
26105
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('errorPage')
|
|
26106
|
+
])));
|
|
26107
|
+
}),
|
|
26082
26108
|
requestInfo: A4(
|
|
26083
26109
|
$mdgriffith$elm_codegen$Elm$Annotation$alias,
|
|
26084
26110
|
$author$project$Gen$Pages$Internal$Platform$moduleName_,
|
|
@@ -26202,7 +26228,33 @@ var $author$project$Gen$Pages$Internal$Platform$Cli$annotation_ = {
|
|
|
26202
26228
|
'Msg',
|
|
26203
26229
|
_List_Nil)
|
|
26204
26230
|
])));
|
|
26205
|
-
}
|
|
26231
|
+
},
|
|
26232
|
+
programConfig: F9(
|
|
26233
|
+
function (programConfigArg0, programConfigArg1, programConfigArg2, programConfigArg3, programConfigArg4, programConfigArg5, programConfigArg6, programConfigArg7, programConfigArg8) {
|
|
26234
|
+
return A4(
|
|
26235
|
+
$mdgriffith$elm_codegen$Elm$Annotation$alias,
|
|
26236
|
+
$author$project$Gen$Pages$Internal$Platform$Cli$moduleName_,
|
|
26237
|
+
'ProgramConfig',
|
|
26238
|
+
_List_fromArray(
|
|
26239
|
+
[programConfigArg0, programConfigArg1, programConfigArg2, programConfigArg3, programConfigArg4, programConfigArg5, programConfigArg6, programConfigArg7, programConfigArg8]),
|
|
26240
|
+
A3(
|
|
26241
|
+
$mdgriffith$elm_codegen$Elm$Annotation$namedWith,
|
|
26242
|
+
_List_fromArray(
|
|
26243
|
+
['Pages', 'ProgramConfig']),
|
|
26244
|
+
'ProgramConfig',
|
|
26245
|
+
_List_fromArray(
|
|
26246
|
+
[
|
|
26247
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('userMsg'),
|
|
26248
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('userModel'),
|
|
26249
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('route'),
|
|
26250
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('pageData'),
|
|
26251
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('actionData'),
|
|
26252
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('sharedData'),
|
|
26253
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('effect'),
|
|
26254
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('mappedMsg'),
|
|
26255
|
+
$mdgriffith$elm_codegen$Elm$Annotation$var('errorPage')
|
|
26256
|
+
])));
|
|
26257
|
+
})
|
|
26206
26258
|
};
|
|
26207
26259
|
var $author$project$Gen$PagesMsg$moduleName_ = _List_fromArray(
|
|
26208
26260
|
['PagesMsg']);
|
|
@@ -26341,7 +26393,7 @@ var $author$project$Gen$Pages$Internal$Platform$application = function (applicat
|
|
|
26341
26393
|
A3(
|
|
26342
26394
|
$mdgriffith$elm_codegen$Elm$Annotation$namedWith,
|
|
26343
26395
|
_List_fromArray(
|
|
26344
|
-
['Pages', '
|
|
26396
|
+
['Pages', 'Internal', 'Platform']),
|
|
26345
26397
|
'ProgramConfig',
|
|
26346
26398
|
_List_fromArray(
|
|
26347
26399
|
[
|
|
@@ -31089,7 +31141,7 @@ var $author$project$Gen$Pages$Internal$Platform$Cli$cliApplication = function (c
|
|
|
31089
31141
|
A3(
|
|
31090
31142
|
$mdgriffith$elm_codegen$Elm$Annotation$namedWith,
|
|
31091
31143
|
_List_fromArray(
|
|
31092
|
-
['Pages', '
|
|
31144
|
+
['Pages', 'Internal', 'Platform', 'Cli']),
|
|
31093
31145
|
'ProgramConfig',
|
|
31094
31146
|
_List_fromArray(
|
|
31095
31147
|
[
|
package/generator/src/build.js
CHANGED
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"danfishgold/base64-bytes": "1.1.0",
|
|
13
13
|
"danyx23/elm-mimetype": "4.0.1",
|
|
14
14
|
"dillonkearns/elm-bcp47-language-tag": "2.0.0",
|
|
15
|
-
"dillonkearns/elm-form": "3.0.
|
|
15
|
+
"dillonkearns/elm-form": "3.0.1",
|
|
16
16
|
"dillonkearns/elm-markdown": "7.0.1",
|
|
17
|
-
"dillonkearns/elm-pages": "10.
|
|
17
|
+
"dillonkearns/elm-pages": "10.2.0",
|
|
18
18
|
"elm/browser": "1.0.2",
|
|
19
19
|
"elm/bytes": "1.0.8",
|
|
20
20
|
"elm/core": "1.0.5",
|
|
@@ -31,12 +31,12 @@
|
|
|
31
31
|
"elm-community/result-extra": "2.4.0",
|
|
32
32
|
"jluckyiv/elm-utc-date-strings": "1.0.0",
|
|
33
33
|
"justinmimbs/date": "4.1.0",
|
|
34
|
-
"mdgriffith/elm-codegen": "
|
|
35
|
-
"miniBill/elm-codec": "2.
|
|
34
|
+
"mdgriffith/elm-codegen": "5.2.0",
|
|
35
|
+
"miniBill/elm-codec": "2.2.0",
|
|
36
36
|
"noahzgordon/elm-color-extra": "1.0.2",
|
|
37
37
|
"robinheghan/fnv1a": "1.0.0",
|
|
38
38
|
"rtfeldman/elm-css": "18.0.0",
|
|
39
|
-
"the-sett/elm-syntax-dsl": "6.0.
|
|
39
|
+
"the-sett/elm-syntax-dsl": "6.0.3",
|
|
40
40
|
"turboMaCk/non-empty-list-alias": "1.4.0",
|
|
41
41
|
"vito/elm-ansi": "10.0.1"
|
|
42
42
|
},
|
|
@@ -53,9 +53,10 @@
|
|
|
53
53
|
"robinheghan/murmur3": "1.0.0",
|
|
54
54
|
"rtfeldman/elm-hex": "1.0.0",
|
|
55
55
|
"rtfeldman/elm-iso8601-date-strings": "1.1.4",
|
|
56
|
-
"stil4m/elm-syntax": "7.3.
|
|
56
|
+
"stil4m/elm-syntax": "7.3.8",
|
|
57
57
|
"stil4m/structured-writer": "1.0.3",
|
|
58
|
-
"the-sett/elm-pretty-printer": "3.1.0"
|
|
58
|
+
"the-sett/elm-pretty-printer": "3.1.0",
|
|
59
|
+
"wolfadex/elm-ansi": "3.0.0"
|
|
59
60
|
}
|
|
60
61
|
},
|
|
61
62
|
"test-dependencies": {
|
|
@@ -5,7 +5,8 @@ type ElmPagesInit = {
|
|
|
5
5
|
|
|
6
6
|
const config: ElmPagesInit = {
|
|
7
7
|
load: async function (elmLoaded) {
|
|
8
|
-
await elmLoaded;
|
|
8
|
+
const app = await elmLoaded;
|
|
9
|
+
console.log("App loaded", app);
|
|
9
10
|
},
|
|
10
11
|
flags: function () {
|
|
11
12
|
return "You can decode this in Shared.elm using Json.Decode.string!";
|
|
@@ -7,15 +7,15 @@
|
|
|
7
7
|
"build": "elm-pages build"
|
|
8
8
|
},
|
|
9
9
|
"devDependencies": {
|
|
10
|
-
"elm-codegen": "^0.
|
|
10
|
+
"elm-codegen": "^0.6.1",
|
|
11
11
|
"elm-optimize-level-2": "^0.3.5",
|
|
12
|
-
"elm-pages": "
|
|
12
|
+
"elm-pages": "3.0.19",
|
|
13
13
|
"elm-review": "^2.12.0",
|
|
14
14
|
"elm-tooling": "^1.15.1",
|
|
15
|
-
"lamdera": "^0.19.1-1.2
|
|
16
|
-
"vite": "^
|
|
15
|
+
"lamdera": "^0.19.1-1.3.2",
|
|
16
|
+
"vite": "^6.0.6"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@netlify/functions": "^
|
|
19
|
+
"@netlify/functions": "^3.0.0"
|
|
20
20
|
}
|
|
21
|
-
}
|
|
21
|
+
}
|
|
@@ -8,12 +8,12 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"direct": {
|
|
10
10
|
"dillonkearns/elm-cli-options-parser": "3.2.0",
|
|
11
|
-
"dillonkearns/elm-pages": "10.
|
|
11
|
+
"dillonkearns/elm-pages": "10.2.0",
|
|
12
12
|
"elm/bytes": "1.0.8",
|
|
13
13
|
"elm/core": "1.0.5",
|
|
14
14
|
"elm/html": "1.0.0",
|
|
15
15
|
"elm/json": "1.1.3",
|
|
16
|
-
"mdgriffith/elm-codegen": "
|
|
16
|
+
"mdgriffith/elm-codegen": "5.2.0"
|
|
17
17
|
},
|
|
18
18
|
"indirect": {
|
|
19
19
|
"Chadtech/elm-bool-extra": "2.4.2",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"danyx23/elm-mimetype": "4.0.1",
|
|
23
23
|
"dillonkearns/elm-bcp47-language-tag": "2.0.0",
|
|
24
24
|
"dillonkearns/elm-date-or-date-time": "2.0.0",
|
|
25
|
-
"dillonkearns/elm-form": "3.0.
|
|
25
|
+
"dillonkearns/elm-form": "3.0.1",
|
|
26
26
|
"elm/browser": "1.0.2",
|
|
27
27
|
"elm/file": "1.0.5",
|
|
28
28
|
"elm/http": "2.0.0",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"fredcy/elm-parseint": "2.0.1",
|
|
39
39
|
"jluckyiv/elm-utc-date-strings": "1.0.0",
|
|
40
40
|
"justinmimbs/date": "4.1.0",
|
|
41
|
-
"miniBill/elm-codec": "2.
|
|
41
|
+
"miniBill/elm-codec": "2.2.0",
|
|
42
42
|
"miniBill/elm-unicode": "1.1.1",
|
|
43
43
|
"noahzgordon/elm-color-extra": "1.0.2",
|
|
44
44
|
"robinheghan/fnv1a": "1.0.0",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
"rtfeldman/elm-css": "18.0.0",
|
|
47
47
|
"rtfeldman/elm-hex": "1.0.0",
|
|
48
48
|
"rtfeldman/elm-iso8601-date-strings": "1.1.4",
|
|
49
|
-
"stil4m/elm-syntax": "7.3.
|
|
49
|
+
"stil4m/elm-syntax": "7.3.8",
|
|
50
50
|
"stil4m/structured-writer": "1.0.3",
|
|
51
51
|
"the-sett/elm-pretty-printer": "3.1.0",
|
|
52
|
-
"the-sett/elm-syntax-dsl": "6.0.
|
|
53
|
-
"
|
|
52
|
+
"the-sett/elm-syntax-dsl": "6.0.3",
|
|
53
|
+
"wolfadex/elm-ansi": "3.0.0"
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"test-dependencies": {
|
|
@@ -22,6 +22,7 @@ import Gen.List
|
|
|
22
22
|
import Gen.Maybe
|
|
23
23
|
import Gen.Pages.Form as PagesForm
|
|
24
24
|
import Gen.Pages.Script
|
|
25
|
+
import Gen.Platform.Sub
|
|
25
26
|
import Gen.Server.Request as Request
|
|
26
27
|
import Gen.Server.Response as Response
|
|
27
28
|
import Gen.View
|
|
@@ -253,7 +254,7 @@ createFile { moduleName, fields } =
|
|
|
253
254
|
Elm.tuple (Elm.record []) Effect.none
|
|
254
255
|
, subscriptions =
|
|
255
256
|
\{ routeParams, path, shared, model } ->
|
|
256
|
-
|
|
257
|
+
Gen.Platform.Sub.none
|
|
257
258
|
, model =
|
|
258
259
|
Alias (Type.record [])
|
|
259
260
|
, msg =
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "elm-pages",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.20",
|
|
5
5
|
"homepage": "https://elm-pages.com",
|
|
6
6
|
"moduleResolution": "node",
|
|
7
7
|
"description": "Type-safe static sites, written in pure elm with your own custom elm-markup syntax.",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"cookie-signature": "^1.2.2",
|
|
35
35
|
"cross-spawn": "7.0.6",
|
|
36
36
|
"devcert": "^1.2.2",
|
|
37
|
-
"elm-doc-preview": "^
|
|
37
|
+
"elm-doc-preview": "^6.0.0",
|
|
38
38
|
"elm-hot": "^1.1.6",
|
|
39
39
|
"esbuild": "^0.24.0",
|
|
40
40
|
"fs-extra": "^11.2.0",
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"micromatch": "^4.0.8",
|
|
48
48
|
"serve-static": "^1.16.2",
|
|
49
49
|
"terser": "^5.36.0",
|
|
50
|
+
"vite": "^6.0.0",
|
|
50
51
|
"which": "^5.0.0"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
@@ -65,7 +66,6 @@
|
|
|
65
66
|
"elm-verify-examples": "^6.0.3",
|
|
66
67
|
"lamdera": "^0.19.1-1.3.2",
|
|
67
68
|
"typescript": "^5.7.2",
|
|
68
|
-
"vite": "^6.0.0",
|
|
69
69
|
"vitest": "^2.1.6"
|
|
70
70
|
},
|
|
71
71
|
"files": [
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
module Pages.Internal.Platform.Cli exposing (Flags, Model, Msg(..), Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey)
|
|
1
|
+
module Pages.Internal.Platform.Cli exposing (Flags, Model, Msg(..), ProgramConfig, Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey)
|
|
2
2
|
|
|
3
3
|
{-| Exposed for internal use only (used in generated code).
|
|
4
4
|
|
|
5
|
-
@docs Flags, Model, Msg, Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey
|
|
5
|
+
@docs Flags, Model, Msg, ProgramConfig, Program, cliApplication, init, requestDecoder, update, currentCompatibilityKey
|
|
6
6
|
|
|
7
7
|
-}
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ import Pages.Internal.Platform.Effect as Effect exposing (Effect)
|
|
|
29
29
|
import Pages.Internal.Platform.StaticResponses as StaticResponses
|
|
30
30
|
import Pages.Internal.Platform.ToJsPayload as ToJsPayload
|
|
31
31
|
import Pages.Internal.ResponseSketch as ResponseSketch
|
|
32
|
-
import Pages.ProgramConfig
|
|
32
|
+
import Pages.ProgramConfig
|
|
33
33
|
import Pages.SiteConfig exposing (SiteConfig)
|
|
34
34
|
import Pages.StaticHttp.Request
|
|
35
35
|
import PagesMsg exposing (PagesMsg)
|
|
@@ -71,6 +71,11 @@ type alias Program route =
|
|
|
71
71
|
Platform.Program Flags (Model route) Msg
|
|
72
72
|
|
|
73
73
|
|
|
74
|
+
{-| -}
|
|
75
|
+
type alias ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage =
|
|
76
|
+
Pages.ProgramConfig.ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage
|
|
77
|
+
|
|
78
|
+
|
|
74
79
|
{-| -}
|
|
75
80
|
cliApplication :
|
|
76
81
|
ProgramConfig userMsg userModel (Maybe route) pageData actionData sharedData effect mappedMsg errorPage
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
module Pages.Internal.Platform exposing
|
|
2
|
-
( Flags, Model, Msg(..), Program, application, init, update
|
|
2
|
+
( Flags, Model, Msg(..), Program, ProgramConfig, application, init, update
|
|
3
3
|
, Effect(..), RequestInfo, view
|
|
4
4
|
)
|
|
5
5
|
|
|
6
6
|
{-| Exposed for internal use only (used in generated code).
|
|
7
7
|
|
|
8
|
-
@docs Flags, Model, Msg, Program, application, init, update
|
|
8
|
+
@docs Flags, Model, Msg, Program, ProgramConfig, application, init, update
|
|
9
9
|
|
|
10
10
|
@docs Effect, RequestInfo, view
|
|
11
11
|
|
|
@@ -35,7 +35,7 @@ import Pages.Internal.NotFoundReason exposing (NotFoundReason)
|
|
|
35
35
|
import Pages.Internal.ResponseSketch as ResponseSketch exposing (ResponseSketch)
|
|
36
36
|
import Pages.Internal.String as String
|
|
37
37
|
import Pages.Navigation
|
|
38
|
-
import Pages.ProgramConfig
|
|
38
|
+
import Pages.ProgramConfig
|
|
39
39
|
import Pages.StaticHttpRequest as StaticHttpRequest
|
|
40
40
|
import PagesMsg exposing (PagesMsg)
|
|
41
41
|
import QueryParams
|
|
@@ -50,6 +50,11 @@ type alias Program userModel userMsg pageData actionData sharedData errorPage =
|
|
|
50
50
|
Platform.Program Flags (Model userModel pageData actionData sharedData) (Msg userMsg pageData actionData sharedData errorPage)
|
|
51
51
|
|
|
52
52
|
|
|
53
|
+
{-| -}
|
|
54
|
+
type alias ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage =
|
|
55
|
+
Pages.ProgramConfig.ProgramConfig userMsg userModel route pageData actionData sharedData effect mappedMsg errorPage
|
|
56
|
+
|
|
57
|
+
|
|
53
58
|
mainView :
|
|
54
59
|
ProgramConfig userMsg userModel route pageData actionData sharedData effect (Msg userMsg pageData actionData sharedData errorPage) errorPage
|
|
55
60
|
-> Model userModel pageData actionData sharedData
|
|
@@ -567,8 +572,14 @@ update config appMsg model =
|
|
|
567
572
|
)
|
|
568
573
|
|
|
569
574
|
else
|
|
570
|
-
-- TODO should the user msg still be run if the form is invalid?
|
|
571
575
|
( model, NoEffect )
|
|
576
|
+
|> (case fields.msg of
|
|
577
|
+
Just justUserMsg ->
|
|
578
|
+
performUserMsg justUserMsg config
|
|
579
|
+
|
|
580
|
+
Nothing ->
|
|
581
|
+
identity
|
|
582
|
+
)
|
|
572
583
|
|
|
573
584
|
Pages.Internal.Msg.FormMsg formMsg ->
|
|
574
585
|
-- TODO when init is called for a new page, also need to clear out client-side `pageFormState`
|
package/src/TerminalText.elm
CHANGED
|
@@ -17,7 +17,8 @@ module TerminalText exposing
|
|
|
17
17
|
, yellow
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
import Ansi
|
|
20
|
+
import Ansi.Color
|
|
21
|
+
import Ansi.Parser
|
|
21
22
|
import Json.Encode as Encode
|
|
22
23
|
|
|
23
24
|
|
|
@@ -32,27 +33,27 @@ text value =
|
|
|
32
33
|
|
|
33
34
|
cyan : String -> Text
|
|
34
35
|
cyan inner =
|
|
35
|
-
Style { blankStyle | color = Just Ansi.Cyan } inner
|
|
36
|
+
Style { blankStyle | color = Just Ansi.Color.Cyan } inner
|
|
36
37
|
|
|
37
38
|
|
|
38
39
|
green : String -> Text
|
|
39
40
|
green inner =
|
|
40
|
-
Style { blankStyle | color = Just Ansi.Green } inner
|
|
41
|
+
Style { blankStyle | color = Just Ansi.Color.Green } inner
|
|
41
42
|
|
|
42
43
|
|
|
43
44
|
yellow : String -> Text
|
|
44
45
|
yellow inner =
|
|
45
|
-
Style { blankStyle | color = Just Ansi.Yellow } inner
|
|
46
|
+
Style { blankStyle | color = Just Ansi.Color.Yellow } inner
|
|
46
47
|
|
|
47
48
|
|
|
48
49
|
red : String -> Text
|
|
49
50
|
red inner =
|
|
50
|
-
Style { blankStyle | color = Just Ansi.Red } inner
|
|
51
|
+
Style { blankStyle | color = Just Ansi.Color.Red } inner
|
|
51
52
|
|
|
52
53
|
|
|
53
54
|
blue : String -> Text
|
|
54
55
|
blue inner =
|
|
55
|
-
Style { blankStyle | color = Just Ansi.Blue } inner
|
|
56
|
+
Style { blankStyle | color = Just Ansi.Color.Blue } inner
|
|
56
57
|
|
|
57
58
|
|
|
58
59
|
resetColors : String
|
|
@@ -70,23 +71,23 @@ ansiPrefix =
|
|
|
70
71
|
"\u{001B}"
|
|
71
72
|
|
|
72
73
|
|
|
73
|
-
colorToString : Ansi.Color -> String
|
|
74
|
+
colorToString : Ansi.Color.Color -> String
|
|
74
75
|
colorToString color =
|
|
75
76
|
ansi <|
|
|
76
77
|
case color of
|
|
77
|
-
Ansi.Red ->
|
|
78
|
+
Ansi.Color.Red ->
|
|
78
79
|
"[31m"
|
|
79
80
|
|
|
80
|
-
Ansi.Blue ->
|
|
81
|
+
Ansi.Color.Blue ->
|
|
81
82
|
"[34m"
|
|
82
83
|
|
|
83
|
-
Ansi.Green ->
|
|
84
|
+
Ansi.Color.Green ->
|
|
84
85
|
"[32m"
|
|
85
86
|
|
|
86
|
-
Ansi.Yellow ->
|
|
87
|
+
Ansi.Color.Yellow ->
|
|
87
88
|
"[33m"
|
|
88
89
|
|
|
89
|
-
Ansi.Cyan ->
|
|
90
|
+
Ansi.Color.Cyan ->
|
|
90
91
|
"[36m"
|
|
91
92
|
|
|
92
93
|
_ ->
|
|
@@ -104,7 +105,7 @@ toString list =
|
|
|
104
105
|
toString_ : Text -> String
|
|
105
106
|
toString_ (Style ansiStyle innerText) =
|
|
106
107
|
String.concat
|
|
107
|
-
[ ansiStyle.color |> Maybe.withDefault Ansi.White |> colorToString
|
|
108
|
+
[ ansiStyle.color |> Maybe.withDefault Ansi.Color.White |> colorToString
|
|
108
109
|
, innerText
|
|
109
110
|
, resetColors
|
|
110
111
|
]
|
|
@@ -119,7 +120,7 @@ toPlainString list =
|
|
|
119
120
|
|
|
120
121
|
fromAnsiString : String -> List Text
|
|
121
122
|
fromAnsiString ansiString =
|
|
122
|
-
Ansi.parseInto ( blankStyle, [] ) parseInto ansiString
|
|
123
|
+
Ansi.Parser.parseInto ( blankStyle, [] ) parseInto ansiString
|
|
123
124
|
|> Tuple.second
|
|
124
125
|
|> List.reverse
|
|
125
126
|
|
|
@@ -127,7 +128,7 @@ fromAnsiString ansiString =
|
|
|
127
128
|
type alias AnsiStyle =
|
|
128
129
|
{ bold : Bool
|
|
129
130
|
, underline : Bool
|
|
130
|
-
, color : Maybe Ansi.Color
|
|
131
|
+
, color : Maybe Ansi.Color.Color
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
|
|
@@ -139,16 +140,16 @@ blankStyle =
|
|
|
139
140
|
}
|
|
140
141
|
|
|
141
142
|
|
|
142
|
-
parseInto : Ansi.
|
|
143
|
+
parseInto : Ansi.Parser.Command -> ( AnsiStyle, List Text ) -> ( AnsiStyle, List Text )
|
|
143
144
|
parseInto action ( pendingStyle, soFar ) =
|
|
144
145
|
case action of
|
|
145
|
-
Ansi.
|
|
146
|
+
Ansi.Parser.Text string ->
|
|
146
147
|
( blankStyle, Style pendingStyle string :: soFar )
|
|
147
148
|
|
|
148
|
-
Ansi.Remainder _ ->
|
|
149
|
+
Ansi.Parser.Remainder _ ->
|
|
149
150
|
( pendingStyle, soFar )
|
|
150
151
|
|
|
151
|
-
Ansi.SetForeground maybeColor ->
|
|
152
|
+
Ansi.Parser.SetForeground maybeColor ->
|
|
152
153
|
case maybeColor of
|
|
153
154
|
Just newColor ->
|
|
154
155
|
( { pendingStyle
|
|
@@ -160,22 +161,22 @@ parseInto action ( pendingStyle, soFar ) =
|
|
|
160
161
|
Nothing ->
|
|
161
162
|
( blankStyle, soFar )
|
|
162
163
|
|
|
163
|
-
Ansi.SetBold bool ->
|
|
164
|
+
Ansi.Parser.SetBold bool ->
|
|
164
165
|
( { pendingStyle | bold = bool }, soFar )
|
|
165
166
|
|
|
166
|
-
Ansi.SetFaint _ ->
|
|
167
|
+
Ansi.Parser.SetFaint _ ->
|
|
167
168
|
( pendingStyle, soFar )
|
|
168
169
|
|
|
169
|
-
Ansi.SetItalic _ ->
|
|
170
|
+
Ansi.Parser.SetItalic _ ->
|
|
170
171
|
( pendingStyle, soFar )
|
|
171
172
|
|
|
172
|
-
Ansi.SetUnderline bool ->
|
|
173
|
+
Ansi.Parser.SetUnderline bool ->
|
|
173
174
|
( { pendingStyle | underline = bool }, soFar )
|
|
174
175
|
|
|
175
|
-
Ansi.SetBackground _ ->
|
|
176
|
+
Ansi.Parser.SetBackground _ ->
|
|
176
177
|
( pendingStyle, soFar )
|
|
177
178
|
|
|
178
|
-
Ansi.Linebreak ->
|
|
179
|
+
Ansi.Parser.Linebreak ->
|
|
179
180
|
case soFar of
|
|
180
181
|
next :: rest ->
|
|
181
182
|
( pendingStyle, Style blankStyle "\n" :: next :: rest )
|
|
@@ -194,56 +195,59 @@ encoder (Style ansiStyle string) =
|
|
|
194
195
|
, ( "underline", Encode.bool ansiStyle.underline )
|
|
195
196
|
, ( "color"
|
|
196
197
|
, Encode.string <|
|
|
197
|
-
case ansiStyle.color |> Maybe.withDefault Ansi.White of
|
|
198
|
-
Ansi.Red ->
|
|
198
|
+
case ansiStyle.color |> Maybe.withDefault Ansi.Color.White of
|
|
199
|
+
Ansi.Color.Red ->
|
|
199
200
|
"red"
|
|
200
201
|
|
|
201
|
-
Ansi.Blue ->
|
|
202
|
+
Ansi.Color.Blue ->
|
|
202
203
|
"blue"
|
|
203
204
|
|
|
204
|
-
Ansi.Green ->
|
|
205
|
+
Ansi.Color.Green ->
|
|
205
206
|
"green"
|
|
206
207
|
|
|
207
|
-
Ansi.Yellow ->
|
|
208
|
+
Ansi.Color.Yellow ->
|
|
208
209
|
"yellow"
|
|
209
210
|
|
|
210
|
-
Ansi.Cyan ->
|
|
211
|
+
Ansi.Color.Cyan ->
|
|
211
212
|
"cyan"
|
|
212
213
|
|
|
213
|
-
Ansi.Black ->
|
|
214
|
+
Ansi.Color.Black ->
|
|
214
215
|
"black"
|
|
215
216
|
|
|
216
|
-
Ansi.Magenta ->
|
|
217
|
+
Ansi.Color.Magenta ->
|
|
217
218
|
"magenta"
|
|
218
219
|
|
|
219
|
-
Ansi.White ->
|
|
220
|
+
Ansi.Color.White ->
|
|
220
221
|
"white"
|
|
221
222
|
|
|
222
|
-
Ansi.BrightBlack ->
|
|
223
|
+
Ansi.Color.BrightBlack ->
|
|
223
224
|
"BLACK"
|
|
224
225
|
|
|
225
|
-
Ansi.BrightRed ->
|
|
226
|
+
Ansi.Color.BrightRed ->
|
|
226
227
|
"RED"
|
|
227
228
|
|
|
228
|
-
Ansi.BrightGreen ->
|
|
229
|
+
Ansi.Color.BrightGreen ->
|
|
229
230
|
"GREEN"
|
|
230
231
|
|
|
231
|
-
Ansi.BrightYellow ->
|
|
232
|
+
Ansi.Color.BrightYellow ->
|
|
232
233
|
"YELLOW"
|
|
233
234
|
|
|
234
|
-
Ansi.BrightBlue ->
|
|
235
|
+
Ansi.Color.BrightBlue ->
|
|
235
236
|
"BLUE"
|
|
236
237
|
|
|
237
|
-
Ansi.BrightMagenta ->
|
|
238
|
+
Ansi.Color.BrightMagenta ->
|
|
238
239
|
"MAGENTA"
|
|
239
240
|
|
|
240
|
-
Ansi.BrightCyan ->
|
|
241
|
+
Ansi.Color.BrightCyan ->
|
|
241
242
|
"CYAN"
|
|
242
243
|
|
|
243
|
-
Ansi.BrightWhite ->
|
|
244
|
+
Ansi.Color.BrightWhite ->
|
|
244
245
|
"WHITE"
|
|
245
246
|
|
|
246
|
-
Ansi.
|
|
247
|
+
Ansi.Color.Custom256 _ ->
|
|
248
|
+
""
|
|
249
|
+
|
|
250
|
+
Ansi.Color.CustomTrueColor _ ->
|
|
247
251
|
""
|
|
248
252
|
)
|
|
249
253
|
, ( "string", Encode.string string )
|