firefly-compiler 0.4.91 → 0.5.2

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.
@@ -1201,7 +1201,7 @@ extend self: Parser {
1201
1201
  }
1202
1202
  let target = DynamicCall(EField(token.at(), False, result, "with"), False)
1203
1203
  result = ECall(record.at, target, effect, [], [
1204
- Argument(argument.at, None, EString(argument.at, argument.name.grab()))
1204
+ Argument(argument.at, None, EString(argument.at, "\"" + argument.name.grab() + "\""))
1205
1205
  Argument(argument.value.at, None, argument.value)
1206
1206
  ], [])
1207
1207
  }
@@ -5,7 +5,7 @@ capability Compression {}
5
5
  extend self: Compression {
6
6
 
7
7
  compressBrotli(uncompressed: Buffer, level: Int = 4): Buffer {
8
- internalCompress("brotli", level, uncompressed)
8
+ internalCompress(self, "brotli", level, uncompressed)
9
9
  }
10
10
 
11
11
  decompressBrotli(compressed: Buffer): Buffer {
@@ -13,7 +13,7 @@ extend self: Compression {
13
13
  }
14
14
 
15
15
  compressGzip(uncompressed: Buffer, level: Int = 6): Buffer {
16
- internalCompress("gzip", level, uncompressed)
16
+ internalCompress(self, "gzip", level, uncompressed)
17
17
  }
18
18
 
19
19
  decompressGzip(compressed: Buffer): Buffer {
@@ -21,7 +21,7 @@ extend self: Compression {
21
21
  }
22
22
 
23
23
  compressDeflate(uncompressed: Buffer, level: Int = 6): Buffer {
24
- internalCompress("deflate", level, uncompressed)
24
+ internalCompress(self, "deflate", level, uncompressed)
25
25
  }
26
26
 
27
27
  decompressDeflate(compressed: Buffer): Buffer {
@@ -36,9 +36,9 @@ newForBrowserSystem(browserSystem: BrowserSystem): Compression
36
36
  newForNodeSystem(nodeSystem: NodeSystem): Compression
37
37
  target js async "return globalThis"
38
38
 
39
- internalCompress(algorithm: String, level: Int, buffer: Buffer): Buffer {
39
+ internalCompress(compression: Compression, algorithm: String, level: Int, buffer: Buffer): Buffer {
40
40
  let js = UnsafeJs.jsSystem()
41
- let dataView = UnsafeJs.toJsValue(buffer)
41
+ let dataView = js.value(buffer)
42
42
  let uint8Array = js->Uint8Array->(dataView->buffer, dataView->byteOffset, dataView->byteLength)
43
43
  let stream = js->ReadableStream->(js->(
44
44
  start = js->{controller =>
@@ -73,6 +73,12 @@ serveGuide(system: NodeSystem, request: WebRequest[WebResponse]): Bool {
73
73
 
74
74
  browserMain(system: BrowserSystem): Unit {
75
75
  let demos = ExamplesOverview.demos()
76
+ let js = system.js()
77
+ js->document->onclick = js->{
78
+ js->Notification->requestPermission()->then(js->{
79
+ js->Notification->("Hi!", js->(body = "From the Firefly JS FFI"))
80
+ })
81
+ }
76
82
  guides.collect {guide =>
77
83
  if(system.urlPath().startsWith(guide.prefix)):
78
84
  Lux.renderById(system, "main") {lux =>
@@ -12,9 +12,10 @@ Most JavaScript functionality can be accessed via the `JsSystem` object.
12
12
 
13
13
  ```firefly
14
14
  browserMain(system: BrowserSystem): Unit {
15
- let document = system.js()->document
16
- let element = document->getElementById("my-id")
17
- element->innerText = "Hi!"
15
+ let js = system.js()
16
+ js->Notification->requestPermission()->then(js->{
17
+ js->Notification->("Hi!", js->(body = "From the Firefly JS FFI"))
18
+ })
18
19
  }
19
20
  ```
20
21
 
@@ -1559,7 +1559,7 @@ if(ff_core_Option.Option_isEmpty(argument_.name_)) {
1559
1559
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Expected a named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
1560
1560
  };
1561
1561
  const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, result_, "with"), false);
1562
- result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, ff_core_Option.Option_grab(argument_.name_))), ff_compiler_Syntax.Argument(argument_.value_.at_, ff_core_Option.None(), argument_.value_)], [])
1562
+ result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, (("\"" + ff_core_Option.Option_grab(argument_.name_)) + "\""))), ff_compiler_Syntax.Argument(argument_.value_.at_, ff_core_Option.None(), argument_.value_)], [])
1563
1563
  }));
1564
1564
  return result_
1565
1565
  }
@@ -3169,7 +3169,7 @@ if(ff_core_Option.Option_isEmpty(argument_.name_)) {
3169
3169
  throw Object.assign(new Error(), {ffException: ff_core_Any.toAny_(ff_compiler_Syntax.CompileError(argument_.at_, "Expected a named argument"), ff_compiler_Syntax.ff_core_Any_HasAnyTag$ff_compiler_Syntax_CompileError)})
3170
3170
  };
3171
3171
  const target_ = ff_compiler_Syntax.DynamicCall(ff_compiler_Syntax.EField(ff_compiler_Token.Token_at(token_), false, result_, "with"), false);
3172
- result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, ff_core_Option.Option_grab(argument_.name_))), ff_compiler_Syntax.Argument(argument_.value_.at_, ff_core_Option.None(), argument_.value_)], [])
3172
+ result_ = ff_compiler_Syntax.ECall(record_.at_, target_, effect_, [], [ff_compiler_Syntax.Argument(argument_.at_, ff_core_Option.None(), ff_compiler_Syntax.EString(argument_.at_, (("\"" + ff_core_Option.Option_grab(argument_.name_)) + "\""))), ff_compiler_Syntax.Argument(argument_.value_.at_, ff_core_Option.None(), argument_.value_)], [])
3173
3173
  }));
3174
3174
  return result_
3175
3175
  }
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly compiler",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.91",
7
+ "version": "0.5.2",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -18,6 +18,5 @@ cancelled(): Bool
18
18
  // Replaced by the compiler
19
19
  target js sync "return false"
20
20
 
21
- toJsValue[T](value: T): JsValue
21
+ value[T](value: T): JsValue
22
22
  target js sync "return value_"
23
-
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.4.91",
7
+ "version": "0.5.2",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"