<commit_before># Proto JS plugin

The Gradle plugin which assists the Protobuf JS compiler in code generation.

Currently, the plugin only purpose is adding `fromJson(json)` and `fromObject(object)` methods to 
the generated messages. These methods allow to parse the message from the JSON `string` and 
JavaScript `Object` respectively.

## Usage

To use the plugin, add it to the `classpath` configuration of the `buildscript` as follows:

```groovy
buildscript {
    dependencies {
        classpath "io.spine.tools:spine-proto-js-plugin:$spineBaseVersion"
    }
}
```

The plugin may then be applied where necessary:

```groovy
apply plugin: "io.spine.tools.proto-js-plugin"
```

The `protoJs` extension provides access to the main plugin action. It may then be used to configure 
when the action will be executed relative to other tasks. Example:

```groovy
protoJs {
    generateParsersTask().dependsOn compileProtoToJs
    compileJs.dependsOn generateParsersTask()
}
```

By default, the plugin action will just be a dependency of the `build` task.

## Required configurations

At the moment, the plugin relies on the set of hard-coded Gradle configurations which are required 
to be set in the project applying the plugin.

These settings are:

1. The root of the JavaScript code generated by the Protobuf JS compiler set to 
   `${projectDir}/proto/${sourceSet}/js`.
2. The Protobuf descriptor set file stored at location 
   `${projectDir}/build/descriptors/${sourceSet}/known_types.desc`.
3. The `CommonJS` import style for the generated JavaScript files 
   (`js {option "import_style=commonjs"}` in `protobuf` extension).
4. The tasks `compileProtoToJs` and `copyModuleSources` available in the project and being the 
   dependencies of the `build` task.

In general, these settings mimic how the [Spine Web](https://github.com/SpineEventEngine/web) 
builds its JS modules.<commit_msg>Update the readme for `ProtoJsPlugin`<commit_after># Proto JS plugin

The Gradle plugin which assists the Protobuf JS compiler in code generation.

Currently, the plugin only purpose is adding `fromJson(json)` and `fromObject(object)` methods to 
the generated messages. These methods allow to parse the message from the JSON `string` and 
JavaScript `Object` respectively.

## Usage

To use the plugin, add it to the `classpath` configuration of the `buildscript` as follows:

```groovy
buildscript {
    dependencies {
        classpath "io.spine.tools:spine-proto-js-plugin:$spineBaseVersion"
    }
}
```

The plugin may then be applied where necessary:

```groovy
apply plugin: "io.spine.tools.proto-js-plugin"
```

The `protoJs` extension provides access to the main plugin action. It may then be used to configure 
when the action will be executed relative to other tasks. Example:

```groovy
protoJs {
    generateParsersTask().dependsOn compileProtoToJs
    compileJs.dependsOn generateParsersTask()
}
```

By default, the plugin action will just be a dependency of the `build` task.

## Required configurations

These settings are:

1. The `CommonJS` import style for the generated JavaScript files 
   (`js {option "import_style=commonjs"}` in `protobuf` extension).
1. The task `compileProtoToJs` available in the project and being
 the dependency of the `build` task.

{'fraction_non_alphanumeric': 0.08145210494203783, 'fraction_numerical': 0.0018303843807199512, 'mean_word_length': 4.567062818336163, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2953190', 'n_tokens_mistral': 930, 'n_tokens_neox': 892, 'n_words': 397}