Skip to content

Commit 9334f83

Browse files
committed
Continued refinement
1. Fixed issues with JQuery and JQLite 2. Added EventSource and EventTarget 3. Added window.URL
1 parent 1100f2b commit 9334f83

File tree

17 files changed

+1106
-1245
lines changed

17 files changed

+1106
-1245
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ for {
178178

179179
The Node.js integration is nearly complete (feature for feature), and should be more than sufficient for most web-based
180180
and CLI applications. Additionally, there are a growing number of third-party (mostly OSS) modules that have been
181-
implemented as well, including bcrypt, datastax/cassandra-driver, kafka-node, mysql, xml2js and many others.
181+
implemented as well, including bcrypt, cassandra-driver, kafka-node, mysql, xml2js and many others.
182182

183183
<a name="node_modules">
184184
#### Modules
@@ -209,8 +209,8 @@ The following core Node.js modules have been implemented:
209209
| vm | 7.4.0 | nodejs | The vm module provides APIs for compiling and running code within V8 Virtual Machine contexts.| Stable |
210210
| zlib | 7.4.0 | nodejs | This provides bindings to Gzip/Gunzip, Deflate/Inflate, and DeflateRaw/InflateRaw classes. | Stable |
211211

212-
*NOTE*: The full SBT artifact expression is: "io.scalajs" %%% "scalajs-nodejs-xxxx" % version
213-
(e.g. "io.scalajs" %%% "scalajs-nodejs-readline" % "0.2.0")
212+
*NOTE*: The full SBT artifact expression is: "io.scalajs.npm" %%% "xxxx" % version
213+
(e.g. "io.scalajs.npm" %%% "readline" % "0.3.0.0")
214214

215215
<a name="npm_modules">
216216
#### Third-party Modules

browser/angularjs/core/src/main/scala/io/scalajs/npm/angularjs/Angular.scala

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import io.scalajs.npm.angularjs.Module.EnrichedModule
66

77
import scala.language.implicitConversions
88
import scala.scalajs.js
9+
import scala.scalajs.js.|
910

1011
/**
1112
* AngularJS 1.4.2 Binding
@@ -79,9 +80,7 @@ trait Angular extends js.Object {
7980

8081
def copy(source: js.Any, destination: js.Any): js.Any = js.native
8182

82-
def element(elem: Element): JQLite = js.native
83-
84-
def element(jQuery: JQuery): JQLite = js.native
83+
def element(elem: Element | String): JQLite = js.native
8584

8685
/**
8786
* Determines if two objects or two values are equivalent. Supports value types, regular expressions, arrays and objects.

browser/angularjs/core/src/main/scala/io/scalajs/npm/angularjs/JQLite.scala

+31-538
Large diffs are not rendered by default.

browser/dom/src/main/scala/io/scalajs/dom/Element.scala

+19-11
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@ import scala.scalajs.js
1414
@js.native
1515
trait Element extends ParentNode {
1616

17+
/////////////////////////////////////////////////////////////////////////////////
18+
// Properties
19+
/////////////////////////////////////////////////////////////////////////////////
20+
21+
/**
22+
* The qualified name of an Element node, including any namespace prefix.
23+
*
24+
* In HTML this is returned in all uppercase regardless of the case used in the document;
25+
* in XML the case used in the document is preserved.
26+
*
27+
* In all cases, the tagName of an element is exactly the same as its nodeName.
28+
* This property is readonly.
29+
*/
30+
def tagName: String = js.native
31+
32+
/////////////////////////////////////////////////////////////////////////////////
33+
// Methods
34+
/////////////////////////////////////////////////////////////////////////////////
35+
1736
/**
1837
* Get the value of an attribute with the specified name.
1938
*
@@ -213,15 +232,4 @@ trait Element extends ParentNode {
213232
*/
214233
def setAttributeNS(namespace: String, name: String, value: js.Any): Unit = js.native
215234

216-
/**
217-
* The qualified name of an Element node, including any namespace prefix.
218-
*
219-
* In HTML this is returned in all uppercase regardless of the case used in the document;
220-
* in XML the case used in the document is preserved.
221-
*
222-
* In all cases, the tagName of an element is exactly the same as its nodeName.
223-
* This property is readonly.
224-
*/
225-
def tagName: String = js.native
226-
227235
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package io.scalajs.dom
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.JSName
5+
6+
/**
7+
* The EventSource interface is used to receive server-sent events. It connects to a server over HTTP
8+
* and receives events in text/event-stream format without closing the connection.
9+
* @param url A DOMString representing the URL of the source.
10+
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventSource
11+
*/
12+
@js.native
13+
@JSName("EventSource")
14+
class EventSource(val url: String) extends EventTarget {
15+
16+
/////////////////////////////////////////////////////////////////////////////////
17+
// Properties
18+
/////////////////////////////////////////////////////////////////////////////////
19+
20+
/**
21+
* Is an EventHandler being called when an error occurs and the error event is dispatched on this object.
22+
*/
23+
var onerror: js.Function = js.native
24+
25+
/**
26+
* Is an EventHandler being called when a message event is received, that is when a message is coming from the source.
27+
*/
28+
var onmessage: js.Function = js.native
29+
30+
/**
31+
* Is an EventHandler being called when an open event is received, that is when the connection was just opened.
32+
*/
33+
var onopen: js.Function = js.native
34+
35+
/**
36+
* Read only: An unsigned short representing the state of the connection.
37+
* Possible values are CONNECTING (0), OPEN (1), or CLOSED (2).
38+
*/
39+
def readyState: Int = js.native
40+
41+
/////////////////////////////////////////////////////////////////////////////////
42+
// Methods
43+
/////////////////////////////////////////////////////////////////////////////////
44+
45+
/**
46+
* Closes the connection, if any, and sets the readyState attribute to CLOSED.
47+
* If the connection is already closed, the method does nothing.
48+
*/
49+
def close(): Unit = js.native
50+
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package io.scalajs.dom
2+
3+
import io.scalajs.RawOptions
4+
5+
import scala.scalajs.js
6+
import scala.scalajs.js.|
7+
8+
/**
9+
* EventTarget is an interface implemented by objects that can receive events and may have listeners for them.
10+
*
11+
* Element, document, and window are the most common event targets, but other objects can be event targets too,
12+
* for example XMLHttpRequest, AudioNode, AudioContext, and others.
13+
*
14+
* Many event targets (including elements, documents, and windows) also support setting event handlers via on...
15+
* properties and attributes.
16+
* @see https://developer.mozilla.org/en-US/docs/Web/API/EventTarget
17+
*/
18+
@js.native
19+
trait EventTarget extends js.Object {
20+
21+
/**
22+
* Register an event handler of a specific event type on the EventTarget.
23+
* @param `type` A string representing the event type to listen for.
24+
* @param listener The object that receives a notification (an object that implements the Event interface) when
25+
* an event of the specified type occurs. This must be an object implementing the EventListener
26+
* interface, or simply a JavaScript function.
27+
*/
28+
def addEventListener(`type`: String, listener: js.Function): Unit = js.native
29+
30+
/**
31+
* Register an event handler of a specific event type on the EventTarget.
32+
* @param `type` A string representing the event type to listen for.
33+
* @param listener The object that receives a notification (an object that implements the Event interface) when
34+
* an event of the specified type occurs. This must be an object implementing the EventListener
35+
* interface, or simply a JavaScript function.
36+
* @param options An options object that specifies characteristics about the event listener.
37+
*/
38+
def addEventListener(`type`: String, listener: js.Function, options: EventTargetOptions | RawOptions): Unit = js.native
39+
40+
/**
41+
* Register an event handler of a specific event type on the EventTarget.
42+
* @param `type` A string representing the event type to listen for.
43+
* @param listener The object that receives a notification (an object that implements the Event interface) when
44+
* an event of the specified type occurs. This must be an object implementing the EventListener
45+
* interface, or simply a JavaScript function.
46+
* @param useCapture A Boolean that indicates that events of this type will be dispatched to the registered listener
47+
* before being dispatched to any EventTarget beneath it in the DOM tree. Events that are bubbling
48+
* upward through the tree will not trigger a listener designated to use capture. Event bubbling
49+
* and capturing are two ways of propagating events that occur in an element that is nested within
50+
* another element, when both elements have registered a handle for that event. The event
51+
* propagation mode determines the order in which elements receive the event.
52+
* See DOM Level 3 Events and JavaScript Event order for a detailed explanation.
53+
* If not specified, useCapture defaults to false.
54+
*/
55+
def addEventListener(`type`: String, listener: js.Function, useCapture: Boolean): Unit = js.native
56+
57+
/**
58+
* Removes an event listener from the EventTarget.
59+
* @param `type` A string representing the event type to remove.
60+
* @param listener The EventListener function to remove from the event target.
61+
* @param options An options object that specifies characteristics about the event listener.
62+
*/
63+
def removeEventListener(`type`: String, listener: js.Function, options: EventTargetOptions | RawOptions): Unit = js.native
64+
65+
/**
66+
* Removes an event listener from the EventTarget.
67+
* @param `type` A string representing the event type to remove.
68+
* @param listener The EventListener function to remove from the event target.
69+
* @param useCapture Specifies whether the EventListener to be removed is registered as a capturing listener or not.
70+
* If this parameter is absent, a default value of false is assumed.
71+
* If a listener is registered twice, one with capture and one without, remove each one separately.
72+
* Removal of a capturing listener does not affect a non-capturing version of the same listener,
73+
* and vice versa.
74+
*/
75+
def removeEventListener(`type`: String, listener: js.Function, useCapture: Boolean): Unit = js.native
76+
77+
/**
78+
* Dispatch an event to this EventTarget.
79+
* @param event event is the Event object to be dispatched.
80+
* @return false if event is cancelable and at least one of the event handlers which handled this event
81+
* called Event.preventDefault(). Otherwise it returns true.
82+
*/
83+
def dispatchEvent(event: Event): Boolean = js.native
84+
85+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.scalajs.dom
2+
3+
import scala.scalajs.js
4+
import scala.scalajs.js.annotation.ScalaJSDefined
5+
6+
/**
7+
* An options object that specifies characteristics about the event listener.
8+
* The available options are:
9+
* @param capture A Boolean that indicates that events of this type will be dispatched to the registered
10+
* listener before being dispatched to any EventTarget beneath it in the DOM tree.
11+
* @param once A Boolean indicating that the listener should be invoked at most once after being added.
12+
* If it is true, the listener would be removed automatically when it is invoked.
13+
* @param passive A Boolean indicating that the listener will never call preventDefault(). If it does,
14+
* the user agent should ignore it and generate a console warning.
15+
* @param mozSystemGroup Available only in code running in XBL or in Firefox's chrome, it is a Boolean defining
16+
* if the listener is added to the system group.
17+
*/
18+
@ScalaJSDefined
19+
class EventTargetOptions(val capture: js.UndefOr[Boolean] = js.undefined,
20+
val once: js.UndefOr[Boolean] = js.undefined,
21+
val passive: js.UndefOr[Boolean] = js.undefined,
22+
val mozSystemGroup: js.UndefOr[Boolean] = js.undefined) extends js.Object

browser/dom/src/main/scala/io/scalajs/dom/html/HTMLElement.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import scala.scalajs.js
1111
* @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
1212
*/
1313
@js.native
14-
class HTMLElement extends Element {
14+
trait HTMLElement extends Element {
1515

1616
/////////////////////////////////////////////////////////////////////////////////
1717
// Methods

browser/dom/src/main/scala/io/scalajs/dom/html/browser/Window.scala

+17-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,13 @@ class Window extends js.Object {
347347
def top: js.Any = js.native
348348

349349
/**
350-
* TBD
350+
* returns an object that provides static methods used for creating and managing object URLs.
351+
* It can also be called as a constructor to construct URL objects.
352+
*/
353+
def URL: URL = js.native
354+
355+
/**
356+
* TODO
351357
*/
352358
var WebSocket: js.UndefOr[WebSocket] = js.native
353359

@@ -584,6 +590,16 @@ object Window {
584590

585591
@js.native
586592
trait SpeechSynthesis extends js.Object
593+
594+
/**
595+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/URL
596+
*/
597+
@js.native
598+
trait URL extends js.Object {
599+
600+
def createObjectURL(value: js.Any): String = js.native
601+
602+
}
587603

588604
@js.native
589605
trait XULControllers extends js.Object

browser/dom/src/main/scala/io/scalajs/dom/html/canvas/HTMLCanvasElement.scala

+2-19
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@ package io.scalajs.dom.html.canvas
22

33
import java.lang.{Double => JDouble}
44

5-
import io.scalajs.dom.Element
6-
import io.scalajs.dom.html.{Blob, File}
5+
import io.scalajs.dom.html.{Blob, File, HTMLElement}
76
import io.scalajs.util.ScalaJsHelper._
87

98
import scala.concurrent.Promise
109
import scala.scalajs.js
11-
import scala.scalajs.js.annotation._
1210

1311
/**
1412
* The HTMLCanvasElement interface provides properties and methods for manipulating the layout and presentation of
@@ -17,7 +15,7 @@ import scala.scalajs.js.annotation._
1715
1816
*/
1917
@js.native
20-
class HTMLCanvasElement extends Element {
18+
class HTMLCanvasElement extends HTMLElement {
2119

2220
/////////////////////////////////////////////////////////////////////////////////
2321
// Properties
@@ -45,21 +43,6 @@ class HTMLCanvasElement extends Element {
4543
// Methods
4644
/////////////////////////////////////////////////////////////////////////////////
4745

48-
/**
49-
*
50-
* @param index
51-
* @return
52-
*/
53-
@JSBracketAccess
54-
def apply(index: Int): this.type = js.native
55-
56-
/**
57-
* ???
58-
* @param value
59-
* @return
60-
*/
61-
def attr(value: js.Any): Unit = js.native
62-
6346
/**
6447
* Returns a [[CanvasCaptureMediaStream]] that is a real-time video capture of the surface of the canvas.
6548
*/

0 commit comments

Comments
 (0)