|
| 1 | +Guide to Contributing |
| 2 | +===================== |
| 3 | + |
| 4 | +Contents: |
| 5 | + |
| 6 | +* Packages |
| 7 | +* Files |
| 8 | +* Facades |
| 9 | +* Non-Facades |
| 10 | +* Partially-Supported DOM API |
| 11 | +* Binary Compatibility |
| 12 | +* Submitting a PR |
| 13 | + |
| 14 | + |
| 15 | +Packages |
| 16 | +======== |
| 17 | + |
| 18 | +TODO: Put `beacon` in `dom` |
| 19 | +TODO: Put DOMParser in `dom` with its extra types in its companion object |
| 20 | +TODO: Put `gamepad` in `dom` |
| 21 | +TODO: Put `push` in `dom`? Everything is `Push*`. Or will there be `Push*` from other APIs too? Do we care? |
| 22 | +TODO: Put `sharedworkers` in `dom` |
| 23 | +TODO: Put `storage` in `dom`? Does it really warrant its own package? |
| 24 | +TODO: Put `webgl/extensions` in `webgl` |
| 25 | +TODO: The `ext` package is named confusingly imo. Ideally we could rename it to something clearer. |
| 26 | + |
| 27 | +``` |
| 28 | +org.scalajs.dom — All top-level facades |
| 29 | + +-- beacon — Beacon API |
| 30 | + +-- crypto — Crypto API |
| 31 | + +-- deviceorientation — Device Orientation API |
| 32 | + +-- domparser — DOMParser API |
| 33 | + +-- ext — Scala helpers for nicer usage |
| 34 | + +-- gamepad — Gamepad API |
| 35 | + +-- intl — Internationalization API |
| 36 | + +-- mediastream — MediaStream API |
| 37 | + +-- permissions — Permissions API |
| 38 | + +-- push — Push API |
| 39 | + +-- raw — deprecated. Remains only for backwards-compatibility |
| 40 | + +-- serviceworkers — Service Workers API |
| 41 | + +-- sharedworkers — |
| 42 | + +-- storage — Storage API |
| 43 | + +-- webgl — WebGL API |
| 44 | + | +-- extensions — |
| 45 | + +-- webrtc — WebRTC API |
| 46 | +``` |
| 47 | + |
| 48 | + |
| 49 | +Files |
| 50 | +===== |
| 51 | + |
| 52 | +* Use `package.scala` for a package object and nothing else. |
| 53 | + Also don't include traits/classes/objects. |
| 54 | + |
| 55 | +* Match the filename to the trait/class/object in it; don't add multiple top-level types. |
| 56 | + This is effectively Java-style. |
| 57 | + |
| 58 | + |
| 59 | +Facades |
| 60 | +======= |
| 61 | + |
| 62 | +If a feature has many types that don't share a common unambiguous prefix (like `crypto`), |
| 63 | + * create a feature package |
| 64 | + * put all of its types in its package |
| 65 | + |
| 66 | +If a feature has only a few types that don't share a common unambiguous prefix (like `DOMParser`), |
| 67 | + * create a facade for the main feature |
| 68 | + * create a companion object for the facade |
| 69 | + * put all of its types in the companion object |
| 70 | + |
| 71 | +If a feature has types that all share a common unambiguous prefix (like `Gamepad*`), |
| 72 | + * put it all in `dom` |
| 73 | + |
| 74 | + |
| 75 | +Non-Facades |
| 76 | +=========== |
| 77 | + |
| 78 | +* Implicit conversions should go in companion objects so that they are always in scope without the |
| 79 | + need for imports. There's no need to group by feature, the types already specify the feature. |
| 80 | + |
| 81 | +* Add Scala-only utilities that pertain to a specific facade, in the facades companion object |
| 82 | + Eg: helper constructors, legal facade values. |
| 83 | + |
| 84 | +* Add Scala-only utilities that don't pertain to a specific facade, or shouldn't be universally |
| 85 | + available (subjective judgement here) in the `ext` package. |
| 86 | + |
| 87 | + |
| 88 | +Partially-Supported DOM API |
| 89 | +=========================== |
| 90 | + |
| 91 | +TODO: Pending discussion in #514 |
| 92 | + |
| 93 | + |
| 94 | +Binary Compatibility |
| 95 | +==================== |
| 96 | + |
| 97 | +Binary compatibility for Scala.JS facades is different than standard Scala. |
| 98 | +The following are changes that are indeed incompatible in both formats: |
| 99 | + |
| 100 | +Don't: |
| 101 | + * Remove a trait / class / object |
| 102 | + * Change a class into a trait or vice versa |
| 103 | + |
| 104 | +Here is a non-exhaustive list of changes that would be binary incompatible for Scala classes, but |
| 105 | +are compatible for JS facade types: |
| 106 | + |
| 107 | +You can: |
| 108 | + * Remove a member |
| 109 | + * Change the type or signature of a member |
| 110 | + * Add a field in a trait |
| 111 | + * Add an abstract member in a trait |
| 112 | + |
| 113 | + |
| 114 | +Submitting a PR |
| 115 | +=============== |
| 116 | + |
| 117 | +Once you're done making your changes... |
| 118 | + |
| 119 | +1. Run `sbt prePR` |
| 120 | +2. Run `git diff api-reports` and ensure that you aren't breaking backwards-binary-compatibility |
| 121 | + (see above). We'll probably automate this step in the future (See #503) |
| 122 | +3. Check in and commit the changes to `api-reports` |
| 123 | +4. Submit your PR |
| 124 | +5. Know that your contribution is appreciated, thank you! |
0 commit comments