Skip to content

Commit 3f01c3e

Browse files
Merge pull request #163 from fable-compiler/repl4
Update to Fable 4 (multi-lang selection)
2 parents 57c68c1 + 6da3e85 commit 3f01c3e

26 files changed

Lines changed: 272 additions & 171 deletions

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
]
1616
},
1717
"fable": {
18-
"version": "3.2.11",
18+
"version": "4.0.0-snake-island-alpha-024",
1919
"commands": [
2020
"fable"
2121
]

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## Unreleased
88

9+
## 4.0.0-alpha-022
10+
11+
* Fable 4 alpha-22
12+
* Fix JS compilation
13+
14+
## 4.0.0-alpha-016
15+
16+
* Fable 4 -alpha-016
17+
* Save language selection and selected output tab
18+
19+
## 4.0.0-alpha-001
20+
21+
* Fable 4 alpha
22+
* Target language selection
23+
924
## 3.7.10
1025

1126
* Update Fable and fix typo

build.fsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,10 @@ let METADATA_LIB, STANDALONE_DIST, STANDALONE_SRC =
3737
| Some _ ->
3838
printfn "Using local packages..."
3939
"../Fable/src/fable-metadata/lib", "../Fable/src/fable-standalone/dist", "../Fable/src/fable-standalone/src"
40-
| None -> "node_modules/fable-metadata/lib", "node_modules/fable-standalone/dist", "node_modules/fable-standalone/src"
40+
| None ->
41+
printfn "Using fable-metadata/fable-standalone packages from node_modules..."
42+
printfn "To use local pacakges, set LOCAL_PKG env var and run `./build.sh standalone` in sibling Fable repository\n"
43+
"node_modules/fable-metadata/lib", "node_modules/fable-standalone/dist", "node_modules/fable-standalone/src"
4144

4245
module Util =
4346

@@ -128,7 +131,10 @@ let copyModules = BuildTask.create "CopyModules" [ npmInstall ] {
128131
Shell.rename (filename + ".txt") filename
129132
)
130133

134+
printfn "Copy files from %s to %s" STANDALONE_DIST REPL_OUTPUT
131135
Shell.copyDir REPL_OUTPUT STANDALONE_DIST (fun _ -> true)
136+
137+
printfn "Copy files from %s to %s" STANDALONE_SRC "src/Standalone"
132138
Shell.copyDir "src/Standalone" STANDALONE_SRC (fun f -> f.EndsWith(".fs"))
133139
}
134140

@@ -168,11 +174,11 @@ let buildLib = BuildTask.create "BuildLib" [ copyModules ] {
168174
)
169175
}
170176

