firefly-compiler 0.5.2 → 0.5.3

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/bin/Release.ff CHANGED
@@ -39,6 +39,7 @@ release(
39
39
  releaseFireflyPackage(system, accessKeyId, secretAccessKey, "webserver")
40
40
  runSuccessful(system, "git", ["commit", "-a", "-m", "Autorelease " + version], system.path(".."))
41
41
  runSuccessful(system, "git", ["push"], system.path(".."))
42
+ runSuccessful(system, "npm", ["install", "-g", "firefly-compiler"], system.path(".."))
42
43
  }
43
44
 
44
45
  releaseFireflyPackage(
package/core/JsSystem.ff CHANGED
@@ -61,6 +61,9 @@ extend self: JsSystem {
61
61
 
62
62
  object(): JsValue
63
63
  target js sync "return {}"
64
+
65
+ new0(): JsValue
66
+ target js sync "return {}"
64
67
 
65
68
  array(values: List[JsValue]): JsValue
66
69
  target js sync "return values_.slice()"
@@ -73,12 +73,6 @@ 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
- }
82
76
  guides.collect {guide =>
83
77
  if(system.urlPath().startsWith(guide.prefix)):
84
78
  Lux.renderById(system, "main") {lux =>
@@ -13,17 +13,33 @@ Most JavaScript functionality can be accessed via the `JsSystem` object.
13
13
  ```firefly
14
14
  browserMain(system: BrowserSystem): Unit {
15
15
  let js = system.js()
16
- js->Notification->requestPermission()->then(js->{
17
- js->Notification->("Hi!", js->(body = "From the Firefly JS FFI"))
18
- })
16
+ js->document->onclick = js->{
17
+ js->Notification->requestPermission()->then(js->{
18
+ js->Notification->(
19
+ "Hi!"
20
+ js->(body = "From the Firefly JS FFI")
21
+ )
22
+ })
23
+ }
19
24
  }
20
25
  ```
21
26
 
22
- This example gets the global `document`, calls `getElementId("my-id")` on it, and sets `innerText = "Hi!"`.
27
+ This is equivalent to the following JavaScript:
28
+
29
+ ```js
30
+ document.onclick = {() =>
31
+ Notification.requestPermission().then({() =>
32
+ new Notification(
33
+ "Hi!",
34
+ {body: "From the Firefly JS FFI"}
35
+ )
36
+ })
37
+ }
38
+ ```
23
39
 
24
- The `->` is shorthand for calling the methods `get`, `set`, `increment`, `decrement`, `call1` etc.
40
+ The `->` is shorthand for calling the methods `get`, `set`, `increment`, `decrement`, `object`, `call1`, `new1` and `function1` (substitute 0 to 9 for 1).
25
41
 
26
- The type of the `document` and `element` variables here is `JsValue`, which represents an arbitrary JavaScript value.
42
+ The `js` variable is of the type `JsSystem` and the rest of the expressions return `JsValue`, which represents an arbitrary JavaScript value.
27
43
 
28
44
 
29
45
  # The ff:unsafejs package
@@ -45,6 +61,9 @@ throwIfCancelled(): Unit
45
61
 
46
62
  // Returns true if the current task has been aborted
47
63
  cancelled(): Bool
64
+
65
+ // Casts any Firefly value to a JavaScript value without conversion
66
+ value[T](value: T): JsValue
48
67
  ```
49
68
 
50
69
  In the future, it may be possible to provide a whitelist of dependencies that are allowed to use this package.
@@ -179,6 +179,10 @@ export function JsSystem_object(self_) {
179
179
  return {}
180
180
  }
181
181
 
182
+ export function JsSystem_new0(self_) {
183
+ return {}
184
+ }
185
+
182
186
  export function JsSystem_array(self_, values_) {
183
187
  return values_.slice()
184
188
  }
@@ -307,6 +311,10 @@ export async function JsSystem_object$(self_, $task) {
307
311
  throw new Error('Function JsSystem_object is missing on this target in async context.');
308
312
  }
309
313
 
314
+ export async function JsSystem_new0$(self_, $task) {
315
+ throw new Error('Function JsSystem_new0 is missing on this target in async context.');
316
+ }
317
+
310
318
  export async function JsSystem_array$(self_, values_, $task) {
311
319
  throw new Error('Function JsSystem_array is missing on this target in async context.');
312
320
  }
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.5.2",
7
+ "version": "0.5.3",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"
@@ -4,7 +4,7 @@
4
4
  "description": "Firefly language support",
5
5
  "author": "Firefly team",
6
6
  "license": "MIT",
7
- "version": "0.5.2",
7
+ "version": "0.5.3",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/Ahnfelt/firefly-boot"