Skip to content

Commit

Permalink
Fix scala.js deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Mingun committed Sep 12, 2023
1 parent 2b84e0a commit 17b8cd2
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 9 deletions.
8 changes: 8 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 0.11 (TBD)

* Packaging / infrastructure improvements:
* [npm package `kaitai-struct-compiler`](https://www.npmjs.com/package/kaitai-struct-compiler/) now
returns the compiler object itself instead of a constructor function (called `KaitaiStructCompiler`).
Make sure to adapt your code: replace `(new KaitaiStructCompiler()).compile(...)` to
`KaitaiStructCompiler.compile(...)` ([#222](https://github.com/kaitai-io/kaitai_struct_compiler/pull/222))

# 0.10 (2022-07-08)

* General compilation improvements:
Expand Down
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ lazy val buildNpmJsFileTask = Def.task {
|
|$compiledFileContents
|
|return exports.io.kaitai.struct.MainJs;
|return exports.MainJs;
|
|}));
|""".stripMargin
Expand Down
17 changes: 11 additions & 6 deletions js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,28 @@ Our [examples repository](https://github.com/kaitai-io/kaitai_struct_examples) c

## Plugging in

> :information_source: Before the version 0.11.0 the `kaitai-struct-compiler`
> module returned a _compiler constructor_ (called `KaitaiStructCompiler`) and
> you would use it as `(new KaitaiStructCompiler()).compile(...)`, but since
> 0.11.0 release it returns the _compiler object_ itself and you just need to
> do `KaitaiStructCompiler.compile(...)`. Make sure to adapt your code.
We publish the compiler as a [UMD module](https://github.com/umdjs/umd), so it works from various environments, including server-side (e.g. Node.js) and client-side (e.g. web browser) ones.

Note: currently we don't publish the compiler as standard ES module. This will probably change in the future. If you need ES module, please comment on [this issue](https://github.com/kaitai-io/kaitai_struct/issues/180).

### node

```javascript
var KaitaiStructCompiler = require("kaitai-struct-compiler");
var compiler = new KaitaiStructCompiler();
var compiler = require("kaitai-struct-compiler");
```

### browser using script tags

```html
<script src="node_modules/kaitai-struct-compiler/kaitai-struct-compiler.js"></script>
<script>
var compiler = new KaitaiStructCompiler();
var compiler = KaitaiStructCompiler;
</script>
```

Expand All @@ -85,8 +90,8 @@ var compiler = new KaitaiStructCompiler();
}
});
require(['kaitai-struct-compiler'], function(KaitaiStructCompiler){
var compiler = new KaitaiStructCompiler();
require(['kaitai-struct-compiler'], function(compiler){
// ...
});
</script>
```
Expand Down Expand Up @@ -204,5 +209,5 @@ Kaitai Struct compiler in JavaScript depends on the following libraries:

Note that these clauses only apply only to compiler itself, not `.ksy`
input files that one supplies in normal process of compilation, nor to
compiler's output files — that consitutes normal usage process and you
compiler's output files — that constitutes normal usage process and you
obviously keep copyright to both.
2 changes: 2 additions & 0 deletions js/src/main/scala/io/kaitai/struct/JavaScriptImporter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package io.kaitai.struct

import scala.scalajs.js
import scala.scalajs.js.Promise
import scala.scalajs.js.annotation.JSGlobal

@js.native
@JSGlobal
class JavaScriptImporter extends js.Object {
def importYaml(name: String, mode: String): Promise[js.Object] = js.native
}
4 changes: 2 additions & 2 deletions js/src/main/scala/io/kaitai/struct/MainJs.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.Future
import scala.scalajs.js
import scala.scalajs.js.JSConverters._
import scala.scalajs.js.annotation.JSExport
import scala.scalajs.js.annotation.{JSExport, JSExportTopLevel}

@JSExport
@JSExportTopLevel("MainJs")
object MainJs {
KSVersion.current = Version.version

Expand Down

0 comments on commit 17b8cd2

Please sign in to comment.