tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Thiago H. de Paula Figueiredo" <thiag...@gmail.com>
Subject Re: [1/3] tapestry-5 git commit: TAP5-2591: add support for TypeScript modules
Date Thu, 30 Nov 2017 16:12:03 GMT
This is awesome! Thank you very much!

On Mon, Nov 27, 2017 at 10:01 AM, <jkemnade@apache.org> wrote:

> Repository: tapestry-5
> Updated Branches:
>   refs/heads/master 80f65eb4b -> 0f2c01c9a
>
>
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c01c9/tapestry-
> webresources/src/test/groovy/t5/webresources/tests/
> TypeScriptCompilerSpec.groovy
> ----------------------------------------------------------------------
> diff --git a/tapestry-webresources/src/test/groovy/t5/webresources/
> tests/TypeScriptCompilerSpec.groovy b/tapestry-webresources/src/
> test/groovy/t5/webresources/tests/TypeScriptCompilerSpec.groovy
> new file mode 100644
> index 0000000..aafd30a
> --- /dev/null
> +++ b/tapestry-webresources/src/test/groovy/t5/webresources/
> tests/TypeScriptCompilerSpec.groovy
> @@ -0,0 +1,58 @@
> +package t5.webresources.tests;
> +
> +import org.apache.tapestry5.SymbolConstants
> +import org.apache.tapestry5.internal.InternalSymbols
> +import org.apache.tapestry5.internal.test.PageTesterContext
> +import org.apache.tapestry5.internal.webresources.TypeScriptCompiler
> +import org.apache.tapestry5.ioc.MappedConfiguration
> +import org.apache.tapestry5.ioc.annotations.Autobuild
> +import org.apache.tapestry5.ioc.annotations.Inject
> +import org.apache.tapestry5.ioc.annotations.SubModule
> +import org.apache.tapestry5.ioc.internal.util.ClasspathResource
> +import org.apache.tapestry5.modules.AssetsModule
> +import org.apache.tapestry5.modules.TapestryModule
> +import org.apache.tapestry5.services.ApplicationGlobals
> +import org.apache.tapestry5.webresources.modules.WebResourcesModule
> +
> +import spock.lang.Shared
> +import spock.lang.Specification
> +
> +@SubModule([TapestryModule, WebResourcesModule, TypeScriptCompilerSpec.TestModule,
> AssetsModule])
> +class TypeScriptCompilerSpec extends Specification {
> +
> +  @Autobuild
> +  private TypeScriptCompiler typeScriptCompiler;
> +
> +  @Inject
> +  @Shared
> +  private ApplicationGlobals applicationGlobals
> +
> +  def setupSpec(){
> +    applicationGlobals.storeContext(new PageTesterContext("/test"));
> +  }
> +
> +  def "Compile Hello World example"(){
> +    when:
> +    def resource = new ClasspathResource("t5/webresources/greeter.ts")
> +    def compiled = typeScriptCompiler.transform(resource, null)
> +    then:
> +    compiled.text == TypeScriptCompilerSpec.class.
> getResourceAsStream('/t5/webresources/greeter-compiled.js').text
> +  }
> +
> +  def "Type information is preserved"(){
> +    when:
> +    def resource = new ClasspathResource("t5/
> webresources/park-example.ts")
> +    def compiled = typeScriptCompiler.transform(resource, null)
> +    then:
> +    compiled.text == TypeScriptCompilerSpec.class.
> getResourceAsStream('/t5/webresources/park-example-compiled.js').text
> +  }
> +
> +  public static class TestModule {
> +
> +    def contributeApplicationDefaults(MappedConfiguration configuration){
> +      configuration.add(InternalSymbols.APP_NAME, "test")
> +      configuration.add("tapestry.app-package", "typescript")
> +      configuration.add(SymbolConstants.MINIFICATION_ENABLED, false)
> +    }
> +  }
> +}
>
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c01c9/tapestry-
> webresources/src/test/resources/t5/webresources/greeter-compiled.js
> ----------------------------------------------------------------------
> diff --git a/tapestry-webresources/src/test/resources/t5/
> webresources/greeter-compiled.js b/tapestry-webresources/src/
> test/resources/t5/webresources/greeter-compiled.js
> new file mode 100644
> index 0000000..0794189
> --- /dev/null
> +++ b/tapestry-webresources/src/test/resources/t5/
> webresources/greeter-compiled.js
> @@ -0,0 +1,8 @@
> +define(["require", "exports"], function (require, exports) {
> +    "use strict";
> +    function greeter(person) {
> +        return "Hello, " + person;
> +    }
> +    var user = "Jane User";
> +    document.body.innerHTML = greeter(user);
> +});
>
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c01c9/tapestry-
> webresources/src/test/resources/t5/webresources/greeter.ts
> ----------------------------------------------------------------------
> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
> b/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
> new file mode 100644
> index 0000000..7fc2d1a
> --- /dev/null
> +++ b/tapestry-webresources/src/test/resources/t5/webresources/greeter.ts
> @@ -0,0 +1,7 @@
> +function greeter(person) {
> +    return "Hello, " + person;
> +}
> +
> +var user = "Jane User";
> +
> +document.body.innerHTML = greeter(user);
> \ No newline at end of file
>
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c01c9/tapestry-
> webresources/src/test/resources/t5/webresources/park-example-compiled.js
> ----------------------------------------------------------------------
> diff --git a/tapestry-webresources/src/test/resources/t5/
> webresources/park-example-compiled.js b/tapestry-webresources/src/
> test/resources/t5/webresources/park-example-compiled.js
> new file mode 100644
> index 0000000..6d8e725
> --- /dev/null
> +++ b/tapestry-webresources/src/test/resources/t5/
> webresources/park-example-compiled.js
> @@ -0,0 +1,26 @@
> +var __decorate = (this && this.__decorate) || function (decorators,
> target, key, desc) {
> +    var c = arguments.length, r = c < 3 ? target : desc === null ? desc =
> Object.getOwnPropertyDescriptor(target, key) : desc, d;
> +    if (typeof Reflect === "object" && typeof Reflect.decorate ===
> "function") r = Reflect.decorate(decorators, target, key, desc);
> +    else for (var i = decorators.length - 1; i >= 0; i--) if (d =
> decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target,
> key)) || r;
> +    return c > 3 && r && Object.defineProperty(target, key, r), r;
> +};
> +var __metadata = (this && this.__metadata) || function (k, v) {
> +    if (typeof Reflect === "object" && typeof Reflect.metadata ===
> "function") return Reflect.metadata(k, v);
> +};
> +define(["require", "exports"], function (require, exports) {
> +    "use strict";
> +    var Pterodactyls = /** @class */ (function () {
> +        function Pterodactyls() {
> +        }
> +        return Pterodactyls;
> +    }());
> +    var Park = /** @class */ (function () {
> +        function Park(x, y) {
> +        }
> +        Park = __decorate([
> +            Aviary,
> +            __metadata("design:paramtypes", [Pterodactyls, String])
> +        ], Park);
> +        return Park;
> +    }());
> +});
>
> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/0f2c01c9/tapestry-
> webresources/src/test/resources/t5/webresources/park-example.ts
> ----------------------------------------------------------------------
> diff --git a/tapestry-webresources/src/test/resources/t5/webresources/park-example.ts
> b/tapestry-webresources/src/test/resources/t5/webresources/park-example.ts
> new file mode 100644
> index 0000000..ce9b4f2
> --- /dev/null
> +++ b/tapestry-webresources/src/test/resources/t5/
> webresources/park-example.ts
> @@ -0,0 +1,6 @@
> +class Pterodactyls {}
> +
> +@Aviary
> +class Park {
> +  constructor(x: Pterodactyls, y: string) {}
> +}
> \ No newline at end of file
>
>


-- 
Thiago

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message