171-
let buildApp = BuildTask.create "BuildApp" [ updatePreludeREPLVersion.IfNeeded; buildLib ] {
177+
let buildApp = BuildTask.create "BuildApp" [ updatePreludeREPLVersion.IfNeeded ] {
172178
Npm.run "build" id
173179
}
174180

175-
let watchApp = BuildTask.create "WatchApp" [ ] {
181+
let watchApp = BuildTask.create "WatchApp" [ copyModules ] {
176182
Npm.run "start" id
177183
}
178184

global.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"sdk": {
3-
"version": "5.0.300",
3+
"version": "6.0.100",
44
"rollForward": "minor"
55
}
66
}

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

paket.dependencies

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ nuget Thoth.Json
1313
nuget Thoth.Elmish.Toast ~> 2
1414
nuget Fable.Fetch
1515
nuget Fable.FontAwesome.Free
16-
nuget Feliz
16+
nuget Feliz prerelease
1717
nuget Feliz.Bulma
1818
nuget Feliz.Bulma.Tooltip
1919
nuget Fable.Browser.Css

paket.lock

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ STORAGE: NONE
22
RESTRICTION: == netstandard2.0
33
NUGET
44
remote: https://www.nuget.org/api/v2
5-
Fable.AST (3.1.1)
5+
Fable.AST (4.0)
66
Fable.Browser.Blob (1.1.4)
77
Fable.Core (>= 3.0)
88
FSharp.Core (>= 4.7.2)
@@ -76,10 +76,10 @@ NUGET
7676
Fable.Browser.Dom (>= 2.4.4)
7777
Fable.Core (>= 3.2.7)
7878
FSharp.Core (>= 4.7.2)
79-
Feliz (1.51)
79+
Feliz (2.0.0-prerelease-002)
8080
Fable.Core (>= 3.1.5)
8181
Fable.React (>= 7.4)
82-
Feliz.CompilerPlugins (>= 1.6)
82+
Feliz.CompilerPlugins (>= 2.0.0-prerelease-002)
8383
FSharp.Core (>= 4.7.2)
8484
Feliz.Bulma (2.17)
8585
Feliz (>= 1.32)
@@ -88,8 +88,8 @@ NUGET
8888
Feliz (>= 1.32)
8989
Feliz.Bulma (>= 2.8.1)
9090
FSharp.Core (>= 5.0)
91-
Feliz.CompilerPlugins (1.6)
92-
Fable.AST (>= 3.0)
91+
Feliz.CompilerPlugins (2.0.0-prerelease-002)
92+
Fable.AST (>= 4.0)
9393
FSharp.Core (>= 4.7.2)
9494
FsCheck (2.16)
9595
FSharp.Core (>= 4.2.3)
@@ -129,15 +129,15 @@ GITHUB
129129
SourceLink.Create.CommandLine
130130
Unquote
131131
remote: fable-compiler/fable-promise
132-
FULLPROJECT (703b555263cafc86f90ce82a1405864443a041cc)
132+
FULLPROJECT (14eca483d664dce5aebbe50fb92a536a7c1ffe53)
133133
remote: alfonsogarciacaro/Feliz.Engine
134-
FULLPROJECT (f08a3bd19ea854ace8b308c4eb2290c0c001e916)
134+
FULLPROJECT (61152aebd6c0b7878bfc4db05e2e10724b434a3e)
135135
remote: alfonsogarciacaro/Feliz.Snabbdom
136136
FULLPROJECT (7b28ccbceebcc9b66a8cb67aab89b7ae9576dbfb)
137137
remote: davedawkins/Feliz.Engine.Bulma
138-
FULLPROJECT (e960f99e842b362f6cc54524d857d12557da520b)
138+
FULLPROJECT (0df54855ac3464a432cd207412ab66e650a87d77)
139139
remote: davedawkins/Sutil
140-
FULLPROJECT (98be5f8441787929b14ba460a253f5b33b1c4d5f)
140+
FULLPROJECT (343bc31867127638a79afede0dcaa97ca56fa264)
141141
GROUP netcorebuild
142142
NUGET
143143
remote: https://www.nuget.org/api/v2

public/samples/games/mario.fs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ module Keyboard =
1515

1616
/// Update the state of the set for given key event
1717
let update (e : KeyboardEvent, pressed) =
18-
let keyCode = int e.keyCode
18+
let key = e.key
1919
let op = if pressed then Set.add else Set.remove
20-
keysPressed <- op keyCode keysPressed
20+
keysPressed <- op key keysPressed
2121

2222
/// Returns pair with -1 for left or down and +1
2323
/// for right or up (0 if no or both keys are pressed)
2424
let arrows () =
25-
(code 39 - code 37, code 38 - code 40)
25+
(code "ArrowRight" - code "ArrowLeft", code "ArrowUp" - code "ArrowDown")
2626

2727
let initKeyboard () =
2828
document.addEventListener("keydown", fun e -> update(e :?> _, true))

public/samples/games/ozmo.fs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,31 @@ module Keyboard =
1515

1616
let code x = if keysPressed.Contains(x) then 1 else 0
1717

18-
let arrows () = (code 39 - code 37, code 38 - code 40)
18+
let arrows () =
19+
(code "ArrowRight" - code "ArrowLeft", code "ArrowUp" - code "ArrowDown")
1920

2021
let update (e : KeyboardEvent, pressed) =
21-
let keyCode = int e.keyCode
22+
let key = e.key
2223
let op = if pressed then Set.add else Set.remove
23-
keysPressed <- op keyCode keysPressed
24+
keysPressed <- op key keysPressed
2425

2526
let init () =
2627
window.addEventListener("keydown", fun e -> update(e :?> _, true))
2728
window.addEventListener("keyup", fun e -> update(e :?> _, false))
2829

2930
// Main
3031

32+
/// Scale to make it fit in a 1920*1080 screen
33+
let scale = 0.8
34+
3135
/// The width of the canvas
32-
let width = 900.
36+
let width = 900. * scale
3337
/// The height of the canvas
34-
let height = 668.
38+
let height = 668. * scale
3539
/// Height of the floor - the bottom black part
36-
let floorHeight = 100.
40+
let floorHeight = 100. * scale
3741
/// Height of the atmosphere - the yellow gradient
38-
let atmosHeight = 300.
42+
let atmosHeight = 300. * scale
3943

4044
Keyboard.init()
4145

@@ -44,7 +48,6 @@ let ctx = canvas.getContext_2d()
4448
canvas.width <- width
4549
canvas.height <- height
4650

47-
4851
/// Draw gradient between two Y offsets and two colours
4952
let drawGrd (ctx:CanvasRenderingContext2D)
5053
(canvas:HTMLCanvasElement) (y0,y1) (c0,c1) =

0 commit comments

Comments
 (0)